@polka-codes/cli-shared 0.9.23 → 0.9.24
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.js +61 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -61403,13 +61403,14 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
61403
61403
|
return resp;
|
|
61404
61404
|
};
|
|
61405
61405
|
let hasPause = false;
|
|
61406
|
+
const toolUseContents = response.filter((c) => c.type === "tool_use");
|
|
61406
61407
|
outer:
|
|
61407
61408
|
for (const content of response) {
|
|
61408
61409
|
switch (content.type) {
|
|
61409
61410
|
case "text":
|
|
61410
61411
|
break;
|
|
61411
61412
|
case "tool_use": {
|
|
61412
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name,
|
|
61413
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
|
|
61413
61414
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
61414
61415
|
switch (toolResp.type) {
|
|
61415
61416
|
case "Reply" /* Reply */: {
|
|
@@ -61418,52 +61419,73 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
61418
61419
|
break;
|
|
61419
61420
|
}
|
|
61420
61421
|
case "Exit" /* Exit */:
|
|
61422
|
+
case "HandOver" /* HandOver */:
|
|
61423
|
+
case "Delegate" /* Delegate */: {
|
|
61424
|
+
if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
|
|
61425
|
+
const message = {
|
|
61426
|
+
type: "Error" /* Error */,
|
|
61427
|
+
message: {
|
|
61428
|
+
type: "error-text",
|
|
61429
|
+
value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
|
|
61430
|
+
},
|
|
61431
|
+
canRetry: false
|
|
61432
|
+
};
|
|
61433
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
|
|
61434
|
+
toolResponses.push({
|
|
61435
|
+
type: "response",
|
|
61436
|
+
tool: content.name,
|
|
61437
|
+
response: processResponse(message.message),
|
|
61438
|
+
id: content.id
|
|
61439
|
+
});
|
|
61440
|
+
break;
|
|
61441
|
+
}
|
|
61421
61442
|
if (toolResponses.length > 0) {
|
|
61422
61443
|
break outer;
|
|
61423
61444
|
}
|
|
61424
|
-
|
|
61445
|
+
if (toolResp.type === "Exit" /* Exit */) {
|
|
61446
|
+
return { type: "exit", reason: toolResp };
|
|
61447
|
+
}
|
|
61448
|
+
if (toolResp.type === "HandOver" /* HandOver */) {
|
|
61449
|
+
await this.#callback({
|
|
61450
|
+
kind: "ToolHandOver" /* ToolHandOver */,
|
|
61451
|
+
agent: this,
|
|
61452
|
+
tool: content.name,
|
|
61453
|
+
agentName: toolResp.agentName,
|
|
61454
|
+
task: toolResp.task,
|
|
61455
|
+
context: toolResp.context,
|
|
61456
|
+
files: toolResp.files
|
|
61457
|
+
});
|
|
61458
|
+
return { type: "exit", reason: toolResp };
|
|
61459
|
+
}
|
|
61460
|
+
if (toolResp.type === "Delegate" /* Delegate */) {
|
|
61461
|
+
await this.#callback({
|
|
61462
|
+
kind: "ToolDelegate" /* ToolDelegate */,
|
|
61463
|
+
agent: this,
|
|
61464
|
+
tool: content.name,
|
|
61465
|
+
agentName: toolResp.agentName,
|
|
61466
|
+
task: toolResp.task,
|
|
61467
|
+
context: toolResp.context,
|
|
61468
|
+
files: toolResp.files
|
|
61469
|
+
});
|
|
61470
|
+
return { type: "exit", reason: toolResp };
|
|
61471
|
+
}
|
|
61472
|
+
break;
|
|
61473
|
+
}
|
|
61425
61474
|
case "Invalid" /* Invalid */: {
|
|
61426
61475
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
61427
61476
|
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
61428
|
-
|
|
61429
|
-
}
|
|
61430
|
-
case "Error" /* Error */: {
|
|
61431
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
61432
|
-
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
61433
|
-
break outer;
|
|
61434
|
-
}
|
|
61435
|
-
case "Interrupted" /* Interrupted */:
|
|
61436
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
61437
|
-
return { type: "exit", reason: toolResp };
|
|
61438
|
-
case "HandOver" /* HandOver */: {
|
|
61439
|
-
if (toolResponses.length > 0) {
|
|
61477
|
+
if (this.config.toolFormat !== "native") {
|
|
61440
61478
|
break outer;
|
|
61441
61479
|
}
|
|
61442
|
-
|
|
61443
|
-
kind: "ToolHandOver" /* ToolHandOver */,
|
|
61444
|
-
agent: this,
|
|
61445
|
-
tool: content.name,
|
|
61446
|
-
agentName: toolResp.agentName,
|
|
61447
|
-
task: toolResp.task,
|
|
61448
|
-
context: toolResp.context,
|
|
61449
|
-
files: toolResp.files
|
|
61450
|
-
});
|
|
61451
|
-
return { type: "exit", reason: toolResp };
|
|
61480
|
+
break;
|
|
61452
61481
|
}
|
|
61453
|
-
case "
|
|
61454
|
-
|
|
61482
|
+
case "Error" /* Error */: {
|
|
61483
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
|
|
61484
|
+
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
61485
|
+
if (this.config.toolFormat !== "native") {
|
|
61455
61486
|
break outer;
|
|
61456
61487
|
}
|
|
61457
|
-
|
|
61458
|
-
kind: "ToolDelegate" /* ToolDelegate */,
|
|
61459
|
-
agent: this,
|
|
61460
|
-
tool: content.name,
|
|
61461
|
-
agentName: toolResp.agentName,
|
|
61462
|
-
task: toolResp.task,
|
|
61463
|
-
context: toolResp.context,
|
|
61464
|
-
files: toolResp.files
|
|
61465
|
-
});
|
|
61466
|
-
return { type: "exit", reason: toolResp };
|
|
61488
|
+
break;
|
|
61467
61489
|
}
|
|
61468
61490
|
case "Pause" /* Pause */: {
|
|
61469
61491
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
@@ -62602,7 +62624,7 @@ var handler15 = async (provider2, args) => {
|
|
|
62602
62624
|
commandParts.push(commitRange);
|
|
62603
62625
|
}
|
|
62604
62626
|
if (file3) {
|
|
62605
|
-
commandParts.push("--", file3);
|
|
62627
|
+
commandParts.push("--", `'${file3}'`);
|
|
62606
62628
|
}
|
|
62607
62629
|
const command = commandParts.join(" ");
|
|
62608
62630
|
try {
|
|
@@ -69059,7 +69081,7 @@ ${event.systemPrompt}`);
|
|
|
69059
69081
|
case "ToolUse" /* ToolUse */: {
|
|
69060
69082
|
customConsole.log(source_default.yellow(`
|
|
69061
69083
|
|
|
69062
|
-
Tool use:`, event.tool), event.
|
|
69084
|
+
Tool use:`, event.tool), event.params);
|
|
69063
69085
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
69064
69086
|
stats.calls++;
|
|
69065
69087
|
toolCallStats.set(event.tool, stats);
|
|
@@ -69077,7 +69099,7 @@ Tool use:`, event.tool), event.content);
|
|
|
69077
69099
|
customConsole.error(source_default.red(`
|
|
69078
69100
|
|
|
69079
69101
|
Tool error:`, event.tool));
|
|
69080
|
-
customConsole.error(
|
|
69102
|
+
customConsole.error(event.error);
|
|
69081
69103
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
69082
69104
|
stats.errors++;
|
|
69083
69105
|
toolCallStats.set(event.tool, stats);
|