@sjawhar/claude-envoy 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36763,8 +36763,14 @@ function brokenParts(parts) {
36763
36763
  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)";
36764
36764
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
36765
36765
  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}.`;
36766
+ 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.";
36767
+ 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}.`;
36766
36768
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
36767
36769
  var MARKDOWN_EXTENSION = /^(md|markdown)$/i;
36770
+ function pathKeepsBytesOf(name) {
36771
+ const extension = NAME_EXTENSION.exec(name.trim())?.[1];
36772
+ return extension === undefined || !MARKDOWN_EXTENSION.test(extension);
36773
+ }
36768
36774
  var artifactOwner = documentOwnerValidation(false);
36769
36775
  function artifactProblem(value) {
36770
36776
  const input = value;
@@ -36906,6 +36912,42 @@ var handoffValidation = {
36906
36912
  message: HANDOFF_RULE,
36907
36913
  refusal: (value) => handoffProblem(value) ?? HANDOFF_RULE
36908
36914
  };
36915
+ var RESULT_REQUIRED_FIELDS = ["issue", "check", "role", "verdict", "commit"];
36916
+ var RESULT_RECORD_FIELDS = [
36917
+ ...RESULT_REQUIRED_FIELDS,
36918
+ "surface",
36919
+ "run",
36920
+ "observed",
36921
+ "negative_control",
36922
+ "failed",
36923
+ "skipped",
36924
+ "excluded",
36925
+ "screenshots"
36926
+ ];
36927
+ var RESULT_RETRACT_RULE = "Pass retract with the id of a result recorded before, and reason with why that result is " + "wrong, to retract it.";
36928
+ var RESULT_SHAPE_RULE = `${RESULT_RETRACT_RULE} A call with retract takes reason and no other argument. A call ` + "without retract records a result, and it takes issue, check, role, verdict and commit.";
36929
+ function resultProblem(value) {
36930
+ const input = value;
36931
+ const carried = RESULT_RECORD_FIELDS.filter((field) => input[field] !== undefined);
36932
+ if (typeof input["retract"] === "string") {
36933
+ const reason = input["reason"];
36934
+ if (typeof reason !== "string" || reason.trim() === "") {
36935
+ return "retract needs reason, the words that say why the result is wrong.";
36936
+ }
36937
+ if (carried.length > 0) {
36938
+ return `retract takes reason alone, and this call also carries ${carried.join(", ")}. Retract the result, then record a new one with a call of its own.`;
36939
+ }
36940
+ return;
36941
+ }
36942
+ if (input["reason"] !== undefined) {
36943
+ return "reason goes with retract, and this call carries no retract. Name the result to retract, or drop reason.";
36944
+ }
36945
+ const missing = RESULT_REQUIRED_FIELDS.filter((field) => input[field] === undefined);
36946
+ if (missing.length > 0) {
36947
+ return `recording a result needs ${missing.join(", ")}. ${RESULT_RETRACT_RULE}`;
36948
+ }
36949
+ return;
36950
+ }
36909
36951
  var SEARCH_QUERY_MAX = 1000;
36910
36952
  var SEARCH_QUERY_HINT = "search with a short phrase of a few words, not a passage";
36911
36953
  var SEARCH_KIND_DEPTH = 100;
@@ -37259,13 +37301,13 @@ var dispatchToolSpecs = [
37259
37301
  verdict: "pass",
37260
37302
  commit: "1111111111111111111111111111111111111111"
37261
37303
  },
37262
- description: "Record one result of one check of an issue's Verification document, and print the " + "pull-request body line it implies. The check is named by its block id, or, when two " + "Verification documents in reach share that id, by its canonical reference " + "(dispatch://KEY/artifact/verification-md#b-<id>); 409 CHECK_AMBIGUOUS names them, and an " + "id no Verification document of the issue or of an issue above it holds is 400 " + "UNKNOWN_CHECK. A pass counting any failed, skipped or excluded case contradicts itself " + "and is 400 RESULT_CONTRADICTS. Dispatch asks GitHub whether the repository of the " + "check's issue holds the commit: one it does not hold is 400 RESULT_COMMIT_UNKNOWN, " + "naming the commit and that owner/repo, so record the result after the commit is pushed. " + "A repository Dispatch cannot read records the result as before. " + "The result is recorded against the check's own issue, so " + "a child's run of a parent's check appears under that check. A closed issue takes a " + "result only for a check whose when is after_merge or default_branch \u2014 the production " + "check after the merge \u2014 and refuses every other one with 409 ISSUE_CLOSED, as it refuses " + "every other write. Write the printed line into the pull-request body unchanged: it is " + "the one grammar every writer uses, and it carries no link to Dispatch. " + ISSUE_REFERENCE,
37304
+ description: "Record one result of one check of an issue's Verification document, or retract a result " + "recorded before. A record prints the pull-request body line it implies. Write that line " + "into the pull-request body unchanged: it is the one grammar every writer uses, and it " + "carries no link to Dispatch. " + "Name the check by its block id. Where two Verification documents in reach hold that id, " + "name it by its canonical reference (dispatch://KEY/artifact/verification-md#b-<id>). " + "409 CHECK_AMBIGUOUS names both documents. An id no Verification document of the issue " + "or of an issue above it holds is 400 UNKNOWN_CHECK. " + "A pass that counts a failed, a skipped or an excluded case contradicts itself, and is " + "400 RESULT_CONTRADICTS. " + "Dispatch asks GitHub whether the repository of the check's issue holds the commit. A " + "commit that repository does not hold is 400 RESULT_COMMIT_UNKNOWN, which names the " + "commit and that owner/repo. Record the result after the commit is pushed. A repository " + "Dispatch cannot read records the result as before. " + "The result is recorded against the check's own issue, so a child's run of a parent's " + "check appears under that check. A closed issue takes a result only for a check whose " + "when is after_merge or default_branch, the production check after the merge. It refuses " + "every other record with 409 ISSUE_CLOSED, as it refuses every other write. " + RESULT_RETRACT_RULE + " The retraction keeps both records: the result stays readable, and it proves nothing " + "from then on. Record a new result where the check still needs one. A retraction is " + "taken on a closed issue and for a check of any when. Three callers may retract: the " + "session that recorded the result, a session that holds the Dispatch claim of the issue " + "the result was recorded on, and a caller whose credential carries a person. Every other " + "caller is 403 RETRACTION_FORBIDDEN. A result retracted already is 409 RESULT_RETRACTED. " + ISSUE_REFERENCE,
37263
37305
  arguments: (z) => ({
37264
- issue: z.string().describe(ISSUE_REFERENCE),
37265
- check: z.string().describe("The check block's id, or its canonical reference dispatch://KEY/artifact/verification-md#b-<id> when the id is not unique among the issue's Verification document and those of the issues above it."),
37266
- role: z.string({ max: 32 }).describe("Who ran it: implementer, tester, reviewer. At most 32 characters of a-z and -, printed in the pull-request line."),
37267
- verdict: z.enum(["pass", "fail"]).describe("Whether the check passed."),
37268
- commit: z.string().describe("The 40-character lowercase hex commit the check ran at."),
37306
+ issue: z.string().describe(ISSUE_REFERENCE).optional(),
37307
+ check: z.string().describe("The check block's id, or its canonical reference dispatch://KEY/artifact/verification-md#b-<id> when the id is not unique among the issue's Verification document and those of the issues above it.").optional(),
37308
+ role: z.string({ max: 32 }).describe("Who ran it: implementer, tester, reviewer. At most 32 characters of a-z and -, printed in the pull-request line.").optional(),
37309
+ verdict: z.enum(["pass", "fail"]).describe("Whether the check passed.").optional(),
37310
+ commit: z.string().describe("The 40-character lowercase hex commit the check ran at.").optional(),
37269
37311
  surface: z.string().describe("Where a person reaches the change.").optional(),
37270
37312
  run: z.string().describe("The command that proved it.").optional(),
37271
37313
  observed: z.string().describe("What the command printed.").optional(),
@@ -37273,28 +37315,38 @@ var dispatchToolSpecs = [
37273
37315
  failed: z.number({ int: true, min: 0 }).describe("Cases the run failed; 0 by default.").optional(),
37274
37316
  skipped: z.number({ int: true, min: 0 }).describe("Cases the run skipped; 0 by default.").optional(),
37275
37317
  excluded: z.number({ int: true, min: 0 }).describe("Cases the run excluded; 0 by default.").optional(),
37276
- screenshots: z.array(z.string()).describe("dispatch:// references to image documents of this issue or of the check's issue.").optional()
37277
- })
37318
+ screenshots: z.array(z.string()).describe("dispatch:// references to image documents of this issue or of the check's issue.").optional(),
37319
+ retract: z.string().describe("The id of a result recorded before. It records that the result is wrong, and it takes reason alone beside it.").optional(),
37320
+ reason: z.string().describe("Why the retracted result is wrong. It goes with retract and with nothing else.").optional()
37321
+ }),
37322
+ validation: {
37323
+ check: (value) => resultProblem(value) === undefined,
37324
+ message: RESULT_SHAPE_RULE,
37325
+ refusal: (value) => resultProblem(value) ?? RESULT_SHAPE_RULE
37326
+ }
37278
37327
  },
37279
37328
  {
37280
37329
  name: "dispatch_results",
37281
37330
  example: { issue: "DSP-1" },
37282
- description: "Print each check of an issue's Verification document with its latest result and whether " + "that result is current. A result is current when it ran at the commit the work stands at " + "\u2014 the head of an open pull request of the check's issue, the final head of a merged one, " + "for an after_merge check a commit on the branch that issue's pull request merged into or " + "on the repository's default branch (which answers alone where Dispatch holds no merge of " + "that issue), or for a default_branch check a commit on the repository's default branch, " + "whatever branch the pull request merged into \u2014 and the check's words have not changed " + "since; older otherwise, and unknown when Dispatch cannot read the repository. On an " + "after_merge check's base branch a read GitHub refused \u2014 a 403 or 404, which a branch it " + "no longer holds answers with \u2014 says the commit is not on that branch and leaves the " + "default branch to decide; every other failure of that read, a rate limit or a 5xx " + "among them, leaves the result unknown and never older. A push that moves the " + "pull request's head makes a result older with no write of anyone's: record it again at " + "the new head. " + ISSUE_REFERENCE,
37331
+ description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. " + ISSUE_REFERENCE,
37283
37332
  arguments: (z) => ({
37284
- issue: z.string().describe(ISSUE_REFERENCE)
37333
+ issue: z.string().describe(ISSUE_REFERENCE),
37334
+ at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with, and Dispatch reads GitHub for none of it.").optional(),
37335
+ brief: z.boolean().describe("Cut each reading whose result stands at none of the compared commits to its first 200 characters. Every other reading prints whole.").optional()
37285
37336
  })
37286
37337
  },
37287
37338
  {
37288
37339
  name: "dispatch_artifact",
37289
37340
  example: { issue: "DSP-1", name: "design.md", content: `# Design
37290
37341
  ` },
37291
- 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}`,
37342
+ 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. 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_NAME_EXISTS_RULE} ` + `${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. " + `${OWNER_REFERENCE}`,
37292
37343
  arguments: (z) => ({
37293
37344
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
37294
37345
  project: z.string().describe("Project key for an unlinked document.").optional(),
37295
37346
  name: z.string().describe("Artifact filename shown in Dispatch."),
37296
37347
  path: z.string().describe("Local path to the file to upload.").optional(),
37297
- 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(),
37348
+ 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(),
37349
+ 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(),
37298
37350
  summary: z.string().describe("Optional version summary.").optional()
37299
37351
  }),
37300
37352
  validation: {
@@ -41703,8 +41755,17 @@ function askAnswerText(answer) {
41703
41755
  }
41704
41756
 
41705
41757
  // ../envoy-client/src/errors.ts
41758
+ function dispatchCode(error) {
41759
+ if (!("fromDispatch" in error) || !("code" in error))
41760
+ return;
41761
+ const code = error.code;
41762
+ return typeof code === "string" && code !== "" ? code : undefined;
41763
+ }
41706
41764
  function messageFor(error) {
41707
- return error instanceof Error ? error.message : String(error);
41765
+ if (!(error instanceof Error))
41766
+ return String(error);
41767
+ const code = dispatchCode(error);
41768
+ return code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`;
41708
41769
  }
41709
41770
  function hasErrnoCode(error, code) {
41710
41771
  return error instanceof Error && "code" in error && error.code === code;
@@ -42559,6 +42620,13 @@ class DispatchClient {
42559
42620
  return answer;
42560
42621
  throw new Error(`GET ${this.#url(path, query)} asked for the unpaged listing and got ${whyNotAnArray(answer)}.`);
42561
42622
  }
42623
+ async listIssueArtifacts(issue) {
42624
+ return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
42625
+ }
42626
+ async markdownRoundTrip(markdown) {
42627
+ const answer = await this.#json("POST", ["api", "v1", "markdown", "round-trip"], { markdown });
42628
+ return answer.markdown;
42629
+ }
42562
42630
  async listProjectArtifacts(project, unlinked = false) {
42563
42631
  return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
42564
42632
  }
@@ -42746,8 +42814,11 @@ class DispatchClient {
42746
42814
  async recordResult(issue, input) {
42747
42815
  return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], input);
42748
42816
  }
42749
- async issueResults(issue) {
42750
- return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"]);
42817
+ async issueResults(issue, at) {
42818
+ return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], undefined, at === undefined ? undefined : { at });
42819
+ }
42820
+ async retractResult(resultID, input) {
42821
+ return this.#json("POST", ["api", "v1", "results", resultID, "retract"], input);
42751
42822
  }
42752
42823
  async editAsk(id, input) {
42753
42824
  return this.#json("PATCH", ["api", "v1", "asks", id], input);
@@ -42822,6 +42893,9 @@ class DispatchClient {
42822
42893
  async docRead(id, version) {
42823
42894
  return version === undefined ? this.#json("GET", ["api", "v1", "artifacts", id, "text"]) : this.#json("GET", ["api", "v1", "artifacts", id, "versions", String(version)]);
42824
42895
  }
42896
+ async docReadWithBlocks(id) {
42897
+ return this.#json("GET", ["api", "v1", "artifacts", id, "text"], undefined, { blocks: true });
42898
+ }
42825
42899
  async fileVersion(id, version) {
42826
42900
  const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
42827
42901
  const response = await this.#send("GET", url, undefined, "*/*");
@@ -47918,11 +47992,11 @@ async function sessionAnswersSettled(session) {
47918
47992
  class ToolInputError extends Error {
47919
47993
  tool;
47920
47994
  problems;
47921
- constructor(tool, problems) {
47995
+ constructor(tool, problems, options) {
47922
47996
  const count = problems.length;
47923
47997
  const cli = isDispatchTool(tool);
47924
47998
  const help = cli ? [
47925
- `Allowed flags: ${commandFlags(tool).join(", ")}`,
47999
+ ...options?.aboutAFlag === false ? [] : [`Allowed flags: ${commandFlags(tool).join(", ")}`],
47926
48000
  `Example: ${commandLine(tool, exampleFor(tool))}`
47927
48001
  ] : [];
47928
48002
  super([
@@ -48080,6 +48154,17 @@ var triageAdviceShown = new Set;
48080
48154
  function adviceMemory() {
48081
48155
  return triageAdviceShown;
48082
48156
  }
48157
+ function handBackApprovalCommand(request) {
48158
+ const owner = request.owner.kind === "project" ? `--project ${request.owner.key} --artifact ${request.artifactID}` : request.primary ? `--issue ${request.owner.key}` : `--issue ${request.owner.key} --artifact ${request.artifactID}`;
48159
+ const verification = request.owner.kind === "issue" && request.primary && request.verification ? " --include-verification" : "";
48160
+ return `dispatch request-approval ${owner}${verification} ` + `--summary '<what changed since version ${request.summaryVersion}>'`;
48161
+ }
48162
+ function movedApprovalClauses(documents) {
48163
+ return documents.map((document) => `${document.name} asked about version ${document.requested_version} and is now version ${document.version}`).join("; ");
48164
+ }
48165
+ function movedApprovalDocuments(documents) {
48166
+ return documents.filter((document) => document.requested_version < document.version);
48167
+ }
48083
48168
  function renderAdvice(tool, key, advice, opts) {
48084
48169
  if (advice === undefined)
48085
48170
  return [];
@@ -48110,6 +48195,24 @@ function renderAdvice(tool, key, advice, opts) {
48110
48195
  lines.push(`You still have an open ask on ${key}: "${ask.question.slice(0, 80)}" (${ask.id}). Still needed? See the \`dispatch\` skill, "Close what you opened".`);
48111
48196
  }
48112
48197
  }
48198
+ const movedApproval = advice.moved_approval_request;
48199
+ if (movedApproval !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
48200
+ const documents = movedApproval.documents ?? [];
48201
+ const moved = movedApprovalDocuments(documents);
48202
+ const movedOwner = movedApproval.issue !== undefined && movedApproval.issue !== "" ? { kind: "issue", key: movedApproval.issue } : movedApproval.project !== undefined && movedApproval.project !== "" ? { kind: "project", key: movedApproval.project } : undefined;
48203
+ const first = documents[0];
48204
+ const firstMoved = moved[0];
48205
+ if (moved.length > 0 && movedOwner !== undefined && first !== undefined && firstMoved !== undefined) {
48206
+ const command = handBackApprovalCommand({
48207
+ owner: movedOwner,
48208
+ artifactID: first.artifact_id,
48209
+ primary: first.primary,
48210
+ verification: documents.slice(1).some((document) => document.role === "verification"),
48211
+ summaryVersion: firstMoved.requested_version
48212
+ });
48213
+ lines.push(`This write moved the open approval request (ask ${movedApproval.ask_id}): it waits on ` + "an agent now, not on the person, and nothing tells the person. " + `${movedApprovalClauses(moved)}. Once the human has agreed to every point in it, hand ` + `the same request back: ${command}. Not yours to hand back? Tell the issue's architect.`);
48214
+ }
48215
+ }
48113
48216
  const superseded = advice.superseded_approval;
48114
48217
  if (superseded !== undefined && (tool === "dispatch_doc_edit" || tool === "dispatch_artifact")) {
48115
48218
  const gates = Array.isArray(superseded.design_gates) ? superseded.design_gates : [];
@@ -48416,7 +48519,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
48416
48519
  `${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
48417
48520
  ]);
48418
48521
  }
48419
- async function resolveIdPrefix(tool, kind, id, ownerName, list) {
48522
+ async function resolveIdPrefix(tool, kind, id, ownerName, list, candidates) {
48420
48523
  const fullID = normalizeUUID(id);
48421
48524
  if (fullID !== undefined)
48422
48525
  return fullID;
@@ -48426,9 +48529,13 @@ async function resolveIdPrefix(tool, kind, id, ownerName, list) {
48426
48529
  ]);
48427
48530
  }
48428
48531
  const prefix = id.toLowerCase();
48429
- const matches = (await list()).filter((item) => item.id.toLowerCase().startsWith(prefix));
48532
+ const all = await list();
48533
+ const matches = all.filter((item) => item.id.toLowerCase().startsWith(prefix));
48430
48534
  if (matches.length === 1 && matches[0] !== undefined)
48431
48535
  return matches[0].id;
48536
+ if (candidates !== undefined) {
48537
+ throw new ToolInputError(tool, [candidates.refusal(matches, all)], { aboutAFlag: false });
48538
+ }
48432
48539
  throw new ToolInputError(tool, [
48433
48540
  matches.length === 0 ? `${kind} id ${id} matches none of the ${kind}s on ${ownerName}; use the full id` : `${kind} id ${id} matches ${matches.length} ${kind}s on ${ownerName}; use the full id`
48434
48541
  ]);
@@ -48879,6 +48986,9 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
48879
48986
  if (tool === "dispatch_read" && typeof args.message === "string") {
48880
48987
  return { args, ref, owner: null };
48881
48988
  }
48989
+ if (tool === "dispatch_result" && typeof args["retract"] === "string") {
48990
+ return { args, ref, owner: null };
48991
+ }
48882
48992
  const legionIssue = env.LEGION_ISSUE;
48883
48993
  if (!legionIssue) {
48884
48994
  problems.push(ownerRequiredProblem);
@@ -49037,9 +49147,14 @@ function boundedEditDistance(a, b, limit) {
49037
49147
  return Math.min(previous[b.length], limit + 1);
49038
49148
  }
49039
49149
  var askHintLimit = 8;
49040
- function askIDInputProblem(asks, scope) {
49150
+ function openAskChoices(asks, owner) {
49151
+ if (asks.length === 0)
49152
+ return `${owner} holds no open ask.`;
49041
49153
  const hints = asks.slice(0, askHintLimit).map((ask) => `${ask.id.slice(0, 8)}\u2026 ${textHead(ask.question)}`);
49042
- return `ask IDs are UUIDs; use the full ask ID; ${scope} open asks: ${hints.length === 0 ? "none" : hints.join(", ")}`;
49154
+ return `The open asks of ${owner} are: ${hints.join(", ")}.`;
49155
+ }
49156
+ function askIDInputProblem(asks, owner) {
49157
+ return `ask ids are uuids. Write the whole id, or at least its first 8 characters. ${openAskChoices(asks, owner)}`;
49043
49158
  }
49044
49159
  async function movedApprovalLine(client, askID) {
49045
49160
  const ask = (await client.getAsk(askID).catch(() => {
@@ -49048,19 +49163,52 @@ async function movedApprovalLine(client, askID) {
49048
49163
  const approval = ask?.approval;
49049
49164
  if (ask?.kind !== "approval" || approval === undefined)
49050
49165
  return;
49051
- if (approval.requested_version >= approval.version)
49166
+ const listed = approval.documents ?? [];
49167
+ const documents = listed.length > 0 ? listed : [
49168
+ {
49169
+ name: approval.name,
49170
+ requested_version: approval.requested_version,
49171
+ version: approval.version
49172
+ }
49173
+ ];
49174
+ const moved = movedApprovalDocuments(documents);
49175
+ if (moved.length === 0)
49052
49176
  return;
49053
- 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}`;
49054
- 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}>'`;
49177
+ const firstMoved = moved[0];
49178
+ if (firstMoved === undefined)
49179
+ return;
49180
+ const command = handBackApprovalCommand({
49181
+ owner: ask.issue_key === null ? { kind: "project", key: ask.approval_artifact?.project ?? "<project>" } : { kind: "issue", key: ask.issue_key },
49182
+ artifactID: approval.artifact_id,
49183
+ primary: ask.approval_artifact?.primary === true,
49184
+ verification: documents.length > 1 && ask.approval_artifact?.primary === true,
49185
+ summaryVersion: firstMoved.requested_version
49186
+ });
49187
+ return "The reply did not hand the ask to the human: it is an open approval request, and " + `${movedApprovalClauses(moved)}. No reply hands a moved approval request back. Once the ` + `human has agreed to every point in it, run: ${command}`;
49055
49188
  }
49056
- async function invalidReplyToAskProblem(client, owner, resolved) {
49189
+ async function replyToAskCandidates(client, owner, resolved) {
49057
49190
  if (owner.kind === "issue") {
49058
49191
  const issue = resolved?.issue ?? await client.getIssue(owner.issue);
49059
- return askIDInputProblem(issue.open_asks ?? [], "this issue's");
49192
+ return { asks: issue.open_asks ?? [], owner: "this issue" };
49060
49193
  }
49061
49194
  if (resolved === undefined)
49062
49195
  throw new Error("project document is missing its resolved artifact");
49063
- return askIDInputProblem(await client.getArtifactAsks(resolved.artifact.id, "open"), "this document's");
49196
+ return {
49197
+ asks: await client.getArtifactAsks(resolved.artifact.id, "open"),
49198
+ owner: "this document"
49199
+ };
49200
+ }
49201
+ async function resolveReplyToAsk(tool, client, target, resolved, id) {
49202
+ const whole = normalizeUUID(id);
49203
+ if (whole !== undefined)
49204
+ return whole;
49205
+ const { asks, owner } = await replyToAskCandidates(client, target, resolved);
49206
+ if (!isIdPrefix(id)) {
49207
+ throw new ToolInputError(tool, [askIDInputProblem(asks, owner)], { aboutAFlag: false });
49208
+ }
49209
+ return resolveIdPrefix(tool, "ask", id, owner, async () => asks, {
49210
+ refusal: (found, all) => found.length === 0 ? `reply_to_ask ${id} names no open ask of ${owner}. ${openAskChoices(all, owner)}` : `reply_to_ask ${id} names ${found.length} open asks of ${owner}. Write more of the id. ${openAskChoices(all, owner)}`
49211
+ });
49064
49212
  }
49065
49213
  function anchor(artifact, args) {
49066
49214
  const quote = optionalString(args, "quote");
@@ -49100,6 +49248,89 @@ function approvalLine(artifact) {
49100
49248
  return `Approval: ${approval.state} on v${approval.version}${content}`;
49101
49249
  }
49102
49250
  }
49251
+ function artifactUnderName(artifacts, name) {
49252
+ const written = name.trim();
49253
+ return artifacts.find((held) => held.slug === written) ?? artifacts.find((held) => held.name === written);
49254
+ }
49255
+ function artifactNameExistsProblem(held, owner) {
49256
+ const versions = held.versions ?? [];
49257
+ const newest = versions[versions.length - 1];
49258
+ if (newest === undefined) {
49259
+ 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}`;
49260
+ }
49261
+ const authors = (newest.authors ?? []).map(actorText);
49262
+ const wroteIt = authors.length === 0 ? actorText(held.created_by) : authors.join(" and ");
49263
+ return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
49264
+ }
49265
+ var STORED_LINE_QUOTED = 200;
49266
+ function quotedStoredLine(line) {
49267
+ if (line.length <= STORED_LINE_QUOTED)
49268
+ return JSON.stringify(line);
49269
+ const head = JSON.stringify(line.slice(0, STORED_LINE_QUOTED));
49270
+ return `${head} (cut after ${STORED_LINE_QUOTED} of its ${line.length} characters)`;
49271
+ }
49272
+ function firstStoredDifference(given, stored) {
49273
+ const written = given.split(`
49274
+ `);
49275
+ const holds = stored.split(`
49276
+ `);
49277
+ for (let line = 0;line < Math.max(written.length, holds.length); line += 1) {
49278
+ const wrote = written[line];
49279
+ const held = holds[line];
49280
+ if (wrote === held)
49281
+ continue;
49282
+ if (wrote === undefined && held !== undefined) {
49283
+ return `the store writes a line ${line + 1}, ${quotedStoredLine(held)}`;
49284
+ }
49285
+ if (held === undefined && wrote !== undefined) {
49286
+ return `the store drops line ${line + 1}, ${quotedStoredLine(wrote)}`;
49287
+ }
49288
+ if (wrote !== undefined && held !== undefined) {
49289
+ return `line ${line + 1} reads ${quotedStoredLine(wrote)} and is stored as ${quotedStoredLine(held)}`;
49290
+ }
49291
+ }
49292
+ return "the stored text differs from the text given";
49293
+ }
49294
+ var STORED_TEXT_PRINTED = 2000;
49295
+ function storedTextPrinted(stored) {
49296
+ if (stored.length <= STORED_TEXT_PRINTED)
49297
+ return { text: stored, cut: "" };
49298
+ const head = stored.slice(0, STORED_TEXT_PRINTED);
49299
+ const lastLineFeed = head.lastIndexOf(`
49300
+ `);
49301
+ const text = lastLineFeed === -1 ? head : head.slice(0, lastLineFeed + 1);
49302
+ return {
49303
+ text,
49304
+ cut: ` The text below is cut after ${text.length} of its ${stored.length} characters: change the line named above and send the text again.`
49305
+ };
49306
+ }
49307
+ function storedTextProblem(given, stored, name) {
49308
+ const asBytes = pathKeepsBytesOf(name) ? ` To keep the text as you wrote it, send it as a file with ${PATH_KEEPS_BYTES}.` : "";
49309
+ const printed = storedTextPrinted(stored);
49310
+ return [
49311
+ `Dispatch stores this text under another spelling: ${firstStoredDifference(given, stored)}.`,
49312
+ ` Send the text Dispatch stores, which is between the two marker lines below.${asBytes}`,
49313
+ `${printed.cut}
49314
+ --- the text Dispatch stores ---
49315
+ ${printed.text}`,
49316
+ "--- end of the text Dispatch stores ---"
49317
+ ].join("");
49318
+ }
49319
+ function storedTextCheckFailed(error, name) {
49320
+ 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)}.`;
49321
+ if (!dispatchAnswered(error, 413)) {
49322
+ return `${failure} Send the upload again once that call is answered.`;
49323
+ }
49324
+ const asBytes = pathKeepsBytesOf(name) ? ` Send it as a file with ${PATH_KEEPS_BYTES}, which asks this check nothing.` : "";
49325
+ 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}`;
49326
+ }
49327
+ function roundTripRouteAbsent(error) {
49328
+ return dispatchAnswered(error, 404) || dispatchAnswered(error, 405);
49329
+ }
49330
+ function withoutFinalLineFeed(text) {
49331
+ return text.endsWith(`
49332
+ `) ? text.slice(0, -1) : text;
49333
+ }
49103
49334
  function componentsLine(components) {
49104
49335
  const ids = components.ids ?? [];
49105
49336
  const unknown = components.unknown ?? [];
@@ -49193,7 +49424,96 @@ function progressText(progress, sep) {
49193
49424
  }
49194
49425
  return parts.join(sep);
49195
49426
  }
49196
- function formatCheckResults(results) {
49427
+ var BRIEF_READING_CHARACTERS = 200;
49428
+ var COMPARISON_REASONS = {
49429
+ no_pull_request_or_branch: "the issue has no pull request and no branch to compare with",
49430
+ repository_unreadable: "Dispatch cannot read the repository",
49431
+ read_failed: "a read Dispatch made did not answer"
49432
+ };
49433
+ function learnedText(learned) {
49434
+ if (learned.kind === "read_at")
49435
+ return `Dispatch read it ${learned.at}`;
49436
+ return `GitHub updated it ${learned.at}`;
49437
+ }
49438
+ function basisText(basis) {
49439
+ const learned = basis.learned_at === undefined ? "" : ` (${learnedText(basis.learned_at)})`;
49440
+ if (basis.kind === "pull_request") {
49441
+ const number = basis.pull_request === undefined ? "" : `#${basis.pull_request} `;
49442
+ return `the head of pull request ${number}at ${basis.commit ?? "an unnamed commit"}${learned}`;
49443
+ }
49444
+ if (basis.kind === "branch")
49445
+ return `branch ${basis.branch ?? "unnamed"}${learned}`;
49446
+ return `the commit you named, ${basis.commit ?? ""}${learned}`;
49447
+ }
49448
+ function basisPlace(basis) {
49449
+ if (basis.kind === "pull_request") {
49450
+ return basis.pull_request === undefined ? "the head of a pull request" : `the head of pull request #${basis.pull_request}`;
49451
+ }
49452
+ if (basis.kind === "branch")
49453
+ return `on branch ${basis.branch ?? "unnamed"}`;
49454
+ return "the commit you named";
49455
+ }
49456
+ function commitStandsText(stands) {
49457
+ if (stands === undefined) {
49458
+ return "Where that commit stands is not known: this Dispatch server does not say";
49459
+ }
49460
+ if (stands.answer === "at_basis") {
49461
+ return stands.basis === undefined ? "That commit is one of the compared commits" : `That commit is ${basisPlace(stands.basis)}`;
49462
+ }
49463
+ if (stands.answer === "other_commit")
49464
+ return "That commit is none of the compared commits";
49465
+ return stands.reason === undefined ? "Where that commit stands is not known" : `Where that commit stands is not known: ${COMPARISON_REASONS[stands.reason]}`;
49466
+ }
49467
+ function checkWordsText(check, result) {
49468
+ const versions = `result version ${result.check_version}, check version ${check.version}`;
49469
+ if (result.check_words_moved === undefined) {
49470
+ return `Whether the check's words moved is not known (${versions})`;
49471
+ }
49472
+ return result.check_words_moved ? `The check's words moved after this result (${versions})` : `The check's words did not move after this result (${versions})`;
49473
+ }
49474
+ function passStandsText(pass) {
49475
+ if (pass === undefined)
49476
+ return "Whether a pass stands is not known: this Dispatch server does not say";
49477
+ if (pass.answer === "yes") {
49478
+ const roles = pass.roles ?? [];
49479
+ return roles.length === 0 ? "A pass stands: yes" : `A pass stands: yes, from ${roles.join(", ")}`;
49480
+ }
49481
+ if (pass.answer === "no")
49482
+ return "A pass stands: no";
49483
+ return "A pass stands: not known";
49484
+ }
49485
+ function readingLines(result, brief) {
49486
+ const observed = result.observed;
49487
+ if (observed === "")
49488
+ return [" The role recorded no reading."];
49489
+ const cut = brief && result.commit_stands?.answer !== "at_basis";
49490
+ if (cut && observed.length > BRIEF_READING_CHARACTERS) {
49491
+ return [` Reading: ${observed.slice(0, BRIEF_READING_CHARACTERS)}\u2026 (result ${result.id})`];
49492
+ }
49493
+ return [` Reading: ${observed}`];
49494
+ }
49495
+ function resultLines(check, result, brief) {
49496
+ const lines = [
49497
+ ` - ${result.verdict} by ${result.role} at ${result.commit_sha}. ${commitStandsText(result.commit_stands)}. ${checkWordsText(check, result)}. Recorded ${result.created_at}. Result ${result.id}.`
49498
+ ];
49499
+ const retracted = result.retracted;
49500
+ if (retracted !== undefined) {
49501
+ lines.push(` Retracted by ${actorText(retracted.actor)} at ${retracted.created_at}. The reason: ${retracted.reason}`);
49502
+ }
49503
+ return [...lines, ...readingLines(result, brief)];
49504
+ }
49505
+ function checkLines(check, brief) {
49506
+ const bases = check.compared_with ?? [];
49507
+ const reason = check.compared_nothing;
49508
+ const compared = bases.length > 0 ? `Compared with ${bases.map(basisText).join(", ")}` : reason === undefined ? "Compared with nothing, and this Dispatch server does not say why" : `Compared with nothing: ${COMPARISON_REASONS[reason]}`;
49509
+ const results = check.results ?? [];
49510
+ return [
49511
+ `- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands)}.`,
49512
+ ` The check's words: ${check.text}`,
49513
+ ...results.length === 0 ? [" No result is recorded for this check."] : results.flatMap((result) => resultLines(check, result, brief))
49514
+ ];
49515
+ }
49516
+ function formatCheckResults(results, brief = false) {
49197
49517
  if (results.verification_artifact_id === "") {
49198
49518
  return `${results.issue} has no Verification document, so it has no checks. Write one (verification.md) with a check block per thing that must be proved.`;
49199
49519
  }
@@ -49201,15 +49521,10 @@ function formatCheckResults(results) {
49201
49521
  if (checks.length === 0) {
49202
49522
  return `${results.issue}'s Verification document holds no check blocks.`;
49203
49523
  }
49204
- const lines = checks.map((check) => {
49205
- const head = `- ${check.block_id} (${check.when}): `;
49206
- const latest = (check.results ?? [])[0];
49207
- if (latest === undefined) {
49208
- return `${head}no result yet. ${check.text}`;
49209
- }
49210
- return `${head}${latest.verdict} at ${latest.commit_sha} by ${latest.role}, ${latest.currency ?? "unknown"}. ${check.text}`;
49211
- });
49212
- return [`Checks of ${results.issue}:`, ...lines].join(`
49524
+ const blocks = checks.map((check) => checkLines(check, brief).join(`
49525
+ `));
49526
+ return [`Checks of ${results.issue}:`, ...blocks].join(`
49527
+
49213
49528
  `);
49214
49529
  }
49215
49530
  function repositoryLine(issue) {
@@ -49876,9 +50191,6 @@ ${text}`,
49876
50191
  var BLOCK_OPENING_CHARS = 60;
49877
50192
  async function listDocumentBlocks(client, artifact) {
49878
50193
  const live = await liveBlocks(client, artifact);
49879
- if (live === undefined) {
49880
- throw new Error(`${artifact.name} changed while dispatch doc-read --blocks read it, so the opening words could name the wrong text; nothing is listed. Run it again.`);
49881
- }
49882
50194
  const { bytes, blocks } = live;
49883
50195
  const decoder = new TextDecoder;
49884
50196
  const lines = [
@@ -49915,15 +50227,19 @@ async function listDocumentBlocks(client, artifact) {
49915
50227
  holders.push(block);
49916
50228
  }
49917
50229
  return { text: lines.join(`
49918
- `), token: live.token };
50230
+ `), token: live.token, version: live.version };
49919
50231
  }
49920
50232
  async function liveBlocks(client, artifact) {
49921
- const before = await client.docRead(artifact.id);
49922
- const blocks = await client.artifactBlocks(artifact.id);
49923
- const after = await client.docRead(artifact.id);
49924
- if (before.token !== after.token || before.markdown !== after.markdown)
49925
- return;
49926
- return { bytes: new TextEncoder().encode(before.markdown), token: before.token, blocks };
50233
+ const read = await client.docReadWithBlocks(artifact.id);
50234
+ if (read.blocks === undefined) {
50235
+ throw new Error(`${artifact.name} was read from a Dispatch older than this command: it serves a document's blocks only on their own route, not beside the text they index, so nothing was listed.`);
50236
+ }
50237
+ return {
50238
+ bytes: new TextEncoder().encode(read.markdown),
50239
+ token: read.token,
50240
+ version: read.version ?? null,
50241
+ blocks: read.blocks
50242
+ };
49927
50243
  }
49928
50244
  async function refuseOpenDecisionBlocks(client, tool, resolved) {
49929
50245
  const artifact = resolved.artifact;
@@ -50706,12 +51022,7 @@ async function executeDispatchTool(input) {
50706
51022
  const anchored = resolved ? anchor(resolved.artifact, args) : undefined;
50707
51023
  const replyTo = itemReplyTo(args, "reply_to");
50708
51024
  const replyToAskTarget = itemReplyTo(args, "reply_to_ask");
50709
- const replyToAsk = replyToAskTarget === undefined ? undefined : normalizeUUID(replyToAskTarget.id);
50710
- if (replyToAskTarget !== undefined && replyToAsk === undefined) {
50711
- throw new ToolInputError(input.tool, [
50712
- await invalidReplyToAskProblem(client, owner, resolved)
50713
- ]);
50714
- }
51025
+ const replyToAsk = replyToAskTarget === undefined ? undefined : await resolveReplyToAsk(input.tool, client, owner, resolved, replyToAskTarget.id);
50715
51026
  const replyToBlock = replyTo?.block ?? replyToAskTarget?.block;
50716
51027
  const requestedTurn = optionalString(args, "turn");
50717
51028
  const body = await writePictures(resolved, stringArg(args, "body"));
@@ -50932,10 +51243,15 @@ async function executeDispatchTool(input) {
50932
51243
  throw new Error(`${resolved.artifact.name} is an uploaded ${resolved.artifact.kind}, not a document, so it has no blocks. Read it with dispatch doc-read without --blocks.`);
50933
51244
  }
50934
51245
  const listed = await listDocumentBlocks(client, resolved.artifact);
51246
+ const trailer = [
51247
+ ...listed.token === undefined ? [] : [`Document token: ${listed.token}`],
51248
+ `Document version: ${listed.version === null ? "none yet" : listed.version}`
51249
+ ];
50935
51250
  return {
50936
- text: listed.token === undefined ? listed.text : `${listed.text}
51251
+ text: `${listed.text}
50937
51252
 
50938
- Document token: ${listed.token}`,
51253
+ ${trailer.join(`
51254
+ `)}`,
50939
51255
  details: resolved.owner.kind === "project" ? {
50940
51256
  project: resolved.artifact.project,
50941
51257
  document: documentLabel(resolved.artifact.project, resolved.artifact.slug)
@@ -51036,6 +51352,23 @@ Document token: ${listed.token}`,
51036
51352
  };
51037
51353
  }
51038
51354
  case "dispatch_result": {
51355
+ const retract = optionalString(args, "retract");
51356
+ if (retract !== undefined) {
51357
+ const retraction = await client.retractResult(retract, {
51358
+ actor,
51359
+ reason: stringArg(args, "reason")
51360
+ });
51361
+ return {
51362
+ text: `Retracted result ${retraction.result_id}. ${actorText(retraction.actor)} retracted it at ${retraction.created_at}. The reason: ${retraction.reason}
51363
+
51364
+ The result stays readable, and it proves nothing from now on. Record a new result where the check still needs one.`,
51365
+ details: {
51366
+ result: retraction.result_id,
51367
+ reason: retraction.reason,
51368
+ created_at: retraction.created_at
51369
+ }
51370
+ };
51371
+ }
51039
51372
  const issue = stringArg(args, "issue");
51040
51373
  const optional = {
51041
51374
  ...defined("surface", optionalString(args, "surface")),
@@ -51071,16 +51404,45 @@ ${recorded.line}`,
51071
51404
  }
51072
51405
  case "dispatch_results": {
51073
51406
  const issue = stringArg(args, "issue");
51074
- const results = await client.issueResults(issue);
51407
+ const at = optionalString(args, "at");
51408
+ const brief = optionalBoolean(args, "brief") === true;
51409
+ const results = await client.issueResults(issue, at);
51410
+ const checks = results.checks ?? [];
51075
51411
  return {
51076
- text: formatCheckResults(results),
51077
- details: { issue, checks: (results.checks ?? []).length }
51412
+ text: formatCheckResults(results, brief),
51413
+ details: {
51414
+ issue,
51415
+ checks: checks.length,
51416
+ results: checks.reduce((total, check) => total + (check.results ?? []).length, 0)
51417
+ }
51078
51418
  };
51079
51419
  }
51080
51420
  case "dispatch_artifact": {
51081
51421
  const summary = optionalString(args, "summary");
51082
51422
  const name = stringArg(args, "name");
51083
51423
  const content = optionalString(args, "content");
51424
+ const artifactOwner = documentOwner();
51425
+ if (optionalBoolean(args, "force") !== true) {
51426
+ const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
51427
+ if (held !== undefined) {
51428
+ throw new ToolInputError(input.tool, [
51429
+ artifactNameExistsProblem(held, artifactOwner.kind === "project" ? `project ${artifactOwner.project}` : `issue ${issue()}`)
51430
+ ]);
51431
+ }
51432
+ }
51433
+ if (content !== undefined) {
51434
+ let stored;
51435
+ try {
51436
+ stored = await client.markdownRoundTrip(content);
51437
+ } catch (error) {
51438
+ if (!roundTripRouteAbsent(error)) {
51439
+ throw new Error(storedTextCheckFailed(error, name), { cause: error });
51440
+ }
51441
+ }
51442
+ if (stored !== undefined && withoutFinalLineFeed(stored) !== withoutFinalLineFeed(content)) {
51443
+ throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
51444
+ }
51445
+ }
51084
51446
  const artifactInput = content === undefined ? {
51085
51447
  name,
51086
51448
  file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
@@ -51094,7 +51456,6 @@ ${recorded.line}`,
51094
51456
  ...summary === undefined ? {} : { summary },
51095
51457
  actor
51096
51458
  };
51097
- const artifactOwner = documentOwner();
51098
51459
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
51099
51460
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
51100
51461
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -55499,7 +55860,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
55499
55860
 
55500
55861
  // package.json
55501
55862
  var name = "@sjawhar/claude-envoy";
55502
- var version2 = "2.1.0";
55863
+ var version2 = "2.3.0";
55503
55864
  var legion = {
55504
55865
  daemonApiVersion: 73
55505
55866
  };