@sjawhar/claude-envoy 1.37.0 → 1.39.0

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": "1.37.0"
5
+ "version": "1.39.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
package/dist/dispatch.js CHANGED
@@ -14738,8 +14738,9 @@ var askEventPayloadFields = {
14738
14738
  primary: boolean2().optional()
14739
14739
  }).optional(),
14740
14740
  resolution: object({
14741
- kind: _enum2(["retracted", "resolved", "withdrawn"]).optional(),
14741
+ kind: string2().optional(),
14742
14742
  reason: string2().optional(),
14743
+ dispatch_words: string2().optional(),
14743
14744
  actor: object({ kind: string2().optional(), id: string2().optional() }).passthrough().optional(),
14744
14745
  at: string2().optional()
14745
14746
  }).nullish(),
@@ -15431,7 +15432,7 @@ var dispatchToolSpecs = [
15431
15432
  kind: "retracted",
15432
15433
  reason: "A newer question supersedes this one."
15433
15434
  },
15434
- description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
15435
+ description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "a person who chose not to answer declined the ask on a route of their own (kind declined, " + "which only they write, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
15435
15436
  arguments: (z) => ({
15436
15437
  ask: z.string().describe("Ask id (uuid) to close; an 8+ hex prefix unique among this session's own open asks " + "works too."),
15437
15438
  kind: z.enum(["retracted", "resolved"]).describe("Whether the ask is retracted or self-resolved."),
@@ -17607,6 +17608,13 @@ function textHead(text, length = HEAD_LENGTH) {
17607
17608
  const flat = text.replace(/\s+/g, " ").trim();
17608
17609
  return flat.length > length ? `${flat.slice(0, length)}\u2026` : flat;
17609
17610
  }
17611
+ var QUESTION_HEAD = 200;
17612
+ var DISPATCH_WORDS_LABEL = "Dispatch's words:";
17613
+ function dispatchWordsText(words, render) {
17614
+ if (words === null || words === undefined || words === "")
17615
+ return;
17616
+ return `${DISPATCH_WORDS_LABEL} ${render === undefined ? words : render(words)}`;
17617
+ }
17610
17618
  function askAnswerText(answer) {
17611
17619
  if (answer === null || answer === undefined)
17612
17620
  return "";
@@ -19799,7 +19807,9 @@ function askResolutionText(resolution) {
19799
19807
  return;
19800
19808
  const kind = resolution.kind ?? "resolved";
19801
19809
  const reason = resolution.reason ?? "";
19802
- return reason === "" ? kind : `${kind}: ${reason}`;
19810
+ const closed = reason === "" ? kind : `${kind}: ${reason}`;
19811
+ const words = dispatchWordsText(resolution.dispatch_words);
19812
+ return words === undefined ? closed : `${closed} \xB7 ${words}`;
19803
19813
  }
19804
19814
  function dispatchCompact(event, comment) {
19805
19815
  if (event.type === "artifact.human_edited") {
@@ -20563,7 +20573,14 @@ function answerLines(lead, answer) {
20563
20573
  ];
20564
20574
  }
20565
20575
  function resolutionText(resolution) {
20566
- return `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}: ${indentedText(resolution.reason)}`;
20576
+ const closed = `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}`;
20577
+ const parts = [
20578
+ resolution.reason === "" ? closed : `${closed}: ${indentedText(resolution.reason)}`
20579
+ ];
20580
+ const words = dispatchWordsText(resolution.dispatch_words, indentedText);
20581
+ if (words !== undefined)
20582
+ parts.push(words);
20583
+ return parts.join(" \xB7 ");
20567
20584
  }
20568
20585
  function askStateLines(ask) {
20569
20586
  if (ask === undefined) {
@@ -20709,6 +20726,26 @@ function decisionBlockLines(advice, context) {
20709
20726
  ];
20710
20727
  }
20711
20728
  }
20729
+ function declinedAskLines(advice, issueKey, configUrl) {
20730
+ try {
20731
+ const declined = advice?.declined_asks;
20732
+ if (declined === undefined || declined === null || declined.length === 0)
20733
+ return [];
20734
+ const count = declined.length;
20735
+ const lines = [
20736
+ count === 1 ? "This issue holds a question a person declined to answer. Ask it again only if the facts have changed:" : `This issue holds ${count} questions a person declined to answer. Ask one again only if the facts have changed:`
20737
+ ];
20738
+ for (const ask of declined) {
20739
+ const href = absoluteHref(`/issues/${encodeURIComponent(issueKey)}/asks/${encodeURIComponent(ask.id)}`, configUrl);
20740
+ lines.push(`- Declined: ${ask.question} \u2192 ${href}`);
20741
+ if (ask.note !== "")
20742
+ lines.push(` Their note: ${ask.note}`);
20743
+ }
20744
+ return lines;
20745
+ } catch (error) {
20746
+ return [`The issue's declined asks could not be shown: ${messageFor(error)}`];
20747
+ }
20748
+ }
20712
20749
  function relatedCheckForm(suggestions, context) {
20713
20750
  const form = relatedCheckFormOf(suggestions);
20714
20751
  if (form.form === "not_made") {
@@ -20803,12 +20840,12 @@ var SESSION_ANSWERS_MAX_CHARS = 8000;
20803
20840
  var SESSION_ANSWERS_DEADLINE_MS = 800;
20804
20841
  var READ_TIMEOUT_MS = 1e4;
20805
20842
  var NO_ROUTE_BACKOFF_MS = 5 * 60000;
20806
- var QUESTION_MAX = 200;
20807
20843
  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.]";
20808
20844
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
20809
20845
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
20810
20846
  var RELATION_PHRASES = {
20811
20847
  answered_your_ask: "answered your ask",
20848
+ declined_your_ask: "declined to answer your ask",
20812
20849
  replied_on_your_ask: "replied on your ask",
20813
20850
  replied_in_a_comment_thread: "replied in a comment thread",
20814
20851
  commented_on_a_document: "commented on a document",
@@ -20833,13 +20870,15 @@ function renderSessionAnswerItem(item) {
20833
20870
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
20834
20871
  const lines = [head.join(" \xB7 "), where];
20835
20872
  if (item.ask !== undefined) {
20836
- const question = item.ask.question.replace(/\s+/g, " ").trim();
20837
- lines.push(`Question: ${question.length > QUESTION_MAX ? `${question.slice(0, QUESTION_MAX)}\u2026` : question}`);
20873
+ lines.push(`Question: ${textHead(item.ask.question, QUESTION_HEAD)}`);
20838
20874
  }
20839
20875
  if (item.kind === "answer") {
20840
20876
  const selected = item.selected ?? [];
20841
20877
  lines.push(`Selected: ${selected.length === 0 ? "none" : selected.join(", ")}`);
20842
20878
  }
20879
+ const words = dispatchWordsText(item.dispatch_words);
20880
+ if (words !== undefined)
20881
+ lines.push(words);
20843
20882
  if (item.text !== "")
20844
20883
  lines.push(item.text);
20845
20884
  return lines.join(`
@@ -21283,7 +21322,16 @@ function renderAdvice(tool, key, advice, opts) {
21283
21322
  }
21284
21323
  const superseded = advice.superseded_approval;
21285
21324
  if (superseded !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
21286
- lines.push(`Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since: a Legion design gate on this document is closed meanwhile, so every READY in its tree is refused. Meant to change the approved design? Request approval with \`dispatch request-approval\`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.`);
21325
+ const gates = Array.isArray(superseded.design_gates) ? superseded.design_gates : [];
21326
+ const parts = [
21327
+ `Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since.`
21328
+ ];
21329
+ if (gates.length > 0) {
21330
+ const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
21331
+ parts.push(`A Legion design gate records this document, so every READY in ${gates.length === 1 ? "its" : "each"} tree is refused until that approval comes back: ${named}.`);
21332
+ }
21333
+ parts.push("Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.");
21334
+ lines.push(parts.join(" "));
21287
21335
  }
21288
21336
  if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
21289
21337
  const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
@@ -22648,6 +22696,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
22648
22696
  `${reply.id} \xB7 ${actorText(reply.author)}`,
22649
22697
  `Body: ${reply.body}`
22650
22698
  ]);
22699
+ const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
22651
22700
  return [
22652
22701
  `Question: ${ask.question}`,
22653
22702
  ...anchorLines(ask),
@@ -22674,7 +22723,8 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
22674
22723
  "Resolution:",
22675
22724
  `- By: ${ask.resolution.actor.id}`,
22676
22725
  `- Kind: ${ask.resolution.kind}`,
22677
- `- Reason: ${ask.resolution.reason}`
22726
+ ...ask.resolution.reason === "" ? [] : [`- Reason: ${ask.resolution.reason}`],
22727
+ ...resolutionWords === undefined ? [] : [`- ${resolutionWords}`]
22678
22728
  ],
22679
22729
  "Replies:",
22680
22730
  ...chain.length === 0 ? ["- none"] : chain,
@@ -23818,16 +23868,19 @@ async function executeDispatchTool(input) {
23818
23868
  };
23819
23869
  const ask = resolved?.owner.kind === "project" ? await client.artifactAsk(resolved.artifact.id, askInput) : await client.ask(issue(), askInput);
23820
23870
  const askOwner = ask.issue_key !== null ? issueTopic(ask.issue_key) : resolved === undefined ? issueTopic(issue()) : documentTopic(resolved.artifact);
23821
- const checkLines = relatedCheckLines(ask.advice?.suggestions, {
23871
+ const checkContext = {
23822
23872
  project: resolved?.artifact.project ?? (ask.issue_key ?? "").replace(/-[0-9]+$/, ""),
23823
23873
  text: stringArg(args, "question"),
23824
23874
  configUrl: linkBase
23825
- });
23875
+ };
23876
+ const checkLines = relatedCheckLines(ask.advice?.suggestions, checkContext);
23877
+ const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
23826
23878
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
23827
23879
  return {
23828
23880
  text: [
23829
23881
  `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}`,
23830
23882
  ...checkLines,
23883
+ ...declinedLines,
23831
23884
  await followsAsk(askOwner, input.subscriptions),
23832
23885
  ...adviceLines
23833
23886
  ].join(`
@@ -24044,17 +24097,20 @@ async function executeDispatchTool(input) {
24044
24097
  const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded or holds a tree too deep to read \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
24045
24098
  const applied = `${head}${unchangedText}${lostText}`;
24046
24099
  const editAskText = ops.map((operation) => /^:{3,}ask\{.*\n([\s\S]*)/mu.exec(operation.markdown ?? operation.with ?? "")?.[1]).find((text) => text !== undefined) ?? resolved.issue?.title ?? "";
24047
- const checkLines = decisionBlockLines(edited.advice, {
24100
+ const checkContext = {
24048
24101
  project: resolved.artifact.project,
24049
24102
  text: editAskText,
24050
24103
  configUrl: linkBase
24051
- });
24104
+ };
24105
+ const checkLines = decisionBlockLines(edited.advice, checkContext);
24106
+ const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
24052
24107
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {}));
24053
24108
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
24054
24109
  return {
24055
24110
  text: [
24056
24111
  `${applied}${await notSubscribed(resolvedTopic(resolved), input.subscriptions)}`,
24057
24112
  ...checkLines,
24113
+ ...declinedLines,
24058
24114
  ...tokenTrailer,
24059
24115
  ...adviceLines
24060
24116
  ].join(`
@@ -36387,8 +36387,9 @@ var askEventPayloadFields = {
36387
36387
  primary: boolean2().optional()
36388
36388
  }).optional(),
36389
36389
  resolution: object({
36390
- kind: _enum2(["retracted", "resolved", "withdrawn"]).optional(),
36390
+ kind: string2().optional(),
36391
36391
  reason: string2().optional(),
36392
+ dispatch_words: string2().optional(),
36392
36393
  actor: object({ kind: string2().optional(), id: string2().optional() }).passthrough().optional(),
36393
36394
  at: string2().optional()
36394
36395
  }).nullish(),
@@ -37080,7 +37081,7 @@ var dispatchToolSpecs = [
37080
37081
  kind: "retracted",
37081
37082
  reason: "A newer question supersedes this one."
37082
37083
  },
37083
- description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
37084
+ description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "a person who chose not to answer declined the ask on a route of their own (kind declined, " + "which only they write, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
37084
37085
  arguments: (z) => ({
37085
37086
  ask: z.string().describe("Ask id (uuid) to close; an 8+ hex prefix unique among this session's own open asks " + "works too."),
37086
37087
  kind: z.enum(["retracted", "resolved"]).describe("Whether the ask is retracted or self-resolved."),
@@ -41682,6 +41683,13 @@ function textHead(text, length = HEAD_LENGTH) {
41682
41683
  const flat = text.replace(/\s+/g, " ").trim();
41683
41684
  return flat.length > length ? `${flat.slice(0, length)}\u2026` : flat;
41684
41685
  }
41686
+ var QUESTION_HEAD = 200;
41687
+ var DISPATCH_WORDS_LABEL = "Dispatch's words:";
41688
+ function dispatchWordsText(words, render) {
41689
+ if (words === null || words === undefined || words === "")
41690
+ return;
41691
+ return `${DISPATCH_WORDS_LABEL} ${render === undefined ? words : render(words)}`;
41692
+ }
41685
41693
  function askAnswerText(answer) {
41686
41694
  if (answer === null || answer === undefined)
41687
41695
  return "";
@@ -43752,7 +43760,9 @@ function askResolutionText(resolution) {
43752
43760
  return;
43753
43761
  const kind = resolution.kind ?? "resolved";
43754
43762
  const reason = resolution.reason ?? "";
43755
- return reason === "" ? kind : `${kind}: ${reason}`;
43763
+ const closed = reason === "" ? kind : `${kind}: ${reason}`;
43764
+ const words = dispatchWordsText(resolution.dispatch_words);
43765
+ return words === undefined ? closed : `${closed} \xB7 ${words}`;
43756
43766
  }
43757
43767
  function dispatchCompact(event, comment) {
43758
43768
  if (event.type === "artifact.human_edited") {
@@ -47377,7 +47387,14 @@ function answerLines(lead, answer) {
47377
47387
  ];
47378
47388
  }
47379
47389
  function resolutionText(resolution) {
47380
- return `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}: ${indentedText(resolution.reason)}`;
47390
+ const closed = `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}`;
47391
+ const parts = [
47392
+ resolution.reason === "" ? closed : `${closed}: ${indentedText(resolution.reason)}`
47393
+ ];
47394
+ const words = dispatchWordsText(resolution.dispatch_words, indentedText);
47395
+ if (words !== undefined)
47396
+ parts.push(words);
47397
+ return parts.join(" \xB7 ");
47381
47398
  }
47382
47399
  function askStateLines(ask) {
47383
47400
  if (ask === undefined) {
@@ -47523,6 +47540,26 @@ function decisionBlockLines(advice, context) {
47523
47540
  ];
47524
47541
  }
47525
47542
  }
47543
+ function declinedAskLines(advice, issueKey, configUrl) {
47544
+ try {
47545
+ const declined = advice?.declined_asks;
47546
+ if (declined === undefined || declined === null || declined.length === 0)
47547
+ return [];
47548
+ const count = declined.length;
47549
+ const lines = [
47550
+ count === 1 ? "This issue holds a question a person declined to answer. Ask it again only if the facts have changed:" : `This issue holds ${count} questions a person declined to answer. Ask one again only if the facts have changed:`
47551
+ ];
47552
+ for (const ask of declined) {
47553
+ const href = absoluteHref(`/issues/${encodeURIComponent(issueKey)}/asks/${encodeURIComponent(ask.id)}`, configUrl);
47554
+ lines.push(`- Declined: ${ask.question} \u2192 ${href}`);
47555
+ if (ask.note !== "")
47556
+ lines.push(` Their note: ${ask.note}`);
47557
+ }
47558
+ return lines;
47559
+ } catch (error) {
47560
+ return [`The issue's declined asks could not be shown: ${messageFor(error)}`];
47561
+ }
47562
+ }
47526
47563
  function relatedCheckForm(suggestions, context) {
47527
47564
  const form = relatedCheckFormOf(suggestions);
47528
47565
  if (form.form === "not_made") {
@@ -47585,12 +47622,12 @@ var SESSION_ANSWERS_MAX_CHARS = 8000;
47585
47622
  var SESSION_ANSWERS_DEADLINE_MS = 800;
47586
47623
  var READ_TIMEOUT_MS = 1e4;
47587
47624
  var NO_ROUTE_BACKOFF_MS = 5 * 60000;
47588
- var QUESTION_MAX = 200;
47589
47625
  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.]";
47590
47626
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
47591
47627
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
47592
47628
  var RELATION_PHRASES = {
47593
47629
  answered_your_ask: "answered your ask",
47630
+ declined_your_ask: "declined to answer your ask",
47594
47631
  replied_on_your_ask: "replied on your ask",
47595
47632
  replied_in_a_comment_thread: "replied in a comment thread",
47596
47633
  commented_on_a_document: "commented on a document",
@@ -47615,13 +47652,15 @@ function renderSessionAnswerItem(item) {
47615
47652
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
47616
47653
  const lines = [head.join(" \xB7 "), where];
47617
47654
  if (item.ask !== undefined) {
47618
- const question = item.ask.question.replace(/\s+/g, " ").trim();
47619
- lines.push(`Question: ${question.length > QUESTION_MAX ? `${question.slice(0, QUESTION_MAX)}\u2026` : question}`);
47655
+ lines.push(`Question: ${textHead(item.ask.question, QUESTION_HEAD)}`);
47620
47656
  }
47621
47657
  if (item.kind === "answer") {
47622
47658
  const selected = item.selected ?? [];
47623
47659
  lines.push(`Selected: ${selected.length === 0 ? "none" : selected.join(", ")}`);
47624
47660
  }
47661
+ const words = dispatchWordsText(item.dispatch_words);
47662
+ if (words !== undefined)
47663
+ lines.push(words);
47625
47664
  if (item.text !== "")
47626
47665
  lines.push(item.text);
47627
47666
  return lines.join(`
@@ -48065,7 +48104,16 @@ function renderAdvice(tool, key, advice, opts) {
48065
48104
  }
48066
48105
  const superseded = advice.superseded_approval;
48067
48106
  if (superseded !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
48068
- lines.push(`Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since: a Legion design gate on this document is closed meanwhile, so every READY in its tree is refused. Meant to change the approved design? Request approval with \`dispatch request-approval\`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.`);
48107
+ const gates = Array.isArray(superseded.design_gates) ? superseded.design_gates : [];
48108
+ const parts = [
48109
+ `Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since.`
48110
+ ];
48111
+ if (gates.length > 0) {
48112
+ const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
48113
+ parts.push(`A Legion design gate records this document, so every READY in ${gates.length === 1 ? "its" : "each"} tree is refused until that approval comes back: ${named}.`);
48114
+ }
48115
+ parts.push("Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.");
48116
+ lines.push(parts.join(" "));
48069
48117
  }
48070
48118
  if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
48071
48119
  const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
@@ -49430,6 +49478,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
49430
49478
  `${reply.id} \xB7 ${actorText(reply.author)}`,
49431
49479
  `Body: ${reply.body}`
49432
49480
  ]);
49481
+ const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
49433
49482
  return [
49434
49483
  `Question: ${ask.question}`,
49435
49484
  ...anchorLines(ask),
@@ -49456,7 +49505,8 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
49456
49505
  "Resolution:",
49457
49506
  `- By: ${ask.resolution.actor.id}`,
49458
49507
  `- Kind: ${ask.resolution.kind}`,
49459
- `- Reason: ${ask.resolution.reason}`
49508
+ ...ask.resolution.reason === "" ? [] : [`- Reason: ${ask.resolution.reason}`],
49509
+ ...resolutionWords === undefined ? [] : [`- ${resolutionWords}`]
49460
49510
  ],
49461
49511
  "Replies:",
49462
49512
  ...chain.length === 0 ? ["- none"] : chain,
@@ -50600,16 +50650,19 @@ async function executeDispatchTool(input) {
50600
50650
  };
50601
50651
  const ask = resolved?.owner.kind === "project" ? await client.artifactAsk(resolved.artifact.id, askInput) : await client.ask(issue(), askInput);
50602
50652
  const askOwner = ask.issue_key !== null ? issueTopic(ask.issue_key) : resolved === undefined ? issueTopic(issue()) : documentTopic(resolved.artifact);
50603
- const checkLines = relatedCheckLines(ask.advice?.suggestions, {
50653
+ const checkContext = {
50604
50654
  project: resolved?.artifact.project ?? (ask.issue_key ?? "").replace(/-[0-9]+$/, ""),
50605
50655
  text: stringArg(args, "question"),
50606
50656
  configUrl: linkBase
50607
- });
50657
+ };
50658
+ const checkLines = relatedCheckLines(ask.advice?.suggestions, checkContext);
50659
+ const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
50608
50660
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
50609
50661
  return {
50610
50662
  text: [
50611
50663
  `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}`,
50612
50664
  ...checkLines,
50665
+ ...declinedLines,
50613
50666
  await followsAsk(askOwner, input.subscriptions),
50614
50667
  ...adviceLines
50615
50668
  ].join(`
@@ -50826,17 +50879,20 @@ async function executeDispatchTool(input) {
50826
50879
  const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded or holds a tree too deep to read \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
50827
50880
  const applied = `${head}${unchangedText}${lostText}`;
50828
50881
  const editAskText = ops.map((operation) => /^:{3,}ask\{.*\n([\s\S]*)/mu.exec(operation.markdown ?? operation.with ?? "")?.[1]).find((text) => text !== undefined) ?? resolved.issue?.title ?? "";
50829
- const checkLines = decisionBlockLines(edited.advice, {
50882
+ const checkContext = {
50830
50883
  project: resolved.artifact.project,
50831
50884
  text: editAskText,
50832
50885
  configUrl: linkBase
50833
- });
50886
+ };
50887
+ const checkLines = decisionBlockLines(edited.advice, checkContext);
50888
+ const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
50834
50889
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {}));
50835
50890
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
50836
50891
  return {
50837
50892
  text: [
50838
50893
  `${applied}${await notSubscribed(resolvedTopic(resolved), input.subscriptions)}`,
50839
50894
  ...checkLines,
50895
+ ...declinedLines,
50840
50896
  ...tokenTrailer,
50841
50897
  ...adviceLines
50842
50898
  ].join(`
@@ -52350,6 +52406,7 @@ var LEGION_WAIT_ANSWERS = [
52350
52406
  "retracted",
52351
52407
  "closed",
52352
52408
  "reply",
52409
+ "declined",
52353
52410
  "turn",
52354
52411
  "approved",
52355
52412
  "changes_requested",
@@ -55433,9 +55490,9 @@ var import_nats2 = __toESM(require_mod4(), 1);
55433
55490
 
55434
55491
  // package.json
55435
55492
  var name = "@sjawhar/claude-envoy";
55436
- var version2 = "1.37.0";
55493
+ var version2 = "1.39.0";
55437
55494
  var legion = {
55438
- daemonApiVersion: 64
55495
+ daemonApiVersion: 68
55439
55496
  };
55440
55497
 
55441
55498
  // ../pi-shared/src/agent-stream.ts
@@ -13737,8 +13737,9 @@ var askEventPayloadFields = {
13737
13737
  primary: boolean2().optional()
13738
13738
  }).optional(),
13739
13739
  resolution: object({
13740
- kind: _enum2(["retracted", "resolved", "withdrawn"]).optional(),
13740
+ kind: string2().optional(),
13741
13741
  reason: string2().optional(),
13742
+ dispatch_words: string2().optional(),
13742
13743
  actor: object({ kind: string2().optional(), id: string2().optional() }).passthrough().optional(),
13743
13744
  at: string2().optional()
13744
13745
  }).nullish(),
@@ -14430,7 +14431,7 @@ var dispatchToolSpecs = [
14430
14431
  kind: "retracted",
14431
14432
  reason: "A newer question supersedes this one."
14432
14433
  },
14433
- description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
14434
+ description: "Retract an open question that is moot or resolve one after finding the answer. This closes " + "the question without answering it. An ask that lives as an `ask` block in a document is " + 'closed in the document too. A reason beginning "removed from the document in version" is ' + "refused: that marks a retraction the document's own settlement wrote. Use retracted for an ask " + "a newer one replaces or the design made moot, resolved for one whose answer you found; an " + "answered ask cannot be resolved, and resolving records no decision by a person. An issue's " + "close withdrew its open asks (kind withdrawn, which only Dispatch writes, never this tool); " + "a person who chose not to answer declined the ask on a route of their own (kind declined, " + "which only they write, never this tool); " + "an ask on a closed issue is refused (409 ISSUE_CLOSED): reopen the issue first.",
14434
14435
  arguments: (z) => ({
14435
14436
  ask: z.string().describe("Ask id (uuid) to close; an 8+ hex prefix unique among this session's own open asks " + "works too."),
14436
14437
  kind: z.enum(["retracted", "resolved"]).describe("Whether the ask is retracted or self-resolved."),
@@ -16093,6 +16094,13 @@ function textHead(text, length = HEAD_LENGTH) {
16093
16094
  const flat = text.replace(/\s+/g, " ").trim();
16094
16095
  return flat.length > length ? `${flat.slice(0, length)}\u2026` : flat;
16095
16096
  }
16097
+ var QUESTION_HEAD = 200;
16098
+ var DISPATCH_WORDS_LABEL = "Dispatch's words:";
16099
+ function dispatchWordsText(words, render) {
16100
+ if (words === null || words === undefined || words === "")
16101
+ return;
16102
+ return `${DISPATCH_WORDS_LABEL} ${render === undefined ? words : render(words)}`;
16103
+ }
16096
16104
  function askAnswerText(answer) {
16097
16105
  if (answer === null || answer === undefined)
16098
16106
  return "";
@@ -18803,7 +18811,9 @@ function askResolutionText(resolution) {
18803
18811
  return;
18804
18812
  const kind = resolution.kind ?? "resolved";
18805
18813
  const reason = resolution.reason ?? "";
18806
- return reason === "" ? kind : `${kind}: ${reason}`;
18814
+ const closed = reason === "" ? kind : `${kind}: ${reason}`;
18815
+ const words = dispatchWordsText(resolution.dispatch_words);
18816
+ return words === undefined ? closed : `${closed} \xB7 ${words}`;
18807
18817
  }
18808
18818
  function dispatchCompact(event, comment) {
18809
18819
  if (event.type === "artifact.human_edited") {
@@ -19567,7 +19577,14 @@ function answerLines(lead, answer) {
19567
19577
  ];
19568
19578
  }
19569
19579
  function resolutionText(resolution) {
19570
- return `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}: ${indentedText(resolution.reason)}`;
19580
+ const closed = `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}`;
19581
+ const parts = [
19582
+ resolution.reason === "" ? closed : `${closed}: ${indentedText(resolution.reason)}`
19583
+ ];
19584
+ const words = dispatchWordsText(resolution.dispatch_words, indentedText);
19585
+ if (words !== undefined)
19586
+ parts.push(words);
19587
+ return parts.join(" \xB7 ");
19571
19588
  }
19572
19589
  function askStateLines(ask) {
19573
19590
  if (ask === undefined) {
@@ -19713,6 +19730,26 @@ function decisionBlockLines(advice, context) {
19713
19730
  ];
19714
19731
  }
19715
19732
  }
19733
+ function declinedAskLines(advice, issueKey, configUrl) {
19734
+ try {
19735
+ const declined = advice?.declined_asks;
19736
+ if (declined === undefined || declined === null || declined.length === 0)
19737
+ return [];
19738
+ const count = declined.length;
19739
+ const lines = [
19740
+ count === 1 ? "This issue holds a question a person declined to answer. Ask it again only if the facts have changed:" : `This issue holds ${count} questions a person declined to answer. Ask one again only if the facts have changed:`
19741
+ ];
19742
+ for (const ask of declined) {
19743
+ const href = absoluteHref(`/issues/${encodeURIComponent(issueKey)}/asks/${encodeURIComponent(ask.id)}`, configUrl);
19744
+ lines.push(`- Declined: ${ask.question} \u2192 ${href}`);
19745
+ if (ask.note !== "")
19746
+ lines.push(` Their note: ${ask.note}`);
19747
+ }
19748
+ return lines;
19749
+ } catch (error) {
19750
+ return [`The issue's declined asks could not be shown: ${messageFor(error)}`];
19751
+ }
19752
+ }
19716
19753
  function relatedCheckForm(suggestions, context) {
19717
19754
  const form = relatedCheckFormOf(suggestions);
19718
19755
  if (form.form === "not_made") {
@@ -19807,12 +19844,12 @@ var SESSION_ANSWERS_MAX_CHARS = 8000;
19807
19844
  var SESSION_ANSWERS_DEADLINE_MS = 800;
19808
19845
  var READ_TIMEOUT_MS = 1e4;
19809
19846
  var NO_ROUTE_BACKOFF_MS = 5 * 60000;
19810
- var QUESTION_MAX = 200;
19811
19847
  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.]";
19812
19848
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
19813
19849
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
19814
19850
  var RELATION_PHRASES = {
19815
19851
  answered_your_ask: "answered your ask",
19852
+ declined_your_ask: "declined to answer your ask",
19816
19853
  replied_on_your_ask: "replied on your ask",
19817
19854
  replied_in_a_comment_thread: "replied in a comment thread",
19818
19855
  commented_on_a_document: "commented on a document",
@@ -19837,13 +19874,15 @@ function renderSessionAnswerItem(item) {
19837
19874
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
19838
19875
  const lines = [head.join(" \xB7 "), where];
19839
19876
  if (item.ask !== undefined) {
19840
- const question = item.ask.question.replace(/\s+/g, " ").trim();
19841
- lines.push(`Question: ${question.length > QUESTION_MAX ? `${question.slice(0, QUESTION_MAX)}\u2026` : question}`);
19877
+ lines.push(`Question: ${textHead(item.ask.question, QUESTION_HEAD)}`);
19842
19878
  }
19843
19879
  if (item.kind === "answer") {
19844
19880
  const selected = item.selected ?? [];
19845
19881
  lines.push(`Selected: ${selected.length === 0 ? "none" : selected.join(", ")}`);
19846
19882
  }
19883
+ const words = dispatchWordsText(item.dispatch_words);
19884
+ if (words !== undefined)
19885
+ lines.push(words);
19847
19886
  if (item.text !== "")
19848
19887
  lines.push(item.text);
19849
19888
  return lines.join(`
@@ -20287,7 +20326,16 @@ function renderAdvice(tool, key, advice, opts) {
20287
20326
  }
20288
20327
  const superseded = advice.superseded_approval;
20289
20328
  if (superseded !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
20290
- lines.push(`Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since: a Legion design gate on this document is closed meanwhile, so every READY in its tree is refused. Meant to change the approved design? Request approval with \`dispatch request-approval\`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.`);
20329
+ const gates = Array.isArray(superseded.design_gates) ? superseded.design_gates : [];
20330
+ const parts = [
20331
+ `Stored version ${superseded.version}, superseding version ${superseded.approved_version}, which ${superseded.approved_by} approved. That approval is stale until someone approves version ${superseded.version} or a later write stores the text of version ${superseded.approved_version} again exactly, with no decision block in it decided since.`
20332
+ ];
20333
+ if (gates.length > 0) {
20334
+ const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
20335
+ parts.push(`A Legion design gate records this document, so every READY in ${gates.length === 1 ? "its" : "each"} tree is refused until that approval comes back: ${named}.`);
20336
+ }
20337
+ parts.push("Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the tree's architect, and keep the next one in a comment or in the plan.");
20338
+ lines.push(parts.join(" "));
20291
20339
  }
20292
20340
  if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
20293
20341
  const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
@@ -21652,6 +21700,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
21652
21700
  `${reply.id} \xB7 ${actorText(reply.author)}`,
21653
21701
  `Body: ${reply.body}`
21654
21702
  ]);
21703
+ const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
21655
21704
  return [
21656
21705
  `Question: ${ask.question}`,
21657
21706
  ...anchorLines(ask),
@@ -21678,7 +21727,8 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
21678
21727
  "Resolution:",
21679
21728
  `- By: ${ask.resolution.actor.id}`,
21680
21729
  `- Kind: ${ask.resolution.kind}`,
21681
- `- Reason: ${ask.resolution.reason}`
21730
+ ...ask.resolution.reason === "" ? [] : [`- Reason: ${ask.resolution.reason}`],
21731
+ ...resolutionWords === undefined ? [] : [`- ${resolutionWords}`]
21682
21732
  ],
21683
21733
  "Replies:",
21684
21734
  ...chain.length === 0 ? ["- none"] : chain,
@@ -22822,16 +22872,19 @@ async function executeDispatchTool(input) {
22822
22872
  };
22823
22873
  const ask = resolved?.owner.kind === "project" ? await client.artifactAsk(resolved.artifact.id, askInput) : await client.ask(issue(), askInput);
22824
22874
  const askOwner = ask.issue_key !== null ? issueTopic(ask.issue_key) : resolved === undefined ? issueTopic(issue()) : documentTopic(resolved.artifact);
22825
- const checkLines = relatedCheckLines(ask.advice?.suggestions, {
22875
+ const checkContext = {
22826
22876
  project: resolved?.artifact.project ?? (ask.issue_key ?? "").replace(/-[0-9]+$/, ""),
22827
22877
  text: stringArg(args, "question"),
22828
22878
  configUrl: linkBase
22829
- });
22879
+ };
22880
+ const checkLines = relatedCheckLines(ask.advice?.suggestions, checkContext);
22881
+ const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
22830
22882
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
22831
22883
  return {
22832
22884
  text: [
22833
22885
  `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}`,
22834
22886
  ...checkLines,
22887
+ ...declinedLines,
22835
22888
  await followsAsk(askOwner, input.subscriptions),
22836
22889
  ...adviceLines
22837
22890
  ].join(`
@@ -23048,17 +23101,20 @@ async function executeDispatchTool(input) {
23048
23101
  const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded or holds a tree too deep to read \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
23049
23102
  const applied = `${head}${unchangedText}${lostText}`;
23050
23103
  const editAskText = ops.map((operation) => /^:{3,}ask\{.*\n([\s\S]*)/mu.exec(operation.markdown ?? operation.with ?? "")?.[1]).find((text) => text !== undefined) ?? resolved.issue?.title ?? "";
23051
- const checkLines = decisionBlockLines(edited.advice, {
23104
+ const checkContext = {
23052
23105
  project: resolved.artifact.project,
23053
23106
  text: editAskText,
23054
23107
  configUrl: linkBase
23055
- });
23108
+ };
23109
+ const checkLines = decisionBlockLines(edited.advice, checkContext);
23110
+ const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
23056
23111
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {}));
23057
23112
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
23058
23113
  return {
23059
23114
  text: [
23060
23115
  `${applied}${await notSubscribed(resolvedTopic(resolved), input.subscriptions)}`,
23061
23116
  ...checkLines,
23117
+ ...declinedLines,
23062
23118
  ...tokenTrailer,
23063
23119
  ...adviceLines
23064
23120
  ].join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
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": 64
22
+ "daemonApiVersion": 68
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",