@polka-codes/cli 0.7.14 → 0.7.16

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 +22 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24629,7 +24629,7 @@ var {
24629
24629
  Help
24630
24630
  } = import__.default;
24631
24631
  // package.json
24632
- var version = "0.7.14";
24632
+ var version = "0.7.16";
24633
24633
 
24634
24634
  // ../core/src/AiService/AiServiceBase.ts
24635
24635
  class AiServiceBase {
@@ -33346,6 +33346,16 @@ class UsageMeter {
33346
33346
  }
33347
33347
  this.#usage.totalCost += usage.totalCost ?? 0;
33348
33348
  }
33349
+ setUsage(usage, messageCount) {
33350
+ this.#usage.inputTokens = usage.inputTokens ?? this.#usage.inputTokens;
33351
+ this.#usage.outputTokens = usage.outputTokens ?? this.#usage.outputTokens;
33352
+ this.#usage.cacheWriteTokens = usage.cacheWriteTokens ?? this.#usage.cacheWriteTokens;
33353
+ this.#usage.cacheReadTokens = usage.cacheReadTokens ?? this.#usage.cacheReadTokens;
33354
+ this.#usage.totalCost = usage.totalCost ?? this.#usage.totalCost;
33355
+ if (messageCount !== undefined) {
33356
+ this.#messageCount = messageCount;
33357
+ }
33358
+ }
33349
33359
  incrementMessageCount(count = 1) {
33350
33360
  this.#messageCount += count;
33351
33361
  }
@@ -33367,7 +33377,7 @@ class UsageMeter {
33367
33377
  }
33368
33378
  }
33369
33379
  get usage() {
33370
- return { ...this.#usage };
33380
+ return { ...this.#usage, messageCount: this.#messageCount };
33371
33381
  }
33372
33382
  printUsage() {
33373
33383
  const { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens } = this.#usage;
@@ -34734,11 +34744,11 @@ ${agents}`;
34734
34744
  }
34735
34745
  const response = await this.#request(nextRequest);
34736
34746
  const resp = await this.#handleResponse(response);
34737
- if ("exit" in resp) {
34738
- this.#callback({ kind: "EndTask" /* EndTask */, agent: this, exitReason: resp.exit });
34739
- return resp.exit;
34747
+ if (resp.type === "exit") {
34748
+ this.#callback({ kind: "EndTask" /* EndTask */, agent: this, exitReason: resp.reason });
34749
+ return resp.reason;
34740
34750
  }
34741
- nextRequest = resp.replay;
34751
+ nextRequest = resp.message;
34742
34752
  }
34743
34753
  }
34744
34754
  async continueTask(userMessage) {
@@ -34811,7 +34821,7 @@ ${agents}`;
34811
34821
  if (toolReponses.length > 0) {
34812
34822
  break outer;
34813
34823
  }
34814
- return { exit: toolResp };
34824
+ return { type: "exit", reason: toolResp };
34815
34825
  case "Invalid" /* Invalid */:
34816
34826
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
34817
34827
  toolReponses.push({ tool: content.name, response: toolResp.message });
@@ -34822,7 +34832,7 @@ ${agents}`;
34822
34832
  break outer;
34823
34833
  case "Interrupted" /* Interrupted */:
34824
34834
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
34825
- return { exit: toolResp };
34835
+ return { type: "exit", reason: toolResp };
34826
34836
  case "HandOver" /* HandOver */:
34827
34837
  if (toolReponses.length > 0) {
34828
34838
  break outer;
@@ -34836,7 +34846,7 @@ ${agents}`;
34836
34846
  context: toolResp.context,
34837
34847
  files: toolResp.files
34838
34848
  });
34839
- return { exit: toolResp };
34849
+ return { type: "exit", reason: toolResp };
34840
34850
  case "Delegate" /* Delegate */:
34841
34851
  if (toolReponses.length > 0) {
34842
34852
  continue;
@@ -34850,19 +34860,19 @@ ${agents}`;
34850
34860
  context: toolResp.context,
34851
34861
  files: toolResp.files
34852
34862
  });
34853
- return { exit: toolResp };
34863
+ return { type: "exit", reason: toolResp };
34854
34864
  }
34855
34865
  break;
34856
34866
  }
34857
34867
  }
34858
34868
  }
34859
34869
  if (toolReponses.length === 0) {
34860
- return { replay: responsePrompts.requireUseTool };
34870
+ return { type: "reply", message: responsePrompts.requireUseTool };
34861
34871
  }
34862
34872
  const finalResp = toolReponses.map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
34863
34873
 
34864
34874
  `);
34865
- return { replay: finalResp };
34875
+ return { type: "reply", message: finalResp };
34866
34876
  }
34867
34877
  async#invokeTool(name2, args2) {
34868
34878
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.7.14",
3
+ "version": "0.7.16",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",