@tekmidian/pai 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chain-OzYgALdx.mjs → chain-Cltx0NjY.mjs} +4 -4
- package/dist/{chain-OzYgALdx.mjs.map → chain-Cltx0NjY.mjs.map} +1 -1
- package/dist/cli/index.mjs +9 -9
- package/dist/cli/program.mjs +9 -9
- package/dist/{context-handover-cache-k2kWbE6G.mjs → context-handover-cache-Dt4HW1Ro.mjs} +3 -3
- package/dist/{context-handover-cache-k2kWbE6G.mjs.map → context-handover-cache-Dt4HW1Ro.mjs.map} +1 -1
- package/dist/daemon/index.mjs +7 -7
- package/dist/{daemon-D8zXReoA.mjs → daemon-B6hx1Ysz.mjs} +7 -7
- package/dist/{daemon-Caxrq2iQ.mjs → daemon-CmqJfeb9.mjs} +24 -14
- package/dist/daemon-CmqJfeb9.mjs.map +1 -0
- package/dist/daemon-mcp/index.mjs +5 -5
- package/dist/{fallback-CiG573uw.mjs → fallback-B_2ozQHw.mjs} +4 -4
- package/dist/{fallback-CiG573uw.mjs.map → fallback-B_2ozQHw.mjs.map} +1 -1
- package/dist/hooks/worker-status-line.mjs +3 -1
- package/dist/hooks/worker-status-line.mjs.map +2 -2
- package/dist/{main-resolver-Dx-pxic1.mjs → main-resolver-DYNxxNwJ.mjs} +166 -12
- package/dist/main-resolver-DYNxxNwJ.mjs.map +1 -0
- package/dist/{main-resolver-uDtK9p6e.mjs → main-resolver-Df65bPAi.mjs} +2 -2
- package/dist/{planner-s1iQQsjj.mjs → planner-DsZZEZCA.mjs} +5 -5
- package/dist/{planner-s1iQQsjj.mjs.map → planner-DsZZEZCA.mjs.map} +1 -1
- package/dist/{program-COHW5ZtV.mjs → program-B5miXqQa.mjs} +70 -74
- package/dist/program-B5miXqQa.mjs.map +1 -0
- package/dist/{run-9HbO1gTM.mjs → run-XaA-UPdW.mjs} +14 -10
- package/dist/run-XaA-UPdW.mjs.map +1 -0
- package/dist/{config-B93YS8tP.mjs → run-env-DyTWgZC9.mjs} +112 -3
- package/dist/run-env-DyTWgZC9.mjs.map +1 -0
- package/dist/{server-CGuZFOeR.mjs → server-CzqHGbKt.mjs} +4 -113
- package/dist/server-CzqHGbKt.mjs.map +1 -0
- package/dist/{session-keepalive-Dg3wiiFJ.mjs → session-keepalive-DDsEo81Q.mjs} +4 -4
- package/dist/{session-keepalive-Dg3wiiFJ.mjs.map → session-keepalive-DDsEo81Q.mjs.map} +1 -1
- package/dist/{work-queue-worker-DEbWsrDQ.mjs → work-queue-worker-BY7xn4pw.mjs} +4 -4
- package/dist/{work-queue-worker-DufMOtrL.mjs → work-queue-worker-DL9lu8sN.mjs} +2 -2
- package/dist/{work-queue-worker-DufMOtrL.mjs.map → work-queue-worker-DL9lu8sN.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/config-B93YS8tP.mjs.map +0 -1
- package/dist/daemon-Caxrq2iQ.mjs.map +0 -1
- package/dist/main-resolver-Dx-pxic1.mjs.map +0 -1
- package/dist/program-COHW5ZtV.mjs.map +0 -1
- package/dist/run-9HbO1gTM.mjs.map +0 -1
- package/dist/server-CGuZFOeR.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./factory-DiuntvwG.mjs";
|
|
2
2
|
import "./config-D1omG_UU.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { G as shortText, I as loadStatuses, L as newWorkerId, T as appendLedger, W as parseRunnerArgs, n as runWorker, t as printResult } from "./run-
|
|
5
|
-
import {
|
|
6
|
-
import { n as swapPromptArg } from "./chain-
|
|
3
|
+
import { T as readWorkersSection } from "./run-env-DyTWgZC9.mjs";
|
|
4
|
+
import { G as shortText, I as loadStatuses, L as newWorkerId, T as appendLedger, W as parseRunnerArgs, n as runWorker, t as printResult } from "./run-XaA-UPdW.mjs";
|
|
5
|
+
import { h as ledgerPath, v as workersLogDir } from "./server-CzqHGbKt.mjs";
|
|
6
|
+
import { n as swapPromptArg } from "./chain-Cltx0NjY.mjs";
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
@@ -244,4 +244,4 @@ function statusesOfChildren(logDir, plannerId) {
|
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
246
|
export { runPlanner };
|
|
247
|
-
//# sourceMappingURL=planner-
|
|
247
|
+
//# sourceMappingURL=planner-DsZZEZCA.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-s1iQQsjj.mjs","names":[],"sources":["../src/workers/planner.ts"],"sourcesContent":["/**\n * planner.ts — the plan class: plan, spawn, integrate.\n *\n * `pai worker run --class plan -p \"<goal>\"` does not run one worker but a\n * small orchestration:\n *\n * 1. a planner worker (the plan class's provider) reads the repository and\n * writes `<logDir>/plans/<planner id>.json` — 5–50 sub-tasks, fewer only\n * when the goal itself names a smaller count, each with title, brief,\n * class, files and acceptance;\n * 2. the runner validates the plan and spawns the sub-tasks as children of\n * the planner worker (`parent` = the planner id, so `ps` shows the\n * tree), at most `workers.tree.maxChildren` at a time;\n * 3. each child that finishes delivers its structured report to the\n * planner's inbox as a `kind: \"result\"` handoff (see handoff.ts);\n * 4. the run finishes with a summary report and the branches to merge.\n *\n * The planner's prompt carries the prompt rules from the self-driving\n * codebases write-up: domain-specific instructions only, constraints over\n * step lists, explicit quantity ranges, no checkbox style.\n */\n\nimport { existsSync, mkdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readWorkersSection } from \"./config.js\";\nimport { appendLedger } from \"./ledger.js\";\nimport { ledgerPath, workersLogDir } from \"./paths.js\";\nimport { loadStatuses, newWorkerId, type WorkerStatus } from \"./status.js\";\nimport { parseRunnerArgs, shortText } from \"./args.js\";\nimport { swapPromptArg } from \"./chain.js\";\nimport { runWorker, printResult, type RunOptions, type StreamEvent } from \"./run.js\";\nimport type { WorkerReport } from \"./report.js\";\n\n/** Where a planner run's plan file lives: <logDir>/plans/<planner id>.json. */\nexport function planPathFor(logDir: string, plannerId: string): string {\n return join(logDir, \"plans\", `${plannerId}.json`);\n}\n\nexport interface PlannerTask {\n title: string;\n brief: string;\n /** Task class of the child (implement, research, …); default implement. */\n class?: string;\n /** Files the sub-task likely touches. */\n files?: string[];\n /** How to tell the sub-task is done. */\n acceptance?: string[];\n}\n\nexport const MIN_TASKS = 5;\nexport const MAX_TASKS = 50;\n\n/**\n * Validate a raw plan file into its tasks. Accepts 1–MAX_TASKS tasks: the\n * prompt asks for MIN_TASKS–MAX_TASKS, but a goal may itself name a smaller\n * explicit count (\"one sub-task per file\" with three files), and that\n * explicit range wins. Everything else — missing file, damaged JSON, tasks\n * without a title or brief — throws with a message the operator can act on.\n */\nexport function validatePlan(raw: unknown): PlannerTask[] {\n if (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) {\n throw new Error(\"plan file must be a JSON object\");\n }\n const tasksRaw = (raw as Record<string, unknown>).tasks;\n if (!Array.isArray(tasksRaw)) throw new Error('plan file needs a \"tasks\" array');\n if (tasksRaw.length < 1) throw new Error(\"plan file has no tasks\");\n if (tasksRaw.length > MAX_TASKS) {\n throw new Error(`plan file has ${tasksRaw.length} tasks; the maximum is ${MAX_TASKS}`);\n }\n const tasks: PlannerTask[] = [];\n for (let i = 0; i < tasksRaw.length; i++) {\n const t = tasksRaw[i];\n if (typeof t !== \"object\" || t === null || Array.isArray(t)) {\n throw new Error(`task ${i + 1} must be an object`);\n }\n const o = t as Record<string, unknown>;\n const title = typeof o.title === \"string\" ? o.title.trim() : \"\";\n const brief = typeof o.brief === \"string\" ? o.brief.trim() : \"\";\n if (!title) throw new Error(`task ${i + 1} needs a non-empty \"title\"`);\n if (!brief) throw new Error(`task ${i + 1} needs a non-empty \"brief\"`);\n const strArr = (v: unknown): string[] | undefined =>\n Array.isArray(v) && v.every((x) => typeof x === \"string\") ? (v as string[]) : undefined;\n const files = strArr(o.files);\n const acceptance = strArr(o.acceptance);\n tasks.push({\n title,\n brief,\n ...(typeof o.class === \"string\" && o.class.trim() ? { class: o.class.trim() } : {}),\n ...(files?.length ? { files } : {}),\n ...(acceptance?.length ? { acceptance } : {}),\n });\n }\n return tasks;\n}\n\n/** The planner worker's instructions, goal and prompt rules included. */\nexport function plannerPrompt(goal: string, planFile: string, maxChildren: number): string {\n return [\n \"You are a PLANNER worker. Turn the goal below into a plan file and stop —\",\n \"you do not implement anything, and you do not spawn workers yourself:\",\n \"the runner executes your plan on your behalf (the sub-tasks run as your\",\n \"children and report back to you).\",\n \"\",\n `Write the plan with the Write tool to ${planFile} as one JSON object:`,\n '{\"tasks\":[{\"title\":\"…\",\"brief\":\"…\",\"class\":\"implement\",\"files\":[\"…\"],\"acceptance\":[\"…\"]}]}',\n \"\",\n \"Prompt rules for the plan itself (they are yours too):\",\n \"- Domain-specific instructions only: name real files, commands and\",\n \" constraints of this repository, never generic advice.\",\n \"- Constraints over step lists: state what must hold (and what must not\",\n \" change), not a numbered procedure to follow.\",\n \"- Explicit quantity ranges: how many, how much, how long — never\",\n ' \"several\", \"some\", \"as needed\".',\n \"- No checkbox style: no `[ ]` items, no step numbering theatre.\",\n \"\",\n `Emit between ${MIN_TASKS} and ${MAX_TASKS} sub-tasks — unless the goal itself`,\n 'names a smaller explicit count (\"one sub-task per file\" with three files',\n \"means three); an explicit count in the goal always wins.\",\n `At most ${maxChildren} of them run at a time, so independent tasks are better`,\n \"than long chains. Each task's class picks its provider: implement, draft,\",\n \"review, research, spotcheck, simple, complex, image.\",\n \"\",\n \"Read the repository first (Glob/Grep/Read) so tasks name real files.\",\n \"Every sub-task runs in its own worktree of the same repository: name files\",\n \"relative to the repository root and never an absolute path or a worktree\",\n \"directory in a title, brief, files or acceptance entry.\",\n \"\",\n \"## Goal\",\n \"\",\n goal,\n ].join(\"\\n\");\n}\n\n/** The child's prompt for one planned sub-task. */\nexport function taskPrompt(goal: string, task: PlannerTask, index: number, of: number): string {\n return [\n `You are sub-task ${index + 1} of ${of} of a planned goal. Do exactly this sub-task;`,\n \"the other sub-tasks are other workers' business.\",\n \"\",\n `# ${task.title}`,\n \"\",\n task.brief,\n ...(task.files?.length ? [\"\", \"Files likely touched: \" + task.files.join(\", \")] : []),\n ...(task.acceptance?.length\n ? [\"\", \"Done means:\", ...task.acceptance.map((a) => `- ${a}`)]\n : []),\n \"\",\n \"## The overall goal (context only — your scope is the sub-task above)\",\n \"\",\n goal,\n ].join(\"\\n\");\n}\n\nexport interface PlannerDeps {\n /** Stage runner; tests inject a mock, production uses runWorker. */\n runStage?: (opts: RunOptions) => Promise<number>;\n /** logDir override for tests. */\n logDir?: string;\n /** maxChildren override for tests. */\n maxChildren?: number;\n}\n\n/**\n * The planner orchestration; returns the process exit code. The planner id is\n * minted here and preset on the phase-1 run, so the plan file's name is known\n * before the worker starts and the prompt can name its exact path.\n */\nexport async function runPlanner(opts: RunOptions, deps: PlannerDeps = {}): Promise<number> {\n const runStage = deps.runStage ?? runWorker;\n const { workers: config } = readWorkersSection();\n const logDir = deps.logDir ?? workersLogDir(config);\n const maxChildren = deps.maxChildren ?? config.tree.maxChildren;\n const parsed = parseRunnerArgs(opts.claudeArgs);\n const goal = parsed.prompt ?? \"\";\n const plannerId = newWorkerId();\n const planFile = planPathFor(logDir, plannerId);\n mkdirSync(join(logDir, \"plans\"), { recursive: true });\n\n // --- phase 1: the planner worker writes the plan file\n process.stderr.write(`planner ${plannerId}: writing plan (${planFile})\\n`);\n const rc1 = await runStage({\n ...opts,\n id: plannerId,\n claudeArgs: swapPromptArg(opts.claudeArgs, plannerPrompt(goal, planFile, maxChildren)),\n quiet: true,\n _planner: true,\n });\n if (rc1 !== 0) return rc1;\n if (!existsSync(planFile)) {\n process.stderr.write(\n `planner ${plannerId}: no plan file at ${planFile} — the planner worker did not write one. ` +\n `Re-run, or write the plan yourself and run the tasks with pai worker run.\\n`\n );\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", { planner: plannerId, rc: 1, failed: \"plan\" });\n return 1;\n }\n let tasks: PlannerTask[];\n try {\n tasks = validatePlan(JSON.parse(readFileSync(planFile, \"utf8\")));\n } catch (e) {\n process.stderr.write(`planner ${plannerId}: invalid plan file ${planFile}: ${(e as Error).message}\\n`);\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", { planner: plannerId, rc: 1, failed: \"plan\" });\n return 1;\n }\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN\", {\n planner: plannerId,\n tasks: tasks.length,\n plan: planFile,\n });\n\n // --- phase 2: run the sub-tasks as children, maxChildren at a time\n const results: { task: PlannerTask; rc: number }[] = [];\n for (let i = 0; i < tasks.length; i += maxChildren) {\n const wave = tasks.slice(i, i + maxChildren);\n process.stderr.write(\n `planner ${plannerId}: sub-tasks ${i + 1}–${i + wave.length} of ${tasks.length}\\n`\n );\n const rcs = await Promise.all(\n wave.map((task, w) =>\n runStage({\n className: task.class ?? \"implement\",\n providerFlag: opts.providerFlag,\n modelFlag: opts.modelFlag,\n label: shortText(task.title, 40),\n noPane: opts.noPane,\n mcpFlag: opts.mcpFlag,\n claudeArgs: swapPromptArg(opts.claudeArgs, taskPrompt(goal, task, i + w, tasks.length)),\n cwd: opts.cwd,\n worktreeFlag: opts.worktreeFlag,\n parent: plannerId,\n quiet: true,\n })\n )\n );\n for (let w = 0; w < wave.length; w++) results.push({ task: wave[w], rc: rcs[w] });\n }\n\n // --- phase 3: summary from the children's statuses and inbox handoffs\n const failed = results.filter((r) => r.rc !== 0).length;\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", {\n planner: plannerId,\n rc: failed ? 1 : 0,\n failed,\n });\n printPlannerSummary(logDir, plannerId, results, parsed.outputFormat, opts.quiet === true);\n return failed ? 1 : 0;\n}\n\n/** Compose and print the planner's summary report (text or json). */\nfunction printPlannerSummary(\n logDir: string,\n plannerId: string,\n results: { task: PlannerTask; rc: number }[],\n fmt: \"text\" | \"json\" | \"stream-json\",\n quiet: boolean\n): void {\n const children = statusesOfChildren(logDir, plannerId);\n const ok = results.filter((r) => r.rc === 0).length;\n const unmerged = children.filter((c) => c.branch && !c.merged);\n const report: WorkerReport = {\n checks: results.map((r, i) => ({\n name: r.task.title,\n ok: r.rc === 0,\n detail: r.rc === 0 ? shortText(children[i]?.last, 80) : `rc=${r.rc}`,\n })),\n ...(unmerged.length\n ? { open: unmerged.map((c) => `branch to merge: pai worker merge ${c.id} (${c.branch})`) }\n : {}),\n notes: `${ok}/${results.length} sub-tasks ok${unmerged.length ? `; ${unmerged.length} branch(es) to merge` : \"\"}`,\n };\n if (quiet || fmt === \"stream-json\") return;\n const resultEvent: StreamEvent = {\n type: \"result\",\n result: [\n `planner ${plannerId}: ${report.notes}`,\n ...(unmerged.length ? [\"branches to merge:\"] : []),\n ...unmerged.map((c) => ` pai worker merge ${c.id} # ${c.branch}`),\n ].join(\"\\n\"),\n is_error: ok !== results.length,\n };\n printResult(fmt, resultEvent, ok === results.length ? 0 : 1, logDir, plannerId, report, {\n plan: results.length,\n ...(unmerged.length ? { branches: unmerged.map((c) => c.branch!) } : {}),\n });\n}\n\n/** Children of the planner, oldest first, from the status files. */\nfunction statusesOfChildren(logDir: string, plannerId: string): WorkerStatus[] {\n return loadStatuses(logDir).filter((s) => s.parent === plannerId);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAgB,WAA2B;AACrE,QAAO,KAAK,QAAQ,SAAS,GAAG,UAAU,OAAO;;AAcnD,MAAa,YAAY;AACzB,MAAa,YAAY;;;;;;;;AASzB,SAAgB,aAAa,KAA6B;AACxD,KAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,IAAI,CAC/D,OAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,WAAY,IAAgC;AAClD,KAAI,CAAC,MAAM,QAAQ,SAAS,CAAE,OAAM,IAAI,MAAM,oCAAkC;AAChF,KAAI,SAAS,SAAS,EAAG,OAAM,IAAI,MAAM,yBAAyB;AACl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,SAAS,mBAAmB,QAAgB,WAAmC;AAC7E,QAAO,aAAa,OAAO,CAAC,QAAQ,MAAM,EAAE,WAAW,UAAU"}
|
|
1
|
+
{"version":3,"file":"planner-DsZZEZCA.mjs","names":[],"sources":["../src/workers/planner.ts"],"sourcesContent":["/**\n * planner.ts — the plan class: plan, spawn, integrate.\n *\n * `pai worker run --class plan -p \"<goal>\"` does not run one worker but a\n * small orchestration:\n *\n * 1. a planner worker (the plan class's provider) reads the repository and\n * writes `<logDir>/plans/<planner id>.json` — 5–50 sub-tasks, fewer only\n * when the goal itself names a smaller count, each with title, brief,\n * class, files and acceptance;\n * 2. the runner validates the plan and spawns the sub-tasks as children of\n * the planner worker (`parent` = the planner id, so `ps` shows the\n * tree), at most `workers.tree.maxChildren` at a time;\n * 3. each child that finishes delivers its structured report to the\n * planner's inbox as a `kind: \"result\"` handoff (see handoff.ts);\n * 4. the run finishes with a summary report and the branches to merge.\n *\n * The planner's prompt carries the prompt rules from the self-driving\n * codebases write-up: domain-specific instructions only, constraints over\n * step lists, explicit quantity ranges, no checkbox style.\n */\n\nimport { existsSync, mkdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readWorkersSection } from \"./config.js\";\nimport { appendLedger } from \"./ledger.js\";\nimport { ledgerPath, workersLogDir } from \"./paths.js\";\nimport { loadStatuses, newWorkerId, type WorkerStatus } from \"./status.js\";\nimport { parseRunnerArgs, shortText } from \"./args.js\";\nimport { swapPromptArg } from \"./chain.js\";\nimport { runWorker, printResult, type RunOptions, type StreamEvent } from \"./run.js\";\nimport type { WorkerReport } from \"./report.js\";\n\n/** Where a planner run's plan file lives: <logDir>/plans/<planner id>.json. */\nexport function planPathFor(logDir: string, plannerId: string): string {\n return join(logDir, \"plans\", `${plannerId}.json`);\n}\n\nexport interface PlannerTask {\n title: string;\n brief: string;\n /** Task class of the child (implement, research, …); default implement. */\n class?: string;\n /** Files the sub-task likely touches. */\n files?: string[];\n /** How to tell the sub-task is done. */\n acceptance?: string[];\n}\n\nexport const MIN_TASKS = 5;\nexport const MAX_TASKS = 50;\n\n/**\n * Validate a raw plan file into its tasks. Accepts 1–MAX_TASKS tasks: the\n * prompt asks for MIN_TASKS–MAX_TASKS, but a goal may itself name a smaller\n * explicit count (\"one sub-task per file\" with three files), and that\n * explicit range wins. Everything else — missing file, damaged JSON, tasks\n * without a title or brief — throws with a message the operator can act on.\n */\nexport function validatePlan(raw: unknown): PlannerTask[] {\n if (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) {\n throw new Error(\"plan file must be a JSON object\");\n }\n const tasksRaw = (raw as Record<string, unknown>).tasks;\n if (!Array.isArray(tasksRaw)) throw new Error('plan file needs a \"tasks\" array');\n if (tasksRaw.length < 1) throw new Error(\"plan file has no tasks\");\n if (tasksRaw.length > MAX_TASKS) {\n throw new Error(`plan file has ${tasksRaw.length} tasks; the maximum is ${MAX_TASKS}`);\n }\n const tasks: PlannerTask[] = [];\n for (let i = 0; i < tasksRaw.length; i++) {\n const t = tasksRaw[i];\n if (typeof t !== \"object\" || t === null || Array.isArray(t)) {\n throw new Error(`task ${i + 1} must be an object`);\n }\n const o = t as Record<string, unknown>;\n const title = typeof o.title === \"string\" ? o.title.trim() : \"\";\n const brief = typeof o.brief === \"string\" ? o.brief.trim() : \"\";\n if (!title) throw new Error(`task ${i + 1} needs a non-empty \"title\"`);\n if (!brief) throw new Error(`task ${i + 1} needs a non-empty \"brief\"`);\n const strArr = (v: unknown): string[] | undefined =>\n Array.isArray(v) && v.every((x) => typeof x === \"string\") ? (v as string[]) : undefined;\n const files = strArr(o.files);\n const acceptance = strArr(o.acceptance);\n tasks.push({\n title,\n brief,\n ...(typeof o.class === \"string\" && o.class.trim() ? { class: o.class.trim() } : {}),\n ...(files?.length ? { files } : {}),\n ...(acceptance?.length ? { acceptance } : {}),\n });\n }\n return tasks;\n}\n\n/** The planner worker's instructions, goal and prompt rules included. */\nexport function plannerPrompt(goal: string, planFile: string, maxChildren: number): string {\n return [\n \"You are a PLANNER worker. Turn the goal below into a plan file and stop —\",\n \"you do not implement anything, and you do not spawn workers yourself:\",\n \"the runner executes your plan on your behalf (the sub-tasks run as your\",\n \"children and report back to you).\",\n \"\",\n `Write the plan with the Write tool to ${planFile} as one JSON object:`,\n '{\"tasks\":[{\"title\":\"…\",\"brief\":\"…\",\"class\":\"implement\",\"files\":[\"…\"],\"acceptance\":[\"…\"]}]}',\n \"\",\n \"Prompt rules for the plan itself (they are yours too):\",\n \"- Domain-specific instructions only: name real files, commands and\",\n \" constraints of this repository, never generic advice.\",\n \"- Constraints over step lists: state what must hold (and what must not\",\n \" change), not a numbered procedure to follow.\",\n \"- Explicit quantity ranges: how many, how much, how long — never\",\n ' \"several\", \"some\", \"as needed\".',\n \"- No checkbox style: no `[ ]` items, no step numbering theatre.\",\n \"\",\n `Emit between ${MIN_TASKS} and ${MAX_TASKS} sub-tasks — unless the goal itself`,\n 'names a smaller explicit count (\"one sub-task per file\" with three files',\n \"means three); an explicit count in the goal always wins.\",\n `At most ${maxChildren} of them run at a time, so independent tasks are better`,\n \"than long chains. Each task's class picks its provider: implement, draft,\",\n \"review, research, spotcheck, simple, complex, image.\",\n \"\",\n \"Read the repository first (Glob/Grep/Read) so tasks name real files.\",\n \"Every sub-task runs in its own worktree of the same repository: name files\",\n \"relative to the repository root and never an absolute path or a worktree\",\n \"directory in a title, brief, files or acceptance entry.\",\n \"\",\n \"## Goal\",\n \"\",\n goal,\n ].join(\"\\n\");\n}\n\n/** The child's prompt for one planned sub-task. */\nexport function taskPrompt(goal: string, task: PlannerTask, index: number, of: number): string {\n return [\n `You are sub-task ${index + 1} of ${of} of a planned goal. Do exactly this sub-task;`,\n \"the other sub-tasks are other workers' business.\",\n \"\",\n `# ${task.title}`,\n \"\",\n task.brief,\n ...(task.files?.length ? [\"\", \"Files likely touched: \" + task.files.join(\", \")] : []),\n ...(task.acceptance?.length\n ? [\"\", \"Done means:\", ...task.acceptance.map((a) => `- ${a}`)]\n : []),\n \"\",\n \"## The overall goal (context only — your scope is the sub-task above)\",\n \"\",\n goal,\n ].join(\"\\n\");\n}\n\nexport interface PlannerDeps {\n /** Stage runner; tests inject a mock, production uses runWorker. */\n runStage?: (opts: RunOptions) => Promise<number>;\n /** logDir override for tests. */\n logDir?: string;\n /** maxChildren override for tests. */\n maxChildren?: number;\n}\n\n/**\n * The planner orchestration; returns the process exit code. The planner id is\n * minted here and preset on the phase-1 run, so the plan file's name is known\n * before the worker starts and the prompt can name its exact path.\n */\nexport async function runPlanner(opts: RunOptions, deps: PlannerDeps = {}): Promise<number> {\n const runStage = deps.runStage ?? runWorker;\n const { workers: config } = readWorkersSection();\n const logDir = deps.logDir ?? workersLogDir(config);\n const maxChildren = deps.maxChildren ?? config.tree.maxChildren;\n const parsed = parseRunnerArgs(opts.claudeArgs);\n const goal = parsed.prompt ?? \"\";\n const plannerId = newWorkerId();\n const planFile = planPathFor(logDir, plannerId);\n mkdirSync(join(logDir, \"plans\"), { recursive: true });\n\n // --- phase 1: the planner worker writes the plan file\n process.stderr.write(`planner ${plannerId}: writing plan (${planFile})\\n`);\n const rc1 = await runStage({\n ...opts,\n id: plannerId,\n claudeArgs: swapPromptArg(opts.claudeArgs, plannerPrompt(goal, planFile, maxChildren)),\n quiet: true,\n _planner: true,\n });\n if (rc1 !== 0) return rc1;\n if (!existsSync(planFile)) {\n process.stderr.write(\n `planner ${plannerId}: no plan file at ${planFile} — the planner worker did not write one. ` +\n `Re-run, or write the plan yourself and run the tasks with pai worker run.\\n`\n );\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", { planner: plannerId, rc: 1, failed: \"plan\" });\n return 1;\n }\n let tasks: PlannerTask[];\n try {\n tasks = validatePlan(JSON.parse(readFileSync(planFile, \"utf8\")));\n } catch (e) {\n process.stderr.write(`planner ${plannerId}: invalid plan file ${planFile}: ${(e as Error).message}\\n`);\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", { planner: plannerId, rc: 1, failed: \"plan\" });\n return 1;\n }\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN\", {\n planner: plannerId,\n tasks: tasks.length,\n plan: planFile,\n });\n\n // --- phase 2: run the sub-tasks as children, maxChildren at a time\n const results: { task: PlannerTask; rc: number }[] = [];\n for (let i = 0; i < tasks.length; i += maxChildren) {\n const wave = tasks.slice(i, i + maxChildren);\n process.stderr.write(\n `planner ${plannerId}: sub-tasks ${i + 1}–${i + wave.length} of ${tasks.length}\\n`\n );\n const rcs = await Promise.all(\n wave.map((task, w) =>\n runStage({\n className: task.class ?? \"implement\",\n providerFlag: opts.providerFlag,\n modelFlag: opts.modelFlag,\n label: shortText(task.title, 40),\n noPane: opts.noPane,\n mcpFlag: opts.mcpFlag,\n claudeArgs: swapPromptArg(opts.claudeArgs, taskPrompt(goal, task, i + w, tasks.length)),\n cwd: opts.cwd,\n worktreeFlag: opts.worktreeFlag,\n parent: plannerId,\n quiet: true,\n })\n )\n );\n for (let w = 0; w < wave.length; w++) results.push({ task: wave[w], rc: rcs[w] });\n }\n\n // --- phase 3: summary from the children's statuses and inbox handoffs\n const failed = results.filter((r) => r.rc !== 0).length;\n appendLedger(ledgerPath(logDir), \"WORKER-PLAN-END\", {\n planner: plannerId,\n rc: failed ? 1 : 0,\n failed,\n });\n printPlannerSummary(logDir, plannerId, results, parsed.outputFormat, opts.quiet === true);\n return failed ? 1 : 0;\n}\n\n/** Compose and print the planner's summary report (text or json). */\nfunction printPlannerSummary(\n logDir: string,\n plannerId: string,\n results: { task: PlannerTask; rc: number }[],\n fmt: \"text\" | \"json\" | \"stream-json\",\n quiet: boolean\n): void {\n const children = statusesOfChildren(logDir, plannerId);\n const ok = results.filter((r) => r.rc === 0).length;\n const unmerged = children.filter((c) => c.branch && !c.merged);\n const report: WorkerReport = {\n checks: results.map((r, i) => ({\n name: r.task.title,\n ok: r.rc === 0,\n detail: r.rc === 0 ? shortText(children[i]?.last, 80) : `rc=${r.rc}`,\n })),\n ...(unmerged.length\n ? { open: unmerged.map((c) => `branch to merge: pai worker merge ${c.id} (${c.branch})`) }\n : {}),\n notes: `${ok}/${results.length} sub-tasks ok${unmerged.length ? `; ${unmerged.length} branch(es) to merge` : \"\"}`,\n };\n if (quiet || fmt === \"stream-json\") return;\n const resultEvent: StreamEvent = {\n type: \"result\",\n result: [\n `planner ${plannerId}: ${report.notes}`,\n ...(unmerged.length ? [\"branches to merge:\"] : []),\n ...unmerged.map((c) => ` pai worker merge ${c.id} # ${c.branch}`),\n ].join(\"\\n\"),\n is_error: ok !== results.length,\n };\n printResult(fmt, resultEvent, ok === results.length ? 0 : 1, logDir, plannerId, report, {\n plan: results.length,\n ...(unmerged.length ? { branches: unmerged.map((c) => c.branch!) } : {}),\n });\n}\n\n/** Children of the planner, oldest first, from the status files. */\nfunction statusesOfChildren(logDir: string, plannerId: string): WorkerStatus[] {\n return loadStatuses(logDir).filter((s) => s.parent === plannerId);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,YAAY,QAAgB,WAA2B;AACrE,QAAO,KAAK,QAAQ,SAAS,GAAG,UAAU,OAAO;;AAcnD,MAAa,YAAY;AACzB,MAAa,YAAY;;;;;;;;AASzB,SAAgB,aAAa,KAA6B;AACxD,KAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,IAAI,CAC/D,OAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,WAAY,IAAgC;AAClD,KAAI,CAAC,MAAM,QAAQ,SAAS,CAAE,OAAM,IAAI,MAAM,oCAAkC;AAChF,KAAI,SAAS,SAAS,EAAG,OAAM,IAAI,MAAM,yBAAyB;AAClE,KAAI,SAAS,SAAS,UACpB,OAAM,IAAI,MAAM,iBAAiB,SAAS,OAAO,yBAAyB,YAAY;CAExF,MAAM,QAAuB,EAAE;AAC/B,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,IAAI,SAAS;AACnB,MAAI,OAAO,MAAM,YAAY,MAAM,Q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
6
|
import { a as getStorageBackend, i as getRegistryBackend, r as createStorageBackend, s as humanDuration } from "./factory-DiuntvwG.mjs";
|
|
7
7
|
import { a as formatDetectionJson, i as formatDetection, n as migrateIdentityFile, r as detectProject } from "./wakeup-D0uvqLsE.mjs";
|
|
8
|
-
import { B as claudeProjectsDir, C as findLatestNote, H as scanTranscriptFolders, I as resolveHome, L as saveScanConfig, M as cmdScan, N as loadScanConfig, P as migrateScanConfig, R as upsertProject, S as applyContinue, T as readBodyFile, U as transcriptFiles, V as findMovedProjects, d as migrateWorkQueue, g as migrateSummaryCooldowns, t as readContextHandoverCache, v as extractAndStoreTriples, w as findNotesDir$1, x as appendCheckpointToNote, z as upsertSession } from "./context-handover-cache-
|
|
8
|
+
import { B as claudeProjectsDir, C as findLatestNote, H as scanTranscriptFolders, I as resolveHome, L as saveScanConfig, M as cmdScan, N as loadScanConfig, P as migrateScanConfig, R as upsertProject, S as applyContinue, T as readBodyFile, U as transcriptFiles, V as findMovedProjects, d as migrateWorkQueue, g as migrateSummaryCooldowns, t as readContextHandoverCache, v as extractAndStoreTriples, w as findNotesDir$1, x as appendCheckpointToNote, z as upsertSession } from "./context-handover-cache-Dt4HW1Ro.mjs";
|
|
9
9
|
import { a as paiHomePath, i as paiHomeDir, n as migratePaiDir, o as resolvePaiFile, r as migratePaiFile, t as PaiFileMigrationError } from "./pai-home-CeOIYltV.mjs";
|
|
10
10
|
import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-D1omG_UU.mjs";
|
|
11
11
|
import { a as schedulerLogPath, i as paiSocketPath, n as daemonLogPath, r as daemonPidPath } from "./runtime-paths-BRwDeBEg.mjs";
|
|
12
|
-
import { A as
|
|
13
|
-
import { B as saveStatus, C as mergeWorker, D as UNLABELED, F as loadStatus, H as waitForTerminalStatus, I as loadStatuses, K as describeMcp, N as isChatPane, P as isLive, S as discardWorker, T as appendLedger, U as longInlinePromptHint, V as setWorkerLabel, W as parseRunnerArgs, a as projectLaunchConfig, c as handoffFromInside, f as checkPaneForWorker, i as usageContextTokens, m as openPaneForWorker, n as runWorker, o as parseWorkerReport, p as openFollowPane, q as expandMcpNames, r as testProvider, u as sayToWorker, z as ownsPid } from "./run-
|
|
12
|
+
import { A as initWorkersYaml, B as stripModelVariant, F as relocateWorkersYaml, I as workersYamlLegacyNotice, L as workersYamlPath, M as migrateWorkersToYaml, N as needsWorkersYamlRelocation, P as parseWorkersYamlDocument, R as DEFAULT_CONTEXT_WINDOW, S as nativeAnthropicProvider, T as readWorkersSection, _ as expandHome$1, d as PROVIDER_TAGS, j as inlineWorkersYamlKeys, p as WorkersConfigError, r as ANTHROPIC_NATIVE, t as buildRunEnv, u as MODEL_CAPABILITIES, v as getProviderOrNative, x as maskKey, y as isModelCapability, z as contextWindowFromModelId } from "./run-env-DyTWgZC9.mjs";
|
|
13
|
+
import { B as saveStatus, C as mergeWorker, D as UNLABELED, F as loadStatus, H as waitForTerminalStatus, I as loadStatuses, K as describeMcp, N as isChatPane, P as isLive, S as discardWorker, T as appendLedger, U as longInlinePromptHint, V as setWorkerLabel, W as parseRunnerArgs, a as projectLaunchConfig, c as handoffFromInside, f as checkPaneForWorker, i as usageContextTokens, m as openPaneForWorker, n as runWorker, o as parseWorkerReport, p as openFollowPane, q as expandMcpNames, r as testProvider, u as sayToWorker, z as ownsPid } from "./run-XaA-UPdW.mjs";
|
|
14
14
|
import { t as MergeError } from "./merge-xoyfZQ4W.mjs";
|
|
15
15
|
import { n as oldFederationPath, t as federationDbPath } from "./federation-db-w8e-sKjp.mjs";
|
|
16
16
|
import { r as registryDbPath, t as oldRegistryPath } from "./registry-db-Bkpbp7Gf.mjs";
|
|
17
17
|
import { i as indexProjectWithBackend } from "./async-CLvuY7b-.mjs";
|
|
18
18
|
import { t as PaiClient } from "./ipc-client-Dasm515c.mjs";
|
|
19
|
-
import { A as getConfigValueOp, C as psOutput, D as resolveSpecPath, E as readSpecPrompt, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as followWorkers, T as statusLineOutput, _ as setWorkersEnabled, a as addProvider, b as updateProvider, c as describeModels, d as removeProvider, f as resolveProviderName, g as setProviderModel, h as setProviderEnabled, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as describeProviders, m as setClass, n as fallbackOn, o as classTargetText, p as setCapabilityPreference, r as fallbackStatus, s as describeCapabilities, t as fallbackOff, u as modelPrefsText, v as unsetCapabilityPreference, w as replayOutput, x as useProvider, y as unsetClass } from "./fallback-
|
|
20
|
-
import { _ as
|
|
19
|
+
import { A as getConfigValueOp, C as psOutput, D as resolveSpecPath, E as readSpecPrompt, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as followWorkers, T as statusLineOutput, _ as setWorkersEnabled, a as addProvider, b as updateProvider, c as describeModels, d as removeProvider, f as resolveProviderName, g as setProviderModel, h as setProviderEnabled, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as describeProviders, m as setClass, n as fallbackOn, o as classTargetText, p as setCapabilityPreference, r as fallbackStatus, s as describeCapabilities, t as fallbackOff, u as modelPrefsText, v as unsetCapabilityPreference, w as replayOutput, x as useProvider, y as unsetClass } from "./fallback-B_2ozQHw.mjs";
|
|
20
|
+
import { _ as scanCacheFilePath, a as buildDeduped, c as hasConversation, d as restoreTopLevel, f as resumeArgvText, g as resolveSessionByNameOrId, h as migrateSessionScanCache, l as launchInDir, m as fmtAge, o as normalizeName$2, p as printExitDir, s as renderDedupedSessions, t as cmdMain, u as providerResumePlan, v as scanSessions } from "./main-resolver-DYNxxNwJ.mjs";
|
|
21
21
|
import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-xz5axTj3.mjs";
|
|
22
|
-
import {
|
|
22
|
+
import { h as ledgerPath, m as eventsPath, n as ensureProxyRunning, p as ensureNoMcpConfig, r as stopProxy, t as DEFAULT_PROXY_PORT, v as workersLogDir } from "./server-CzqHGbKt.mjs";
|
|
23
23
|
import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-BK1h--W_.mjs";
|
|
24
|
-
import { a as totalUsageTokens, i as parseSessionUsage, r as sessionKeepaliveLedgerSummary, t as loadSessionKeepaliveState } from "./session-keepalive-
|
|
25
|
-
import { t as runChain } from "./chain-
|
|
24
|
+
import { a as totalUsageTokens, i as parseSessionUsage, r as sessionKeepaliveLedgerSummary, t as loadSessionKeepaliveState } from "./session-keepalive-DDsEo81Q.mjs";
|
|
25
|
+
import { t as runChain } from "./chain-Cltx0NjY.mjs";
|
|
26
26
|
import { appendFileSync, chmodSync, copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
27
27
|
import { homedir, platform, tmpdir } from "node:os";
|
|
28
28
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -2035,7 +2035,7 @@ async function cmdUnregister(slug, opts = {}) {
|
|
|
2035
2035
|
//#region src/cli/commands/project/projects-index.ts
|
|
2036
2036
|
function registerProjectsCommands(projectsCmd) {
|
|
2037
2037
|
projectsCmd.command("list", { isDefault: true }).description("Show the unified deduped listing (same as `pai`).\nUse --all to include cold / zero-session / archived projects.").option("--all", "Show all entries including cold / zero-session / archived projects").option("-n, --n <count>", "Max rows to show", "20").action(async (opts) => {
|
|
2038
|
-
const { cmdMain } = await import("./main-resolver-
|
|
2038
|
+
const { cmdMain } = await import("./main-resolver-Df65bPAi.mjs");
|
|
2039
2039
|
await cmdMain(void 0, void 0, opts);
|
|
2040
2040
|
});
|
|
2041
2041
|
projectsCmd.command("list-raw").description("Raw registry listing with slug, path, status, last_active columns").option("--all", "Include archived projects (default: active only)").option("--status <status>", "Filter by status: active | archived").option("--tag <tag>", "Filter by tag").option("--type <type>", "Filter by type").action(async (opts) => {
|
|
@@ -4444,7 +4444,28 @@ async function keepTriggeredSchedule(task, opts, state, now) {
|
|
|
4444
4444
|
return `, could NOT keep the schedule: ${e instanceof Error ? e.message : String(e)}`;
|
|
4445
4445
|
}
|
|
4446
4446
|
}
|
|
4447
|
-
|
|
4447
|
+
/** Re-dispatch attempts allowed for one claim before NOT-RECEIVED gives up. */
|
|
4448
|
+
const NOT_RECEIVED_MAX_ATTEMPTS = 3;
|
|
4449
|
+
/** Minutes of backoff per attempt: try 1 waits 2m, try 2 waits 4m, try 3 waits 6m. */
|
|
4450
|
+
const NOT_RECEIVED_BACKOFF_BASE_MIN = 2;
|
|
4451
|
+
/**
|
|
4452
|
+
* Does a probe reply say "alive, but the dispatch never reached me"?
|
|
4453
|
+
*
|
|
4454
|
+
* The session answers the liveness probe with NOT-RECEIVED (or the "alive, not
|
|
4455
|
+
* received" spelling) when it is demonstrably live yet has no knowledge of the
|
|
4456
|
+
* work order — the dispatch was reported delivered and was not. That is not
|
|
4457
|
+
* silence (the session is fine) and not death (nothing needs recovering): it is
|
|
4458
|
+
* an UNDELIVERED dispatch, and the honest response is to send it again.
|
|
4459
|
+
*
|
|
4460
|
+
* Anchored to the first line so a reply merely discussing the phrase —
|
|
4461
|
+
* "we discussed not received earlier" — does not trip it.
|
|
4462
|
+
*/
|
|
4463
|
+
function isNotReceivedReply(reply) {
|
|
4464
|
+
if (!reply) return false;
|
|
4465
|
+
const first = reply.split("\n", 1)[0].trim().toLowerCase();
|
|
4466
|
+
return first.startsWith("not-received") || /^alive[,:]\s*not[ -]received/.test(first);
|
|
4467
|
+
}
|
|
4468
|
+
async function handleProbe(task, elapsed, opts, state, now) {
|
|
4448
4469
|
const project = task.owner.project;
|
|
4449
4470
|
const el = elapsed === null ? "unknown" : `${elapsed}m`;
|
|
4450
4471
|
if (opts.dryRun) return {
|
|
@@ -4458,6 +4479,31 @@ async function handleProbe(task, elapsed, opts, state) {
|
|
|
4458
4479
|
const answer = await opts.prober.ask(project, `Are you still working on the task "${task.title}"? Reply in one short line.`);
|
|
4459
4480
|
if (answer.state === "replied" || answer.state === "busy") {
|
|
4460
4481
|
state.failedProbes[task.id] = 0;
|
|
4482
|
+
if (isNotReceivedReply(answer.reply)) {
|
|
4483
|
+
const attempts = state.notReceivedAttempts[task.id] ?? 0;
|
|
4484
|
+
const retryAt = state.notReceivedRetryAt[task.id] ?? 0;
|
|
4485
|
+
if (now < retryAt) return {
|
|
4486
|
+
note: `alive but NOT-RECEIVED — re-dispatch backed off ${Math.round((retryAt - now) / 6e4)}m (try ${attempts})`,
|
|
4487
|
+
stuck: false
|
|
4488
|
+
};
|
|
4489
|
+
if (attempts >= NOT_RECEIVED_MAX_ATTEMPTS) return {
|
|
4490
|
+
note: `alive but NOT-RECEIVED x${attempts} — dispatch never landed, claim left for a human`,
|
|
4491
|
+
stuck: true
|
|
4492
|
+
};
|
|
4493
|
+
const next = attempts + 1;
|
|
4494
|
+
state.notReceivedAttempts[task.id] = next;
|
|
4495
|
+
state.notReceivedRetryAt[task.id] = now + next * NOT_RECEIVED_BACKOFF_BASE_MIN * 6e4;
|
|
4496
|
+
const r = await handleDispatch(task, 0, opts, state, now);
|
|
4497
|
+
return {
|
|
4498
|
+
note: `alive but NOT-RECEIVED — re-dispatched (try ${next}): ${r.note}`,
|
|
4499
|
+
stuck: r.alarm === true,
|
|
4500
|
+
dispatched: true
|
|
4501
|
+
};
|
|
4502
|
+
}
|
|
4503
|
+
if (answer.state === "replied") {
|
|
4504
|
+
delete state.notReceivedAttempts[task.id];
|
|
4505
|
+
delete state.notReceivedRetryAt[task.id];
|
|
4506
|
+
}
|
|
4461
4507
|
const expected = expectedMinutes(state.history[task.id] ?? []);
|
|
4462
4508
|
if (elapsed !== null && elapsed > expected * GROSS_OVERRUN_FACTOR) return {
|
|
4463
4509
|
note: `alive but ${el} against an expected ${expected}m — ${GROSS_OVERRUN_FACTOR}x over, worth a look`,
|
|
@@ -6833,7 +6879,7 @@ function cmdLogs(opts) {
|
|
|
6833
6879
|
}
|
|
6834
6880
|
function registerDaemonCommands(daemonCmd) {
|
|
6835
6881
|
daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
|
|
6836
|
-
const { serve } = await import("./daemon-
|
|
6882
|
+
const { serve } = await import("./daemon-B6hx1Ysz.mjs");
|
|
6837
6883
|
const { loadConfig: lc, ensureConfigDir } = await import("./config-DCYWFaEi.mjs");
|
|
6838
6884
|
ensureConfigDir();
|
|
6839
6885
|
await serve(lc());
|
|
@@ -17859,12 +17905,17 @@ async function cmdRecent(opts) {
|
|
|
17859
17905
|
* and only an unrecognised layout falls back to spawning claude)
|
|
17860
17906
|
* b. If probe succeeds:
|
|
17861
17907
|
* exec claude --resume <uuid> --name "<friendlyName>" "/Name <friendlyName>\ngo"
|
|
17908
|
+
* — through the provider the transcript ran on, when its model
|
|
17909
|
+
* matches one (providerResumePlan in lib/launch.ts)
|
|
17862
17910
|
* c. Else (probe failed):
|
|
17863
17911
|
* print clear stderr line: "Resume failed. Starting fresh session in same dir."
|
|
17864
17912
|
* exec claude --name "<friendlyName>" "/Name <friendlyName>\ngo"
|
|
17865
17913
|
* 4. Else (no uuid known):
|
|
17866
17914
|
* exec claude --name "<friendlyName>" "/Name <friendlyName>\ngo"
|
|
17867
17915
|
*
|
|
17916
|
+
* Steps 3 and 4 are launchInDir's, shared — this file no longer carries its
|
|
17917
|
+
* own copy of the spawn dance.
|
|
17918
|
+
*
|
|
17868
17919
|
* Why both --name AND /Name?
|
|
17869
17920
|
* --name <friendlyName> → sets Claude Code's internal session label
|
|
17870
17921
|
* "/Name <friendlyName>\ngo" → runs the /Name slash command via AIBroker, which updates
|
|
@@ -17913,14 +17964,15 @@ async function cmdGoto(query, opts) {
|
|
|
17913
17964
|
return;
|
|
17914
17965
|
}
|
|
17915
17966
|
const name = friendlyName ?? query;
|
|
17916
|
-
const promptArg = `/Name ${name}\ngo`;
|
|
17917
17967
|
if (opts.dryRun) {
|
|
17918
17968
|
if (resumableUuid) {
|
|
17919
|
-
const
|
|
17969
|
+
const plan = providerResumePlan(resumableUuid, projectDir);
|
|
17970
|
+
const argvResume = resumeArgvText(resumableUuid, name, plan);
|
|
17920
17971
|
const argvFresh = `claude --name "${name}" "/Name ${name}\\ngo"`;
|
|
17921
17972
|
console.log("\n" + chalk.bold("Dry run — would probe then exec (RESUME path):") + "\n");
|
|
17922
17973
|
console.log(` cwd: ${chalk.cyan(projectDir)}`);
|
|
17923
17974
|
console.log(` probe: claude --resume ${resumableUuid} --print --output-format=json "_"`);
|
|
17975
|
+
if (plan) console.log(` route: ${plan.provider} (${plan.model})`);
|
|
17924
17976
|
console.log(` argv: ${chalk.white(argvResume)}`);
|
|
17925
17977
|
console.log(` fallback: ${chalk.yellow(argvFresh)}`);
|
|
17926
17978
|
if (resumableSession) {
|
|
@@ -17938,66 +17990,10 @@ async function cmdGoto(query, opts) {
|
|
|
17938
17990
|
console.log();
|
|
17939
17991
|
return;
|
|
17940
17992
|
}
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
"--resume",
|
|
17946
|
-
resumableUuid,
|
|
17947
|
-
"--name",
|
|
17948
|
-
name,
|
|
17949
|
-
promptArg
|
|
17950
|
-
], {
|
|
17951
|
-
cwd: projectDir,
|
|
17952
|
-
stdio: "inherit",
|
|
17953
|
-
env: process.env
|
|
17954
|
-
});
|
|
17955
|
-
if (result.error) {
|
|
17956
|
-
console.error(err(`Failed to launch claude: ${result.error.message}`));
|
|
17957
|
-
process.exitCode = 1;
|
|
17958
|
-
return;
|
|
17959
|
-
}
|
|
17960
|
-
printExitDir(projectDir);
|
|
17961
|
-
process.exitCode = result.status ?? 0;
|
|
17962
|
-
return;
|
|
17963
|
-
} else {
|
|
17964
|
-
process.stderr.write(chalk.yellow(`\n Resume failed for ${resumableUuid.slice(0, 8)}: ${probe.reason ?? "unknown error"}\n Starting fresh session in same directory.\n\n`));
|
|
17965
|
-
const result = spawnSync("claude", [
|
|
17966
|
-
"--name",
|
|
17967
|
-
name,
|
|
17968
|
-
promptArg
|
|
17969
|
-
], {
|
|
17970
|
-
cwd: projectDir,
|
|
17971
|
-
stdio: "inherit",
|
|
17972
|
-
env: process.env
|
|
17973
|
-
});
|
|
17974
|
-
if (result.error) {
|
|
17975
|
-
console.error(err(`Failed to launch claude: ${result.error.message}`));
|
|
17976
|
-
process.exitCode = 1;
|
|
17977
|
-
return;
|
|
17978
|
-
}
|
|
17979
|
-
printExitDir(projectDir);
|
|
17980
|
-
process.exitCode = result.status ?? 0;
|
|
17981
|
-
return;
|
|
17982
|
-
}
|
|
17983
|
-
} else {
|
|
17984
|
-
const result = spawnSync("claude", [
|
|
17985
|
-
"--name",
|
|
17986
|
-
name,
|
|
17987
|
-
promptArg
|
|
17988
|
-
], {
|
|
17989
|
-
cwd: projectDir,
|
|
17990
|
-
stdio: "inherit",
|
|
17991
|
-
env: process.env
|
|
17992
|
-
});
|
|
17993
|
-
if (result.error) {
|
|
17994
|
-
console.error(err(`Failed to launch claude: ${result.error.message}`));
|
|
17995
|
-
process.exitCode = 1;
|
|
17996
|
-
return;
|
|
17997
|
-
}
|
|
17998
|
-
printExitDir(projectDir);
|
|
17999
|
-
process.exitCode = result.status ?? 0;
|
|
18000
|
-
}
|
|
17993
|
+
launchInDir(projectDir, name, {
|
|
17994
|
+
resumableUuid,
|
|
17995
|
+
engine: "claude"
|
|
17996
|
+
});
|
|
18001
17997
|
}
|
|
18002
17998
|
|
|
18003
17999
|
//#endregion
|
|
@@ -21567,4 +21563,4 @@ claude() {
|
|
|
21567
21563
|
|
|
21568
21564
|
//#endregion
|
|
21569
21565
|
export { drainStdio as n, buildProgram as t };
|
|
21570
|
-
//# sourceMappingURL=program-
|
|
21566
|
+
//# sourceMappingURL=program-B5miXqQa.mjs.map
|