@sjawhar/pi-envoy 15.1.1 → 15.1.3

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/README.md CHANGED
@@ -284,6 +284,13 @@ dispatch artifact --issue LEGION-1 --name spec.md --content-file - <<'EOF'
284
284
  EOF
285
285
  ```
286
286
 
287
+ Inline content is stored as a Markdown document, so `--content` and `--content-file` take only a
288
+ `--name` that ends in `.md` or `.markdown` or has no extension. The command refuses any other name
289
+ (`rows.jsonl`, `sizes.tsv`, `rows.jsonl.1`, `plan v1.2`) before it sends anything and names
290
+ `--path`, which stores a file whose path does not end in `.md` or `.markdown` as its bytes,
291
+ unchanged, under that name. A document title with a dot near its end takes `--content` once it
292
+ ends in `.md`.
293
+
287
294
  `dispatch handoff-write --issue <KEY> --phase <phase> --body-file <path>` records a Legion phase
288
295
  handoff on its issue as this session: the file's text, one JSON object, is stored exactly as
289
296
  written, and each write is the phase's next version. Keep the file outside the workspace (such as
@@ -342,10 +349,12 @@ before any call of that message runs. So the gate reads a file before an earlier
342
349
  message writes or edits it. A file that is not there yet is refused in `block` mode with the
343
350
  advice to send the call again in a later message; in `warn` mode the call runs unreviewed, with
344
351
  that advice as its note. A file that an earlier call changed is refused by the CLI in `block` mode
345
- (`… AskGate reviews the calls of a message before any of them runs, so it did not review that
346
- change. Send the call again in a later message.`); in `warn` mode it posts with a
352
+ when a review, a rebuttal or a breaker trip stands behind the call (`… AskGate reads the files of a
353
+ message's calls before any of them runs, so it did not see that change. Send the call again in a
354
+ later message than the one that changes the file.`); in `warn` mode it posts with a
347
355
  `dispatch: warning:` line. Write or edit a file in one message, and send the write that posts it
348
- in the next.
356
+ in the next. A call the gate reviewed nothing of (a halt, a session whose model is on another
357
+ provider, a review that failed) checks no file, so its file posts as the CLI reads it.
349
358
 
350
359
  **The form the gate reads.** One `dispatch` call, alone in the bash call:
351
360
 
@@ -391,11 +400,12 @@ gated write only when it consumes one, so a write sent any other way is refused
391
400
  record pi-envoy cannot write is a notice in the session, at start or at a switch.
392
401
  - **The marker.** The gate mints one file in the store for each literal call it lets run, created
393
402
  owner-only and exclusively. It binds the exact argument vector the CLI receives and, behind a
394
- review or a deliberate pass (a rebuttal, a breaker trip, a halt, another provider), the digest
395
- of the arguments the dry run printed and the sha256 of each file the argv names, as the gate
396
- read it. A call no verdict stands behind, and a `task` subagent's literal call, get a marker of
397
- the argument vector alone. Nothing of it is in the command the agent sees. A marker goes when
398
- its call ends, is refused or the session shuts down; a backgrounded call keeps its marker until
403
+ review or a deliberate pass (a rebuttal, a breaker trip), the digest of the arguments the dry
404
+ run printed and the sha256 of each file the argv names, as the gate read it. A call no verdict
405
+ stands behind (a halt and another provider among them), and a `task` subagent's literal call,
406
+ get a marker of the argument vector alone. Nothing of it is in the command the agent sees. A
407
+ marker goes when its call ends, is refused or the session shuts down; a backgrounded call keeps
408
+ its marker until
399
409
  shutdown, and a marker older than two hours, longer than any tool's time limit, is refused and
400
410
  removed. The process removes its store when it exits; the CLI's daily session pruning removes
401
411
  the store of a process that is gone and that nothing changed for two hours.
package/dist/dispatch.js CHANGED
@@ -1234,7 +1234,7 @@ function consumeMarker(stores, argv, args, files, now) {
1234
1234
  if (changed !== undefined)
1235
1235
  return {
1236
1236
  ok: false,
1237
- why: `a file this write posts changed after AskGate reviewed it (\`${changed.flag} ${changed.operand}\`)`,
1237
+ why: `a file this write posts changed after AskGate read it (\`${changed.flag} ${changed.operand}\`)`,
1238
1238
  changed
1239
1239
  };
1240
1240
  return {
@@ -14913,6 +14913,25 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
14913
14913
  message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
14914
14914
  };
14915
14915
  }
14916
+ var ARTIFACT_OWNER_AND_SOURCE_RULE = "Exactly one of path or content is required. Exactly one of issue and project is required; with project, artifact names the document.";
14917
+ var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
14918
+ var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
14919
+ var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
14920
+ var NAME_EXTENSION = /\.([^\s.]+)$/u;
14921
+ var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
14922
+ var artifactOwner = documentOwnerValidation(false);
14923
+ function artifactProblem(value) {
14924
+ const input = value;
14925
+ if (!artifactOwner.check(value) || typeof input.path === "string" === (typeof input.content === "string")) {
14926
+ return ARTIFACT_OWNER_AND_SOURCE_RULE;
14927
+ }
14928
+ if (typeof input.content !== "string" || typeof input.name !== "string")
14929
+ return;
14930
+ const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
14931
+ if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
14932
+ return;
14933
+ return `${CONTENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; content takes a name ending in .md or .markdown or with no extension.`;
14934
+ }
14916
14935
  var documentEditOwner = documentOwnerValidation(true);
14917
14936
  var documentEditValidation = {
14918
14937
  check: (value) => {
@@ -14960,7 +14979,7 @@ var messageValidation = {
14960
14979
  },
14961
14980
  message: "issue is required unless in_reply_to names a message delivered to this session, which is the one message with no issue."
14962
14981
  };
14963
- var readOwner = documentOwnerValidation(true);
14982
+ var readOwner = documentOwnerValidation(false);
14964
14983
  var readValidation = {
14965
14984
  check: (value) => {
14966
14985
  const input = value;
@@ -14968,7 +14987,7 @@ var readValidation = {
14968
14987
  return readOwner.check(value);
14969
14988
  return input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
14970
14989
  },
14971
- message: `${readOwner.message} message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.`
14990
+ message: "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one. " + "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it."
14972
14991
  };
14973
14992
  var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
14974
14993
  function componentsArgument(z) {
@@ -15227,7 +15246,7 @@ var dispatchToolSpecs = [
15227
15246
  body: z.string({ max: DISPATCH_BODY_MAX }).describe(`Review comment, at most ${DISPATCH_BODY_MAX} characters.`),
15228
15247
  reply_to: z.string().describe("A comment id (uuid); replying to any comment in a thread continues that thread (an " + "ask's clarification thread included). A block reference to one block of the comment " + "(dispatch://KEY/comment/<id>#b-<block id>) replies to that comment and names the " + "passage the reply answers. To reply to an ask, use reply_to_ask with the ask id, or " + "with a reference to one of its parts, instead.").optional(),
15229
15248
  reply_to_ask: z.string().describe("Optional ask id to reply to, threading this comment under that question. A block " + "reference to one part of the ask (dispatch://KEY/ask/<id>#b-<part id>, the id an " + "option or the answer carries) threads under that ask and names the part the reply " + "answers. Mutually exclusive with reply_to.").optional(),
15230
- turn: z.enum(["agent", "human"]).describe("Only with reply_to_ask: who holds the turn after this reply. agent: a progress note - " + "you keep the turn and the ask stays 'Waiting on agents' for the human; human (default): " + "you need the human to act - the ask returns to 'Waiting on you'.").optional(),
15249
+ turn: z.enum(["agent", "human"]).describe("Only with reply_to_ask: who holds the turn after this reply. agent: a progress note - " + "you keep the turn and the ask stays 'Waiting on agents' for the human; human (default): " + "you need the human to act - the ask returns to 'Waiting on you'. human does not " + "apply to an approval request a newer version moved: it stays with you until dispatch " + "request-approval hands it back at the current version.").optional(),
15231
15250
  images: imagesArgument(z, "the issue (or the project document's project)", `the ${DISPATCH_BODY_MAX}-character body limit`)
15232
15251
  }),
15233
15252
  validation: commentValidation
@@ -15333,27 +15352,25 @@ var dispatchToolSpecs = [
15333
15352
  name: "dispatch_artifact",
15334
15353
  example: { issue: "DSP-1", name: "design.md", content: `# Design
15335
15354
  ` },
15336
- description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
15355
+ description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
15337
15356
  arguments: (z) => ({
15338
15357
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15339
15358
  project: z.string().describe("Project key for an unlinked document.").optional(),
15340
15359
  name: z.string().describe("Artifact filename shown in Dispatch."),
15341
15360
  path: z.string().describe("Local path to the file to upload.").optional(),
15342
- content: z.string().describe("Inline text to store as a Markdown document; a CR LF or a lone carriage return in it is stored as a line feed.").optional(),
15361
+ content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension; a CR LF or a lone carriage return in it is stored as a line feed.").optional(),
15343
15362
  summary: z.string().describe("Optional version summary.").optional()
15344
15363
  }),
15345
15364
  validation: {
15346
- check: (value) => {
15347
- const input = value;
15348
- return documentOwnerValidation(false).check(value) && typeof input.path === "string" !== (typeof input.content === "string");
15349
- },
15350
- message: "Exactly one of path or content is required. Exactly one of issue and project is required; with project, artifact names the document."
15365
+ check: (value) => artifactProblem(value) === undefined,
15366
+ message: `${ARTIFACT_OWNER_AND_SOURCE_RULE} ${ARTIFACT_CONTENT_NAME_RULE}`,
15367
+ refusal: (value) => artifactProblem(value) ?? ARTIFACT_OWNER_AND_SOURCE_RULE
15351
15368
  }
15352
15369
  },
15353
15370
  {
15354
15371
  name: "dispatch_read",
15355
15372
  example: { issue: "DSP-1" },
15356
- description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), or project plus artifact; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Document:`, `Changed in version:` and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
15373
+ description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Document:`, `Changed in version:` and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
15357
15374
  arguments: (z) => ({
15358
15375
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15359
15376
  project: z.string().describe("Project key owning the document.").optional(),
@@ -16609,22 +16626,25 @@ class DispatchWriteUnsettledError extends Error {
16609
16626
  last;
16610
16627
  attempts;
16611
16628
  name = "DispatchWriteUnsettledError";
16612
- constructor(last, attempts, unanswered) {
16629
+ constructor(last, attempts, unanswered, keyed = false) {
16613
16630
  let answer;
16614
16631
  let why = "an earlier attempt of the write may have reached Dispatch";
16615
16632
  if (last instanceof DispatchGatewayError) {
16616
16633
  answer = last.answer;
16634
+ } else if (last instanceof DispatchServiceError && last.code === IDEMPOTENCY_KEY_IN_FLIGHT) {
16635
+ answer = last.code;
16636
+ why = "Dispatch was still running an earlier attempt of the write";
16617
16637
  } else if (last instanceof DispatchServiceError) {
16618
16638
  answer = `${last.code}: ${last.message}`;
16619
- if (last.code === IDEMPOTENCY_KEY_IN_FLIGHT) {
16620
- why = "Dispatch was still running an earlier attempt of the write";
16621
- }
16622
16639
  } else {
16623
16640
  answer = unanswered ?? last.message;
16624
16641
  why = "an attempt of the write may have reached Dispatch";
16625
16642
  }
16626
16643
  const tried = attempts === 1 ? "its only attempt" : `the last of ${attempts} attempts`;
16627
- super(`${answer} (${tried}), and ${why}, so it may or may not have taken effect: check whether ` + "it did before retrying it.", { cause: last });
16644
+ const next = keyed ? ". Dispatch finishes an attempt it received whatever this command does, so read the " + "write back before you send it again: a new command sends it under a new key." : ": check whether it did before retrying it.";
16645
+ super(`${answer} (${tried}), and ${why}, so it may or may not have taken effect${next}`, {
16646
+ cause: last
16647
+ });
16628
16648
  this.last = last;
16629
16649
  this.attempts = attempts;
16630
16650
  }
@@ -16659,7 +16679,9 @@ function requestSignal(signal) {
16659
16679
  var DISPATCH_WRITE_RETRY = {
16660
16680
  pausesMs: [1000, 2000, 4000, 8000],
16661
16681
  withinMs: 30000,
16662
- silenceMs: 20000
16682
+ silenceMs: 20000,
16683
+ inFlightPauseMs: 3000,
16684
+ inFlightWithinMs: 55000
16663
16685
  };
16664
16686
  function pauseFor(ms, signal) {
16665
16687
  const { promise, resolve, reject } = Promise.withResolvers();
@@ -16754,7 +16776,7 @@ var NULL_BODY_STATUSES = new Set([101, 204, 205, 304]);
16754
16776
  async function writeAnswer(response, key) {
16755
16777
  const echoed = keyEchoed(response, key);
16756
16778
  if (response.ok || NULL_BODY_STATUSES.has(response.status)) {
16757
- return { response, again: false, reached: false, echoed, unjudged: false };
16779
+ return { response, again: false, reached: false, running: false, echoed, unjudged: false };
16758
16780
  }
16759
16781
  const { status } = response;
16760
16782
  const text = await response.text();
@@ -16767,6 +16789,7 @@ async function writeAnswer(response, key) {
16767
16789
  }
16768
16790
  }
16769
16791
  const again = retriesUnderKey(status, shape.code);
16792
+ const running = again && status === 409;
16770
16793
  return {
16771
16794
  response: new Response(text, {
16772
16795
  status,
@@ -16774,7 +16797,8 @@ async function writeAnswer(response, key) {
16774
16797
  headers: response.headers
16775
16798
  }),
16776
16799
  again,
16777
- reached: status >= 500 || again && status === 409,
16800
+ reached: status >= 500 || running,
16801
+ running,
16778
16802
  echoed,
16779
16803
  unjudged: !echoed && typeof shape.error === "string"
16780
16804
  };
@@ -16867,12 +16891,14 @@ class DispatchClient {
16867
16891
  #baseUrl;
16868
16892
  #resolvedIssues = new Map;
16869
16893
  #signal;
16894
+ #madeAt;
16870
16895
  constructor(baseUrl, token, fetchImpl = fetch, signal, writeRetry = DISPATCH_WRITE_RETRY) {
16871
16896
  this.token = token;
16872
16897
  this.fetchImpl = fetchImpl;
16873
16898
  this.writeRetry = writeRetry;
16874
16899
  this.#baseUrl = baseUrl.replace(/\/+$/, "");
16875
16900
  this.#signal = requestSignal(signal);
16901
+ this.#madeAt = this.#now();
16876
16902
  }
16877
16903
  async issue(input) {
16878
16904
  const answer = await this.#jsonAnswer("POST", ["api", "v1", "issues"], input);
@@ -17276,10 +17302,16 @@ class DispatchClient {
17276
17302
  }
17277
17303
  const key = callerKey ?? crypto.randomUUID();
17278
17304
  headers[IDEMPOTENCY_KEY_HEADER] = key;
17279
- const { pausesMs, withinMs, silenceMs, pause = pauseFor } = this.writeRetry;
17305
+ const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
17306
+ const pause = this.writeRetry.pause ?? pauseFor;
17280
17307
  const request = `${method} ${url}`;
17281
17308
  const started = this.#now();
17309
+ const bodyBytes = body === undefined ? 0 : typeof body.content === "string" ? Buffer.byteLength(body.content) : body.content.byteLength;
17310
+ const upload = bodyBytes >= STREAMED_BODY_MIN;
17311
+ const lastAsk = this.#madeAt + inFlightWithinMs;
17282
17312
  let reached = false;
17313
+ let running = false;
17314
+ let sawKeyedLayer = false;
17283
17315
  for (let attempt = 1;; attempt++) {
17284
17316
  let answer;
17285
17317
  let thrown;
@@ -17290,34 +17322,43 @@ class DispatchClient {
17290
17322
  if (!answer.again)
17291
17323
  return answer.response;
17292
17324
  reached ||= answer.reached;
17325
+ running ||= answer.running && !upload;
17326
+ sawKeyedLayer ||= answer.echoed;
17293
17327
  } catch (error) {
17294
17328
  const name = error instanceof Error || error instanceof DOMException ? error.name : "";
17295
17329
  if (!(error instanceof WriteAttemptSilent) && (this.#signal.aborted || name === "AbortError" || name === "TimeoutError")) {
17296
- throw this.#ended(error, request, attempt, true);
17330
+ throw this.#ended(error, request, attempt, true, sawKeyedLayer);
17297
17331
  }
17298
17332
  thrown = error;
17299
17333
  reached = true;
17334
+ running ||= error instanceof WriteAttemptSilent && !upload;
17300
17335
  }
17301
- const scheduled = pausesMs[attempt - 1];
17336
+ const scheduled = running ? Math.min(pausesMs[attempt - 1] ?? inFlightPauseMs, inFlightPauseMs) : pausesMs[attempt - 1];
17302
17337
  const wait = Math.max(scheduled ?? 0, answer === undefined ? 0 : retryAfterMs(answer.response));
17303
- const inTime = scheduled !== undefined && this.#now() - started + wait <= withinMs;
17304
- if (!inTime || !(answer?.echoed || await this.#runsKeyedLayer(answer?.unjudged ?? false))) {
17338
+ const latest = Math.min(started + (running ? inFlightWithinMs : withinMs), lastAsk);
17339
+ let again = scheduled !== undefined && this.#now() + wait <= latest;
17340
+ if (again) {
17341
+ again = answer?.echoed || await this.#runsKeyedLayer(answer?.unjudged ?? false);
17342
+ sawKeyedLayer ||= again;
17343
+ again &&= this.#now() + wait <= latest;
17344
+ }
17345
+ if (again) {
17346
+ try {
17347
+ await pause(wait, this.#signal);
17348
+ } catch (error) {
17349
+ throw this.#ended(error, request, attempt, reached, sawKeyedLayer);
17350
+ }
17351
+ again = this.#now() <= latest;
17352
+ }
17353
+ if (!again) {
17305
17354
  if (answer !== undefined) {
17306
- return this.#unsettled(method, url, answer.response, reached, attempt);
17355
+ return this.#unsettled(method, url, answer.response, reached, attempt, sawKeyedLayer);
17307
17356
  }
17308
17357
  if (thrown instanceof WriteAttemptSilent) {
17309
- throw new DispatchWriteUnsettledError(thrown, attempt, `${request} ${thrown.message}`);
17358
+ throw new DispatchWriteUnsettledError(thrown, attempt, `${request} ${thrown.message}`, sawKeyedLayer);
17310
17359
  }
17311
17360
  throw thrown;
17312
17361
  }
17313
- await answer?.response.body?.cancel().catch(() => {
17314
- return;
17315
- });
17316
- try {
17317
- await pause(wait, this.#signal);
17318
- } catch (error) {
17319
- throw this.#ended(error, request, attempt, reached);
17320
- }
17321
17362
  }
17322
17363
  }
17323
17364
  #now() {
@@ -17349,12 +17390,12 @@ class DispatchClient {
17349
17390
  clearTimeout(timer);
17350
17391
  }
17351
17392
  }
17352
- #ended(error, request, attempts, mayHaveReached) {
17393
+ #ended(error, request, attempts, mayHaveReached, keyed) {
17353
17394
  const reason = this.#signal.aborted ? this.#signal.reason : error;
17354
17395
  const timedOut = (reason instanceof Error || reason instanceof DOMException) && reason.name === "TimeoutError";
17355
17396
  if (!timedOut || !mayHaveReached || !(error instanceof Error))
17356
17397
  return error;
17357
- return new DispatchWriteUnsettledError(error, attempts, `${request} had no definitive answer when its deadline ended it`);
17398
+ return new DispatchWriteUnsettledError(error, attempts, `${request} had no definitive answer when its deadline ended it`, keyed);
17358
17399
  }
17359
17400
  async#runsKeyedLayer(unjudged) {
17360
17401
  const origin = this.#baseUrl;
@@ -17388,12 +17429,12 @@ class DispatchClient {
17388
17429
  return false;
17389
17430
  }
17390
17431
  }
17391
- async#unsettled(method, url, response, reached, attempts) {
17432
+ async#unsettled(method, url, response, reached, attempts, keyed) {
17392
17433
  const refusal = await this.#response(method, url, response).catch((error) => error);
17393
17434
  if (reached && refusal instanceof DispatchServiceError) {
17394
17435
  const landedAlone = refusal instanceof DispatchGatewayError ? refusal.mayHaveReachedDispatch : refusal.status >= 500;
17395
17436
  if (!landedAlone)
17396
- throw new DispatchWriteUnsettledError(refusal, attempts);
17437
+ throw new DispatchWriteUnsettledError(refusal, attempts, undefined, keyed);
17397
17438
  }
17398
17439
  throw refusal;
17399
17440
  }
@@ -17832,7 +17873,9 @@ async function textWithPictures(tool, text, pictures, limit, owner, upload, acto
17832
17873
  uploaded = await upload({ name: picture.name, file: picture.file, actor });
17833
17874
  } catch (error) {
17834
17875
  const earlier = addresses.length === 0 ? "" : `; the pictures before it are uploaded (${addresses.join(", ")})`;
17835
- throw new Error(`images: ${picture.path} was not uploaded: ${messageFor(error)}. Nothing was posted${earlier}.`);
17876
+ const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
17877
+ const outcome = refused ? "was not uploaded" : "may or may not have been uploaded";
17878
+ throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
17836
17879
  }
17837
17880
  const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
17838
17881
  addresses.push(address);
@@ -19225,7 +19268,7 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
19225
19268
  const artifacts = routed === undefined ? unlinked : [routed, ...unlinked.filter((candidate) => candidate.id !== routed.id)];
19226
19269
  return {
19227
19270
  owner,
19228
- artifact: artifactByReference(artifacts, artifactReference, "project", canonical)
19271
+ artifact: artifactByReference(artifacts, artifactReference, owner, canonical)
19229
19272
  };
19230
19273
  }
19231
19274
  const issue = await client.getIssue(owner.issue);
@@ -19233,10 +19276,13 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
19233
19276
  if (artifactReference === undefined || artifactReference === "spec") {
19234
19277
  artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
19235
19278
  } else {
19236
- artifact = artifactByReference(issue.artifacts, artifactReference, "issue", canonical);
19279
+ artifact = artifactByReference(issue.artifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
19237
19280
  }
19238
19281
  if (!artifact) {
19239
- throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, "issue"));
19282
+ throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, {
19283
+ kind: "issue",
19284
+ issue: issue.key
19285
+ }));
19240
19286
  }
19241
19287
  return { owner, issue, artifact };
19242
19288
  }
@@ -19257,15 +19303,85 @@ async function documentTargets(client, resolution) {
19257
19303
  }
19258
19304
  var documentHintLimit = 8;
19259
19305
  function documentReferenceProblem(reference, documents, owner, ambiguous = false) {
19260
- const hints = documents.slice(0, documentHintLimit).map((document) => `${document.slug} (${document.name})`);
19306
+ const scope = owner.kind;
19307
+ const busy = !ambiguous && documents.length > documentHintLimit;
19308
+ const hints = (busy ? documentsNearest(reference, documents) : documents).slice(0, documentHintLimit).map((document) => `${document.slug} (${document.name})`);
19261
19309
  const list = hints.length === 0 ? "none" : hints.join(", ");
19262
- return ambiguous ? `"${reference}" names ${documents.length} documents on this ${owner}; use a slug: ${list}` : `document "${reference}" not found by slug; this ${owner}'s documents: ${list}`;
19310
+ if (busy) {
19311
+ const read = owner.kind === "issue" ? `dispatch read --issue ${owner.issue}` : `dispatch read --project ${owner.project}`;
19312
+ const counted = documents.every((document) => (document.kind ?? "doc") === "doc") ? "documents" : "documents and files";
19313
+ return `document "${reference}" not found by slug; this ${scope}'s ${documents.length} ${counted} include: ${list}; ${read} lists them all`;
19314
+ }
19315
+ return ambiguous ? `"${reference}" names ${documents.length} documents on this ${scope}; use a slug: ${list}` : `document "${reference}" not found by slug; this ${scope}'s documents: ${list}`;
19316
+ }
19317
+ function documentsNearest(reference, documents) {
19318
+ return documents.map((document, index) => ({
19319
+ document,
19320
+ index,
19321
+ ...documentCloseness(reference, document.slug, document.name)
19322
+ })).sort((a, b) => {
19323
+ if (a.near !== b.near)
19324
+ return a.near ? -1 : 1;
19325
+ if (a.near && a.distance !== b.distance)
19326
+ return a.distance - b.distance;
19327
+ return b.index - a.index;
19328
+ }).map(({ document }) => document);
19329
+ }
19330
+ function documentListLines(documents) {
19331
+ return documents.length === 0 ? ["- none"] : documents.map((document) => `- ${document.slug} (${document.name}, ${document.kind})`);
19332
+ }
19333
+ function documentCloseness(reference, slug, name) {
19334
+ const wanted = [...reference.replace(/[A-Z]/g, (letter) => letter.toLowerCase())];
19335
+ const limit = Math.max(2, Math.floor(wanted.length / 3));
19336
+ let distance = Number.POSITIVE_INFINITY;
19337
+ for (const candidate of [slug, name]) {
19338
+ const label = [...candidate.replace(/[A-Z]/g, (letter) => letter.toLowerCase())];
19339
+ let edits = boundedEditDistance(wanted, label, limit);
19340
+ if (wanted.length >= 4 && label.join("").includes(wanted.join("")) || label.length >= 4 && wanted.join("").includes(label.join(""))) {
19341
+ edits = Math.abs(label.length - wanted.length);
19342
+ } else if (edits > limit) {
19343
+ continue;
19344
+ }
19345
+ distance = Math.min(distance, edits);
19346
+ }
19347
+ return distance === Number.POSITIVE_INFINITY ? { distance: limit + 1, near: false } : { distance, near: true };
19348
+ }
19349
+ function boundedEditDistance(a, b, limit) {
19350
+ if (Math.abs(a.length - b.length) > limit)
19351
+ return limit + 1;
19352
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
19353
+ let current = new Array(b.length + 1).fill(0);
19354
+ for (let i = 1;i <= a.length; i++) {
19355
+ current[0] = i;
19356
+ let smallest = i;
19357
+ for (let j = 1;j <= b.length; j++) {
19358
+ const substitution = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
19359
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, substitution);
19360
+ smallest = Math.min(smallest, current[j]);
19361
+ }
19362
+ if (smallest > limit)
19363
+ return limit + 1;
19364
+ [previous, current] = [current, previous];
19365
+ }
19366
+ return Math.min(previous[b.length], limit + 1);
19263
19367
  }
19264
19368
  var askHintLimit = 8;
19265
19369
  function askIDInputProblem(asks, scope) {
19266
19370
  const hints = asks.slice(0, askHintLimit).map((ask) => `${ask.id.slice(0, 8)}\u2026 ${textHead(ask.question)}`);
19267
19371
  return `ask IDs are UUIDs; use the full ask ID; ${scope} open asks: ${hints.length === 0 ? "none" : hints.join(", ")}`;
19268
19372
  }
19373
+ async function movedApprovalLine(client, askID) {
19374
+ const ask = (await client.getAsk(askID).catch(() => {
19375
+ return;
19376
+ }))?.ask;
19377
+ const approval = ask?.approval;
19378
+ if (ask?.kind !== "approval" || approval === undefined)
19379
+ return;
19380
+ if (approval.requested_version >= approval.version)
19381
+ return;
19382
+ const owner = ask.issue_key === null ? `--project ${ask.approval_artifact?.project ?? "<project>"} --artifact ${approval.artifact_id}` : ask.approval_artifact?.primary === true ? `--issue ${ask.issue_key}` : `--issue ${ask.issue_key} --artifact ${approval.artifact_id}`;
19383
+ return `The reply did not hand the ask to the human: it is the approval request for ${approval.name} ` + `at version ${approval.requested_version}, and ${approval.name} is now version ${approval.version}. ` + "No reply hands a moved approval request back. Once the human has agreed to every point in " + `version ${approval.version}, run: dispatch request-approval ${owner} --summary ` + `'<what changed since version ${approval.requested_version}>'`;
19384
+ }
19269
19385
  async function invalidReplyToAskProblem(client, owner, resolved) {
19270
19386
  if (owner.kind === "issue") {
19271
19387
  const issue = resolved?.issue ?? await client.getIssue(owner.issue);
@@ -19422,6 +19538,8 @@ function issueSummary(issue, events, references, graph, linkBase, titles) {
19422
19538
  ...specApproval === undefined ? [] : [`Spec ${specApproval.replace(/^Approval/, "approval")}`],
19423
19539
  "External links:",
19424
19540
  ...issue.external_links.length === 0 ? ["- none"] : issue.external_links.map((link) => `- ${link.url}${link.kind === undefined ? "" : ` (${link.kind})`}`),
19541
+ "Documents:",
19542
+ ...documentListLines(issue.artifacts ?? []),
19425
19543
  "Open asks:",
19426
19544
  ...asks.length === 0 ? ["- none"] : asks.map((ask) => `- ${ask.id}: ${ask.question}`),
19427
19545
  "References:",
@@ -20670,9 +20788,11 @@ async function executeDispatchTool(input) {
20670
20788
  });
20671
20789
  if (replyToAsk !== undefined) {
20672
20790
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
20791
+ const moved = requestedTurn !== "agent" && comment.ask_waiting_on === "agent" ? await movedApprovalLine(client, replyToAsk) : undefined;
20673
20792
  return {
20674
20793
  text: [
20675
20794
  `Replied on ask ${replyToAsk} (comment ${comment.id}${askState}). ${await followsAsk(commentOwner, input.subscriptions)}`,
20795
+ ...moved === undefined ? [] : [moved],
20676
20796
  ...adviceLines
20677
20797
  ].join(`
20678
20798
  `),
@@ -21143,6 +21263,19 @@ ${handoff.body}`,
21143
21263
  }
21144
21264
  };
21145
21265
  }
21266
+ const projectOwner = documentOwner();
21267
+ if (projectOwner.kind === "project" && optionalString(args, "artifact") === undefined) {
21268
+ const documents = await client.listProjectArtifacts(projectOwner.project, true);
21269
+ return {
21270
+ text: [
21271
+ `Project: ${projectOwner.project}`,
21272
+ "Documents:",
21273
+ ...documentListLines(documents)
21274
+ ].join(`
21275
+ `),
21276
+ details: { project: projectOwner.project }
21277
+ };
21278
+ }
21146
21279
  const documentReference = optionalString(args, "artifact");
21147
21280
  if (documentOwner().kind === "project" || documentReference !== undefined) {
21148
21281
  const resolved = await resolveDocument(documentOwner(), documentReference);
@@ -22455,7 +22588,7 @@ var REFUSED = 1;
22455
22588
  var USAGE = 2;
22456
22589
  var HOSTS = ["omp", "claude"];
22457
22590
  var CLAUDE_OUTPUT_MAX = 25000;
22458
- var SAME_MESSAGE = "AskGate reviews the calls of a message before any of them runs, so it did not review that change.";
22591
+ var SAME_MESSAGE = "AskGate reads the files of a message's calls before any of them runs, so it did not see that change.";
22459
22592
  var STATE_WRITE_FAILED = "dispatch: Dispatch took the call, but this session's state";
22460
22593
  function stateWriteFailed(problem) {
22461
22594
  return `${STATE_WRITE_FAILED} could not be written: ${problem}`;
@@ -22602,7 +22735,7 @@ async function runDispatchCli(argv, rawEnv, io) {
22602
22735
  const spent = consumeMarker(gate.stores, argv, parsed.args, files, Date.now());
22603
22736
  const asksCarried = spent.ok ? 0 : newAsks(parsed.tool, uploadBytes === undefined ? parsed.args : { ...parsed.args, content: new TextDecoder().decode(uploadBytes) }).length;
22604
22737
  if (!spent.ok && gate.mode === "block") {
22605
- return refuse(spent.changed === undefined ? `${notCalled} AskGate is on for this session, and ${spent.why}. ${LITERAL_FORM} Send the write again in that form, as a bash call of its own.` : `${notCalled} AskGate is on for this session, and ${spent.why}. ${SAME_MESSAGE} Send the call again in a later message.`, REFUSED, parsed.tool, { mode: "block", why: spent.why, asksCarried });
22738
+ return refuse(spent.changed === undefined ? `${notCalled} AskGate is on for this session, and ${spent.why}. ${LITERAL_FORM} Send the write again in that form, as a bash call of its own.` : `${notCalled} AskGate is on for this session, and ${spent.why}. ${SAME_MESSAGE} Send the call again in a later message than the one that changes the file.`, REFUSED, parsed.tool, { mode: "block", why: spent.why, asksCarried });
22606
22739
  }
22607
22740
  if (!spent.ok) {
22608
22741
  try {
package/dist/envoy.js CHANGED
@@ -30033,6 +30033,25 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
30033
30033
  message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
30034
30034
  };
30035
30035
  }
30036
+ var ARTIFACT_OWNER_AND_SOURCE_RULE = "Exactly one of path or content is required. Exactly one of issue and project is required; with project, artifact names the document.";
30037
+ var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
30038
+ var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
30039
+ var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
30040
+ var NAME_EXTENSION = /\.([^\s.]+)$/u;
30041
+ var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
30042
+ var artifactOwner = documentOwnerValidation(false);
30043
+ function artifactProblem(value) {
30044
+ const input = value;
30045
+ if (!artifactOwner.check(value) || typeof input.path === "string" === (typeof input.content === "string")) {
30046
+ return ARTIFACT_OWNER_AND_SOURCE_RULE;
30047
+ }
30048
+ if (typeof input.content !== "string" || typeof input.name !== "string")
30049
+ return;
30050
+ const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
30051
+ if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
30052
+ return;
30053
+ return `${CONTENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; content takes a name ending in .md or .markdown or with no extension.`;
30054
+ }
30036
30055
  var documentEditOwner = documentOwnerValidation(true);
30037
30056
  var documentEditValidation = {
30038
30057
  check: (value) => {
@@ -30080,7 +30099,7 @@ var messageValidation = {
30080
30099
  },
30081
30100
  message: "issue is required unless in_reply_to names a message delivered to this session, which is the one message with no issue."
30082
30101
  };
30083
- var readOwner = documentOwnerValidation(true);
30102
+ var readOwner = documentOwnerValidation(false);
30084
30103
  var readValidation = {
30085
30104
  check: (value) => {
30086
30105
  const input = value;
@@ -30088,7 +30107,7 @@ var readValidation = {
30088
30107
  return readOwner.check(value);
30089
30108
  return input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
30090
30109
  },
30091
- message: `${readOwner.message} message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.`
30110
+ message: "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one. " + "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it."
30092
30111
  };
30093
30112
  var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
30094
30113
  function componentsArgument(z) {
@@ -30347,7 +30366,7 @@ var dispatchToolSpecs = [
30347
30366
  body: z.string({ max: DISPATCH_BODY_MAX }).describe(`Review comment, at most ${DISPATCH_BODY_MAX} characters.`),
30348
30367
  reply_to: z.string().describe("A comment id (uuid); replying to any comment in a thread continues that thread (an " + "ask's clarification thread included). A block reference to one block of the comment " + "(dispatch://KEY/comment/<id>#b-<block id>) replies to that comment and names the " + "passage the reply answers. To reply to an ask, use reply_to_ask with the ask id, or " + "with a reference to one of its parts, instead.").optional(),
30349
30368
  reply_to_ask: z.string().describe("Optional ask id to reply to, threading this comment under that question. A block " + "reference to one part of the ask (dispatch://KEY/ask/<id>#b-<part id>, the id an " + "option or the answer carries) threads under that ask and names the part the reply " + "answers. Mutually exclusive with reply_to.").optional(),
30350
- turn: z.enum(["agent", "human"]).describe("Only with reply_to_ask: who holds the turn after this reply. agent: a progress note - " + "you keep the turn and the ask stays 'Waiting on agents' for the human; human (default): " + "you need the human to act - the ask returns to 'Waiting on you'.").optional(),
30369
+ turn: z.enum(["agent", "human"]).describe("Only with reply_to_ask: who holds the turn after this reply. agent: a progress note - " + "you keep the turn and the ask stays 'Waiting on agents' for the human; human (default): " + "you need the human to act - the ask returns to 'Waiting on you'. human does not " + "apply to an approval request a newer version moved: it stays with you until dispatch " + "request-approval hands it back at the current version.").optional(),
30351
30370
  images: imagesArgument(z, "the issue (or the project document's project)", `the ${DISPATCH_BODY_MAX}-character body limit`)
30352
30371
  }),
30353
30372
  validation: commentValidation
@@ -30453,27 +30472,25 @@ var dispatchToolSpecs = [
30453
30472
  name: "dispatch_artifact",
30454
30473
  example: { issue: "DSP-1", name: "design.md", content: `# Design
30455
30474
  ` },
30456
- description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
30475
+ description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ` + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
30457
30476
  arguments: (z) => ({
30458
30477
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30459
30478
  project: z.string().describe("Project key for an unlinked document.").optional(),
30460
30479
  name: z.string().describe("Artifact filename shown in Dispatch."),
30461
30480
  path: z.string().describe("Local path to the file to upload.").optional(),
30462
- content: z.string().describe("Inline text to store as a Markdown document; a CR LF or a lone carriage return in it is stored as a line feed.").optional(),
30481
+ content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension; a CR LF or a lone carriage return in it is stored as a line feed.").optional(),
30463
30482
  summary: z.string().describe("Optional version summary.").optional()
30464
30483
  }),
30465
30484
  validation: {
30466
- check: (value) => {
30467
- const input = value;
30468
- return documentOwnerValidation(false).check(value) && typeof input.path === "string" !== (typeof input.content === "string");
30469
- },
30470
- message: "Exactly one of path or content is required. Exactly one of issue and project is required; with project, artifact names the document."
30485
+ check: (value) => artifactProblem(value) === undefined,
30486
+ message: `${ARTIFACT_OWNER_AND_SOURCE_RULE} ${ARTIFACT_CONTENT_NAME_RULE}`,
30487
+ refusal: (value) => artifactProblem(value) ?? ARTIFACT_OWNER_AND_SOURCE_RULE
30471
30488
  }
30472
30489
  },
30473
30490
  {
30474
30491
  name: "dispatch_read",
30475
30492
  example: { issue: "DSP-1" },
30476
- description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), or project plus artifact; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Document:`, `Changed in version:` and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
30493
+ description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Document:`, `Changed in version:` and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
30477
30494
  arguments: (z) => ({
30478
30495
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30479
30496
  project: z.string().describe("Project key owning the document.").optional(),
@@ -32054,22 +32071,25 @@ class DispatchWriteUnsettledError extends Error {
32054
32071
  last;
32055
32072
  attempts;
32056
32073
  name = "DispatchWriteUnsettledError";
32057
- constructor(last, attempts, unanswered) {
32074
+ constructor(last, attempts, unanswered, keyed = false) {
32058
32075
  let answer;
32059
32076
  let why = "an earlier attempt of the write may have reached Dispatch";
32060
32077
  if (last instanceof DispatchGatewayError) {
32061
32078
  answer = last.answer;
32079
+ } else if (last instanceof DispatchServiceError && last.code === IDEMPOTENCY_KEY_IN_FLIGHT) {
32080
+ answer = last.code;
32081
+ why = "Dispatch was still running an earlier attempt of the write";
32062
32082
  } else if (last instanceof DispatchServiceError) {
32063
32083
  answer = `${last.code}: ${last.message}`;
32064
- if (last.code === IDEMPOTENCY_KEY_IN_FLIGHT) {
32065
- why = "Dispatch was still running an earlier attempt of the write";
32066
- }
32067
32084
  } else {
32068
32085
  answer = unanswered ?? last.message;
32069
32086
  why = "an attempt of the write may have reached Dispatch";
32070
32087
  }
32071
32088
  const tried = attempts === 1 ? "its only attempt" : `the last of ${attempts} attempts`;
32072
- super(`${answer} (${tried}), and ${why}, so it may or may not have taken effect: check whether ` + "it did before retrying it.", { cause: last });
32089
+ const next = keyed ? ". Dispatch finishes an attempt it received whatever this command does, so read the " + "write back before you send it again: a new command sends it under a new key." : ": check whether it did before retrying it.";
32090
+ super(`${answer} (${tried}), and ${why}, so it may or may not have taken effect${next}`, {
32091
+ cause: last
32092
+ });
32073
32093
  this.last = last;
32074
32094
  this.attempts = attempts;
32075
32095
  }
@@ -32104,7 +32124,9 @@ function requestSignal(signal) {
32104
32124
  var DISPATCH_WRITE_RETRY = {
32105
32125
  pausesMs: [1000, 2000, 4000, 8000],
32106
32126
  withinMs: 30000,
32107
- silenceMs: 20000
32127
+ silenceMs: 20000,
32128
+ inFlightPauseMs: 3000,
32129
+ inFlightWithinMs: 55000
32108
32130
  };
32109
32131
  function pauseFor(ms, signal) {
32110
32132
  const { promise, resolve, reject } = Promise.withResolvers();
@@ -32170,7 +32192,7 @@ var NULL_BODY_STATUSES = new Set([101, 204, 205, 304]);
32170
32192
  async function writeAnswer(response, key) {
32171
32193
  const echoed = keyEchoed(response, key);
32172
32194
  if (response.ok || NULL_BODY_STATUSES.has(response.status)) {
32173
- return { response, again: false, reached: false, echoed, unjudged: false };
32195
+ return { response, again: false, reached: false, running: false, echoed, unjudged: false };
32174
32196
  }
32175
32197
  const { status } = response;
32176
32198
  const text = await response.text();
@@ -32183,6 +32205,7 @@ async function writeAnswer(response, key) {
32183
32205
  }
32184
32206
  }
32185
32207
  const again = retriesUnderKey(status, shape.code);
32208
+ const running = again && status === 409;
32186
32209
  return {
32187
32210
  response: new Response(text, {
32188
32211
  status,
@@ -32190,7 +32213,8 @@ async function writeAnswer(response, key) {
32190
32213
  headers: response.headers
32191
32214
  }),
32192
32215
  again,
32193
- reached: status >= 500 || again && status === 409,
32216
+ reached: status >= 500 || running,
32217
+ running,
32194
32218
  echoed,
32195
32219
  unjudged: !echoed && typeof shape.error === "string"
32196
32220
  };
@@ -32283,12 +32307,14 @@ class DispatchClient {
32283
32307
  #baseUrl;
32284
32308
  #resolvedIssues = new Map;
32285
32309
  #signal;
32310
+ #madeAt;
32286
32311
  constructor(baseUrl, token, fetchImpl = fetch, signal, writeRetry = DISPATCH_WRITE_RETRY) {
32287
32312
  this.token = token;
32288
32313
  this.fetchImpl = fetchImpl;
32289
32314
  this.writeRetry = writeRetry;
32290
32315
  this.#baseUrl = baseUrl.replace(/\/+$/, "");
32291
32316
  this.#signal = requestSignal(signal);
32317
+ this.#madeAt = this.#now();
32292
32318
  }
32293
32319
  async issue(input) {
32294
32320
  const answer = await this.#jsonAnswer("POST", ["api", "v1", "issues"], input);
@@ -32692,10 +32718,16 @@ class DispatchClient {
32692
32718
  }
32693
32719
  const key = callerKey ?? crypto.randomUUID();
32694
32720
  headers[IDEMPOTENCY_KEY_HEADER] = key;
32695
- const { pausesMs, withinMs, silenceMs, pause = pauseFor } = this.writeRetry;
32721
+ const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
32722
+ const pause = this.writeRetry.pause ?? pauseFor;
32696
32723
  const request = `${method} ${url}`;
32697
32724
  const started = this.#now();
32725
+ const bodyBytes = body === undefined ? 0 : typeof body.content === "string" ? Buffer.byteLength(body.content) : body.content.byteLength;
32726
+ const upload = bodyBytes >= STREAMED_BODY_MIN;
32727
+ const lastAsk = this.#madeAt + inFlightWithinMs;
32698
32728
  let reached = false;
32729
+ let running = false;
32730
+ let sawKeyedLayer = false;
32699
32731
  for (let attempt = 1;; attempt++) {
32700
32732
  let answer;
32701
32733
  let thrown;
@@ -32706,34 +32738,43 @@ class DispatchClient {
32706
32738
  if (!answer.again)
32707
32739
  return answer.response;
32708
32740
  reached ||= answer.reached;
32741
+ running ||= answer.running && !upload;
32742
+ sawKeyedLayer ||= answer.echoed;
32709
32743
  } catch (error) {
32710
32744
  const name = error instanceof Error || error instanceof DOMException ? error.name : "";
32711
32745
  if (!(error instanceof WriteAttemptSilent) && (this.#signal.aborted || name === "AbortError" || name === "TimeoutError")) {
32712
- throw this.#ended(error, request, attempt, true);
32746
+ throw this.#ended(error, request, attempt, true, sawKeyedLayer);
32713
32747
  }
32714
32748
  thrown = error;
32715
32749
  reached = true;
32750
+ running ||= error instanceof WriteAttemptSilent && !upload;
32716
32751
  }
32717
- const scheduled = pausesMs[attempt - 1];
32752
+ const scheduled = running ? Math.min(pausesMs[attempt - 1] ?? inFlightPauseMs, inFlightPauseMs) : pausesMs[attempt - 1];
32718
32753
  const wait = Math.max(scheduled ?? 0, answer === undefined ? 0 : retryAfterMs(answer.response));
32719
- const inTime = scheduled !== undefined && this.#now() - started + wait <= withinMs;
32720
- if (!inTime || !(answer?.echoed || await this.#runsKeyedLayer(answer?.unjudged ?? false))) {
32754
+ const latest = Math.min(started + (running ? inFlightWithinMs : withinMs), lastAsk);
32755
+ let again = scheduled !== undefined && this.#now() + wait <= latest;
32756
+ if (again) {
32757
+ again = answer?.echoed || await this.#runsKeyedLayer(answer?.unjudged ?? false);
32758
+ sawKeyedLayer ||= again;
32759
+ again &&= this.#now() + wait <= latest;
32760
+ }
32761
+ if (again) {
32762
+ try {
32763
+ await pause(wait, this.#signal);
32764
+ } catch (error) {
32765
+ throw this.#ended(error, request, attempt, reached, sawKeyedLayer);
32766
+ }
32767
+ again = this.#now() <= latest;
32768
+ }
32769
+ if (!again) {
32721
32770
  if (answer !== undefined) {
32722
- return this.#unsettled(method, url, answer.response, reached, attempt);
32771
+ return this.#unsettled(method, url, answer.response, reached, attempt, sawKeyedLayer);
32723
32772
  }
32724
32773
  if (thrown instanceof WriteAttemptSilent) {
32725
- throw new DispatchWriteUnsettledError(thrown, attempt, `${request} ${thrown.message}`);
32774
+ throw new DispatchWriteUnsettledError(thrown, attempt, `${request} ${thrown.message}`, sawKeyedLayer);
32726
32775
  }
32727
32776
  throw thrown;
32728
32777
  }
32729
- await answer?.response.body?.cancel().catch(() => {
32730
- return;
32731
- });
32732
- try {
32733
- await pause(wait, this.#signal);
32734
- } catch (error) {
32735
- throw this.#ended(error, request, attempt, reached);
32736
- }
32737
32778
  }
32738
32779
  }
32739
32780
  #now() {
@@ -32765,12 +32806,12 @@ class DispatchClient {
32765
32806
  clearTimeout(timer);
32766
32807
  }
32767
32808
  }
32768
- #ended(error, request, attempts, mayHaveReached) {
32809
+ #ended(error, request, attempts, mayHaveReached, keyed) {
32769
32810
  const reason = this.#signal.aborted ? this.#signal.reason : error;
32770
32811
  const timedOut = (reason instanceof Error || reason instanceof DOMException) && reason.name === "TimeoutError";
32771
32812
  if (!timedOut || !mayHaveReached || !(error instanceof Error))
32772
32813
  return error;
32773
- return new DispatchWriteUnsettledError(error, attempts, `${request} had no definitive answer when its deadline ended it`);
32814
+ return new DispatchWriteUnsettledError(error, attempts, `${request} had no definitive answer when its deadline ended it`, keyed);
32774
32815
  }
32775
32816
  async#runsKeyedLayer(unjudged) {
32776
32817
  const origin = this.#baseUrl;
@@ -32804,12 +32845,12 @@ class DispatchClient {
32804
32845
  return false;
32805
32846
  }
32806
32847
  }
32807
- async#unsettled(method, url, response, reached, attempts) {
32848
+ async#unsettled(method, url, response, reached, attempts, keyed) {
32808
32849
  const refusal = await this.#response(method, url, response).catch((error) => error);
32809
32850
  if (reached && refusal instanceof DispatchServiceError) {
32810
32851
  const landedAlone = refusal instanceof DispatchGatewayError ? refusal.mayHaveReachedDispatch : refusal.status >= 500;
32811
32852
  if (!landedAlone)
32812
- throw new DispatchWriteUnsettledError(refusal, attempts);
32853
+ throw new DispatchWriteUnsettledError(refusal, attempts, undefined, keyed);
32813
32854
  }
32814
32855
  throw refusal;
32815
32856
  }
@@ -37150,7 +37191,7 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
37150
37191
  const artifacts = routed === undefined ? unlinked : [routed, ...unlinked.filter((candidate) => candidate.id !== routed.id)];
37151
37192
  return {
37152
37193
  owner,
37153
- artifact: artifactByReference(artifacts, artifactReference, "project", canonical)
37194
+ artifact: artifactByReference(artifacts, artifactReference, owner, canonical)
37154
37195
  };
37155
37196
  }
37156
37197
  const issue = await client.getIssue(owner.issue);
@@ -37158,10 +37199,13 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
37158
37199
  if (artifactReference === undefined || artifactReference === "spec") {
37159
37200
  artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
37160
37201
  } else {
37161
- artifact = artifactByReference(issue.artifacts, artifactReference, "issue", canonical);
37202
+ artifact = artifactByReference(issue.artifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
37162
37203
  }
37163
37204
  if (!artifact) {
37164
- throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, "issue"));
37205
+ throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, {
37206
+ kind: "issue",
37207
+ issue: issue.key
37208
+ }));
37165
37209
  }
37166
37210
  return { owner, issue, artifact };
37167
37211
  }
@@ -37182,9 +37226,64 @@ async function documentTargets(client, resolution) {
37182
37226
  }
37183
37227
  var documentHintLimit = 8;
37184
37228
  function documentReferenceProblem(reference, documents, owner, ambiguous = false) {
37185
- const hints = documents.slice(0, documentHintLimit).map((document) => `${document.slug} (${document.name})`);
37229
+ const scope = owner.kind;
37230
+ const busy = !ambiguous && documents.length > documentHintLimit;
37231
+ const hints = (busy ? documentsNearest(reference, documents) : documents).slice(0, documentHintLimit).map((document) => `${document.slug} (${document.name})`);
37186
37232
  const list = hints.length === 0 ? "none" : hints.join(", ");
37187
- return ambiguous ? `"${reference}" names ${documents.length} documents on this ${owner}; use a slug: ${list}` : `document "${reference}" not found by slug; this ${owner}'s documents: ${list}`;
37233
+ if (busy) {
37234
+ const read = owner.kind === "issue" ? `dispatch read --issue ${owner.issue}` : `dispatch read --project ${owner.project}`;
37235
+ const counted = documents.every((document) => (document.kind ?? "doc") === "doc") ? "documents" : "documents and files";
37236
+ return `document "${reference}" not found by slug; this ${scope}'s ${documents.length} ${counted} include: ${list}; ${read} lists them all`;
37237
+ }
37238
+ return ambiguous ? `"${reference}" names ${documents.length} documents on this ${scope}; use a slug: ${list}` : `document "${reference}" not found by slug; this ${scope}'s documents: ${list}`;
37239
+ }
37240
+ function documentsNearest(reference, documents) {
37241
+ return documents.map((document, index) => ({
37242
+ document,
37243
+ index,
37244
+ ...documentCloseness(reference, document.slug, document.name)
37245
+ })).sort((a, b) => {
37246
+ if (a.near !== b.near)
37247
+ return a.near ? -1 : 1;
37248
+ if (a.near && a.distance !== b.distance)
37249
+ return a.distance - b.distance;
37250
+ return b.index - a.index;
37251
+ }).map(({ document }) => document);
37252
+ }
37253
+ function documentCloseness(reference, slug, name) {
37254
+ const wanted = [...reference.replace(/[A-Z]/g, (letter) => letter.toLowerCase())];
37255
+ const limit = Math.max(2, Math.floor(wanted.length / 3));
37256
+ let distance = Number.POSITIVE_INFINITY;
37257
+ for (const candidate of [slug, name]) {
37258
+ const label = [...candidate.replace(/[A-Z]/g, (letter) => letter.toLowerCase())];
37259
+ let edits = boundedEditDistance(wanted, label, limit);
37260
+ if (wanted.length >= 4 && label.join("").includes(wanted.join("")) || label.length >= 4 && wanted.join("").includes(label.join(""))) {
37261
+ edits = Math.abs(label.length - wanted.length);
37262
+ } else if (edits > limit) {
37263
+ continue;
37264
+ }
37265
+ distance = Math.min(distance, edits);
37266
+ }
37267
+ return distance === Number.POSITIVE_INFINITY ? { distance: limit + 1, near: false } : { distance, near: true };
37268
+ }
37269
+ function boundedEditDistance(a, b, limit) {
37270
+ if (Math.abs(a.length - b.length) > limit)
37271
+ return limit + 1;
37272
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
37273
+ let current = new Array(b.length + 1).fill(0);
37274
+ for (let i = 1;i <= a.length; i++) {
37275
+ current[0] = i;
37276
+ let smallest = i;
37277
+ for (let j = 1;j <= b.length; j++) {
37278
+ const substitution = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
37279
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, substitution);
37280
+ smallest = Math.min(smallest, current[j]);
37281
+ }
37282
+ if (smallest > limit)
37283
+ return limit + 1;
37284
+ [previous, current] = [current, previous];
37285
+ }
37286
+ return Math.min(previous[b.length], limit + 1);
37188
37287
  }
37189
37288
  async function liveBlocks(client, artifact) {
37190
37289
  const before = await client.docRead(artifact.id);
@@ -38160,7 +38259,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
38160
38259
 
38161
38260
  // package.json
38162
38261
  var name = "@sjawhar/pi-envoy";
38163
- var version2 = "15.1.1";
38262
+ var version2 = "15.1.3";
38164
38263
  var package_default = {
38165
38264
  name,
38166
38265
  version: version2,
@@ -41343,7 +41442,9 @@ var UNREVIEWED_OUTCOMES = [
41343
41442
  "timeout",
41344
41443
  "no-verdict",
41345
41444
  "abandoned",
41346
- "shutdown"
41445
+ "shutdown",
41446
+ "halted",
41447
+ "skipped"
41347
41448
  ];
41348
41449
  var GATE_CONTEXT_MAX_BYTES = 256 * 1024;
41349
41450
  var GATE_ARGS_MAX_BYTES = 64 * 1024;
@@ -25,12 +25,12 @@ Which machines, files or people, the numbers, then "A happens to X, or B to Y?"
25
25
  ```
26
26
 
27
27
  - In Legion, fix a clear defect in code your tree uses, hand others to the controller, and ask about decisions (`skill://legion-worker/references/findings.md`).
28
- - An open ask is the request; never repeat it in each message.
28
+ - An open ask is the request; never repeat it per message.
29
29
  - Change an open ask's block with `dispatch edit-ask`, or `doc-edit`'s `replace` or `move`. An answered ask is fixed: ask anew.
30
- - Answer a person's reply to an open ask with `dispatch comment --reply-to-ask`; `--turn agent` for a note that needs nothing from them.
30
+ - Reply on an open ask with `dispatch comment --reply-to-ask`; `--turn agent` for a note needing nothing. An approval request a newer version moved needs `request-approval` again.
31
31
  - When an answer's option and text disagree, the text wins.
32
32
  - An ask block has a block id, for `doc-edit`, and an ask id, for the ask commands. `dispatch read --ref dispatch://KEY/ask/<id>` takes either.
33
- - An ask reaches the issue's assignee. On an unassigned issue, name who must answer.
33
+ - An ask reaches the issue's assignee; if none, name who answers.
34
34
 
35
35
  ## Choosing what to work on
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-envoy",
3
- "version": "15.1.1",
3
+ "version": "15.1.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {