@sjawhar/claude-envoy 6.30.1 → 6.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "6.30.1"
5
+ "version": "6.31.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "6.30.1",
3
+ "version": "6.31.1",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -15413,7 +15413,7 @@ var dispatchToolSpecs = [
15413
15413
  {
15414
15414
  name: "dispatch_steps",
15415
15415
  example: { issue: "DSP-1" },
15416
- description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on and that has no plan prints " + "0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch read fails for it, " + `NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
15416
+ description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered last, as provider/model. result is passed, failed or stopped. After the result " + "each line prints set and the model the role was set to, or - for none. Then it prints " + "answered and each model with its calls and its share of the step's calls in whole " + "percent, as anthropic/claude-opus-5-5=41(93%). It prints running for a run not yet " + "ended, unknown where Legion does not know the counts, and none for a step with no call. " + "A field with no value prints -, and a run that has not ended prints running for its end " + "and its result. A closed issue's steps read too. An issue that no step ran on and that " + "has no plan prints 0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch " + `read fails for it, NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
15417
15417
  arguments: (z) => ({
15418
15418
  issue: z.string().describe(ISSUE_REFERENCE)
15419
15419
  }),
@@ -15422,7 +15422,7 @@ var dispatchToolSpecs = [
15422
15422
  {
15423
15423
  name: "dispatch_plans",
15424
15424
  example: { project: "INFRA" },
15425
- description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at failed steps <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. An issue with no plan prints plan " + "none, one with no rating prints ratings none, and one whose time is not known prints " + "time -: an issue Legion never ran prints all three. since and until, each an RFC 3339 " + "time, keep the issues closed at or after since and before until.",
15425
+ description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n> on set model <n> off <n> unknown <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at unknown <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. on set model counts the issue's step " + "records that name an agent and a set model, know their counts and name no other model. " + "off counts the records with an agent that name a set model, know their counts and name " + "another model. unknown counts every other step record that names an agent. Each of the " + "three prints - where the Dispatch server is older than these counts. An issue with no " + "plan prints plan none, one with no rating prints ratings none, and one whose time is not " + "known prints time -: an issue Legion never ran prints all three. since and until, each an " + "RFC 3339 time, keep the issues closed at or after since and before until.",
15426
15426
  arguments: (z) => ({
15427
15427
  project: z.string().describe("Project key whose finished issues to list, such as INFRA."),
15428
15428
  since: z.string().describe("Optional RFC 3339 time; only issues closed at or after it.").optional(),
@@ -19784,6 +19784,22 @@ function canonicalRepo(owner, repo) {
19784
19784
  }
19785
19785
  // ../contracts/src/slack.ts
19786
19786
  var SLACK_POST_TEXT_MAX = 4000;
19787
+ // ../contracts/src/step-answers.ts
19788
+ function setModelText(record) {
19789
+ const setModel = record.set_model ?? "";
19790
+ return setModel === "" ? null : setModel;
19791
+ }
19792
+ function answeredText(record) {
19793
+ if (record.ended_at === null)
19794
+ return "running";
19795
+ const answers = record.answers ?? null;
19796
+ if (answers === null)
19797
+ return "unknown";
19798
+ if (answers.length === 0)
19799
+ return "none";
19800
+ const calls = answers.reduce((sum, answer) => sum + answer.calls, 0);
19801
+ return answers.map((answer) => `${answer.model}=${answer.calls}(${Math.round(100 * answer.calls / calls)}%)`).join(",");
19802
+ }
19787
19803
  // ../contracts/src/subject-project.ts
19788
19804
  var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
19789
19805
  var KEPT_PREFIX = "notifications.envoy.kept.";
@@ -29320,7 +29336,7 @@ function renderAdvice(tool, key, advice, opts) {
29320
29336
  const issueAdvice = "issue_status" in advice ? advice : undefined;
29321
29337
  const hasIssueAdvice = issueAdvice !== undefined;
29322
29338
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
29323
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
29339
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
29324
29340
  const lines = [];
29325
29341
  const unparsed = advice.unparsed_openers;
29326
29342
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -29375,12 +29391,45 @@ function renderAdvice(tool, key, advice, opts) {
29375
29391
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
29376
29392
  lines.push(parts.join(" "));
29377
29393
  }
29378
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
29379
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
29380
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
29394
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
29395
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
29396
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
29381
29397
  }
29382
29398
  return lines;
29383
29399
  }
29400
+ function cadenceCount(tool, issueAdvice, isAskReply) {
29401
+ const count = issueAdvice?.session_writes_since_human;
29402
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
29403
+ return posts && count !== undefined && count >= 3 ? count : undefined;
29404
+ }
29405
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
29406
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
29407
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
29408
+ return false;
29409
+ const answered = issueAdvice?.legion_managed_status;
29410
+ if (answered !== undefined)
29411
+ return answered;
29412
+ try {
29413
+ return await legionLabelOnChain(client, issueKey);
29414
+ } catch {
29415
+ return false;
29416
+ }
29417
+ }
29418
+ async function legionLabelOnChain(client, key) {
29419
+ let issue = await client.getIssue(key);
29420
+ const project = issue.project;
29421
+ const read = new Set;
29422
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
29423
+ read.add(issue.key);
29424
+ const parent = issue.parent ?? null;
29425
+ if (parent === null || read.has(parent))
29426
+ return false;
29427
+ issue = await client.getIssue(parent);
29428
+ if (issue.project !== project)
29429
+ return false;
29430
+ }
29431
+ return true;
29432
+ }
29384
29433
  async function otherAdviceLines(render) {
29385
29434
  try {
29386
29435
  return await render();
@@ -31990,7 +32039,9 @@ async function askCommand(context) {
31990
32039
  });
31991
32040
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
31992
32041
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
31993
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
32042
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
32043
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
32044
+ }));
31994
32045
  const asked = waitsOnPerson(ask);
31995
32046
  return {
31996
32047
  text: [
@@ -32199,9 +32250,11 @@ async function commentCommand(context) {
32199
32250
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
32200
32251
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
32201
32252
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
32253
+ const isAskReply = replyToAsk !== undefined;
32202
32254
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
32203
- isAskReply: replyToAsk !== undefined,
32204
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
32255
+ isAskReply,
32256
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
32257
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
32205
32258
  });
32206
32259
  if (replyToAsk !== undefined) {
32207
32260
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -32305,7 +32358,9 @@ async function messageCommand(context) {
32305
32358
  actor
32306
32359
  });
32307
32360
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
32308
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
32361
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
32362
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
32363
+ });
32309
32364
  return {
32310
32365
  text: [
32311
32366
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -33671,6 +33726,11 @@ function timeText(seconds) {
33671
33726
  const minutes = Math.floor(seconds / 60);
33672
33727
  return `time ${Math.floor(minutes / 60)}h${minutes % 60}m`;
33673
33728
  }
33729
+ function setModelStepsText(counts) {
33730
+ if (counts === undefined)
33731
+ return "on set model - off - unknown -";
33732
+ return `on set model ${counts.on} off ${counts.off} unknown ${counts.unknown}`;
33733
+ }
33674
33734
  function issueLine(issue) {
33675
33735
  return [
33676
33736
  issue.issue,
@@ -33681,6 +33741,7 @@ function issueLine(issue) {
33681
33741
  timeText(issue.duration_seconds),
33682
33742
  "failed steps",
33683
33743
  issue.failed_steps,
33744
+ setModelStepsText(issue.set_model_steps),
33684
33745
  ...issue.experiment == null || issue.variant == null ? [] : [`variant ${issue.experiment}/${issue.variant}`]
33685
33746
  ].join(" ");
33686
33747
  }
@@ -34825,7 +34886,11 @@ function stepLine(record) {
34825
34886
  orDash(record.agent),
34826
34887
  orDash(record.model),
34827
34888
  orDash(record.started_at),
34828
- ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
34889
+ ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)],
34890
+ "set",
34891
+ orDash(setModelText(record)),
34892
+ "answered",
34893
+ answeredText(record)
34829
34894
  ].join(" ");
34830
34895
  }
34831
34896
  function taskLine(task, needs, planned) {
package/dist/dispatch.js CHANGED
@@ -16013,7 +16013,7 @@ var dispatchToolSpecs = [
16013
16013
  {
16014
16014
  name: "dispatch_steps",
16015
16015
  example: { issue: "DSP-1" },
16016
- description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on and that has no plan prints " + "0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch read fails for it, " + `NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
16016
+ description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered last, as provider/model. result is passed, failed or stopped. After the result " + "each line prints set and the model the role was set to, or - for none. Then it prints " + "answered and each model with its calls and its share of the step's calls in whole " + "percent, as anthropic/claude-opus-5-5=41(93%). It prints running for a run not yet " + "ended, unknown where Legion does not know the counts, and none for a step with no call. " + "A field with no value prints -, and a run that has not ended prints running for its end " + "and its result. A closed issue's steps read too. An issue that no step ran on and that " + "has no plan prints 0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch " + `read fails for it, NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
16017
16017
  arguments: (z) => ({
16018
16018
  issue: z.string().describe(ISSUE_REFERENCE)
16019
16019
  }),
@@ -16022,7 +16022,7 @@ var dispatchToolSpecs = [
16022
16022
  {
16023
16023
  name: "dispatch_plans",
16024
16024
  example: { project: "INFRA" },
16025
- description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at failed steps <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. An issue with no plan prints plan " + "none, one with no rating prints ratings none, and one whose time is not known prints " + "time -: an issue Legion never ran prints all three. since and until, each an RFC 3339 " + "time, keep the issues closed at or after since and before until.",
16025
+ description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n> on set model <n> off <n> unknown <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at unknown <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. on set model counts the issue's step " + "records that name an agent and a set model, know their counts and name no other model. " + "off counts the records with an agent that name a set model, know their counts and name " + "another model. unknown counts every other step record that names an agent. Each of the " + "three prints - where the Dispatch server is older than these counts. An issue with no " + "plan prints plan none, one with no rating prints ratings none, and one whose time is not " + "known prints time -: an issue Legion never ran prints all three. since and until, each an " + "RFC 3339 time, keep the issues closed at or after since and before until.",
16026
16026
  arguments: (z) => ({
16027
16027
  project: z.string().describe("Project key whose finished issues to list, such as INFRA."),
16028
16028
  since: z.string().describe("Optional RFC 3339 time; only issues closed at or after it.").optional(),
@@ -20384,6 +20384,22 @@ function canonicalRepo(owner, repo) {
20384
20384
  }
20385
20385
  // ../contracts/src/slack.ts
20386
20386
  var SLACK_POST_TEXT_MAX = 4000;
20387
+ // ../contracts/src/step-answers.ts
20388
+ function setModelText(record) {
20389
+ const setModel = record.set_model ?? "";
20390
+ return setModel === "" ? null : setModel;
20391
+ }
20392
+ function answeredText(record) {
20393
+ if (record.ended_at === null)
20394
+ return "running";
20395
+ const answers = record.answers ?? null;
20396
+ if (answers === null)
20397
+ return "unknown";
20398
+ if (answers.length === 0)
20399
+ return "none";
20400
+ const calls = answers.reduce((sum, answer) => sum + answer.calls, 0);
20401
+ return answers.map((answer) => `${answer.model}=${answer.calls}(${Math.round(100 * answer.calls / calls)}%)`).join(",");
20402
+ }
20387
20403
  // ../contracts/src/subject-project.ts
20388
20404
  var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
20389
20405
  var KEPT_PREFIX = "notifications.envoy.kept.";
@@ -32179,7 +32195,7 @@ function renderAdvice(tool, key, advice, opts) {
32179
32195
  const issueAdvice = "issue_status" in advice ? advice : undefined;
32180
32196
  const hasIssueAdvice = issueAdvice !== undefined;
32181
32197
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
32182
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
32198
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
32183
32199
  const lines = [];
32184
32200
  const unparsed = advice.unparsed_openers;
32185
32201
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -32234,12 +32250,45 @@ function renderAdvice(tool, key, advice, opts) {
32234
32250
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
32235
32251
  lines.push(parts.join(" "));
32236
32252
  }
32237
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
32238
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32239
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32253
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
32254
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32255
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32240
32256
  }
32241
32257
  return lines;
32242
32258
  }
32259
+ function cadenceCount(tool, issueAdvice, isAskReply) {
32260
+ const count = issueAdvice?.session_writes_since_human;
32261
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
32262
+ return posts && count !== undefined && count >= 3 ? count : undefined;
32263
+ }
32264
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
32265
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
32266
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
32267
+ return false;
32268
+ const answered = issueAdvice?.legion_managed_status;
32269
+ if (answered !== undefined)
32270
+ return answered;
32271
+ try {
32272
+ return await legionLabelOnChain(client, issueKey);
32273
+ } catch {
32274
+ return false;
32275
+ }
32276
+ }
32277
+ async function legionLabelOnChain(client, key) {
32278
+ let issue = await client.getIssue(key);
32279
+ const project = issue.project;
32280
+ const read = new Set;
32281
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
32282
+ read.add(issue.key);
32283
+ const parent = issue.parent ?? null;
32284
+ if (parent === null || read.has(parent))
32285
+ return false;
32286
+ issue = await client.getIssue(parent);
32287
+ if (issue.project !== project)
32288
+ return false;
32289
+ }
32290
+ return true;
32291
+ }
32243
32292
  async function otherAdviceLines(render) {
32244
32293
  try {
32245
32294
  return await render();
@@ -38367,7 +38416,9 @@ async function askCommand(context) {
38367
38416
  });
38368
38417
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
38369
38418
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
38370
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
38419
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
38420
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
38421
+ }));
38371
38422
  const asked = waitsOnPerson(ask);
38372
38423
  return {
38373
38424
  text: [
@@ -38576,9 +38627,11 @@ async function commentCommand(context) {
38576
38627
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
38577
38628
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
38578
38629
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
38630
+ const isAskReply = replyToAsk !== undefined;
38579
38631
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
38580
- isAskReply: replyToAsk !== undefined,
38581
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
38632
+ isAskReply,
38633
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
38634
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
38582
38635
  });
38583
38636
  if (replyToAsk !== undefined) {
38584
38637
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -38682,7 +38735,9 @@ async function messageCommand(context) {
38682
38735
  actor
38683
38736
  });
38684
38737
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
38685
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
38738
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
38739
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
38740
+ });
38686
38741
  return {
38687
38742
  text: [
38688
38743
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -39878,6 +39933,11 @@ function timeText(seconds) {
39878
39933
  const minutes = Math.floor(seconds / 60);
39879
39934
  return `time ${Math.floor(minutes / 60)}h${minutes % 60}m`;
39880
39935
  }
39936
+ function setModelStepsText(counts) {
39937
+ if (counts === undefined)
39938
+ return "on set model - off - unknown -";
39939
+ return `on set model ${counts.on} off ${counts.off} unknown ${counts.unknown}`;
39940
+ }
39881
39941
  function issueLine(issue) {
39882
39942
  return [
39883
39943
  issue.issue,
@@ -39888,6 +39948,7 @@ function issueLine(issue) {
39888
39948
  timeText(issue.duration_seconds),
39889
39949
  "failed steps",
39890
39950
  issue.failed_steps,
39951
+ setModelStepsText(issue.set_model_steps),
39891
39952
  ...issue.experiment == null || issue.variant == null ? [] : [`variant ${issue.experiment}/${issue.variant}`]
39892
39953
  ].join(" ");
39893
39954
  }
@@ -41032,7 +41093,11 @@ function stepLine(record) {
41032
41093
  orDash(record.agent),
41033
41094
  orDash(record.model),
41034
41095
  orDash(record.started_at),
41035
- ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
41096
+ ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)],
41097
+ "set",
41098
+ orDash(setModelText(record)),
41099
+ "answered",
41100
+ answeredText(record)
41036
41101
  ].join(" ");
41037
41102
  }
41038
41103
  function taskLine(task, needs, planned) {
@@ -38213,7 +38213,7 @@ var dispatchToolSpecs = [
38213
38213
  {
38214
38214
  name: "dispatch_steps",
38215
38215
  example: { issue: "DSP-1" },
38216
- description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on and that has no plan prints " + "0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch read fails for it, " + `NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
38216
+ description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered last, as provider/model. result is passed, failed or stopped. After the result " + "each line prints set and the model the role was set to, or - for none. Then it prints " + "answered and each model with its calls and its share of the step's calls in whole " + "percent, as anthropic/claude-opus-5-5=41(93%). It prints running for a run not yet " + "ended, unknown where Legion does not know the counts, and none for a step with no call. " + "A field with no value prints -, and a run that has not ended prints running for its end " + "and its result. A closed issue's steps read too. An issue that no step ran on and that " + "has no plan prints 0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch " + `read fails for it, NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
38217
38217
  arguments: (z) => ({
38218
38218
  issue: z.string().describe(ISSUE_REFERENCE)
38219
38219
  }),
@@ -38222,7 +38222,7 @@ var dispatchToolSpecs = [
38222
38222
  {
38223
38223
  name: "dispatch_plans",
38224
38224
  example: { project: "INFRA" },
38225
- description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at failed steps <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. An issue with no plan prints plan " + "none, one with no rating prints ratings none, and one whose time is not known prints " + "time -: an issue Legion never ran prints all three. since and until, each an RFC 3339 " + "time, keep the issues closed at or after since and before until.",
38225
+ description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n> on set model <n> off <n> unknown <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at unknown <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. on set model counts the issue's step " + "records that name an agent and a set model, know their counts and name no other model. " + "off counts the records with an agent that name a set model, know their counts and name " + "another model. unknown counts every other step record that names an agent. Each of the " + "three prints - where the Dispatch server is older than these counts. An issue with no " + "plan prints plan none, one with no rating prints ratings none, and one whose time is not " + "known prints time -: an issue Legion never ran prints all three. since and until, each an " + "RFC 3339 time, keep the issues closed at or after since and before until.",
38226
38226
  arguments: (z) => ({
38227
38227
  project: z.string().describe("Project key whose finished issues to list, such as INFRA."),
38228
38228
  since: z.string().describe("Optional RFC 3339 time; only issues closed at or after it.").optional(),
@@ -42584,6 +42584,22 @@ function canonicalRepo(owner, repo) {
42584
42584
  }
42585
42585
  // ../contracts/src/slack.ts
42586
42586
  var SLACK_POST_TEXT_MAX = 4000;
42587
+ // ../contracts/src/step-answers.ts
42588
+ function setModelText(record) {
42589
+ const setModel = record.set_model ?? "";
42590
+ return setModel === "" ? null : setModel;
42591
+ }
42592
+ function answeredText(record) {
42593
+ if (record.ended_at === null)
42594
+ return "running";
42595
+ const answers = record.answers ?? null;
42596
+ if (answers === null)
42597
+ return "unknown";
42598
+ if (answers.length === 0)
42599
+ return "none";
42600
+ const calls = answers.reduce((sum, answer) => sum + answer.calls, 0);
42601
+ return answers.map((answer) => `${answer.model}=${answer.calls}(${Math.round(100 * answer.calls / calls)}%)`).join(",");
42602
+ }
42587
42603
  // ../contracts/src/subject-project.ts
42588
42604
  var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
42589
42605
  var KEPT_PREFIX = "notifications.envoy.kept.";
@@ -57192,7 +57208,7 @@ function renderAdvice(tool, key, advice, opts) {
57192
57208
  const issueAdvice = "issue_status" in advice ? advice : undefined;
57193
57209
  const hasIssueAdvice = issueAdvice !== undefined;
57194
57210
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
57195
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
57211
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
57196
57212
  const lines = [];
57197
57213
  const unparsed = advice.unparsed_openers;
57198
57214
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -57247,12 +57263,45 @@ function renderAdvice(tool, key, advice, opts) {
57247
57263
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
57248
57264
  lines.push(parts.join(" "));
57249
57265
  }
57250
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
57251
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
57252
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
57266
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
57267
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
57268
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
57253
57269
  }
57254
57270
  return lines;
57255
57271
  }
57272
+ function cadenceCount(tool, issueAdvice, isAskReply) {
57273
+ const count = issueAdvice?.session_writes_since_human;
57274
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
57275
+ return posts && count !== undefined && count >= 3 ? count : undefined;
57276
+ }
57277
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
57278
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
57279
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
57280
+ return false;
57281
+ const answered = issueAdvice?.legion_managed_status;
57282
+ if (answered !== undefined)
57283
+ return answered;
57284
+ try {
57285
+ return await legionLabelOnChain(client, issueKey);
57286
+ } catch {
57287
+ return false;
57288
+ }
57289
+ }
57290
+ async function legionLabelOnChain(client, key) {
57291
+ let issue = await client.getIssue(key);
57292
+ const project = issue.project;
57293
+ const read = new Set;
57294
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
57295
+ read.add(issue.key);
57296
+ const parent = issue.parent ?? null;
57297
+ if (parent === null || read.has(parent))
57298
+ return false;
57299
+ issue = await client.getIssue(parent);
57300
+ if (issue.project !== project)
57301
+ return false;
57302
+ }
57303
+ return true;
57304
+ }
57256
57305
  async function otherAdviceLines(render) {
57257
57306
  try {
57258
57307
  return await render();
@@ -59491,7 +59540,9 @@ async function askCommand(context) {
59491
59540
  });
59492
59541
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
59493
59542
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
59494
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
59543
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
59544
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
59545
+ }));
59495
59546
  const asked = waitsOnPerson(ask);
59496
59547
  return {
59497
59548
  text: [
@@ -59700,9 +59751,11 @@ async function commentCommand(context) {
59700
59751
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
59701
59752
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
59702
59753
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
59754
+ const isAskReply = replyToAsk !== undefined;
59703
59755
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
59704
- isAskReply: replyToAsk !== undefined,
59705
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
59756
+ isAskReply,
59757
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
59758
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
59706
59759
  });
59707
59760
  if (replyToAsk !== undefined) {
59708
59761
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -59806,7 +59859,9 @@ async function messageCommand(context) {
59806
59859
  actor
59807
59860
  });
59808
59861
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
59809
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
59862
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
59863
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
59864
+ });
59810
59865
  return {
59811
59866
  text: [
59812
59867
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -61172,6 +61227,11 @@ function timeText(seconds) {
61172
61227
  const minutes = Math.floor(seconds / 60);
61173
61228
  return `time ${Math.floor(minutes / 60)}h${minutes % 60}m`;
61174
61229
  }
61230
+ function setModelStepsText(counts) {
61231
+ if (counts === undefined)
61232
+ return "on set model - off - unknown -";
61233
+ return `on set model ${counts.on} off ${counts.off} unknown ${counts.unknown}`;
61234
+ }
61175
61235
  function issueLine(issue) {
61176
61236
  return [
61177
61237
  issue.issue,
@@ -61182,6 +61242,7 @@ function issueLine(issue) {
61182
61242
  timeText(issue.duration_seconds),
61183
61243
  "failed steps",
61184
61244
  issue.failed_steps,
61245
+ setModelStepsText(issue.set_model_steps),
61185
61246
  ...issue.experiment == null || issue.variant == null ? [] : [`variant ${issue.experiment}/${issue.variant}`]
61186
61247
  ].join(" ");
61187
61248
  }
@@ -62326,7 +62387,11 @@ function stepLine(record) {
62326
62387
  orDash(record.agent),
62327
62388
  orDash(record.model),
62328
62389
  orDash(record.started_at),
62329
- ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
62390
+ ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)],
62391
+ "set",
62392
+ orDash(setModelText(record)),
62393
+ "answered",
62394
+ answeredText(record)
62330
62395
  ].join(" ");
62331
62396
  }
62332
62397
  function taskLine(task, needs, planned) {
@@ -69042,7 +69107,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
69042
69107
 
69043
69108
  // package.json
69044
69109
  var name2 = "@sjawhar/claude-envoy";
69045
- var version2 = "6.30.1";
69110
+ var version2 = "6.31.1";
69046
69111
  var package_default = {
69047
69112
  name: name2,
69048
69113
  version: version2,
@@ -15431,7 +15431,7 @@ var dispatchToolSpecs = [
15431
15431
  {
15432
15432
  name: "dispatch_steps",
15433
15433
  example: { issue: "DSP-1" },
15434
- description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on and that has no plan prints " + "0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch read fails for it, " + `NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
15434
+ description: "Print each task of an issue's plan and each step that ran on the issue, as the Legion " + "daemon recorded it at the step's start and at its end, and the experiment and the " + "variant the issue was drawn into, where its records name one. The first line is " + "`<KEY>: <n> steps in <m> tasks`, where m counts each task listed, a task of the plan " + "with no run included. Where the records of the issue's newest run name an experiment, " + "the next line is `Experiment <experiment>: variant <variant>.`, and an issue whose " + "newest run's records name none prints no such line. The tasks of the issue's newest " + "plan come first, in the plan's order, then each other task with a run, in the order " + "each first ran. A task of the plan prints `task <task> needs <needs>: <place> <step> " + "<state>, ...`: needs is the tasks it needs as a list, [a,b], [] where it needs none, " + "and - where its plan node recorded none, then each step the plan gives it, where state " + "is where Dispatch says it stands among the records of the plan's own run: not started, " + "running, or the result of its newest run there. Then each run of a step of the task " + "prints one line: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered last, as provider/model. result is passed, failed or stopped. After the result " + "each line prints set and the model the role was set to, or - for none. Then it prints " + "answered and each model with its calls and its share of the step's calls in whole " + "percent, as anthropic/claude-opus-5-5=41(93%). It prints running for a run not yet " + "ended, unknown where Legion does not know the counts, and none for a step with no call. " + "A field with no value prints -, and a run that has not ended prints running for its end " + "and its result. A closed issue's steps read too. An issue that no step ran on and that " + "has no plan prints 0 steps in 0 tasks, and a key Dispatch does not hold fails as dispatch " + `read fails for it, NOT_FOUND: not found. ${ISSUE_REFERENCE}`,
15435
15435
  arguments: (z) => ({
15436
15436
  issue: z.string().describe(ISSUE_REFERENCE)
15437
15437
  }),
@@ -15440,7 +15440,7 @@ var dispatchToolSpecs = [
15440
15440
  {
15441
15441
  name: "dispatch_plans",
15442
15442
  example: { project: "INFRA" },
15443
- description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at failed steps <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. An issue with no plan prints plan " + "none, one with no rating prints ratings none, and one whose time is not known prints " + "time -: an issue Legion never ran prints all three. since and until, each an RFC 3339 " + "time, keep the issues closed at or after since and before until.",
15443
+ description: "Print each finished issue of a project, newest close first, with the plan Legion ran it " + "from, the rating each retro gave that plan with its reason, its time, its count of " + "failed steps, and the experiment and the variant it was drawn into, where its records " + "name one. An issue is finished when its status is done and Dispatch closed it. The " + "first line is `<PROJECT>: <n> finished issues`. Then each issue prints one line: `<KEY> " + "closed <closed_at> plan <source> (<n> tasks: <steps of the first task>) ratings " + `<rating>/${LEGION_PLAN_RATING_MOST} "<reason>"[, <rating>/${LEGION_PLAN_RATING_MOST} "<reason>" ...] time <h>h<m>m failed steps <n> on set model <n> off <n> unknown <n>[ variant <experiment>/<variant>]\`. ` + "The line ends with variant <experiment>/<variant> where the records of the issue's " + "newest run name an experiment, and at unknown <n> where they name none. " + "source is default (Legion's default steps) or owner (the plan the issue's owner wrote), " + `and the plan is the one of the issue's newest run. A rating is ${LEGION_PLAN_RATING_LEAST} (the plan cost the ` + `work) to ${LEGION_PLAN_RATING_MOST} (the plan fit the work), one for each retro in the order the retros ran, and ` + "its reason prints as a JSON string. time runs from the first start of the issue's steps " + "to the last end, in whole hours and minutes rounded down. failed steps counts the runs " + "of a step that failed, retros and merges left out. on set model counts the issue's step " + "records that name an agent and a set model, know their counts and name no other model. " + "off counts the records with an agent that name a set model, know their counts and name " + "another model. unknown counts every other step record that names an agent. Each of the " + "three prints - where the Dispatch server is older than these counts. An issue with no " + "plan prints plan none, one with no rating prints ratings none, and one whose time is not " + "known prints time -: an issue Legion never ran prints all three. since and until, each an " + "RFC 3339 time, keep the issues closed at or after since and before until.",
15444
15444
  arguments: (z) => ({
15445
15445
  project: z.string().describe("Project key whose finished issues to list, such as INFRA."),
15446
15446
  since: z.string().describe("Optional RFC 3339 time; only issues closed at or after it.").optional(),
@@ -19802,6 +19802,22 @@ function canonicalRepo(owner, repo) {
19802
19802
  }
19803
19803
  // ../contracts/src/slack.ts
19804
19804
  var SLACK_POST_TEXT_MAX = 4000;
19805
+ // ../contracts/src/step-answers.ts
19806
+ function setModelText(record) {
19807
+ const setModel = record.set_model ?? "";
19808
+ return setModel === "" ? null : setModel;
19809
+ }
19810
+ function answeredText(record) {
19811
+ if (record.ended_at === null)
19812
+ return "running";
19813
+ const answers = record.answers ?? null;
19814
+ if (answers === null)
19815
+ return "unknown";
19816
+ if (answers.length === 0)
19817
+ return "none";
19818
+ const calls = answers.reduce((sum, answer) => sum + answer.calls, 0);
19819
+ return answers.map((answer) => `${answer.model}=${answer.calls}(${Math.round(100 * answer.calls / calls)}%)`).join(",");
19820
+ }
19805
19821
  // ../contracts/src/subject-project.ts
19806
19822
  var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
19807
19823
  var KEPT_PREFIX = "notifications.envoy.kept.";
@@ -32237,7 +32253,7 @@ function renderAdvice(tool, key, advice, opts) {
32237
32253
  const issueAdvice = "issue_status" in advice ? advice : undefined;
32238
32254
  const hasIssueAdvice = issueAdvice !== undefined;
32239
32255
  const openAsks = issueAdvice?.your_open_asks ?? undefined;
32240
- const writesSinceHuman = issueAdvice?.session_writes_since_human;
32256
+ const cadence = cadenceCount(tool, issueAdvice, opts.isAskReply);
32241
32257
  const lines = [];
32242
32258
  const unparsed = advice.unparsed_openers;
32243
32259
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
@@ -32292,12 +32308,45 @@ function renderAdvice(tool, key, advice, opts) {
32292
32308
  parts.push(opts.isPlan === true ? `A plan is approved by its plan review, and Dispatch refuses a request for a person's approval of a plan. Once a plan review approves version ${superseded.version}, record it with \`dispatch plan-approve --issue ${key} --version ${superseded.version}\`.` : "Meant to change the approved design? Request approval with `dispatch request-approval`. Meant a correction beside it? Tell the issue's architect, and keep the next one in a comment or in the plan.");
32293
32309
  lines.push(parts.join(" "));
32294
32310
  }
32295
- if (hasIssueAdvice && writesSinceHuman !== undefined && writesSinceHuman >= 3 && (tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && opts.isAskReply !== true)) {
32296
- const middle = writesSinceHuman >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32297
- lines.push(`Posted. You've sent ${writesSinceHuman} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32311
+ if (cadence !== undefined && opts.legionRunsIssue !== true) {
32312
+ const middle = cadence >= 6 ? "Stop posting here until a human replies. Their reply ends this: post then what you held back." : "Progress ledger or scratchpad? If so, stop.";
32313
+ lines.push(`Posted. You've sent ${cadence} messages on ${key} with no human response. ${middle} See the \`dispatch\` skill, "Structure over stream".`);
32298
32314
  }
32299
32315
  return lines;
32300
32316
  }
32317
+ function cadenceCount(tool, issueAdvice, isAskReply) {
32318
+ const count = issueAdvice?.session_writes_since_human;
32319
+ const posts = tool === "dispatch_message" || tool === "dispatch_ask" || tool === "dispatch_comment" && isAskReply !== true;
32320
+ return posts && count !== undefined && count >= 3 ? count : undefined;
32321
+ }
32322
+ async function legionRunsPostedIssue(client, tool, issueKey, advice, isAskReply) {
32323
+ const issueAdvice = advice !== undefined && "issue_status" in advice ? advice : undefined;
32324
+ if (issueKey === null || cadenceCount(tool, issueAdvice, isAskReply) === undefined)
32325
+ return false;
32326
+ const answered = issueAdvice?.legion_managed_status;
32327
+ if (answered !== undefined)
32328
+ return answered;
32329
+ try {
32330
+ return await legionLabelOnChain(client, issueKey);
32331
+ } catch {
32332
+ return false;
32333
+ }
32334
+ }
32335
+ async function legionLabelOnChain(client, key) {
32336
+ let issue = await client.getIssue(key);
32337
+ const project = issue.project;
32338
+ const read = new Set;
32339
+ while (!(issue.labels ?? []).some((label) => /^legion$/i.test(label))) {
32340
+ read.add(issue.key);
32341
+ const parent = issue.parent ?? null;
32342
+ if (parent === null || read.has(parent))
32343
+ return false;
32344
+ issue = await client.getIssue(parent);
32345
+ if (issue.project !== project)
32346
+ return false;
32347
+ }
32348
+ return true;
32349
+ }
32301
32350
  async function otherAdviceLines(render) {
32302
32351
  try {
32303
32352
  return await render();
@@ -34907,7 +34956,9 @@ async function askCommand(context) {
34907
34956
  });
34908
34957
  const reviewLines = await otherAdviceLines(() => standingReviewLines(ask.advice));
34909
34958
  const declinedLines = ask.issue_key === null ? [] : declinedAskLines(ask.advice, ask.issue_key, linkBase);
34910
- const adviceLines = await otherAdviceLines(() => renderAdvice(input.tool, askOwner.label, ask.advice, {}));
34959
+ const adviceLines = await otherAdviceLines(async () => renderAdvice(input.tool, askOwner.label, ask.advice, {
34960
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, ask.issue_key, ask.advice)
34961
+ }));
34911
34962
  const asked = waitsOnPerson(ask);
34912
34963
  return {
34913
34964
  text: [
@@ -35116,9 +35167,11 @@ async function commentCommand(context) {
35116
35167
  const comment = resolved?.owner.kind === "project" ? await client.artifactComment(resolved.artifact.id, commentInput) : await client.comment(issue(), commentInput);
35117
35168
  const commentOwner = resolved === undefined ? issueTopic(issue()) : resolvedTopic(resolved);
35118
35169
  const commentDetails = resolved === undefined ? { issue: comment.issue_key, comment: comment.id } : writeResultDetails(resolved, { comment: comment.id });
35170
+ const isAskReply = replyToAsk !== undefined;
35119
35171
  const adviceLines = renderAdvice(input.tool, commentOwner.label, comment.advice, {
35120
- isAskReply: replyToAsk !== undefined,
35121
- replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
35172
+ isAskReply,
35173
+ replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false),
35174
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, comment.issue_key, comment.advice, isAskReply)
35122
35175
  });
35123
35176
  if (replyToAsk !== undefined) {
35124
35177
  const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
@@ -35222,7 +35275,9 @@ async function messageCommand(context) {
35222
35275
  actor
35223
35276
  });
35224
35277
  const messageRef = dispatchChildRef(dispatchIssueRef(issueKey), "message", message.id);
35225
- const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {});
35278
+ const adviceLines = renderAdvice(input.tool, issueKey, message.advice, {
35279
+ legionRunsIssue: await legionRunsPostedIssue(client, input.tool, issueKey, message.advice)
35280
+ });
35226
35281
  return {
35227
35282
  text: [
35228
35283
  `Posted message ${message.id} (${messageRef})${await notSubscribed(issueTopic(issueKey), input.subscriptions)}`,
@@ -36588,6 +36643,11 @@ function timeText(seconds) {
36588
36643
  const minutes = Math.floor(seconds / 60);
36589
36644
  return `time ${Math.floor(minutes / 60)}h${minutes % 60}m`;
36590
36645
  }
36646
+ function setModelStepsText(counts) {
36647
+ if (counts === undefined)
36648
+ return "on set model - off - unknown -";
36649
+ return `on set model ${counts.on} off ${counts.off} unknown ${counts.unknown}`;
36650
+ }
36591
36651
  function issueLine(issue) {
36592
36652
  return [
36593
36653
  issue.issue,
@@ -36598,6 +36658,7 @@ function issueLine(issue) {
36598
36658
  timeText(issue.duration_seconds),
36599
36659
  "failed steps",
36600
36660
  issue.failed_steps,
36661
+ setModelStepsText(issue.set_model_steps),
36601
36662
  ...issue.experiment == null || issue.variant == null ? [] : [`variant ${issue.experiment}/${issue.variant}`]
36602
36663
  ].join(" ");
36603
36664
  }
@@ -37742,7 +37803,11 @@ function stepLine(record) {
37742
37803
  orDash(record.agent),
37743
37804
  orDash(record.model),
37744
37805
  orDash(record.started_at),
37745
- ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
37806
+ ...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)],
37807
+ "set",
37808
+ orDash(setModelText(record)),
37809
+ "answered",
37810
+ answeredText(record)
37746
37811
  ].join(" ");
37747
37812
  }
37748
37813
  function taskLine(task, needs, planned) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "6.30.1",
3
+ "version": "6.31.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",