@sjawhar/pi-envoy 16.46.1 → 16.48.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.
package/dist/dispatch.js CHANGED
@@ -14705,8 +14705,9 @@ var askEventPayloadFields = {
14705
14705
  primary: boolean2().optional()
14706
14706
  }).optional(),
14707
14707
  resolution: object({
14708
- kind: _enum2(["retracted", "resolved", "withdrawn"]).optional(),
14708
+ kind: string2().optional(),
14709
14709
  reason: string2().optional(),
14710
+ dispatch_words: string2().optional(),
14710
14711
  actor: object({ kind: string2().optional(), id: string2().optional() }).passthrough().optional(),
14711
14712
  at: string2().optional()
14712
14713
  }).nullish(),
@@ -15371,7 +15372,7 @@ var dispatchToolSpecs = [
15371
15372
  kind: "retracted",
15372
15373
  reason: "A newer question supersedes this one."
15373
15374
  },
15374
- 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.",
15375
+ 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.",
15375
15376
  arguments: (z) => ({
15376
15377
  ask: z.string().describe("Ask id (uuid) to close; an 8+ hex prefix unique among this session's own open asks " + "works too."),
15377
15378
  kind: z.enum(["retracted", "resolved"]).describe("Whether the ask is retracted or self-resolved."),
@@ -17474,6 +17475,13 @@ function textHead(text, length = HEAD_LENGTH) {
17474
17475
  const flat = text.replace(/\s+/g, " ").trim();
17475
17476
  return flat.length > length ? `${flat.slice(0, length)}\u2026` : flat;
17476
17477
  }
17478
+ var QUESTION_HEAD = 200;
17479
+ var DISPATCH_WORDS_LABEL = "Dispatch's words:";
17480
+ function dispatchWordsText(words, render) {
17481
+ if (words === null || words === undefined || words === "")
17482
+ return;
17483
+ return `${DISPATCH_WORDS_LABEL} ${render === undefined ? words : render(words)}`;
17484
+ }
17477
17485
  function askAnswerText(answer) {
17478
17486
  if (answer === null || answer === undefined)
17479
17487
  return "";
@@ -19144,7 +19152,14 @@ function answerLines(lead, answer) {
19144
19152
  ];
19145
19153
  }
19146
19154
  function resolutionText(resolution) {
19147
- return `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}: ${indentedText(resolution.reason)}`;
19155
+ const closed = `${resolution.kind} by ${actorText(resolution.actor)} at ${resolution.at}`;
19156
+ const parts = [
19157
+ resolution.reason === "" ? closed : `${closed}: ${indentedText(resolution.reason)}`
19158
+ ];
19159
+ const words = dispatchWordsText(resolution.dispatch_words, indentedText);
19160
+ if (words !== undefined)
19161
+ parts.push(words);
19162
+ return parts.join(" \xB7 ");
19148
19163
  }
19149
19164
  function askStateLines(ask) {
19150
19165
  if (ask === undefined) {
@@ -19290,6 +19305,26 @@ function decisionBlockLines(advice, context) {
19290
19305
  ];
19291
19306
  }
19292
19307
  }
19308
+ function declinedAskLines(advice, issueKey, configUrl) {
19309
+ try {
19310
+ const declined = advice?.declined_asks;
19311
+ if (declined === undefined || declined === null || declined.length === 0)
19312
+ return [];
19313
+ const count = declined.length;
19314
+ const lines = [
19315
+ 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:`
19316
+ ];
19317
+ for (const ask of declined) {
19318
+ const href = absoluteHref(`/issues/${encodeURIComponent(issueKey)}/asks/${encodeURIComponent(ask.id)}`, configUrl);
19319
+ lines.push(`- Declined: ${ask.question} \u2192 ${href}`);
19320
+ if (ask.note !== "")
19321
+ lines.push(` Their note: ${ask.note}`);
19322
+ }
19323
+ return lines;
19324
+ } catch (error) {
19325
+ return [`The issue's declined asks could not be shown: ${messageFor(error)}`];
19326
+ }
19327
+ }
19293
19328
  function relatedCheckForm(suggestions, context) {
19294
19329
  const form = relatedCheckFormOf(suggestions);
19295
19330
  if (form.form === "not_made") {
@@ -19378,9 +19413,9 @@ function writeAtomically(path, text) {
19378
19413
  var SESSION_ANSWERS_WINDOW_MS = 72 * 3600000;
19379
19414
  var SESSION_ANSWERS_MAX_CHARS = 8000;
19380
19415
  var NO_ROUTE_BACKOFF_MS = 5 * 60000;
19381
- var QUESTION_MAX = 200;
19382
19416
  var RELATION_PHRASES = {
19383
19417
  answered_your_ask: "answered your ask",
19418
+ declined_your_ask: "declined to answer your ask",
19384
19419
  replied_on_your_ask: "replied on your ask",
19385
19420
  replied_in_a_comment_thread: "replied in a comment thread",
19386
19421
  commented_on_a_document: "commented on a document",
@@ -19405,13 +19440,15 @@ function renderSessionAnswerItem(item) {
19405
19440
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
19406
19441
  const lines = [head.join(" \xB7 "), where];
19407
19442
  if (item.ask !== undefined) {
19408
- const question = item.ask.question.replace(/\s+/g, " ").trim();
19409
- lines.push(`Question: ${question.length > QUESTION_MAX ? `${question.slice(0, QUESTION_MAX)}\u2026` : question}`);
19443
+ lines.push(`Question: ${textHead(item.ask.question, QUESTION_HEAD)}`);
19410
19444
  }
19411
19445
  if (item.kind === "answer") {
19412
19446
  const selected = item.selected ?? [];
19413
19447
  lines.push(`Selected: ${selected.length === 0 ? "none" : selected.join(", ")}`);
19414
19448
  }
19449
+ const words = dispatchWordsText(item.dispatch_words);
19450
+ if (words !== undefined)
19451
+ lines.push(words);
19415
19452
  if (item.text !== "")
19416
19453
  lines.push(item.text);
19417
19454
  return lines.join(`
@@ -19639,7 +19676,16 @@ function renderAdvice(tool, key, advice, opts) {
19639
19676
  }
19640
19677
  const superseded = advice.superseded_approval;
19641
19678
  if (superseded !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
19642
- 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.`);
19679
+ const gates = Array.isArray(superseded.design_gates) ? superseded.design_gates : [];
19680
+ const parts = [
19681
+ `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.`
19682
+ ];
19683
+ if (gates.length > 0) {
19684
+ const named = gates.map((gate) => `${gate.issue}, step ${gate.step}`).join("; ");
19685
+ 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}.`);
19686
+ }
19687
+ 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.");
19688
+ lines.push(parts.join(" "));
19643
19689
  }
19644
19690
  if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
19645
19691
  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.";
@@ -21004,6 +21050,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
21004
21050
  `${reply.id} \xB7 ${actorText(reply.author)}`,
21005
21051
  `Body: ${reply.body}`
21006
21052
  ]);
21053
+ const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
21007
21054
  return [
21008
21055
  `Question: ${ask.question}`,
21009
21056
  ...anchorLines(ask),
@@ -21030,7 +21077,8 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
21030
21077
  "Resolution:",
21031
21078
  `- By: ${ask.resolution.actor.id}`,
21032
21079
  `- Kind: ${ask.resolution.kind}`,
21033
- `- Reason: ${ask.resolution.reason}`
21080
+ ...ask.resolution.reason === "" ? [] : [`- Reason: ${ask.resolution.reason}`],
21081
+ ...resolutionWords === undefined ? [] : [`- ${resolutionWords}`]
21034
21082
  ],
21035
21083
  "Replies:",
21036
21084
  ...chain.length === 0 ? ["- none"] : chain,
@@ -22174,16 +22222,19 @@ async function executeDispatchTool(input) {
22174
22222
  };
22175
22223
  const ask = resolved?.owner.kind === "project" ? await client.artifactAsk(resolved.artifact.id, askInput) : await client.ask(issue(), askInput);
22176
22224
  const askOwner = ask.issue_key !== null ? issueTopic(ask.issue_key) : resolved === undefined ? issueTopic(issue()) : documentTopic(resolved.artifact);
22177
- const checkLines = relatedCheckLines(ask.advice?.suggestions, {
22225
+ const checkContext = {
22178
22226
  project: resolved?.artifact.project ?? (ask.issue_key ?? "").replace(/-[0-9]+$/, ""),
22179
22227
  text: stringArg(args, "question"),
22180
22228
  configUrl: linkBase
22181
- });
22229
+ };
22230
+ const checkLines = relatedCheckLines(ask.advice?.suggestions, checkContext);
22231
+ const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
22182
22232
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
22183
22233
  return {
22184
22234
  text: [
22185
22235
  `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency}): ${ask.question}`,
22186
22236
  ...checkLines,
22237
+ ...declinedLines,
22187
22238
  await followsAsk(askOwner, input.subscriptions),
22188
22239
  ...adviceLines
22189
22240
  ].join(`
@@ -22400,17 +22451,20 @@ async function executeDispatchTool(input) {
22400
22451
  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`;
22401
22452
  const applied = `${head}${unchangedText}${lostText}`;
22402
22453
  const editAskText = ops.map((operation) => /^:{3,}ask\{.*\n([\s\S]*)/mu.exec(operation.markdown ?? operation.with ?? "")?.[1]).find((text) => text !== undefined) ?? resolved.issue?.title ?? "";
22403
- const checkLines = decisionBlockLines(edited.advice, {
22454
+ const checkContext = {
22404
22455
  project: resolved.artifact.project,
22405
22456
  text: editAskText,
22406
22457
  configUrl: linkBase
22407
- });
22458
+ };
22459
+ const checkLines = decisionBlockLines(edited.advice, checkContext);
22460
+ const declinedLines = resolved.issue === undefined ? [] : declinedAskLines(edited.advice, resolved.issue.key, linkBase);
22408
22461
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {}));
22409
22462
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
22410
22463
  return {
22411
22464
  text: [
22412
22465
  `${applied}${await notSubscribed(resolvedTopic(resolved), input.subscriptions)}`,
22413
22466
  ...checkLines,
22467
+ ...declinedLines,
22414
22468
  ...tokenTrailer,
22415
22469
  ...adviceLines
22416
22470
  ].join(`
package/dist/envoy.js CHANGED
@@ -29794,8 +29794,9 @@ var askEventPayloadFields = {
29794
29794
  primary: boolean2().optional()
29795
29795
  }).optional(),
29796
29796
  resolution: object({
29797
- kind: _enum2(["retracted", "resolved", "withdrawn"]).optional(),
29797
+ kind: string2().optional(),
29798
29798
  reason: string2().optional(),
29799
+ dispatch_words: string2().optional(),
29799
29800
  actor: object({ kind: string2().optional(), id: string2().optional() }).passthrough().optional(),
29800
29801
  at: string2().optional()
29801
29802
  }).nullish(),
@@ -30410,7 +30411,7 @@ var dispatchToolSpecs = [
30410
30411
  kind: "retracted",
30411
30412
  reason: "A newer question supersedes this one."
30412
30413
  },
30413
- 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.",
30414
+ 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.",
30414
30415
  arguments: (z) => ({
30415
30416
  ask: z.string().describe("Ask id (uuid) to close; an 8+ hex prefix unique among this session's own open asks " + "works too."),
30416
30417
  kind: z.enum(["retracted", "resolved"]).describe("Whether the ask is retracted or self-resolved."),
@@ -35122,6 +35123,13 @@ function textHead(text, length = HEAD_LENGTH) {
35122
35123
  const flat = text.replace(/\s+/g, " ").trim();
35123
35124
  return flat.length > length ? `${flat.slice(0, length)}\u2026` : flat;
35124
35125
  }
35126
+ var QUESTION_HEAD = 200;
35127
+ var DISPATCH_WORDS_LABEL = "Dispatch's words:";
35128
+ function dispatchWordsText(words, render) {
35129
+ if (words === null || words === undefined || words === "")
35130
+ return;
35131
+ return `${DISPATCH_WORDS_LABEL} ${render === undefined ? words : render(words)}`;
35132
+ }
35125
35133
  function askAnswerText(answer) {
35126
35134
  if (answer === null || answer === undefined)
35127
35135
  return "";
@@ -36902,7 +36910,9 @@ function askResolutionText(resolution) {
36902
36910
  return;
36903
36911
  const kind = resolution.kind ?? "resolved";
36904
36912
  const reason = resolution.reason ?? "";
36905
- return reason === "" ? kind : `${kind}: ${reason}`;
36913
+ const closed = reason === "" ? kind : `${kind}: ${reason}`;
36914
+ const words = dispatchWordsText(resolution.dispatch_words);
36915
+ return words === undefined ? closed : `${closed} \xB7 ${words}`;
36906
36916
  }
36907
36917
  function dispatchCompact(event, comment) {
36908
36918
  if (event.type === "artifact.human_edited") {
@@ -40059,12 +40069,12 @@ var SESSION_ANSWERS_MAX_CHARS = 8000;
40059
40069
  var SESSION_ANSWERS_DEADLINE_MS = 800;
40060
40070
  var READ_TIMEOUT_MS = 1e4;
40061
40071
  var NO_ROUTE_BACKOFF_MS = 5 * 60000;
40062
- var QUESTION_MAX = 200;
40063
40072
  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.]";
40064
40073
  var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
40065
40074
  var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
40066
40075
  var RELATION_PHRASES = {
40067
40076
  answered_your_ask: "answered your ask",
40077
+ declined_your_ask: "declined to answer your ask",
40068
40078
  replied_on_your_ask: "replied on your ask",
40069
40079
  replied_in_a_comment_thread: "replied in a comment thread",
40070
40080
  commented_on_a_document: "commented on a document",
@@ -40092,13 +40102,15 @@ function renderSessionAnswerItem(item) {
40092
40102
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
40093
40103
  const lines = [head.join(" \xB7 "), where];
40094
40104
  if (item.ask !== undefined) {
40095
- const question = item.ask.question.replace(/\s+/g, " ").trim();
40096
- lines.push(`Question: ${question.length > QUESTION_MAX ? `${question.slice(0, QUESTION_MAX)}\u2026` : question}`);
40105
+ lines.push(`Question: ${textHead(item.ask.question, QUESTION_HEAD)}`);
40097
40106
  }
40098
40107
  if (item.kind === "answer") {
40099
40108
  const selected = item.selected ?? [];
40100
40109
  lines.push(`Selected: ${selected.length === 0 ? "none" : selected.join(", ")}`);
40101
40110
  }
40111
+ const words = dispatchWordsText(item.dispatch_words);
40112
+ if (words !== undefined)
40113
+ lines.push(words);
40102
40114
  if (item.text !== "")
40103
40115
  lines.push(item.text);
40104
40116
  return lines.join(`
@@ -42706,7 +42718,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
42706
42718
 
42707
42719
  // package.json
42708
42720
  var name = "@sjawhar/pi-envoy";
42709
- var version2 = "16.46.1";
42721
+ var version2 = "16.48.0";
42710
42722
  var package_default = {
42711
42723
  name,
42712
42724
  version: version2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-envoy",
3
- "version": "16.46.1",
3
+ "version": "16.48.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {