@ai-sdk/harness-acp 1.0.1 → 1.0.3
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/CHANGELOG.md +19 -0
- package/README.md +13 -0
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/index.mjs +176 -18
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +132 -1
- package/dist/index.js +130 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/acp-harness.ts +20 -0
- package/src/acp-tool-call.ts +124 -0
- package/src/index.ts +19 -0
- package/src/v1/acp-v1-bridge-protocol.ts +38 -2
- package/src/v1/acp-v1-harness.ts +116 -4
- package/src/v1/acp-v1-settings.ts +29 -0
- package/src/v1/acp-v1-turn-start-config.ts +7 -0
- package/src/v1/bridge/create-emit-stream-event.ts +8 -1
- package/src/v1/bridge/index.ts +61 -6
- package/src/v1/bridge/instruction-mapping.ts +132 -0
- package/src/v1/bridge/stream-translator.ts +62 -5
- package/src/v1/index.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,104 @@
|
|
|
1
1
|
import { HarnessV1PermissionMode, HarnessV1 } from '@ai-sdk/harness';
|
|
2
2
|
import { ToolSet } from '@ai-sdk/provider-utils';
|
|
3
3
|
|
|
4
|
+
type ACPMetadata = Record<string, unknown>;
|
|
5
|
+
type ACPRole = 'assistant' | 'user';
|
|
6
|
+
type ACPAnnotations = {
|
|
7
|
+
audience?: Array<ACPRole> | null;
|
|
8
|
+
lastModified?: string | null;
|
|
9
|
+
priority?: number | null;
|
|
10
|
+
_meta?: ACPMetadata | null;
|
|
11
|
+
};
|
|
12
|
+
type ACPTextContent = {
|
|
13
|
+
annotations?: ACPAnnotations | null;
|
|
14
|
+
text: string;
|
|
15
|
+
_meta?: ACPMetadata | null;
|
|
16
|
+
};
|
|
17
|
+
type ACPImageContent = {
|
|
18
|
+
annotations?: ACPAnnotations | null;
|
|
19
|
+
data: string;
|
|
20
|
+
mimeType: string;
|
|
21
|
+
uri?: string | null;
|
|
22
|
+
_meta?: ACPMetadata | null;
|
|
23
|
+
};
|
|
24
|
+
type ACPAudioContent = {
|
|
25
|
+
annotations?: ACPAnnotations | null;
|
|
26
|
+
data: string;
|
|
27
|
+
mimeType: string;
|
|
28
|
+
_meta?: ACPMetadata | null;
|
|
29
|
+
};
|
|
30
|
+
type ACPResourceLink = {
|
|
31
|
+
annotations?: ACPAnnotations | null;
|
|
32
|
+
description?: string | null;
|
|
33
|
+
mimeType?: string | null;
|
|
34
|
+
name: string;
|
|
35
|
+
size?: number | null;
|
|
36
|
+
title?: string | null;
|
|
37
|
+
uri: string;
|
|
38
|
+
_meta?: ACPMetadata | null;
|
|
39
|
+
};
|
|
40
|
+
type ACPTextResourceContents = {
|
|
41
|
+
mimeType?: string | null;
|
|
42
|
+
text: string;
|
|
43
|
+
uri: string;
|
|
44
|
+
_meta?: ACPMetadata | null;
|
|
45
|
+
};
|
|
46
|
+
type ACPBlobResourceContents = {
|
|
47
|
+
blob: string;
|
|
48
|
+
mimeType?: string | null;
|
|
49
|
+
uri: string;
|
|
50
|
+
_meta?: ACPMetadata | null;
|
|
51
|
+
};
|
|
52
|
+
type ACPEmbeddedResource = {
|
|
53
|
+
annotations?: ACPAnnotations | null;
|
|
54
|
+
resource: ACPTextResourceContents | ACPBlobResourceContents;
|
|
55
|
+
_meta?: ACPMetadata | null;
|
|
56
|
+
};
|
|
57
|
+
type ACPContentBlock = (ACPTextContent & {
|
|
58
|
+
type: 'text';
|
|
59
|
+
}) | (ACPImageContent & {
|
|
60
|
+
type: 'image';
|
|
61
|
+
}) | (ACPAudioContent & {
|
|
62
|
+
type: 'audio';
|
|
63
|
+
}) | (ACPResourceLink & {
|
|
64
|
+
type: 'resource_link';
|
|
65
|
+
}) | (ACPEmbeddedResource & {
|
|
66
|
+
type: 'resource';
|
|
67
|
+
});
|
|
68
|
+
type ACPToolCallContent = {
|
|
69
|
+
type: 'content';
|
|
70
|
+
content: ACPContentBlock;
|
|
71
|
+
_meta?: ACPMetadata | null;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'diff';
|
|
74
|
+
path: string;
|
|
75
|
+
oldText?: string | null;
|
|
76
|
+
newText: string;
|
|
77
|
+
_meta?: ACPMetadata | null;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'terminal';
|
|
80
|
+
terminalId: string;
|
|
81
|
+
_meta?: ACPMetadata | null;
|
|
82
|
+
};
|
|
83
|
+
type ACPToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'switch_mode' | 'other';
|
|
84
|
+
type ACPToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
85
|
+
type ACPToolCallLocation = {
|
|
86
|
+
path: string;
|
|
87
|
+
line?: number | null;
|
|
88
|
+
_meta?: ACPMetadata | null;
|
|
89
|
+
};
|
|
90
|
+
type ACPToolCall = {
|
|
91
|
+
toolCallId: string;
|
|
92
|
+
title: string;
|
|
93
|
+
kind?: ACPToolKind;
|
|
94
|
+
status?: ACPToolCallStatus;
|
|
95
|
+
content?: Array<ACPToolCallContent>;
|
|
96
|
+
locations?: Array<ACPToolCallLocation>;
|
|
97
|
+
rawInput?: unknown;
|
|
98
|
+
rawOutput?: unknown;
|
|
99
|
+
_meta?: ACPMetadata | null;
|
|
100
|
+
};
|
|
101
|
+
|
|
4
102
|
type ACPSerializablePrimitive = string | number | boolean | null;
|
|
5
103
|
type ACPSerializableValue = ACPSerializablePrimitive | ReadonlyArray<ACPSerializableValue> | {
|
|
6
104
|
readonly [key: string]: ACPSerializableValue;
|
|
@@ -50,9 +148,24 @@ type ACPPermissionModeTarget = {
|
|
|
50
148
|
readonly value: string | boolean;
|
|
51
149
|
};
|
|
52
150
|
type ACPPermissionModeMapping = Readonly<Record<HarnessV1PermissionMode, ACPPermissionModeTarget | null>>;
|
|
151
|
+
/**
|
|
152
|
+
* Describes where an ACP implementation accepts native session instructions.
|
|
153
|
+
* Session metadata paths are relative to `_meta`; launch environment paths are
|
|
154
|
+
* relative to the parsed JSON object stored in `variable`.
|
|
155
|
+
*/
|
|
156
|
+
type ACPInstructionMapping = {
|
|
157
|
+
readonly type: 'session-meta';
|
|
158
|
+
readonly path: ReadonlyArray<string>;
|
|
159
|
+
} | {
|
|
160
|
+
readonly type: 'launch-env-json';
|
|
161
|
+
readonly variable: string;
|
|
162
|
+
readonly path: ReadonlyArray<string>;
|
|
163
|
+
};
|
|
53
164
|
type ACPV1Settings = {
|
|
54
165
|
readonly version?: 'v1';
|
|
55
166
|
readonly harnessId: string;
|
|
167
|
+
readonly mcpServers?: Record<string, unknown>;
|
|
168
|
+
readonly isMcpToolCall?: (toolCall: ACPToolCall) => boolean;
|
|
56
169
|
readonly auth?: ACPProviderAuthenticationMode;
|
|
57
170
|
readonly source: ACPSource;
|
|
58
171
|
readonly executable: string;
|
|
@@ -66,10 +179,20 @@ type ACPV1Settings = {
|
|
|
66
179
|
readonly authentication?: ACPAuthentication;
|
|
67
180
|
readonly providerAuthentication?: ACPProviderAuthentication;
|
|
68
181
|
readonly modelId?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Routes HarnessAgent instructions to a runtime-native system or developer
|
|
184
|
+
* prompt. When omitted, instructions are prepended to the first user prompt.
|
|
185
|
+
*/
|
|
186
|
+
readonly instructionMapping?: ACPInstructionMapping;
|
|
69
187
|
readonly permissionModeMapping?: ACPPermissionModeMapping;
|
|
70
188
|
readonly session?: {
|
|
71
189
|
readonly meta?: Readonly<Record<string, ACPSerializableValue>>;
|
|
72
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Creates the authentication token used by the sandbox bridge. Defaults to
|
|
193
|
+
* a random 32-byte hexadecimal token.
|
|
194
|
+
*/
|
|
195
|
+
readonly mintBridgeToken?: (sandboxId: string) => string;
|
|
73
196
|
};
|
|
74
197
|
|
|
75
198
|
type ACPAuthOptions = ACPProviderAuthenticationMode;
|
|
@@ -80,6 +203,12 @@ type ACPClientApp = {
|
|
|
80
203
|
|
|
81
204
|
type ACPHarnessSettings<TBuiltinTools extends ToolSet = {}> = {
|
|
82
205
|
readonly builtinTools?: TBuiltinTools;
|
|
206
|
+
/**
|
|
207
|
+
* MCP server definitions keyed by server name. Each definition uses the
|
|
208
|
+
* underlying runtime's native MCP server configuration format.
|
|
209
|
+
*/
|
|
210
|
+
readonly mcpServers?: Record<string, unknown>;
|
|
211
|
+
readonly isMcpToolCall?: (toolCall: ACPToolCall) => boolean;
|
|
83
212
|
readonly port?: number;
|
|
84
213
|
readonly startupTimeoutMs?: number;
|
|
85
214
|
readonly clientApp?: ACPClientApp;
|
|
@@ -94,11 +223,13 @@ type ACPHarnessSettings<TBuiltinTools extends ToolSet = {}> = {
|
|
|
94
223
|
readonly authentication?: ACPV1Settings['authentication'];
|
|
95
224
|
readonly providerAuthentication?: ACPV1Settings['providerAuthentication'];
|
|
96
225
|
readonly modelId?: ACPV1Settings['modelId'];
|
|
226
|
+
readonly instructionMapping?: ACPV1Settings['instructionMapping'];
|
|
97
227
|
readonly permissionModeMapping?: ACPV1Settings['permissionModeMapping'];
|
|
98
228
|
readonly session?: ACPV1Settings['session'];
|
|
229
|
+
readonly mintBridgeToken?: ACPV1Settings['mintBridgeToken'];
|
|
99
230
|
};
|
|
100
231
|
declare function createACP<TBuiltinTools extends ToolSet = {}>(settings: ACPHarnessSettings<TBuiltinTools>): HarnessV1<TBuiltinTools>;
|
|
101
232
|
|
|
102
233
|
declare const VERSION: string;
|
|
103
234
|
|
|
104
|
-
export { type ACPAuthOptions, type ACPAuthentication, type ACPClientApp, type ACPHarnessSettings, type ACPNpmLockedSource, type ACPNpmSimpleSource, type ACPPermissionModeMapping, type ACPPermissionModeTarget, type ACPProfileValue, type ACPProviderAuthentication, type ACPProviderAuthenticationMode, type ACPSerializablePrimitive, type ACPSerializableValue, type ACPSource, type ACPV1Settings, type ACPValueSource, VERSION, createACP };
|
|
235
|
+
export { type ACPAnnotations, type ACPAudioContent, type ACPAuthOptions, type ACPAuthentication, type ACPBlobResourceContents, type ACPClientApp, type ACPContentBlock, 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 };
|
package/dist/index.js
CHANGED
|
@@ -518,6 +518,18 @@ var permissionModeMappingSchema = z2.object({
|
|
|
518
518
|
"allow-edits": permissionModeTargetSchema.nullable(),
|
|
519
519
|
"allow-all": permissionModeTargetSchema.nullable()
|
|
520
520
|
});
|
|
521
|
+
var instructionMappingPathSchema = z2.array(z2.string().min(1)).min(1);
|
|
522
|
+
var instructionMappingSchema = z2.discriminatedUnion("type", [
|
|
523
|
+
z2.object({
|
|
524
|
+
type: z2.literal("session-meta"),
|
|
525
|
+
path: instructionMappingPathSchema
|
|
526
|
+
}),
|
|
527
|
+
z2.object({
|
|
528
|
+
type: z2.literal("launch-env-json"),
|
|
529
|
+
variable: z2.string().min(1),
|
|
530
|
+
path: instructionMappingPathSchema
|
|
531
|
+
})
|
|
532
|
+
]);
|
|
521
533
|
var acpTurnStartConfigSchema = z2.object({
|
|
522
534
|
version: z2.literal(1),
|
|
523
535
|
configurationFingerprint: z2.string(),
|
|
@@ -540,9 +552,21 @@ var coldRestoreSchema = z2.object({
|
|
|
540
552
|
type: z2.literal("cold-restore"),
|
|
541
553
|
acpSessionId: z2.string()
|
|
542
554
|
});
|
|
543
|
-
var
|
|
555
|
+
var acpToolCallCandidateSchema = z2.object({
|
|
556
|
+
type: z2.literal("acp-tool-call-candidate"),
|
|
557
|
+
toolCall: z2.custom(
|
|
558
|
+
(value) => value != null && typeof value === "object" && typeof value.toolCallId === "string" && typeof value.title === "string"
|
|
559
|
+
)
|
|
560
|
+
});
|
|
561
|
+
var outboundMessageSchema = z2.union([
|
|
562
|
+
harnessV1BridgeOutboundMessageSchema,
|
|
563
|
+
acpToolCallCandidateSchema
|
|
564
|
+
]);
|
|
544
565
|
var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
|
|
545
566
|
prompt: z2.array(acpTextContentBlockSchema),
|
|
567
|
+
instructions: z2.string().optional(),
|
|
568
|
+
instructionMapping: instructionMappingSchema.optional(),
|
|
569
|
+
mcpServers: z2.record(z2.string(), z2.unknown()).optional(),
|
|
546
570
|
tools: z2.array(acpSerializableToolSpecSchema).optional(),
|
|
547
571
|
builtinTools: z2.array(builtinToolSchema).readonly().default([]),
|
|
548
572
|
permissionModeMapping: permissionModeMappingSchema.optional(),
|
|
@@ -622,9 +646,11 @@ function createACPTurnStartConfig({
|
|
|
622
646
|
builtinTools,
|
|
623
647
|
permissionMode,
|
|
624
648
|
permissionModeMapping,
|
|
649
|
+
mcpServers,
|
|
625
650
|
debug,
|
|
626
651
|
authenticationProfile,
|
|
627
|
-
sessionMeta
|
|
652
|
+
sessionMeta,
|
|
653
|
+
instructionMapping
|
|
628
654
|
}) {
|
|
629
655
|
return {
|
|
630
656
|
version: 1,
|
|
@@ -632,8 +658,10 @@ function createACPTurnStartConfig({
|
|
|
632
658
|
stableStringify3({
|
|
633
659
|
authenticationProfile,
|
|
634
660
|
sessionMeta: sessionMeta ?? null,
|
|
661
|
+
...instructionMapping == null ? {} : { instructionMapping },
|
|
635
662
|
builtinTools,
|
|
636
|
-
permissionModeMapping: permissionModeMapping ?? null
|
|
663
|
+
permissionModeMapping: permissionModeMapping ?? null,
|
|
664
|
+
mcpServers: mcpServers ?? null
|
|
637
665
|
})
|
|
638
666
|
).digest("hex"),
|
|
639
667
|
prompt: [...prompt],
|
|
@@ -897,6 +925,14 @@ function createACPV1({
|
|
|
897
925
|
clientApp,
|
|
898
926
|
lifecycleStateSchema
|
|
899
927
|
}) {
|
|
928
|
+
if (settings.mcpServers != null && Object.prototype.hasOwnProperty.call(
|
|
929
|
+
settings.mcpServers,
|
|
930
|
+
"ai-sdk-harness-tools"
|
|
931
|
+
)) {
|
|
932
|
+
throw new Error(
|
|
933
|
+
'ACP MCP server name "ai-sdk-harness-tools" is reserved for HarnessAgent tools.'
|
|
934
|
+
);
|
|
935
|
+
}
|
|
900
936
|
if (!HARNESS_ID_REGEXP.test(settings.harnessId)) {
|
|
901
937
|
throw new Error(
|
|
902
938
|
`ACP harnessId must be a stable kebab-case identifier; received ${JSON.stringify(settings.harnessId)}.`
|
|
@@ -1112,12 +1148,15 @@ function createACPV1({
|
|
|
1112
1148
|
proc: void 0,
|
|
1113
1149
|
modelId: settings.modelId,
|
|
1114
1150
|
sessionMeta: settings.session?.meta,
|
|
1151
|
+
instructionMapping: settings.instructionMapping,
|
|
1115
1152
|
debug: startOptions.observability?.debug,
|
|
1116
1153
|
implementationIdentity,
|
|
1117
1154
|
authenticationProfile,
|
|
1118
1155
|
builtinTools: builtinToolCatalog,
|
|
1119
1156
|
permissionMode,
|
|
1120
1157
|
permissionModeMapping,
|
|
1158
|
+
mcpServers: settings.mcpServers,
|
|
1159
|
+
isMcpToolCall: settings.isMcpToolCall,
|
|
1121
1160
|
initialGuidanceApplied: resolveACPInitialGuidanceApplied({
|
|
1122
1161
|
isResume: true,
|
|
1123
1162
|
lifecycleState: lifecycleData
|
|
@@ -1166,8 +1205,10 @@ function createACPV1({
|
|
|
1166
1205
|
turnStartConfig,
|
|
1167
1206
|
authenticationProfile,
|
|
1168
1207
|
sessionMeta: settings.session?.meta,
|
|
1208
|
+
instructionMapping: settings.instructionMapping,
|
|
1169
1209
|
builtinTools: builtinToolCatalog,
|
|
1170
|
-
permissionModeMapping
|
|
1210
|
+
permissionModeMapping,
|
|
1211
|
+
mcpServers: settings.mcpServers
|
|
1171
1212
|
});
|
|
1172
1213
|
respawnStrategy = {
|
|
1173
1214
|
mode: "lossy-rerun",
|
|
@@ -1194,8 +1235,10 @@ function createACPV1({
|
|
|
1194
1235
|
permissionMode,
|
|
1195
1236
|
authenticationProfile,
|
|
1196
1237
|
sessionMeta: settings.session?.meta,
|
|
1238
|
+
instructionMapping: settings.instructionMapping,
|
|
1197
1239
|
builtinTools: builtinToolCatalog,
|
|
1198
1240
|
permissionModeMapping,
|
|
1241
|
+
mcpServers: settings.mcpServers,
|
|
1199
1242
|
debug: startOptions.observability?.debug
|
|
1200
1243
|
});
|
|
1201
1244
|
respawnStrategy = {
|
|
@@ -1210,7 +1253,7 @@ function createACPV1({
|
|
|
1210
1253
|
override: portOverride,
|
|
1211
1254
|
harnessId: settings.harnessId
|
|
1212
1255
|
});
|
|
1213
|
-
const token = randomBytes(32).toString("hex");
|
|
1256
|
+
const token = settings.mintBridgeToken == null ? randomBytes(32).toString("hex") : settings.mintBridgeToken(sandboxSession.id);
|
|
1214
1257
|
await sandbox.run({
|
|
1215
1258
|
command: `mkdir -p ${shellQuote(workDir)} ${shellQuote(bridgeStateDir)}`,
|
|
1216
1259
|
abortSignal: startOptions.abortSignal
|
|
@@ -1300,6 +1343,8 @@ function createACPV1({
|
|
|
1300
1343
|
builtinTools: builtinToolCatalog,
|
|
1301
1344
|
permissionMode,
|
|
1302
1345
|
permissionModeMapping,
|
|
1346
|
+
...settings.instructionMapping == null ? {} : { instructionMapping: settings.instructionMapping },
|
|
1347
|
+
...settings.mcpServers == null ? {} : { mcpServers: settings.mcpServers },
|
|
1303
1348
|
tools: respawnStrategy.turnStartConfig.tools,
|
|
1304
1349
|
turnStartConfig: respawnStrategy.turnStartConfig,
|
|
1305
1350
|
recoveryMode: {
|
|
@@ -1331,12 +1376,15 @@ function createACPV1({
|
|
|
1331
1376
|
proc,
|
|
1332
1377
|
modelId: settings.modelId,
|
|
1333
1378
|
sessionMeta: settings.session?.meta,
|
|
1379
|
+
instructionMapping: settings.instructionMapping,
|
|
1334
1380
|
debug: startOptions.observability?.debug,
|
|
1335
1381
|
implementationIdentity,
|
|
1336
1382
|
authenticationProfile,
|
|
1337
1383
|
builtinTools: builtinToolCatalog,
|
|
1338
1384
|
permissionMode,
|
|
1339
1385
|
permissionModeMapping,
|
|
1386
|
+
mcpServers: settings.mcpServers,
|
|
1387
|
+
isMcpToolCall: settings.isMcpToolCall,
|
|
1340
1388
|
initialGuidanceApplied: resolveACPInitialGuidanceApplied({
|
|
1341
1389
|
isResume,
|
|
1342
1390
|
lifecycleState: lifecycleData
|
|
@@ -1490,12 +1538,15 @@ function createSession({
|
|
|
1490
1538
|
proc,
|
|
1491
1539
|
modelId,
|
|
1492
1540
|
sessionMeta,
|
|
1541
|
+
instructionMapping,
|
|
1493
1542
|
debug,
|
|
1494
1543
|
implementationIdentity,
|
|
1495
1544
|
authenticationProfile,
|
|
1496
1545
|
builtinTools,
|
|
1497
1546
|
permissionMode,
|
|
1498
1547
|
permissionModeMapping,
|
|
1548
|
+
mcpServers,
|
|
1549
|
+
isMcpToolCall,
|
|
1499
1550
|
initialGuidanceApplied: initialGuidanceAppliedAtStart,
|
|
1500
1551
|
skillCatalog,
|
|
1501
1552
|
skillsFingerprint,
|
|
@@ -1542,6 +1593,8 @@ function createSession({
|
|
|
1542
1593
|
let abortError;
|
|
1543
1594
|
let abortListenerAttached = false;
|
|
1544
1595
|
let openBlock;
|
|
1596
|
+
const dynamicToolCalls = /* @__PURE__ */ new Map();
|
|
1597
|
+
const toolCallClassificationErrors = /* @__PURE__ */ new Map();
|
|
1545
1598
|
const subscriptions = [];
|
|
1546
1599
|
const forward = (event) => {
|
|
1547
1600
|
if (event.type === "text-start" || event.type === "reasoning-start") {
|
|
@@ -1574,9 +1627,7 @@ function createSession({
|
|
|
1574
1627
|
"reasoning-start",
|
|
1575
1628
|
"reasoning-delta",
|
|
1576
1629
|
"reasoning-end",
|
|
1577
|
-
"tool-call",
|
|
1578
1630
|
"tool-approval-request",
|
|
1579
|
-
"tool-result",
|
|
1580
1631
|
"file-change",
|
|
1581
1632
|
"finish-step",
|
|
1582
1633
|
"raw"
|
|
@@ -1604,6 +1655,44 @@ function createSession({
|
|
|
1604
1655
|
settle({ error: abortError });
|
|
1605
1656
|
}
|
|
1606
1657
|
};
|
|
1658
|
+
subscriptions.push(
|
|
1659
|
+
channel.on("acp-tool-call-candidate", (event) => {
|
|
1660
|
+
try {
|
|
1661
|
+
dynamicToolCalls.set(
|
|
1662
|
+
event.toolCall.toolCallId,
|
|
1663
|
+
isMcpToolCall?.(event.toolCall) === true
|
|
1664
|
+
);
|
|
1665
|
+
} catch (error) {
|
|
1666
|
+
toolCallClassificationErrors.set(event.toolCall.toolCallId, error);
|
|
1667
|
+
}
|
|
1668
|
+
})
|
|
1669
|
+
);
|
|
1670
|
+
subscriptions.push(
|
|
1671
|
+
channel.on("tool-call", (event) => {
|
|
1672
|
+
if (toolCallClassificationErrors.has(event.toolCallId)) {
|
|
1673
|
+
const error = toolCallClassificationErrors.get(event.toolCallId);
|
|
1674
|
+
closeForwardedBlock();
|
|
1675
|
+
forward({ type: "error", error });
|
|
1676
|
+
try {
|
|
1677
|
+
channel.send({ type: "abort" });
|
|
1678
|
+
} catch {
|
|
1679
|
+
}
|
|
1680
|
+
settle({ error });
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
forward(
|
|
1684
|
+
dynamicToolCalls.get(event.toolCallId) === true ? { ...event, dynamic: true } : event
|
|
1685
|
+
);
|
|
1686
|
+
})
|
|
1687
|
+
);
|
|
1688
|
+
subscriptions.push(
|
|
1689
|
+
channel.on("tool-result", (event) => {
|
|
1690
|
+
const dynamic = dynamicToolCalls.get(event.toolCallId) === true;
|
|
1691
|
+
dynamicToolCalls.delete(event.toolCallId);
|
|
1692
|
+
toolCallClassificationErrors.delete(event.toolCallId);
|
|
1693
|
+
forward(dynamic ? { ...event, dynamic: true } : event);
|
|
1694
|
+
})
|
|
1695
|
+
);
|
|
1607
1696
|
for (const type of eventTypes) {
|
|
1608
1697
|
subscriptions.push(channel.on(type, (event) => forward(event)));
|
|
1609
1698
|
}
|
|
@@ -1744,9 +1833,11 @@ function createSession({
|
|
|
1744
1833
|
builtinTools,
|
|
1745
1834
|
permissionMode,
|
|
1746
1835
|
permissionModeMapping,
|
|
1836
|
+
mcpServers,
|
|
1747
1837
|
debug,
|
|
1748
1838
|
authenticationProfile,
|
|
1749
|
-
sessionMeta
|
|
1839
|
+
sessionMeta,
|
|
1840
|
+
instructionMapping
|
|
1750
1841
|
});
|
|
1751
1842
|
const control = wireTurn({
|
|
1752
1843
|
emit: options.emit,
|
|
@@ -1762,13 +1853,18 @@ function createSession({
|
|
|
1762
1853
|
type: "start",
|
|
1763
1854
|
prompt: initialGuidanceApplied ? prompt : prependACPInitialGuidance({
|
|
1764
1855
|
prompt,
|
|
1765
|
-
instructions: options.instructions,
|
|
1856
|
+
instructions: instructionMapping == null ? options.instructions : void 0,
|
|
1766
1857
|
skills: skillCatalog
|
|
1767
1858
|
}),
|
|
1859
|
+
...instructionMapping == null ? {} : {
|
|
1860
|
+
instructionMapping,
|
|
1861
|
+
...options.instructions == null ? {} : { instructions: options.instructions }
|
|
1862
|
+
},
|
|
1768
1863
|
debug,
|
|
1769
1864
|
builtinTools,
|
|
1770
1865
|
permissionMode,
|
|
1771
1866
|
permissionModeMapping,
|
|
1867
|
+
...mcpServers == null ? {} : { mcpServers },
|
|
1772
1868
|
tools: options.tools == null ? void 0 : turnStartConfig.tools,
|
|
1773
1869
|
turnStartConfig
|
|
1774
1870
|
});
|
|
@@ -1806,6 +1902,11 @@ function createSession({
|
|
|
1806
1902
|
builtinTools: turnStartConfig.builtinTools,
|
|
1807
1903
|
permissionMode: turnStartConfig.permissionMode,
|
|
1808
1904
|
permissionModeMapping: turnStartConfig.permissionModeMapping,
|
|
1905
|
+
...instructionMapping == null ? {} : {
|
|
1906
|
+
instructionMapping,
|
|
1907
|
+
...options.instructions == null ? {} : { instructions: options.instructions }
|
|
1908
|
+
},
|
|
1909
|
+
...mcpServers == null ? {} : { mcpServers },
|
|
1809
1910
|
tools: turnStartConfig.tools,
|
|
1810
1911
|
turnStartConfig,
|
|
1811
1912
|
recoveryMode: {
|
|
@@ -1937,8 +2038,10 @@ function validateACPTurnStartConfig({
|
|
|
1937
2038
|
turnStartConfig,
|
|
1938
2039
|
authenticationProfile,
|
|
1939
2040
|
sessionMeta,
|
|
2041
|
+
instructionMapping,
|
|
1940
2042
|
builtinTools,
|
|
1941
|
-
permissionModeMapping
|
|
2043
|
+
permissionModeMapping,
|
|
2044
|
+
mcpServers
|
|
1942
2045
|
}) {
|
|
1943
2046
|
const current = createACPTurnStartConfig({
|
|
1944
2047
|
prompt: turnStartConfig.prompt,
|
|
@@ -1946,9 +2049,11 @@ function validateACPTurnStartConfig({
|
|
|
1946
2049
|
builtinTools,
|
|
1947
2050
|
permissionMode: turnStartConfig.permissionMode,
|
|
1948
2051
|
permissionModeMapping,
|
|
2052
|
+
mcpServers,
|
|
1949
2053
|
debug: turnStartConfig.debug,
|
|
1950
2054
|
authenticationProfile,
|
|
1951
|
-
sessionMeta
|
|
2055
|
+
sessionMeta,
|
|
2056
|
+
instructionMapping
|
|
1952
2057
|
});
|
|
1953
2058
|
if (current.configurationFingerprint !== turnStartConfig.configurationFingerprint) {
|
|
1954
2059
|
throw new Error(
|
|
@@ -1962,8 +2067,10 @@ function validateACPColdSessionConfiguration({
|
|
|
1962
2067
|
permissionMode,
|
|
1963
2068
|
authenticationProfile,
|
|
1964
2069
|
sessionMeta,
|
|
2070
|
+
instructionMapping,
|
|
1965
2071
|
builtinTools,
|
|
1966
2072
|
permissionModeMapping,
|
|
2073
|
+
mcpServers,
|
|
1967
2074
|
debug
|
|
1968
2075
|
}) {
|
|
1969
2076
|
const current = createACPTurnStartConfig({
|
|
@@ -1972,9 +2079,11 @@ function validateACPColdSessionConfiguration({
|
|
|
1972
2079
|
builtinTools,
|
|
1973
2080
|
permissionMode,
|
|
1974
2081
|
permissionModeMapping,
|
|
2082
|
+
mcpServers,
|
|
1975
2083
|
debug,
|
|
1976
2084
|
authenticationProfile,
|
|
1977
|
-
sessionMeta
|
|
2085
|
+
sessionMeta,
|
|
2086
|
+
instructionMapping
|
|
1978
2087
|
});
|
|
1979
2088
|
if (current.configurationFingerprint !== coldSession.configurationFingerprint || coldSession.permissionMode !== permissionMode || coldSession.modelId !== modelId) {
|
|
1980
2089
|
throw new Error(
|
|
@@ -2021,7 +2130,7 @@ function deserializeBridgeError({
|
|
|
2021
2130
|
}
|
|
2022
2131
|
|
|
2023
2132
|
// src/version.ts
|
|
2024
|
-
var VERSION = true ? "1.0.
|
|
2133
|
+
var VERSION = true ? "1.0.3" : "0.0.0-test";
|
|
2025
2134
|
|
|
2026
2135
|
// src/acp-harness.ts
|
|
2027
2136
|
var ACP_CLIENT_APP = {
|
|
@@ -2063,6 +2172,14 @@ var acpResumeStateSchema = z4.object({
|
|
|
2063
2172
|
skillsFingerprint: z4.string().optional()
|
|
2064
2173
|
});
|
|
2065
2174
|
function createACP(settings) {
|
|
2175
|
+
if (settings.mcpServers != null && Object.prototype.hasOwnProperty.call(
|
|
2176
|
+
settings.mcpServers,
|
|
2177
|
+
"ai-sdk-harness-tools"
|
|
2178
|
+
)) {
|
|
2179
|
+
throw new Error(
|
|
2180
|
+
'ACP MCP server name "ai-sdk-harness-tools" is reserved for HarnessAgent tools.'
|
|
2181
|
+
);
|
|
2182
|
+
}
|
|
2066
2183
|
const version = settings.version ?? "v1";
|
|
2067
2184
|
switch (version) {
|
|
2068
2185
|
case "v1": {
|