@sjawhar/claude-envoy 4.13.0 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "4.13.0"
5
+ "version": "4.14.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "4.13.0",
3
+ "version": "4.14.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
  }
package/AGENTS.md CHANGED
@@ -4,7 +4,7 @@
4
4
  One MCP stdio server (`src/envoy-channel-server.ts`) is the session's Envoy ingress and serves the `envoy_*` tools; the mod (`hooks/mod.ts`) writes into a terminal session; `bin/dispatch` puts the `dispatch` command on the Bash tool's `PATH`.
5
5
  In a pane `legion claude-bridge` launched, the server also runs the Legion phase worker (`src/legion-*.ts`).
6
6
  `codex/` and `src/codex/` are the Codex CLI plugin, `@sjawhar/codex-envoy`, built from this source.
7
- `README.md` has the architecture, the bundle and release, and the manual smokes.
7
+ `README.md` has the architecture, the bundle and release, and the smokes.
8
8
 
9
9
  ## Commands
10
10
 
@@ -14066,10 +14066,24 @@ var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewri
14066
14066
  var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
14067
14067
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
14068
14068
  var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
14069
- var ARTIFACT_NAME_EXISTS_RULE = "An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. Send the upload again with force (--force) to write the next version.";
14069
+ var ARTIFACT_NAME_EXISTS_RULE = `An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. To write the next version, send the upload again with force (--force) and the token of the version it replaces (--precondition-json '{"document":"sha256:\u2026"}', the token dispatch doc-read prints).`;
14070
14070
  var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
14071
14071
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
14072
14072
  var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
14073
+ function preconditionArgument(z) {
14074
+ return z.object({
14075
+ document: z.string({ min: 1 }).describe("Token for the exact canonical document returned by dispatch doc-read.").optional(),
14076
+ blocks: z.array(z.object({
14077
+ id: z.string({ min: 1 }).describe("Stable block id dispatch doc-read --blocks lists."),
14078
+ token: z.string({ min: 1 }).describe("That block's full-state token, including inline marks.")
14079
+ }), { min: 1 }).describe("Every content block this batch changes, each with the token dispatch doc-read --blocks lists.").optional()
14080
+ }).describe("Optional optimistic-concurrency guard; select exactly one of document or blocks.").optional();
14081
+ }
14082
+ function uploadPreconditionArgument(z) {
14083
+ return z.object({
14084
+ document: z.string({ min: 1 }).describe("Token for the exact canonical document returned by dispatch doc-read.")
14085
+ }).describe("The token of the version this upload replaces, which an upload over a document the owner already holds must name; a first upload under a name replaces nothing and names none.").optional();
14086
+ }
14073
14087
  function pathKeepsBytesOf(name) {
14074
14088
  const extension = NAME_EXTENSION.exec(name.trim())?.[1];
14075
14089
  return extension === undefined || !MARKDOWN_EXTENSION.test(extension);
@@ -14564,13 +14578,7 @@ var dispatchToolSpecs = [
14564
14578
  type: z.string().describe("Typed block name for retype.").optional(),
14565
14579
  attributes: z.unknown().describe("Typed block attributes for retype; a CR LF or a lone carriage return in a string value is written as a line feed.").optional()
14566
14580
  }, { strict: true })).describe("Flat tagged edits; an operation takes only the keys below, a misspelled one is refused rather than ignored, and the server validates the fields its op requires."),
14567
- precondition: z.object({
14568
- document: z.string({ min: 1 }).describe("Token for the exact canonical document returned by dispatch doc-read.").optional(),
14569
- blocks: z.array(z.object({
14570
- id: z.string({ min: 1 }).describe("Stable block id dispatch doc-read --blocks lists."),
14571
- token: z.string({ min: 1 }).describe("That block's full-state token, including inline marks.")
14572
- }), { min: 1 }).describe("Every content block this batch changes, each with the token dispatch doc-read --blocks lists.").optional()
14573
- }).describe("Optional optimistic-concurrency guard; select exactly one of document or blocks.").optional(),
14581
+ precondition: preconditionArgument(z),
14574
14582
  summary: z.string().describe("Optional named-version summary.").optional()
14575
14583
  }),
14576
14584
  validation: documentEditValidation
@@ -14673,7 +14681,7 @@ var dispatchToolSpecs = [
14673
14681
  name: "dispatch_artifact",
14674
14682
  example: { issue: "DSP-1", name: "design.md", content: `# Design
14675
14683
  ` },
14676
- description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. 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. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force, so a title typed twice never empties the document that holds it. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_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. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
14684
+ description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. 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. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force and a token, so a title typed twice never empties the document that holds it; that refusal names no token, since no token makes such a call one Dispatch takes. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + "An upload that replaces a document the owner already holds under that name says which version it replaces: precondition.document takes the document token dispatch doc-read prints as `Document token: sha256:\u2026`, and an upload that names none is refused with 400 PRECONDITION_REQUIRED. A token behind the live document is refused with 409 PRECONDITION_FAILED. The refusal tells you to read the document again with dispatch doc-read, which prints the token the document carries now, and to upload again naming that token. A first upload under a name replaces no version, and a file that is not a document holds no token, so neither names one. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_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. " + `${CI_CHECK_RULE} ` + `${OWNER_REFERENCE}`,
14677
14685
  arguments: (z) => ({
14678
14686
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
14679
14687
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -14681,6 +14689,7 @@ var dispatchToolSpecs = [
14681
14689
  path: z.string().describe("Local path to the file to upload.").optional(),
14682
14690
  content: z.string().describe("Inline text to store as a Markdown document, under a name ending in .md or .markdown or with no extension. The command refuses a text the store would write under another spelling, a CR LF or a lone carriage return among them, which Dispatch stores as a line feed. A missing line feed at the end is not such a text: Dispatch adds one, and the upload goes on. The refusal prints the text Dispatch stores, which is the text to send.").optional(),
14683
14691
  force: z.boolean().describe("Write the next version of a document the owner already holds under this name; without it the upload of a name that exists is refused.").optional(),
14692
+ precondition: uploadPreconditionArgument(z),
14684
14693
  summary: z.string().describe("Optional version summary.").optional()
14685
14694
  }),
14686
14695
  validation: {
@@ -20408,6 +20417,8 @@ class DispatchClient {
20408
20417
  form.set("name", input.name);
20409
20418
  if (input.summary !== undefined)
20410
20419
  form.set("summary", input.summary);
20420
+ if (input.precondition !== undefined)
20421
+ form.set("precondition", JSON.stringify(input.precondition));
20411
20422
  if (input.actor !== undefined)
20412
20423
  form.set("actor", JSON.stringify(input.actor));
20413
20424
  form.set("file", input.file, input.name);
@@ -22192,6 +22203,10 @@ function optionalNumber(args, name) {
22192
22203
  const value = args[name];
22193
22204
  return typeof value === "number" ? value : undefined;
22194
22205
  }
22206
+ function optionalPrecondition(args) {
22207
+ const { precondition } = args;
22208
+ return precondition;
22209
+ }
22195
22210
  function defined(name, value) {
22196
22211
  return value === undefined ? {} : { [name]: value };
22197
22212
  }
@@ -23326,6 +23341,25 @@ function movedApprovalClauses(documents) {
23326
23341
  function movedApprovalDocuments(documents) {
23327
23342
  return documents.filter((document) => document.requested_version < document.version);
23328
23343
  }
23344
+ function standingReviewLines(advice) {
23345
+ const review = advice?.standing_review;
23346
+ if (review === undefined)
23347
+ return [];
23348
+ const carriedFrom = review.carried_from_version;
23349
+ if (carriedFrom !== undefined) {
23350
+ return [
23351
+ `${review.by}'s approval of this issue's spec was carried forward from the approval of version ${carriedFrom}, and Dispatch recorded that carry on ${review.at}.`,
23352
+ "Say what changed since that review in a reply on this ask."
23353
+ ];
23354
+ }
23355
+ const verb = review.state === "approved" ? "approved" : "asked for changes on";
23356
+ const opening = `${review.by} ${verb} this issue's spec at version ${review.version} on ${review.at}`;
23357
+ const reason = review.reason ?? "";
23358
+ return [
23359
+ reason === "" ? `${opening}, and gave no reason.` : `${opening}: ${JSON.stringify(reason)}`,
23360
+ "Say what changed since that review in a reply on this ask."
23361
+ ];
23362
+ }
23329
23363
  function renderAdvice(tool, key, advice, opts) {
23330
23364
  if (advice === undefined)
23331
23365
  return [];
@@ -24955,6 +24989,7 @@ async function askCommand(context) {
24955
24989
  text: stringArg(args, "question"),
24956
24990
  linkBase
24957
24991
  });
24992
+ const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
24958
24993
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
24959
24994
  const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
24960
24995
  const asked = waitsOnPerson(ask);
@@ -24962,6 +24997,7 @@ async function askCommand(context) {
24962
24997
  text: [
24963
24998
  `Asked ${ask.id} on ${askOwner.label} (urgency ${ask.urgency})${asked === undefined ? "" : `, waiting on ${asked}`}: ${ask.question}`,
24964
24999
  ...checkLines,
25000
+ ...reviewLines,
24965
25001
  ...declinedLines,
24966
25002
  await followsAsk(askOwner, input.subscriptions),
24967
25003
  ...adviceLines
@@ -25236,6 +25272,91 @@ import { resolve as resolvePath2 } from "path";
25236
25272
  // ../contracts/src/go-blank.ts
25237
25273
  var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
25238
25274
 
25275
+ // ../envoy-client/src/dispatch-commands/upload-checks.ts
25276
+ function artifactUnderName(artifacts, name) {
25277
+ const written = name.trim();
25278
+ return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
25279
+ }
25280
+ function artifactNameExistsProblem(held, owner) {
25281
+ const versions = held.versions ?? [];
25282
+ const newest = versions[versions.length - 1];
25283
+ if (newest === undefined) {
25284
+ return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${ARTIFACT_NAME_EXISTS_RULE}`;
25285
+ }
25286
+ const authors = (newest.authors ?? []).map(actorText);
25287
+ const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
25288
+ return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
25289
+ }
25290
+ var STORED_LINE_QUOTED = 200;
25291
+ function quotedStoredLine(line) {
25292
+ if (line.length <= STORED_LINE_QUOTED)
25293
+ return JSON.stringify(line);
25294
+ const head = JSON.stringify(line.slice(0, STORED_LINE_QUOTED));
25295
+ return `${head} (cut after ${STORED_LINE_QUOTED} of its ${line.length} characters)`;
25296
+ }
25297
+ function firstStoredDifference(given, stored) {
25298
+ const written = given.split(`
25299
+ `);
25300
+ const holds = stored.split(`
25301
+ `);
25302
+ for (let line = 0;line < Math.max(written.length, holds.length); line += 1) {
25303
+ const wrote = written[line];
25304
+ const held = holds[line];
25305
+ if (wrote === held)
25306
+ continue;
25307
+ if (wrote === undefined && held !== undefined) {
25308
+ return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
25309
+ }
25310
+ if (held === undefined && wrote !== undefined) {
25311
+ return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
25312
+ }
25313
+ if (wrote !== undefined && held !== undefined) {
25314
+ return `line ${line + 1} reads ${quotedStoredLine(wrote)} and is stored as ${quotedStoredLine(held)}`;
25315
+ }
25316
+ }
25317
+ return "the stored text differs from the text given";
25318
+ }
25319
+ var STORED_TEXT_PRINTED = 2000;
25320
+ function storedTextPrinted(stored) {
25321
+ if (stored.length <= STORED_TEXT_PRINTED)
25322
+ return { text: stored, cut: "" };
25323
+ const head = stored.slice(0, STORED_TEXT_PRINTED);
25324
+ const lastLineFeed = head.lastIndexOf(`
25325
+ `);
25326
+ const text = lastLineFeed === -1 ? head : head.slice(0, lastLineFeed + 1);
25327
+ return {
25328
+ text,
25329
+ cut: ` The text below is cut after ${text.length} of its ${stored.length} characters: change the line named above and send the text again.`
25330
+ };
25331
+ }
25332
+ function storedTextProblem(given, stored, name) {
25333
+ const asBytes = pathKeepsBytesOf(name) ? ` To keep the text as you wrote it, send it as a file with ${PATH_KEEPS_BYTES}.` : "";
25334
+ const printed = storedTextPrinted(stored);
25335
+ return [
25336
+ `Dispatch stores this text under another spelling: ${firstStoredDifference(given, stored)}.`,
25337
+ ` Send the text Dispatch stores, which is between the two marker lines below.${asBytes}`,
25338
+ `${printed.cut}
25339
+ --- the text Dispatch stores ---
25340
+ ${printed.text}`,
25341
+ "--- end of the text Dispatch stores ---"
25342
+ ].join("");
25343
+ }
25344
+ function storedTextCheckFailed(error, name) {
25345
+ const failure = `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip failed with ${messageFor(error)}.`;
25346
+ if (!dispatchAnswered(error, 413)) {
25347
+ return `${failure} Send the upload again once that call is answered.`;
25348
+ }
25349
+ const asBytes = pathKeepsBytesOf(name) ? ` Send it as a file with ${PATH_KEEPS_BYTES}, which asks this check nothing.` : "";
25350
+ return `${failure} This text is longer than the check reads, and sending the upload again does not change that: a markdown document is at most 1 MiB, so shorten it or split it across documents of at most that.${asBytes}`;
25351
+ }
25352
+ function roundTripRouteAbsent(error) {
25353
+ return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
25354
+ }
25355
+ function withoutFinalLineFeed(text) {
25356
+ return text.endsWith(`
25357
+ `) ? text.slice(0, -1) : text;
25358
+ }
25359
+
25239
25360
  // ../envoy-client/src/dispatch-commands/documents.ts
25240
25361
  async function blockAsks(client, resolved, state) {
25241
25362
  const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
@@ -25415,8 +25536,7 @@ async function docEditCommand(context) {
25415
25536
  const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
25416
25537
  const ops = args.ops;
25417
25538
  const summary = optionalString(args, "summary");
25418
- const { precondition: rawPrecondition } = args;
25419
- const precondition = rawPrecondition;
25539
+ const precondition = optionalPrecondition(args);
25420
25540
  await refuseRemovingOpenDecisionBlocks(client, input.tool, resolved, ops);
25421
25541
  const edited = await client.docEdit(resolved.artifact.id, {
25422
25542
  ops,
@@ -25596,96 +25716,19 @@ async function planApproveCommand(context) {
25596
25716
  }
25597
25717
  };
25598
25718
  }
25599
- function artifactUnderName(artifacts, name) {
25600
- const written = name.trim();
25601
- return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
25602
- }
25603
- function artifactNameExistsProblem(held, owner) {
25604
- const versions = held.versions ?? [];
25605
- const newest = versions[versions.length - 1];
25606
- if (newest === undefined) {
25607
- return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}), which has no version yet and which ${actorText(held.created_by)} created. ${ARTIFACT_NAME_EXISTS_RULE}`;
25608
- }
25609
- const authors = (newest.authors ?? []).map(actorText);
25610
- const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
25611
- return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
25612
- }
25613
- var STORED_LINE_QUOTED = 200;
25614
- function quotedStoredLine(line) {
25615
- if (line.length <= STORED_LINE_QUOTED)
25616
- return JSON.stringify(line);
25617
- const head = JSON.stringify(line.slice(0, STORED_LINE_QUOTED));
25618
- return `${head} (cut after ${STORED_LINE_QUOTED} of its ${line.length} characters)`;
25619
- }
25620
- function firstStoredDifference(given, stored) {
25621
- const written = given.split(`
25622
- `);
25623
- const holds = stored.split(`
25624
- `);
25625
- for (let line = 0;line < Math.max(written.length, holds.length); line += 1) {
25626
- const wrote = written[line];
25627
- const held = holds[line];
25628
- if (wrote === held)
25629
- continue;
25630
- if (wrote === undefined && held !== undefined) {
25631
- return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
25632
- }
25633
- if (held === undefined && wrote !== undefined) {
25634
- return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
25635
- }
25636
- if (wrote !== undefined && held !== undefined) {
25637
- return `line ${line + 1} reads ${quotedStoredLine(wrote)} and is stored as ${quotedStoredLine(held)}`;
25638
- }
25639
- }
25640
- return "the stored text differs from the text given";
25641
- }
25642
- var STORED_TEXT_PRINTED = 2000;
25643
- function storedTextPrinted(stored) {
25644
- if (stored.length <= STORED_TEXT_PRINTED)
25645
- return { text: stored, cut: "" };
25646
- const head = stored.slice(0, STORED_TEXT_PRINTED);
25647
- const lastLineFeed = head.lastIndexOf(`
25648
- `);
25649
- const text = lastLineFeed === -1 ? head : head.slice(0, lastLineFeed + 1);
25650
- return {
25651
- text,
25652
- cut: ` The text below is cut after ${text.length} of its ${stored.length} characters: change the line named above and send the text again.`
25653
- };
25654
- }
25655
- function storedTextProblem(given, stored, name) {
25656
- const asBytes = pathKeepsBytesOf(name) ? ` To keep the text as you wrote it, send it as a file with ${PATH_KEEPS_BYTES}.` : "";
25657
- const printed = storedTextPrinted(stored);
25658
- return [
25659
- `Dispatch stores this text under another spelling: ${firstStoredDifference(given, stored)}.`,
25660
- ` Send the text Dispatch stores, which is between the two marker lines below.${asBytes}`,
25661
- `${printed.cut}
25662
- --- the text Dispatch stores ---
25663
- ${printed.text}`,
25664
- "--- end of the text Dispatch stores ---"
25665
- ].join("");
25666
- }
25667
- function storedTextCheckFailed(error, name) {
25668
- const failure = `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip failed with ${messageFor(error)}.`;
25669
- if (!dispatchAnswered(error, 413)) {
25670
- return `${failure} Send the upload again once that call is answered.`;
25671
- }
25672
- const asBytes = pathKeepsBytesOf(name) ? ` Send it as a file with ${PATH_KEEPS_BYTES}, which asks this check nothing.` : "";
25673
- return `${failure} This text is longer than the check reads, and sending the upload again does not change that: a markdown document is at most 1 MiB, so shorten it or split it across documents of at most that.${asBytes}`;
25674
- }
25675
- function roundTripRouteAbsent(error) {
25676
- return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
25677
- }
25678
- function withoutFinalLineFeed(text) {
25679
- return text.endsWith(`
25680
- `) ? text.slice(0, -1) : text;
25681
- }
25682
25719
  async function artifactCommand(context) {
25683
25720
  const { args, client, actor, input, documentOwner, issue } = context;
25684
25721
  const summary = optionalString(args, "summary");
25685
25722
  const name = stringArg(args, "name");
25686
25723
  const content = optionalString(args, "content");
25687
25724
  const path = optionalString(args, "path");
25688
- const options = { name, ...summary === undefined ? {} : { summary }, actor };
25725
+ const precondition = optionalPrecondition(args);
25726
+ const options = {
25727
+ name,
25728
+ ...summary === undefined ? {} : { summary },
25729
+ ...precondition === undefined ? {} : { precondition },
25730
+ actor
25731
+ };
25689
25732
  const artifactOwner = documentOwner();
25690
25733
  const blank = content === undefined || goBlankPattern.test(content);
25691
25734
  if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {