file-references.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /** Session Controller adapter for Agent-scoped file-reference discovery. */
  2. import type { Context } from '@deepseek-ai/cordis'
  3. import type { Agent } from '@deepseek-ai/dsh-agent'
  4. import type {} from '@deepseek-ai/dsh-file-reference'
  5. import type { FileReferenceCandidate } from '@deepseek-ai/dsh-file-reference/types'
  6. import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
  7. declare module '@deepseek-ai/cordis' {
  8. interface Context {
  9. /** Host owner of the `fileReferences` Remote namespace. */
  10. sessionFileReferences: SessionFileReferences
  11. }
  12. }
  13. /** Host Remote adapter over the composed file-reference provider. */
  14. export class SessionFileReferences extends TypertRemoteService {
  15. static inject = ['fileReferences', 'typert']
  16. /** @param ctx - Host context carrying the selected file-reference provider. */
  17. constructor(ctx: Context) {
  18. super(ctx, 'sessionFileReferences', { namespace: 'fileReferences' })
  19. }
  20. /**
  21. * List file and directory candidates for one Agent's working directory.
  22. * @param agent - target Agent resolved from the Session identity on the wire.
  23. * @param query - path text following `@` or `@"`.
  24. * @param signal - caller cancellation.
  25. * @returns deterministic path-only candidates from the composed provider.
  26. */
  27. @Remote
  28. list(
  29. agent: Agent,
  30. query: string,
  31. signal: AbortSignal,
  32. ): Promise<FileReferenceCandidate[]> {
  33. return this.ctx.fileReferences.list(agent, query, signal)
  34. }
  35. }
  36. export default SessionFileReferences