@polka-codes/cli-shared 0.9.22 → 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 +72 -45
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -15711,7 +15711,7 @@ var require_ignore = __commonJS((exports, module) => {
15711
15711
  define2(module.exports, Symbol.for("setupWindows"), setupWindows);
15712
15712
  });
15713
15713
 
15714
- // ../../node_modules/mime-db/db.json
15714
+ // node_modules/mime-types/node_modules/mime-db/db.json
15715
15715
  var require_db = __commonJS((exports, module) => {
15716
15716
  module.exports = {
15717
15717
  "application/1d-interleaved-parityfec": {
@@ -25057,7 +25057,7 @@ var require_db = __commonJS((exports, module) => {
25057
25057
  };
25058
25058
  });
25059
25059
 
25060
- // ../../node_modules/mime-db/index.js
25060
+ // node_modules/mime-types/node_modules/mime-db/index.js
25061
25061
  var require_mime_db = __commonJS((exports, module) => {
25062
25062
  /*!
25063
25063
  * mime-db
@@ -25068,7 +25068,7 @@ var require_mime_db = __commonJS((exports, module) => {
25068
25068
  module.exports = require_db();
25069
25069
  });
25070
25070
 
25071
- // ../../node_modules/mime-types/mimeScore.js
25071
+ // node_modules/mime-types/mimeScore.js
25072
25072
  var require_mimeScore = __commonJS((exports, module) => {
25073
25073
  var FACET_SCORES = {
25074
25074
  "prs.": 100,
@@ -61403,13 +61403,14 @@ Retrying request ${i + 2} of ${retryCount}`);
61403
61403
  return resp;
61404
61404
  };
61405
61405
  let hasPause = false;
61406
+ const toolUseContents = response.filter((c) => c.type === "tool_use");
61406
61407
  outer:
61407
61408
  for (const content of response) {
61408
61409
  switch (content.type) {
61409
61410
  case "text":
61410
61411
  break;
61411
61412
  case "tool_use": {
61412
- await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, content: content.params });
61413
+ await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
61413
61414
  const toolResp = await this.#invokeTool(content.name, content.params);
61414
61415
  switch (toolResp.type) {
61415
61416
  case "Reply" /* Reply */: {
@@ -61418,52 +61419,73 @@ Retrying request ${i + 2} of ${retryCount}`);
61418
61419
  break;
61419
61420
  }
61420
61421
  case "Exit" /* Exit */:
61422
+ case "HandOver" /* HandOver */:
61423
+ case "Delegate" /* Delegate */: {
61424
+ if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
61425
+ const message = {
61426
+ type: "Error" /* Error */,
61427
+ message: {
61428
+ type: "error-text",
61429
+ value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
61430
+ },
61431
+ canRetry: false
61432
+ };
61433
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
61434
+ toolResponses.push({
61435
+ type: "response",
61436
+ tool: content.name,
61437
+ response: processResponse(message.message),
61438
+ id: content.id
61439
+ });
61440
+ break;
61441
+ }
61421
61442
  if (toolResponses.length > 0) {
61422
61443
  break outer;
61423
61444
  }
61424
- return { type: "exit", reason: toolResp };
61445
+ if (toolResp.type === "Exit" /* Exit */) {
61446
+ return { type: "exit", reason: toolResp };
61447
+ }
61448
+ if (toolResp.type === "HandOver" /* HandOver */) {
61449
+ await this.#callback({
61450
+ kind: "ToolHandOver" /* ToolHandOver */,
61451
+ agent: this,
61452
+ tool: content.name,
61453
+ agentName: toolResp.agentName,
61454
+ task: toolResp.task,
61455
+ context: toolResp.context,
61456
+ files: toolResp.files
61457
+ });
61458
+ return { type: "exit", reason: toolResp };
61459
+ }
61460
+ if (toolResp.type === "Delegate" /* Delegate */) {
61461
+ await this.#callback({
61462
+ kind: "ToolDelegate" /* ToolDelegate */,
61463
+ agent: this,
61464
+ tool: content.name,
61465
+ agentName: toolResp.agentName,
61466
+ task: toolResp.task,
61467
+ context: toolResp.context,
61468
+ files: toolResp.files
61469
+ });
61470
+ return { type: "exit", reason: toolResp };
61471
+ }
61472
+ break;
61473
+ }
61425
61474
  case "Invalid" /* Invalid */: {
61426
61475
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
61427
61476
  toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
61428
- break outer;
61429
- }
61430
- case "Error" /* Error */: {
61431
- await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
61432
- toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
61433
- break outer;
61434
- }
61435
- case "Interrupted" /* Interrupted */:
61436
- await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
61437
- return { type: "exit", reason: toolResp };
61438
- case "HandOver" /* HandOver */: {
61439
- if (toolResponses.length > 0) {
61477
+ if (this.config.toolFormat !== "native") {
61440
61478
  break outer;
61441
61479
  }
61442
- await this.#callback({
61443
- kind: "ToolHandOver" /* ToolHandOver */,
61444
- agent: this,
61445
- tool: content.name,
61446
- agentName: toolResp.agentName,
61447
- task: toolResp.task,
61448
- context: toolResp.context,
61449
- files: toolResp.files
61450
- });
61451
- return { type: "exit", reason: toolResp };
61480
+ break;
61452
61481
  }
61453
- case "Delegate" /* Delegate */: {
61454
- if (toolResponses.length > 0) {
61482
+ case "Error" /* Error */: {
61483
+ await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
61484
+ toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
61485
+ if (this.config.toolFormat !== "native") {
61455
61486
  break outer;
61456
61487
  }
61457
- await this.#callback({
61458
- kind: "ToolDelegate" /* ToolDelegate */,
61459
- agent: this,
61460
- tool: content.name,
61461
- agentName: toolResp.agentName,
61462
- task: toolResp.task,
61463
- context: toolResp.context,
61464
- files: toolResp.files
61465
- });
61466
- return { type: "exit", reason: toolResp };
61488
+ break;
61467
61489
  }
61468
61490
  case "Pause" /* Pause */: {
61469
61491
  await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
@@ -62083,8 +62105,13 @@ class MultiAgent {
62083
62105
  throw new Error("An active agent already exists");
62084
62106
  }
62085
62107
  this.#originalTask = options.task;
62086
- return this.#startTask(options.agentName, `<task>${options.task}</task>
62087
- <context>${options.context}</context>`);
62108
+ const userContent = options.files ?? [];
62109
+ userContent.push({
62110
+ type: "text",
62111
+ text: `<task>${options.task}</task>
62112
+ <context>${options.context}</context>`
62113
+ });
62114
+ return this.#startTask(options.agentName, userContent);
62088
62115
  }
62089
62116
  async continueTask(userMessage) {
62090
62117
  if (!this.#agents.length) {
@@ -62597,7 +62624,7 @@ var handler15 = async (provider2, args) => {
62597
62624
  commandParts.push(commitRange);
62598
62625
  }
62599
62626
  if (file3) {
62600
- commandParts.push("--", file3);
62627
+ commandParts.push("--", `'${file3}'`);
62601
62628
  }
62602
62629
  const command = commandParts.join(" ");
62603
62630
  try {
@@ -68097,7 +68124,7 @@ ${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursor
68097
68124
  // src/provider.ts
68098
68125
  var import_ignore2 = __toESM(require_ignore(), 1);
68099
68126
 
68100
- // ../../node_modules/mime-types/index.js
68127
+ // node_modules/mime-types/index.js
68101
68128
  /*!
68102
68129
  * mime-types
68103
68130
  * Copyright(c) 2014 Jonathan Ong
@@ -69054,7 +69081,7 @@ ${event.systemPrompt}`);
69054
69081
  case "ToolUse" /* ToolUse */: {
69055
69082
  customConsole.log(source_default.yellow(`
69056
69083
 
69057
- Tool use:`, event.tool), event.content);
69084
+ Tool use:`, event.tool), event.params);
69058
69085
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
69059
69086
  stats.calls++;
69060
69087
  toolCallStats.set(event.tool, stats);
@@ -69072,7 +69099,7 @@ Tool use:`, event.tool), event.content);
69072
69099
  customConsole.error(source_default.red(`
69073
69100
 
69074
69101
  Tool error:`, event.tool));
69075
- customConsole.error(source_default.red(event.content));
69102
+ customConsole.error(event.error);
69076
69103
  const stats = toolCallStats.get(event.tool) ?? { calls: 0, success: 0, errors: 0 };
69077
69104
  stats.errors++;
69078
69105
  toolCallStats.set(event.tool, stats);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli-shared",
3
- "version": "0.9.22",
3
+ "version": "0.9.24",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@ai-sdk/provider-utils": "^3.0.0",
21
- "@polka-codes/core": "0.9.19",
21
+ "@polka-codes/core": "0.9.22",
22
22
  "ignore": "^7.0.3",
23
23
  "lodash": "^4.17.21",
24
24
  "mime-types": "^3.0.1",