rpc-map.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * RPC method registry and signature-derived generics. Map keys are the wire
  3. * path segments of API Proxy unary calls.
  4. */
  5. import type { HostApi } from './host.ts'
  6. import type { AgentPresetsApi } from './agent-presets.ts'
  7. import type { SkillsApi } from './skills.ts'
  8. import type { GoalsApi } from './goals.ts'
  9. import type { SettingsApi } from './settings.ts'
  10. import type { CredentialsApi } from './credentials.ts'
  11. import type { LlmApi } from './llm.ts'
  12. import type { SubagentsApi } from './subagents.ts'
  13. import type { RpcResponse } from './rpc.ts'
  14. /**
  15. * Method name → method signature. Signatures are the single source of truth; payload/value
  16. * types are always derived from here. A method may declare a trailing AbortSignal after the
  17. * request; the carrier passes its request signal, never a wire field.
  18. */
  19. export interface RpcMethodMap {
  20. 'subagent.list': SubagentsApi['list']
  21. 'subagent.prompt': SubagentsApi['prompt']
  22. 'subagent.interrupt': SubagentsApi['interrupt']
  23. 'host.describe': HostApi['describe']
  24. 'host.pickDirectory': HostApi['pickDirectory']
  25. 'host.listDirectory': HostApi['listDirectory']
  26. 'host.createDirectory': HostApi['createDirectory']
  27. 'host.openPath': HostApi['openPath']
  28. 'skill.list': SkillsApi['list']
  29. 'agentPreset.list': AgentPresetsApi['list']
  30. 'agentPreset.select': AgentPresetsApi['select']
  31. 'agentPreset.read': AgentPresetsApi['read']
  32. 'agentPreset.copy': AgentPresetsApi['copy']
  33. 'agentPreset.openDocument': AgentPresetsApi['openDocument']
  34. 'agentPreset.remove': AgentPresetsApi['remove']
  35. 'goal.create': GoalsApi['create']
  36. 'goal.edit': GoalsApi['edit']
  37. 'goal.pause': GoalsApi['pause']
  38. 'goal.resume': GoalsApi['resume']
  39. 'goal.complete': GoalsApi['complete']
  40. 'goal.clear': GoalsApi['clear']
  41. 'settings.describe': SettingsApi['describe']
  42. 'settings.openDocument': SettingsApi['openDocument']
  43. 'settings.update': SettingsApi['update']
  44. 'settings.replace': SettingsApi['replace']
  45. 'settings.mutate': SettingsApi['mutate']
  46. 'credentials.describe': CredentialsApi['describe']
  47. 'credentials.set': CredentialsApi['set']
  48. 'credentials.unset': CredentialsApi['unset']
  49. 'llm.providers': LlmApi['providers']
  50. 'llm.models': LlmApi['models']
  51. 'llm.discoverModels': LlmApi['discoverModels']
  52. }
  53. /** Business request payload of method K (reaches through the RpcRequest narrow form to payload). */
  54. export type RequestPayload<K extends keyof RpcMethodMap> = Parameters<RpcMethodMap[K]>[0]['payload']
  55. /** Business return value of method K (reaches through the RpcResponse narrow form to infer the ok value of result). */
  56. export type ResponseValue<K extends keyof RpcMethodMap> =
  57. Awaited<ReturnType<RpcMethodMap[K]>> extends RpcResponse<infer T> ? T : never