@posthog/wizard 2.73.2 → 2.74.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/README.md +32 -28
- package/dist/README.md +11 -4
- package/dist/{add-mcp-server-to-clients-BaVuIyoj.js → add-mcp-server-to-clients-BtWwRG7O.js} +4 -4
- package/dist/{add-mcp-server-to-clients-BaVuIyoj.js.map → add-mcp-server-to-clients-BtWwRG7O.js.map} +1 -1
- package/dist/{agent-interface-Dm28tBj-.js → agent-interface-CK6pmvkF.js} +484 -339
- package/dist/agent-interface-CK6pmvkF.js.map +1 -0
- package/dist/{agent-prompt-loader-Dv9HIHm1.js → agent-prompt-loader-CPCNMvGh.js} +6 -7
- package/dist/agent-prompt-loader-CPCNMvGh.js.map +1 -0
- package/dist/{agent-runner-C1Dwg9sa.js → agent-runner-jz4yiJfh.js} +49 -67
- package/dist/agent-runner-jz4yiJfh.js.map +1 -0
- package/dist/analytics-CfadnLFG.js +2 -0
- package/dist/{analytics-BY4qZ0AC.js → analytics-DZNb3aRN.js} +2 -2
- package/dist/{analytics-BY4qZ0AC.js.map → analytics-DZNb3aRN.js.map} +1 -1
- package/dist/{api-DwWMv1Qc.js → api-DXGaiK94.js} +3 -3
- package/dist/{api-DwWMv1Qc.js.map → api-DXGaiK94.js.map} +1 -1
- package/dist/bin.js +59 -54
- package/dist/bin.js.map +1 -1
- package/dist/{bounded-fs-DIYnGoSv.js → bounded-fs-CErPpkN2.js} +3 -3
- package/dist/{bounded-fs-DIYnGoSv.js.map → bounded-fs-CErPpkN2.js.map} +1 -1
- package/dist/{ci-install-BL5ObQ3S.js → ci-install-CzWzi_qu.js} +21 -24
- package/dist/ci-install-CzWzi_qu.js.map +1 -0
- package/dist/{debug-CY2VLyCW.js → debug-D4y9vVWt.js} +1 -1
- package/dist/{debug-BrWB-OAq.js → debug-ECdmmlDM.js} +21 -33
- package/dist/debug-ECdmmlDM.js.map +1 -0
- package/dist/{env-api-key-C6XP1N9g.js → env-api-key-g5w775Ve.js} +2 -2
- package/dist/{env-api-key-C6XP1N9g.js.map → env-api-key-g5w775Ve.js.map} +1 -1
- package/dist/{environment-CXxQd0SR.js → environment-DDkdsWUr.js} +4 -4
- package/dist/{environment-CXxQd0SR.js.map → environment-DDkdsWUr.js.map} +1 -1
- package/dist/{errors-u8z27V-x.js → errors--OqLxmWR.js} +34 -3
- package/dist/errors--OqLxmWR.js.map +1 -0
- package/dist/{file-watcher-Duj0RMwi.js → file-watcher-BNdFPlI8.js} +2 -2
- package/dist/{file-watcher-Duj0RMwi.js.map → file-watcher-BNdFPlI8.js.map} +1 -1
- package/dist/{headless-ui-B1hA9Rx8.js → headless-ui-DBZCl4CG.js} +2 -2
- package/dist/{headless-ui-B1hA9Rx8.js.map → headless-ui-DBZCl4CG.js.map} +1 -1
- package/dist/{interactive-B2OUN9yB.js → interactive-BKxXUB0T.js} +3 -3
- package/dist/{interactive-B2OUN9yB.js.map → interactive-BKxXUB0T.js.map} +1 -1
- package/dist/{mcp-BkHaEmEn.js → mcp-CwM45_Kp.js} +2 -2
- package/dist/{mcp-BkHaEmEn.js.map → mcp-CwM45_Kp.js.map} +1 -1
- package/dist/{mcp-prompt-streaming-hV0rkw9s.js → mcp-prompt-streaming-R8H7uhuO.js} +5 -5
- package/dist/mcp-prompt-streaming-R8H7uhuO.js.map +1 -0
- package/dist/{non-interactive-ByaO-qoX.js → non-interactive-DxzBwNxJ.js} +3 -3
- package/dist/{non-interactive-ByaO-qoX.js.map → non-interactive-DxzBwNxJ.js.map} +1 -1
- package/dist/{orchestrator-tools-pBKJnRjl.js → orchestrator-tools-CTpKnk5-.js} +3 -3
- package/dist/{orchestrator-tools-pBKJnRjl.js.map → orchestrator-tools-CTpKnk5-.js.map} +1 -1
- package/dist/{package-manager-CIm2MNel.js → package-manager-Bi6gaPa4.js} +2 -2
- package/dist/{package-manager-CIm2MNel.js.map → package-manager-Bi6gaPa4.js.map} +1 -1
- package/dist/{pi-Dj0EHErj.js → pi-DpWFwz5u.js} +35 -20
- package/dist/pi-DpWFwz5u.js.map +1 -0
- package/dist/{playground-UJyt6uLu.js → playground-BtTCVaSD.js} +7 -12
- package/dist/playground-BtTCVaSD.js.map +1 -0
- package/dist/{posthog-BuIPmmdp.js → posthog-B99H8Zyk.js} +2 -2
- package/dist/{posthog-BuIPmmdp.js.map → posthog-B99H8Zyk.js.map} +1 -1
- package/dist/{posthog-integration-HXLZnann.js → posthog-integration-CxvkKY1j.js} +13 -13
- package/dist/{posthog-integration-HXLZnann.js.map → posthog-integration-CxvkKY1j.js.map} +1 -1
- package/dist/{provisioning-B9kEzRE_.js → provisioning-BewSEuFX.js} +4 -10
- package/dist/provisioning-BewSEuFX.js.map +1 -0
- package/dist/{queue-tools-CDqueOnz.js → queue-tools-CbRM-OET.js} +4 -31
- package/dist/queue-tools-CbRM-OET.js.map +1 -0
- package/dist/{registry-Cl77fAHR.js → registry-Bt2Mc4vC.js} +5 -5
- package/dist/{registry-Cl77fAHR.js.map → registry-Bt2Mc4vC.js.map} +1 -1
- package/dist/{security-CfoEOKN4.js → security-Cmxb64bz.js} +5 -5
- package/dist/{security-CfoEOKN4.js.map → security-Cmxb64bz.js.map} +1 -1
- package/dist/{setup-utils-BVQaFad8.js → setup-utils-CCphwDIz.js} +9 -15
- package/dist/setup-utils-CCphwDIz.js.map +1 -0
- package/dist/smoke-test-ci.sh +5 -2
- package/dist/{start-tui-DJGq1bFx.js → start-tui-BRwZzlWb.js} +22 -22
- package/dist/{start-tui-DJGq1bFx.js.map → start-tui-BRwZzlWb.js.map} +1 -1
- package/dist/{steps-BLrL5Kst.js → steps-CJrx1t72.js} +7 -7
- package/dist/{steps-BLrL5Kst.js.map → steps-CJrx1t72.js.map} +1 -1
- package/dist/{store-l1aCLB7H.js → store-BhcCTIn4.js} +6 -10
- package/dist/store-BhcCTIn4.js.map +1 -0
- package/dist/{subagent-BAU9BElX.js → subagent-BeMPBF5r.js} +2 -2
- package/dist/{subagent-BAU9BElX.js.map → subagent-BeMPBF5r.js.map} +1 -1
- package/dist/{task-B7LbltJW.js → task-DX3eZgBL.js} +36 -21
- package/dist/task-DX3eZgBL.js.map +1 -0
- package/dist/{task-stream-Du_99Tv-.js → task-stream-BW7BG70C.js} +5 -5
- package/dist/{task-stream-Du_99Tv-.js.map → task-stream-BW7BG70C.js.map} +1 -1
- package/dist/{tasks-7XjlfAbk.js → tasks-Did1AR7v.js} +2 -2
- package/dist/{tasks-7XjlfAbk.js.map → tasks-Did1AR7v.js.map} +1 -1
- package/dist/{telemetry-CW5a6Bog.js → telemetry-CPWHrsXK.js} +3 -3
- package/dist/{telemetry-CW5a6Bog.js.map → telemetry-CPWHrsXK.js.map} +1 -1
- package/dist/{terminal-DMZIApv7.js → terminal-CpVFsbGu.js} +12 -12
- package/dist/{terminal-DMZIApv7.js.map → terminal-CpVFsbGu.js.map} +1 -1
- package/dist/{tools-CIkbTll3.js → tools-DjiwCd53.js} +6 -6
- package/dist/{tools-CIkbTll3.js.map → tools-DjiwCd53.js.map} +1 -1
- package/dist/{wizard-abort-serrH83C.js → wizard-abort-DjJ-6y6S.js} +1 -1
- package/dist/{wizard-abort-DcuNitMi.js → wizard-abort-RUnY1Dax.js} +4 -4
- package/dist/{wizard-abort-DcuNitMi.js.map → wizard-abort-RUnY1Dax.js.map} +1 -1
- package/dist/yara-hooks-CBMSmD9F.js +2 -0
- package/dist/{yara-hooks-BKhDtn2N.js → yara-hooks-jBqAkgxw.js} +4 -4
- package/dist/{yara-hooks-BKhDtn2N.js.map → yara-hooks-jBqAkgxw.js.map} +1 -1
- package/package.json +1 -1
- package/dist/agent-interface-Dm28tBj-.js.map +0 -1
- package/dist/agent-prompt-loader-Dv9HIHm1.js.map +0 -1
- package/dist/agent-runner-C1Dwg9sa.js.map +0 -1
- package/dist/analytics-Bhw7ODc0.js +0 -2
- package/dist/ci-install-BL5ObQ3S.js.map +0 -1
- package/dist/debug-BrWB-OAq.js.map +0 -1
- package/dist/errors-u8z27V-x.js.map +0 -1
- package/dist/mcp-prompt-streaming-hV0rkw9s.js.map +0 -1
- package/dist/pi-Dj0EHErj.js.map +0 -1
- package/dist/playground-UJyt6uLu.js.map +0 -1
- package/dist/provisioning-B9kEzRE_.js.map +0 -1
- package/dist/queue-tools-CDqueOnz.js.map +0 -1
- package/dist/setup-utils-BVQaFad8.js.map +0 -1
- package/dist/store-l1aCLB7H.js.map +0 -1
- package/dist/task-B7LbltJW.js.map +0 -1
- package/dist/yara-hooks-rZT6WNop.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as logToFile } from "./debug-
|
|
2
|
-
import { n as analytics } from "./analytics-
|
|
3
|
-
import {
|
|
4
|
-
import { g as isThinkingLevel } from "./queue-tools-
|
|
1
|
+
import { s as logToFile } from "./debug-ECdmmlDM.js";
|
|
2
|
+
import { n as analytics } from "./analytics-DZNb3aRN.js";
|
|
3
|
+
import { A as WIZARD_TOOL_NAMES, H as fetchWithRetry } from "./agent-interface-CK6pmvkF.js";
|
|
4
|
+
import { g as isThinkingLevel } from "./queue-tools-CbRM-OET.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.
|
|
@@ -106,8 +106,7 @@ function queueTools(disallowedTools) {
|
|
|
106
106
|
const disallowed = new Set(disallowedTools.map((n) => n.replace(ORCHESTRATOR_TOOL_PREFIX, "")));
|
|
107
107
|
return [...ORCHESTRATOR_TOOLS].filter((t) => !disallowed.has(t));
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* column, anything else the sdk (anthropic) column. */
|
|
109
|
+
/** Pi selects the pi profile; the legacy Anthropic SDK selects the sdk profile. */
|
|
111
110
|
function promptModelFor(prompt, harness) {
|
|
112
111
|
const pi = harness === "pi";
|
|
113
112
|
return {
|
|
@@ -312,4 +311,4 @@ const EMPTY_PROMPT = {};
|
|
|
312
311
|
//#endregion
|
|
313
312
|
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 };
|
|
314
313
|
|
|
315
|
-
//# sourceMappingURL=agent-prompt-loader-
|
|
314
|
+
//# sourceMappingURL=agent-prompt-loader-CPCNMvGh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-prompt-loader-CPCNMvGh.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 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/** 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 /** 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 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 === 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 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,KAAwC;AAK9D,QAAO;;;wBAGe,IAAI,UAAU;0BACZ,IAAI,cAAc;kBAC1B,IAAI,KAAK,QAAQ;wEACqC,IAAI,KAAK;;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V,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,19 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { F as HAIKU_MODEL, L as Harness, M as GPT5_6_LUNA_MODEL, N as GPT5_6_SOL_MODEL, O as DEFAULT_AGENT_MODEL, P as GPT5_6_TERRA_MODEL,
|
|
2
|
+
import { a as AGENT_ERROR_CODE, d as ErrorCodes, o as AgentSignals, r as skillErrorCode } from "./errors--OqLxmWR.js";
|
|
3
|
+
import { $ as Sequence, F as HAIKU_MODEL, L as Harness, M as GPT5_6_LUNA_MODEL, N as GPT5_6_SOL_MODEL, O as DEFAULT_AGENT_MODEL, P as GPT5_6_TERRA_MODEL, Q as SONNET_5_MODEL, _ as evaluateWizardReadiness, a as getLogFilePath, at as WIZARD_ORCHESTRATOR_FLAG_KEY, c as WIZARD_BENCHMARK_FILE, f as getUI, ft as getSkillsBaseUrl, g as SIGNUP_WIZARD_READINESS_CONFIG, gt as RUN_SURFACE, h as SERVICE_LABELS, i as enableDebugLogs, k as DETECTION_TIMEOUT_MS, l as WIZARD_LOG_FILE, mt as VERSION, o as initLogFile, ot as WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, s as logToFile, st as WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, t as configureLogFile, tt as WIZARD_CONTACT_EMAIL, ut as WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, v as getBlockingServiceKeys, yt as runtimeEnv, z as Integration } from "./debug-ECdmmlDM.js";
|
|
4
4
|
import { o as mayReportScanResults } from "./wizard-session-GdDN_aMS.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 {
|
|
11
|
-
import { a as detectNodePackageManagers } from "./package-manager-
|
|
12
|
-
import { t as FRAMEWORK_REGISTRY } from "./registry-
|
|
13
|
-
import { a as flushScanReport, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-
|
|
14
|
-
import { _ as isValidModel, f as QUEUE_DIR_NAME, h as TaskStatus, l as dependencyClosure, m as SkipReason, p as QueueStore, u as uncoveredBySink, y as requireKnownModel } from "./queue-tools-
|
|
15
|
-
import { a as piBackend, s as createAioCapture } from "./pi-
|
|
16
|
-
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-
|
|
5
|
+
import { a as ciExcludedTaskTypes, n as analytics, r as groupsFromUser } from "./analytics-DZNb3aRN.js";
|
|
6
|
+
import { a as safeReadFile, i as readProjectFile, o as walkProjectFiles } from "./bounded-fs-CErPpkN2.js";
|
|
7
|
+
import { c as OAuthError, s as refreshAccessToken, t as getOrAskForProjectData, u as mcpUrlFor } from "./setup-utils-CCphwDIz.js";
|
|
8
|
+
import { i as wizardAbort, n as registerCleanup, t as WizardError } from "./wizard-abort-RUnY1Dax.js";
|
|
9
|
+
import { n as isNonInteractiveEnvironment } from "./environment-DDkdsWUr.js";
|
|
10
|
+
import { F as installSkillById, G as gatewayAuth, J as isEnvFileName, P as fetchSkillMenu, U as createWizardAskBridge, X as toPromptSafeRelativePath, Y as parseEnvKeyNames, Z as markGrantRevoked, c as checkAllSettingsConflicts, d as restoreClaudeSettings, h as createTriageLLMProvider, i as runAgent$1, l as classifySettingsConflicts, n as buildRunTags, q as MAX_ENV_KEY_SET, r as initializeAgent, s as backupAndFixClaudeSettings } from "./agent-interface-CK6pmvkF.js";
|
|
11
|
+
import { a as detectNodePackageManagers } from "./package-manager-Bi6gaPa4.js";
|
|
12
|
+
import { t as FRAMEWORK_REGISTRY } from "./registry-Bt2Mc4vC.js";
|
|
13
|
+
import { a as flushScanReport, m as writeScanReport, o as formatScanReport, s as formatYaraAbortMessage } from "./yara-hooks-jBqAkgxw.js";
|
|
14
|
+
import { _ as isValidModel, f as QUEUE_DIR_NAME, h as TaskStatus, l as dependencyClosure, m as SkipReason, p as QueueStore, u as uncoveredBySink, y as requireKnownModel } from "./queue-tools-CbRM-OET.js";
|
|
15
|
+
import { a as piBackend, s as createAioCapture } from "./pi-DpWFwz5u.js";
|
|
16
|
+
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-CPCNMvGh.js";
|
|
17
17
|
import * as semver from "semver";
|
|
18
18
|
import fs, { cpSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
19
19
|
import * as path$1 from "path";
|
|
@@ -3241,19 +3241,6 @@ function reportWarehouseSourcesDetected(session) {
|
|
|
3241
3241
|
}
|
|
3242
3242
|
//#endregion
|
|
3243
3243
|
//#region src/lib/agent/runner/harness/anthropic/index.ts
|
|
3244
|
-
/**
|
|
3245
|
-
* The `anthropic` runner — the control. Wraps the claude-agent-sdk path
|
|
3246
|
-
* (`initializeAgent` + `runAgent`) that was inline in `linear.ts` before the
|
|
3247
|
-
* runner seam. Owns only the agent loop + model transport; the shared pipeline
|
|
3248
|
-
* (skill install, prompt, ask bridge, error routing, outro) stays in `linear.ts`.
|
|
3249
|
-
*
|
|
3250
|
-
* Implements both entry points:
|
|
3251
|
-
* - `run` for linear mode (one call per program)
|
|
3252
|
-
* - `runTask` for orchestrator mode (one call for the seed plan, one per
|
|
3253
|
-
* drained task). This is the only harness that supports
|
|
3254
|
-
* orchestrator today; pi omits `runTask` and the orchestrator
|
|
3255
|
-
* runner fails loudly when handed a harness without it.
|
|
3256
|
-
*/
|
|
3257
3244
|
const anthropicBackend = {
|
|
3258
3245
|
name: "anthropic",
|
|
3259
3246
|
async run(inputs) {
|
|
@@ -3395,12 +3382,13 @@ const SELF_DRIVING_EXPERIMENT = {
|
|
|
3395
3382
|
* resolution. Experiment modules in this folder declare *which* flags they
|
|
3396
3383
|
* use; this module owns *how* a config resolves to a route.
|
|
3397
3384
|
*/
|
|
3398
|
-
/** Model variant key → gateway id.
|
|
3385
|
+
/** Model variant key → gateway id. A key the gateway no longer mints is dropped
|
|
3386
|
+
* rather than re-aimed: the payload then fails validation and the binding
|
|
3387
|
+
* default stands, which is visible in the log instead of silently rerouting. */
|
|
3399
3388
|
const MODEL_FLAG_VARIANTS = {
|
|
3400
3389
|
"gpt-5-6-luna": GPT5_6_LUNA_MODEL,
|
|
3401
3390
|
"gpt-5-6-terra": GPT5_6_TERRA_MODEL,
|
|
3402
3391
|
"gpt-5-6-sol": GPT5_6_SOL_MODEL,
|
|
3403
|
-
"sonnet-4-6": DEFAULT_AGENT_MODEL,
|
|
3404
3392
|
"sonnet-5": SONNET_5_MODEL
|
|
3405
3393
|
};
|
|
3406
3394
|
/** Valid effort variants; anything else leaves the model's table default. */
|
|
@@ -4052,21 +4040,20 @@ function pricingFromInput(input, output) {
|
|
|
4052
4040
|
/**
|
|
4053
4041
|
* Exact-match price table, keyed by the *undated* model id prefix —
|
|
4054
4042
|
* `pricePerMtokForModel` strips a dated suffix before falling back to this
|
|
4055
|
-
* table, so
|
|
4056
|
-
*
|
|
4057
|
-
*
|
|
4058
|
-
*
|
|
4059
|
-
*
|
|
4060
|
-
* (a turn on an id NOT in this table contributes $0 to the live estimate
|
|
4061
|
-
* rather than guessing — see `pricePerMtokForModel`).
|
|
4043
|
+
* table, so a dated Anthropic id resolves via its undated entry without
|
|
4044
|
+
* needing a duplicate key. Ids the wizard no longer dispatches on stay
|
|
4045
|
+
* priced, since a subagent turn or the SDK can still report one (a turn on
|
|
4046
|
+
* an id NOT in this table contributes $0 to the live estimate rather than
|
|
4047
|
+
* guessing, see `pricePerMtokForModel`).
|
|
4062
4048
|
*
|
|
4063
|
-
* `
|
|
4064
|
-
* (promotional launch discount), so
|
|
4065
|
-
* `
|
|
4049
|
+
* `SONNET_5_MODEL` is intentionally absent: its price is time-dependent
|
|
4050
|
+
* (promotional launch discount), so `pricePerMtokForModel` resolves it via
|
|
4051
|
+
* `sonnet5Price`. It is also `DEFAULT_AGENT_MODEL`, so the no-model fallback
|
|
4052
|
+
* goes through that branch.
|
|
4066
4053
|
*/
|
|
4067
4054
|
const PRICE_TABLE = {
|
|
4068
|
-
|
|
4069
|
-
|
|
4055
|
+
"claude-sonnet-4-6": pricingFromInput(3, 15),
|
|
4056
|
+
[HAIKU_MODEL]: pricingFromInput(1, 5),
|
|
4070
4057
|
"claude-opus-4-5": pricingFromInput(5, 25)
|
|
4071
4058
|
};
|
|
4072
4059
|
/**
|
|
@@ -4074,8 +4061,8 @@ const PRICE_TABLE = {
|
|
|
4074
4061
|
* UTC; from 2026-09-01 it reverts to the same rate as Sonnet 4.6 ($3/$15)
|
|
4075
4062
|
* — not a coincidence, Anthropic prices it identically to 4.6 once the
|
|
4076
4063
|
* promo ends. Re-verify against https://models.dev/api.json if this ever
|
|
4077
|
-
* looks off, and
|
|
4078
|
-
*
|
|
4064
|
+
* looks off, and fold this special case into a flat `PRICE_TABLE` entry at
|
|
4065
|
+
* the post-promo rate once the window is well past.
|
|
4079
4066
|
*/
|
|
4080
4067
|
const SONNET_5_PROMO_ENDS_UTC = /* @__PURE__ */ new Date("2026-09-01T00:00:00Z");
|
|
4081
4068
|
function sonnet5Price(now) {
|
|
@@ -4102,10 +4089,10 @@ function stripDateSuffix(model) {
|
|
|
4102
4089
|
* other entry in this table is time-dependent.
|
|
4103
4090
|
*/
|
|
4104
4091
|
function pricePerMtokForModel(model, now = /* @__PURE__ */ new Date()) {
|
|
4105
|
-
|
|
4106
|
-
const undated = stripDateSuffix(
|
|
4092
|
+
const id = model ?? "claude-sonnet-5";
|
|
4093
|
+
const undated = stripDateSuffix(id);
|
|
4107
4094
|
if (undated === "claude-sonnet-5") return sonnet5Price(now);
|
|
4108
|
-
return PRICE_TABLE[
|
|
4095
|
+
return PRICE_TABLE[id] ?? PRICE_TABLE[undated];
|
|
4109
4096
|
}
|
|
4110
4097
|
/**
|
|
4111
4098
|
* Cost in USD for one usage delta, priced at `usage.model`'s exact rates
|
|
@@ -5657,14 +5644,6 @@ function resolveSequence(ctx) {
|
|
|
5657
5644
|
//#endregion
|
|
5658
5645
|
//#region src/lib/agent/runner/switchboard/index.ts
|
|
5659
5646
|
/**
|
|
5660
|
-
* The switchboard — where a program's `(sequence, harness, model)` binding is
|
|
5661
|
-
* resolved. Two independent middleware chains, one per axis: CLI wins over
|
|
5662
|
-
* PostHog flag wins over per-program binding wins over `DEFAULT_BINDING`.
|
|
5663
|
-
*
|
|
5664
|
-
* Layout: `index.ts` (shared machinery + composer), `harness.ts`, `sequence.ts`.
|
|
5665
|
-
* Model ids are gateway strings — add new ones as constants in `@lib/constants`.
|
|
5666
|
-
*/
|
|
5667
|
-
/**
|
|
5668
5647
|
* Run a middleware chain over `ctx`. Each middleware receives `next` (which
|
|
5669
5648
|
* runs the rest of the chain) and can either:
|
|
5670
5649
|
* - defer: call `next()` and optionally modify its result (overlay pattern)
|
|
@@ -5687,7 +5666,6 @@ function runChain(chain, ctx, fallback) {
|
|
|
5687
5666
|
}
|
|
5688
5667
|
return step(0);
|
|
5689
5668
|
}
|
|
5690
|
-
/** Default binding. Every program points here until it overrides. */
|
|
5691
5669
|
const DEFAULT_BINDING = {
|
|
5692
5670
|
sequence: "linear",
|
|
5693
5671
|
harness: "anthropic",
|
|
@@ -5876,7 +5854,8 @@ async function bootstrapProgram(session, config, programConfig) {
|
|
|
5876
5854
|
});
|
|
5877
5855
|
await refreshAccessTokenIfNeeded(session);
|
|
5878
5856
|
const credentials = session.credentials;
|
|
5879
|
-
const
|
|
5857
|
+
const currentGatewayAuth = () => gatewayAuth(credentials.host, credentials.accessToken, programConfig.id);
|
|
5858
|
+
await currentGatewayAuth();
|
|
5880
5859
|
return {
|
|
5881
5860
|
skillsBaseUrl,
|
|
5882
5861
|
credentials,
|
|
@@ -5885,16 +5864,19 @@ async function bootstrapProgram(session, config, programConfig) {
|
|
|
5885
5864
|
wizardFlagPayloads,
|
|
5886
5865
|
wizardMetadata,
|
|
5887
5866
|
project,
|
|
5888
|
-
triageProvider: createTriageLLMProvider({
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5867
|
+
triageProvider: createTriageLLMProvider(async () => {
|
|
5868
|
+
const auth = await currentGatewayAuth();
|
|
5869
|
+
return {
|
|
5870
|
+
baseURL: auth.gatewayUrl,
|
|
5871
|
+
authToken: auth.token,
|
|
5872
|
+
teamId: auth.teamId,
|
|
5873
|
+
legacy: auth.legacy,
|
|
5874
|
+
wizardMetadata: {
|
|
5875
|
+
...wizardMetadata,
|
|
5876
|
+
call_type: "yara-triage"
|
|
5877
|
+
},
|
|
5878
|
+
wizardFlags
|
|
5879
|
+
};
|
|
5898
5880
|
}, resolveHarness({
|
|
5899
5881
|
program: programConfig.id,
|
|
5900
5882
|
flags: wizardFlags,
|
|
@@ -6001,4 +5983,4 @@ var agent_runner_exports = /* @__PURE__ */ __exportAll({ runAgent: () => runAgen
|
|
|
6001
5983
|
//#endregion
|
|
6002
5984
|
export { detectFramework as _, formatCostUsd as a, maybeStampAiSdkDetected as c, detectWarehousePrerequisites as d, getDetectedWarehouseSources as f, gatherFrameworkContext as g, resolveProjectDir as h, computeTokenCostUsd as i, reportWarehouseSourcesDetected as l, detectProjectsWithAgent as m, runAgent as n, formatTokenCount as o, detectWarehouseSources as p, shouldDisableAsk as r, detectPostHogIntegration as s, agent_runner_exports as t, WAREHOUSE_ABORT_CASES as u, authenticate as v };
|
|
6003
5985
|
|
|
6004
|
-
//# sourceMappingURL=agent-runner-
|
|
5986
|
+
//# sourceMappingURL=agent-runner-jz4yiJfh.js.map
|