@finalai/agents 0.11.0 → 0.12.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.
Files changed (185) hide show
  1. package/HOSTING.md +334 -245
  2. package/README.md +214 -29
  3. package/dist/modules/agent-client/agent-input.d.mts +24 -0
  4. package/dist/modules/agent-client/agent-input.mjs +46 -0
  5. package/dist/modules/agent-client/agent-input.mjs.map +7 -0
  6. package/dist/modules/agent-client/channels.d.mts +52 -3
  7. package/dist/modules/agent-client/channels.mjs +71 -10
  8. package/dist/modules/agent-client/channels.mjs.map +2 -2
  9. package/dist/modules/agent-client/client.d.mts +85 -20
  10. package/dist/modules/agent-client/client.mjs +74 -21
  11. package/dist/modules/agent-client/client.mjs.map +2 -2
  12. package/dist/modules/agent-client/config-options.mjs +1 -2
  13. package/dist/modules/agent-client/config-options.mjs.map +2 -2
  14. package/dist/modules/agent-client/conversation-resources.d.mts +85 -0
  15. package/dist/modules/agent-client/conversation-resources.mjs +150 -0
  16. package/dist/modules/agent-client/conversation-resources.mjs.map +7 -0
  17. package/dist/modules/agent-client/conversations.d.mts +116 -38
  18. package/dist/modules/agent-client/conversations.mjs +379 -71
  19. package/dist/modules/agent-client/conversations.mjs.map +2 -2
  20. package/dist/modules/agent-client/defaults.d.mts +8 -0
  21. package/dist/modules/agent-client/defaults.mjs +77 -0
  22. package/dist/modules/agent-client/defaults.mjs.map +7 -0
  23. package/dist/modules/agent-client/errors.d.mts +22 -2
  24. package/dist/modules/agent-client/errors.mjs +19 -0
  25. package/dist/modules/agent-client/errors.mjs.map +2 -2
  26. package/dist/modules/agent-client/events.d.mts +62 -0
  27. package/dist/modules/agent-client/events.mjs +107 -0
  28. package/dist/modules/agent-client/events.mjs.map +7 -0
  29. package/dist/modules/agent-client/harnesses.d.mts +66 -0
  30. package/dist/modules/agent-client/harnesses.mjs +156 -0
  31. package/dist/modules/agent-client/harnesses.mjs.map +7 -0
  32. package/dist/modules/agent-client/http.d.mts +2 -1
  33. package/dist/modules/agent-client/http.mjs +21 -2
  34. package/dist/modules/agent-client/http.mjs.map +2 -2
  35. package/dist/modules/agent-client/index.d.mts +21 -6
  36. package/dist/modules/agent-client/index.mjs +26 -0
  37. package/dist/modules/agent-client/index.mjs.map +2 -2
  38. package/dist/modules/agent-client/integrations.d.mts +40 -0
  39. package/dist/modules/agent-client/integrations.mjs +92 -0
  40. package/dist/modules/agent-client/integrations.mjs.map +7 -0
  41. package/dist/modules/agent-client/local-host-protocol.d.mts +156 -0
  42. package/dist/modules/agent-client/local-host-protocol.mjs +258 -0
  43. package/dist/modules/agent-client/local-host-protocol.mjs.map +7 -0
  44. package/dist/modules/agent-client/local-host.d.mts +56 -0
  45. package/dist/modules/agent-client/local-host.mjs +200 -0
  46. package/dist/modules/agent-client/local-host.mjs.map +7 -0
  47. package/dist/modules/agent-client/oauth-clients.d.mts +36 -0
  48. package/dist/modules/agent-client/oauth-clients.mjs +67 -0
  49. package/dist/modules/agent-client/oauth-clients.mjs.map +7 -0
  50. package/dist/modules/agent-client/project-agents.d.mts +54 -0
  51. package/dist/modules/agent-client/project-agents.mjs +111 -0
  52. package/dist/modules/agent-client/project-agents.mjs.map +7 -0
  53. package/dist/modules/agent-client/project.d.mts +43 -0
  54. package/dist/modules/agent-client/project.mjs +66 -0
  55. package/dist/modules/agent-client/project.mjs.map +7 -0
  56. package/dist/modules/agent-client/projects.d.mts +61 -0
  57. package/dist/modules/agent-client/projects.mjs +145 -0
  58. package/dist/modules/agent-client/projects.mjs.map +7 -0
  59. package/dist/modules/agent-client/provide.d.mts +41 -0
  60. package/dist/modules/agent-client/provide.mjs +90 -0
  61. package/dist/modules/agent-client/provide.mjs.map +7 -0
  62. package/dist/modules/agent-client/publishers.d.mts +57 -0
  63. package/dist/modules/agent-client/publishers.mjs +109 -0
  64. package/dist/modules/agent-client/publishers.mjs.map +7 -0
  65. package/dist/modules/agent-client/requirements.d.mts +60 -0
  66. package/dist/modules/agent-client/requirements.mjs +83 -0
  67. package/dist/modules/agent-client/requirements.mjs.map +7 -0
  68. package/dist/modules/agent-client/sandbox-providers.d.mts +34 -0
  69. package/dist/modules/agent-client/sandbox-providers.mjs +75 -0
  70. package/dist/modules/agent-client/sandbox-providers.mjs.map +7 -0
  71. package/dist/modules/agent-client/sandbox-uri.d.mts +1 -1
  72. package/dist/modules/agent-client/sandbox-uri.mjs +4 -4
  73. package/dist/modules/agent-client/sandbox-uri.mjs.map +1 -1
  74. package/dist/modules/agent-client/sandboxes.d.mts +65 -0
  75. package/dist/modules/agent-client/sandboxes.mjs +130 -0
  76. package/dist/modules/agent-client/sandboxes.mjs.map +7 -0
  77. package/dist/modules/agent-client/schedules.d.mts +24 -0
  78. package/dist/modules/agent-client/schedules.mjs +56 -0
  79. package/dist/modules/agent-client/schedules.mjs.map +7 -0
  80. package/dist/modules/agent-client/sessions.d.mts +46 -8
  81. package/dist/modules/agent-client/sessions.mjs +91 -29
  82. package/dist/modules/agent-client/sessions.mjs.map +2 -2
  83. package/dist/modules/agent-client/start.d.mts +101 -0
  84. package/dist/modules/agent-client/start.mjs +260 -0
  85. package/dist/modules/agent-client/start.mjs.map +7 -0
  86. package/dist/modules/agent-client/test-fakes.d.mts +1 -0
  87. package/dist/modules/agent-client/test-fakes.mjs +3 -1
  88. package/dist/modules/agent-client/test-fakes.mjs.map +2 -2
  89. package/dist/modules/cli/agent-module.d.mts +39 -0
  90. package/dist/modules/cli/agent-module.mjs +89 -0
  91. package/dist/modules/cli/agent-module.mjs.map +7 -0
  92. package/dist/modules/cli/cli.d.mts +6 -6
  93. package/dist/modules/cli/cli.mjs +94 -120
  94. package/dist/modules/cli/cli.mjs.map +2 -2
  95. package/dist/modules/cli/conformance.d.mts +2 -6
  96. package/dist/modules/cli/conformance.mjs +5 -8
  97. package/dist/modules/cli/conformance.mjs.map +2 -2
  98. package/dist/modules/cli/main.mjs.map +1 -1
  99. package/dist/modules/cli/output.d.mts +0 -9
  100. package/dist/modules/cli/output.mjs +7 -85
  101. package/dist/modules/cli/output.mjs.map +2 -2
  102. package/dist/modules/harnesses.mjs.map +2 -2
  103. package/dist/modules/index.d.mts +0 -2
  104. package/dist/modules/index.mjs +0 -4
  105. package/dist/modules/index.mjs.map +2 -2
  106. package/dist/modules/integrations.d.mts +24 -0
  107. package/dist/modules/integrations.mjs +30 -0
  108. package/dist/modules/integrations.mjs.map +7 -0
  109. package/dist/modules/public.d.mts +10 -10
  110. package/dist/modules/public.mjs +29 -78
  111. package/dist/modules/public.mjs.map +2 -2
  112. package/dist/modules/sandboxes.d.mts +2 -0
  113. package/dist/modules/sandboxes.mjs +4 -0
  114. package/dist/modules/sandboxes.mjs.map +2 -2
  115. package/dist/modules/verify.d.mts +1 -0
  116. package/dist/modules/verify.mjs +2 -0
  117. package/dist/modules/verify.mjs.map +7 -0
  118. package/dist/modules/webhooks.d.mts +37 -0
  119. package/dist/modules/webhooks.mjs +100 -0
  120. package/dist/modules/webhooks.mjs.map +7 -0
  121. package/examples/release-scout/README.md +18 -10
  122. package/examples/release-scout/agent.ts +41 -0
  123. package/examples/release-scout/by-name.ts +43 -0
  124. package/examples/release-scout/db.ts +6 -0
  125. package/examples/release-scout/instructions.md +5 -0
  126. package/examples/release-scout/run-on-a-computer.ts +49 -0
  127. package/examples/release-scout/run.ts +38 -0
  128. package/package.json +42 -28
  129. package/dist/modules/agent-client/build.d.mts +0 -110
  130. package/dist/modules/agent-client/build.mjs +0 -213
  131. package/dist/modules/agent-client/build.mjs.map +0 -7
  132. package/dist/modules/authoring/index.d.mts +0 -1
  133. package/dist/modules/authoring/index.mjs +0 -2
  134. package/dist/modules/authoring/index.mjs.map +0 -7
  135. package/dist/modules/authoring/instructions.d.mts +0 -1
  136. package/dist/modules/authoring/instructions.mjs +0 -2
  137. package/dist/modules/authoring/instructions.mjs.map +0 -7
  138. package/dist/modules/authoring/providers.d.mts +0 -2
  139. package/dist/modules/authoring/providers.mjs +0 -1
  140. package/dist/modules/authoring/providers.mjs.map +0 -7
  141. package/dist/modules/cli/build.d.mts +0 -22
  142. package/dist/modules/cli/build.mjs +0 -77
  143. package/dist/modules/cli/build.mjs.map +0 -7
  144. package/dist/modules/cli/channel-install.d.mts +0 -12
  145. package/dist/modules/cli/channel-install.mjs +0 -25
  146. package/dist/modules/cli/channel-install.mjs.map +0 -7
  147. package/dist/modules/cli/channel-socket.d.mts +0 -9
  148. package/dist/modules/cli/channel-socket.mjs +0 -114
  149. package/dist/modules/cli/channel-socket.mjs.map +0 -7
  150. package/dist/modules/cli/dev.d.mts +0 -26
  151. package/dist/modules/cli/dev.mjs +0 -311
  152. package/dist/modules/cli/dev.mjs.map +0 -7
  153. package/dist/modules/cli/files.d.mts +0 -18
  154. package/dist/modules/cli/files.mjs +0 -66
  155. package/dist/modules/cli/files.mjs.map +0 -7
  156. package/dist/modules/cli/harness-descriptions.d.mts +0 -20
  157. package/dist/modules/cli/harness-descriptions.mjs +0 -70
  158. package/dist/modules/cli/harness-descriptions.mjs.map +0 -7
  159. package/dist/modules/cli/publish.d.mts +0 -15
  160. package/dist/modules/cli/publish.mjs +0 -92
  161. package/dist/modules/cli/publish.mjs.map +0 -7
  162. package/dist/modules/compile.d.mts +0 -3
  163. package/dist/modules/compile.mjs +0 -58
  164. package/dist/modules/compile.mjs.map +0 -7
  165. package/dist/modules/index.browser.d.mts +0 -4
  166. package/dist/modules/index.browser.mjs +0 -8
  167. package/dist/modules/index.browser.mjs.map +0 -7
  168. package/examples/custom-harness/README.md +0 -16
  169. package/examples/custom-harness/agent.ts +0 -154
  170. package/examples/custom-sandbox/README.md +0 -12
  171. package/examples/custom-sandbox/agent.ts +0 -14
  172. package/examples/custom-sandbox/sandbox.ts +0 -24
  173. package/examples/release-scout/agent/agent.ts +0 -22
  174. package/examples/release-scout/agent/channels/github-signature.ts +0 -27
  175. package/examples/release-scout/agent/channels/github.ts +0 -32
  176. package/examples/release-scout/agent/connections/linear.ts +0 -9
  177. package/examples/release-scout/agent/hooks/audit.ts +0 -24
  178. package/examples/release-scout/agent/instructions/org-context.ts +0 -26
  179. package/examples/release-scout/agent/instructions.md +0 -2
  180. package/examples/release-scout/agent/sandbox.ts +0 -20
  181. package/examples/release-scout/agent/schedules/daily-digest.md +0 -7
  182. package/examples/release-scout/agent/skills/triage/SKILL.md +0 -8
  183. package/examples/release-scout/agent/skills/triage/checklist.md +0 -3
  184. package/examples/release-scout/agent/tools/lookup_release_notes.ts +0 -24
  185. package/examples/release-scout/client.ts +0 -122
@@ -1,60 +1,42 @@
1
- import { resolve } from "node:path";
2
1
  import { parseArgs } from "node:util";
2
+ import { documentOf } from "@finalai/agent-definition";
3
3
  import * as z from "zod";
4
- import { createClient } from "../agent-client/client.mjs";
5
- import { runChannelInstall } from "./channel-install.mjs";
6
- import { runBuild } from "./build.mjs";
4
+ import { createClient, DEFAULT_AGENTS_HOST } from "../agent-client/client.mjs";
5
+ import { DefinitionKind, loadDefinitionModule } from "./agent-module.mjs";
7
6
  import { runConformance } from "./conformance.mjs";
8
- import { DEFAULT_DEV_PORT, runDev } from "./dev.mjs";
9
- import { gitListFiles } from "./files.mjs";
10
- import { runPublish } from "./publish.mjs";
11
- const DEFAULT_AGENTS_HOST = "https://agent-session.final.ai/api";
12
- const DEFAULT_COMMIT_MESSAGE = "Publish with final agents publish";
7
+ import { errorLines } from "./output.mjs";
13
8
  const USAGE = [
14
9
  "usage: final-agents <command> [options]",
15
10
  "",
16
11
  "commands:",
17
- " build [dir] compile the agent directory and report on its harness",
18
- " dev [dir] serve its channel routes at http://localhost:<port>/<channel><path>",
19
- " publish [dir] --agent <slug> commit the checkout to the agent and publish it",
20
- " channel install <key> --revision <id> --project <id> --install <id> [--replace] install or explicitly update a published channel",
12
+ " print <module> write the document of the agent, harness or ACP adapter",
13
+ " the module exports, as JSON",
14
+ " publish <module> --name <name> store it and point <name> at it in a project",
21
15
  " conformance <module> run the harness conformance kit against a harness the module exports",
22
16
  "",
23
17
  "options:",
24
- " --host <url> agent platform API (overrides FINAL_API_HOST; default " + DEFAULT_AGENTS_HOST + ")",
25
- " --agent <slug> publish: the agent definition (slug or id)",
26
- " --ref <ref> publish: the ref to publish (GitHub-backed agents)",
27
- " --message <text> publish: commit message",
28
- " --note <text> publish: revision note",
29
- " --no-activate publish: store approved source without changing the live agent",
30
- " --replace channel install: explicitly update the existing binding",
31
- ` --port <port> dev: port to listen on (default ${DEFAULT_DEV_PORT})`,
32
- ' --export <name> conformance: the export to test (default "default"): a HarnessIface or { harness, dial }',
33
- " --profile <name> conformance: final (default) or plain-acp-v2",
18
+ " --export <name> the export to use (print and publish: an agent, a harness or an ACP adapter,",
19
+ " found by itself when omitted;",
20
+ ' conformance: a HarnessIface or { harness, dial }, default "default")',
21
+ " --name <name> publish: the name to point at it",
22
+ " --project <id> publish: the project (overrides FINAL_PROJECT_ID)",
23
+ " --host <url> agents API (overrides FINAL_API_HOST; default " + DEFAULT_AGENTS_HOST + ")",
24
+ " --profile <name> conformance: final (default), final-required (ACP adapters) or plain-acp-v2",
34
25
  " --timeout <ms> conformance: per-case timeout",
35
26
  " --json conformance: print the report as JSON",
36
27
  "",
37
- "FINAL_API_KEY authenticates. build checks compatibility only with it.",
38
- "FINAL_API_HOST selects the deployment for build and publish; it does not rewrite authored URLs.",
39
- `dev reads route secrets from AGENT_LOCAL_SECRETS_JSON ({"name": "value"}), limited to the manifest's secrets.`
28
+ "publish authenticates with FINAL_API_KEY. print calls nothing."
40
29
  ].join("\n");
41
30
  const envSchema = z.object({
42
31
  FINAL_API_KEY: z.string().min(1).optional(),
43
- FINAL_API_HOST: z.string().url().optional()
32
+ FINAL_API_HOST: z.string().url().optional(),
33
+ FINAL_PROJECT_ID: z.string().min(1).optional()
44
34
  });
45
35
  const optionsConfig = {
46
- host: { type: "string" },
47
- agent: { type: "string" },
48
- ref: { type: "string" },
49
- message: { type: "string" },
50
- note: { type: "string" },
51
- "no-activate": { type: "boolean" },
52
- port: { type: "string" },
53
- project: { type: "string" },
54
- install: { type: "string" },
55
- replace: { type: "boolean" },
56
- revision: { type: "string" },
57
36
  export: { type: "string" },
37
+ name: { type: "string" },
38
+ project: { type: "string" },
39
+ host: { type: "string" },
58
40
  profile: { type: "string" },
59
41
  timeout: { type: "string" },
60
42
  json: { type: "boolean" },
@@ -77,101 +59,32 @@ const runAgentsCommand = async (deps) => {
77
59
  return 2;
78
60
  }
79
61
  const { values, positionals } = parsedArgs.parsed;
80
- const [command, dirArg, ...extra] = positionals;
62
+ const [command, moduleArg, ...extra] = positionals;
81
63
  if (values.help === true || command == null || command === "help") {
82
64
  (command == null && values.help !== true ? output.stderr : output.stdout)(USAGE);
83
65
  return command == null && values.help !== true ? 2 : 0;
84
66
  }
85
- if (extra.length > 0 && !(command === "channel" && dirArg === "install" && extra.length === 1)) {
67
+ if (extra.length > 0) {
86
68
  output.stderr(`error: unexpected arguments: ${extra.join(" ")}`);
87
69
  return 2;
88
70
  }
89
- const env = envSchema.safeParse(deps.env);
90
- if (!env.success) {
91
- output.stderr(
92
- "error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL"
93
- );
71
+ if (command !== "print" && command !== "publish" && command !== "conformance") {
72
+ output.stderr(`error: unknown command ${command}`);
73
+ output.stderr(USAGE);
94
74
  return 2;
95
75
  }
96
- const apiKey = env.success ? env.data.FINAL_API_KEY ?? null : null;
97
- const dir = resolve(deps.cwd, dirArg ?? ".");
98
- const client = (key) => createClient({
99
- host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,
100
- auth: { apiKey: key },
101
- fetch: deps.fetch
102
- });
103
- if (command === "channel") {
104
- const channelKey = extra[0];
105
- if (dirArg !== "install" || channelKey == null || values.revision == null || values.project == null || values.install == null) {
106
- output.stderr(
107
- "error: channel install needs <key> --revision <id> --project <id> --install <id>"
108
- );
109
- return 2;
110
- }
111
- if (apiKey == null) {
112
- output.stderr("error: set FINAL_API_KEY to a Final API key");
113
- return 2;
114
- }
115
- return runChannelInstall({
116
- channelKey,
117
- revisionId: values.revision,
118
- replace: values.replace,
119
- projectId: values.project,
120
- connectorInstallId: values.install,
121
- client: client(apiKey),
122
- output
123
- });
124
- }
125
- if (command === "build") {
126
- return runBuild({ dir, client: apiKey == null ? null : client(apiKey), output });
127
- }
128
- if (command === "dev") {
129
- const port = values.port == null ? DEFAULT_DEV_PORT : Number(values.port);
130
- if (!Number.isInteger(port) || port < 0 || port > 65535) {
131
- output.stderr(`error: --port must be a port number`);
132
- return 2;
133
- }
134
- return runDev({
135
- dir,
136
- port,
137
- env: deps.env,
138
- output,
139
- signal: deps.signal ?? new AbortController().signal
140
- });
141
- }
142
- if (command === "publish") {
143
- if (values.agent == null) {
144
- output.stderr("error: publish needs --agent <slug>");
145
- return 2;
146
- }
147
- if (apiKey == null) {
148
- output.stderr("error: set FINAL_API_KEY to a Final API key");
149
- return 2;
150
- }
151
- return runPublish({
152
- dir,
153
- agent: values.agent,
154
- ref: values.ref ?? null,
155
- message: values.message ?? DEFAULT_COMMIT_MESSAGE,
156
- note: values.note ?? null,
157
- activate: values["no-activate"] === true ? false : void 0,
158
- client: client(apiKey),
159
- listFiles: deps.listFiles ?? gitListFiles,
160
- output
161
- });
76
+ if (moduleArg == null) {
77
+ output.stderr(`error: ${command} needs <module>`);
78
+ return 2;
162
79
  }
163
80
  if (command === "conformance") {
164
- if (dirArg == null) {
165
- output.stderr("error: conformance needs <module>");
166
- return 2;
167
- }
168
81
  const timeoutMs = values.timeout == null ? null : Number(values.timeout);
169
82
  if (timeoutMs != null && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {
170
83
  output.stderr("error: --timeout must be a positive number of milliseconds");
171
84
  return 2;
172
85
  }
173
86
  return runConformance({
174
- module: dirArg,
87
+ module: moduleArg,
175
88
  exportName: values.export ?? "default",
176
89
  profile: values.profile ?? "final",
177
90
  timeoutMs,
@@ -182,12 +95,73 @@ const runAgentsCommand = async (deps) => {
182
95
  signal: deps.signal
183
96
  });
184
97
  }
185
- output.stderr(`error: unknown command ${command}`);
186
- output.stderr(USAGE);
187
- return 2;
98
+ const env = envSchema.safeParse(deps.env);
99
+ if (!env.success) {
100
+ output.stderr(
101
+ "error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL"
102
+ );
103
+ return 2;
104
+ }
105
+ const loaded = await loadDefinitionModule({
106
+ module: moduleArg,
107
+ exportName: values.export ?? null,
108
+ cwd: deps.cwd,
109
+ importModule: deps.importModule,
110
+ documentOf: deps.documentOf ?? documentOf
111
+ });
112
+ if (!loaded.ok) {
113
+ output.stderr(`error: ${loaded.message}`);
114
+ return 1;
115
+ }
116
+ if (command === "print") {
117
+ output.stdout(JSON.stringify(loaded.document, null, 2));
118
+ return 0;
119
+ }
120
+ if (values.name == null) {
121
+ output.stderr("error: publish needs --name <name>");
122
+ return 2;
123
+ }
124
+ const projectId = values.project ?? env.data.FINAL_PROJECT_ID;
125
+ if (projectId == null) {
126
+ output.stderr("error: publish needs --project <id> or FINAL_PROJECT_ID");
127
+ return 2;
128
+ }
129
+ const apiKey = env.data.FINAL_API_KEY;
130
+ if (apiKey == null) {
131
+ output.stderr("error: set FINAL_API_KEY to a Final API key");
132
+ return 2;
133
+ }
134
+ const agentDocument = loaded.kind === DefinitionKind.Agent ? loaded.document : null;
135
+ const client = createClient({
136
+ host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,
137
+ auth: { apiKey },
138
+ fetch: deps.fetch,
139
+ localCompute: false,
140
+ // The document is already made; publishing sends exactly it.
141
+ agentCodec: {
142
+ documentOf: () => {
143
+ if (agentDocument == null) throw new Error("Only an agent has an agent document");
144
+ return agentDocument;
145
+ },
146
+ inProcessCodeOf: () => ({ tools: {}, hooks: {}, approvals: {} })
147
+ }
148
+ });
149
+ try {
150
+ const project = client.project({ id: projectId });
151
+ const name = values.name;
152
+ const signal = deps.signal;
153
+ const published = loaded.kind === DefinitionKind.Agent ? await project.agents.publish({ agent: loaded.agent, name, signal }) : loaded.kind === DefinitionKind.Harness ? await project.harnesses.publish({ harness: loaded.document, name, signal }) : await project.acpAdapters.publish({ adapter: loaded.document, name, signal });
154
+ output.stdout(`published ${published.name}: ${published.hash}`);
155
+ if ("id" in published && published.id != null) output.stdout(`id: ${published.id}`);
156
+ return 0;
157
+ } catch (cause) {
158
+ for (const line of errorLines(cause)) output.stderr(line);
159
+ return 1;
160
+ } finally {
161
+ client.close();
162
+ }
188
163
  };
189
164
  export {
190
- DEFAULT_AGENTS_HOST,
191
165
  runAgentsCommand
192
166
  };
193
167
  //# sourceMappingURL=cli.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/cli.ts"],
4
- "sourcesContent": ["import { resolve } from 'node:path';\nimport { parseArgs } from 'node:util';\nimport * as z from 'zod';\nimport { createClient, type AgentClientIface } from \"../agent-client/client.mjs\";\nimport type { FetchIface } from \"../agent-client/http.mjs\";\nimport { runChannelInstall } from \"./channel-install.mjs\";\nimport { runBuild } from \"./build.mjs\";\nimport { runConformance, type ImportModule } from \"./conformance.mjs\";\nimport { DEFAULT_DEV_PORT, runDev } from \"./dev.mjs\";\nimport { gitListFiles, type ListFiles } from \"./files.mjs\";\nimport type { OutputIface } from \"./output.mjs\";\nimport { runPublish } from \"./publish.mjs\";\n\n// Agent CLI commands:\n// `build` and `publish`, plus `dev` and `conformance`. Shipped as the `final-agents` bin until a general\n// `final` CLI exists; `runAgentsCommand` is what `final agents` would mount.\n\n// The agents API, authenticated with FINAL_API_KEY.\nexport const DEFAULT_AGENTS_HOST = 'https://agent-session.final.ai/api';\n\nconst DEFAULT_COMMIT_MESSAGE = 'Publish with final agents publish';\n\nconst USAGE = [\n 'usage: final-agents <command> [options]',\n '',\n 'commands:',\n ' build [dir] compile the agent directory and report on its harness',\n ' dev [dir] serve its channel routes at http://localhost:<port>/<channel><path>',\n ' publish [dir] --agent <slug> commit the checkout to the agent and publish it',\n ' channel install <key> --revision <id> --project <id> --install <id> [--replace] install or explicitly update a published channel',\n ' conformance <module> run the harness conformance kit against a harness the module exports',\n '',\n 'options:',\n ' --host <url> agent platform API (overrides FINAL_API_HOST; default ' +\n DEFAULT_AGENTS_HOST +\n ')',\n ' --agent <slug> publish: the agent definition (slug or id)',\n ' --ref <ref> publish: the ref to publish (GitHub-backed agents)',\n ' --message <text> publish: commit message',\n ' --note <text> publish: revision note',\n ' --no-activate publish: store approved source without changing the live agent',\n ' --replace channel install: explicitly update the existing binding',\n ` --port <port> dev: port to listen on (default ${DEFAULT_DEV_PORT})`,\n ' --export <name> conformance: the export to test (default \"default\"): a HarnessIface or { harness, dial }',\n ' --profile <name> conformance: final (default) or plain-acp-v2',\n ' --timeout <ms> conformance: per-case timeout',\n ' --json conformance: print the report as JSON',\n '',\n 'FINAL_API_KEY authenticates. build checks compatibility only with it.',\n 'FINAL_API_HOST selects the deployment for build and publish; it does not rewrite authored URLs.',\n 'dev reads route secrets from AGENT_LOCAL_SECRETS_JSON ({\"name\": \"value\"}), limited to the manifest\\'s secrets.',\n].join('\\n');\n\nconst envSchema = z.object({\n FINAL_API_KEY: z.string().min(1).optional(),\n FINAL_API_HOST: z.string().url().optional(),\n});\n\nexport interface AgentsCliDepsIface {\n argv: string[];\n env: Record<string, string | undefined>;\n cwd: string;\n output: OutputIface;\n // Seams: API requests and the checkout's file listing.\n fetch?: FetchIface;\n listFiles?: ListFiles;\n // Ends long-running commands (dev); main.ts aborts it on SIGINT and SIGTERM.\n signal?: AbortSignal;\n // Seam: loads the conformance module (dynamic import by file URL).\n importModule?: ImportModule;\n}\n\nconst optionsConfig = {\n host: { type: 'string' },\n agent: { type: 'string' },\n ref: { type: 'string' },\n message: { type: 'string' },\n note: { type: 'string' },\n 'no-activate': { type: 'boolean' },\n port: { type: 'string' },\n project: { type: 'string' },\n install: { type: 'string' },\n replace: { type: 'boolean' },\n revision: { type: 'string' },\n export: { type: 'string' },\n profile: { type: 'string' },\n timeout: { type: 'string' },\n json: { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n} as const;\n\nconst parseCommandLine = (argv: string[]) =>\n parseArgs({ args: argv, options: optionsConfig, allowPositionals: true });\n\ntype ParsedResult =\n | { ok: true; parsed: ReturnType<typeof parseCommandLine> }\n | { ok: false; message: string };\n\nconst parse = (argv: string[]): ParsedResult => {\n try {\n return { ok: true, parsed: parseCommandLine(argv) };\n } catch (cause) {\n return { ok: false, message: cause instanceof Error ? cause.message : String(cause) };\n }\n};\n\nexport const runAgentsCommand = async (deps: AgentsCliDepsIface): Promise<number> => {\n const { output } = deps;\n const parsedArgs = parse(deps.argv);\n if (!parsedArgs.ok) {\n output.stderr(`error: ${parsedArgs.message}`);\n output.stderr(USAGE);\n return 2;\n }\n const { values, positionals } = parsedArgs.parsed;\n const [command, dirArg, ...extra] = positionals;\n if (values.help === true || command == null || command === 'help') {\n (command == null && values.help !== true ? output.stderr : output.stdout)(USAGE);\n return command == null && values.help !== true ? 2 : 0;\n }\n if (extra.length > 0 && !(command === 'channel' && dirArg === 'install' && extra.length === 1)) {\n output.stderr(`error: unexpected arguments: ${extra.join(' ')}`);\n return 2;\n }\n const env = envSchema.safeParse(deps.env);\n if (!env.success) {\n output.stderr(\n 'error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL',\n );\n return 2;\n }\n const apiKey = env.success ? (env.data.FINAL_API_KEY ?? null) : null;\n const dir = resolve(deps.cwd, dirArg ?? '.');\n const client = (key: string): AgentClientIface =>\n createClient({\n host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,\n auth: { apiKey: key },\n fetch: deps.fetch,\n });\n\n if (command === 'channel') {\n const channelKey = extra[0];\n if (\n dirArg !== 'install' ||\n channelKey == null ||\n values.revision == null ||\n values.project == null ||\n values.install == null\n ) {\n output.stderr(\n 'error: channel install needs <key> --revision <id> --project <id> --install <id>',\n );\n return 2;\n }\n if (apiKey == null) {\n output.stderr('error: set FINAL_API_KEY to a Final API key');\n return 2;\n }\n return runChannelInstall({\n channelKey,\n revisionId: values.revision,\n replace: values.replace,\n projectId: values.project,\n connectorInstallId: values.install,\n client: client(apiKey),\n output,\n });\n }\n if (command === 'build') {\n return runBuild({ dir, client: apiKey == null ? null : client(apiKey), output });\n }\n if (command === 'dev') {\n const port = values.port == null ? DEFAULT_DEV_PORT : Number(values.port);\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n output.stderr(`error: --port must be a port number`);\n return 2;\n }\n return runDev({\n dir,\n port,\n env: deps.env,\n output,\n signal: deps.signal ?? new AbortController().signal,\n });\n }\n if (command === 'publish') {\n if (values.agent == null) {\n output.stderr('error: publish needs --agent <slug>');\n return 2;\n }\n if (apiKey == null) {\n output.stderr('error: set FINAL_API_KEY to a Final API key');\n return 2;\n }\n return runPublish({\n dir,\n agent: values.agent,\n ref: values.ref ?? null,\n message: values.message ?? DEFAULT_COMMIT_MESSAGE,\n note: values.note ?? null,\n activate: values['no-activate'] === true ? false : undefined,\n client: client(apiKey),\n listFiles: deps.listFiles ?? gitListFiles,\n output,\n });\n }\n if (command === 'conformance') {\n if (dirArg == null) {\n output.stderr('error: conformance needs <module>');\n return 2;\n }\n const timeoutMs = values.timeout == null ? null : Number(values.timeout);\n if (timeoutMs != null && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n output.stderr('error: --timeout must be a positive number of milliseconds');\n return 2;\n }\n return runConformance({\n module: dirArg,\n exportName: values.export ?? 'default',\n profile: values.profile ?? 'final',\n timeoutMs,\n json: values.json === true,\n cwd: deps.cwd,\n output,\n importModule: deps.importModule,\n signal: deps.signal,\n });\n }\n output.stderr(`error: unknown command ${command}`);\n output.stderr(USAGE);\n return 2;\n};\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,YAAY,OAAO;AACnB,SAAS,oBAA2C;AAEpD,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,SAAS,sBAAyC;AAClD,SAAS,kBAAkB,cAAc;AACzC,SAAS,oBAAoC;AAE7C,SAAS,kBAAkB;AAOpB,MAAM,sBAAsB;AAEnC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MACA,OAAO,OAAO;AAAA,MACd,KAAK,OAAO,OAAO;AAAA,MACnB,SAAS,OAAO,WAAW;AAAA,MAC3B,MAAM,OAAO,QAAQ;AAAA,MACrB,UAAU,OAAO,aAAa,MAAM,OAAO,QAAQ;AAAA,MACnD,QAAQ,OAAO,MAAM;AAAA,MACrB,WAAW,KAAK,aAAa;AAAA,MAC7B;AAAA,IACF,CAAC;AAAA,EACH;AACA,MAAI,YAAY,eAAe;AAC7B,QAAI,UAAU,MAAM;AAClB,aAAO,OAAO,mCAAmC;AACjD,aAAO;AAAA,IACT;AACA,UAAM,YAAY,OAAO,WAAW,OAAO,OAAO,OAAO,OAAO,OAAO;AACvE,QAAI,aAAa,SAAS,CAAC,OAAO,UAAU,SAAS,KAAK,aAAa,IAAI;AACzE,aAAO,OAAO,4DAA4D;AAC1E,aAAO;AAAA,IACT;AACA,WAAO,eAAe;AAAA,MACpB,QAAQ;AAAA,MACR,YAAY,OAAO,UAAU;AAAA,MAC7B,SAAS,OAAO,WAAW;AAAA,MAC3B;AAAA,MACA,MAAM,OAAO,SAAS;AAAA,MACtB,KAAK,KAAK;AAAA,MACV;AAAA,MACA,cAAc,KAAK;AAAA,MACnB,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,EACH;AACA,SAAO,OAAO,0BAA0B,OAAO,EAAE;AACjD,SAAO,OAAO,KAAK;AACnB,SAAO;AACT;",
4
+ "sourcesContent": ["import { parseArgs } from 'node:util';\nimport { documentOf, type AgentIface } from '@finalai/agent-definition';\nimport type { AgentDocumentIface } from '@finalai/agent-provider/document';\nimport * as z from 'zod';\nimport { createClient, DEFAULT_AGENTS_HOST, type AgentClientIface } from \"../agent-client/client.mjs\";\nimport type { FetchIface } from \"../agent-client/http.mjs\";\nimport { DefinitionKind, loadDefinitionModule, type ImportModule } from \"./agent-module.mjs\";\nimport { runConformance } from \"./conformance.mjs\";\nimport { errorLines, type OutputIface } from \"./output.mjs\";\n\n// `final-agents`: `print` writes the document of an agent, a harness or an\n// ACP adapter, `publish` gives it a name in a project, `conformance` checks a\n// harness implementation. Nothing is built or deployed: each is data.\n\nconst USAGE = [\n 'usage: final-agents <command> [options]',\n '',\n 'commands:',\n ' print <module> write the document of the agent, harness or ACP adapter',\n ' the module exports, as JSON',\n ' publish <module> --name <name> store it and point <name> at it in a project',\n ' conformance <module> run the harness conformance kit against a harness the module exports',\n '',\n 'options:',\n ' --export <name> the export to use (print and publish: an agent, a harness or an ACP adapter,',\n ' found by itself when omitted;',\n ' conformance: a HarnessIface or { harness, dial }, default \"default\")',\n ' --name <name> publish: the name to point at it',\n ' --project <id> publish: the project (overrides FINAL_PROJECT_ID)',\n ' --host <url> agents API (overrides FINAL_API_HOST; default ' +\n DEFAULT_AGENTS_HOST +\n ')',\n ' --profile <name> conformance: final (default), final-required (ACP adapters) or plain-acp-v2',\n ' --timeout <ms> conformance: per-case timeout',\n ' --json conformance: print the report as JSON',\n '',\n 'publish authenticates with FINAL_API_KEY. print calls nothing.',\n].join('\\n');\n\nconst envSchema = z.object({\n FINAL_API_KEY: z.string().min(1).optional(),\n FINAL_API_HOST: z.string().url().optional(),\n FINAL_PROJECT_ID: z.string().min(1).optional(),\n});\n\nexport interface AgentsCliDepsIface {\n argv: string[];\n env: Record<string, string | undefined>;\n cwd: string;\n output: OutputIface;\n // Seams: API requests, module loading and document making.\n fetch?: FetchIface;\n importModule?: ImportModule;\n documentOf?: (agent: AgentIface) => AgentDocumentIface;\n // Ends long-running commands; main.ts aborts it on SIGINT and SIGTERM.\n signal?: AbortSignal;\n}\n\nconst optionsConfig = {\n export: { type: 'string' },\n name: { type: 'string' },\n project: { type: 'string' },\n host: { type: 'string' },\n profile: { type: 'string' },\n timeout: { type: 'string' },\n json: { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n} as const;\n\nconst parseCommandLine = (argv: string[]) =>\n parseArgs({ args: argv, options: optionsConfig, allowPositionals: true });\n\ntype ParsedResult =\n | { ok: true; parsed: ReturnType<typeof parseCommandLine> }\n | { ok: false; message: string };\n\nconst parse = (argv: string[]): ParsedResult => {\n try {\n return { ok: true, parsed: parseCommandLine(argv) };\n } catch (cause) {\n return { ok: false, message: cause instanceof Error ? cause.message : String(cause) };\n }\n};\n\nexport const runAgentsCommand = async (deps: AgentsCliDepsIface): Promise<number> => {\n const { output } = deps;\n const parsedArgs = parse(deps.argv);\n if (!parsedArgs.ok) {\n output.stderr(`error: ${parsedArgs.message}`);\n output.stderr(USAGE);\n return 2;\n }\n const { values, positionals } = parsedArgs.parsed;\n const [command, moduleArg, ...extra] = positionals;\n if (values.help === true || command == null || command === 'help') {\n (command == null && values.help !== true ? output.stderr : output.stdout)(USAGE);\n return command == null && values.help !== true ? 2 : 0;\n }\n if (extra.length > 0) {\n output.stderr(`error: unexpected arguments: ${extra.join(' ')}`);\n return 2;\n }\n if (command !== 'print' && command !== 'publish' && command !== 'conformance') {\n output.stderr(`error: unknown command ${command}`);\n output.stderr(USAGE);\n return 2;\n }\n if (moduleArg == null) {\n output.stderr(`error: ${command} needs <module>`);\n return 2;\n }\n\n if (command === 'conformance') {\n const timeoutMs = values.timeout == null ? null : Number(values.timeout);\n if (timeoutMs != null && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {\n output.stderr('error: --timeout must be a positive number of milliseconds');\n return 2;\n }\n return runConformance({\n module: moduleArg,\n exportName: values.export ?? 'default',\n profile: values.profile ?? 'final',\n timeoutMs,\n json: values.json === true,\n cwd: deps.cwd,\n output,\n importModule: deps.importModule,\n signal: deps.signal,\n });\n }\n\n const env = envSchema.safeParse(deps.env);\n if (!env.success) {\n output.stderr(\n 'error: FINAL_API_KEY must be nonempty and FINAL_API_HOST must be an absolute URL',\n );\n return 2;\n }\n const loaded = await loadDefinitionModule({\n module: moduleArg,\n exportName: values.export ?? null,\n cwd: deps.cwd,\n importModule: deps.importModule,\n documentOf: deps.documentOf ?? documentOf,\n });\n if (!loaded.ok) {\n output.stderr(`error: ${loaded.message}`);\n return 1;\n }\n\n if (command === 'print') {\n output.stdout(JSON.stringify(loaded.document, null, 2));\n return 0;\n }\n\n if (values.name == null) {\n output.stderr('error: publish needs --name <name>');\n return 2;\n }\n const projectId = values.project ?? env.data.FINAL_PROJECT_ID;\n if (projectId == null) {\n output.stderr('error: publish needs --project <id> or FINAL_PROJECT_ID');\n return 2;\n }\n const apiKey = env.data.FINAL_API_KEY;\n if (apiKey == null) {\n output.stderr('error: set FINAL_API_KEY to a Final API key');\n return 2;\n }\n const agentDocument = loaded.kind === DefinitionKind.Agent ? loaded.document : null;\n const client: AgentClientIface = createClient({\n host: values.host ?? env.data.FINAL_API_HOST ?? DEFAULT_AGENTS_HOST,\n auth: { apiKey },\n fetch: deps.fetch,\n localCompute: false,\n // The document is already made; publishing sends exactly it.\n agentCodec: {\n documentOf: () => {\n if (agentDocument == null) throw new Error('Only an agent has an agent document');\n return agentDocument;\n },\n inProcessCodeOf: () => ({ tools: {}, hooks: {}, approvals: {} }),\n },\n });\n try {\n const project = client.project({ id: projectId });\n const name = values.name;\n const signal = deps.signal;\n const published =\n loaded.kind === DefinitionKind.Agent\n ? await project.agents.publish({ agent: loaded.agent, name, signal })\n : loaded.kind === DefinitionKind.Harness\n ? await project.harnesses.publish({ harness: loaded.document, name, signal })\n : await project.acpAdapters.publish({ adapter: loaded.document, name, signal });\n output.stdout(`published ${published.name}: ${published.hash}`);\n if ('id' in published && published.id != null) output.stdout(`id: ${published.id}`);\n return 0;\n } catch (cause) {\n for (const line of errorLines(cause)) output.stderr(line);\n return 1;\n } finally {\n client.close();\n }\n};\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAmC;AAE5C,YAAY,OAAO;AACnB,SAAS,cAAc,2BAAkD;AAEzE,SAAS,gBAAgB,4BAA+C;AACxE,SAAS,sBAAsB;AAC/B,SAAS,kBAAoC;AAM7C,MAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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YACJ,OAAO,SAAS,eAAe,QAC3B,MAAM,QAAQ,OAAO,QAAQ,EAAE,OAAO,OAAO,OAAO,MAAM,OAAO,CAAC,IAClE,OAAO,SAAS,eAAe,UAC7B,MAAM,QAAQ,UAAU,QAAQ,EAAE,SAAS,OAAO,UAAU,MAAM,OAAO,CAAC,IAC1E,MAAM,QAAQ,YAAY,QAAQ,EAAE,SAAS,OAAO,UAAU,MAAM,OAAO,CAAC;AACpF,WAAO,OAAO,aAAa,UAAU,IAAI,KAAK,UAAU,IAAI,EAAE;AAC9D,QAAI,QAAQ,aAAa,UAAU,MAAM,KAAM,QAAO,OAAO,OAAO,UAAU,EAAE,EAAE;AAClF,WAAO;AAAA,EACT,SAAS,OAAO;AACd,eAAW,QAAQ,WAAW,KAAK,EAAG,QAAO,OAAO,IAAI;AACxD,WAAO;AAAA,EACT,UAAE;AACA,WAAO,MAAM;AAAA,EACf;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,12 +1,9 @@
1
1
  import { type HarnessEndpointIface, type HarnessIface } from '@finalai/agent-provider';
2
2
  import { type ConformanceStreamIface, type HarnessConformanceReportIface, type RunHarnessConformanceArgsIface } from '@finalai/agent-provider/conformance';
3
- import * as z from 'zod';
3
+ import { type ImportModule, type ModuleNamespace } from "./agent-module.mjs";
4
4
  import type { OutputIface } from "./output.mjs";
5
- declare const moduleNamespaceSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
6
- /** An imported module's exports, before the conformance export is parsed. */
7
- export type ModuleNamespace = z.output<typeof moduleNamespaceSchema>;
5
+ export type { ImportModule, ModuleNamespace } from "./agent-module.mjs";
8
6
  type ModuleExport = ModuleNamespace[string];
9
- export type ImportModule = (url: string) => Promise<ModuleNamespace>;
10
7
  export interface ConformanceTargetIface {
11
8
  harness: HarnessIface;
12
9
  dial: RunHarnessConformanceArgsIface['dial'];
@@ -33,4 +30,3 @@ export declare const runConformance: (args: {
33
30
  importModule?: ImportModule;
34
31
  signal?: AbortSignal;
35
32
  }) => Promise<number>;
36
- export {};
@@ -19,15 +19,11 @@ import { resolve } from "node:path";
19
19
  import { pathToFileURL } from "node:url";
20
20
  import WebSocket from "ws";
21
21
  import * as z from "zod";
22
- const moduleNamespaceSchema = z.record(z.string(), z.unknown());
23
- const importModule = async (url) => moduleNamespaceSchema.parse(await import(
24
- /* @vite-ignore */
25
- url
26
- ));
22
+ import { importModule } from "./agent-module.mjs";
27
23
  const functionCheck = z.function();
28
24
  const isFunction = (value) => functionCheck.safeParse(value).success;
29
25
  const harnessMethodsSchema = z.looseObject({
30
- describe: z.custom(isFunction),
26
+ definition: z.looseObject({}),
31
27
  open: z.custom(isFunction),
32
28
  resume: z.custom(isFunction),
33
29
  park: z.custom(isFunction),
@@ -120,8 +116,9 @@ const dialHarnessEndpoint = async (endpoint) => {
120
116
  return { ...stream, close: () => child.kill("SIGTERM") };
121
117
  }
122
118
  case AcpTransport.Relay:
119
+ case AcpTransport.Sandbox:
123
120
  throw new Error(
124
- "relay endpoints are dialed by the session plane; export { harness, dial } to run them here"
121
+ `${endpoint.transport} endpoints are dialed by the session plane; export { harness, dial } to run them here`
125
122
  );
126
123
  }
127
124
  };
@@ -163,7 +160,7 @@ const runConformance = async (args) => {
163
160
  const profile = z.nativeEnum(ConformanceProfile).safeParse(args.profile);
164
161
  if (!profile.success) {
165
162
  args.output.stderr(
166
- `error: --profile must be ${Object.values(ConformanceProfile).join(" or ")}`
163
+ `error: --profile must be one of ${Object.values(ConformanceProfile).join(", ")}`
167
164
  );
168
165
  return 2;
169
166
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/conformance.ts"],
4
- "sourcesContent": ["import { createHttpStream } from '@agentclientprotocol/sdk/experimental/http-client';\nimport { ndJsonStream } from '@agentclientprotocol/sdk/experimental/v2';\nimport { createWebSocketStream } from '@agentclientprotocol/sdk/experimental/ws-client';\nimport {\n AcpTransport,\n type HarnessEndpointIface,\n type HarnessIface,\n} from '@finalai/agent-provider';\nimport {\n ConformanceCaseStatus,\n ConformanceProfile,\n conformanceOpenArgs,\n runHarnessConformance,\n type ConformanceStreamIface,\n type HarnessConformanceReportIface,\n type RunHarnessConformanceArgsIface,\n} from '@finalai/agent-provider/conformance';\nimport {\n configureNodeClientWebSocket,\n createNodeClientTlsSession,\n} from '@finalai/websockets/node-client-tls';\nimport { spawn } from 'node:child_process';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport WebSocket from 'ws';\nimport * as z from 'zod';\nimport type { OutputIface } from \"./output.mjs\";\n\n// `final-agents conformance <module>` exercises the public lifecycle and ACP\n// contracts of a harness exported by a module. The export is a HarnessIface, or `{ harness, dial }`\n// (with optional `nativeSessionId`) when its endpoints need a dialer of its own.\n\nconst moduleNamespaceSchema = z.record(z.string(), z.unknown());\n/** An imported module's exports, before the conformance export is parsed. */\nexport type ModuleNamespace = z.output<typeof moduleNamespaceSchema>;\ntype ModuleExport = ModuleNamespace[string];\n\nexport type ImportModule = (url: string) => Promise<ModuleNamespace>;\n\nconst importModule: ImportModule = async (url) =>\n moduleNamespaceSchema.parse(await import(/* @vite-ignore */ url));\n\nexport interface ConformanceTargetIface {\n harness: HarnessIface;\n dial: RunHarnessConformanceArgsIface['dial'];\n nativeSessionId?: RunHarnessConformanceArgsIface['nativeSessionId'];\n}\n\n// zod's function check, so functions from any realm qualify.\nconst functionCheck = z.function();\nconst isFunction = (value: ModuleExport): boolean => functionCheck.safeParse(value).success;\n\nconst harnessMethodsSchema = z.looseObject({\n describe: z.custom(isFunction),\n open: z.custom(isFunction),\n resume: z.custom(isFunction),\n park: z.custom(isFunction),\n close: z.custom(isFunction),\n health: z.custom(isFunction),\n});\n// An object with the methods, or a callable carrying them (what `defineHarness` returns).\nconst harnessSchema = z.custom<HarnessIface>(\n (value) =>\n harnessMethodsSchema.safeParse(isFunction(value) ? Object.assign({}, value) : value).success,\n);\nconst dialSchema = z.custom<ConformanceTargetIface['dial']>(\n isFunction,\n '`dial` must be a function',\n);\nconst nativeSessionIdSchema = z.custom<NonNullable<ConformanceTargetIface['nativeSessionId']>>(\n isFunction,\n '`nativeSessionId` must be a function',\n);\nconst targetFieldsSchema = z.looseObject({\n harness: harnessSchema,\n dial: dialSchema.optional(),\n nativeSessionId: nativeSessionIdSchema.optional(),\n});\n\n// Dials the endpoint kinds a harness outside Final can return: stdio programs,\n// Streamable HTTP and WebSocket, including header authentication and client TLS.\n// Relay endpoints are Final-managed.\nexport const dialHarnessEndpoint = async (\n endpoint: HarnessEndpointIface,\n): Promise<ConformanceStreamIface> => {\n switch (endpoint.transport) {\n case AcpTransport.Http: {\n const headers = { ...endpoint.headers, ...(await endpoint.resolveHeaders?.()) };\n const tlsSession =\n endpoint.tls == null ? null : createNodeClientTlsSession({ tls: endpoint.tls });\n const stream = createHttpStream(endpoint.url, {\n headers,\n cookies: 'omit',\n fetch: tlsSession?.fetch,\n });\n return {\n ...stream,\n close: () => {\n void stream.writable.close().catch(() => undefined);\n void tlsSession?.close().catch(() => undefined);\n },\n };\n }\n case AcpTransport.Ws: {\n const headers = { ...endpoint.headers, ...(await endpoint.resolveHeaders?.()) };\n const stream = createWebSocketStream(endpoint.url, {\n cookies: 'omit',\n headers,\n WebSocket: configureNodeClientWebSocket({ constructor: WebSocket, tls: endpoint.tls }),\n });\n return {\n ...stream,\n close: () => void stream.writable.close().catch(() => undefined),\n };\n }\n case AcpTransport.Stdio: {\n const child = spawn(endpoint.command, endpoint.args, {\n env: { ...process.env, ...endpoint.env },\n stdio: ['pipe', 'pipe', 'inherit'],\n });\n child.stdin.on('error', () => undefined);\n let open = true;\n const input = new ReadableStream<Uint8Array>({\n start: (controller) => {\n child.stdout.on('data', (chunk: Buffer) => {\n if (open) controller.enqueue(new Uint8Array(chunk));\n });\n child.stdout.on('end', () => {\n if (!open) return;\n open = false;\n controller.close();\n });\n child.on('error', (error) => {\n if (!open) return;\n open = false;\n controller.error(error);\n });\n },\n cancel: () => {\n open = false;\n child.stdout.destroy();\n },\n });\n const output = new WritableStream<Uint8Array>({\n write: (chunk) =>\n new Promise<void>((done, fail) => {\n child.stdin.write(chunk, (error) => (error == null ? done() : fail(error)));\n }),\n close: () => {\n child.stdin.end();\n },\n });\n const stream = ndJsonStream(output, input);\n return { ...stream, close: () => child.kill('SIGTERM') };\n }\n case AcpTransport.Relay:\n throw new Error(\n 'relay endpoints are dialed by the session plane; export { harness, dial } to run them here',\n );\n }\n};\n\nexport type ConformanceTargetResult =\n | { ok: true; target: ConformanceTargetIface }\n | { ok: false; message: string };\n\n// The export as a conformance target: a HarnessIface (dialed built in), or\n// `{ harness, dial?, nativeSessionId? }`.\nexport const conformanceTargetOf = (value: ModuleExport): ConformanceTargetResult => {\n const harness = harnessSchema.safeParse(value);\n if (harness.success)\n return { ok: true, target: { harness: harness.data, dial: dialHarnessEndpoint } };\n const fields = targetFieldsSchema.safeParse(value);\n if (!fields.success) {\n const issue = fields.error.issues.find((entry) => entry.path[0] !== 'harness');\n return {\n ok: false,\n message:\n issue?.message ??\n 'the export must be a HarnessIface or { harness, dial?, nativeSessionId? }',\n };\n }\n return {\n ok: true,\n target: {\n harness: fields.data.harness,\n dial: fields.data.dial ?? dialHarnessEndpoint,\n nativeSessionId: fields.data.nativeSessionId,\n },\n };\n};\n\nconst statusLabel = {\n [ConformanceCaseStatus.Passed]: 'pass',\n [ConformanceCaseStatus.Failed]: 'FAIL',\n [ConformanceCaseStatus.Skipped]: 'skip',\n} satisfies Record<ConformanceCaseStatus, string>;\n\nexport const reportLines = (report: HarnessConformanceReportIface): string[] => [\n `profile: ${report.profile}`,\n ...report.cases.map((entry) => {\n const why = entry.error ?? entry.detail;\n return `${statusLabel[entry.status]} ${entry.name}${why == null ? '' : ` (${why})`}`;\n }),\n report.passed ? 'conformance: passed' : 'conformance: failed',\n];\n\nexport const runConformance = async (args: {\n module: string;\n exportName: string;\n profile: string;\n timeoutMs: number | null;\n json: boolean;\n cwd: string;\n output: OutputIface;\n importModule?: ImportModule;\n // SIGINT/SIGTERM (main.ts): the kit has no cancellation, so the command stops\n // waiting for it and the process exits.\n signal?: AbortSignal;\n}): Promise<number> => {\n const profile = z.nativeEnum(ConformanceProfile).safeParse(args.profile);\n if (!profile.success) {\n args.output.stderr(\n `error: --profile must be ${Object.values(ConformanceProfile).join(' or ')}`,\n );\n return 2;\n }\n const url = pathToFileURL(resolve(args.cwd, args.module)).href;\n let loaded: ModuleNamespace;\n try {\n loaded = await (args.importModule ?? importModule)(url);\n } catch (cause) {\n args.output.stderr(\n `error: cannot load ${args.module}: ${cause instanceof Error ? cause.message : String(cause)}`,\n );\n return 1;\n }\n if (!(args.exportName in loaded)) {\n args.output.stderr(`error: ${args.module} has no export ${args.exportName}`);\n return 1;\n }\n const parsed = conformanceTargetOf(loaded[args.exportName]);\n if (!parsed.ok) {\n args.output.stderr(`error: ${args.module}#${args.exportName}: ${parsed.message}`);\n return 1;\n }\n const target = parsed.target;\n const run = runHarnessConformance({\n harness: target.harness,\n dial: target.dial,\n nativeSessionId: target.nativeSessionId,\n profile: profile.data,\n openArgs: conformanceOpenArgs(),\n timeoutMs: args.timeoutMs ?? undefined,\n cwd: args.cwd,\n });\n const signal = args.signal;\n const interrupted =\n signal == null\n ? null\n : new Promise<null>((done) => {\n if (signal.aborted) done(null);\n else signal.addEventListener('abort', () => done(null), { once: true });\n });\n const report = await (interrupted == null ? run : Promise.race([run, interrupted]));\n if (report == null) {\n run.catch(() => undefined);\n args.output.stderr('conformance: interrupted');\n return 130;\n }\n if (args.json) args.output.stdout(JSON.stringify(report, null, 2));\n else for (const line of reportLines(report)) args.output.stdout(line);\n return report.passed ? 0 : 1;\n};\n"],
5
- "mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa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,IAAI,KAAK,UAAU,KAAK,OAAO,OAAO,EAAE;AAChF,WAAO;AAAA,EACT;AACA,QAAM,SAAS,OAAO;AACtB,QAAM,MAAM,sBAAsB;AAAA,IAChC,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,iBAAiB,OAAO;AAAA,IACxB,SAAS,QAAQ;AAAA,IACjB,UAAU,oBAAoB;AAAA,IAC9B,WAAW,KAAK,aAAa;AAAA,IAC7B,KAAK,KAAK;AAAA,EACZ,CAAC;AACD,QAAM,SAAS,KAAK;AACpB,QAAM,cACJ,UAAU,OACN,OACA,IAAI,QAAc,CAAC,SAAS;AAC1B,QAAI,OAAO,QAAS,MAAK,IAAI;AAAA,QACxB,QAAO,iBAAiB,SAAS,MAAM,KAAK,IAAI,GAAG,EAAE,MAAM,KAAK,CAAC;AAAA,EACxE,CAAC;AACP,QAAM,SAAS,OAAO,eAAe,OAAO,MAAM,QAAQ,KAAK,CAAC,KAAK,WAAW,CAAC;AACjF,MAAI,UAAU,MAAM;AAClB,QAAI,MAAM,MAAM,MAAS;AACzB,SAAK,OAAO,OAAO,0BAA0B;AAC7C,WAAO;AAAA,EACT;AACA,MAAI,KAAK,KAAM,MAAK,OAAO,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,MAC5D,YAAW,QAAQ,YAAY,MAAM,EAAG,MAAK,OAAO,OAAO,IAAI;AACpE,SAAO,OAAO,SAAS,IAAI;AAC7B;",
4
+ "sourcesContent": ["import { createHttpStream } from '@agentclientprotocol/sdk/experimental/http-client';\nimport { ndJsonStream } from '@agentclientprotocol/sdk/experimental/v2';\nimport { createWebSocketStream } from '@agentclientprotocol/sdk/experimental/ws-client';\nimport {\n AcpTransport,\n type HarnessEndpointIface,\n type HarnessIface,\n} from '@finalai/agent-provider';\nimport {\n ConformanceCaseStatus,\n ConformanceProfile,\n conformanceOpenArgs,\n runHarnessConformance,\n type ConformanceStreamIface,\n type HarnessConformanceReportIface,\n type RunHarnessConformanceArgsIface,\n} from '@finalai/agent-provider/conformance';\nimport {\n configureNodeClientWebSocket,\n createNodeClientTlsSession,\n} from '@finalai/websockets/node-client-tls';\nimport { spawn } from 'node:child_process';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport WebSocket from 'ws';\nimport * as z from 'zod';\nimport { importModule, type ImportModule, type ModuleNamespace } from \"./agent-module.mjs\";\nimport type { OutputIface } from \"./output.mjs\";\n\nexport type { ImportModule, ModuleNamespace } from \"./agent-module.mjs\";\n\n// `final-agents conformance <module>` exercises the public lifecycle and ACP\n// contracts of a harness exported by a module. The export is a HarnessIface (its definition\n// and lifecycle), or `{ harness, dial }` (with optional `nativeSessionId`) when its endpoints\n// need a dialer of its own.\n\ntype ModuleExport = ModuleNamespace[string];\n\nexport interface ConformanceTargetIface {\n harness: HarnessIface;\n dial: RunHarnessConformanceArgsIface['dial'];\n nativeSessionId?: RunHarnessConformanceArgsIface['nativeSessionId'];\n}\n\n// zod's function check, so functions from any realm qualify.\nconst functionCheck = z.function();\nconst isFunction = (value: ModuleExport): boolean => functionCheck.safeParse(value).success;\n\nconst harnessMethodsSchema = z.looseObject({\n definition: z.looseObject({}),\n open: z.custom(isFunction),\n resume: z.custom(isFunction),\n park: z.custom(isFunction),\n close: z.custom(isFunction),\n health: z.custom(isFunction),\n});\n// An object with the methods, or a callable carrying them.\nconst harnessSchema = z.custom<HarnessIface>(\n (value) =>\n harnessMethodsSchema.safeParse(isFunction(value) ? Object.assign({}, value) : value).success,\n);\nconst dialSchema = z.custom<ConformanceTargetIface['dial']>(\n isFunction,\n '`dial` must be a function',\n);\nconst nativeSessionIdSchema = z.custom<NonNullable<ConformanceTargetIface['nativeSessionId']>>(\n isFunction,\n '`nativeSessionId` must be a function',\n);\nconst targetFieldsSchema = z.looseObject({\n harness: harnessSchema,\n dial: dialSchema.optional(),\n nativeSessionId: nativeSessionIdSchema.optional(),\n});\n\n// Dials the endpoint kinds a harness outside Final can return: stdio programs,\n// Streamable HTTP and WebSocket, including header authentication and client TLS.\n// Relay endpoints are Final-managed.\nexport const dialHarnessEndpoint = async (\n endpoint: HarnessEndpointIface,\n): Promise<ConformanceStreamIface> => {\n switch (endpoint.transport) {\n case AcpTransport.Http: {\n const headers = { ...endpoint.headers, ...(await endpoint.resolveHeaders?.()) };\n const tlsSession =\n endpoint.tls == null ? null : createNodeClientTlsSession({ tls: endpoint.tls });\n const stream = createHttpStream(endpoint.url, {\n headers,\n cookies: 'omit',\n fetch: tlsSession?.fetch,\n });\n return {\n ...stream,\n close: () => {\n void stream.writable.close().catch(() => undefined);\n void tlsSession?.close().catch(() => undefined);\n },\n };\n }\n case AcpTransport.Ws: {\n const headers = { ...endpoint.headers, ...(await endpoint.resolveHeaders?.()) };\n const stream = createWebSocketStream(endpoint.url, {\n cookies: 'omit',\n headers,\n WebSocket: configureNodeClientWebSocket({ constructor: WebSocket, tls: endpoint.tls }),\n });\n return {\n ...stream,\n close: () => void stream.writable.close().catch(() => undefined),\n };\n }\n case AcpTransport.Stdio: {\n const child = spawn(endpoint.command, endpoint.args, {\n env: { ...process.env, ...endpoint.env },\n stdio: ['pipe', 'pipe', 'inherit'],\n });\n child.stdin.on('error', () => undefined);\n let open = true;\n const input = new ReadableStream<Uint8Array>({\n start: (controller) => {\n child.stdout.on('data', (chunk: Buffer) => {\n if (open) controller.enqueue(new Uint8Array(chunk));\n });\n child.stdout.on('end', () => {\n if (!open) return;\n open = false;\n controller.close();\n });\n child.on('error', (error) => {\n if (!open) return;\n open = false;\n controller.error(error);\n });\n },\n cancel: () => {\n open = false;\n child.stdout.destroy();\n },\n });\n const output = new WritableStream<Uint8Array>({\n write: (chunk) =>\n new Promise<void>((done, fail) => {\n child.stdin.write(chunk, (error) => (error == null ? done() : fail(error)));\n }),\n close: () => {\n child.stdin.end();\n },\n });\n const stream = ndJsonStream(output, input);\n return { ...stream, close: () => child.kill('SIGTERM') };\n }\n case AcpTransport.Relay:\n case AcpTransport.Sandbox:\n throw new Error(\n `${endpoint.transport} endpoints are dialed by the session plane; export { harness, dial } to run them here`,\n );\n }\n};\n\nexport type ConformanceTargetResult =\n | { ok: true; target: ConformanceTargetIface }\n | { ok: false; message: string };\n\n// The export as a conformance target: a HarnessIface (dialed built in), or\n// `{ harness, dial?, nativeSessionId? }`.\nexport const conformanceTargetOf = (value: ModuleExport): ConformanceTargetResult => {\n const harness = harnessSchema.safeParse(value);\n if (harness.success)\n return { ok: true, target: { harness: harness.data, dial: dialHarnessEndpoint } };\n const fields = targetFieldsSchema.safeParse(value);\n if (!fields.success) {\n const issue = fields.error.issues.find((entry) => entry.path[0] !== 'harness');\n return {\n ok: false,\n message:\n issue?.message ??\n 'the export must be a HarnessIface or { harness, dial?, nativeSessionId? }',\n };\n }\n return {\n ok: true,\n target: {\n harness: fields.data.harness,\n dial: fields.data.dial ?? dialHarnessEndpoint,\n nativeSessionId: fields.data.nativeSessionId,\n },\n };\n};\n\nconst statusLabel = {\n [ConformanceCaseStatus.Passed]: 'pass',\n [ConformanceCaseStatus.Failed]: 'FAIL',\n [ConformanceCaseStatus.Skipped]: 'skip',\n} satisfies Record<ConformanceCaseStatus, string>;\n\nexport const reportLines = (report: HarnessConformanceReportIface): string[] => [\n `profile: ${report.profile}`,\n ...report.cases.map((entry) => {\n const why = entry.error ?? entry.detail;\n return `${statusLabel[entry.status]} ${entry.name}${why == null ? '' : ` (${why})`}`;\n }),\n report.passed ? 'conformance: passed' : 'conformance: failed',\n];\n\nexport const runConformance = async (args: {\n module: string;\n exportName: string;\n profile: string;\n timeoutMs: number | null;\n json: boolean;\n cwd: string;\n output: OutputIface;\n importModule?: ImportModule;\n // SIGINT/SIGTERM (main.ts): the kit has no cancellation, so the command stops\n // waiting for it and the process exits.\n signal?: AbortSignal;\n}): Promise<number> => {\n const profile = z.nativeEnum(ConformanceProfile).safeParse(args.profile);\n if (!profile.success) {\n args.output.stderr(\n `error: --profile must be one of ${Object.values(ConformanceProfile).join(', ')}`,\n );\n return 2;\n }\n const url = pathToFileURL(resolve(args.cwd, args.module)).href;\n let loaded: ModuleNamespace;\n try {\n loaded = await (args.importModule ?? importModule)(url);\n } catch (cause) {\n args.output.stderr(\n `error: cannot load ${args.module}: ${cause instanceof Error ? cause.message : String(cause)}`,\n );\n return 1;\n }\n if (!(args.exportName in loaded)) {\n args.output.stderr(`error: ${args.module} has no export ${args.exportName}`);\n return 1;\n }\n const parsed = conformanceTargetOf(loaded[args.exportName]);\n if (!parsed.ok) {\n args.output.stderr(`error: ${args.module}#${args.exportName}: ${parsed.message}`);\n return 1;\n }\n const target = parsed.target;\n const run = runHarnessConformance({\n harness: target.harness,\n dial: target.dial,\n nativeSessionId: target.nativeSessionId,\n profile: profile.data,\n openArgs: conformanceOpenArgs(),\n timeoutMs: args.timeoutMs ?? undefined,\n cwd: args.cwd,\n });\n const signal = args.signal;\n const interrupted =\n signal == null\n ? null\n : new Promise<null>((done) => {\n if (signal.aborted) done(null);\n else signal.addEventListener('abort', () => done(null), { once: true });\n });\n const report = await (interrupted == null ? run : Promise.race([run, interrupted]));\n if (report == null) {\n run.catch(() => undefined);\n args.output.stderr('conformance: interrupted');\n return 130;\n }\n if (args.json) args.output.stdout(JSON.stringify(report, null, 2));\n else for (const line of reportLines(report)) args.output.stdout(line);\n return report.passed ? 0 : 1;\n};\n"],
5
+ "mappings": "AAAA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,OAAO,eAAe;AACtB,YAAY,OAAO;AACnB,SAAS,oBAA6D;AAmBtE,MAAM,gBAAgB,EAAE,SAAS;AACjC,MAAM,aAAa,CAAC,UAAiC,cAAc,UAAU,KAAK,EAAE;AAEpF,MAAM,uBAAuB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AAK;AAAA,EACZ,CAAC;AACD,QAAM,SAAS,KAAK;AACpB,QAAM,cACJ,UAAU,OACN,OACA,IAAI,QAAc,CAAC,SAAS;AAC1B,QAAI,OAAO,QAAS,MAAK,IAAI;AAAA,QACxB,QAAO,iBAAiB,SAAS,MAAM,KAAK,IAAI,GAAG,EAAE,MAAM,KAAK,CAAC;AAAA,EACxE,CAAC;AACP,QAAM,SAAS,OAAO,eAAe,OAAO,MAAM,QAAQ,KAAK,CAAC,KAAK,WAAW,CAAC;AACjF,MAAI,UAAU,MAAM;AAClB,QAAI,MAAM,MAAM,MAAS;AACzB,SAAK,OAAO,OAAO,0BAA0B;AAC7C,WAAO;AAAA,EACT;AACA,MAAI,KAAK,KAAM,MAAK,OAAO,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,MAC5D,YAAW,QAAQ,YAAY,MAAM,EAAG,MAAK,OAAO,OAAO,IAAI;AACpE,SAAO,OAAO,SAAS,IAAI;AAC7B;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/cli/main.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\nimport 'zod/compile';\nimport { runAgentsCommand } from \"./cli.mjs\";\n\n// `final-agents build|dev|publish|conformance`: `final agents \u2026` until a general `final` CLI exists.\n\nconst stop = new AbortController();\nfor (const signal of ['SIGINT', 'SIGTERM'] as const) process.once(signal, () => stop.abort());\n\nprocess.exit(\n await runAgentsCommand({\n argv: process.argv.slice(2),\n env: process.env,\n cwd: process.cwd(),\n signal: stop.signal,\n output: {\n stdout: (line) => process.stdout.write(`${line}\\n`),\n stderr: (line) => process.stderr.write(`${line}\\n`),\n },\n }),\n);\n"],
4
+ "sourcesContent": ["#!/usr/bin/env node\nimport 'zod/compile';\nimport { runAgentsCommand } from \"./cli.mjs\";\n\n// `final-agents print|publish|conformance`: `final agents \u2026` until a general `final` CLI exists.\n\nconst stop = new AbortController();\nfor (const signal of ['SIGINT', 'SIGTERM'] as const) process.once(signal, () => stop.abort());\n\nprocess.exit(\n await runAgentsCommand({\n argv: process.argv.slice(2),\n env: process.env,\n cwd: process.cwd(),\n signal: stop.signal,\n output: {\n stdout: (line) => process.stdout.write(`${line}\\n`),\n stderr: (line) => process.stderr.write(`${line}\\n`),\n },\n }),\n);\n"],
5
5
  "mappings": ";AACA,OAAO;AACP,SAAS,wBAAwB;AAIjC,MAAM,OAAO,IAAI,gBAAgB;AACjC,WAAW,UAAU,CAAC,UAAU,SAAS,EAAY,SAAQ,KAAK,QAAQ,MAAM,KAAK,MAAM,CAAC;AAE5F,QAAQ;AAAA,EACN,MAAM,iBAAiB;AAAA,IACrB,MAAM,QAAQ,KAAK,MAAM,CAAC;AAAA,IAC1B,KAAK,QAAQ;AAAA,IACb,KAAK,QAAQ,IAAI;AAAA,IACjB,QAAQ,KAAK;AAAA,IACb,QAAQ;AAAA,MACN,QAAQ,CAAC,SAAS,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAAA,MAClD,QAAQ,CAAC,SAAS,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAAA,IACpD;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,14 +1,5 @@
1
- import type { CompatibilityReportIface } from '@finalai/agent-definition/compatibility';
2
- import type { DiagnosticIface } from '@finalai/agent-definition/compiler';
3
- import { type AgentManifestIface } from '@finalai/agent-provider';
4
- import { type PublishResultIface } from "../agent-client/index.mjs";
5
1
  export interface OutputIface {
6
2
  stdout: (line: string) => void;
7
3
  stderr: (line: string) => void;
8
4
  }
9
- export declare const manifestSummaryLines: (manifest: AgentManifestIface) => string[];
10
- export declare const hookLines: (manifest: AgentManifestIface) => string[];
11
- export declare const reportLines: (report: CompatibilityReportIface) => string[];
12
- export declare const diagnosticLine: (item: DiagnosticIface) => string;
13
5
  export declare const errorLines: (cause: unknown) => string[];
14
- export declare const publishResultLines: (result: PublishResultIface) => string[];