@cabane/companion 0.6.127 → 0.6.128

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
@@ -1037,6 +1037,11 @@ function leaseRefusal(err) {
1037
1037
  function isWriteFenceRefusal(err) {
1038
1038
  return err instanceof ApiError && err.status === 409 && apiErrorCode(err) === "not_running";
1039
1039
  }
1040
+ function isTurnEndedRefusal(err) {
1041
+ if (!(err instanceof ApiError) || err.status !== 401) return false;
1042
+ const body = err.body;
1043
+ return typeof body === "object" && body !== null && body.reason === "turn_ended";
1044
+ }
1040
1045
  function describeErrorBody(body) {
1041
1046
  if (body === void 0 || body === null) return void 0;
1042
1047
  let text;
@@ -1286,6 +1291,15 @@ var init_api = __esm({
1286
1291
  progressed = true;
1287
1292
  } catch (err) {
1288
1293
  if (err instanceof ApiError && err.status >= 400 && err.status < 500) {
1294
+ if (entry.kind === "active-run" && isTurnEndedRefusal(err)) {
1295
+ this.opts.log?.debug(
1296
+ { kind: entry.kind, turnId: entry.turnId, ...apiErrorLogFields(err) },
1297
+ "companion: queued settle refused; the turn had already ended"
1298
+ );
1299
+ outbox.remove(entry.turnId, entry.seq);
1300
+ progressed = true;
1301
+ continue;
1302
+ }
1289
1303
  this.opts.log?.warn(
1290
1304
  { kind: entry.kind, turnId: entry.turnId, seq: entry.seq, ...apiErrorLogFields(err) },
1291
1305
  "Cabane rejected a saved update; it could not be delivered. This companion may need an update: npm i -g @cabane/companion@latest"
@@ -8998,10 +9012,17 @@ var init_turn_execution = __esm({
8998
9012
  body
8999
9013
  );
9000
9014
  } catch (err) {
9001
- turnLog.warn(
9002
- { ...apiErrorLogFields(err), turnId },
9003
- "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
9004
- );
9015
+ if (isTurnEndedRefusal(err)) {
9016
+ turnLog.debug(
9017
+ { ...apiErrorLogFields(err), turnId },
9018
+ "companion: settle refused; the turn had already ended"
9019
+ );
9020
+ } else {
9021
+ turnLog.warn(
9022
+ { ...apiErrorLogFields(err), turnId },
9023
+ "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
9024
+ );
9025
+ }
9005
9026
  }
9006
9027
  const durationMs = Date.now() - startedAt;
9007
9028
  this.supervisor.notifyEnd({ id: payload.messageId, ok: false, durationMs, reason });
@@ -9809,10 +9830,17 @@ var init_turn_execution = __esm({
9809
9830
  body
9810
9831
  );
9811
9832
  } catch (err) {
9812
- turnLog.warn(
9813
- { ...apiErrorLogFields(err) },
9814
- "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
9815
- );
9833
+ if (isTurnEndedRefusal(err)) {
9834
+ turnLog.debug(
9835
+ { ...apiErrorLogFields(err) },
9836
+ "companion: settle refused; the turn had already ended"
9837
+ );
9838
+ } else {
9839
+ turnLog.warn(
9840
+ { ...apiErrorLogFields(err) },
9841
+ "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
9842
+ );
9843
+ }
9816
9844
  }
9817
9845
  this.supervisor.releaseAbort(turnId, abortController);
9818
9846
  }
package/dist/runtime.js CHANGED
@@ -2279,6 +2279,11 @@ function leaseRefusal(err) {
2279
2279
  function isWriteFenceRefusal(err) {
2280
2280
  return err instanceof ApiError && err.status === 409 && apiErrorCode(err) === "not_running";
2281
2281
  }
2282
+ function isTurnEndedRefusal(err) {
2283
+ if (!(err instanceof ApiError) || err.status !== 401) return false;
2284
+ const body = err.body;
2285
+ return typeof body === "object" && body !== null && body.reason === "turn_ended";
2286
+ }
2282
2287
  var ERROR_BODY_LOG_CAP = 2e3;
2283
2288
  function describeErrorBody(body) {
2284
2289
  if (body === void 0 || body === null) return void 0;
@@ -2469,6 +2474,15 @@ var CabaneApi = class {
2469
2474
  progressed = true;
2470
2475
  } catch (err) {
2471
2476
  if (err instanceof ApiError && err.status >= 400 && err.status < 500) {
2477
+ if (entry.kind === "active-run" && isTurnEndedRefusal(err)) {
2478
+ this.opts.log?.debug(
2479
+ { kind: entry.kind, turnId: entry.turnId, ...apiErrorLogFields(err) },
2480
+ "companion: queued settle refused; the turn had already ended"
2481
+ );
2482
+ outbox.remove(entry.turnId, entry.seq);
2483
+ progressed = true;
2484
+ continue;
2485
+ }
2472
2486
  this.opts.log?.warn(
2473
2487
  { kind: entry.kind, turnId: entry.turnId, seq: entry.seq, ...apiErrorLogFields(err) },
2474
2488
  "Cabane rejected a saved update; it could not be delivered. This companion may need an update: npm i -g @cabane/companion@latest"
@@ -9984,10 +9998,17 @@ var TurnExecution = class {
9984
9998
  body
9985
9999
  );
9986
10000
  } catch (err) {
9987
- turnLog.warn(
9988
- { ...apiErrorLogFields(err), turnId },
9989
- "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
9990
- );
10001
+ if (isTurnEndedRefusal(err)) {
10002
+ turnLog.debug(
10003
+ { ...apiErrorLogFields(err), turnId },
10004
+ "companion: settle refused; the turn had already ended"
10005
+ );
10006
+ } else {
10007
+ turnLog.warn(
10008
+ { ...apiErrorLogFields(err), turnId },
10009
+ "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
10010
+ );
10011
+ }
9991
10012
  }
9992
10013
  const durationMs = Date.now() - startedAt;
9993
10014
  this.supervisor.notifyEnd({ id: payload.messageId, ok: false, durationMs, reason });
@@ -10795,10 +10816,17 @@ var TurnExecution = class {
10795
10816
  body
10796
10817
  );
10797
10818
  } catch (err) {
10798
- turnLog.warn(
10799
- { ...apiErrorLogFields(err) },
10800
- "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
10801
- );
10819
+ if (isTurnEndedRefusal(err)) {
10820
+ turnLog.debug(
10821
+ { ...apiErrorLogFields(err) },
10822
+ "companion: settle refused; the turn had already ended"
10823
+ );
10824
+ } else {
10825
+ turnLog.warn(
10826
+ { ...apiErrorLogFields(err) },
10827
+ "Couldn't save the turn's result to Cabane. This companion may need an update: npm i -g @cabane/companion@latest"
10828
+ );
10829
+ }
10802
10830
  }
10803
10831
  this.supervisor.releaseAbort(turnId, abortController);
10804
10832
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabane/companion",
3
- "version": "0.6.127",
3
+ "version": "0.6.128",
4
4
  "type": "module",
5
5
  "description": "The Cabane Companion (headless): connect a coding 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",