@sjawhar/claude-envoy 4.4.0 → 4.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": "4.4.0"
5
+ "version": "4.5.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "4.4.0",
3
+ "version": "4.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
  }
@@ -15239,6 +15239,7 @@ var commentEventPayloadFields = {
15239
15239
  ask_question: string2().optional(),
15240
15240
  ask_state: askFields.state.optional(),
15241
15241
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
15242
+ ask_sessions: array(string2()).optional(),
15242
15243
  ...referenceChangesFields,
15243
15244
  ...threadLoginsFields,
15244
15245
  ...carriedBodyFields
@@ -15246,6 +15247,7 @@ var commentEventPayloadFields = {
15246
15247
  var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
15247
15248
  var CommentEventPayloadSchema = object({
15248
15249
  id: commentFields.id.optional(),
15250
+ artifact_id: commentFields.artifact_id,
15249
15251
  artifact_name: commentEventPayloadFields.artifact_name.optional(),
15250
15252
  project_key: commentEventPayloadFields.project_key,
15251
15253
  artifact_slug: commentEventPayloadFields.artifact_slug,
@@ -15255,6 +15257,7 @@ var CommentEventPayloadSchema = object({
15255
15257
  ask_question: commentEventPayloadFields.ask_question,
15256
15258
  ask_state: commentEventPayloadFields.ask_state,
15257
15259
  ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
15260
+ ask_sessions: commentEventPayloadFields.ask_sessions,
15258
15261
  turn: commentFields.turn.optional(),
15259
15262
  anchor: object({
15260
15263
  artifact_id: anchorFields.artifact_id.optional(),
@@ -19387,6 +19390,27 @@ ${body}${fence}${note ? `
19387
19390
  ${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
19388
19391
  }
19389
19392
 
19393
+ // ../envoy-client/src/session-answer-relations.ts
19394
+ var RELATION_PHRASES = {
19395
+ answered_your_ask: "answered your ask",
19396
+ answered_an_ask: "answered an ask",
19397
+ declined_your_ask: "declined to answer your ask",
19398
+ declined_an_ask: "declined to answer an ask",
19399
+ replied_on_your_ask: "replied on your ask",
19400
+ replied_in_a_comment_thread: "replied in a comment thread",
19401
+ commented_on_a_document: "commented on a document",
19402
+ commented_on_an_issue: "commented on an issue",
19403
+ mentioned_you: "mentioned you",
19404
+ sent_you_a_message: "sent you a message",
19405
+ replied_to_your_message: "replied to your message"
19406
+ };
19407
+ function isSessionAnswerRelation(value) {
19408
+ return Object.hasOwn(RELATION_PHRASES, value);
19409
+ }
19410
+ function sessionAnswerRelationPhrase(relation) {
19411
+ return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
19412
+ }
19413
+
19390
19414
  // ../envoy-client/src/delivery.ts
19391
19415
  var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
19392
19416
  var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
@@ -19593,8 +19617,11 @@ function carriedItem(event) {
19593
19617
  return;
19594
19618
  return { resource, id, issueKey: event.issue_key };
19595
19619
  }
19620
+ function payloadWasOmitted(payload) {
19621
+ return isObject2(payload) && payload["payload_omitted"] === true;
19622
+ }
19596
19623
  function bodyWasCut(payload) {
19597
- return isObject2(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
19624
+ return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
19598
19625
  }
19599
19626
  function wholeItemRoute(item) {
19600
19627
  return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
@@ -19602,7 +19629,7 @@ function wholeItemRoute(item) {
19602
19629
  function carriedBodyNote(event) {
19603
19630
  if (!bodyWasCut(event.payload))
19604
19631
  return;
19605
- const what = isObject2(event.payload) && event.payload["payload_omitted"] === true ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
19632
+ const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
19606
19633
  const item = carriedItem(event);
19607
19634
  return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
19608
19635
  }
@@ -19705,6 +19732,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
19705
19732
  })
19706
19733
  };
19707
19734
  }
19735
+ function ownsRepliedAsk(comment, sessionID) {
19736
+ if (comment?.ask_id === undefined || comment.ask_id === null)
19737
+ return;
19738
+ return comment.ask_sessions?.includes(sessionID);
19739
+ }
19740
+ function repliedAskRelation(event, comment, owns, mentioned) {
19741
+ if (owns)
19742
+ return "replied_on_your_ask";
19743
+ if (mentioned)
19744
+ return "mentioned_you";
19745
+ if (comment.reply_to !== undefined && comment.reply_to !== null) {
19746
+ return "replied_in_a_comment_thread";
19747
+ }
19748
+ if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
19749
+ return "commented_on_a_document";
19750
+ }
19751
+ return "commented_on_an_issue";
19752
+ }
19708
19753
  function askResolutionText(resolution) {
19709
19754
  if (resolution === null || resolution === undefined)
19710
19755
  return;
@@ -19714,7 +19759,7 @@ function askResolutionText(resolution) {
19714
19759
  const words = dispatchWordsText(resolution.dispatch_words);
19715
19760
  return words === undefined ? closed : `${closed} \xB7 ${words}`;
19716
19761
  }
19717
- function dispatchCompact(event, comment) {
19762
+ function dispatchCompact(event, comment, ownsAsk) {
19718
19763
  if (event.type === "artifact.human_edited") {
19719
19764
  const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
19720
19765
  if (!edit.success)
@@ -19731,7 +19776,7 @@ function dispatchCompact(event, comment) {
19731
19776
  ...question === undefined ? {} : { question },
19732
19777
  reply: comment.body ?? "",
19733
19778
  ...comment.ask_state === undefined ? {} : { state: comment.ask_state },
19734
- ...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
19779
+ ...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
19735
19780
  }
19736
19781
  };
19737
19782
  }
@@ -19938,7 +19983,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
19938
19983
  let bodyNote;
19939
19984
  let cutItem;
19940
19985
  let inReplyTo = envelope.in_reply_to;
19941
- let askAuthor;
19986
+ let payloadSessions = [];
19942
19987
  let trailer = "";
19943
19988
  const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
19944
19989
  if (envelope.source === "dispatch") {
@@ -19983,11 +20028,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
19983
20028
  }
19984
20029
  const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
19985
20030
  const commentPayload = comment?.success === true ? comment.data : undefined;
19986
- const compact = dispatchCompact(frame.event, commentPayload);
20031
+ const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
20032
+ const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
20033
+ payloadSessions = commentPayload?.ask_sessions ?? [];
19987
20034
  if (frame.event.type.startsWith("ask.")) {
19988
20035
  const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
19989
20036
  if (asked.success && asked.data.author.kind === "session") {
19990
- askAuthor = asked.data.author.id;
20037
+ payloadSessions = [asked.data.author.id];
19991
20038
  }
19992
20039
  }
19993
20040
  if (inReplyTo !== undefined) {
@@ -20035,6 +20082,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20035
20082
  };
20036
20083
  }
20037
20084
  }
20085
+ const mentioned = delivery !== undefined;
20086
+ const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
20087
+ if (ownsAsk === false && !mentioned)
20088
+ dispatchReply = undefined;
20038
20089
  const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
20039
20090
  ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
20040
20091
  ...compact.record
@@ -20043,6 +20094,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20043
20094
  owner: dispatchOwner(frame.event, topic),
20044
20095
  type: frame.event.type,
20045
20096
  actor: frame.event.actor,
20097
+ ...relation === undefined ? {} : { relation },
20046
20098
  ...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
20047
20099
  };
20048
20100
  dispatchActor = frame.event.actor;
@@ -20076,7 +20128,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20076
20128
  let foreignSession;
20077
20129
  for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
20078
20130
  for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
20079
- if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0] !== askAuthor) {
20131
+ if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
20080
20132
  foreignSession = match[0];
20081
20133
  break;
20082
20134
  }
@@ -24652,25 +24704,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
24652
24704
  var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
24653
24705
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
24654
24706
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
24655
- var RELATION_PHRASES = {
24656
- answered_your_ask: "answered your ask",
24657
- declined_your_ask: "declined to answer your ask",
24658
- replied_on_your_ask: "replied on your ask",
24659
- replied_in_a_comment_thread: "replied in a comment thread",
24660
- commented_on_a_document: "commented on a document",
24661
- commented_on_an_issue: "commented on an issue",
24662
- mentioned_you: "mentioned you",
24663
- sent_you_a_message: "sent you a message",
24664
- replied_to_your_message: "replied to your message"
24665
- };
24666
- function isSessionAnswerRelation(value) {
24667
- return Object.hasOwn(RELATION_PHRASES, value);
24668
- }
24669
24707
  function isNoAnswersRoute(error) {
24670
24708
  return isNoRoute(error) || error instanceof DispatchNoRouteError;
24671
24709
  }
24672
24710
  function renderSessionAnswerItem(item) {
24673
- const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
24711
+ const phrase = sessionAnswerRelationPhrase(item.relation);
24674
24712
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
24675
24713
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
24676
24714
  if (item.edited_at !== undefined)
@@ -24711,7 +24749,8 @@ function sessionAnswersWords(items) {
24711
24749
  item.at,
24712
24750
  item.edited_at ?? null,
24713
24751
  item.selected ?? null,
24714
- item.text
24752
+ item.text,
24753
+ item.relation
24715
24754
  ]));
24716
24755
  }
24717
24756
  var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
package/dist/dispatch.js CHANGED
@@ -16303,6 +16303,7 @@ var commentEventPayloadFields = {
16303
16303
  ask_question: string2().optional(),
16304
16304
  ask_state: askFields.state.optional(),
16305
16305
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
16306
+ ask_sessions: array(string2()).optional(),
16306
16307
  ...referenceChangesFields,
16307
16308
  ...threadLoginsFields,
16308
16309
  ...carriedBodyFields
@@ -16310,6 +16311,7 @@ var commentEventPayloadFields = {
16310
16311
  var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
16311
16312
  var CommentEventPayloadSchema = object({
16312
16313
  id: commentFields.id.optional(),
16314
+ artifact_id: commentFields.artifact_id,
16313
16315
  artifact_name: commentEventPayloadFields.artifact_name.optional(),
16314
16316
  project_key: commentEventPayloadFields.project_key,
16315
16317
  artifact_slug: commentEventPayloadFields.artifact_slug,
@@ -16319,6 +16321,7 @@ var CommentEventPayloadSchema = object({
16319
16321
  ask_question: commentEventPayloadFields.ask_question,
16320
16322
  ask_state: commentEventPayloadFields.ask_state,
16321
16323
  ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
16324
+ ask_sessions: commentEventPayloadFields.ask_sessions,
16322
16325
  turn: commentFields.turn.optional(),
16323
16326
  anchor: object({
16324
16327
  artifact_id: anchorFields.artifact_id.optional(),
@@ -20512,6 +20515,27 @@ ${body}${fence}${note ? `
20512
20515
  ${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
20513
20516
  }
20514
20517
 
20518
+ // ../envoy-client/src/session-answer-relations.ts
20519
+ var RELATION_PHRASES = {
20520
+ answered_your_ask: "answered your ask",
20521
+ answered_an_ask: "answered an ask",
20522
+ declined_your_ask: "declined to answer your ask",
20523
+ declined_an_ask: "declined to answer an ask",
20524
+ replied_on_your_ask: "replied on your ask",
20525
+ replied_in_a_comment_thread: "replied in a comment thread",
20526
+ commented_on_a_document: "commented on a document",
20527
+ commented_on_an_issue: "commented on an issue",
20528
+ mentioned_you: "mentioned you",
20529
+ sent_you_a_message: "sent you a message",
20530
+ replied_to_your_message: "replied to your message"
20531
+ };
20532
+ function isSessionAnswerRelation(value) {
20533
+ return Object.hasOwn(RELATION_PHRASES, value);
20534
+ }
20535
+ function sessionAnswerRelationPhrase(relation) {
20536
+ return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
20537
+ }
20538
+
20515
20539
  // ../envoy-client/src/delivery.ts
20516
20540
  var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
20517
20541
  var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
@@ -20718,8 +20742,11 @@ function carriedItem(event) {
20718
20742
  return;
20719
20743
  return { resource, id, issueKey: event.issue_key };
20720
20744
  }
20745
+ function payloadWasOmitted(payload) {
20746
+ return isObject2(payload) && payload["payload_omitted"] === true;
20747
+ }
20721
20748
  function bodyWasCut(payload) {
20722
- return isObject2(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
20749
+ return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
20723
20750
  }
20724
20751
  function wholeItemRoute(item) {
20725
20752
  return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
@@ -20727,7 +20754,7 @@ function wholeItemRoute(item) {
20727
20754
  function carriedBodyNote(event) {
20728
20755
  if (!bodyWasCut(event.payload))
20729
20756
  return;
20730
- const what = isObject2(event.payload) && event.payload["payload_omitted"] === true ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
20757
+ const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
20731
20758
  const item = carriedItem(event);
20732
20759
  return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
20733
20760
  }
@@ -20830,6 +20857,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
20830
20857
  })
20831
20858
  };
20832
20859
  }
20860
+ function ownsRepliedAsk(comment, sessionID) {
20861
+ if (comment?.ask_id === undefined || comment.ask_id === null)
20862
+ return;
20863
+ return comment.ask_sessions?.includes(sessionID);
20864
+ }
20865
+ function repliedAskRelation(event, comment, owns, mentioned) {
20866
+ if (owns)
20867
+ return "replied_on_your_ask";
20868
+ if (mentioned)
20869
+ return "mentioned_you";
20870
+ if (comment.reply_to !== undefined && comment.reply_to !== null) {
20871
+ return "replied_in_a_comment_thread";
20872
+ }
20873
+ if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
20874
+ return "commented_on_a_document";
20875
+ }
20876
+ return "commented_on_an_issue";
20877
+ }
20833
20878
  function askResolutionText(resolution) {
20834
20879
  if (resolution === null || resolution === undefined)
20835
20880
  return;
@@ -20839,7 +20884,7 @@ function askResolutionText(resolution) {
20839
20884
  const words = dispatchWordsText(resolution.dispatch_words);
20840
20885
  return words === undefined ? closed : `${closed} \xB7 ${words}`;
20841
20886
  }
20842
- function dispatchCompact(event, comment) {
20887
+ function dispatchCompact(event, comment, ownsAsk) {
20843
20888
  if (event.type === "artifact.human_edited") {
20844
20889
  const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
20845
20890
  if (!edit.success)
@@ -20856,7 +20901,7 @@ function dispatchCompact(event, comment) {
20856
20901
  ...question === undefined ? {} : { question },
20857
20902
  reply: comment.body ?? "",
20858
20903
  ...comment.ask_state === undefined ? {} : { state: comment.ask_state },
20859
- ...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
20904
+ ...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
20860
20905
  }
20861
20906
  };
20862
20907
  }
@@ -21063,7 +21108,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
21063
21108
  let bodyNote;
21064
21109
  let cutItem;
21065
21110
  let inReplyTo = envelope.in_reply_to;
21066
- let askAuthor;
21111
+ let payloadSessions = [];
21067
21112
  let trailer = "";
21068
21113
  const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
21069
21114
  if (envelope.source === "dispatch") {
@@ -21108,11 +21153,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
21108
21153
  }
21109
21154
  const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
21110
21155
  const commentPayload = comment?.success === true ? comment.data : undefined;
21111
- const compact = dispatchCompact(frame.event, commentPayload);
21156
+ const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
21157
+ const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
21158
+ payloadSessions = commentPayload?.ask_sessions ?? [];
21112
21159
  if (frame.event.type.startsWith("ask.")) {
21113
21160
  const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
21114
21161
  if (asked.success && asked.data.author.kind === "session") {
21115
- askAuthor = asked.data.author.id;
21162
+ payloadSessions = [asked.data.author.id];
21116
21163
  }
21117
21164
  }
21118
21165
  if (inReplyTo !== undefined) {
@@ -21160,6 +21207,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
21160
21207
  };
21161
21208
  }
21162
21209
  }
21210
+ const mentioned = delivery !== undefined;
21211
+ const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
21212
+ if (ownsAsk === false && !mentioned)
21213
+ dispatchReply = undefined;
21163
21214
  const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
21164
21215
  ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
21165
21216
  ...compact.record
@@ -21168,6 +21219,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
21168
21219
  owner: dispatchOwner(frame.event, topic),
21169
21220
  type: frame.event.type,
21170
21221
  actor: frame.event.actor,
21222
+ ...relation === undefined ? {} : { relation },
21171
21223
  ...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
21172
21224
  };
21173
21225
  dispatchActor = frame.event.actor;
@@ -21201,7 +21253,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
21201
21253
  let foreignSession;
21202
21254
  for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
21203
21255
  for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
21204
- if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0] !== askAuthor) {
21256
+ if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
21205
21257
  foreignSession = match[0];
21206
21258
  break;
21207
21259
  }
@@ -25685,25 +25737,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
25685
25737
  var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
25686
25738
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
25687
25739
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
25688
- var RELATION_PHRASES = {
25689
- answered_your_ask: "answered your ask",
25690
- declined_your_ask: "declined to answer your ask",
25691
- replied_on_your_ask: "replied on your ask",
25692
- replied_in_a_comment_thread: "replied in a comment thread",
25693
- commented_on_a_document: "commented on a document",
25694
- commented_on_an_issue: "commented on an issue",
25695
- mentioned_you: "mentioned you",
25696
- sent_you_a_message: "sent you a message",
25697
- replied_to_your_message: "replied to your message"
25698
- };
25699
- function isSessionAnswerRelation(value) {
25700
- return Object.hasOwn(RELATION_PHRASES, value);
25701
- }
25702
25740
  function isNoAnswersRoute(error) {
25703
25741
  return isNoRoute(error) || error instanceof DispatchNoRouteError;
25704
25742
  }
25705
25743
  function renderSessionAnswerItem(item) {
25706
- const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
25744
+ const phrase = sessionAnswerRelationPhrase(item.relation);
25707
25745
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
25708
25746
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
25709
25747
  if (item.edited_at !== undefined)
@@ -25744,7 +25782,8 @@ function sessionAnswersWords(items) {
25744
25782
  item.at,
25745
25783
  item.edited_at ?? null,
25746
25784
  item.selected ?? null,
25747
- item.text
25785
+ item.text,
25786
+ item.relation
25748
25787
  ]));
25749
25788
  }
25750
25789
  var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
@@ -37895,6 +37895,7 @@ var commentEventPayloadFields = {
37895
37895
  ask_question: string2().optional(),
37896
37896
  ask_state: askFields.state.optional(),
37897
37897
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
37898
+ ask_sessions: array(string2()).optional(),
37898
37899
  ...referenceChangesFields,
37899
37900
  ...threadLoginsFields,
37900
37901
  ...carriedBodyFields
@@ -37902,6 +37903,7 @@ var commentEventPayloadFields = {
37902
37903
  var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
37903
37904
  var CommentEventPayloadSchema = object({
37904
37905
  id: commentFields.id.optional(),
37906
+ artifact_id: commentFields.artifact_id,
37905
37907
  artifact_name: commentEventPayloadFields.artifact_name.optional(),
37906
37908
  project_key: commentEventPayloadFields.project_key,
37907
37909
  artifact_slug: commentEventPayloadFields.artifact_slug,
@@ -37911,6 +37913,7 @@ var CommentEventPayloadSchema = object({
37911
37913
  ask_question: commentEventPayloadFields.ask_question,
37912
37914
  ask_state: commentEventPayloadFields.ask_state,
37913
37915
  ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
37916
+ ask_sessions: commentEventPayloadFields.ask_sessions,
37914
37917
  turn: commentFields.turn.optional(),
37915
37918
  anchor: object({
37916
37919
  artifact_id: anchorFields.artifact_id.optional(),
@@ -46354,6 +46357,27 @@ ${body}${fence}${note ? `
46354
46357
  ${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
46355
46358
  }
46356
46359
 
46360
+ // ../envoy-client/src/session-answer-relations.ts
46361
+ var RELATION_PHRASES = {
46362
+ answered_your_ask: "answered your ask",
46363
+ answered_an_ask: "answered an ask",
46364
+ declined_your_ask: "declined to answer your ask",
46365
+ declined_an_ask: "declined to answer an ask",
46366
+ replied_on_your_ask: "replied on your ask",
46367
+ replied_in_a_comment_thread: "replied in a comment thread",
46368
+ commented_on_a_document: "commented on a document",
46369
+ commented_on_an_issue: "commented on an issue",
46370
+ mentioned_you: "mentioned you",
46371
+ sent_you_a_message: "sent you a message",
46372
+ replied_to_your_message: "replied to your message"
46373
+ };
46374
+ function isSessionAnswerRelation(value) {
46375
+ return Object.hasOwn(RELATION_PHRASES, value);
46376
+ }
46377
+ function sessionAnswerRelationPhrase(relation) {
46378
+ return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
46379
+ }
46380
+
46357
46381
  // ../envoy-client/src/delivery.ts
46358
46382
  var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
46359
46383
  var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
@@ -46560,8 +46584,11 @@ function carriedItem(event) {
46560
46584
  return;
46561
46585
  return { resource, id, issueKey: event.issue_key };
46562
46586
  }
46587
+ function payloadWasOmitted(payload) {
46588
+ return isObject3(payload) && payload["payload_omitted"] === true;
46589
+ }
46563
46590
  function bodyWasCut(payload) {
46564
- return isObject3(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
46591
+ return isObject3(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
46565
46592
  }
46566
46593
  function wholeItemRoute(item) {
46567
46594
  return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
@@ -46569,7 +46596,7 @@ function wholeItemRoute(item) {
46569
46596
  function carriedBodyNote(event) {
46570
46597
  if (!bodyWasCut(event.payload))
46571
46598
  return;
46572
- const what = isObject3(event.payload) && event.payload["payload_omitted"] === true ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
46599
+ const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
46573
46600
  const item = carriedItem(event);
46574
46601
  return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
46575
46602
  }
@@ -46672,6 +46699,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
46672
46699
  })
46673
46700
  };
46674
46701
  }
46702
+ function ownsRepliedAsk(comment, sessionID) {
46703
+ if (comment?.ask_id === undefined || comment.ask_id === null)
46704
+ return;
46705
+ return comment.ask_sessions?.includes(sessionID);
46706
+ }
46707
+ function repliedAskRelation(event, comment, owns, mentioned) {
46708
+ if (owns)
46709
+ return "replied_on_your_ask";
46710
+ if (mentioned)
46711
+ return "mentioned_you";
46712
+ if (comment.reply_to !== undefined && comment.reply_to !== null) {
46713
+ return "replied_in_a_comment_thread";
46714
+ }
46715
+ if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
46716
+ return "commented_on_a_document";
46717
+ }
46718
+ return "commented_on_an_issue";
46719
+ }
46675
46720
  function askResolutionText(resolution) {
46676
46721
  if (resolution === null || resolution === undefined)
46677
46722
  return;
@@ -46681,7 +46726,7 @@ function askResolutionText(resolution) {
46681
46726
  const words = dispatchWordsText(resolution.dispatch_words);
46682
46727
  return words === undefined ? closed : `${closed} \xB7 ${words}`;
46683
46728
  }
46684
- function dispatchCompact(event, comment) {
46729
+ function dispatchCompact(event, comment, ownsAsk) {
46685
46730
  if (event.type === "artifact.human_edited") {
46686
46731
  const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
46687
46732
  if (!edit.success)
@@ -46698,7 +46743,7 @@ function dispatchCompact(event, comment) {
46698
46743
  ...question === undefined ? {} : { question },
46699
46744
  reply: comment.body ?? "",
46700
46745
  ...comment.ask_state === undefined ? {} : { state: comment.ask_state },
46701
- ...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
46746
+ ...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
46702
46747
  }
46703
46748
  };
46704
46749
  }
@@ -46905,7 +46950,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
46905
46950
  let bodyNote;
46906
46951
  let cutItem;
46907
46952
  let inReplyTo = envelope.in_reply_to;
46908
- let askAuthor;
46953
+ let payloadSessions = [];
46909
46954
  let trailer = "";
46910
46955
  const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
46911
46956
  if (envelope.source === "dispatch") {
@@ -46950,11 +46995,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
46950
46995
  }
46951
46996
  const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
46952
46997
  const commentPayload = comment?.success === true ? comment.data : undefined;
46953
- const compact = dispatchCompact(frame.event, commentPayload);
46998
+ const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
46999
+ const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
47000
+ payloadSessions = commentPayload?.ask_sessions ?? [];
46954
47001
  if (frame.event.type.startsWith("ask.")) {
46955
47002
  const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
46956
47003
  if (asked.success && asked.data.author.kind === "session") {
46957
- askAuthor = asked.data.author.id;
47004
+ payloadSessions = [asked.data.author.id];
46958
47005
  }
46959
47006
  }
46960
47007
  if (inReplyTo !== undefined) {
@@ -47002,6 +47049,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
47002
47049
  };
47003
47050
  }
47004
47051
  }
47052
+ const mentioned = delivery !== undefined;
47053
+ const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
47054
+ if (ownsAsk === false && !mentioned)
47055
+ dispatchReply = undefined;
47005
47056
  const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
47006
47057
  ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
47007
47058
  ...compact.record
@@ -47010,6 +47061,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
47010
47061
  owner: dispatchOwner(frame.event, topic),
47011
47062
  type: frame.event.type,
47012
47063
  actor: frame.event.actor,
47064
+ ...relation === undefined ? {} : { relation },
47013
47065
  ...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
47014
47066
  };
47015
47067
  dispatchActor = frame.event.actor;
@@ -47043,7 +47095,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
47043
47095
  let foreignSession;
47044
47096
  for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
47045
47097
  for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
47046
- if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0] !== askAuthor) {
47098
+ if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
47047
47099
  foreignSession = match[0];
47048
47100
  break;
47049
47101
  }
@@ -51587,25 +51639,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
51587
51639
  var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
51588
51640
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
51589
51641
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
51590
- var RELATION_PHRASES = {
51591
- answered_your_ask: "answered your ask",
51592
- declined_your_ask: "declined to answer your ask",
51593
- replied_on_your_ask: "replied on your ask",
51594
- replied_in_a_comment_thread: "replied in a comment thread",
51595
- commented_on_a_document: "commented on a document",
51596
- commented_on_an_issue: "commented on an issue",
51597
- mentioned_you: "mentioned you",
51598
- sent_you_a_message: "sent you a message",
51599
- replied_to_your_message: "replied to your message"
51600
- };
51601
- function isSessionAnswerRelation(value) {
51602
- return Object.hasOwn(RELATION_PHRASES, value);
51603
- }
51604
51642
  function isNoAnswersRoute(error) {
51605
51643
  return isNoRoute(error) || error instanceof DispatchNoRouteError;
51606
51644
  }
51607
51645
  function renderSessionAnswerItem(item) {
51608
- const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
51646
+ const phrase = sessionAnswerRelationPhrase(item.relation);
51609
51647
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
51610
51648
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
51611
51649
  if (item.edited_at !== undefined)
@@ -51646,7 +51684,8 @@ function sessionAnswersWords(items) {
51646
51684
  item.at,
51647
51685
  item.edited_at ?? null,
51648
51686
  item.selected ?? null,
51649
- item.text
51687
+ item.text,
51688
+ item.relation
51650
51689
  ]));
51651
51690
  }
51652
51691
  var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
@@ -57829,7 +57868,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
57829
57868
 
57830
57869
  // package.json
57831
57870
  var name2 = "@sjawhar/claude-envoy";
57832
- var version2 = "4.4.0";
57871
+ var version2 = "4.5.1";
57833
57872
  var legion = {
57834
57873
  daemonApiVersion: 152
57835
57874
  };
@@ -58067,25 +58106,29 @@ class AgentStreamPublisher {
58067
58106
  this.#fitCommands(subject);
58068
58107
  }
58069
58108
  setContext(subject, usage) {
58070
- if (usage === undefined)
58071
- return;
58072
- if (!(usage.contextWindow > 0))
58073
- return;
58074
- if (typeof usage.percent !== "number" && !(usage.tokens > 0))
58075
- return;
58076
- const kept = {
58077
- contextWindow: usage.contextWindow,
58078
- tokens: usage.tokens
58079
- };
58080
- const json = JSON.stringify(kept);
58081
- if (json === this.#contextJson)
58082
- return;
58083
- this.#context = kept;
58084
- this.#contextJson = json;
58109
+ if (usage === undefined || !(usage.contextWindow > 0)) {
58110
+ if (this.#context === "cleared")
58111
+ return;
58112
+ this.#context = "cleared";
58113
+ this.#contextJson = undefined;
58114
+ } else {
58115
+ if (typeof usage.percent !== "number" && !(usage.tokens > 0))
58116
+ return;
58117
+ const kept = {
58118
+ contextWindow: usage.contextWindow,
58119
+ tokens: usage.tokens
58120
+ };
58121
+ const json = JSON.stringify(kept);
58122
+ if (json === this.#contextJson)
58123
+ return;
58124
+ this.#context = kept;
58125
+ this.#contextJson = json;
58126
+ }
58085
58127
  this.#seq += 1;
58086
58128
  this.#contextSeq = this.#seq;
58087
- if (this.watched)
58088
- this.#deps.publish(subject, JSON.stringify(this.#contextFrame(kept)));
58129
+ if (this.watched) {
58130
+ this.#deps.publish(subject, JSON.stringify(this.#contextFrame(this.#context)));
58131
+ }
58089
58132
  this.#fitCommands(subject);
58090
58133
  }
58091
58134
  #fitCommands(subject) {
@@ -58126,6 +58169,9 @@ class AgentStreamPublisher {
58126
58169
  return { ...settings, kind: "settings", seq: this.#settingsSeq, v: AGENT_STREAM_PROTOCOL };
58127
58170
  }
58128
58171
  #contextFrame(context) {
58172
+ if (context === "cleared") {
58173
+ return { kind: "context-cleared", seq: this.#contextSeq, v: AGENT_STREAM_PROTOCOL };
58174
+ }
58129
58175
  return { ...context, kind: "context", seq: this.#contextSeq, v: AGENT_STREAM_PROTOCOL };
58130
58176
  }
58131
58177
  record(subject, raw, streaming, dispatchMessageId) {
@@ -15240,6 +15240,7 @@ var commentEventPayloadFields = {
15240
15240
  ask_question: string2().optional(),
15241
15241
  ask_state: askFields.state.optional(),
15242
15242
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
15243
+ ask_sessions: array(string2()).optional(),
15243
15244
  ...referenceChangesFields,
15244
15245
  ...threadLoginsFields,
15245
15246
  ...carriedBodyFields
@@ -15247,6 +15248,7 @@ var commentEventPayloadFields = {
15247
15248
  var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
15248
15249
  var CommentEventPayloadSchema = object({
15249
15250
  id: commentFields.id.optional(),
15251
+ artifact_id: commentFields.artifact_id,
15250
15252
  artifact_name: commentEventPayloadFields.artifact_name.optional(),
15251
15253
  project_key: commentEventPayloadFields.project_key,
15252
15254
  artifact_slug: commentEventPayloadFields.artifact_slug,
@@ -15256,6 +15258,7 @@ var CommentEventPayloadSchema = object({
15256
15258
  ask_question: commentEventPayloadFields.ask_question,
15257
15259
  ask_state: commentEventPayloadFields.ask_state,
15258
15260
  ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
15261
+ ask_sessions: commentEventPayloadFields.ask_sessions,
15259
15262
  turn: commentFields.turn.optional(),
15260
15263
  anchor: object({
15261
15264
  artifact_id: anchorFields.artifact_id.optional(),
@@ -19388,6 +19391,27 @@ ${body}${fence}${note ? `
19388
19391
  ${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
19389
19392
  }
19390
19393
 
19394
+ // ../envoy-client/src/session-answer-relations.ts
19395
+ var RELATION_PHRASES = {
19396
+ answered_your_ask: "answered your ask",
19397
+ answered_an_ask: "answered an ask",
19398
+ declined_your_ask: "declined to answer your ask",
19399
+ declined_an_ask: "declined to answer an ask",
19400
+ replied_on_your_ask: "replied on your ask",
19401
+ replied_in_a_comment_thread: "replied in a comment thread",
19402
+ commented_on_a_document: "commented on a document",
19403
+ commented_on_an_issue: "commented on an issue",
19404
+ mentioned_you: "mentioned you",
19405
+ sent_you_a_message: "sent you a message",
19406
+ replied_to_your_message: "replied to your message"
19407
+ };
19408
+ function isSessionAnswerRelation(value) {
19409
+ return Object.hasOwn(RELATION_PHRASES, value);
19410
+ }
19411
+ function sessionAnswerRelationPhrase(relation) {
19412
+ return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
19413
+ }
19414
+
19391
19415
  // ../envoy-client/src/delivery.ts
19392
19416
  var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
19393
19417
  var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
@@ -19594,8 +19618,11 @@ function carriedItem(event) {
19594
19618
  return;
19595
19619
  return { resource, id, issueKey: event.issue_key };
19596
19620
  }
19621
+ function payloadWasOmitted(payload) {
19622
+ return isObject2(payload) && payload["payload_omitted"] === true;
19623
+ }
19597
19624
  function bodyWasCut(payload) {
19598
- return isObject2(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
19625
+ return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
19599
19626
  }
19600
19627
  function wholeItemRoute(item) {
19601
19628
  return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
@@ -19603,7 +19630,7 @@ function wholeItemRoute(item) {
19603
19630
  function carriedBodyNote(event) {
19604
19631
  if (!bodyWasCut(event.payload))
19605
19632
  return;
19606
- const what = isObject2(event.payload) && event.payload["payload_omitted"] === true ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
19633
+ const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
19607
19634
  const item = carriedItem(event);
19608
19635
  return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
19609
19636
  }
@@ -19706,6 +19733,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
19706
19733
  })
19707
19734
  };
19708
19735
  }
19736
+ function ownsRepliedAsk(comment, sessionID) {
19737
+ if (comment?.ask_id === undefined || comment.ask_id === null)
19738
+ return;
19739
+ return comment.ask_sessions?.includes(sessionID);
19740
+ }
19741
+ function repliedAskRelation(event, comment, owns, mentioned) {
19742
+ if (owns)
19743
+ return "replied_on_your_ask";
19744
+ if (mentioned)
19745
+ return "mentioned_you";
19746
+ if (comment.reply_to !== undefined && comment.reply_to !== null) {
19747
+ return "replied_in_a_comment_thread";
19748
+ }
19749
+ if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
19750
+ return "commented_on_a_document";
19751
+ }
19752
+ return "commented_on_an_issue";
19753
+ }
19709
19754
  function askResolutionText(resolution) {
19710
19755
  if (resolution === null || resolution === undefined)
19711
19756
  return;
@@ -19715,7 +19760,7 @@ function askResolutionText(resolution) {
19715
19760
  const words = dispatchWordsText(resolution.dispatch_words);
19716
19761
  return words === undefined ? closed : `${closed} \xB7 ${words}`;
19717
19762
  }
19718
- function dispatchCompact(event, comment) {
19763
+ function dispatchCompact(event, comment, ownsAsk) {
19719
19764
  if (event.type === "artifact.human_edited") {
19720
19765
  const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
19721
19766
  if (!edit.success)
@@ -19732,7 +19777,7 @@ function dispatchCompact(event, comment) {
19732
19777
  ...question === undefined ? {} : { question },
19733
19778
  reply: comment.body ?? "",
19734
19779
  ...comment.ask_state === undefined ? {} : { state: comment.ask_state },
19735
- ...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
19780
+ ...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
19736
19781
  }
19737
19782
  };
19738
19783
  }
@@ -19939,7 +19984,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
19939
19984
  let bodyNote;
19940
19985
  let cutItem;
19941
19986
  let inReplyTo = envelope.in_reply_to;
19942
- let askAuthor;
19987
+ let payloadSessions = [];
19943
19988
  let trailer = "";
19944
19989
  const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
19945
19990
  if (envelope.source === "dispatch") {
@@ -19984,11 +20029,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
19984
20029
  }
19985
20030
  const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
19986
20031
  const commentPayload = comment?.success === true ? comment.data : undefined;
19987
- const compact = dispatchCompact(frame.event, commentPayload);
20032
+ const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
20033
+ const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
20034
+ payloadSessions = commentPayload?.ask_sessions ?? [];
19988
20035
  if (frame.event.type.startsWith("ask.")) {
19989
20036
  const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
19990
20037
  if (asked.success && asked.data.author.kind === "session") {
19991
- askAuthor = asked.data.author.id;
20038
+ payloadSessions = [asked.data.author.id];
19992
20039
  }
19993
20040
  }
19994
20041
  if (inReplyTo !== undefined) {
@@ -20036,6 +20083,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20036
20083
  };
20037
20084
  }
20038
20085
  }
20086
+ const mentioned = delivery !== undefined;
20087
+ const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
20088
+ if (ownsAsk === false && !mentioned)
20089
+ dispatchReply = undefined;
20039
20090
  const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
20040
20091
  ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
20041
20092
  ...compact.record
@@ -20044,6 +20095,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20044
20095
  owner: dispatchOwner(frame.event, topic),
20045
20096
  type: frame.event.type,
20046
20097
  actor: frame.event.actor,
20098
+ ...relation === undefined ? {} : { relation },
20047
20099
  ...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
20048
20100
  };
20049
20101
  dispatchActor = frame.event.actor;
@@ -20077,7 +20129,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
20077
20129
  let foreignSession;
20078
20130
  for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
20079
20131
  for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
20080
- if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0] !== askAuthor) {
20132
+ if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
20081
20133
  foreignSession = match[0];
20082
20134
  break;
20083
20135
  }
@@ -24653,25 +24705,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
24653
24705
  var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
24654
24706
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
24655
24707
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
24656
- var RELATION_PHRASES = {
24657
- answered_your_ask: "answered your ask",
24658
- declined_your_ask: "declined to answer your ask",
24659
- replied_on_your_ask: "replied on your ask",
24660
- replied_in_a_comment_thread: "replied in a comment thread",
24661
- commented_on_a_document: "commented on a document",
24662
- commented_on_an_issue: "commented on an issue",
24663
- mentioned_you: "mentioned you",
24664
- sent_you_a_message: "sent you a message",
24665
- replied_to_your_message: "replied to your message"
24666
- };
24667
- function isSessionAnswerRelation(value) {
24668
- return Object.hasOwn(RELATION_PHRASES, value);
24669
- }
24670
24708
  function isNoAnswersRoute(error) {
24671
24709
  return isNoRoute(error) || error instanceof DispatchNoRouteError;
24672
24710
  }
24673
24711
  function renderSessionAnswerItem(item) {
24674
- const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
24712
+ const phrase = sessionAnswerRelationPhrase(item.relation);
24675
24713
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
24676
24714
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
24677
24715
  if (item.edited_at !== undefined)
@@ -24712,7 +24750,8 @@ function sessionAnswersWords(items) {
24712
24750
  item.at,
24713
24751
  item.edited_at ?? null,
24714
24752
  item.selected ?? null,
24715
- item.text
24753
+ item.text,
24754
+ item.relation
24716
24755
  ]));
24717
24756
  }
24718
24757
  var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",