@cabane/companion 0.6.200 → 0.6.202

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/cli.js CHANGED
@@ -1314,6 +1314,11 @@ function isTurnEndedRefusal(err) {
1314
1314
  const body = err.body;
1315
1315
  return typeof body === "object" && body !== null && body.reason === "turn_ended";
1316
1316
  }
1317
+ function turnEndedOutcome(err) {
1318
+ if (!isTurnEndedRefusal(err)) return void 0;
1319
+ const outcome = err.body.outcome;
1320
+ return typeof outcome === "string" ? outcome : void 0;
1321
+ }
1317
1322
  function describeErrorBody(body) {
1318
1323
  if (body === void 0 || body === null) return void 0;
1319
1324
  let text;
@@ -1705,9 +1710,11 @@ var init_api = __esm({
1705
1710
  signal: AbortSignal.timeout(this.opts.leaseCheckTimeoutMs ?? LEASE_CHECK_TIMEOUT_MS)
1706
1711
  }
1707
1712
  );
1708
- return res?.state === "running" || res?.state === "ended" ? res.state : "unknown";
1713
+ if (res?.state === "ended") return res.outcome === "stopped" ? "stopped" : "ended";
1714
+ return res?.state === "running" ? "running" : "unknown";
1709
1715
  } catch (err) {
1710
- return isTurnEndedRefusal(err) ? "ended" : "unknown";
1716
+ if (!isTurnEndedRefusal(err)) return "unknown";
1717
+ return turnEndedOutcome(err) === "stopped" ? "stopped" : "ended";
1711
1718
  }
1712
1719
  }
1713
1720
  // Flips `active_run_started_at` and optionally captures the SDK session
@@ -2379,6 +2386,20 @@ function summarizeToolInput(input) {
2379
2386
  }
2380
2387
  return "";
2381
2388
  }
2389
+ function summarizeToolIo(input) {
2390
+ const capped = typeof input === "string" ? input : capStrings(input, /* @__PURE__ */ new WeakSet());
2391
+ return truncate(renderToolIo(capped), TOOL_IO_MAX_CHARS);
2392
+ }
2393
+ function capStrings(value, ancestors) {
2394
+ if (typeof value === "string") return truncate(value, TOOL_IO_VALUE_MAX_CHARS);
2395
+ if (!value || typeof value !== "object" || ancestors.has(value)) return value;
2396
+ ancestors.add(value);
2397
+ const capped = Array.isArray(value) ? value.map((item) => capStrings(item, ancestors)) : Object.fromEntries(
2398
+ Object.entries(value).map(([key, item]) => [key, capStrings(item, ancestors)])
2399
+ );
2400
+ ancestors.delete(value);
2401
+ return capped;
2402
+ }
2382
2403
  function renderToolIo(input) {
2383
2404
  if (input === void 0 || input === null) return "";
2384
2405
  if (typeof input === "string") return input.trim();
@@ -2416,11 +2437,12 @@ function truncate(s, max) {
2416
2437
  if (s.length <= max) return s;
2417
2438
  return `${s.slice(0, max)}\u2026[+${s.length - max} chars]`;
2418
2439
  }
2419
- var TOOL_IO_MAX_CHARS;
2440
+ var TOOL_IO_MAX_CHARS, TOOL_IO_VALUE_MAX_CHARS;
2420
2441
  var init_transcript = __esm({
2421
2442
  "packages/agent-runtime/src/transcript.ts"() {
2422
2443
  "use strict";
2423
2444
  TOOL_IO_MAX_CHARS = 1e4;
2445
+ TOOL_IO_VALUE_MAX_CHARS = 2e3;
2424
2446
  }
2425
2447
  });
2426
2448
 
@@ -2440,7 +2462,7 @@ function sinkEmitter(sink, _onError) {
2440
2462
  toolUseId: event.id,
2441
2463
  toolName: event.name,
2442
2464
  summary: event.summary,
2443
- input: truncate(input, TOOL_IO_MAX_CHARS),
2465
+ input: summarizeToolIo(event.input),
2444
2466
  result: result === null ? "" : truncate(result, TOOL_IO_MAX_CHARS),
2445
2467
  // Only when the event carried an input: a completion whose start this process never saw has
2446
2468
  // none, and a zero would overwrite the size its start recorded.
@@ -10226,11 +10248,11 @@ var init_turn_execution = __esm({
10226
10248
  payload.agentId,
10227
10249
  turnId
10228
10250
  );
10229
- if (state !== "ended") return;
10251
+ if (state !== "ended" && state !== "stopped") return;
10230
10252
  if (abortController.signal.aborted) return;
10231
- o.leaseLost = true;
10253
+ if (state === "ended") o.leaseLost = true;
10232
10254
  turnLog.debug(
10233
- { turnId, trigger },
10255
+ { turnId, trigger, state },
10234
10256
  "dispatcher: this turn is no longer running server-side \u2014 aborting the loop"
10235
10257
  );
10236
10258
  abortController.abort();
@@ -10367,6 +10389,7 @@ var init_turn_execution = __esm({
10367
10389
  o.resultReason = "cancelled";
10368
10390
  }
10369
10391
  const userCancelled = abortController.signal.aborted && o.timeoutReason === null && !o.leaseLost && !terminated;
10392
+ if (userCancelled && !o.okResult) o.resultReason = "cancelled";
10370
10393
  if (o.timeoutReason !== null) {
10371
10394
  o.resultReason = o.timeoutReason;
10372
10395
  o.okResult = false;
package/dist/runtime.js CHANGED
@@ -1802,6 +1802,11 @@ function isTurnEndedRefusal(err) {
1802
1802
  const body = err.body;
1803
1803
  return typeof body === "object" && body !== null && body.reason === "turn_ended";
1804
1804
  }
1805
+ function turnEndedOutcome(err) {
1806
+ if (!isTurnEndedRefusal(err)) return void 0;
1807
+ const outcome = err.body.outcome;
1808
+ return typeof outcome === "string" ? outcome : void 0;
1809
+ }
1805
1810
  var ERROR_BODY_LOG_CAP = 2e3;
1806
1811
  function describeErrorBody(body) {
1807
1812
  if (body === void 0 || body === null) return void 0;
@@ -2133,9 +2138,11 @@ var CabaneApi = class {
2133
2138
  signal: AbortSignal.timeout(this.opts.leaseCheckTimeoutMs ?? LEASE_CHECK_TIMEOUT_MS)
2134
2139
  }
2135
2140
  );
2136
- return res?.state === "running" || res?.state === "ended" ? res.state : "unknown";
2141
+ if (res?.state === "ended") return res.outcome === "stopped" ? "stopped" : "ended";
2142
+ return res?.state === "running" ? "running" : "unknown";
2137
2143
  } catch (err) {
2138
- return isTurnEndedRefusal(err) ? "ended" : "unknown";
2144
+ if (!isTurnEndedRefusal(err)) return "unknown";
2145
+ return turnEndedOutcome(err) === "stopped" ? "stopped" : "ended";
2139
2146
  }
2140
2147
  }
2141
2148
  // Flips `active_run_started_at` and optionally captures the SDK session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabane/companion",
3
- "version": "0.6.200",
3
+ "version": "0.6.202",
4
4
  "type": "module",
5
5
  "description": "The Cabane Companion (headless): connect an agent on your machine to your Cabane workspace as a responder — drive work against your own codebase, files, and MCP servers without putting any of it in Cabane.",
6
6
  "license": "UNLICENSED",