@posthog/wizard 2.76.1 → 2.77.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/README.md +16 -15
- package/dist/{add-mcp-server-to-clients-4yHaRvOo.js → add-mcp-server-to-clients-BnRyE4pw.js} +428 -114
- package/dist/add-mcp-server-to-clients-BnRyE4pw.js.map +1 -0
- package/dist/{agent-interface-DPaPdIjS.js → agent-interface-Avtr_5M5.js} +34 -10
- package/dist/agent-interface-Avtr_5M5.js.map +1 -0
- package/dist/{agent-prompt-loader-BlhabNM2.js → agent-prompt-loader-CHixNPgY.js} +23 -7
- package/dist/agent-prompt-loader-CHixNPgY.js.map +1 -0
- package/dist/{agent-runner-JFwQQj2k.js → agent-runner-COOIUJCP.js} +171 -83
- package/dist/agent-runner-COOIUJCP.js.map +1 -0
- package/dist/{analytics-DSVyjIVF.js → analytics-C67F2vee.js} +2 -2
- package/dist/{analytics-DSVyjIVF.js.map → analytics-C67F2vee.js.map} +1 -1
- package/dist/analytics-CJA1uLlk.js +2 -0
- package/dist/{api-Ci0dZWLR.js → api-Dj1yabTj.js} +3 -3
- package/dist/{api-Ci0dZWLR.js.map → api-Dj1yabTj.js.map} +1 -1
- package/dist/bin.js +41 -41
- package/dist/bin.js.map +1 -1
- package/dist/{bounded-fs-FbZJ_vJ_.js → bounded-fs-CWRYuLAn.js} +3 -3
- package/dist/bounded-fs-CWRYuLAn.js.map +1 -0
- package/dist/{ci-install-CEVCqahf.js → ci-install-CvXL5h13.js} +5 -5
- package/dist/{ci-install-CEVCqahf.js.map → ci-install-CvXL5h13.js.map} +1 -1
- package/dist/{debug-DWYDVp0B.js → debug-B4kzIZPi.js} +10 -6
- package/dist/debug-B4kzIZPi.js.map +1 -0
- package/dist/{debug-C6KWXbQi.js → debug-CziFS0cA.js} +1 -1
- package/dist/{defaults-DulzMJpN.js → defaults-4c4YwTmW.js} +26 -3
- package/dist/defaults-4c4YwTmW.js.map +1 -0
- package/dist/{env-api-key-DwmkB3fm.js → env-api-key-BZ5wE3Y4.js} +2 -2
- package/dist/{env-api-key-DwmkB3fm.js.map → env-api-key-BZ5wE3Y4.js.map} +1 -1
- package/dist/{environment-1wA7uwAS.js → environment-BEvsey6i.js} +4 -4
- package/dist/{environment-1wA7uwAS.js.map → environment-BEvsey6i.js.map} +1 -1
- package/dist/{errors--OqLxmWR.js → errors-BoJvrdw8.js} +4 -2
- package/dist/errors-BoJvrdw8.js.map +1 -0
- package/dist/{file-C3HGL1IM.js → file-BoD3REGB.js} +2 -2
- package/dist/{file-C3HGL1IM.js.map → file-BoD3REGB.js.map} +1 -1
- package/dist/{file-watcher-D8s0b-VT.js → file-watcher-BPFazvG_.js} +2 -2
- package/dist/{file-watcher-D8s0b-VT.js.map → file-watcher-BPFazvG_.js.map} +1 -1
- package/dist/{gateway-session-s1xr8b48.js → gateway-session-C118uACz.js} +1 -1
- package/dist/{gateway-session-OqzCMpZ9.js → gateway-session-xPFv6p5c.js} +5 -5
- package/dist/{gateway-session-OqzCMpZ9.js.map → gateway-session-xPFv6p5c.js.map} +1 -1
- package/dist/{headless-ui-DRGWDg9Z.js → headless-ui-CsmQrDIl.js} +2 -2
- package/dist/{headless-ui-DRGWDg9Z.js.map → headless-ui-CsmQrDIl.js.map} +1 -1
- package/dist/{interactive-B6OlvhSf.js → interactive-Dej-sxvR.js} +2 -2
- package/dist/{interactive-B6OlvhSf.js.map → interactive-Dej-sxvR.js.map} +1 -1
- package/dist/{mcp-BprhJJ2c.js → mcp-Cbuw_xss.js} +2 -2
- package/dist/{mcp-BprhJJ2c.js.map → mcp-Cbuw_xss.js.map} +1 -1
- package/dist/{mcp-prompt-streaming-E1d8DJcX.js → mcp-prompt-streaming-BU_kuur_.js} +5 -5
- package/dist/{mcp-prompt-streaming-E1d8DJcX.js.map → mcp-prompt-streaming-BU_kuur_.js.map} +1 -1
- package/dist/{mint-failure-C82j0RMC.js → mint-failure-BrleGqMd.js} +68 -39
- package/dist/mint-failure-BrleGqMd.js.map +1 -0
- package/dist/{non-interactive-DGT2H_n4.js → non-interactive-DcOjH2fw.js} +3 -3
- package/dist/{non-interactive-DGT2H_n4.js.map → non-interactive-DcOjH2fw.js.map} +1 -1
- package/dist/{orchestrator-tools-BBBNV1z5.js → orchestrator-tools-DXwr8Sp3.js} +4 -4
- package/dist/orchestrator-tools-DXwr8Sp3.js.map +1 -0
- package/dist/{package-manager-DU3aVif4.js → package-manager-DR23m5Jg.js} +2 -2
- package/dist/{package-manager-DU3aVif4.js.map → package-manager-DR23m5Jg.js.map} +1 -1
- package/dist/{pi-fG5fT50Y.js → pi-mY8I2XkG.js} +13 -13
- package/dist/{pi-fG5fT50Y.js.map → pi-mY8I2XkG.js.map} +1 -1
- package/dist/{playground-UFSHP-Yn.js → playground-CDUUKLkC.js} +13 -9
- package/dist/playground-CDUUKLkC.js.map +1 -0
- package/dist/{posthog-O9kKcnda.js → posthog-Hc_-9wrr.js} +2 -2
- package/dist/{posthog-O9kKcnda.js.map → posthog-Hc_-9wrr.js.map} +1 -1
- package/dist/{provisioning-B-tzjG4r.js → provisioning-xfdjhFtA.js} +3 -3
- package/dist/{provisioning-B-tzjG4r.js.map → provisioning-xfdjhFtA.js.map} +1 -1
- package/dist/{queue-tools-7Oso-fpt.js → queue-tools-C8y_xZJi.js} +8 -4
- package/dist/queue-tools-C8y_xZJi.js.map +1 -0
- package/dist/{registry-D1L5e-WQ.js → registry-DTmREJ-f.js} +5 -5
- package/dist/{registry-D1L5e-WQ.js.map → registry-DTmREJ-f.js.map} +1 -1
- package/dist/{security-n3-xdINN.js → security-Dw2oFJjP.js} +5 -5
- package/dist/{security-n3-xdINN.js.map → security-Dw2oFJjP.js.map} +1 -1
- package/dist/{setup-utils-Bj0gejEf.js → setup-utils-fjJTBhaB.js} +8 -8
- package/dist/setup-utils-fjJTBhaB.js.map +1 -0
- package/dist/{start-tui-BowrTPXm.js → start-tui-UNe2xQ0U.js} +25 -25
- package/dist/start-tui-UNe2xQ0U.js.map +1 -0
- package/dist/{steps-CpNTGu9N.js → steps-C2yqOk_h.js} +7 -7
- package/dist/{steps-CpNTGu9N.js.map → steps-C2yqOk_h.js.map} +1 -1
- package/dist/{store-CVkJKlny.js → store-Bic4Cr3L.js} +5 -32
- package/dist/store-Bic4Cr3L.js.map +1 -0
- package/dist/{subagent-SxmvfDfp.js → subagent-Dz41vV9j.js} +2 -2
- package/dist/{subagent-SxmvfDfp.js.map → subagent-Dz41vV9j.js.map} +1 -1
- package/dist/{task-nF7Ry8ff.js → task-5-fw_Vw3.js} +14 -14
- package/dist/{task-nF7Ry8ff.js.map → task-5-fw_Vw3.js.map} +1 -1
- package/dist/{task-stream-C9BLiAhz.js → task-stream-dVzl6b_q.js} +6 -6
- package/dist/{task-stream-C9BLiAhz.js.map → task-stream-dVzl6b_q.js.map} +1 -1
- package/dist/{tasks-BEEVIBcT.js → tasks-D1c2z1aw.js} +2 -2
- package/dist/{tasks-BEEVIBcT.js.map → tasks-D1c2z1aw.js.map} +1 -1
- package/dist/{telemetry-PD7bhcda.js → telemetry-BRnxBRWK.js} +3 -3
- package/dist/{telemetry-PD7bhcda.js.map → telemetry-BRnxBRWK.js.map} +1 -1
- package/dist/{terminal-NhNl-BIA.js → terminal-9bvRa4Qt.js} +38 -34
- package/dist/terminal-9bvRa4Qt.js.map +1 -0
- package/dist/{tools-BBdpgcIf.js → tools-Dp6i9k70.js} +8 -8
- package/dist/{tools-BBdpgcIf.js.map → tools-Dp6i9k70.js.map} +1 -1
- package/dist/{wizard-abort-D3YA1hXX.js → wizard-abort-CAcInAxg.js} +1 -1
- package/dist/{wizard-abort-hqHF-9xD.js → wizard-abort-lE6umflt.js} +4 -4
- package/dist/{wizard-abort-hqHF-9xD.js.map → wizard-abort-lE6umflt.js.map} +1 -1
- package/dist/{yara-hooks-BaPKsm-B.js → yara-hooks-BTNJ6MGW.js} +4 -4
- package/dist/{yara-hooks-BaPKsm-B.js.map → yara-hooks-BTNJ6MGW.js.map} +1 -1
- package/dist/yara-hooks-CFY4pGcW.js +2 -0
- package/package.json +8 -1
- package/dist/add-mcp-server-to-clients-4yHaRvOo.js.map +0 -1
- package/dist/agent-interface-DPaPdIjS.js.map +0 -1
- package/dist/agent-prompt-loader-BlhabNM2.js.map +0 -1
- package/dist/agent-runner-JFwQQj2k.js.map +0 -1
- package/dist/analytics-CcHoyhE_.js +0 -2
- package/dist/bounded-fs-FbZJ_vJ_.js.map +0 -1
- package/dist/debug-DWYDVp0B.js.map +0 -1
- package/dist/defaults-DulzMJpN.js.map +0 -1
- package/dist/errors--OqLxmWR.js.map +0 -1
- package/dist/mint-failure-C82j0RMC.js.map +0 -1
- package/dist/orchestrator-tools-BBBNV1z5.js.map +0 -1
- package/dist/playground-UFSHP-Yn.js.map +0 -1
- package/dist/queue-tools-7Oso-fpt.js.map +0 -1
- package/dist/setup-utils-Bj0gejEf.js.map +0 -1
- package/dist/start-tui-BowrTPXm.js.map +0 -1
- package/dist/store-CVkJKlny.js.map +0 -1
- package/dist/terminal-NhNl-BIA.js.map +0 -1
- package/dist/yara-hooks-CwfQuEl3.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as logToFile } from "./debug-
|
|
2
|
-
import { n as analytics } from "./analytics-
|
|
3
|
-
import { R as WIZARD_TOOL_NAMES, rt as fetchWithRetry } from "./agent-interface-
|
|
4
|
-
import {
|
|
1
|
+
import { s as logToFile } from "./debug-B4kzIZPi.js";
|
|
2
|
+
import { n as analytics } from "./analytics-C67F2vee.js";
|
|
3
|
+
import { R as WIZARD_TOOL_NAMES, rt as fetchWithRetry } from "./agent-interface-Avtr_5M5.js";
|
|
4
|
+
import { v as isThinkingLevel } from "./queue-tools-C8y_xZJi.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.
|
|
@@ -35,7 +35,18 @@ function renderToolInventory(toolNames) {
|
|
|
35
35
|
return `Your tools for this task: ${toolNames.join(", ")}. 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.`;
|
|
36
36
|
}
|
|
37
37
|
const 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.`;
|
|
38
|
-
const 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.`;
|
|
38
|
+
const SEED_BASICS = `You are the orchestrator. Plan the work and seed the queue with enqueue_task — each call names the task kind in its \`type\` field (the tool has no \`task\` field) and 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.`;
|
|
39
|
+
/**
|
|
40
|
+
* Injected only when the run excludes task types (a flag or CI gate), so the
|
|
41
|
+
* seed prompt of an ordinary run is byte-identical to one with no exclusions.
|
|
42
|
+
* Naming the types beats a "check the tool's list" rule: the planner has
|
|
43
|
+
* nothing to infer, and the pre-queued (runner-seeded) tasks — absent from the
|
|
44
|
+
* enqueue list by design — cannot be mistaken for exclusions.
|
|
45
|
+
*/
|
|
46
|
+
function excludedTypesNote(types) {
|
|
47
|
+
if (types.length === 0) return null;
|
|
48
|
+
return `The plan below may mention these task types, but this run excludes them: ${types.join(", ")}. enqueue_task will not accept them — do not queue them, do not retry them, and hang nothing off them.`;
|
|
49
|
+
}
|
|
39
50
|
/**
|
|
40
51
|
* Tasks the wizard queued before the planner ran. It has to see them: they are
|
|
41
52
|
* part of the run it is planning around, and the task that reports last has to
|
|
@@ -73,10 +84,11 @@ function assembleTaskPrompt(ctx, body, skillPaths = []) {
|
|
|
73
84
|
].filter(Boolean).join("\n\n");
|
|
74
85
|
}
|
|
75
86
|
/** The seed agent's full prompt: injected basics, then the authored intent. */
|
|
76
|
-
function assembleSeedPrompt(ctx, body, preQueued = []) {
|
|
87
|
+
function assembleSeedPrompt(ctx, body, preQueued = [], excludedTypes = []) {
|
|
77
88
|
return [
|
|
78
89
|
projectContext(ctx),
|
|
79
90
|
SEED_BASICS,
|
|
91
|
+
excludedTypesNote(excludedTypes),
|
|
80
92
|
preQueuedTasks(preQueued),
|
|
81
93
|
body
|
|
82
94
|
].filter(Boolean).join("\n\n");
|
|
@@ -128,11 +140,14 @@ function buildRegistry(prompts, flow, opts) {
|
|
|
128
140
|
});
|
|
129
141
|
const byType = new Map(inFlow.map((p) => [p.type, p]));
|
|
130
142
|
const tasks = inFlow.filter((p) => !p.seed);
|
|
143
|
+
const flowTypes = new Set(prompts.filter((p) => p.flow === flow && !p.seed).map((p) => p.type));
|
|
131
144
|
return {
|
|
132
145
|
types: tasks.map((p) => p.type),
|
|
133
146
|
enqueueableTypes: tasks.filter((p) => !p.runnerSeeded).map((p) => p.type),
|
|
134
147
|
sinkTypes: tasks.filter((p) => p.sink).map((p) => p.type),
|
|
135
148
|
runnerSeededTypes: tasks.filter((p) => p.runnerSeeded).map((p) => p.type),
|
|
149
|
+
optionalTypes: tasks.filter((p) => p.optional).map((p) => p.type),
|
|
150
|
+
excludedTypes: [...excluded].filter((t) => flowTypes.has(t)),
|
|
136
151
|
seed: inFlow.find((p) => p.seed),
|
|
137
152
|
get: (type) => byType.get(type)
|
|
138
153
|
};
|
|
@@ -195,6 +210,7 @@ function parseAgentPrompt(text, fallbackType, fallbackFlow) {
|
|
|
195
210
|
seed: fields.seed === "true",
|
|
196
211
|
sink: fields.sink === "true",
|
|
197
212
|
runnerSeeded: fields.runnerSeeded === "true",
|
|
213
|
+
optional: fields.optional === "true",
|
|
198
214
|
modelPi: str(fields.model_pi),
|
|
199
215
|
effortPi: effort(fields.effort_pi, "effort_pi"),
|
|
200
216
|
modelSdk: str(fields.model_sdk),
|
|
@@ -311,4 +327,4 @@ const EMPTY_PROMPT = {};
|
|
|
311
327
|
//#endregion
|
|
312
328
|
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 };
|
|
313
329
|
|
|
314
|
-
//# sourceMappingURL=agent-prompt-loader-
|
|
330
|
+
//# sourceMappingURL=agent-prompt-loader-CHixNPgY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-prompt-loader-CHixNPgY.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 // Both hosts, distinctly labelled: `apiHost` is the ingestion/API origin the\n // SDK talks to, `appHost` the user-facing web app. A task that hands the user\n // a link (e.g. the data-warehouse new-source fallback) must build it from the\n // app host — the ingestion host does not serve those pages.\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- PostHog app URL (base for any link you show the user in a browser): ${ctx.host.appHost}`;\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 names the task kind in its \\`type\\` field (the tool has no \\`task\\` field) and 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 * Injected only when the run excludes task types (a flag or CI gate), so the\n * seed prompt of an ordinary run is byte-identical to one with no exclusions.\n * Naming the types beats a \"check the tool's list\" rule: the planner has\n * nothing to infer, and the pre-queued (runner-seeded) tasks — absent from the\n * enqueue list by design — cannot be mistaken for exclusions.\n */\nfunction excludedTypesNote(types: readonly string[]): string | null {\n if (types.length === 0) return null;\n return `The plan below may mention these task types, but this run excludes them: ${types.join(\n ', ',\n )}. enqueue_task will not accept them — do not queue them, do not retry them, and hang nothing off them.`;\n}\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 excludedTypes: readonly string[] = [],\n): string {\n return [\n projectContext(ctx),\n SEED_BASICS,\n excludedTypesNote(excludedTypes),\n preQueuedTasks(preQueued),\n body,\n ]\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/** The skill-menu tools, as agents ask for them in frontmatter. */\nconst SKILL_MENU_TOOL = 'load_skill_menu';\nconst INSTALL_SKILL_TOOL = 'install_skill';\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 /** Marks a supplementary task: terminal failure unblocks dependents and never fails the run. */\n optional: boolean;\n /** Per-harness model/effort; both profiles also require gateway admission and prompt compatibility. */\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/** Pi selects the pi profile; the legacy Anthropic SDK selects the sdk profile. */\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 types whose terminal failure must not block dependents or fail the run. */\n readonly optionalTypes: string[];\n /**\n * The excluded types this flow actually had, deduped — the honest list for\n * the seed prompt's exclusion note. An exclusion naming a type the flow\n * never carried is dropped: telling the planner it was \"excluded\" would\n * describe work that was never available.\n */\n readonly excludedTypes: 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 const flowTypes = new Set(\n prompts.filter((p) => p.flow === flow && !p.seed).map((p) => p.type),\n );\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 optionalTypes: tasks.filter((p) => p.optional).map((p) => p.type),\n excludedTypes: [...excluded].filter((t) => flowTypes.has(t)),\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 === SKILL_MENU_TOOL) return WIZARD_TOOL_NAMES.loadSkillMenu;\n if (name === INSTALL_SKILL_TOOL) return WIZARD_TOOL_NAMES.installSkill;\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 optional: fields.optional === '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 };\n}\n\nconst EMPTY_PROMPT = {} as AgentPrompt;\n"],"mappings":";;;;;AAgDA,SAAS,eAAe,KAAw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KAAK,KAAK,IAAI,cAC3B,QACD;AACD,QAAO;EACL,OAAO,KAAK,SAAS,OAAO;EAC5B,QAAQ,OAAO;EAChB;;AAGH,MAAM,eAAe,EAAE"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
|
|
2
|
-
import { a as AGENT_ERROR_CODE, d as ErrorCodes, o as AgentSignals, r as skillErrorCode } from "./errors
|
|
3
|
-
import {
|
|
2
|
+
import { a as AGENT_ERROR_CODE, d as ErrorCodes, o as AgentSignals, r as skillErrorCode } from "./errors-BoJvrdw8.js";
|
|
3
|
+
import { B as Harness, C as AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS, Ct as runtimeEnv, F as GPT5_6_LUNA_MODEL, H as Integration, I as GPT5_6_SOL_MODEL, L as GPT5_6_TERRA_MODEL, M as DETECTION_TIMEOUT_MS, R as HAIKU_MODEL, _ as SIGNUP_WIZARD_READINESS_CONFIG, a as getLogFilePath, bt as RUN_SURFACE, c as WIZARD_BENCHMARK_FILE, dt as WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, g as SERVICE_LABELS, gt as getSkillsBaseUrl, i as enableDebugLogs, it as WIZARD_CONTACT_EMAIL, j as DEFAULT_AGENT_MODEL, l as WIZARD_LOG_FILE, lt as WIZARD_ORCHESTRATOR_FLAG_KEY, mt as WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, nt as Sequence, o as initLogFile, p as getUI, s as logToFile, t as configureLogFile, tt as SONNET_5_MODEL, ut as WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, v as evaluateWizardReadiness, vt as VERSION, w as AGENTIC_DETECTION_RETRY_TIMEOUT_MS, y as getBlockingServiceKeys } from "./debug-B4kzIZPi.js";
|
|
4
4
|
import { o as mayReportScanResults } from "./wizard-session-FSJCkTcP.js";
|
|
5
|
-
import { a as ciExcludedTaskTypes, n as analytics, r as groupsFromUser } from "./analytics-
|
|
6
|
-
import { a as safeReadFile, i as readProjectFile, o as walkProjectFiles } from "./bounded-fs-
|
|
7
|
-
import { c as OAuthError, s as refreshAccessToken, t as getOrAskForProjectData, u as mcpUrlFor } from "./setup-utils-
|
|
8
|
-
import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-
|
|
9
|
-
import { n as isNonInteractiveEnvironment } from "./environment-
|
|
10
|
-
import { G as fetchSkillMenu, K as installSkillById, at as createWizardAskBridge, c as checkAllSettingsConflicts, ct as isEnvFileName, d as restoreClaudeSettings, dt as markGrantRevoked, h as createTriageLLMProvider, i as runAgent$1, it as LONGER_ASK_TIMEOUT_MS, l as classifySettingsConflicts, lt as parseEnvKeyNames, n as buildRunTags, r as initializeAgent, s as backupAndFixClaudeSettings, st as MAX_ENV_KEY_SET, ut as toPromptSafeRelativePath } from "./agent-interface-
|
|
11
|
-
import { a as detectNodePackageManagers } from "./package-manager-
|
|
12
|
-
import { t as FRAMEWORK_REGISTRY } from "./registry-
|
|
13
|
-
import { o as gatewayAuth } from "./gateway-session-
|
|
14
|
-
import { _ as AUDIT_CHECKS_KEY, a as flushScanReport, b as coerceAuditChecks, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-
|
|
15
|
-
import {
|
|
16
|
-
import { a as piBackend, c as createAioCapture } from "./pi-
|
|
17
|
-
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-
|
|
18
|
-
import { t as startFileWatcher } from "./file-watcher-
|
|
5
|
+
import { a as ciExcludedTaskTypes, n as analytics, r as groupsFromUser } from "./analytics-C67F2vee.js";
|
|
6
|
+
import { a as safeReadFile, i as readProjectFile, o as walkProjectFiles } from "./bounded-fs-CWRYuLAn.js";
|
|
7
|
+
import { c as OAuthError, s as refreshAccessToken, t as getOrAskForProjectData, u as mcpUrlFor } from "./setup-utils-fjJTBhaB.js";
|
|
8
|
+
import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-lE6umflt.js";
|
|
9
|
+
import { n as isNonInteractiveEnvironment } from "./environment-BEvsey6i.js";
|
|
10
|
+
import { G as fetchSkillMenu, K as installSkillById, at as createWizardAskBridge, c as checkAllSettingsConflicts, ct as isEnvFileName, d as restoreClaudeSettings, dt as markGrantRevoked, h as createTriageLLMProvider, i as runAgent$1, it as LONGER_ASK_TIMEOUT_MS, l as classifySettingsConflicts, lt as parseEnvKeyNames, n as buildRunTags, r as initializeAgent, s as backupAndFixClaudeSettings, st as MAX_ENV_KEY_SET, ut as toPromptSafeRelativePath } from "./agent-interface-Avtr_5M5.js";
|
|
11
|
+
import { a as detectNodePackageManagers } from "./package-manager-DR23m5Jg.js";
|
|
12
|
+
import { t as FRAMEWORK_REGISTRY } from "./registry-DTmREJ-f.js";
|
|
13
|
+
import { o as gatewayAuth } from "./gateway-session-xPFv6p5c.js";
|
|
14
|
+
import { _ as AUDIT_CHECKS_KEY, a as flushScanReport, b as coerceAuditChecks, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-BTNJ6MGW.js";
|
|
15
|
+
import { _ as TaskStatus, d as uncoveredBySink, g as TASK_OUTCOMES_KEY, h as SkipReason, m as QueueStore, p as QUEUE_DIR_NAME, u as dependencyClosure, x as requireKnownModel, y as isValidModel } from "./queue-tools-C8y_xZJi.js";
|
|
16
|
+
import { a as piBackend, c as createAioCapture } from "./pi-mY8I2XkG.js";
|
|
17
|
+
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-CHixNPgY.js";
|
|
18
|
+
import { t as startFileWatcher } from "./file-watcher-BPFazvG_.js";
|
|
19
19
|
import * as semver from "semver";
|
|
20
20
|
import fs, { cpSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
21
21
|
import * as path$1 from "path";
|
|
@@ -288,6 +288,12 @@ async function checkFrameworkVersion(config, options) {
|
|
|
288
288
|
* discoverable. Runs AFTER auth: it uses the same agent loop every program
|
|
289
289
|
* uses, which needs credentials.
|
|
290
290
|
*/
|
|
291
|
+
var AgenticDetectionTimeoutError = class extends Error {
|
|
292
|
+
constructor(attempt, timeoutMs) {
|
|
293
|
+
super(`Project scan attempt ${attempt} timed out after ${timeoutMs / 1e3}s`);
|
|
294
|
+
this.name = "AgenticDetectionTimeoutError";
|
|
295
|
+
}
|
|
296
|
+
};
|
|
291
297
|
/**
|
|
292
298
|
* Every project-manifest / workspace-marker filename the wizard's frameworks
|
|
293
299
|
* are identified by. One brace-expansion Glob over all of these locates every
|
|
@@ -491,63 +497,74 @@ async function detectProjectsWithAgent(session, options) {
|
|
|
491
497
|
}),
|
|
492
498
|
call_type: "detection"
|
|
493
499
|
};
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
"
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
collected
|
|
516
|
-
collectedChars
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
500
|
+
const prompt = buildPrompt(cwd, targets, purpose, recommend);
|
|
501
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
502
|
+
const timeoutMs = attempt === 0 ? AGENTIC_DETECTION_FIRST_ATTEMPT_TIMEOUT_MS : AGENTIC_DETECTION_RETRY_TIMEOUT_MS;
|
|
503
|
+
const agent = await initializeAgent({
|
|
504
|
+
workingDirectory: cwd,
|
|
505
|
+
posthogMcpUrl: host.mcpUrl,
|
|
506
|
+
posthogApiKey: accessToken,
|
|
507
|
+
host,
|
|
508
|
+
detectPackageManager: detectNodePackageManagers,
|
|
509
|
+
skillsBaseUrl: getSkillsBaseUrl(),
|
|
510
|
+
programId,
|
|
511
|
+
integrationLabel: "agentic-detect",
|
|
512
|
+
wizardMetadata,
|
|
513
|
+
allowedTools: [
|
|
514
|
+
"Read",
|
|
515
|
+
"Grep",
|
|
516
|
+
"Glob"
|
|
517
|
+
],
|
|
518
|
+
modelOverride: HAIKU_MODEL
|
|
519
|
+
}, runOptions);
|
|
520
|
+
const MAX_TRANSCRIPT_CHARS = 256 * 1024;
|
|
521
|
+
const collected = [];
|
|
522
|
+
let collectedChars = 0;
|
|
523
|
+
const collect = (text) => {
|
|
524
|
+
collected.push(text);
|
|
525
|
+
collectedChars += text.length;
|
|
526
|
+
while (collectedChars > MAX_TRANSCRIPT_CHARS && collected.length > 1) collectedChars -= collected.shift().length;
|
|
527
|
+
};
|
|
528
|
+
let resultText = "";
|
|
529
|
+
const result = await runAgent$1(agent, prompt, runOptions, NOOP_SPINNER, {
|
|
530
|
+
spinnerMessage: "Scanning the repo...",
|
|
531
|
+
successMessage: "Detection complete",
|
|
532
|
+
errorMessage: "Detection failed",
|
|
533
|
+
requestRemark: false,
|
|
534
|
+
timeoutMs
|
|
535
|
+
}, {
|
|
536
|
+
onMessage: (message) => {
|
|
537
|
+
if (message?.type === "assistant") {
|
|
538
|
+
for (const block of message.message?.content ?? []) if (block?.type === "text" && typeof block.text === "string") {
|
|
539
|
+
collect(block.text);
|
|
540
|
+
const line = block.text.trim();
|
|
541
|
+
if (line && onEvent) onEvent(line.length > 100 ? `${line.slice(0, 100)}…` : line);
|
|
542
|
+
} else if (block?.type === "tool_use") onEvent?.(formatToolUse(block));
|
|
543
|
+
} else if (message?.type === "result" && typeof message.result === "string") resultText = message.result;
|
|
544
|
+
},
|
|
545
|
+
finalize: (_resultMessage, _durationMs) => void 0
|
|
546
|
+
});
|
|
547
|
+
if (result.error === "WIZARD_AGENTIC_DETECTION_TIMEOUT") {
|
|
548
|
+
if (attempt === 0) {
|
|
549
|
+
onEvent?.("Project scan timed out; retrying...");
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
throw new AgenticDetectionTimeoutError(attempt + 1, timeoutMs);
|
|
553
|
+
}
|
|
554
|
+
if (result.error) throw new Error(result.message || `Agent error: ${result.error}`);
|
|
555
|
+
const output = `${collected.join("\n")}\n${resultText}`;
|
|
556
|
+
const derived = deriveReportJson(output);
|
|
557
|
+
if (derived !== null) return coerceAgenticReport(derived, targets.map((t) => t.id), {
|
|
558
|
+
recommend,
|
|
559
|
+
rerankIds
|
|
560
|
+
});
|
|
541
561
|
if (output.includes(AgentSignals.ABORT)) return {
|
|
542
562
|
repoType: "single",
|
|
543
563
|
projects: []
|
|
544
564
|
};
|
|
545
|
-
|
|
565
|
+
if (attempt === 0) onEvent?.("Retrying project scan...");
|
|
546
566
|
}
|
|
547
|
-
|
|
548
|
-
recommend,
|
|
549
|
-
rerankIds
|
|
550
|
-
});
|
|
567
|
+
throw new Error("Agent did not return a JSON object after retry");
|
|
551
568
|
}
|
|
552
569
|
//#endregion
|
|
553
570
|
//#region src/lib/warehouse-sources/registry.ts
|
|
@@ -617,7 +634,7 @@ const CORE_SOURCE_DETECTORS = [
|
|
|
617
634
|
{
|
|
618
635
|
kind: "BigQuery",
|
|
619
636
|
label: "BigQuery",
|
|
620
|
-
mode: "
|
|
637
|
+
mode: "deep-link",
|
|
621
638
|
signals: {
|
|
622
639
|
npm: ["@google-cloud/bigquery"],
|
|
623
640
|
python: ["google-cloud-bigquery"],
|
|
@@ -5225,12 +5242,28 @@ function canAsk(prompt) {
|
|
|
5225
5242
|
/** Splits terminal failures into run-failing (required) and reported-only (optional). */
|
|
5226
5243
|
function drainVerdict(tasks) {
|
|
5227
5244
|
const failed = tasks.filter((t) => t.status === TaskStatus.Failed);
|
|
5245
|
+
const pending = tasks.filter((t) => t.status === TaskStatus.Pending);
|
|
5228
5246
|
return {
|
|
5229
5247
|
requiredFailedTypes: failed.filter((t) => t.optional !== true).map((t) => t.type),
|
|
5230
5248
|
optionalFailedTypes: failed.filter((t) => t.optional === true).map((t) => t.type),
|
|
5231
|
-
blocked:
|
|
5249
|
+
blocked: pending.length,
|
|
5250
|
+
blockedTypes: pending.map((t) => t.type)
|
|
5232
5251
|
};
|
|
5233
5252
|
}
|
|
5253
|
+
/**
|
|
5254
|
+
* The one-line "what went wrong" the abort message leads with.
|
|
5255
|
+
*
|
|
5256
|
+
* Both halves are named. A drain that ends with work still pending used to
|
|
5257
|
+
* report only how many steps never ran, which is the least useful fact about
|
|
5258
|
+
* them: a user who agreed to connect their data sources and then read that
|
|
5259
|
+
* "2 steps never ran" had no way to tell whether that step was one of them.
|
|
5260
|
+
*/
|
|
5261
|
+
function describeDrainFailure(verdict) {
|
|
5262
|
+
const parts = [];
|
|
5263
|
+
if (verdict.requiredFailedTypes.length > 0) parts.push(`the ${verdict.requiredFailedTypes.join(", ")} step failed`);
|
|
5264
|
+
if (verdict.blockedTypes.length > 0) parts.push(`the ${verdict.blockedTypes.join(", ")} step${verdict.blockedTypes.length === 1 ? "" : "s"} never ran`);
|
|
5265
|
+
return parts.join(", so ");
|
|
5266
|
+
}
|
|
5234
5267
|
/** How many tasks deep in the graph a task sits — 0 when it depends on nothing. */
|
|
5235
5268
|
function graphDepth(task, byId, memo) {
|
|
5236
5269
|
const cached = memo.get(task.id);
|
|
@@ -5260,6 +5293,14 @@ function displayOrder(tasks, isOptional) {
|
|
|
5260
5293
|
index
|
|
5261
5294
|
})).sort((a, b) => a.depth - b.depth || a.optional - b.optional || a.index - b.index).map((entry) => entry.task);
|
|
5262
5295
|
}
|
|
5296
|
+
/**
|
|
5297
|
+
* The run's excluded task types: CI gates plus the program's flag mapping.
|
|
5298
|
+
* Exported so a test can pin the flag→exclusion hookup against the real
|
|
5299
|
+
* program config — the registry and seed note both read this one list.
|
|
5300
|
+
*/
|
|
5301
|
+
function effectiveExcludedTaskTypes(programConfig, flags) {
|
|
5302
|
+
return [...ciExcludedTaskTypes(), ...programConfig.excludedTaskTypes?.(flags) ?? []];
|
|
5303
|
+
}
|
|
5263
5304
|
async function runOrchestrator(session, config, programConfig, boot) {
|
|
5264
5305
|
const runId = randomUUID();
|
|
5265
5306
|
const switchboardCtx = {
|
|
@@ -5272,7 +5313,7 @@ async function runOrchestrator(session, config, programConfig, boot) {
|
|
|
5272
5313
|
};
|
|
5273
5314
|
const flow = programConfig.agentFlow ?? programConfig.id;
|
|
5274
5315
|
const registry = await loadAgentRegistry(boot.skillsBaseUrl, flow, {
|
|
5275
|
-
exclude:
|
|
5316
|
+
exclude: effectiveExcludedTaskTypes(programConfig, boot.wizardFlags),
|
|
5276
5317
|
overrides: resolveStageOverrides(programConfig.id, boot.wizardFlags, boot.wizardFlagPayloads)
|
|
5277
5318
|
});
|
|
5278
5319
|
const seedPrompt = registry.seed;
|
|
@@ -5406,6 +5447,7 @@ or integrate manually here:
|
|
|
5406
5447
|
validTypes: registry.enqueueableTypes,
|
|
5407
5448
|
sinkTypes: registry.sinkTypes,
|
|
5408
5449
|
runnerSeededTypes: registry.runnerSeededTypes,
|
|
5450
|
+
optionalTypes: registry.optionalTypes,
|
|
5409
5451
|
currentTaskId
|
|
5410
5452
|
});
|
|
5411
5453
|
const seedEntries = areSeededTasksEnabled(boot.wizardFlags) ? programConfig.seedTasks?.(session) ?? [] : [];
|
|
@@ -5455,7 +5497,7 @@ or integrate manually here:
|
|
|
5455
5497
|
session,
|
|
5456
5498
|
programConfig,
|
|
5457
5499
|
boot,
|
|
5458
|
-
prompt: assembleSeedPrompt(promptContext, seedPrompt.body, store.list()),
|
|
5500
|
+
prompt: assembleSeedPrompt(promptContext, seedPrompt.body, store.list(), registry.excludedTypes),
|
|
5459
5501
|
spinner,
|
|
5460
5502
|
model: requireKnownModel(seedModel.model, seedPick.model),
|
|
5461
5503
|
effort: seedModel.effort,
|
|
@@ -5579,6 +5621,11 @@ or integrate manually here:
|
|
|
5579
5621
|
try {
|
|
5580
5622
|
await drainQueue(store, runTask);
|
|
5581
5623
|
} finally {
|
|
5624
|
+
session.frameworkContext[TASK_OUTCOMES_KEY] = store.list().map((t) => ({
|
|
5625
|
+
type: t.type,
|
|
5626
|
+
status: t.status,
|
|
5627
|
+
optional: t.optional === true
|
|
5628
|
+
}));
|
|
5582
5629
|
try {
|
|
5583
5630
|
if (referenceSkillId && referenceInstallPath) promoteReferenceSkill(path$1.join(session.installDir, referenceInstallPath), claudeSkillsDir, referenceSkillId);
|
|
5584
5631
|
} catch (err) {
|
|
@@ -5616,9 +5663,17 @@ or integrate manually here:
|
|
|
5616
5663
|
const notRequired = summary[TaskStatus.Skipped];
|
|
5617
5664
|
const verdict = drainVerdict(store.list());
|
|
5618
5665
|
const blocked = verdict.blocked;
|
|
5666
|
+
for (const task of store.list()) {
|
|
5667
|
+
if (task.status !== TaskStatus.Pending) continue;
|
|
5668
|
+
analytics.wizardCapture("orchestrator task blocked", {
|
|
5669
|
+
type: task.type,
|
|
5670
|
+
optional: task.optional === true,
|
|
5671
|
+
failed_types: verdict.requiredFailedTypes.join(",") || "none"
|
|
5672
|
+
});
|
|
5673
|
+
}
|
|
5619
5674
|
if (verdict.requiredFailedTypes.length > 0 || blocked > 0) {
|
|
5620
5675
|
const failedTypes = verdict.requiredFailedTypes.join(", ");
|
|
5621
|
-
const whatFailed =
|
|
5676
|
+
const whatFailed = describeDrainFailure(verdict);
|
|
5622
5677
|
const missingScopes = boot.credentials.missingScopes ?? [];
|
|
5623
5678
|
const 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}`;
|
|
5624
5679
|
await wizardAbort({
|
|
@@ -5818,6 +5873,43 @@ function resolveBinding(ctx, role = "default") {
|
|
|
5818
5873
|
};
|
|
5819
5874
|
}
|
|
5820
5875
|
//#endregion
|
|
5876
|
+
//#region src/lib/programs/program-step.ts
|
|
5877
|
+
/**
|
|
5878
|
+
* Project program steps into the narrower Screen shape the router consumes.
|
|
5879
|
+
*
|
|
5880
|
+
* Two things happen here:
|
|
5881
|
+
* 1. Headless steps (no `screenId`) are filtered out. The router walks
|
|
5882
|
+
* visible screens; gate-only steps like `detect` are store concerns.
|
|
5883
|
+
* 2. The step is narrowed to just { id, show, isComplete } — the
|
|
5884
|
+
* router has no business touching gate, onInit, or label.
|
|
5885
|
+
*
|
|
5886
|
+
* This intentional separation keeps the router focused on one question:
|
|
5887
|
+
* "Which screen should be rendered right now?"
|
|
5888
|
+
*/
|
|
5889
|
+
/**
|
|
5890
|
+
* The gated steps the agent runner awaits after `auth` and before `run`, in
|
|
5891
|
+
* step order. Empty when a program has no auth step or runs before it.
|
|
5892
|
+
*/
|
|
5893
|
+
function postAuthGateSteps(steps) {
|
|
5894
|
+
const authIndex = steps.findIndex((s) => s.screenId === "auth");
|
|
5895
|
+
const runIndex = steps.findIndex((s) => s.screenId === "run");
|
|
5896
|
+
if (authIndex === -1 || runIndex <= authIndex) return [];
|
|
5897
|
+
return steps.slice(authIndex + 1, runIndex).filter((s) => s.gate);
|
|
5898
|
+
}
|
|
5899
|
+
function createProgramSequence(steps) {
|
|
5900
|
+
const entries = steps.filter((step) => step.screenId != null).map((step) => ({
|
|
5901
|
+
id: step.screenId,
|
|
5902
|
+
show: step.show,
|
|
5903
|
+
isComplete: step.isComplete ?? step.gate
|
|
5904
|
+
}));
|
|
5905
|
+
entries.push({
|
|
5906
|
+
id: "exit",
|
|
5907
|
+
show: void 0,
|
|
5908
|
+
isComplete: void 0
|
|
5909
|
+
});
|
|
5910
|
+
return entries;
|
|
5911
|
+
}
|
|
5912
|
+
//#endregion
|
|
5821
5913
|
//#region src/lib/agent/runner/shared/bootstrap.ts
|
|
5822
5914
|
/**
|
|
5823
5915
|
* Decide whether the `wizard_ask` overlay should be wired for this run.
|
|
@@ -5926,14 +6018,10 @@ async function bootstrapProgram(session, config, programConfig) {
|
|
|
5926
6018
|
logToFile("[agent-runner] checking AI opt-in gate");
|
|
5927
6019
|
await getUI().waitForAiOptIn();
|
|
5928
6020
|
logToFile("[agent-runner] AI opt-in gate cleared");
|
|
5929
|
-
const
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
logToFile(`[agent-runner] awaiting post-auth gate: ${step.id}`);
|
|
5934
|
-
await getUI().waitForGate(step.id);
|
|
5935
|
-
logToFile(`[agent-runner] post-auth gate cleared: ${step.id}`);
|
|
5936
|
-
}
|
|
6021
|
+
for (const step of postAuthGateSteps(programConfig.steps)) {
|
|
6022
|
+
logToFile(`[agent-runner] awaiting post-auth gate: ${step.id}`);
|
|
6023
|
+
await getUI().waitForGate(step.id);
|
|
6024
|
+
logToFile(`[agent-runner] post-auth gate cleared: ${step.id}`);
|
|
5937
6025
|
}
|
|
5938
6026
|
const wizardFlags = await analytics.getAllFlagsForWizard();
|
|
5939
6027
|
const wizardFlagPayloads = analytics.getWizardFlagPayloads();
|
|
@@ -6095,6 +6183,6 @@ function tagBinding(boot, binding) {
|
|
|
6095
6183
|
//#region src/lib/agent/agent-runner.ts
|
|
6096
6184
|
var agent_runner_exports = /* @__PURE__ */ __exportAll({ runAgent: () => runAgent });
|
|
6097
6185
|
//#endregion
|
|
6098
|
-
export {
|
|
6186
|
+
export { authenticate as C, detectFramework as S, detectWarehouseSources as _, computeTokenCostUsd as a, resolveProjectDir as b, detectPostHogIntegration as c, POSTHOG_SDKS as d, STRIPE_SDKS as f, getDetectedWarehouseSources as g, detectWarehousePrerequisites as h, createProgramSequence as i, maybeStampAiSdkDetected as l, WAREHOUSE_ABORT_CASES as m, runAgent as n, formatCostUsd as o, findPackageJsons as p, shouldDisableAsk as r, formatTokenCount as s, agent_runner_exports as t, reportWarehouseSourcesDetected as u, AgenticDetectionTimeoutError as v, gatherFrameworkContext as x, detectProjectsWithAgent as y };
|
|
6099
6187
|
|
|
6100
|
-
//# sourceMappingURL=agent-runner-
|
|
6188
|
+
//# sourceMappingURL=agent-runner-COOIUJCP.js.map
|