@tekmidian/pai 0.66.48 → 0.66.49

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 (76) hide show
  1. package/dist/auto-route-CMARQbQ4.mjs +8 -0
  2. package/dist/{auto-route-DrncbMaz.mjs → auto-route-Dpm6nZ6X.mjs} +2 -2
  3. package/dist/{auto-route-DrncbMaz.mjs.map → auto-route-Dpm6nZ6X.mjs.map} +1 -1
  4. package/dist/{chain-Bba4Y8A8.mjs → chain-xSc3-u0X.mjs} +5 -5
  5. package/dist/{chain-Bba4Y8A8.mjs.map → chain-xSc3-u0X.mjs.map} +1 -1
  6. package/dist/cli/index.mjs +14 -14
  7. package/dist/cli/program.mjs +14 -14
  8. package/dist/{config-2pR0RqHM.mjs → config-CYjjGSWq.mjs} +41 -4
  9. package/dist/config-CYjjGSWq.mjs.map +1 -0
  10. package/dist/config-IuOG1W92.mjs +4 -0
  11. package/dist/daemon/index.mjs +10 -10
  12. package/dist/{daemon-C25MKGD8.mjs → daemon-BIG7XcqE.mjs} +10 -10
  13. package/dist/{daemon-C6K3kikA.mjs → daemon-CiSmbylJ.mjs} +7 -7
  14. package/dist/{daemon-C6K3kikA.mjs.map → daemon-CiSmbylJ.mjs.map} +1 -1
  15. package/dist/daemon-mcp/index.mjs +8 -8
  16. package/dist/{fallback-DyhAZAOe.mjs → fallback-BgAukP8r.mjs} +6 -5
  17. package/dist/fallback-BgAukP8r.mjs.map +1 -0
  18. package/dist/hooks/block-sleep-poll.mjs.map +2 -2
  19. package/dist/hooks/load-project-context.mjs +26 -2
  20. package/dist/hooks/load-project-context.mjs.map +2 -2
  21. package/dist/hooks/route-agents-to-worker.mjs +26 -2
  22. package/dist/hooks/route-agents-to-worker.mjs.map +2 -2
  23. package/dist/hooks/security-validator.mjs +26 -2
  24. package/dist/hooks/security-validator.mjs.map +2 -2
  25. package/dist/hooks/worker-guard.mjs +26 -2
  26. package/dist/hooks/worker-guard.mjs.map +2 -2
  27. package/dist/hooks/worker-pool-host.mjs +242 -14
  28. package/dist/hooks/worker-pool-host.mjs.map +4 -4
  29. package/dist/hooks/worker-proxy.mjs +26 -2
  30. package/dist/hooks/worker-proxy.mjs.map +2 -2
  31. package/dist/hooks/worker-status-line.mjs +26 -2
  32. package/dist/hooks/worker-status-line.mjs.map +2 -2
  33. package/dist/hooks/worker-supervision.mjs +26 -2
  34. package/dist/hooks/worker-supervision.mjs.map +2 -2
  35. package/dist/index.mjs +4 -4
  36. package/dist/{local-EmOjw5jq.mjs → local-Bt-7L0oB.mjs} +3 -3
  37. package/dist/{local-EmOjw5jq.mjs.map → local-Bt-7L0oB.mjs.map} +1 -1
  38. package/dist/local-oqPQEmhb.mjs +7 -0
  39. package/dist/{local-tiers-BIINbhkY.mjs → local-tiers-C0QSQcP1.mjs} +2 -2
  40. package/dist/{local-tiers-8fmjiySw.mjs → local-tiers-_ZOTbjeP.mjs} +2 -2
  41. package/dist/{local-tiers-8fmjiySw.mjs.map → local-tiers-_ZOTbjeP.mjs.map} +1 -1
  42. package/dist/{main-resolver-DBXvnYKp.mjs → main-resolver-BwjexuSA.mjs} +3 -3
  43. package/dist/{main-resolver-B10-lsU0.mjs → main-resolver-CVo0ab7j.mjs} +3 -3
  44. package/dist/{main-resolver-B10-lsU0.mjs.map → main-resolver-CVo0ab7j.mjs.map} +1 -1
  45. package/dist/{pai-marker-CDwQOpQ8.mjs → pai-marker-CJ6WMt05.mjs} +4 -4
  46. package/dist/{pai-marker-CDwQOpQ8.mjs.map → pai-marker-CJ6WMt05.mjs.map} +1 -1
  47. package/dist/{planner-dO-3PLjD.mjs → planner-ZKXZf9JS.mjs} +8 -8
  48. package/dist/{planner-dO-3PLjD.mjs.map → planner-ZKXZf9JS.mjs.map} +1 -1
  49. package/dist/{pool-DLhqOY3P.mjs → pool-CgsnP3La.mjs} +3 -3
  50. package/dist/{pool-DLhqOY3P.mjs.map → pool-CgsnP3La.mjs.map} +1 -1
  51. package/dist/{pool-cli-DerrWWpP.mjs → pool-cli-kGGuZCzJ.mjs} +4 -4
  52. package/dist/{pool-cli-DerrWWpP.mjs.map → pool-cli-kGGuZCzJ.mjs.map} +1 -1
  53. package/dist/{program-B7gVKc-u.mjs → program-DgcwJN6Z.mjs} +25 -463
  54. package/dist/program-DgcwJN6Z.mjs.map +1 -0
  55. package/dist/{run-a_JzcVwv.mjs → run-CsrBbtj_.mjs} +686 -21
  56. package/dist/run-CsrBbtj_.mjs.map +1 -0
  57. package/dist/{run-env-DyFZ8C1s.mjs → run-env-Cyw2iwBh.mjs} +15 -5
  58. package/dist/{run-env-DyFZ8C1s.mjs.map → run-env-Cyw2iwBh.mjs.map} +1 -1
  59. package/dist/{status-C3fBJKU_.mjs → status-B0br9zV0.mjs} +2 -2
  60. package/dist/status-B0br9zV0.mjs.map +1 -0
  61. package/dist/{supervisor-B_2JKYxe.mjs → supervisor-BZA0KICt.mjs} +7 -7
  62. package/dist/{supervisor-B_2JKYxe.mjs.map → supervisor-BZA0KICt.mjs.map} +1 -1
  63. package/dist/workers-config-BifEz8ns.mjs +4 -0
  64. package/dist/{worktree-lnmAOFQv.mjs → worktree-B6d-1uIn.mjs} +2 -2
  65. package/dist/{worktree-lnmAOFQv.mjs.map → worktree-B6d-1uIn.mjs.map} +1 -1
  66. package/docs/worker.md +22 -0
  67. package/package.json +1 -1
  68. package/dist/auto-route-DYuVfXwc.mjs +0 -8
  69. package/dist/config-2pR0RqHM.mjs.map +0 -1
  70. package/dist/config-CQWpEdXb.mjs +0 -4
  71. package/dist/fallback-DyhAZAOe.mjs.map +0 -1
  72. package/dist/local-B5SekWOC.mjs +0 -7
  73. package/dist/program-B7gVKc-u.mjs.map +0 -1
  74. package/dist/run-a_JzcVwv.mjs.map +0 -1
  75. package/dist/status-C3fBJKU_.mjs.map +0 -1
  76. package/dist/workers-config-nXSiW07z.mjs +0 -4
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-C3fBJKU_.mjs","names":[],"sources":["../src/workers/paths.ts","../src/workers/args.ts","../src/workers/preamble.ts","../src/session/forge-sink.ts","../src/workers/status.ts"],"sourcesContent":["/**\n * paths.ts — where worker run artefacts live.\n *\n * Everything a run writes (event mirror, status file, pane registry, routing\n * state, the empty MCP config) sits under one logDir so the whole tree is\n * disposable and configurable: `workers.logDir`, default ~/.claude/logs/workers.\n */\n\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { expandHome, DEFAULT_LOG_DIR, type WorkersConfig } from \"./config.js\";\nimport { paiHomePath, resolvePaiFile } from \"../config/pai-home.js\";\n\n/**\n * Absolute logDir for the given config. An explicit `logDir` in workers.yaml\n * is honored verbatim (the user chose it). Otherwise this resolves like every\n * other PAI_HOME file: PAI_HOME/logs/workers if it exists, else the old\n * ~/.claude/logs/workers (with a one-time notice), else the new path.\n */\nexport function workersLogDir(config: WorkersConfig): string {\n const expanded = expandHome(config.logDir);\n if (config.logDir !== DEFAULT_LOG_DIR) return expanded;\n return resolvePaiFile(paiHomePath(\"logs\", \"workers\"), [expanded], \"pai config migrate --logs\");\n}\n\n/** The strict empty MCP config for headless runs, written on demand. */\nexport function ensureNoMcpConfig(logDir: string): string {\n const path = noMcpConfigPath(logDir);\n if (!existsSync(path)) {\n mkdirSync(logDir, { recursive: true });\n writeFileSync(path, '{ \"mcpServers\": {} }\\n', \"utf8\");\n }\n return path;\n}\n\nexport function statusPath(logDir: string, id: string): string {\n return join(logDir, `${id}.status`);\n}\n\nexport function eventsPath(logDir: string, id: string): string {\n return join(logDir, `${id}.jsonl`);\n}\n\nexport function ledgerPath(logDir: string): string {\n return join(logDir, \"ledger.log\");\n}\n\nexport function routingStatePath(logDir: string): string {\n return join(logDir, \"routing-state.json\");\n}\n\nexport function panesDir(logDir: string): string {\n return join(logDir, \"panes\");\n}\n\n/**\n * The strict empty MCP config handed to headless workers. Written into the\n * logDir on demand (never into the user's vendor config directory — this is\n * PAI state, not vendor state).\n */\nexport function noMcpConfigPath(logDir: string): string {\n return join(logDir, \"no-mcp.json\");\n}\n","/**\n * args.ts — parse the claude-args tail that `pai worker run` receives.\n *\n * The runner needs a few things out of the caller's argument vector: the\n * prompt (for the default label), the requested --output-format (so the final\n * print matches what plain `claude -p` would have produced), whether the\n * caller already chose a --model or an --mcp-config (both suppress the\n * defaults the runner would otherwise force), any --mcp allowlist names, any\n * --allowedTools grants (their mcp__server__… entries decide which servers\n * load), and whether they appended their own system prompt (the worker\n * contract is then added alongside, not instead). Everything is passed\n * through untouched — the runner never rewrites the caller's task.\n */\n\nexport interface ParsedRunnerArgs {\n /** Prompt string after -p/--print, when the run is headless. */\n prompt: string | null;\n /** Caller's --output-format: text (default), json, or stream-json. */\n outputFormat: \"text\" | \"json\" | \"stream-json\";\n /** Args to hand to claude (minus --output-format/--verbose, which we add). */\n rest: string[];\n /** Headless: a -p/--print flag is present. */\n headless: boolean;\n /** Caller passed --model (or --model=…): do not force the provider model. */\n callerModel: boolean;\n /** Caller passed --mcp-config (or --mcp-config=…): keep their MCP setup. */\n callerMcpConfig: boolean;\n /** Caller passed --append-system-prompt: the contract is added alongside. */\n callerSystemPrompt: boolean;\n /** The caller's --append-system-prompt texts, pulled out of `rest` (claude keeps only the last flag). */\n callerSystemPrompts: string[];\n /** Caller passed --tools (or --tools=…): a project's `pai project tools` pin does not apply. */\n callerTools: boolean;\n /** --mcp values (repeatable, comma-separated inside one flag). */\n mcp: string[];\n /** --allowedTools values (repeatable, comma-separated inside one flag). */\n allowedTools: string[];\n}\n\nexport function parseRunnerArgs(argv: string[]): ParsedRunnerArgs {\n let prompt: string | null = null;\n let outputFormat: ParsedRunnerArgs[\"outputFormat\"] = \"text\";\n const rest: string[] = [];\n let headless = false;\n let callerModel = false;\n let callerMcpConfig = false;\n let callerSystemPrompt = false;\n const callerSystemPrompts: string[] = [];\n let callerTools = false;\n const mcp: string[] = [];\n const allowedTools: string[] = [];\n\n let i = 0;\n while (i < argv.length) {\n const a = argv[i];\n if (a === \"-p\" || a === \"--print\") {\n headless = true;\n rest.push(a);\n if (i + 1 < argv.length && !argv[i + 1].startsWith(\"-\")) {\n prompt = argv[i + 1];\n rest.push(prompt);\n i += 1;\n }\n } else if (a === \"--output-format\") {\n const v = argv[i + 1];\n if (v === \"json\" || v === \"stream-json\") outputFormat = v;\n i += 1; // dropped; the runner prints the result in this format itself\n } else if (a.startsWith(\"--output-format=\")) {\n const v = a.slice(\"--output-format=\".length);\n if (v === \"json\" || v === \"stream-json\") outputFormat = v;\n } else if (a === \"--verbose\") {\n // dropped; re-added by the runner\n } else if (a === \"--append-system-prompt\") {\n callerSystemPrompt = true;\n if (i + 1 < argv.length) callerSystemPrompts.push(argv[++i]);\n } else if (a.startsWith(\"--append-system-prompt=\")) {\n callerSystemPrompt = true;\n callerSystemPrompts.push(a.slice(\"--append-system-prompt=\".length));\n } else if (a === \"--mcp\") {\n const v = argv[i + 1];\n if (v !== undefined && !v.startsWith(\"-\")) {\n mcp.push(v);\n i += 1;\n }\n } else if (a.startsWith(\"--mcp=\")) {\n mcp.push(a.slice(\"--mcp=\".length));\n } else if (a === \"--allowedTools\") {\n // captured for the MCP derivation, but still claude's flag: it passes through\n rest.push(a);\n const v = argv[i + 1];\n if (v !== undefined && !v.startsWith(\"-\")) {\n allowedTools.push(v);\n rest.push(v);\n i += 1;\n }\n } else if (a.startsWith(\"--allowedTools=\")) {\n allowedTools.push(a.slice(\"--allowedTools=\".length));\n rest.push(a);\n } else {\n if (a === \"--model\") callerModel = true;\n if (a.startsWith(\"--model=\")) callerModel = true;\n if (a === \"--mcp-config\") callerMcpConfig = true;\n if (a.startsWith(\"--mcp-config=\")) callerMcpConfig = true;\n if (a === \"--tools\") callerTools = true;\n if (a.startsWith(\"--tools=\")) callerTools = true;\n if (\n prompt === null && !a.startsWith(\"-\") && rest.length > 0 &&\n (rest[rest.length - 1] === \"-p\" || rest[rest.length - 1] === \"--print\")\n ) {\n prompt = a;\n }\n rest.push(a);\n }\n i += 1;\n }\n\n return {\n prompt,\n outputFormat,\n rest,\n headless,\n callerModel,\n callerMcpConfig,\n callerSystemPrompt,\n callerSystemPrompts,\n callerTools,\n mcp,\n allowedTools,\n };\n}\n\n/**\n * The one --append-system-prompt flag for a spawn: claude keeps only the LAST\n * occurrence, so every piece is joined (blank line between) into a single flag.\n * Empty parts are dropped; no parts, no flag.\n */\nexport function appendSystemPromptArgs(parts: string[]): string[] {\n const text = parts.filter((p) => p.trim()).join(\"\\n\\n\");\n return text ? [\"--append-system-prompt\", text] : [];\n}\n\n/**\n * Turn `-p \"<prompt>\"` into bare `-p` (same for --print): for stream-json\n * stdin runs the prompt moves to the first user message on stdin, so the\n * value must not stay on the command line. Only prompt values directly\n * following the flag are touched; everything else passes through.\n */\nexport function stripPromptValues(argv: string[]): string[] {\n const out: string[] = [];\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i];\n const isPrint = a === \"-p\" || a === \"--print\";\n out.push(a);\n if (isPrint && i + 1 < argv.length && !argv[i + 1].startsWith(\"-\")) {\n i += 1; // drop the prompt value; the flag itself stays\n }\n }\n return out;\n}\n\n/**\n * A one-line stderr hint (never blocking) for an inline -p prompt long or\n * multi-line enough to be a shell-quoting risk — write it to a file and pass\n * --spec instead. null when the prompt is short/simple enough to be fine.\n */\nexport function longInlinePromptHint(prompt: string | null): string | null {\n if (!prompt) return null;\n const newlines = (prompt.match(/\\n/g) ?? []).length;\n if (prompt.length > 600 || newlines > 3) {\n return \"hint: long inline prompts break on shell quoting — write the spec to a file and use --spec <file>\";\n }\n return null;\n}\n\n/** Collapse whitespace and cut to n chars with an ellipsis (label rendering). */\nexport function shortText(s: unknown, n: number): string {\n const t = String(s ?? \"\").split(/\\s+/).filter(Boolean).join(\" \");\n return t.length <= n ? t : t.slice(0, n - 1) + \"…\";\n}\n","/**\n * Per-project worker preamble: `.pai/worker.md` at the project root (git\n * toplevel of the cwd; the cwd itself outside git). Its text is appended to the\n * worker's system prompt right after the contract, so a project's standing\n * rules ride on every worker started there.\n */\nimport { execFileSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport const PREAMBLE_REL = \".pai/worker.md\";\nexport const PREAMBLE_MAX_BYTES = 16 * 1024;\n\nexport interface Preamble {\n path: string;\n text: string;\n lines: number;\n hash: string;\n}\n\nexport type PreambleResult = { preamble: Preamble | null } | { refused: string };\n\nexport function projectRoot(cwd: string): string {\n try {\n return execFileSync(\"git\", [\"rev-parse\", \"--show-toplevel\"], {\n cwd,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n } catch {\n return cwd;\n }\n}\n\n/** Missing or empty file: no preamble. Over PREAMBLE_MAX_BYTES: refused, never truncated. */\nexport function loadPreamble(cwd: string): PreambleResult {\n const path = join(projectRoot(cwd), PREAMBLE_REL);\n if (!existsSync(path)) return { preamble: null };\n const size = statSync(path).size;\n if (size > PREAMBLE_MAX_BYTES) {\n return { refused: `${path} is ${size} bytes, over the ${PREAMBLE_MAX_BYTES} byte limit — shorten it` };\n }\n const text = readFileSync(path, \"utf8\");\n if (!text.trim()) return { preamble: null };\n const hash = createHash(\"sha256\").update(text).digest(\"hex\").slice(0, 8);\n return { preamble: { path, text: text.trim(), lines: text.trimEnd().split(\"\\n\").length, hash } };\n}\n\n/**\n * The system-prompt block: a fixed header plus the raw file text, nothing run-specific\n * (no ids, paths, hashes), so every worker of a project shares one cacheable prefix.\n */\nexport function preambleBlock(p: Preamble): string {\n return `## Project worker rules\\n\\n${p.text}`;\n}\n\nexport function preambleLine(p: Preamble | null): string {\n return p ? `preamble: ${PREAMBLE_REL} (${p.lines} lines)` : \"preamble: none\";\n}\n","/**\n * Status sink: write the session handover (\"## Continue\") into a forge issue\n * instead of Notes/TODO.md. Opt-in per project via `.pai/project.yaml`:\n *\n * status:\n * sink: forge # todo (default) | forge\n * forge:\n * anchor: 283 # issue number of the anchor\n * marker: CASELEAF-HANDOVER-ANCHOR-V1 # must occur in the anchor body\n * repo: OWNER/NAME # optional; default from `git remote get-url origin`\n *\n * Anchor format: the anchor body carries the line `handover: #<n>`, naming the\n * day's handover issue. If no such line exists, the first `#<n>` after the\n * marker is used. The handover issue body holds the section\n * `<!-- pai:continue --> ... <!-- /pai:continue -->`, replaced or appended.\n * Never comments, never closes. Token: config `forge.token`, else env\n * FORGE_TOKEN, else AIBROKER_FORGE_TOKEN; never printed.\n *\n * Synchronous (callers are hooks) via curl, 5 s budget for the whole write.\n */\nimport { execFileSync, spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { parse } from \"yaml\";\nimport { projectRoot } from \"../workers/preamble.js\";\nimport { readMainConfigRaw } from \"../daemon/config.js\";\n\nexport const PROJECT_CONFIG_REL = \".pai/project.yaml\";\nexport const SECTION_OPEN = \"<!-- pai:continue -->\";\nexport const SECTION_CLOSE = \"<!-- /pai:continue -->\";\nexport const FORGE_BUDGET_MS = 5000;\n\nexport interface StatusConfig {\n sink: \"todo\" | \"forge\";\n anchor?: number;\n marker?: string;\n repo?: string;\n}\n\nexport interface HttpResult { status: number; text: string }\n/** Injected in tests. Throws on transport failure. */\nexport type Http = (method: \"GET\" | \"PATCH\" | \"POST\" | \"DELETE\", url: string, token: string, body: string | undefined, timeoutMs: number) => HttpResult;\n\nexport class ForgeError extends Error {}\n\nexport function parseStatusConfig(text: string): StatusConfig {\n const doc = (parse(text) ?? {}) as { status?: { sink?: unknown; forge?: Record<string, unknown> } };\n const forge = doc.status?.forge ?? {};\n const anchor = Number(forge.anchor);\n return {\n sink: doc.status?.sink === \"forge\" ? \"forge\" : \"todo\",\n anchor: Number.isInteger(anchor) && anchor > 0 ? anchor : undefined,\n marker: typeof forge.marker === \"string\" && forge.marker ? forge.marker : undefined,\n repo: typeof forge.repo === \"string\" && forge.repo ? forge.repo : undefined,\n };\n}\n\nexport function loadStatusConfig(cwd: string): StatusConfig {\n const path = join(projectRoot(cwd), PROJECT_CONFIG_REL);\n if (!existsSync(path)) return { sink: \"todo\" };\n try {\n return parseStatusConfig(readFileSync(path, \"utf8\"));\n } catch (e) {\n throw new ForgeError(`${PROJECT_CONFIG_REL} unreadable (${(e as Error).message.split(\"\\n\")[0]})`);\n }\n}\n\n/** https://host/git/OWNER/REPO.git -> API base https://host/git/api/v1 + \"OWNER/REPO\". */\nexport function deriveRepo(originUrl: string): { apiBase: string; repo: string } {\n const m = originUrl.trim().match(/^(https?):\\/\\/(?:[^@/]+@)?([^/]+)\\/(.*?)\\/?$/);\n if (m) {\n const parts = m[3].replace(/\\.git$/, \"\").split(\"/\");\n if (parts.length >= 2) {\n const prefix = parts.slice(0, -2).join(\"/\");\n return { apiBase: `${m[1]}://${m[2]}${prefix ? `/${prefix}` : \"\"}/api/v1`, repo: parts.slice(-2).join(\"/\") };\n }\n }\n throw new ForgeError(\"cannot derive forge API from origin URL\");\n}\n\nfunction resolveToken(): string | undefined {\n try {\n const t = (readMainConfigRaw().forge as { token?: unknown } | undefined)?.token;\n if (typeof t === \"string\" && t) return t;\n } catch { /* unreadable config: fall through to env */ }\n return process.env.FORGE_TOKEN || process.env.AIBROKER_FORGE_TOKEN || undefined;\n}\n\n/** Real transport: curl; the token goes in on stdin so it never shows in ps. */\nexport const curlHttp: Http = (method, url, token, body, timeoutMs) => {\n const cfg = [\n `url = \"${url}\"`,\n `request = \"${method}\"`,\n `header = \"Authorization: token ${token}\"`,\n `header = \"Content-Type: application/json\"`,\n `max-time = ${Math.max(0.5, timeoutMs / 1000)}`,\n `silent`,\n `write-out = \"\\\\n%{http_code}\"`,\n ].join(\"\\n\");\n const argv = body !== undefined ? [\"-K\", \"-\", \"--data-raw\", body] : [\"-K\", \"-\"];\n const r = spawnSync(\"curl\", argv, { input: cfg, encoding: \"utf8\", timeout: timeoutMs + 500, maxBuffer: 16 * 1024 * 1024 });\n if (r.error || r.status !== 0) throw new ForgeError(`curl failed (${r.error?.message ?? `exit ${r.status}`})`);\n const at = r.stdout.lastIndexOf(\"\\n\");\n return { status: Number(r.stdout.slice(at + 1)), text: r.stdout.slice(0, at) };\n};\n\n/** `handover: #<n>` line wins; else the first `#<n>` after the marker. */\nexport function extractHandoverNumber(anchorBody: string, marker: string): number | undefined {\n const line = anchorBody.match(/^\\s*handover:\\s*#(\\d+)/im);\n if (line) return Number(line[1]);\n const after = anchorBody.slice(anchorBody.indexOf(marker) + marker.length).match(/#(\\d+)/);\n return after ? Number(after[1]) : undefined;\n}\n\n/** Replace the delimited section, or append it; everything else stays byte-identical. */\nexport function upsertSection(body: string, markdown: string, tag = \"continue\"): string {\n const open = tag === \"continue\" ? SECTION_OPEN : `<!-- pai:${tag} -->`;\n const close = tag === \"continue\" ? SECTION_CLOSE : `<!-- /pai:${tag} -->`;\n const section = `${open}\\n${markdown.trim()}\\n${close}`;\n const a = body.indexOf(open);\n const b = a === -1 ? -1 : body.indexOf(close, a);\n if (b !== -1) return body.slice(0, a) + section + body.slice(b + close.length);\n const sep = body === \"\" || body.endsWith(\"\\n\\n\") ? \"\" : body.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n return body + sep + section + \"\\n\";\n}\n\nexport interface ForgeDeps { http?: Http; token?: string; originUrl?: string; dryRun?: boolean }\n\ntype Method = \"GET\" | \"PATCH\" | \"POST\" | \"DELETE\";\n\n/** One forge repo + token + 5 s budget; dry run records mutating calls in `planned` instead of sending them. */\nfunction forgeClient(cwd: string, cfg: StatusConfig, deps: ForgeDeps) {\n const token = deps.token ?? resolveToken();\n if (!token) throw new ForgeError(\"no forge token\");\n const http = deps.http ?? curlHttp;\n let origin = deps.originUrl;\n if (!origin) {\n try {\n origin = execFileSync(\"git\", [\"remote\", \"get-url\", \"origin\"], { cwd, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] });\n } catch { throw new ForgeError(\"no origin remote\"); }\n }\n const derived = deriveRepo(origin);\n const repo = cfg.repo ?? derived.repo;\n const deadline = Date.now() + FORGE_BUDGET_MS;\n const planned: string[] = [];\n const call = (method: Method, path: string, body?: string): HttpResult => {\n if (deps.dryRun && method !== \"GET\") {\n planned.push(`${method} ${derived.apiBase}/repos/${repo}/${path}${body ? ` ${body}` : \"\"}`);\n return { status: 200, text: \"{}\" };\n }\n const left = deadline - Date.now();\n if (left < 300) throw new ForgeError(\"time budget exhausted\");\n let r: HttpResult;\n try { r = http(method, `${derived.apiBase}/repos/${repo}/${path}`, token, body, left); }\n catch (e) { throw e instanceof ForgeError ? e : new ForgeError(`request failed (${(e as Error).message})`); }\n if (r.status < 200 || r.status >= 300) throw new ForgeError(`HTTP ${r.status} on ${method} ${path}`);\n return r;\n };\n return { repo, call, planned };\n}\n\nfunction json<T>(r: HttpResult): T {\n try { return JSON.parse(r.text) as T; } catch { throw new ForgeError(\"unparseable forge response\"); }\n}\n\n/** Returns the issue number written (or, dry run, that would be). Throws ForgeError with the reason. */\nexport function writeContinueToForge(cwd: string, cfg: StatusConfig, markdown: string, deps: ForgeDeps = {}): { issue: number; body: string } {\n return writeSectionToForge(cwd, cfg, markdown, \"continue\", deps);\n}\n\n/** Replace/append section `tag` in the day's handover issue; the rest of the body is untouched. */\nexport function writeSectionToForge(cwd: string, cfg: StatusConfig, markdown: string, tag: string, deps: ForgeDeps = {}): { issue: number; body: string } {\n if (!cfg.anchor || !cfg.marker) throw new ForgeError(\"status.forge.anchor/marker missing\");\n const { call } = forgeClient(cwd, cfg, deps);\n const bodyOf = (n: number): string => String(json<{ body?: unknown }>(call(\"GET\", `issues/${n}`)).body ?? \"\");\n const anchorBody = bodyOf(cfg.anchor);\n if (!anchorBody.includes(cfg.marker)) throw new ForgeError(`anchor #${cfg.anchor} lacks marker`);\n const handover = extractHandoverNumber(anchorBody, cfg.marker);\n if (!handover) throw new ForgeError(`no handover number in anchor #${cfg.anchor}`);\n const next = upsertSection(bodyOf(handover), markdown, tag);\n if (!deps.dryRun) call(\"PATCH\", `issues/${handover}`, JSON.stringify({ body: next }));\n return { issue: handover, body: next };\n}\n\n// Claim convention (identical on the AIBroker side): assignee CLAIM_ASSIGNEE + label CLAIM_LABEL.\n// PAI never closes issues.\nexport const CLAIM_ASSIGNEE = \"claude\";\nexport const CLAIM_LABEL = \"in-progress\";\n\nexport interface ClaimResult { repo: string; issue: number; message: string; planned: string[] }\nexport interface ClaimRecord { issue: number; repo: string; at: string }\n\ninterface IssueView { assignees?: Array<{ login: string }> | null; labels?: Array<{ id: number; name: string }> | null }\n\n/** Claim (add=true) or release (add=false) issue `n`; other assignees and labels are left alone. */\nexport function setClaim(cwd: string, cfg: StatusConfig, n: number, add: boolean, deps: ForgeDeps = {}): ClaimResult {\n const { repo, call, planned } = forgeClient(cwd, cfg, deps);\n const issue = json<IssueView>(call(\"GET\", `issues/${n}`));\n const logins = (issue.assignees ?? []).map((a) => a.login);\n const next = add ? [...new Set([...logins, CLAIM_ASSIGNEE])] : logins.filter((l) => l !== CLAIM_ASSIGNEE);\n if (next.length !== logins.length || next.some((l, i) => l !== logins[i])) {\n call(\"PATCH\", `issues/${n}`, JSON.stringify({ assignees: next }));\n }\n const verb = add ? \"claimed\" : \"released\";\n let message = `${verb} ${repo}#${n}`;\n const has = (issue.labels ?? []).find((l) => l.name === CLAIM_LABEL);\n if (add && !has) {\n const label = json<Array<{ id: number; name: string }>>(call(\"GET\", \"labels?limit=100\")).find((l) => l.name === CLAIM_LABEL);\n if (label) call(\"POST\", `issues/${n}/labels`, JSON.stringify({ labels: [label.id] }));\n else message += ` (assignee only: label \"${CLAIM_LABEL}\" does not exist in ${repo})`;\n } else if (!add && has) {\n call(\"DELETE\", `issues/${n}/labels/${has.id}`);\n }\n return { repo, issue: n, message, planned };\n}\n\n/** Open issues in the repo currently carrying the claim label. */\nexport function listClaims(cwd: string, cfg: StatusConfig, deps: ForgeDeps = {}): Array<{ issue: number; title: string; assignees: string[] }> {\n const { call } = forgeClient(cwd, cfg, deps);\n const rows = json<Array<{ number: number; title: string; pull_request?: unknown } & IssueView>>(\n call(\"GET\", `issues?state=open&type=issues&labels=${CLAIM_LABEL}&limit=50`),\n );\n return rows.map((r) => ({ issue: r.number, title: r.title, assignees: (r.assignees ?? []).map((a) => a.login) }));\n}\n\n/** Release every claim best-effort; returns the per-issue errors (never throws). */\nexport function releaseClaims(cwd: string, claims: ClaimRecord[], deps: ForgeDeps = {}): string[] {\n const errors: string[] = [];\n for (const c of claims) {\n try { setClaim(cwd, { ...loadStatusConfig(cwd), repo: c.repo }, c.issue, false, deps); }\n catch (e) { errors.push(`${c.repo}#${c.issue}: ${(e as Error).message}`); }\n }\n return errors;\n}\n\n// ---- stale report: open issues that landed in the integration branch or went idle ----\n\nexport type Git = (args: string[]) => string;\nexport interface StaleRow { issue: number; title: string; kind: \"landed\" | \"idle\"; via?: string; idleDays: number; claim: string[] }\nexport interface StaleDeps extends ForgeDeps { git?: Git; now?: number }\n\n/** One shared sink for the CLI/MCP report and the daemon section. */\nexport function formatStale(rows: StaleRow[]): string {\n if (!rows.length) return \"No stale issues.\";\n return rows\n .map((r) => `- #${r.issue} ${r.title} - ${r.kind === \"landed\" ? `landed via ${r.via}` : `idle ${r.idleDays} days`}${r.claim.length ? ` [${r.claim.join(\", \")}]` : \"\"}`)\n .join(\"\\n\");\n}\n\n/**\n * Open issues that either landed or idle >= days. Landed first, then idle by age.\n * Landed (deterministic; a plain mention like \"see #283\" never counts):\n * (a) a branch merged into the integration branch whose name has <n> as a whole token (split on / - _ .), or\n * (b) an integration-branch commit whose subject has a closing reference (fixes|closes|resolves #<n>).\n * A trailing \"(#<n>)\" is a plain reference and does not count. The configured anchor issue is never listed.\n */\nexport function listStale(cwd: string, cfg: StatusConfig, days = 7, deps: StaleDeps = {}): StaleRow[] {\n const { call } = forgeClient(cwd, cfg, deps);\n const git: Git = deps.git ?? ((a) => execFileSync(\"git\", a, { cwd, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"], maxBuffer: 64 * 1024 * 1024 }));\n const gitTry = (a: string[]): string => { try { return git(a); } catch { return \"\"; } };\n type Row = { number: number; title: string; updated_at: string } & IssueView;\n const rows: Row[] = [];\n for (let page = 1; page <= 10; page++) {\n const chunk = json<Row[]>(call(\"GET\", `issues?state=open&type=issues&limit=50&page=${page}`));\n rows.push(...chunk);\n if (chunk.length < 50) break;\n }\n const refs = new Set(gitTry([\"for-each-ref\", \"--format=%(refname:short)\"]).split(\"\\n\"));\n let integ = [\"develop\", \"origin/develop\"].find((b) => refs.has(b));\n if (!integ) {\n let def = \"main\";\n try { def = json<{ default_branch?: string }>(call(\"GET\", \"\")).default_branch || \"main\"; } catch { /* repo info unavailable: main */ }\n integ = refs.has(def) ? def : refs.has(`origin/${def}`) ? `origin/${def}` : def;\n }\n const tip = gitTry([\"rev-parse\", integ]).trim();\n const merged = gitTry([\"branch\", \"-a\", \"--merged\", integ, \"--format=%(refname:short) %(objectname)\"])\n .split(\"\\n\").map((l) => l.trim().split(\" \")).filter(([n, sha]) => n && sha && sha !== tip && n !== integ && !n.endsWith(\"/HEAD\") && n !== `origin/${integ}`)\n .map(([n]) => n);\n const now = deps.now ?? Date.now();\n const out: StaleRow[] = [];\n for (const r of rows) {\n const n = r.number;\n if (n === cfg.anchor) continue;\n const idleDays = Math.floor((now - Date.parse(r.updated_at)) / 86_400_000);\n const claim = [...((r.assignees ?? []).some((a) => a.login === CLAIM_ASSIGNEE) ? [`assignee ${CLAIM_ASSIGNEE}`] : []), ...((r.labels ?? []).some((l) => l.name === CLAIM_LABEL) ? [CLAIM_LABEL] : [])];\n const branch = merged.find((b) => b.split(/[/\\-_.]/).includes(String(n)));\n const closing = new RegExp(`\\\\b(fixes|fix|closes|close|resolves|resolve)\\\\s+#${n}\\\\b`, \"i\");\n const commit = branch ? undefined : gitTry([\"log\", integ, \"-E\", `--grep=#${n}([^0-9]|$)`, \"--format=%h %s\"]).split(\"\\n\").find((l) => closing.test(l.slice(l.indexOf(\" \") + 1)));\n if (branch || commit) out.push({ issue: n, title: r.title, kind: \"landed\", via: branch ?? `commit ${commit}`, idleDays, claim });\n else if (idleDays >= days) out.push({ issue: n, title: r.title, kind: \"idle\", idleDays, claim });\n }\n return out.sort((a, b) => (a.kind === b.kind ? b.idleDays - a.idleDays : a.kind === \"landed\" ? -1 : 1));\n}\n","/**\n * status.ts — the live per-worker status file.\n *\n * One JSON file per run, rewritten atomically on every turn, read by `ps`,\n * `follow`, the status line and the pane logic. Same field set the Python\n * runner wrote, plus `provider` (routing is multi-provider now) and `session`\n * (the AIBroker identity of the launching session, see scope.ts).\n */\n\nimport { execFileSync } from \"node:child_process\";\nimport {\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { shortText } from \"./args.js\";\nimport { statusPath } from \"./paths.js\";\nimport { releaseClaims, type ClaimRecord } from \"../session/forge-sink.js\";\nimport type { WaitingOn } from \"./waiting.js\";\nimport type { Denial } from \"./denials.js\";\n\nexport interface WorkerSessionRef {\n /** AIBroker/iTerm session id (the iTerm UUID). */\n id: string;\n /** AIBroker name of that session, when it has one. */\n name: string;\n}\n\nexport interface WorkerStatus {\n id: string;\n pid: number;\n label: string;\n cwd: string;\n /** iTerm session id of the launching terminal (\"\" outside iTerm). */\n term: string;\n provider: string;\n model: string;\n state: \"running\" | \"done\" | \"failed\" | \"killed\" | \"lost\";\n started: string;\n updated: string;\n turns: number;\n tools: number;\n last: string;\n rc: number | null;\n secs: number | null;\n /** Launching session resolved through AIBroker, when it was. */\n session?: WorkerSessionRef | null;\n /** Claude Code session id (system/init) — what `resume` continues. */\n claudeSession?: string | null;\n /**\n * Claude Code session id of the orchestrator whose Bash launched this run,\n * when the status line's session map knew it (see scope.ts). Distinct from\n * claudeSession, which is the run's own session.\n */\n spawnerSession?: string | null;\n /** Follow-pane outcome of the run start: opened, or why not. */\n pane?: { opened: boolean; reason?: string; session?: string } | null;\n /** Context meter: tokens of the last assistant turn (input+cache+output). */\n contextTokens?: number | null;\n /** Current context fill: input+cache_read+cache_creation of the latest assistant turn. */\n contextUsed?: number | null;\n /** Context meter: window size (init model info or provider default). */\n contextWindow?: number | null;\n /** Path the prompt was read from via --spec (\"-\" for stdin), when it was. */\n spec?: string | null;\n /**\n * Caller's --output-format, when the run was headless. A json/stream-json\n * caller reads its own result and is notified on process exit by the\n * harness — supervision.ts uses this to skip the duplicate relay send.\n */\n outputFormat?: \"text\" | \"json\" | \"stream-json\";\n /** Chain this stage belongs to (the chain id), when it is a chain stage. */\n parent?: string;\n /** Class name of the chain stage (\"draft\", \"implement\", …). */\n stage?: string;\n /** Worktree this run executed in, when it got one (see worktree.ts). */\n worktreeDir?: string | null;\n /** Branch the worker committed on (worker/<id>), set on worktree runs. */\n branch?: string | null;\n /** Set on a resumed worker: the id whose worktree it took over (see worktree.ts adoptTree). */\n resumedFrom?: string;\n /** Set on the old id when a resume took its worktree: that id owns the tree now. */\n resumedBy?: string;\n /** Commit the branch started from (worktree base) for the commits count. */\n worktreeBase?: string | null;\n /** Whether `worktreeBase` is a snapshot of uncommitted checkout state, not HEAD. */\n worktreeSnapshot?: boolean | null;\n /** Commits the worker made on its branch; set with `branch` on success. */\n commits?: number | null;\n /** Set by `pai worker merge` once the branch landed in the original checkout. */\n merged?: boolean;\n /** Set by `pai worker gc`: the hidden ref (refs/pai-archive/<id>) holding the leftover worktree's state. */\n archived?: string | null;\n /**\n * How the run came to be: \"spawn\" (a `pai worker run` subagent) or \"chat\"\n * (the terminal's interactive pane itself, tracked like a worker). Absent\n * on statuses written before the flag existed — read as a spawn.\n */\n origin?: \"spawn\" | \"chat\";\n /** Where the routing policy sent this run and why (policy.ts); absent without a policy. */\n route?: { policy: string; reason: string; local: boolean };\n /** Fall-through link: the local run this cloud run repeats, and (on the local run) its repeat. */\n fallThroughOf?: string;\n fallThroughTo?: string;\n /** Which contract/parser this run used for its final report (see report.ts). */\n reportFormat?: \"json\" | \"ag2\";\n /** Whether the final AG2 report passed `aibroker agentish check`; unset for json reports or when no validator ran. */\n reportValid?: boolean;\n /** Validation error messages, when reportValid is false. */\n reportErrors?: string[];\n /** Whether the headless prompt got the end-of-turn \"final message must be…\" trailer line. */\n promptTrailer?: boolean;\n /** The project preamble (.pai/worker.md) appended to this run's prompt: path + short content hash. */\n preamble?: { path: string; hash: string };\n /** The provider contract addendum appended to this run's prompt: path + sha256 prefix. */\n contractAddendum?: { path: string; sha: string };\n /** Whether an invalid AG2 final message triggered the one bounded re-ask (see run.ts). */\n reportRetried?: boolean;\n /**\n * Consecutive failed tool executions in this run, maintained by the runner's\n * stream loop (0 after any success). Absent on old status files — every\n * reader must treat that as \"no signal\".\n */\n consecFails?: number | null;\n /** Hook/permission denials the run hit (capped list, see denials.ts) and their true total. */\n denials?: Denial[];\n denialCount?: number;\n /**\n * Seconds of the most recent single long sleep observed in a Bash tool_use\n * (see parseSleepSecs), cleared when the command completes. Absent on old\n * status files.\n */\n sleepSec?: number | null;\n /** Epoch ms the run is stopped at (deadline.ts); absent = no limit. */\n deadlineAt?: number | null;\n /** Limit in minutes the deadline was derived from. */\n maxMinutes?: number | null;\n /** The deadline stopped this run (state failed, `last` says why). */\n timedOut?: boolean;\n /** Launching process (the parent of `pai worker run`) at start, and its command name. */\n parentPid?: number;\n parentComm?: string;\n parentBackground?: boolean;\n /** Why the run ended (endreason.ts): exit, deadline, pai-worker-kill, parent-gone, external-signal. */\n endReason?: string;\n /** Who asked for the stop, when known (kill caller, daemon:<reason>). */\n endBy?: string;\n /** Detail for the reason (signal, sender note). */\n endNote?: string;\n /**\n * What the worker is blocked on right now: written by `pai worker wait-on`\n * while it waits (null once it returns), rendered by waiting.ts.\n */\n waitingOn?: WaitingOn | null;\n /** Forge issues this worker claimed (`pai issue claim` inside it); released when it ends unless claimsContinue. */\n claims?: ClaimRecord[];\n /** The final report said the work continues (r=~): claims stay. Set by finaliseRun before the end write. */\n claimsContinue?: boolean;\n /** Per-issue errors from the best-effort release at worker end. */\n claimReleaseErrors?: string[];\n /** Ever granted clickr desktop controls (see controls.ts) — the runner returns them best-effort on exit. */\n controlsHeld?: boolean;\n /**\n * Set when the task ran through the worker session pool (pool.ts) instead\n * of a fresh claude spawn: task index within its slot, the slot's claude\n * session id (shared across tasks), and the host pid. `pid` names the slot\n * process — killing it kills the whole slot, not just this task.\n */\n pool?: { task: number; slotSession: string | null; hostPid: number };\n}\n\n/** Label a worker gets when launched with neither --label nor a prompt. */\nexport const UNLABELED = \"unlabeled\";\n\n/**\n * Whether a status is the terminal's interactive chat pane, not a spawned\n * task worker. `origin` is the real discriminator; the fallback catches\n * running entries from before the flag existed (unlabeled, no turns yet).\n * Removable once every pane runs code that writes `origin`.\n */\nexport function isChatPane(s: Pick<WorkerStatus, \"origin\" | \"label\" | \"turns\">): boolean {\n return (\n s.origin === \"chat\" ||\n (!s.origin && (s.label === UNLABELED || s.label === \"(no prompt)\") && s.turns === 0)\n );\n}\n\n/** Context-meter percentage 0–100, null when the numbers are missing. */\nexport function contextPercent(s: Pick<WorkerStatus, \"contextTokens\" | \"contextWindow\">): number | null {\n if (!s.contextTokens || !s.contextWindow) return null;\n return Math.round((s.contextTokens / s.contextWindow) * 100);\n}\n\n/** Compact token count: 84k, 200k, 900. */\nexport function fmtContextK(n: number): string {\n return n >= 1000 ? `${Math.round(n / 1000)}k` : String(n);\n}\n\n/** Footer token count: 48k, 1M, 1.5M. */\nexport function fmtTokens(n: number): string {\n if (n >= 1_000_000) return `${Number((n / 1_000_000).toFixed(1))}M`;\n return fmtContextK(n);\n}\n\n/** `<used> / <window>`, or just `<used>` when the window is unknown; \"\" with no reading. */\nexport function contextFooter(s: Pick<WorkerStatus, \"contextUsed\" | \"contextWindow\">): string {\n if (!s.contextUsed) return \"\";\n return s.contextWindow ? `${fmtTokens(s.contextUsed)} / ${fmtTokens(s.contextWindow)}` : fmtTokens(s.contextUsed);\n}\n\n/**\n * The one context-meter label, shared by every renderer so identical\n * numbers always render identically: `ctx 84k/200k (42%)` — used-style\n * percent. Empty when the numbers are missing (callers drop the part).\n */\nexport function contextLabel(\n s: Pick<WorkerStatus, \"contextTokens\" | \"contextWindow\">\n): string {\n const pct = contextPercent(s);\n if (pct === null) return \"\";\n return `ctx ${fmtContextK(s.contextTokens ?? 0)}/${fmtContextK(s.contextWindow ?? 0)} (${pct}%)`;\n}\n\n/** Timestamp format shared by status files and the ledger. */\nexport function nowStamp(d: Date = new Date()): string {\n const p = (n: number) => String(n).padStart(2, \"0\");\n return (\n `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ` +\n `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`\n );\n}\n\n// second-resolution ids repeat when two workers/chains start together in one\n// process; a repeat gets a monotonic suffix so files never collide\nlet lastId = \"\";\nlet idSeq = 0;\n\nexport function newWorkerId(d: Date = new Date(), pid = process.pid): string {\n const p = (n: number) => String(n).padStart(2, \"0\");\n const base = `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}-${pid}`;\n if (base === lastId) {\n idSeq += 1;\n return `${base}-${String(idSeq).padStart(2, \"0\")}`;\n }\n lastId = base;\n idSeq = 0;\n return base;\n}\n\n// Temp names must be unique per writer, not just per worker: two processes\n// legitimately write the same id at the same moment (`pai worker kill` marking\n// a run killed while the run's own SIGTERM handler writes its terminal state).\n// With one shared `<id>.status.tmp` they clobber each other's temp file and the\n// loser's rename fails with ENOENT — observed live on 2026-09-19.\nlet tmpSeq = 0;\n\n/** A temp path only this call owns — never the same string twice. */\nexport function statusTmpPath(logDir: string, id: string): string {\n return `${statusPath(logDir, id)}.${process.pid}.${tmpSeq++}.tmp`;\n}\n\n// The label this process first wrote for a given worker id: run.ts holds one\n// unchanging label in memory for the whole run and passes it to every\n// periodic saveStatus call, so a later call whose label still equals this\n// baseline is that unmodified write, never an intentional change — on-disk\n// then wins, so an external `pai worker goal` relabel between two of a\n// worker's own writes survives instead of being reverted by the next one. A\n// call whose label differs from the baseline (or the first call for an id in\n// this process, which has no baseline yet) IS the intentional change and\n// always wins — exactly the one-shot `pai worker goal` process itself.\nconst firstWrittenLabel = new Map<string, string>();\n\n/** Write status atomically (temp + rename) and stamp `updated`. */\nexport function saveStatus(logDir: string, status: WorkerStatus, d: Date = new Date()): void {\n status.updated = nowStamp(d);\n const path = statusPath(logDir, status.id);\n const baseline = firstWrittenLabel.get(status.id);\n if (baseline === undefined) {\n firstWrittenLabel.set(status.id, status.label);\n }\n const onDisk = baseline === undefined ? undefined : loadStatus(logDir, status.id);\n if (onDisk) {\n if (status.label === baseline && onDisk.label !== status.label) status.label = onDisk.label;\n // Set by another process (`pai worker controls`); a true flag is never dropped by a stale in-memory copy.\n if (onDisk.controlsHeld) status.controlsHeld = true;\n // Written by `pai worker wait-on` (another process); the runner's in-memory copy never knows it.\n if (status.waitingOn === undefined && onDisk.waitingOn) status.waitingOn = onDisk.waitingOn;\n // Recorded by `pai issue claim` (another process).\n if (status.claims === undefined && onDisk.claims) status.claims = onDisk.claims;\n }\n // The one owner of \"an ended worker holds no claims\" (like its pane, below): every end path saves through here.\n if (status.state !== \"running\" && status.claims?.length && !status.claimsContinue) {\n const errors = releaseClaims(status.cwd, status.claims);\n status.claims = [];\n if (errors.length) {\n status.claimReleaseErrors = errors;\n process.stderr.write(`claim release failed: ${errors.join(\"; \")}\\n`);\n }\n }\n const tmp = statusTmpPath(logDir, status.id);\n if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });\n try {\n writeFileSync(tmp, JSON.stringify(status), \"utf8\");\n renameSync(tmp, path);\n } catch (e) {\n try {\n rmSync(tmp, { force: true });\n } catch {\n // nothing to clean up\n }\n throw e;\n }\n}\n\n/**\n * Set a worker's goal (the operator's `--label`), atomically, through the\n * same saveStatus path everything else writes with. Used by `pai worker\n * goal` and the `--goal` option of `say`: a fresh call in a fresh process, so\n * it always carries no baseline yet and always wins over the worker's own\n * next periodic write (see saveStatus above).\n */\nexport function setWorkerLabel(logDir: string, id: string, label: string): WorkerStatus {\n const status = loadStatus(logDir, id);\n if (!status) throw new Error(`no worker named \"${id}\"`);\n status.label = label;\n saveStatus(logDir, status);\n return status;\n}\n\n/** Load every status file in the logDir, oldest id first, skipping damage. */\nexport function loadStatuses(logDir: string): WorkerStatus[] {\n if (!existsSync(logDir)) return [];\n const out: WorkerStatus[] = [];\n for (const name of readdirSync(logDir).sort()) {\n if (!name.endsWith(\".status\")) continue;\n try {\n out.push(JSON.parse(readFileSync(join(logDir, name), \"utf8\")) as WorkerStatus);\n } catch {\n // a half-written or damaged status file is not worth a crash\n }\n }\n return out;\n}\n\nexport function loadStatus(logDir: string, id: string): WorkerStatus | null {\n const path = statusPath(logDir, id);\n if (!existsSync(path)) return null;\n try {\n return JSON.parse(readFileSync(path, \"utf8\")) as WorkerStatus;\n } catch {\n return null;\n }\n}\n\n/**\n * Wait for a worker to record its own terminal state (the run's signal\n * handler writes killed/rc/secs). Returns that status, or null when it is\n * still \"running\" after `timeoutMs` — the caller then writes the state itself.\n */\nexport async function waitForTerminalStatus(\n logDir: string,\n id: string,\n timeoutMs = 2000,\n stepMs = 50\n): Promise<WorkerStatus | null> {\n const deadline = Date.now() + timeoutMs;\n for (;;) {\n const s = loadStatus(logDir, id);\n if (s && s.state !== \"running\") return s;\n if (Date.now() >= deadline) return null;\n await new Promise((r) => setTimeout(r, stepMs));\n }\n}\n\nexport function alive(pid: number | null | undefined): boolean {\n if (!pid || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Whether `status.pid` still names the process that was started as this\n * worker, not a later, unrelated process the OS handed the same pid to after\n * the worker exited. `alive()` alone can't tell these apart — a pid observed\n * live on 2026-09-19 (worker 20260919-083549-90913) had been reused, and\n * `pai worker kill` signalled the wrong, unrelated process. `ps -o lstart=`\n * reads the running process's actual start time and compares it against the\n * status file's own `started` stamp; a reused pid almost never starts within\n * 120s of the original, so a wider drift means \"different process\".\n */\nexport function ownsPid(status: Pick<WorkerStatus, \"pid\" | \"started\">): boolean {\n if (status.pid <= 0 || !alive(status.pid)) return false;\n try {\n const out = execFileSync(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(status.pid)], {\n encoding: \"utf8\",\n env: { ...process.env, LC_ALL: \"C\" },\n }).trim();\n const psStart = Date.parse(out);\n const started = Date.parse(status.started.replace(\" \", \"T\"));\n if (Number.isNaN(psStart) || Number.isNaN(started)) return alive(status.pid);\n return Math.abs(psStart - started) <= 120_000;\n } catch {\n // pid exited between the alive() check and the ps call, or ps failed for\n // another reason — the pid-existence check is still better than nothing.\n return alive(status.pid);\n }\n}\n\n/** Whether a status is both marked \"running\" and still owns its recorded pid. */\nexport function isLive(status: Pick<WorkerStatus, \"pid\" | \"started\" | \"state\">): boolean {\n return status.state === \"running\" && ownsPid(status);\n}\n\n/** \"42s\" under 90s, \"7m\" above — the coarse age the table and bar show. */\nexport function ageOf(ts: string, now: Date = new Date()): string {\n const t = Date.parse(ts.replace(\" \", \"T\"));\n if (Number.isNaN(t)) return \"?\";\n const s = Math.max(0, Math.floor((now.getTime() - t) / 1000));\n return s < 90 ? `${s}s` : `${Math.floor(s / 60)}m`;\n}\n\n/** Precise elapsed time: \"45s\", \"1m 23s\", \"12m 05s\", \"1h 02m 05s\" — seconds zero-padded after a larger unit. */\nexport function elapsedOf(ts: string, now: Date = new Date()): string {\n const t = Date.parse(ts.replace(\" \", \"T\"));\n if (Number.isNaN(t)) return \"?\";\n const secs = Math.max(0, Math.floor((now.getTime() - t) / 1000));\n const hours = Math.floor(secs / 3600);\n const mins = Math.floor((secs % 3600) / 60);\n const sec = secs % 60;\n if (hours > 0) return `${hours}h ${String(mins).padStart(2, \"0\")}m ${String(sec).padStart(2, \"0\")}s`;\n if (mins > 0) return `${mins}m ${String(sec).padStart(2, \"0\")}s`;\n return `${sec}s`;\n}\n\n/** Shorter sleeps are legitimate polling — not worth a supervision event. */\nexport const SLEEP_FLOOR_SECS = 60;\n\nconst SLEEP_RE = /^\\s*sleep\\s+([0-9]+(?:\\.[0-9]+)?)([smhd]?)\\s*(?:$|[;&|])/;\n\n/** s/m/h/d suffix to seconds multiplier, shared by every `sleep N<unit>` parse below. */\nfunction sleepUnitMultiplier(unit: string): number {\n return unit === \"m\" ? 60 : unit === \"h\" ? 3600 : unit === \"d\" ? 86_400 : 1;\n}\n\n/**\n * Seconds of a `sleep N` (N plain or with an s/m/h/d suffix) that stands alone\n * or leads a compound command (`sleep 150; cat f`, `sleep 2m && tail f`,\n * `sleep 90 || true`, `sleep 60 &`), or null when no long sleep leads: anchored\n * to the start of the command, so a filename containing \"sleep\" or an\n * `echo sleep 500` never trips it, and floored at SLEEP_FLOOR_SECS so ordinary\n * polling stays invisible.\n */\nexport function parseSleepSecs(command: string): number | null {\n const m = command.match(SLEEP_RE);\n if (!m) return null;\n const secs = Number(m[1]) * sleepUnitMultiplier(m[2]);\n return Number.isFinite(secs) && secs >= SLEEP_FLOOR_SECS ? secs : null;\n}\n\n/**\n * Every command-segment boundary a shell recognises before a new simple\n * command can start: the very start of the string, `;`, `&`/`&&`, `|`/`||`,\n * a newline, an opening `(` or `{` (also covers `$(...)`, which ends in `(`),\n * or the keywords `do`/`then`. Segment end is the mirror image plus a closing\n * `)`, so `sleep 90` inside `$(sleep 90)` or `(sleep 90)` still counts.\n */\n// The terminator is a lookahead, not a consumed match: two sleeps sharing one\n// separator (`sleep 65; sleep 590`) both need that `;` available as their own\n// boundary — matchAll never revisits a character a previous match consumed.\nconst SLEEP_SEGMENT_RE =\n /(?:^|[;&|\\n(){]|\\bdo\\b|\\bthen\\b)\\s*sleep\\s+([0-9]+(?:\\.[0-9]+)?)([smhd]?)(?=\\s*(?:$|[;&|)\\n]))/g;\n\n/**\n * The longest `sleep N` found as its OWN command segment anywhere in\n * `command` — not just leading it, unlike {@link parseSleepSecs} — or null\n * when none reaches SLEEP_FLOOR_SECS. Used by the PreToolUse Bash gate\n * (block-sleep-poll.ts), which must catch a sleep buried after `&&`, inside a\n * `do ... done` loop, or in a subshell, not only one that leads the command.\n */\nexport function longestSleepSecs(command: string): number | null {\n let longest: number | null = null;\n for (const m of command.matchAll(SLEEP_SEGMENT_RE)) {\n const secs = Number(m[1]) * sleepUnitMultiplier(m[2]);\n if (!Number.isFinite(secs) || secs < SLEEP_FLOOR_SECS) continue;\n if (longest === null || secs > longest) longest = secs;\n }\n return longest;\n}\n\nconst LOOP_RE = /\\b(for|while|until)\\b([^;\\n]*)[;\\n]\\s*do\\b([\\s\\S]*?)\\bdone\\b/g;\n\nfunction sleepSum(text: string): number {\n let sum = 0;\n for (const m of text.matchAll(SLEEP_SEGMENT_RE)) {\n const secs = Number(m[1]) * sleepUnitMultiplier(m[2]);\n if (Number.isFinite(secs)) sum += secs;\n }\n return sum;\n}\n\n/** Iterations of a `for x in <words>` header, or null when not provably small. */\nfunction forIterations(header: string): number | null {\n const words = header.replace(/^\\s*\\w+\\s+in\\s+/, \"\").trim();\n if (words === header.trim() || /[$`*?]/.test(words)) return null;\n const range = /^\\{(-?\\d+)\\.\\.(-?\\d+)\\}$/.exec(words);\n if (range) return Math.abs(Number(range[2]) - Number(range[1])) + 1;\n return words ? words.split(/\\s+/).length : 0;\n}\n\n/**\n * Total sleep of one Bash command: every `sleep N` segment counted once, plus\n * loop repetition — `for x in a b c` multiplies its body by the word count;\n * `while`/`until` and any unbounded `for` count as at least SLEEP_FLOOR_SECS,\n * except a `kill -0` job-wait (the sanctioned wait-for-a-job loop). Used by\n * the PreToolUse gate so `sleep 58; sleep 58` is caught as the 116 s it is.\n */\n// ponytail: loops are not nested-aware (body ends at the first `done`); upgrade to a real shell parse if that bites.\nexport function totalSleepSecs(command: string): number {\n let total = sleepSum(command);\n for (const m of command.matchAll(LOOP_RE)) {\n const body = sleepSum(m[3]);\n if (body === 0) continue;\n if (m[1] === \"for\") {\n const n = forIterations(m[2]);\n total += n === null ? Math.max(SLEEP_FLOOR_SECS, body) : body * (n - 1);\n } else if (!/\\bkill\\s+-0\\b/.test(m[2])) {\n total += SLEEP_FLOOR_SECS;\n }\n }\n return total;\n}\n\n/** One-line description of a tool call, e.g. \"Bash: npm test\". */\nexport function describeTool(name: string, inp: unknown): string {\n if (typeof inp !== \"object\" || inp === null) return name;\n const i = inp as Record<string, unknown>;\n const get = (k: string) => (typeof i[k] === \"string\" ? (i[k] as string) : \"\");\n if (name === \"Bash\") return `Bash: ${shortText(get(\"command\"), 70)}`;\n if (name === \"Read\" || name === \"Edit\" || name === \"Write\" || name === \"MultiEdit\") {\n const file = get(\"file_path\").split(\"/\").pop() ?? \"\";\n return `${name}: ${file}`;\n }\n if (name === \"Grep\" || name === \"Glob\") return `${name}: ${shortText(get(\"pattern\"), 50)}`;\n if (name === \"WebSearch\") return `${name}: ${shortText(get(\"query\"), 50)}`;\n if (name === \"WebFetch\") return `${name}: ${shortText(get(\"url\"), 60)}`;\n return name;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,cAAc,QAA+B;CAC3D,MAAM,WAAW,WAAW,OAAO,OAAO;AAC1C,KAAI,OAAO,WAAW,gBAAiB,QAAO;AAC9C,QAAO,eAAe,YAAY,QAAQ,UAAU,EAAE,CAAC,SAAS,EAAE,4BAA4B;;;AAIhG,SAAgB,kBAAkB,QAAwB;CACxD,MAAM,OAAO,gBAAgB,OAAO;AACpC,KAAI,CAAC,WAAW,KAAK,EAAE;AACrB,YAAU,QAAQ,EAAE,WAAW,MAAM,CAAC;AACtC,gBAAc,MAAM,4BAA0B,OAAO;;AAEvD,QAAO;;AAGT,SAAgB,WAAW,QAAgB,IAAoB;AAC7D,QAAO,KAAK,QAAQ,GAAG,GAAG,SAAS;;AAGrC,SAAgB,WAAW,QAAgB,IAAoB;AAC7D,QAAO,KAAK,QAAQ,GAAG,GAAG,QAAQ;;AAGpC,SAAgB,WAAW,QAAwB;AACjD,QAAO,KAAK,QAAQ,aAAa;;AAGnC,SAAgB,iBAAiB,QAAwB;AACvD,QAAO,KAAK,QAAQ,qBAAqB;;AAG3C,SAAgB,SAAS,QAAwB;AAC/C,QAAO,KAAK,QAAQ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AY,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI;AAGpD,KAAI,SAAS,UAAU,SAAS,OAAQ,QAAO,GAAG,KAAK,IAAI,UAAU,IAAI,UAAU,EAAE,GAAG;AACxF,KAAI,SAAS,YAAa,QAAO,GAAG,KAAK,IAAI,UAAU,IAAI,QAAQ,EAAE,GAAG;AACxE,KAAI,SAAS,WAAY,QAAO,GAAG,KAAK,IAAI,UAAU,IAAI,MAAM,EAAE,GAAG;AACrE,QAAO"}
@@ -1,4 +0,0 @@
1
- import "./config-DSdCEcHS.mjs";
2
- import { $ as writeWorkersYamlText, B as WORKERS_YAML_FILENAME, G as needsWorkersYamlRelocation, H as initWorkersYaml, J as relocateWorkersYaml, K as parseWorkersYamlDocument, Q as writeWorkersYaml, U as inlineWorkersYamlKeys, V as buildWorkersYamlText, W as migrateWorkersToYaml, X as workersYamlLegacyNotice, Y as starterWorkersYamlText, Z as workersYamlPath, q as readWorkersYaml } from "./config-2pR0RqHM.mjs";
3
-
4
- export { workersYamlPath };