@sjawhar/claude-envoy 5.35.0 → 5.35.2

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": "5.35.0"
5
+ "version": "5.35.2"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "5.35.0",
3
+ "version": "5.35.2",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -981,6 +981,7 @@ __export(exports_coerce, {
981
981
 
982
982
  // hooks/codex-hook.ts
983
983
  import { rm as rm5 } from "fs/promises";
984
+
984
985
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
985
986
  var NEVER = Object.freeze({
986
987
  status: "aborted"
package/dist/dispatch.js CHANGED
@@ -1587,6 +1587,7 @@ function consumeMarker(stores, argv, args, files, now) {
1587
1587
  why: mismatched ? "its arguments differ from the ones AskGate reviewed" : expired ? "its AskGate marker expired before it ran" : "this call carries no AskGate marker"
1588
1588
  };
1589
1589
  }
1590
+
1590
1591
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
1591
1592
  var NEVER = Object.freeze({
1592
1593
  status: "aborted"
@@ -23781,6 +23781,7 @@ import { spawn as spawn2 } from "child_process";
23781
23781
  import { unwatchFile as unwatchFile3, watchFile as watchFile3 } from "fs";
23782
23782
  import { homedir as homedir4 } from "os";
23783
23783
  import { join as join23, resolve as resolve4 } from "path";
23784
+
23784
23785
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
23785
23786
  var NEVER = Object.freeze({
23786
23787
  status: "aborted"
@@ -65508,7 +65509,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
65508
65509
 
65509
65510
  // package.json
65510
65511
  var name2 = "@sjawhar/claude-envoy";
65511
- var version2 = "5.35.0";
65512
+ var version2 = "5.35.2";
65512
65513
  var package_default = {
65513
65514
  name: name2,
65514
65515
  version: version2,
@@ -65517,9 +65518,9 @@ var package_default = {
65517
65518
  type: "module",
65518
65519
  files: [".claude-plugin/**", ".mcp.json", ".omp-plugin/**", "bin/**", "dist/**", "hooks/**", "legion/**", "scripts/**", "skills/**", "src/**", "README.md", "AGENTS.md"],
65519
65520
  repository: { type: "git", url: "https://github.com/cybermonklabs/legion" },
65520
- scripts: { channel: "bun bin/envoy-channel.ts", "verify-build": "bash scripts/verify-build.sh", prepack: "bash scripts/pack-skills.sh", postpack: "bash scripts/pack-skills.sh --restore", typecheck: "bunx tsc --noEmit", test: "bun test --timeout=60000", lint: "bunx biome check src/ hooks/ scripts/" },
65521
+ scripts: { channel: "bun bin/envoy-channel.ts", "verify-build": "bash scripts/verify-build.sh", prepack: "bash scripts/pack-skills.sh", postpack: "bash scripts/pack-skills.sh --restore", typecheck: "bun ../contracts/scripts/gen-api.ts && bunx tsc --noEmit", test: "bun test --timeout=60000", lint: "bunx biome check src/ hooks/ scripts/" },
65521
65522
  devDependencies: { "@biomejs/biome": "^2.3.14", "@legion/cipher-client": "workspace:*", "@legion/contracts": "workspace:*", "@legion/envoy-client": "workspace:*", "@legion/pi-shared": "workspace:*", "@legion/test-fixtures": "workspace:*", "@modelcontextprotocol/sdk": "^1.30.0", "bun-types": "latest", nats: "^2.29.2", typescript: "^5.3.0", zod: "4.3.6" },
65522
- legion: { daemonApiVersion: 276 }
65523
+ legion: { daemonApiVersion: 277 }
65523
65524
  };
65524
65525
 
65525
65526
  // ../envoy-client/src/inbound-card.ts
@@ -67230,12 +67231,12 @@ var legionCheckView = object({
67230
67231
  pullRequest: number2().int().positive().optional(),
67231
67232
  mergeCommit: string2().optional(),
67232
67233
  openedAt: timestamp.optional(),
67233
- role: nonEmptyString2,
67234
- looks: number2().int().nonnegative(),
67234
+ role: nonEmptyString2.optional(),
67235
+ looks: number2().int().nonnegative().optional(),
67235
67236
  lookOpen: boolean2().optional(),
67236
67237
  lastWake: legionCheckWakeView.optional(),
67237
67238
  nextWakeAt: timestamp.optional(),
67238
- last: boolean2()
67239
+ last: boolean2().optional()
67239
67240
  });
67240
67241
  var LEGION_WAIT_ANSWERS = [
67241
67242
  "ask",
@@ -67830,12 +67831,15 @@ var LegionHandoffCompleteRequest = strictObject({
67830
67831
  commit: nonEmptyString2.optional(),
67831
67832
  handoffId: nonEmptyString2.optional(),
67832
67833
  handoffVersion: number2().int().positive().optional(),
67834
+ checkOpenedAt: LegionInstant.optional(),
67833
67835
  wakeAt: LegionInstant.optional(),
67834
67836
  planRating: legionPlanRatingScale(number2()).optional(),
67835
67837
  planReason: legionPlanReason.optional(),
67836
67838
  returnTo: number2().int().positive().optional()
67837
67839
  }).refine((request) => legionPlanRatingLoneField(request.planRating, request.planReason) === undefined, { message: "planRating and planReason appear together" }).refine((request) => request.returnTo === undefined || request.verdict === "fail", {
67838
67840
  message: "returnTo is carried only by a completion with the verdict fail"
67841
+ }).refine((request) => request.checkOpenedAt === undefined || request.commit === undefined && request.handoffId === undefined && request.handoffVersion === undefined, {
67842
+ message: "a report naming checkOpenedAt carries no commit, handoffId or handoffVersion"
67839
67843
  });
67840
67844
  var LegionIssueStatusRequest = strictObject({
67841
67845
  grantId: nonEmptyString2,
@@ -67930,10 +67934,6 @@ var ISSUE_RECORD_READS = [
67930
67934
  "workers{}.claim.state",
67931
67935
  "workers{}.claim.lastTurnStart",
67932
67936
  "workers{}.claim.lastTurnEnd",
67933
- "check",
67934
- "check.role",
67935
- "check.looks",
67936
- "check.last",
67937
67937
  "designGate",
67938
67938
  "designGate.currentVersion",
67939
67939
  "designGate.approvedVersion",
@@ -69343,6 +69343,16 @@ var PHASE_OPS = [
69343
69343
  "ready_for_update",
69344
69344
  "read_build"
69345
69345
  ];
69346
+ function namesCheck(args) {
69347
+ return args["check_opened_at"] !== undefined;
69348
+ }
69349
+ function phaseInputAfter(op, args) {
69350
+ if (op === "ready_for_update")
69351
+ return "update-answered";
69352
+ if (op === "request_backward_move" || op === "handoff_complete" && !namesCheck(args))
69353
+ return "phase-closed";
69354
+ return;
69355
+ }
69346
69356
  var requiredString = (op, field) => {
69347
69357
  const message = `${op} requires ${field}`;
69348
69358
  return string2({ error: message }).refine((value) => value.trim() !== "", { error: message });
@@ -69350,6 +69360,7 @@ var requiredString = (op, field) => {
69350
69360
  var rfc3339String = (op, field, message) => requiredString(op, field).refine((value) => value.trim() === "" || LegionInstant.safeParse(value).success, { error: message });
69351
69361
  var windowStart = rfc3339String("read_release_records", "since", "read_release_records' since is an RFC 3339 time, as 2026-11-02T09:00:00Z is");
69352
69362
  var nextLook = rfc3339String("handoff_complete", "wake_at", "handoff_complete's wake_at is an RFC 3339 time, as 2026-11-02T09:00:00Z is");
69363
+ var checkOpening = rfc3339String("handoff_complete", "check_opened_at", "handoff_complete's check_opened_at is the RFC 3339 time, with seconds, its look task names");
69353
69364
  var PLAN_RATING_REFUSAL = `handoff_complete's plan_rating is a whole number from ${LEGION_PLAN_RATING_LEAST} to ${LEGION_PLAN_RATING_MOST}`;
69354
69365
  var planRating = legionPlanRatingScale(number2({ error: PLAN_RATING_REFUSAL }), PLAN_RATING_REFUSAL);
69355
69366
  var PLAN_REASON_MOST = LEGION_PLAN_REASON_MAX.toLocaleString("en-US");
@@ -69381,6 +69392,7 @@ var PhaseOpArguments = discriminatedUnion("op", [
69381
69392
  error: "handoff_complete's verdict is pass, pending or fail"
69382
69393
  }).optional(),
69383
69394
  wake_at: nextLook.optional(),
69395
+ check_opened_at: checkOpening.optional(),
69384
69396
  plan_rating: planRating.optional(),
69385
69397
  plan_reason: planReason.optional(),
69386
69398
  return_to: returnTo.optional()
@@ -69440,7 +69452,7 @@ var PHASE_OP_SENTENCES = {
69440
69452
  };
69441
69453
  var STALE_ENTRY_INSTRUCTION = "End this turn without completing. The task of the entry the phase is on is owed to this claim, and the daemon sends it by itself. " + "That task is work of its own: do what it asks at the head it names and complete it with a handoff of its own, never this completion's " + "record, commit or verdict";
69442
69454
  function legionToolDescription(host) {
69443
- return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers alone: the daemon refuses an architect's completion, with ACCEPTANCE_IS_SIGN_OFF where nothing else refuses it first, since an architect accepts with sign_off; " + "the daemon accepts a completion only from the role working the issue's current phase, " + "or a role's first completion of the phase it left, which it records and which moves nothing, " + "and the checking role's report on a look of its closed issue's production check) reports this phase complete: `summary` (two sentences for the " + "architect), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict from " + "any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet, or carries it with a requirement only the deploy can show still unobserved and a look still to follow; on the check's last look, only for an issue with no such requirement). " + "A tester's fail may name `return_to`, the place of a step of the task its issue runs, 1 for its first: the step the task goes back " + "to; without it, the task goes back to the first implementation step before the step that failed. Only a completion with the verdict " + "fail names it (RETURN_TO_NEEDS_FAIL), a place below 1 is refused (INVALID_RETURN_TO), and so is a step the task cannot go back to " + "(RETURN_REFUSED). " + "A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads from Dispatch the newest record of the phase your role works or, once the issue has moved on, of the phase it left, " + "and reports it with `commit`, the head that record's body names " + "(`head`, the 40-character lower-case commit the work it reports was done against); in implementing, the implementer's must be the commit its " + "workspace stands on, `@-`, pushed to `legion/<issue>@origin`, so push the branch first; retro, the merger's completion and a phase you left with no record, or with an implement record naming no head, report the commit the workspace stands on. It " + "refuses, posting nothing, a phase you work with no record, a Dispatch that does not answer, and, in implementing, an implement record naming no head, an " + "implementer's `@-` not yet on `legion/<issue>@origin`, or an implement record whose head is not that pushed `@-`, each naming the remedy. A production check report " + "(the task whose first line is `Production check of <KEY>`, handed once the merge closed the issue to the role the check records) needs no " + "handoff and no commit: it carries its verdict and summary alone. A pending report also names `wake_at`, an RFC 3339 time: when you want the " + "next look. A pass, a fail, and a pending on the check's last look end the check, so none of them carries `wake_at` " + "(CHECK_WAKE_UNEXPECTED), and a pending on any other look is refused without one (CHECK_WAKE_REQUIRED). A report on an issue whose check is " + "closed or never opened is refused (CHECK_NOT_OPEN), and so is one from a role the check does not record (CHECK_ROLE_MISMATCH). " + `The completion that ends the retro carries \`plan_rating\` (${LEGION_PLAN_RATING_LEAST} to ${LEGION_PLAN_RATING_MOST}) and \`plan_reason\`, as ` + "skill://legion-retro says, and the daemon refuses a completion that breaks that skill's rating rule " + "(PLAN_RATING_REQUIRED, PLAN_RATING_UNEXPECTED or PLAN_RATING_INPUT). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ENTRY (this completion is of a phase entry behind the one your role's phases row names, because the phase was entered " + `again while your turn ran, and nothing was recorded. ${STALE_ENTRY_INSTRUCTION}), the implementer's completion of implementing with no open ` + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide); a refused completion changed " + "nothing, so fix what it names and complete again. " + "ready_for_update answers the daemon's update message on this issue's pod: `round` is the round id that message names, and the " + "daemon takes your answer for that round alone. The reviewer creates no commit and pushes nothing, so each commit " + "and push this description names is not its own, and the merger pushes the merge of the base it made. Push every commit you want kept to the issue branch " + "first. Then let each subagent and each background job that you started finish, or stop it. Commit and push what it made " + "before you answer. The daemon replaces the pod and its disk when the round ends. The round ends at the moment the message " + "names. It can end earlier, once every role has answered, no role is in a turn and each role's last report names no running " + "subagent or background job. No answer delays that moment, and the end of a turn is no answer. If a subagent or a background " + "job finishes after you answer, commit and push what it made. Then call ready_for_update again with the same round. " + "The call ends no phase. The daemon holds your next task until your process comes back on the new pod, in this same session. " + (host.after ?? "") + `What a later phase needs goes in your handoff; a question for another live role goes to its role topic with ${host.envoyPublish}.`;
69455
+ return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers alone: the daemon refuses an architect's completion, with ACCEPTANCE_IS_SIGN_OFF where nothing else refuses it first, since an architect accepts with sign_off; " + "the daemon accepts a completion only from the role working the issue's current phase, " + "or a role's first completion of the phase it left, which it records and which moves nothing, " + "and the checking role's report naming its production check with `check_opened_at`) reports this phase complete: `summary` (two sentences for the " + "architect), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict from " + "any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet, or carries it with a requirement only the deploy can show still unobserved and a look still to follow; on the check's last look, only for an issue with no such requirement). " + "A tester's fail may name `return_to`, the place of a step of the task its issue runs, 1 for its first: the step the task goes back " + "to; without it, the task goes back to the first implementation step before the step that failed. Only a completion with the verdict " + "fail names it (RETURN_TO_NEEDS_FAIL), a place below 1 is refused (INVALID_RETURN_TO), and so is a step the task cannot go back to " + "(RETURN_REFUSED). " + "A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads from Dispatch the newest record of the phase your role works or, once the issue has moved on, of the phase it left, " + "and reports it with `commit`, the head that record's body names " + "(`head`, the 40-character lower-case commit the work it reports was done against); in implementing, the implementer's must be the commit its " + "workspace stands on, `@-`, pushed to `legion/<issue>@origin`, so push the branch first; retro, the merger's completion and a phase you left with no record, or with an implement record naming no head, report the commit the workspace stands on. It " + "refuses, posting nothing, a phase you work with no record, a Dispatch that does not answer, and, in implementing, an implement record naming no head, an " + "implementer's `@-` not yet on `legion/<issue>@origin`, or an implement record whose head is not that pushed `@-`, each naming the remedy. A production check report " + "names `check_opened_at`, the RFC 3339 opening time in its `Production check of <KEY>` task, with its stored microseconds unchanged. " + "Only that field selects a check report, on any phase. Without it the call completes a step. A report carries its verdict and summary, " + "no handoff or commit: this tool reads no record first. A pending report names `wake_at` when it asks for another look. " + "The daemon refuses a wake on a pass, fail or last look (CHECK_WAKE_UNEXPECTED), and a pending on any other look without one " + "(CHECK_WAKE_REQUIRED). It first refuses a missing, closed or differently opened check (CHECK_NOT_OPEN), then another role " + "(CHECK_ROLE_MISMATCH), then a look the claim has not served (CHECK_LOOK_NOT_SERVED). A report ends no phase. " + `The completion that ends the retro carries \`plan_rating\` (${LEGION_PLAN_RATING_LEAST} to ${LEGION_PLAN_RATING_MOST}) and \`plan_reason\`, as ` + "skill://legion-retro says, and the daemon refuses a completion that breaks that skill's rating rule " + "(PLAN_RATING_REQUIRED, PLAN_RATING_UNEXPECTED or PLAN_RATING_INPUT). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ENTRY (this completion is of a phase entry behind the one your role's phases row names, because the phase was entered " + `again while your turn ran, and nothing was recorded. ${STALE_ENTRY_INSTRUCTION}), the implementer's completion of implementing with no open ` + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide); a refused completion changed " + "nothing, so fix what it names and complete again. " + "ready_for_update answers the daemon's update message on this issue's pod: `round` is the round id that message names, and the " + "daemon takes your answer for that round alone. The reviewer creates no commit and pushes nothing, so each commit " + "and push this description names is not its own, and the merger pushes the merge of the base it made. Push every commit you want kept to the issue branch " + "first. Then let each subagent and each background job that you started finish, or stop it. Commit and push what it made " + "before you answer. The daemon replaces the pod and its disk when the round ends. The round ends at the moment the message " + "names. It can end earlier, once every role has answered, no role is in a turn and each role's last report names no running " + "subagent or background job. No answer delays that moment, and the end of a turn is no answer. If a subagent or a background " + "job finishes after you answer, commit and push what it made. Then call ready_for_update again with the same round. " + "The call ends no phase. The daemon holds your next task until your process comes back on the new pod, in this same session. " + (host.after ?? "") + `What a later phase needs goes in your handoff; a question for another live role goes to its role topic with ${host.envoyPublish}.`;
69444
69456
  }
69445
69457
  function pluginBuildOf(manifest, from) {
69446
69458
  return {
@@ -69667,41 +69679,32 @@ async function releaseRecords(runtime, since) {
69667
69679
  }
69668
69680
  async function completeHandoff(runtime, args, rating) {
69669
69681
  const { daemon, claim } = runtime;
69670
- const record = await recordFrom(daemon, claim.issue);
69671
- if (record.phase === "done") {
69682
+ if (namesCheck(args)) {
69683
+ if (args.verdict === undefined) {
69684
+ throw new Error("handoff_complete with check_opened_at names a verdict of pass, pending or fail");
69685
+ }
69672
69686
  if (args.return_to !== undefined) {
69673
- throw new Error("handoff_complete's return_to names the step a failed step's task returns to, and a report on a production check names none; send it again without return_to");
69687
+ throw new Error("handoff_complete's return_to names the step a failed step's task returns to; a report with check_opened_at names none");
69674
69688
  }
69675
- const check = record.check;
69676
- if (check !== undefined) {
69677
- if (args.verdict === undefined) {
69678
- throw new Error("handoff_complete on a production check names a verdict of pass, pending or fail");
69679
- }
69680
- if (claim.role !== check.role) {
69681
- throw new Error(`${claim.issue}'s production check is the ${check.role}'s, and this session is the ${claim.role}'s: only the role the check records reports on it`);
69682
- }
69683
- if (args.verdict === "pending" && args.wake_at === undefined && !check.last) {
69684
- throw new Error(`handoff_complete's pending report names wake_at, when the next look of ${claim.issue}'s production check is due`);
69685
- }
69686
- if (args.wake_at !== undefined && (args.verdict !== "pending" || check.last)) {
69687
- const why = args.verdict === "pending" ? `look ${check.looks} is the check's last, after which the check closes as not run` : `a ${args.verdict} report closes the check`;
69688
- throw new Error(`handoff_complete names wake_at and no look follows it: ${why}; send it again without a time`);
69689
- }
69689
+ if (args.wake_at !== undefined && args.verdict !== "pending") {
69690
+ throw new Error("handoff_complete names wake_at and no look follows a pass or fail; send it again without a time");
69690
69691
  }
69691
69692
  return daemon.handoffComplete({
69692
69693
  grantId: await mintClaimGrant(daemon, claim),
69693
69694
  summary: args.summary,
69694
- verdict: args.verdict ?? "",
69695
+ verdict: args.verdict,
69696
+ checkOpenedAt: args.check_opened_at,
69695
69697
  ...args.wake_at === undefined ? {} : { wakeAt: args.wake_at },
69696
69698
  ...rating
69697
69699
  });
69698
69700
  }
69699
69701
  if (args.verdict === "pending") {
69700
- throw new Error("handoff_complete's verdict is pass or fail on a phase completion; pending is a production check's");
69702
+ throw new Error("handoff_complete's pending verdict reports a production check. Send check_opened_at with the time from the look task or check.openedAt from read_record. To complete a step, send pass or fail.");
69701
69703
  }
69702
69704
  if (args.wake_at !== undefined) {
69703
- throw new Error("handoff_complete's wake_at is a production check's pending report alone; a phase completion carries none");
69705
+ throw new Error("handoff_complete's wake_at reports a production check. Send check_opened_at with the time from the look task or check.openedAt from read_record. A step's completion carries no wake.");
69704
69706
  }
69707
+ const record = await recordFrom(daemon, claim.issue);
69705
69708
  const report = await runtime.handoffReport(record.phase, claim.role);
69706
69709
  return daemon.handoffComplete({
69707
69710
  grantId: await mintClaimGrant(daemon, claim),
@@ -69741,6 +69744,15 @@ async function executeLegionTool(runtime, input, signal) {
69741
69744
  ...signal === undefined ? {} : { restart: { signal } }
69742
69745
  }, input);
69743
69746
  }
69747
+ async function answerLegionTool(runtime, args, hooks, signal) {
69748
+ const answer = await executeLegionTool(runtime, args, signal);
69749
+ const effect = phaseInputAfter(String(args["op"]), args);
69750
+ if (effect === "phase-closed")
69751
+ await hooks.phaseClosed();
69752
+ else if (effect === "update-answered")
69753
+ await hooks.updateAnswered();
69754
+ return answer;
69755
+ }
69744
69756
 
69745
69757
  // src/mod-link.ts
69746
69758
  import { randomUUID as randomUUID9 } from "crypto";
@@ -72311,12 +72323,10 @@ async function runEnvoyChannelServer() {
72311
72323
  handoffReport: paneHandoffReport(configFile, process.env, directory, identity.id),
72312
72324
  branchHead: () => findPushedBranchHead({ env: process.env })
72313
72325
  };
72314
- const answer = await executeLegionTool(legionRuntime, request.params.arguments, extra.signal);
72315
- const op = request.params.arguments?.["op"];
72316
- if (op === "handoff_complete" || op === "request_backward_move")
72317
- phaseHook?.phaseClosed();
72318
- else if (op === "ready_for_update")
72319
- phaseHook?.updateAnswered();
72326
+ const answer = await answerLegionTool(legionRuntime, request.params.arguments ?? {}, {
72327
+ phaseClosed: () => phaseHook?.phaseClosed(),
72328
+ updateAnswered: () => phaseHook?.updateAnswered()
72329
+ }, extra.signal);
72320
72330
  return mcpResult(answer);
72321
72331
  }
72322
72332
  if (runtime === undefined)
@@ -4502,6 +4502,7 @@ async function saveDeviceLogin(path, login, held, keep = false) {
4502
4502
  }
4503
4503
  } catch {}
4504
4504
  }
4505
+
4505
4506
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
4506
4507
  var NEVER = Object.freeze({
4507
4508
  status: "aborted"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "5.35.0",
3
+ "version": "5.35.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "verify-build": "bash scripts/verify-build.sh",
28
28
  "prepack": "bash scripts/pack-skills.sh",
29
29
  "postpack": "bash scripts/pack-skills.sh --restore",
30
- "typecheck": "bunx tsc --noEmit",
30
+ "typecheck": "bun ../contracts/scripts/gen-api.ts && bunx tsc --noEmit",
31
31
  "test": "bun test --timeout=60000",
32
32
  "lint": "bunx biome check src/ hooks/ scripts/"
33
33
  },
@@ -45,6 +45,6 @@
45
45
  "zod": "4.3.6"
46
46
  },
47
47
  "legion": {
48
- "daemonApiVersion": 276
48
+ "daemonApiVersion": 277
49
49
  }
50
50
  }
@@ -135,7 +135,7 @@ import {
135
135
  phaseStallFile,
136
136
  } from "./legion-phase-hook"
137
137
  import {
138
- executeLegionTool,
138
+ answerLegionTool,
139
139
  LEGION_TOOL_NAME,
140
140
  type LegionToolRuntime,
141
141
  legionToolDefinition,
@@ -2676,17 +2676,15 @@ export async function runEnvoyChannelServer(): Promise<void> {
2676
2676
  }
2677
2677
  // The request's signal aborts on the client's notifications/cancelled, which ends a wait
2678
2678
  // for a restarting daemon.
2679
- const answer = await executeLegionTool(legionRuntime, request.params.arguments, extra.signal)
2680
- // A call that returned without throwing: a completion, and a backward move, which hands the
2681
- // issue to another phase. Either way this session's phase is no longer open, and the
2682
- // reminder must stop — the same two operations the Oh My Pi host closes its phase on
2683
- // (`createLegionTool` in `packages/pi-legion/src/tools.ts`). `ready_for_update` ends no
2684
- // phase: it answers the pod's update message, and the worker then waits for its process to be
2685
- // replaced, so the `Stop` of the turn it answered in blocks nothing (`updateAnswered`,
2686
- // `./legion-phase-hook`), as the Oh My Pi host's `onUpdateAnswered` does.
2687
- const op = request.params.arguments?.["op"]
2688
- if (op === "handoff_complete" || op === "request_backward_move") phaseHook?.phaseClosed()
2689
- else if (op === "ready_for_update") phaseHook?.updateAnswered()
2679
+ const answer = await answerLegionTool(
2680
+ legionRuntime,
2681
+ request.params.arguments ?? {},
2682
+ {
2683
+ phaseClosed: () => phaseHook?.phaseClosed(),
2684
+ updateAnswered: () => phaseHook?.updateAnswered(),
2685
+ },
2686
+ extra.signal,
2687
+ )
2690
2688
  return mcpResult(answer)
2691
2689
  }
2692
2690
  if (runtime === undefined)
@@ -8,6 +8,7 @@ import {
8
8
  legionToolDescription,
9
9
  PHASE_OP_SENTENCES,
10
10
  PHASE_OPS,
11
+ phaseInputAfter,
11
12
  phaseOpParameters,
12
13
  pluginBuildOf,
13
14
  } from "@legion/pi-shared/legion-phase-ops"
@@ -82,3 +83,20 @@ export async function executeLegionTool(
82
83
  input,
83
84
  )
84
85
  }
86
+
87
+ /** Runs a successful call through the host's input hooks; a refusal changes no input gate. */
88
+ export async function answerLegionTool(
89
+ runtime: LegionToolRuntime,
90
+ args: Record<string, unknown>,
91
+ hooks: {
92
+ readonly phaseClosed: () => void | Promise<void>
93
+ readonly updateAnswered: () => void | Promise<void>
94
+ },
95
+ signal?: AbortSignal,
96
+ ): Promise<unknown> {
97
+ const answer = await executeLegionTool(runtime, args, signal)
98
+ const effect = phaseInputAfter(String(args["op"]), args)
99
+ if (effect === "phase-closed") await hooks.phaseClosed()
100
+ else if (effect === "update-answered") await hooks.updateAnswered()
101
+ return answer
102
+ }