@polka-codes/cli 0.8.23 → 0.8.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 +34 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38447,7 +38447,7 @@ var {
|
|
|
38447
38447
|
Help
|
|
38448
38448
|
} = import__.default;
|
|
38449
38449
|
// package.json
|
|
38450
|
-
var version = "0.8.
|
|
38450
|
+
var version = "0.8.24";
|
|
38451
38451
|
|
|
38452
38452
|
// ../core/src/AiService/AiServiceBase.ts
|
|
38453
38453
|
class AiServiceBase {
|
|
@@ -49012,7 +49012,7 @@ var updateKnowledge_default = {
|
|
|
49012
49012
|
// ../core/src/tools/writeToFile.ts
|
|
49013
49013
|
var toolInfo11 = {
|
|
49014
49014
|
name: "write_to_file",
|
|
49015
|
-
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<
|
|
49015
|
+
description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `<`, `>`, or `&`. Also ensure there is no unwanted CDATA tags in the content.",
|
|
49016
49016
|
parameters: [
|
|
49017
49017
|
{
|
|
49018
49018
|
name: "path",
|
|
@@ -49063,7 +49063,10 @@ var handler11 = async (provider, args) => {
|
|
|
49063
49063
|
};
|
|
49064
49064
|
}
|
|
49065
49065
|
const path = getString(args, "path");
|
|
49066
|
-
|
|
49066
|
+
let content = getString(args, "content");
|
|
49067
|
+
const trimmedContent = content.trim();
|
|
49068
|
+
if (trimmedContent.startsWith("<![CDATA[") && content.endsWith("]]>"))
|
|
49069
|
+
content = trimmedContent.slice(9, -3);
|
|
49067
49070
|
await provider.writeFile(path, content);
|
|
49068
49071
|
return {
|
|
49069
49072
|
type: "Reply" /* Reply */,
|
|
@@ -49622,12 +49625,27 @@ Ensure the opening and closing tags are correctly nested and closed, and that yo
|
|
|
49622
49625
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
49623
49626
|
Avoid unnecessary escape characters or special characters.
|
|
49624
49627
|
`,
|
|
49625
|
-
toolResults: (tool, result) =>
|
|
49626
|
-
|
|
49627
|
-
|
|
49628
|
-
|
|
49629
|
-
|
|
49630
|
-
</tool_response
|
|
49628
|
+
toolResults: (tool, result) => {
|
|
49629
|
+
if (typeof result === "string") {
|
|
49630
|
+
return [
|
|
49631
|
+
{
|
|
49632
|
+
type: "text",
|
|
49633
|
+
text: `<tool_response name=${tool}>${result}</tool_response>`
|
|
49634
|
+
}
|
|
49635
|
+
];
|
|
49636
|
+
}
|
|
49637
|
+
return [
|
|
49638
|
+
{
|
|
49639
|
+
type: "text",
|
|
49640
|
+
text: `<tool_response name=${tool}>`
|
|
49641
|
+
},
|
|
49642
|
+
...result,
|
|
49643
|
+
{
|
|
49644
|
+
type: "text",
|
|
49645
|
+
text: "</tool_response>"
|
|
49646
|
+
}
|
|
49647
|
+
];
|
|
49648
|
+
},
|
|
49631
49649
|
commandResult: (command, exitCode, stdout, stderr) => `<command>${command}</command>
|
|
49632
49650
|
<command_exit_code>${exitCode}</command_exit_code>
|
|
49633
49651
|
<command_stdout>
|
|
@@ -49791,23 +49809,26 @@ ${instance.prompt}`;
|
|
|
49791
49809
|
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
49792
49810
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
49793
49811
|
switch (toolResp.type) {
|
|
49794
|
-
case "Reply" /* Reply */:
|
|
49812
|
+
case "Reply" /* Reply */: {
|
|
49795
49813
|
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
49796
49814
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
49797
49815
|
break;
|
|
49816
|
+
}
|
|
49798
49817
|
case "Exit" /* Exit */:
|
|
49799
49818
|
if (toolResponses.length > 0) {
|
|
49800
49819
|
break outer;
|
|
49801
49820
|
}
|
|
49802
49821
|
return { type: "exit", reason: toolResp };
|
|
49803
|
-
case "Invalid" /* Invalid */:
|
|
49822
|
+
case "Invalid" /* Invalid */: {
|
|
49804
49823
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
49805
49824
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
49806
49825
|
break outer;
|
|
49807
|
-
|
|
49826
|
+
}
|
|
49827
|
+
case "Error" /* Error */: {
|
|
49808
49828
|
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
49809
49829
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
49810
49830
|
break outer;
|
|
49831
|
+
}
|
|
49811
49832
|
case "Interrupted" /* Interrupted */:
|
|
49812
49833
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
49813
49834
|
return { type: "exit", reason: toolResp };
|
|
@@ -49857,9 +49878,7 @@ ${instance.prompt}`;
|
|
|
49857
49878
|
if (toolResponses.length === 0) {
|
|
49858
49879
|
return { type: "reply", message: responsePrompts.requireUseTool };
|
|
49859
49880
|
}
|
|
49860
|
-
const finalResp = toolResponses.filter((resp) => resp.type === "response").
|
|
49861
|
-
|
|
49862
|
-
`);
|
|
49881
|
+
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
49863
49882
|
return { type: "reply", message: finalResp };
|
|
49864
49883
|
}
|
|
49865
49884
|
async#invokeTool(name, args) {
|