@sjawhar/claude-envoy 5.23.6 → 5.24.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.
@@ -36872,6 +36872,8 @@ var ASK_OPTIONS_CONTRACT = "Options carry the genuinely different approaches. Ea
36872
36872
  var ASK_IS_FOR_A_PERSON = "An ask is a question for a person, never a request to another agent. Ask an agent by envoy_send or a comment on the issue.";
36873
36873
  var ASK_WAITS_ON_THE_ASSIGNEE = "An ask waits on its asked-of person, else the issue's assignee, else the project's default assignee; no agent hands one on.";
36874
36874
  var HUMAN_AGREED_TO_DOCUMENT = "the human has agreed to every point in the document";
36875
+ var DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; with project, artifact names the document.";
36876
+ var NAMED_DOCUMENT_OWNER_RULE = "Exactly one of issue and project is required; artifact or ref must name the document.";
36875
36877
  function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
36876
36878
  return {
36877
36879
  check: (value) => {
@@ -36882,15 +36884,21 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
36882
36884
  const hasRef = typeof input.ref === "string";
36883
36885
  return (hasIssue !== hasProject || !hasIssue && !hasProject && hasRef) && (!hasProject || !requireArtifact || hasArtifact) && (!alwaysRequireArtifact || hasArtifact || hasRef);
36884
36886
  },
36885
- message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
36887
+ message: alwaysRequireArtifact ? NAMED_DOCUMENT_OWNER_RULE : DOCUMENT_OWNER_RULE
36886
36888
  };
36887
36889
  }
36888
36890
  var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
36889
- var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
36891
+ var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} ${DOCUMENT_OWNER_RULE}`;
36890
36892
  function brokenParts(parts) {
36891
36893
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
36892
36894
  return broken.length === 0 ? undefined : broken.join(" ");
36893
36895
  }
36896
+ function withoutOwnerRule(refusal) {
36897
+ const rule = DISPATCH_OWNER_RULES.find((owner) => refusal === owner || refusal.startsWith(`${owner} `));
36898
+ if (rule === undefined)
36899
+ return refusal;
36900
+ return refusal === rule ? undefined : refusal.slice(rule.length + 1);
36901
+ }
36894
36902
  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)";
36895
36903
  var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
36896
36904
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
@@ -36934,18 +36942,13 @@ function pathKeepsBytesOf(name) {
36934
36942
  var artifactOwner = documentOwnerValidation(false);
36935
36943
  function artifactProblem(value) {
36936
36944
  const input = value;
36937
- const ownerOrSourceProblem = brokenParts([
36945
+ const extension = typeof input.path === "string" || typeof input.name !== "string" ? undefined : NAME_EXTENSION.exec(input.name.trim())?.[1];
36946
+ const nameProblem = extension === undefined || MARKDOWN_EXTENSION.test(extension) ? undefined : `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
36947
+ return brokenParts([
36938
36948
  [artifactOwner.check(value), artifactOwner.message],
36939
- [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
36949
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE],
36950
+ [nameProblem === undefined, nameProblem ?? ""]
36940
36951
  ]);
36941
- if (ownerOrSourceProblem !== undefined)
36942
- return ownerOrSourceProblem;
36943
- if (typeof input.path === "string" || typeof input.name !== "string")
36944
- return;
36945
- const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
36946
- if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
36947
- return;
36948
- return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
36949
36952
  }
36950
36953
  var documentEditOwner = documentOwnerValidation(true);
36951
36954
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -37040,34 +37043,100 @@ var ISSUE_UPDATE_FIELDS_RULE = "Issue update requires at least one field besides
37040
37043
  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";
37041
37044
  var ISSUE_UPDATE_REASON_RULE = "reason goes only with status done";
37042
37045
  var ISSUE_UPDATE_LABELS_RULE = "labels_add goes without labels";
37043
- var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}.`;
37044
- function issueUpdateProblem(value) {
37045
- const input = value;
37046
+ var ISSUE_UPDATE_LABELS_REFUSAL = `${ISSUE_UPDATE_LABELS_RULE}: labels replaces every label the issue holds and labels_add adds to them, so name the labels to add in labels_add alone, or the whole set in labels alone.`;
37047
+ var ISSUE_STATUS_OPTIONS = [
37048
+ "include_children",
37049
+ "unlink_children",
37050
+ "include_parent"
37051
+ ];
37052
+ function issueStatusOptionsOf(input) {
37053
+ return ISSUE_STATUS_OPTIONS.filter((option) => input[option] === true);
37054
+ }
37055
+ var ISSUE_UPDATE_PATCH_FIELDS = [
37056
+ "title",
37057
+ "labels",
37058
+ "labels_add",
37059
+ "priority",
37060
+ "assignee",
37061
+ "external_links",
37062
+ "route",
37063
+ "parent",
37064
+ "blocked_by",
37065
+ "advances",
37066
+ "advances_revision",
37067
+ "components",
37068
+ "repo",
37069
+ "before",
37070
+ "after"
37071
+ ];
37072
+ var ISSUE_UPDATE_OPTIONS_RULE = "include_children, unlink_children and include_parent go with status, and with reason when the status is done, and with no other field. include_children does not go with unlink_children, or with status done.";
37073
+ var ISSUE_UPDATE_RULE = `${ISSUE_UPDATE_FIELDS_RULE} ${ISSUE_UPDATE_DONE_RULE}; ${ISSUE_UPDATE_REASON_RULE}; ${ISSUE_UPDATE_LABELS_RULE}. ${ISSUE_UPDATE_OPTIONS_RULE}`;
37074
+ function issueStatusOptionsProblem(input) {
37075
+ const options = issueStatusOptionsOf(input);
37076
+ if (options.length === 0)
37077
+ return;
37078
+ const named = options.join(", ").replace(/, ([^,]*)$/, " and $1");
37079
+ const others = ISSUE_UPDATE_PATCH_FIELDS.filter((field) => input[field] !== undefined);
37080
+ return brokenParts([
37081
+ [
37082
+ !(input["include_children"] === true && input["unlink_children"] === true),
37083
+ "include_children does not go with unlink_children. The open children move with the issue or leave it, so name one of the two."
37084
+ ],
37085
+ [
37086
+ !(input["include_children"] === true && input["status"] === "done"),
37087
+ "include_children does not go with status done. Only a person who is signed in at a browser can close the open issues under an issue together with it, and this call presents a token. That person does it on the issue's page in Dispatch: Close issue, then Move them with it."
37088
+ ],
37089
+ [
37090
+ typeof input["status"] === "string",
37091
+ `status is required with ${named}. Add status, or drop ${named}.`
37092
+ ],
37093
+ [
37094
+ others.length === 0,
37095
+ `With ${named}, give status alone, and reason when the status is done. This call also names ${others.join(", ")}. Send those fields in a call of their own.`
37096
+ ]
37097
+ ]);
37098
+ }
37099
+ function issueReasonProblem(input) {
37046
37100
  if (input.status === "done") {
37047
- if (typeof input.reason !== "string" || input.reason.trim() === "") {
37048
- return `${ISSUE_UPDATE_DONE_RULE}.`;
37049
- }
37050
- } else if (input.reason !== undefined) {
37051
- const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
37052
- return `${ISSUE_UPDATE_REASON_RULE}: it is the note posted on the issue as it closes, and ${status} closes nothing. Drop reason, or set status done to close the issue.`;
37053
- }
37054
- if (input.labels !== undefined && input.labels_add !== undefined) {
37055
- return `${ISSUE_UPDATE_LABELS_RULE}: labels replaces every label the issue holds and labels_add adds to them, so name the labels to add in labels_add alone, or the whole set in labels alone.`;
37101
+ return typeof input.reason !== "string" || input.reason.trim() === "" ? `${ISSUE_UPDATE_DONE_RULE}.` : undefined;
37056
37102
  }
37103
+ if (input.reason === undefined)
37104
+ return;
37105
+ const status = typeof input.status === "string" ? `status ${input.status}` : "an update without status done";
37106
+ return `${ISSUE_UPDATE_REASON_RULE}: it is the note posted on the issue as it closes, and ${status} closes nothing. Drop reason, or set status done to close the issue.`;
37107
+ }
37108
+ function issueUpdateProblem(value) {
37109
+ const input = value;
37110
+ const reasonProblem = issueReasonProblem(input);
37111
+ const optionsProblem = issueStatusOptionsProblem(value);
37112
+ const broken = brokenParts([
37113
+ [reasonProblem === undefined, reasonProblem ?? ""],
37114
+ [input.labels === undefined || input.labels_add === undefined, ISSUE_UPDATE_LABELS_REFUSAL],
37115
+ [optionsProblem === undefined, optionsProblem ?? ""]
37116
+ ]);
37117
+ if (broken !== undefined)
37118
+ return broken;
37057
37119
  const changesAField = typeof input.status === "string" || typeof input.title === "string" || Array.isArray(input.labels) || Array.isArray(input.labels_add) || typeof input.priority === "number" || input.priority === null || typeof input.assignee === "string" || input.assignee === null || Array.isArray(input.external_links) || typeof input.route === "string" || typeof input.parent === "string" || Array.isArray(input.blocked_by) || Array.isArray(input.advances) || typeof input.components === "object" && input.components !== null || typeof input.repo === "string" || typeof input.before === "string" || typeof input.after === "string";
37058
37120
  return changesAField ? undefined : ISSUE_UPDATE_FIELDS_RULE;
37059
37121
  }
37122
+ var MESSAGE_OWNER_RULE = "issue is required unless in_reply_to names a message delivered to this session, which is the one message with no issue.";
37060
37123
  var messageValidation = {
37061
37124
  check: (value) => {
37062
37125
  const input = value;
37063
37126
  return typeof input.issue === "string" || typeof input.in_reply_to === "string";
37064
37127
  },
37065
- message: "issue is required unless in_reply_to names a message delivered to this session, which is the one message with no issue."
37128
+ message: MESSAGE_OWNER_RULE
37066
37129
  };
37067
37130
  var readOwner = documentOwnerValidation(false);
37068
37131
  var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
37069
37132
  var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
37070
37133
  var READ_HISTORY_RULE = "history reads each body an edit or the delete of one post replaced, so it needs a ref naming one comment or one issue message: message stands alone and names a whole conversation, which keeps no history of its own.";
37134
+ var DISPATCH_OWNER_RULES = [
37135
+ DOCUMENT_OWNER_RULE,
37136
+ NAMED_DOCUMENT_OWNER_RULE,
37137
+ READ_OWNER_RULE,
37138
+ MESSAGE_OWNER_RULE
37139
+ ];
37071
37140
  function readProblem(value) {
37072
37141
  const input = value;
37073
37142
  const historyKept = input.history !== true || typeof input.ref === "string";
@@ -37258,11 +37327,14 @@ var dispatchToolSpecs = [
37258
37327
  priority: 1,
37259
37328
  before: "DSP-2"
37260
37329
  },
37261
- description: "Update an existing issue: move its lifecycle status, retitle it, add labels to it or " + "replace its labels, set " + "its priority, set or clear its assignee, link a URL (the pull request that delivers it, a " + "run, a document), set its " + "route, set or clear its parent, replace the issues it is blocked by, replace the " + "priorities it advances, attach it to " + "architecture components, set the repository it targets, or move it on its project's " + "board. Status is one of " + `${ISSUE_STATUSES.join(", ")}; outside Legion, move it yourself as the work advances; inside ` + "Legion the daemon moves it. labels_add adds labels and keeps every label the issue holds; " + "labels replaces the whole set, so a label it does not name is removed, and the two never " + "go together. A non-empty external_links is " + "merged into the issue's existing links by URL, so linking the pull request you just opened " + "keeps every earlier link; an empty external_links removes every link instead. components " + "replaces the issue's own attachment. Closing an issue " + "(status done) requires reason, the note that says why: it is posted on the issue as a " + "message, then the issue closes, so the close carries its note; closing an issue that is " + "already closed is refused (ISSUE_CLOSED) before anything is posted. Reason goes only " + "with status done. Closing an issue withdraws every open ask " + "it holds (resolution kind withdrawn, naming the closer), and reopening it brings exactly " + "those asks back. " + "A closed issue still takes messages and comments, though not asks or artifacts; of this " + "tool's fields it takes only a board move " + "(before, after), components, " + "a reopening status (any status but done), and an external_links write that adds no new " + "link (so a link can move to the issue that replaced it); everything else, priority " + "included, waits for the reopen. " + "priority is yours to set and a human overrides it. assignee is the person who answers " + "this issue's asks, and every ask on it waits on them until a person hands that ask on. " + "Passing null unassigns the issue, and every ask on it then waits on the project's default " + "assignee: a question reaches the person it was handed to, else the issue's assignee, else " + "the project's default assignee, so every question reaches a person. " + "Set the assignee when a person said who owns the work, as you " + "file the issue or hand it over. before and after move the issue on " + "its project's board: before puts it above that issue, after below, and both together " + "land it between them. A project's board order is one agent's to keep; in a Legion " + "deployment that is the controller. Never reassign an issue a person holds to get a " + "faster answer: who holds it is their call. At least one " + `field besides issue is required. ${ISSUE_REFERENCE}`,
37330
+ description: "Update an existing issue: move its lifecycle status, retitle it, add labels to it or " + "replace its labels, set " + "its priority, set or clear its assignee, link a URL (the pull request that delivers it, a " + "run, a document), set its " + "route, set or clear its parent, replace the issues it is blocked by, replace the " + "priorities it advances, attach it to " + "architecture components, set the repository it targets, or move it on its project's " + "board. Status is one of " + `${ISSUE_STATUSES.join(", ")}; outside Legion, move it yourself as the work advances; inside ` + "Legion the daemon moves it. labels_add adds labels and keeps every label the issue holds; " + "labels replaces the whole set, so a label it does not name is removed, and the two never " + "go together. A non-empty external_links is " + "merged into the issue's existing links by URL, so linking the pull request you just opened " + "keeps every earlier link; an empty external_links removes every link instead. components " + "replaces the issue's own attachment. Closing an issue " + "(status done) requires reason, the note that says why: it is posted on the issue as a " + "message, then the issue closes, so the close carries its note; closing an issue that is " + "already closed is refused (ISSUE_CLOSED) before anything is posted. Reason goes only " + "with status done. Closing an issue withdraws every open ask " + "it holds (resolution kind withdrawn, naming the closer), and reopening it brings exactly " + "those asks back. " + "Dispatch puts the statuses in three groups: not started (triage, icebox, backlog), in work " + "(todo, in_progress, testing, needs_review, retro) and done. A parent is done only when each " + "child is done, and while a child is in work its parent is in work. Where Dispatch keeps " + "this rule, it refuses a status or parent change that breaks it with 409 " + "PARENT_STATUS_CONFLICT, which names each issue that holds it. include_children, " + "unlink_children and include_parent tell Dispatch what to do with those issues. Each goes " + "with status alone, and with reason when the status is done. include_children does not go " + "with done: only a person signed in at a browser closes the open issues under an issue " + "together with it, on the issue's page. " + "A closed issue still takes messages and comments, though not asks or artifacts; of this " + "tool's fields it takes only a board move " + "(before, after), components, " + "a reopening status (any status but done), and an external_links write that adds no new " + "link (so a link can move to the issue that replaced it); everything else, priority " + "included, waits for the reopen. " + "priority is yours to set and a human overrides it. assignee is the person who answers " + "this issue's asks, and every ask on it waits on them until a person hands that ask on. " + "Passing null unassigns the issue, and every ask on it then waits on the project's default " + "assignee: a question reaches the person it was handed to, else the issue's assignee, else " + "the project's default assignee, so every question reaches a person. " + "Set the assignee when a person said who owns the work, as you " + "file the issue or hand it over. before and after move the issue on " + "its project's board: before puts it above that issue, after below, and both together " + "land it between them. A project's board order is one agent's to keep; in a Legion " + "deployment that is the controller. Never reassign an issue a person holds to get a " + "faster answer: who holds it is their call. At least one " + `field besides issue is required. ${ISSUE_REFERENCE}`,
37262
37331
  arguments: (z) => ({
37263
37332
  issue: z.string().describe(ISSUE_REFERENCE),
37264
37333
  status: z.enum(ISSUE_STATUSES).describe("New lifecycle status.").optional(),
37265
37334
  reason: z.string().describe(`Required with status done, and only with it: why the issue is closing. Posted on the issue as a message before it closes. ${BODY_BLOCK_RULE}`).optional(),
37335
+ include_children: z.boolean().describe("With status, also write that status on each open issue under this issue, at any depth, whose status is in another group. Not with status done, which this tool refuses before anything is sent: only a person who is signed in at a browser can close the open issues under an issue together with it, on the issue's page in Dispatch (Close issue, then Move them with it).").optional(),
37336
+ unlink_children: z.boolean().describe("With status, also remove each open child from this issue, so that it has no parent. Each child keeps its status, and a done child stays.").optional(),
37337
+ include_parent: z.boolean().describe("With status, also move each issue above this issue that is not in work to in_progress, a done one included.").optional(),
37266
37338
  title: z.string({ min: 1, max: ISSUE_TITLE_MAX }).describe("Replacement title, at most 1,000 characters.").optional(),
37267
37339
  labels: z.array(z.string({ min: 1, max: ISSUE_LABEL_MAX }), { max: MAX_ISSUE_LABELS }).describe(`Replacement label set, at most ${MAX_ISSUE_LABELS} labels of up to ${ISSUE_LABEL_MAX} characters; replaces every existing label, so a label it does not name is removed. To add labels and keep the others, use labels_add. Not with labels_add.`).optional(),
37268
37340
  labels_add: z.array(z.string({ min: 1, max: ISSUE_LABEL_MAX }), { max: MAX_ISSUE_LABELS }).describe(`Labels to add, at most ${MAX_ISSUE_LABELS} of up to ${ISSUE_LABEL_MAX} characters: each is added to the labels the issue holds when the write lands, and every label it holds stays; the issue holds at most ${MAX_ISSUE_LABELS} in all. Not with labels.`).optional(),
@@ -37716,7 +37788,7 @@ var dispatchToolSpecs = [
37716
37788
  {
37717
37789
  name: "dispatch_issues",
37718
37790
  example: { project: "PROJ", limit: 250, offset: 250 },
37719
- description: "List a project's issues for a roadmap or backlog pass: every issue in one project, each carrying " + "its status, priority, parent, labels, open-ask count, progress (its spec's task-list items and " + "its direct children, each done of total, as `tasks 3/7 \xB7 children 2/5`, each only when it has " + "any), and route with whether it reaches anyone, " + "so you can see backlog shape without opening every issue. Optionally filter by status, parent, " + "label, priority, route status, or how recently it changed; priority takes one or more of 0-3 " + "(P0-P3) and null for an issue with no priority, so an owner's P0/P1 audit is priority [0, 1]. " + 'route_status "no_holder" lists every open issue whose route names a role nobody holds or a ' + "session that is not running, as of the server's copy of the listener's session list, at " + "most 5 s old, whatever its priority. A restarting " + "session is absent for minutes, so an issue is unowned only when a read ten minutes later agrees. " + "Do not use it to search by keyword or phrase; dispatch search remains the keyword surface. " + "Dispatch pages the list: limit sets the page size (default " + `${DEFAULT_ISSUE_PAGE_LIMIT}, max ${MAX_ISSUE_PAGE_LIMIT}) and offset selects where it starts ` + "(default 0), and the answer names how many issues match, so repeat with the next offset to " + "walk every matching issue. A walk is exact only while the list does not change: an issue " + "that enters or leaves what the filters match, or whose status or rank changes, between two " + "pages shifts rows across a page boundary, so one issue can come back twice and another never. " + "all takes the whole filtered list in one read instead, for a caller that must not miss or " + "repeat a row while other writers change the list, and especially for one whose own writes " + "move issues out of what it filtered on.",
37791
+ description: "List a project's issues for a roadmap or backlog pass: every issue in one project, each carrying " + "its status, priority, parent, labels, open-ask count, progress (its spec's task-list items and " + "its direct children, each done of total, as `tasks 3/7 \xB7 children 2/5`, each only when it has " + "any), and route with whether it reaches anyone, " + "so you can see backlog shape without opening every issue. Optionally filter by status, parent, " + "label, priority, route status, or how recently it changed; priority takes one or more of 0-3 " + "(P0-P3) and null for an issue with no priority, so an owner's P0/P1 audit is priority [0, 1]. " + 'route_status "no_holder" lists every open issue whose route names a role nobody holds or a ' + "session that is not running, as of the server's copy of the listener's session list, at " + "most 5 s old, whatever its priority. A restarting " + "session is absent for minutes, so an issue is unowned only when a read ten minutes later agrees. " + "Do not use it to search by keyword or phrase; dispatch search remains the keyword surface. " + "Dispatch pages the list: limit sets the page size (default " + `${DEFAULT_ISSUE_PAGE_LIMIT}, max ${MAX_ISSUE_PAGE_LIMIT}) and offset selects where it starts ` + "(default 0), and the answer names how many issues match, so repeat with the next offset to " + "walk every matching issue. A walk is exact only while the list does not change: an issue " + "that enters or leaves what the filters match, or whose status or rank changes, between two " + "pages shifts rows across a page boundary, so one issue can come back twice and another never. " + "all takes the whole filtered list in one read instead, for a caller that must not miss or " + "repeat a row while other writers change the list, and especially for one whose own writes " + "move issues out of what it filtered on. json prints the listing as one JSON object, for a " + "program such as jq to read.",
37720
37792
  arguments: (z) => ({
37721
37793
  project: z.string().describe("Project key to list issues from."),
37722
37794
  status: z.enum(ISSUE_STATUSES).describe("Optional lifecycle status filter.").optional(),
@@ -37727,7 +37799,8 @@ var dispatchToolSpecs = [
37727
37799
  route_status: z.enum(ISSUE_ROUTE_STATUSES).describe("Optional: only open issues whose route is in this state. live: a running session holds " + "the role or is the routed session. holder_unresponsive: that session has missed its " + "heartbeats without ending, so the route still reaches it and its messages wait. " + "no_holder: nobody running holds the role, or the session is gone, right now. " + "unknown: the Envoy listener did not answer.").optional(),
37728
37800
  limit: z.number({ int: true, min: 1, max: MAX_ISSUE_PAGE_LIMIT }).describe(`Maximum rows, 1-${MAX_ISSUE_PAGE_LIMIT}; default ${DEFAULT_ISSUE_PAGE_LIMIT}.`).optional(),
37729
37801
  offset: z.number({ int: true, min: 0 }).describe("Rows to skip before the page; nonnegative integer; default 0.").optional(),
37730
- all: z.boolean().describe("Take every matching issue in one unpaged read, so no row is missed or repeated while " + "the list changes. Refused with limit or offset.").optional()
37802
+ all: z.boolean().describe("Take every matching issue in one unpaged read, so no row is missed or repeated while " + "the list changes. Refused with limit or offset.").optional(),
37803
+ json: z.boolean().describe("Print the listing as one JSON object and nothing else: {issues, total, offset, limit}, " + "each issue with its status, parent and labels. The dispatch command prints it whole, " + "also on a host that cuts long output.").optional()
37731
37804
  })
37732
37805
  },
37733
37806
  {
@@ -45461,18 +45534,22 @@ var DISPATCH_URL_SETTING = "the configured Dispatch URL";
45461
45534
  class DispatchServiceError extends Error {
45462
45535
  code;
45463
45536
  status;
45537
+ name = "DispatchServiceError";
45538
+ fromDispatch = true;
45464
45539
  candidates;
45465
45540
  current;
45466
45541
  mismatches;
45467
- name = "DispatchServiceError";
45468
- fromDispatch = true;
45469
- constructor(code, status, message, candidates, current, mismatches) {
45542
+ issues;
45543
+ changed;
45544
+ constructor(code, status, message, details = {}) {
45470
45545
  super(message);
45471
45546
  this.code = code;
45472
45547
  this.status = status;
45473
- this.candidates = candidates;
45474
- this.current = current;
45475
- this.mismatches = mismatches;
45548
+ this.candidates = details.candidates;
45549
+ this.current = details.current;
45550
+ this.mismatches = details.mismatches;
45551
+ this.issues = details.issues;
45552
+ this.changed = details.changed;
45476
45553
  }
45477
45554
  }
45478
45555
 
@@ -45573,6 +45650,9 @@ function reviewNoRouteRefusal(baseUrl, route, version) {
45573
45650
  function resultDryRunNoRouteRefusal(baseUrl, route) {
45574
45651
  return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${urlForText(baseUrl, DISPATCH_URL_SETTING)} answered no route for ${route} each ` + "time the dry run was sent: this build is older than a result's dry run, so it cannot show " + "the pull-request body line before the record. Nothing was recorded.");
45575
45652
  }
45653
+ function statusChangeNoRouteRefusal(baseUrl, route) {
45654
+ return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${urlForText(baseUrl, DISPATCH_URL_SETTING)} answered no route for ${route} each ` + "time the status change was sent. This build is older than that route, so it takes no " + "include_children, unlink_children or include_parent, and nothing changed. No PATCH was " + "sent in its place, since a PATCH would write the status without the option.");
45655
+ }
45576
45656
  var ISSUE_EVENTS_PAGE_MAX = 200;
45577
45657
  var DISPATCH_TOOL_DEADLINE_MS = 60000;
45578
45658
  function requestSignal(signal, deadlineMs) {
@@ -45891,6 +45971,14 @@ class DispatchClient {
45891
45971
  async updateIssue(issue, input) {
45892
45972
  return this.#json("PATCH", ["api", "v1", "issues", await this.#resolveIssue(issue)], input);
45893
45973
  }
45974
+ async changeIssueStatus(issue, input) {
45975
+ const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "status-change"];
45976
+ try {
45977
+ return await this.#json("POST", path, input);
45978
+ } catch (error) {
45979
+ throw this.#refusalOfNoRoute(error, path, (route) => statusChangeNoRouteRefusal(this.#baseUrl, route));
45980
+ }
45981
+ }
45894
45982
  async claimIssue(issue, input = {}) {
45895
45983
  return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "claim"], input);
45896
45984
  }
@@ -46045,10 +46133,7 @@ class DispatchClient {
46045
46133
  try {
46046
46134
  return await this.#json("POST", path, body);
46047
46135
  } catch (error) {
46048
- if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
46049
- throw error;
46050
- const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
46051
- throw reviewNoRouteRefusal(this.#baseUrl, route, version);
46136
+ throw this.#refusalOfNoRoute(error, path, (route) => reviewNoRouteRefusal(this.#baseUrl, route, version));
46052
46137
  }
46053
46138
  }
46054
46139
  async recordResult(issue, input) {
@@ -46059,10 +46144,7 @@ class DispatchClient {
46059
46144
  try {
46060
46145
  return await this.#writingNothing(path, input, { writes: false });
46061
46146
  } catch (error) {
46062
- if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
46063
- throw error;
46064
- const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
46065
- throw resultDryRunNoRouteRefusal(this.#baseUrl, route);
46147
+ throw this.#refusalOfNoRoute(error, path, (route) => resultDryRunNoRouteRefusal(this.#baseUrl, route));
46066
46148
  }
46067
46149
  }
46068
46150
  async issueResults(issue, at) {
@@ -46307,6 +46389,11 @@ class DispatchClient {
46307
46389
  sleep: this.#sleep
46308
46390
  });
46309
46391
  }
46392
+ #refusalOfNoRoute(error, path, refuse) {
46393
+ if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
46394
+ return error;
46395
+ return refuse(`POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`);
46396
+ }
46310
46397
  #writeCall(method, url, key, writes = true) {
46311
46398
  if (method !== "POST" && method !== "PATCH")
46312
46399
  return;
@@ -46640,7 +46727,7 @@ class DispatchClient {
46640
46727
  if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
46641
46728
  throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
46642
46729
  }
46643
- throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error.candidates, error.current, error.mismatches);
46730
+ throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
46644
46731
  }
46645
46732
  throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
46646
46733
  }
@@ -51391,6 +51478,7 @@ var pictureSendingTools = {
51391
51478
  };
51392
51479
  var refGrammarProblem = "ref must be a valid dispatch:// reference such as dispatch://KEY-1, " + "dispatch://KEY-1/ask/<uuid>, dispatch://KEY-1/comment/<uuid>, " + "dispatch://KEY-1/message/<uuid>, dispatch://KEY-1/artifact/<slug>, " + "dispatch://PROJECT/artifact/<document-ref> (an artifact id, slug, or filename), " + "dispatch://KEY-1/spec#b-<block id>, dispatch://KEY-1/artifact/<slug>#b-<block id> or " + "dispatch://PROJECT/artifact/<slug>#b-<block id> (one block of a document, its id " + "percent-encoded, optionally pinned to a version of the document with @v<N> after it; for " + "dispatch read), dispatch://KEY-1/ask/<uuid>#b-<part id> or " + "dispatch://PROJECT/artifact/<slug>/ask/<uuid>#b-<part id> (one part of an ask: its question, " + "one of its options or its answer, optionally pinned to a revision of the ask's parts with " + "@v<N> after it; for dispatch read), dispatch://KEY-1/comment/<uuid>#b-<block id>, " + "dispatch://PROJECT/artifact/<slug>/comment/<uuid>#b-<block id> or " + "dispatch://KEY-1/message/<uuid>#b-<block id> (one block of a comment or message, a " + "comment's optionally pinned to a revision of the comment with @v<N> after it; for dispatch " + "read), or " + "dispatch://agent/<session id>/artifact/<slug> (a picture in a conversation on the Agents page, " + "for dispatch doc-read); a dashboard URL on this Dispatch server is accepted too";
51393
51480
  var ownerRequiredProblem = "issue is required; supply issue or set LEGION_ISSUE";
51481
+ var ownerStandInIssue = "OWNER-1";
51394
51482
  function argumentProblems(tool, args) {
51395
51483
  const problems = [];
51396
51484
  switch (tool) {
@@ -51676,7 +51764,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
51676
51764
  const legionIssue = env.LEGION_ISSUE;
51677
51765
  if (!legionIssue) {
51678
51766
  problems.push(ownerRequiredProblem);
51679
- return { args, ref, owner: null };
51767
+ return { args, ref, owner: null, ownerMissing: true };
51680
51768
  }
51681
51769
  if (nativeIssueKeyPattern.test(legionIssue) || externalIssueRefPattern.test(legionIssue)) {
51682
51770
  const issue = canonicalExternalIssueRef(legionIssue);
@@ -51684,18 +51772,24 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
51684
51772
  }
51685
51773
  if (!bareIssueNumberPattern.test(legionIssue)) {
51686
51774
  problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
51687
- return { args, ref, owner: null };
51775
+ return { args, ref, owner: null, ownerMissing: true };
51688
51776
  }
51689
51777
  const repo = await resolveCwdRepo(cwd, exec);
51690
51778
  if (!repo) {
51691
51779
  problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
51692
- return { args, ref, owner: null };
51780
+ return { args, ref, owner: null, ownerMissing: true };
51693
51781
  }
51694
51782
  const issue = `${repo}#${legionIssue}`;
51695
51783
  return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
51696
51784
  }
51697
- function restatesMissingOwner(issue) {
51698
- return issue.code === "invalid_type" && issue.path.length === 1 && issue.path[0] === "issue" && issue.input === undefined || issue.code === "custom" && issue.path.length === 0 && (issue.message.startsWith("Exactly one of issue and project is required") || issue.message.startsWith("issue is required unless in_reply_to"));
51785
+ function withoutMissingOwner(issue) {
51786
+ if (issue.code === "invalid_type" && issue.path.length === 1 && issue.path[0] === "issue" && issue.input === undefined) {
51787
+ return;
51788
+ }
51789
+ if (issue.code !== "custom" || issue.path.length !== 0)
51790
+ return issue;
51791
+ const message = withoutOwnerRule(issue.message);
51792
+ return message === undefined ? undefined : message === issue.message ? issue : { ...issue, message };
51699
51793
  }
51700
51794
  function dispatchServerUrls(config) {
51701
51795
  return config.publicUrl === undefined ? [config.url] : [config.url, config.publicUrl];
@@ -51706,11 +51800,12 @@ async function checkDispatchCall(input) {
51706
51800
  const owner = await resolveOwnerArguments(tool, args, cwd, input.env ?? process.env, input.exec ?? defaultExec, input.serverUrls, problems);
51707
51801
  const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
51708
51802
  problems.push(...conflicts);
51709
- const ownerMissing = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
51803
+ const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
51710
51804
  const schema = toolSchema(tool);
51711
- const parsed = schema.safeParse(owner.args, { reportInput: true });
51805
+ const standIn = owner.ownerMissing === true;
51806
+ const parsed = schema.safeParse(standIn ? { ...owner.args, issue: ownerStandInIssue } : owner.args, { reportInput: true });
51712
51807
  if (!parsed.success) {
51713
- const issues = ownerMissing ? parsed.error.issues.filter((issue) => !restatesMissingOwner(issue)) : parsed.error.issues;
51808
+ const issues = standIn ? parsed.error.issues : ownerAlreadySaid ? parsed.error.issues.flatMap((issue) => withoutMissingOwner(issue) ?? []) : parsed.error.issues;
51714
51809
  problems.push(...formatZodIssues(issues, schema, tool));
51715
51810
  }
51716
51811
  problems.push(...argumentProblems(tool, owner.args));
@@ -51718,7 +51813,7 @@ async function checkDispatchCall(input) {
51718
51813
  return {
51719
51814
  problems,
51720
51815
  owner,
51721
- args: parsed.success ? parsed.data : owner.args,
51816
+ args: parsed.success && !standIn ? parsed.data : owner.args,
51722
51817
  pictures
51723
51818
  };
51724
51819
  }
@@ -51736,7 +51831,75 @@ function refusalWithCode(error, ...clauses) {
51736
51831
  }
51737
51832
  if (!(error instanceof DispatchServiceError))
51738
51833
  return error;
51739
- return new DispatchServiceError(error.code, error.status, `${error.code}: ${error.message}${joined}`, error.candidates, error.current, error.mismatches);
51834
+ const told = joined !== "" && /[.!?]$/.test(error.message) ? `${error.message} ${suffix.charAt(0).toUpperCase()}${suffix.slice(1)}` : `${error.message}${joined}`;
51835
+ return new DispatchServiceError(error.code, error.status, `${error.code}: ${told}`, error);
51836
+ }
51837
+ function parentStatusConflictLines(error, tool, args, legionIssue) {
51838
+ if (!dispatchAnswered(error, 409) || error.code !== "PARENT_STATUS_CONFLICT")
51839
+ return;
51840
+ const issues = error.issues ?? [];
51841
+ if (issues.length === 0)
51842
+ return;
51843
+ const parents = issues.filter((issue) => issue.relation === "parent").map(({ key }) => key);
51844
+ const children = issues.filter((issue) => issue.relation === "child").map(({ key }) => key);
51845
+ return [
51846
+ messageFor(error),
51847
+ ...issues.map((issue) => `${issue.key} [${issue.status}] ${issue.title}`),
51848
+ ...nextSteps(tool, args, parents, children, legionIssue)
51849
+ ];
51850
+ }
51851
+ var CHILD_FLAGS = "dispatch issue-update --status takes --unlink-children, which removes its open children from it, or, with a status other than done, --include-children, which moves the open issues under the issue with it. A person signed in at a browser closes them with it on the issue's page.";
51852
+ var PARENT_FLAG = "dispatch issue-update --status takes --include-parent, which moves each issue above the issue that is not in work to in_progress.";
51853
+ function otherProjectSentence(named, keys) {
51854
+ const project = named === undefined ? undefined : issueProject(named);
51855
+ if (project === undefined)
51856
+ return "";
51857
+ const others = keys.filter((key) => {
51858
+ const other = issueProject(key);
51859
+ return other !== undefined && other !== project;
51860
+ });
51861
+ if (others.length === 0)
51862
+ return "";
51863
+ const one = others.length === 1;
51864
+ return ` ${others.join(", ")} ${one ? "is" : "are"} not in the project of ${named}. A credential scoped to one project is refused a step that writes ${one ? "it" : "them"} (403 PROJECT_SCOPE), so a person, or a credential that names no project, must make that step.`;
51865
+ }
51866
+ function includeParentCall(key) {
51867
+ return `${commandLine("dispatch_issue_update", { issue: key, status: "in_progress", include_parent: true })}, which also moves each issue above ${key} that is not in work`;
51868
+ }
51869
+ function nextSteps(tool, args, parents, children, legionIssue) {
51870
+ if (tool === "dispatch_issue") {
51871
+ return parents.map((key) => `dispatch issue takes no flag that moves a done parent. Reopen ${key} first, with ${includeParentCall(key)}, then run dispatch issue again; or run it with --parent naming an open issue, or with no --parent.`);
51872
+ }
51873
+ const issueUpdate = tool === "dispatch_issue_update";
51874
+ const written = issueUpdate ? args : {};
51875
+ const fields = Object.keys(written).filter((field) => field !== "issue" && written[field] !== undefined);
51876
+ const issue = optionalString(written, "issue");
51877
+ const named = issueUpdate ? issue ?? legionIssue : undefined;
51878
+ const childHolds = children.length > 0;
51879
+ const childScope = otherProjectSentence(named, children);
51880
+ const status = optionalString(written, "status");
51881
+ const parent = optionalString(written, "parent");
51882
+ const alone = `--status${status === "done" ? " and --reason" : ""} alone`;
51883
+ if (parent !== undefined && parent !== "") {
51884
+ const issueFlag = issue === undefined ? "" : ` --issue ${issue}`;
51885
+ const statusFlag = status === undefined || childHolds ? "" : ` --status ${status}`;
51886
+ const kept = fields.filter((field) => field !== "parent" && field !== "status" && !(childHolds && field === "reason"));
51887
+ const otherFlags = kept.length > 0 ? ", with the call's other flags" : "";
51888
+ const reparent = `dispatch issue-update${issueFlag} --parent ${parent}${statusFlag}${otherFlags}`;
51889
+ const afterStatus = childHolds ? ", after the status change," : "";
51890
+ return [
51891
+ ...childHolds ? [
51892
+ `${CHILD_FLAGS} Each goes with ${alone}, so run the status change first, in a call of its own, and the reparent after it: ${reparent}.${childScope}`
51893
+ ] : [],
51894
+ ...parents.map((key) => `dispatch issue-update takes no flag that moves the parent a reparent names. Move ${key} into work first, with ${includeParentCall(key)}; then${afterStatus} run the reparent again: ${reparent}.`)
51895
+ ];
51896
+ }
51897
+ const others = ISSUE_UPDATE_PATCH_FIELDS.some((field) => written[field] !== undefined);
51898
+ const apart = (subject) => others ? ` ${subject} with ${alone}, so send the call's other changes in a call of their own.` : "";
51899
+ return [
51900
+ ...childHolds ? [`${CHILD_FLAGS}${apart("Each goes")}${childScope}`] : [],
51901
+ ...parents.length > 0 ? [`${PARENT_FLAG}${apart("It goes")}${otherProjectSentence(named, parents)}`] : []
51902
+ ];
51740
51903
  }
51741
51904
  function dispatchAnswered(error, status) {
51742
51905
  return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
@@ -51761,6 +51924,11 @@ function writeMayHaveLanded(error) {
51761
51924
  return error.mayHaveReachedDispatch;
51762
51925
  return !(error instanceof DispatchServiceError) || error.status >= 500;
51763
51926
  }
51927
+ function closeAccount(error, closingNote) {
51928
+ const posted = `the reason already landed as message ${closingNote.id} (${closingNote.ref})`;
51929
+ const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
51930
+ return writeMayHaveLanded(error) ? `${posted}, and the close may or may not have taken effect. Read the issue's status before retrying: done means it closed; otherwise retry with a reason that points at message ${closingNote.id}, since retrying this call posts its reason again` : `${posted} but the issue did not close. Retrying this call posts its reason again, so ${fix}retry with a reason that points at message ${closingNote.id}`;
51931
+ }
51764
51932
  function withAccount(error, account) {
51765
51933
  const message = messageFor(error);
51766
51934
  const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
@@ -53114,6 +53282,85 @@ async function followedAskDetails(client, ask, artifact) {
53114
53282
  return { ...await askOwnerDetails(client, ask, artifact), follows: { ask: ask.id } };
53115
53283
  }
53116
53284
 
53285
+ // ../envoy-client/src/dispatch-commands/status-change.ts
53286
+ async function issuesBeforeStatusChange(client, before, options) {
53287
+ const issues = new Map([
53288
+ [before.key, { status: before.status, parent: before.parent ?? null }]
53289
+ ]);
53290
+ for (const child of before.children ?? []) {
53291
+ issues.set(child.key, { status: child.status, parent: before.key });
53292
+ }
53293
+ try {
53294
+ if (options.includes("include_children")) {
53295
+ for (const row of await client.listAllIssues({ project: before.project })) {
53296
+ issues.set(row.key, { status: row.status, parent: row.parent ?? null });
53297
+ }
53298
+ } else if (options.includes("include_parent")) {
53299
+ let parent = before.parent ?? null;
53300
+ while (parent !== null && !issues.has(parent)) {
53301
+ const above = await client.getIssue(parent);
53302
+ issues.set(above.key, { status: above.status, parent: above.parent ?? null });
53303
+ parent = above.parent ?? null;
53304
+ }
53305
+ }
53306
+ } catch (error) {
53307
+ throw refusalWithCode(error);
53308
+ }
53309
+ return issues;
53310
+ }
53311
+ async function statusChangeCommand(context, before, options, issuesBefore, closingNote) {
53312
+ const { args, client, actor, input, issue } = context;
53313
+ const status = stringArg(args, "status");
53314
+ const change = (entry) => {
53315
+ const was = issuesBefore.get(entry.key);
53316
+ if (entry.key !== before.key && entry.parent === null && was?.parent === before.key) {
53317
+ return `unlinked from ${before.key}`;
53318
+ }
53319
+ return was === undefined ? `status -> ${entry.status}` : `status ${was.status} -> ${entry.status}`;
53320
+ };
53321
+ let answer;
53322
+ try {
53323
+ answer = await client.changeIssueStatus(issue(), {
53324
+ status,
53325
+ ...options.includes("include_children") ? { include_children: true } : {},
53326
+ ...options.includes("unlink_children") ? { unlink_children: true } : {},
53327
+ ...options.includes("include_parent") ? { include_parent: true } : {},
53328
+ actor
53329
+ });
53330
+ } catch (error) {
53331
+ if (error instanceof DispatchWriteLandedError)
53332
+ throw error;
53333
+ const committed = error instanceof DispatchServiceError ? error.changed ?? [] : [];
53334
+ const changed = committed.length === 0 ? "" : `the steps before the refusal changed ${committed.map((entry) => `${entry.key} (${change(entry)})`).join(", ")}`;
53335
+ if (closingNote === undefined)
53336
+ throw refusalWithCode(error, changed);
53337
+ const landed = closeAccount(error, closingNote);
53338
+ if (error instanceof DispatchServiceError)
53339
+ throw refusalWithCode(error, changed, landed);
53340
+ throw withAccount(error, landed);
53341
+ }
53342
+ const suffix = await notSubscribed(issueTopic(before.key), input.subscriptions);
53343
+ const namedLine = (after) => `${before.key}: ${[
53344
+ ...closingNote === undefined ? [] : [`reason posted as message ${closingNote.id} (${closingNote.ref})`],
53345
+ `status ${before.status} -> ${after}`
53346
+ ].join("; ")}${suffix}`;
53347
+ const changed = answer.changed ?? [];
53348
+ const lines = changed.map((entry) => entry.key === before.key ? namedLine(entry.status) : `${entry.key}: ${change(entry)}`);
53349
+ if (!changed.some((entry) => entry.key === before.key))
53350
+ lines.push(namedLine(answer.issue.status));
53351
+ return {
53352
+ text: lines.join(`
53353
+ `),
53354
+ details: {
53355
+ issue: before.key,
53356
+ status: answer.issue.status,
53357
+ external_links: (answer.issue.external_links ?? []).map((link) => link.url),
53358
+ changed: changed.map(({ key, status, parent }) => ({ key, status, parent })),
53359
+ ...closingNote === undefined ? {} : { message: closingNote.id }
53360
+ }
53361
+ };
53362
+ }
53363
+
53117
53364
  // ../envoy-client/src/dispatch-commands/issues.ts
53118
53365
  function componentsChange(input, after) {
53119
53366
  switch (input.mode) {
@@ -53265,6 +53512,7 @@ async function issueUpdateCommand(context) {
53265
53512
  const advances = optionalStringArray(args, "advances");
53266
53513
  const advancesRevision = optionalNumber(args, "advances_revision");
53267
53514
  const requestedLinks = Array.isArray(args.external_links) ? [...new Set(args.external_links)] : undefined;
53515
+ const options = issueStatusOptionsOf(args);
53268
53516
  let before;
53269
53517
  try {
53270
53518
  before = await client.getIssue(issueKey);
@@ -53275,6 +53523,7 @@ async function issueUpdateCommand(context) {
53275
53523
  if (status === "done" && typeof before.closed_at === "string") {
53276
53524
  throw refusalWithCode(new DispatchServiceError("ISSUE_CLOSED", 409, "issue is closed"), `${issueKey} closed at ${before.closed_at}, so the reason was not posted and the close was not sent`);
53277
53525
  }
53526
+ const issuesBefore = options.length === 0 ? undefined : await issuesBeforeStatusChange(client, before, options);
53278
53527
  let closingNote;
53279
53528
  if (reason !== undefined) {
53280
53529
  try {
@@ -53293,6 +53542,9 @@ async function issueUpdateCommand(context) {
53293
53542
  throw withAccount(error, told);
53294
53543
  }
53295
53544
  }
53545
+ if (issuesBefore !== undefined) {
53546
+ return statusChangeCommand(context, before, options, issuesBefore, closingNote);
53547
+ }
53296
53548
  const existingLinks = before.external_links ?? [];
53297
53549
  const linked = existingLinks.map((link) => link.url);
53298
53550
  const newLinks = requestedLinks?.filter((url) => !linked.includes(url)) ?? [];
@@ -53331,9 +53583,7 @@ async function issueUpdateCommand(context) {
53331
53583
  }
53332
53584
  throw refusalWithCode(error, taken);
53333
53585
  }
53334
- const posted = `the reason already landed as message ${closingNote.id} (${closingNote.ref})`;
53335
- const fix = error instanceof DispatchGatewayError && error.transient ? "" : "fix what refused the close, then ";
53336
- const landed = writeMayHaveLanded(error) ? `${posted}, and the close may or may not have taken effect. Read the issue's status before retrying: done means it closed; otherwise retry with a reason that points at message ${closingNote.id}, since retrying this call posts its reason again` : `${posted} but the issue did not close. Retrying this call posts its reason again, so ${fix}retry with a reason that points at message ${closingNote.id}`;
53586
+ const landed = closeAccount(error, closingNote);
53337
53587
  if (error instanceof DispatchServiceError)
53338
53588
  throw refusalWithCode(error, taken, landed);
53339
53589
  throw withAccount(error, [taken, landed].filter((clause) => clause !== "").join("; "));
@@ -53455,8 +53705,11 @@ async function relatedCommand(context) {
53455
53705
  details: { project, suggestions }
53456
53706
  };
53457
53707
  }
53708
+ function printsJson(tool, args) {
53709
+ return tool === "dispatch_issues" && args["json"] === true;
53710
+ }
53458
53711
  async function issuesCommand(context) {
53459
- const { args, client } = context;
53712
+ const { args, client, input } = context;
53460
53713
  const project = stringArg(args, "project");
53461
53714
  const status = optionalString(args, "status");
53462
53715
  const parent = optionalString(args, "parent");
@@ -53499,6 +53752,10 @@ async function issuesCommand(context) {
53499
53752
  updated_at: row.updated_at,
53500
53753
  progress: row.progress
53501
53754
  }));
53755
+ const listing = { issues: rows, total, offset, limit };
53756
+ if (printsJson(input.tool, args)) {
53757
+ return { text: JSON.stringify(listing), details: listing };
53758
+ }
53502
53759
  const agents = await liveAgents(client, rows.some((row) => holdsSession(row.claim)));
53503
53760
  const isPartial = offset !== 0 || rows.length !== total;
53504
53761
  const showing = !isPartial ? "" : rows.length === 0 ? `showing 0-0 of ${total}` : pageSummaryText(offset, rows.length, total);
@@ -53511,7 +53768,7 @@ async function issuesCommand(context) {
53511
53768
  })
53512
53769
  ].join(`
53513
53770
  `),
53514
- details: { issues: rows, total, offset, limit }
53771
+ details: listing
53515
53772
  };
53516
53773
  }
53517
53774
  function dryRunAsksDispatch(tool, args) {
@@ -62829,9 +63086,9 @@ var import_nats5 = __toESM(require_mod4(), 1);
62829
63086
 
62830
63087
  // package.json
62831
63088
  var name2 = "@sjawhar/claude-envoy";
62832
- var version2 = "5.23.6";
63089
+ var version2 = "5.24.0";
62833
63090
  var legion = {
62834
- daemonApiVersion: 250
63091
+ daemonApiVersion: 256
62835
63092
  };
62836
63093
  var package_default = {
62837
63094
  name: name2,
@@ -64460,7 +64717,9 @@ var legionClaimView = object({
64460
64717
  lastTurnStart: timestamp.optional(),
64461
64718
  lastTurnEnd: timestamp.optional(),
64462
64719
  lastDeathCause: nonEmptyString2.optional(),
64720
+ lastDeathAt: timestamp.optional(),
64463
64721
  lastStartFailure: nonEmptyString2.optional(),
64722
+ lastStartFailureAt: timestamp.optional(),
64464
64723
  lastReady: timestamp.optional(),
64465
64724
  step: legionStepView.optional(),
64466
64725
  wake: object(legionPacedWake).optional(),
@@ -65040,7 +65299,9 @@ var LegionOperatorClaimResponse = object({
65040
65299
  lastTurnStart: timestamp.optional(),
65041
65300
  lastTurnEnd: timestamp.optional(),
65042
65301
  lastDeathCause: nonEmptyString2.optional(),
65302
+ lastDeathAt: timestamp.optional(),
65043
65303
  lastStartFailure: nonEmptyString2.optional(),
65304
+ lastStartFailureAt: timestamp.optional(),
65044
65305
  lastReady: timestamp.optional(),
65045
65306
  step: legionStepView.optional(),
65046
65307
  failure: legionClaimFailureView.optional(),