github-router 0.3.367 → 0.3.369
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/ado-tools-C0sY_rX1.js +1 -0
- package/dist/{attribution-settings-wVzQvIdL.js → attribution-settings-zoBxw08y.js} +223 -191
- package/dist/attribution-settings-zoBxw08y.js.map +1 -0
- package/dist/{balanced-profile-contract-DtnTIBjL.js → balanced-profile-contract-Dm_usmw7.js} +7 -1
- package/dist/{balanced-profile-contract-DtnTIBjL.js.map → balanced-profile-contract-Dm_usmw7.js.map} +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{claude-B3pIageM.js → claude-BbIfnWbm.js} +15 -13
- package/dist/claude-BbIfnWbm.js.map +1 -0
- package/dist/{claude-md-injection-BV4tPUWo.js → claude-md-injection-BtBG1RBZ.js} +36 -11
- package/dist/claude-md-injection-BtBG1RBZ.js.map +1 -0
- package/dist/{codex-B_AMB6JM.js → codex-CZVlP2tB.js} +5 -5
- package/dist/{codex-B_AMB6JM.js.map → codex-CZVlP2tB.js.map} +1 -1
- package/dist/engine-DeIo-VIR.js +1 -0
- package/dist/{gate-discovery-CXE-7VcM.js → gate-discovery-BYyYeUnn.js} +2 -2
- package/dist/{gate-discovery-CXE-7VcM.js.map → gate-discovery-BYyYeUnn.js.map} +1 -1
- package/dist/hooks.mjs +72 -10
- package/dist/hooks.sha256 +1 -1
- package/dist/{internal-fast-dispatch-guard-DP25L_Bx.js → internal-fast-dispatch-guard-De_DJOyZ.js} +1 -1
- package/dist/{internal-fast-dispatch-guard-DbrgO9Ab.js → internal-fast-dispatch-guard-_n-A8hgo.js} +2 -2
- package/dist/{internal-fast-dispatch-guard-DbrgO9Ab.js.map → internal-fast-dispatch-guard-_n-A8hgo.js.map} +1 -1
- package/dist/{internal-prompt-submit-DPUBQZtG.js → internal-prompt-submit-B-kKTl-8.js} +2 -2
- package/dist/{internal-prompt-submit-BaccW_CC.js → internal-prompt-submit-bi7F7pKk.js} +2 -2
- package/dist/{internal-prompt-submit-BaccW_CC.js.map → internal-prompt-submit-bi7F7pKk.js.map} +1 -1
- package/dist/{internal-rebrief-NjSlx5QY.js → internal-rebrief-B6ZJS6Mp.js} +3 -3
- package/dist/{internal-rebrief-NjSlx5QY.js.map → internal-rebrief-B6ZJS6Mp.js.map} +1 -1
- package/dist/{internal-stop-hook-B2TTl6Zp.js → internal-stop-hook-BbyobGUU.js} +2 -2
- package/dist/{internal-stop-hook-B2TTl6Zp.js.map → internal-stop-hook-BbyobGUU.js.map} +1 -1
- package/dist/main.js +9 -9
- package/dist/{peer-mcp-personas-BOgR46nM.js → peer-mcp-personas-DNtWI2C1.js} +721 -330
- package/dist/peer-mcp-personas-DNtWI2C1.js.map +1 -0
- package/dist/{pi-DcWp83mx.js → pi-Bc-MVgAo.js} +31 -12
- package/dist/{pi-DcWp83mx.js.map → pi-Bc-MVgAo.js.map} +1 -1
- package/dist/{provision-DkWR9B6I.js → provision-DUWdcY_a.js} +2 -2
- package/dist/{provision-DkWR9B6I.js.map → provision-DUWdcY_a.js.map} +1 -1
- package/dist/{serve-BGwEVDdc.js → serve-CmWOTR7m.js} +7 -7
- package/dist/{serve-BGwEVDdc.js.map → serve-CmWOTR7m.js.map} +1 -1
- package/dist/{server-setup-DVPL9iph.js → server-setup-CIzmDJzT.js} +55 -121
- package/dist/server-setup-CIzmDJzT.js.map +1 -0
- package/dist/{start-BUWx3nSr.js → start-rlpaeAtx.js} +3 -3
- package/dist/{start-BUWx3nSr.js.map → start-rlpaeAtx.js.map} +1 -1
- package/dist/state-CiwCLVDZ.js.map +1 -1
- package/dist/{static-context-pack-ChHuxBpk.js → static-context-pack-DvwLWlbe.js} +153 -17
- package/dist/static-context-pack-DvwLWlbe.js.map +1 -0
- package/package.json +1 -1
- package/dist/ado-tools-rysFZDws.js +0 -1
- package/dist/attribution-settings-wVzQvIdL.js.map +0 -1
- package/dist/claude-B3pIageM.js.map +0 -1
- package/dist/claude-md-injection-BV4tPUWo.js.map +0 -1
- package/dist/engine-D3oNrF6Z.js +0 -1
- package/dist/peer-mcp-personas-BOgR46nM.js.map +0 -1
- package/dist/server-setup-DVPL9iph.js.map +0 -1
- package/dist/static-context-pack-ChHuxBpk.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as warmTreeSitterPool } from "./service-backend-B6D_DY1Z.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Z as runSelfUpdate, a as setupAndServe, i as parseSharedArgs, n as getCodexEnvVars, o as sharedServerArgs, t as getClaudeCodeEnvVars, v as startKeepAwake } from "./server-setup-CIzmDJzT.js";
|
|
3
|
+
import { Mn as provisionAndIndexColbert, Tn as provisionBrowserAssets, Tt as browserToolsEnabled, jn as colbertDegradedWarning } from "./peer-mcp-personas-DNtWI2C1.js";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
import process$1 from "node:process";
|
|
@@ -130,4 +130,4 @@ const start = defineCommand({
|
|
|
130
130
|
//#endregion
|
|
131
131
|
export { start };
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=start-
|
|
133
|
+
//# sourceMappingURL=start-rlpaeAtx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-BUWx3nSr.js","names":["process"],"sources":["../src/lib/shell.ts","../src/start.ts"],"sourcesContent":["import process from \"node:process\"\n\ntype ShellName = \"bash\" | \"zsh\" | \"fish\" | \"powershell\" | \"cmd\" | \"sh\"\ntype EnvVars = Record<string, string | undefined>\n\nfunction getShell(): ShellName {\n const { platform, env } = process\n\n if (platform === \"win32\") {\n // Git Bash / MSYS2 / Cygwin set SHELL even on Windows\n if (env.SHELL) {\n if (env.SHELL.endsWith(\"zsh\")) return \"zsh\"\n if (env.SHELL.endsWith(\"fish\")) return \"fish\"\n if (env.SHELL.endsWith(\"bash\")) return \"bash\"\n return \"sh\"\n }\n\n // Windows PowerShell 5.x sets this\n if (env.POWERSHELL_DISTRIBUTION_CHANNEL) return \"powershell\"\n\n // PowerShell (both 5.x and 7+/pwsh) adds user-scoped module paths\n // at runtime. The system-level PSModulePath in CMD lacks these paths.\n if (env.PSModulePath) {\n const lower = env.PSModulePath.toLowerCase()\n if (\n lower.includes(\"documents\\\\powershell\")\n || lower.includes(\"documents\\\\windowspowershell\")\n ) {\n return \"powershell\"\n }\n }\n\n return \"cmd\"\n }\n\n const shellPath = env.SHELL\n if (shellPath) {\n if (shellPath.endsWith(\"zsh\")) return \"zsh\"\n if (shellPath.endsWith(\"fish\")) return \"fish\"\n if (shellPath.endsWith(\"bash\")) return \"bash\"\n }\n\n return \"sh\"\n}\n\nfunction quotePosixValue(value: string): string {\n return `'${value.replace(/'/g, \"'\\\\''\")}'`\n}\n\nfunction quotePowerShellValue(value: string): string {\n return `'${value.replace(/'/g, \"''\")}'`\n}\n\n/**\n * Generates a copy-pasteable script to set multiple environment variables\n * and run a subsequent command.\n * @param {EnvVars} envVars - An object of environment variables to set.\n * @param {string} commandToRun - The command to run after setting the variables.\n * @returns {string} The formatted script string.\n */\nexport function generateEnvScript(\n envVars: EnvVars,\n commandToRun: string = \"\",\n): string {\n const shell = getShell()\n const filteredEnvVars = Object.entries(envVars).filter(\n ([, value]) => value !== undefined,\n ) as Array<[string, string]>\n\n let commandBlock: string\n\n switch (shell) {\n case \"powershell\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `$env:${key} = ${quotePowerShellValue(value)}`)\n .join(\"; \")\n break\n }\n case \"cmd\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `set \"${key}=${value}\"`)\n .join(\" & \")\n break\n }\n case \"fish\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `set -gx ${key} ${quotePosixValue(value)}`)\n .join(\"; \")\n break\n }\n default: {\n // bash, zsh, sh\n const assignments = filteredEnvVars\n .map(([key, value]) => `${key}=${quotePosixValue(value)}`)\n .join(\" \")\n commandBlock = filteredEnvVars.length > 0 ? `export ${assignments}` : \"\"\n break\n }\n }\n\n if (commandBlock && commandToRun) {\n const separator =\n shell === \"cmd\" ? \" & \" : shell === \"powershell\" ? \"; \" : \" && \"\n return `${commandBlock}${separator}${commandToRun}`\n }\n\n return commandBlock || commandToRun\n}\n","#!/usr/bin/env node\n\nimport { defineCommand } from \"citty\"\nimport clipboard from \"clipboardy\"\nimport consola from \"consola\"\n\nimport { generateEnvScript } from \"./lib/shell\"\nimport { DEFAULT_CODEX_MODEL, DEFAULT_PORT } from \"./lib/port\"\nimport { provisionBrowserAssets } from \"./lib/browser-mcp/provision\"\nimport { browserToolsEnabled } from \"./lib/mcp-capabilities\"\nimport { colbertDegradedWarning, provisionAndIndexColbert } from \"./lib/colbert\"\nimport { startKeepAwake } from \"./lib/keep-awake\"\nimport { warmTreeSitterPool } from \"./lib/tree-sitter-pool/pool\"\nimport {\n getClaudeCodeEnvVars,\n getCodexEnvVars,\n parseSharedArgs,\n setupAndServe,\n sharedServerArgs,\n} from \"./lib/server-setup\"\nimport { runSelfUpdate } from \"./lib/self-update\"\n\nfunction printAndCopyCommand(command: string, label: string): void {\n consola.box(`${label}\\n\\n${command}`)\n try {\n clipboard.writeSync(command)\n consola.success(`Copied ${label} command to clipboard!`)\n } catch {\n consola.warn(\"Failed to copy to clipboard. Copy the command above manually.\")\n }\n}\n\nfunction generateClaudeCodeCommand(serverUrl: string, model?: string) {\n const envVars = getClaudeCodeEnvVars(serverUrl, model)\n const command = generateEnvScript(envVars, \"claude --dangerously-skip-permissions\")\n printAndCopyCommand(command, \"Claude Code\")\n}\n\nfunction generateCodexCommand(serverUrl: string, model?: string) {\n const codexModel = model ?? DEFAULT_CODEX_MODEL\n const envVars = getCodexEnvVars(serverUrl)\n const command = generateEnvScript(envVars, `codex -m ${codexModel}`)\n printAndCopyCommand(command, \"Codex CLI\")\n}\n\nexport const start = defineCommand({\n meta: {\n name: \"start\",\n description: \"Start the github-router server\",\n },\n args: {\n ...sharedServerArgs,\n cc: {\n type: \"boolean\",\n default: false,\n description:\n \"Generate a command to launch Claude Code with Copilot API config\",\n },\n cx: {\n type: \"boolean\",\n default: false,\n description:\n \"Generate a command to launch Codex CLI with Copilot API config\",\n },\n model: {\n alias: \"m\",\n type: \"string\",\n description: \"Override the default model (used with --cc or --cx)\",\n },\n },\n async run({ args }) {\n const parsed = parseSharedArgs(args as unknown as Record<string, unknown>)\n\n const { serverUrl } = await setupAndServe({\n ...parsed,\n port: parsed.port ?? DEFAULT_PORT,\n silent: false,\n })\n\n // Best-effort self-update (detached, applies next launch). Runs\n // after the server is listening so the bounded probe can't delay it.\n void runSelfUpdate({ selfUpdate: args[\"self-update\"] !== false })\n\n // Best-effort ColBERT semantic-search provision + background index of\n // the launch cwd (if a git repo). Opt-IN via --search (no-op otherwise);\n // never blocks launch, never throws.\n void provisionAndIndexColbert()\n\n // Surface a terminally-failed semantic index to the HUMAN (see the note\n // in claude.ts). Fire-and-forget; lexical search still works.\n void colbertDegradedWarning()\n .then((warning) => {\n if (warning) process.stderr.write(`${warning}\\n`)\n })\n .catch(() => {})\n\n // Ready one tree-sitter worker in the background so the first code search\n // avoids WASM/grammar initialization. One worker keeps launch CPU bounded;\n // demand grows the pool lazily. Opt out with GH_ROUTER_DISABLE_TS_POOL_WARMUP=1.\n void warmTreeSitterPool()\n\n // Best-effort: keep the machine awake while the proxy serves (win32\n // default-on; opt out with GH_ROUTER_DISABLE_KEEP_AWAKE=1). Holds a\n // SetThreadExecutionState assertion via a persistent PowerShell\n // helper. Self-registers its own SIGINT/SIGTERM/exit reaper — load-\n // bearing here, because `start` has no launchChild/onShutdown.\n startKeepAwake()\n\n // Best-effort: materialize the browser extension + bridge into the\n // stable app-dir and stamp the running version, so a one-time \"Load\n // unpacked\" survives npx/bunx upgrades. Gated on --browse; never\n // blocks launch, never throws.\n if (browserToolsEnabled()) {\n void provisionBrowserAssets().catch((err) =>\n consola.debug(\"Browser extension provisioning failed:\", err),\n )\n }\n\n if (args.cc) generateClaudeCodeCommand(serverUrl, args.model)\n if (args.cx) generateCodexCommand(serverUrl, args.model)\n\n consola.box(\n `🌐 Usage Viewer: https://animeshkundu.github.io/github-router/dashboard.html?endpoint=${serverUrl}/usage`,\n )\n },\n})\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"start-rlpaeAtx.js","names":["process"],"sources":["../src/lib/shell.ts","../src/start.ts"],"sourcesContent":["import process from \"node:process\"\n\ntype ShellName = \"bash\" | \"zsh\" | \"fish\" | \"powershell\" | \"cmd\" | \"sh\"\ntype EnvVars = Record<string, string | undefined>\n\nfunction getShell(): ShellName {\n const { platform, env } = process\n\n if (platform === \"win32\") {\n // Git Bash / MSYS2 / Cygwin set SHELL even on Windows\n if (env.SHELL) {\n if (env.SHELL.endsWith(\"zsh\")) return \"zsh\"\n if (env.SHELL.endsWith(\"fish\")) return \"fish\"\n if (env.SHELL.endsWith(\"bash\")) return \"bash\"\n return \"sh\"\n }\n\n // Windows PowerShell 5.x sets this\n if (env.POWERSHELL_DISTRIBUTION_CHANNEL) return \"powershell\"\n\n // PowerShell (both 5.x and 7+/pwsh) adds user-scoped module paths\n // at runtime. The system-level PSModulePath in CMD lacks these paths.\n if (env.PSModulePath) {\n const lower = env.PSModulePath.toLowerCase()\n if (\n lower.includes(\"documents\\\\powershell\")\n || lower.includes(\"documents\\\\windowspowershell\")\n ) {\n return \"powershell\"\n }\n }\n\n return \"cmd\"\n }\n\n const shellPath = env.SHELL\n if (shellPath) {\n if (shellPath.endsWith(\"zsh\")) return \"zsh\"\n if (shellPath.endsWith(\"fish\")) return \"fish\"\n if (shellPath.endsWith(\"bash\")) return \"bash\"\n }\n\n return \"sh\"\n}\n\nfunction quotePosixValue(value: string): string {\n return `'${value.replace(/'/g, \"'\\\\''\")}'`\n}\n\nfunction quotePowerShellValue(value: string): string {\n return `'${value.replace(/'/g, \"''\")}'`\n}\n\n/**\n * Generates a copy-pasteable script to set multiple environment variables\n * and run a subsequent command.\n * @param {EnvVars} envVars - An object of environment variables to set.\n * @param {string} commandToRun - The command to run after setting the variables.\n * @returns {string} The formatted script string.\n */\nexport function generateEnvScript(\n envVars: EnvVars,\n commandToRun: string = \"\",\n): string {\n const shell = getShell()\n const filteredEnvVars = Object.entries(envVars).filter(\n ([, value]) => value !== undefined,\n ) as Array<[string, string]>\n\n let commandBlock: string\n\n switch (shell) {\n case \"powershell\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `$env:${key} = ${quotePowerShellValue(value)}`)\n .join(\"; \")\n break\n }\n case \"cmd\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `set \"${key}=${value}\"`)\n .join(\" & \")\n break\n }\n case \"fish\": {\n commandBlock = filteredEnvVars\n .map(([key, value]) => `set -gx ${key} ${quotePosixValue(value)}`)\n .join(\"; \")\n break\n }\n default: {\n // bash, zsh, sh\n const assignments = filteredEnvVars\n .map(([key, value]) => `${key}=${quotePosixValue(value)}`)\n .join(\" \")\n commandBlock = filteredEnvVars.length > 0 ? `export ${assignments}` : \"\"\n break\n }\n }\n\n if (commandBlock && commandToRun) {\n const separator =\n shell === \"cmd\" ? \" & \" : shell === \"powershell\" ? \"; \" : \" && \"\n return `${commandBlock}${separator}${commandToRun}`\n }\n\n return commandBlock || commandToRun\n}\n","#!/usr/bin/env node\n\nimport { defineCommand } from \"citty\"\nimport clipboard from \"clipboardy\"\nimport consola from \"consola\"\n\nimport { generateEnvScript } from \"./lib/shell\"\nimport { DEFAULT_CODEX_MODEL, DEFAULT_PORT } from \"./lib/port\"\nimport { provisionBrowserAssets } from \"./lib/browser-mcp/provision\"\nimport { browserToolsEnabled } from \"./lib/mcp-capabilities\"\nimport { colbertDegradedWarning, provisionAndIndexColbert } from \"./lib/colbert\"\nimport { startKeepAwake } from \"./lib/keep-awake\"\nimport { warmTreeSitterPool } from \"./lib/tree-sitter-pool/pool\"\nimport {\n getClaudeCodeEnvVars,\n getCodexEnvVars,\n parseSharedArgs,\n setupAndServe,\n sharedServerArgs,\n} from \"./lib/server-setup\"\nimport { runSelfUpdate } from \"./lib/self-update\"\n\nfunction printAndCopyCommand(command: string, label: string): void {\n consola.box(`${label}\\n\\n${command}`)\n try {\n clipboard.writeSync(command)\n consola.success(`Copied ${label} command to clipboard!`)\n } catch {\n consola.warn(\"Failed to copy to clipboard. Copy the command above manually.\")\n }\n}\n\nfunction generateClaudeCodeCommand(serverUrl: string, model?: string) {\n const envVars = getClaudeCodeEnvVars(serverUrl, model)\n const command = generateEnvScript(envVars, \"claude --dangerously-skip-permissions\")\n printAndCopyCommand(command, \"Claude Code\")\n}\n\nfunction generateCodexCommand(serverUrl: string, model?: string) {\n const codexModel = model ?? DEFAULT_CODEX_MODEL\n const envVars = getCodexEnvVars(serverUrl)\n const command = generateEnvScript(envVars, `codex -m ${codexModel}`)\n printAndCopyCommand(command, \"Codex CLI\")\n}\n\nexport const start = defineCommand({\n meta: {\n name: \"start\",\n description: \"Start the github-router server\",\n },\n args: {\n ...sharedServerArgs,\n cc: {\n type: \"boolean\",\n default: false,\n description:\n \"Generate a command to launch Claude Code with Copilot API config\",\n },\n cx: {\n type: \"boolean\",\n default: false,\n description:\n \"Generate a command to launch Codex CLI with Copilot API config\",\n },\n model: {\n alias: \"m\",\n type: \"string\",\n description: \"Override the default model (used with --cc or --cx)\",\n },\n },\n async run({ args }) {\n const parsed = parseSharedArgs(args as unknown as Record<string, unknown>)\n\n const { serverUrl } = await setupAndServe({\n ...parsed,\n port: parsed.port ?? DEFAULT_PORT,\n silent: false,\n })\n\n // Best-effort self-update (detached, applies next launch). Runs\n // after the server is listening so the bounded probe can't delay it.\n void runSelfUpdate({ selfUpdate: args[\"self-update\"] !== false })\n\n // Best-effort ColBERT semantic-search provision + background index of\n // the launch cwd (if a git repo). Opt-IN via --search (no-op otherwise);\n // never blocks launch, never throws.\n void provisionAndIndexColbert()\n\n // Surface a terminally-failed semantic index to the HUMAN (see the note\n // in claude.ts). Fire-and-forget; lexical search still works.\n void colbertDegradedWarning()\n .then((warning) => {\n if (warning) process.stderr.write(`${warning}\\n`)\n })\n .catch(() => {})\n\n // Ready one tree-sitter worker in the background so the first code search\n // avoids WASM/grammar initialization. One worker keeps launch CPU bounded;\n // demand grows the pool lazily. Opt out with GH_ROUTER_DISABLE_TS_POOL_WARMUP=1.\n void warmTreeSitterPool()\n\n // Best-effort: keep the machine awake while the proxy serves (win32\n // default-on; opt out with GH_ROUTER_DISABLE_KEEP_AWAKE=1). Holds a\n // SetThreadExecutionState assertion via a persistent PowerShell\n // helper. Self-registers its own SIGINT/SIGTERM/exit reaper — load-\n // bearing here, because `start` has no launchChild/onShutdown.\n startKeepAwake()\n\n // Best-effort: materialize the browser extension + bridge into the\n // stable app-dir and stamp the running version, so a one-time \"Load\n // unpacked\" survives npx/bunx upgrades. Gated on --browse; never\n // blocks launch, never throws.\n if (browserToolsEnabled()) {\n void provisionBrowserAssets().catch((err) =>\n consola.debug(\"Browser extension provisioning failed:\", err),\n )\n }\n\n if (args.cc) generateClaudeCodeCommand(serverUrl, args.model)\n if (args.cx) generateCodexCommand(serverUrl, args.model)\n\n consola.box(\n `🌐 Usage Viewer: https://animeshkundu.github.io/github-router/dashboard.html?endpoint=${serverUrl}/usage`,\n )\n },\n})\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-CiwCLVDZ.js","names":[],"sources":["../src/lib/state.ts"],"sourcesContent":["import { randomBytes, randomUUID } from \"node:crypto\"\n\nimport type { ModelsResponse } from \"~/services/copilot/get-models\"\nimport type { BluebirdMcpClient } from \"./bluebird-client\"\nimport type { LaunchProfileId } from \"./launch-profile\"\n\n/**\n * One authenticated `github-router claude` (or `serve`) launch's identity\n * and capability scope, keyed by `launchId` in `state.launchRegistry`.\n *\n * Replaces the earlier scalar `state.peerMcpNonce` assumption — a single\n * process-global nonce cannot express \"which profile is this caller\", so\n * a concurrent fast + standard launch (or a reconnect) had no way to keep\n * their identities from being interchangeable. Each entry carries BOTH\n * credentials a launch presents on the wire:\n *\n * - `nonce` — the `/mcp` bearer (Streamable HTTP `Authorization` header).\n * - `secret` — the `/v1/messages` identity-preflight bearer, deliberately\n * a SEPARATE credential from `nonce` so leaking one surface's token\n * (say, via a client log) does not also authenticate the other.\n *\n * `allowedGroups` / `allowedPersonas` are the narrowing declaration for\n * scoped MCP surfaces: `undefined` means UNRESTRICTED (the standard/BYO\n * launch shape today), and a concrete `ReadonlySet` is a restricted profile's\n * hard allow-list. This module only stores and looks up the declaration;\n * enforcing it against `tools/list` / `tools/call` is the MCP route\n * handler's job.\n */\nexport interface LaunchRegistryEntry {\n /** Opaque per-launch id. Primary key into `state.launchRegistry`. */\n launchId: string\n /** `/mcp` Streamable HTTP bearer for this launch. */\n nonce: string\n /**\n * Optional lead-only `/mcp` bearer for fast profile.\n * Grants access to lead-only tools such as `astra`.\n */\n leadPeersNonce?: string\n /** `/v1/messages` identity-preflight bearer for this launch. */\n secret: string\n /** Which launch profile authenticated this entry. */\n profileId: LaunchProfileId\n /** Scoped MCP group allow-list. `undefined` = unrestricted. */\n allowedGroups?: ReadonlySet<string>\n /** Persona (peers-group) tool-name allow-list. `undefined` = unrestricted. */\n allowedPersonas?: ReadonlySet<string>\n createdAt: number\n}\n\n/**\n * Registry key backing the `state.peerMcpNonce` back-compat accessor\n * below. Not a real launch id (no `registerLaunch` caller ever produces\n * this string), so it can never collide with a genuine per-launch UUID.\n */\nconst DEFAULT_LAUNCH_ID = \"__default__\"\n\nexport interface State {\n githubToken?: string\n copilotToken?: string\n /**\n * GitHub login of `githubToken`, resolved once at setup for the\n * launch summary. Display-only; auth decisions never read it.\n */\n githubUserLogin?: string\n\n /**\n * Where `githubToken` came from, which decides whether the proxy may\n * re-read it from disk.\n *\n * `\"file\"` — read from `PATHS.GITHUB_TOKEN_PATH`. A re-read is allowed, so\n * an out-of-band `github-router auth` heals a running proxy without a\n * restart.\n *\n * `\"explicit\"` — supplied by the operator via `--github-token` / `GH_TOKEN`.\n * The file is NEVER read on this path: silently replacing a\n * caller-supplied credential with whatever happens to be on disk would\n * override an explicit instruction. It also means \"run `github-router\n * auth`\" is false advice for this source — the remediation is to replace\n * the supplied value.\n */\n githubTokenSource?: \"file\" | \"explicit\"\n\n /**\n * Monotonic counter bumped on every SUCCESSFUL Copilot token exchange.\n *\n * This is the retry criterion for `tryRefreshAndRetry`, and it is\n * deliberately not \"did the token string change\": two consecutive\n * successful exchanges were observed returning an identical token, so a\n * string comparison would silently suppress legitimate retries. Nor is it\n * the refresh's own verdict — with requests A and B both holding a stale\n * token, A can refresh while B's later 401 is cooled down to a no-op, and\n * a verdict of \"nothing happened\" would fail B even though a good token is\n * already in `copilotToken`. Comparing generations answers the question\n * each request actually has: \"is what is in state now different from what\n * I already tried?\"\n */\n copilotTokenGeneration: number\n\n /**\n * Wall-clock ms after which `copilotToken` should be refreshed — already\n * skew-adjusted, so the per-request check is a plain `Date.now() >=` compare.\n *\n * Derived from the exchange's `refresh_in` (a DURATION) and never from its\n * absolute `expires_at`. A local clock running ahead of GitHub's would make\n * an absolute timestamp look already-past on a brand-new token and drive a\n * refresh storm; a duration is immune, because it is anchored to the same\n * clock that later reads it.\n */\n copilotTokenRefreshAt?: number\n\n /**\n * Second, WRITE-capable GitHub token for the first-mate\n * agent-orchestration surface (`--agents`). Minted by a separate\n * device-flow login against the GitHub CLI's OAuth client\n * (`GITHUB_AGENT_CLIENT_ID`, scopes `repo workflow read:org`) and\n * stored at `PATHS.GITHUB_AGENT_TOKEN_PATH`, apart from `githubToken`\n * (the Copilot App token, read:user). The first-mate GitHub service\n * layer uses this for ALL its calls (reads included, so it also works\n * on private repos). Undefined until the agent login has run.\n */\n githubAgentToken?: string\n\n accountType: string\n copilotApiUrl?: string\n models?: ModelsResponse\n vsCodeVersion?: string\n copilotVersion?: string\n\n manualApprove: boolean\n rateLimitWait: boolean\n showToken: boolean\n extendedBetas: boolean\n\n /**\n * Opt-in flag for the browser-control MCP tools (`browser_*`). Set by\n * `setupAndServe` from the `--browse` CLI flag or\n * `GH_ROUTER_ENABLE_BROWSE=1` env var. When false, all `browser_*`\n * tools are dropped from `tools/list` AND `tools/call` returns\n * -32601 — same defense-in-depth pattern as `workerToolsEnabled()` /\n * `standInToolEnabled()`. See `browserToolsEnabled()` in\n * `src/routes/mcp/handler.ts`.\n */\n browseEnabled: boolean\n\n /**\n * Opt-in flag for the fleet session-control MCP tools (`mcp__fleet__*`).\n * Set by `setupAndServe` from the `--fleet` CLI flag or\n * `GH_ROUTER_ENABLE_FLEET=1` env var. When false, all fleet tools are\n * dropped from `tools/list` AND `tools/call` returns -32601 — same\n * defense-in-depth pattern as `workerToolsEnabled()` /\n * `standInToolEnabled()`. See `fleetToolsEnabled()` in\n * `src/lib/mcp-capabilities.ts`.\n */\n fleetEnabled: boolean\n\n /**\n * Opt-in flag for the first-mate agent-orchestration MCP tools\n * (`mcp__first-mate__*`) and the in-process GitHub cloud-agent driving\n * layer. Set by `setupAndServe` from the `--agents` CLI flag or\n * `GH_ROUTER_ENABLE_AGENTS=1`. When false, the first-mate tools are\n * dropped from `tools/list` AND `tools/call` returns -32601 — same\n * defense-in-depth pattern as `fleetToolsEnabled()`. Additionally\n * requires `state.githubAgentToken` present (the write login), so the\n * surface is invisible rather than 401-ing when unauthenticated. See\n * `agentToolsEnabled()` in `src/lib/mcp-capabilities.ts`.\n */\n agentsEnabled: boolean\n\n /**\n * When true, --power-browse was passed (or GH_ROUTER_ENABLE_POWER_BROWSE=1\n * is set). Exposes the FULL browser MCP surface (~18 tools) on /mcp,\n * including the L0/L1 primitives that hand DOM details (refs,\n * bboxes, role/name dumps) to the lead model. Default --browse mode\n * exposes only the 6 lead-model tools (act, observe, extract,\n * navigate, screenshot, open_tab). Always implies browseEnabled.\n */\n powerBrowseEnabled: boolean\n\n /**\n * Opt-in flag for ColBERT/colgrep semantic code search. Set by\n * `setupAndServe` from the `--search` CLI flag or\n * `GH_ROUTER_ENABLE_SEMANTIC_SEARCH=1` env var. When false, no colgrep\n * binary/model is provisioned, no workspace is indexed, and the `code`\n * MCP tool serves lexical results (with `lexical-fallback` source when\n * semantic mode was requested). See `semanticSearchOptedIn()` in\n * `src/lib/colbert/index.ts`; `GH_ROUTER_DISABLE_SEMANTIC_SEARCH=1`\n * hard-disables regardless of this flag.\n */\n searchEnabled: boolean\n\n /**\n * Opt-in flag for Bluebird Azure DevOps code search. Set by\n * `setupAndServe` from the `--bluebird` CLI flag or\n * `GH_ROUTER_ENABLE_BLUEBIRD=1` env var. When true, the `code` MCP\n * tool routes `semantic`/`lexical` modes through the Bluebird MCP\n * server. This flag is independent from `searchEnabled`, which controls\n * local ColBERT provisioning; `exact`/`regex`/`ast` stay local.\n * See `src/lib/bluebird-client.ts`.\n */\n bluebirdEnabled: boolean\n\n /** Last connected Bluebird client, retained only for compatibility and\n * diagnostics. Client selection is owned by the Bluebird runtime manager. */\n bluebirdClient: BluebirdMcpClient | null\n\n /** Resolved Bluebird scope (org/project/repos/branch), for logging and\n * the `x-mcp-ec-*` headers baked into the client. */\n bluebirdOrganization: string | null\n bluebirdProject: string | null\n bluebirdRepositories: Array<string>\n bluebirdBranch: string | null\n\n /**\n * Azure DevOps remote MCP group (`mcp__ado__*`). Enabled by `--ado`, by\n * `GH_ROUTER_ENABLE_ADO=1`, or automatically when the workspace's git\n * remotes resolve to an Azure DevOps repository. See\n * `src/lib/azure-mcp-flags.ts` for the precedence and the trust argument.\n */\n adoEnabled: boolean\n /** Organization whose `https://mcp.dev.azure.com/{org}` endpoint is used. */\n adoOrganization: string | null\n /**\n * `X-MCP-Toolsets` selection. The single entry `\"all\"` means \"send no\n * header\". Empty only while the group is off.\n */\n adoToolsets: Array<string>\n /**\n * Send `X-MCP-Readonly: true`. True unless `--ado-write` was passed. Never\n * cleared by discovery — a git remote can turn this group on but can never\n * widen it to writes.\n */\n adoReadOnly: boolean\n\n /**\n * Kusto (Azure Data Explorer) MCP group (`mcp__kusto__*`). Turned on by the\n * operator's `--kusto` flag, by a named cluster, or automatically when the\n * workspace's git remotes resolve to an Azure DevOps repository. Discovery\n * turns the GROUP on and never supplies a cluster: the model names one per\n * call, and the operator's own cluster access bounds the reach.\n */\n kustoEnabled: boolean\n /**\n * Default cluster for calls that do not name one, or null. Null no longer\n * turns the group off: every kusto tool takes its own `cluster`, so a launch\n * with no default still works, it just requires the argument.\n */\n kustoCluster: string | null\n kustoDatabase: string | null\n\n /**\n * Cloud Agent Job API v2 MCP group (`mcp__cloudagent__*`): hand work to a cloud\n * coding agent running against an Azure DevOps repository.\n *\n * Enabled by `--cloudagent`, by `GH_ROUTER_ENABLE_CLOUDAGENT=1`, or automatically\n * when the workspace's git remotes resolve to an Azure DevOps repository.\n * Discovery enables the whole group, write tools included, matching the ADO,\n * Kusto and Bluebird groups; `--no-cloudagent` remains the operator's veto.\n */\n cloudAgentEnabled: boolean\n /** `prod` or `ppe`, normalized by `resolveCloudAgentFlags()` at launch. */\n cloudAgentEnvironment: string\n\n /**\n * Humanlike pacing override:\n * \"on\" - --humanlike CLI flag or GH_ROUTER_HUMANLIKE=1 env;\n * inject Beta-distributed inter-action delays, Bezier\n * mouse paths, per-keystroke jitter, scroll chunking\n * into every browser_* action dispatch.\n * \"off\" - GH_ROUTER_BROWSER_NO_HUMANLIKE=1; HARD disable, wins\n * over \"on\" so tests are reproducible.\n * \"auto\" - default; pacing engages only when bot-challenge\n * detection fires (Phase 4-future).\n *\n * Lead model never sees this state — it's an internal concern.\n */\n humanlikeForce: \"on\" | \"off\" | \"auto\"\n\n // Rate limiting configuration\n rateLimitSeconds?: number\n lastRequestTimestamp?: number\n\n // Persistent session identifiers to match VS Code fingerprint\n sessionId: string\n machineId: string\n\n /**\n * Keyed per-launch registry for the loopback `/mcp` endpoint AND the\n * `/v1/messages` identity preflight. Set by the `claude` subcommand\n * (via `registerLaunch` in `./launch-registry`) after `setupAndServe`\n * and before spawning Claude Code; removed by the launch's own\n * cleanup. When empty, `/mcp` rejects all requests — closes the\n * loopback-no-auth gap (DNS rebinding, malicious browser-ext native\n * messaging, sibling-process probe) exactly as the old scalar nonce\n * did when unset.\n *\n * Multiple entries coexist for concurrent fast/standard launches (or a\n * launch plus a reconnect); each is looked up by its OWN nonce/secret,\n * so two launches' authenticated identities never cross.\n */\n launchRegistry: Map<string, LaunchRegistryEntry>\n\n /**\n * @deprecated Back-compat accessor over the registry's DEFAULT_LAUNCH_ID\n * entry (profileId \"standard\", unrestricted `allowedGroups`/\n * `allowedPersonas`) — defined below via `Object.defineProperty`, not a\n * real stored field. Reading returns that entry's nonce; writing creates\n * or updates it (or deletes it on `undefined`). Exists so single-launch\n * call sites and tests that already do `state.peerMcpNonce = NONCE`\n * keep working unmodified while `checkAuth` and the identity preflight\n * consult the real keyed registry underneath. New code should call\n * `registerLaunch` / `findLaunchByNonce` / `findLaunchBySecret` from\n * `./launch-registry` directly instead of reading/writing this field.\n */\n peerMcpNonce?: string\n\n /**\n * Set by `github-router serve` (a single machine-wide control plane serving\n * many repos). When true, repo-scoped worker tools require an explicit/So-derived\n * `workspace` and must NOT silently default to the proxy launch cwd.\n */\n serveMode?: boolean\n}\n\nexport const state: State = {\n accountType: \"enterprise\",\n copilotTokenGeneration: 0,\n manualApprove: false,\n rateLimitWait: false,\n showToken: false,\n extendedBetas: false,\n browseEnabled: false,\n fleetEnabled: false,\n agentsEnabled: false,\n powerBrowseEnabled: false,\n searchEnabled: false,\n bluebirdEnabled: false,\n bluebirdClient: null,\n bluebirdOrganization: null,\n bluebirdProject: null,\n bluebirdRepositories: [],\n bluebirdBranch: null,\n adoEnabled: false,\n adoOrganization: null,\n adoToolsets: [],\n adoReadOnly: true,\n kustoEnabled: false,\n kustoCluster: null,\n kustoDatabase: null,\n cloudAgentEnabled: false,\n cloudAgentEnvironment: \"prod\",\n humanlikeForce: \"auto\",\n sessionId: randomUUID(),\n machineId: randomBytes(32).toString(\"hex\"),\n launchRegistry: new Map(),\n}\n\n// `peerMcpNonce` is not a plain data field — it's a live view onto\n// `state.launchRegistry.get(DEFAULT_LAUNCH_ID)`. Defined via\n// `Object.defineProperty` (rather than a class) so `state` stays the\n// plain object literal every existing importer already destructures /\n// mutates directly.\nObject.defineProperty(state, \"peerMcpNonce\", {\n enumerable: true,\n configurable: true,\n get(): string | undefined {\n return state.launchRegistry.get(DEFAULT_LAUNCH_ID)?.nonce\n },\n set(value: string | undefined) {\n if (value === undefined) {\n state.launchRegistry.delete(DEFAULT_LAUNCH_ID)\n return\n }\n const existing = state.launchRegistry.get(DEFAULT_LAUNCH_ID)\n state.launchRegistry.set(DEFAULT_LAUNCH_ID, {\n launchId: DEFAULT_LAUNCH_ID,\n nonce: value,\n // A caller that only ever touches `peerMcpNonce` exposes MCP only and has\n // no Messages identity secret.\n // Never reuse the MCP bearer across surfaces: an empty secret cannot match\n // any non-empty custom header, while registered Claude launches always use\n // `registerLaunch` with independently generated credentials.\n secret: existing?.secret ?? \"\",\n profileId: existing?.profileId ?? \"standard\",\n allowedGroups: existing?.allowedGroups,\n allowedPersonas: existing?.allowedPersonas,\n createdAt: existing?.createdAt ?? Date.now(),\n })\n },\n})\n"],"mappings":";;;;;;;AAsDA,MAAM,oBAAoB;AA6Q1B,MAAa,QAAe;CAC1B,aAAa;CACb,wBAAwB;CACxB,eAAe;CACf,eAAe;CACf,WAAW;CACX,eAAe;CACf,eAAe;CACf,cAAc;CACd,eAAe;CACf,oBAAoB;CACpB,eAAe;CACf,iBAAiB;CACjB,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,sBAAsB,CAAC;CACvB,gBAAgB;CAChB,YAAY;CACZ,iBAAiB;CACjB,aAAa,CAAC;CACd,aAAa;CACb,cAAc;CACd,cAAc;CACd,eAAe;CACf,mBAAmB;CACnB,uBAAuB;CACvB,gBAAgB;CAChB,WAAW,WAAW;CACtB,WAAW,YAAY,EAAE,CAAC,CAAC,SAAS,KAAK;CACzC,gCAAgB,IAAI,IAAI;AAC1B;AAOA,OAAO,eAAe,OAAO,gBAAgB;CAC3C,YAAY;CACZ,cAAc;CACd,MAA0B;EACxB,OAAO,MAAM,eAAe,IAAI,iBAAiB,CAAC,EAAE;CACtD;CACA,IAAI,OAA2B;EAC7B,IAAI,UAAU,KAAA,GAAW;GACvB,MAAM,eAAe,OAAO,iBAAiB;GAC7C;EACF;EACA,MAAM,WAAW,MAAM,eAAe,IAAI,iBAAiB;EAC3D,MAAM,eAAe,IAAI,mBAAmB;GAC1C,UAAU;GACV,OAAO;GAMP,QAAQ,UAAU,UAAU;GAC5B,WAAW,UAAU,aAAa;GAClC,eAAe,UAAU;GACzB,iBAAiB,UAAU;GAC3B,WAAW,UAAU,aAAa,KAAK,IAAI;EAC7C,CAAC;CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"state-CiwCLVDZ.js","names":[],"sources":["../src/lib/state.ts"],"sourcesContent":["import { randomBytes, randomUUID } from \"node:crypto\"\n\nimport type { ModelsResponse } from \"~/services/copilot/get-models\"\nimport type { BluebirdMcpClient } from \"./bluebird-client\"\nimport type { LaunchProfileId } from \"./launch-profile\"\n\n/**\n * One authenticated `github-router claude` (or `serve`) launch's identity\n * and capability scope, keyed by `launchId` in `state.launchRegistry`.\n *\n * Replaces the earlier scalar `state.peerMcpNonce` assumption — a single\n * process-global nonce cannot express \"which profile is this caller\", so\n * a concurrent fast + standard launch (or a reconnect) had no way to keep\n * their identities from being interchangeable. Each entry carries BOTH\n * credentials a launch presents on the wire:\n *\n * - `nonce` — the `/mcp` bearer (Streamable HTTP `Authorization` header).\n * - `secret` — the `/v1/messages` identity-preflight bearer, deliberately\n * a SEPARATE credential from `nonce` so leaking one surface's token\n * (say, via a client log) does not also authenticate the other.\n *\n * `allowedGroups` / `allowedPersonas` are the narrowing declaration for\n * scoped MCP surfaces: `undefined` means UNRESTRICTED (the standard/BYO\n * launch shape today), and a concrete `ReadonlySet` is a restricted profile's\n * hard allow-list. This module only stores and looks up the declaration;\n * enforcing it against `tools/list` / `tools/call` is the MCP route\n * handler's job.\n */\nexport interface LaunchRegistryEntry {\n /** Opaque per-launch id. Primary key into `state.launchRegistry`. */\n launchId: string\n /** `/mcp` Streamable HTTP bearer for this launch. */\n nonce: string\n /**\n * Optional lead-only `/mcp` bearer for fast profile.\n * Grants access to lead-only tools such as `astra`.\n */\n leadPeersNonce?: string\n /** `/v1/messages` identity-preflight bearer for this launch. */\n secret: string\n /** Which launch profile authenticated this entry. */\n profileId: LaunchProfileId\n /** Scoped MCP group allow-list. `undefined` = unrestricted. */\n allowedGroups?: ReadonlySet<string>\n /** Persona (peers-group) tool-name allow-list. `undefined` = unrestricted. */\n allowedPersonas?: ReadonlySet<string>\n /**\n * The client's own conversation id, learned from `x-claude-code-session-id`\n * on this launch's `/v1/messages` traffic.\n *\n * `/mcp` has no conversation header of its own, so a local consult issued\n * from an MCP tool call has nothing to key prompt-cache routing on. The\n * lead's `/v1/messages` requests are the one channel that carries the id,\n * and the launch registry is the shared place the messages route and the MCP\n * route both hold. Latest value wins: `/clear` starts a new conversation and\n * the stale id would otherwise follow the session forever.\n */\n sessionId?: string\n createdAt: number\n}\n\n/**\n * Registry key backing the `state.peerMcpNonce` back-compat accessor\n * below. Not a real launch id (no `registerLaunch` caller ever produces\n * this string), so it can never collide with a genuine per-launch UUID.\n */\nconst DEFAULT_LAUNCH_ID = \"__default__\"\n\nexport interface State {\n githubToken?: string\n copilotToken?: string\n /**\n * GitHub login of `githubToken`, resolved once at setup for the\n * launch summary. Display-only; auth decisions never read it.\n */\n githubUserLogin?: string\n\n /**\n * Where `githubToken` came from, which decides whether the proxy may\n * re-read it from disk.\n *\n * `\"file\"` — read from `PATHS.GITHUB_TOKEN_PATH`. A re-read is allowed, so\n * an out-of-band `github-router auth` heals a running proxy without a\n * restart.\n *\n * `\"explicit\"` — supplied by the operator via `--github-token` / `GH_TOKEN`.\n * The file is NEVER read on this path: silently replacing a\n * caller-supplied credential with whatever happens to be on disk would\n * override an explicit instruction. It also means \"run `github-router\n * auth`\" is false advice for this source — the remediation is to replace\n * the supplied value.\n */\n githubTokenSource?: \"file\" | \"explicit\"\n\n /**\n * Monotonic counter bumped on every SUCCESSFUL Copilot token exchange.\n *\n * This is the retry criterion for `tryRefreshAndRetry`, and it is\n * deliberately not \"did the token string change\": two consecutive\n * successful exchanges were observed returning an identical token, so a\n * string comparison would silently suppress legitimate retries. Nor is it\n * the refresh's own verdict — with requests A and B both holding a stale\n * token, A can refresh while B's later 401 is cooled down to a no-op, and\n * a verdict of \"nothing happened\" would fail B even though a good token is\n * already in `copilotToken`. Comparing generations answers the question\n * each request actually has: \"is what is in state now different from what\n * I already tried?\"\n */\n copilotTokenGeneration: number\n\n /**\n * Wall-clock ms after which `copilotToken` should be refreshed — already\n * skew-adjusted, so the per-request check is a plain `Date.now() >=` compare.\n *\n * Derived from the exchange's `refresh_in` (a DURATION) and never from its\n * absolute `expires_at`. A local clock running ahead of GitHub's would make\n * an absolute timestamp look already-past on a brand-new token and drive a\n * refresh storm; a duration is immune, because it is anchored to the same\n * clock that later reads it.\n */\n copilotTokenRefreshAt?: number\n\n /**\n * Second, WRITE-capable GitHub token for the first-mate\n * agent-orchestration surface (`--agents`). Minted by a separate\n * device-flow login against the GitHub CLI's OAuth client\n * (`GITHUB_AGENT_CLIENT_ID`, scopes `repo workflow read:org`) and\n * stored at `PATHS.GITHUB_AGENT_TOKEN_PATH`, apart from `githubToken`\n * (the Copilot App token, read:user). The first-mate GitHub service\n * layer uses this for ALL its calls (reads included, so it also works\n * on private repos). Undefined until the agent login has run.\n */\n githubAgentToken?: string\n\n accountType: string\n copilotApiUrl?: string\n models?: ModelsResponse\n vsCodeVersion?: string\n copilotVersion?: string\n\n manualApprove: boolean\n rateLimitWait: boolean\n showToken: boolean\n extendedBetas: boolean\n\n /**\n * Opt-in flag for the browser-control MCP tools (`browser_*`). Set by\n * `setupAndServe` from the `--browse` CLI flag or\n * `GH_ROUTER_ENABLE_BROWSE=1` env var. When false, all `browser_*`\n * tools are dropped from `tools/list` AND `tools/call` returns\n * -32601 — same defense-in-depth pattern as `workerToolsEnabled()` /\n * `standInToolEnabled()`. See `browserToolsEnabled()` in\n * `src/routes/mcp/handler.ts`.\n */\n browseEnabled: boolean\n\n /**\n * Opt-in flag for the fleet session-control MCP tools (`mcp__fleet__*`).\n * Set by `setupAndServe` from the `--fleet` CLI flag or\n * `GH_ROUTER_ENABLE_FLEET=1` env var. When false, all fleet tools are\n * dropped from `tools/list` AND `tools/call` returns -32601 — same\n * defense-in-depth pattern as `workerToolsEnabled()` /\n * `standInToolEnabled()`. See `fleetToolsEnabled()` in\n * `src/lib/mcp-capabilities.ts`.\n */\n fleetEnabled: boolean\n\n /**\n * Opt-in flag for the first-mate agent-orchestration MCP tools\n * (`mcp__first-mate__*`) and the in-process GitHub cloud-agent driving\n * layer. Set by `setupAndServe` from the `--agents` CLI flag or\n * `GH_ROUTER_ENABLE_AGENTS=1`. When false, the first-mate tools are\n * dropped from `tools/list` AND `tools/call` returns -32601 — same\n * defense-in-depth pattern as `fleetToolsEnabled()`. Additionally\n * requires `state.githubAgentToken` present (the write login), so the\n * surface is invisible rather than 401-ing when unauthenticated. See\n * `agentToolsEnabled()` in `src/lib/mcp-capabilities.ts`.\n */\n agentsEnabled: boolean\n\n /**\n * When true, --power-browse was passed (or GH_ROUTER_ENABLE_POWER_BROWSE=1\n * is set). Exposes the FULL browser MCP surface (~18 tools) on /mcp,\n * including the L0/L1 primitives that hand DOM details (refs,\n * bboxes, role/name dumps) to the lead model. Default --browse mode\n * exposes only the 6 lead-model tools (act, observe, extract,\n * navigate, screenshot, open_tab). Always implies browseEnabled.\n */\n powerBrowseEnabled: boolean\n\n /**\n * Opt-in flag for ColBERT/colgrep semantic code search. Set by\n * `setupAndServe` from the `--search` CLI flag or\n * `GH_ROUTER_ENABLE_SEMANTIC_SEARCH=1` env var. When false, no colgrep\n * binary/model is provisioned, no workspace is indexed, and the `code`\n * MCP tool serves lexical results (with `lexical-fallback` source when\n * semantic mode was requested). See `semanticSearchOptedIn()` in\n * `src/lib/colbert/index.ts`; `GH_ROUTER_DISABLE_SEMANTIC_SEARCH=1`\n * hard-disables regardless of this flag.\n */\n searchEnabled: boolean\n\n /**\n * Opt-in flag for Bluebird Azure DevOps code search. Set by\n * `setupAndServe` from the `--bluebird` CLI flag or\n * `GH_ROUTER_ENABLE_BLUEBIRD=1` env var. When true, the `code` MCP\n * tool routes `semantic`/`lexical` modes through the Bluebird MCP\n * server. This flag is independent from `searchEnabled`, which controls\n * local ColBERT provisioning; `exact`/`regex`/`ast` stay local.\n * See `src/lib/bluebird-client.ts`.\n */\n bluebirdEnabled: boolean\n\n /** Last connected Bluebird client, retained only for compatibility and\n * diagnostics. Client selection is owned by the Bluebird runtime manager. */\n bluebirdClient: BluebirdMcpClient | null\n\n /** Resolved Bluebird scope (org/project/repos/branch), for logging and\n * the `x-mcp-ec-*` headers baked into the client. */\n bluebirdOrganization: string | null\n bluebirdProject: string | null\n bluebirdRepositories: Array<string>\n bluebirdBranch: string | null\n\n /**\n * Azure DevOps remote MCP group (`mcp__ado__*`). Enabled by `--ado`, by\n * `GH_ROUTER_ENABLE_ADO=1`, or automatically when the workspace's git\n * remotes resolve to an Azure DevOps repository. See\n * `src/lib/azure-mcp-flags.ts` for the precedence and the trust argument.\n */\n adoEnabled: boolean\n /** Organization whose `https://mcp.dev.azure.com/{org}` endpoint is used. */\n adoOrganization: string | null\n /**\n * `X-MCP-Toolsets` selection. The single entry `\"all\"` means \"send no\n * header\". Empty only while the group is off.\n */\n adoToolsets: Array<string>\n /**\n * Send `X-MCP-Readonly: true`. True unless `--ado-write` was passed. Never\n * cleared by discovery — a git remote can turn this group on but can never\n * widen it to writes.\n */\n adoReadOnly: boolean\n\n /**\n * Kusto (Azure Data Explorer) MCP group (`mcp__kusto__*`). Turned on by the\n * operator's `--kusto` flag, by a named cluster, or automatically when the\n * workspace's git remotes resolve to an Azure DevOps repository. Discovery\n * turns the GROUP on and never supplies a cluster: the model names one per\n * call, and the operator's own cluster access bounds the reach.\n */\n kustoEnabled: boolean\n /**\n * Default cluster for calls that do not name one, or null. Null no longer\n * turns the group off: every kusto tool takes its own `cluster`, so a launch\n * with no default still works, it just requires the argument.\n */\n kustoCluster: string | null\n kustoDatabase: string | null\n\n /**\n * Cloud Agent Job API v2 MCP group (`mcp__cloudagent__*`): hand work to a cloud\n * coding agent running against an Azure DevOps repository.\n *\n * Enabled by `--cloudagent`, by `GH_ROUTER_ENABLE_CLOUDAGENT=1`, or automatically\n * when the workspace's git remotes resolve to an Azure DevOps repository.\n * Discovery enables the whole group, write tools included, matching the ADO,\n * Kusto and Bluebird groups; `--no-cloudagent` remains the operator's veto.\n */\n cloudAgentEnabled: boolean\n /** `prod` or `ppe`, normalized by `resolveCloudAgentFlags()` at launch. */\n cloudAgentEnvironment: string\n\n /**\n * Humanlike pacing override:\n * \"on\" - --humanlike CLI flag or GH_ROUTER_HUMANLIKE=1 env;\n * inject Beta-distributed inter-action delays, Bezier\n * mouse paths, per-keystroke jitter, scroll chunking\n * into every browser_* action dispatch.\n * \"off\" - GH_ROUTER_BROWSER_NO_HUMANLIKE=1; HARD disable, wins\n * over \"on\" so tests are reproducible.\n * \"auto\" - default; pacing engages only when bot-challenge\n * detection fires (Phase 4-future).\n *\n * Lead model never sees this state — it's an internal concern.\n */\n humanlikeForce: \"on\" | \"off\" | \"auto\"\n\n // Rate limiting configuration\n rateLimitSeconds?: number\n lastRequestTimestamp?: number\n\n // Persistent session identifiers to match VS Code fingerprint\n sessionId: string\n machineId: string\n\n /**\n * Keyed per-launch registry for the loopback `/mcp` endpoint AND the\n * `/v1/messages` identity preflight. Set by the `claude` subcommand\n * (via `registerLaunch` in `./launch-registry`) after `setupAndServe`\n * and before spawning Claude Code; removed by the launch's own\n * cleanup. When empty, `/mcp` rejects all requests — closes the\n * loopback-no-auth gap (DNS rebinding, malicious browser-ext native\n * messaging, sibling-process probe) exactly as the old scalar nonce\n * did when unset.\n *\n * Multiple entries coexist for concurrent fast/standard launches (or a\n * launch plus a reconnect); each is looked up by its OWN nonce/secret,\n * so two launches' authenticated identities never cross.\n */\n launchRegistry: Map<string, LaunchRegistryEntry>\n\n /**\n * @deprecated Back-compat accessor over the registry's DEFAULT_LAUNCH_ID\n * entry (profileId \"standard\", unrestricted `allowedGroups`/\n * `allowedPersonas`) — defined below via `Object.defineProperty`, not a\n * real stored field. Reading returns that entry's nonce; writing creates\n * or updates it (or deletes it on `undefined`). Exists so single-launch\n * call sites and tests that already do `state.peerMcpNonce = NONCE`\n * keep working unmodified while `checkAuth` and the identity preflight\n * consult the real keyed registry underneath. New code should call\n * `registerLaunch` / `findLaunchByNonce` / `findLaunchBySecret` from\n * `./launch-registry` directly instead of reading/writing this field.\n */\n peerMcpNonce?: string\n\n /**\n * Set by `github-router serve` (a single machine-wide control plane serving\n * many repos). When true, repo-scoped worker tools require an explicit/So-derived\n * `workspace` and must NOT silently default to the proxy launch cwd.\n */\n serveMode?: boolean\n}\n\nexport const state: State = {\n accountType: \"enterprise\",\n copilotTokenGeneration: 0,\n manualApprove: false,\n rateLimitWait: false,\n showToken: false,\n extendedBetas: false,\n browseEnabled: false,\n fleetEnabled: false,\n agentsEnabled: false,\n powerBrowseEnabled: false,\n searchEnabled: false,\n bluebirdEnabled: false,\n bluebirdClient: null,\n bluebirdOrganization: null,\n bluebirdProject: null,\n bluebirdRepositories: [],\n bluebirdBranch: null,\n adoEnabled: false,\n adoOrganization: null,\n adoToolsets: [],\n adoReadOnly: true,\n kustoEnabled: false,\n kustoCluster: null,\n kustoDatabase: null,\n cloudAgentEnabled: false,\n cloudAgentEnvironment: \"prod\",\n humanlikeForce: \"auto\",\n sessionId: randomUUID(),\n machineId: randomBytes(32).toString(\"hex\"),\n launchRegistry: new Map(),\n}\n\n// `peerMcpNonce` is not a plain data field — it's a live view onto\n// `state.launchRegistry.get(DEFAULT_LAUNCH_ID)`. Defined via\n// `Object.defineProperty` (rather than a class) so `state` stays the\n// plain object literal every existing importer already destructures /\n// mutates directly.\nObject.defineProperty(state, \"peerMcpNonce\", {\n enumerable: true,\n configurable: true,\n get(): string | undefined {\n return state.launchRegistry.get(DEFAULT_LAUNCH_ID)?.nonce\n },\n set(value: string | undefined) {\n if (value === undefined) {\n state.launchRegistry.delete(DEFAULT_LAUNCH_ID)\n return\n }\n const existing = state.launchRegistry.get(DEFAULT_LAUNCH_ID)\n state.launchRegistry.set(DEFAULT_LAUNCH_ID, {\n launchId: DEFAULT_LAUNCH_ID,\n nonce: value,\n // A caller that only ever touches `peerMcpNonce` exposes MCP only and has\n // no Messages identity secret.\n // Never reuse the MCP bearer across surfaces: an empty secret cannot match\n // any non-empty custom header, while registered Claude launches always use\n // `registerLaunch` with independently generated credentials.\n secret: existing?.secret ?? \"\",\n profileId: existing?.profileId ?? \"standard\",\n allowedGroups: existing?.allowedGroups,\n allowedPersonas: existing?.allowedPersonas,\n createdAt: existing?.createdAt ?? Date.now(),\n })\n },\n})\n"],"mappings":";;;;;;;AAkEA,MAAM,oBAAoB;AA6Q1B,MAAa,QAAe;CAC1B,aAAa;CACb,wBAAwB;CACxB,eAAe;CACf,eAAe;CACf,WAAW;CACX,eAAe;CACf,eAAe;CACf,cAAc;CACd,eAAe;CACf,oBAAoB;CACpB,eAAe;CACf,iBAAiB;CACjB,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,sBAAsB,CAAC;CACvB,gBAAgB;CAChB,YAAY;CACZ,iBAAiB;CACjB,aAAa,CAAC;CACd,aAAa;CACb,cAAc;CACd,cAAc;CACd,eAAe;CACf,mBAAmB;CACnB,uBAAuB;CACvB,gBAAgB;CAChB,WAAW,WAAW;CACtB,WAAW,YAAY,EAAE,CAAC,CAAC,SAAS,KAAK;CACzC,gCAAgB,IAAI,IAAI;AAC1B;AAOA,OAAO,eAAe,OAAO,gBAAgB;CAC3C,YAAY;CACZ,cAAc;CACd,MAA0B;EACxB,OAAO,MAAM,eAAe,IAAI,iBAAiB,CAAC,EAAE;CACtD;CACA,IAAI,OAA2B;EAC7B,IAAI,UAAU,KAAA,GAAW;GACvB,MAAM,eAAe,OAAO,iBAAiB;GAC7C;EACF;EACA,MAAM,WAAW,MAAM,eAAe,IAAI,iBAAiB;EAC3D,MAAM,eAAe,IAAI,mBAAmB;GAC1C,UAAU;GACV,OAAO;GAMP,QAAQ,UAAU,UAAU;GAC5B,WAAW,UAAU,aAAa;GAClC,eAAe,UAAU;GACzB,iBAAiB,UAAU;GAC3B,WAAW,UAAU,aAAa,KAAK,IAAI;EAC7C,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as BALANCED_PROFILE_MODELS, t as BALANCED_PROFILE_CONTRACT } from "./balanced-profile-contract-
|
|
1
|
+
import { r as BALANCED_PROFILE_MODELS, t as BALANCED_PROFILE_CONTRACT } from "./balanced-profile-contract-Dm_usmw7.js";
|
|
2
2
|
import { t as buildSelfCommand } from "./self-invocation-BtcGj-lY.js";
|
|
3
3
|
import { s as isSubagentContext } from "./stop-gate-policy-Dx9c98_d.js";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
@@ -92,6 +92,15 @@ const CHEAPEST_PROFILE_ADVISOR_EFFORT = "medium";
|
|
|
92
92
|
const CHEAPEST_PROFILE_ORACLE_MODEL = CHEAPEST_PROFILE_MODELS.oracle;
|
|
93
93
|
const CHEAPEST_PROFILE_ORACLE_EFFORT = "high";
|
|
94
94
|
/**
|
|
95
|
+
* The Copilot model the prompt-rewrite hooks dispatch on.
|
|
96
|
+
*
|
|
97
|
+
* Separate from `advisorModel` because the two are only incidentally the same
|
|
98
|
+
* tier today: a rewrite is always a Copilot call, so a family member whose
|
|
99
|
+
* consultants move to another transport must not drag the rewrite along with
|
|
100
|
+
* them (see `cheaplocal-profile-contract.ts`).
|
|
101
|
+
*/
|
|
102
|
+
const CHEAPEST_PROFILE_REWRITE_MODEL = CHEAPEST_PROFILE_MODELS.advisor;
|
|
103
|
+
/**
|
|
95
104
|
* Synthesized MCP consultant tools for `-m cheapest`: Oracle only, like
|
|
96
105
|
* `-m cheap` (never `astra`).
|
|
97
106
|
*/
|
|
@@ -131,6 +140,13 @@ const CHEAPEST_PROFILE_CONTRACT = Object.freeze({
|
|
|
131
140
|
advisorEffort: CHEAPEST_PROFILE_ADVISOR_EFFORT,
|
|
132
141
|
oracleModel: CHEAPEST_PROFILE_ORACLE_MODEL,
|
|
133
142
|
oracleEffort: CHEAPEST_PROFILE_ORACLE_EFFORT,
|
|
143
|
+
rewriteModel: CHEAPEST_PROFILE_REWRITE_MODEL,
|
|
144
|
+
/**
|
|
145
|
+
* Where the Advisor and Oracle are served. `cheapest` and `cheapest2` both
|
|
146
|
+
* consult Copilot; `cheaplocal` is the family member that consults the local
|
|
147
|
+
* endpoint. Consumers branch on this value, never on a profile id.
|
|
148
|
+
*/
|
|
149
|
+
consultTransport: "copilot",
|
|
134
150
|
synthesizedPeers: CHEAPEST_PROFILE_SYNTHESIZED_PEERS,
|
|
135
151
|
delegationGraph: CHEAPEST_PROFILE_DELEGATION_GRAPH
|
|
136
152
|
});
|
|
@@ -171,6 +187,8 @@ const CHEAPEST2_PROFILE_ADVISOR_CLIENT_MODEL = CHEAPEST2_PROFILE_MODELS.advisor;
|
|
|
171
187
|
*/
|
|
172
188
|
const CHEAPEST2_PROFILE_ADVISOR_EFFORT = "high";
|
|
173
189
|
const CHEAPEST2_PROFILE_ORACLE_MODEL = CHEAPEST2_PROFILE_MODELS.oracle;
|
|
190
|
+
/** The rewrite stays on this sibling's own Sol tier. */
|
|
191
|
+
const CHEAPEST2_PROFILE_REWRITE_MODEL = CHEAPEST2_PROFILE_MODELS.advisor;
|
|
174
192
|
/** The `-m cheapest2` aggregate: the base contract with only the Sol
|
|
175
193
|
* identities and the Advisor effort replaced. */
|
|
176
194
|
const CHEAPEST2_PROFILE_CONTRACT = Object.freeze({
|
|
@@ -180,7 +198,8 @@ const CHEAPEST2_PROFILE_CONTRACT = Object.freeze({
|
|
|
180
198
|
advisorModel: CHEAPEST2_PROFILE_ADVISOR_MODEL,
|
|
181
199
|
advisorClientModel: CHEAPEST2_PROFILE_ADVISOR_CLIENT_MODEL,
|
|
182
200
|
advisorEffort: CHEAPEST2_PROFILE_ADVISOR_EFFORT,
|
|
183
|
-
oracleModel: CHEAPEST2_PROFILE_ORACLE_MODEL
|
|
201
|
+
oracleModel: CHEAPEST2_PROFILE_ORACLE_MODEL,
|
|
202
|
+
rewriteModel: CHEAPEST2_PROFILE_REWRITE_MODEL
|
|
184
203
|
});
|
|
185
204
|
//#endregion
|
|
186
205
|
//#region src/lib/local-profile-contract.ts
|
|
@@ -265,7 +284,14 @@ const LOCAL_PROFILE_CONTRACT = Object.freeze({
|
|
|
265
284
|
oracleModel: LOCAL_PROFILE_ORACLE_MODEL,
|
|
266
285
|
oracleEffort: CHEAPEST_PROFILE_ORACLE_EFFORT,
|
|
267
286
|
synthesizedPeers: CHEAPEST_PROFILE_SYNTHESIZED_PEERS,
|
|
268
|
-
delegationGraph: CHEAPEST_PROFILE_DELEGATION_GRAPH
|
|
287
|
+
delegationGraph: CHEAPEST_PROFILE_DELEGATION_GRAPH,
|
|
288
|
+
/**
|
|
289
|
+
* The consultants here are Copilot dispatches even though the LEAD is local:
|
|
290
|
+
* `local`'s Oracle persona and `local2`'s curated Advisor both run on the
|
|
291
|
+
* inherited Copilot slug. Declared so the cheapest family's transport field
|
|
292
|
+
* is present across every contract a curated-Advisor call site can hold.
|
|
293
|
+
*/
|
|
294
|
+
consultTransport: "copilot"
|
|
269
295
|
});
|
|
270
296
|
/**
|
|
271
297
|
* The `-m local2` Advisor: `gpt-6.1-sol` on Copilot, `high`, at the cheapest
|
|
@@ -345,24 +371,127 @@ const BALANCED2_PROFILE_CONTRACT = Object.freeze({
|
|
|
345
371
|
oracleModel: BALANCED2_PROFILE_ORACLE_MODEL
|
|
346
372
|
});
|
|
347
373
|
//#endregion
|
|
374
|
+
//#region src/lib/cheaplocal-profile-contract.ts
|
|
375
|
+
/**
|
|
376
|
+
* Fixed identities for the literal `github-router claude -m cheaplocal` profile.
|
|
377
|
+
*
|
|
378
|
+
* `cheaplocal` is `cheapest` with its two consultants moved off Copilot: the
|
|
379
|
+
* Advisor and the Oracle are served by the local Anthropic-Messages endpoint
|
|
380
|
+
* (the same one `-m local` / `-m local2` point their main loop at) instead of a
|
|
381
|
+
* Copilot model.
|
|
382
|
+
*
|
|
383
|
+
* Everything else is inherited verbatim from `CHEAPEST_PROFILE_CONTRACT`:
|
|
384
|
+
* the `gpt-6-luna`/max lead, the Luna natives, the bare-slug 200K window, the
|
|
385
|
+
* curated 24K Advisor digest, the Oracle-only peer set, the three-agent surface
|
|
386
|
+
* and the delegation graph.
|
|
387
|
+
*
|
|
388
|
+
* Nothing in this file may characterize the local model. The endpoint is the
|
|
389
|
+
* only fact the profile carries about it, so no name, window, price or speed
|
|
390
|
+
* claim is made anywhere: the contract names a bare SLUG (`opus`) and a
|
|
391
|
+
* transport, and prose that reaches the model describes the consultants by
|
|
392
|
+
* transport ("the local model"), never by identity. The one effort the consult
|
|
393
|
+
* requests (`LOCAL_CONSULT_EFFORT`) is the operator's setting, not a property
|
|
394
|
+
* of the model.
|
|
395
|
+
*
|
|
396
|
+
* Derived by spread rather than copied, so a field added to the cheapest family
|
|
397
|
+
* later is inherited here automatically and the declared deltas below are the
|
|
398
|
+
* only lines that can drift.
|
|
399
|
+
*/
|
|
400
|
+
/**
|
|
401
|
+
* The one model id this profile sends to the local endpoint.
|
|
402
|
+
*
|
|
403
|
+
* Bare, like the `-m local` lead: the profile assumes nothing about which model
|
|
404
|
+
* answers, and the endpoint maps the id itself. It is deliberately the SAME id
|
|
405
|
+
* for the Advisor and the Oracle because a second spelling would imply a
|
|
406
|
+
* distinction the profile cannot observe.
|
|
407
|
+
*/
|
|
408
|
+
const CHEAPLOCAL_CONSULT_MODEL = "opus";
|
|
409
|
+
/**
|
|
410
|
+
* The Copilot model the prompt-rewrite hooks run on. Under `cheaplocal` the
|
|
411
|
+
* consultants are local, but the rewrite is a Copilot dispatch and must stay
|
|
412
|
+
* inside the profile's `{sol, luna}` egress ceiling, so it keeps the base
|
|
413
|
+
* family's Sol rather than following `advisorModel` to the local slug.
|
|
414
|
+
*/
|
|
415
|
+
const CHEAPLOCAL_PROFILE_REWRITE_MODEL = "gpt-5.6-sol";
|
|
416
|
+
const CHEAPLOCAL_PROFILE_MODELS = Object.freeze({
|
|
417
|
+
...CHEAPEST_PROFILE_MODELS,
|
|
418
|
+
advisor: CHEAPLOCAL_CONSULT_MODEL,
|
|
419
|
+
oracle: CHEAPLOCAL_CONSULT_MODEL
|
|
420
|
+
});
|
|
421
|
+
const CHEAPLOCAL_PROFILE_NATIVE_MODELS = Object.freeze({
|
|
422
|
+
Explore: CHEAPLOCAL_PROFILE_MODELS.explore,
|
|
423
|
+
"General-Purpose": CHEAPLOCAL_PROFILE_MODELS["General-Purpose"],
|
|
424
|
+
reviewer: CHEAPLOCAL_PROFILE_MODELS.reviewer
|
|
425
|
+
});
|
|
426
|
+
const CHEAPLOCAL_PROFILE_ADVISOR_MODEL = CHEAPLOCAL_PROFILE_MODELS.advisor;
|
|
427
|
+
/**
|
|
428
|
+
* Client-visible Advisor identity. A LABEL, not the model that answers: the
|
|
429
|
+
* wire id sent to the endpoint is `CHEAPLOCAL_CONSULT_MODEL`, and nothing in
|
|
430
|
+
* this profile can observe which model receives it.
|
|
431
|
+
*
|
|
432
|
+
* It is deliberately not a model id at all, for two reasons. First, naming a
|
|
433
|
+
* model here would make the client UI claim that model is consulting, which the
|
|
434
|
+
* profile cannot know. Second, Claude Code resolves a RECOGNIZED model alias
|
|
435
|
+
* through its own registry before putting the value in the native Advisor
|
|
436
|
+
* tool's `model` field: `--advisor opus` arrives at the proxy as
|
|
437
|
+
* `claude-opus-5.5`, so an alias can never be a stable pin for the strict
|
|
438
|
+
* client-drift check. `local` is not a model alias, so it passes through
|
|
439
|
+
* verbatim.
|
|
440
|
+
*/
|
|
441
|
+
const CHEAPLOCAL_PROFILE_ADVISOR_CLIENT_MODEL = "local";
|
|
442
|
+
/**
|
|
443
|
+
* The declared effort is inherited but never transmitted: the local transport
|
|
444
|
+
* sends one fixed `max` request (`LOCAL_CONSULT_EFFORT`) instead of the
|
|
445
|
+
* family's Copilot effort, so the field exists only so the family contract
|
|
446
|
+
* stays a complete object.
|
|
447
|
+
*/
|
|
448
|
+
const CHEAPLOCAL_PROFILE_ADVISOR_EFFORT = CHEAPEST_PROFILE_CONTRACT.advisorEffort;
|
|
449
|
+
const CHEAPLOCAL_PROFILE_ORACLE_MODEL = CHEAPLOCAL_PROFILE_MODELS.oracle;
|
|
450
|
+
/** The `-m cheaplocal` aggregate: the base contract with the two consultants
|
|
451
|
+
* pointed at the local endpoint. */
|
|
452
|
+
const CHEAPLOCAL_PROFILE_CONTRACT = Object.freeze({
|
|
453
|
+
...CHEAPEST_PROFILE_CONTRACT,
|
|
454
|
+
models: CHEAPLOCAL_PROFILE_MODELS,
|
|
455
|
+
nativeModels: CHEAPLOCAL_PROFILE_NATIVE_MODELS,
|
|
456
|
+
advisorModel: CHEAPLOCAL_PROFILE_ADVISOR_MODEL,
|
|
457
|
+
advisorClientModel: CHEAPLOCAL_PROFILE_ADVISOR_CLIENT_MODEL,
|
|
458
|
+
advisorEffort: CHEAPLOCAL_PROFILE_ADVISOR_EFFORT,
|
|
459
|
+
oracleModel: CHEAPLOCAL_PROFILE_ORACLE_MODEL,
|
|
460
|
+
rewriteModel: CHEAPLOCAL_PROFILE_REWRITE_MODEL,
|
|
461
|
+
consultTransport: "local"
|
|
462
|
+
});
|
|
463
|
+
//#endregion
|
|
348
464
|
//#region src/lib/profile-family.ts
|
|
349
465
|
/**
|
|
350
|
-
* The `cheapest`/`cheapest2` and `balanced`/`balanced2`
|
|
466
|
+
* The `cheapest`/`cheapest2`/`cheaplocal` and `balanced`/`balanced2`
|
|
467
|
+
* launch-profile families.
|
|
351
468
|
*
|
|
352
469
|
* The `-2` aliases are not separate tiers: each is its base profile with a
|
|
353
470
|
* declared set of Sol identities replaced (`cheapest2`: Advisor + Oracle at
|
|
354
471
|
* `gpt-6.1-sol`, Advisor effort `high`; `balanced2`: lead + reviewer at
|
|
355
472
|
* `gpt-6.1-sol`, Oracle `grok-4.7`). Every consumer therefore asks the family
|
|
356
473
|
* helpers below rather than comparing against one literal id, which is what
|
|
357
|
-
* keeps the
|
|
474
|
+
* keeps the siblings from drifting: a check written for `cheapest` covers
|
|
358
475
|
* `cheapest2` by construction instead of needing a parallel branch.
|
|
359
476
|
*
|
|
360
|
-
*
|
|
477
|
+
* `cheaplocal` is a third cheapest sibling, not a local-family member: its lead
|
|
478
|
+
* and natives stay on Copilot and only its two consultants move to the local
|
|
479
|
+
* endpoint. It joins the family because every lead/native/window decision is
|
|
480
|
+
* identical to `cheapest`; the transport difference rides on the contract's
|
|
481
|
+
* `consultTransport`, so consumers branch on data rather than on this id.
|
|
482
|
+
*
|
|
483
|
+
* This module imports only the five contract modules — never
|
|
361
484
|
* `launch-profile.ts` — so it can be imported from anywhere in `src/lib`
|
|
362
485
|
* without creating a cycle.
|
|
363
486
|
*/
|
|
364
487
|
function isCheapestFamily(profileId) {
|
|
365
|
-
return profileId === "cheapest" || profileId === "cheapest2";
|
|
488
|
+
return profileId === "cheapest" || profileId === "cheapest2" || profileId === "cheaplocal";
|
|
489
|
+
}
|
|
490
|
+
/** The one cheapest sibling whose consultants leave Copilot. The predicate
|
|
491
|
+
* form matters at call sites that must EXCLUDE the id: Pi rejects it, and a
|
|
492
|
+
* plain `boolean` would leave `CheapestProfileId` intact after the refusal. */
|
|
493
|
+
function isCheaplocalProfile(profileId) {
|
|
494
|
+
return profileId === "cheaplocal";
|
|
366
495
|
}
|
|
367
496
|
function isBalancedFamily(profileId) {
|
|
368
497
|
return profileId === "balanced" || profileId === "balanced2";
|
|
@@ -371,9 +500,10 @@ function isLocalFamily(profileId) {
|
|
|
371
500
|
return profileId === "local" || profileId === "local2";
|
|
372
501
|
}
|
|
373
502
|
/**
|
|
374
|
-
* Every FIXED-ROSTER launch profile: `fast`, the cheap pair,
|
|
375
|
-
* and the local pair. These are the launches whose
|
|
376
|
-
* mirror purge and status line the router owns
|
|
503
|
+
* Every FIXED-ROSTER launch profile: `fast`, the cheap pair, the three cheapest
|
|
504
|
+
* siblings, the balanced pair, and the local pair. These are the launches whose
|
|
505
|
+
* MCP surface, picker rows, mirror purge and status line the router owns
|
|
506
|
+
* outright.
|
|
377
507
|
*
|
|
378
508
|
* `max` is deliberately absent. It shares some of the same wiring, but it
|
|
379
509
|
* has its own reviewer/roster path rather than the shared fast-style
|
|
@@ -385,6 +515,7 @@ const PINNED_PROFILE_IDS = /* @__PURE__ */ new Set([
|
|
|
385
515
|
"cheap1m",
|
|
386
516
|
"cheapest",
|
|
387
517
|
"cheapest2",
|
|
518
|
+
"cheaplocal",
|
|
388
519
|
"balanced",
|
|
389
520
|
"balanced2",
|
|
390
521
|
"local",
|
|
@@ -398,7 +529,9 @@ function isPinnedLaunchProfile(profileId) {
|
|
|
398
529
|
* non-family launch still gets a complete, valid object rather than
|
|
399
530
|
* `undefined`. */
|
|
400
531
|
function cheapestContractFor(profileId) {
|
|
401
|
-
|
|
532
|
+
if (profileId === "cheapest2") return CHEAPEST2_PROFILE_CONTRACT;
|
|
533
|
+
if (profileId === "cheaplocal") return CHEAPLOCAL_PROFILE_CONTRACT;
|
|
534
|
+
return CHEAPEST_PROFILE_CONTRACT;
|
|
402
535
|
}
|
|
403
536
|
/** The contract for a balanced-family profile (base fallback, as above). */
|
|
404
537
|
function balancedContractFor(profileId) {
|
|
@@ -447,12 +580,15 @@ function displayModelName(modelId) {
|
|
|
447
580
|
return MODEL_DISPLAY_NAMES[modelId] ?? modelId;
|
|
448
581
|
}
|
|
449
582
|
/**
|
|
450
|
-
* The model the cheapest-family prompt rewrite runs on.
|
|
451
|
-
*
|
|
452
|
-
*
|
|
583
|
+
* The model the cheapest-family prompt rewrite runs on.
|
|
584
|
+
*
|
|
585
|
+
* Read from `rewriteModel`, NOT `advisorModel`: the rewrite is always a Copilot
|
|
586
|
+
* dispatch, so a sibling whose consultants moved to the local endpoint must not
|
|
587
|
+
* hand a local slug to it. One call site serves every member and a future tier
|
|
588
|
+
* only has to change its contract.
|
|
453
589
|
*/
|
|
454
590
|
function cheapestRewriteModelFor(profileId) {
|
|
455
|
-
return cheapestContractFor(profileId).
|
|
591
|
+
return cheapestContractFor(profileId).rewriteModel;
|
|
456
592
|
}
|
|
457
593
|
//#endregion
|
|
458
594
|
//#region src/lib/cheapest-prompt-rewrite.ts
|
|
@@ -1308,6 +1444,6 @@ function buildStaticPack(workspace) {
|
|
|
1308
1444
|
};
|
|
1309
1445
|
}
|
|
1310
1446
|
//#endregion
|
|
1311
|
-
export {
|
|
1447
|
+
export { CHEAPEST_PROFILE_ADVISOR_MODEL as A, BALANCED2_PROFILE_MODELS as C, LOCAL_PROFILE_TIER_MODELS as D, LOCAL_PROFILE_NATIVE_MODELS as E, CHEAPEST_PROFILE_NATIVE_AGENT_NAMES as F, CHEAPEST_PROFILE_NATIVE_EFFORTS as I, CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MAX as M, CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MIN as N, CHEAPEST2_PROFILE_MODELS as O, CHEAPEST_PROFILE_MODELS as P, localContractFor as S, LOCAL_PROFILE_NATIVE_AGENT_NAMES as T, isCheapestFamily as _, decidePromptSubmitV2 as a, isPinnedLaunchProfile as b, CHEAPEST_REWRITE_EFFORT as c, runCheapestRewrite as d, balancedContractFor as f, isBalancedFamily as g, displayModelName as h, decidePromptSubmit as i, CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_DEFAULT as j, CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL as k, buildRebriefSystem as l, cheapestRewriteModelFor as m, PROMPT_STEER_GOAL as n, getPromptSearchTip as o, cheapestContractFor as p, buildPromptSubmitHookCommand as r, isNonTrivialPrompt as s, buildStaticPack as t, isCheapestRewriteDisabledEnv as u, isCheaplocalProfile as v, LOCAL_PROFILE_LEAD_MODEL as w, local2AdvisorContract as x, isLocalFamily as y };
|
|
1312
1448
|
|
|
1313
|
-
//# sourceMappingURL=static-context-pack-
|
|
1449
|
+
//# sourceMappingURL=static-context-pack-DvwLWlbe.js.map
|