@codyswann/lisa 4.107.6 → 4.107.7

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.
Files changed (103) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  3. package/dist/core/upstream-evidence-manifest.js +6 -4
  4. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  5. package/package.json +4 -4
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +8 -1
  9. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  10. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  11. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  12. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +8 -1
  13. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  14. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  15. package/plugins/lisa/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  16. package/plugins/lisa-agy/plugin.json +1 -1
  17. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +8 -1
  18. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  19. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  20. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  21. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  24. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  28. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +8 -1
  30. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  31. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  32. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  33. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +8 -1
  35. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  36. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  37. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  38. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  40. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +8 -1
  41. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  42. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  43. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/workers.mjs +84 -12
  44. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  46. package/plugins/lisa-expo-agy/plugin.json +1 -1
  47. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  51. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  54. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  58. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  60. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  61. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  65. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  67. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  68. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  72. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  74. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  75. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  79. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  81. package/plugins/lisa-rails-agy/plugin.json +1 -1
  82. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  86. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  89. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  93. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  94. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  95. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  96. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  98. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  99. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  100. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +8 -1
  101. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +11 -5
  102. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-workers.mjs +1 -0
  103. package/plugins/src/base/skills/lisa-session-manager/scripts/workers.mjs +84 -12
@@ -19,6 +19,32 @@ export const WORKER_SETTINGS = JSON.stringify({
19
19
  crossSessionInbound: "accept",
20
20
  });
21
21
 
22
+ /**
23
+ * The permission and settings flags every worker invocation carries, spawn
24
+ * and resume alike. Resume once dropped them (lisa#4522): whether `--resume`
25
+ * keeps the original session's permission mode is undocumented, so a resumed
26
+ * worker could fall back to default permissions and prompt with nobody
27
+ * attached to answer.
28
+ */
29
+ export const WORKER_PERMISSION_ARGS = Object.freeze([
30
+ "--dangerously-skip-permissions",
31
+ "--settings",
32
+ WORKER_SETTINGS,
33
+ ]);
34
+
35
+ /**
36
+ * A `waitingFor` that names the session's own subagent as what it waits on,
37
+ * which is ordinary work. Anchored, so a prompt that merely mentions a
38
+ * subagent ("permission prompt (subagent x)") still blocks.
39
+ *
40
+ * Observed in Claude Code 2.1.319: `waitingFor` is set only while the session
41
+ * awaits a person ("permission prompt", "dialog open", "input needed",
42
+ * "sandbox request", "goal proposal"); an idle session reports none, and
43
+ * subagent work is reported as a separate work kind, not as `waitingFor`.
44
+ * This exclusion is defensive, for a future string of that shape.
45
+ */
46
+ const SUBAGENT_WAIT_PATTERN = /^\s*sub-?agent\b/i;
47
+
22
48
  /**
23
49
  * Stall policy used when the caller passes none. Mirrors the
24
50
  * `sessionManager.stall` defaults, so a missing config block still classifies.
@@ -163,9 +189,10 @@ function stringOrNull(value) {
163
189
  * terminal state, has finished. Reading `state` alone undercounted capacity,
164
190
  * let `spawn` duplicate a live worker and made `classify` say `dead`.
165
191
  * Every row comes back with all fields present (null when absent) and an
166
- * `active` flag, so callers never branch on shape.
192
+ * `active` flag, so callers never branch on shape. `waitingFor` is kept so
193
+ * `classifyWorker` can see a worker stuck on a prompt (lisa#4522).
167
194
  * @param {unknown} parsed - `JSON.parse` of the command's stdout
168
- * @returns {Array<{name: string|null, sessionId: string|null, id: string|null, pid: number|null, cwd: string|null, kind: string|null, startedAt: number|null, status: string|null, state: string|null, active: boolean}>} Rows
195
+ * @returns {Array<{name: string|null, sessionId: string|null, id: string|null, pid: number|null, cwd: string|null, kind: string|null, startedAt: number|null, status: string|null, state: string|null, waitingFor: string|null, active: boolean}>} Rows
169
196
  */
170
197
  export function normalizeAgents(parsed) {
171
198
  if (!Array.isArray(parsed)) {
@@ -188,6 +215,7 @@ export function normalizeAgents(parsed) {
188
215
  startedAt: typeof row.startedAt === "number" ? row.startedAt : null,
189
216
  status,
190
217
  state,
218
+ waitingFor: stringOrNull(row.waitingFor),
191
219
  active:
192
220
  activeShape || state === null || !TERMINAL_AGENT_STATES.has(state),
193
221
  };
@@ -280,13 +308,12 @@ export function buildWorkerSpawn({ ref, name, manager, repoDir, env }) {
280
308
  requireText("repoDir", repoDir);
281
309
  return {
282
310
  command: "claude",
311
+ // The name stays at args[2]: `spawn` in cli-workers.mjs reads it there.
283
312
  args: [
284
313
  "--bg",
285
314
  "-n",
286
315
  name,
287
- "--dangerously-skip-permissions",
288
- "--settings",
289
- WORKER_SETTINGS,
316
+ ...WORKER_PERMISSION_ARGS,
290
317
  `/lisa:implement ${ref} managedBy=${manager}`,
291
318
  ],
292
319
  cwd: repoDir,
@@ -296,7 +323,8 @@ export function buildWorkerSpawn({ ref, name, manager, repoDir, env }) {
296
323
 
297
324
  /**
298
325
  * Build the spawn that resumes a worker with one message (an answer, or a
299
- * nudge after a stall), with the same cwd and environment scrub as a spawn.
326
+ * nudge after a stall), with the same cwd, environment scrub and permission
327
+ * flags (`WORKER_PERMISSION_ARGS`) as a spawn.
300
328
  * @param {{sessionId: string, text: string, repoDir: string, env: Record<string, string | undefined>}} input - Resume inputs
301
329
  * @returns {{command: string, args: string[], cwd: string, env: Record<string, string | undefined>}} Spawn spec
302
330
  */
@@ -313,7 +341,14 @@ export function buildWorkerResume({ sessionId, text, repoDir, env }) {
313
341
  command: "claude",
314
342
  // `--` ends option parsing: an answer that starts with `--` (claude
315
343
  // 2.1.296 reads `--x` there as an unknown option) stays message text.
316
- args: ["--bg", "--resume", sessionId, "--", text],
344
+ args: [
345
+ "--bg",
346
+ "--resume",
347
+ sessionId,
348
+ ...WORKER_PERMISSION_ARGS,
349
+ "--",
350
+ text,
351
+ ],
317
352
  cwd: repoDir,
318
353
  env: scrubWorkerEnv(env),
319
354
  };
@@ -350,6 +385,24 @@ function toMillis(value) {
350
385
  return null;
351
386
  }
352
387
 
388
+ /**
389
+ * Whether an agent row's `waitingFor` means the worker is stuck on something
390
+ * nobody will answer.
391
+ *
392
+ * Workers run unattended, so any non-empty `waitingFor` (Claude Code reports
393
+ * e.g. "permission prompt") blocks them for good, except a parent waiting on
394
+ * its own subagent (`SUBAGENT_WAIT_PATTERN`), which is ordinary work.
395
+ * @param {unknown} waitingFor - The row's `waitingFor`
396
+ * @returns {boolean} True when the worker can never proceed on its own
397
+ */
398
+ export function isBlockingWait(waitingFor) {
399
+ return (
400
+ typeof waitingFor === "string" &&
401
+ waitingFor.trim() !== "" &&
402
+ !SUBAGENT_WAIT_PATTERN.test(waitingFor)
403
+ );
404
+ }
405
+
353
406
  /**
354
407
  * Classify one dispatched item for this cycle.
355
408
  *
@@ -358,11 +411,15 @@ function toMillis(value) {
358
411
  * reads `done`; then a first prompt that never ran (`firstPromptFailure`,
359
412
  * read from the worker's transcript) is a `setup-gap` — a machine problem no
360
413
  * retry can fix, so it is never `working` until the stall timer and never
361
- * `exhausted` (lisa#4503); only then is liveness judged. `stalled` and `dead`
362
- * become `exhausted` at `maxAttempts`, which is the manager's cue to move the
363
- * item to Blocked instead of retrying it again.
414
+ * `exhausted` (lisa#4503); then an active worker whose row reports a
415
+ * blocking `waitingFor` (see `isBlockingWait`) is `blocked-on-prompt`, never
416
+ * `working` however its logs change (lisa#4522) — a pending question still
417
+ * wins, because a managed worker ends its turn after asking; only then is liveness
418
+ * judged. `blocked-on-prompt`, `stalled` and `dead` become `exhausted` at
419
+ * `maxAttempts`, which is the manager's cue to move the item to Blocked
420
+ * instead of retrying it again.
364
421
  * @param {{agent: ReturnType<typeof normalizeAgents>[number] | null, entry: {status?: string, startedAt?: string|number, lastProgressAt?: string|number|null, logsHash?: string|null, pendingQuestion?: {askedAt?: string|number, lastPingAt?: string|number|null} | null, attempts?: number}, logsHash?: string | null | undefined, now: Date | number, stall?: {noOutputMinutes: number, requestionHours: number, maxAttempts: number}, firstPromptFailure?: {kind: string, detail: string} | null}} input - Classification inputs
365
- * @returns {"finished"|"waiting"|"requestion"|"setup-gap"|"working"|"stalled"|"dead"|"exhausted"} Classification
422
+ * @returns {"finished"|"waiting"|"requestion"|"setup-gap"|"blocked-on-prompt"|"working"|"stalled"|"dead"|"exhausted"} Classification
366
423
  */
367
424
  export function classifyWorker({
368
425
  agent,
@@ -384,7 +441,7 @@ export function classifyWorker({
384
441
  }
385
442
  if (firstPromptFailure) return "setup-gap";
386
443
  const outcome = agent?.active
387
- ? judgeActive(entry, logsHash, nowMs, stall)
444
+ ? judgeLive(agent, entry, logsHash, nowMs, stall)
388
445
  : "dead";
389
446
  if (outcome !== "working" && (entry.attempts ?? 0) >= stall.maxAttempts) {
390
447
  return "exhausted";
@@ -392,6 +449,21 @@ export function classifyWorker({
392
449
  return outcome;
393
450
  }
394
451
 
452
+ /**
453
+ * Judge an active worker: blocked on a prompt, or else by its progress.
454
+ * @param {{waitingFor?: string|null}} agent - Normalized active row
455
+ * @param {Parameters<typeof judgeActive>[0]} entry - Ledger row
456
+ * @param {string | null | undefined} logsHash - This cycle's logs hash
457
+ * @param {number} nowMs - Clock reading
458
+ * @param {{noOutputMinutes: number}} stall - Stall policy
459
+ * @returns {"blocked-on-prompt"|"working"|"stalled"} Classification
460
+ */
461
+ function judgeLive(agent, entry, logsHash, nowMs, stall) {
462
+ return isBlockingWait(agent.waitingFor)
463
+ ? "blocked-on-prompt"
464
+ : judgeActive(entry, logsHash, nowMs, stall);
465
+ }
466
+
395
467
  /**
396
468
  * Decide whether an active worker is making progress.
397
469
  * @param {{logsHash?: string|null, lastProgressAt?: string|number|null, startedAt?: string|number}} entry - Ledger row
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -452,8 +452,15 @@ shows them.
452
452
  | `requestion` | With Telegram: re-send the pending question once, then re-record it with `ledger set-question` (same text, new message id); that restarts the re-ping clock. With no channel: nothing to re-send; leave it pending. |
453
453
  | `stalled`, `dead` | Read the item. If it left the `claimed` role, a human moved it: do not retry or move it; `ledger finish <ref> --status FAILED` with reason "left the claimed role outside the manager". Otherwise check for a merged PR first (`gh pr list --state merged --search <ref>` in the item's repo dir). If merged, leave the state change to Lisa's lifecycle and `ledger finish <ref> --status DONE` with reason "PR merged". Otherwise `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts). |
454
454
  | `setup-gap` | The worker's first prompt never ran: `setupGap.kind` is `unknown-command` (Lisa's plugin is not visible in that repo, so `/lisa:implement` is unknown there) or `prompt-blocked` (a `UserPromptSubmit` hook rejected the prompt; `setupGap.detail` is what the hook said). Retrying cannot fix it. `claude stop <worker>` if it is still listed, `ledger finish <ref> --status FAILED --setup-gap` with reason "setup gap: <kind>: <detail>" (the spawn is not counted as an attempt). Then read the item: If it left the `claimed` role, a human moved it: respect that and do not move it back to the `ready` role. Otherwise move the item back to the `ready` role. Either way post one plain-language line naming the repo and the fix to Telegram, do not respawn it, do not dispatch to that repo again until the operator fixes it, and end the cycle `recovery-required` with that line as the summary. `classify` has already recorded the repo's setup gap, so later cycles' `queue` leaves that repo out and `spawn` refuses it until the operator fixes the repo and runs `ledger clear-setup-gap <repo>` (`.` on a single-repo project); include that command in the line. |
455
+ | `blocked-on-prompt` | The live worker is stuck on a prompt nobody attached can answer: its agent row reports `waitingFor` (e.g. "permission prompt") other than waiting on its own subagent. It will never proceed on its own, however its logs change. `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts; at `stall.maxAttempts` it classifies `exhausted` instead). Send the operator one plain-English line naming the item, the `waitingFor` text, and that the worker was stopped and a fresh attempt starts when capacity allows (Telegram when configured, else the cycle summary). This is once per occurrence: the fresh worker is not blocked, so the same occurrence never repeats. Not a `setup-gap`: the first prompt ran, so the attempt counts and the item stays claimed. |
455
456
  | `exhausted` | Attempts reached `stall.maxAttempts`. Stop the worker if listed, `ledger finish <ref> --status FAILED`, then follow "Mark and move on" with `--kind exhausted` and, as the reason, how many attempts failed and how each ended: it moves the item to the `blocked` role and marks it for a human. |
456
457
 
458
+ Why a worker started with `--dangerously-skip-permissions` reaches a permission prompt at all is
459
+ still unexplained: subagents inherit the bypass, and none of the documented bypass exceptions
460
+ covers a plain Bash call (lisa#4522). So `blocked-on-prompt` detection is the guard, not a cure.
461
+ `resume` passes the same permission flags as `spawn`, so a relayed answer or nudge never drops
462
+ the bypass.
463
+
457
464
  **Blocked.** List the items in the `blocked` role (paged to completion, same access paths as the
458
465
  queue below). For each:
459
466
 
@@ -626,7 +633,7 @@ session `start` creates), every cycle ends in **exactly one** of the six outcome
626
633
  | This cycle | Run outcome |
627
634
  |---|---|
628
635
  | No dispatch, no state change, no question relayed or newly pending. The summary still states the denominator: "swept N ready, 0 dispatchable; R running/C cap". | `nothing-needed` |
629
- | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled item retried. | `change-proved` |
636
+ | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
630
637
  | An item was marked human-needed ("Mark and move on": marker and question comment written and read back), in any of the four cases, including an `exhausted` item moved to the `blocked` role, or a marked item whose question comment was re-posted after `item-answer` reported `no-question-comment`; or a worker `FAILED` moved the item to the `blocked` role with its reason comment, both read back. The summary names each ref and where to answer it. | `candidate-proposed` |
631
638
  | No item was newly marked, but a pending question was re-sent on Telegram (`requestion`) and awaits the operator, and nothing else changed. | `approval-requested` |
632
639
  | The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); a worker classified `setup-gap` (the item went back to Ready); the capacity probe failed. | `recovery-required` |
@@ -50,7 +50,9 @@ Workers and capacity
50
50
  cwd,firstPrompt}, firstPrompt "alive" or "unconfirmed" (the transcript
51
51
  did not resolve in time).
52
52
  resume <ref> STDIN: the message for the worker
53
- claude --bg --resume <full session id> -- "<stdin>" in the worker's repo
53
+ claude --bg --resume <full session id> --dangerously-skip-permissions
54
+ --settings <worker settings> -- "<stdin>" (spawn's permission flags) in
55
+ the worker's repo
54
56
  dir, TELEGRAM_* removed; the full id comes from claude agents --json --all
55
57
  (exit 2 when none does). Exit 2 when the ledger item finished (DONE or
56
58
  FAILED): a finished worker is never resumed.
@@ -60,10 +62,14 @@ Workers and capacity
60
62
  a hash of claude logs <worker>, plus the worker's transcript; records
61
63
  the hash as progress. stdout
62
64
  [{ref,worker,sessionId,repo,classification,attempts,agentStatus,
63
- pendingQuestion,setupGap}], classification one of finished|waiting|
64
- requestion|setup-gap|working|stalled|dead|exhausted. setup-gap: the
65
- worker's first prompt never ran; setupGap is {kind:"unknown-command"|
66
- "prompt-blocked",detail}, else null.
65
+ waitingFor,pendingQuestion,setupGap}], classification one of
66
+ finished|waiting|requestion|setup-gap|blocked-on-prompt|working|
67
+ stalled|dead|exhausted. setup-gap: the worker's first prompt never
68
+ ran; setupGap is {kind:"unknown-command"|"prompt-blocked",detail},
69
+ else null. blocked-on-prompt: the live worker's agent row reports a
70
+ waitingFor other than a subagent (e.g. "permission prompt"), which
71
+ nobody attached can answer. waitingFor is the agent row's text, else
72
+ null.
67
73
  cycle
68
74
  Records that this session ran a cycle now: cyclers[<by>] = <at> in
69
75
  the ledger, by tmux:<session> when tmux names the caller's session,
@@ -510,6 +510,7 @@ export async function classify(ctx) {
510
510
  classification,
511
511
  attempts: entry.attempts ?? 0,
512
512
  agentStatus: agent?.status ?? agent?.state ?? null,
513
+ waitingFor: agent?.waitingFor ?? null,
513
514
  pendingQuestion: entry.pendingQuestion ?? null,
514
515
  setupGap: classification === "setup-gap" ? setupGap : null,
515
516
  });
@@ -19,6 +19,32 @@ export const WORKER_SETTINGS = JSON.stringify({
19
19
  crossSessionInbound: "accept",
20
20
  });
21
21
 
22
+ /**
23
+ * The permission and settings flags every worker invocation carries, spawn
24
+ * and resume alike. Resume once dropped them (lisa#4522): whether `--resume`
25
+ * keeps the original session's permission mode is undocumented, so a resumed
26
+ * worker could fall back to default permissions and prompt with nobody
27
+ * attached to answer.
28
+ */
29
+ export const WORKER_PERMISSION_ARGS = Object.freeze([
30
+ "--dangerously-skip-permissions",
31
+ "--settings",
32
+ WORKER_SETTINGS,
33
+ ]);
34
+
35
+ /**
36
+ * A `waitingFor` that names the session's own subagent as what it waits on,
37
+ * which is ordinary work. Anchored, so a prompt that merely mentions a
38
+ * subagent ("permission prompt (subagent x)") still blocks.
39
+ *
40
+ * Observed in Claude Code 2.1.319: `waitingFor` is set only while the session
41
+ * awaits a person ("permission prompt", "dialog open", "input needed",
42
+ * "sandbox request", "goal proposal"); an idle session reports none, and
43
+ * subagent work is reported as a separate work kind, not as `waitingFor`.
44
+ * This exclusion is defensive, for a future string of that shape.
45
+ */
46
+ const SUBAGENT_WAIT_PATTERN = /^\s*sub-?agent\b/i;
47
+
22
48
  /**
23
49
  * Stall policy used when the caller passes none. Mirrors the
24
50
  * `sessionManager.stall` defaults, so a missing config block still classifies.
@@ -163,9 +189,10 @@ function stringOrNull(value) {
163
189
  * terminal state, has finished. Reading `state` alone undercounted capacity,
164
190
  * let `spawn` duplicate a live worker and made `classify` say `dead`.
165
191
  * Every row comes back with all fields present (null when absent) and an
166
- * `active` flag, so callers never branch on shape.
192
+ * `active` flag, so callers never branch on shape. `waitingFor` is kept so
193
+ * `classifyWorker` can see a worker stuck on a prompt (lisa#4522).
167
194
  * @param {unknown} parsed - `JSON.parse` of the command's stdout
168
- * @returns {Array<{name: string|null, sessionId: string|null, id: string|null, pid: number|null, cwd: string|null, kind: string|null, startedAt: number|null, status: string|null, state: string|null, active: boolean}>} Rows
195
+ * @returns {Array<{name: string|null, sessionId: string|null, id: string|null, pid: number|null, cwd: string|null, kind: string|null, startedAt: number|null, status: string|null, state: string|null, waitingFor: string|null, active: boolean}>} Rows
169
196
  */
170
197
  export function normalizeAgents(parsed) {
171
198
  if (!Array.isArray(parsed)) {
@@ -188,6 +215,7 @@ export function normalizeAgents(parsed) {
188
215
  startedAt: typeof row.startedAt === "number" ? row.startedAt : null,
189
216
  status,
190
217
  state,
218
+ waitingFor: stringOrNull(row.waitingFor),
191
219
  active:
192
220
  activeShape || state === null || !TERMINAL_AGENT_STATES.has(state),
193
221
  };
@@ -280,13 +308,12 @@ export function buildWorkerSpawn({ ref, name, manager, repoDir, env }) {
280
308
  requireText("repoDir", repoDir);
281
309
  return {
282
310
  command: "claude",
311
+ // The name stays at args[2]: `spawn` in cli-workers.mjs reads it there.
283
312
  args: [
284
313
  "--bg",
285
314
  "-n",
286
315
  name,
287
- "--dangerously-skip-permissions",
288
- "--settings",
289
- WORKER_SETTINGS,
316
+ ...WORKER_PERMISSION_ARGS,
290
317
  `/lisa:implement ${ref} managedBy=${manager}`,
291
318
  ],
292
319
  cwd: repoDir,
@@ -296,7 +323,8 @@ export function buildWorkerSpawn({ ref, name, manager, repoDir, env }) {
296
323
 
297
324
  /**
298
325
  * Build the spawn that resumes a worker with one message (an answer, or a
299
- * nudge after a stall), with the same cwd and environment scrub as a spawn.
326
+ * nudge after a stall), with the same cwd, environment scrub and permission
327
+ * flags (`WORKER_PERMISSION_ARGS`) as a spawn.
300
328
  * @param {{sessionId: string, text: string, repoDir: string, env: Record<string, string | undefined>}} input - Resume inputs
301
329
  * @returns {{command: string, args: string[], cwd: string, env: Record<string, string | undefined>}} Spawn spec
302
330
  */
@@ -313,7 +341,14 @@ export function buildWorkerResume({ sessionId, text, repoDir, env }) {
313
341
  command: "claude",
314
342
  // `--` ends option parsing: an answer that starts with `--` (claude
315
343
  // 2.1.296 reads `--x` there as an unknown option) stays message text.
316
- args: ["--bg", "--resume", sessionId, "--", text],
344
+ args: [
345
+ "--bg",
346
+ "--resume",
347
+ sessionId,
348
+ ...WORKER_PERMISSION_ARGS,
349
+ "--",
350
+ text,
351
+ ],
317
352
  cwd: repoDir,
318
353
  env: scrubWorkerEnv(env),
319
354
  };
@@ -350,6 +385,24 @@ function toMillis(value) {
350
385
  return null;
351
386
  }
352
387
 
388
+ /**
389
+ * Whether an agent row's `waitingFor` means the worker is stuck on something
390
+ * nobody will answer.
391
+ *
392
+ * Workers run unattended, so any non-empty `waitingFor` (Claude Code reports
393
+ * e.g. "permission prompt") blocks them for good, except a parent waiting on
394
+ * its own subagent (`SUBAGENT_WAIT_PATTERN`), which is ordinary work.
395
+ * @param {unknown} waitingFor - The row's `waitingFor`
396
+ * @returns {boolean} True when the worker can never proceed on its own
397
+ */
398
+ export function isBlockingWait(waitingFor) {
399
+ return (
400
+ typeof waitingFor === "string" &&
401
+ waitingFor.trim() !== "" &&
402
+ !SUBAGENT_WAIT_PATTERN.test(waitingFor)
403
+ );
404
+ }
405
+
353
406
  /**
354
407
  * Classify one dispatched item for this cycle.
355
408
  *
@@ -358,11 +411,15 @@ function toMillis(value) {
358
411
  * reads `done`; then a first prompt that never ran (`firstPromptFailure`,
359
412
  * read from the worker's transcript) is a `setup-gap` — a machine problem no
360
413
  * retry can fix, so it is never `working` until the stall timer and never
361
- * `exhausted` (lisa#4503); only then is liveness judged. `stalled` and `dead`
362
- * become `exhausted` at `maxAttempts`, which is the manager's cue to move the
363
- * item to Blocked instead of retrying it again.
414
+ * `exhausted` (lisa#4503); then an active worker whose row reports a
415
+ * blocking `waitingFor` (see `isBlockingWait`) is `blocked-on-prompt`, never
416
+ * `working` however its logs change (lisa#4522) — a pending question still
417
+ * wins, because a managed worker ends its turn after asking; only then is liveness
418
+ * judged. `blocked-on-prompt`, `stalled` and `dead` become `exhausted` at
419
+ * `maxAttempts`, which is the manager's cue to move the item to Blocked
420
+ * instead of retrying it again.
364
421
  * @param {{agent: ReturnType<typeof normalizeAgents>[number] | null, entry: {status?: string, startedAt?: string|number, lastProgressAt?: string|number|null, logsHash?: string|null, pendingQuestion?: {askedAt?: string|number, lastPingAt?: string|number|null} | null, attempts?: number}, logsHash?: string | null | undefined, now: Date | number, stall?: {noOutputMinutes: number, requestionHours: number, maxAttempts: number}, firstPromptFailure?: {kind: string, detail: string} | null}} input - Classification inputs
365
- * @returns {"finished"|"waiting"|"requestion"|"setup-gap"|"working"|"stalled"|"dead"|"exhausted"} Classification
422
+ * @returns {"finished"|"waiting"|"requestion"|"setup-gap"|"blocked-on-prompt"|"working"|"stalled"|"dead"|"exhausted"} Classification
366
423
  */
367
424
  export function classifyWorker({
368
425
  agent,
@@ -384,7 +441,7 @@ export function classifyWorker({
384
441
  }
385
442
  if (firstPromptFailure) return "setup-gap";
386
443
  const outcome = agent?.active
387
- ? judgeActive(entry, logsHash, nowMs, stall)
444
+ ? judgeLive(agent, entry, logsHash, nowMs, stall)
388
445
  : "dead";
389
446
  if (outcome !== "working" && (entry.attempts ?? 0) >= stall.maxAttempts) {
390
447
  return "exhausted";
@@ -392,6 +449,21 @@ export function classifyWorker({
392
449
  return outcome;
393
450
  }
394
451
 
452
+ /**
453
+ * Judge an active worker: blocked on a prompt, or else by its progress.
454
+ * @param {{waitingFor?: string|null}} agent - Normalized active row
455
+ * @param {Parameters<typeof judgeActive>[0]} entry - Ledger row
456
+ * @param {string | null | undefined} logsHash - This cycle's logs hash
457
+ * @param {number} nowMs - Clock reading
458
+ * @param {{noOutputMinutes: number}} stall - Stall policy
459
+ * @returns {"blocked-on-prompt"|"working"|"stalled"} Classification
460
+ */
461
+ function judgeLive(agent, entry, logsHash, nowMs, stall) {
462
+ return isBlockingWait(agent.waitingFor)
463
+ ? "blocked-on-prompt"
464
+ : judgeActive(entry, logsHash, nowMs, stall);
465
+ }
466
+
395
467
  /**
396
468
  * Decide whether an active worker is making progress.
397
469
  * @param {{logsHash?: string|null, lastProgressAt?: string|number|null, startedAt?: string|number}} entry - Ledger row
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.107.6",
3
+ "version": "4.107.7",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -452,8 +452,15 @@ shows them.
452
452
  | `requestion` | With Telegram: re-send the pending question once, then re-record it with `ledger set-question` (same text, new message id); that restarts the re-ping clock. With no channel: nothing to re-send; leave it pending. |
453
453
  | `stalled`, `dead` | Read the item. If it left the `claimed` role, a human moved it: do not retry or move it; `ledger finish <ref> --status FAILED` with reason "left the claimed role outside the manager". Otherwise check for a merged PR first (`gh pr list --state merged --search <ref>` in the item's repo dir). If merged, leave the state change to Lisa's lifecycle and `ledger finish <ref> --status DONE` with reason "PR merged". Otherwise `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts). |
454
454
  | `setup-gap` | The worker's first prompt never ran: `setupGap.kind` is `unknown-command` (Lisa's plugin is not visible in that repo, so `/lisa:implement` is unknown there) or `prompt-blocked` (a `UserPromptSubmit` hook rejected the prompt; `setupGap.detail` is what the hook said). Retrying cannot fix it. `claude stop <worker>` if it is still listed, `ledger finish <ref> --status FAILED --setup-gap` with reason "setup gap: <kind>: <detail>" (the spawn is not counted as an attempt). Then read the item: If it left the `claimed` role, a human moved it: respect that and do not move it back to the `ready` role. Otherwise move the item back to the `ready` role. Either way post one plain-language line naming the repo and the fix to Telegram, do not respawn it, do not dispatch to that repo again until the operator fixes it, and end the cycle `recovery-required` with that line as the summary. `classify` has already recorded the repo's setup gap, so later cycles' `queue` leaves that repo out and `spawn` refuses it until the operator fixes the repo and runs `ledger clear-setup-gap <repo>` (`.` on a single-repo project); include that command in the line. |
455
+ | `blocked-on-prompt` | The live worker is stuck on a prompt nobody attached can answer: its agent row reports `waitingFor` (e.g. "permission prompt") other than waiting on its own subagent. It will never proceed on its own, however its logs change. `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts; at `stall.maxAttempts` it classifies `exhausted` instead). Send the operator one plain-English line naming the item, the `waitingFor` text, and that the worker was stopped and a fresh attempt starts when capacity allows (Telegram when configured, else the cycle summary). This is once per occurrence: the fresh worker is not blocked, so the same occurrence never repeats. Not a `setup-gap`: the first prompt ran, so the attempt counts and the item stays claimed. |
455
456
  | `exhausted` | Attempts reached `stall.maxAttempts`. Stop the worker if listed, `ledger finish <ref> --status FAILED`, then follow "Mark and move on" with `--kind exhausted` and, as the reason, how many attempts failed and how each ended: it moves the item to the `blocked` role and marks it for a human. |
456
457
 
458
+ Why a worker started with `--dangerously-skip-permissions` reaches a permission prompt at all is
459
+ still unexplained: subagents inherit the bypass, and none of the documented bypass exceptions
460
+ covers a plain Bash call (lisa#4522). So `blocked-on-prompt` detection is the guard, not a cure.
461
+ `resume` passes the same permission flags as `spawn`, so a relayed answer or nudge never drops
462
+ the bypass.
463
+
457
464
  **Blocked.** List the items in the `blocked` role (paged to completion, same access paths as the
458
465
  queue below). For each:
459
466
 
@@ -626,7 +633,7 @@ session `start` creates), every cycle ends in **exactly one** of the six outcome
626
633
  | This cycle | Run outcome |
627
634
  |---|---|
628
635
  | No dispatch, no state change, no question relayed or newly pending. The summary still states the denominator: "swept N ready, 0 dispatchable; R running/C cap". | `nothing-needed` |
629
- | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled item retried. | `change-proved` |
636
+ | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
630
637
  | An item was marked human-needed ("Mark and move on": marker and question comment written and read back), in any of the four cases, including an `exhausted` item moved to the `blocked` role, or a marked item whose question comment was re-posted after `item-answer` reported `no-question-comment`; or a worker `FAILED` moved the item to the `blocked` role with its reason comment, both read back. The summary names each ref and where to answer it. | `candidate-proposed` |
631
638
  | No item was newly marked, but a pending question was re-sent on Telegram (`requestion`) and awaits the operator, and nothing else changed. | `approval-requested` |
632
639
  | The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); a worker classified `setup-gap` (the item went back to Ready); the capacity probe failed. | `recovery-required` |
@@ -50,7 +50,9 @@ Workers and capacity
50
50
  cwd,firstPrompt}, firstPrompt "alive" or "unconfirmed" (the transcript
51
51
  did not resolve in time).
52
52
  resume <ref> STDIN: the message for the worker
53
- claude --bg --resume <full session id> -- "<stdin>" in the worker's repo
53
+ claude --bg --resume <full session id> --dangerously-skip-permissions
54
+ --settings <worker settings> -- "<stdin>" (spawn's permission flags) in
55
+ the worker's repo
54
56
  dir, TELEGRAM_* removed; the full id comes from claude agents --json --all
55
57
  (exit 2 when none does). Exit 2 when the ledger item finished (DONE or
56
58
  FAILED): a finished worker is never resumed.
@@ -60,10 +62,14 @@ Workers and capacity
60
62
  a hash of claude logs <worker>, plus the worker's transcript; records
61
63
  the hash as progress. stdout
62
64
  [{ref,worker,sessionId,repo,classification,attempts,agentStatus,
63
- pendingQuestion,setupGap}], classification one of finished|waiting|
64
- requestion|setup-gap|working|stalled|dead|exhausted. setup-gap: the
65
- worker's first prompt never ran; setupGap is {kind:"unknown-command"|
66
- "prompt-blocked",detail}, else null.
65
+ waitingFor,pendingQuestion,setupGap}], classification one of
66
+ finished|waiting|requestion|setup-gap|blocked-on-prompt|working|
67
+ stalled|dead|exhausted. setup-gap: the worker's first prompt never
68
+ ran; setupGap is {kind:"unknown-command"|"prompt-blocked",detail},
69
+ else null. blocked-on-prompt: the live worker's agent row reports a
70
+ waitingFor other than a subagent (e.g. "permission prompt"), which
71
+ nobody attached can answer. waitingFor is the agent row's text, else
72
+ null.
67
73
  cycle
68
74
  Records that this session ran a cycle now: cyclers[<by>] = <at> in
69
75
  the ledger, by tmux:<session> when tmux names the caller's session,
@@ -510,6 +510,7 @@ export async function classify(ctx) {
510
510
  classification,
511
511
  attempts: entry.attempts ?? 0,
512
512
  agentStatus: agent?.status ?? agent?.state ?? null,
513
+ waitingFor: agent?.waitingFor ?? null,
513
514
  pendingQuestion: entry.pendingQuestion ?? null,
514
515
  setupGap: classification === "setup-gap" ? setupGap : null,
515
516
  });