@sjawhar/claude-envoy 4.14.5 → 4.15.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.
@@ -36907,17 +36907,41 @@ var documentEditValidation = {
36907
36907
  };
36908
36908
  var commentOwner = documentOwnerValidation(true);
36909
36909
  var COMMENT_TURN_RULE = "turn requires reply_to_ask: turn says who holds an open ask's thread after the reply. Pass reply_to_ask with the open ask's id, or drop turn.";
36910
+ var MAX_COMMENT_MENTIONS = 10;
36911
+ var COMMENT_MENTION_LIMIT_RULE = `mentions allow at most ${MAX_COMMENT_MENTIONS} targets`;
36912
+ var MENTION_TARGET_PATTERNS = [/^role:[a-z0-9-]+$/, /^session:[A-Za-z0-9_-]+$/];
36913
+ var COMMENT_MENTION_TARGET_RULE = "mention target must be role:<name> or session:<id>";
36914
+ var COMMENT_MENTION_REPEAT_RULE = "mentions must not repeat a target";
36915
+ function mentionProblem(mentions) {
36916
+ if (!Array.isArray(mentions))
36917
+ return;
36918
+ if (mentions.length > MAX_COMMENT_MENTIONS)
36919
+ return COMMENT_MENTION_LIMIT_RULE;
36920
+ const seen = new Set;
36921
+ for (const target of mentions) {
36922
+ if (typeof target !== "string" || !MENTION_TARGET_PATTERNS.some((pattern) => pattern.test(target))) {
36923
+ return COMMENT_MENTION_TARGET_RULE;
36924
+ }
36925
+ if (seen.has(target))
36926
+ return COMMENT_MENTION_REPEAT_RULE;
36927
+ seen.add(target);
36928
+ }
36929
+ return;
36930
+ }
36910
36931
  function commentProblem(value) {
36911
36932
  const input = value;
36933
+ const mention = mentionProblem(input.mentions);
36912
36934
  return brokenParts([
36913
36935
  [commentOwner.check(value), commentOwner.message],
36914
- [input.turn === undefined || typeof input.reply_to_ask === "string", COMMENT_TURN_RULE]
36936
+ [input.turn === undefined || typeof input.reply_to_ask === "string", COMMENT_TURN_RULE],
36937
+ [mention === undefined, mention ?? ""]
36915
36938
  ]);
36916
36939
  }
36940
+ var COMMENT_RULE = `${commentOwner.message} ${COMMENT_TURN_RULE} ${COMMENT_MENTION_LIMIT_RULE}, each ${COMMENT_MENTION_TARGET_RULE}, and ${COMMENT_MENTION_REPEAT_RULE}.`;
36917
36941
  var commentValidation = {
36918
36942
  check: (value) => commentProblem(value) === undefined,
36919
- message: `${commentOwner.message} ${COMMENT_TURN_RULE}`,
36920
- refusal: (value) => commentProblem(value) ?? `${commentOwner.message} ${COMMENT_TURN_RULE}`
36943
+ message: COMMENT_RULE,
36944
+ refusal: (value) => commentProblem(value) ?? COMMENT_RULE
36921
36945
  };
36922
36946
  var ISSUE_UPDATE_FIELDS_RULE = "Issue update requires at least one field besides issue: status, title, labels, priority, assignee, external_links, route, parent, blocked_by, advances, components, repo, before, or after.";
36923
36947
  var ISSUE_UPDATE_DONE_RULE = "status done requires reason, a non-empty note saying why the issue is closing, posted on the issue before it closes so the close carries its note";
@@ -37277,6 +37301,7 @@ var dispatchToolSpecs = [
37277
37301
  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(),
37278
37302
  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(),
37279
37303
  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(),
37304
+ mentions: z.array(z.string()).describe("Optional targets the comment mentions: role:<name> (lowercase letters, digits and -), " + "which reaches the session holding that role, or session:<id> (letters, digits, _ " + "and -); at most 10, none named twice. Dispatch delivers the comment to each target, " + "retries a send that does not go through, and records every attempt on the comment.").optional(),
37280
37305
  images: imagesArgument(z, "the issue (or the project document's project)")
37281
37306
  }),
37282
37307
  validation: commentValidation
@@ -37422,7 +37447,7 @@ var dispatchToolSpecs = [
37422
37447
  verdict: "pass",
37423
37448
  commit: "1111111111111111111111111111111111111111"
37424
37449
  },
37425
- 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, no private host and no issue key: Dispatch keeps only words " + "of letters, digits and plain punctuation, and of those leaves out every word that holds " + "`://`, a private or Dispatch host, or an issue key of one of its projects; the record keeps " + "the whole reading. --dry-run prints the line the record would print, and records nothing. " + "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. " + `${CHECK_PROVED_BY_CI}. ` + "Dispatch reads its result from that run, so a record for it is 409 " + "CHECK_PROVED_BY_CI from every role, which names the check and the run. " + "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. " + "A check a document version rewords while the result is being written is 409 " + "CHECK_CONTENDED, with nothing recorded: run the same command again. " + 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,
37450
+ 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, no private host and no issue key: Dispatch keeps only words " + "of letters, digits and plain punctuation, and of those leaves out every word that holds " + "`://`, a private or Dispatch host, or an issue key of one of its projects; the record keeps " + "the whole reading. --dry-run prints the line the record would print, and records nothing. " + "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. " + `${CHECK_PROVED_BY_CI}. ` + "Dispatch reads its result from that run, so a record for it is 409 " + "CHECK_PROVED_BY_CI from every role, which names the check and the run. " + "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. If " + "GitHub does not say that it does, Dispatch reads the external links of the check's issue: " + "a link to a GitHub pull request (https://github.com/<owner>/<repo>/pull/<n>) that is open " + "or merged, in a repository that Dispatch's GitHub App is installed on and can read, adds " + "the repository of that pull request. One record reads at most 10 linked pull requests. A " + "commit that none of these repositories holds is 400 RESULT_COMMIT_UNKNOWN, which names the " + "commit and each owner/repo that Dispatch asked. It also names, with its reason " + "(owner/repo#n (repository_unreadable)), each linked pull request that Dispatch could not " + "read, at most 10 and a count of the rest, and every linked pull request in whose " + "repository it could not read the commit, since each of those spent one of the record's 10 " + "reads, and says to grant Dispatch's GitHub App that repository or to link a readable pull " + "request. It says how many linked pull requests it left unread past that bound. Record the " + "result after the commit is pushed. A linked repository that the App is not installed on " + "or cannot read does " + "not count. Where a read of " + "a linked pull request or of a linked repository does not answer, and no repository is shown " + "to hold the commit, the record is 502 GITHUB_UNREADABLE and nothing is recorded: record the " + "result again, after the wait the refusal names for a rate limit. Where the issue has no " + "repository, the result is recorded as before. Where Dispatch cannot read the repository " + "of the check's issue, the result is recorded as before only when every linked read " + "answers and no linked repository holds the commit: a linked read that does not answer " + "is 502 GITHUB_UNREADABLE and nothing is recorded. " + "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. " + "A check a document version rewords while the result is being written is 409 " + "CHECK_CONTENDED, with nothing recorded: run the same command again. " + 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,
37426
37451
  arguments: (z) => ({
37427
37452
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
37428
37453
  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(),
@@ -39493,6 +39518,7 @@ var EnvelopeSchema = object({
39493
39518
  expires_at: number2().int().optional(),
39494
39519
  kept_at: number2().int().optional(),
39495
39520
  mention_dedupe_keys: record(string2(), string2()).optional(),
39521
+ role: string2().min(1).optional(),
39496
39522
  payload_summary: string2().min(1),
39497
39523
  payload: string2().optional(),
39498
39524
  payload_ref: string2().optional(),
@@ -49184,6 +49210,153 @@ function childrenSummary(issue) {
49184
49210
  `);
49185
49211
  }
49186
49212
 
49213
+ // ../envoy-client/src/dispatch-commands/render-results.ts
49214
+ var BRIEF_READING_CHARACTERS = 200;
49215
+ var COMPARISON_REASONS = {
49216
+ no_pull_request_or_branch: () => "the issue has no pull request and no branch to compare with",
49217
+ repository_unreadable: (repo = "the repository") => `Dispatch cannot read ${repo}`,
49218
+ read_failed: (repo) => repo === undefined ? "a read Dispatch made did not answer" : `a read Dispatch made of ${repo} did not answer`
49219
+ };
49220
+ function isComparisonReason(reason) {
49221
+ return Object.hasOwn(COMPARISON_REASONS, reason);
49222
+ }
49223
+ function reasonText(reason, repo) {
49224
+ if (isComparisonReason(reason))
49225
+ return COMPARISON_REASONS[reason](repo);
49226
+ return repo === undefined ? reason : `${reason} (${repo})`;
49227
+ }
49228
+ function learnedText(learned) {
49229
+ if (learned.kind === "read_at")
49230
+ return `Dispatch read it ${learned.at}`;
49231
+ return `GitHub updated it ${learned.at}`;
49232
+ }
49233
+ function pullRequestName(basis, number) {
49234
+ return basis.repo === undefined ? `pull request #${number}` : `${basis.repo}#${number}`;
49235
+ }
49236
+ function branchName(basis) {
49237
+ const branch = basis.branch ?? "unnamed";
49238
+ return basis.repo === undefined ? branch : `${branch} of ${basis.repo}`;
49239
+ }
49240
+ function basisText(basis) {
49241
+ const learned = basis.learned_at === undefined ? "" : ` (${learnedText(basis.learned_at)})`;
49242
+ if (basis.kind === "pull_request") {
49243
+ const pullRequest = basis.pull_request === undefined ? "pull request " : `${pullRequestName(basis, basis.pull_request)} `;
49244
+ return `the head of ${pullRequest}at ${basis.commit ?? "an unnamed commit"}${learned}`;
49245
+ }
49246
+ if (basis.kind === "branch")
49247
+ return `branch ${branchName(basis)}${learned}`;
49248
+ return `the commit you named, ${basis.commit ?? ""}${learned}`;
49249
+ }
49250
+ function basisPlace(basis) {
49251
+ if (basis.kind === "pull_request") {
49252
+ return basis.pull_request === undefined ? "the head of a pull request" : `the head of ${pullRequestName(basis, basis.pull_request)}`;
49253
+ }
49254
+ if (basis.kind === "branch")
49255
+ return `on branch ${branchName(basis)}`;
49256
+ return "the commit you named";
49257
+ }
49258
+ function commitStandsText(stands) {
49259
+ if (stands === undefined) {
49260
+ return "Where that commit stands is not known: this Dispatch server does not say";
49261
+ }
49262
+ if (stands.answer === "at_basis") {
49263
+ return stands.basis === undefined ? "That commit is one of the compared commits" : `That commit is ${basisPlace(stands.basis)}`;
49264
+ }
49265
+ if (stands.answer === "other_commit") {
49266
+ return stands.repo === undefined ? "That commit is none of the compared commits" : `That commit, of ${stands.repo}, is none of the compared commits`;
49267
+ }
49268
+ if (stands.reason === undefined) {
49269
+ return stands.repo === undefined ? "Where that commit stands is not known" : `Where that commit of ${stands.repo} stands is not known`;
49270
+ }
49271
+ return `Where that commit stands is not known: ${reasonText(stands.reason, stands.repo)}`;
49272
+ }
49273
+ function checkWordsText(check, result) {
49274
+ const versions = `result version ${result.check_version}, check version ${check.version}`;
49275
+ if (result.check_words_moved === undefined) {
49276
+ return `Whether the check's words moved is not known (${versions})`;
49277
+ }
49278
+ 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})`;
49279
+ }
49280
+ function passStandsText(pass) {
49281
+ if (pass === undefined)
49282
+ return "Whether a pass stands is not known: this Dispatch server does not say";
49283
+ if (pass.answer === "yes") {
49284
+ const roles = pass.roles ?? [];
49285
+ return roles.length === 0 ? "A pass stands: yes" : `A pass stands: yes, from ${roles.join(", ")}`;
49286
+ }
49287
+ if (pass.answer === "no")
49288
+ return "A pass stands: no";
49289
+ return "A pass stands: not known";
49290
+ }
49291
+ function readingLines(result, brief, indent = " ") {
49292
+ const observed = result.observed;
49293
+ if (observed === "")
49294
+ return [`${indent}The role recorded no reading.`];
49295
+ const cut = brief && result.commit_stands?.answer !== "at_basis";
49296
+ if (cut && observed.length > BRIEF_READING_CHARACTERS) {
49297
+ return [
49298
+ `${indent}Reading: ${observed.slice(0, BRIEF_READING_CHARACTERS)}\u2026 (result ${result.id})`
49299
+ ];
49300
+ }
49301
+ return [`${indent}Reading: ${observed}`];
49302
+ }
49303
+ function resultLines(check, result, brief) {
49304
+ const lines = [
49305
+ ` - ${result.verdict} by ${result.role} at ${result.commit_sha}. ${commitStandsText(result.commit_stands)}. ${checkWordsText(check, result)}. Recorded ${result.created_at}. Result ${result.id}.`
49306
+ ];
49307
+ const retracted = result.retracted;
49308
+ if (retracted !== undefined) {
49309
+ lines.push(` Retracted by ${actorText(retracted.actor)} at ${retracted.created_at}. The reason: ${retracted.reason}`);
49310
+ }
49311
+ return [...lines, ...readingLines(result, brief)];
49312
+ }
49313
+ function ciCheckLines(check, ci, brief) {
49314
+ const passStandsLine = ` ${passStandsText(check.pass_stands)}.`;
49315
+ const pullRequestLine = ` Pull request line: ${ci.line}`;
49316
+ const derived = check.results?.[0];
49317
+ if (derived === undefined) {
49318
+ return [
49319
+ `- ${check.block_id} (${check.when}): no result: ${ci.detail} ${check.text}`,
49320
+ passStandsLine,
49321
+ pullRequestLine
49322
+ ];
49323
+ }
49324
+ const stands = commitStandsText(derived.commit_stands);
49325
+ return [
49326
+ `- ${check.block_id} (${check.when}): ${derived.verdict} at ${derived.commit_sha} by ${derived.role} (CI run ${ci.run}, ${ci.case}), ${stands.charAt(0).toLowerCase()}${stands.slice(1)}. ${check.text}`,
49327
+ passStandsLine,
49328
+ pullRequestLine,
49329
+ ...readingLines(derived, brief, " ")
49330
+ ];
49331
+ }
49332
+ function checkLines(check, brief) {
49333
+ if (check.ci !== undefined)
49334
+ return ciCheckLines(check, check.ci, brief);
49335
+ const bases = check.compared_with ?? [];
49336
+ const reason = check.compared_nothing;
49337
+ 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: ${reasonText(reason)}`;
49338
+ const results = check.results ?? [];
49339
+ return [
49340
+ `- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands)}.`,
49341
+ ` The check's words: ${check.text}`,
49342
+ ...results.length === 0 ? [" No result is recorded for this check."] : results.flatMap((result) => resultLines(check, result, brief))
49343
+ ];
49344
+ }
49345
+ function formatCheckResults(results, brief = false) {
49346
+ if (results.verification_artifact_id === "") {
49347
+ 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.`;
49348
+ }
49349
+ const checks = results.checks ?? [];
49350
+ if (checks.length === 0) {
49351
+ return `${results.issue}'s Verification document holds no check blocks.`;
49352
+ }
49353
+ const blocks = checks.map((check) => checkLines(check, brief).join(`
49354
+ `));
49355
+ return [`Checks of ${results.issue}:`, ...blocks].join(`
49356
+
49357
+ `);
49358
+ }
49359
+
49187
49360
  // ../envoy-client/src/dispatch-subscribe.ts
49188
49361
  function followedAsk(details) {
49189
49362
  if (typeof details !== "object" || details === null)
@@ -49709,132 +49882,6 @@ async function issuesCommand(context) {
49709
49882
  details: { issues: rows, total, offset, limit }
49710
49883
  };
49711
49884
  }
49712
- var BRIEF_READING_CHARACTERS = 200;
49713
- var COMPARISON_REASONS = {
49714
- no_pull_request_or_branch: "the issue has no pull request and no branch to compare with",
49715
- repository_unreadable: "Dispatch cannot read the repository",
49716
- read_failed: "a read Dispatch made did not answer"
49717
- };
49718
- function learnedText(learned) {
49719
- if (learned.kind === "read_at")
49720
- return `Dispatch read it ${learned.at}`;
49721
- return `GitHub updated it ${learned.at}`;
49722
- }
49723
- function basisText(basis) {
49724
- const learned = basis.learned_at === undefined ? "" : ` (${learnedText(basis.learned_at)})`;
49725
- if (basis.kind === "pull_request") {
49726
- const number = basis.pull_request === undefined ? "" : `#${basis.pull_request} `;
49727
- return `the head of pull request ${number}at ${basis.commit ?? "an unnamed commit"}${learned}`;
49728
- }
49729
- if (basis.kind === "branch")
49730
- return `branch ${basis.branch ?? "unnamed"}${learned}`;
49731
- return `the commit you named, ${basis.commit ?? ""}${learned}`;
49732
- }
49733
- function basisPlace(basis) {
49734
- if (basis.kind === "pull_request") {
49735
- return basis.pull_request === undefined ? "the head of a pull request" : `the head of pull request #${basis.pull_request}`;
49736
- }
49737
- if (basis.kind === "branch")
49738
- return `on branch ${basis.branch ?? "unnamed"}`;
49739
- return "the commit you named";
49740
- }
49741
- function commitStandsText(stands) {
49742
- if (stands === undefined) {
49743
- return "Where that commit stands is not known: this Dispatch server does not say";
49744
- }
49745
- if (stands.answer === "at_basis") {
49746
- return stands.basis === undefined ? "That commit is one of the compared commits" : `That commit is ${basisPlace(stands.basis)}`;
49747
- }
49748
- if (stands.answer === "other_commit")
49749
- return "That commit is none of the compared commits";
49750
- return stands.reason === undefined ? "Where that commit stands is not known" : `Where that commit stands is not known: ${COMPARISON_REASONS[stands.reason]}`;
49751
- }
49752
- function checkWordsText(check, result) {
49753
- const versions = `result version ${result.check_version}, check version ${check.version}`;
49754
- if (result.check_words_moved === undefined) {
49755
- return `Whether the check's words moved is not known (${versions})`;
49756
- }
49757
- 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})`;
49758
- }
49759
- function passStandsText(pass) {
49760
- if (pass === undefined)
49761
- return "Whether a pass stands is not known: this Dispatch server does not say";
49762
- if (pass.answer === "yes") {
49763
- const roles = pass.roles ?? [];
49764
- return roles.length === 0 ? "A pass stands: yes" : `A pass stands: yes, from ${roles.join(", ")}`;
49765
- }
49766
- if (pass.answer === "no")
49767
- return "A pass stands: no";
49768
- return "A pass stands: not known";
49769
- }
49770
- function readingLines(result, brief, indent = " ") {
49771
- const observed = result.observed;
49772
- if (observed === "")
49773
- return [`${indent}The role recorded no reading.`];
49774
- const cut = brief && result.commit_stands?.answer !== "at_basis";
49775
- if (cut && observed.length > BRIEF_READING_CHARACTERS) {
49776
- return [
49777
- `${indent}Reading: ${observed.slice(0, BRIEF_READING_CHARACTERS)}\u2026 (result ${result.id})`
49778
- ];
49779
- }
49780
- return [`${indent}Reading: ${observed}`];
49781
- }
49782
- function resultLines(check, result, brief) {
49783
- const lines = [
49784
- ` - ${result.verdict} by ${result.role} at ${result.commit_sha}. ${commitStandsText(result.commit_stands)}. ${checkWordsText(check, result)}. Recorded ${result.created_at}. Result ${result.id}.`
49785
- ];
49786
- const retracted = result.retracted;
49787
- if (retracted !== undefined) {
49788
- lines.push(` Retracted by ${actorText(retracted.actor)} at ${retracted.created_at}. The reason: ${retracted.reason}`);
49789
- }
49790
- return [...lines, ...readingLines(result, brief)];
49791
- }
49792
- function ciCheckLines(check, ci, brief) {
49793
- const passStandsLine = ` ${passStandsText(check.pass_stands)}.`;
49794
- const pullRequestLine = ` Pull request line: ${ci.line}`;
49795
- const derived = check.results?.[0];
49796
- if (derived === undefined) {
49797
- return [
49798
- `- ${check.block_id} (${check.when}): no result: ${ci.detail} ${check.text}`,
49799
- passStandsLine,
49800
- pullRequestLine
49801
- ];
49802
- }
49803
- const stands = commitStandsText(derived.commit_stands);
49804
- return [
49805
- `- ${check.block_id} (${check.when}): ${derived.verdict} at ${derived.commit_sha} by ${derived.role} (CI run ${ci.run}, ${ci.case}), ${stands.charAt(0).toLowerCase()}${stands.slice(1)}. ${check.text}`,
49806
- passStandsLine,
49807
- pullRequestLine,
49808
- ...readingLines(derived, brief, " ")
49809
- ];
49810
- }
49811
- function checkLines(check, brief) {
49812
- if (check.ci !== undefined)
49813
- return ciCheckLines(check, check.ci, brief);
49814
- const bases = check.compared_with ?? [];
49815
- const reason = check.compared_nothing;
49816
- 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]}`;
49817
- const results = check.results ?? [];
49818
- return [
49819
- `- ${check.block_id} (${check.when}). ${compared}. ${passStandsText(check.pass_stands)}.`,
49820
- ` The check's words: ${check.text}`,
49821
- ...results.length === 0 ? [" No result is recorded for this check."] : results.flatMap((result) => resultLines(check, result, brief))
49822
- ];
49823
- }
49824
- function formatCheckResults(results, brief = false) {
49825
- if (results.verification_artifact_id === "") {
49826
- 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.`;
49827
- }
49828
- const checks = results.checks ?? [];
49829
- if (checks.length === 0) {
49830
- return `${results.issue}'s Verification document holds no check blocks.`;
49831
- }
49832
- const blocks = checks.map((check) => checkLines(check, brief).join(`
49833
- `));
49834
- return [`Checks of ${results.issue}:`, ...blocks].join(`
49835
-
49836
- `);
49837
- }
49838
49885
  function dryRunAsksDispatch(tool, args) {
49839
49886
  return tool === "dispatch_result" && args["retract"] === undefined;
49840
49887
  }
@@ -50586,6 +50633,7 @@ async function commentCommand(context) {
50586
50633
  const replyToAsk = replyToAskTarget === undefined ? undefined : await resolveReplyToAsk(input.tool, client, owner, resolved, replyToAskTarget.id);
50587
50634
  const replyToBlock = replyTo?.block ?? replyToAskTarget?.block;
50588
50635
  const requestedTurn = optionalString(args, "turn");
50636
+ const mentions = optionalStringArray(args, "mentions");
50589
50637
  const body = await writePictures(resolved, stringArg(args, "body"));
50590
50638
  const commentInput = {
50591
50639
  body,
@@ -50594,6 +50642,7 @@ async function commentCommand(context) {
50594
50642
  ...replyToBlock === undefined ? {} : { reply_to_block: replyToBlock },
50595
50643
  ...replyToAsk === undefined ? {} : { ask_id: replyToAsk },
50596
50644
  ...requestedTurn === undefined ? {} : { turn: requestedTurn },
50645
+ ...mentions === undefined ? {} : { mentions: mentions.map((target) => ({ target })) },
50597
50646
  actor
50598
50647
  };
50599
50648
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
@@ -58530,7 +58579,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
58530
58579
 
58531
58580
  // package.json
58532
58581
  var name2 = "@sjawhar/claude-envoy";
58533
- var version2 = "4.14.5";
58582
+ var version2 = "4.15.0";
58534
58583
  var legion = {
58535
58584
  daemonApiVersion: 178
58536
58585
  };
@@ -59846,9 +59895,14 @@ function claimRoleAtFirstTurn(host, role, firstTurn) {
59846
59895
  clearTimeout(bound);
59847
59896
  (async () => {
59848
59897
  try {
59849
- await host.claimRole(role);
59898
+ await claimRoleAgainOnBusy(() => host.claimRole(role), role, {
59899
+ log: host.log,
59900
+ firstDelayMs: host.roleClaimRetryFirstDelayMs,
59901
+ signal: host.signal
59902
+ });
59850
59903
  } catch (error) {
59851
- stopAfterRegistration(host, role, error);
59904
+ if (!host.signal?.aborted)
59905
+ stopAfterRegistration(host, role, error);
59852
59906
  }
59853
59907
  done.resolve();
59854
59908
  })();
@@ -59858,6 +59912,43 @@ function claimRoleAtFirstTurn(host, role, firstTurn) {
59858
59912
  firstTurn(claim);
59859
59913
  return done.promise;
59860
59914
  }
59915
+ var ROLE_CLAIM_RETRY_FIRST_DELAY_MS = 1000;
59916
+ var ROLE_CLAIM_RETRY_MAX_DELAY_MS = 30000;
59917
+ async function claimRoleAgainOnBusy(claim, role, options) {
59918
+ let wait = options.firstDelayMs ?? ROLE_CLAIM_RETRY_FIRST_DELAY_MS;
59919
+ for (let attempt = 1;; attempt++) {
59920
+ try {
59921
+ await claim();
59922
+ return;
59923
+ } catch (error) {
59924
+ if (!listenerAskedToClaimAgain(error) || options.signal?.aborted)
59925
+ throw error;
59926
+ if (options.maxAttempts !== undefined && attempt >= options.maxAttempts)
59927
+ throw error;
59928
+ options.log(`claim of Envoy role ${role} was answered 503 at attempt ${attempt}, so nothing was claimed; claiming it again in ${wait} ms: ${messageFor(error)}`);
59929
+ const waited = Promise.withResolvers();
59930
+ const timer = setTimeout(waited.resolve, wait);
59931
+ timer.unref?.();
59932
+ const abort = () => {
59933
+ clearTimeout(timer);
59934
+ waited.resolve();
59935
+ };
59936
+ options.signal?.addEventListener("abort", abort, { once: true });
59937
+ await waited.promise;
59938
+ options.signal?.removeEventListener("abort", abort);
59939
+ if (options.signal?.aborted)
59940
+ throw error;
59941
+ wait = Math.min(wait * 2, ROLE_CLAIM_RETRY_MAX_DELAY_MS);
59942
+ }
59943
+ }
59944
+ }
59945
+ function listenerAskedToClaimAgain(error) {
59946
+ if (!(error instanceof Error) || error.name !== "EnvoyApiError" || !("details" in error)) {
59947
+ return false;
59948
+ }
59949
+ const { details } = error;
59950
+ return typeof details === "object" && details !== null && "status" in details && details.status === 503;
59951
+ }
59861
59952
 
59862
59953
  // src/legion-phase-hook.ts
59863
59954
  import { randomUUID as randomUUID4 } from "crypto";
@@ -60656,6 +60747,7 @@ function startLegionClaim(deps) {
60656
60747
  firstTurnBoundMs: claimFirstTurnBoundMs(deps.env ?? process.env, paneReminderLog(deps.log)),
60657
60748
  onRoleRegained: (listener) => deps.session.onRoleRegained(listener),
60658
60749
  log: deps.log,
60750
+ signal: deps.signal,
60659
60751
  stopping: "stopping the pane so the daemon launches it again",
60660
60752
  stop: () => {
60661
60753
  if (!deps.signal.aborted)