@sjawhar/claude-envoy 1.23.1 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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": "1.23.1"
5
+ "version": "1.24.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
@@ -52114,6 +52114,16 @@ var legionCapabilityReportView = object({
52114
52114
  ok: array(nonEmptyString),
52115
52115
  open: array(object({ name: nonEmptyString, detail: nonEmptyString }))
52116
52116
  });
52117
+ var legionStepView = object({
52118
+ at: timestamp.optional(),
52119
+ turnStartedAt: timestamp.optional(),
52120
+ tool: nonEmptyString.optional(),
52121
+ callId: nonEmptyString.optional(),
52122
+ argsBytes: number2().int().positive().optional(),
52123
+ argsHash: nonEmptyString.optional(),
52124
+ startedAt: timestamp.optional(),
52125
+ endedAt: timestamp.optional()
52126
+ });
52117
52127
  var legionClaimView = object({
52118
52128
  session: string2(),
52119
52129
  state: _enum2(LEGION_CLAIM_STATES),
@@ -52121,7 +52131,8 @@ var legionClaimView = object({
52121
52131
  capabilities: legionCapabilityReportView.optional(),
52122
52132
  pluginContract: number2().int().nonnegative(),
52123
52133
  updateRound: nonEmptyString.optional(),
52124
- updateHead: nonEmptyString.optional()
52134
+ updateHead: nonEmptyString.optional(),
52135
+ step: legionStepView.optional()
52125
52136
  });
52126
52137
  var legionHandoffRecordView = object({
52127
52138
  id: nonEmptyString,
@@ -52477,7 +52488,8 @@ var LegionOperatorClaimResponse = object({
52477
52488
  suspensionHeld: literal(true).optional(),
52478
52489
  pluginContract: number2().int().nonnegative(),
52479
52490
  updateRound: nonEmptyString.optional(),
52480
- updateHead: nonEmptyString.optional()
52491
+ updateHead: nonEmptyString.optional(),
52492
+ step: legionStepView.optional()
52481
52493
  });
52482
52494
  var legionPodUpdateRounds = object({
52483
52495
  swept: boolean2(),
@@ -55262,9 +55274,9 @@ var import_nats2 = __toESM(require_mod4(), 1);
55262
55274
 
55263
55275
  // package.json
55264
55276
  var name = "@sjawhar/claude-envoy";
55265
- var version2 = "1.23.1";
55277
+ var version2 = "1.24.0";
55266
55278
  var legion = {
55267
- daemonApiVersion: 56
55279
+ daemonApiVersion: 57
55268
55280
  };
55269
55281
 
55270
55282
  // ../pi-shared/src/agent-stream.ts
@@ -56824,6 +56836,10 @@ async function withBound(work, ms) {
56824
56836
  clearTimeout(timer);
56825
56837
  }
56826
56838
  }
56839
+ function architectLive(record) {
56840
+ const architect = record?.architect;
56841
+ return architect !== undefined && architect.state !== "retired" && architect.state !== "failed";
56842
+ }
56827
56843
  function createPhaseReminder(deps) {
56828
56844
  const boundMs = deps.recordBoundMs ?? RECORD_READ_BOUND_MS;
56829
56845
  let stall = { state: "closed", count: 0 };
@@ -56909,7 +56925,7 @@ function createPhaseReminder(deps) {
56909
56925
  const phase = record?.phase ?? "unknown";
56910
56926
  const reminders = stall.count;
56911
56927
  try {
56912
- const live = record?.architect !== undefined && record.architect.state !== "retired" && record.architect.state !== "failed";
56928
+ const live = architectLive(record);
56913
56929
  const topic = ROLE_TOPIC_PREFIX + roleToken(deps.project ?? "", live ? claim.issue : claim.tree, "architect");
56914
56930
  const answer = await publish({
56915
56931
  topic,
@@ -57094,8 +57110,19 @@ var DEFAULT_STALL_LIMITS = {
57094
57110
  reminderMs: 300000,
57095
57111
  waitingMs: 900000,
57096
57112
  resumeMs: 120000,
57097
- architectAfter: 3
57113
+ architectAfter: 3,
57114
+ callGraceMs: 300000,
57115
+ callBoundMs: 3600000,
57116
+ stepMs: 120000
57098
57117
  };
57118
+ var LONG_CALL_BOUND_MS = 14400000;
57119
+ var LONG_CALL_BOUND_ROLES = [
57120
+ "implementer",
57121
+ "reviewer"
57122
+ ];
57123
+ function defaultCallBoundMs(role) {
57124
+ return role !== undefined && LONG_CALL_BOUND_ROLES.includes(role) ? LONG_CALL_BOUND_MS : DEFAULT_STALL_LIMITS.callBoundMs;
57125
+ }
57099
57126
  function integerSetting(env, log, name, fallback, least) {
57100
57127
  const raw = env[name];
57101
57128
  if (raw === undefined)
@@ -57109,12 +57136,15 @@ function integerSetting(env, log, name, fallback, least) {
57109
57136
  }
57110
57137
  return value;
57111
57138
  }
57112
- function stallLimits(env, log) {
57139
+ function stallLimits(env, log, role) {
57113
57140
  return {
57114
57141
  reminderMs: integerSetting(env, log, "LEGION_STALL_REMINDER_MS", DEFAULT_STALL_LIMITS.reminderMs, 0),
57115
57142
  waitingMs: integerSetting(env, log, "LEGION_STALL_WAITING_MS", DEFAULT_STALL_LIMITS.waitingMs, 0),
57116
57143
  resumeMs: integerSetting(env, log, "LEGION_STALL_RESUME_MS", DEFAULT_STALL_LIMITS.resumeMs, 0),
57117
- architectAfter: integerSetting(env, log, "LEGION_STALL_ARCHITECT_AFTER", DEFAULT_STALL_LIMITS.architectAfter, 2)
57144
+ architectAfter: integerSetting(env, log, "LEGION_STALL_ARCHITECT_AFTER", DEFAULT_STALL_LIMITS.architectAfter, 2),
57145
+ callGraceMs: integerSetting(env, log, "LEGION_STALL_CALL_GRACE_MS", DEFAULT_STALL_LIMITS.callGraceMs, 0),
57146
+ callBoundMs: integerSetting(env, log, "LEGION_STALL_CALL_BOUND_MS", defaultCallBoundMs(role), 0),
57147
+ stepMs: integerSetting(env, log, "LEGION_STALL_STEP_MS", DEFAULT_STALL_LIMITS.stepMs, 0)
57118
57148
  };
57119
57149
  }
57120
57150
 
@@ -57246,7 +57276,7 @@ function writePhaseStallRecord(file, entry, recreatedNoticeSent, log) {
57246
57276
  }
57247
57277
  }
57248
57278
  function createPhaseHookEndpoint(deps) {
57249
- const limits = stallLimits(deps.env, deps.log);
57279
+ const limits = stallLimits(deps.env, deps.log, configuredValue(deps.env["LEGION_ROLE"]));
57250
57280
  const restored = readPhaseStallRecord(deps.stateFile, deps.log);
57251
57281
  let entry = restored.entry ?? { state: "closed", count: 0, reported: false };
57252
57282
  let recreatedNoticeSent = restored.recreatedNoticeSent;
@@ -38,6 +38,7 @@ and 7 (a conflict, the hand-over, the close) is in
38
38
  | `merge-waiting` | GitHub has not completed the merge the daemon submitted within an hour of READY's acceptance, and nothing has been withdrawn: read the pull request on GitHub for what GitHub waits on and ask a person for what no worker can do (`skill://legion-architect/references/merge-notices.md#merge-waiting`). |
39
39
  | A reply on an ask you follow | Interpret the reply in the issue's design context. Answer in its thread (`dispatch comment --reply-to <comment id>`; under an open ask whose next move is yours, such as the approval request you must revise or hand back, `--reply-to-ask <ask id> --turn agent`, since a default-turn reply hands that request back to the human and a corrected `--summary` is then refused) where the reply carries a question, a disagreement, a correction or a fact you do not have, and whenever you are unsure; an approval, or an answer that settles the question with nothing left to say, draws no comment and no message back to the person who answered. Then adjust the plan or relay the reply via `envoy_publish` to the responsible worker's role token, which an answer needing nothing from you still needs; scope and product decisions remain with you. |
40
40
  | `worker-died` | Its `role` and `phase`. That role's claim failed: its launches or prompts ran out. For a phase worker the daemon holds the issue (phase `held`) and starts nothing more on it. Reassess the work, then decide with `retry_or_escalate`: `retry` when the failure looks agent-specific or transient, `escalate` to hand the held issue to the controller when it looks environmental. |
41
+ | `worker-stalled` | Its `role` and `reason`. The daemon's stall backstop acted on that worker's stalled turn: its agent had not stepped for longer than the `worker_stall_backstop_hours` this deployment gives the role, and most often the daemon ended the turn and brought the same session back on a new process. The `reason` is the record the daemon read — when the agent last stepped and how long ago that was, the bound it passed, when the turn began, and the last call the daemon saw, with its tool, its call id, when it started and whether it ended — and never a call's arguments, whose text the daemon keeps in no column. It says what the daemon did as well, which is not always a relaunch: where the daemon's wake pacing parked the replacement, the task was taken back and the launch that replaces the stalled process is queued, due at the moment the notice names, and that process runs on until the launch's turn, which may start nothing — a suspension waiting for the claim, a refused lifecycle recheck or the tree's close can end the claim there instead; where a suspension was already waiting for that turn, that suspension ran instead of a replacement and the claim is suspended with nothing queued for it, waiting on a resume; where the launch that replaces the process could not be written, the daemon is still retrying that launch; and where every try at that launch was refused, the claim has failed, and the `worker-died` that comes with it is yours to answer as that row says. It says what became of the stalled process too, for every end but the parked one: that it was stopped, or that the runtime did not confirm the stop, in which case that process may be running still and holding what it runs on — tell the controller of that one, because the daemon stops it again only at its next launch of that claim or at its next restart. No second notice follows any of these unless the daemon restarts while a relaunch is parked, which decides the claim again. The task that worker was serving is still owed to it, and what its return waits on is the one the notice names — the parked launch's turn, the retried launch, or a resume; the stall itself charged the claim nothing, and no phase moved: on every end but the failed one the phase goes on by itself and you start nothing. Your part is to read what the record says the agent was doing and to judge whether that work needs a decision of yours — a call that hung on something the plan did not foresee is one, a turn that comes back and finishes is not. A stall of your own session reaches you the same way, on your own issue; when the stalled claim is a tree's architect, the controller is told of it too. |
41
42
  | `held` | Its `role` and `phase` (the phase the issue left), or `phase` with `reason: "escalated"`. Without `reason`, that phase's worker ran out of launches or prompts: the issue is held (phase `held`), the `worker-died` that comes with it is yours to answer with `retry_or_escalate` as that row says, and the controller hears of the hold too. With `reason: "escalated"`, it records your own `escalate`: the controller has the issue now, and you start nothing for it. |
42
43
  | `ready-refused` | Its `version` and `reason`, and the `reason` names the gated step the READY waits on. The merger's READY was refused, and its packet is kept with the completion so no second READY is ever needed. With `version` greater than 0, `reason` reads `READY refused: approve design version <N> of the tree's <step> document before requesting READY.`: that step's document is already registered at that version, so get it approved (`skill://legion-architect/references/design-gate.md`), and the daemon advances the merge and posts the kept packet the moment every gated step is open. With `version` 0, `reason` reads `READY refused: no design version of the tree's <step> document is approved; register and approve it before requesting READY.`: that step is not registered yet, so register it and get it approved (`skill://legion-architect/references/design-gate.md`) exactly as above; the daemon releases the kept packet the same way — at registration itself when that opens the step (a deployment that gates no step, or Dispatch already shows the version approved), otherwise the moment a human approves the version you registered. The refusal names the first closed step, in the order the deployment gates them, and no second READY is asked for however many steps were closed: read `gatedSteps` in your own record (the `legion` tool's `read_record`) for every step still closed, and open each one. Nothing else is needed once every gated step is open. On a root whose catch-up said `carried`, the gate is a copy on the old root's spec document: run nothing of `skill://legion-architect/references/design-gate.md` for that step; tell the controller the READY waits on a human's approval of that document, and `carried-gate-opened` follows the approval. A `reason` starting `READY_PACKET_MISSING` names a READY refused before the daemon kept packets: that READY is void and the issue stays in merging, so start it over (`park_child` then `rerun_child`, for a child) or end it. |
43
44
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: legion-controller
3
- description: Use when you are a Legion project's controller session, on any controller wake (triage, slot-free, todo, tick, unslotted, awaiting-person, parked-decision, held, worker-died, update-stalled), weekly-plan ranking, backlog stewardship, a clear defect or finding ask a role sends, an issue a person asks you to file, the daily report, an architect's escalation, or a person's message or mention.
3
+ description: Use when you are a Legion project's controller session, on any controller wake (triage, slot-free, todo, tick, unslotted, awaiting-person, parked-decision, held, worker-died, worker-stalled, update-stalled), weekly-plan ranking, backlog stewardship, a clear defect or finding ask a role sends, an issue a person asks you to file, the daily report, an architect's escalation, or a person's message or mention.
4
4
  ---
5
5
 
6
6
  # Legion Controller
@@ -73,6 +73,7 @@ Wake details: `skill://legion-controller/references/wakes.md`.
73
73
  | `parked-decision on <KEY>` | `skill://legion-controller/references/parked-decisions.md#deciding` |
74
74
  | `held on <KEY>` | Nothing, unless `reason: "escalated"`: then an escalation |
75
75
  | `worker-died on <KEY>` (`role: "architect"`) | Re-admit once its cause is gone, else park it |
76
+ | `worker-stalled on <KEY>` (`role: "architect"`) | Nothing, unless the notice says the claim failed: its turn was ended, its task is still owed, and the notice says what became of its process |
76
77
  | `update-stalled on <KEY>` | `skill://legion-controller/references/escalation.md#an-update-round-that-is-not-finishing-update-stalled` |
77
78
  | An architect's escalation | `skill://legion-controller/references/escalation.md` |
78
79
  | A finding ask's reference, or its answer | `skill://legion-controller/references/finding-asks.md` |
@@ -118,6 +118,52 @@ architect's last message on the root issue. When you find none, or it is gone, r
118
118
  fresh budgets). When it stays, park the tree (`set_status` the root to `backlog`) and say why on
119
119
  the issue, because a relaunch would fail the same way.
120
120
 
121
+ ## `worker-stalled on <KEY>` (`{kind: "worker-stalled", role: "architect", reason}`)
122
+
123
+ The daemon's stall backstop acted on a stalled turn of the tree's architect: its agent had not
124
+ stepped for longer than the `worker_stall_backstop_hours` the deployment gives that role, and most
125
+ often the daemon ended the turn and brought the same session back on a new process. You get a copy
126
+ only for a tree's own architect, because every other notice of the tree goes to that architect and
127
+ nobody inside the tree is left to read this one; the architect is told on its issue as well. The
128
+ `reason` is the record the daemon read: when the agent last stepped and how long ago that was, the
129
+ bound it passed, when the turn began, and the last call the daemon saw, with its tool, its call
130
+ id, when it started and whether it ended — never a call's arguments, whose text the daemon keeps
131
+ in no column. It says what the daemon did as well, which is not always a relaunch: where the
132
+ daemon's wake pacing parked the replacement, the task was taken back and the launch that replaces
133
+ the stalled process is queued, due at the moment the notice names; the daemon made no stop of
134
+ that process and the claim records it still. The launch's turn may start nothing, or not the
135
+ launch the park queued — a suspension waiting for the claim, a refused lifecycle recheck, the
136
+ tree's close, a take-back the store refuses at the turn itself, a launch whose own write or start
137
+ the daemon cannot make, and an
138
+ operator's task that runs the launch early are among the things that can change it; where a
139
+ suspension was already waiting for that turn, the suspension ran instead of a replacement and the
140
+ claim is suspended with nothing queued for it, waiting on a resume; where the launch that replaces
141
+ the process has not started, either its write was refused and the daemon retries it at its probe
142
+ interval, or the daemon's own shutdown cut the launch short and the daemon's next start takes it up;
143
+ and where every try at that
144
+ launch was refused, the claim has failed and nothing relaunches it. The notice says which, and no
145
+ second notice follows it: where it names a parked launch, the `wakesWaiting` list of `read_state`
146
+ is what says whether that launch is still waiting its turn.
147
+
148
+ The notice says what became of the stalled process itself, for every end: that the daemon made no
149
+ stop of it and the claim records it still, which is the parked end; that it was stopped; or that
150
+ the runtime did not confirm the stop, in which case that process may be running still and holding
151
+ what it runs on.
152
+ A stop the runtime would not make is a finding to put to a person, with the notice in it, because
153
+ the daemon stops that process again only at its next launch of that claim or at its next restart.
154
+
155
+ Nothing was charged to the claim for the stall itself, and on every end but the failed one
156
+ nothing failed either: the task that architect was serving is still owed to it, and the notice
157
+ names what its return waits on — the parked launch's turn, the retried launch, or a resume — no
158
+ issue was held, and no status moved.
159
+ Do nothing to the tree — park nothing, re-admit nothing, set no status — and start nothing. A
160
+ notice that names the failed end is the exception: that architect's claim is failed, its
161
+ `worker-died` reaches you as any other does, and you answer that notice as its own section says.
162
+ One copy comes per stall, so an architect that stalls again
163
+ and again sends one each time: that is a finding to put to a person
164
+ ([Findings](skill://legion-controller/SKILL.md#findings-and-the-issues-you-file)), with the
165
+ records you were sent in it.
166
+
121
167
  ## `update-stalled on <KEY>` (`{kind: "update-stalled", reason, update}`)
122
168
 
123
169
  An update round over the issue's pod, or over one claim's own process, is not finishing. Handle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "AGENTS.md"
20
20
  ],
21
21
  "legion": {
22
- "daemonApiVersion": 56
22
+ "daemonApiVersion": 57
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -311,7 +311,7 @@ export function writePhaseStallRecord(
311
311
  * restored here before any hook can be answered.
312
312
  */
313
313
  export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint {
314
- const limits = stallLimits(deps.env, deps.log)
314
+ const limits = stallLimits(deps.env, deps.log, configuredValue(deps.env["LEGION_ROLE"]))
315
315
  const restored = readPhaseStallRecord(deps.stateFile, deps.log)
316
316
  // The machine's entry and this host's own key are one record, so the last entry written is kept
317
317
  // for the write the notice makes.