@ai-sdk/harness-acp 1.0.10 → 1.0.11

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.
package/dist/index.d.ts CHANGED
@@ -164,6 +164,10 @@ type ACPInstructionMapping = {
164
164
  readonly variable: string;
165
165
  readonly path: ReadonlyArray<string>;
166
166
  };
167
+ type ACPOutputSchemaMapping = {
168
+ readonly type: 'session-prompt-meta';
169
+ readonly path: ReadonlyArray<string>;
170
+ };
167
171
  type ACPV1Settings = {
168
172
  readonly version?: 'v1';
169
173
  readonly harnessId: string;
@@ -189,6 +193,11 @@ type ACPV1Settings = {
189
193
  * prompt. When omitted, instructions are prepended to the first user prompt.
190
194
  */
191
195
  readonly instructionMapping?: ACPInstructionMapping;
196
+ /**
197
+ * Maps structured output JSON Schema to an implementation-specific path
198
+ * below the ACP session prompt's `_meta` field.
199
+ */
200
+ readonly outputSchemaMapping?: ACPOutputSchemaMapping;
192
201
  readonly permissionModeMapping?: ACPPermissionModeMapping;
193
202
  readonly session?: {
194
203
  readonly meta?: Readonly<Record<string, ACPSerializableValue>>;
@@ -231,6 +240,7 @@ type ACPHarnessSettings<TBuiltinTools extends ToolSet = {}> = {
231
240
  readonly providerAuthentication?: ACPV1Settings['providerAuthentication'];
232
241
  readonly modelId?: ACPV1Settings['modelId'];
233
242
  readonly instructionMapping?: ACPV1Settings['instructionMapping'];
243
+ readonly outputSchemaMapping?: ACPV1Settings['outputSchemaMapping'];
234
244
  readonly permissionModeMapping?: ACPV1Settings['permissionModeMapping'];
235
245
  readonly session?: ACPV1Settings['session'];
236
246
  readonly mintBridgeToken?: ACPV1Settings['mintBridgeToken'];
@@ -239,4 +249,4 @@ declare function createACP<TBuiltinTools extends ToolSet = {}>(settings: ACPHarn
239
249
 
240
250
  declare const VERSION: string;
241
251
 
242
- export { type ACPAnnotations, type ACPAudioContent, type ACPAuthOptions, type ACPAuthentication, type ACPBlobResourceContents, type ACPClientApp, type ACPContentBlock, type ACPCredentialBrokering, type ACPEmbeddedResource, type ACPHarnessSettings, type ACPImageContent, type ACPInstructionMapping, type ACPMetadata, type ACPNpmLockedSource, type ACPNpmSimpleSource, type ACPPermissionModeMapping, type ACPPermissionModeTarget, type ACPProfileValue, type ACPProviderAuthentication, type ACPProviderAuthenticationMode, type ACPResourceLink, type ACPRole, type ACPSerializablePrimitive, type ACPSerializableValue, type ACPSource, type ACPTextContent, type ACPTextResourceContents, type ACPToolCall, type ACPToolCallContent, type ACPToolCallLocation, type ACPToolCallStatus, type ACPToolKind, type ACPV1Settings, type ACPValueSource, VERSION, createACP };
252
+ export { type ACPAnnotations, type ACPAudioContent, type ACPAuthOptions, type ACPAuthentication, type ACPBlobResourceContents, type ACPClientApp, type ACPContentBlock, type ACPCredentialBrokering, type ACPEmbeddedResource, type ACPHarnessSettings, type ACPImageContent, type ACPInstructionMapping, type ACPMetadata, type ACPNpmLockedSource, type ACPNpmSimpleSource, type ACPOutputSchemaMapping, type ACPPermissionModeMapping, type ACPPermissionModeTarget, type ACPProfileValue, type ACPProviderAuthentication, type ACPProviderAuthenticationMode, type ACPResourceLink, type ACPRole, type ACPSerializablePrimitive, type ACPSerializableValue, type ACPSource, type ACPTextContent, type ACPTextResourceContents, type ACPToolCall, type ACPToolCallContent, type ACPToolCallLocation, type ACPToolCallStatus, type ACPToolKind, type ACPV1Settings, type ACPValueSource, VERSION, createACP };
package/dist/index.js CHANGED
@@ -650,6 +650,10 @@ var instructionMappingSchema = z2.discriminatedUnion("type", [
650
650
  path: instructionMappingPathSchema
651
651
  })
652
652
  ]);
653
+ var outputSchemaMappingSchema = z2.object({
654
+ type: z2.literal("session-prompt-meta"),
655
+ path: z2.array(z2.string().min(1)).min(1)
656
+ });
653
657
  var acpTurnStartConfigSchema = z2.object({
654
658
  version: z2.literal(1),
655
659
  configurationFingerprint: z2.string(),
@@ -658,7 +662,9 @@ var acpTurnStartConfigSchema = z2.object({
658
662
  builtinTools: z2.array(builtinToolSchema).default([]),
659
663
  permissionMode: harnessV1BridgeStartBaseSchema.shape.permissionMode.unwrap(),
660
664
  permissionModeMapping: permissionModeMappingSchema.optional(),
661
- debug: harnessV1BridgeStartBaseSchema.shape.debug.optional()
665
+ debug: harnessV1BridgeStartBaseSchema.shape.debug.optional(),
666
+ responseFormat: harnessV1BridgeStartBaseSchema.shape.responseFormat.optional(),
667
+ outputSchemaMapping: outputSchemaMappingSchema.optional()
662
668
  });
663
669
  var acpColdSessionStateSchema = acpTurnStartConfigSchema.omit({ prompt: true, debug: true }).extend({
664
670
  modelId: z2.string().optional()
@@ -686,6 +692,7 @@ var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
686
692
  prompt: z2.array(acpTextContentBlockSchema),
687
693
  instructions: z2.string().optional(),
688
694
  instructionMapping: instructionMappingSchema.optional(),
695
+ outputSchemaMapping: outputSchemaMappingSchema.optional(),
689
696
  mcpServers: z2.record(z2.string(), z2.unknown()).optional(),
690
697
  tools: z2.array(acpSerializableToolSpecSchema).optional(),
691
698
  builtinTools: z2.array(builtinToolSchema).readonly().default([]),
@@ -868,7 +875,9 @@ function createACPTurnStartConfig({
868
875
  debug,
869
876
  authenticationProfile,
870
877
  sessionMeta,
871
- instructionMapping
878
+ instructionMapping,
879
+ responseFormat,
880
+ outputSchemaMapping
872
881
  }) {
873
882
  return {
874
883
  version: 1,
@@ -877,6 +886,7 @@ function createACPTurnStartConfig({
877
886
  authenticationProfile,
878
887
  sessionMeta: sessionMeta ?? null,
879
888
  ...instructionMapping == null ? {} : { instructionMapping },
889
+ ...outputSchemaMapping == null ? {} : { outputSchemaMapping },
880
890
  builtinTools,
881
891
  permissionModeMapping: permissionModeMapping ?? null,
882
892
  mcpServers: mcpServers ?? null
@@ -886,6 +896,13 @@ function createACPTurnStartConfig({
886
896
  tools: tools.map((tool) => acpSerializableToolSpecSchema.parse(tool)),
887
897
  builtinTools: [...builtinTools],
888
898
  permissionMode,
899
+ ...responseFormat == null ? {} : { responseFormat },
900
+ ...outputSchemaMapping == null ? {} : {
901
+ outputSchemaMapping: {
902
+ type: outputSchemaMapping.type,
903
+ path: [...outputSchemaMapping.path]
904
+ }
905
+ },
889
906
  ...permissionModeMapping == null ? {} : { permissionModeMapping },
890
907
  ...debug == null ? {} : { debug }
891
908
  };
@@ -900,6 +917,8 @@ function createACPColdSessionState({
900
917
  tools: turnStartConfig.tools,
901
918
  builtinTools: turnStartConfig.builtinTools,
902
919
  permissionMode: turnStartConfig.permissionMode,
920
+ ...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
921
+ ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
903
922
  ...turnStartConfig.permissionModeMapping == null ? {} : { permissionModeMapping: turnStartConfig.permissionModeMapping },
904
923
  ...modelId == null ? {} : { modelId }
905
924
  };
@@ -1367,6 +1386,7 @@ function createACPV1({
1367
1386
  modelId: settings.modelId,
1368
1387
  sessionMeta: settings.session?.meta,
1369
1388
  instructionMapping: settings.instructionMapping,
1389
+ outputSchemaMapping: settings.outputSchemaMapping,
1370
1390
  debug: startOptions.observability?.debug,
1371
1391
  implementationIdentity,
1372
1392
  authenticationProfile,
@@ -1424,6 +1444,7 @@ function createACPV1({
1424
1444
  authenticationProfile,
1425
1445
  sessionMeta: settings.session?.meta,
1426
1446
  instructionMapping: settings.instructionMapping,
1447
+ outputSchemaMapping: settings.outputSchemaMapping,
1427
1448
  builtinTools: builtinToolCatalog,
1428
1449
  permissionModeMapping,
1429
1450
  mcpServers: settings.mcpServers
@@ -1454,6 +1475,7 @@ function createACPV1({
1454
1475
  authenticationProfile,
1455
1476
  sessionMeta: settings.session?.meta,
1456
1477
  instructionMapping: settings.instructionMapping,
1478
+ outputSchemaMapping: settings.outputSchemaMapping,
1457
1479
  builtinTools: builtinToolCatalog,
1458
1480
  permissionModeMapping,
1459
1481
  mcpServers: settings.mcpServers,
@@ -1594,6 +1616,7 @@ function createACPV1({
1594
1616
  modelId: settings.modelId,
1595
1617
  sessionMeta: settings.session?.meta,
1596
1618
  instructionMapping: settings.instructionMapping,
1619
+ outputSchemaMapping: settings.outputSchemaMapping,
1597
1620
  debug: startOptions.observability?.debug,
1598
1621
  implementationIdentity,
1599
1622
  authenticationProfile,
@@ -1778,6 +1801,7 @@ function createSession({
1778
1801
  modelId,
1779
1802
  sessionMeta,
1780
1803
  instructionMapping,
1804
+ outputSchemaMapping,
1781
1805
  debug,
1782
1806
  implementationIdentity,
1783
1807
  authenticationProfile,
@@ -2054,6 +2078,20 @@ function createSession({
2054
2078
  isResume,
2055
2079
  ...modelId == null ? {} : { modelId },
2056
2080
  doPromptTurn: async (options) => {
2081
+ if (options.responseFormat?.type === "json") {
2082
+ if (options.responseFormat.schema == null) {
2083
+ throw unsupported({
2084
+ harnessId,
2085
+ message: `${harnessId} requires a JSON schema for structured output.`
2086
+ });
2087
+ }
2088
+ if (outputSchemaMapping == null) {
2089
+ throw unsupported({
2090
+ harnessId,
2091
+ message: `${harnessId} does not support structured output through ACP.`
2092
+ });
2093
+ }
2094
+ }
2057
2095
  if (replayOnly) {
2058
2096
  throw new Error(
2059
2097
  `${harnessId} recovered this turn through disk replay only and has no restored ACP process for a subsequent prompt.`
@@ -2076,7 +2114,9 @@ function createSession({
2076
2114
  debug,
2077
2115
  authenticationProfile,
2078
2116
  sessionMeta,
2079
- instructionMapping
2117
+ instructionMapping,
2118
+ responseFormat: options.responseFormat,
2119
+ outputSchemaMapping
2080
2120
  });
2081
2121
  const control = wireTurn({
2082
2122
  emit: options.emit,
@@ -2103,6 +2143,8 @@ function createSession({
2103
2143
  builtinTools,
2104
2144
  permissionMode,
2105
2145
  permissionModeMapping,
2146
+ ...options.responseFormat == null ? {} : { responseFormat: options.responseFormat },
2147
+ ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
2106
2148
  ...mcpServers == null ? {} : { mcpServers },
2107
2149
  tools: options.tools == null ? void 0 : turnStartConfig.tools,
2108
2150
  turnStartConfig
@@ -2114,6 +2156,20 @@ function createSession({
2114
2156
  return control;
2115
2157
  },
2116
2158
  doContinueTurn: async (options) => {
2159
+ if (options.responseFormat?.type === "json") {
2160
+ if (options.responseFormat.schema == null) {
2161
+ throw unsupported({
2162
+ harnessId,
2163
+ message: `${harnessId} requires a JSON schema for structured output.`
2164
+ });
2165
+ }
2166
+ if (outputSchemaMapping == null) {
2167
+ throw unsupported({
2168
+ harnessId,
2169
+ message: `${harnessId} does not support structured output through ACP.`
2170
+ });
2171
+ }
2172
+ }
2117
2173
  if (!turnInFlight) {
2118
2174
  throw new Error(`${harnessId} has no in-flight ACP turn to continue.`);
2119
2175
  }
@@ -2141,6 +2197,8 @@ function createSession({
2141
2197
  builtinTools: turnStartConfig.builtinTools,
2142
2198
  permissionMode: turnStartConfig.permissionMode,
2143
2199
  permissionModeMapping: turnStartConfig.permissionModeMapping,
2200
+ ...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
2201
+ ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
2144
2202
  ...instructionMapping == null ? {} : {
2145
2203
  instructionMapping,
2146
2204
  ...options.instructions == null ? {} : { instructions: options.instructions }
@@ -2278,6 +2336,7 @@ function validateACPTurnStartConfig({
2278
2336
  authenticationProfile,
2279
2337
  sessionMeta,
2280
2338
  instructionMapping,
2339
+ outputSchemaMapping,
2281
2340
  builtinTools,
2282
2341
  permissionModeMapping,
2283
2342
  mcpServers
@@ -2292,7 +2351,9 @@ function validateACPTurnStartConfig({
2292
2351
  debug: turnStartConfig.debug,
2293
2352
  authenticationProfile,
2294
2353
  sessionMeta,
2295
- instructionMapping
2354
+ instructionMapping,
2355
+ responseFormat: turnStartConfig.responseFormat,
2356
+ outputSchemaMapping
2296
2357
  });
2297
2358
  if (current.configurationFingerprint !== turnStartConfig.configurationFingerprint) {
2298
2359
  throw new Error(
@@ -2307,6 +2368,7 @@ function validateACPColdSessionConfiguration({
2307
2368
  authenticationProfile,
2308
2369
  sessionMeta,
2309
2370
  instructionMapping,
2371
+ outputSchemaMapping,
2310
2372
  builtinTools,
2311
2373
  permissionModeMapping,
2312
2374
  mcpServers,
@@ -2322,7 +2384,9 @@ function validateACPColdSessionConfiguration({
2322
2384
  debug,
2323
2385
  authenticationProfile,
2324
2386
  sessionMeta,
2325
- instructionMapping
2387
+ instructionMapping,
2388
+ responseFormat: coldSession.responseFormat,
2389
+ outputSchemaMapping
2326
2390
  });
2327
2391
  if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode || coldSession.modelId !== modelId) {
2328
2392
  throw new Error(
@@ -2369,7 +2433,7 @@ function deserializeBridgeError({
2369
2433
  }
2370
2434
 
2371
2435
  // src/version.ts
2372
- var VERSION = true ? "1.0.10" : "0.0.0-test";
2436
+ var VERSION = true ? "1.0.11" : "0.0.0-test";
2373
2437
 
2374
2438
  // src/acp-harness.ts
2375
2439
  var ACP_CLIENT_APP = {