@posthog/wizard 2.62.0 → 2.63.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.
Files changed (102) hide show
  1. package/README.md +48 -6
  2. package/dist/{add-mcp-server-to-clients-Bzl7_wB3.js → add-mcp-server-to-clients-Bsyb6MUB.js} +4 -4
  3. package/dist/{add-mcp-server-to-clients-Bzl7_wB3.js.map → add-mcp-server-to-clients-Bsyb6MUB.js.map} +1 -1
  4. package/dist/{agent-interface-C90hyvs1.js → agent-interface-C4CV7p0L.js} +24 -16
  5. package/dist/agent-interface-C4CV7p0L.js.map +1 -0
  6. package/dist/{agent-prompt-loader-CBj2DWAJ.js → agent-prompt-loader-DiM8xfSZ.js} +13 -6
  7. package/dist/agent-prompt-loader-DiM8xfSZ.js.map +1 -0
  8. package/dist/{agent-runner-DA5YfjOD.js → agent-runner-X3JWS2WK.js} +200 -33
  9. package/dist/agent-runner-X3JWS2WK.js.map +1 -0
  10. package/dist/analytics-F6z7o3N2.js +2 -0
  11. package/dist/{analytics-BdKBzz4M.js → analytics-YLZKudpE.js} +2 -2
  12. package/dist/{analytics-BdKBzz4M.js.map → analytics-YLZKudpE.js.map} +1 -1
  13. package/dist/{api-aTkzJ9vG.js → api-DlRJAFI2.js} +3 -3
  14. package/dist/{api-aTkzJ9vG.js.map → api-DlRJAFI2.js.map} +1 -1
  15. package/dist/bin.js +101 -42
  16. package/dist/bin.js.map +1 -1
  17. package/dist/{bounded-fs-BU2L5mjO.js → bounded-fs-CYxETRCt.js} +3 -3
  18. package/dist/{bounded-fs-BU2L5mjO.js.map → bounded-fs-CYxETRCt.js.map} +1 -1
  19. package/dist/{ci-install-BnTAUOz8.js → ci-install-Cyqj_i3I.js} +4 -4
  20. package/dist/{ci-install-BnTAUOz8.js.map → ci-install-Cyqj_i3I.js.map} +1 -1
  21. package/dist/{debug-D2L-fM_I.js → debug-2W78IhFE.js} +1 -1
  22. package/dist/{debug-BTPYy9p7.js → debug-BYIoy1Oz.js} +15 -8
  23. package/dist/debug-BYIoy1Oz.js.map +1 -0
  24. package/dist/{env-api-key-cjD4yfGT.js → env-api-key-B7kiHT3h.js} +4 -7
  25. package/dist/env-api-key-B7kiHT3h.js.map +1 -0
  26. package/dist/{environment-lV2X1gS-.js → environment-Br-oy8cq.js} +4 -4
  27. package/dist/{environment-lV2X1gS-.js.map → environment-Br-oy8cq.js.map} +1 -1
  28. package/dist/{file-watcher-qqQBl5Em.js → file-watcher-HaK4IrJ5.js} +2 -2
  29. package/dist/{file-watcher-qqQBl5Em.js.map → file-watcher-HaK4IrJ5.js.map} +1 -1
  30. package/dist/{headless-ui-TSoOsa3j.js → headless-ui-Dd7Ty4Ul.js} +2 -2
  31. package/dist/{headless-ui-TSoOsa3j.js.map → headless-ui-Dd7Ty4Ul.js.map} +1 -1
  32. package/dist/{interactive-DMoXEiKo.js → interactive-CYv97Lgg.js} +2 -2
  33. package/dist/{interactive-DMoXEiKo.js.map → interactive-CYv97Lgg.js.map} +1 -1
  34. package/dist/{mcp-Dqu0_QzN.js → mcp-D6cJWFPn.js} +2 -2
  35. package/dist/{mcp-Dqu0_QzN.js.map → mcp-D6cJWFPn.js.map} +1 -1
  36. package/dist/{mcp-prompt-streaming-B4cYVDVP.js → mcp-prompt-streaming-DYX7vQ3q.js} +3 -3
  37. package/dist/{mcp-prompt-streaming-B4cYVDVP.js.map → mcp-prompt-streaming-DYX7vQ3q.js.map} +1 -1
  38. package/dist/{non-interactive-EG_lII4R.js → non-interactive-BR4kmPE5.js} +2 -2
  39. package/dist/{non-interactive-EG_lII4R.js.map → non-interactive-BR4kmPE5.js.map} +1 -1
  40. package/dist/{orchestrator-tools-DrhpNOKK.js → orchestrator-tools-CTP6l34W.js} +13 -10
  41. package/dist/orchestrator-tools-CTP6l34W.js.map +1 -0
  42. package/dist/{package-manager-z33XHEWO.js → package-manager-FyJmIsqr.js} +2 -2
  43. package/dist/{package-manager-z33XHEWO.js.map → package-manager-FyJmIsqr.js.map} +1 -1
  44. package/dist/{pi-CVJB0Ban.js → pi-DeF8mWlb.js} +11 -11
  45. package/dist/{pi-CVJB0Ban.js.map → pi-DeF8mWlb.js.map} +1 -1
  46. package/dist/{playground-BjWqoWhf.js → playground-BSMgOp3k.js} +6 -6
  47. package/dist/{playground-BjWqoWhf.js.map → playground-BSMgOp3k.js.map} +1 -1
  48. package/dist/{posthog-3ijs_66W.js → posthog-ZWC-083a.js} +2 -2
  49. package/dist/{posthog-3ijs_66W.js.map → posthog-ZWC-083a.js.map} +1 -1
  50. package/dist/{posthog-integration-C3wuB5B1.js → posthog-integration-CoAID6XW.js} +53 -23
  51. package/dist/{posthog-integration-C3wuB5B1.js.map → posthog-integration-CoAID6XW.js.map} +1 -1
  52. package/dist/{provisioning-IKacrvWB.js → provisioning-xirriYQJ.js} +3 -3
  53. package/dist/{provisioning-IKacrvWB.js.map → provisioning-xirriYQJ.js.map} +1 -1
  54. package/dist/{queue-tools-zM8_mxx6.js → queue-tools-BtJ7_fEW.js} +117 -19
  55. package/dist/queue-tools-BtJ7_fEW.js.map +1 -0
  56. package/dist/{registry-DF_aKyS0.js → registry-B-whj8SQ.js} +5 -5
  57. package/dist/{registry-DF_aKyS0.js.map → registry-B-whj8SQ.js.map} +1 -1
  58. package/dist/{security-CVFKNYBn.js → security-CPtn_dUW.js} +5 -5
  59. package/dist/{security-CVFKNYBn.js.map → security-CPtn_dUW.js.map} +1 -1
  60. package/dist/{setup-utils-iINkc0xu.js → setup-utils-e78zkZoW.js} +71 -18
  61. package/dist/setup-utils-e78zkZoW.js.map +1 -0
  62. package/dist/{start-tui-CjtL-ls7.js → start-tui-B08PfE0V.js} +21 -18
  63. package/dist/start-tui-B08PfE0V.js.map +1 -0
  64. package/dist/{steps-DzUGHdfY.js → steps-Dpd8UTJX.js} +7 -7
  65. package/dist/{steps-DzUGHdfY.js.map → steps-Dpd8UTJX.js.map} +1 -1
  66. package/dist/{store-DtckpbSC.js → store-B-ctPH7O.js} +5 -4
  67. package/dist/store-B-ctPH7O.js.map +1 -0
  68. package/dist/{subagent-cD_bF490.js → subagent-B18BesIW.js} +2 -2
  69. package/dist/{subagent-cD_bF490.js.map → subagent-B18BesIW.js.map} +1 -1
  70. package/dist/{task-eIt2iATF.js → task-D1RaGg3b.js} +12 -12
  71. package/dist/{task-eIt2iATF.js.map → task-D1RaGg3b.js.map} +1 -1
  72. package/dist/{task-stream-DGBUveUD.js → task-stream-DvTf1NOr.js} +4 -4
  73. package/dist/{task-stream-DGBUveUD.js.map → task-stream-DvTf1NOr.js.map} +1 -1
  74. package/dist/{tasks-wQ3V6Ft6.js → tasks-CvHNNFB1.js} +2 -2
  75. package/dist/{tasks-wQ3V6Ft6.js.map → tasks-CvHNNFB1.js.map} +1 -1
  76. package/dist/{telemetry-BWYDFAwf.js → telemetry-C72C8V6q.js} +3 -3
  77. package/dist/{telemetry-BWYDFAwf.js.map → telemetry-C72C8V6q.js.map} +1 -1
  78. package/dist/{terminal-yKJZx1UC.js → terminal-BJms6G77.js} +16 -13
  79. package/dist/terminal-BJms6G77.js.map +1 -0
  80. package/dist/{tools-CDlaJb_e.js → tools-BcXOgEvh.js} +6 -6
  81. package/dist/{tools-CDlaJb_e.js.map → tools-BcXOgEvh.js.map} +1 -1
  82. package/dist/{wizard-abort-Cjk5z73h.js → wizard-abort-BUpx4qnK.js} +1 -1
  83. package/dist/{wizard-abort-CztG5WTv.js → wizard-abort-DRscjUOg.js} +3 -3
  84. package/dist/{wizard-abort-CztG5WTv.js.map → wizard-abort-DRscjUOg.js.map} +1 -1
  85. package/dist/wizard-session-BUhlJ1b8.js.map +1 -1
  86. package/dist/{yara-hooks-DeLjTIiJ.js → yara-hooks-DKRsn0lN.js} +4 -4
  87. package/dist/{yara-hooks-DeLjTIiJ.js.map → yara-hooks-DKRsn0lN.js.map} +1 -1
  88. package/dist/yara-hooks-fHntXaFu.js +2 -0
  89. package/package.json +1 -1
  90. package/dist/agent-interface-C90hyvs1.js.map +0 -1
  91. package/dist/agent-prompt-loader-CBj2DWAJ.js.map +0 -1
  92. package/dist/agent-runner-DA5YfjOD.js.map +0 -1
  93. package/dist/analytics-CijpxQFN.js +0 -2
  94. package/dist/debug-BTPYy9p7.js.map +0 -1
  95. package/dist/env-api-key-cjD4yfGT.js.map +0 -1
  96. package/dist/orchestrator-tools-DrhpNOKK.js.map +0 -1
  97. package/dist/queue-tools-zM8_mxx6.js.map +0 -1
  98. package/dist/setup-utils-iINkc0xu.js.map +0 -1
  99. package/dist/start-tui-CjtL-ls7.js.map +0 -1
  100. package/dist/store-DtckpbSC.js.map +0 -1
  101. package/dist/terminal-yKJZx1UC.js.map +0 -1
  102. package/dist/yara-hooks-DVGKhwaz.js +0 -2
@@ -1,7 +1,7 @@
1
- import { s as logToFile } from "./debug-BTPYy9p7.js";
2
- import { n as analytics } from "./analytics-BdKBzz4M.js";
3
- import { f as isThinkingLevel } from "./queue-tools-zM8_mxx6.js";
4
- import { M as fetchWithRetry, S as WIZARD_TOOL_NAMES } from "./agent-interface-C90hyvs1.js";
1
+ import { s as logToFile } from "./debug-BYIoy1Oz.js";
2
+ import { n as analytics } from "./analytics-YLZKudpE.js";
3
+ import { m as isThinkingLevel } from "./queue-tools-BtJ7_fEW.js";
4
+ import { M as fetchWithRetry, S as WIZARD_TOOL_NAMES } from "./agent-interface-C4CV7p0L.js";
5
5
  //#region src/lib/agent/agent-prompt-loader.ts
6
6
  function projectContext(ctx) {
7
7
  return `You have access to the PostHog MCP server and the wizard tools.
@@ -39,10 +39,17 @@ const SEED_BASICS = `You are the orchestrator. Plan the work and seed the queue
39
39
  * Tasks the wizard queued before the planner ran. It has to see them: they are
40
40
  * part of the run it is planning around, and the task that reports last has to
41
41
  * depend on them. Their ids are real, so it can wire the edge directly.
42
+ *
43
+ * The one-way rule matters as much as the sink edge. These tasks are deferred to
44
+ * the end of the drain after planning (`seeded-deps.ts`) and may block on a
45
+ * person, so a task the planner hangs off one would wait on the user too — which
46
+ * is the interruption deferring them removed. The resolver drops such a task
47
+ * from the seeded task's own dependencies to stay acyclic, so the damage is
48
+ * silent; saying so here is what prevents it.
42
49
  */
43
50
  function preQueuedTasks(tasks) {
44
51
  if (tasks.length === 0) return null;
45
- return `The queue already holds these tasks, placed by the wizard from what it found in this project. Do not queue them again — plan around them, and make sure the reporting task ends up depending on each one:\n${tasks.map((t) => `- ${t.type} (id: ${t.id})`).join("\n")}`;
52
+ return `The queue already holds these tasks, placed by the wizard from what it found in this project. Do not queue them again. They run late — after every task you queue — and one may stop to ask the user for input, so make the reporting task depend on each one and hang nothing else off them: any other task you made depend on one would end up waiting on a person.\n${tasks.map((t) => `- ${t.type} (id: ${t.id})`).join("\n")}`;
46
53
  }
47
54
  /**
48
55
  * Points the agent at its installed task instructions (the HOW). They live under
@@ -299,4 +306,4 @@ const EMPTY_PROMPT = {};
299
306
  //#endregion
300
307
  export { assembleTaskPrompt as a, queueTools as c, taskModelSpec as d, assembleSeedPrompt as i, renderToolInventory as l, agentRunTools as n, loadAgentRegistry as o, allowsPostHogMcp as r, promptModelFor as s, ASK_TOOL as t, resolveTask as u };
301
308
 
302
- //# sourceMappingURL=agent-prompt-loader-CBj2DWAJ.js.map
309
+ //# sourceMappingURL=agent-prompt-loader-DiM8xfSZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-prompt-loader-DiM8xfSZ.js","names":[],"sources":["../src/lib/agent/agent-prompt-loader.ts"],"sourcesContent":["/**\n * Agent-prompt loader + registry.\n *\n * Agent prompts are the WHAT of a task: a markdown file per type, served from\n * context-mill as the `agents` content type (parallel to skills). The frontmatter\n * carries the artifacts the executor needs — model, the mini-skills to load (the\n * HOW), the tools the task may use, and its dependencies — and the body is the\n * instruction the agent reads.\n *\n * The registry is fetched once at startup and scoped to one flow — agents\n * declare `flow` and (for the planner) `seed: true` in frontmatter, so each\n * program (integration, audit, migration, ...) ships its own agent set and the\n * loader stays generic. Every prompt is downloaded and parsed up front, so\n * resolving a task to its run config is synchronous and adds no mid-drain\n * network latency. The registry's type list also drives `enqueue_task`\n * validation.\n */\nimport type {\n QueueStore,\n QueuedTask,\n} from './runner/sequence/orchestrator/queue';\nimport type { ResolvedTask } from './runner/sequence/orchestrator/executor';\nimport type { HostResolution } from '@lib/host-resolution';\nimport {\n isThinkingLevel,\n type ThinkingLevel,\n} from './runner/switchboard/models';\nimport { logToFile } from '@utils/debug';\nimport { analytics } from '@utils/analytics';\nimport { fetchWithRetry } from '@lib/fetch-retry';\nimport { WIZARD_TOOL_NAMES } from '@lib/wizard-tools/tools';\n\n/**\n * The basics the client injects around every agent-prompt body. The `/agents/`\n * files carry intent only (goal, success criteria); the wizard owns the I/O\n * contract — who the agent is, how it reports, how it surfaces progress — so the\n * authored prompts never restate it.\n */\nexport interface OrchestratorPromptContext {\n projectId: number;\n projectApiKey: string;\n host: HostResolution;\n /** Path to the framework's reference implementation (EXAMPLE.md), if available. */\n examplePath?: string;\n /** Path to the framework's rules (COMMANDMENTS.md), if available. */\n commandmentsPath?: string;\n}\n\nfunction projectContext(ctx: OrchestratorPromptContext): string {\n return `You have access to the PostHog MCP server and the wizard tools.\n\nProject context:\n- PostHog Project ID: ${ctx.projectId}\n- PostHog public token: ${ctx.projectApiKey}\n- PostHog Host: ${ctx.host.apiHost}`;\n}\n\n/** Points the agent at the framework's reference integration to learn patterns from. */\nfunction exampleReference(ctx: OrchestratorPromptContext): string | null {\n if (!ctx.examplePath) return null;\n return `A reference PostHog integration for this framework is at \\`${ctx.examplePath}\\`. It shows the target implementation pattern. Reference its patterns and conventions, adapting them to this codebase.`;\n}\n\n/** The framework's rules ship with the reference skill; every task follows them. */\nfunction commandmentsReference(ctx: OrchestratorPromptContext): string | null {\n if (!ctx.commandmentsPath) return null;\n return `Framework rules for this integration are at \\`${ctx.commandmentsPath}\\`. Read them before you edit and follow them.`;\n}\n\n/**\n * The task's own tool list, injected so an agent never has to discover a tool's\n * absence by trying it — and never reports that absence as a finding. Later\n * tasks hold tools this one does not, so work it cannot do is handed on rather\n * than attempted.\n */\n/** Renders the inventory from the tool names a harness actually registered for\n * the run — the one complete list, in the vocabulary the agent will call. */\nexport function renderToolInventory(toolNames: readonly string[]): string {\n if (toolNames.length === 0) return '';\n return `Your tools for this task: ${toolNames.join(\n ', ',\n )}. Do not look for a tool that is not listed or treat its absence as a problem to report. Later tasks in this run hold tools you do not: when your task needs one, hand that work off in your handoff for the task that can do it, or note it for the final report.`;\n}\n\nconst TASK_BASICS = `You are one step in a larger PostHog workflow made of several tasks, run as a fresh agent with no memory of the other tasks beyond the context you are given. Other tasks — before and after you — own the rest of the work, so stay strictly on your own task: do not do a neighbouring step's job, redo what an upstream handoff already did, or reach beyond what you were asked. Do only your task, then report exactly once by calling complete_task with a structured handoff: what your goal was, what you did, and what the next agent should know. When you are given context from previous steps, trust it — those agents already did their work, so do not re-verify or re-read what their handoffs tell you. Build on it and move fast. Read a file before you edit it, so your own changes do not duplicate what is already there. Work only inside this project's own directory: never read, list, or search (find, ls, grep, glob) outside it — not the OS, not other projects, not global package caches. If your task seems to need something outside this directory, it does not — skip that part and say so in your handoff rather than hunting across the filesystem. If your task does not apply to this project — there is genuinely nothing for it to do — report it with status \\`not needed\\` and say why, rather than marking it done.`;\n\nconst SEED_BASICS = `You are the orchestrator. Plan the work and seed the queue with enqueue_task — each call returns an id you can pass as a dependency to a later task. Give each task a short label for the UI — the action in a few words, not file names, class names, or other specifics. The last task you queue, the one that reports on the run, must depend on every other task in the queue — directly, or through a task it already depends on. You are not a task yourself: do not call complete_task and do not edit the project.`;\n\n/**\n * Tasks the wizard queued before the planner ran. It has to see them: they are\n * part of the run it is planning around, and the task that reports last has to\n * depend on them. Their ids are real, so it can wire the edge directly.\n *\n * The one-way rule matters as much as the sink edge. These tasks are deferred to\n * the end of the drain after planning (`seeded-deps.ts`) and may block on a\n * person, so a task the planner hangs off one would wait on the user too — which\n * is the interruption deferring them removed. The resolver drops such a task\n * from the seeded task's own dependencies to stay acyclic, so the damage is\n * silent; saying so here is what prevents it.\n */\nfunction preQueuedTasks(\n tasks: readonly { id: string; type: string }[],\n): string | null {\n if (tasks.length === 0) return null;\n const lines = tasks.map((t) => `- ${t.type} (id: ${t.id})`);\n return `The queue already holds these tasks, placed by the wizard from what it found in this project. Do not queue them again. They run late — after every task you queue — and one may stop to ask the user for input, so make the reporting task depend on each one and hang nothing else off them: any other task you made depend on one would end up waiting on a person.\\n${lines.join(\n '\\n',\n )}`;\n}\n\n/**\n * Points the agent at its installed task instructions (the HOW). They live under\n * the wizard's run dir, not `.claude/skills/`, so the SDK does not auto-load\n * them — the prompt has to name them.\n */\nfunction skillReference(paths: readonly string[]): string | null {\n if (paths.length === 0) return null;\n const list = paths.map((p) => `\\`${p}\\``).join(', ');\n return `Your task instructions are at ${list}. Read them before you start and follow them. They are wizard scaffolding, not part of the project.`;\n}\n\n/** A task agent's full prompt: injected basics, then the authored intent. */\nexport function assembleTaskPrompt(\n ctx: OrchestratorPromptContext,\n body: string,\n skillPaths: readonly string[] = [],\n): string {\n return [\n projectContext(ctx),\n exampleReference(ctx),\n commandmentsReference(ctx),\n skillReference(skillPaths),\n TASK_BASICS,\n body,\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/** The seed agent's full prompt: injected basics, then the authored intent. */\nexport function assembleSeedPrompt(\n ctx: OrchestratorPromptContext,\n body: string,\n preQueued: readonly { id: string; type: string }[] = [],\n): string {\n return [projectContext(ctx), SEED_BASICS, preQueuedTasks(preQueued), body]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/** Orchestrator tools are MCP tools under the `posthog-wizard` server. Frontmatter\n * names them short (e.g. `enqueue_task`); the SDK gates on the full name. */\nconst ORCHESTRATOR_TOOL_PREFIX = 'mcp__posthog-wizard__';\nconst ORCHESTRATOR_TOOLS = new Set([\n 'enqueue_task',\n 'complete_task',\n 'read_handoffs',\n]);\n\n/** The one tool that stops a task until a person answers. Named short in frontmatter. */\nexport const ASK_TOOL = 'wizard_ask';\n\n/**\n * The PostHog MCP, as an agent asks for it in frontmatter. Every tool a task\n * gets is granted by its own prompt, this one included: a task that never names\n * it never has the server wired in, and one that does gets it under this name\n * on both harnesses.\n */\nexport const POSTHOG_MCP_TOOL = 'posthog_exec';\n/** The same tool as the anthropic SDK names it, on the hosted PostHog server. */\nconst POSTHOG_MCP_SDK_TOOL = 'mcp__posthog-wizard__exec';\n\n/** Whether a task asked for the PostHog MCP — accepts either spelling. */\nexport function allowsPostHogMcp(\n allowedTools: readonly string[] | undefined,\n): boolean {\n return (allowedTools ?? []).some(\n (name) => name === POSTHOG_MCP_TOOL || name === POSTHOG_MCP_SDK_TOOL,\n );\n}\n\n/** The queue tools a task holds — all of them minus its disallows. Short names.\n * Single source for both the injected inventory and the harness's tool grant. */\nexport function queueTools(disallowedTools: readonly string[]): string[] {\n const disallowed = new Set(\n disallowedTools.map((n) => n.replace(ORCHESTRATOR_TOOL_PREFIX, '')),\n );\n return [...ORCHESTRATOR_TOOLS].filter((t) => !disallowed.has(t));\n}\n\n/** A parsed agent prompt. The frontmatter fields plus the markdown body. */\nexport interface AgentPrompt {\n type: string;\n /** Human-readable title for the TUI; falls back to `type` when absent. */\n label?: string;\n /** The flow this agent belongs to (the program id, e.g. \\`posthog-integration\\`). */\n flow?: string;\n /** Marks the flow's planner: it seeds the queue and is not an enqueueable task. */\n seed: boolean;\n /** Marks a task that runs last: it must depend on every other task in the queue. */\n sink: boolean;\n /**\n * Marks a task only the wizard may queue. The planner never sees the type, so\n * whether it runs is a decision the client makes from what it detected, not\n * one an agent can reach — it can neither invent the task nor forget it.\n */\n runnerSeeded: boolean;\n /** Per-profile model + effort. `pi` = the gpt/pi harness, `sdk` = the anthropic\n * harness. The mapping is not 1:1 across providers, so each agent names both. */\n modelPi?: string;\n effortPi?: ThinkingLevel;\n modelSdk?: string;\n effortSdk?: ThinkingLevel;\n skills: string[];\n allowedTools: string[];\n disallowedTools: string[];\n /**\n * Task types this one runs after. Read differently by the two kinds of task:\n *\n * - **Enqueueable types**: advisory. The planner authors the real graph with\n * `enqueue_task`, passing ids, and its seed prompt describes the shape it\n * should build. Nothing resolves this field for them.\n * - **`runnerSeeded` types**: authoritative. Such a task is queued before the\n * planner runs, so it cannot name ids; the runner resolves these types to\n * the ids the planner produced and applies them (see `seeded-deps.ts`).\n * Empty means \"after everything that is not the sink\".\n */\n dependsOn: string[];\n body: string;\n}\n\n/** The model + effort an agent runs on for a given harness — `pi` picks the gpt\n * column, anything else the sdk (anthropic) column. */\nexport function promptModelFor(\n prompt: AgentPrompt,\n harness: string,\n): { model?: string; effort?: ThinkingLevel } {\n const pi = harness === 'pi';\n return {\n model: pi ? prompt.modelPi : prompt.modelSdk,\n effort: pi ? prompt.effortPi : prompt.effortSdk,\n };\n}\n\nexport interface AgentRegistry {\n /** The flow's task types — every prompt except the seed. */\n readonly types: string[];\n /** The types an agent may enqueue: `types` minus the runner-seeded ones. */\n readonly enqueueableTypes: string[];\n /** The types that run last and must depend on the whole queue. */\n readonly sinkTypes: string[];\n /** The types only the wizard queues, from what it detected before the run. */\n readonly runnerSeededTypes: string[];\n /** The flow's planner, the one prompt marked `seed: true` in its frontmatter. */\n readonly seed?: AgentPrompt;\n get(type: string): AgentPrompt | undefined;\n}\n\n/** The registry for one flow's prompts. Pure; the loader feeds it the fetched set. */\nexport function buildRegistry(\n prompts: readonly AgentPrompt[],\n flow: string,\n opts?: {\n exclude?: readonly string[];\n /** Per-stage pi model/effort overlays, keyed by task type ('seed' for the planner). Applied here — the one place prompts enter the wizard — so every downstream read sees the effective spec. */\n overrides?: Record<\n string,\n { model?: string; effort?: ThinkingLevel } | undefined\n >;\n },\n): AgentRegistry {\n // The harness can exclude task types (CI excludes dashboards). An excluded\n // type does not exist for the run: the seed cannot enqueue it and no agent\n // is ever spun up for it.\n const excluded = new Set(opts?.exclude ?? []);\n const inFlow = prompts\n .filter((p) => p.flow === flow && !excluded.has(p.type))\n .map((p) => {\n const o = opts?.overrides?.[p.seed ? 'seed' : p.type];\n if (!o) return p;\n return {\n ...p,\n modelPi: o.model ?? p.modelPi,\n effortPi: o.effort ?? p.effortPi,\n };\n });\n const byType = new Map(inFlow.map((p) => [p.type, p]));\n const tasks = inFlow.filter((p) => !p.seed);\n return {\n types: tasks.map((p) => p.type),\n enqueueableTypes: tasks.filter((p) => !p.runnerSeeded).map((p) => p.type),\n sinkTypes: tasks.filter((p) => p.sink).map((p) => p.type),\n runnerSeededTypes: tasks.filter((p) => p.runnerSeeded).map((p) => p.type),\n seed: inFlow.find((p) => p.seed),\n get: (type) => byType.get(type),\n };\n}\n\ninterface AgentMenu {\n /** `flow` arrived with context-mill's flow-scoped agents folder; older menus omit it. */\n agents: { id: string; flow?: string; downloadUrl: string }[];\n}\n\n/** A native tool passes through; an MCP tool gets its fully-qualified name. */\nfunction expandToolName(name: string): string {\n if (name === ASK_TOOL) return WIZARD_TOOL_NAMES.wizardAsk;\n if (name === POSTHOG_MCP_TOOL) return POSTHOG_MCP_SDK_TOOL;\n return ORCHESTRATOR_TOOLS.has(name)\n ? `${ORCHESTRATOR_TOOL_PREFIX}${name}`\n : name;\n}\n\n/** A prompt's allow/disallow lists with orchestrator tool names MCP-qualified. */\nexport function agentRunTools(prompt: AgentPrompt): {\n allowedTools: string[];\n disallowedTools: string[];\n} {\n return {\n allowedTools: prompt.allowedTools.map(expandToolName),\n disallowedTools: prompt.disallowedTools.map(expandToolName),\n };\n}\n\nfunction toStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((v): v is string => typeof v === 'string');\n}\n\n/**\n * Parse the leading `---` frontmatter block and the markdown body. The\n * frontmatter is a small, known schema (scalars and inline `[a, b]` arrays), so\n * a tiny parser covers it without a YAML dependency. Inline `# comments` after a\n * value are stripped. `fallbackType` (the menu id) and `fallbackFlow` (the\n * menu entry's flow) apply when the frontmatter omits `type:`/`flow:`.\n */\nexport function parseAgentPrompt(\n text: string,\n fallbackType: string,\n fallbackFlow?: string,\n): AgentPrompt {\n const match = text.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n const frontmatter = match ? match[1] : '';\n const body = (match ? match[2] : text).trim();\n\n const fields: Record<string, unknown> = {};\n for (const rawLine of frontmatter.split(/\\r?\\n/)) {\n const line = rawLine.replace(/\\s+#.*$/, '').trim();\n if (!line || line.startsWith('#')) continue;\n const kv = line.match(/^([\\w-]+):\\s*(.*)$/);\n if (!kv) continue;\n const [, key, raw] = kv;\n if (raw.startsWith('[') && raw.endsWith(']')) {\n fields[key] = raw\n .slice(1, -1)\n .split(',')\n .map((s) => s.trim().replace(/^['\"]|['\"]$/g, ''))\n .filter(Boolean);\n } else {\n fields[key] = raw.replace(/^['\"]|['\"]$/g, '');\n }\n }\n\n const str = (v: unknown) => (typeof v === 'string' ? v : undefined);\n // Effort is remote data — reject typos here so downstream carries ThinkingLevel.\n const effort = (v: unknown, key: string): ThinkingLevel | undefined => {\n if (v === undefined) return undefined;\n if (isThinkingLevel(v)) return v;\n logToFile(\n `[agent-prompt] ${fallbackType}: ignoring invalid ${key} \"${String(v)}\"`,\n );\n analytics.wizardCapture('agent prompt invalid effort', {\n task_type: fallbackType,\n key,\n value: String(v),\n });\n return undefined;\n };\n return {\n type: typeof fields.type === 'string' ? fields.type : fallbackType,\n label: typeof fields.label === 'string' ? fields.label : undefined,\n flow: typeof fields.flow === 'string' ? fields.flow : fallbackFlow,\n seed: fields.seed === 'true',\n sink: fields.sink === 'true',\n runnerSeeded: fields.runnerSeeded === 'true',\n modelPi: str(fields.model_pi),\n effortPi: effort(fields.effort_pi, 'effort_pi'),\n modelSdk: str(fields.model_sdk),\n effortSdk: effort(fields.effort_sdk, 'effort_sdk'),\n skills: toStringArray(fields.skills),\n allowedTools: toStringArray(fields.allowedTools),\n disallowedTools: toStringArray(fields.disallowedTools),\n dependsOn: toStringArray(fields.dependsOn),\n body,\n };\n}\n\nasync function fetchText(url: string): Promise<string> {\n const res = await fetchWithRetry(url);\n return res.text();\n}\n\n/**\n * Fetch the agent menu and every agent prompt it lists, parse them, and build\n * the registry for one flow. Throws if the menu cannot be fetched — the\n * orchestrator cannot run without its prompts.\n */\nexport async function loadAgentRegistry(\n skillsBaseUrl: string,\n flow: string,\n opts?: Parameters<typeof buildRegistry>[2],\n): Promise<AgentRegistry> {\n const menuRaw = await fetchText(`${skillsBaseUrl}/agent-menu.json`);\n const menu = JSON.parse(menuRaw) as AgentMenu;\n\n // Menus that carry a flow per entry let us skip other flows' prompts before\n // fetching them; entries without one are fetched and filtered by their\n // frontmatter in buildRegistry, as before.\n const entries = (menu.agents ?? []).filter(\n (entry) => !entry.flow || entry.flow === flow,\n );\n const prompts = await Promise.all(\n entries.map(async (entry) => {\n const text = await fetchText(entry.downloadUrl);\n return parseAgentPrompt(text, entry.id, entry.flow);\n }),\n );\n\n return buildRegistry(prompts, flow, opts);\n}\n\n/**\n * Render a task's own inputs into a section, so a fanned-out task (e.g. one\n * `capture` per event) sees the specific thing it owns. Empty when there are none.\n */\nfunction renderInputs(task: QueuedTask): string {\n const entries = Object.entries(task.inputs ?? {});\n if (entries.length === 0) return '';\n const lines = entries.map(([k, v]) => `- ${k}: ${formatInputValue(v)}`);\n return `## Your task input\\n\\n${lines.join('\\n')}`;\n}\n\nfunction formatInputValue(value: unknown): string {\n if (typeof value === 'string') return value;\n return JSON.stringify(value);\n}\n\n/**\n * The ids of every task `task` transitively depends on — the full upstream\n * chain, not just direct dependencies — ordered roots-first, each once. A `seen`\n * set dedupes diamonds and guards against cycles.\n */\nfunction ancestorIds(task: QueuedTask, store: QueueStore): string[] {\n const seen = new Set<string>();\n const ordered: string[] = [];\n const visit = (id: string): void => {\n if (seen.has(id)) return;\n seen.add(id);\n const t = store.get(id);\n if (!t) return;\n for (const dep of t.dependsOn) visit(dep); // ancestors before dependents\n ordered.push(id);\n };\n for (const dep of task.dependsOn) visit(dep);\n return ordered;\n}\n\n/**\n * Render the handoffs of every step `task` transitively depends on into a context\n * section, so a fresh agent sees the whole upstream chain — not just its direct\n * dependencies. Reliability over token economy: a step must never have to\n * re-discover what any ancestor already established just because an intermediate\n * handoff happened to omit it. Empty when there are no completed ancestors.\n */\nfunction renderHandoffContext(task: QueuedTask, store: QueueStore): string {\n const lines: string[] = [];\n for (const id of ancestorIds(task, store)) {\n const dep = store.get(id);\n const handoff = store.readHandoff(id);\n if (!dep || !handoff) continue;\n lines.push(`### ${dep.type}`);\n lines.push(`- did: ${handoff.did}`);\n lines.push(`- for you: ${handoff.forNextAgent}`);\n if (handoff.filesTouched?.length) {\n lines.push(`- files: ${handoff.filesTouched.join(', ')}`);\n }\n if (handoff.evidence) {\n lines.push(`- evidence: ${handoff.evidence}`);\n }\n if (handoff.assumptions) {\n lines.push(`- assumed: ${handoff.assumptions}`);\n }\n if (handoff.reportSection) {\n lines.push(`- report section:\\n${handoff.reportSection}`);\n }\n lines.push('');\n }\n if (lines.length === 0) return '';\n return `## Context from previous steps\\n\\n${lines.join('\\n')}`.trim();\n}\n\n/**\n * Resolve a queued task to its run config: the prompt body (with upstream\n * handoffs appended), the model, and the tool lists with orchestrator tool names\n * MCP-qualified. The model precedence is enqueue override, then prompt, then\n * default. Throws if no prompt is registered for the task's type.\n */\nexport function resolveTask(\n registry: AgentRegistry,\n task: QueuedTask,\n store: QueueStore,\n): ResolvedTask {\n const prompt = registry.get(task.type);\n if (!prompt) {\n throw new Error(`No agent prompt registered for task type \"${task.type}\"`);\n }\n\n const body = [\n renderInputs(task),\n prompt.body,\n renderHandoffContext(task, store),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n\n return {\n ...agentRunTools(prompt),\n prompt: body,\n skills: prompt.skills,\n };\n}\n\n/** The model + effort a task runs on for a harness: enqueue override, then the\n * prompt's per-profile frontmatter; the caller's switchboard pick is the fallback. */\nexport function taskModelSpec(\n registry: AgentRegistry,\n task: QueuedTask,\n harness: string,\n): { model?: string; effort?: ThinkingLevel } {\n const picked = promptModelFor(\n registry.get(task.type) ?? EMPTY_PROMPT,\n harness,\n );\n return {\n model: task.model ?? picked.model,\n effort: picked.effort,\n };\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K,GAAG;AAE3D,MAAI,QAAQ,SACV,OAAM,KAAK,eAAe,QAAQ,WAAW;AAE/C,MAAI,QAAQ,YACV,OAAM,KAAK,cAAc,QAAQ,cAAc;AAEjD,MAAI,QAAQ,cACV,OAAM,KAAK,sBAAsB,QAAQ,gBAAgB;AAE3D,QAAM,KAAK,GAAG;;AAEhB,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAO,qCAAqC,MAAM,KAAK,KAAK,GAAG,MAAM;;;;;;;;AASvE,SAAgB,YACd,UACA,MACA,OACc;CACd,MAAM,SAAS,SAAS,IAAI,KAAK,KAAK;AACtC,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,6CAA6C,KAAK,KAAK,GAAG;CAG5E,MAAM,OAAO;EACX,aAAa,KAAK;EAClB,OAAO;EACP,qBAAqB,MAAM,MAAM;EAClC,CACE,OAAO,QAAQ,CACf,KAAK,OAAO;AAEf,QAAO;EACL,GAAG,cAAc,OAAO;EACxB,QAAQ;EACR,QAAQ,OAAO;EAChB;;;;AAKH,SAAgB,cACd,UACA,MACA,SAC4C;CAC5C,MAAM,SAAS,eACb,SAAS,IAAI,KAAK,KAAK,IAAI,cAC3B,QACD;AACD,QAAO;EACL,OAAO,KAAK,SAAS,OAAO;EAC5B,QAAQ,OAAO;EAChB;;AAGH,MAAM,eAAe,EAAE"}
@@ -1,17 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
2
- import { A as GPT5_6_LUNA_MODEL, D as DEFAULT_AGENT_MODEL, F as Harness, M as GPT5_6_TERRA_MODEL, _ as evaluateWizardReadiness, a as getLogFilePath, c as WIZARD_BENCHMARK_FILE, ct as WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, et as SONNET_5_MODEL, f as getUI, ft as WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, g as SIGNUP_WIZARD_READINESS_CONFIG, h as SERVICE_LABELS, i as enableDebugLogs, j as GPT5_6_SOL_MODEL, l as WIZARD_LOG_FILE, lt as WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, mt as getSkillsBaseUrl, o as initLogFile, rt as WIZARD_CONTACT_EMAIL, s as logToFile, st as WIZARD_ORCHESTRATOR_FLAG_KEY, t as configureLogFile, tt as Sequence, v as getBlockingServiceKeys, vt as RUN_SURFACE, xt as runtimeEnv } from "./debug-BTPYy9p7.js";
3
- import { a as ciExcludedTaskTypes, n as analytics, r as groupsFromUser } from "./analytics-BdKBzz4M.js";
4
- import { t as getOrAskForProjectData } from "./setup-utils-iINkc0xu.js";
2
+ import { A as GPT5_6_LUNA_MODEL, D as DEFAULT_AGENT_MODEL, F as Harness, M as GPT5_6_TERRA_MODEL, _ as evaluateWizardReadiness, a as getLogFilePath, c as WIZARD_BENCHMARK_FILE, ct as WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, et as SONNET_5_MODEL, f as getUI, ft as WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, g as SIGNUP_WIZARD_READINESS_CONFIG, h as SERVICE_LABELS, i as enableDebugLogs, j as GPT5_6_SOL_MODEL, l as WIZARD_LOG_FILE, lt as WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, mt as getSkillsBaseUrl, o as initLogFile, rt as WIZARD_CONTACT_EMAIL, s as logToFile, st as WIZARD_ORCHESTRATOR_FLAG_KEY, t as configureLogFile, tt as Sequence, v as getBlockingServiceKeys, vt as RUN_SURFACE, xt as runtimeEnv } from "./debug-BYIoy1Oz.js";
3
+ import { a as ciExcludedTaskTypes, n as analytics, r as groupsFromUser } from "./analytics-YLZKudpE.js";
4
+ import { t as getOrAskForProjectData } from "./setup-utils-e78zkZoW.js";
5
5
  import "./wizard-session-BUhlJ1b8.js";
6
- import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-CztG5WTv.js";
7
- import { n as isNonInteractiveEnvironment } from "./environment-lV2X1gS-.js";
8
- import { c as QueueStore, h as requireKnownModel, l as TaskStatus, o as uncoveredBySink, p as isValidModel, s as QUEUE_DIR_NAME } from "./queue-tools-zM8_mxx6.js";
9
- import { E as installSkillById, F as createTriageLLMProvider, N as createWizardAskBridge, T as fetchSkillMenu, c as classifySettingsConflicts, i as runAgent$1, n as buildRunTags, o as backupAndFixClaudeSettings, p as AgentSignals, r as initializeAgent, s as checkAllSettingsConflicts, u as restoreClaudeSettings } from "./agent-interface-C90hyvs1.js";
10
- import { a as flushScanReport, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-DeLjTIiJ.js";
11
- import { a as piBackend, s as createAioCapture } from "./pi-CVJB0Ban.js";
12
- import { r as detectNodePackageManagers } from "./package-manager-z33XHEWO.js";
13
- import { t as FRAMEWORK_REGISTRY } from "./registry-DF_aKyS0.js";
14
- import { a as assembleTaskPrompt, d as taskModelSpec, i as assembleSeedPrompt, n as agentRunTools, o as loadAgentRegistry, s as promptModelFor, t as ASK_TOOL, u as resolveTask } from "./agent-prompt-loader-CBj2DWAJ.js";
6
+ import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-DRscjUOg.js";
7
+ import { n as isNonInteractiveEnvironment } from "./environment-Br-oy8cq.js";
8
+ import { _ as requireKnownModel, c as uncoveredBySink, d as TaskStatus, h as isValidModel, l as QUEUE_DIR_NAME, s as dependencyClosure, u as QueueStore } from "./queue-tools-BtJ7_fEW.js";
9
+ import { E as installSkillById, F as createTriageLLMProvider, N as createWizardAskBridge, T as fetchSkillMenu, c as classifySettingsConflicts, i as runAgent$1, n as buildRunTags, o as backupAndFixClaudeSettings, p as AgentSignals, r as initializeAgent, s as checkAllSettingsConflicts, u as restoreClaudeSettings } from "./agent-interface-C4CV7p0L.js";
10
+ import { a as flushScanReport, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-DKRsn0lN.js";
11
+ import { a as piBackend, s as createAioCapture } from "./pi-DeF8mWlb.js";
12
+ import { r as detectNodePackageManagers } from "./package-manager-FyJmIsqr.js";
13
+ import { t as FRAMEWORK_REGISTRY } from "./registry-B-whj8SQ.js";
14
+ import { a as assembleTaskPrompt, d as taskModelSpec, i as assembleSeedPrompt, n as agentRunTools, o as loadAgentRegistry, s as promptModelFor, t as ASK_TOOL, u as resolveTask } from "./agent-prompt-loader-DiM8xfSZ.js";
15
15
  import fs, { cpSync, existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "fs";
16
16
  import * as path$1 from "path";
17
17
  import path from "path";
@@ -21,7 +21,7 @@ import { randomUUID } from "crypto";
21
21
  async function authenticate(session, programId) {
22
22
  if (session.credentials) return;
23
23
  logToFile("[agent-runner] starting OAuth");
24
- const { projectApiKey, host, accessToken, projectId, roleAtOrganization, user, project } = await getOrAskForProjectData({
24
+ const { projectApiKey, host, accessToken, projectId, roleAtOrganization, user, project, missingScopes } = await getOrAskForProjectData({
25
25
  signup: session.signup,
26
26
  ci: session.ci,
27
27
  apiKey: session.apiKey,
@@ -36,7 +36,8 @@ async function authenticate(session, programId) {
36
36
  accessToken,
37
37
  projectApiKey,
38
38
  host,
39
- projectId
39
+ projectId,
40
+ missingScopes
40
41
  };
41
42
  session.apiProject = project;
42
43
  session.roleAtOrganization = roleAtOrganization;
@@ -105,6 +106,7 @@ const anthropicBackend = {
105
106
  additionalFeatureQueue: config.additionalFeatureQueue ?? [],
106
107
  abortCases: config.abortCases,
107
108
  emitStepEvents: config.trackStepProgress ?? false,
109
+ resolveStepKey: config.resolveStepKey,
108
110
  triageProvider: boot.triageProvider
109
111
  }, middleware);
110
112
  },
@@ -1614,6 +1616,7 @@ var RunMetrics = class {
1614
1616
  firstStartMs;
1615
1617
  lastStartMs;
1616
1618
  firstCompleteMs;
1619
+ firstAskMs;
1617
1620
  lastVisibleMs;
1618
1621
  maxGapMs = 0;
1619
1622
  constructor(runStartMs) {
@@ -1640,6 +1643,14 @@ var RunMetrics = class {
1640
1643
  this.markVisible(nowMs);
1641
1644
  }
1642
1645
  /**
1646
+ * A question was put to the user. Only the first matters here, and it is not a
1647
+ * queue transition — waiting on a person is not the silence `max_gap_ms`
1648
+ * measures, so this deliberately does not mark visible progress.
1649
+ */
1650
+ recordAsk(nowMs) {
1651
+ this.firstAskMs ??= nowMs;
1652
+ }
1653
+ /**
1643
1654
  * The run-level responsiveness summary. Timings are `undefined` when the
1644
1655
  * relevant transition never happened (e.g. a run that started no task), so a
1645
1656
  * no-task run stays distinguishable from a genuine zero.
@@ -1648,7 +1659,8 @@ var RunMetrics = class {
1648
1659
  return {
1649
1660
  time_to_first_task_ms: this.firstStartMs === void 0 ? void 0 : this.firstStartMs - this.runStartMs,
1650
1661
  time_to_first_completion_ms: this.firstCompleteMs === void 0 ? void 0 : this.firstCompleteMs - this.runStartMs,
1651
- max_gap_ms: this.lastVisibleMs === void 0 ? void 0 : this.maxGapMs
1662
+ max_gap_ms: this.lastVisibleMs === void 0 ? void 0 : this.maxGapMs,
1663
+ time_to_first_ask_ms: this.firstAskMs === void 0 ? void 0 : this.firstAskMs - this.runStartMs
1652
1664
  };
1653
1665
  }
1654
1666
  /** requeue is not user-visible, so a retry stall counts as silence here. */
@@ -1658,6 +1670,72 @@ var RunMetrics = class {
1658
1670
  }
1659
1671
  };
1660
1672
  //#endregion
1673
+ //#region src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts
1674
+ /**
1675
+ * Resolve a runner-seeded task's dependencies against the planned queue.
1676
+ *
1677
+ * Two exclusions apply to both the declared and the default path:
1678
+ *
1679
+ * - **Sinks are never dependencies.** A sink runs last and must depend on the
1680
+ * whole queue, this task included. Depending on it back would invert the edge
1681
+ * and cost the report this task's `reportSection`. Leaving sinks out means a
1682
+ * planner that forgot the sink→seeded edge is still caught by the sink
1683
+ * invariant check rather than silently papered over here.
1684
+ * - **Anything already downstream of this task is never a dependency**, which is
1685
+ * what makes the result cycle-free by construction rather than by the queue's
1686
+ * per-edge refusal.
1687
+ */
1688
+ function seededDependencies(store, seededTaskId, declaredTypes, sinkTypes) {
1689
+ const eligible = store.list().filter((task) => {
1690
+ if (task.id === seededTaskId) return false;
1691
+ if (sinkTypes.includes(task.type)) return false;
1692
+ return !dependencyClosure(store, [task.id]).has(seededTaskId);
1693
+ });
1694
+ if (declaredTypes.length === 0) return {
1695
+ depIds: eligible.map((t) => t.id),
1696
+ unresolvedTypes: [],
1697
+ declared: false
1698
+ };
1699
+ const depIds = [];
1700
+ const unresolvedTypes = [];
1701
+ for (const type of declaredTypes) {
1702
+ if (!store.list().some((t) => t.type === type)) {
1703
+ unresolvedTypes.push(type);
1704
+ continue;
1705
+ }
1706
+ for (const task of eligible) if (task.type === type && !depIds.includes(task.id)) depIds.push(task.id);
1707
+ }
1708
+ return {
1709
+ depIds,
1710
+ unresolvedTypes,
1711
+ declared: true
1712
+ };
1713
+ }
1714
+ /**
1715
+ * Give every runner-seeded task the dependencies it could not name at enqueue,
1716
+ * and report what happened per task.
1717
+ *
1718
+ * The runner calls this once, after the planner has seeded the queue and before
1719
+ * the sink invariant is checked. Kept here rather than inline in the runner so
1720
+ * the wiring — which prompt's types feed which task — is testable without
1721
+ * standing up a whole run.
1722
+ */
1723
+ function deferSeededTasks(store, seededTasks, declaredTypesFor, sinkTypes) {
1724
+ return seededTasks.map((seeded) => {
1725
+ const declaredTypes = [...declaredTypesFor(seeded.type)];
1726
+ const resolved = seededDependencies(store, seeded.id, declaredTypes, sinkTypes);
1727
+ const { added, refused } = store.addDependencies(seeded.id, resolved.depIds);
1728
+ return {
1729
+ type: seeded.type,
1730
+ declaredTypes,
1731
+ declared: resolved.declared,
1732
+ added,
1733
+ refused,
1734
+ unresolvedTypes: resolved.unresolvedTypes
1735
+ };
1736
+ });
1737
+ }
1738
+ //#endregion
1661
1739
  //#region src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts
1662
1740
  /**
1663
1741
  * Experimental task-queue orchestrator runner.
@@ -1747,6 +1825,43 @@ function resolveReferenceSkillId(entries, framework) {
1747
1825
  * — the executor holds the task's promise — so the only real limit is this one.
1748
1826
  */
1749
1827
  const TASK_ASK_TIMEOUT_MS = 1200 * 1e3;
1828
+ /**
1829
+ * How long an optional step's notice waits for an answer.
1830
+ *
1831
+ * Much shorter than the ask timeout above, because it is asking for something
1832
+ * much smaller: one keypress to accept or decline, not "go mint a restricted
1833
+ * Stripe key". The notice is also the only interactive screen sitting in front
1834
+ * of the run's final steps, so an unanswered one holds the report — and with it
1835
+ * the notebook and the outro — behind a modal nobody is looking at.
1836
+ */
1837
+ const TASK_NOTICE_TIMEOUT_MS = 300 * 1e3;
1838
+ /**
1839
+ * Offer an optional step, defaulting to declining it if nobody answers.
1840
+ *
1841
+ * Skip is the right default on a timeout: continuing would send the step on to
1842
+ * ask for credentials that the same absent user cannot supply either, burning
1843
+ * {@link TASK_ASK_TIMEOUT_MS} per question before falling back to the same
1844
+ * links declining gives immediately.
1845
+ */
1846
+ async function offerSeededTask(notice, timeoutMs = TASK_NOTICE_TIMEOUT_MS) {
1847
+ let timer;
1848
+ let timedOut = false;
1849
+ const timeout = new Promise((resolve) => {
1850
+ timer = setTimeout(() => {
1851
+ timedOut = true;
1852
+ getUI().cancelTaskNotice();
1853
+ resolve(false);
1854
+ }, timeoutMs);
1855
+ });
1856
+ try {
1857
+ return {
1858
+ keep: await Promise.race([getUI().showTaskNotice(notice), timeout]),
1859
+ timedOut
1860
+ };
1861
+ } finally {
1862
+ if (timer) clearTimeout(timer);
1863
+ }
1864
+ }
1750
1865
  /** Whether a task's prompt lets it ask the user, and so needs the ask bridge. */
1751
1866
  function canAsk(prompt) {
1752
1867
  return (prompt?.allowedTools ?? []).includes(ASK_TOOL);
@@ -1789,7 +1904,7 @@ function displayOrder(tasks, isOptional) {
1789
1904
  index
1790
1905
  })).sort((a, b) => a.depth - b.depth || a.optional - b.optional || a.index - b.index).map((entry) => entry.task);
1791
1906
  }
1792
- async function runOrchestrator(session, programConfig, boot) {
1907
+ async function runOrchestrator(session, config, programConfig, boot) {
1793
1908
  const runId = randomUUID();
1794
1909
  const switchboardCtx = {
1795
1910
  program: programConfig.id,
@@ -1927,27 +2042,19 @@ or integrate manually here:
1927
2042
  store,
1928
2043
  validTypes: registry.enqueueableTypes,
1929
2044
  sinkTypes: registry.sinkTypes,
2045
+ runnerSeededTypes: registry.runnerSeededTypes,
1930
2046
  currentTaskId
1931
2047
  });
1932
2048
  const seedEntries = areSeededTasksEnabled(boot.wizardFlags) ? programConfig.seedTasks?.(session) ?? [] : [];
1933
2049
  const seededTypes = [];
2050
+ const seededTasks = [];
2051
+ const seededNotices = /* @__PURE__ */ new Map();
1934
2052
  for (const seeded of seedEntries) {
1935
2053
  if (!registry.runnerSeededTypes.includes(seeded.type)) {
1936
2054
  logToFile(`[orchestrator] skipping runner-seeded task "${seeded.type}": not a runner-seeded type in this flow`);
1937
2055
  continue;
1938
2056
  }
1939
- if (seeded.notice) {
1940
- const keep = await getUI().showTaskNotice(seeded.notice);
1941
- analytics.wizardCapture("orchestrator task notice answered", {
1942
- type: seeded.type,
1943
- kept: keep
1944
- });
1945
- if (!keep) {
1946
- logToFile(`[orchestrator] user declined runner-seeded ${seeded.type}`);
1947
- continue;
1948
- }
1949
- }
1950
- store.enqueue({
2057
+ const task = store.enqueue({
1951
2058
  type: seeded.type,
1952
2059
  label: seeded.label,
1953
2060
  inputs: seeded.inputs,
@@ -1955,6 +2062,8 @@ or integrate manually here:
1955
2062
  optional: true
1956
2063
  });
1957
2064
  seededTypes.push(seeded.type);
2065
+ seededTasks.push(task);
2066
+ if (seeded.notice) seededNotices.set(task.id, seeded.notice);
1958
2067
  logToFile(`[orchestrator] runner-seeded task ${seeded.type}`);
1959
2068
  }
1960
2069
  const askingTypes = seededTypes.filter((type) => canAsk(registry.get(type)));
@@ -1966,9 +2075,12 @@ or integrate manually here:
1966
2075
  });
1967
2076
  const askBridge = shouldDisableAsk(session) ? void 0 : createWizardAskBridge({
1968
2077
  getSource: () => session.skillId ?? programConfig.id,
1969
- showQuestion: (q) => getUI().requestQuestion(q),
2078
+ showQuestion: (q) => {
2079
+ metrics.recordAsk(Date.now());
2080
+ return getUI().requestQuestion(q);
2081
+ },
1970
2082
  cancelQuestion: () => getUI().cancelPendingQuestion(),
1971
- richLinks: false,
2083
+ richLinks: config.richLinks ?? false,
1972
2084
  timeoutMs: TASK_ASK_TIMEOUT_MS
1973
2085
  });
1974
2086
  const spinner = getUI().spinner();
@@ -1999,6 +2111,28 @@ or integrate manually here:
1999
2111
  types: store.list().map((t) => t.type)
2000
2112
  });
2001
2113
  renderQueue();
2114
+ const deferred = deferSeededTasks(store, seededTasks, (type) => registry.get(type)?.dependsOn ?? [], registry.sinkTypes);
2115
+ for (const entry of deferred) {
2116
+ logToFile(`[orchestrator] deferred runner-seeded ${entry.type}: ${entry.added.length} deps (${entry.declared ? `declared: ${entry.declaredTypes.join(", ")}` : "default"})${entry.refused.length > 0 ? `, ${entry.refused.length} refused` : ""}${entry.unresolvedTypes.length > 0 ? `, unresolved: ${entry.unresolvedTypes.join(", ")}` : ""}`);
2117
+ analytics.wizardCapture("orchestrator seeded task deferred", {
2118
+ type: entry.type,
2119
+ dep_count: entry.added.length,
2120
+ declared: entry.declared,
2121
+ declared_types: entry.declaredTypes,
2122
+ unresolved_types: entry.unresolvedTypes,
2123
+ refused_count: entry.refused.length
2124
+ });
2125
+ }
2126
+ if (deferred.length > 0) renderQueue();
2127
+ for (const seeded of seededTasks) {
2128
+ const dependants = store.list().filter((t) => !registry.sinkTypes.includes(t.type) && t.id !== seeded.id && dependencyClosure(store, [t.id]).has(seeded.id));
2129
+ if (dependants.length === 0) continue;
2130
+ logToFile(`[orchestrator] one-way rule broken: ${dependants.map((t) => t.type).join(", ")} depend on runner-seeded ${seeded.type}`);
2131
+ analytics.wizardCapture("orchestrator seeded task depended on", {
2132
+ type: seeded.type,
2133
+ dependant_types: dependants.map((t) => t.type)
2134
+ });
2135
+ }
2002
2136
  const unwaited = store.list().filter((t) => registry.sinkTypes.includes(t.type)).flatMap((sink) => uncoveredBySink({
2003
2137
  store,
2004
2138
  validTypes: registry.types,
@@ -2020,8 +2154,38 @@ or integrate manually here:
2020
2154
  const taskSkillsRoot = path$1.join(QUEUE_DIR_NAME, "skills");
2021
2155
  const claudeSkillsDir = path$1.join(session.installDir, ".claude", "skills");
2022
2156
  const preexistingSkills = new Set(existsSync(claudeSkillsDir) ? readdirSync(claudeSkillsDir) : []);
2157
+ let noticeGate = Promise.resolve();
2023
2158
  const runTask = async (task) => {
2024
2159
  renderQueue();
2160
+ const notice = seededNotices.get(task.id);
2161
+ if (notice) {
2162
+ seededNotices.delete(task.id);
2163
+ const offer = noticeGate.then(() => offerSeededTask(notice));
2164
+ noticeGate = offer.catch(() => void 0);
2165
+ const { keep, timedOut } = await offer.catch((err) => {
2166
+ logToFile(`[orchestrator] notice failed for ${task.type}, declining: ${String(err)}`);
2167
+ analytics.captureException(err instanceof Error ? err : new Error(String(err)), { step: "orchestrator_task_notice" });
2168
+ return {
2169
+ keep: false,
2170
+ timedOut: false
2171
+ };
2172
+ });
2173
+ analytics.wizardCapture("orchestrator task notice answered", {
2174
+ type: task.type,
2175
+ kept: keep,
2176
+ timed_out: timedOut
2177
+ });
2178
+ if (!keep) {
2179
+ logToFile(`[orchestrator] runner-seeded ${task.type} declined (${timedOut ? "timed out" : "by the user"})`);
2180
+ store.skip(task.id, {
2181
+ goals: notice.title,
2182
+ did: timedOut ? "Nothing — the step was offered and the offer timed out with no answer." : "Nothing — the user chose to skip this step when offered it.",
2183
+ forNextAgent: timedOut ? "This step was offered and nobody answered, so it did no work. Report it as not set up, and point the user at how to do it later." : "This step was offered and declined, so it did no work. Report it as skipped at the user’s request, not as failed."
2184
+ });
2185
+ renderQueue();
2186
+ return;
2187
+ }
2188
+ }
2025
2189
  try {
2026
2190
  const resolved = resolveTask(registry, task, store);
2027
2191
  const skillPaths = [];
@@ -2116,12 +2280,15 @@ or integrate manually here:
2116
2280
  const blocked = verdict.blocked;
2117
2281
  if (verdict.requiredFailedTypes.length > 0 || blocked > 0) {
2118
2282
  const failedTypes = verdict.requiredFailedTypes.join(", ");
2283
+ const whatFailed = failedTypes ? `the ${failedTypes} step failed` : `${blocked} steps never ran`;
2284
+ const missingScopes = boot.credentials.missingScopes ?? [];
2119
2285
  await wizardAbort({
2120
- message: `The wizard was unable to set up PostHog: ${failedTypes ? `the ${failedTypes} step failed` : `${blocked} steps never ran`}.\n\nPlease report this to: ${WIZARD_CONTACT_EMAIL}`,
2286
+ message: missingScopes.length > 0 ? `The wizard could not finish setup: ${whatFailed}, and this run was authorized without the following permission${missingScopes.length === 1 ? "" : "s"}: ${missingScopes.join(", ")}.\n\nPlease try again, approving all permissions on the PostHog authorization screen. If it still fails, report it to: ${WIZARD_CONTACT_EMAIL}` : `The wizard was unable to set up PostHog: ${whatFailed}.\n\nPlease report this to: ${WIZARD_CONTACT_EMAIL}`,
2121
2287
  error: new WizardError("orchestrator drain ended with failed tasks", {
2122
2288
  tasks_failed: summary.failed,
2123
2289
  tasks_blocked: blocked,
2124
2290
  failed_types: failedTypes,
2291
+ missing_oauth_scopes: missingScopes.join(" "),
2125
2292
  queue_state: JSON.stringify(store.list())
2126
2293
  })
2127
2294
  });
@@ -2151,7 +2318,7 @@ const SEQUENCE_OPTIONS = {
2151
2318
  },
2152
2319
  ["orchestrator"]: {
2153
2320
  name: "orchestrator",
2154
- run: (session, _config, programConfig, boot, _composed) => runOrchestrator(session, programConfig, boot)
2321
+ run: (session, config, programConfig, boot, _composed) => runOrchestrator(session, config, programConfig, boot)
2155
2322
  }
2156
2323
  };
2157
2324
  function getSequence(name) {
@@ -2521,4 +2688,4 @@ var agent_runner_exports = /* @__PURE__ */ __exportAll({ runAgent: () => runAgen
2521
2688
  //#endregion
2522
2689
  export { formatCostUsd as a, computeTokenCostUsd as i, runAgent as n, formatTokenCount as o, shouldDisableAsk as r, authenticate as s, agent_runner_exports as t };
2523
2690
 
2524
- //# sourceMappingURL=agent-runner-DA5YfjOD.js.map
2691
+ //# sourceMappingURL=agent-runner-X3JWS2WK.js.map