@sjawhar/pi-legion-envoy 1.28.2 → 1.30.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.
package/dist/legion.js CHANGED
@@ -34545,10 +34545,23 @@ async function persistedTranscript(context) {
34545
34545
  throw new Error("Legion session transcript has no agent id");
34546
34546
  return { sessionFile, agentId };
34547
34547
  }
34548
+ var LEGION_BOOTSTRAPPED_SESSION = Symbol.for("legion.pi-envoy.bootstrapped-session");
34549
+ var bootstrappedSessionStore = globalThis;
34550
+ function recordBootstrappedSession(sessionFile) {
34551
+ bootstrappedSessionStore[LEGION_BOOTSTRAPPED_SESSION] = sessionFile;
34552
+ }
34553
+ function resetLegionBootstrappedSessionForTests() {
34554
+ delete bootstrappedSessionStore[LEGION_BOOTSTRAPPED_SESSION];
34555
+ }
34548
34556
  async function isSubagentSession(context) {
34549
34557
  await context.sessionManager.ensureOnDisk();
34550
34558
  const sessionFile = context.sessionManager.getSessionFile();
34551
- return sessionFile !== undefined && fs.existsSync(`${path4.dirname(sessionFile)}.jsonl`);
34559
+ if (sessionFile === undefined)
34560
+ return false;
34561
+ const bootstrapped = bootstrappedSessionStore[LEGION_BOOTSTRAPPED_SESSION];
34562
+ if (bootstrapped !== undefined && bootstrapped !== sessionFile)
34563
+ return true;
34564
+ return fs.existsSync(`${path4.dirname(sessionFile)}.jsonl`);
34552
34565
  }
34553
34566
  function isSingleLegionCommand(command) {
34554
34567
  if (typeof command !== "string")
@@ -34811,6 +34824,7 @@ function legionExtension(pi) {
34811
34824
  const bootToken = requiredSecret(process.env, "LEGION_BOOT_TOKEN");
34812
34825
  bootstrap = (async () => {
34813
34826
  const { sessionFile, agentId } = await persistedTranscript(context);
34827
+ recordBootstrappedSession(sessionFile);
34814
34828
  const started = await (async () => {
34815
34829
  try {
34816
34830
  return await createLegionDaemonClient(requiredEnvironment(process.env, "LEGION_DAEMON_URL")).processStarted({
@@ -34889,6 +34903,7 @@ function legionExtension(pi) {
34889
34903
  const bootToken = requiredSecret(process.env, "LEGION_BOOT_TOKEN");
34890
34904
  bootstrap = (async () => {
34891
34905
  const { sessionFile, agentId } = await persistedTranscript(context);
34906
+ recordBootstrappedSession(sessionFile);
34892
34907
  const started = await (async () => {
34893
34908
  try {
34894
34909
  return await createLegionDaemonClient(requiredEnvironment(process.env, "LEGION_DAEMON_URL")).workerStarted({
@@ -34956,6 +34971,9 @@ function legionExtension(pi) {
34956
34971
  case "controller": {
34957
34972
  const sessionID = context.sessionManager.getSessionId();
34958
34973
  if (controllerSessionID === undefined || controllerSessionID === sessionID) {
34974
+ const sessionFile = context.sessionManager.getSessionFile();
34975
+ if (sessionFile !== undefined)
34976
+ recordBootstrappedSession(sessionFile);
34959
34977
  await claimController(context);
34960
34978
  }
34961
34979
  return;
@@ -35093,5 +35111,6 @@ function legionExtension(pi) {
35093
35111
  }
35094
35112
  export {
35095
35113
  legionExtension as default,
35114
+ resetLegionBootstrappedSessionForTests,
35096
35115
  setLegionBootstrapExitForTests
35097
35116
  };
@@ -306,7 +306,7 @@ corresponding lifecycle procedure.
306
306
  | `pr-closed-unmerged` | Decide from current scope whether to reopen the work, send a fresh implementer, or cancel it with a reason. Delegate the repository action to the responsible phase worker and keep ownership. |
307
307
  | `issue-comment` | Interpret the comment in the issue's design context. Answer it, adjust the plan, or relay it via `envoy_publish` to the responsible worker's role token; scope and product decisions remain with you. |
308
308
  | `catchup-overseer` | Verify its gates, child counts, and PR verdicts against current artifacts, then resume the applicable numbered lifecycle step. It is a current-state snapshot, not a raw-event replay. `gates[LEGION_TREE].open` is the design gate's current state: `true` means the root spec is approved at its current version and you may spawn; `false` (or no `open` key, meaning no gate is registered) means the sequence in section 1 still applies. For each entry in its `phaseCompletions` (`{issue, role, summary, at}`, phases that completed while you were not live), handle it exactly as a `phase-complete` wake. Then compare `childCounts[LEGION_ISSUE].open` (the children not `done`) with `legion state` and Dispatch: any **open** released child — `todo` through `retro` — with no architect role claim gets `spawn_worker` for its architect, a `child-adopted` or `child-status` wake you missed while not live; a `done` child gets nothing, whether or not a lingering legacy tree of its own still shows in `legion state`. |
309
- | `worker-died` | Payload `{type:"worker-died", issue, role}`. The daemon probed and retried this role's worker through `MAX_LAUNCH_FAILURES` attempts and could not confirm a boot — never a raw-event replay or a silent revive. Reassess the work and `spawn_worker` again for the role (it resumes the same agent via `--resume` if a session file survived) or reassign it if the failure looks environmental, not agent-specific. |
309
+ | `worker-died` | Payload `{type:"worker-died", issue, role}`. Two causes, one verdict: the daemon retried this role's boot through `MAX_LAUNCH_FAILURES` attempts and could not confirm it, or the worker booted and acknowledged every prompt without ever starting a turn through `MAX_PROMPT_RETIRES` retire-and-relaunch cycles (LEGION-93) — never a raw-event replay or a silent revive. Your next `spawn_worker` for the role is the retry (one cold launch, three prompts, and `worker-died` again if the agent is still broken). Reassess the work and `spawn_worker` again for the role (it resumes the same agent via `--resume` if a session file survived) or reassign it if the failure looks environmental, not agent-specific. |
310
310
  | `reopened` | Reopen the root lifecycle: inspect the reason and current artifacts, reassess scope and children, and resume at the first applicable numbered step. |
311
311
 
312
312
  ## Escalation judgment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "1.28.2",
3
+ "version": "1.30.0",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [