@sjawhar/claude-envoy 6.4.0 → 6.5.1

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": "6.4.0"
5
+ "version": "6.5.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.4.0",
3
+ "version": "6.5.1",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -14323,21 +14323,22 @@ var ISSUE_UPDATE_OPTIONS_RULE = "include_children, unlink_children and include_p
14323
14323
  var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
14324
14324
  function issueStatusOptionsProblem(input) {
14325
14325
  const options = issueStatusOptionsOf(input);
14326
+ const optionInput = input;
14326
14327
  if (options.length === 0)
14327
14328
  return;
14328
14329
  const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
14329
14330
  const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
14330
14331
  return brokenParts([
14331
14332
  [
14332
- !(input["include_children"] === true && input["unlink_children"] === true),
14333
+ !(optionInput.include_children === true && optionInput.unlink_children === true),
14333
14334
  "include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
14334
14335
  ],
14335
14336
  [
14336
- !(input["include_children"] === true && input["status"] === "done"),
14337
+ !(optionInput.include_children === true && optionInput.status === "done"),
14337
14338
  "include_children does not go with status done. Only a person who is signed in at a browser can close the open issues under an issue together with it, and this call presents a token. That person does it on the issue's page in Dispatch: Close issue, then Move them with it."
14338
14339
  ],
14339
14340
  [
14340
- typeof input["status"] === "string",
14341
+ typeof optionInput.status === "string",
14341
14342
  `status is required with ${named}. Add status, or drop ${named}.`
14342
14343
  ],
14343
14344
  [
@@ -14490,8 +14491,8 @@ var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason
14490
14491
  function resultProblem(value) {
14491
14492
  const input = value;
14492
14493
  const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
14493
- if (typeof input["retract"] === "string") {
14494
- const reason = input["reason"];
14494
+ if (typeof input.retract === "string") {
14495
+ const reason = input.reason;
14495
14496
  if (typeof reason !== "string" || reason.trim() === "") {
14496
14497
  return "retract needs reason, the words that say why the result is wrong.";
14497
14498
  }
@@ -14500,7 +14501,7 @@ function resultProblem(value) {
14500
14501
  }
14501
14502
  return;
14502
14503
  }
14503
- if (input["reason"] !== undefined) {
14504
+ if (input.reason !== undefined) {
14504
14505
  return "reason goes with retract, and this call carries no retract. Name the result to retract, or drop reason.";
14505
14506
  }
14506
14507
  const missing = RESULT_REQUIRED_FIELDS.filter((field) => input[field] === undefined);
@@ -15969,6 +15970,52 @@ var DispatchTargetedDeliverySchema = union([
15969
15970
  DispatchTargetedCommentDeliverySchema,
15970
15971
  DispatchTargetedMessageDeliverySchema
15971
15972
  ]);
15973
+ function isCommentTargetedDelivery(delivery) {
15974
+ return "comment_id" in delivery;
15975
+ }
15976
+ var DispatchTargetedFrameSchema = object({
15977
+ event: DispatchEventSchema,
15978
+ delivery: DispatchTargetedDeliverySchema
15979
+ }).superRefine(({ event, delivery }, context) => {
15980
+ if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
15981
+ return;
15982
+ }
15983
+ if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
15984
+ return;
15985
+ }
15986
+ context.addIssue({
15987
+ code: "custom",
15988
+ message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
15989
+ });
15990
+ });
15991
+ var RecoverableDispatchDeliveryFailureSchema = object({
15992
+ event: object({
15993
+ type: _enum2(["message.created", "comment.created"]),
15994
+ issue_key: string2().nullable(),
15995
+ payload: object({ id: string2(), body: string2().optional() }).passthrough()
15996
+ }).passthrough(),
15997
+ delivery: DispatchTargetedDeliverySchema
15998
+ }).refine(({ event, delivery }) => event.type === "comment.created" ? isCommentTargetedDelivery(delivery) : !isCommentTargetedDelivery(delivery) && DispatchTargetedResourceIDSchema.safeParse(event.payload.id).success, { message: "delivery resource must match its event type" });
15999
+ function readDispatchPayload(value) {
16000
+ if (typeof value === "object" && value !== null && "delivery" in value) {
16001
+ const targeted = DispatchTargetedFrameSchema.safeParse(value);
16002
+ if (targeted.success) {
16003
+ const { event: wireEvent } = value;
16004
+ return {
16005
+ kind: "event",
16006
+ event: targeted.data.event,
16007
+ wireEvent,
16008
+ delivery: targeted.data.delivery
16009
+ };
16010
+ }
16011
+ const recovered = RecoverableDispatchDeliveryFailureSchema.safeParse(value);
16012
+ if (recovered.success)
16013
+ return { kind: "recovered", failure: recovered.data };
16014
+ return { kind: "raw", targeted: true };
16015
+ }
16016
+ const parsed = DispatchEventSchema.safeParse(value);
16017
+ return parsed.success ? { kind: "event", event: parsed.data, wireEvent: value } : { kind: "raw", targeted: false };
16018
+ }
15972
16019
  // ../contracts/src/dispatch-api-user.ts
15973
16020
  var UserIssueStateSchema = strictObject({
15974
16021
  pinned: boolean2(),
@@ -19545,9 +19592,6 @@ function reachedNothing(error) {
19545
19592
  }
19546
19593
 
19547
19594
  class LoggableError extends Error {
19548
- constructor(message) {
19549
- super(message);
19550
- }
19551
19595
  }
19552
19596
  var SERVER_REFUSALS = [
19553
19597
  "Authorization Violation",
@@ -26569,7 +26613,7 @@ function parseFrameJSON(text) {
26569
26613
  const containers = typeof value === "object" && value !== null ? [value] : [];
26570
26614
  for (let next = containers.pop();next !== undefined; next = containers.pop()) {
26571
26615
  const members = next;
26572
- delete members["__proto__"];
26616
+ Reflect.deleteProperty(members, "__proto__");
26573
26617
  let names = Object.keys(members);
26574
26618
  if (names.some((name) => name.search(LONE_SURROGATE) !== -1)) {
26575
26619
  const held = names.map((name) => members[name]);
@@ -26801,32 +26845,6 @@ function createDeliveryDedupe(now = Date.now) {
26801
26845
  }
26802
26846
  };
26803
26847
  }
26804
- function isCommentTargetedDelivery(delivery) {
26805
- return "comment_id" in delivery;
26806
- }
26807
- var DispatchTargetedFrameSchema = object({
26808
- event: DispatchEventSchema,
26809
- delivery: DispatchTargetedDeliverySchema
26810
- }).superRefine(({ event, delivery }, context) => {
26811
- if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
26812
- return;
26813
- }
26814
- if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
26815
- return;
26816
- }
26817
- context.addIssue({
26818
- code: "custom",
26819
- message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
26820
- });
26821
- });
26822
- var RecoverableDispatchDeliveryFailureSchema = object({
26823
- event: object({
26824
- type: _enum2(["message.created", "comment.created"]),
26825
- issue_key: string2().nullable(),
26826
- payload: object({ id: string2(), body: string2().optional() }).passthrough()
26827
- }).passthrough(),
26828
- delivery: DispatchTargetedDeliverySchema
26829
- }).refine(({ event, delivery }) => event.type === "comment.created" ? isCommentTargetedDelivery(delivery) : !isCommentTargetedDelivery(delivery) && DispatchTargetedResourceIDSchema.safeParse(event.payload.id).success, { message: "delivery resource must match its event type" });
26830
26848
  function eventPictures(event) {
26831
26849
  let text;
26832
26850
  if (event.type.startsWith("message.")) {
@@ -26858,16 +26876,22 @@ function carriedItem(event) {
26858
26876
  const resource = event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("message.") ? "message" : undefined;
26859
26877
  if (resource === undefined || !isObject3(event.payload))
26860
26878
  return;
26861
- const id = event.payload["id"];
26879
+ const { id } = event.payload;
26862
26880
  if (typeof id !== "string" || id === "")
26863
26881
  return;
26864
26882
  return { resource, id, issueKey: event.issue_key };
26865
26883
  }
26866
26884
  function payloadWasOmitted(payload) {
26867
- return isObject3(payload) && payload["payload_omitted"] === true;
26885
+ if (!isObject3(payload))
26886
+ return false;
26887
+ const { payload_omitted } = payload;
26888
+ return payload_omitted === true;
26868
26889
  }
26869
26890
  function bodyWasCut(payload) {
26870
- return isObject3(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
26891
+ if (!isObject3(payload))
26892
+ return false;
26893
+ const { body_truncated } = payload;
26894
+ return body_truncated === true || payloadWasOmitted(payload);
26871
26895
  }
26872
26896
  function wholeItemRoute(item) {
26873
26897
  return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
@@ -27112,7 +27136,10 @@ var DISPATCH_BOOKKEEPING = new Set([
27112
27136
  ]);
27113
27137
  function dispatchPayloadForReader(event, sessionID, issuedAt, toReader) {
27114
27138
  const whole = dispatchPayload(event);
27115
- const changed = event.type !== "issue.created" && isObject3(whole) && Array.isArray(whole["changed"]) ? whole["changed"] : [];
27139
+ let changedField;
27140
+ if (event.type !== "issue.created" && isObject3(whole))
27141
+ ({ changed: changedField } = whole);
27142
+ const changed = Array.isArray(changedField) ? changedField : [];
27116
27143
  const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
27117
27144
  if (!isObject3(payload) || Array.isArray(payload))
27118
27145
  return payload;
@@ -27227,27 +27254,25 @@ function parseDispatchFrame(rawPayload, wholeBody) {
27227
27254
  try {
27228
27255
  value = parseFrameJSON(rawPayload);
27229
27256
  } catch {
27230
- return { raw: rawPayload };
27257
+ return {};
27231
27258
  }
27232
- if (isObject3(value) && "delivery" in value) {
27233
- const targeted = DispatchTargetedFrameSchema.safeParse(value);
27234
- if (targeted.success) {
27235
- const wireFrame = value;
27259
+ const reading = readDispatchPayload(value);
27260
+ switch (reading.kind) {
27261
+ case "event": {
27262
+ const { notify, quiet } = reading.wireEvent;
27236
27263
  return {
27237
- event: withWholeBody(targeted.data.event, wholeBody),
27238
- notify: wireFrame.event.notify,
27239
- quiet: wireFrame.event.quiet,
27240
- delivery: targeted.data.delivery
27264
+ event: withWholeBody(reading.event, wholeBody),
27265
+ notify,
27266
+ quiet,
27267
+ delivery: reading.delivery
27241
27268
  };
27242
27269
  }
27243
- const recoverable = RecoverableDispatchDeliveryFailureSchema.safeParse(value);
27244
- if (recoverable.success) {
27245
- const delivery = recoverable.data.delivery;
27270
+ case "recovered": {
27271
+ const { delivery, event } = reading.failure;
27246
27272
  const commentDelivery = isCommentTargetedDelivery(delivery);
27247
27273
  const resource = commentDelivery ? "comment" : "message";
27248
- const id = commentDelivery ? delivery.comment_id : recoverable.data.event.payload.id;
27274
+ const id = commentDelivery ? delivery.comment_id : event.payload.id;
27249
27275
  return {
27250
- raw: value,
27251
27276
  rejectedDelivery: {
27252
27277
  resource,
27253
27278
  id,
@@ -27255,24 +27280,15 @@ function parseDispatchFrame(rawPayload, wholeBody) {
27255
27280
  mode: delivery.mode,
27256
27281
  replyPath: dispatchReplyPath(resource, id),
27257
27282
  replyFields: commentDelivery ? { target: delivery.target } : {},
27258
- issueKey: recoverable.data.event.issue_key,
27259
- body: recoverable.data.event.payload.body ?? ""
27283
+ issueKey: event.issue_key,
27284
+ body: event.payload.body ?? ""
27260
27285
  },
27261
27286
  malformedDelivery: true
27262
27287
  };
27263
27288
  }
27264
- return { raw: value, malformedDelivery: true };
27289
+ case "raw":
27290
+ return reading.targeted ? { malformedDelivery: true } : {};
27265
27291
  }
27266
- const parsed = DispatchEventSchema.safeParse(value);
27267
- if (!parsed.success)
27268
- return { raw: value };
27269
- const wireEvent = value;
27270
- return {
27271
- event: withWholeBody(parsed.data, wholeBody),
27272
- notify: wireEvent.notify,
27273
- quiet: wireEvent.quiet,
27274
- delivery: undefined
27275
- };
27276
27292
  }
27277
27293
  var INBOUND_CARD_MAX_BYTES = 1 << 20;
27278
27294
  function encodeWithin(value, maxBytes) {
@@ -27287,6 +27303,28 @@ function encodeWithin(value, maxBytes) {
27287
27303
  return lines.join(`
27288
27304
  `);
27289
27305
  }
27306
+ function headerActor(actor) {
27307
+ const { kind, id, act, service } = actor;
27308
+ return {
27309
+ kind,
27310
+ ...id === undefined ? {} : { id },
27311
+ ...act === undefined ? {} : { act: ActorActSchema.safeParse(act).data ?? "not shown" },
27312
+ ...kind !== "session" || service === undefined ? {} : { service: typeof service === "string" ? service : "not shown" }
27313
+ };
27314
+ }
27315
+ function dispatchCardAsText(rendered, event, reason, bound) {
27316
+ let text;
27317
+ try {
27318
+ text = JSON.stringify(event);
27319
+ } catch {}
27320
+ const asText = text === undefined ? undefined : encodeWithin({ envoy: { ...rendered, dispatch: text } }, bound);
27321
+ if (asText !== undefined)
27322
+ return asText;
27323
+ const notShown = `not shown: ${reason}`;
27324
+ const owner = event.owner === undefined ? {} : { owner: event.owner };
27325
+ const header = { type: event.type, actor: headerActor(event.actor), payload: notShown };
27326
+ return encodeWithin({ envoy: { ...rendered, dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: { ...owner, ...header } } }, bound) ?? encodeWithin({ envoy: { dispatch: header } }, bound) ?? encode3({ envoy: { dispatch: { payload: notShown } } });
27327
+ }
27290
27328
  function inboundTimestamp(milliseconds) {
27291
27329
  if (milliseconds === undefined)
27292
27330
  return "unknown";
@@ -27394,13 +27432,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27394
27432
  dispatchReply = dispatchCommentReplyWith(frame.event, topic, commentPayload);
27395
27433
  if (frame.event.type === "message.created") {
27396
27434
  const message = DispatchTargetedMessagePayloadSchema.safeParse(frame.event.payload);
27397
- const requested = DispatchTargetedDeliverySchema.safeParse(frame.delivery);
27398
- if (message.success && requested.success && !isCommentTargetedDelivery(requested.data)) {
27435
+ const requested = frame.delivery;
27436
+ if (message.success && requested !== undefined && !isCommentTargetedDelivery(requested)) {
27399
27437
  delivery = {
27400
27438
  resource: "message",
27401
27439
  id: message.data.id,
27402
- attempt: requested.data.attempt,
27403
- mode: requested.data.mode,
27440
+ attempt: requested.attempt,
27441
+ mode: requested.mode,
27404
27442
  replyPath: dispatchReplyPath("message", message.data.id),
27405
27443
  replyFields: {},
27406
27444
  issueKey: frame.event.issue_key,
@@ -27418,15 +27456,15 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27418
27456
  }
27419
27457
  } else if (frame.event.type === "comment.created") {
27420
27458
  const comment = DispatchTargetedCommentPayloadSchema.safeParse(frame.event.payload);
27421
- const requested = DispatchTargetedDeliverySchema.safeParse(frame.delivery);
27422
- if (comment.success && requested.success && isCommentTargetedDelivery(requested.data)) {
27459
+ const requested = frame.delivery;
27460
+ if (comment.success && requested !== undefined && isCommentTargetedDelivery(requested)) {
27423
27461
  delivery = {
27424
27462
  resource: "comment",
27425
- id: requested.data.comment_id,
27426
- attempt: requested.data.attempt,
27427
- mode: requested.data.mode,
27428
- replyPath: dispatchReplyPath("comment", requested.data.comment_id),
27429
- replyFields: { target: requested.data.target },
27463
+ id: requested.comment_id,
27464
+ attempt: requested.attempt,
27465
+ mode: requested.mode,
27466
+ replyPath: dispatchReplyPath("comment", requested.comment_id),
27467
+ replyFields: { target: requested.target },
27430
27468
  issueKey: frame.event.issue_key,
27431
27469
  body: comment.data.body,
27432
27470
  ...comment.data.body_truncated === true ? { bodyTruncated: true } : {}
@@ -27445,7 +27483,9 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27445
27483
  let actor = frame.event.actor;
27446
27484
  if ("origin" in frame.event.actor) {
27447
27485
  const { origin, ...rest } = frame.event.actor;
27448
- const title = isObject3(origin) ? origin["session_title"] : undefined;
27486
+ let title;
27487
+ if (isObject3(origin))
27488
+ ({ session_title: title } = origin);
27449
27489
  actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
27450
27490
  }
27451
27491
  const owner = dispatchOwner(frame.event, topic);
@@ -27467,7 +27507,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27467
27507
  trailer = humanEditDiffBlock(edit.data.diff, edit.data.diff_truncated);
27468
27508
  }
27469
27509
  } else {
27470
- dispatchEvent = frame.raw;
27510
+ dispatchIssue = "payload";
27471
27511
  rejectedDelivery = frame.rejectedDelivery;
27472
27512
  malformedDelivery = frame.malformedDelivery === true;
27473
27513
  }
@@ -27522,7 +27562,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27522
27562
  args: { topic: `notifications.role.${role}`, message: "..." }
27523
27563
  }
27524
27564
  },
27525
- ...dispatchRendered ? { dispatch: dispatchEvent } : {
27565
+ ...dispatchRendered ? dispatchEvent === undefined ? {} : { dispatch: dispatchEvent } : {
27526
27566
  ...summaryIsHead ? {} : { summary: payloadSummary },
27527
27567
  ...message === undefined ? {} : { message }
27528
27568
  },
@@ -27532,7 +27572,6 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27532
27572
  },
27533
27573
  ...unrecognised === undefined ? {} : { unrecognised }
27534
27574
  };
27535
- const payloadKey = dispatchRendered ? "dispatch" : "message";
27536
27575
  const payloadValue = dispatchRendered ? dispatchEvent : message;
27537
27576
  const cardBound = Math.max(INBOUND_CARD_MAX_BYTES, 2 * (Buffer.byteLength(raw) + (wholeBody === undefined ? 0 : Buffer.byteLength(escapeString(wholeBody)))));
27538
27577
  let card;
@@ -27546,7 +27585,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
27546
27585
  }
27547
27586
  if (card === undefined) {
27548
27587
  payloadShownAsText ??= `its layout is larger than the ${cardBound} bytes a card holds`;
27549
- card = encode3({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
27588
+ card = dispatchEvent === undefined ? encode3({ envoy: { ...rendered, message: envelope.payload } }) : dispatchCardAsText(rendered, dispatchEvent, payloadShownAsText, cardBound);
27550
27589
  }
27551
27590
  return {
27552
27591
  skip: false,
@@ -28640,7 +28679,8 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
28640
28679
  if (tool === "dispatch_read" && typeof args.message === "string") {
28641
28680
  return { args, ref, owner: null };
28642
28681
  }
28643
- if (tool === "dispatch_result" && typeof args["retract"] === "string") {
28682
+ const { retract } = args;
28683
+ if (tool === "dispatch_result" && typeof retract === "string") {
28644
28684
  return { args, ref, owner: null };
28645
28685
  }
28646
28686
  const legionIssue = env.LEGION_ISSUE;
@@ -30599,7 +30639,8 @@ async function relatedCommand(context) {
30599
30639
  };
30600
30640
  }
30601
30641
  function printsJson(tool, args) {
30602
- return tool === "dispatch_issues" && args["json"] === true;
30642
+ const { json } = args;
30643
+ return tool === "dispatch_issues" && json === true;
30603
30644
  }
30604
30645
  async function issuesCommand(context) {
30605
30646
  const { args, client, input } = context;
@@ -30665,7 +30706,8 @@ async function issuesCommand(context) {
30665
30706
  };
30666
30707
  }
30667
30708
  function dryRunAsksDispatch(tool, args) {
30668
- return tool === "dispatch_result" && args["retract"] === undefined;
30709
+ const { retract } = args;
30710
+ return tool === "dispatch_result" && retract === undefined;
30669
30711
  }
30670
30712
  async function resultCommand(context) {
30671
30713
  const { args, client, actor } = context;