@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
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @finalai/agents
2
+
3
+ SDK for defining, publishing, and using agents. Authoring helpers are implemented in
4
+ `@finalai/agent-definition`; Final-specific bindings come from
5
+ `@finalai/final-agent-provider`.
6
+
7
+ ```ts
8
+ import { defineAgent } from '@finalai/agents';
9
+ import { serverlessPi } from '@finalai/agents/harnesses';
10
+
11
+ export default defineAgent({
12
+ name: 'Assistant',
13
+ harness: serverlessPi({
14
+ credentials: { payer: 'agent-owner', tryInOrder: [{ kind: 'platform' }] },
15
+ }),
16
+ });
17
+ ```
18
+
19
+ Use `@finalai/agents/client` for definitions, sessions, conversations, approvals,
20
+ attachments, schedules, sandbox access, and realtime. Use `final-agents --help`
21
+ for CLI commands. Compilation requires Node 26 and ships its assets through
22
+ `agent-definition`.
23
+
24
+ Credential-chain declarations select which credentials an agent may use and in
25
+ which order. Set the payer policy explicitly in the harness configuration.
26
+
27
+ For custom provider implementations, import contracts from `@finalai/agent-provider`,
28
+ sandbox adapters from `@finalai/agent-provider/sandbox`, and conformance tools from
29
+ `@finalai/agent-provider/conformance`. Run a harness check with
30
+ `final-agents conformance ./harness.ts`.
@@ -0,0 +1,19 @@
1
+ import { type AcpFrameEventIface, type AcpSessionUpdateParamsIface } from '@finalai/agent-protocol/agent-platform';
2
+ export type AcpSessionUpdateIface = AcpSessionUpdateParamsIface['update'];
3
+ /** The `session/update` payload of an agent frame, or null for any other frame. */
4
+ export declare const sessionUpdateOf: (event: AcpFrameEventIface) => AcpSessionUpdateIface | null;
5
+ /** Text carried by an `agent_message_chunk` / `agent_message` update. */
6
+ export declare const textOf: (update: AcpSessionUpdateIface) => string;
7
+ export interface TurnEndIface {
8
+ stopReason: string | null;
9
+ }
10
+ /** A `state_update` to `idle` ends the turn (ACP v2); returns its stop reason. */
11
+ export declare const turnEndOf: (event: AcpFrameEventIface) => TurnEndIface | null;
12
+ /** Whether the frame is the user-message update ACP emits for the accepted prompt `messageId`. */
13
+ export declare const isUserMessageFor: (event: AcpFrameEventIface, messageId: string) => boolean;
14
+ export interface TextCollectorIface {
15
+ add: (event: AcpFrameEventIface) => void;
16
+ text: () => string;
17
+ }
18
+ /** Accumulates visible agent text across chunks and full messages, per message id. */
19
+ export declare const createTextCollector: () => TextCollectorIface;
@@ -0,0 +1,49 @@
1
+ import {
2
+ AcpFrameDirection,
3
+ acpSessionUpdateParamsSchema
4
+ } from "@finalai/agent-protocol/agent-platform";
5
+ const SESSION_UPDATE = "session/update";
6
+ const sessionUpdateOf = (event) => {
7
+ if (event.frame.method !== SESSION_UPDATE) return null;
8
+ const parsed = acpSessionUpdateParamsSchema.safeParse(event.frame.params);
9
+ return parsed.success ? parsed.data.update : null;
10
+ };
11
+ const textOf = (update) => {
12
+ const content = update.content;
13
+ if (content == null) return "";
14
+ const blocks = Array.isArray(content) ? content : [content];
15
+ return blocks.map((block) => block.type === "text" ? block.text ?? "" : "").join("");
16
+ };
17
+ const turnEndOf = (event) => {
18
+ if (event.direction !== AcpFrameDirection.AgentToClient) return null;
19
+ const update = sessionUpdateOf(event);
20
+ if (update?.sessionUpdate !== "state_update" || update.state !== "idle") return null;
21
+ return { stopReason: update.stopReason ?? null };
22
+ };
23
+ const isUserMessageFor = (event, messageId) => {
24
+ const update = sessionUpdateOf(event);
25
+ return update != null && (update.sessionUpdate === "user_message" || update.sessionUpdate === "user_message_chunk") && update.messageId === messageId;
26
+ };
27
+ const createTextCollector = () => {
28
+ const order = [];
29
+ const byMessage = /* @__PURE__ */ new Map();
30
+ const add = (event) => {
31
+ const update = sessionUpdateOf(event);
32
+ if (update == null) return;
33
+ const chunk = update.sessionUpdate === "agent_message_chunk";
34
+ if (!chunk && update.sessionUpdate !== "agent_message") return;
35
+ if (!chunk && update.content == null) return;
36
+ const key = update.messageId ?? "";
37
+ if (!byMessage.has(key)) order.push(key);
38
+ byMessage.set(key, chunk ? `${byMessage.get(key) ?? ""}${textOf(update)}` : textOf(update));
39
+ };
40
+ return { add, text: () => order.map((key) => byMessage.get(key) ?? "").join("") };
41
+ };
42
+ export {
43
+ createTextCollector,
44
+ isUserMessageFor,
45
+ sessionUpdateOf,
46
+ textOf,
47
+ turnEndOf
48
+ };
49
+ //# sourceMappingURL=acp-frames.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/acp-frames.ts"],
4
+ "sourcesContent": ["import {\n AcpFrameDirection,\n acpSessionUpdateParamsSchema,\n type AcpFrameEventIface,\n type AcpSessionUpdateParamsIface,\n} from '@finalai/agent-protocol/agent-platform';\n\nexport type AcpSessionUpdateIface = AcpSessionUpdateParamsIface['update'];\n\nconst SESSION_UPDATE = 'session/update';\n\n/** The `session/update` payload of an agent frame, or null for any other frame. */\nexport const sessionUpdateOf = (event: AcpFrameEventIface): AcpSessionUpdateIface | null => {\n if (event.frame.method !== SESSION_UPDATE) return null;\n const parsed = acpSessionUpdateParamsSchema.safeParse(event.frame.params);\n return parsed.success ? parsed.data.update : null;\n};\n\n/** Text carried by an `agent_message_chunk` / `agent_message` update. */\nexport const textOf = (update: AcpSessionUpdateIface): string => {\n const content = update.content;\n if (content == null) return '';\n const blocks = Array.isArray(content) ? content : [content];\n return blocks.map((block) => (block.type === 'text' ? (block.text ?? '') : '')).join('');\n};\n\nexport interface TurnEndIface {\n stopReason: string | null;\n}\n\n/** A `state_update` to `idle` ends the turn (ACP v2); returns its stop reason. */\nexport const turnEndOf = (event: AcpFrameEventIface): TurnEndIface | null => {\n if (event.direction !== AcpFrameDirection.AgentToClient) return null;\n const update = sessionUpdateOf(event);\n if (update?.sessionUpdate !== 'state_update' || update.state !== 'idle') return null;\n return { stopReason: update.stopReason ?? null };\n};\n\n/** Whether the frame is the user-message update ACP emits for the accepted prompt `messageId`. */\nexport const isUserMessageFor = (event: AcpFrameEventIface, messageId: string): boolean => {\n const update = sessionUpdateOf(event);\n return (\n update != null &&\n (update.sessionUpdate === 'user_message' || update.sessionUpdate === 'user_message_chunk') &&\n update.messageId === messageId\n );\n};\n\nexport interface TextCollectorIface {\n add: (event: AcpFrameEventIface) => void;\n text: () => string;\n}\n\n/** Accumulates visible agent text across chunks and full messages, per message id. */\nexport const createTextCollector = (): TextCollectorIface => {\n const order: string[] = [];\n const byMessage = new Map<string, string>();\n const add = (event: AcpFrameEventIface): void => {\n const update = sessionUpdateOf(event);\n if (update == null) return;\n const chunk = update.sessionUpdate === 'agent_message_chunk';\n if (!chunk && update.sessionUpdate !== 'agent_message') return;\n if (!chunk && update.content == null) return;\n const key = update.messageId ?? '';\n if (!byMessage.has(key)) order.push(key);\n byMessage.set(key, chunk ? `${byMessage.get(key) ?? ''}${textOf(update)}` : textOf(update));\n };\n return { add, text: () => order.map((key) => byMessage.get(key) ?? '').join('') };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAIP,MAAM,iBAAiB;AAGhB,MAAM,kBAAkB,CAAC,UAA4D;AAC1F,MAAI,MAAM,MAAM,WAAW,eAAgB,QAAO;AAClD,QAAM,SAAS,6BAA6B,UAAU,MAAM,MAAM,MAAM;AACxE,SAAO,OAAO,UAAU,OAAO,KAAK,SAAS;AAC/C;AAGO,MAAM,SAAS,CAAC,WAA0C;AAC/D,QAAM,UAAU,OAAO;AACvB,MAAI,WAAW,KAAM,QAAO;AAC5B,QA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ientConnection } from '@agentclientprotocol/sdk/experimental/v2';
2
+ import type { WebSocketConstructor } from '@agentclientprotocol/sdk/experimental/ws-client';
3
+ import type { SignalOptionsIface } from "./context.mjs";
4
+ import { type CreateHttpOptionsIface, type HttpIface } from "./http.mjs";
5
+ /** How the WebSocket upgrade authenticates. */
6
+ export declare enum AcpAuthMode {
7
+ /** The client's authorization header (Node and other runtimes that can set headers). */
8
+ Headers = "headers",
9
+ /**
10
+ * A single-use ticket minted over HTTP (`POST /v1/acp/tickets`) and offered
11
+ * as a subprotocol: for browsers, whose WebSocket cannot send headers.
12
+ */
13
+ Ticket = "ticket"
14
+ }
15
+ export interface AcpConnectArgsIface extends SignalOptionsIface {
16
+ /** Agent slug or id; may instead be given in `session/new` `_meta`. */
17
+ agent?: string;
18
+ /** The ClientApp to connect; defaults to an app with no handlers. */
19
+ app?: ClientApp;
20
+ /** WebSocket constructor for Node (for example `ws.WebSocket`); browsers use the global. */
21
+ WebSocket?: WebSocketConstructor;
22
+ /** Defaults to `Ticket` for cookie-authenticated (browser) clients, `Headers` otherwise. */
23
+ authMode?: AcpAuthMode;
24
+ }
25
+ export interface AcpApiIface {
26
+ connect: (args?: AcpConnectArgsIface) => Promise<ClientConnection>;
27
+ }
28
+ export declare const acpWebSocketUrl: (args: {
29
+ host: URL;
30
+ agent?: string;
31
+ endpoint?: string;
32
+ }) => string;
33
+ export interface AcpTransportIface {
34
+ url: string;
35
+ headers: Record<string, string>;
36
+ protocols: string[] | undefined;
37
+ }
38
+ /** Where and how `connect` opens the socket; exported for tests. */
39
+ export declare const resolveAcpTransport: (http: HttpIface, args: AcpConnectArgsIface | undefined) => Promise<AcpTransportIface>;
40
+ export declare const createAcpApi: (context: {
41
+ http: HttpIface;
42
+ }) => AcpApiIface;
43
+ export declare const createAcpClient: (options: CreateHttpOptionsIface) => AcpApiIface;
@@ -0,0 +1,76 @@
1
+ import {
2
+ ACP_TICKET_SUBPROTOCOL_PREFIX,
3
+ ACP_WS_SUBPROTOCOL,
4
+ acpTicketRequestSchema,
5
+ acpTicketSchema
6
+ } from "@finalai/agent-protocol/agent-platform";
7
+ import { createHttp, HttpMethod } from "./http.mjs";
8
+ var AcpAuthMode = /* @__PURE__ */ ((AcpAuthMode2) => {
9
+ AcpAuthMode2["Headers"] = "headers";
10
+ AcpAuthMode2["Ticket"] = "ticket";
11
+ return AcpAuthMode2;
12
+ })(AcpAuthMode || {});
13
+ const acpWebSocketUrl = (args) => {
14
+ const url = args.endpoint == null ? new URL("/acp/ws", args.host) : new URL(args.endpoint);
15
+ url.protocol = url.protocol === "http:" || url.protocol === "ws:" ? "ws:" : "wss:";
16
+ if (args.agent != null) url.searchParams.set("agent", args.agent);
17
+ return url.toString();
18
+ };
19
+ const resolveAcpTransport = async (http, args) => {
20
+ const mode = args?.authMode ?? (http.usesCookies ? "ticket" /* Ticket */ : "headers" /* Headers */);
21
+ if (mode === "headers" /* Headers */) {
22
+ return {
23
+ url: acpWebSocketUrl({ host: http.url(""), agent: args?.agent }),
24
+ headers: await http.headers(),
25
+ protocols: void 0
26
+ };
27
+ }
28
+ const ticket = await http.request({
29
+ method: HttpMethod.Post,
30
+ path: "/v1/acp/tickets",
31
+ body: { schema: acpTicketRequestSchema, value: { agent: args?.agent } },
32
+ response: acpTicketSchema,
33
+ signal: args?.signal
34
+ });
35
+ return {
36
+ url: acpWebSocketUrl({
37
+ host: http.url(""),
38
+ agent: args?.agent,
39
+ endpoint: ticket.url ?? void 0
40
+ }),
41
+ headers: {},
42
+ protocols: [ACP_WS_SUBPROTOCOL, `${ACP_TICKET_SUBPROTOCOL_PREFIX}${ticket.ticket}`]
43
+ };
44
+ };
45
+ const createAcpApi = (context) => ({
46
+ connect: async (args) => {
47
+ const [{ client }, { createWebSocketStream }] = await Promise.all([
48
+ import("@agentclientprotocol/sdk/experimental/v2"),
49
+ import("@agentclientprotocol/sdk/experimental/ws-client")
50
+ ]);
51
+ const transport = await resolveAcpTransport(context.http, args);
52
+ const stream = createWebSocketStream(transport.url, {
53
+ headers: transport.headers,
54
+ protocols: transport.protocols,
55
+ // The ticket is the credential; the session service has no cookie auth.
56
+ cookies: "omit",
57
+ WebSocket: args?.WebSocket
58
+ });
59
+ const connection = (args?.app ?? client({ name: "@finalai/agents" })).connect(stream);
60
+ const signal = args?.signal;
61
+ if (signal != null) {
62
+ if (signal.aborted) connection.close(signal.reason);
63
+ else signal.addEventListener("abort", () => connection.close(signal.reason), { once: true });
64
+ }
65
+ return connection;
66
+ }
67
+ });
68
+ const createAcpClient = (options) => createAcpApi({ http: createHttp(options) });
69
+ export {
70
+ AcpAuthMode,
71
+ acpWebSocketUrl,
72
+ createAcpApi,
73
+ createAcpClient,
74
+ resolveAcpTransport
75
+ };
76
+ //# sourceMappingURL=acp.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/acp.ts"],
4
+ "sourcesContent": ["import type {\n AnyWireMessage,\n ClientApp,\n ClientConnection,\n} from '@agentclientprotocol/sdk/experimental/v2';\nimport type { WebSocketConstructor } from '@agentclientprotocol/sdk/experimental/ws-client';\nimport {\n ACP_TICKET_SUBPROTOCOL_PREFIX,\n ACP_WS_SUBPROTOCOL,\n acpTicketRequestSchema,\n acpTicketSchema,\n} from '@finalai/agent-protocol/agent-platform';\nimport type { SignalOptionsIface } from \"./context.mjs\";\nimport { createHttp, HttpMethod, type CreateHttpOptionsIface, type HttpIface } from \"./http.mjs\";\n\n// ACP-native access: the session service serves a standard ACP v2 agent at\n// `/acp/ws`. Callers bring a ClientApp with their handlers (session updates,\n// permission requests); `?agent=` is the agent a plain `session/new` opens,\n// and `_meta[\"final.ai\"].agent` names one per session.\n\n/** How the WebSocket upgrade authenticates. */\nexport enum AcpAuthMode {\n /** The client's authorization header (Node and other runtimes that can set headers). */\n Headers = 'headers',\n /**\n * A single-use ticket minted over HTTP (`POST /v1/acp/tickets`) and offered\n * as a subprotocol: for browsers, whose WebSocket cannot send headers.\n */\n Ticket = 'ticket',\n}\n\nexport interface AcpConnectArgsIface extends SignalOptionsIface {\n /** Agent slug or id; may instead be given in `session/new` `_meta`. */\n agent?: string;\n /** The ClientApp to connect; defaults to an app with no handlers. */\n app?: ClientApp;\n /** WebSocket constructor for Node (for example `ws.WebSocket`); browsers use the global. */\n WebSocket?: WebSocketConstructor;\n /** Defaults to `Ticket` for cookie-authenticated (browser) clients, `Headers` otherwise. */\n authMode?: AcpAuthMode;\n}\n\nexport interface AcpApiIface {\n connect: (args?: AcpConnectArgsIface) => Promise<ClientConnection>;\n}\n\nexport const acpWebSocketUrl = (args: { host: URL; agent?: string; endpoint?: string }): string => {\n // ACP is served at the session service's origin, not under the API prefix (a\n // ticket names it, which matters behind console-server's HTTP-only proxy).\n const url = args.endpoint == null ? new URL('/acp/ws', args.host) : new URL(args.endpoint);\n url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';\n if (args.agent != null) url.searchParams.set('agent', args.agent);\n return url.toString();\n};\n\nexport interface AcpTransportIface {\n url: string;\n headers: Record<string, string>;\n protocols: string[] | undefined;\n}\n\n/** Where and how `connect` opens the socket; exported for tests. */\nexport const resolveAcpTransport = async (\n http: HttpIface,\n args: AcpConnectArgsIface | undefined,\n): Promise<AcpTransportIface> => {\n const mode = args?.authMode ?? (http.usesCookies ? AcpAuthMode.Ticket : AcpAuthMode.Headers);\n if (mode === AcpAuthMode.Headers) {\n return {\n url: acpWebSocketUrl({ host: http.url(''), agent: args?.agent }),\n headers: await http.headers(),\n protocols: undefined,\n };\n }\n const ticket = await http.request({\n method: HttpMethod.Post,\n path: '/v1/acp/tickets',\n body: { schema: acpTicketRequestSchema, value: { agent: args?.agent } },\n response: acpTicketSchema,\n signal: args?.signal,\n });\n return {\n url: acpWebSocketUrl({\n host: http.url(''),\n agent: args?.agent,\n endpoint: ticket.url ?? undefined,\n }),\n headers: {},\n protocols: [ACP_WS_SUBPROTOCOL, `${ACP_TICKET_SUBPROTOCOL_PREFIX}${ticket.ticket}`],\n };\n};\n\nexport const createAcpApi = (context: { http: HttpIface }): AcpApiIface => ({\n connect: async (args) => {\n // The ACP SDK loads on first use: bundlers that split code keep it out of\n // HTTP-only pages.\n const [{ client }, { createWebSocketStream }] = await Promise.all([\n import('@agentclientprotocol/sdk/experimental/v2'),\n import('@agentclientprotocol/sdk/experimental/ws-client'),\n ]);\n const transport = await resolveAcpTransport(context.http, args);\n const stream = createWebSocketStream<AnyWireMessage>(transport.url, {\n headers: transport.headers,\n protocols: transport.protocols,\n // The ticket is the credential; the session service has no cookie auth.\n cookies: 'omit',\n WebSocket: args?.WebSocket,\n });\n const connection = (args?.app ?? client({ name: '@finalai/agents' })).connect(stream);\n const signal = args?.signal;\n if (signal != null) {\n if (signal.aborted) connection.close(signal.reason);\n else signal.addEventListener('abort', () => connection.close(signal.reason), { once: true });\n }\n return connection;\n },\n});\n\n// `client.acp` without the rest of the client (`@finalai/agents/client/acp`).\nexport const createAcpClient = (options: CreateHttpOptionsIface): AcpApiIface =>\n createAcpApi({ http: createHttp(options) });\n"],
5
+ "mappings": "AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,YAAY,kBAA+D;AAQ7E,IAAK,cAAL,kBAAKA,iBAAL;AAEL,EAAAA,aAAA,aAAU;AAKV,EAAAA,aAAA,YAAS;AAPC,SAAAA;AAAA,GAAA;AAyBL,MAAM,kBAAkB,CAAC,SAAmE;AAGjG,QAAM,MAAM,KAAK,YAAY,OAAO,IAAI,IAAI,WAAW,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,QAAQ;AACzF,MAAI,WAAW,IAAI,aAAa,WAAW,IAAI,aAAa,QAAQ,QAAQ;AAC5E,MAAI,KAAK,SAAS,KAAM,KAAI,aAAa,IAAI,SAAS,KAAK,KAAK;AAChE,SAAO,IAAI,SAAS;AACtB;AASO,MAAM,sBAAsB,OACjC,MACA,SAC+B;AAC/B,QAAM,OAAO,MAAM,aAAa,KAAK,cAAc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AClB,UAAI,OAAO,QAAS,YAAW,MAAM,OAAO,MAAM;AAAA,UAC7C,QAAO,iBAAiB,SAAS,MAAM,WAAW,MAAM,OAAO,MAAM,GAAG,EAAE,MAAM,KAAK,CAAC;AAAA,IAC7F;AACA,WAAO;AAAA,EACT;AACF;AAGO,MAAM,kBAAkB,CAAC,YAC9B,aAAa,EAAE,MAAM,WAAW,OAAO,EAAE,CAAC;",
6
+ "names": ["AcpAuthMode"]
7
+ }
@@ -0,0 +1,10 @@
1
+ export interface AsyncQueueIface<Value> {
2
+ push: (value: Value) => void;
3
+ end: () => void;
4
+ fail: (cause: unknown) => void;
5
+ readonly closed: () => boolean;
6
+ iterator: AsyncIterableIterator<Value>;
7
+ }
8
+ export declare const createAsyncQueue: <Value>(cleanup: () => void) => AsyncQueueIface<Value>;
9
+ /** Fails the queue with the signal's reason when it aborts; returns the detach function. */
10
+ export declare const failOnAbort: <Value>(queue: AsyncQueueIface<Value>, signal: AbortSignal | undefined) => (() => void);
@@ -0,0 +1,66 @@
1
+ const DONE = { done: true, value: void 0 };
2
+ const createAsyncQueue = (cleanup) => {
3
+ const values = [];
4
+ const waiters = [];
5
+ let finished = false;
6
+ let failure = null;
7
+ let cleanedUp = false;
8
+ const runCleanup = () => {
9
+ if (cleanedUp) return;
10
+ cleanedUp = true;
11
+ cleanup();
12
+ };
13
+ const push = (value) => {
14
+ if (finished) return;
15
+ const waiter = waiters.shift();
16
+ if (waiter != null) waiter.resolve({ done: false, value });
17
+ else values.push(value);
18
+ };
19
+ const end = () => {
20
+ if (finished) return;
21
+ finished = true;
22
+ for (const waiter of waiters.splice(0)) waiter.resolve(DONE);
23
+ runCleanup();
24
+ };
25
+ const fail = (cause) => {
26
+ if (finished) return;
27
+ finished = true;
28
+ failure = { cause };
29
+ values.length = 0;
30
+ for (const waiter of waiters.splice(0)) waiter.reject(cause);
31
+ runCleanup();
32
+ };
33
+ const iterator = {
34
+ next: () => {
35
+ const value = values.shift();
36
+ if (value !== void 0) return Promise.resolve({ done: false, value });
37
+ if (failure != null) return Promise.reject(failure.cause);
38
+ if (finished) return Promise.resolve(DONE);
39
+ return new Promise((resolve, reject) => waiters.push({ resolve, reject }));
40
+ },
41
+ return: () => {
42
+ values.length = 0;
43
+ end();
44
+ return Promise.resolve(DONE);
45
+ },
46
+ [Symbol.asyncIterator]: () => iterator
47
+ };
48
+ return { push, end, fail, closed: () => finished, iterator };
49
+ };
50
+ const failOnAbort = (queue, signal) => {
51
+ if (signal == null) return () => {
52
+ };
53
+ if (signal.aborted) {
54
+ queue.fail(signal.reason);
55
+ return () => {
56
+ };
57
+ }
58
+ const onAbort = () => queue.fail(signal.reason);
59
+ signal.addEventListener("abort", onAbort, { once: true });
60
+ return () => signal.removeEventListener("abort", onAbort);
61
+ };
62
+ export {
63
+ createAsyncQueue,
64
+ failOnAbort
65
+ };
66
+ //# sourceMappingURL=async-queue.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/agent-client/async-queue.ts"],
4
+ "sourcesContent": ["// A push-to-pull bridge: producers push values, one consumer iterates them.\n// `cleanup` runs once, when the producer ends or fails or the consumer stops\n// (break, return, abort).\n\nexport interface AsyncQueueIface<Value> {\n push: (value: Value) => void;\n end: () => void;\n fail: (cause: unknown) => void;\n readonly closed: () => boolean;\n iterator: AsyncIterableIterator<Value>;\n}\n\ninterface WaiterIface<Value> {\n resolve: (result: IteratorResult<Value, undefined>) => void;\n reject: (cause: unknown) => void;\n}\n\nconst DONE = { done: true, value: undefined } as const;\n\nexport const createAsyncQueue = <Value>(cleanup: () => void): AsyncQueueIface<Value> => {\n const values: Value[] = [];\n const waiters: WaiterIface<Value>[] = [];\n let finished = false;\n let failure: { cause: unknown } | null = null;\n let cleanedUp = false;\n\n const runCleanup = (): void => {\n if (cleanedUp) return;\n cleanedUp = true;\n cleanup();\n };\n\n const push = (value: Value): void => {\n if (finished) return;\n const waiter = waiters.shift();\n if (waiter != null) waiter.resolve({ done: false, value });\n else values.push(value);\n };\n\n const end = (): void => {\n if (finished) return;\n finished = true;\n for (const waiter of waiters.splice(0)) waiter.resolve(DONE);\n runCleanup();\n };\n\n const fail = (cause: unknown): void => {\n if (finished) return;\n finished = true;\n failure = { cause };\n values.length = 0;\n for (const waiter of waiters.splice(0)) waiter.reject(cause);\n runCleanup();\n };\n\n const iterator: AsyncIterableIterator<Value> = {\n next: (): Promise<IteratorResult<Value, undefined>> => {\n const value = values.shift();\n if (value !== undefined) return Promise.resolve({ done: false, value });\n if (failure != null) return Promise.reject(failure.cause);\n if (finished) return Promise.resolve(DONE);\n return new Promise((resolve, reject) => waiters.push({ resolve, reject }));\n },\n return: (): Promise<IteratorResult<Value, undefined>> => {\n values.length = 0;\n end();\n return Promise.resolve(DONE);\n },\n [Symbol.asyncIterator]: () => iterator,\n };\n\n return { push, end, fail, closed: () => finished, iterator };\n};\n\n/** Fails the queue with the signal's reason when it aborts; returns the detach function. */\nexport const failOnAbort = <Value>(\n queue: AsyncQueueIface<Value>,\n signal: AbortSignal | undefined,\n): (() => void) => {\n if (signal == null) return () => {};\n if (signal.aborted) {\n queue.fail(signal.reason);\n return () => {};\n }\n const onAbort = (): void => queue.fail(signal.reason);\n signal.addEventListener('abort', onAbort, { once: true });\n return () => signal.removeEventListener('abort', onAbort);\n};\n"],
5
+ "mappings": "AAiBA,MAAM,OAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAErC,MAAM,mBAAmB,CAAQ,YAAgD;AACtF,QAAM,SAAkB,CAAC;AACzB,QAAM,UAAgC,CAAC;AACvC,MAAI,WAAW;AACf,MAAI,UAAqC;AACzC,MAAI,YAAY;AAEhB,QAAM,aAAa,MAAY;AAC7B,QAAI,UAAW;AACf,gBAAY;AACZ,YAAQ;AAAA,EACV;AAEA,QAAM,OAAO,CAAC,UAAuB;AACnC,QAAI,SAAU;AACd,UAAM,SAAS,QAAQ,MAAM;AAC7B,QAAI,UAAU,KAAM,QAAO,QAAQ,EAAE,MAAM,OAAO,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CAAC;AACxD,SAAO,MAAM,OAAO,oBAAoB,SAAS,OAAO;AAC1D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,107 @@
1
+ import { type AttachChannelBindingResponseIface, type CommitDefinitionRequestIface, type CommitResultIface, type CompatibilityReportIface, type CompileResultIface, type ComputerSetupGuideDetailIface, type ComputerSetupGuideIface, type ComputerSetupGuideVersionIface, type CreateDefinitionRequestIface, type CredentialPolicyPreviewIface, type DefinitionChannelIface, type DefinitionCloneUrlIface, type DefinitionFilesIface, type DefinitionIface, type PreviewCredentialPolicyRequestIface, type ProviderEntryIface, type PublishComputerSetupGuideRequestIface, type PublishResultIface, type RevisionDiffIface, type RevisionIface, type ScheduleIface, type ScheduleRunResultIface, type UpdateScheduleRequestIface } from '@finalai/agent-protocol/agent-platform';
2
+ import { type ClientContextIface, type SignalOptionsIface } from "./context.mjs";
3
+ export interface DefinitionRefIface extends SignalOptionsIface {
4
+ /** Definition id or slug. */
5
+ definition: string;
6
+ }
7
+ export interface DefinitionsApiIface {
8
+ /** Compiles a draft into an immutable test snapshot without publishing or activating schedules/channels. */
9
+ testRevision: (args: DefinitionRefIface & {
10
+ ref: string;
11
+ }) => Promise<RevisionIface>;
12
+ previewCredentialPolicy: (args: DefinitionRefIface & PreviewCredentialPolicyRequestIface) => Promise<CredentialPolicyPreviewIface>;
13
+ list: (options?: SignalOptionsIface & {
14
+ cursor?: string;
15
+ limit?: number;
16
+ }) => Promise<{
17
+ definitions: DefinitionIface[];
18
+ nextCursor: string | null;
19
+ }>;
20
+ create: (args: CreateDefinitionRequestIface & SignalOptionsIface) => Promise<DefinitionIface>;
21
+ get: (args: DefinitionRefIface) => Promise<DefinitionIface>;
22
+ /** Compiles the directory at `ref` server-side without publishing. */
23
+ compile: (args: DefinitionRefIface & {
24
+ ref: string;
25
+ harness?: string;
26
+ }) => Promise<CompileResultIface>;
27
+ commit: (args: DefinitionRefIface & CommitDefinitionRequestIface) => Promise<CommitResultIface>;
28
+ /** Compiles `ref`, stores a revision and makes it current. */
29
+ publish: (args: DefinitionRefIface & {
30
+ ref: string;
31
+ note?: string;
32
+ }) => Promise<PublishResultIface>;
33
+ /** The agent directory's files at `ref` (default branch when omitted). */
34
+ files: (args: DefinitionRefIface & {
35
+ ref?: string;
36
+ }) => Promise<DefinitionFilesIface>;
37
+ revisions: (args: DefinitionRefIface & {
38
+ cursor?: string;
39
+ }) => Promise<{
40
+ revisions: RevisionIface[];
41
+ nextCursor: string | null;
42
+ }>;
43
+ /**
44
+ * What changed in the compiled manifest between two revisions (revision ids
45
+ * or numbers); `to` defaults to the current revision.
46
+ */
47
+ revisionDiff: (args: DefinitionRefIface & {
48
+ from: string | number;
49
+ to?: string | number;
50
+ }) => Promise<RevisionDiffIface>;
51
+ compatibility: (args: DefinitionRefIface & {
52
+ harness: string;
53
+ ref?: string;
54
+ }) => Promise<CompatibilityReportIface>;
55
+ /** The agent's live channel bindings, with the conversation each is attached to. */
56
+ channels: (args: DefinitionRefIface) => Promise<DefinitionChannelIface[]>;
57
+ /**
58
+ * Attaches a channel binding to a conversation the agent and the caller take
59
+ * part in (its events and bound-conversation schedules post there); null detaches.
60
+ */
61
+ attachChannel: (args: DefinitionRefIface & {
62
+ bindingId: string;
63
+ conversationId: string | null;
64
+ }) => Promise<AttachChannelBindingResponseIface>;
65
+ /**
66
+ * Archives the definition: it leaves listings, its schedules and channel
67
+ * bindings stop, and new sessions are refused. Its repository is kept.
68
+ */
69
+ archive: (args: DefinitionRefIface) => Promise<DefinitionIface>;
70
+ /**
71
+ * A short-lived, read-only git remote for a Final-hosted repository, for
72
+ * `git clone` (owners of personal agents, organization admins otherwise).
73
+ */
74
+ cloneUrl: (args: DefinitionRefIface) => Promise<DefinitionCloneUrlIface>;
75
+ }
76
+ export interface ProvidersApiIface {
77
+ list: (options?: SignalOptionsIface) => Promise<ProviderEntryIface[]>;
78
+ }
79
+ export interface ComputerSetupGuidesApiIface {
80
+ list: (options?: SignalOptionsIface) => Promise<ComputerSetupGuideIface[]>;
81
+ /** Guide by slug or id, with its versions. */
82
+ get: (ref: string, options?: SignalOptionsIface) => Promise<ComputerSetupGuideDetailIface>;
83
+ /** Publishes a new version (creating the guide on first publish). */
84
+ publish: (args: PublishComputerSetupGuideRequestIface & SignalOptionsIface) => Promise<{
85
+ guide: ComputerSetupGuideIface;
86
+ version: ComputerSetupGuideVersionIface;
87
+ }>;
88
+ }
89
+ export type ScheduleRef = {
90
+ scheduleId: string;
91
+ } | {
92
+ agent: string;
93
+ key: string;
94
+ };
95
+ export interface SchedulesApiIface {
96
+ list: (options?: SignalOptionsIface & {
97
+ agent?: string;
98
+ }) => Promise<ScheduleIface[]>;
99
+ runNow: (args: ScheduleRef & SignalOptionsIface) => Promise<ScheduleRunResultIface>;
100
+ update: (args: {
101
+ scheduleId: string;
102
+ } & UpdateScheduleRequestIface & SignalOptionsIface) => Promise<ScheduleIface>;
103
+ }
104
+ export declare const createDefinitionsApi: ({ http }: ClientContextIface) => DefinitionsApiIface;
105
+ export declare const createProvidersApi: ({ http }: ClientContextIface) => ProvidersApiIface;
106
+ export declare const createComputerSetupGuidesApi: ({ http, }: ClientContextIface) => ComputerSetupGuidesApiIface;
107
+ export declare const createSchedulesApi: ({ http }: ClientContextIface) => SchedulesApiIface;