@polka-codes/cli-shared 0.9.9 → 0.9.11
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 +70 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50694,7 +50694,17 @@ ${Object.entries(example.input).map(([name17, value]) => renderParameterValue(na
|
|
|
50694
50694
|
`)}
|
|
50695
50695
|
</${toolNamePrefix}${tool.name}>
|
|
50696
50696
|
`;
|
|
50697
|
-
var toolUsePrompt = (tools, toolNamePrefix) => {
|
|
50697
|
+
var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
|
|
50698
|
+
if (useNativeTool) {
|
|
50699
|
+
return `
|
|
50700
|
+
====
|
|
50701
|
+
|
|
50702
|
+
TOOL USE
|
|
50703
|
+
|
|
50704
|
+
- You MUST use a tool.
|
|
50705
|
+
- Batch tool use when feasible; avoid redundant calls.
|
|
50706
|
+
`;
|
|
50707
|
+
}
|
|
50698
50708
|
if (tools.length === 0) {
|
|
50699
50709
|
return "";
|
|
50700
50710
|
}
|
|
@@ -51045,7 +51055,8 @@ ${instance.prompt}`;
|
|
|
51045
51055
|
}
|
|
51046
51056
|
if (requestTimeoutSeconds > 0 && requestAbortController) {
|
|
51047
51057
|
timeout = setTimeout(() => {
|
|
51048
|
-
console.debug(`
|
|
51058
|
+
console.debug(`
|
|
51059
|
+
Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`);
|
|
51049
51060
|
requestAbortController?.abort();
|
|
51050
51061
|
}, requestTimeoutSeconds * 1000);
|
|
51051
51062
|
}
|
|
@@ -51106,7 +51117,15 @@ ${instance.prompt}`;
|
|
|
51106
51117
|
}
|
|
51107
51118
|
}
|
|
51108
51119
|
if (this.config.toolFormat === "native") {
|
|
51109
|
-
if (respMessages.some((m) =>
|
|
51120
|
+
if (respMessages.some((m) => {
|
|
51121
|
+
if (m.role === "tool") {
|
|
51122
|
+
return true;
|
|
51123
|
+
}
|
|
51124
|
+
if (typeof m.content === "string") {
|
|
51125
|
+
return true;
|
|
51126
|
+
}
|
|
51127
|
+
return m.content.some((part) => part.type === "tool-call" || part.type === "tool-result" || part.type === "text");
|
|
51128
|
+
})) {
|
|
51110
51129
|
break;
|
|
51111
51130
|
}
|
|
51112
51131
|
} else {
|
|
@@ -51118,7 +51137,8 @@ ${instance.prompt}`;
|
|
|
51118
51137
|
break;
|
|
51119
51138
|
}
|
|
51120
51139
|
if (i < retryCount - 1) {
|
|
51121
|
-
console.debug(`
|
|
51140
|
+
console.debug(`
|
|
51141
|
+
Retrying request ${i + 2} of ${retryCount}`);
|
|
51122
51142
|
}
|
|
51123
51143
|
}
|
|
51124
51144
|
if (respMessages.length === 0) {
|
|
@@ -51356,7 +51376,7 @@ You are the **Analyzer** agent, responsible for:
|
|
|
51356
51376
|
5. **Documentation Assessment**: Review documentation quality and completeness.
|
|
51357
51377
|
6. **Non-Modification**: Never modify code or files - focus solely on analysis.
|
|
51358
51378
|
|
|
51359
|
-
${useNativeTool
|
|
51379
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
51360
51380
|
${capabilities(toolNamePrefix)}
|
|
51361
51381
|
${systemInformation(info)}
|
|
51362
51382
|
${customInstructions(instructions)}
|
|
@@ -51477,7 +51497,7 @@ RETRY GUIDELINES
|
|
|
51477
51497
|
- Report any partial improvements`;
|
|
51478
51498
|
var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
|
|
51479
51499
|
${basePrompt}
|
|
51480
|
-
${useNativeTool
|
|
51500
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
51481
51501
|
${codeFixingStrategies}
|
|
51482
51502
|
${retryGuidelines}
|
|
51483
51503
|
${capabilities(toolNamePrefix)}
|
|
@@ -51676,7 +51696,7 @@ You solve the user's task by working in small, verifiable steps.
|
|
|
51676
51696
|
`;
|
|
51677
51697
|
var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
|
|
51678
51698
|
${basePrompt2}
|
|
51679
|
-
${useNativeTool
|
|
51699
|
+
${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
|
|
51680
51700
|
${editingFilesPrompt(toolNamePrefix)}
|
|
51681
51701
|
${capabilities(toolNamePrefix)}
|
|
51682
51702
|
${rules(toolNamePrefix)}
|
|
@@ -58494,54 +58514,54 @@ var source_default = chalk;
|
|
|
58494
58514
|
|
|
58495
58515
|
// src/utils/eventHandler.ts
|
|
58496
58516
|
var toolCallStats = new Map;
|
|
58497
|
-
var printEvent = (verbose, usageMeter) => {
|
|
58517
|
+
var printEvent = (verbose, usageMeter, customConsole = console) => {
|
|
58498
58518
|
let hadReasoning = false;
|
|
58499
58519
|
return (event) => {
|
|
58500
58520
|
switch (event.kind) {
|
|
58501
58521
|
case "StartTask" /* StartTask */:
|
|
58502
58522
|
toolCallStats.clear();
|
|
58503
58523
|
if (verbose > 1) {
|
|
58504
|
-
|
|
58524
|
+
customConsole.log(`
|
|
58505
58525
|
====== System Prompt ======
|
|
58506
58526
|
${event.systemPrompt}`);
|
|
58507
|
-
|
|
58527
|
+
customConsole.log(`
|
|
58508
58528
|
|
|
58509
58529
|
================
|
|
58510
58530
|
`);
|
|
58511
58531
|
}
|
|
58512
58532
|
break;
|
|
58513
58533
|
case "StartRequest" /* StartRequest */:
|
|
58514
|
-
|
|
58534
|
+
customConsole.log(`
|
|
58515
58535
|
|
|
58516
58536
|
======== New Request ========
|
|
58517
58537
|
`);
|
|
58518
58538
|
if (verbose) {
|
|
58519
58539
|
const userMessage = event.userMessage.content;
|
|
58520
58540
|
if (typeof userMessage === "string") {
|
|
58521
|
-
|
|
58541
|
+
customConsole.log(userMessage);
|
|
58522
58542
|
} else {
|
|
58523
58543
|
for (const content of userMessage) {
|
|
58524
58544
|
switch (content.type) {
|
|
58525
58545
|
case "text":
|
|
58526
|
-
|
|
58546
|
+
customConsole.log(content.text);
|
|
58527
58547
|
break;
|
|
58528
58548
|
case "image":
|
|
58529
58549
|
if (content.image instanceof URL) {
|
|
58530
|
-
|
|
58550
|
+
customConsole.log(source_default.yellow(`[Image content from URL: ${content.image}]`));
|
|
58531
58551
|
} else {
|
|
58532
|
-
|
|
58552
|
+
customConsole.log(source_default.yellow(`[Image content: ${content.mediaType}]`));
|
|
58533
58553
|
}
|
|
58534
58554
|
break;
|
|
58535
58555
|
case "file":
|
|
58536
|
-
|
|
58556
|
+
customConsole.log(source_default.yellow(`[File name: ${content.filename}, type: ${content.mediaType}]`));
|
|
58537
58557
|
break;
|
|
58538
58558
|
case "tool-call":
|
|
58539
|
-
|
|
58559
|
+
customConsole.log(source_default.yellow(`[Tool call: ${content.toolName}]`));
|
|
58540
58560
|
break;
|
|
58541
58561
|
case "tool-result":
|
|
58542
|
-
|
|
58562
|
+
customConsole.log(source_default.yellow(`[Tool result: ${content.toolName}]`));
|
|
58543
58563
|
if (verbose > 0) {
|
|
58544
|
-
|
|
58564
|
+
customConsole.log(content.output);
|
|
58545
58565
|
}
|
|
58546
58566
|
break;
|
|
58547
58567
|
case "reasoning":
|
|
@@ -58549,14 +58569,14 @@ ${event.systemPrompt}`);
|
|
|
58549
58569
|
}
|
|
58550
58570
|
}
|
|
58551
58571
|
}
|
|
58552
|
-
|
|
58572
|
+
customConsole.log(`
|
|
58553
58573
|
|
|
58554
58574
|
======== Request Message Ended ========
|
|
58555
58575
|
`);
|
|
58556
58576
|
}
|
|
58557
58577
|
break;
|
|
58558
58578
|
case "EndRequest" /* EndRequest */:
|
|
58559
|
-
|
|
58579
|
+
customConsole.log(`
|
|
58560
58580
|
|
|
58561
58581
|
======== Request Ended ========
|
|
58562
58582
|
`);
|
|
@@ -58567,6 +58587,9 @@ ${event.systemPrompt}`);
|
|
|
58567
58587
|
case "Usage" /* Usage */:
|
|
58568
58588
|
break;
|
|
58569
58589
|
case "Text" /* Text */:
|
|
58590
|
+
if (customConsole !== console) {
|
|
58591
|
+
break;
|
|
58592
|
+
}
|
|
58570
58593
|
if (hadReasoning) {
|
|
58571
58594
|
process.stdout.write(`
|
|
58572
58595
|
|
|
@@ -58576,11 +58599,14 @@ ${event.systemPrompt}`);
|
|
|
58576
58599
|
process.stdout.write(event.newText);
|
|
58577
58600
|
break;
|
|
58578
58601
|
case "Reasoning" /* Reasoning */:
|
|
58602
|
+
if (customConsole !== console) {
|
|
58603
|
+
break;
|
|
58604
|
+
}
|
|
58579
58605
|
process.stdout.write(source_default.dim(event.newText));
|
|
58580
58606
|
hadReasoning = true;
|
|
58581
58607
|
break;
|
|
58582
58608
|
case "ToolUse" /* ToolUse */: {
|
|
58583
|
-
|
|
58609
|
+
customConsole.log(source_default.yellow(`
|
|
58584
58610
|
|
|
58585
58611
|
Tool use:`, event.tool), event.content);
|
|
58586
58612
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
@@ -58597,10 +58623,10 @@ Tool use:`, event.tool), event.content);
|
|
|
58597
58623
|
case "ToolInvalid" /* ToolInvalid */:
|
|
58598
58624
|
break;
|
|
58599
58625
|
case "ToolError" /* ToolError */: {
|
|
58600
|
-
|
|
58626
|
+
customConsole.error(source_default.red(`
|
|
58601
58627
|
|
|
58602
58628
|
Tool error:`, event.tool));
|
|
58603
|
-
|
|
58629
|
+
customConsole.error(source_default.red(event.content));
|
|
58604
58630
|
const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
|
|
58605
58631
|
stats.errors++;
|
|
58606
58632
|
toolCallStats.set(event.tool, stats);
|
|
@@ -58609,48 +58635,48 @@ Tool error:`, event.tool));
|
|
|
58609
58635
|
case "ToolInterrupted" /* ToolInterrupted */:
|
|
58610
58636
|
break;
|
|
58611
58637
|
case "ToolHandOver" /* ToolHandOver */:
|
|
58612
|
-
|
|
58638
|
+
customConsole.log(`
|
|
58613
58639
|
|
|
58614
58640
|
======== Task Handed Over ========
|
|
58615
58641
|
`);
|
|
58616
|
-
|
|
58617
|
-
|
|
58618
|
-
|
|
58619
|
-
|
|
58620
|
-
|
|
58642
|
+
customConsole.log("Agent:", event.agentName);
|
|
58643
|
+
customConsole.log("Task:", event.task);
|
|
58644
|
+
customConsole.log("Context:", event.context);
|
|
58645
|
+
customConsole.log("Files:", event.files);
|
|
58646
|
+
customConsole.log();
|
|
58621
58647
|
break;
|
|
58622
58648
|
case "ToolDelegate" /* ToolDelegate */:
|
|
58623
|
-
|
|
58649
|
+
customConsole.log(`
|
|
58624
58650
|
|
|
58625
58651
|
======== Task Delegated ========
|
|
58626
58652
|
`);
|
|
58627
|
-
|
|
58628
|
-
|
|
58629
|
-
|
|
58630
|
-
|
|
58631
|
-
|
|
58653
|
+
customConsole.log("Agent:", event.agentName);
|
|
58654
|
+
customConsole.log("Task:", event.task);
|
|
58655
|
+
customConsole.log("Context:", event.context);
|
|
58656
|
+
customConsole.log("Files:", event.files);
|
|
58657
|
+
customConsole.log();
|
|
58632
58658
|
break;
|
|
58633
58659
|
case "UsageExceeded" /* UsageExceeded */:
|
|
58634
|
-
|
|
58660
|
+
customConsole.log(`
|
|
58635
58661
|
|
|
58636
58662
|
======= Usage Exceeded ========
|
|
58637
58663
|
`);
|
|
58638
58664
|
break;
|
|
58639
58665
|
case "EndTask" /* EndTask */:
|
|
58640
|
-
|
|
58666
|
+
customConsole.log(`
|
|
58641
58667
|
|
|
58642
58668
|
======== Task Ended ========
|
|
58643
58669
|
`);
|
|
58644
|
-
|
|
58670
|
+
customConsole.log("Reason:", event.exitReason.type);
|
|
58645
58671
|
switch (event.exitReason.type) {
|
|
58646
58672
|
case "Exit" /* Exit */:
|
|
58647
|
-
|
|
58673
|
+
customConsole.log("Exit Message:", event.exitReason.message);
|
|
58648
58674
|
break;
|
|
58649
58675
|
case "Interrupted" /* Interrupted */:
|
|
58650
|
-
|
|
58676
|
+
customConsole.log("Interrupted Message:", event.exitReason.message);
|
|
58651
58677
|
break;
|
|
58652
58678
|
}
|
|
58653
|
-
|
|
58679
|
+
customConsole.log(`
|
|
58654
58680
|
|
|
58655
58681
|
======== Tool Call Stats ========`);
|
|
58656
58682
|
if (toolCallStats.size > 0) {
|
|
@@ -58664,9 +58690,9 @@ Tool error:`, event.tool));
|
|
|
58664
58690
|
"Success Rate": `${successRate.toFixed(2)}%`
|
|
58665
58691
|
};
|
|
58666
58692
|
});
|
|
58667
|
-
|
|
58693
|
+
customConsole.table(tableData);
|
|
58668
58694
|
} else {
|
|
58669
|
-
|
|
58695
|
+
customConsole.log("No tools were called.");
|
|
58670
58696
|
}
|
|
58671
58697
|
break;
|
|
58672
58698
|
}
|