@sjawhar/claude-envoy 6.2.3 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.2.3"
5
+ "version": "6.3.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.2.3",
3
+ "version": "6.3.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
  }
@@ -32027,6 +32027,95 @@ async function sendToAgentCommand(context) {
32027
32027
  // ../envoy-client/src/dispatch-commands/documents.ts
32028
32028
  import { resolve as resolvePath3 } from "path";
32029
32029
 
32030
+ // ../envoy-client/src/dispatch-commands/open-decision-blocks.ts
32031
+ async function blockAsks(client, resolved, state) {
32032
+ const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
32033
+ return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
32034
+ }
32035
+ var OPEN_BLOCK_ASK_THE_HUMAN = "Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds.";
32036
+ var OPEN_BLOCK_WAIVED = "If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason)";
32037
+ async function refuseOpenDecisionBlocks(client, resolved, refusal) {
32038
+ const artifact = resolved.artifact;
32039
+ const latest = artifact.approval?.latest_version;
32040
+ if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
32041
+ return;
32042
+ const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
32043
+ if (blocks.length === 0)
32044
+ return;
32045
+ const [documentAsks, version] = await Promise.all([
32046
+ blockAsks(client, resolved),
32047
+ client.docRead(artifact.id, latest)
32048
+ ]);
32049
+ const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
32050
+ const lines = version.markdown.split(`
32051
+ `);
32052
+ const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
32053
+ const open = blocks.flatMap((block) => {
32054
+ const ask = asks.get(block.id);
32055
+ const id = typedBlockIdAttribute(block.id);
32056
+ const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
32057
+ const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
32058
+ const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
32059
+ if (states.length === 0)
32060
+ return [`${named}, which version ${latest} does not hold yet`];
32061
+ if (!states.includes("open") && states.some((state) => state !== undefined))
32062
+ return [];
32063
+ if (ask !== undefined)
32064
+ return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
32065
+ const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
32066
+ const sourceId = attribute("copied_from");
32067
+ const document = attribute("copied_from_document");
32068
+ if (sourceId === undefined || document === undefined) {
32069
+ return [`${named}, whose ask Dispatch has not opened yet`];
32070
+ }
32071
+ const source = parseDispatchRef(document);
32072
+ const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
32073
+ const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
32074
+ return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
32075
+ });
32076
+ if (open.length === 0)
32077
+ return;
32078
+ const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
32079
+ throw new Error([
32080
+ `${refusal.call} was not called: ${artifact.name} (version ${latest}) has ${count}. ${refusal.effect}`,
32081
+ ...open.map((line) => `- ${line}`),
32082
+ refusal.remedy
32083
+ ].join(`
32084
+ `));
32085
+ }
32086
+ async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
32087
+ const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
32088
+ if (removing.length === 0)
32089
+ return;
32090
+ const artifact = resolved.artifact;
32091
+ const blocks = await client.artifactBlocks(artifact.id);
32092
+ const askBlocks = blocks.filter((block) => block.type === "ask");
32093
+ const removed = new Set;
32094
+ for (const operation of removing) {
32095
+ const target = blocks.find((block) => block.id === operation.block);
32096
+ if (target === undefined)
32097
+ continue;
32098
+ for (const block of askBlocks) {
32099
+ if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
32100
+ removed.add(block.id);
32101
+ }
32102
+ }
32103
+ }
32104
+ if (removed.size === 0)
32105
+ return;
32106
+ const asks = await blockAsks(client, resolved, "open");
32107
+ const open = asks.filter((ask) => removed.has(ask.block_id));
32108
+ if (open.length === 0)
32109
+ return;
32110
+ const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
32111
+ throw new Error([
32112
+ `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
32113
+ ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
32114
+ "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
32115
+ ].join(`
32116
+ `));
32117
+ }
32118
+
32030
32119
  // ../envoy-client/src/dispatch-commands/stored-text.ts
32031
32120
  import { resolve as resolvePath2 } from "path";
32032
32121
 
@@ -32558,10 +32647,6 @@ function artifactNameExistsProblem(held, owner, upload) {
32558
32647
  }
32559
32648
 
32560
32649
  // ../envoy-client/src/dispatch-commands/documents.ts
32561
- async function blockAsks(client, resolved, state) {
32562
- const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
32563
- return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
32564
- }
32565
32650
  async function readUploadedFile(client, artifact, details, requested, owner, shown) {
32566
32651
  const versions = artifact.versions ?? [];
32567
32652
  const latest = Math.max(0, ...versions.map((version) => version.number));
@@ -32653,87 +32738,6 @@ async function listDocumentBlocks(client, artifact) {
32653
32738
  return { text: lines.join(`
32654
32739
  `), token: live.token, version: live.version };
32655
32740
  }
32656
- async function refuseOpenDecisionBlocks(client, tool, resolved) {
32657
- const artifact = resolved.artifact;
32658
- const latest = artifact.approval?.latest_version;
32659
- if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
32660
- return;
32661
- const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
32662
- if (blocks.length === 0)
32663
- return;
32664
- const [documentAsks, version] = await Promise.all([
32665
- blockAsks(client, resolved),
32666
- client.docRead(artifact.id, latest)
32667
- ]);
32668
- const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
32669
- const lines = version.markdown.split(`
32670
- `);
32671
- const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
32672
- const open = blocks.flatMap((block) => {
32673
- const ask = asks.get(block.id);
32674
- const id = typedBlockIdAttribute(block.id);
32675
- const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
32676
- const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
32677
- const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
32678
- if (states.length === 0)
32679
- return [`${named}, which version ${latest} does not hold yet`];
32680
- if (!states.includes("open") && states.some((state) => state !== undefined))
32681
- return [];
32682
- if (ask !== undefined)
32683
- return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
32684
- const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
32685
- const sourceId = attribute("copied_from");
32686
- const document = attribute("copied_from_document");
32687
- if (sourceId === undefined || document === undefined) {
32688
- return [`${named}, whose ask Dispatch has not opened yet`];
32689
- }
32690
- const source = parseDispatchRef(document);
32691
- const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
32692
- const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
32693
- return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
32694
- });
32695
- if (open.length === 0)
32696
- return;
32697
- const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
32698
- throw new Error([
32699
- `dispatch ${commandName(tool)} was not called: ${artifact.name} (version ${latest}) has ${count}. Answering one writes a new version, which would move this request to that version and leave it waiting on you.`,
32700
- ...open.map((line) => `- ${line}`),
32701
- "Do not request approval over an open block, even when a human asked for it. Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds. When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason), write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
32702
- ].join(`
32703
- `));
32704
- }
32705
- async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
32706
- const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
32707
- if (removing.length === 0)
32708
- return;
32709
- const artifact = resolved.artifact;
32710
- const blocks = await client.artifactBlocks(artifact.id);
32711
- const askBlocks = blocks.filter((block) => block.type === "ask");
32712
- const removed = new Set;
32713
- for (const operation of removing) {
32714
- const target = blocks.find((block) => block.id === operation.block);
32715
- if (target === undefined)
32716
- continue;
32717
- for (const block of askBlocks) {
32718
- if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
32719
- removed.add(block.id);
32720
- }
32721
- }
32722
- }
32723
- if (removed.size === 0)
32724
- return;
32725
- const asks = await blockAsks(client, resolved, "open");
32726
- const open = asks.filter((ask) => removed.has(ask.block_id));
32727
- if (open.length === 0)
32728
- return;
32729
- const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
32730
- throw new Error([
32731
- `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
32732
- ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
32733
- "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
32734
- ].join(`
32735
- `));
32736
- }
32737
32741
  async function docEditCommand(context) {
32738
32742
  const { args, client, actor, input, linkBase, documentOwner, resolveDocument } = context;
32739
32743
  const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
@@ -32859,11 +32863,18 @@ ${trailer.join(`
32859
32863
  } : { issue: resolved.issue?.key }
32860
32864
  };
32861
32865
  }
32866
+ var APPROVAL_REQUEST_OPEN_BLOCKS = {
32867
+ effect: "Answering one writes a new version, which would move this request to that version and leave it waiting on you.",
32868
+ remedy: "Do not request approval over an open block, even when a human asked for it. " + OPEN_BLOCK_ASK_THE_HUMAN + " When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. " + OPEN_BLOCK_WAIVED + ", write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
32869
+ };
32862
32870
  async function requestApprovalCommand(context) {
32863
32871
  const { args, client, actor, input, ownerArguments, documentOwner, resolveDocument } = context;
32864
32872
  const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
32865
32873
  const resolved = await resolveDocument(documentOwner(), artifactReference);
32866
- await refuseOpenDecisionBlocks(client, input.tool, resolved);
32874
+ await refuseOpenDecisionBlocks(client, resolved, {
32875
+ call: `dispatch ${commandName(input.tool)}`,
32876
+ ...APPROVAL_REQUEST_OPEN_BLOCKS
32877
+ });
32867
32878
  const includeVerification = optionalBoolean(args, "include_verification") === true;
32868
32879
  const result = await client.requestApproval(resolved.artifact.id, {
32869
32880
  actor,
package/dist/dispatch.js CHANGED
@@ -36866,6 +36866,95 @@ async function sendToAgentCommand(context) {
36866
36866
  // ../envoy-client/src/dispatch-commands/documents.ts
36867
36867
  import { resolve as resolvePath3 } from "path";
36868
36868
 
36869
+ // ../envoy-client/src/dispatch-commands/open-decision-blocks.ts
36870
+ async function blockAsks(client, resolved, state) {
36871
+ const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
36872
+ return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
36873
+ }
36874
+ var OPEN_BLOCK_ASK_THE_HUMAN = "Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds.";
36875
+ var OPEN_BLOCK_WAIVED = "If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason)";
36876
+ async function refuseOpenDecisionBlocks(client, resolved, refusal) {
36877
+ const artifact = resolved.artifact;
36878
+ const latest = artifact.approval?.latest_version;
36879
+ if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
36880
+ return;
36881
+ const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
36882
+ if (blocks.length === 0)
36883
+ return;
36884
+ const [documentAsks, version] = await Promise.all([
36885
+ blockAsks(client, resolved),
36886
+ client.docRead(artifact.id, latest)
36887
+ ]);
36888
+ const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
36889
+ const lines = version.markdown.split(`
36890
+ `);
36891
+ const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
36892
+ const open = blocks.flatMap((block) => {
36893
+ const ask = asks.get(block.id);
36894
+ const id = typedBlockIdAttribute(block.id);
36895
+ const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
36896
+ const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
36897
+ const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
36898
+ if (states.length === 0)
36899
+ return [`${named}, which version ${latest} does not hold yet`];
36900
+ if (!states.includes("open") && states.some((state) => state !== undefined))
36901
+ return [];
36902
+ if (ask !== undefined)
36903
+ return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
36904
+ const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
36905
+ const sourceId = attribute("copied_from");
36906
+ const document = attribute("copied_from_document");
36907
+ if (sourceId === undefined || document === undefined) {
36908
+ return [`${named}, whose ask Dispatch has not opened yet`];
36909
+ }
36910
+ const source = parseDispatchRef(document);
36911
+ const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
36912
+ const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
36913
+ return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
36914
+ });
36915
+ if (open.length === 0)
36916
+ return;
36917
+ const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
36918
+ throw new Error([
36919
+ `${refusal.call} was not called: ${artifact.name} (version ${latest}) has ${count}. ${refusal.effect}`,
36920
+ ...open.map((line) => `- ${line}`),
36921
+ refusal.remedy
36922
+ ].join(`
36923
+ `));
36924
+ }
36925
+ async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
36926
+ const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
36927
+ if (removing.length === 0)
36928
+ return;
36929
+ const artifact = resolved.artifact;
36930
+ const blocks = await client.artifactBlocks(artifact.id);
36931
+ const askBlocks = blocks.filter((block) => block.type === "ask");
36932
+ const removed = new Set;
36933
+ for (const operation of removing) {
36934
+ const target = blocks.find((block) => block.id === operation.block);
36935
+ if (target === undefined)
36936
+ continue;
36937
+ for (const block of askBlocks) {
36938
+ if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
36939
+ removed.add(block.id);
36940
+ }
36941
+ }
36942
+ }
36943
+ if (removed.size === 0)
36944
+ return;
36945
+ const asks = await blockAsks(client, resolved, "open");
36946
+ const open = asks.filter((ask) => removed.has(ask.block_id));
36947
+ if (open.length === 0)
36948
+ return;
36949
+ const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
36950
+ throw new Error([
36951
+ `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
36952
+ ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
36953
+ "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
36954
+ ].join(`
36955
+ `));
36956
+ }
36957
+
36869
36958
  // ../envoy-client/src/dispatch-commands/upload-checks.ts
36870
36959
  function artifactUnderName(artifacts, name) {
36871
36960
  const written = name.trim();
@@ -36889,10 +36978,6 @@ function artifactNameExistsProblem(held, owner, upload) {
36889
36978
  }
36890
36979
 
36891
36980
  // ../envoy-client/src/dispatch-commands/documents.ts
36892
- async function blockAsks(client, resolved, state) {
36893
- const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
36894
- return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
36895
- }
36896
36981
  async function readUploadedFile(client, artifact, details, requested, owner, shown) {
36897
36982
  const versions = artifact.versions ?? [];
36898
36983
  const latest = Math.max(0, ...versions.map((version) => version.number));
@@ -36984,87 +37069,6 @@ async function listDocumentBlocks(client, artifact) {
36984
37069
  return { text: lines.join(`
36985
37070
  `), token: live.token, version: live.version };
36986
37071
  }
36987
- async function refuseOpenDecisionBlocks(client, tool, resolved) {
36988
- const artifact = resolved.artifact;
36989
- const latest = artifact.approval?.latest_version;
36990
- if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
36991
- return;
36992
- const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
36993
- if (blocks.length === 0)
36994
- return;
36995
- const [documentAsks, version] = await Promise.all([
36996
- blockAsks(client, resolved),
36997
- client.docRead(artifact.id, latest)
36998
- ]);
36999
- const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
37000
- const lines = version.markdown.split(`
37001
- `);
37002
- const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
37003
- const open = blocks.flatMap((block) => {
37004
- const ask = asks.get(block.id);
37005
- const id = typedBlockIdAttribute(block.id);
37006
- const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
37007
- const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
37008
- const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
37009
- if (states.length === 0)
37010
- return [`${named}, which version ${latest} does not hold yet`];
37011
- if (!states.includes("open") && states.some((state) => state !== undefined))
37012
- return [];
37013
- if (ask !== undefined)
37014
- return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
37015
- const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
37016
- const sourceId = attribute("copied_from");
37017
- const document = attribute("copied_from_document");
37018
- if (sourceId === undefined || document === undefined) {
37019
- return [`${named}, whose ask Dispatch has not opened yet`];
37020
- }
37021
- const source = parseDispatchRef(document);
37022
- const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
37023
- const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
37024
- return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
37025
- });
37026
- if (open.length === 0)
37027
- return;
37028
- const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
37029
- throw new Error([
37030
- `dispatch ${commandName(tool)} was not called: ${artifact.name} (version ${latest}) has ${count}. Answering one writes a new version, which would move this request to that version and leave it waiting on you.`,
37031
- ...open.map((line) => `- ${line}`),
37032
- "Do not request approval over an open block, even when a human asked for it. Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds. When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason), write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
37033
- ].join(`
37034
- `));
37035
- }
37036
- async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
37037
- const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
37038
- if (removing.length === 0)
37039
- return;
37040
- const artifact = resolved.artifact;
37041
- const blocks = await client.artifactBlocks(artifact.id);
37042
- const askBlocks = blocks.filter((block) => block.type === "ask");
37043
- const removed = new Set;
37044
- for (const operation of removing) {
37045
- const target = blocks.find((block) => block.id === operation.block);
37046
- if (target === undefined)
37047
- continue;
37048
- for (const block of askBlocks) {
37049
- if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
37050
- removed.add(block.id);
37051
- }
37052
- }
37053
- }
37054
- if (removed.size === 0)
37055
- return;
37056
- const asks = await blockAsks(client, resolved, "open");
37057
- const open = asks.filter((ask) => removed.has(ask.block_id));
37058
- if (open.length === 0)
37059
- return;
37060
- const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
37061
- throw new Error([
37062
- `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
37063
- ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
37064
- "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
37065
- ].join(`
37066
- `));
37067
- }
37068
37072
  async function docEditCommand(context) {
37069
37073
  const { args, client, actor, input, linkBase, documentOwner, resolveDocument } = context;
37070
37074
  const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
@@ -37190,11 +37194,18 @@ ${trailer.join(`
37190
37194
  } : { issue: resolved.issue?.key }
37191
37195
  };
37192
37196
  }
37197
+ var APPROVAL_REQUEST_OPEN_BLOCKS = {
37198
+ effect: "Answering one writes a new version, which would move this request to that version and leave it waiting on you.",
37199
+ remedy: "Do not request approval over an open block, even when a human asked for it. " + OPEN_BLOCK_ASK_THE_HUMAN + " When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. " + OPEN_BLOCK_WAIVED + ", write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
37200
+ };
37193
37201
  async function requestApprovalCommand(context) {
37194
37202
  const { args, client, actor, input, ownerArguments, documentOwner, resolveDocument } = context;
37195
37203
  const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
37196
37204
  const resolved = await resolveDocument(documentOwner(), artifactReference);
37197
- await refuseOpenDecisionBlocks(client, input.tool, resolved);
37205
+ await refuseOpenDecisionBlocks(client, resolved, {
37206
+ call: `dispatch ${commandName(input.tool)}`,
37207
+ ...APPROVAL_REQUEST_OPEN_BLOCKS
37208
+ });
37198
37209
  const includeVerification = optionalBoolean(args, "include_verification") === true;
37199
37210
  const result = await client.requestApproval(resolved.artifact.id, {
37200
37211
  actor,
@@ -57636,6 +57636,95 @@ async function sendToAgentCommand(context) {
57636
57636
  // ../envoy-client/src/dispatch-commands/documents.ts
57637
57637
  import { resolve as resolvePath3 } from "path";
57638
57638
 
57639
+ // ../envoy-client/src/dispatch-commands/open-decision-blocks.ts
57640
+ async function blockAsks(client, resolved, state) {
57641
+ const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
57642
+ return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
57643
+ }
57644
+ var OPEN_BLOCK_ASK_THE_HUMAN = "Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds.";
57645
+ var OPEN_BLOCK_WAIVED = "If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason)";
57646
+ async function refuseOpenDecisionBlocks(client, resolved, refusal) {
57647
+ const artifact = resolved.artifact;
57648
+ const latest = artifact.approval?.latest_version;
57649
+ if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
57650
+ return;
57651
+ const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
57652
+ if (blocks.length === 0)
57653
+ return;
57654
+ const [documentAsks, version] = await Promise.all([
57655
+ blockAsks(client, resolved),
57656
+ client.docRead(artifact.id, latest)
57657
+ ]);
57658
+ const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
57659
+ const lines = version.markdown.split(`
57660
+ `);
57661
+ const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
57662
+ const open = blocks.flatMap((block) => {
57663
+ const ask = asks.get(block.id);
57664
+ const id = typedBlockIdAttribute(block.id);
57665
+ const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
57666
+ const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
57667
+ const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
57668
+ if (states.length === 0)
57669
+ return [`${named}, which version ${latest} does not hold yet`];
57670
+ if (!states.includes("open") && states.some((state) => state !== undefined))
57671
+ return [];
57672
+ if (ask !== undefined)
57673
+ return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
57674
+ const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
57675
+ const sourceId = attribute("copied_from");
57676
+ const document = attribute("copied_from_document");
57677
+ if (sourceId === undefined || document === undefined) {
57678
+ return [`${named}, whose ask Dispatch has not opened yet`];
57679
+ }
57680
+ const source = parseDispatchRef(document);
57681
+ const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
57682
+ const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
57683
+ return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
57684
+ });
57685
+ if (open.length === 0)
57686
+ return;
57687
+ const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
57688
+ throw new Error([
57689
+ `${refusal.call} was not called: ${artifact.name} (version ${latest}) has ${count}. ${refusal.effect}`,
57690
+ ...open.map((line) => `- ${line}`),
57691
+ refusal.remedy
57692
+ ].join(`
57693
+ `));
57694
+ }
57695
+ async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
57696
+ const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
57697
+ if (removing.length === 0)
57698
+ return;
57699
+ const artifact = resolved.artifact;
57700
+ const blocks = await client.artifactBlocks(artifact.id);
57701
+ const askBlocks = blocks.filter((block) => block.type === "ask");
57702
+ const removed = new Set;
57703
+ for (const operation of removing) {
57704
+ const target = blocks.find((block) => block.id === operation.block);
57705
+ if (target === undefined)
57706
+ continue;
57707
+ for (const block of askBlocks) {
57708
+ if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
57709
+ removed.add(block.id);
57710
+ }
57711
+ }
57712
+ }
57713
+ if (removed.size === 0)
57714
+ return;
57715
+ const asks = await blockAsks(client, resolved, "open");
57716
+ const open = asks.filter((ask) => removed.has(ask.block_id));
57717
+ if (open.length === 0)
57718
+ return;
57719
+ const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
57720
+ throw new Error([
57721
+ `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
57722
+ ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
57723
+ "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
57724
+ ].join(`
57725
+ `));
57726
+ }
57727
+
57639
57728
  // ../envoy-client/src/dispatch-commands/stored-text.ts
57640
57729
  import { resolve as resolvePath2 } from "path";
57641
57730
 
@@ -58167,10 +58256,6 @@ function artifactNameExistsProblem(held, owner, upload) {
58167
58256
  }
58168
58257
 
58169
58258
  // ../envoy-client/src/dispatch-commands/documents.ts
58170
- async function blockAsks(client, resolved, state) {
58171
- const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
58172
- return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
58173
- }
58174
58259
  async function readUploadedFile(client, artifact, details, requested, owner, shown) {
58175
58260
  const versions = artifact.versions ?? [];
58176
58261
  const latest = Math.max(0, ...versions.map((version) => version.number));
@@ -58262,87 +58347,6 @@ async function listDocumentBlocks(client, artifact) {
58262
58347
  return { text: lines.join(`
58263
58348
  `), token: live.token, version: live.version };
58264
58349
  }
58265
- async function refuseOpenDecisionBlocks(client, tool, resolved) {
58266
- const artifact = resolved.artifact;
58267
- const latest = artifact.approval?.latest_version;
58268
- if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
58269
- return;
58270
- const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
58271
- if (blocks.length === 0)
58272
- return;
58273
- const [documentAsks, version] = await Promise.all([
58274
- blockAsks(client, resolved),
58275
- client.docRead(artifact.id, latest)
58276
- ]);
58277
- const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
58278
- const lines = version.markdown.split(`
58279
- `);
58280
- const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
58281
- const open = blocks.flatMap((block) => {
58282
- const ask = asks.get(block.id);
58283
- const id = typedBlockIdAttribute(block.id);
58284
- const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
58285
- const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
58286
- const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
58287
- if (states.length === 0)
58288
- return [`${named}, which version ${latest} does not hold yet`];
58289
- if (!states.includes("open") && states.some((state) => state !== undefined))
58290
- return [];
58291
- if (ask !== undefined)
58292
- return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
58293
- const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
58294
- const sourceId = attribute("copied_from");
58295
- const document = attribute("copied_from_document");
58296
- if (sourceId === undefined || document === undefined) {
58297
- return [`${named}, whose ask Dispatch has not opened yet`];
58298
- }
58299
- const source = parseDispatchRef(document);
58300
- const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
58301
- const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
58302
- return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
58303
- });
58304
- if (open.length === 0)
58305
- return;
58306
- const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
58307
- throw new Error([
58308
- `dispatch ${commandName(tool)} was not called: ${artifact.name} (version ${latest}) has ${count}. Answering one writes a new version, which would move this request to that version and leave it waiting on you.`,
58309
- ...open.map((line) => `- ${line}`),
58310
- "Do not request approval over an open block, even when a human asked for it. Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds. When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason), write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
58311
- ].join(`
58312
- `));
58313
- }
58314
- async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
58315
- const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
58316
- if (removing.length === 0)
58317
- return;
58318
- const artifact = resolved.artifact;
58319
- const blocks = await client.artifactBlocks(artifact.id);
58320
- const askBlocks = blocks.filter((block) => block.type === "ask");
58321
- const removed = new Set;
58322
- for (const operation of removing) {
58323
- const target = blocks.find((block) => block.id === operation.block);
58324
- if (target === undefined)
58325
- continue;
58326
- for (const block of askBlocks) {
58327
- if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
58328
- removed.add(block.id);
58329
- }
58330
- }
58331
- }
58332
- if (removed.size === 0)
58333
- return;
58334
- const asks = await blockAsks(client, resolved, "open");
58335
- const open = asks.filter((ask) => removed.has(ask.block_id));
58336
- if (open.length === 0)
58337
- return;
58338
- const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
58339
- throw new Error([
58340
- `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
58341
- ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
58342
- "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
58343
- ].join(`
58344
- `));
58345
- }
58346
58350
  async function docEditCommand(context) {
58347
58351
  const { args, client, actor, input, linkBase, documentOwner, resolveDocument } = context;
58348
58352
  const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
@@ -58468,11 +58472,18 @@ ${trailer.join(`
58468
58472
  } : { issue: resolved.issue?.key }
58469
58473
  };
58470
58474
  }
58475
+ var APPROVAL_REQUEST_OPEN_BLOCKS = {
58476
+ effect: "Answering one writes a new version, which would move this request to that version and leave it waiting on you.",
58477
+ remedy: "Do not request approval over an open block, even when a human asked for it. " + OPEN_BLOCK_ASK_THE_HUMAN + " When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. " + OPEN_BLOCK_WAIVED + ", write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
58478
+ };
58471
58479
  async function requestApprovalCommand(context) {
58472
58480
  const { args, client, actor, input, ownerArguments, documentOwner, resolveDocument } = context;
58473
58481
  const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
58474
58482
  const resolved = await resolveDocument(documentOwner(), artifactReference);
58475
- await refuseOpenDecisionBlocks(client, input.tool, resolved);
58483
+ await refuseOpenDecisionBlocks(client, resolved, {
58484
+ call: `dispatch ${commandName(input.tool)}`,
58485
+ ...APPROVAL_REQUEST_OPEN_BLOCKS
58486
+ });
58476
58487
  const includeVerification = optionalBoolean(args, "include_verification") === true;
58477
58488
  const result = await client.requestApproval(resolved.artifact.id, {
58478
58489
  actor,
@@ -65830,12 +65841,18 @@ var STORED_DELIVERY = "Every notification topic is stored (agent, dispatch, gith
65830
65841
  var NOT_SENT_GUIDE = "An error that says the message was not sent means nothing was stored, so the same message may " + "be sent again later.";
65831
65842
  var TOPIC_GUIDE = "Topic guide (all are under notifications.): agent.<session_id> (subscribe: own inbox); role.<role> " + "(publish-to; holders claim via envoy_role_set). > matches one or more trailing tokens and does not " + "match the base subject. Envoy registers the concrete base when you subscribe to <subject>.>, so " + "the recommended default remains github.<owner>.<repo>.pr.<n>.>. <owner> and <repo> are one token " + "each, with every dot in the name written _ (sjawhar/.github is github.sjawhar._github; " + "acme/site.io is github.acme.site_io), and a topic spelled with the dot receives nothing. " + "Default PR subscription: " + "github.<owner>.<repo>.pr.<n>.> (it receives the quiet PR family): pr.<n> (lifecycle: " + "opened/synchronize/closed; closed carries merged, merge_commit_sha, merged_by, head_sha), " + "pr.<n>.comment, pr.<n>.review, pr.<n>.mention, pr.<n>.checks (one settlement event per commit whose checks settle, the head or not, naming its sha: " + "passed/failed/cancelled/skipped check runs with failing names and URLs, check_runs, each check's latest run as " + "{name, id, conclusion} with conclusion GitHub's own word for that run where one is recorded (for example " + "success, skipped, neutral or timed_out; a skipped check ran nothing on that commit), and statuses, each commit status as " + "{context, state, created_at} with state success, failure or error and created_at the time GitHub created it, " + "left out when none is recorded; for each context keep the entry with the later created_at, and keep a context " + 'that a settlement leaves out as it was; re-fires with superseded_settlement: "true" ' + "when new runs appear, or a commit status is new or changes state, for the same commit). Other GitHub: issue.<n>, issue.<n>.comment, " + "issue.<n>.mention, mention, push.branch.<name>, push.tag.<name>, workflow.<file>.<action> (only " + "runs without an associated PR); slack.<team>.<channel>.message|mention and " + "slack.<team>.<channel>.thread.<ts>.message|mention; ghostwispr.<session>.<kind>; " + "whatsapp.<phone>.<jid>.<kind>; envoy.exceptions.<original-topic>.";
65832
65843
  var URGENCY_VALUES = EnvelopeSchema.shape.urgency.unwrap().options;
65844
+ var EXPECTS_REPLY_MEANINGS = {
65845
+ false: "no reply wanted",
65846
+ optional: "a reply is welcome; nothing waits on it",
65847
+ required: "the sender waits on the answer"
65848
+ };
65849
+ var EXPECTS_REPLY_GUIDE = EXPECTS_REPLY_VALUES.map((value) => `${JSON.stringify(value)} (${EXPECTS_REPLY_MEANINGS[`${value}`]})`).join(", ");
65833
65850
  function messageMetadataShape(schema) {
65834
65851
  return {
65835
65852
  in_reply_to: schema.string().optional(),
65836
65853
  supersedes: schema.string().optional(),
65837
- urgency: schema.enum(URGENCY_VALUES).describe("low | med | high | blocking: how soon the recipient should act, shown on its card. It does not deliver the message sooner or ahead of others.").optional(),
65838
- expects_reply: schema.literal(EXPECTS_REPLY_VALUES).describe("false | optional | required").optional(),
65854
+ urgency: schema.enum(URGENCY_VALUES).optional().describe("low | med | high | blocking: how soon the recipient should act, shown on its card. It does not deliver the message sooner or ahead of others."),
65855
+ expects_reply: schema.literal(EXPECTS_REPLY_VALUES).optional().describe(`One of these JSON values: ${EXPECTS_REPLY_GUIDE}.`),
65839
65856
  expires_at: schema.number({ int: true }).optional()
65840
65857
  };
65841
65858
  }
@@ -65898,7 +65915,7 @@ var envoyToolSpecs = [
65898
65915
  arguments: (schema) => ({
65899
65916
  session_id: schema.string().describe("Target session ID; find it with envoy_sessions or envoy_whoami."),
65900
65917
  ...messageArguments(schema),
65901
- idempotency_key: schema.string().describe("Only to send again a message whose envoy_send was not confirmed delivered: the idempotency_key that error named. Omit it for a new message.").optional()
65918
+ idempotency_key: schema.string().optional().describe("Only to send again a message whose envoy_send was not confirmed delivered: the idempotency_key that error named. Omit it for a new message.")
65902
65919
  }),
65903
65920
  operation: EnvoyToolOperation.send
65904
65921
  },
@@ -66238,7 +66255,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
66238
66255
 
66239
66256
  // package.json
66240
66257
  var name2 = "@sjawhar/claude-envoy";
66241
- var version2 = "6.2.3";
66258
+ var version2 = "6.3.1";
66242
66259
  var package_default = {
66243
66260
  name: name2,
66244
66261
  version: version2,
@@ -66249,7 +66266,7 @@ var package_default = {
66249
66266
  repository: { type: "git", url: "https://github.com/cybermonklabs/legion" },
66250
66267
  scripts: { channel: "bun bin/envoy-channel.ts", "verify-build": "bash scripts/verify-build.sh", prepack: "bash scripts/pack-skills.sh", postpack: "bash scripts/pack-skills.sh --restore", typecheck: "bun ../contracts/scripts/gen-api.ts && bunx tsc --noEmit", test: "bun test --timeout=60000", lint: "bunx biome check src/ hooks/ scripts/" },
66251
66268
  devDependencies: { "@biomejs/biome": "^2.3.14", "@legion/cipher-client": "workspace:*", "@legion/contracts": "workspace:*", "@legion/envoy-client": "workspace:*", "@legion/pi-shared": "workspace:*", "@legion/test-fixtures": "workspace:*", "@modelcontextprotocol/sdk": "^1.30.0", "bun-types": "latest", nats: "^2.29.2", typescript: "^5.3.0", zod: "4.3.6" },
66252
- legion: { daemonApiVersion: 280 }
66269
+ legion: { daemonApiVersion: 281 }
66253
66270
  };
66254
66271
 
66255
66272
  // ../envoy-client/src/inbound-card.ts
@@ -67743,6 +67760,7 @@ var LegionInstant = timestamp.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)
67743
67760
  var LEGION_WORKFLOW_PHASES = [
67744
67761
  "admitted",
67745
67762
  "awaiting_person",
67763
+ "awaiting_children",
67746
67764
  "planning",
67747
67765
  "implementing",
67748
67766
  "testing",
@@ -67919,13 +67937,29 @@ var legionGateView = object({
67919
67937
  approvedVersion: number2().int().positive().nullable().optional()
67920
67938
  });
67921
67939
  var legionDesignStep = _enum2(GATED_STEPS);
67940
+ var legionGatedStepBasis = object({
67941
+ issue: issueKey,
67942
+ artifactId: nonEmptyString2.optional(),
67943
+ version: number2().int().positive(),
67944
+ approver: nonEmptyString2.optional(),
67945
+ approvedAt: timestamp.optional(),
67946
+ askId: nonEmptyString2.optional()
67947
+ });
67922
67948
  var legionGatedStepView = object({
67923
67949
  step: legionDesignStep.optional(),
67924
67950
  artifactId: nonEmptyString2.optional(),
67925
67951
  currentVersion: number2().int().positive().optional(),
67926
67952
  approvedVersion: number2().int().positive().nullable().optional(),
67927
- status: _enum2(["unregistered", "waiting", "approved", "changes_requested"]).optional(),
67928
- changesReason: nonEmptyString2.optional()
67953
+ status: _enum2([
67954
+ "unregistered",
67955
+ "waiting",
67956
+ "approved",
67957
+ "changes_requested",
67958
+ "open_on_basis",
67959
+ "pending_on_basis"
67960
+ ]).optional(),
67961
+ changesReason: nonEmptyString2.optional(),
67962
+ basis: legionGatedStepBasis.optional()
67929
67963
  });
67930
67964
  var legionSlotView = object({
67931
67965
  index: number2().int().nonnegative().optional(),
@@ -68040,6 +68074,7 @@ var legionIssue = object({
68040
68074
  phase: _enum2(LEGION_PHASES),
68041
68075
  status: nonEmptyString2.optional(),
68042
68076
  tree: issueKey.optional(),
68077
+ treeRuns: boolean2().optional(),
68043
68078
  repo: nonEmptyString2.optional(),
68044
68079
  defaultBranch: nonEmptyString2.optional(),
68045
68080
  holdReason: _enum2(["escalated", "task-stopped", "children"]).optional(),
@@ -68092,6 +68127,7 @@ var LEGION_HELD_REASONS = [
68092
68127
  "label_off",
68093
68128
  "ancestry",
68094
68129
  "root_awaiting_person",
68130
+ "awaiting_children",
68095
68131
  "design_gate",
68096
68132
  "dispatch_blocker",
68097
68133
  "children_first",
@@ -68605,7 +68641,10 @@ var LegionGateRegisterRequest = strictObject({
68605
68641
  issue: nonEmptyString2,
68606
68642
  artifactId: uuid2(),
68607
68643
  version: number2().int().positive(),
68608
- step: legionDesignStep.optional()
68644
+ step: legionDesignStep.optional(),
68645
+ basisArtifactId: uuid2().optional(),
68646
+ basisVersion: number2().int().positive().optional(),
68647
+ reason: nonEmptyString2.optional()
68609
68648
  });
68610
68649
  var LegionWaveReleaseRequest = strictObject({
68611
68650
  grantId: nonEmptyString2,
@@ -68668,6 +68707,12 @@ var ISSUE_RECORD_READS = [
68668
68707
  "designGate",
68669
68708
  "designGate.currentVersion",
68670
68709
  "designGate.approvedVersion",
68710
+ "gatedSteps",
68711
+ "gatedSteps[].step",
68712
+ "gatedSteps[].status",
68713
+ "gatedSteps[].basis",
68714
+ "gatedSteps[].basis.issue",
68715
+ "gatedSteps[].basis.version",
68671
68716
  "slot",
68672
68717
  "slot.index",
68673
68718
  "slot.admittedAt",
@@ -70176,7 +70221,7 @@ function phaseOpParameters(zod) {
70176
70221
  return byField;
70177
70222
  }
70178
70223
  var PHASE_OP_SENTENCES = {
70179
- readRecord: "read_record returns the record of `issue` from the daemon's record route for that issue, your own issue when you leave `issue` out. " + "A held issue names in `heldFrom` the phase the hold took it out of, and in `holdReason` why it is held when its hold has a reason: " + "`escalated` (its architect sent it to the controller), `task-stopped` (its owner stopped its task with stop_task) or `children` (it " + "waits, before its retro, for the issues beneath it). A failed claim carries `failure`: the " + "`cause` word for what failed it, the `detail` sentence beside that word, `at`, when it failed, and " + "`attempts`, the four counts it failed with. A todo written on a held root releases the hold and starts " + "that phase again, as the architect's retry_or_escalate with retry does, but a root held `task-stopped` starts its task again at its " + "first step (a task that never started waits for its gate and its line, as any task does before its first step), and a root held " + "`children` stays held until the issues beneath it close. ",
70224
+ readRecord: "read_record returns the record of `issue` from the daemon's record route for that issue, your own issue when you leave `issue` out. " + "A held issue names in `heldFrom` the phase the hold took it out of, and in `holdReason` why it is held when its hold has a reason: " + "`escalated` (its architect sent it to the controller), `task-stopped` (its owner stopped its task with stop_task) or `children` (it " + "waits, before its retro, for the issues beneath it, the roots that rest on its approval or its open Dispatch children). A failed claim carries `failure`: the " + "`cause` word for what failed it, the `detail` sentence beside that word, `at`, when it failed, and " + "`attempts`, the four counts it failed with. A todo written on a held root releases the hold and starts " + "that phase again, as the architect's retry_or_escalate with retry does, but a root held `task-stopped` starts its task again at its " + "first step (a task that never started waits for its gate and its line, as any task does before its first step), and a root held " + "`children` stays held until none of those holds it any longer. ",
70180
70225
  readReleaseRecords: "read_release_records returns this deployment's idle-release records from `since` (an RFC 3339 time) on, read with this session's own claim: " + "every release, resume and hold the daemon recorded, and over them the counts of releases, of the releases among them that suspended no " + "role, of resumes by wake kind and of holds by reason, the pod-hours released, the share of releases woken again within ten minutes, and " + "the median, 90th percentile and maximum seconds from a wake to the woken role's first turn. A wake that a project pause held is " + "counted as `heldByPause` and left out of those seconds, since its wait measures the pause. A release that suspended no role is woken by " + "nothing, so the pod-hours released and the woken share count the releases that suspended a role alone. ",
70181
70226
  requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`). A phase worker moves its own issue. " + "The architect that owns an issue in accepting moves it, named by `issue`, back to the phase of an earlier step of its task. " + "That move counts no review round: only a review that requests changes counts one. ",
70182
70227
  readBuild: "read_build reports the build this process runs: the plugin package and version the process loaded, and the contract that build speaks. " + "It also reports the contract the daemon states on its answer to the health route. " + "That contract is null where the daemon stated none, where the daemon refused the health route and where no answer reached this process at all, and a note of its own says which. " + "The two numbers can differ, and the answer shows both. " + "Report the version this call answers, never the one at the plugin's path on the image. " + "In a pod, an Oh My Pi role relaunched onto the daemon's contract loads the build that relaunch installed under the role's own state home, " + "and a Claude Code role installs no plugin: it loads its pod image's own claude-envoy. " + "read_build reads no project state. "
@@ -33175,6 +33175,95 @@ async function sendToAgentCommand(context) {
33175
33175
  // ../envoy-client/src/dispatch-commands/documents.ts
33176
33176
  import { resolve as resolvePath3 } from "path";
33177
33177
 
33178
+ // ../envoy-client/src/dispatch-commands/open-decision-blocks.ts
33179
+ async function blockAsks(client, resolved, state) {
33180
+ const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
33181
+ return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
33182
+ }
33183
+ var OPEN_BLOCK_ASK_THE_HUMAN = "Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds.";
33184
+ var OPEN_BLOCK_WAIVED = "If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason)";
33185
+ async function refuseOpenDecisionBlocks(client, resolved, refusal) {
33186
+ const artifact = resolved.artifact;
33187
+ const latest = artifact.approval?.latest_version;
33188
+ if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
33189
+ return;
33190
+ const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
33191
+ if (blocks.length === 0)
33192
+ return;
33193
+ const [documentAsks, version] = await Promise.all([
33194
+ blockAsks(client, resolved),
33195
+ client.docRead(artifact.id, latest)
33196
+ ]);
33197
+ const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
33198
+ const lines = version.markdown.split(`
33199
+ `);
33200
+ const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
33201
+ const open = blocks.flatMap((block) => {
33202
+ const ask = asks.get(block.id);
33203
+ const id = typedBlockIdAttribute(block.id);
33204
+ const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
33205
+ const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
33206
+ const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
33207
+ if (states.length === 0)
33208
+ return [`${named}, which version ${latest} does not hold yet`];
33209
+ if (!states.includes("open") && states.some((state) => state !== undefined))
33210
+ return [];
33211
+ if (ask !== undefined)
33212
+ return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
33213
+ const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
33214
+ const sourceId = attribute("copied_from");
33215
+ const document = attribute("copied_from_document");
33216
+ if (sourceId === undefined || document === undefined) {
33217
+ return [`${named}, whose ask Dispatch has not opened yet`];
33218
+ }
33219
+ const source = parseDispatchRef(document);
33220
+ const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
33221
+ const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
33222
+ return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
33223
+ });
33224
+ if (open.length === 0)
33225
+ return;
33226
+ const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
33227
+ throw new Error([
33228
+ `${refusal.call} was not called: ${artifact.name} (version ${latest}) has ${count}. ${refusal.effect}`,
33229
+ ...open.map((line) => `- ${line}`),
33230
+ refusal.remedy
33231
+ ].join(`
33232
+ `));
33233
+ }
33234
+ async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
33235
+ const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
33236
+ if (removing.length === 0)
33237
+ return;
33238
+ const artifact = resolved.artifact;
33239
+ const blocks = await client.artifactBlocks(artifact.id);
33240
+ const askBlocks = blocks.filter((block) => block.type === "ask");
33241
+ const removed = new Set;
33242
+ for (const operation of removing) {
33243
+ const target = blocks.find((block) => block.id === operation.block);
33244
+ if (target === undefined)
33245
+ continue;
33246
+ for (const block of askBlocks) {
33247
+ if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
33248
+ removed.add(block.id);
33249
+ }
33250
+ }
33251
+ }
33252
+ if (removed.size === 0)
33253
+ return;
33254
+ const asks = await blockAsks(client, resolved, "open");
33255
+ const open = asks.filter((ask) => removed.has(ask.block_id));
33256
+ if (open.length === 0)
33257
+ return;
33258
+ const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
33259
+ throw new Error([
33260
+ `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
33261
+ ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
33262
+ "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
33263
+ ].join(`
33264
+ `));
33265
+ }
33266
+
33178
33267
  // ../envoy-client/src/dispatch-commands/stored-text.ts
33179
33268
  import { resolve as resolvePath2 } from "path";
33180
33269
 
@@ -33706,10 +33795,6 @@ function artifactNameExistsProblem(held, owner, upload) {
33706
33795
  }
33707
33796
 
33708
33797
  // ../envoy-client/src/dispatch-commands/documents.ts
33709
- async function blockAsks(client, resolved, state) {
33710
- const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
33711
- return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
33712
- }
33713
33798
  async function readUploadedFile(client, artifact, details, requested, owner, shown) {
33714
33799
  const versions = artifact.versions ?? [];
33715
33800
  const latest = Math.max(0, ...versions.map((version) => version.number));
@@ -33801,87 +33886,6 @@ async function listDocumentBlocks(client, artifact) {
33801
33886
  return { text: lines.join(`
33802
33887
  `), token: live.token, version: live.version };
33803
33888
  }
33804
- async function refuseOpenDecisionBlocks(client, tool, resolved) {
33805
- const artifact = resolved.artifact;
33806
- const latest = artifact.approval?.latest_version;
33807
- if (latest === undefined || latest < 1 || artifact.approval?.state === "approved")
33808
- return;
33809
- const blocks = (await client.artifactBlocks(artifact.id)).filter((block) => block.type === "ask");
33810
- if (blocks.length === 0)
33811
- return;
33812
- const [documentAsks, version] = await Promise.all([
33813
- blockAsks(client, resolved),
33814
- client.docRead(artifact.id, latest)
33815
- ]);
33816
- const asks = new Map(documentAsks.map((ask) => [ask.block_id, ask]));
33817
- const lines = version.markdown.split(`
33818
- `);
33819
- const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
33820
- const open = blocks.flatMap((block) => {
33821
- const ask = asks.get(block.id);
33822
- const id = typedBlockIdAttribute(block.id);
33823
- const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
33824
- const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
33825
- const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
33826
- if (states.length === 0)
33827
- return [`${named}, which version ${latest} does not hold yet`];
33828
- if (!states.includes("open") && states.some((state) => state !== undefined))
33829
- return [];
33830
- if (ask !== undefined)
33831
- return ask.state === "open" ? [named] : [stillOpen(named, ask.state)];
33832
- const attribute = (name) => openers.map((line) => new RegExp(`\\b${name}="([^"]+)"`).exec(line)?.[1]).find((value) => value !== undefined);
33833
- const sourceId = attribute("copied_from");
33834
- const document = attribute("copied_from_document");
33835
- if (sourceId === undefined || document === undefined) {
33836
- return [`${named}, whose ask Dispatch has not opened yet`];
33837
- }
33838
- const source = parseDispatchRef(document);
33839
- const where = source === null ? document : source.owner.kind === "project" ? documentLabel(source.owner.project, source.id) : `${source.owner.issue} ${source.id}`;
33840
- const ref = source?.owner.kind === "issue" ? dispatchChildRef(dispatchIssueRef(source.owner.issue), "ask", sourceId) : dispatchChildRef(document, "ask", sourceId);
33841
- return [`${named}, a copy of ask ${ref}, which is open on ${where}: answer it there`];
33842
- });
33843
- if (open.length === 0)
33844
- return;
33845
- const count = open.length === 1 ? "1 open decision block" : `${open.length} open decision blocks`;
33846
- throw new Error([
33847
- `dispatch ${commandName(tool)} was not called: ${artifact.name} (version ${latest}) has ${count}. Answering one writes a new version, which would move this request to that version and leave it waiting on you.`,
33848
- ...open.map((line) => `- ${line}`),
33849
- "Do not request approval over an open block, even when a human asked for it. Tell the human which block is open and ask them to answer it or to waive it. Once it is answered, it settles into a version on its own in about two seconds. When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. If they waive it, close the block with dispatch resolve-ask (--kind resolved, their words as the --reason), write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
33850
- ].join(`
33851
- `));
33852
- }
33853
- async function refuseRemovingOpenDecisionBlocks(client, tool, resolved, ops) {
33854
- const removing = ops.filter((operation) => operation.block !== undefined && (operation.op === "delete" || operation.op === "retype" && operation.type !== "ask"));
33855
- if (removing.length === 0)
33856
- return;
33857
- const artifact = resolved.artifact;
33858
- const blocks = await client.artifactBlocks(artifact.id);
33859
- const askBlocks = blocks.filter((block) => block.type === "ask");
33860
- const removed = new Set;
33861
- for (const operation of removing) {
33862
- const target = blocks.find((block) => block.id === operation.block);
33863
- if (target === undefined)
33864
- continue;
33865
- for (const block of askBlocks) {
33866
- if (block.id === target.id || operation.op === "delete" && block.from >= target.from && block.to <= target.to) {
33867
- removed.add(block.id);
33868
- }
33869
- }
33870
- }
33871
- if (removed.size === 0)
33872
- return;
33873
- const asks = await blockAsks(client, resolved, "open");
33874
- const open = asks.filter((ask) => removed.has(ask.block_id));
33875
- if (open.length === 0)
33876
- return;
33877
- const [what, question] = open.length === 1 ? ["a decision block whose ask is", "question"] : [`${open.length} decision blocks whose asks are`, "questions"];
33878
- throw new Error([
33879
- `dispatch ${commandName(tool)} was not called: it would remove ${what} still open, and the human's ${question} would leave their Inbox unanswered.`,
33880
- ...open.map((ask) => `- ${JSON.stringify(ask.question)} (block ${ask.block_id}, ask ${ask.id})`),
33881
- "A decision block leaves the document once its ask is answered or resolved. Until then, reword it with replace, relocate it with move, or change its question, options, urgency or multiple with dispatch edit-ask if you asked it; each keeps it."
33882
- ].join(`
33883
- `));
33884
- }
33885
33889
  async function docEditCommand(context) {
33886
33890
  const { args, client, actor, input, linkBase, documentOwner, resolveDocument } = context;
33887
33891
  const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
@@ -34007,11 +34011,18 @@ ${trailer.join(`
34007
34011
  } : { issue: resolved.issue?.key }
34008
34012
  };
34009
34013
  }
34014
+ var APPROVAL_REQUEST_OPEN_BLOCKS = {
34015
+ effect: "Answering one writes a new version, which would move this request to that version and leave it waiting on you.",
34016
+ remedy: "Do not request approval over an open block, even when a human asked for it. " + OPEN_BLOCK_ASK_THE_HUMAN + " When the human approved an earlier version and their answer is the whole change since it, Dispatch carries the approval to the new version in their name: request nothing. When the answer changes design text outside the block, rewrite that text (never to restate the answer), then request approval again once the human has agreed to every point in the new version, with a one-sentence --summary naming what changed since the earlier approval. On a document nobody has approved, wait for that version, then request. " + OPEN_BLOCK_WAIVED + ", write their decision into the text with dispatch doc-edit, then request approval again once the human has agreed to every point in the new version. The call opens the request, or hands an open one back to the human."
34017
+ };
34010
34018
  async function requestApprovalCommand(context) {
34011
34019
  const { args, client, actor, input, ownerArguments, documentOwner, resolveDocument } = context;
34012
34020
  const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
34013
34021
  const resolved = await resolveDocument(documentOwner(), artifactReference);
34014
- await refuseOpenDecisionBlocks(client, input.tool, resolved);
34022
+ await refuseOpenDecisionBlocks(client, resolved, {
34023
+ call: `dispatch ${commandName(input.tool)}`,
34024
+ ...APPROVAL_REQUEST_OPEN_BLOCKS
34025
+ });
34015
34026
  const includeVerification = optionalBoolean(args, "include_verification") === true;
34016
34027
  const result = await client.requestApproval(resolved.artifact.id, {
34017
34028
  actor,
@@ -22,7 +22,10 @@ owns the document.
22
22
  and what each would cost.
23
23
  3. **A requirement nothing can check.** A `requirement` block of the spec that no `check` block of
24
24
  the issue's Verification document serves, and a check with no command, test or request whose
25
- expected output decides it.
25
+ expected output decides it. A requirement whose text starts `Delivered by` after its number and
26
+ any title and names the issue that delivers it needs no plan task and no check in this issue's
27
+ own documents, whatever that issue's parent, since that issue's checks serve it, and a view's
28
+ requirements are the parts of its ancestor's requirements that its `Delivers:` line names.
26
29
  4. **Claims and requirements with no source.** A statement about how a system works today that the
27
30
  code, its documentation or a read-only command does not show. Also, when the caller gave you the
28
31
  owner's words to check the document against, a requirement that traces to neither them nor a
@@ -28,7 +28,11 @@ it out without getting stuck? You find blockers, not improvements.
28
28
  3. **Contradictions.** No two steps contradict each other, and no step contradicts a `check` block
29
29
  of the issue's Verification document or a `requirement` block of its spec.
30
30
  4. **Every requirement is served.** Each `requirement` block the spec marks is named in the
31
- `serves` of at least one `plan_task`, and each `check` has a task that makes it pass.
31
+ `serves` of at least one `plan_task`, and each `check` has a task that makes it pass. A
32
+ requirement whose text starts `Delivered by` after its number and any title and names the issue
33
+ that delivers it needs no task and no check in this issue's own documents, whatever that
34
+ issue's parent, since that issue's checks serve it, and a view's requirements are the parts of
35
+ its ancestor's requirements that its `Delivers:` line names.
32
36
  5. **A check that waits too long.** A check marked `after_merge` that could be run before the
33
37
  merge is a blocking issue: it moves the proof past the gate that would have caught it.
34
38
  6. **The goal and the requirements.** The plan delivers the issue's goal and every requirement of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "6.2.3",
3
+ "version": "6.3.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -45,6 +45,6 @@
45
45
  "zod": "4.3.6"
46
46
  },
47
47
  "legion": {
48
- "daemonApiVersion": 280
48
+ "daemonApiVersion": 281
49
49
  }
50
50
  }