@sjawhar/claude-envoy 5.19.2 → 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.2"
5
+ "version": "5.19.3"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "5.19.2",
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,7 +62733,7 @@ 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.2";
62736
+ var version2 = "5.19.3";
62719
62737
  var legion = {
62720
62738
  daemonApiVersion: 232
62721
62739
  };
@@ -68274,6 +68292,10 @@ function createChannelDelivery(input) {
68274
68292
  const eventId = envelope.event_id;
68275
68293
  if (eventId !== undefined && inbox.some((entry) => entry.event_id === eventId))
68276
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
+ }
68277
68299
  inbox.unshift({
68278
68300
  event_id: eventId ?? "unknown",
68279
68301
  at: inboundTimestamp(envelope.issued_at),
@@ -68319,10 +68341,6 @@ function createChannelDelivery(input) {
68319
68341
  }
68320
68342
  if (late === true && passOverLateBtw(rendered))
68321
68343
  return tail.then(() => false);
68322
- if (rendered.payloadShownAsText !== undefined) {
68323
- 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})
68324
- `);
68325
- }
68326
68344
  return queued(async () => {
68327
68345
  const routed = await input.router?.()?.route(rendered);
68328
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.2",
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",
@@ -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