@polka-codes/runner 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.
Files changed (2) hide show
  1. package/dist/index.js +55 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32748,7 +32748,7 @@ var {
32748
32748
  Help
32749
32749
  } = import__.default;
32750
32750
  // package.json
32751
- var version = "0.8.23";
32751
+ var version = "0.8.24";
32752
32752
 
32753
32753
  // src/runner.ts
32754
32754
  import { execSync } from "node:child_process";
@@ -43287,7 +43287,7 @@ var updateKnowledge_default = {
43287
43287
  // ../core/src/tools/writeToFile.ts
43288
43288
  var toolInfo11 = {
43289
43289
  name: "write_to_file",
43290
- 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 `<` and `>`.",
43290
+ 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.",
43291
43291
  parameters: [
43292
43292
  {
43293
43293
  name: "path",
@@ -43338,7 +43338,10 @@ var handler11 = async (provider, args) => {
43338
43338
  };
43339
43339
  }
43340
43340
  const path = getString(args, "path");
43341
- const content = getString(args, "content");
43341
+ let content = getString(args, "content");
43342
+ const trimmedContent = content.trim();
43343
+ if (trimmedContent.startsWith("<![CDATA[") && content.endsWith("]]>"))
43344
+ content = trimmedContent.slice(9, -3);
43342
43345
  await provider.writeFile(path, content);
43343
43346
  return {
43344
43347
  type: "Reply" /* Reply */,
@@ -43897,12 +43900,27 @@ Ensure the opening and closing tags are correctly nested and closed, and that yo
43897
43900
  Avoid unnecessary text or symbols before or after the tool use.
43898
43901
  Avoid unnecessary escape characters or special characters.
43899
43902
  `,
43900
- toolResults: (tool, result) => `<tool_response>
43901
- <tool_name>${tool}</tool_name>
43902
- <tool_result>
43903
- ${result}
43904
- </tool_result>
43905
- </tool_response>`,
43903
+ toolResults: (tool, result) => {
43904
+ if (typeof result === "string") {
43905
+ return [
43906
+ {
43907
+ type: "text",
43908
+ text: `<tool_response name=${tool}>${result}</tool_response>`
43909
+ }
43910
+ ];
43911
+ }
43912
+ return [
43913
+ {
43914
+ type: "text",
43915
+ text: `<tool_response name=${tool}>`
43916
+ },
43917
+ ...result,
43918
+ {
43919
+ type: "text",
43920
+ text: "</tool_response>"
43921
+ }
43922
+ ];
43923
+ },
43906
43924
  commandResult: (command, exitCode, stdout, stderr) => `<command>${command}</command>
43907
43925
  <command_exit_code>${exitCode}</command_exit_code>
43908
43926
  <command_stdout>
@@ -44066,23 +44084,26 @@ ${instance.prompt}`;
44066
44084
  await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name });
44067
44085
  const toolResp = await this.#invokeTool(content.name, content.params);
44068
44086
  switch (toolResp.type) {
44069
- case "Reply" /* Reply */:
44087
+ case "Reply" /* Reply */: {
44070
44088
  await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
44071
44089
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
44072
44090
  break;
44091
+ }
44073
44092
  case "Exit" /* Exit */:
44074
44093
  if (toolResponses.length > 0) {
44075
44094
  break outer;
44076
44095
  }
44077
44096
  return { type: "exit", reason: toolResp };
44078
- case "Invalid" /* Invalid */:
44097
+ case "Invalid" /* Invalid */: {
44079
44098
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
44080
44099
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
44081
44100
  break outer;
44082
- case "Error" /* Error */:
44101
+ }
44102
+ case "Error" /* Error */: {
44083
44103
  await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
44084
44104
  toolResponses.push({ type: "response", tool: content.name, response: toolResp.message });
44085
44105
  break outer;
44106
+ }
44086
44107
  case "Interrupted" /* Interrupted */:
44087
44108
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
44088
44109
  return { type: "exit", reason: toolResp };
@@ -44132,9 +44153,7 @@ ${instance.prompt}`;
44132
44153
  if (toolResponses.length === 0) {
44133
44154
  return { type: "reply", message: responsePrompts.requireUseTool };
44134
44155
  }
44135
- const finalResp = toolResponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
44136
-
44137
- `);
44156
+ const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2));
44138
44157
  return { type: "reply", message: finalResp };
44139
44158
  }
44140
44159
  async#invokeTool(name, args) {
@@ -58371,6 +58390,25 @@ var wsIncomingMessageSchema = z3.discriminatedUnion("type", [
58371
58390
  z3.object({ type: z3.literal("get_files") }),
58372
58391
  z3.object({ type: z3.literal("done") })
58373
58392
  ]);
58393
+ var textBlockParamSchema = z3.object({
58394
+ type: z3.literal("text"),
58395
+ text: z3.string()
58396
+ });
58397
+ var imageBlockParamSchema = z3.object({
58398
+ type: z3.literal("image"),
58399
+ source: z3.union([
58400
+ z3.object({
58401
+ data: z3.string(),
58402
+ media_type: z3.string(),
58403
+ type: z3.literal("base64")
58404
+ }),
58405
+ z3.object({
58406
+ type: z3.literal("url"),
58407
+ url: z3.string()
58408
+ })
58409
+ ])
58410
+ });
58411
+ var userContentSchema = z3.union([z3.string(), z3.array(z3.union([textBlockParamSchema, imageBlockParamSchema]))]);
58374
58412
  var wsOutgoingMessageSchema = z3.discriminatedUnion("type", [
58375
58413
  z3.object({
58376
58414
  type: z3.literal("pending_tools_response"),
@@ -58378,7 +58416,7 @@ var wsOutgoingMessageSchema = z3.discriminatedUnion("type", [
58378
58416
  responses: z3.array(z3.object({
58379
58417
  index: z3.number(),
58380
58418
  tool: z3.string(),
58381
- response: z3.string()
58419
+ response: userContentSchema
58382
58420
  }))
58383
58421
  }),
58384
58422
  z3.object({
@@ -58653,7 +58691,7 @@ class Runner {
58653
58691
  }
58654
58692
  };
58655
58693
  const respMsg = await fn();
58656
- if (typeof respMsg === "string") {
58694
+ if (typeof respMsg === "string" || Array.isArray(respMsg)) {
58657
58695
  responses.push({
58658
58696
  index: request.index,
58659
58697
  tool: request.tool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.8.23",
3
+ "version": "0.8.24",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",