@ai-sdk/harness-pi 1.0.89 → 1.0.93
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 +33 -0
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/pi-translate.ts +13 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/harness-pi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ai-sdk/harness": "1.0.
|
|
30
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
29
|
+
"@ai-sdk/harness": "1.0.91",
|
|
30
|
+
"@ai-sdk/provider-utils": "5.0.32",
|
|
31
31
|
"@earendil-works/pi-ai": "0.74.2",
|
|
32
32
|
"@earendil-works/pi-coding-agent": "^0.80.10",
|
|
33
33
|
"pi-mcp-adapter": "2.12.1",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"zod": "^3.25.76 || ^4.1.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ai-sdk/sandbox-just-bash": "1.0.
|
|
40
|
+
"@ai-sdk/sandbox-just-bash": "1.0.91",
|
|
41
41
|
"@types/node": "22.19.19",
|
|
42
42
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
43
43
|
"tsup": "^8.5.1",
|
package/src/pi-translate.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface PiTranslatorState {
|
|
|
30
30
|
observedToolNames: Map<string, string>;
|
|
31
31
|
/** Tool ids requested by the current assistant message but not yet completed. */
|
|
32
32
|
pendingStepToolCallIds: Set<string>;
|
|
33
|
+
/** Total tool calls requested by the current assistant message. */
|
|
34
|
+
stepToolCallCount: number | undefined;
|
|
33
35
|
/** Whether the current assistant message has opened a visible step. */
|
|
34
36
|
stepOpen: boolean;
|
|
35
37
|
/**
|
|
@@ -84,6 +86,7 @@ export function createPiTranslatorState(
|
|
|
84
86
|
reasoningStarted: false,
|
|
85
87
|
observedToolNames: new Map(),
|
|
86
88
|
pendingStepToolCallIds: new Set(),
|
|
89
|
+
stepToolCallCount: undefined,
|
|
87
90
|
stepOpen: false,
|
|
88
91
|
hostToolResults: new Map(),
|
|
89
92
|
dynamicToolCallIds: new Set(),
|
|
@@ -155,6 +158,7 @@ function finishStep(state: PiTranslatorState): HarnessV1StreamPart[] {
|
|
|
155
158
|
if (!state.stepOpen || state.pendingStepToolCallIds.size > 0) return [];
|
|
156
159
|
state.stepOpen = false;
|
|
157
160
|
state.pendingStepToolCallIds.clear();
|
|
161
|
+
state.stepToolCallCount = undefined;
|
|
158
162
|
return [
|
|
159
163
|
{
|
|
160
164
|
type: 'finish-step',
|
|
@@ -215,6 +219,7 @@ export function translatePiEvent(
|
|
|
215
219
|
if (event.type === 'message_start') {
|
|
216
220
|
state.stepOpen = true;
|
|
217
221
|
state.pendingStepToolCallIds.clear();
|
|
222
|
+
state.stepToolCallCount = undefined;
|
|
218
223
|
}
|
|
219
224
|
state.streamedAssistantText = '';
|
|
220
225
|
state.currentTextId = undefined;
|
|
@@ -308,11 +313,15 @@ export function translatePiEvent(
|
|
|
308
313
|
state.currentReasoningId = undefined;
|
|
309
314
|
}
|
|
310
315
|
if (event.type === 'message_end') {
|
|
311
|
-
|
|
316
|
+
const toolCallIds = extractPiToolCallIds(event.message);
|
|
317
|
+
state.stepToolCallCount =
|
|
318
|
+
toolCallIds.length > 0 ? toolCallIds.length : undefined;
|
|
319
|
+
for (const toolCallId of toolCallIds) {
|
|
312
320
|
state.pendingStepToolCallIds.add(toolCallId);
|
|
313
321
|
}
|
|
314
322
|
} else {
|
|
315
323
|
state.pendingStepToolCallIds.clear();
|
|
324
|
+
state.stepToolCallCount = undefined;
|
|
316
325
|
parts.push(...finishStep(state));
|
|
317
326
|
}
|
|
318
327
|
return parts;
|
|
@@ -337,6 +346,9 @@ export function translatePiEvent(
|
|
|
337
346
|
...(wire !== native ? { nativeName: native } : {}),
|
|
338
347
|
...(providerExecuted ? { providerExecuted: true } : {}),
|
|
339
348
|
...(isMcpTool ? { dynamic: true } : {}),
|
|
349
|
+
...(state.stepToolCallCount != null
|
|
350
|
+
? { stepToolCallCount: state.stepToolCallCount }
|
|
351
|
+
: {}),
|
|
340
352
|
} as HarnessV1StreamPart,
|
|
341
353
|
];
|
|
342
354
|
}
|