@cabane/companion 0.6.199 → 0.6.201

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
@@ -2379,6 +2379,20 @@ function summarizeToolInput(input) {
2379
2379
  }
2380
2380
  return "";
2381
2381
  }
2382
+ function summarizeToolIo(input) {
2383
+ const capped = typeof input === "string" ? input : capStrings(input, /* @__PURE__ */ new WeakSet());
2384
+ return truncate(renderToolIo(capped), TOOL_IO_MAX_CHARS);
2385
+ }
2386
+ function capStrings(value, ancestors) {
2387
+ if (typeof value === "string") return truncate(value, TOOL_IO_VALUE_MAX_CHARS);
2388
+ if (!value || typeof value !== "object" || ancestors.has(value)) return value;
2389
+ ancestors.add(value);
2390
+ const capped = Array.isArray(value) ? value.map((item) => capStrings(item, ancestors)) : Object.fromEntries(
2391
+ Object.entries(value).map(([key, item]) => [key, capStrings(item, ancestors)])
2392
+ );
2393
+ ancestors.delete(value);
2394
+ return capped;
2395
+ }
2382
2396
  function renderToolIo(input) {
2383
2397
  if (input === void 0 || input === null) return "";
2384
2398
  if (typeof input === "string") return input.trim();
@@ -2416,11 +2430,12 @@ function truncate(s, max) {
2416
2430
  if (s.length <= max) return s;
2417
2431
  return `${s.slice(0, max)}\u2026[+${s.length - max} chars]`;
2418
2432
  }
2419
- var TOOL_IO_MAX_CHARS;
2433
+ var TOOL_IO_MAX_CHARS, TOOL_IO_VALUE_MAX_CHARS;
2420
2434
  var init_transcript = __esm({
2421
2435
  "packages/agent-runtime/src/transcript.ts"() {
2422
2436
  "use strict";
2423
2437
  TOOL_IO_MAX_CHARS = 1e4;
2438
+ TOOL_IO_VALUE_MAX_CHARS = 2e3;
2424
2439
  }
2425
2440
  });
2426
2441
 
@@ -2440,7 +2455,7 @@ function sinkEmitter(sink, _onError) {
2440
2455
  toolUseId: event.id,
2441
2456
  toolName: event.name,
2442
2457
  summary: event.summary,
2443
- input: truncate(input, TOOL_IO_MAX_CHARS),
2458
+ input: summarizeToolIo(event.input),
2444
2459
  result: result === null ? "" : truncate(result, TOOL_IO_MAX_CHARS),
2445
2460
  // Only when the event carried an input: a completion whose start this process never saw has
2446
2461
  // none, and a zero would overwrite the size its start recorded.
@@ -14179,6 +14194,10 @@ var CompanionSupervisor = class {
14179
14194
  // Whether the device stream is open, which is what every workspace's link on
14180
14195
  // the dashboard reports.
14181
14196
  deviceConnected = false;
14197
+ // Set when the device stream ended on a 403: the device was deactivated, not
14198
+ // unpaired. The next accepted heartbeat proves it was reactivated, and
14199
+ // reopens the stream.
14200
+ deviceStreamDeactivated = false;
14182
14201
  recoveryChecked = false;
14183
14202
  recovering = false;
14184
14203
  heartbeated = false;
@@ -14314,7 +14333,15 @@ var CompanionSupervisor = class {
14314
14333
  }
14315
14334
  if (ev.event === "message") await this.handleDeviceMessage(ev);
14316
14335
  },
14317
- onAuthFailure: () => {
14336
+ onAuthFailure: (status2) => {
14337
+ if (status2 === 403) {
14338
+ this.deviceStreamDeactivated = true;
14339
+ this.heartbeatTimer?.ref();
14340
+ this.log.warn(
14341
+ "This device was deactivated in Cabane. The companion will reconnect once it is reactivated."
14342
+ );
14343
+ return;
14344
+ }
14318
14345
  this.log.error(
14319
14346
  `Cabane no longer accepts this device. Run ${cabane("logout")}, then ${cabane("setup")} to pair again.`
14320
14347
  );
@@ -14404,6 +14431,12 @@ var CompanionSupervisor = class {
14404
14431
  lastAcknowledgedDevice: view.success ? view.data : null,
14405
14432
  lastHeartbeatRefused: false
14406
14433
  };
14434
+ if (this.deviceStreamDeactivated && this.deviceSub && !this.stopped) {
14435
+ this.deviceStreamDeactivated = false;
14436
+ this.heartbeatTimer?.unref();
14437
+ this.log.info("This device was reactivated; reconnecting to Cabane.");
14438
+ this.deviceSub.start();
14439
+ }
14407
14440
  void this.recoverRuns();
14408
14441
  void this.updater?.onHeartbeat(res.companion, this.deviceConnected).catch(
14409
14442
  (err) => this.log.warn(
package/dist/runtime.js CHANGED
@@ -9789,6 +9789,10 @@ var CompanionSupervisor = class {
9789
9789
  // Whether the device stream is open, which is what every workspace's link on
9790
9790
  // the dashboard reports.
9791
9791
  deviceConnected = false;
9792
+ // Set when the device stream ended on a 403: the device was deactivated, not
9793
+ // unpaired. The next accepted heartbeat proves it was reactivated, and
9794
+ // reopens the stream.
9795
+ deviceStreamDeactivated = false;
9792
9796
  recoveryChecked = false;
9793
9797
  recovering = false;
9794
9798
  heartbeated = false;
@@ -9924,7 +9928,15 @@ var CompanionSupervisor = class {
9924
9928
  }
9925
9929
  if (ev.event === "message") await this.handleDeviceMessage(ev);
9926
9930
  },
9927
- onAuthFailure: () => {
9931
+ onAuthFailure: (status) => {
9932
+ if (status === 403) {
9933
+ this.deviceStreamDeactivated = true;
9934
+ this.heartbeatTimer?.ref();
9935
+ this.log.warn(
9936
+ "This device was deactivated in Cabane. The companion will reconnect once it is reactivated."
9937
+ );
9938
+ return;
9939
+ }
9928
9940
  this.log.error(
9929
9941
  `Cabane no longer accepts this device. Run ${cabane("logout")}, then ${cabane("setup")} to pair again.`
9930
9942
  );
@@ -10014,6 +10026,12 @@ var CompanionSupervisor = class {
10014
10026
  lastAcknowledgedDevice: view.success ? view.data : null,
10015
10027
  lastHeartbeatRefused: false
10016
10028
  };
10029
+ if (this.deviceStreamDeactivated && this.deviceSub && !this.stopped) {
10030
+ this.deviceStreamDeactivated = false;
10031
+ this.heartbeatTimer?.unref();
10032
+ this.log.info("This device was reactivated; reconnecting to Cabane.");
10033
+ this.deviceSub.start();
10034
+ }
10017
10035
  void this.recoverRuns();
10018
10036
  void this.updater?.onHeartbeat(res.companion, this.deviceConnected).catch(
10019
10037
  (err) => this.log.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabane/companion",
3
- "version": "0.6.199",
3
+ "version": "0.6.201",
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",