github-router 0.3.380 → 0.3.381

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.
@@ -1,4 +1,4 @@
1
- import { a as setupAndServe, d as startKeepAwake, f as stopKeepAwake, h as enableFileLogging, i as parseSharedArgs, m as listModelsForEndpoint, n as getCodexEnvVars, o as sharedServerArgs } from "./server-setup-DLwejgVA.js";
1
+ import { _ as enableFileLogging, a as setupAndServe, g as listModelsForEndpoint, i as parseSharedArgs, m as stopKeepAwake, n as getCodexEnvVars, o as sharedServerArgs, p as startKeepAwake } from "./server-setup-byIhjgOb.js";
2
2
  import { i as launchChild, t as provisionToolbelt } from "./provision-BWtuDq_v.js";
3
3
  import { Bn as colbertDegradedWarning, D as toolbeltEnabled, Mn as provisionBrowserAssets, Nn as hasSupportedBrowserInstalled, Qn as DEFAULT_CODEX_MODEL_FALLBACKS, Vn as provisionAndIndexColbert, Zn as DEFAULT_CODEX_MODEL } from "./peer-mcp-personas-Dny0r5Am.js";
4
4
  import { u as runSelfUpdate } from "./pi-version-check-BeBB0Ny9.js";
@@ -92,4 +92,4 @@ const codex = defineCommand({
92
92
  });
93
93
  export { codex };
94
94
 
95
- //# sourceMappingURL=codex-C6ix3BaY.js.map
95
+ //# sourceMappingURL=codex-50GzveCD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-C6ix3BaY.js","names":[],"sources":["../src/codex.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { enableFileLogging } from \"./lib/file-log-reporter\"\nimport { launchChild } from \"./lib/launch\"\nimport { listModelsForEndpoint } from \"./lib/model-validation\"\nimport {\n DEFAULT_CODEX_MODEL,\n DEFAULT_CODEX_MODEL_FALLBACKS,\n} from \"./lib/port\"\nimport {\n getCodexEnvVars,\n parseSharedArgs,\n setupAndServe,\n sharedServerArgs,\n} from \"./lib/server-setup\"\nimport { runSelfUpdate } from \"./lib/self-update\"\nimport { state } from \"./lib/state\"\nimport { toolbeltEnabled } from \"./lib/toolbelt\"\nimport { provisionToolbelt } from \"./lib/toolbelt/provision\"\nimport { colbertDegradedWarning, provisionAndIndexColbert } from \"./lib/colbert\"\nimport { startKeepAwake, stopKeepAwake } from \"./lib/keep-awake\"\nimport { warmTreeSitterPool } from \"./lib/tree-sitter-pool/pool\"\nimport { provisionBrowserAssets } from \"./lib/browser-mcp/provision\"\nimport { hasSupportedBrowserInstalled } from \"./lib/browser-mcp/browser-detect\"\nimport { disposeBluebirdClients } from \"./lib/bluebird-client\"\nimport { resolveCodexModel, resolveModel } from \"./lib/utils\"\n\nexport const codex = defineCommand({\n meta: {\n name: \"codex\",\n description: \"Start the proxy server and launch Codex CLI\",\n },\n args: {\n ...sharedServerArgs,\n model: {\n alias: \"m\",\n type: \"string\",\n description: \"Override the default model for Codex CLI\",\n },\n },\n async run({ args }) {\n if (!process.stdout.isTTY) {\n consola.error(\"The codex subcommand requires a TTY (interactive terminal).\")\n process.exit(1)\n }\n\n const parsed = parseSharedArgs(args as unknown as Record<string, unknown>)\n\n let server: Awaited<ReturnType<typeof setupAndServe>>[\"server\"]\n let serverUrl: string\n try {\n const result = await setupAndServe({\n ...parsed,\n port: parsed.port, // undefined = random port\n silent: true,\n })\n server = result.server\n serverUrl = result.serverUrl\n } catch (error) {\n consola.error(\"Failed to start server:\", error instanceof Error ? error.message : error)\n process.exit(1)\n }\n\n // Best-effort self-update (detached, applies next launch).\n void runSelfUpdate({ selfUpdate: args[\"self-update\"] !== false })\n\n // Materialize the LLM toolbelt in the background (PATH prepend is in\n // getCodexEnvVars). Best-effort; never blocks launch.\n if (toolbeltEnabled()) {\n void provisionToolbelt().catch(() => {})\n }\n\n // Best-effort ColBERT semantic-search provision + background index of\n // the launch cwd. Opt-IN via --search (no-op otherwise); never blocks\n // 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(undefined, { logsToFile: true })\n .then((warning) => {\n if (warning) process.stderr.write(`${warning}\\n`)\n })\n .catch(() => {})\n\n // Best-effort, bounded launch warm-up: ready one tree-sitter worker.\n // Opt out with GH_ROUTER_DISABLE_TS_POOL_WARMUP=1.\n void warmTreeSitterPool()\n\n // Best-effort: keep the machine awake while the proxy/Codex session\n // runs (win32 default-on; opt out GH_ROUTER_DISABLE_KEEP_AWAKE=1).\n // Self-registered SIGINT/SIGTERM/exit reaper releases the assertion.\n startKeepAwake()\n\n // Best-effort: materialize the browser extension + bridge into the\n // stable app-dir and stamp the running version. Gated inline (browse\n // opt-in + a supported browser) rather than via browserToolsEnabled()\n // so the codex command path doesn't eagerly pull the compressor /\n // worker-agent graph. Never blocks launch, never throws.\n const browseOptIn =\n state.browseEnabled || process.env.GH_ROUTER_ENABLE_BROWSE === \"1\"\n if (browseOptIn && hasSupportedBrowserInstalled()) {\n void provisionBrowserAssets().catch((err) =>\n consola.debug(\"Browser extension provisioning failed:\", err),\n )\n }\n\n const usingDefault = !args.model\n const requestedModel = args.model ?? DEFAULT_CODEX_MODEL\n\n // Resolve model before printing success message (so we show the actual model)\n // but enable file logging first so resolution warnings go to file, not terminal\n enableFileLogging()\n\n let codexModel = resolveCodexModel(requestedModel)\n if (codexModel !== requestedModel) {\n consola.info(`Model \"${requestedModel}\" resolved to \"${codexModel}\"`)\n }\n\n // For the implicit-default path only: honor the explicit fallback order\n // (DEFAULT_CODEX_MODEL, then DEFAULT_CODEX_MODEL_FALLBACKS led by gpt-5.5)\n // by cache presence BEFORE resolveCodexModel's codex-slug-preferring\n // \"best /responses model\" safety net. `resolveModel` (NOT resolveCodexModel)\n // walks the chain, so the codex-slug preference can't shadow an\n // earlier-in-chain named fallback (e.g. gpt-5.5) that IS present. The\n // resolveCodexModel result above stays as the FINAL safety net, used only\n // when none of the named chain entries is in the catalog.\n if (usingDefault && state.models) {\n const inCache = (id: string) =>\n state.models?.data.some((m) => m.id === id) ?? false\n const firstPresent = [DEFAULT_CODEX_MODEL, ...DEFAULT_CODEX_MODEL_FALLBACKS]\n .map((id) => resolveModel(id))\n .find((id) => inCache(id))\n if (firstPresent) {\n if (firstPresent !== codexModel) {\n consola.info(\n `Default model \"${DEFAULT_CODEX_MODEL}\" not in your Copilot model list; falling back to \"${firstPresent}\".`,\n )\n }\n codexModel = firstPresent\n }\n }\n\n // Validate model exists in Copilot model list\n const modelEntry = state.models?.data.find((m) => m.id === codexModel)\n if (!modelEntry) {\n const available = listModelsForEndpoint(\"/responses\")\n consola.warn(\n `Model \"${codexModel}\" not found. Available codex models: ${available.join(\", \")}`,\n )\n } else {\n const ctx = modelEntry.capabilities?.limits?.max_context_window_tokens\n if (ctx) consola.info(`Model context window: ${ctx.toLocaleString()} tokens`)\n }\n\n // Print to stderr directly — consola's terminal reporter is already gone\n process.stderr.write(`Server ready on ${serverUrl}, launching Codex CLI (${codexModel})...\\n`)\n\n const envVars = getCodexEnvVars(serverUrl)\n const extraArgs = ((args as unknown as Record<string, unknown>)._ as string[]) ?? []\n\n launchChild(\n {\n kind: \"codex\",\n envVars,\n extraArgs,\n model: codexModel,\n serverUrl,\n },\n server,\n {\n onShutdown: async () => {\n await stopKeepAwake()\n // Dynamic, like `claude.ts` and `pi.ts` do for the same call: a\n // static import of `ado-tools` would pull the whole non-persona MCP\n // registry (and the worker/orchestration modules behind it) into the\n // Codex CLI's import graph for one shutdown-time call. The client\n // module has a second, static importer in `serve.ts`, which already\n // loads that registry — this import is the one that would be pure\n // weight.\n const { disposeAdoClients } = await import(\"./lib/ado-tools\")\n await disposeBluebirdClients()\n await disposeAdoClients()\n },\n },\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAa,QAAQ,cAAc;CACjC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,GAAG;EACH,OAAO;GACL,OAAO;GACP,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,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E,CAAC,CAAC,CAC7B,MAAM,OAAO,QAAQ,EAAE,CAAC;GAC3B,IAAI,cAAc;IAChB,IAAI,iBAAiB,YACnB,QAAQ,KACN,kBAAkB,oBAAoB,qDAAqD,aAAa,GAC1G;IAEF,aAAa;GACf;EACF;EAGA,MAAM,aAAa,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,UAAU;EACrE,IAAI,CAAC,YAAY;GACf,MAAM,YAAY,sBAAsB,YAAY;GACpD,QAAQ,KACN,UAAU,WAAW,uCAAuC,UAAU,KAAK,IAAI,GACjF;EACF,OAAO;GACL,MAAM,MAAM,WAAW,cAAc,QAAQ;GAC7C,IAAI,KAAK,QAAQ,KAAK,yBAAyB,IAAI,eAAe,EAAE,QAAQ;EAC9E;EAGA,QAAQ,OAAO,MAAM,mBAAmB,UAAU,yBAAyB,WAAW,OAAO;EAE7F,MAAM,UAAU,gBAAgB,SAAS;EACzC,MAAM,YAAc,KAA4C,KAAkB,CAAC;EAEnF,YACE;GACE,MAAM;GACN;GACA;GACA,OAAO;GACP;EACF,GACA,QACA,EACE,YAAY,YAAY;GACtB,MAAM,cAAc;GAQpB,MAAM,EAAE,sBAAsB,MAAM,OAAO;GAC3C,MAAM,uBAAuB;GAC7B,MAAM,kBAAkB;EAC1B,EACF,CACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"codex-50GzveCD.js","names":[],"sources":["../src/codex.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { enableFileLogging } from \"./lib/file-log-reporter\"\nimport { launchChild } from \"./lib/launch\"\nimport { listModelsForEndpoint } from \"./lib/model-validation\"\nimport {\n DEFAULT_CODEX_MODEL,\n DEFAULT_CODEX_MODEL_FALLBACKS,\n} from \"./lib/port\"\nimport {\n getCodexEnvVars,\n parseSharedArgs,\n setupAndServe,\n sharedServerArgs,\n} from \"./lib/server-setup\"\nimport { runSelfUpdate } from \"./lib/self-update\"\nimport { state } from \"./lib/state\"\nimport { toolbeltEnabled } from \"./lib/toolbelt\"\nimport { provisionToolbelt } from \"./lib/toolbelt/provision\"\nimport { colbertDegradedWarning, provisionAndIndexColbert } from \"./lib/colbert\"\nimport { startKeepAwake, stopKeepAwake } from \"./lib/keep-awake\"\nimport { warmTreeSitterPool } from \"./lib/tree-sitter-pool/pool\"\nimport { provisionBrowserAssets } from \"./lib/browser-mcp/provision\"\nimport { hasSupportedBrowserInstalled } from \"./lib/browser-mcp/browser-detect\"\nimport { disposeBluebirdClients } from \"./lib/bluebird-client\"\nimport { resolveCodexModel, resolveModel } from \"./lib/utils\"\n\nexport const codex = defineCommand({\n meta: {\n name: \"codex\",\n description: \"Start the proxy server and launch Codex CLI\",\n },\n args: {\n ...sharedServerArgs,\n model: {\n alias: \"m\",\n type: \"string\",\n description: \"Override the default model for Codex CLI\",\n },\n },\n async run({ args }) {\n if (!process.stdout.isTTY) {\n consola.error(\"The codex subcommand requires a TTY (interactive terminal).\")\n process.exit(1)\n }\n\n const parsed = parseSharedArgs(args as unknown as Record<string, unknown>)\n\n let server: Awaited<ReturnType<typeof setupAndServe>>[\"server\"]\n let serverUrl: string\n try {\n const result = await setupAndServe({\n ...parsed,\n port: parsed.port, // undefined = random port\n silent: true,\n })\n server = result.server\n serverUrl = result.serverUrl\n } catch (error) {\n consola.error(\"Failed to start server:\", error instanceof Error ? error.message : error)\n process.exit(1)\n }\n\n // Best-effort self-update (detached, applies next launch).\n void runSelfUpdate({ selfUpdate: args[\"self-update\"] !== false })\n\n // Materialize the LLM toolbelt in the background (PATH prepend is in\n // getCodexEnvVars). Best-effort; never blocks launch.\n if (toolbeltEnabled()) {\n void provisionToolbelt().catch(() => {})\n }\n\n // Best-effort ColBERT semantic-search provision + background index of\n // the launch cwd. Opt-IN via --search (no-op otherwise); never blocks\n // 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(undefined, { logsToFile: true })\n .then((warning) => {\n if (warning) process.stderr.write(`${warning}\\n`)\n })\n .catch(() => {})\n\n // Best-effort, bounded launch warm-up: ready one tree-sitter worker.\n // Opt out with GH_ROUTER_DISABLE_TS_POOL_WARMUP=1.\n void warmTreeSitterPool()\n\n // Best-effort: keep the machine awake while the proxy/Codex session\n // runs (win32 default-on; opt out GH_ROUTER_DISABLE_KEEP_AWAKE=1).\n // Self-registered SIGINT/SIGTERM/exit reaper releases the assertion.\n startKeepAwake()\n\n // Best-effort: materialize the browser extension + bridge into the\n // stable app-dir and stamp the running version. Gated inline (browse\n // opt-in + a supported browser) rather than via browserToolsEnabled()\n // so the codex command path doesn't eagerly pull the compressor /\n // worker-agent graph. Never blocks launch, never throws.\n const browseOptIn =\n state.browseEnabled || process.env.GH_ROUTER_ENABLE_BROWSE === \"1\"\n if (browseOptIn && hasSupportedBrowserInstalled()) {\n void provisionBrowserAssets().catch((err) =>\n consola.debug(\"Browser extension provisioning failed:\", err),\n )\n }\n\n const usingDefault = !args.model\n const requestedModel = args.model ?? DEFAULT_CODEX_MODEL\n\n // Resolve model before printing success message (so we show the actual model)\n // but enable file logging first so resolution warnings go to file, not terminal\n enableFileLogging()\n\n let codexModel = resolveCodexModel(requestedModel)\n if (codexModel !== requestedModel) {\n consola.info(`Model \"${requestedModel}\" resolved to \"${codexModel}\"`)\n }\n\n // For the implicit-default path only: honor the explicit fallback order\n // (DEFAULT_CODEX_MODEL, then DEFAULT_CODEX_MODEL_FALLBACKS led by gpt-5.5)\n // by cache presence BEFORE resolveCodexModel's codex-slug-preferring\n // \"best /responses model\" safety net. `resolveModel` (NOT resolveCodexModel)\n // walks the chain, so the codex-slug preference can't shadow an\n // earlier-in-chain named fallback (e.g. gpt-5.5) that IS present. The\n // resolveCodexModel result above stays as the FINAL safety net, used only\n // when none of the named chain entries is in the catalog.\n if (usingDefault && state.models) {\n const inCache = (id: string) =>\n state.models?.data.some((m) => m.id === id) ?? false\n const firstPresent = [DEFAULT_CODEX_MODEL, ...DEFAULT_CODEX_MODEL_FALLBACKS]\n .map((id) => resolveModel(id))\n .find((id) => inCache(id))\n if (firstPresent) {\n if (firstPresent !== codexModel) {\n consola.info(\n `Default model \"${DEFAULT_CODEX_MODEL}\" not in your Copilot model list; falling back to \"${firstPresent}\".`,\n )\n }\n codexModel = firstPresent\n }\n }\n\n // Validate model exists in Copilot model list\n const modelEntry = state.models?.data.find((m) => m.id === codexModel)\n if (!modelEntry) {\n const available = listModelsForEndpoint(\"/responses\")\n consola.warn(\n `Model \"${codexModel}\" not found. Available codex models: ${available.join(\", \")}`,\n )\n } else {\n const ctx = modelEntry.capabilities?.limits?.max_context_window_tokens\n if (ctx) consola.info(`Model context window: ${ctx.toLocaleString()} tokens`)\n }\n\n // Print to stderr directly — consola's terminal reporter is already gone\n process.stderr.write(`Server ready on ${serverUrl}, launching Codex CLI (${codexModel})...\\n`)\n\n const envVars = getCodexEnvVars(serverUrl)\n const extraArgs = ((args as unknown as Record<string, unknown>)._ as string[]) ?? []\n\n launchChild(\n {\n kind: \"codex\",\n envVars,\n extraArgs,\n model: codexModel,\n serverUrl,\n },\n server,\n {\n onShutdown: async () => {\n await stopKeepAwake()\n // Dynamic, like `claude.ts` and `pi.ts` do for the same call: a\n // static import of `ado-tools` would pull the whole non-persona MCP\n // registry (and the worker/orchestration modules behind it) into the\n // Codex CLI's import graph for one shutdown-time call. The client\n // module has a second, static importer in `serve.ts`, which already\n // loads that registry — this import is the one that would be pure\n // weight.\n const { disposeAdoClients } = await import(\"./lib/ado-tools\")\n await disposeBluebirdClients()\n await disposeAdoClients()\n },\n },\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAa,QAAQ,cAAc;CACjC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,GAAG;EACH,OAAO;GACL,OAAO;GACP,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI,CAA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AAC,CAC7B,MAAM,OAAO,QAAQ,EAAE,CAAC;GAC3B,IAAI,cAAc;IAChB,IAAI,iBAAiB,YACnB,QAAQ,KACN,kBAAkB,oBAAoB,qDAAqD,aAAa,GAC1G;IAEF,aAAa;GACf;EACF;EAGA,MAAM,aAAa,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAE,OAAO,UAAU;EACrE,IAAI,CAAC,YAAY;GACf,MAAM,YAAY,sBAAsB,YAAY;GACpD,QAAQ,KACN,UAAU,WAAW,uCAAuC,UAAU,KAAK,IAAI,GACjF;EACF,OAAO;GACL,MAAM,MAAM,WAAW,cAAc,QAAQ;GAC7C,IAAI,KAAK,QAAQ,KAAK,yBAAyB,IAAI,eAAe,EAAE,QAAQ;EAC9E;EAGA,QAAQ,OAAO,MAAM,mBAAmB,UAAU,yBAAyB,WAAW,OAAO;EAE7F,MAAM,UAAU,gBAAgB,SAAS;EACzC,MAAM,YAAc,KAA4C,KAAkB,CAAC;EAEnF,YACE;GACE,MAAM;GACN;GACA;GACA,OAAO;GACP;EACF,GACA,QACA,EACE,YAAY,YAAY;GACtB,MAAM,cAAc;GAQpB,MAAM,EAAE,sBAAsB,MAAM,OAAO;GAC3C,MAAM,uBAAuB;GAC7B,MAAM,kBAAkB;EAC1B,EACF,CACF;CACF;AACF,CAAC"}
package/dist/main.js CHANGED
@@ -61,12 +61,12 @@ const main = defineCommand({
61
61
  },
62
62
  subCommands: {
63
63
  auth: () => import("./auth-5TKcQbbH.js").then((m) => m.auth),
64
- start: () => import("./start-DvV3Lbwy.js").then((m) => m.start),
65
- claude: () => import("./claude-BWwkOMi3.js").then((m) => m.claude),
66
- codex: () => import("./codex-C6ix3BaY.js").then((m) => m.codex),
67
- pi: () => import("./pi-YhoA26wi.js").then((m) => m.pi),
64
+ start: () => import("./start-7CiQIl0r.js").then((m) => m.start),
65
+ claude: () => import("./claude-CkrhHkPQ.js").then((m) => m.claude),
66
+ codex: () => import("./codex-50GzveCD.js").then((m) => m.codex),
67
+ pi: () => import("./pi-DVud9eQn.js").then((m) => m.pi),
68
68
  workiq: () => import("./workiq-D5b7xlbr.js").then((m) => m.workiq),
69
- serve: () => import("./serve-DrHAX2Bh.js").then((m) => m.serve),
69
+ serve: () => import("./serve-B8Igr9Q0.js").then((m) => m.serve),
70
70
  models: () => import("./models-BDV-YLf2.js").then((m) => m.models),
71
71
  "check-usage": () => import("./check-usage-DM39fdel.js").then((m) => m.checkUsage),
72
72
  index: () => import("./index-cmd-DsK6VFs8.js").then((m) => m.indexCmd),
@@ -6,12 +6,12 @@ import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as A
6
6
  import { d as removeAicLedgerFile, f as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath } from "./aic-ledger-6GKI28nY.js";
7
7
  import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-DM98PuAF.js";
8
8
  import { r as resolveSelfInvocation } from "./self-invocation-Dnq4iVD6.js";
9
- import { B as validateCheapestProfilePrerequisites, F as profileDescriptor, H as validateLocalProfilePrerequisites, I as resolveLaunchProfile, L as validateBalancedProfilePrerequisites, M as formatCheapestPrerequisiteFailure, P as formatLocalPrerequisiteFailure, a as setupAndServe, c as ensurePiAgentMirror, d as startKeepAwake, f as stopKeepAwake, h as enableFileLogging, i as parseSharedArgs, k as formatBalancedPrerequisiteFailure, l as removeOwnPiAgentMirror, o as sharedServerArgs, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as sweepStalePiAgentMirrors } from "./server-setup-DLwejgVA.js";
10
- import { t as PATHS } from "./paths-DeFmYJhO.js";
9
+ import { H as validateCheapestProfilePrerequisites, I as formatLocalPrerequisiteFailure, L as profileDescriptor, P as formatCheapestPrerequisiteFailure, R as resolveLaunchProfile, W as validateLocalProfilePrerequisites, _ as enableFileLogging, a as setupAndServe, c as ensurePiAgentMirror, d as seedPiPackageCache, f as sweepStalePiPackageCaches, i as parseSharedArgs, j as formatBalancedPrerequisiteFailure, l as removeOwnPiAgentMirror, m as stopKeepAwake, o as sharedServerArgs, p as startKeepAwake, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as sweepStalePiAgentMirrors, z as validateBalancedProfilePrerequisites } from "./server-setup-byIhjgOb.js";
11
10
  import { t as FRESH_CONSULT_CONTRACT } from "./claude-md-injection-DNMDcw1W.js";
12
11
  import { Bn as colbertDegradedWarning, Bt as cloudAgentToolsEnabled, D as toolbeltEnabled, Dt as artifactToolsEnabled, Gn as LOCAL_CONSULT_REDACTION_NOTE, Mn as provisionBrowserAssets, Nt as browserToolsEnabled, Qt as kustoToolsEnabled, Sn as unregisterLaunch, Tt as adoToolsEnabled, Vn as provisionAndIndexColbert, Wn as LOCAL_CONSULT_REDACTION_LINE, bn as registerLaunch, fn as configureLocalEgress, jt as browseAgentEnabled, pn as localBaseUrl, sn as workiqToolsEnabled } from "./peer-mcp-personas-Dny0r5Am.js";
13
12
  import { C as localContractFor, O as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, h as consultIsLocalTransport, p as cheapestContractFor, v as isCheapestFamily, y as isCheaplocalProfile } from "./static-context-pack-BKFelEbM.js";
14
13
  import { i as launchChild, t as provisionToolbelt } from "./provision-BWtuDq_v.js";
14
+ import { t as PATHS } from "./paths-DeFmYJhO.js";
15
15
  import { t as state } from "./state-CCGDJ43X.js";
16
16
  import { t as getPackageVersion } from "./version-CTqwKr26.js";
17
17
  import { P as warmTreeSitterPool } from "./service-backend-BdhWVRSz.js";
@@ -19,7 +19,7 @@ import { defineCommand } from "citty";
19
19
  import consola from "consola";
20
20
  import { existsSync } from "node:fs";
21
21
  import path from "node:path";
22
- import { createHash, randomBytes } from "node:crypto";
22
+ import { randomBytes } from "node:crypto";
23
23
  import fs$1 from "node:fs/promises";
24
24
  import process$1 from "node:process";
25
25
  // src/lib/managed-install/pi-command.ts
@@ -484,156 +484,6 @@ function buildPiStatusPayload(source, opts) {
484
484
  worktree: null
485
485
  };
486
486
  }
487
- // src/lib/pi-package-cache.ts
488
- /**
489
- * Persistent npm-package cache for Pi launches.
490
- *
491
- * Pi installs the mirror's `packages[]` into `<agentDir>/npm` on every
492
- * boot, and the agent dir is a fresh per-launch mirror
493
- * (`pi-agent-<pid>-<rand>`) — so every launch pays a full registry
494
- * install (~5s + `added N packages` noise that bypasses
495
- * `npm_config_loglevel=error`). Pi skips the install when the package
496
- * dir already exists and the installed version satisfies the configured
497
- * range — and unpinned `npm:name` specs match ANY installed version —
498
- * so pre-seeding `<mirror>/npm` from a durable cache makes repeat
499
- * launches install nothing: faster AND silent.
500
- *
501
- * Keyed by the exact package set (sorted spec fingerprints), so flag
502
- * combinations (`--helpers`/`--ui`/`--search`/`--browse`) each get
503
- * their own entry and can never cross-contaminate. Entries older than
504
- * the max age are treated as a miss so unpinned packages periodically
505
- * refresh to upstream latest; the fresh install is then saved back over
506
- * the entry. Opt out entirely with `GH_ROUTER_PI_NO_PACKAGE_CACHE=1`.
507
- *
508
- * Max age defaults to 24h, not the original 7d. Pi resolves an unpinned
509
- * `npm:name` spec to whatever is already installed, so the max age IS the
510
- * worst-case staleness of every extension the user runs — a week of it meant a
511
- * fix published upstream on Monday was still missing the following Sunday.
512
- * A day bounds the lag without making the cache pointless: the npm install it
513
- * avoids takes ~5s, so one refresh per day is paid back by every other launch
514
- * that day. Override with `GH_ROUTER_PI_PACKAGE_CACHE_HOURS`.
515
- */
516
- const PI_PACKAGE_CACHE_MAX_AGE_MS = 864e5;
517
- /**
518
- * Effective max age. Read per call rather than at module load so a test (or a
519
- * long-lived process re-reading config) can change the env and observe it, and
520
- * so a malformed value degrades to the default instead of `NaN` day math —
521
- * `Date.now() - mtime > NaN` is always false, which would make every entry
522
- * eternally fresh.
523
- */
524
- function piPackageCacheMaxAgeMs() {
525
- const raw = (process.env["GH_ROUTER_PI_PACKAGE_CACHE_HOURS"] ?? "").trim();
526
- if (!raw) return PI_PACKAGE_CACHE_MAX_AGE_MS;
527
- const hours = Number(raw);
528
- if (!Number.isFinite(hours) || hours <= 0) return PI_PACKAGE_CACHE_MAX_AGE_MS;
529
- return hours * 3600 * 1e3;
530
- }
531
- function cacheDisabled() {
532
- return process.env.GH_ROUTER_PI_NO_PACKAGE_CACHE === "1";
533
- }
534
- /** Stable fingerprint of one `packages[]` entry (order-independent). */
535
- function piPackageSpecFingerprint(entry) {
536
- if (typeof entry === "string") return entry;
537
- const join = (v) => [...v ?? []].sort().join(",");
538
- return [
539
- entry.source,
540
- `ext:${join(entry.extensions)}`,
541
- `skills:${join(entry.skills)}`,
542
- `prompts:${join(entry.prompts)}`,
543
- `themes:${join(entry.themes)}`
544
- ].join("::");
545
- }
546
- /** Order-independent cache key for a launch's full `packages[]` slice. */
547
- function piPackageCacheKey(packages) {
548
- const specs = packages.map(piPackageSpecFingerprint).sort();
549
- return createHash("sha256").update(specs.join("\n")).digest("hex").slice(0, 16);
550
- }
551
- function piPackageCacheDir(key) {
552
- return path.join(PATHS.APP_DIR, "pi-packages", key);
553
- }
554
- function npmDirOf(root) {
555
- return path.join(root, "npm");
556
- }
557
- async function mtimeMsOf(dir) {
558
- try {
559
- return (await fs$1.stat(dir)).mtimeMs;
560
- } catch {
561
- return null;
562
- }
563
- }
564
- /**
565
- * Copy the cached `<key>/npm` tree into a fresh mirror before Pi boots.
566
- * Returns true on a hit (mirror pre-seeded; Pi should install nothing).
567
- * Stale entries (older than the max age) are a miss so the launch
568
- * refreshes to upstream latest. Never throws.
569
- */
570
- async function seedPiPackageCache(mirrorDir, packages) {
571
- if (cacheDisabled()) return false;
572
- const key = piPackageCacheKey(packages);
573
- const cachedNpm = npmDirOf(piPackageCacheDir(key));
574
- const mtime = await mtimeMsOf(cachedNpm);
575
- if (mtime === null) return false;
576
- const maxAge = piPackageCacheMaxAgeMs();
577
- if (Date.now() - mtime > maxAge) {
578
- const ageHours = Math.floor((Date.now() - mtime) / 36e5);
579
- consola.debug(`Pi package cache ${key} is stale (${ageHours}h old, max ${Math.round(maxAge / 36e5)}h); refreshing from registry.`);
580
- return false;
581
- }
582
- try {
583
- await fs$1.cp(cachedNpm, npmDirOf(mirrorDir), { recursive: true });
584
- return true;
585
- } catch (err) {
586
- consola.debug("Pi package cache seed skipped:", err);
587
- return false;
588
- }
589
- }
590
- /**
591
- * Persist a mirror's installed `<mirror>/npm` tree back to the cache
592
- * (call on shutdown, BEFORE the mirror is removed). Overwrites the
593
- * entry, refreshing its mtime. Never throws.
594
- */
595
- async function savePiPackageCache(mirrorDir, packages) {
596
- if (cacheDisabled()) return;
597
- const mirrorNpm = npmDirOf(mirrorDir);
598
- if (await mtimeMsOf(path.join(mirrorNpm, "node_modules")) === null) return;
599
- const dest = npmDirOf(piPackageCacheDir(piPackageCacheKey(packages)));
600
- try {
601
- await fs$1.mkdir(path.dirname(dest), { recursive: true });
602
- await fs$1.rm(dest, {
603
- recursive: true,
604
- force: true
605
- });
606
- await fs$1.cp(mirrorNpm, dest, { recursive: true });
607
- } catch (err) {
608
- consola.debug("Pi package cache save skipped:", err);
609
- }
610
- }
611
- /**
612
- * Sweep cache entries whose `npm/` tree is older than the max age.
613
- * Best-effort, never throws. Runs opportunistically at boot.
614
- */
615
- async function sweepStalePiPackageCaches() {
616
- if (cacheDisabled()) return;
617
- const root = path.join(PATHS.APP_DIR, "pi-packages");
618
- let entries;
619
- try {
620
- entries = await fs$1.readdir(root);
621
- } catch {
622
- return;
623
- }
624
- await Promise.all(entries.map(async (entry) => {
625
- const npmDir = npmDirOf(path.join(root, entry));
626
- try {
627
- const mtime = await mtimeMsOf(npmDir);
628
- if (mtime === null || Date.now() - mtime > piPackageCacheMaxAgeMs()) await fs$1.rm(path.join(root, entry), {
629
- recursive: true,
630
- force: true
631
- });
632
- } catch (err) {
633
- consola.debug(`Pi package cache sweep: skipping ${entry}:`, err);
634
- }
635
- }));
636
- }
637
487
  // src/lib/pi-models-settings.ts
638
488
  /**
639
489
  * Pi thinking levels that can appear in `thinkingLevelMap`. `off` is
@@ -3866,7 +3716,6 @@ const pi = defineCommand({
3866
3716
  const precedence = await inspectMirrorPrecedence(mirror, process$1.cwd());
3867
3717
  if (precedence.systemMd) consola.warn(`Pi: ${path.join(mirror, "SYSTEM.md")} REPLACES Pi's default system prompt. gh-router's mode guidance is still appended to it, but any harness rules your SYSTEM.md leaves out are not restored. Remove it (or merge it into APPEND_SYSTEM.md) for the stock prompt.`);
3868
3718
  if (precedence.projectAppendSystem) consola.warn(`Pi: ${precedence.projectAppendSystem} exists. If this project is trusted, Pi loads it INSTEAD of the gh-router mode digest (the mirror's APPEND_SYSTEM.md). Keep one or the other.`);
3869
- let packagesForCache = [];
3870
3719
  let foreignAvailable;
3871
3720
  let foreignStats;
3872
3721
  const launchSecret = randomBytes(32).toString("hex");
@@ -3929,8 +3778,8 @@ const pi = defineCommand({
3929
3778
  userKeybindings = {};
3930
3779
  }
3931
3780
  await writeJsonFile(keybindingsPath, { ...mergePiKeybindingsSettings(userKeybindings, buildPiKeybindingsJson()) });
3932
- packagesForCache = [...builtSettings.packages];
3933
- if (await seedPiPackageCache(mirror, packagesForCache)) consola.debug("Pi package cache hit: mirror pre-seeded, skipping registry install.");
3781
+ const seed = await seedPiPackageCache(mirror, builtSettings.packages);
3782
+ consola.debug(`Pi package cache: ${seed.reason}.`);
3934
3783
  const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
3935
3784
  let bridgeStats;
3936
3785
  let bridgeScoped = [];
@@ -4184,7 +4033,6 @@ const pi = defineCommand({
4184
4033
  await stopKeepAwake();
4185
4034
  await disposeBluebirdClients();
4186
4035
  await disposeAdoClients();
4187
- await savePiPackageCache(mirror, packagesForCache);
4188
4036
  await removeOwnPiAgentMirror();
4189
4037
  await removeAicLedgerFile();
4190
4038
  },
@@ -4200,4 +4048,4 @@ const pi = defineCommand({
4200
4048
  });
4201
4049
  export { pi };
4202
4050
 
4203
- //# sourceMappingURL=pi-YhoA26wi.js.map
4051
+ //# sourceMappingURL=pi-DVud9eQn.js.map