@polka-codes/cli 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 +62 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -58572,7 +58572,7 @@ var {
58572
58572
  Help
58573
58573
  } = import__.default;
58574
58574
  // package.json
58575
- var version = "0.9.23";
58575
+ var version = "0.9.24";
58576
58576
 
58577
58577
  // src/commands/chat.ts
58578
58578
  import { readFile as readFile3 } from "node:fs/promises";
@@ -96532,13 +96532,14 @@ Retrying request ${i + 2} of ${retryCount}`);
96532
96532
  return resp;
96533
96533
  };
96534
96534
  let hasPause = false;
96535
+ const toolUseContents = response.filter((c) => c.type === "tool_use");
96535
96536
  outer:
96536
96537
  for (const content of response) {
96537
96538
  switch (content.type) {
96538
96539
  case "text":
96539
96540
  break;
96540
96541
  case "tool_use": {
96541
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
96542
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
96542
96543
  const toolResp = await this.#invokeTool(content.name, content.params);
96543
96544
  switch (toolResp.type) {
96544
96545
  case "Reply" /* Reply */: {
@@ -96547,52 +96548,73 @@ Retrying request ${i + 2} of ${retryCount}`);
96547
96548
  break;
96548
96549
  }
96549
96550
  case "Exit" /* Exit */:
96551
+ case "HandOver" /* HandOver */:
96552
+ case "Delegate" /* Delegate */: {
96553
+ if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
96554
+ const message = {
96555
+ type: "Error" /* Error */,
96556
+ message: {
96557
+ type: "error-text",
96558
+ value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
96559
+ },
96560
+ canRetry: false
96561
+ };
96562
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
96563
+ toolResponses.push({
96564
+ type: "response",
96565
+ tool: content.name,
96566
+ response: processResponse(message.message),
96567
+ id: content.id
96568
+ });
96569
+ break;
96570
+ }
96550
96571
  if (toolResponses.length > 0) {
96551
96572
  break outer;
96552
96573
  }
96553
- return { type: "exit", reason: toolResp };
96574
+ if (toolResp.type === "Exit" /* Exit */) {
96575
+ return { type: "exit", reason: toolResp };
96576
+ }
96577
+ if (toolResp.type === "HandOver" /* HandOver */) {
96578
+ await this.#callback({
96579
+ kind: "ToolHandOver" /* ToolHandOver */,
96580
+ agent: this,
96581
+ tool: content.name,
96582
+ agentName: toolResp.agentName,
96583
+ task: toolResp.task,
96584
+ context: toolResp.context,
96585
+ files: toolResp.files
96586
+ });
96587
+ return { type: "exit", reason: toolResp };
96588
+ }
96589
+ if (toolResp.type === "Delegate" /* Delegate */) {
96590
+ await this.#callback({
96591
+ kind: "ToolDelegate" /* ToolDelegate */,
96592
+ agent: this,
96593
+ tool: content.name,
96594
+ agentName: toolResp.agentName,
96595
+ task: toolResp.task,
96596
+ context: toolResp.context,
96597
+ files: toolResp.files
96598
+ });
96599
+ return { type: "exit", reason: toolResp };
96600
+ }
96601
+ break;
96602
+ }
96554
96603
  case "Invalid" /* Invalid */: {
96555
96604
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
96556
96605
  toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
96557
- break outer;
96558
- }
96559
- case "Error" /* Error */: {
96560
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
96561
- toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
96562
- break outer;
96563
- }
96564
- case "Interrupted" /* Interrupted */:
96565
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
96566
- return { type: "exit", reason: toolResp };
96567
- case "HandOver" /* HandOver */: {
96568
- if (toolResponses.length > 0) {
96606
+ if (this.config.toolFormat !== "native") {
96569
96607
  break outer;
96570
96608
  }
96571
- await this.#callback({
96572
- kind: "ToolHandOver" /* ToolHandOver */,
96573
- agent: this,
96574
- tool: content.name,
96575
- agentName: toolResp.agentName,
96576
- task: toolResp.task,
96577
- context: toolResp.context,
96578
- files: toolResp.files
96579
- });
96580
- return { type: "exit", reason: toolResp };
96609
+ break;
96581
96610
  }
96582
- case "Delegate" /* Delegate */: {
96583
- if (toolResponses.length > 0) {
96611
+ case "Error" /* Error */: {
96612
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
96613
+ toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
96614
+ if (this.config.toolFormat !== "native") {
96584
96615
  break outer;
96585
96616
  }
96586
- await this.#callback({
96587
- kind: "ToolDelegate" /* ToolDelegate */,
96588
- agent: this,
96589
- tool: content.name,
96590
- agentName: toolResp.agentName,
96591
- task: toolResp.task,
96592
- context: toolResp.context,
96593
- files: toolResp.files
96594
- });
96595
- return { type: "exit", reason: toolResp };
96617
+ break;
96596
96618
  }
96597
96619
  case "Pause" /* Pause */: {
96598
96620
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
@@ -97971,7 +97993,7 @@ var handler15 = async (provider2, args) => {
97971
97993
  commandParts.push(commitRange);
97972
97994
  }
97973
97995
  if (file3) {
97974
- commandParts.push("--", file3);
97996
+ commandParts.push("--", `'${file3}'`);
97975
97997
  }
97976
97998
  const command = commandParts.join(" ");
97977
97999
  try {
@@ -114582,7 +114604,7 @@ ${event.systemPrompt}`);
114582
114604
  case "ToolUse" /* ToolUse */: {
114583
114605
  customConsole.log(source_default.yellow(`
114584
114606
 
114585
- Tool use:`, event.tool), event.content);
114607
+ Tool use:`, event.tool), event.params);
114586
114608
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
114587
114609
  stats.calls++;
114588
114610
  toolCallStats.set(event.tool, stats);
@@ -114600,7 +114622,7 @@ Tool use:`, event.tool), event.content);
114600
114622
  customConsole.error(source_default.red(`
114601
114623
 
114602
114624
  Tool error:`, event.tool));
114603
- customConsole.error(source_default.red(event.content));
114625
+ customConsole.error(event.error);
114604
114626
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
114605
114627
  stats.errors++;
114606
114628
  toolCallStats.set(event.tool, stats);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
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",