github-router 0.3.345 → 0.3.346

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,7 +1,7 @@
1
1
  import { N as warmTreeSitterPool } from "./service-backend-7SPDLUB9.js";
2
2
  import { t as state } from "./state-CVp30CBF.js";
3
3
  import { d as resolveModel, u as resolveCodexModel } from "./token-s5Wd-Kwr.js";
4
- import { B as runSelfUpdate, a as setupAndServe, c as startKeepAwake, d as listModelsForEndpoint, f as enableFileLogging, i as parseSharedArgs, l as stopKeepAwake, n as getCodexEnvVars, o as sharedServerArgs } from "./server-setup-BO-kzlt0.js";
4
+ import { B as runSelfUpdate, a as setupAndServe, c as startKeepAwake, d as listModelsForEndpoint, f as enableFileLogging, i as parseSharedArgs, l as stopKeepAwake, n as getCodexEnvVars, o as sharedServerArgs } from "./server-setup-tNMUzFgE.js";
5
5
  import { D as toolbeltEnabled, an as provisionAndIndexColbert, gn as DEFAULT_CODEX_MODEL_FALLBACKS, hn as DEFAULT_CODEX_MODEL, in as colbertDegradedWarning, nn as provisionBrowserAssets, rn as hasSupportedBrowserInstalled } from "./peer-mcp-personas-CIV3aDP6.js";
6
6
  import { i as launchChild, t as provisionToolbelt } from "./provision-J68elA3c.js";
7
7
  import { s as disposeBluebirdClients } from "./bluebird-client-DpYl1YmJ.js";
@@ -90,4 +90,4 @@ const codex = defineCommand({
90
90
  //#endregion
91
91
  export { codex };
92
92
 
93
- //# sourceMappingURL=codex-DVTp1CuU.js.map
93
+ //# sourceMappingURL=codex-D6ZfS7hJ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-DVTp1CuU.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 await disposeBluebirdClients()\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,CAAC,QAAQ,OAAO,OAAO;GACzB,QAAQ,MAAM,6DAA6D;GAC3E,QAAQ,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c;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;GACpB,MAAM,uBAAuB;EAC/B,EACF,CACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"codex-D6ZfS7hJ.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 await disposeBluebirdClients()\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,CAAC,QAAQ,OAAO,OAAO;GACzB,QAAQ,MAAM,6DAA6D;GAC3E,QAAQ,KAAK,CAAC;EAChB;EAEA,MAAM,SAAS,gBAAgB,IAA0C;EAEzE,IAAI;EACJ,IAAI;EACJ,IAAI;GACF,MAAM,SAAS,MAAM,cAAc;IACjC,GAAG;IACH,MAAM,OAAO;IACb,QAAQ;GACV,CAAC;GACD,SAAS,OAAO;GAChB,YAAY,OAAO;EACrB,SAAS,OAAO;GACd,QAAQ,MAAM,2BAA2B,iBAAiB,QAAQ,MAAM,UAAU,KAAK;GACvF,QAAQ,KAA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L,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;GACpB,MAAM,uBAAuB;EAC/B,EACF,CACF;CACF;AACF,CAAC"}
package/dist/main.js CHANGED
@@ -47,11 +47,11 @@ const main = defineCommand({
47
47
  },
48
48
  subCommands: {
49
49
  auth: () => import("./auth-Cgsy2T0s.js").then((m) => m.auth),
50
- start: () => import("./start-B_ikqtvL.js").then((m) => m.start),
51
- claude: () => import("./claude-CqAnTpZv.js").then((m) => m.claude),
52
- codex: () => import("./codex-DVTp1CuU.js").then((m) => m.codex),
53
- pi: () => import("./pi-DJM02Mm2.js").then((m) => m.pi),
54
- serve: () => import("./serve-CCjPimSJ.js").then((m) => m.serve),
50
+ start: () => import("./start-BDxUhfDG.js").then((m) => m.start),
51
+ claude: () => import("./claude-Bc-4s27I.js").then((m) => m.claude),
52
+ codex: () => import("./codex-D6ZfS7hJ.js").then((m) => m.codex),
53
+ pi: () => import("./pi-CugyWYp7.js").then((m) => m.pi),
54
+ serve: () => import("./serve-BEY7EjEv.js").then((m) => m.serve),
55
55
  models: () => import("./models-BGCeGVXl.js").then((m) => m.models),
56
56
  "check-usage": () => import("./check-usage-26G2hw_F.js").then((m) => m.checkUsage),
57
57
  index: () => import("./index-cmd-DXYWgKS6.js").then((m) => m.indexCmd),
@@ -3,7 +3,7 @@ import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
3
3
  import { t as PATHS } from "./paths-CpbTHKeP.js";
4
4
  import { t as state } from "./state-CVp30CBF.js";
5
5
  import { c as runCommandVoid, o as resolveExecutable, s as runCommandCapture } from "./exec-MCU1H-KZ.js";
6
- import { B as runSelfUpdate, E as formatBalancedPrerequisiteFailure, I as validateCheapestProfilePrerequisites, M as resolveLaunchProfile, N as validateBalancedProfilePrerequisites, a as setupAndServe, c as startKeepAwake, f as enableFileLogging, i as parseSharedArgs, j as profileDescriptor, k as formatCheapestPrerequisiteFailure, l as stopKeepAwake, o as sharedServerArgs, r as getPiLaunchEnvVars, z as queueDetachedGlobalInstall } from "./server-setup-BO-kzlt0.js";
6
+ import { B as runSelfUpdate, E as formatBalancedPrerequisiteFailure, I as validateCheapestProfilePrerequisites, M as resolveLaunchProfile, N as validateBalancedProfilePrerequisites, a as setupAndServe, c as startKeepAwake, f as enableFileLogging, i as parseSharedArgs, j as profileDescriptor, k as formatCheapestPrerequisiteFailure, l as stopKeepAwake, o as sharedServerArgs, r as getPiLaunchEnvVars, z as queueDetachedGlobalInstall } from "./server-setup-tNMUzFgE.js";
7
7
  import { a as BALANCED_PROFILE_NATIVE_EFFORTS, c as BALANCED_PROFILE_ORACLE_MODEL, r as BALANCED_PROFILE_MODELS, s as BALANCED_PROFILE_ORACLE_EFFORT } from "./balanced-profile-contract-C6AgFJNp.js";
8
8
  import { D as toolbeltEnabled, Gt as registerLaunch, In as CHEAPEST_PROFILE_NATIVE_EFFORTS, Kt as unregisterLaunch, Mn as CHEAPEST_PROFILE_ADVISOR_EFFORT, Nn as CHEAPEST_PROFILE_ADVISOR_MODEL, Pn as CHEAPEST_PROFILE_MODELS, Rn as CHEAPEST_PROFILE_ORACLE_EFFORT, an as provisionAndIndexColbert, ft as browserToolsEnabled, in as colbertDegradedWarning, nn as provisionBrowserAssets, zn as CHEAPEST_PROFILE_ORACLE_MODEL } from "./peer-mcp-personas-CIV3aDP6.js";
9
9
  import { r as resolveSelfInvocation } from "./self-invocation-DIUyoRgL.js";
@@ -15,7 +15,7 @@ import { defineCommand } from "citty";
15
15
  import consola from "consola";
16
16
  import { existsSync } from "node:fs";
17
17
  import path from "node:path";
18
- import { randomBytes } from "node:crypto";
18
+ import { createHash, randomBytes } from "node:crypto";
19
19
  import fs$1 from "node:fs/promises";
20
20
  import os from "node:os";
21
21
  import process$1 from "node:process";
@@ -614,6 +614,110 @@ async function sweepStalePiAgentMirrors() {
614
614
  }
615
615
  }));
616
616
  }
617
+ function cacheDisabled() {
618
+ return process.env.GH_ROUTER_PI_NO_PACKAGE_CACHE === "1";
619
+ }
620
+ /** Stable fingerprint of one `packages[]` entry (order-independent). */
621
+ function piPackageSpecFingerprint(entry) {
622
+ if (typeof entry === "string") return entry;
623
+ const join = (v) => [...v ?? []].sort().join(",");
624
+ return [
625
+ entry.source,
626
+ `ext:${join(entry.extensions)}`,
627
+ `skills:${join(entry.skills)}`,
628
+ `prompts:${join(entry.prompts)}`,
629
+ `themes:${join(entry.themes)}`
630
+ ].join("::");
631
+ }
632
+ /** Order-independent cache key for a launch's full `packages[]` slice. */
633
+ function piPackageCacheKey(packages) {
634
+ const specs = packages.map(piPackageSpecFingerprint).sort();
635
+ return createHash("sha256").update(specs.join("\n")).digest("hex").slice(0, 16);
636
+ }
637
+ function piPackageCacheDir(key) {
638
+ return path.join(PATHS.APP_DIR, "pi-packages", key);
639
+ }
640
+ function npmDirOf(root) {
641
+ return path.join(root, "npm");
642
+ }
643
+ async function mtimeMsOf(dir) {
644
+ try {
645
+ return (await fs$1.stat(dir)).mtimeMs;
646
+ } catch {
647
+ return null;
648
+ }
649
+ }
650
+ /**
651
+ * Copy the cached `<key>/npm` tree into a fresh mirror before Pi boots.
652
+ * Returns true on a hit (mirror pre-seeded; Pi should install nothing).
653
+ * Stale entries (older than the max age) are a miss so the launch
654
+ * refreshes to upstream latest. Never throws.
655
+ */
656
+ async function seedPiPackageCache(mirrorDir, packages) {
657
+ if (cacheDisabled()) return false;
658
+ const key = piPackageCacheKey(packages);
659
+ const cachedNpm = npmDirOf(piPackageCacheDir(key));
660
+ const mtime = await mtimeMsOf(cachedNpm);
661
+ if (mtime === null) return false;
662
+ if (Date.now() - mtime > 6048e5) {
663
+ consola.debug(`Pi package cache ${key} is stale; refreshing from registry.`);
664
+ return false;
665
+ }
666
+ try {
667
+ await fs$1.cp(cachedNpm, npmDirOf(mirrorDir), { recursive: true });
668
+ return true;
669
+ } catch (err) {
670
+ consola.debug("Pi package cache seed skipped:", err);
671
+ return false;
672
+ }
673
+ }
674
+ /**
675
+ * Persist a mirror's installed `<mirror>/npm` tree back to the cache
676
+ * (call on shutdown, BEFORE the mirror is removed). Overwrites the
677
+ * entry, refreshing its mtime. Never throws.
678
+ */
679
+ async function savePiPackageCache(mirrorDir, packages) {
680
+ if (cacheDisabled()) return;
681
+ const mirrorNpm = npmDirOf(mirrorDir);
682
+ if (await mtimeMsOf(path.join(mirrorNpm, "node_modules")) === null) return;
683
+ const dest = npmDirOf(piPackageCacheDir(piPackageCacheKey(packages)));
684
+ try {
685
+ await fs$1.mkdir(path.dirname(dest), { recursive: true });
686
+ await fs$1.rm(dest, {
687
+ recursive: true,
688
+ force: true
689
+ });
690
+ await fs$1.cp(mirrorNpm, dest, { recursive: true });
691
+ } catch (err) {
692
+ consola.debug("Pi package cache save skipped:", err);
693
+ }
694
+ }
695
+ /**
696
+ * Sweep cache entries whose `npm/` tree is older than the max age.
697
+ * Best-effort, never throws. Runs opportunistically at boot.
698
+ */
699
+ async function sweepStalePiPackageCaches() {
700
+ if (cacheDisabled()) return;
701
+ const root = path.join(PATHS.APP_DIR, "pi-packages");
702
+ let entries;
703
+ try {
704
+ entries = await fs$1.readdir(root);
705
+ } catch {
706
+ return;
707
+ }
708
+ await Promise.all(entries.map(async (entry) => {
709
+ const npmDir = npmDirOf(path.join(root, entry));
710
+ try {
711
+ const mtime = await mtimeMsOf(npmDir);
712
+ if (mtime === null || Date.now() - mtime > 6048e5) await fs$1.rm(path.join(root, entry), {
713
+ recursive: true,
714
+ force: true
715
+ });
716
+ } catch (err) {
717
+ consola.debug(`Pi package cache sweep: skipping ${entry}:`, err);
718
+ }
719
+ }));
720
+ }
617
721
  //#endregion
618
722
  //#region src/lib/pi-models-settings.ts
619
723
  /**
@@ -957,10 +1061,15 @@ function applyCosmeticUserOverrides(userSettings, builtSettings) {
957
1061
  * the launch has neither `--search` nor `--browse`, otherwise it
958
1062
  * double-pays our ColBERT/browser surfaces.
959
1063
  * - `pi-agent-extensions`: allowlisted stable extensions only
960
- * (sessions, structured questions, todos, handoff, context/files
1064
+ * (sessions, structured questions, todos, handoff, context
961
1065
  * dashboards, notifications, analytics). `review`/`loop`/`workflow`/
962
1066
  * `control` overlap our delegate/review pipeline and `powerline-footer`
963
1067
  * would fight the router-owned AIC footer, so all are excluded.
1068
+ * `files` is deliberately excluded too: it registers `ctrl+shift+o`
1069
+ * (file browser), colliding with `pi-claude-code-ui`'s `ctrl+shift+o`
1070
+ * (extra tool detail) — Pi warns and the files binding dies, so
1071
+ * shipping it only buys noise. `@file` mentions + the `context`
1072
+ * dashboard + `read`/`ls`/`find` cover the need.
964
1073
  */
965
1074
  const PI_HELPERS_MCP_ADAPTER = {
966
1075
  source: "npm:pi-mcp-adapter",
@@ -975,7 +1084,9 @@ const PI_HELPERS_WEB_ACCESS = {
975
1084
  /** Verified manifest paths (pi-agent-extensions 0.5.x). Bare relative
976
1085
  * form, NO `./` prefix: Pi matches package-filter patterns with
977
1086
  * minimatch against root-relative paths, and a `./` prefix matches
978
- * nothing (observed live: zero extensions loaded, silent). */
1087
+ * nothing (observed live: zero extensions loaded, silent).
1088
+ * `extensions/files/index.ts` is intentionally absent: it owns
1089
+ * `ctrl+shift+o`, which `pi-claude-code-ui` also registers. */
979
1090
  const PI_HELPERS_AGENT_EXTENSIONS = {
980
1091
  source: "npm:pi-agent-extensions",
981
1092
  extensions: [
@@ -984,7 +1095,6 @@ const PI_HELPERS_AGENT_EXTENSIONS = {
984
1095
  "extensions/handoff/index.ts",
985
1096
  "extensions/notify/index.ts",
986
1097
  "extensions/context/index.ts",
987
- "extensions/files/index.ts",
988
1098
  "extensions/todos/index.ts",
989
1099
  "extensions/answer/index.ts",
990
1100
  "extensions/cwd-history/index.ts",
@@ -1922,7 +2032,7 @@ const piArgs = {
1922
2032
  helpers: {
1923
2033
  type: "boolean",
1924
2034
  default: true,
1925
- description: "Wire the helpful bundle: pi-mcp-adapter, allowlisted pi-agent-extensions (sessions, ask_user, todos, handoff, context, files, analytics — no review/loop/footer), and pi-web-access when neither --search nor --browse is on. Set to false (--no-helpers) for pi-subagents + gh-router-pi only."
2035
+ description: "Wire the helpful bundle: pi-mcp-adapter, allowlisted pi-agent-extensions (sessions, ask_user, todos, handoff, context, analytics — no review/loop/footer, no files picker so Ctrl+Shift+O stays unambiguous for the UI), and pi-web-access when neither --search nor --browse is on. Set to false (--no-helpers) for pi-subagents + gh-router-pi only."
1926
2036
  },
1927
2037
  ui: {
1928
2038
  type: "boolean",
@@ -2088,11 +2198,13 @@ const pi = defineCommand({
2088
2198
  try {
2089
2199
  mirror = await ensurePiAgentMirror();
2090
2200
  await sweepStalePiAgentMirrors();
2201
+ sweepStalePiPackageCaches();
2091
2202
  } catch (err) {
2092
2203
  consola.error(`Failed to provision Pi config mirror: ${err instanceof Error ? err.message : String(err)}.`);
2093
2204
  process$1.exit(1);
2094
2205
  }
2095
2206
  enableFileLogging();
2207
+ let packagesForCache = [];
2096
2208
  try {
2097
2209
  const catalog = state.models?.data.map((m) => {
2098
2210
  const cost = piUsdCostFor(m.billing?.token_prices);
@@ -2140,6 +2252,8 @@ const pi = defineCommand({
2140
2252
  ...cosmeticOverrides,
2141
2253
  ...mergedSubagents ? { subagents: mergedSubagents } : {}
2142
2254
  });
2255
+ packagesForCache = [...builtSettings.packages];
2256
+ if (await seedPiPackageCache(mirror, packagesForCache)) consola.debug("Pi package cache hit: mirror pre-seeded, skipping registry install.");
2143
2257
  const bridgeDisabled = args["memory-bridge"] === false || process$1.env.GH_ROUTER_PI_BRIDGE === "0" || process$1.env.GH_ROUTER_DISABLE_PI_BRIDGE === "1";
2144
2258
  let bridgeStats;
2145
2259
  let bridgeScoped = [];
@@ -2290,6 +2404,7 @@ const pi = defineCommand({
2290
2404
  unregisterLaunch(entry.launchId);
2291
2405
  await stopKeepAwake();
2292
2406
  await disposeBluebirdClients();
2407
+ await savePiPackageCache(mirror, packagesForCache);
2293
2408
  await removeOwnPiAgentMirror();
2294
2409
  await removeAicLedgerFile();
2295
2410
  },
@@ -2306,4 +2421,4 @@ const pi = defineCommand({
2306
2421
  //#endregion
2307
2422
  export { pi };
2308
2423
 
2309
- //# sourceMappingURL=pi-DJM02Mm2.js.map
2424
+ //# sourceMappingURL=pi-CugyWYp7.js.map