@polka-codes/runner 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.
Files changed (2) hide show
  1. package/dist/index.js +60 -38
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -30458,7 +30458,7 @@ var {
30458
30458
  Help
30459
30459
  } = import__.default;
30460
30460
  // package.json
30461
- var version = "0.9.23";
30461
+ var version = "0.9.24";
30462
30462
 
30463
30463
  // src/runner.ts
30464
30464
  import { execSync } from "node:child_process";
@@ -66765,13 +66765,14 @@ Retrying request ${i + 2} of ${retryCount}`);
66765
66765
  return resp;
66766
66766
  };
66767
66767
  let hasPause = false;
66768
+ const toolUseContents = response.filter((c) => c.type === "tool_use");
66768
66769
  outer:
66769
66770
  for (const content of response) {
66770
66771
  switch (content.type) {
66771
66772
  case "text":
66772
66773
  break;
66773
66774
  case "tool_use": {
66774
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
66775
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
66775
66776
  const toolResp = await this.#invokeTool(content.name, content.params);
66776
66777
  switch (toolResp.type) {
66777
66778
  case "Reply" /* Reply */: {
@@ -66780,52 +66781,73 @@ Retrying request ${i + 2} of ${retryCount}`);
66780
66781
  break;
66781
66782
  }
66782
66783
  case "Exit" /* Exit */:
66784
+ case "HandOver" /* HandOver */:
66785
+ case "Delegate" /* Delegate */: {
66786
+ if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
66787
+ const message = {
66788
+ type: "Error" /* Error */,
66789
+ message: {
66790
+ type: "error-text",
66791
+ value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
66792
+ },
66793
+ canRetry: false
66794
+ };
66795
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
66796
+ toolResponses.push({
66797
+ type: "response",
66798
+ tool: content.name,
66799
+ response: processResponse(message.message),
66800
+ id: content.id
66801
+ });
66802
+ break;
66803
+ }
66783
66804
  if (toolResponses.length > 0) {
66784
66805
  break outer;
66785
66806
  }
66786
- return { type: "exit", reason: toolResp };
66807
+ if (toolResp.type === "Exit" /* Exit */) {
66808
+ return { type: "exit", reason: toolResp };
66809
+ }
66810
+ if (toolResp.type === "HandOver" /* HandOver */) {
66811
+ await this.#callback({
66812
+ kind: "ToolHandOver" /* ToolHandOver */,
66813
+ agent: this,
66814
+ tool: content.name,
66815
+ agentName: toolResp.agentName,
66816
+ task: toolResp.task,
66817
+ context: toolResp.context,
66818
+ files: toolResp.files
66819
+ });
66820
+ return { type: "exit", reason: toolResp };
66821
+ }
66822
+ if (toolResp.type === "Delegate" /* Delegate */) {
66823
+ await this.#callback({
66824
+ kind: "ToolDelegate" /* ToolDelegate */,
66825
+ agent: this,
66826
+ tool: content.name,
66827
+ agentName: toolResp.agentName,
66828
+ task: toolResp.task,
66829
+ context: toolResp.context,
66830
+ files: toolResp.files
66831
+ });
66832
+ return { type: "exit", reason: toolResp };
66833
+ }
66834
+ break;
66835
+ }
66787
66836
  case "Invalid" /* Invalid */: {
66788
66837
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
66789
66838
  toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66790
- break outer;
66791
- }
66792
- case "Error" /* Error */: {
66793
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
66794
- toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66795
- break outer;
66796
- }
66797
- case "Interrupted" /* Interrupted */:
66798
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
66799
- return { type: "exit", reason: toolResp };
66800
- case "HandOver" /* HandOver */: {
66801
- if (toolResponses.length > 0) {
66839
+ if (this.config.toolFormat !== "native") {
66802
66840
  break outer;
66803
66841
  }
66804
- await this.#callback({
66805
- kind: "ToolHandOver" /* ToolHandOver */,
66806
- agent: this,
66807
- tool: content.name,
66808
- agentName: toolResp.agentName,
66809
- task: toolResp.task,
66810
- context: toolResp.context,
66811
- files: toolResp.files
66812
- });
66813
- return { type: "exit", reason: toolResp };
66842
+ break;
66814
66843
  }
66815
- case "Delegate" /* Delegate */: {
66816
- if (toolResponses.length > 0) {
66844
+ case "Error" /* Error */: {
66845
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
66846
+ toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
66847
+ if (this.config.toolFormat !== "native") {
66817
66848
  break outer;
66818
66849
  }
66819
- await this.#callback({
66820
- kind: "ToolDelegate" /* ToolDelegate */,
66821
- agent: this,
66822
- tool: content.name,
66823
- agentName: toolResp.agentName,
66824
- task: toolResp.task,
66825
- context: toolResp.context,
66826
- files: toolResp.files
66827
- });
66828
- return { type: "exit", reason: toolResp };
66850
+ break;
66829
66851
  }
66830
66852
  case "Pause" /* Pause */: {
66831
66853
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
@@ -67964,7 +67986,7 @@ var handler15 = async (provider2, args) => {
67964
67986
  commandParts.push(commitRange);
67965
67987
  }
67966
67988
  if (file3) {
67967
- commandParts.push("--", file3);
67989
+ commandParts.push("--", `'${file3}'`);
67968
67990
  }
67969
67991
  const command = commandParts.join(" ");
67970
67992
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",