@khalilgharbaoui/opencode-claude-code-plugin 0.57.1 → 0.57.2

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.
package/dist/index.js CHANGED
@@ -13426,6 +13426,26 @@ function startsTurn(prompt) {
13426
13426
  const before = prompt[prompt.length - 2];
13427
13427
  return before === void 0 || before.role !== "tool";
13428
13428
  }
13429
+ function turnToolCalls(prompt) {
13430
+ let start = 0;
13431
+ for (let index = prompt.length - 1; index >= 0; index -= 1) {
13432
+ if (prompt[index].role !== "user") continue;
13433
+ const before = prompt[index - 1];
13434
+ if (before === void 0 || before.role !== "tool") {
13435
+ start = index;
13436
+ break;
13437
+ }
13438
+ }
13439
+ let calls = 0;
13440
+ for (let index = start; index < prompt.length; index += 1) {
13441
+ const message = prompt[index];
13442
+ if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
13443
+ for (const part of message.content) {
13444
+ if (part && typeof part === "object" && part.type === "tool-call") calls += 1;
13445
+ }
13446
+ }
13447
+ return calls;
13448
+ }
13429
13449
  var MAX_TURN_STARTS = 256;
13430
13450
  var turnStarts = /* @__PURE__ */ new Map();
13431
13451
  function markTurnStart(key, at, chars) {
@@ -13450,6 +13470,9 @@ function isSample(value) {
13450
13470
  return false;
13451
13471
  }
13452
13472
  if (sample.effort !== void 0 && typeof sample.effort !== "string") return false;
13473
+ if (sample.calls !== void 0 && (typeof sample.calls !== "number" || !Number.isFinite(sample.calls) || sample.calls < 0)) {
13474
+ return false;
13475
+ }
13453
13476
  return true;
13454
13477
  }
13455
13478
  function cleanSample(sample) {
@@ -13457,6 +13480,7 @@ function cleanSample(sample) {
13457
13480
  ms: Math.round(sample.ms),
13458
13481
  ...sample.chars !== void 0 ? { chars: Math.round(sample.chars) } : {},
13459
13482
  ...sample.effort ? { effort: sample.effort } : {},
13483
+ ...sample.calls !== void 0 ? { calls: Math.round(sample.calls) } : {},
13460
13484
  at: sample.at
13461
13485
  };
13462
13486
  }
@@ -18513,6 +18537,10 @@ var ClaudeCodeLanguageModel = class {
18513
18537
  ms: endedAt - start.at,
18514
18538
  chars: start.chars,
18515
18539
  effort: reasoningEffort,
18540
+ // The turn's tool calls, counted as the TUI counts its tool
18541
+ // parts (h #g250): the earlier steps' from the prompt, this
18542
+ // step's own from what it emitted.
18543
+ calls: turnToolCalls(options.prompt) + state.toolCallEmittedIds.size,
18516
18544
  at: endedAt
18517
18545
  });
18518
18546
  }