@finalai/agents 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @finalai/agents might be problematic. Click here for more details.

Files changed (153) hide show
  1. package/README.md +30 -0
  2. package/dist/modules/agent-client/acp-frames.d.mts +19 -0
  3. package/dist/modules/agent-client/acp-frames.mjs +49 -0
  4. package/dist/modules/agent-client/acp-frames.mjs.map +7 -0
  5. package/dist/modules/agent-client/acp.d.mts +43 -0
  6. package/dist/modules/agent-client/acp.mjs +76 -0
  7. package/dist/modules/agent-client/acp.mjs.map +7 -0
  8. package/dist/modules/agent-client/async-queue.d.mts +10 -0
  9. package/dist/modules/agent-client/async-queue.mjs +66 -0
  10. package/dist/modules/agent-client/async-queue.mjs.map +7 -0
  11. package/dist/modules/agent-client/build.d.mts +107 -0
  12. package/dist/modules/agent-client/build.mjs +222 -0
  13. package/dist/modules/agent-client/build.mjs.map +7 -0
  14. package/dist/modules/agent-client/client.d.mts +111 -0
  15. package/dist/modules/agent-client/client.mjs +198 -0
  16. package/dist/modules/agent-client/client.mjs.map +7 -0
  17. package/dist/modules/agent-client/collection-events.d.mts +35 -0
  18. package/dist/modules/agent-client/collection-events.mjs +142 -0
  19. package/dist/modules/agent-client/collection-events.mjs.map +7 -0
  20. package/dist/modules/agent-client/config-options.d.mts +24 -0
  21. package/dist/modules/agent-client/config-options.mjs +49 -0
  22. package/dist/modules/agent-client/config-options.mjs.map +7 -0
  23. package/dist/modules/agent-client/context.d.mts +31 -0
  24. package/dist/modules/agent-client/context.mjs +11 -0
  25. package/dist/modules/agent-client/context.mjs.map +7 -0
  26. package/dist/modules/agent-client/conversations.d.mts +385 -0
  27. package/dist/modules/agent-client/conversations.mjs +1156 -0
  28. package/dist/modules/agent-client/conversations.mjs.map +7 -0
  29. package/dist/modules/agent-client/errors.d.mts +85 -0
  30. package/dist/modules/agent-client/errors.mjs +94 -0
  31. package/dist/modules/agent-client/errors.mjs.map +7 -0
  32. package/dist/modules/agent-client/event-stream.d.mts +14 -0
  33. package/dist/modules/agent-client/event-stream.mjs +89 -0
  34. package/dist/modules/agent-client/event-stream.mjs.map +7 -0
  35. package/dist/modules/agent-client/frame-stream.d.mts +51 -0
  36. package/dist/modules/agent-client/frame-stream.mjs +333 -0
  37. package/dist/modules/agent-client/frame-stream.mjs.map +7 -0
  38. package/dist/modules/agent-client/http.d.mts +68 -0
  39. package/dist/modules/agent-client/http.mjs +168 -0
  40. package/dist/modules/agent-client/http.mjs.map +7 -0
  41. package/dist/modules/agent-client/index.d.mts +17 -0
  42. package/dist/modules/agent-client/index.mjs +86 -0
  43. package/dist/modules/agent-client/index.mjs.map +7 -0
  44. package/dist/modules/agent-client/live-stream.d.mts +18 -0
  45. package/dist/modules/agent-client/live-stream.mjs +94 -0
  46. package/dist/modules/agent-client/live-stream.mjs.map +7 -0
  47. package/dist/modules/agent-client/realtime.d.mts +72 -0
  48. package/dist/modules/agent-client/realtime.mjs +186 -0
  49. package/dist/modules/agent-client/realtime.mjs.map +7 -0
  50. package/dist/modules/agent-client/sandbox-uri.d.mts +19 -0
  51. package/dist/modules/agent-client/sandbox-uri.mjs +43 -0
  52. package/dist/modules/agent-client/sandbox-uri.mjs.map +7 -0
  53. package/dist/modules/agent-client/sessions.d.mts +124 -0
  54. package/dist/modules/agent-client/sessions.mjs +350 -0
  55. package/dist/modules/agent-client/sessions.mjs.map +7 -0
  56. package/dist/modules/agent-client/test-fakes.d.mts +40 -0
  57. package/dist/modules/agent-client/test-fakes.mjs +94 -0
  58. package/dist/modules/agent-client/test-fakes.mjs.map +7 -0
  59. package/dist/modules/authoring/approval.d.mts +1 -0
  60. package/dist/modules/authoring/approval.mjs +2 -0
  61. package/dist/modules/authoring/approval.mjs.map +7 -0
  62. package/dist/modules/authoring/channels.d.mts +1 -0
  63. package/dist/modules/authoring/channels.mjs +2 -0
  64. package/dist/modules/authoring/channels.mjs.map +7 -0
  65. package/dist/modules/authoring/final-channel.d.mts +1 -0
  66. package/dist/modules/authoring/final-channel.mjs +2 -0
  67. package/dist/modules/authoring/final-channel.mjs.map +7 -0
  68. package/dist/modules/authoring/hooks.d.mts +1 -0
  69. package/dist/modules/authoring/hooks.mjs +2 -0
  70. package/dist/modules/authoring/hooks.mjs.map +7 -0
  71. package/dist/modules/authoring/index.d.mts +1 -0
  72. package/dist/modules/authoring/index.mjs +2 -0
  73. package/dist/modules/authoring/index.mjs.map +7 -0
  74. package/dist/modules/authoring/instructions.d.mts +1 -0
  75. package/dist/modules/authoring/instructions.mjs +2 -0
  76. package/dist/modules/authoring/instructions.mjs.map +7 -0
  77. package/dist/modules/authoring/providers.d.mts +2 -0
  78. package/dist/modules/authoring/providers.mjs +1 -0
  79. package/dist/modules/authoring/providers.mjs.map +7 -0
  80. package/dist/modules/authoring/tools.d.mts +1 -0
  81. package/dist/modules/authoring/tools.mjs +2 -0
  82. package/dist/modules/authoring/tools.mjs.map +7 -0
  83. package/dist/modules/cli/build.d.mts +22 -0
  84. package/dist/modules/cli/build.mjs +77 -0
  85. package/dist/modules/cli/build.mjs.map +7 -0
  86. package/dist/modules/cli/channel-socket.d.mts +9 -0
  87. package/dist/modules/cli/channel-socket.mjs +114 -0
  88. package/dist/modules/cli/channel-socket.mjs.map +7 -0
  89. package/dist/modules/cli/cli.d.mts +16 -0
  90. package/dist/modules/cli/cli.mjs +151 -0
  91. package/dist/modules/cli/cli.mjs.map +7 -0
  92. package/dist/modules/cli/conformance.d.mts +36 -0
  93. package/dist/modules/cli/conformance.mjs +220 -0
  94. package/dist/modules/cli/conformance.mjs.map +7 -0
  95. package/dist/modules/cli/dev.d.mts +24 -0
  96. package/dist/modules/cli/dev.mjs +263 -0
  97. package/dist/modules/cli/dev.mjs.map +7 -0
  98. package/dist/modules/cli/files.d.mts +18 -0
  99. package/dist/modules/cli/files.mjs +66 -0
  100. package/dist/modules/cli/files.mjs.map +7 -0
  101. package/dist/modules/cli/harness-descriptions.d.mts +20 -0
  102. package/dist/modules/cli/harness-descriptions.mjs +70 -0
  103. package/dist/modules/cli/harness-descriptions.mjs.map +7 -0
  104. package/dist/modules/cli/main.d.mts +2 -0
  105. package/dist/modules/cli/main.mjs +20 -0
  106. package/dist/modules/cli/main.mjs.map +7 -0
  107. package/dist/modules/cli/output.d.mts +14 -0
  108. package/dist/modules/cli/output.mjs +94 -0
  109. package/dist/modules/cli/output.mjs.map +7 -0
  110. package/dist/modules/cli/publish.d.mts +14 -0
  111. package/dist/modules/cli/publish.mjs +89 -0
  112. package/dist/modules/cli/publish.mjs.map +7 -0
  113. package/dist/modules/compile.d.mts +3 -0
  114. package/dist/modules/compile.mjs +62 -0
  115. package/dist/modules/compile.mjs.map +7 -0
  116. package/dist/modules/harnesses.d.mts +1 -0
  117. package/dist/modules/harnesses.mjs +2 -0
  118. package/dist/modules/harnesses.mjs.map +7 -0
  119. package/dist/modules/index.browser.d.mts +4 -0
  120. package/dist/modules/index.browser.mjs +8 -0
  121. package/dist/modules/index.browser.mjs.map +7 -0
  122. package/dist/modules/index.d.mts +3 -0
  123. package/dist/modules/index.mjs +6 -0
  124. package/dist/modules/index.mjs.map +7 -0
  125. package/dist/modules/models.d.mts +1 -0
  126. package/dist/modules/models.mjs +2 -0
  127. package/dist/modules/models.mjs.map +7 -0
  128. package/dist/modules/public.d.mts +6 -0
  129. package/dist/modules/public.mjs +68 -0
  130. package/dist/modules/public.mjs.map +7 -0
  131. package/dist/modules/sandboxes.d.mts +1 -0
  132. package/dist/modules/sandboxes.mjs +2 -0
  133. package/dist/modules/sandboxes.mjs.map +7 -0
  134. package/examples/custom-harness/README.md +16 -0
  135. package/examples/custom-harness/agent.ts +154 -0
  136. package/examples/custom-sandbox/README.md +12 -0
  137. package/examples/custom-sandbox/agent.ts +14 -0
  138. package/examples/custom-sandbox/sandbox.ts +22 -0
  139. package/examples/release-scout/README.md +11 -0
  140. package/examples/release-scout/agent/agent.ts +22 -0
  141. package/examples/release-scout/agent/channels/github-signature.ts +27 -0
  142. package/examples/release-scout/agent/channels/github.ts +38 -0
  143. package/examples/release-scout/agent/connections/linear.ts +9 -0
  144. package/examples/release-scout/agent/hooks/audit.ts +24 -0
  145. package/examples/release-scout/agent/instructions/org-context.ts +26 -0
  146. package/examples/release-scout/agent/instructions.md +2 -0
  147. package/examples/release-scout/agent/sandbox.ts +20 -0
  148. package/examples/release-scout/agent/schedules/daily-digest.md +7 -0
  149. package/examples/release-scout/agent/skills/triage/SKILL.md +8 -0
  150. package/examples/release-scout/agent/skills/triage/checklist.md +3 -0
  151. package/examples/release-scout/agent/tools/lookup_release_notes.ts +24 -0
  152. package/examples/release-scout/client.ts +123 -0
  153. package/package.json +126 -0
@@ -0,0 +1,222 @@
1
+ import {
2
+ attachChannelBindingRequestSchema,
3
+ attachChannelBindingResponseSchema,
4
+ commitDefinitionRequestSchema,
5
+ commitResultSchema,
6
+ compatibilityReportSchema,
7
+ compileDefinitionRequestSchema,
8
+ compileResultSchema,
9
+ computerSetupGuideDetailSchema,
10
+ computerSetupGuideListSchema,
11
+ createDefinitionRequestSchema,
12
+ credentialPolicyPreviewSchema,
13
+ definitionChannelsResponseSchema,
14
+ definitionCloneUrlSchema,
15
+ definitionFilesSchema,
16
+ definitionListSchema,
17
+ definitionSchema,
18
+ previewCredentialPolicyRequestSchema,
19
+ providerListSchema,
20
+ publishComputerSetupGuideRequestSchema,
21
+ publishComputerSetupGuideResultSchema,
22
+ publishDefinitionRequestSchema,
23
+ publishResultSchema,
24
+ revisionDiffSchema,
25
+ revisionListSchema,
26
+ revisionSchema,
27
+ scheduleListSchema,
28
+ scheduleRunResultSchema,
29
+ scheduleSchema,
30
+ updateScheduleRequestSchema
31
+ } from "@finalai/agent-protocol/agent-platform";
32
+ import { encodePath } from "./context.mjs";
33
+ import { clientError, ClientErrorCode } from "./errors.mjs";
34
+ import { HttpMethod } from "./http.mjs";
35
+ const definitionPath = (definition, suffix = "") => `/v1/definitions/${encodePath(definition)}${suffix}`;
36
+ const createDefinitionsApi = ({ http }) => ({
37
+ testRevision: ({ definition, signal, ...value }) => http.request({
38
+ method: HttpMethod.Post,
39
+ path: definitionPath(definition, "/test-revision"),
40
+ body: { schema: compileDefinitionRequestSchema, value },
41
+ response: revisionSchema,
42
+ signal
43
+ }),
44
+ previewCredentialPolicy: ({ definition, signal, ...value }) => http.request({
45
+ method: HttpMethod.Post,
46
+ path: definitionPath(definition, "/credential-policy/preview"),
47
+ body: { schema: previewCredentialPolicyRequestSchema, value },
48
+ response: credentialPolicyPreviewSchema,
49
+ signal
50
+ }),
51
+ list: (options) => http.request({
52
+ method: HttpMethod.Get,
53
+ path: "/v1/definitions",
54
+ query: { cursor: options?.cursor, limit: options?.limit },
55
+ response: definitionListSchema,
56
+ signal: options?.signal
57
+ }),
58
+ create: ({ signal, ...value }) => http.request({
59
+ method: HttpMethod.Post,
60
+ path: "/v1/definitions",
61
+ body: { schema: createDefinitionRequestSchema, value },
62
+ response: definitionSchema,
63
+ signal
64
+ }),
65
+ get: ({ definition, signal }) => http.request({
66
+ method: HttpMethod.Get,
67
+ path: definitionPath(definition),
68
+ response: definitionSchema,
69
+ signal
70
+ }),
71
+ compile: ({ definition, signal, ...value }) => http.request({
72
+ method: HttpMethod.Post,
73
+ path: definitionPath(definition, "/compile"),
74
+ body: { schema: compileDefinitionRequestSchema, value },
75
+ response: compileResultSchema,
76
+ signal
77
+ }),
78
+ commit: ({ definition, signal, ...value }) => http.request({
79
+ method: HttpMethod.Post,
80
+ path: definitionPath(definition, "/commit"),
81
+ body: { schema: commitDefinitionRequestSchema, value },
82
+ response: commitResultSchema,
83
+ signal
84
+ }),
85
+ publish: ({ definition, signal, ...value }) => http.request({
86
+ method: HttpMethod.Post,
87
+ path: definitionPath(definition, "/publish"),
88
+ body: { schema: publishDefinitionRequestSchema, value },
89
+ response: publishResultSchema,
90
+ signal
91
+ }),
92
+ files: ({ definition, ref, signal }) => http.request({
93
+ method: HttpMethod.Get,
94
+ path: definitionPath(definition, "/files"),
95
+ query: { ref },
96
+ response: definitionFilesSchema,
97
+ signal
98
+ }),
99
+ revisions: ({ definition, cursor, signal }) => http.request({
100
+ method: HttpMethod.Get,
101
+ path: definitionPath(definition, "/revisions"),
102
+ query: { cursor },
103
+ response: revisionListSchema,
104
+ signal
105
+ }),
106
+ revisionDiff: ({ definition, from, to, signal }) => http.request({
107
+ method: HttpMethod.Get,
108
+ path: definitionPath(definition, "/revisions/diff"),
109
+ query: { from, to },
110
+ response: revisionDiffSchema,
111
+ signal
112
+ }),
113
+ compatibility: ({ definition, harness, ref, signal }) => http.request({
114
+ method: HttpMethod.Get,
115
+ path: definitionPath(definition, "/compatibility"),
116
+ query: { harness, ref },
117
+ response: compatibilityReportSchema,
118
+ signal
119
+ }),
120
+ channels: async ({ definition, signal }) => (await http.request({
121
+ method: HttpMethod.Get,
122
+ path: definitionPath(definition, "/channels"),
123
+ response: definitionChannelsResponseSchema,
124
+ signal
125
+ })).channels,
126
+ attachChannel: ({ definition, bindingId, conversationId, signal }) => http.request({
127
+ method: HttpMethod.Put,
128
+ path: definitionPath(definition, `/channels/${encodePath(bindingId)}/conversation`),
129
+ body: { schema: attachChannelBindingRequestSchema, value: { conversationId } },
130
+ response: attachChannelBindingResponseSchema,
131
+ signal
132
+ }),
133
+ archive: ({ definition, signal }) => http.request({
134
+ method: HttpMethod.Post,
135
+ path: definitionPath(definition, "/archive"),
136
+ response: definitionSchema,
137
+ signal
138
+ }),
139
+ cloneUrl: ({ definition, signal }) => http.request({
140
+ method: HttpMethod.Post,
141
+ path: definitionPath(definition, "/clone-url"),
142
+ response: definitionCloneUrlSchema,
143
+ signal
144
+ })
145
+ });
146
+ const createProvidersApi = ({ http }) => ({
147
+ list: async (options) => (await http.request({
148
+ method: HttpMethod.Get,
149
+ path: "/v1/providers",
150
+ response: providerListSchema,
151
+ signal: options?.signal
152
+ })).providers
153
+ });
154
+ const createComputerSetupGuidesApi = ({
155
+ http
156
+ }) => ({
157
+ list: async (options) => (await http.request({
158
+ method: HttpMethod.Get,
159
+ path: "/v1/computer-setup-guides",
160
+ response: computerSetupGuideListSchema,
161
+ signal: options?.signal
162
+ })).guides,
163
+ get: (ref, options) => http.request({
164
+ method: HttpMethod.Get,
165
+ path: `/v1/computer-setup-guides/${encodePath(ref)}`,
166
+ response: computerSetupGuideDetailSchema,
167
+ signal: options?.signal
168
+ }),
169
+ publish: ({ signal, ...value }) => http.request({
170
+ method: HttpMethod.Post,
171
+ path: "/v1/computer-setup-guides",
172
+ body: { schema: publishComputerSetupGuideRequestSchema, value },
173
+ response: publishComputerSetupGuideResultSchema,
174
+ signal
175
+ })
176
+ });
177
+ const createSchedulesApi = ({ http }) => {
178
+ const list = async (options) => (await http.request({
179
+ method: HttpMethod.Get,
180
+ path: "/v1/schedules",
181
+ query: { agent: options?.agent },
182
+ response: scheduleListSchema,
183
+ signal: options?.signal
184
+ })).schedules;
185
+ const scheduleIdOf = async (args) => {
186
+ if ("scheduleId" in args) return args.scheduleId;
187
+ const found = (await list({ agent: args.agent, signal: args.signal })).find(
188
+ (schedule) => schedule.key === args.key
189
+ );
190
+ if (found == null) {
191
+ throw clientError({
192
+ message: `No schedule ${args.key} on agent ${args.agent}`,
193
+ status: 0,
194
+ code: ClientErrorCode.NotFound
195
+ });
196
+ }
197
+ return found.id;
198
+ };
199
+ return {
200
+ list,
201
+ runNow: async (args) => http.request({
202
+ method: HttpMethod.Post,
203
+ path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,
204
+ response: scheduleRunResultSchema,
205
+ signal: args.signal
206
+ }),
207
+ update: ({ scheduleId, signal, ...value }) => http.request({
208
+ method: HttpMethod.Patch,
209
+ path: `/v1/schedules/${encodePath(scheduleId)}`,
210
+ body: { schema: updateScheduleRequestSchema, value },
211
+ response: scheduleSchema,
212
+ signal
213
+ })
214
+ };
215
+ };
216
+ export {
217
+ createComputerSetupGuidesApi,
218
+ createDefinitionsApi,
219
+ createProvidersApi,
220
+ createSchedulesApi
221
+ };
222
+ //# sourceMappingURL=build.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/build.ts"],
4
+ "sourcesContent": ["import {\n attachChannelBindingRequestSchema,\n attachChannelBindingResponseSchema,\n commitDefinitionRequestSchema,\n commitResultSchema,\n compatibilityReportSchema,\n compileDefinitionRequestSchema,\n compileResultSchema,\n computerSetupGuideDetailSchema,\n computerSetupGuideListSchema,\n createDefinitionRequestSchema,\n credentialPolicyPreviewSchema,\n definitionChannelsResponseSchema,\n definitionCloneUrlSchema,\n definitionFilesSchema,\n definitionListSchema,\n definitionSchema,\n previewCredentialPolicyRequestSchema,\n providerListSchema,\n publishComputerSetupGuideRequestSchema,\n publishComputerSetupGuideResultSchema,\n publishDefinitionRequestSchema,\n publishResultSchema,\n revisionDiffSchema,\n revisionListSchema,\n revisionSchema,\n scheduleListSchema,\n scheduleRunResultSchema,\n scheduleSchema,\n updateScheduleRequestSchema,\n type AttachChannelBindingResponseIface,\n type CommitDefinitionRequestIface,\n type CommitResultIface,\n type CompatibilityReportIface,\n type CompileResultIface,\n type ComputerSetupGuideDetailIface,\n type ComputerSetupGuideIface,\n type ComputerSetupGuideVersionIface,\n type CreateDefinitionRequestIface,\n type CredentialPolicyPreviewIface,\n type DefinitionChannelIface,\n type DefinitionCloneUrlIface,\n type DefinitionFilesIface,\n type DefinitionIface,\n type PreviewCredentialPolicyRequestIface,\n type ProviderEntryIface,\n type PublishComputerSetupGuideRequestIface,\n type PublishResultIface,\n type RevisionDiffIface,\n type RevisionIface,\n type ScheduleIface,\n type ScheduleRunResultIface,\n type UpdateScheduleRequestIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\n// Definitions, providers, setup guides, schedules, credentials and budgets:\n// what Build, settings and CI use.\n\nexport interface DefinitionRefIface extends SignalOptionsIface {\n /** Definition id or slug. */\n definition: string;\n}\n\nexport interface DefinitionsApiIface {\n /** Compiles a draft into an immutable test snapshot without publishing or activating schedules/channels. */\n testRevision: (args: DefinitionRefIface & { ref: string }) => Promise<RevisionIface>;\n previewCredentialPolicy: (\n args: DefinitionRefIface & PreviewCredentialPolicyRequestIface,\n ) => Promise<CredentialPolicyPreviewIface>;\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<{ definitions: DefinitionIface[]; nextCursor: string | null }>;\n create: (args: CreateDefinitionRequestIface & SignalOptionsIface) => Promise<DefinitionIface>;\n get: (args: DefinitionRefIface) => Promise<DefinitionIface>;\n /** Compiles the directory at `ref` server-side without publishing. */\n compile: (\n args: DefinitionRefIface & { ref: string; harness?: string },\n ) => Promise<CompileResultIface>;\n commit: (args: DefinitionRefIface & CommitDefinitionRequestIface) => Promise<CommitResultIface>;\n /** Compiles `ref`, stores a revision and makes it current. */\n publish: (\n args: DefinitionRefIface & { ref: string; note?: string },\n ) => Promise<PublishResultIface>;\n /** The agent directory's files at `ref` (default branch when omitted). */\n files: (args: DefinitionRefIface & { ref?: string }) => Promise<DefinitionFilesIface>;\n revisions: (\n args: DefinitionRefIface & { cursor?: string },\n ) => Promise<{ revisions: RevisionIface[]; nextCursor: string | null }>;\n /**\n * What changed in the compiled manifest between two revisions (revision ids\n * or numbers); `to` defaults to the current revision.\n */\n revisionDiff: (\n args: DefinitionRefIface & { from: string | number; to?: string | number },\n ) => Promise<RevisionDiffIface>;\n compatibility: (\n args: DefinitionRefIface & { harness: string; ref?: string },\n ) => Promise<CompatibilityReportIface>;\n /** The agent's live channel bindings, with the conversation each is attached to. */\n channels: (args: DefinitionRefIface) => Promise<DefinitionChannelIface[]>;\n /**\n * Attaches a channel binding to a conversation the agent and the caller take\n * part in (its events and bound-conversation schedules post there); null detaches.\n */\n attachChannel: (\n args: DefinitionRefIface & { bindingId: string; conversationId: string | null },\n ) => Promise<AttachChannelBindingResponseIface>;\n /**\n * Archives the definition: it leaves listings, its schedules and channel\n * bindings stop, and new sessions are refused. Its repository is kept.\n */\n archive: (args: DefinitionRefIface) => Promise<DefinitionIface>;\n /**\n * A short-lived, read-only git remote for a Final-hosted repository, for\n * `git clone` (owners of personal agents, organization admins otherwise).\n */\n cloneUrl: (args: DefinitionRefIface) => Promise<DefinitionCloneUrlIface>;\n}\n\nexport interface ProvidersApiIface {\n list: (options?: SignalOptionsIface) => Promise<ProviderEntryIface[]>;\n}\n\nexport interface ComputerSetupGuidesApiIface {\n list: (options?: SignalOptionsIface) => Promise<ComputerSetupGuideIface[]>;\n /** Guide by slug or id, with its versions. */\n get: (ref: string, options?: SignalOptionsIface) => Promise<ComputerSetupGuideDetailIface>;\n /** Publishes a new version (creating the guide on first publish). */\n publish: (\n args: PublishComputerSetupGuideRequestIface & SignalOptionsIface,\n ) => Promise<{ guide: ComputerSetupGuideIface; version: ComputerSetupGuideVersionIface }>;\n}\n\nexport type ScheduleRef = { scheduleId: string } | { agent: string; key: string };\n\nexport interface SchedulesApiIface {\n list: (options?: SignalOptionsIface & { agent?: string }) => Promise<ScheduleIface[]>;\n runNow: (args: ScheduleRef & SignalOptionsIface) => Promise<ScheduleRunResultIface>;\n update: (\n args: { scheduleId: string } & UpdateScheduleRequestIface & SignalOptionsIface,\n ) => Promise<ScheduleIface>;\n}\n\nconst definitionPath = (definition: string, suffix = ''): string =>\n `/v1/definitions/${encodePath(definition)}${suffix}`;\n\nexport const createDefinitionsApi = ({ http }: ClientContextIface): DefinitionsApiIface => ({\n testRevision: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/test-revision'),\n body: { schema: compileDefinitionRequestSchema, value },\n response: revisionSchema,\n signal,\n }),\n previewCredentialPolicy: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/credential-policy/preview'),\n body: { schema: previewCredentialPolicyRequestSchema, value },\n response: credentialPolicyPreviewSchema,\n signal,\n }),\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/definitions',\n query: { cursor: options?.cursor, limit: options?.limit },\n response: definitionListSchema,\n signal: options?.signal,\n }),\n create: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/definitions',\n body: { schema: createDefinitionRequestSchema, value },\n response: definitionSchema,\n signal,\n }),\n get: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition),\n response: definitionSchema,\n signal,\n }),\n compile: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/compile'),\n body: { schema: compileDefinitionRequestSchema, value },\n response: compileResultSchema,\n signal,\n }),\n commit: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/commit'),\n body: { schema: commitDefinitionRequestSchema, value },\n response: commitResultSchema,\n signal,\n }),\n publish: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/publish'),\n body: { schema: publishDefinitionRequestSchema, value },\n response: publishResultSchema,\n signal,\n }),\n files: ({ definition, ref, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/files'),\n query: { ref },\n response: definitionFilesSchema,\n signal,\n }),\n revisions: ({ definition, cursor, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/revisions'),\n query: { cursor },\n response: revisionListSchema,\n signal,\n }),\n revisionDiff: ({ definition, from, to, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/revisions/diff'),\n query: { from, to },\n response: revisionDiffSchema,\n signal,\n }),\n compatibility: ({ definition, harness, ref, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/compatibility'),\n query: { harness, ref },\n response: compatibilityReportSchema,\n signal,\n }),\n channels: async ({ definition, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/channels'),\n response: definitionChannelsResponseSchema,\n signal,\n })\n ).channels,\n attachChannel: ({ definition, bindingId, conversationId, signal }) =>\n http.request({\n method: HttpMethod.Put,\n path: definitionPath(definition, `/channels/${encodePath(bindingId)}/conversation`),\n body: { schema: attachChannelBindingRequestSchema, value: { conversationId } },\n response: attachChannelBindingResponseSchema,\n signal,\n }),\n archive: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/archive'),\n response: definitionSchema,\n signal,\n }),\n cloneUrl: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/clone-url'),\n response: definitionCloneUrlSchema,\n signal,\n }),\n});\n\nexport const createProvidersApi = ({ http }: ClientContextIface): ProvidersApiIface => ({\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/providers',\n response: providerListSchema,\n signal: options?.signal,\n })\n ).providers,\n});\n\nexport const createComputerSetupGuidesApi = ({\n http,\n}: ClientContextIface): ComputerSetupGuidesApiIface => ({\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/computer-setup-guides',\n response: computerSetupGuideListSchema,\n signal: options?.signal,\n })\n ).guides,\n get: (ref, options) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/computer-setup-guides/${encodePath(ref)}`,\n response: computerSetupGuideDetailSchema,\n signal: options?.signal,\n }),\n publish: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/computer-setup-guides',\n body: { schema: publishComputerSetupGuideRequestSchema, value },\n response: publishComputerSetupGuideResultSchema,\n signal,\n }),\n});\n\nexport const createSchedulesApi = ({ http }: ClientContextIface): SchedulesApiIface => {\n const list: SchedulesApiIface['list'] = async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/schedules',\n query: { agent: options?.agent },\n response: scheduleListSchema,\n signal: options?.signal,\n })\n ).schedules;\n\n const scheduleIdOf = async (args: ScheduleRef & SignalOptionsIface): Promise<string> => {\n if ('scheduleId' in args) return args.scheduleId;\n const found = (await list({ agent: args.agent, signal: args.signal })).find(\n (schedule) => schedule.key === args.key,\n );\n if (found == null) {\n throw clientError({\n message: `No schedule ${args.key} on agent ${args.agent}`,\n status: 0,\n code: ClientErrorCode.NotFound,\n });\n }\n return found.id;\n };\n\n return {\n list,\n runNow: async (args) =>\n http.request({\n method: HttpMethod.Post,\n path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,\n response: scheduleRunResultSchema,\n signal: args.signal,\n }),\n update: ({ scheduleId, signal, ...value }) =>\n http.request({\n method: HttpMethod.Patch,\n path: `/v1/schedules/${encodePath(scheduleId)}`,\n body: { schema: updateScheduleRequestSchema, value },\n response: scheduleSchema,\n signal,\n }),\n };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAwBK;AACP,SAAS,kBAAoE;AAC7E,SAAS,aAAa,uBAAuB;AAC7C,SAAS,kBAAkB;AA0F3B,MAAM,iBAAiB,CAAC,YAAoB,SAAS,OACnD,mBAAmB,WAAW,UAAU,CAAC,GAAG,MAAM;AAE7C,MAAM,uBAAuB,CAAC,EAAE,KAAK,OAAgD;AAAA,EAC1F,cAAc,CAAC,EAAE,YAAY,QAAQ,GAAG,MAAM,MAC5C,KAAK,QAAQ;AAAA,IACX,QAAQ,WAAW;AAAA,IACnB,MAAM,eAAe,YAAY,gBAAgB;AAAA,IACjD,MAAM,EAAE,QAAQ,gCAAgC,MAAM;AAAA,IACtD,UAAU;AAAA,IACV;AAAA,EACF,CAAC;AAAA,E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AAM,EAAE,QAAQ,6BAA6B,MAAM;AAAA,MACnD,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACL;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,111 @@
1
+ import { type AgentInfoIface, type AgentListIface, type HealthResponseIface, type PendingRequestIface, type PendingRequestListIface, type PersonIface, type PersonListIface, type RealtimeSessionResponseIface } from '@finalai/agent-protocol/agent-platform';
2
+ import { type AcpApiIface } from "./acp.mjs";
3
+ import { type ComputerSetupGuidesApiIface, type DefinitionsApiIface, type ProvidersApiIface, type SchedulesApiIface } from "./build.mjs";
4
+ import { type CollectionEvent, type CollectionEventsOptionsIface } from "./collection-events.mjs";
5
+ import { type SignalOptionsIface } from "./context.mjs";
6
+ import { type ConversationsApiIface } from "./conversations.mjs";
7
+ import { type StreamTimingIface } from "./frame-stream.mjs";
8
+ import { type AgentClientAuth, type FetchIface, type HeadersOption } from "./http.mjs";
9
+ import { type GatewayConnect, type RealtimeTransportIface } from "./realtime.mjs";
10
+ import { type SessionsApiIface } from "./sessions.mjs";
11
+ export interface CreateClientOptionsIface {
12
+ /**
13
+ * The session service's origin (`https://agent-session.final.ai`; its API is
14
+ * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted
15
+ * under (console-server's `https://<console>/api/agent-platform` proxy).
16
+ */
17
+ host: string;
18
+ auth: AgentClientAuth;
19
+ /** Extra headers per request; console clients send their client identity header here. */
20
+ headers?: HeadersOption;
21
+ /** API requests (the host's routes); carries auth and caller headers. */
22
+ fetch?: FetchIface;
23
+ /**
24
+ * Presigned storage requests (attachment uploads). Gets only the headers the
25
+ * presign requires, never auth, client identity or cookies, so a storage
26
+ * bucket's CORS and third-party hosts see nothing of the caller. Defaults to
27
+ * `globalThis.fetch`; keep it free of header-injecting wrappers.
28
+ */
29
+ storageFetch?: FetchIface;
30
+ /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */
31
+ realtime?: RealtimeTransportIface;
32
+ /** Seam for the default transport's gateway connection. */
33
+ gatewayConnect?: GatewayConnect;
34
+ /** Seam for stream retry timing (tests). */
35
+ timing?: Partial<StreamTimingIface>;
36
+ /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */
37
+ newKey?: () => string;
38
+ /** Seam for the client clock (conversation recovery windows). */
39
+ now?: () => number;
40
+ }
41
+ export interface AgentHandleIface {
42
+ slug: string;
43
+ info: (options?: SignalOptionsIface) => Promise<AgentInfoIface>;
44
+ }
45
+ export interface AgentsApiIface {
46
+ list: (options?: SignalOptionsIface & {
47
+ cursor?: string;
48
+ limit?: number;
49
+ }) => Promise<AgentListIface>;
50
+ /** I/O-free handle by slug or id. */
51
+ get: (slugOrId: string) => AgentHandleIface;
52
+ }
53
+ export interface PendingApiIface {
54
+ /**
55
+ * The caller's pending topic (`user.collection:<userId>:pending`): `acp.pending`
56
+ * events for requests addressed to them, and a `collection.resync` whenever
57
+ * `mine()` must be re-read (on every subscription, resync and while realtime is down).
58
+ */
59
+ events: (options?: CollectionEventsOptionsIface) => AsyncIterableIterator<CollectionEvent>;
60
+ /** Every open permission and elicitation request whose audience includes the caller, newest first (all pages). */
61
+ mine: (options?: SignalOptionsIface) => Promise<PendingRequestIface[]>;
62
+ /** One page, newest first; pass `nextCursor` as `cursor` for the next. */
63
+ page: (options?: SignalOptionsIface & {
64
+ cursor?: string;
65
+ limit?: number;
66
+ }) => Promise<PendingRequestListIface>;
67
+ }
68
+ export interface PeopleApiIface {
69
+ /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */
70
+ list: (options?: SignalOptionsIface & {
71
+ cursor?: string;
72
+ limit?: number;
73
+ }) => Promise<PersonListIface>;
74
+ /** Every member of the caller's organization (all pages). */
75
+ all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;
76
+ }
77
+ export interface RealtimeApiIface {
78
+ /**
79
+ * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:
80
+ * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.
81
+ * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.
82
+ */
83
+ createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;
84
+ }
85
+ export interface AgentClientIface {
86
+ health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;
87
+ agents: AgentsApiIface;
88
+ people: PeopleApiIface;
89
+ realtime: RealtimeApiIface;
90
+ sessions: SessionsApiIface;
91
+ conversations: ConversationsApiIface;
92
+ definitions: DefinitionsApiIface;
93
+ providers: ProvidersApiIface;
94
+ computerSetupGuides: ComputerSetupGuidesApiIface;
95
+ schedules: SchedulesApiIface;
96
+ pending: PendingApiIface;
97
+ /**
98
+ * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the
99
+ * session service is the agent. The ACP SDK loads on the first `connect`.
100
+ */
101
+ acp: AcpApiIface;
102
+ /**
103
+ * Ends every stream (they reject with a `client_closed` ClientError) and, when
104
+ * the client created its own realtime transport, closes the gateway connection
105
+ * and cancels its retries. A transport passed in `realtime` belongs to the
106
+ * caller and is left open. Idempotent.
107
+ */
108
+ close: () => void;
109
+ [Symbol.asyncDispose]: () => Promise<void>;
110
+ }
111
+ export declare const createClient: (options: CreateClientOptionsIface) => AgentClientIface;
@@ -0,0 +1,198 @@
1
+ import {
2
+ agentInfoSchema,
3
+ agentListSchema,
4
+ agentRealtimeTopics,
5
+ healthResponseSchema,
6
+ pendingRequestListSchema,
7
+ personListSchema,
8
+ realtimeSessionResponseSchema
9
+ } from "@finalai/agent-protocol/agent-platform";
10
+ import { createAcpApi } from "./acp.mjs";
11
+ import {
12
+ createComputerSetupGuidesApi,
13
+ createDefinitionsApi,
14
+ createProvidersApi,
15
+ createSchedulesApi
16
+ } from "./build.mjs";
17
+ import {
18
+ streamCollectionEvents
19
+ } from "./collection-events.mjs";
20
+ import {
21
+ ClientCollection,
22
+ encodePath
23
+ } from "./context.mjs";
24
+ import { createConversationsApi } from "./conversations.mjs";
25
+ import { clientError, ClientErrorCode } from "./errors.mjs";
26
+ import { defaultStreamTiming } from "./frame-stream.mjs";
27
+ import {
28
+ createHttp,
29
+ HttpMethod
30
+ } from "./http.mjs";
31
+ import {
32
+ createGatewayRealtimeTransport
33
+ } from "./realtime.mjs";
34
+ import { createSessionsApi } from "./sessions.mjs";
35
+ const createClient = (options) => {
36
+ const http = createHttp({
37
+ host: options.host,
38
+ auth: options.auth,
39
+ headers: options.headers,
40
+ fetch: options.fetch
41
+ });
42
+ let realtime = options.realtime ?? null;
43
+ let ownTransport = null;
44
+ const closing = new AbortController();
45
+ const createRealtimeSession = (sessionOptions) => http.request({
46
+ method: HttpMethod.Post,
47
+ path: "/v1/realtime/session",
48
+ response: realtimeSessionResponseSchema,
49
+ signal: sessionOptions?.signal
50
+ });
51
+ let realtimeOwner = null;
52
+ const realtimeOwnerSession = () => {
53
+ if (realtimeOwner != null) return realtimeOwner;
54
+ const pending = createRealtimeSession({ signal: closing.signal });
55
+ realtimeOwner = pending;
56
+ void pending.catch(() => {
57
+ if (realtimeOwner === pending) realtimeOwner = null;
58
+ });
59
+ return pending;
60
+ };
61
+ let realtimeUser = null;
62
+ const realtimeUserId = () => {
63
+ if (realtimeUser != null) return realtimeUser;
64
+ const pending = realtimeOwnerSession().then((session) => {
65
+ if (session.userId == null)
66
+ throw new Error("This client authenticates as an API-key owner, not a user");
67
+ return session.userId;
68
+ });
69
+ realtimeUser = pending;
70
+ pending.catch(() => {
71
+ if (realtimeUser === pending) realtimeUser = null;
72
+ });
73
+ return pending;
74
+ };
75
+ const context = {
76
+ http,
77
+ closeSignal: closing.signal,
78
+ realtimeUserId,
79
+ realtimeCollectionTopic: async (collection) => {
80
+ const owner = await realtimeOwnerSession();
81
+ if (owner.apiKeyPrincipalId != null)
82
+ return collection === ClientCollection.Pending ? agentRealtimeTopics.apiKeyPending(owner.apiKeyPrincipalId) : agentRealtimeTopics.apiKeyConversations(owner.apiKeyPrincipalId);
83
+ if (owner.userId == null) throw new Error("Realtime session has no collection owner");
84
+ return collection === ClientCollection.Pending ? agentRealtimeTopics.userPending(owner.userId) : agentRealtimeTopics.userConversations(owner.userId);
85
+ },
86
+ storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),
87
+ realtime: () => {
88
+ if (realtime != null) return realtime;
89
+ ownTransport = createGatewayRealtimeTransport({
90
+ createSession: () => createRealtimeSession(),
91
+ connect: options.gatewayConnect
92
+ });
93
+ if (closing.signal.aborted) ownTransport.close();
94
+ realtime = ownTransport;
95
+ return realtime;
96
+ },
97
+ timing: { ...defaultStreamTiming, ...options.timing },
98
+ newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),
99
+ now: options.now ?? Date.now
100
+ };
101
+ const close = () => {
102
+ if (closing.signal.aborted) return;
103
+ closing.abort(
104
+ clientError({ message: "Agent client closed", status: 0, code: ClientErrorCode.Closed })
105
+ );
106
+ ownTransport?.close();
107
+ };
108
+ return {
109
+ close,
110
+ [Symbol.asyncDispose]: async () => close(),
111
+ health: (healthOptions) => http.request({
112
+ method: HttpMethod.Get,
113
+ path: "/v1/health",
114
+ response: healthResponseSchema,
115
+ signal: healthOptions?.signal
116
+ }),
117
+ agents: {
118
+ list: (listOptions) => http.request({
119
+ method: HttpMethod.Get,
120
+ path: "/v1/agents",
121
+ query: { cursor: listOptions?.cursor, limit: listOptions?.limit },
122
+ response: agentListSchema,
123
+ signal: listOptions?.signal
124
+ }),
125
+ get: (slugOrId) => ({
126
+ slug: slugOrId,
127
+ info: (infoOptions) => http.request({
128
+ method: HttpMethod.Get,
129
+ path: `/v1/agents/${encodePath(slugOrId)}`,
130
+ response: agentInfoSchema,
131
+ signal: infoOptions?.signal
132
+ })
133
+ })
134
+ },
135
+ people: /* @__PURE__ */ (() => {
136
+ const list = (listOptions) => http.request({
137
+ method: HttpMethod.Get,
138
+ path: "/v1/people",
139
+ query: { cursor: listOptions?.cursor, limit: listOptions?.limit },
140
+ response: personListSchema,
141
+ signal: listOptions?.signal
142
+ });
143
+ return {
144
+ list,
145
+ all: async (allOptions) => {
146
+ const all = [];
147
+ let cursor;
148
+ for (; ; ) {
149
+ const next = await list({ cursor, signal: allOptions?.signal });
150
+ all.push(...next.people);
151
+ if (next.nextCursor == null) return all;
152
+ cursor = next.nextCursor;
153
+ }
154
+ }
155
+ };
156
+ })(),
157
+ realtime: { createSession: createRealtimeSession },
158
+ sessions: createSessionsApi(context),
159
+ conversations: createConversationsApi(context),
160
+ definitions: createDefinitionsApi(context),
161
+ providers: createProvidersApi(context),
162
+ computerSetupGuides: createComputerSetupGuidesApi(context),
163
+ schedules: createSchedulesApi(context),
164
+ acp: createAcpApi({ http }),
165
+ pending: /* @__PURE__ */ (() => {
166
+ const page = (pageOptions) => http.request({
167
+ method: HttpMethod.Get,
168
+ path: "/v1/pending",
169
+ query: { cursor: pageOptions?.cursor, limit: pageOptions?.limit },
170
+ response: pendingRequestListSchema,
171
+ signal: pageOptions?.signal
172
+ });
173
+ return {
174
+ page,
175
+ events: (eventsOptions) => streamCollectionEvents({
176
+ context,
177
+ topicFor: agentRealtimeTopics.userPending,
178
+ collection: ClientCollection.Pending,
179
+ options: eventsOptions
180
+ }),
181
+ mine: async (mineOptions) => {
182
+ const all = [];
183
+ let cursor;
184
+ for (; ; ) {
185
+ const next = await page({ cursor, signal: mineOptions?.signal });
186
+ all.push(...next.pending);
187
+ if (next.nextCursor == null) return all;
188
+ cursor = next.nextCursor;
189
+ }
190
+ }
191
+ };
192
+ })()
193
+ };
194
+ };
195
+ export {
196
+ createClient
197
+ };
198
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/client.ts"],
4
+ "sourcesContent": ["import {\n agentInfoSchema,\n agentListSchema,\n agentRealtimeTopics,\n healthResponseSchema,\n pendingRequestListSchema,\n personListSchema,\n realtimeSessionResponseSchema,\n type AgentInfoIface,\n type AgentListIface,\n type HealthResponseIface,\n type PendingRequestIface,\n type PendingRequestListIface,\n type PersonIface,\n type PersonListIface,\n type RealtimeSessionResponseIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { createAcpApi, type AcpApiIface } from \"./acp.mjs\";\nimport {\n createComputerSetupGuidesApi,\n createDefinitionsApi,\n createProvidersApi,\n createSchedulesApi,\n type ComputerSetupGuidesApiIface,\n type DefinitionsApiIface,\n type ProvidersApiIface,\n type SchedulesApiIface,\n} from \"./build.mjs\";\nimport {\n streamCollectionEvents,\n type CollectionEvent,\n type CollectionEventsOptionsIface,\n} from \"./collection-events.mjs\";\nimport {\n ClientCollection,\n encodePath,\n type ClientContextIface,\n type SignalOptionsIface,\n} from \"./context.mjs\";\nimport { createConversationsApi, type ConversationsApiIface } from \"./conversations.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nimport {\n createHttp,\n HttpMethod,\n type AgentClientAuth,\n type FetchIface,\n type HeadersOption,\n} from \"./http.mjs\";\nimport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayRealtimeTransportIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nimport { createSessionsApi, type SessionsApiIface } from \"./sessions.mjs\";\n\nexport interface CreateClientOptionsIface {\n /**\n * The session service's origin (`https://agent-session.final.ai`; its API is\n * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted\n * under (console-server's `https://<console>/api/agent-platform` proxy).\n */\n host: string;\n auth: AgentClientAuth;\n /** Extra headers per request; console clients send their client identity header here. */\n headers?: HeadersOption;\n /** API requests (the host's routes); carries auth and caller headers. */\n fetch?: FetchIface;\n /**\n * Presigned storage requests (attachment uploads). Gets only the headers the\n * presign requires, never auth, client identity or cookies, so a storage\n * bucket's CORS and third-party hosts see nothing of the caller. Defaults to\n * `globalThis.fetch`; keep it free of header-injecting wrappers.\n */\n storageFetch?: FetchIface;\n /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */\n realtime?: RealtimeTransportIface;\n /** Seam for the default transport's gateway connection. */\n gatewayConnect?: GatewayConnect;\n /** Seam for stream retry timing (tests). */\n timing?: Partial<StreamTimingIface>;\n /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */\n newKey?: () => string;\n /** Seam for the client clock (conversation recovery windows). */\n now?: () => number;\n}\n\nexport interface AgentHandleIface {\n slug: string;\n info: (options?: SignalOptionsIface) => Promise<AgentInfoIface>;\n}\n\nexport interface AgentsApiIface {\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<AgentListIface>;\n /** I/O-free handle by slug or id. */\n get: (slugOrId: string) => AgentHandleIface;\n}\n\nexport interface PendingApiIface {\n /**\n * The caller's pending topic (`user.collection:<userId>:pending`): `acp.pending`\n * events for requests addressed to them, and a `collection.resync` whenever\n * `mine()` must be re-read (on every subscription, resync and while realtime is down).\n */\n events: (options?: CollectionEventsOptionsIface) => AsyncIterableIterator<CollectionEvent>;\n /** Every open permission and elicitation request whose audience includes the caller, newest first (all pages). */\n mine: (options?: SignalOptionsIface) => Promise<PendingRequestIface[]>;\n /** One page, newest first; pass `nextCursor` as `cursor` for the next. */\n page: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PendingRequestListIface>;\n}\n\nexport interface PeopleApiIface {\n /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PersonListIface>;\n /** Every member of the caller's organization (all pages). */\n all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;\n}\n\nexport interface RealtimeApiIface {\n /**\n * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:\n * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.\n * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.\n */\n createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;\n}\n\nexport interface AgentClientIface {\n health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;\n agents: AgentsApiIface;\n people: PeopleApiIface;\n realtime: RealtimeApiIface;\n sessions: SessionsApiIface;\n conversations: ConversationsApiIface;\n definitions: DefinitionsApiIface;\n providers: ProvidersApiIface;\n computerSetupGuides: ComputerSetupGuidesApiIface;\n schedules: SchedulesApiIface;\n pending: PendingApiIface;\n /**\n * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the\n * session service is the agent. The ACP SDK loads on the first `connect`.\n */\n acp: AcpApiIface;\n /**\n * Ends every stream (they reject with a `client_closed` ClientError) and, when\n * the client created its own realtime transport, closes the gateway connection\n * and cancels its retries. A transport passed in `realtime` belongs to the\n * caller and is left open. Idempotent.\n */\n close: () => void;\n [Symbol.asyncDispose]: () => Promise<void>;\n}\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface => {\n const http = createHttp({\n host: options.host,\n auth: options.auth,\n headers: options.headers,\n fetch: options.fetch,\n });\n let realtime = options.realtime ?? null;\n let ownTransport: GatewayRealtimeTransportIface | null = null;\n const closing = new AbortController();\n const createRealtimeSession: RealtimeApiIface['createSession'] = (sessionOptions) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/realtime/session',\n response: realtimeSessionResponseSchema,\n signal: sessionOptions?.signal,\n });\n let realtimeOwner: Promise<RealtimeSessionResponseIface> | null = null;\n const realtimeOwnerSession = () => {\n if (realtimeOwner != null) return realtimeOwner;\n const pending = createRealtimeSession({ signal: closing.signal });\n realtimeOwner = pending;\n void pending.catch(() => {\n if (realtimeOwner === pending) realtimeOwner = null;\n });\n return pending;\n };\n let realtimeUser: Promise<string> | null = null;\n // Shared by every stream, so it is cancelled only with the client, never by one caller.\n const realtimeUserId: ClientContextIface['realtimeUserId'] = () => {\n if (realtimeUser != null) return realtimeUser;\n const pending = realtimeOwnerSession().then((session) => {\n if (session.userId == null)\n throw new Error('This client authenticates as an API-key owner, not a user');\n return session.userId;\n });\n realtimeUser = pending;\n // A failed (or aborted) read is not cached.\n pending.catch(() => {\n if (realtimeUser === pending) realtimeUser = null;\n });\n return pending;\n };\n const context: ClientContextIface = {\n http,\n closeSignal: closing.signal,\n realtimeUserId,\n realtimeCollectionTopic: async (collection) => {\n const owner = await realtimeOwnerSession();\n if (owner.apiKeyPrincipalId != null)\n return collection === ClientCollection.Pending\n ? agentRealtimeTopics.apiKeyPending(owner.apiKeyPrincipalId)\n : agentRealtimeTopics.apiKeyConversations(owner.apiKeyPrincipalId);\n if (owner.userId == null) throw new Error('Realtime session has no collection owner');\n return collection === ClientCollection.Pending\n ? agentRealtimeTopics.userPending(owner.userId)\n : agentRealtimeTopics.userConversations(owner.userId);\n },\n storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),\n realtime: () => {\n if (realtime != null) return realtime;\n ownTransport = createGatewayRealtimeTransport({\n createSession: () => createRealtimeSession(),\n connect: options.gatewayConnect,\n });\n if (closing.signal.aborted) ownTransport.close();\n realtime = ownTransport;\n return realtime;\n },\n timing: { ...defaultStreamTiming, ...options.timing },\n newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),\n now: options.now ?? Date.now,\n };\n\n const close = (): void => {\n if (closing.signal.aborted) return;\n closing.abort(\n clientError({ message: 'Agent client closed', status: 0, code: ClientErrorCode.Closed }),\n );\n ownTransport?.close();\n };\n\n return {\n close,\n [Symbol.asyncDispose]: async () => close(),\n health: (healthOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/health',\n response: healthResponseSchema,\n signal: healthOptions?.signal,\n }),\n agents: {\n list: (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/agents',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: agentListSchema,\n signal: listOptions?.signal,\n }),\n get: (slugOrId) => ({\n slug: slugOrId,\n info: (infoOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/agents/${encodePath(slugOrId)}`,\n response: agentInfoSchema,\n signal: infoOptions?.signal,\n }),\n }),\n },\n people: (() => {\n const list: PeopleApiIface['list'] = (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/people',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: personListSchema,\n signal: listOptions?.signal,\n });\n return {\n list,\n all: async (allOptions) => {\n const all: PersonIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await list({ cursor, signal: allOptions?.signal });\n all.push(...next.people);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n };\n })(),\n realtime: { createSession: createRealtimeSession },\n sessions: createSessionsApi(context),\n conversations: createConversationsApi(context),\n definitions: createDefinitionsApi(context),\n providers: createProvidersApi(context),\n computerSetupGuides: createComputerSetupGuidesApi(context),\n schedules: createSchedulesApi(context),\n acp: createAcpApi({ http }),\n pending: (() => {\n const page: PendingApiIface['page'] = (pageOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/pending',\n query: { cursor: pageOptions?.cursor, limit: pageOptions?.limit },\n response: pendingRequestListSchema,\n signal: pageOptions?.signal,\n });\n return {\n page,\n events: (eventsOptions) =>\n streamCollectionEvents({\n context,\n topicFor: agentRealtimeTopics.userPending,\n collection: ClientCollection.Pending,\n options: eventsOptions,\n }),\n mine: async (mineOptions) => {\n const all: PendingRequestIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await page({ cursor, signal: mineOptions?.signal });\n all.push(...next.pending);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n };\n })(),\n };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASK;AACP,SAAS,oBAAsC;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,8BAA0D;AACnE,SAAS,aAAa,uBAAuB;AAC7C,SAAS,2BAAmD;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,OA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ACrC,KAAK,QAAQ;AAAA,QACX,QAAQ,WAAW;AAAA,QACnB,MAAM;AAAA,QACN,OAAO,EAAE,QAAQ,aAAa,QAAQ,OAAO,aAAa,MAAM;AAAA,QAChE,UAAU;AAAA,QACV,QAAQ,aAAa;AAAA,MACvB,CAAC;AACH,aAAO;AAAA,QACL;AAAA,QACA,QAAQ,CAAC,kBACP,uBAAuB;AAAA,UACrB;AAAA,UACA,UAAU,oBAAoB;AAAA,UAC9B,YAAY,iBAAiB;AAAA,UAC7B,SAAS;AAAA,QACX,CAAC;AAAA,QACH,MAAM,OAAO,gBAAgB;AAC3B,gBAAM,MAA6B,CAAC;AACpC,cAAI;AACJ,qBAAS;AACP,kBAAM,OAAO,MAAM,KAAK,EAAE,QAAQ,QAAQ,aAAa,OAAO,CAAC;AAC/D,gBAAI,KAAK,GAAG,KAAK,OAAO;AACxB,gBAAI,KAAK,cAAc,KAAM,QAAO;AACpC,qBAAS,KAAK;AAAA,UAChB;AAAA,QACF;AAAA,MACF;AAAA,IACF,GAAG;AAAA,EACL;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,35 @@
1
+ import type { ClientCollection, ClientContextIface, SignalOptionsIface } from "./context.mjs";
2
+ import type { ConversationEvent } from "./conversations.mjs";
3
+ export declare enum CollectionEventKind {
4
+ /** Re-read the collection (`conversations.list()`, `pending.mine()`); events may have been missed. */
5
+ Resync = "collection.resync"
6
+ }
7
+ export declare enum CollectionResyncReason {
8
+ Subscribed = "subscribed",
9
+ ResyncRequired = "resync_required",
10
+ /** The realtime transport is down; repeated every `timing.conversationPollIntervalMs`. */
11
+ Degraded = "degraded"
12
+ }
13
+ export interface CollectionResyncEventIface {
14
+ kind: CollectionEventKind.Resync;
15
+ /** Null while the signed-in user, and so the topic, could not be read yet. */
16
+ topic: string | null;
17
+ reason: CollectionResyncReason;
18
+ }
19
+ /** A realtime event of the collection topic, or a cue to re-read the collection. */
20
+ export type CollectionEvent = ConversationEvent | CollectionResyncEventIface;
21
+ export interface CollectionEventsOptionsIface extends SignalOptionsIface {
22
+ /** Keep streaming; false ends after the first resync. Defaults to true. */
23
+ follow?: boolean;
24
+ /**
25
+ * The signed-in user the topics are keyed by. Defaults to the user of a
26
+ * minted realtime session (`realtime.createSession()`).
27
+ */
28
+ userId?: string;
29
+ }
30
+ export declare const streamCollectionEvents: (args: {
31
+ context: ClientContextIface;
32
+ topicFor: (userId: string) => string;
33
+ collection?: ClientCollection;
34
+ options: CollectionEventsOptionsIface | undefined;
35
+ }) => AsyncIterableIterator<CollectionEvent>;