github-router 0.3.374 → 0.3.376

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 { S as enableFileLogging, Z as runSelfUpdate, a as setupAndServe, i as parseSharedArgs, n as getCodexEnvVars, o as sharedServerArgs, v as startKeepAwake, x as listModelsForEndpoint, y as stopKeepAwake } from "./server-setup-DldGizZR.js";
1
+ import { S as enableFileLogging, Z as runSelfUpdate, a as setupAndServe, i as parseSharedArgs, n as getCodexEnvVars, o as sharedServerArgs, v as startKeepAwake, x as listModelsForEndpoint, y as stopKeepAwake } from "./server-setup-haHlh3o8.js";
2
2
  import { i as launchChild, t as provisionToolbelt } from "./provision-CRmtV6ew.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-Cv21q_YR.js";
4
4
  import { t as state } from "./state-CCGDJ43X.js";
@@ -91,4 +91,4 @@ const codex = defineCommand({
91
91
  });
92
92
  export { codex };
93
93
 
94
- //# sourceMappingURL=codex-DGMUk65v.js.map
94
+ //# sourceMappingURL=codex-ZRCKIbwo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex-DGMUk65v.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,QA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,aAAa,EAAE,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-ZRCKIbwo.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;EA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EAAE,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"}
package/dist/main.js CHANGED
@@ -47,12 +47,12 @@ const main = defineCommand({
47
47
  },
48
48
  subCommands: {
49
49
  auth: () => import("./auth-BZHpTtfF.js").then((m) => m.auth),
50
- start: () => import("./start-C0gngUPK.js").then((m) => m.start),
51
- claude: () => import("./claude-DSXrdz0v.js").then((m) => m.claude),
52
- codex: () => import("./codex-DGMUk65v.js").then((m) => m.codex),
53
- pi: () => import("./pi-DI2QtaiZ.js").then((m) => m.pi),
50
+ start: () => import("./start-BkQ1QWxR.js").then((m) => m.start),
51
+ claude: () => import("./claude-BlD5BLx7.js").then((m) => m.claude),
52
+ codex: () => import("./codex-ZRCKIbwo.js").then((m) => m.codex),
53
+ pi: () => import("./pi-CwBDxTbJ.js").then((m) => m.pi),
54
54
  workiq: () => import("./workiq-CQauEAMc.js").then((m) => m.workiq),
55
- serve: () => import("./serve-DRASJ-ZO.js").then((m) => m.serve),
55
+ serve: () => import("./serve-DW5F8b3a.js").then((m) => m.serve),
56
56
  models: () => import("./models-B6nH1sS6.js").then((m) => m.models),
57
57
  "check-usage": () => import("./check-usage-BlIWDuV2.js").then((m) => m.checkUsage),
58
58
  index: () => import("./index-cmd-BPXhTfGQ.js").then((m) => m.indexCmd),
@@ -1,4 +1,4 @@
1
- import { H as profileDescriptor, I as formatBalancedPrerequisiteFailure, S as enableFileLogging, U as resolveLaunchProfile, V as formatLocalPrerequisiteFailure, W as validateBalancedProfilePrerequisites, Y as validateLocalProfilePrerequisites, Z as runSelfUpdate, _ as sweepStalePiAgentMirrors, a as setupAndServe, c as PI_MIN_VERSION, d as meetsPiMinVersion, f as refreshPiInBackground, g as removeOwnPiAgentMirror, h as ensurePiAgentMirror, i as parseSharedArgs, l as ensurePiInstalled, m as updatePi, o as sharedServerArgs, p as resolvePiRegistry, q as validateCheapestProfilePrerequisites, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as getInstalledPiVersion, v as startKeepAwake, y as stopKeepAwake, z as formatCheapestPrerequisiteFailure } from "./server-setup-DldGizZR.js";
1
+ import { H as profileDescriptor, I as formatBalancedPrerequisiteFailure, S as enableFileLogging, U as resolveLaunchProfile, V as formatLocalPrerequisiteFailure, W as validateBalancedProfilePrerequisites, Y as validateLocalProfilePrerequisites, Z as runSelfUpdate, _ as sweepStalePiAgentMirrors, a as setupAndServe, c as PI_MIN_VERSION, d as meetsPiMinVersion, f as refreshPiInBackground, g as removeOwnPiAgentMirror, h as ensurePiAgentMirror, i as parseSharedArgs, l as ensurePiInstalled, m as updatePi, o as sharedServerArgs, p as resolvePiRegistry, q as validateCheapestProfilePrerequisites, r as getPiLaunchEnvVars, s as LAUNCH_SECRET_HEADER, u as getInstalledPiVersion, v as startKeepAwake, y as stopKeepAwake, z as formatCheapestPrerequisiteFailure } from "./server-setup-haHlh3o8.js";
2
2
  import { i as buildAicStatusHookCommand, n as AIC_STATUSLINE_DISABLE_ENV, t as AIC_LEDGER_ENV } from "./aic-statusline-settings-BKveu679.js";
3
3
  import { d as removeAicLedgerFile, f as sweepStaleAicLedgerFiles, n as aicSnapshot, o as formatAicExitSummary, t as aicLedgerPath } from "./aic-ledger-CeSXqTEE.js";
4
4
  import { n as formatDiscountedCostTable, t as discountedUsdForSnapshot } from "./copilot-discount-CHNQLYDJ.js";
@@ -490,6 +490,22 @@ const PI_MIN_VERSION_NOTE = `Requires Pi >= ${PI_MIN_VERSION} and Node >= 22.19.
490
490
  * digest for keywords.
491
491
  */
492
492
  const PI_TOOL_PREFERENCE_LINE = "- Use the dedicated tools where they fit — read/write/edit for files and grep/find/ls for search — instead of shelling out to cat, sed, or python; but reach for rg, jq, ast-grep, git, and the build/test commands whenever those are the better tool for the job.";
493
+ /**
494
+ * The search-order steer, emitted only when this launch serves `code`.
495
+ *
496
+ * The tool's own description already says semantic-first with a labelled
497
+ * lexical fallback, but a description is read once at roster time and the
498
+ * model still reaches for `grep` first on exact strings. This sentence is the
499
+ * ordering, stated where it is read every turn: narrow by meaning first,
500
+ * because a semantic hit set is ranked and small, then fall back to
501
+ * `rg`/`grep` for what meaning cannot answer — every occurrence, a literal
502
+ * token, a regex, a filename.
503
+ *
504
+ * Only emitted when the launch actually serves the tool (`surfaces.codeSearch`,
505
+ * i.e. `--search` or Bluebird). Naming a tool that is not in the roster is the
506
+ * failure mode the digest exists to avoid.
507
+ */
508
+ const PI_SEARCH_ORDER_LINE = "- When code search is available, narrow with semantic `code` search first — it ranks by meaning and returns a small relevant set — then reach for rg/grep for what meaning cannot answer: every occurrence, an exact token, a regex, or a filename.";
493
509
  function piCopilotContractFor(profileId) {
494
510
  return isCheapestFamily(profileId) ? cheapestContractFor(profileId) : balancedContractFor(profileId);
495
511
  }
@@ -792,6 +808,41 @@ function buildPiModelsJson(opts) {
792
808
  } } };
793
809
  }
794
810
  /**
811
+ * Local-family compaction reserve: 80% of the 200K window.
812
+ *
813
+ * The Copilot derivation below optimises for a price cliff; the local
814
+ * endpoint has none, so the binding constraint there is the summarization
815
+ * request itself. Measured on the live endpoint (`https://…:11111`):
816
+ * with `thinking` enabled the generated ceiling is `thinking.budget_tokens`,
817
+ * NOT `max_tokens` — `max_tokens=25904, budget=16384` stops at exactly
818
+ * 16384 output tokens with `stop_reason: max_tokens`, and `budget=30000`
819
+ * returns 30000. Pi then maps that stop to `length` and
820
+ * `getSummarizationFailure` refuses the truncated summary
821
+ * (`generation hit the token cap and the summary is incomplete`).
822
+ *
823
+ * Triggering at 160K instead of Pi's 183K default leaves the clamp enough
824
+ * room that the 32768 budget below is reachable: at a 160K estimate
825
+ * `clampMaxTokensToContext` yields 32768, so the provider sends
826
+ * `budget = min(32768, 32768 − 1024)`. Raised reserves alone are not enough
827
+ * (the budget, not the trigger, is the ceiling) — both halves ship together.
828
+ */
829
+ const PI_LOCAL_COMPACTION_RESERVE_TOKENS = 4e4;
830
+ /**
831
+ * Thinking budgets for LOCAL launches only.
832
+ *
833
+ * Pi merges these over its `{minimal:1024, low:2048, medium:8192, high:16384}`
834
+ * defaults, and `high` is the level the local rows resolve to (their rows
835
+ * carry no `thinkingLevelMap`, so `clampReasoning` walks `max`/`xhigh` down
836
+ * to `high`). 16384 is the ceiling that truncates real summaries — 5 of the
837
+ * 19 compactions in the reference session reported output above it, up to
838
+ * 21643. 32768 roughly doubles the summarization headroom and costs nothing
839
+ * on local inference.
840
+ *
841
+ * Deliberately NOT emitted for Copilot profiles: there the thinking budget
842
+ * is billed reasoning tokens on every turn, not a free local decode.
843
+ */
844
+ const PI_LOCAL_THINKING_BUDGETS = Object.freeze({ high: 32768 });
845
+ /**
795
846
  * Derive Pi compaction budgets from live catalog `max_prompt_tokens`
796
847
  * ceilings AND each model's cheap-tier window — the Pi-native analogue
797
848
  * of `deriveAutoCompactWindowTokens`. Pi triggers at
@@ -803,14 +854,34 @@ function buildPiModelsJson(opts) {
803
854
  * safe); overrides carry each model's own value. Unknown catalog (no
804
855
  * prompt metadata) → Pi built-in defaults so a missing signal can never
805
856
  * disable compaction.
857
+ *
858
+ * LOCAL launches take a different path entirely (see
859
+ * `PI_LOCAL_COMPACTION_RESERVE_TOKENS`): the local catalog carries no
860
+ * `max_prompt_tokens`, so the price-cliff derivation has nothing to read,
861
+ * and the constraint that matters is the endpoint's thinking-budget
862
+ * ceiling. Every local row is the same 200K window, so one flat reserve
863
+ * covers the whole roster.
806
864
  */
807
- function derivePiCompactionSettings(catalog, modelIds) {
865
+ function derivePiCompactionSettings(catalog, modelIds, profileId) {
808
866
  const FALLBACK = {
809
867
  enabled: true,
810
868
  reserveTokens: 16384,
811
869
  keepRecentTokens: 2e4,
812
870
  modelOverrides: {}
813
871
  };
872
+ if (profileId !== void 0 && isLocalFamily(profileId)) {
873
+ const localOverrides = {};
874
+ for (const id of modelIds) localOverrides[`${PI_PROVIDER_NAME}/${id}`] = {
875
+ reserveTokens: PI_LOCAL_COMPACTION_RESERVE_TOKENS,
876
+ keepRecentTokens: 2e4
877
+ };
878
+ return {
879
+ enabled: true,
880
+ reserveTokens: PI_LOCAL_COMPACTION_RESERVE_TOKENS,
881
+ keepRecentTokens: 2e4,
882
+ modelOverrides: localOverrides
883
+ };
884
+ }
814
885
  if (!catalog || catalog.length === 0) return FALLBACK;
815
886
  const perModel = /* @__PURE__ */ new Map();
816
887
  for (const id of modelIds) {
@@ -1129,7 +1200,8 @@ function buildPiSettingsJson(opts) {
1129
1200
  reserveTokens: 16384,
1130
1201
  skipPrompt: false
1131
1202
  },
1132
- compaction: derivePiCompactionSettings(opts.catalog, modelIds),
1203
+ compaction: derivePiCompactionSettings(opts.catalog, modelIds, opts.profileId),
1204
+ ...isLocalFamily(opts.profileId) ? { thinkingBudgets: { ...PI_LOCAL_THINKING_BUDGETS } } : {},
1133
1205
  retry: {
1134
1206
  enabled: true,
1135
1207
  maxRetries: 3,
@@ -1352,7 +1424,8 @@ function buildPiAppendSystem(profileId, opts = {}) {
1352
1424
  `# gh-router ${profileId} mode`,
1353
1425
  "",
1354
1426
  `- Lead owns planning directly; there is no Plan subagent.`,
1355
- PI_TOOL_PREFERENCE_LINE
1427
+ PI_TOOL_PREFERENCE_LINE,
1428
+ ...opts.codeSearch === true ? [PI_SEARCH_ORDER_LINE] : []
1356
1429
  ];
1357
1430
  if (peers) {
1358
1431
  const oracle = piOracleEnabled(profileId);
@@ -3381,7 +3454,10 @@ const pi = defineCommand({
3381
3454
  swe: sweEnabled,
3382
3455
  peers: peersEnabled
3383
3456
  })) await writeTextFile(path.join(mirror, "prompts", `${prompt.name}.md`), prompt.content);
3384
- await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, { peers: peersEnabled }));
3457
+ await writeTextFile(path.join(mirror, "APPEND_SYSTEM.md"), buildPiAppendSystem(profileId, {
3458
+ peers: peersEnabled,
3459
+ codeSearch: surfaces.codeSearch
3460
+ }));
3385
3461
  try {
3386
3462
  const collected = globalThis.__ghRouterBridgeCollected;
3387
3463
  if (collected) {
@@ -3504,4 +3580,4 @@ const pi = defineCommand({
3504
3580
  });
3505
3581
  export { pi };
3506
3582
 
3507
- //# sourceMappingURL=pi-DI2QtaiZ.js.map
3583
+ //# sourceMappingURL=pi-CwBDxTbJ.js.map