@finalai/agent-provider 0.8.0 → 0.10.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 (200) hide show
  1. package/HOSTING.md +334 -245
  2. package/README.md +93 -14
  3. package/dist/modules/canonical-json.d.mts +4 -0
  4. package/dist/modules/canonical-json.mjs +33 -0
  5. package/dist/modules/canonical-json.mjs.map +7 -0
  6. package/dist/modules/channel.d.mts +9 -3
  7. package/dist/modules/channel.mjs.map +2 -2
  8. package/dist/modules/code-host/host.d.mts +10 -0
  9. package/dist/modules/code-host/host.mjs +88 -0
  10. package/dist/modules/code-host/host.mjs.map +7 -0
  11. package/dist/modules/code-host/in-process.d.mts +24 -0
  12. package/dist/modules/code-host/in-process.mjs +89 -0
  13. package/dist/modules/code-host/in-process.mjs.map +7 -0
  14. package/dist/modules/code-host/index.d.mts +4 -0
  15. package/dist/modules/code-host/index.mjs +5 -0
  16. package/dist/modules/code-host/index.mjs.map +7 -0
  17. package/dist/modules/code-host/serverless.d.mts +63 -0
  18. package/dist/modules/code-host/serverless.mjs +27 -0
  19. package/dist/modules/code-host/serverless.mjs.map +7 -0
  20. package/dist/modules/code-host/types.d.mts +152 -0
  21. package/dist/modules/code-host/types.mjs +85 -0
  22. package/dist/modules/code-host/types.mjs.map +7 -0
  23. package/dist/modules/conformance/agent.mjs +72 -6
  24. package/dist/modules/conformance/agent.mjs.map +2 -2
  25. package/dist/modules/conformance/harness-kit.d.mts +9 -2
  26. package/dist/modules/conformance/harness-kit.mjs +224 -63
  27. package/dist/modules/conformance/harness-kit.mjs.map +3 -3
  28. package/dist/modules/conformance/local-harness.d.mts +1 -4
  29. package/dist/modules/conformance/local-harness.mjs +21 -22
  30. package/dist/modules/conformance/local-harness.mjs.map +2 -2
  31. package/dist/modules/conformance/protocol.d.mts +1 -0
  32. package/dist/modules/conformance/protocol.mjs +2 -0
  33. package/dist/modules/conformance/protocol.mjs.map +2 -2
  34. package/dist/modules/conformance/sandbox-kit.d.mts +12 -4
  35. package/dist/modules/conformance/sandbox-kit.mjs +189 -103
  36. package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
  37. package/dist/modules/conformance/scripted-model/chat-completions.mjs +1 -0
  38. package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +2 -2
  39. package/dist/modules/conformance/scripted-model/directives.d.mts +3 -0
  40. package/dist/modules/conformance/scripted-model/directives.mjs +26 -10
  41. package/dist/modules/conformance/scripted-model/directives.mjs.map +2 -2
  42. package/dist/modules/conformance/scripted-model/messages.mjs +1 -0
  43. package/dist/modules/conformance/scripted-model/messages.mjs.map +2 -2
  44. package/dist/modules/conformance/scripted-model/responses.mjs +2 -0
  45. package/dist/modules/conformance/scripted-model/responses.mjs.map +2 -2
  46. package/dist/modules/conformance/stdio.d.mts +21 -0
  47. package/dist/modules/conformance/stdio.mjs +158 -0
  48. package/dist/modules/conformance/stdio.mjs.map +7 -0
  49. package/dist/modules/credential-routes.d.mts +2 -0
  50. package/dist/modules/credential-routes.mjs +2 -0
  51. package/dist/modules/credential-routes.mjs.map +2 -2
  52. package/dist/modules/document.d.mts +376 -0
  53. package/dist/modules/document.mjs +208 -0
  54. package/dist/modules/document.mjs.map +7 -0
  55. package/dist/modules/harness-configuration.d.mts +16 -0
  56. package/dist/modules/harness-configuration.mjs +83 -0
  57. package/dist/modules/harness-configuration.mjs.map +7 -0
  58. package/dist/modules/harness-definition.d.mts +280 -0
  59. package/dist/modules/harness-definition.mjs +430 -0
  60. package/dist/modules/harness-definition.mjs.map +7 -0
  61. package/dist/modules/harness-provider.d.mts +197 -0
  62. package/dist/modules/harness-provider.mjs +108 -0
  63. package/dist/modules/harness-provider.mjs.map +7 -0
  64. package/dist/modules/harness-requirements.d.mts +19 -0
  65. package/dist/modules/harness-requirements.mjs +40 -0
  66. package/dist/modules/harness-requirements.mjs.map +7 -0
  67. package/dist/modules/harness-start.d.mts +33 -0
  68. package/dist/modules/harness-start.mjs +107 -0
  69. package/dist/modules/harness-start.mjs.map +7 -0
  70. package/dist/modules/harness.d.mts +84 -109
  71. package/dist/modules/harness.mjs +56 -111
  72. package/dist/modules/harness.mjs.map +3 -3
  73. package/dist/modules/identity.d.mts +1 -0
  74. package/dist/modules/identity.mjs +2 -0
  75. package/dist/modules/identity.mjs.map +7 -0
  76. package/dist/modules/index.d.mts +12 -6
  77. package/dist/modules/index.mjs +12 -6
  78. package/dist/modules/index.mjs.map +2 -2
  79. package/dist/modules/inference.d.mts +35 -0
  80. package/dist/modules/inference.mjs +74 -0
  81. package/dist/modules/inference.mjs.map +7 -0
  82. package/dist/modules/local-channel-context.mjs +3 -1
  83. package/dist/modules/local-channel-context.mjs.map +2 -2
  84. package/dist/modules/requirements-check.d.mts +30 -0
  85. package/dist/modules/requirements-check.mjs +164 -0
  86. package/dist/modules/requirements-check.mjs.map +7 -0
  87. package/dist/modules/room-surface.d.mts +0 -5
  88. package/dist/modules/room-surface.mjs.map +2 -2
  89. package/dist/modules/sandbox/client.d.mts +3 -0
  90. package/dist/modules/sandbox/client.mjs +101 -18
  91. package/dist/modules/sandbox/client.mjs.map +2 -2
  92. package/dist/modules/sandbox/grant.d.mts +78 -0
  93. package/dist/modules/sandbox/grant.mjs +134 -0
  94. package/dist/modules/sandbox/grant.mjs.map +7 -0
  95. package/dist/modules/sandbox/index.d.mts +3 -3
  96. package/dist/modules/sandbox/index.mjs +4 -5
  97. package/dist/modules/sandbox/index.mjs.map +2 -2
  98. package/dist/modules/sandbox/mcp-hosted.d.mts +1 -1
  99. package/dist/modules/sandbox/mcp-hosted.mjs +4 -7
  100. package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
  101. package/dist/modules/sandbox/mcp.d.mts +4 -2
  102. package/dist/modules/sandbox/mcp.mjs +14 -7
  103. package/dist/modules/sandbox/mcp.mjs.map +2 -2
  104. package/dist/modules/sandbox/memory-sandbox.d.mts +2 -1
  105. package/dist/modules/sandbox/memory-sandbox.mjs +71 -41
  106. package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
  107. package/dist/modules/sandbox/networking.d.mts +7 -7
  108. package/dist/modules/sandbox/networking.mjs +16 -9
  109. package/dist/modules/sandbox/networking.mjs.map +2 -2
  110. package/dist/modules/sandbox/remote/adapter.d.mts +30 -0
  111. package/dist/modules/sandbox/remote/adapter.mjs +381 -0
  112. package/dist/modules/sandbox/remote/adapter.mjs.map +7 -0
  113. package/dist/modules/sandbox/remote/errors.d.mts +10 -0
  114. package/dist/modules/sandbox/remote/errors.mjs +62 -0
  115. package/dist/modules/sandbox/remote/errors.mjs.map +7 -0
  116. package/dist/modules/sandbox/remote/index.d.mts +5 -0
  117. package/dist/modules/sandbox/remote/index.mjs +6 -0
  118. package/dist/modules/sandbox/remote/index.mjs.map +7 -0
  119. package/dist/modules/sandbox/remote/ndjson.d.mts +6 -0
  120. package/dist/modules/sandbox/remote/ndjson.mjs +80 -0
  121. package/dist/modules/sandbox/remote/ndjson.mjs.map +7 -0
  122. package/dist/modules/sandbox/remote/platform-api.d.mts +8 -0
  123. package/dist/modules/sandbox/remote/platform-api.mjs +15 -0
  124. package/dist/modules/sandbox/remote/platform-api.mjs.map +7 -0
  125. package/dist/modules/sandbox/remote/preamble.d.mts +7 -0
  126. package/dist/modules/sandbox/remote/preamble.mjs +51 -0
  127. package/dist/modules/sandbox/remote/preamble.mjs.map +7 -0
  128. package/dist/modules/sandbox/remote/serve.d.mts +34 -0
  129. package/dist/modules/sandbox/remote/serve.mjs +519 -0
  130. package/dist/modules/sandbox/remote/serve.mjs.map +7 -0
  131. package/dist/modules/sandbox/remote/testing.d.mts +34 -0
  132. package/dist/modules/sandbox/remote/testing.mjs +275 -0
  133. package/dist/modules/sandbox/remote/testing.mjs.map +7 -0
  134. package/dist/modules/sandbox/seeds.d.mts +2 -2
  135. package/dist/modules/sandbox/seeds.mjs +2 -2
  136. package/dist/modules/sandbox/seeds.mjs.map +2 -2
  137. package/dist/modules/sandbox/server.d.mts +4 -6
  138. package/dist/modules/sandbox/server.mjs +93 -49
  139. package/dist/modules/sandbox/server.mjs.map +2 -2
  140. package/dist/modules/sandbox/setup/apply.d.mts +41 -0
  141. package/dist/modules/sandbox/setup/apply.mjs +204 -0
  142. package/dist/modules/sandbox/setup/apply.mjs.map +7 -0
  143. package/dist/modules/sandbox/setup/describe.d.mts +10 -0
  144. package/dist/modules/sandbox/setup/describe.mjs +62 -0
  145. package/dist/modules/sandbox/setup/describe.mjs.map +7 -0
  146. package/dist/modules/sandbox/setup/index.d.mts +6 -0
  147. package/dist/modules/sandbox/setup/index.mjs +17 -0
  148. package/dist/modules/sandbox/setup/index.mjs.map +7 -0
  149. package/dist/modules/sandbox/setup/paths.d.mts +8 -0
  150. package/dist/modules/sandbox/setup/paths.mjs +18 -0
  151. package/dist/modules/sandbox/setup/paths.mjs.map +7 -0
  152. package/dist/modules/sandbox/setup/schema.d.mts +42 -0
  153. package/dist/modules/sandbox/setup/schema.mjs +58 -0
  154. package/dist/modules/sandbox/setup/schema.mjs.map +7 -0
  155. package/dist/modules/sandbox/tool-policy.d.mts +1 -1
  156. package/dist/modules/sandbox/tool-policy.mjs +1 -1
  157. package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
  158. package/dist/modules/sandbox/types.d.mts +117 -130
  159. package/dist/modules/sandbox/types.mjs +46 -50
  160. package/dist/modules/sandbox/types.mjs.map +3 -3
  161. package/dist/modules/sandbox/wire.d.mts +93 -6
  162. package/dist/modules/sandbox/wire.mjs +61 -38
  163. package/dist/modules/sandbox/wire.mjs.map +2 -2
  164. package/dist/modules/schemas.d.mts +5 -76
  165. package/dist/modules/schemas.mjs +18 -85
  166. package/dist/modules/schemas.mjs.map +2 -2
  167. package/dist/modules/tool-annotations.d.mts +15 -6
  168. package/dist/modules/tool-annotations.mjs +9 -3
  169. package/dist/modules/tool-annotations.mjs.map +2 -2
  170. package/dist/modules/tool-descriptor.d.mts +16 -0
  171. package/dist/modules/tool-descriptor.mjs +19 -0
  172. package/dist/modules/tool-descriptor.mjs.map +7 -0
  173. package/dist/modules/tool-patterns.d.mts +7 -7
  174. package/dist/modules/tool-patterns.mjs +10 -9
  175. package/dist/modules/tool-patterns.mjs.map +2 -2
  176. package/package.json +86 -36
  177. package/dist/modules/credentials.d.mts +0 -206
  178. package/dist/modules/credentials.mjs +0 -207
  179. package/dist/modules/credentials.mjs.map +0 -7
  180. package/dist/modules/dynamic.d.mts +0 -40
  181. package/dist/modules/dynamic.mjs +0 -79
  182. package/dist/modules/dynamic.mjs.map +0 -7
  183. package/dist/modules/hosted-bindings.d.mts +0 -15
  184. package/dist/modules/hosted-bindings.mjs +0 -21
  185. package/dist/modules/hosted-bindings.mjs.map +0 -7
  186. package/dist/modules/manifest.d.mts +0 -787
  187. package/dist/modules/manifest.mjs +0 -320
  188. package/dist/modules/manifest.mjs.map +0 -7
  189. package/dist/modules/provider-ref.d.mts +0 -29
  190. package/dist/modules/provider-ref.mjs +0 -55
  191. package/dist/modules/provider-ref.mjs.map +0 -7
  192. package/dist/modules/sandbox/open-scope-node.d.mts +0 -4
  193. package/dist/modules/sandbox/open-scope-node.mjs +0 -19
  194. package/dist/modules/sandbox/open-scope-node.mjs.map +0 -7
  195. package/dist/modules/sandbox/open-scope.d.mts +0 -16
  196. package/dist/modules/sandbox/open-scope.mjs +0 -66
  197. package/dist/modules/sandbox/open-scope.mjs.map +0 -7
  198. package/dist/modules/sandbox/workspace-identity.d.mts +0 -5
  199. package/dist/modules/sandbox/workspace-identity.mjs +0 -14
  200. package/dist/modules/sandbox/workspace-identity.mjs.map +0 -7
@@ -7,7 +7,9 @@ import {
7
7
  accumulateAgentMessages,
8
8
  acpSchemas,
9
9
  advertisedFinalExtensions,
10
+ FINAL_LIVE_TEXT_METHOD,
10
11
  isUnsupportedProtocolVersionError,
12
+ liveTextParamsSchema,
11
13
  jsonValueSchema,
12
14
  MAX_ACP_FRAME_BYTES,
13
15
  MAX_INLINE_MEDIA_BYTES,
@@ -15,15 +17,18 @@ import {
15
17
  RESOURCE_LINK_DESCRIPTION_BYTES,
16
18
  resumeReplayFor,
17
19
  serializedFrameBytes,
20
+ readFinalMetaOf,
18
21
  watchInitializeVersion
19
22
  } from "@finalai/acp-session";
20
23
  import * as z from "zod";
21
24
  import {
22
- harnessDescriptionSchema,
23
25
  McpTransportKind,
24
26
  PromptWhileRunning
25
27
  } from "../harness.mjs";
26
- import { emptyManifest } from "../manifest.mjs";
28
+ import { harnessSettingsSchema } from "@finalai/agent-protocol/agent-platform";
29
+ import { validateHarnessConfiguration } from "../harness-configuration.mjs";
30
+ import { harnessDefinitionSchema } from "../harness-definition.mjs";
31
+ import { agentDocumentSchema } from "../document.mjs";
27
32
  import {
28
33
  answerConformanceMcpMessage,
29
34
  createConformanceMcpHttpHandler
@@ -32,6 +37,7 @@ import {
32
37
  CONFORMANCE_ACP_SERVER_ID,
33
38
  CONFORMANCE_ACP_SERVER_NAME,
34
39
  CONFORMANCE_ELICITATION_ANSWER,
40
+ CONFORMANCE_HARNESS_NAME,
35
41
  CONFORMANCE_HTTP_SERVER_NAME,
36
42
  CONFORMANCE_MCP_TOOL,
37
43
  ConformanceDirective,
@@ -43,9 +49,16 @@ import {
43
49
  import { createLegacyProtocolAgent } from "./v1-agent.mjs";
44
50
  var ConformanceProfile = /* @__PURE__ */ ((ConformanceProfile2) => {
45
51
  ConformanceProfile2["Final"] = "final";
52
+ ConformanceProfile2["FinalRequired"] = "final-required";
46
53
  ConformanceProfile2["PlainAcpV2"] = "plain-acp-v2";
47
54
  return ConformanceProfile2;
48
55
  })(ConformanceProfile || {});
56
+ const REQUIRED_FINAL_SUPPORTS = [
57
+ "observe",
58
+ "authorMeta",
59
+ "resumeReplay",
60
+ "afterSeqReplay"
61
+ ];
49
62
  var ConformanceCaseStatus = /* @__PURE__ */ ((ConformanceCaseStatus2) => {
50
63
  ConformanceCaseStatus2["Passed"] = "passed";
51
64
  ConformanceCaseStatus2["Failed"] = "failed";
@@ -56,9 +69,12 @@ var HarnessConformanceCase = /* @__PURE__ */ ((HarnessConformanceCase2) => {
56
69
  HarnessConformanceCase2["Describe"] = "describe";
57
70
  HarnessConformanceCase2["Open"] = "open";
58
71
  HarnessConformanceCase2["Initialize"] = "initialize";
72
+ HarnessConformanceCase2["Advertisement"] = "final extensions advertised";
59
73
  HarnessConformanceCase2["NewSession"] = "session/new";
60
74
  HarnessConformanceCase2["Prompt"] = "prompt";
61
75
  HarnessConformanceCase2["Stream"] = "stream";
76
+ HarnessConformanceCase2["LiveText"] = "live text";
77
+ HarnessConformanceCase2["AuthorMeta"] = "author meta";
62
78
  HarnessConformanceCase2["Permission"] = "permission";
63
79
  HarnessConformanceCase2["Elicitation"] = "elicitation";
64
80
  HarnessConformanceCase2["McpAcp"] = "mcp over acp";
@@ -67,6 +83,7 @@ var HarnessConformanceCase = /* @__PURE__ */ ((HarnessConformanceCase2) => {
67
83
  HarnessConformanceCase2["ErrorStop"] = "error stop";
68
84
  HarnessConformanceCase2["Cancel"] = "cancel";
69
85
  HarnessConformanceCase2["ResumeReplay"] = "resume with replay";
86
+ HarnessConformanceCase2["Fork"] = "fork";
70
87
  HarnessConformanceCase2["ParkResume"] = "park/resume";
71
88
  HarnessConformanceCase2["PromptWhileRunning"] = "prompt while running";
72
89
  HarnessConformanceCase2["CancelWhileRunning"] = "cancel reaching a prompt sent while running";
@@ -164,41 +181,38 @@ const providerErrorSchema = z.object({
164
181
  providerError: z.object({ code: z.string(), message: z.string(), retryable: z.boolean() })
165
182
  })
166
183
  });
167
- const conformanceOpenArgs = (overrides = {}) => {
168
- const manifest = emptyManifest("Conformance");
169
- return {
170
- session: {
171
- sessionId: crypto.randomUUID(),
172
- organizationId: crypto.randomUUID(),
173
- definitionId: crypto.randomUUID(),
174
- revisionId: crypto.randomUUID(),
175
- sessionServiceUrl: "http://conformance.invalid"
176
- },
177
- harnessSessionId: crypto.randomUUID(),
178
- config: {},
179
- manifest: {
180
- ...manifest,
181
- harness: { harness: manifest.harness.harness, config: {} },
182
- mcpServers: [],
183
- sandboxes: {}
184
- },
185
- mcpServers: [],
186
- baseTools: {},
187
- sandboxes: {},
188
- credentials: {
189
- brokerUrl: "http://conformance.invalid/broker",
190
- grants: [],
191
- atOpen: null,
192
- refresh: null
193
- },
194
- secrets: { get: async () => null },
195
- trace: { traceparent: null, tracestate: null },
196
- ...overrides
197
- };
198
- };
184
+ const conformanceOpenArgs = (overrides = {}) => ({
185
+ session: {
186
+ sessionId: crypto.randomUUID(),
187
+ organizationId: crypto.randomUUID(),
188
+ projectId: crypto.randomUUID(),
189
+ agent: `sha256:${"0".repeat(64)}`,
190
+ definitionId: null,
191
+ sessionServiceUrl: "http://conformance.invalid"
192
+ },
193
+ harnessSessionId: crypto.randomUUID(),
194
+ document: agentDocumentSchema.parse({
195
+ version: 5,
196
+ identity: { name: "Conformance" },
197
+ require: { harness: { permissionMode: "auto" } }
198
+ }),
199
+ settings: harnessSettingsSchema.parse({ harness: CONFORMANCE_HARNESS_NAME }),
200
+ mcpServers: [],
201
+ compute: {},
202
+ credentials: {
203
+ brokerUrl: "http://conformance.invalid/broker",
204
+ grants: [],
205
+ atOpen: null,
206
+ refresh: null
207
+ },
208
+ secrets: { get: async () => null },
209
+ trace: { traceparent: null, tracestate: null },
210
+ ...overrides
211
+ });
199
212
  const runHarnessConformance = async (args) => {
200
- const profile = args.profile === "final" /* Final */ ? "final" /* Final */ : "plain-acp-v2" /* PlainAcpV2 */;
201
- const final = profile === "final" /* Final */;
213
+ const profile = args.profile === "final" /* Final */ ? "final" /* Final */ : args.profile === "final-required" /* FinalRequired */ ? "final-required" /* FinalRequired */ : "plain-acp-v2" /* PlainAcpV2 */;
214
+ const final = profile !== "plain-acp-v2" /* PlainAcpV2 */;
215
+ const required = profile === "final-required" /* FinalRequired */;
202
216
  const timeoutMs = args.timeoutMs ?? 15e3;
203
217
  const replayGraceMs = args.replayGraceMs ?? 300;
204
218
  const cwd = args.cwd ?? "/workspace";
@@ -230,6 +244,7 @@ const runHarnessConformance = async (args) => {
230
244
  };
231
245
  const knownSessions = /* @__PURE__ */ new Set();
232
246
  const foreignUpdates = [];
247
+ const liveTexts = [];
233
248
  const kitClient = client({ name: "final-conformance-kit" }).onRequest(methods.client.session.requestPermission, ({ params, requestId }) => {
234
249
  permissionRequests.push({ optionKinds: params.options.map((option2) => option2.kind) });
235
250
  permissionIds.push({ requestId, epoch });
@@ -251,6 +266,8 @@ const runHarnessConformance = async (args) => {
251
266
  const log = logFor(params.sessionId);
252
267
  log.items.push(params.update);
253
268
  for (const listener of [...log.listeners]) listener();
269
+ }).onNotification(FINAL_LIVE_TEXT_METHOD, liveTextParamsSchema, ({ params }) => {
270
+ liveTexts.push(params);
254
271
  });
255
272
  const waitFor = (sessionId2, predicate, what) => {
256
273
  const log = logFor(sessionId2);
@@ -268,8 +285,8 @@ const runHarnessConformance = async (args) => {
268
285
  what
269
286
  );
270
287
  };
271
- let description = null;
272
- const described = () => description;
288
+ let definition = null;
289
+ const described = () => definition;
273
290
  let endpoint = null;
274
291
  let connection = null;
275
292
  let stream = null;
@@ -277,10 +294,12 @@ const runHarnessConformance = async (args) => {
277
294
  let sessionId = null;
278
295
  let mcpServers = [];
279
296
  let firstPrompt = null;
297
+ let streamed = null;
298
+ const streamedTurn = () => streamed;
280
299
  let echoText = "";
281
300
  const step = async (name, options, run) => {
282
301
  const started = Date.now();
283
- const missing = (options.requires ?? []).filter((required) => !passed.has(required));
302
+ const missing = (options.requires ?? []).filter((required2) => !passed.has(required2));
284
303
  const skip = args.surfaceLimits?.[name] ?? options.skip ?? null;
285
304
  if (skip != null || missing.length > 0) {
286
305
  cases.push({
@@ -330,18 +349,19 @@ const runHarnessConformance = async (args) => {
330
349
  replyExpected: true
331
350
  }
332
351
  };
333
- const sendPrompt = async (text) => {
334
- const id = requireSession();
352
+ const sendBlocks = async (prompt, target) => {
353
+ const id = target ?? requireSession();
335
354
  const from = logFor(id).items.length;
336
355
  const response = await requireConnection().agent.request(methods.agent.session.prompt, {
337
356
  sessionId: id,
338
- prompt: [{ type: "text", text }],
357
+ prompt,
339
358
  _meta: promptMeta
340
359
  });
341
360
  return { messageId: response.messageId, from };
342
361
  };
343
- const awaitTurn = async (sent) => {
344
- const id = requireSession();
362
+ const sendPrompt = (text, target) => sendBlocks([{ type: "text", text }], target);
363
+ const awaitTurn = async (sent, target) => {
364
+ const id = target ?? requireSession();
345
365
  const hasIdle = (items2) => items2.slice(sent.from).some(isIdle);
346
366
  await waitFor(id, hasIdle, "turn end");
347
367
  const items = logFor(id).items;
@@ -363,7 +383,8 @@ const runHarnessConformance = async (args) => {
363
383
  text: textOfUpdates(updates)
364
384
  };
365
385
  };
366
- const turn = async (text) => awaitTurn(await sendPrompt(text));
386
+ const turn = async (text, target) => awaitTurn(await sendPrompt(text, target), target);
387
+ const keepsReplay = () => described()?.supports.resumeReplay === true || required && advertised.resumeReplay === true;
367
388
  const tap = (inner) => {
368
389
  const writer = inner.writable.getWriter();
369
390
  const writable = new WritableStream({
@@ -434,7 +455,7 @@ const runHarnessConformance = async (args) => {
434
455
  const reconnect = async (next) => {
435
456
  endpoint = next.resumed;
436
457
  await connect(next.resumed);
437
- const keeps = next.resumed.ref.generation === next.previous.ref.generation && described()?.supports.resumeReplay === true;
458
+ const keeps = next.resumed.ref.generation === next.previous.ref.generation && keepsReplay();
438
459
  if (keeps) {
439
460
  await requireConnection().agent.request(methods.agent.session.resume, {
440
461
  sessionId: requireSession(),
@@ -498,13 +519,19 @@ const runHarnessConformance = async (args) => {
498
519
  );
499
520
  try {
500
521
  await step("describe" /* Describe */, {}, async () => {
501
- description = harnessDescriptionSchema.parse(
502
- await args.harness.describe({
503
- config: args.openArgs.config,
504
- secrets: args.openArgs.secrets
505
- })
522
+ const parsed = harnessDefinitionSchema.safeParse(args.harness.definition);
523
+ check(parsed.success, `the harness definition is invalid: ${parsed.error?.message ?? ""}`);
524
+ const read = parsed.data ?? args.harness.definition;
525
+ definition = read;
526
+ const acceptance = validateHarnessConfiguration({
527
+ definition: read,
528
+ configuration: args.openArgs.settings.configuration
529
+ });
530
+ check(
531
+ acceptance.valid,
532
+ `the definition refuses the configuration the harness is opened with: ${acceptance.problems.join("; ")}`
506
533
  );
507
- return `transports ${description.acp.transports.join(", ")}; mcp ${description.acp.mcp.join(", ") || "none"}`;
534
+ return `interface ${read.interface}; mcp ${read.mcp.join(", ") || "none"}`;
508
535
  });
509
536
  await step(
510
537
  "open" /* Open */,
@@ -528,6 +555,27 @@ const runHarnessConformance = async (args) => {
528
555
  return `${response.info.name} ${response.info.version}`;
529
556
  }
530
557
  );
558
+ await step(
559
+ "final extensions advertised" /* Advertisement */,
560
+ {
561
+ requires: ["initialize" /* Initialize */],
562
+ skip: final ? null : "not part of the plain ACP v2 profile"
563
+ },
564
+ async () => {
565
+ const missing = REQUIRED_FINAL_SUPPORTS.filter((flag) => advertised[flag] !== true);
566
+ if (required) {
567
+ check(advertised.finalAware, 'initialize advertises no _meta["final.ai"]');
568
+ check(
569
+ missing.length === 0,
570
+ `initialize does not advertise supports ${missing.join(", ")}`
571
+ );
572
+ }
573
+ const supported = [...REQUIRED_FINAL_SUPPORTS, "fork"].filter(
574
+ (flag) => advertised[flag] === true
575
+ );
576
+ return advertised.finalAware ? `supports ${supported.join(", ") || "nothing"}${advertised.program == null ? "" : `; program ${advertised.program}`}` : "no Final extensions advertised";
577
+ }
578
+ );
531
579
  const httpFixture = args.httpMcp == null ? null : await (async () => {
532
580
  const fixture = createConformanceMcpHttpHandler(nonce);
533
581
  const served = await args.httpMcp?.serve(fixture.fetch);
@@ -541,7 +589,7 @@ const runHarnessConformance = async (args) => {
541
589
  "session/new" /* NewSession */,
542
590
  { requires: ["initialize" /* Initialize */] },
543
591
  async () => {
544
- const mcp = described()?.acp.mcp ?? [];
592
+ const mcp = described()?.mcp ?? [];
545
593
  mcpServers = [...args.openArgs.mcpServers];
546
594
  if (mcp.includes(McpTransportKind.Acp)) {
547
595
  mcpServers.push({
@@ -597,9 +645,88 @@ const runHarnessConformance = async (args) => {
597
645
  result.stopReason === "end_turn",
598
646
  `stopReason ${result.stopReason}, expected end_turn`
599
647
  );
648
+ streamed = result;
600
649
  return `${result.updates.length} updates`;
601
650
  }
602
651
  );
652
+ await step(
653
+ "live text" /* LiveText */,
654
+ {
655
+ requires: ["stream" /* Stream */],
656
+ skip: !final ? "not part of the plain ACP v2 profile" : !required && liveTexts.length === 0 ? "the agent sent no _final/live_text" : null
657
+ },
658
+ async () => {
659
+ const result = streamedTurn();
660
+ if (result == null) throw failure("no streamed turn");
661
+ const id = requireSession();
662
+ const chunks = result.updates.filter(
663
+ (update) => update.sessionUpdate === "agent_message_chunk"
664
+ );
665
+ if (required) {
666
+ const unstamped = chunks.filter((chunk) => readFinalMetaOf(chunk).emittedAtMs == null);
667
+ check(
668
+ unstamped.length === 0,
669
+ `${unstamped.length} of ${chunks.length} agent_message_chunk updates carry no _meta["final.ai"].emittedAtMs`
670
+ );
671
+ }
672
+ const texts = /* @__PURE__ */ new Map();
673
+ for (const message of accumulateAgentMessages(result.updates)) {
674
+ texts.set(message.messageId, message.text);
675
+ }
676
+ const live = liveTexts.filter(
677
+ (entry) => entry.sessionId === id && texts.has(entry.messageId)
678
+ );
679
+ check(live.length > 0, "no _final/live_text was sent for the streamed agent message");
680
+ for (const entry of live) {
681
+ const record = texts.get(entry.messageId) ?? "";
682
+ check(
683
+ record.slice(entry.offset, entry.offset + entry.text.length) === entry.text,
684
+ `live text ${JSON.stringify(entry.text)} at offset ${entry.offset} does not match the message record ${JSON.stringify(record)}`
685
+ );
686
+ }
687
+ for (const [messageId, record] of texts) {
688
+ const covered = Array.from({ length: record.length }, () => false);
689
+ for (const entry of live.filter((candidate) => candidate.messageId === messageId)) {
690
+ for (let index = 0; index < entry.text.length; index += 1) {
691
+ covered[entry.offset + index] = true;
692
+ }
693
+ }
694
+ check(
695
+ covered.every(Boolean),
696
+ `live text did not cover the whole of message ${messageId}`
697
+ );
698
+ }
699
+ return `${live.length} live text notifications`;
700
+ }
701
+ );
702
+ await step(
703
+ "author meta" /* AuthorMeta */,
704
+ {
705
+ requires: sessionCases,
706
+ skip: !final ? "not part of the plain ACP v2 profile" : !required && !advertised.authorMeta ? "the agent does not advertise supports.authorMeta" : null
707
+ },
708
+ async () => {
709
+ check(advertised.authorMeta, "initialize does not advertise supports.authorMeta");
710
+ const name = `Author ${nonce}`;
711
+ const result = await awaitTurn(
712
+ await sendBlocks([
713
+ {
714
+ type: "text",
715
+ text: directive(ConformanceDirective.History),
716
+ _meta: {
717
+ [FINAL_META_KEY]: {
718
+ author: { participantId: "conformance-author", kind: "user", displayName: name }
719
+ }
720
+ }
721
+ }
722
+ ])
723
+ );
724
+ check(
725
+ result.text.includes(name),
726
+ `the author ${JSON.stringify(name)} in _meta["final.ai"].author did not reach the model`
727
+ );
728
+ }
729
+ );
603
730
  await step("permission" /* Permission */, { requires: sessionCases }, async () => {
604
731
  const before = permissionRequests.length;
605
732
  const result = await turn(directive(ConformanceDirective.Permission));
@@ -631,7 +758,7 @@ const runHarnessConformance = async (args) => {
631
758
  "mcp over acp" /* McpAcp */,
632
759
  {
633
760
  requires: sessionCases,
634
- skip: described()?.acp.mcp.includes(McpTransportKind.Acp) === true ? null : "harness does not accept acp MCP servers"
761
+ skip: described()?.mcp.includes(McpTransportKind.Acp) === true ? null : "harness does not accept acp MCP servers"
635
762
  },
636
763
  async () => {
637
764
  const before = mcpMessages.length;
@@ -656,7 +783,7 @@ const runHarnessConformance = async (args) => {
656
783
  "mcp over http" /* McpHttp */,
657
784
  {
658
785
  requires: sessionCases,
659
- skip: described()?.acp.mcp.includes(McpTransportKind.Http) !== true ? "harness does not accept http MCP servers" : httpFixture == null ? "no httpMcp host given" : null
786
+ skip: described()?.mcp.includes(McpTransportKind.Http) !== true ? "harness does not accept http MCP servers" : httpFixture == null ? "no httpMcp host given" : null
660
787
  },
661
788
  async () => {
662
789
  const result = await turn(
@@ -676,9 +803,10 @@ const runHarnessConformance = async (args) => {
676
803
  "observe" /* Observe */,
677
804
  {
678
805
  requires: sessionCases,
679
- skip: !final ? "not part of the plain ACP v2 profile" : described()?.supports.observe !== true ? "harness does not declare supports.observe" : null
806
+ skip: !final ? "not part of the plain ACP v2 profile" : !required && described()?.supports.observe !== true ? "harness does not declare supports.observe" : null
680
807
  },
681
808
  async () => {
809
+ if (required) check(advertised.observe, "initialize does not advertise supports.observe");
682
810
  const id = requireSession();
683
811
  const observed = `observed-${nonce}`;
684
812
  const before = logFor(id).items.length;
@@ -730,9 +858,15 @@ const runHarnessConformance = async (args) => {
730
858
  "resume with replay" /* ResumeReplay */,
731
859
  {
732
860
  requires: ["stream" /* Stream */],
733
- skip: described()?.supports.resumeReplay === true ? null : "harness does not declare supports.resumeReplay (resume re-seeds with session/new)"
861
+ skip: required || keepsReplay() ? null : "harness does not declare supports.resumeReplay (resume re-seeds with session/new)"
734
862
  },
735
863
  async () => {
864
+ if (required) {
865
+ check(
866
+ advertised.resumeReplay === true,
867
+ "initialize does not advertise supports.resumeReplay"
868
+ );
869
+ }
736
870
  const id = requireSession();
737
871
  if (endpoint == null) throw failure("no endpoint");
738
872
  const previous = endpoint;
@@ -757,6 +891,7 @@ const runHarnessConformance = async (args) => {
757
891
  );
758
892
  if (!final) return `${replayed.length} updates replayed`;
759
893
  if (!advertised.afterSeqReplay) {
894
+ check(!required, "initialize does not advertise supports.afterSeqReplay");
760
895
  return `${replayed.length} updates replayed; _final/after_seq not advertised`;
761
896
  }
762
897
  const tail = 2;
@@ -779,6 +914,31 @@ const runHarnessConformance = async (args) => {
779
914
  return `${replayed.length} updates replayed; after_seq ok`;
780
915
  }
781
916
  );
917
+ await step(
918
+ "fork" /* Fork */,
919
+ {
920
+ requires: ["stream" /* Stream */],
921
+ skip: !final ? "not part of the plain ACP v2 profile" : advertised.fork !== true ? "the agent does not advertise supports.fork" : null
922
+ },
923
+ async () => {
924
+ const id = requireSession();
925
+ const forked = await requireConnection().agent.request(methods.agent.session.fork, {
926
+ sessionId: id,
927
+ cwd,
928
+ mcpServers
929
+ });
930
+ check(forked.sessionId !== id, "session/fork returned the source session id");
931
+ knownSessions.add(forked.sessionId);
932
+ const history = await turn(directive(ConformanceDirective.History), forked.sessionId);
933
+ check(history.text.includes(echoText), "the fork does not hold the source conversation");
934
+ const marker = `fork-only-${nonce}`;
935
+ await turn(directive(ConformanceDirective.Echo, marker), forked.sessionId);
936
+ const source = await turn(directive(ConformanceDirective.History));
937
+ check(!source.text.includes(marker), "a prompt to the fork reached the source session");
938
+ await requireConnection().agent.request(methods.agent.session.close, { sessionId: forked.sessionId }).catch(() => void 0);
939
+ return `forked into ${forked.sessionId}`;
940
+ }
941
+ );
782
942
  await step("park/resume" /* ParkResume */, { requires: sessionCases }, async () => {
783
943
  const id = requireSession();
784
944
  if (endpoint == null) throw failure("no endpoint");
@@ -1004,7 +1164,7 @@ const runHarnessConformance = async (args) => {
1004
1164
  "native session identity across resume" /* NativeIdPreservation */,
1005
1165
  {
1006
1166
  requires: sessionCases,
1007
- skip: args.nativeSessionId == null ? "driver has no independent native session identity probe" : described()?.supports.resumeReplay !== true ? "harness does not declare supports.resumeReplay" : null
1167
+ skip: args.nativeSessionId == null ? "driver has no independent native session identity probe" : !keepsReplay() ? "harness does not declare supports.resumeReplay" : null
1008
1168
  },
1009
1169
  async () => {
1010
1170
  const id = requireSession();
@@ -1055,7 +1215,7 @@ const runHarnessConformance = async (args) => {
1055
1215
  const result = await turn(directive(ConformanceDirective.Echo, text));
1056
1216
  check(result.text === text, `reply after clear ${JSON.stringify(result.text)}`);
1057
1217
  let detail = "one ACP session id across the native change";
1058
- if (described()?.supports.resumeReplay === true) {
1218
+ if (keepsReplay()) {
1059
1219
  const { how } = await dropAndResume(null);
1060
1220
  check(
1061
1221
  how === "resumed" && requireSession() === id,
@@ -1114,9 +1274,9 @@ const runHarnessConformance = async (args) => {
1114
1274
  textLink != null,
1115
1275
  "the multi-megabyte tool result was not moved to a resource_link carrying its full size"
1116
1276
  );
1117
- const description2 = textLink?.description ?? "";
1277
+ const description = textLink?.description ?? "";
1118
1278
  check(
1119
- new TextEncoder().encode(description2).length <= RESOURCE_LINK_DESCRIPTION_BYTES && description2.length > 0,
1279
+ new TextEncoder().encode(description).length <= RESOURCE_LINK_DESCRIPTION_BYTES && description.length > 0,
1120
1280
  "the resource_link description must be the first 4 KiB of the text"
1121
1281
  );
1122
1282
  check(
@@ -1245,7 +1405,7 @@ const runHarnessConformance = async (args) => {
1245
1405
  async () => {
1246
1406
  if (endpoint == null) throw failure("no endpoint");
1247
1407
  const health = await args.harness.health(endpoint.ref, {
1248
- config: args.openArgs.config,
1408
+ settings: args.openArgs.settings,
1249
1409
  secrets: args.openArgs.secrets
1250
1410
  });
1251
1411
  check(health.ok, `health not ok: ${health.detail ?? ""}`);
@@ -1270,7 +1430,7 @@ const runHarnessConformance = async (args) => {
1270
1430
  return {
1271
1431
  profile,
1272
1432
  passed: cases.every((entry) => entry.status !== "failed" /* Failed */),
1273
- description,
1433
+ definition,
1274
1434
  cases
1275
1435
  };
1276
1436
  };
@@ -1296,6 +1456,7 @@ export {
1296
1456
  ConformanceProfile,
1297
1457
  HARNESS_CONFORMANCE_CASES,
1298
1458
  HarnessConformanceCase,
1459
+ REQUIRED_FINAL_SUPPORTS,
1299
1460
  conformanceOpenArgs,
1300
1461
  describeHarnessConformance,
1301
1462
  runHarnessConformance