@polka-codes/cli-shared 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 +33 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38021,7 +38021,7 @@ var updateKnowledge_default = {
|
|
|
38021
38021
|
// ../core/src/tools/writeToFile.ts
|
|
38022
38022
|
var toolInfo11 = {
|
|
38023
38023
|
name: "write_to_file",
|
|
38024
|
-
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 `<
|
|
38024
|
+
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.",
|
|
38025
38025
|
parameters: [
|
|
38026
38026
|
{
|
|
38027
38027
|
name: "path",
|
|
@@ -38072,7 +38072,10 @@ var handler11 = async (provider, args) => {
|
|
|
38072
38072
|
};
|
|
38073
38073
|
}
|
|
38074
38074
|
const path = getString(args, "path");
|
|
38075
|
-
|
|
38075
|
+
let content = getString(args, "content");
|
|
38076
|
+
const trimmedContent = content.trim();
|
|
38077
|
+
if (trimmedContent.startsWith("<![CDATA[") && content.endsWith("]]>"))
|
|
38078
|
+
content = trimmedContent.slice(9, -3);
|
|
38076
38079
|
await provider.writeFile(path, content);
|
|
38077
38080
|
return {
|
|
38078
38081
|
type: "Reply" /* Reply */,
|
|
@@ -38631,12 +38634,27 @@ Ensure the opening and closing tags are correctly nested and closed, and that yo
|
|
|
38631
38634
|
Avoid unnecessary text or symbols before or after the tool use.
|
|
38632
38635
|
Avoid unnecessary escape characters or special characters.
|
|
38633
38636
|
`,
|
|
38634
|
-
toolResults: (tool, result) =>
|
|
38635
|
-
|
|
38636
|
-
|
|
38637
|
-
|
|
38638
|
-
|
|
38639
|
-
</tool_response
|
|
38637
|
+
toolResults: (tool, result) => {
|
|
38638
|
+
if (typeof result === "string") {
|
|
38639
|
+
return [
|
|
38640
|
+
{
|
|
38641
|
+
type: "text",
|
|
38642
|
+
text: `<tool_response name=${tool}>${result}</tool_response>`
|
|
38643
|
+
}
|
|
38644
|
+
];
|
|
38645
|
+
}
|
|
38646
|
+
return [
|
|
38647
|
+
{
|
|
38648
|
+
type: "text",
|
|
38649
|
+
text: `<tool_response name=${tool}>`
|
|
38650
|
+
},
|
|
38651
|
+
...result,
|
|
38652
|
+
{
|
|
38653
|
+
type: "text",
|
|
38654
|
+
text: "</tool_response>"
|
|
38655
|
+
}
|
|
38656
|
+
];
|
|
38657
|
+
},
|
|
38640
38658
|
commandResult: (command, exitCode, stdout, stderr) => `<command>${command}</command>
|
|
38641
38659
|
<command_exit_code>${exitCode}</command_exit_code>
|
|
38642
38660
|
<command_stdout>
|
|
@@ -38800,23 +38818,26 @@ ${instance.prompt}`;
|
|
|
38800
38818
|
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
|
|
38801
38819
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
38802
38820
|
switch (toolResp.type) {
|
|
38803
|
-
case "Reply" /* Reply */:
|
|
38821
|
+
case "Reply" /* Reply */: {
|
|
38804
38822
|
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
38805
38823
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
38806
38824
|
break;
|
|
38825
|
+
}
|
|
38807
38826
|
case "Exit" /* Exit */:
|
|
38808
38827
|
if (toolResponses.length > 0) {
|
|
38809
38828
|
break outer;
|
|
38810
38829
|
}
|
|
38811
38830
|
return { type: "exit", reason: toolResp };
|
|
38812
|
-
case "Invalid" /* Invalid */:
|
|
38831
|
+
case "Invalid" /* Invalid */: {
|
|
38813
38832
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
38814
38833
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
38815
38834
|
break outer;
|
|
38816
|
-
|
|
38835
|
+
}
|
|
38836
|
+
case "Error" /* Error */: {
|
|
38817
38837
|
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
38818
38838
|
toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
38819
38839
|
break outer;
|
|
38840
|
+
}
|
|
38820
38841
|
case "Interrupted" /* Interrupted */:
|
|
38821
38842
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
38822
38843
|
return { type: "exit", reason: toolResp };
|
|
@@ -38866,9 +38887,7 @@ ${instance.prompt}`;
|
|
|
38866
38887
|
if (toolResponses.length === 0) {
|
|
38867
38888
|
return { type: "reply", message: responsePrompts.requireUseTool };
|
|
38868
38889
|
}
|
|
38869
|
-
const finalResp = toolResponses.filter((resp) => resp.type === "response").
|
|
38870
|
-
|
|
38871
|
-
`);
|
|
38890
|
+
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
|
|
38872
38891
|
return { type: "reply", message: finalResp };
|
|
38873
38892
|
}
|
|
38874
38893
|
async#invokeTool(name, args) {
|