@ai-sdk/harness-acp 1.0.31 → 1.0.32

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
@@ -145,19 +145,13 @@ type ACPProviderAuthentication = {
145
145
  readonly env: Readonly<Record<string, ACPProfileValue>>;
146
146
  };
147
147
  };
148
- type ACPModelResolution = {
149
- /**
150
- * Replaces the implementation's static launch arguments.
151
- */
152
- readonly args?: ReadonlyArray<string>;
153
- /**
154
- * Overlays the implementation's static launch environment.
155
- */
156
- readonly env?: Readonly<Record<string, string>>;
148
+ type ACPModelMapping = {
149
+ readonly type: 'session-config-option';
150
+ readonly path: string;
151
+ } | {
152
+ readonly type: 'session-model';
153
+ readonly path: string;
157
154
  };
158
- type ACPModelResolver = (options: {
159
- readonly model: string;
160
- }) => ACPModelResolution;
161
155
  type ACPCredentialBrokering = ({ env, sandboxEnv, }: {
162
156
  env: Readonly<Record<string, string>>;
163
157
  sandboxEnv?: Readonly<Record<string, string>>;
@@ -212,11 +206,12 @@ type ACPV1Settings = {
212
206
  */
213
207
  readonly env?: Readonly<Record<string, string>>;
214
208
  readonly authentication?: ACPAuthentication;
209
+ readonly clientCapabilities?: Readonly<Record<string, ACPSerializableValue>>;
215
210
  readonly providerAuthentication?: ACPProviderAuthentication;
216
211
  /**
217
- * Maps a HarnessAgent model identifier to implementation launch settings.
212
+ * Maps the HarnessAgent model identifier to an ACP session operation.
218
213
  */
219
- readonly resolveModel: ACPModelResolver;
214
+ readonly modelMapping: ACPModelMapping;
220
215
  /**
221
216
  * @deprecated Use `model` on `HarnessAgent` instead.
222
217
  */
@@ -287,11 +282,12 @@ type ACPHarnessSettings<TBuiltinTools extends ToolSet = {}> = {
287
282
  readonly credentialForwarding?: ACPV1Settings['credentialForwarding'];
288
283
  readonly env?: ACPV1Settings['env'];
289
284
  readonly authentication?: ACPV1Settings['authentication'];
285
+ readonly clientCapabilities?: ACPV1Settings['clientCapabilities'];
290
286
  readonly providerAuthentication?: ACPV1Settings['providerAuthentication'];
291
287
  /**
292
- * Maps a HarnessAgent model identifier to implementation launch settings.
288
+ * Maps the HarnessAgent model identifier to an ACP session operation.
293
289
  */
294
- readonly resolveModel: ACPV1Settings['resolveModel'];
290
+ readonly modelMapping: ACPV1Settings['modelMapping'];
295
291
  /**
296
292
  * @deprecated Use `model` on `HarnessAgent` instead.
297
293
  */
@@ -307,4 +303,4 @@ declare function createACP<TBuiltinTools extends ToolSet = {}>(settings: ACPHarn
307
303
 
308
304
  declare const VERSION: string;
309
305
 
310
- export { type ACPAnnotations, type ACPAudioContent, type ACPAuthentication, type ACPAuthenticationMode, type ACPBlobResourceContents, type ACPClientApp, type ACPContentBlock, type ACPCredentialBrokering, type ACPEmbeddedResource, type ACPHarnessSettings, type ACPImageContent, type ACPInstallCommandSource, type ACPInstructionMapping, type ACPMetadata, type ACPModelResolution, type ACPModelResolver, type ACPNpmLockedSource, type ACPNpmSimpleSource, type ACPOutputSchemaMapping, type ACPPermissionModeMapping, type ACPPermissionModeTarget, type ACPProfileValue, type ACPProviderAuthentication, 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 };
306
+ export { type ACPAnnotations, type ACPAudioContent, type ACPAuthentication, type ACPAuthenticationMode, type ACPBlobResourceContents, type ACPClientApp, type ACPContentBlock, type ACPCredentialBrokering, type ACPEmbeddedResource, type ACPHarnessSettings, type ACPImageContent, type ACPInstallCommandSource, type ACPInstructionMapping, type ACPMetadata, type ACPModelMapping, type ACPNpmLockedSource, type ACPNpmSimpleSource, type ACPOutputSchemaMapping, type ACPPermissionModeMapping, type ACPPermissionModeTarget, type ACPProfileValue, type ACPProviderAuthentication, 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
@@ -311,6 +311,8 @@ function createImplementationIdentity({
311
311
  acpVersion,
312
312
  implementation,
313
313
  clientApp,
314
+ clientCapabilities,
315
+ modelMapping,
314
316
  providerAuthentication,
315
317
  permissionModeMapping
316
318
  }) {
@@ -344,6 +346,8 @@ function createImplementationIdentity({
344
346
  executable: implementation.executable,
345
347
  args: implementation.args ?? [],
346
348
  clientApp,
349
+ clientCapabilities: clientCapabilities ?? null,
350
+ modelMapping,
347
351
  environment: {
348
352
  forwarded: forwardedEnvironment,
349
353
  credential: credentialEnvironment,
@@ -729,6 +733,19 @@ var outputSchemaMappingSchema = z2.object({
729
733
  type: z2.literal("session-prompt-meta"),
730
734
  path: z2.array(z2.string().min(1)).min(1)
731
735
  });
736
+ var modelMappingSchema = z2.discriminatedUnion(
737
+ "type",
738
+ [
739
+ z2.object({
740
+ type: z2.literal("session-config-option"),
741
+ path: z2.string().min(1)
742
+ }),
743
+ z2.object({
744
+ type: z2.literal("session-model"),
745
+ path: z2.string().min(1)
746
+ })
747
+ ]
748
+ );
732
749
  var acpTurnStartConfigSchema = z2.object({
733
750
  version: z2.literal(1),
734
751
  configurationFingerprint: z2.string(),
@@ -737,12 +754,17 @@ var acpTurnStartConfigSchema = z2.object({
737
754
  builtinTools: z2.array(builtinToolSchema).default([]),
738
755
  permissionMode: harnessV1BridgeStartBaseSchema.shape.permissionMode.unwrap(),
739
756
  permissionModeMapping: permissionModeMappingSchema.optional(),
757
+ model: harnessV1BridgeStartBaseSchema.shape.model.optional(),
758
+ modelMapping: modelMappingSchema.optional(),
740
759
  debug: harnessV1BridgeStartBaseSchema.shape.debug.optional(),
741
760
  responseFormat: harnessV1BridgeStartBaseSchema.shape.responseFormat.optional(),
742
761
  outputSchemaMapping: outputSchemaMappingSchema.optional()
743
762
  });
744
- var acpColdSessionStateSchema = acpTurnStartConfigSchema.omit({ prompt: true, debug: true }).extend({
745
- modelId: z2.string().optional()
763
+ var acpColdSessionStateSchema = acpTurnStartConfigSchema.omit({
764
+ prompt: true,
765
+ debug: true,
766
+ model: true,
767
+ modelMapping: true
746
768
  });
747
769
  var lossyRecoverySchema = z2.object({
748
770
  type: z2.literal("lossy-rerun"),
@@ -772,6 +794,7 @@ var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
772
794
  tools: z2.array(acpSerializableToolSpecSchema).optional(),
773
795
  builtinTools: z2.array(builtinToolSchema).readonly().default([]),
774
796
  permissionModeMapping: permissionModeMappingSchema.optional(),
797
+ modelMapping: modelMappingSchema.optional(),
775
798
  turnStartConfig: acpTurnStartConfigSchema,
776
799
  recoveryMode: z2.discriminatedUnion("type", [lossyRecoverySchema, coldRestoreSchema]).optional()
777
800
  });
@@ -826,16 +849,14 @@ var bridgeConfigurationSchema = z3.object({
826
849
  providerAuthentication: providerAuthenticationSchema.optional(),
827
850
  providerEnvironment: z3.record(z3.string(), z3.string()).optional(),
828
851
  sessionMeta: serializableRecordSchema.optional(),
829
- implementationArgs: z3.array(z3.string()).optional(),
830
- implementationEnv: z3.record(z3.string(), z3.string()).optional()
852
+ clientCapabilities: serializableRecordSchema.optional()
831
853
  });
832
854
  function createACPBridgeEnvironment({
833
855
  authentication,
834
856
  providerAuthentication,
835
857
  providerEnvironment,
836
858
  sessionMeta,
837
- implementationArgs,
838
- implementationEnv
859
+ clientCapabilities
839
860
  }) {
840
861
  return {
841
862
  [ACP_BRIDGE_CONFIGURATION_ENV]: JSON.stringify({
@@ -843,8 +864,7 @@ function createACPBridgeEnvironment({
843
864
  ...providerAuthentication == null ? {} : { providerAuthentication },
844
865
  ...providerEnvironment == null ? {} : { providerEnvironment },
845
866
  ...sessionMeta == null ? {} : { sessionMeta },
846
- ...implementationArgs == null ? {} : { implementationArgs },
847
- ...implementationEnv == null ? {} : { implementationEnv }
867
+ ...clientCapabilities == null ? {} : { clientCapabilities }
848
868
  })
849
869
  };
850
870
  }
@@ -958,7 +978,9 @@ function createACPTurnStartConfig({
958
978
  sessionMeta,
959
979
  instructionMapping,
960
980
  responseFormat,
961
- outputSchemaMapping
981
+ outputSchemaMapping,
982
+ model,
983
+ modelMapping
962
984
  }) {
963
985
  return {
964
986
  version: 1,
@@ -968,6 +990,7 @@ function createACPTurnStartConfig({
968
990
  sessionMeta: sessionMeta ?? null,
969
991
  ...instructionMapping == null ? {} : { instructionMapping },
970
992
  ...outputSchemaMapping == null ? {} : { outputSchemaMapping },
993
+ modelMapping,
971
994
  builtinTools,
972
995
  permissionModeMapping: permissionModeMapping ?? null,
973
996
  mcpServers: mcpServers ?? null
@@ -977,6 +1000,7 @@ function createACPTurnStartConfig({
977
1000
  tools: tools.map((tool) => acpSerializableToolSpecSchema.parse(tool)),
978
1001
  builtinTools: [...builtinTools],
979
1002
  permissionMode,
1003
+ ...model == null ? {} : { model, modelMapping },
980
1004
  ...responseFormat == null ? {} : { responseFormat },
981
1005
  ...outputSchemaMapping == null ? {} : {
982
1006
  outputSchemaMapping: {
@@ -989,8 +1013,7 @@ function createACPTurnStartConfig({
989
1013
  };
990
1014
  }
991
1015
  function createACPColdSessionState({
992
- turnStartConfig,
993
- modelId
1016
+ turnStartConfig
994
1017
  }) {
995
1018
  return {
996
1019
  version: turnStartConfig.version,
@@ -1000,8 +1023,7 @@ function createACPColdSessionState({
1000
1023
  permissionMode: turnStartConfig.permissionMode,
1001
1024
  ...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
1002
1025
  ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
1003
- ...turnStartConfig.permissionModeMapping == null ? {} : { permissionModeMapping: turnStartConfig.permissionModeMapping },
1004
- ...modelId == null ? {} : { modelId }
1026
+ ...turnStartConfig.permissionModeMapping == null ? {} : { permissionModeMapping: turnStartConfig.permissionModeMapping }
1005
1027
  };
1006
1028
  }
1007
1029
  function stableStringify3(value) {
@@ -1222,11 +1244,11 @@ function createACPV1({
1222
1244
  `ACP harnessId must be a stable kebab-case identifier; received ${JSON.stringify(settings.harnessId)}.`
1223
1245
  );
1224
1246
  }
1225
- const baseImplementation = createACPV1Implementation({ settings });
1226
- validateACPV1Implementation(baseImplementation);
1247
+ const implementation = createACPV1Implementation({ settings });
1248
+ validateACPV1Implementation(implementation);
1227
1249
  const bootstrap = createACPBootstrap({
1228
1250
  harnessId: settings.harnessId,
1229
- implementation: baseImplementation
1251
+ implementation
1230
1252
  });
1231
1253
  const permissionModeMapping = isCompletePermissionModeMapping({
1232
1254
  value: settings.permissionModeMapping
@@ -1246,19 +1268,6 @@ function createACPV1({
1246
1268
  message: "ACP built-in tool filtering is not available in this initial ACP v1 implementation."
1247
1269
  });
1248
1270
  }
1249
- const modelId = startOptions.model ?? settings.modelId;
1250
- const modelConfiguration = modelId == null ? void 0 : settings.resolveModel({ model: modelId });
1251
- const implementation = {
1252
- ...baseImplementation,
1253
- ...modelConfiguration?.args == null ? {} : { args: modelConfiguration.args },
1254
- ...modelConfiguration?.env == null ? {} : {
1255
- env: {
1256
- ...baseImplementation.env,
1257
- ...modelConfiguration.env
1258
- }
1259
- }
1260
- };
1261
- validateACPV1Implementation(implementation);
1262
1271
  const permissionMode = startOptions.permissionMode ?? "allow-all";
1263
1272
  const env = { ...process.env };
1264
1273
  const authenticationEnvironment = resolveACPAuthenticationEnvironment({
@@ -1275,6 +1284,8 @@ function createACPV1({
1275
1284
  acpVersion: "v1",
1276
1285
  implementation,
1277
1286
  clientApp,
1287
+ clientCapabilities: settings.clientCapabilities,
1288
+ modelMapping: settings.modelMapping,
1278
1289
  providerAuthentication: providerAuthenticationCompatibility,
1279
1290
  permissionModeMapping: settings.permissionModeMapping
1280
1291
  });
@@ -1468,7 +1479,8 @@ function createACPV1({
1468
1479
  harnessId: settings.harnessId,
1469
1480
  channel: attachChannel,
1470
1481
  proc: void 0,
1471
- modelId,
1482
+ modelMapping: settings.modelMapping,
1483
+ defaultModelId: settings.modelId,
1472
1484
  sessionMeta: settings.session?.meta,
1473
1485
  instructionMapping: settings.instructionMapping,
1474
1486
  outputSchemaMapping: settings.outputSchemaMapping,
@@ -1533,6 +1545,7 @@ function createACPV1({
1533
1545
  sessionMeta: settings.session?.meta,
1534
1546
  instructionMapping: settings.instructionMapping,
1535
1547
  outputSchemaMapping: settings.outputSchemaMapping,
1548
+ modelMapping: settings.modelMapping,
1536
1549
  builtinTools: builtinToolCatalog,
1537
1550
  permissionModeMapping,
1538
1551
  mcpServers: settings.mcpServers
@@ -1558,12 +1571,12 @@ function createACPV1({
1558
1571
  }
1559
1572
  const turnStartConfig = validateACPColdSessionConfiguration({
1560
1573
  coldSession,
1561
- modelId,
1562
1574
  permissionMode,
1563
1575
  authenticationProfile,
1564
1576
  sessionMeta: settings.session?.meta,
1565
1577
  instructionMapping: settings.instructionMapping,
1566
1578
  outputSchemaMapping: settings.outputSchemaMapping,
1579
+ modelMapping: settings.modelMapping,
1567
1580
  builtinTools: builtinToolCatalog,
1568
1581
  permissionModeMapping,
1569
1582
  mcpServers: settings.mcpServers,
@@ -1606,8 +1619,7 @@ function createACPV1({
1606
1619
  providerAuthentication: resolvedProviderAuthentication.providerAuthentication,
1607
1620
  providerEnvironment: sandboxProviderEnvironment == null ? void 0 : {},
1608
1621
  sessionMeta: settings.session?.meta,
1609
- implementationArgs: modelConfiguration?.args,
1610
- implementationEnv: modelConfiguration?.env
1622
+ clientCapabilities: settings.clientCapabilities
1611
1623
  }),
1612
1624
  ...sandboxProviderAuthenticationEnvironment,
1613
1625
  BRIDGE_CHANNEL_TOKEN: token,
@@ -1710,7 +1722,8 @@ function createACPV1({
1710
1722
  harnessId: settings.harnessId,
1711
1723
  channel,
1712
1724
  proc,
1713
- modelId,
1725
+ modelMapping: settings.modelMapping,
1726
+ defaultModelId: settings.modelId,
1714
1727
  sessionMeta: settings.session?.meta,
1715
1728
  instructionMapping: settings.instructionMapping,
1716
1729
  outputSchemaMapping: settings.outputSchemaMapping,
@@ -1954,7 +1967,8 @@ function createSession({
1954
1967
  harnessId,
1955
1968
  channel,
1956
1969
  proc,
1957
- modelId,
1970
+ modelMapping,
1971
+ defaultModelId,
1958
1972
  sessionMeta,
1959
1973
  instructionMapping,
1960
1974
  outputSchemaMapping,
@@ -2223,8 +2237,7 @@ function createSession({
2223
2237
  ...bridge == null ? {} : { bridge },
2224
2238
  ...latestTurnStartConfig == null ? {} : {
2225
2239
  coldSession: createACPColdSessionState({
2226
- turnStartConfig: latestTurnStartConfig,
2227
- modelId
2240
+ turnStartConfig: latestTurnStartConfig
2228
2241
  })
2229
2242
  },
2230
2243
  ...!includeTurnStartConfig || latestTurnStartConfig == null ? {} : { turnStartConfig: latestTurnStartConfig },
@@ -2249,7 +2262,6 @@ function createSession({
2249
2262
  return {
2250
2263
  sessionId,
2251
2264
  isResume,
2252
- ...modelId == null ? {} : { modelId },
2253
2265
  doPromptTurn: async (options) => {
2254
2266
  await synchronizeSkills({
2255
2267
  skills: options.skills,
@@ -2281,6 +2293,7 @@ function createSession({
2281
2293
  prompt: options.prompt,
2282
2294
  harnessId
2283
2295
  });
2296
+ const model = options.model ?? defaultModelId;
2284
2297
  const turnStartConfig = createACPTurnStartConfig({
2285
2298
  prompt,
2286
2299
  tools: options.tools ?? [],
@@ -2293,7 +2306,9 @@ function createSession({
2293
2306
  sessionMeta,
2294
2307
  instructionMapping,
2295
2308
  responseFormat: options.responseFormat,
2296
- outputSchemaMapping
2309
+ outputSchemaMapping,
2310
+ model,
2311
+ modelMapping
2297
2312
  });
2298
2313
  const nextInstructionsFingerprint = fingerprintValue({
2299
2314
  value: options.instructions ?? null
@@ -2322,6 +2337,7 @@ function createSession({
2322
2337
  builtinTools,
2323
2338
  permissionMode,
2324
2339
  permissionModeMapping,
2340
+ ...model == null ? {} : { model, modelMapping },
2325
2341
  ...options.responseFormat == null ? {} : { responseFormat: options.responseFormat },
2326
2342
  ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
2327
2343
  ...mcpServers == null ? {} : { mcpServers },
@@ -2381,6 +2397,10 @@ function createSession({
2381
2397
  builtinTools: turnStartConfig.builtinTools,
2382
2398
  permissionMode: turnStartConfig.permissionMode,
2383
2399
  permissionModeMapping: turnStartConfig.permissionModeMapping,
2400
+ ...turnStartConfig.model == null ? {} : {
2401
+ model: turnStartConfig.model,
2402
+ modelMapping: turnStartConfig.modelMapping
2403
+ },
2384
2404
  ...turnStartConfig.responseFormat == null ? {} : { responseFormat: turnStartConfig.responseFormat },
2385
2405
  ...turnStartConfig.outputSchemaMapping == null ? {} : { outputSchemaMapping: turnStartConfig.outputSchemaMapping },
2386
2406
  ...instructionMapping == null ? {} : {
@@ -2525,6 +2545,7 @@ function validateACPTurnStartConfig({
2525
2545
  sessionMeta,
2526
2546
  instructionMapping,
2527
2547
  outputSchemaMapping,
2548
+ modelMapping,
2528
2549
  builtinTools,
2529
2550
  permissionModeMapping,
2530
2551
  mcpServers
@@ -2541,7 +2562,9 @@ function validateACPTurnStartConfig({
2541
2562
  sessionMeta,
2542
2563
  instructionMapping,
2543
2564
  responseFormat: turnStartConfig.responseFormat,
2544
- outputSchemaMapping
2565
+ outputSchemaMapping,
2566
+ model: turnStartConfig.model,
2567
+ modelMapping
2545
2568
  });
2546
2569
  if (current.configurationFingerprint !== turnStartConfig.configurationFingerprint) {
2547
2570
  throw new Error(
@@ -2551,12 +2574,12 @@ function validateACPTurnStartConfig({
2551
2574
  }
2552
2575
  function validateACPColdSessionConfiguration({
2553
2576
  coldSession,
2554
- modelId,
2555
2577
  permissionMode,
2556
2578
  authenticationProfile,
2557
2579
  sessionMeta,
2558
2580
  instructionMapping,
2559
2581
  outputSchemaMapping,
2582
+ modelMapping,
2560
2583
  builtinTools,
2561
2584
  permissionModeMapping,
2562
2585
  mcpServers,
@@ -2574,9 +2597,11 @@ function validateACPColdSessionConfiguration({
2574
2597
  sessionMeta,
2575
2598
  instructionMapping,
2576
2599
  responseFormat: coldSession.responseFormat,
2577
- outputSchemaMapping
2600
+ outputSchemaMapping,
2601
+ model: void 0,
2602
+ modelMapping
2578
2603
  });
2579
- if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode || coldSession.modelId !== modelId) {
2604
+ if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode) {
2580
2605
  throw new Error(
2581
2606
  "ACP cold-session state is incompatible with the current non-secret session configuration."
2582
2607
  );
@@ -2621,7 +2646,7 @@ function deserializeBridgeError({
2621
2646
  }
2622
2647
 
2623
2648
  // src/version.ts
2624
- var VERSION = true ? "1.0.31" : "0.0.0-test";
2649
+ var VERSION = true ? "1.0.32" : "0.0.0-test";
2625
2650
 
2626
2651
  // src/acp-harness.ts
2627
2652
  var ACP_CLIENT_APP = {