@ai-sdk/harness-acp 1.0.8 → 1.0.10
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 +18 -0
- package/README.md +17 -4
- package/dist/bridge/host-tool-mcp.mjs +1 -1
- package/dist/bridge/host-tool-mcp.mjs.map +1 -1
- package/dist/bridge/index.mjs +8 -13
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.js +349 -105
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/acp-harness.ts +10 -0
- package/src/index.ts +1 -0
- package/src/v1/acp-bootstrap.ts +119 -0
- package/src/v1/acp-v1-harness.ts +163 -118
- package/src/v1/acp-v1-settings.ts +12 -1
- package/src/v1/bridge/acp-v1-bridge-environment.ts +4 -0
- package/src/v1/bridge/index.ts +10 -8
- package/src/v1/bridge/stream-translator.ts +4 -14
- package/src/v1/implementation.ts +25 -1
- package/src/v1/index.ts +1 -0
|
@@ -78,7 +78,6 @@ export function createACPStreamTranslator({
|
|
|
78
78
|
| undefined;
|
|
79
79
|
let blockCounter = 0;
|
|
80
80
|
let stepOpen = false;
|
|
81
|
-
let completedToolStepEligible = false;
|
|
82
81
|
let finished = false;
|
|
83
82
|
const blockIdCounts = new Map<string, number>();
|
|
84
83
|
const toolStates = new Map<string, ToolState>();
|
|
@@ -154,15 +153,10 @@ export function createACPStreamTranslator({
|
|
|
154
153
|
harnessMetadata: { acp: { inferredStep: true } },
|
|
155
154
|
});
|
|
156
155
|
stepOpen = false;
|
|
157
|
-
completedToolStepEligible = false;
|
|
158
156
|
};
|
|
159
157
|
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
!stepOpen ||
|
|
163
|
-
!completedToolStepEligible ||
|
|
164
|
-
pendingToolCallIds.size > 0
|
|
165
|
-
) {
|
|
158
|
+
const finishCompletedToolStep = () => {
|
|
159
|
+
if (!stepOpen || pendingToolCallIds.size > 0) {
|
|
166
160
|
return;
|
|
167
161
|
}
|
|
168
162
|
emitInferredStep({
|
|
@@ -252,7 +246,6 @@ export function createACPStreamTranslator({
|
|
|
252
246
|
state.emittedCall = true;
|
|
253
247
|
stepOpen = true;
|
|
254
248
|
pendingToolCallIds.add(state.toolCallId);
|
|
255
|
-
completedToolStepEligible = false;
|
|
256
249
|
}
|
|
257
250
|
|
|
258
251
|
emitFileChanges({ state, emit });
|
|
@@ -270,7 +263,7 @@ export function createACPStreamTranslator({
|
|
|
270
263
|
});
|
|
271
264
|
state.emittedResult = true;
|
|
272
265
|
pendingToolCallIds.delete(state.toolCallId);
|
|
273
|
-
|
|
266
|
+
finishCompletedToolStep();
|
|
274
267
|
}
|
|
275
268
|
};
|
|
276
269
|
|
|
@@ -293,7 +286,6 @@ export function createACPStreamTranslator({
|
|
|
293
286
|
});
|
|
294
287
|
stepOpen = true;
|
|
295
288
|
pendingToolCallIds.add(toolCallId);
|
|
296
|
-
completedToolStepEligible = false;
|
|
297
289
|
};
|
|
298
290
|
|
|
299
291
|
const hostToolResult = ({
|
|
@@ -316,7 +308,7 @@ export function createACPStreamTranslator({
|
|
|
316
308
|
...(isError ? { isError: true } : {}),
|
|
317
309
|
});
|
|
318
310
|
pendingToolCallIds.delete(toolCallId);
|
|
319
|
-
|
|
311
|
+
finishCompletedToolStep();
|
|
320
312
|
};
|
|
321
313
|
|
|
322
314
|
return {
|
|
@@ -338,7 +330,6 @@ export function createACPStreamTranslator({
|
|
|
338
330
|
update.content?.type === 'text' &&
|
|
339
331
|
typeof update.content.text === 'string'
|
|
340
332
|
) {
|
|
341
|
-
flushCompletedToolStep();
|
|
342
333
|
emitContent({
|
|
343
334
|
type: 'text',
|
|
344
335
|
text: update.content.text,
|
|
@@ -351,7 +342,6 @@ export function createACPStreamTranslator({
|
|
|
351
342
|
update.content?.type === 'text' &&
|
|
352
343
|
typeof update.content.text === 'string'
|
|
353
344
|
) {
|
|
354
|
-
flushCompletedToolStep();
|
|
355
345
|
emitContent({
|
|
356
346
|
type: 'reasoning',
|
|
357
347
|
text: update.content.text,
|
package/src/v1/implementation.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type ACPNpmImplementation = {
|
|
|
23
23
|
readonly executable: string;
|
|
24
24
|
readonly args?: ReadonlyArray<string>;
|
|
25
25
|
readonly forwardEnv?: ReadonlyArray<string>;
|
|
26
|
+
readonly credentialEnv?: ReadonlyArray<string>;
|
|
26
27
|
readonly env?: Readonly<Record<string, string>>;
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -36,6 +37,7 @@ export function createACPV1Implementation({
|
|
|
36
37
|
executable: settings.executable,
|
|
37
38
|
args: settings.args,
|
|
38
39
|
forwardEnv: settings.forwardEnv,
|
|
40
|
+
credentialEnv: settings.credentialEnv,
|
|
39
41
|
env: settings.env,
|
|
40
42
|
};
|
|
41
43
|
}
|
|
@@ -68,14 +70,28 @@ export function validateACPV1Implementation(
|
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
validateForwardEnvironment({ forwardEnv: implementation.forwardEnv });
|
|
73
|
+
validateForwardEnvironment({ forwardEnv: implementation.credentialEnv });
|
|
71
74
|
validateEnvironment({ env: implementation.env });
|
|
72
75
|
const forwardedKeys = new Set(implementation.forwardEnv ?? []);
|
|
76
|
+
const credentialKeys = new Set(implementation.credentialEnv ?? []);
|
|
77
|
+
for (const key of credentialKeys) {
|
|
78
|
+
if (forwardedKeys.has(key)) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both forwardEnv and credentialEnv.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
73
84
|
for (const key of Object.keys(implementation.env ?? {})) {
|
|
74
85
|
if (forwardedKeys.has(key)) {
|
|
75
86
|
throw new Error(
|
|
76
87
|
`ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both forwardEnv and env.`,
|
|
77
88
|
);
|
|
78
89
|
}
|
|
90
|
+
if (credentialKeys.has(key)) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both credentialEnv and env.`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
79
95
|
}
|
|
80
96
|
}
|
|
81
97
|
|
|
@@ -165,6 +181,9 @@ export function createImplementationIdentity({
|
|
|
165
181
|
const forwardedEnvironment = [
|
|
166
182
|
...new Set(implementation.forwardEnv ?? []),
|
|
167
183
|
].sort();
|
|
184
|
+
const credentialEnvironment = [
|
|
185
|
+
...new Set(implementation.credentialEnv ?? []),
|
|
186
|
+
].sort();
|
|
168
187
|
const literalEnvironment = Object.fromEntries(
|
|
169
188
|
Object.entries(implementation.env ?? {})
|
|
170
189
|
.sort(([left], [right]) => left.localeCompare(right))
|
|
@@ -179,6 +198,7 @@ export function createImplementationIdentity({
|
|
|
179
198
|
clientApp,
|
|
180
199
|
environment: {
|
|
181
200
|
forwarded: forwardedEnvironment,
|
|
201
|
+
credential: credentialEnvironment,
|
|
182
202
|
literal: literalEnvironment,
|
|
183
203
|
},
|
|
184
204
|
providerAuthentication: providerAuthentication ?? null,
|
|
@@ -213,7 +233,10 @@ export function resolveImplementationEnvironment({
|
|
|
213
233
|
env: Readonly<Record<string, string | undefined>>;
|
|
214
234
|
}): Record<string, string> {
|
|
215
235
|
const forwardedEnvironment: Record<string, string> = {};
|
|
216
|
-
for (const name of
|
|
236
|
+
for (const name of [
|
|
237
|
+
...(implementation.forwardEnv ?? []),
|
|
238
|
+
...(implementation.credentialEnv ?? []),
|
|
239
|
+
]) {
|
|
217
240
|
const value = env[name];
|
|
218
241
|
if (value != null && value.length > 0) {
|
|
219
242
|
forwardedEnvironment[name] = value;
|
|
@@ -284,6 +307,7 @@ function getImplementationEnvironmentKeys({
|
|
|
284
307
|
return [
|
|
285
308
|
...new Set([
|
|
286
309
|
...(implementation.forwardEnv ?? []),
|
|
310
|
+
...(implementation.credentialEnv ?? []),
|
|
287
311
|
...Object.keys(implementation.env ?? {}),
|
|
288
312
|
]),
|
|
289
313
|
].sort();
|