@sjawhar/claude-envoy 5.19.1 → 5.19.3

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.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "5.19.1"
5
+ "version": "5.19.3"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "5.19.1",
3
+ "version": "5.19.3",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -23025,6 +23025,19 @@ function parseDispatchFrame(rawPayload, wholeBody) {
23025
23025
  delivery: undefined
23026
23026
  };
23027
23027
  }
23028
+ var INBOUND_CARD_MAX_BYTES = 1 << 20;
23029
+ function encodeWithin(value, maxBytes) {
23030
+ const lines = [];
23031
+ let bytes = -1;
23032
+ for (const line of encodeLines(value)) {
23033
+ bytes += Buffer.byteLength(line) + 1;
23034
+ if (bytes > maxBytes)
23035
+ return;
23036
+ lines.push(line);
23037
+ }
23038
+ return lines.join(`
23039
+ `);
23040
+ }
23028
23041
  function inboundTimestamp(milliseconds) {
23029
23042
  if (milliseconds === undefined)
23030
23043
  return "unknown";
@@ -23260,17 +23273,22 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
23260
23273
  },
23261
23274
  ...unrecognised === undefined ? {} : { unrecognised }
23262
23275
  };
23276
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
23277
+ const payloadValue = dispatchRendered ? dispatchEvent : message;
23278
+ const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
23263
23279
  let card;
23264
23280
  let payloadShownAsText;
23265
23281
  try {
23266
- card = encode3({ envoy: rendered });
23282
+ card = typeof payloadValue === "object" && payloadValue !== null ? encodeWithin({ envoy: rendered }, cardBound) : encode3({ envoy: rendered });
23267
23283
  } catch (error) {
23268
- const payloadKey = dispatchRendered ? "dispatch" : "message";
23269
- if (envelope.payload === undefined || !(payloadKey in rendered))
23284
+ if (envelope.payload === undefined || payloadValue === undefined)
23270
23285
  throw error;
23271
- card = encode3({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
23272
23286
  payloadShownAsText = messageFor(error);
23273
23287
  }
23288
+ if (card === undefined) {
23289
+ payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
23290
+ card = encode3({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
23291
+ }
23274
23292
  return {
23275
23293
  skip: false,
23276
23294
  content: trailer === "" ? card : `${card}
package/dist/dispatch.js CHANGED
@@ -28318,6 +28318,19 @@ function parseDispatchFrame(rawPayload, wholeBody) {
28318
28318
  delivery: undefined
28319
28319
  };
28320
28320
  }
28321
+ var INBOUND_CARD_MAX_BYTES = 1 << 20;
28322
+ function encodeWithin(value, maxBytes) {
28323
+ const lines = [];
28324
+ let bytes = -1;
28325
+ for (const line of encodeLines(value)) {
28326
+ bytes += Buffer.byteLength(line) + 1;
28327
+ if (bytes > maxBytes)
28328
+ return;
28329
+ lines.push(line);
28330
+ }
28331
+ return lines.join(`
28332
+ `);
28333
+ }
28321
28334
  function inboundTimestamp(milliseconds) {
28322
28335
  if (milliseconds === undefined)
28323
28336
  return "unknown";
@@ -28553,17 +28566,22 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
28553
28566
  },
28554
28567
  ...unrecognised === undefined ? {} : { unrecognised }
28555
28568
  };
28569
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
28570
+ const payloadValue = dispatchRendered ? dispatchEvent : message;
28571
+ const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
28556
28572
  let card;
28557
28573
  let payloadShownAsText;
28558
28574
  try {
28559
- card = encode5({ envoy: rendered });
28575
+ card = typeof payloadValue === "object" && payloadValue !== null ? encodeWithin({ envoy: rendered }, cardBound) : encode5({ envoy: rendered });
28560
28576
  } catch (error) {
28561
- const payloadKey = dispatchRendered ? "dispatch" : "message";
28562
- if (envelope.payload === undefined || !(payloadKey in rendered))
28577
+ if (envelope.payload === undefined || payloadValue === undefined)
28563
28578
  throw error;
28564
- card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
28565
28579
  payloadShownAsText = messageFor(error);
28566
28580
  }
28581
+ if (card === undefined) {
28582
+ payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
28583
+ card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
28584
+ }
28567
28585
  return {
28568
28586
  skip: false,
28569
28587
  content: trailer === "" ? card : `${card}
@@ -50283,6 +50283,19 @@ function parseDispatchFrame(rawPayload, wholeBody) {
50283
50283
  delivery: undefined
50284
50284
  };
50285
50285
  }
50286
+ var INBOUND_CARD_MAX_BYTES = 1 << 20;
50287
+ function encodeWithin(value, maxBytes) {
50288
+ const lines = [];
50289
+ let bytes = -1;
50290
+ for (const line of encodeLines(value)) {
50291
+ bytes += Buffer.byteLength(line) + 1;
50292
+ if (bytes > maxBytes)
50293
+ return;
50294
+ lines.push(line);
50295
+ }
50296
+ return lines.join(`
50297
+ `);
50298
+ }
50286
50299
  function inboundTimestamp(milliseconds) {
50287
50300
  if (milliseconds === undefined)
50288
50301
  return "unknown";
@@ -50518,17 +50531,22 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
50518
50531
  },
50519
50532
  ...unrecognised === undefined ? {} : { unrecognised }
50520
50533
  };
50534
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
50535
+ const payloadValue = dispatchRendered ? dispatchEvent : message;
50536
+ const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
50521
50537
  let card;
50522
50538
  let payloadShownAsText;
50523
50539
  try {
50524
- card = encode5({ envoy: rendered });
50540
+ card = typeof payloadValue === "object" && payloadValue !== null ? encodeWithin({ envoy: rendered }, cardBound) : encode5({ envoy: rendered });
50525
50541
  } catch (error) {
50526
- const payloadKey = dispatchRendered ? "dispatch" : "message";
50527
- if (envelope.payload === undefined || !(payloadKey in rendered))
50542
+ if (envelope.payload === undefined || payloadValue === undefined)
50528
50543
  throw error;
50529
- card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
50530
50544
  payloadShownAsText = messageFor(error);
50531
50545
  }
50546
+ if (card === undefined) {
50547
+ payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
50548
+ card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
50549
+ }
50532
50550
  return {
50533
50551
  skip: false,
50534
50552
  content: trailer === "" ? card : `${card}
@@ -62715,9 +62733,9 @@ var import_nats5 = __toESM(require_mod4(), 1);
62715
62733
 
62716
62734
  // package.json
62717
62735
  var name2 = "@sjawhar/claude-envoy";
62718
- var version2 = "5.19.1";
62736
+ var version2 = "5.19.3";
62719
62737
  var legion = {
62720
- daemonApiVersion: 228
62738
+ daemonApiVersion: 232
62721
62739
  };
62722
62740
  var package_default = {
62723
62741
  name: name2,
@@ -64766,7 +64784,9 @@ var turnOutcomeFields = {
64766
64784
  generation: number2().int().positive(),
64767
64785
  sequence: number2().int().positive(),
64768
64786
  outcome: _enum2(["clean", "refused"]),
64769
- message: string2().optional()
64787
+ message: string2().optional(),
64788
+ httpStatus: number2().int().min(100).max(599).optional(),
64789
+ unprompted: boolean2().optional()
64770
64790
  };
64771
64791
  var LegionTurnOutcomeAgentRequest = strictObject({
64772
64792
  claimToken: nonEmptyString2,
@@ -68272,6 +68292,10 @@ function createChannelDelivery(input) {
68272
68292
  const eventId = envelope.event_id;
68273
68293
  if (eventId !== undefined && inbox.some((entry) => entry.event_id === eventId))
68274
68294
  return;
68295
+ if (rendered.payloadShownAsText !== undefined) {
68296
+ process.stderr.write(`envoy-channel: message ${eventId ?? "unknown"}'s payload is shown as its text; the card could not lay it out (${rendered.payloadShownAsText})
68297
+ `);
68298
+ }
68275
68299
  inbox.unshift({
68276
68300
  event_id: eventId ?? "unknown",
68277
68301
  at: inboundTimestamp(envelope.issued_at),
@@ -68317,10 +68341,6 @@ function createChannelDelivery(input) {
68317
68341
  }
68318
68342
  if (late === true && passOverLateBtw(rendered))
68319
68343
  return tail.then(() => false);
68320
- if (rendered.payloadShownAsText !== undefined) {
68321
- process.stderr.write(`envoy-channel: message ${rendered.envelope?.event_id ?? "unknown"}'s payload is shown as its text; the card could not lay it out (${rendered.payloadShownAsText})
68322
- `);
68323
- }
68324
68344
  return queued(async () => {
68325
68345
  const routed = await input.router?.()?.route(rendered);
68326
68346
  if (routed === true) {
@@ -25825,6 +25825,19 @@ function parseDispatchFrame(rawPayload, wholeBody) {
25825
25825
  delivery: undefined
25826
25826
  };
25827
25827
  }
25828
+ var INBOUND_CARD_MAX_BYTES = 1 << 20;
25829
+ function encodeWithin(value, maxBytes) {
25830
+ const lines = [];
25831
+ let bytes = -1;
25832
+ for (const line of encodeLines(value)) {
25833
+ bytes += Buffer.byteLength(line) + 1;
25834
+ if (bytes > maxBytes)
25835
+ return;
25836
+ lines.push(line);
25837
+ }
25838
+ return lines.join(`
25839
+ `);
25840
+ }
25828
25841
  function inboundTimestamp(milliseconds) {
25829
25842
  if (milliseconds === undefined)
25830
25843
  return "unknown";
@@ -26060,17 +26073,22 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
26060
26073
  },
26061
26074
  ...unrecognised === undefined ? {} : { unrecognised }
26062
26075
  };
26076
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
26077
+ const payloadValue = dispatchRendered ? dispatchEvent : message;
26078
+ const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
26063
26079
  let card;
26064
26080
  let payloadShownAsText;
26065
26081
  try {
26066
- card = encode5({ envoy: rendered });
26082
+ card = typeof payloadValue === "object" && payloadValue !== null ? encodeWithin({ envoy: rendered }, cardBound) : encode5({ envoy: rendered });
26067
26083
  } catch (error) {
26068
- const payloadKey = dispatchRendered ? "dispatch" : "message";
26069
- if (envelope.payload === undefined || !(payloadKey in rendered))
26084
+ if (envelope.payload === undefined || payloadValue === undefined)
26070
26085
  throw error;
26071
- card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
26072
26086
  payloadShownAsText = messageFor(error);
26073
26087
  }
26088
+ if (card === undefined) {
26089
+ payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
26090
+ card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
26091
+ }
26074
26092
  return {
26075
26093
  skip: false,
26076
26094
  content: trailer === "" ? card : `${card}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "5.19.1",
3
+ "version": "5.19.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "AGENTS.md"
20
20
  ],
21
21
  "legion": {
22
- "daemonApiVersion": 228
22
+ "daemonApiVersion": 232
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -573,6 +573,13 @@ export function createChannelDelivery(input: {
573
573
  if (envelope === undefined) return
574
574
  const eventId = envelope.event_id
575
575
  if (eventId !== undefined && inbox.some((entry) => entry.event_id === eventId)) return
576
+ // A payload the card could not lay out is shown as the text its sender sent: said here, for
577
+ // the message the inbox lists the first time, so a copy Envoy sends again says nothing new.
578
+ if (rendered.payloadShownAsText !== undefined) {
579
+ process.stderr.write(
580
+ `envoy-channel: message ${eventId ?? "unknown"}'s payload is shown as its text; the card could not lay it out (${rendered.payloadShownAsText})\n`,
581
+ )
582
+ }
576
583
  inbox.unshift({
577
584
  event_id: eventId ?? "unknown",
578
585
  at: inboundTimestamp(envelope.issued_at),
@@ -635,12 +642,6 @@ export function createChannelDelivery(input: {
635
642
  return tail.then(() => false)
636
643
  }
637
644
  if (late === true && passOverLateBtw(rendered)) return tail.then(() => false)
638
- // A payload the card could not lay out is shown as the text its sender sent, said once here.
639
- if (rendered.payloadShownAsText !== undefined) {
640
- process.stderr.write(
641
- `envoy-channel: message ${rendered.envelope?.event_id ?? "unknown"}'s payload is shown as its text; the card could not lay it out (${rendered.payloadShownAsText})\n`,
642
- )
643
- }
644
645
  return queued(async () => {
645
646
  // A message Dispatch accepted as this session's own turn is never also a card. A failure
646
647
  // after that acceptance throws, so the frame is not answered and the listener sends it
@@ -48,8 +48,12 @@ import { configuredValue } from "./claude-session"
48
48
  * timer, because the task that refused turn carried ended with it and nothing else would wake
49
49
  * this worker, so a single transient refusal would otherwise leave the issue idle. What stops
50
50
  * the reminding for good is the runner's record check, which drops every reminder once the
51
- * daemon has failed this role's claim — the refused turns themselves are counted by the bridge,
52
- * which reports each turn's outcome to the daemon (INFRA-714).
51
+ * daemon has failed this role's claim. The bridge reports each turn's outcome to the daemon, with
52
+ * the status Claude Code named, and marks a turn no prompt of the daemon's ran — a reminder
53
+ * written over the inbox — so the daemon judges that turn from the report (dispatch://INFRA-4508):
54
+ * a refusal whose status cannot clear fails the claim at once and holds the issue, and a refusal
55
+ * that can clear fails nothing, so the reminders keep their pace and the project's controller is
56
+ * told once at six such turns in a row.
53
57
  */
54
58
 
55
59
  /** The tool's name: Claude Code shows it as `mcp__legion__legion_phase_hook`, and a hook entry
@@ -544,8 +548,11 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
544
548
  // provider refusing the turn, and the machine takes it as one: it earns no
545
549
  // continuation, because the next turn would be refused the same way, and one timer,
546
550
  // because nothing else would wake this worker once the task that turn carried ended
547
- // with it. What ends a session the provider keeps refusing is the daemon failing its
548
- // claim on the outcomes the bridge reports, which the timer's own record check reads.
551
+ // with it. What ends the reminding is the daemon failing the claim, which the timer's
552
+ // own record check reads: it does at once for a refusal whose status cannot clear, the
553
+ // status the bridge reports beside the turn's outcome, a reminder's own turn included,
554
+ // and never for a refusal that can clear, of which the controller is told at six in a
555
+ // row (dispatch://INFRA-4508).
549
556
  // Claude Code ignores whatever this hook returns, which costs nothing now that there
550
557
  // is nothing to return.
551
558
  await reminder.settle({ kind: "refused", message: event.lastAssistantMessage ?? "" })