github-router 0.3.297 → 0.3.302

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.
Files changed (100) hide show
  1. package/dist/{attribution-settings-B70GmZ68.js → attribution-settings-B1xutIts.js} +146 -10
  2. package/dist/attribution-settings-B1xutIts.js.map +1 -0
  3. package/dist/{auth-CluG5e-l.js → auth-CpjOjoUG.js} +4 -3
  4. package/dist/{auth-CluG5e-l.js.map → auth-CpjOjoUG.js.map} +1 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/{check-usage-iOzfnKJe.js → check-usage-BsN3S4Fu.js} +4 -4
  7. package/dist/{check-usage-iOzfnKJe.js.map → check-usage-BsN3S4Fu.js.map} +1 -1
  8. package/dist/{claude-DMMfvfns.js → claude-uRuzEH0W.js} +130 -78
  9. package/dist/claude-uRuzEH0W.js.map +1 -0
  10. package/dist/{codex-DVOyVv2B.js → codex-D5ag-liR.js} +6 -5
  11. package/dist/{codex-DVOyVv2B.js.map → codex-D5ag-liR.js.map} +1 -1
  12. package/dist/{debug-DsEwleGg.js → debug-BXRPyeqO.js} +2 -2
  13. package/dist/{debug-DsEwleGg.js.map → debug-BXRPyeqO.js.map} +1 -1
  14. package/dist/engine-2uMJ4Isk.js +2 -0
  15. package/dist/{gate-discovery-G6PAG61j.js → gate-discovery-BTRVyKWu.js} +5 -5
  16. package/dist/{gate-discovery-G6PAG61j.js.map → gate-discovery-BTRVyKWu.js.map} +1 -1
  17. package/dist/{get-copilot-usage-B7Z4XVWj.js → get-copilot-usage-ByjQqhdi.js} +3 -2
  18. package/dist/{get-copilot-usage-B7Z4XVWj.js.map → get-copilot-usage-ByjQqhdi.js.map} +1 -1
  19. package/dist/hooks.mjs +287 -5
  20. package/dist/hooks.sha256 +1 -1
  21. package/dist/{internal-artifact-open-D6tKMg8v.js → internal-artifact-open-DRSxShAW.js} +2 -2
  22. package/dist/{internal-artifact-open-D6tKMg8v.js.map → internal-artifact-open-DRSxShAW.js.map} +1 -1
  23. package/dist/{internal-fast-dispatch-guard-N-RaLrOn.js → internal-fast-dispatch-guard-CYOWbxjX.js} +1 -1
  24. package/dist/{internal-fast-dispatch-guard-Bkr_iGOu.js → internal-fast-dispatch-guard-D2HcfXZv.js} +2 -2
  25. package/dist/{internal-fast-dispatch-guard-Bkr_iGOu.js.map → internal-fast-dispatch-guard-D2HcfXZv.js.map} +1 -1
  26. package/dist/{internal-first-mate-guard-C9BV7J4U.js → internal-first-mate-guard-Bcb5JwiO.js} +3 -3
  27. package/dist/{internal-first-mate-guard-C9BV7J4U.js.map → internal-first-mate-guard-Bcb5JwiO.js.map} +1 -1
  28. package/dist/{internal-first-mate-guard-WJApyc8j.js → internal-first-mate-guard-Brh_uois.js} +1 -1
  29. package/dist/internal-max-dispatch-guard-Bcjavapx.js +2 -0
  30. package/dist/internal-max-dispatch-guard-BjSVXMvC.js +198 -0
  31. package/dist/internal-max-dispatch-guard-BjSVXMvC.js.map +1 -0
  32. package/dist/{internal-plan-review-t3PuNfuL.js → internal-plan-review-DVY-iV2x.js} +3 -3
  33. package/dist/{internal-plan-review-t3PuNfuL.js.map → internal-plan-review-DVY-iV2x.js.map} +1 -1
  34. package/dist/{internal-prompt-submit-C3KovHQG.js → internal-prompt-submit-BTqRn4FW.js} +4 -4
  35. package/dist/{internal-prompt-submit-C3KovHQG.js.map → internal-prompt-submit-BTqRn4FW.js.map} +1 -1
  36. package/dist/{internal-session-bind-d2uoja8I.js → internal-session-bind-YfH656lt.js} +2 -2
  37. package/dist/{internal-session-bind-d2uoja8I.js.map → internal-session-bind-YfH656lt.js.map} +1 -1
  38. package/dist/{internal-stop-hook-BjzrF1zd.js → internal-stop-hook-BZg__ab6.js} +5 -5
  39. package/dist/{internal-stop-hook-BjzrF1zd.js.map → internal-stop-hook-BZg__ab6.js.map} +1 -1
  40. package/dist/{internal-stop-review-YtDUGXpX.js → internal-stop-review-B8MmEyQ1.js} +2 -2
  41. package/dist/{internal-stop-review-YtDUGXpX.js.map → internal-stop-review-B8MmEyQ1.js.map} +1 -1
  42. package/dist/{internal-worker-guard-CdkeS9PN.js → internal-worker-guard-Dr6W83TC.js} +2 -2
  43. package/dist/{internal-worker-guard-CdkeS9PN.js.map → internal-worker-guard-Dr6W83TC.js.map} +1 -1
  44. package/dist/{internal-workspace-header-tuBXJV22.js → internal-workspace-header-Cep0WSIb.js} +2 -2
  45. package/dist/{internal-workspace-header-tuBXJV22.js.map → internal-workspace-header-Cep0WSIb.js.map} +1 -1
  46. package/dist/lifecycle-4TZrJuAa.js +2 -0
  47. package/dist/{lifecycle-CM9eTzvk.js → lifecycle-CmPJ6e_6.js} +2 -2
  48. package/dist/{lifecycle-CM9eTzvk.js.map → lifecycle-CmPJ6e_6.js.map} +1 -1
  49. package/dist/{lifecycle-Bg6doY3-.js → lifecycle-DgsJ_8Am.js} +2 -2
  50. package/dist/{lifecycle-Bg6doY3-.js.map → lifecycle-DgsJ_8Am.js.map} +1 -1
  51. package/dist/lifecycle-O91Vzzb-.js +2 -0
  52. package/dist/main.js +19 -18
  53. package/dist/main.js.map +1 -1
  54. package/dist/max-profile-contract-BTXowh6k.js +264 -0
  55. package/dist/max-profile-contract-BTXowh6k.js.map +1 -0
  56. package/dist/{mcp-workspace-header-dERl2YTT.js → mcp-workspace-header-NzFD0Wgd.js} +2 -2
  57. package/dist/{mcp-workspace-header-dERl2YTT.js.map → mcp-workspace-header-NzFD0Wgd.js.map} +1 -1
  58. package/dist/{models-DZ4hYsR7.js → models-1KwEUgzd.js} +3 -3
  59. package/dist/{models-DZ4hYsR7.js.map → models-1KwEUgzd.js.map} +1 -1
  60. package/dist/{orchestration-BiGCEwbH.js → orchestration-CYyp9w-t.js} +2 -2
  61. package/dist/{orchestration-BiGCEwbH.js.map → orchestration-CYyp9w-t.js.map} +1 -1
  62. package/dist/paths-DDAiPVto.js +2 -0
  63. package/dist/{paths-Ci485qSJ.js → paths-IcZW8gZx.js} +4 -4
  64. package/dist/{paths-Ci485qSJ.js.map → paths-IcZW8gZx.js.map} +1 -1
  65. package/dist/{peer-mcp-personas-ce6_YMnX.js → peer-mcp-personas-DwEiYeJS.js} +423 -186
  66. package/dist/peer-mcp-personas-DwEiYeJS.js.map +1 -0
  67. package/dist/{plan-review-hook-DuW0pSoM.js → plan-review-hook-szSNt6uU.js} +3 -3
  68. package/dist/{plan-review-hook-DuW0pSoM.js.map → plan-review-hook-szSNt6uU.js.map} +1 -1
  69. package/dist/{prompt-submit-hook-IMl7ssfr.js → prompt-submit-hook-ZUxo_jEl.js} +3 -3
  70. package/dist/{prompt-submit-hook-IMl7ssfr.js.map → prompt-submit-hook-ZUxo_jEl.js.map} +1 -1
  71. package/dist/{provision-BhCtm3md.js → provision-BLT1pCFy.js} +4 -4
  72. package/dist/{provision-BhCtm3md.js.map → provision-BLT1pCFy.js.map} +1 -1
  73. package/dist/{self-invocation-DAB_od0C.js → self-invocation-BJWbA8ka.js} +2 -2
  74. package/dist/{self-invocation-DAB_od0C.js.map → self-invocation-BJWbA8ka.js.map} +1 -1
  75. package/dist/{serve-Blj_dRSr.js → serve-wEZoOijw.js} +13 -12
  76. package/dist/{serve-Blj_dRSr.js.map → serve-wEZoOijw.js.map} +1 -1
  77. package/dist/{server-setup-DhG3YZPj.js → server-setup-Zn5wkosb.js} +213 -37
  78. package/dist/server-setup-Zn5wkosb.js.map +1 -0
  79. package/dist/{start-8QaqICtd.js → start-DSqU8d8h.js} +3 -3
  80. package/dist/{start-8QaqICtd.js.map → start-DSqU8d8h.js.map} +1 -1
  81. package/dist/state-B8adscCv.js +51 -0
  82. package/dist/state-B8adscCv.js.map +1 -0
  83. package/dist/{stop-gate-hook-DQnh_KfI.js → stop-gate-hook-CJOk28zd.js} +3 -3
  84. package/dist/{stop-gate-hook-DQnh_KfI.js.map → stop-gate-hook-CJOk28zd.js.map} +1 -1
  85. package/dist/{stop-gate-policy-DMr3KVmw.js → stop-gate-policy-zhzRIj6G.js} +2 -2
  86. package/dist/{stop-gate-policy-DMr3KVmw.js.map → stop-gate-policy-zhzRIj6G.js.map} +1 -1
  87. package/dist/{token-BtJhjXXu.js → token-CbuFyx-B.js} +4 -50
  88. package/dist/token-CbuFyx-B.js.map +1 -0
  89. package/dist/{worker-dispatch-BEHkTbnH.js → worker-dispatch-DgP5yT26.js} +2 -2
  90. package/dist/{worker-dispatch-BEHkTbnH.js.map → worker-dispatch-DgP5yT26.js.map} +1 -1
  91. package/package.json +1 -1
  92. package/dist/attribution-settings-B70GmZ68.js.map +0 -1
  93. package/dist/claude-DMMfvfns.js.map +0 -1
  94. package/dist/engine-BkGRuUNs.js +0 -2
  95. package/dist/lifecycle-CGLt1cJQ.js +0 -2
  96. package/dist/lifecycle-DoUwpVDB.js +0 -2
  97. package/dist/paths-GD7bgGGy.js +0 -2
  98. package/dist/peer-mcp-personas-ce6_YMnX.js.map +0 -1
  99. package/dist/server-setup-DhG3YZPj.js.map +0 -1
  100. package/dist/token-BtJhjXXu.js.map +0 -1
package/dist/main.js CHANGED
@@ -46,24 +46,25 @@ const main = defineCommand({
46
46
  description: "A reverse proxy that exposes GitHub Copilot as OpenAI and Anthropic compatible API endpoints."
47
47
  },
48
48
  subCommands: {
49
- auth: () => import("./auth-CluG5e-l.js").then((m) => m.auth),
50
- start: () => import("./start-8QaqICtd.js").then((m) => m.start),
51
- claude: () => import("./claude-DMMfvfns.js").then((m) => m.claude),
52
- codex: () => import("./codex-DVOyVv2B.js").then((m) => m.codex),
53
- serve: () => import("./serve-Blj_dRSr.js").then((m) => m.serve),
54
- models: () => import("./models-DZ4hYsR7.js").then((m) => m.models),
55
- "check-usage": () => import("./check-usage-iOzfnKJe.js").then((m) => m.checkUsage),
56
- debug: () => import("./debug-DsEwleGg.js").then((m) => m.debug),
57
- "internal-stop-hook": () => import("./internal-stop-hook-BjzrF1zd.js").then((m) => m.internalStopHook),
58
- "internal-prompt-submit": () => import("./internal-prompt-submit-C3KovHQG.js").then((m) => m.internalPromptSubmit),
59
- "internal-stop-review": () => import("./internal-stop-review-YtDUGXpX.js").then((m) => m.internalStopReview),
60
- "internal-plan-review": () => import("./internal-plan-review-t3PuNfuL.js").then((m) => m.internalPlanReview),
61
- "internal-session-bind": () => import("./internal-session-bind-d2uoja8I.js").then((m) => m.internalSessionBind),
62
- "internal-workspace-header": () => import("./internal-workspace-header-tuBXJV22.js").then((m) => m.internalWorkspaceHeader),
63
- "internal-artifact-open": () => import("./internal-artifact-open-D6tKMg8v.js").then((m) => m.internalArtifactOpen),
64
- "internal-first-mate-guard": () => import("./internal-first-mate-guard-WJApyc8j.js").then((m) => m.internalFirstMateGuard),
65
- "internal-worker-guard": () => import("./internal-worker-guard-CdkeS9PN.js").then((m) => m.internalWorkerGuard),
66
- "internal-fast-dispatch-guard": () => import("./internal-fast-dispatch-guard-N-RaLrOn.js").then((m) => m.internalFastDispatchGuard)
49
+ auth: () => import("./auth-CpjOjoUG.js").then((m) => m.auth),
50
+ start: () => import("./start-DSqU8d8h.js").then((m) => m.start),
51
+ claude: () => import("./claude-uRuzEH0W.js").then((m) => m.claude),
52
+ codex: () => import("./codex-D5ag-liR.js").then((m) => m.codex),
53
+ serve: () => import("./serve-wEZoOijw.js").then((m) => m.serve),
54
+ models: () => import("./models-1KwEUgzd.js").then((m) => m.models),
55
+ "check-usage": () => import("./check-usage-BsN3S4Fu.js").then((m) => m.checkUsage),
56
+ debug: () => import("./debug-BXRPyeqO.js").then((m) => m.debug),
57
+ "internal-stop-hook": () => import("./internal-stop-hook-BZg__ab6.js").then((m) => m.internalStopHook),
58
+ "internal-prompt-submit": () => import("./internal-prompt-submit-BTqRn4FW.js").then((m) => m.internalPromptSubmit),
59
+ "internal-stop-review": () => import("./internal-stop-review-B8MmEyQ1.js").then((m) => m.internalStopReview),
60
+ "internal-plan-review": () => import("./internal-plan-review-DVY-iV2x.js").then((m) => m.internalPlanReview),
61
+ "internal-session-bind": () => import("./internal-session-bind-YfH656lt.js").then((m) => m.internalSessionBind),
62
+ "internal-workspace-header": () => import("./internal-workspace-header-Cep0WSIb.js").then((m) => m.internalWorkspaceHeader),
63
+ "internal-artifact-open": () => import("./internal-artifact-open-DRSxShAW.js").then((m) => m.internalArtifactOpen),
64
+ "internal-first-mate-guard": () => import("./internal-first-mate-guard-Brh_uois.js").then((m) => m.internalFirstMateGuard),
65
+ "internal-worker-guard": () => import("./internal-worker-guard-Dr6W83TC.js").then((m) => m.internalWorkerGuard),
66
+ "internal-fast-dispatch-guard": () => import("./internal-fast-dispatch-guard-CYOWbxjX.js").then((m) => m.internalFastDispatchGuard),
67
+ "internal-max-dispatch-guard": () => import("./internal-max-dispatch-guard-Bcjavapx.js").then((m) => m.internalMaxDispatchGuard)
67
68
  }
68
69
  });
69
70
  /**
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":[],"sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand, runMain, showUsage } from \"citty\"\nimport consola from \"consola\"\n\nimport { getPackageVersion } from \"./lib/version\"\n\nprocess.on(\"unhandledRejection\", (error) => {\n consola.error(\"Unhandled rejection:\", error)\n})\n\nprocess.on(\"uncaughtException\", (error) => {\n consola.error(\"Uncaught exception:\", error)\n process.exit(1)\n})\n\nconst version = getPackageVersion()\n\n// Always surface the running version on stderr so crash reports\n// identify which build is in use. Suppressed only for `--version`\n// (citty's built-in handler prints just the bare version number, and\n// a banner above it is redundant). `-v` is NOT special-cased: citty\n// doesn't treat it as `--version`, so users typing `-v` still get\n// the banner — which is the closest thing to \"show me the version\".\nconst argv = process.argv.slice(2)\nconst isVersionFlag = argv.includes(\"--version\")\n// Suppress the banner for the internal hooks: their stdout/stderr is consumed by\n// Claude Code (the Stop hook's stderr is the block message; the prompt-submit\n// hook's stdout is injected context), so it must stay clean. `internal-stop-review`\n// and `internal-plan-review` are detached/background with no consumer, but stay\n// quiet for the same reason.\nconst isInternalHook =\n argv[0] === \"internal-stop-hook\"\n || argv[0] === \"internal-prompt-submit\"\n || argv[0] === \"internal-stop-review\"\n || argv[0] === \"internal-plan-review\"\n || argv[0] === \"internal-session-bind\"\n || argv[0] === \"internal-workspace-header\"\n || argv[0] === \"internal-artifact-open\"\n || argv[0] === \"internal-first-mate-guard\"\n || argv[0] === \"internal-worker-guard\"\n || argv[0] === \"internal-fast-dispatch-guard\"\nif (!isVersionFlag && !isInternalHook) {\n consola.info(`github-router v${version}`)\n}\n\n/**\n * Subcommands are LAZY THUNKS, not static imports.\n *\n * citty resolves only the named entry (`_findSubCommand` → `resolveValue`), so\n * running one subcommand no longer evaluates the other 17 module graphs. That\n * matters because several of these are per-turn Claude Code hooks — the\n * `UserPromptSubmit`, `Stop` and `PreToolUse` handlers registered by\n * `src/claude.ts` each spawn a FRESH `node dist/main.js <sub>` process, so any\n * import-time cost lands in the user's interactive loop on every prompt.\n * `internal-worker-guard`, for instance, needs three modules but was loading\n * the entire claude/serve/MCP graph plus the Pi vendor runtime.\n *\n * Safe because the import-time side effects in this codebase\n * (`assertMcpToolSurfaceConsistent` in `server.ts`, the tree-sitter grammar\n * preload, the worktree/session exit-handler registrations, the first-mate\n * allowlist assertion) are reachable ONLY from claude/codex/serve/start, and\n * all four reach all of them independently — no subcommand relies on another's\n * module being loaded. Verified by an AST walk of the runtime import graph.\n *\n * `--help` is the one path that still resolves everything: citty's\n * `renderUsage` reads each subcommand's meta to print descriptions. That is\n * not latency-critical, and `resolveHelpTarget` below resolves only the single\n * subcommand when help is scoped to one.\n */\nconst main = defineCommand({\n meta: {\n name: \"github-router\",\n version,\n description:\n \"A reverse proxy that exposes GitHub Copilot as OpenAI and Anthropic compatible API endpoints.\",\n },\n subCommands: {\n auth: () => import(\"./auth\").then((m) => m.auth),\n start: () => import(\"./start\").then((m) => m.start),\n claude: () => import(\"./claude\").then((m) => m.claude),\n codex: () => import(\"./codex\").then((m) => m.codex),\n serve: () => import(\"./serve\").then((m) => m.serve),\n models: () => import(\"./models\").then((m) => m.models),\n \"check-usage\": () => import(\"./check-usage\").then((m) => m.checkUsage),\n debug: () => import(\"./debug\").then((m) => m.debug),\n \"internal-stop-hook\": () =>\n import(\"./internal-stop-hook\").then((m) => m.internalStopHook),\n \"internal-prompt-submit\": () =>\n import(\"./internal-prompt-submit\").then((m) => m.internalPromptSubmit),\n \"internal-stop-review\": () =>\n import(\"./internal-stop-review\").then((m) => m.internalStopReview),\n \"internal-plan-review\": () =>\n import(\"./internal-plan-review\").then((m) => m.internalPlanReview),\n \"internal-session-bind\": () =>\n import(\"./internal-session-bind\").then((m) => m.internalSessionBind),\n \"internal-workspace-header\": () =>\n import(\"./internal-workspace-header\").then(\n (m) => m.internalWorkspaceHeader,\n ),\n \"internal-artifact-open\": () =>\n import(\"./internal-artifact-open\").then((m) => m.internalArtifactOpen),\n \"internal-first-mate-guard\": () =>\n import(\"./internal-first-mate-guard\").then(\n (m) => m.internalFirstMateGuard,\n ),\n \"internal-worker-guard\": () =>\n import(\"./internal-worker-guard\").then((m) => m.internalWorkerGuard),\n \"internal-fast-dispatch-guard\": () =>\n import(\"./internal-fast-dispatch-guard\").then((m) => m.internalFastDispatchGuard),\n },\n})\n\n/**\n * Print usage ourselves and let the process DRAIN, instead of letting citty\n * hard-exit while stdout is still queued.\n *\n * citty's `runMain` calls `process.exit(0)` immediately after `showUsage`\n * resolves (citty 0.2.2 dist/index.mjs:389; 0.1.6 does the same, so this is\n * not an upgrade regression). On Windows a PIPE-backed stdout is async, so the\n * usage text is still in a libuv handle when the hard exit tears the loop down\n * and node aborts:\n * `Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\\win\\async.c`\n * — after printing the help the user asked for.\n *\n * `--version` is unaffected: citty's version branch has no `process.exit()`\n * and drains naturally. That asymmetry is why this survived so long — the\n * cheapest smoke test passes while every `--help` path aborts. Node 22 on\n * Windows tolerated it; node 24 does not, and release.yml publishes with\n * node 24.\n *\n * Forcing `_handle.setBlocking(true)` first was tried and does NOT fix it —\n * the abort still reproduces through a pipe. The only reliable fix is to not\n * hard-exit at all, which is the same resolution the internal hooks already\n * use (`process.exitCode = 0`, never `process.exit()`), guarded by the tests\n * in this repo's internal-hooks-crash suite.\n *\n * Only the help path is intercepted; everything else still goes through citty\n * so argument parsing, subcommand dispatch and error handling stay citty's.\n */\nconst HELP_FLAGS = new Set([\"--help\", \"-h\"])\n\nasync function resolveHelpTarget(): Promise<{\n cmd: Parameters<typeof showUsage>[0]\n parent?: Parameters<typeof showUsage>[1]\n}> {\n // First non-flag token is the subcommand, matching citty's own resolution\n // for our single-level command tree.\n const name = argv.find((arg) => !arg.startsWith(\"-\"))\n const table = main.subCommands as Record<string, unknown> | undefined\n const entry = name ? table?.[name] : undefined\n if (!entry) return { cmd: main }\n // citty allows a subcommand to be a value, a promise, or a thunk.\n const resolved = typeof entry === \"function\" ? await entry() : await entry\n return {\n cmd: resolved as Parameters<typeof showUsage>[0],\n parent: main as Parameters<typeof showUsage>[1],\n }\n}\n\nif (argv.some((arg) => HELP_FLAGS.has(arg))) {\n const { cmd, parent } = await resolveHelpTarget()\n await showUsage(cmd, parent)\n // Signal success WITHOUT tearing the loop down — node drains stdout and\n // exits 0 on its own.\n process.exitCode = 0\n} else {\n await runMain(main)\n}\n"],"mappings":";;;;;AAOA,QAAQ,GAAG,uBAAuB,UAAU;CAC1C,QAAQ,MAAM,wBAAwB,KAAK;AAC7C,CAAC;AAED,QAAQ,GAAG,sBAAsB,UAAU;CACzC,QAAQ,MAAM,uBAAuB,KAAK;CAC1C,QAAQ,KAAK,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,kBAAkB;AAQlC,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,gBAAgB,KAAK,SAAS,WAAW;AAM/C,MAAM,iBACJ,KAAK,OAAO,wBACT,KAAK,OAAO,4BACZ,KAAK,OAAO,0BACZ,KAAK,OAAO,0BACZ,KAAK,OAAO,2BACZ,KAAK,OAAO,+BACZ,KAAK,OAAO,4BACZ,KAAK,OAAO,+BACZ,KAAK,OAAO,2BACZ,KAAK,OAAO;AACjB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;;;;;;;;;;;;;;;;;AA6BD,MAAM,6BAAa,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC;AAE3C,eAAe,oBAGZ;CAGD,MAAM,OAAO,KAAK,MAAM,QAAQ,CAAC,IAAI,WAAW,GAAG,CAAC;CACpD,MAAM,QAAQ,KAAK;CACnB,MAAM,QAAQ,OAAO,QAAQ,QAAQ,KAAA;CACrC,IAAI,CAAC,OAAO,OAAO,EAAE,KAAK,KAAK;CAG/B,OAAO;EACL,KAFe,OAAO,UAAU,aAAa,MAAM,MAAM,IAAI,MAAM;EAGnE,QAAQ;CACV;AACF;AAEA,IAAI,KAAK,MAAM,QAAQ,WAAW,IAAI,GAAG,CAAC,GAAG;CAC3C,MAAM,EAAE,KAAK,WAAW,MAAM,kBAAkB;CAChD,MAAM,UAAU,KAAK,MAAM;CAG3B,QAAQ,WAAW;AACrB,OACE,MAAM,QAAQ,IAAI"}
1
+ {"version":3,"file":"main.js","names":[],"sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand, runMain, showUsage } from \"citty\"\nimport consola from \"consola\"\n\nimport { getPackageVersion } from \"./lib/version\"\n\nprocess.on(\"unhandledRejection\", (error) => {\n consola.error(\"Unhandled rejection:\", error)\n})\n\nprocess.on(\"uncaughtException\", (error) => {\n consola.error(\"Uncaught exception:\", error)\n process.exit(1)\n})\n\nconst version = getPackageVersion()\n\n// Always surface the running version on stderr so crash reports\n// identify which build is in use. Suppressed only for `--version`\n// (citty's built-in handler prints just the bare version number, and\n// a banner above it is redundant). `-v` is NOT special-cased: citty\n// doesn't treat it as `--version`, so users typing `-v` still get\n// the banner — which is the closest thing to \"show me the version\".\nconst argv = process.argv.slice(2)\nconst isVersionFlag = argv.includes(\"--version\")\n// Suppress the banner for the internal hooks: their stdout/stderr is consumed by\n// Claude Code (the Stop hook's stderr is the block message; the prompt-submit\n// hook's stdout is injected context), so it must stay clean. `internal-stop-review`\n// and `internal-plan-review` are detached/background with no consumer, but stay\n// quiet for the same reason.\nconst isInternalHook =\n argv[0] === \"internal-stop-hook\"\n || argv[0] === \"internal-prompt-submit\"\n || argv[0] === \"internal-stop-review\"\n || argv[0] === \"internal-plan-review\"\n || argv[0] === \"internal-session-bind\"\n || argv[0] === \"internal-workspace-header\"\n || argv[0] === \"internal-artifact-open\"\n || argv[0] === \"internal-first-mate-guard\"\n || argv[0] === \"internal-worker-guard\"\n || argv[0] === \"internal-fast-dispatch-guard\"\nif (!isVersionFlag && !isInternalHook) {\n consola.info(`github-router v${version}`)\n}\n\n/**\n * Subcommands are LAZY THUNKS, not static imports.\n *\n * citty resolves only the named entry (`_findSubCommand` → `resolveValue`), so\n * running one subcommand no longer evaluates the other 17 module graphs. That\n * matters because several of these are per-turn Claude Code hooks — the\n * `UserPromptSubmit`, `Stop` and `PreToolUse` handlers registered by\n * `src/claude.ts` each spawn a FRESH `node dist/main.js <sub>` process, so any\n * import-time cost lands in the user's interactive loop on every prompt.\n * `internal-worker-guard`, for instance, needs three modules but was loading\n * the entire claude/serve/MCP graph plus the Pi vendor runtime.\n *\n * Safe because the import-time side effects in this codebase\n * (`assertMcpToolSurfaceConsistent` in `server.ts`, the tree-sitter grammar\n * preload, the worktree/session exit-handler registrations, the first-mate\n * allowlist assertion) are reachable ONLY from claude/codex/serve/start, and\n * all four reach all of them independently — no subcommand relies on another's\n * module being loaded. Verified by an AST walk of the runtime import graph.\n *\n * `--help` is the one path that still resolves everything: citty's\n * `renderUsage` reads each subcommand's meta to print descriptions. That is\n * not latency-critical, and `resolveHelpTarget` below resolves only the single\n * subcommand when help is scoped to one.\n */\nconst main = defineCommand({\n meta: {\n name: \"github-router\",\n version,\n description:\n \"A reverse proxy that exposes GitHub Copilot as OpenAI and Anthropic compatible API endpoints.\",\n },\n subCommands: {\n auth: () => import(\"./auth\").then((m) => m.auth),\n start: () => import(\"./start\").then((m) => m.start),\n claude: () => import(\"./claude\").then((m) => m.claude),\n codex: () => import(\"./codex\").then((m) => m.codex),\n serve: () => import(\"./serve\").then((m) => m.serve),\n models: () => import(\"./models\").then((m) => m.models),\n \"check-usage\": () => import(\"./check-usage\").then((m) => m.checkUsage),\n debug: () => import(\"./debug\").then((m) => m.debug),\n \"internal-stop-hook\": () =>\n import(\"./internal-stop-hook\").then((m) => m.internalStopHook),\n \"internal-prompt-submit\": () =>\n import(\"./internal-prompt-submit\").then((m) => m.internalPromptSubmit),\n \"internal-stop-review\": () =>\n import(\"./internal-stop-review\").then((m) => m.internalStopReview),\n \"internal-plan-review\": () =>\n import(\"./internal-plan-review\").then((m) => m.internalPlanReview),\n \"internal-session-bind\": () =>\n import(\"./internal-session-bind\").then((m) => m.internalSessionBind),\n \"internal-workspace-header\": () =>\n import(\"./internal-workspace-header\").then(\n (m) => m.internalWorkspaceHeader,\n ),\n \"internal-artifact-open\": () =>\n import(\"./internal-artifact-open\").then((m) => m.internalArtifactOpen),\n \"internal-first-mate-guard\": () =>\n import(\"./internal-first-mate-guard\").then(\n (m) => m.internalFirstMateGuard,\n ),\n \"internal-worker-guard\": () =>\n import(\"./internal-worker-guard\").then((m) => m.internalWorkerGuard),\n \"internal-fast-dispatch-guard\": () =>\n import(\"./internal-fast-dispatch-guard\").then((m) => m.internalFastDispatchGuard),\n \"internal-max-dispatch-guard\": () =>\n import(\"./internal-max-dispatch-guard\").then((m) => m.internalMaxDispatchGuard),\n },\n})\n\n/**\n * Print usage ourselves and let the process DRAIN, instead of letting citty\n * hard-exit while stdout is still queued.\n *\n * citty's `runMain` calls `process.exit(0)` immediately after `showUsage`\n * resolves (citty 0.2.2 dist/index.mjs:389; 0.1.6 does the same, so this is\n * not an upgrade regression). On Windows a PIPE-backed stdout is async, so the\n * usage text is still in a libuv handle when the hard exit tears the loop down\n * and node aborts:\n * `Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\\win\\async.c`\n * — after printing the help the user asked for.\n *\n * `--version` is unaffected: citty's version branch has no `process.exit()`\n * and drains naturally. That asymmetry is why this survived so long — the\n * cheapest smoke test passes while every `--help` path aborts. Node 22 on\n * Windows tolerated it; node 24 does not, and release.yml publishes with\n * node 24.\n *\n * Forcing `_handle.setBlocking(true)` first was tried and does NOT fix it —\n * the abort still reproduces through a pipe. The only reliable fix is to not\n * hard-exit at all, which is the same resolution the internal hooks already\n * use (`process.exitCode = 0`, never `process.exit()`), guarded by the tests\n * in this repo's internal-hooks-crash suite.\n *\n * Only the help path is intercepted; everything else still goes through citty\n * so argument parsing, subcommand dispatch and error handling stay citty's.\n */\nconst HELP_FLAGS = new Set([\"--help\", \"-h\"])\n\nasync function resolveHelpTarget(): Promise<{\n cmd: Parameters<typeof showUsage>[0]\n parent?: Parameters<typeof showUsage>[1]\n}> {\n // First non-flag token is the subcommand, matching citty's own resolution\n // for our single-level command tree.\n const name = argv.find((arg) => !arg.startsWith(\"-\"))\n const table = main.subCommands as Record<string, unknown> | undefined\n const entry = name ? table?.[name] : undefined\n if (!entry) return { cmd: main }\n // citty allows a subcommand to be a value, a promise, or a thunk.\n const resolved = typeof entry === \"function\" ? await entry() : await entry\n return {\n cmd: resolved as Parameters<typeof showUsage>[0],\n parent: main as Parameters<typeof showUsage>[1],\n }\n}\n\nif (argv.some((arg) => HELP_FLAGS.has(arg))) {\n const { cmd, parent } = await resolveHelpTarget()\n await showUsage(cmd, parent)\n // Signal success WITHOUT tearing the loop down — node drains stdout and\n // exits 0 on its own.\n process.exitCode = 0\n} else {\n await runMain(main)\n}\n"],"mappings":";;;;;AAOA,QAAQ,GAAG,uBAAuB,UAAU;CAC1C,QAAQ,MAAM,wBAAwB,KAAK;AAC7C,CAAC;AAED,QAAQ,GAAG,sBAAsB,UAAU;CACzC,QAAQ,MAAM,uBAAuB,KAAK;CAC1C,QAAQ,KAAK,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,kBAAkB;AAQlC,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,gBAAgB,KAAK,SAAS,WAAW;AAM/C,MAAM,iBACJ,KAAK,OAAO,wBACT,KA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ACnC,MAAM,EAAE,sBACX;EACF,+BACE,OAAO,sCAA0B,CAAC,MAAM,MAAM,EAAE,mBAAmB;EACrE,sCACE,OAAO,6CAAiC,CAAC,MAAM,MAAM,EAAE,yBAAyB;EAClF,qCACE,OAAO,4CAAgC,CAAC,MAAM,MAAM,EAAE,wBAAwB;CAClF;AACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,MAAM,6BAAa,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC;AAE3C,eAAe,oBAGZ;CAGD,MAAM,OAAO,KAAK,MAAM,QAAQ,CAAC,IAAI,WAAW,GAAG,CAAC;CACpD,MAAM,QAAQ,KAAK;CACnB,MAAM,QAAQ,OAAO,QAAQ,QAAQ,KAAA;CACrC,IAAI,CAAC,OAAO,OAAO,EAAE,KAAK,KAAK;CAG/B,OAAO;EACL,KAFe,OAAO,UAAU,aAAa,MAAM,MAAM,IAAI,MAAM;EAGnE,QAAQ;CACV;AACF;AAEA,IAAI,KAAK,MAAM,QAAQ,WAAW,IAAI,GAAG,CAAC,GAAG;CAC3C,MAAM,EAAE,KAAK,WAAW,MAAM,kBAAkB;CAChD,MAAM,UAAU,KAAK,MAAM;CAG3B,QAAQ,WAAW;AACrB,OACE,MAAM,QAAQ,IAAI"}
@@ -0,0 +1,264 @@
1
+ import { t as state } from "./state-B8adscCv.js";
2
+ //#region src/lib/model-suffix.ts
3
+ /** Strip every trailing `[1m]` marker, case-insensitively. */
4
+ function stripTrailingOneMSuffix(id) {
5
+ const match = id.match(/(?:\[1m\])+$/i);
6
+ if (!match || match.index === void 0) return {
7
+ base: id,
8
+ hadSuffix: false
9
+ };
10
+ return {
11
+ base: id.slice(0, match.index),
12
+ hadSuffix: true
13
+ };
14
+ }
15
+ /** Reapply at most one canonical `[1m]` marker when the input had one. */
16
+ function normalizeTrailingOneMSuffix(id) {
17
+ const { base, hadSuffix } = stripTrailingOneMSuffix(id);
18
+ return hadSuffix ? `${base}[1m]` : base;
19
+ }
20
+ //#endregion
21
+ //#region src/lib/fast-endpoint.ts
22
+ const ENDPOINTS = {
23
+ chat: /* @__PURE__ */ new Set(["/chat/completions", "/v1/chat/completions"]),
24
+ responses: /* @__PURE__ */ new Set(["/responses", "/v1/responses"]),
25
+ messages: /* @__PURE__ */ new Set(["/messages", "/v1/messages"])
26
+ };
27
+ /**
28
+ * Return the endpoint mandated by a fast-profile roster model.
29
+ *
30
+ * This is intentionally independent of the standard `pickEndpoint`: that
31
+ * resolver prefers chat when a catalog entry advertises both clients, while
32
+ * fast roles have a fixed provider contract. Gemini stays on chat; Luna, Sol,
33
+ * and Grok stay on Responses; the Opus Oracle stays on native Messages.
34
+ * Unknown ids return undefined so a fast caller cannot guess a transport.
35
+ */
36
+ function fastEndpointRequirement(modelId) {
37
+ const id = modelId.replace(/(?:\[1m\])+$/i, "");
38
+ if (id === "gemini-3.7-flash") return "chat";
39
+ if (id === "gpt-5.6-luna" || id === "gpt-5.6-sol" || id === "grok-4.6") return "responses";
40
+ if (id === "claude-opus-5") return "messages";
41
+ }
42
+ /**
43
+ * Resolve the fixed fast transport only when the catalog explicitly advertises
44
+ * the required endpoint. An entry that advertises both still resolves to the
45
+ * policy endpoint, regardless of advertisement order.
46
+ */
47
+ function fastEndpointForModel(model) {
48
+ const required = fastEndpointRequirement(model.id);
49
+ if (!required) return void 0;
50
+ const advertised = model.supported_endpoints;
51
+ if (!Array.isArray(advertised) || advertised.length === 0) return void 0;
52
+ return advertised.some((endpoint) => ENDPOINTS[required].has(endpoint)) ? required : void 0;
53
+ }
54
+ /** Resolve a fast endpoint from a catalog id, without selecting a fallback. */
55
+ function fastEndpointForCatalogId(modelId, catalog) {
56
+ const found = catalog?.find((model) => model.id === modelId);
57
+ return found ? fastEndpointForModel(found) : void 0;
58
+ }
59
+ const ONE_M_TOKENS = 1e6;
60
+ function catalogModels() {
61
+ return state.models?.data ?? [];
62
+ }
63
+ function catalogModel(id) {
64
+ return catalogModels().find((model) => model.id === id);
65
+ }
66
+ const MAX_PROFILE_MODELS = Object.freeze({
67
+ sol: "gpt-5.6-sol",
68
+ luna: "gpt-5.6-luna",
69
+ gemini: "gemini-3.7-flash",
70
+ grok: "grok-4.6",
71
+ opus: "claude-opus-5"
72
+ });
73
+ const MAX_PROFILE_NATIVE_AGENT_NAMES = [
74
+ "Explore",
75
+ "Plan",
76
+ "general-purpose",
77
+ "implementer",
78
+ "reviewer",
79
+ "brainstorm",
80
+ "peer-review-coordinator"
81
+ ];
82
+ const MAX_PROFILE_NATIVE_EFFORTS = Object.freeze({
83
+ Explore: "high",
84
+ Plan: "high",
85
+ "general-purpose": "max",
86
+ implementer: "high",
87
+ reviewer: "high",
88
+ brainstorm: "medium",
89
+ "peer-review-coordinator": "max"
90
+ });
91
+ /** Default model family behind each native role's frontmatter. The optional
92
+ * Grok brainstorm path may fall back to Gemini, whose allowed effort ladder is
93
+ * identical for the values accepted by the max dispatch guard. */
94
+ const MAX_PROFILE_NATIVE_MODELS = Object.freeze({
95
+ Explore: MAX_PROFILE_MODELS.luna,
96
+ Plan: MAX_PROFILE_MODELS.sol,
97
+ "general-purpose": MAX_PROFILE_MODELS.luna,
98
+ implementer: MAX_PROFILE_MODELS.gemini,
99
+ reviewer: MAX_PROFILE_MODELS.gemini,
100
+ brainstorm: MAX_PROFILE_MODELS.grok,
101
+ "peer-review-coordinator": MAX_PROFILE_MODELS.luna
102
+ });
103
+ const MAX_PROFILE_LEAD_MODEL = MAX_PROFILE_MODELS.sol;
104
+ MAX_PROFILE_MODELS.opus;
105
+ const MAX_PROFILE_ADVISOR_EFFORT = "high";
106
+ const MAX_PROFILE_ADVISOR_INSTRUCTIONS = `# Advisor Tool
107
+
108
+ You have access to an optional, lead-only, transcript-aware Max Advisor. It offers a focused second opinion; it is not a supervisor, approver, workflow gate, or substitute for your own reasoning. You keep decision ownership.
109
+
110
+ Use it only when a consequential uncertainty remains after direct investigation and cannot be settled by repository evidence, a focused command or test, Plan, reviewer, or a fresh-context peer: conflicting evidence, a materially changed assumption, a genuinely non-converging approach, or a hard-to-reverse trade-off. State the precise unresolved question immediately before calling it.
111
+
112
+ Do not call it automatically before substantive work or completion, for routine progress, while waiting, after ordinary tool output, for directly verifiable facts, planner approval, reviewer verification, or as reassurance for a decision the evidence already supports.
113
+
114
+ Treat the result as advice, not authority. Weigh it against the user's intent and verified evidence. Consult again only when materially new evidence creates a different question or directly conflicts with the earlier advice.`;
115
+ function maxAdvisorModelFromPin(pinned, opusModel) {
116
+ const trimmed = pinned?.trim();
117
+ const base = trimmed ? stripTrailingOneMSuffix(trimmed).base : void 0;
118
+ if (base === MAX_PROFILE_MODELS.sol || base === MAX_PROFILE_MODELS.opus) return base;
119
+ return opusModel ?? MAX_PROFILE_MODELS.opus;
120
+ }
121
+ function maxAdvisorPinIsValid(pinned) {
122
+ const trimmed = pinned?.trim();
123
+ const base = trimmed ? stripTrailingOneMSuffix(trimmed).base : trimmed;
124
+ return base === void 0 || base === "" || base === MAX_PROFILE_MODELS.sol || base === MAX_PROFILE_MODELS.opus;
125
+ }
126
+ function maxAdvisorEffortForModel(_model) {
127
+ return MAX_PROFILE_ADVISOR_EFFORT;
128
+ }
129
+ Object.freeze([
130
+ MAX_PROFILE_MODELS.luna,
131
+ MAX_PROFILE_MODELS.gemini,
132
+ MAX_PROFILE_MODELS.grok
133
+ ]);
134
+ const MAX_PROFILE_ALLOWED_LEAD_MODEL_IDS = Object.freeze([
135
+ MAX_PROFILE_MODELS.sol,
136
+ MAX_PROFILE_MODELS.luna,
137
+ MAX_PROFILE_MODELS.gemini,
138
+ MAX_PROFILE_MODELS.opus
139
+ ]);
140
+ function findModel(catalog, id) {
141
+ return catalog?.data?.find((model) => model.id === id);
142
+ }
143
+ function hasToolCalls(model) {
144
+ return model?.capabilities?.supports?.tool_calls === true;
145
+ }
146
+ function hasContextAtLeast(model, tokens) {
147
+ return (model?.capabilities?.limits?.max_context_window_tokens ?? 0) >= tokens;
148
+ }
149
+ function supportsEffort(model, effort) {
150
+ const ladder = model?.capabilities?.supports?.reasoning_effort;
151
+ return Array.isArray(ladder) && ladder.includes(effort);
152
+ }
153
+ function hasUsableLimits(model) {
154
+ const limits = model?.capabilities?.limits;
155
+ const prompt = limits?.max_prompt_tokens;
156
+ const output = limits?.max_output_tokens;
157
+ return typeof prompt === "number" && Number.isFinite(prompt) && prompt > 0 && typeof output === "number" && Number.isFinite(output) && output > 0 && (limits?.max_context_window_tokens ?? 0) >= prompt;
158
+ }
159
+ function supportsEndpoint(model, endpoint) {
160
+ return model !== void 0 && fastEndpointForModel(model) === endpoint;
161
+ }
162
+ function validateRequiredModel(model, id, requirements, missing) {
163
+ if (!model) {
164
+ missing.push(`${id}: absent from the live catalog`);
165
+ return;
166
+ }
167
+ for (const [message, ok] of requirements) if (!ok) missing.push(`${id}: ${message}`);
168
+ }
169
+ function usableGemini(model) {
170
+ return Boolean(model && hasToolCalls(model) && hasContextAtLeast(model, ONE_M_TOKENS) && supportsEffort(model, "high") && supportsEndpoint(model, "chat") && hasUsableLimits(model));
171
+ }
172
+ function usableGrok(model) {
173
+ return Boolean(model && hasToolCalls(model) && supportsEffort(model, "medium") && supportsEndpoint(model, "responses") && hasUsableLimits(model));
174
+ }
175
+ /**
176
+ * Validate the fixed prerequisites for the raw `-m max` launch.
177
+ *
178
+ * Max is a deliberately strong, closed profile. Its lead, planning, reviewer,
179
+ * and transcript-aware Advisor paths must all be present before any runtime
180
+ * artifact is written: Sol, Luna, Gemini 3.7 Flash, and Opus 5 are mandatory.
181
+ * Grok 4.6 is the only optional model. When present it supplies the preferred
182
+ * medium-effort brainstorm/critic path, but it is never a max lead and its
183
+ * sub-1M context must remain undecorated.
184
+ */
185
+ function validateMaxProfilePrerequisites(catalog) {
186
+ const missing = [];
187
+ const sol = findModel(catalog, MAX_PROFILE_MODELS.sol);
188
+ const luna = findModel(catalog, MAX_PROFILE_MODELS.luna);
189
+ const gemini = findModel(catalog, MAX_PROFILE_MODELS.gemini);
190
+ const grok = findModel(catalog, MAX_PROFILE_MODELS.grok);
191
+ const opus = findModel(catalog, MAX_PROFILE_MODELS.opus);
192
+ validateRequiredModel(sol, MAX_PROFILE_MODELS.sol, [
193
+ ["does not advertise tool_calls", hasToolCalls(sol)],
194
+ ["advertised context window is below 1M", hasContextAtLeast(sol, ONE_M_TOKENS)],
195
+ ["does not advertise a high reasoning effort", supportsEffort(sol, "high")],
196
+ ["does not advertise a supported Responses endpoint", supportsEndpoint(sol, "responses")],
197
+ ["has no usable max_prompt_tokens/max_output_tokens limits", hasUsableLimits(sol)]
198
+ ], missing);
199
+ validateRequiredModel(luna, MAX_PROFILE_MODELS.luna, [
200
+ ["does not advertise tool_calls", hasToolCalls(luna)],
201
+ ["advertised context window is below 1M", hasContextAtLeast(luna, ONE_M_TOKENS)],
202
+ ["does not advertise a high reasoning effort", supportsEffort(luna, "high")],
203
+ ["does not advertise a max reasoning effort", supportsEffort(luna, "max")],
204
+ ["does not advertise a supported Responses endpoint", supportsEndpoint(luna, "responses")],
205
+ ["has no usable max_prompt_tokens/max_output_tokens limits", hasUsableLimits(luna)]
206
+ ], missing);
207
+ validateRequiredModel(gemini, MAX_PROFILE_MODELS.gemini, [
208
+ ["does not advertise tool_calls", hasToolCalls(gemini)],
209
+ ["advertised context window is below 1M", hasContextAtLeast(gemini, ONE_M_TOKENS)],
210
+ ["does not advertise a high reasoning effort", supportsEffort(gemini, "high")],
211
+ ["does not advertise a supported Chat Completions endpoint", supportsEndpoint(gemini, "chat")],
212
+ ["has no usable max_prompt_tokens/max_output_tokens limits", hasUsableLimits(gemini)]
213
+ ], missing);
214
+ validateRequiredModel(opus, MAX_PROFILE_MODELS.opus, [
215
+ ["advertised context window is below 1M", hasContextAtLeast(opus, ONE_M_TOKENS)],
216
+ ["does not advertise adaptive_thinking", opus?.capabilities?.supports?.adaptive_thinking === true],
217
+ ["does not advertise a high reasoning effort", supportsEffort(opus, "high")],
218
+ ["does not advertise a supported Messages endpoint", supportsEndpoint(opus, "messages")],
219
+ ["has no usable max_prompt_tokens/max_output_tokens limits", hasUsableLimits(opus)]
220
+ ], missing);
221
+ const geminiUsable = usableGemini(gemini);
222
+ const grokUsable = usableGrok(grok);
223
+ return {
224
+ ok: missing.length === 0,
225
+ missing,
226
+ models: {
227
+ sol: sol && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.sol}:`)) ? sol : void 0,
228
+ luna: luna && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.luna}:`)) ? luna : void 0,
229
+ gemini: geminiUsable ? gemini : void 0,
230
+ grok: grokUsable ? grok : void 0,
231
+ opus: opus && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.opus}:`)) ? opus : void 0,
232
+ thirdLab: grokUsable && supportsEffort(grok, "high") ? "grok" : geminiUsable ? "gemini" : void 0
233
+ }
234
+ };
235
+ }
236
+ function formatMaxPrerequisiteFailure(missing) {
237
+ return "github-router claude -m max requires the following live-catalog capabilities, which this account's catalog does not fully provide:\n" + missing.map((entry) => ` - ${entry}`).join("\n") + "\n\nMax launches do not fall back to arbitrary older models. Use plain `github-router claude` for the standard profile.";
238
+ }
239
+ function maxGeminiModel() {
240
+ const model = catalogModel(MAX_PROFILE_MODELS.gemini);
241
+ return model && usableGemini(model) ? model.id : void 0;
242
+ }
243
+ function maxGrokModel() {
244
+ const model = catalogModel(MAX_PROFILE_MODELS.grok);
245
+ return model && usableGrok(model) ? model.id : void 0;
246
+ }
247
+ /** Grok replacement for max-profile surfaces that require high effort. */
248
+ function maxGrokHighModel() {
249
+ const model = catalogModel(MAX_PROFILE_MODELS.grok);
250
+ return model && usableGrok(model) && supportsEffort(model, "high") ? model.id : void 0;
251
+ }
252
+ /** Max-only replacement for any standard Gemini Pro assignment. */
253
+ function maxProReplacementModel() {
254
+ if (maxGrokHighModel()) return MAX_PROFILE_MODELS.grok;
255
+ if (maxGeminiModel()) return MAX_PROFILE_MODELS.gemini;
256
+ }
257
+ function maxOpusModel() {
258
+ const model = catalogModel(MAX_PROFILE_MODELS.opus);
259
+ return model && hasContextAtLeast(model, ONE_M_TOKENS) && model.capabilities?.supports?.adaptive_thinking === true && supportsEffort(model, "high") && supportsEndpoint(model, "messages") && hasUsableLimits(model) ? model.id : void 0;
260
+ }
261
+ //#endregion
262
+ export { fastEndpointForCatalogId as _, MAX_PROFILE_NATIVE_AGENT_NAMES as a, stripTrailingOneMSuffix as b, formatMaxPrerequisiteFailure as c, maxAdvisorPinIsValid as d, maxGeminiModel as f, validateMaxProfilePrerequisites as g, maxProReplacementModel as h, MAX_PROFILE_MODELS as i, maxAdvisorEffortForModel as l, maxOpusModel as m, MAX_PROFILE_ALLOWED_LEAD_MODEL_IDS as n, MAX_PROFILE_NATIVE_EFFORTS as o, maxGrokModel as p, MAX_PROFILE_LEAD_MODEL as r, MAX_PROFILE_NATIVE_MODELS as s, MAX_PROFILE_ADVISOR_INSTRUCTIONS as t, maxAdvisorModelFromPin as u, fastEndpointForModel as v, normalizeTrailingOneMSuffix as y };
263
+
264
+ //# sourceMappingURL=max-profile-contract-BTXowh6k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-profile-contract-BTXowh6k.js","names":[],"sources":["../src/lib/model-suffix.ts","../src/lib/fast-endpoint.ts","../src/lib/max-profile-contract.ts"],"sourcesContent":["/**\n * Normalize Claude Code's local 1M-context decoration at model boundaries.\n *\n * `[1m]` is a client-side accounting marker, not part of a Copilot catalog id.\n * Claude Code can append its own marker to a picker value that is already\n * decorated by the router, producing a reachable doubled suffix. Keep the\n * helper dependency-free so launch/profile code and request preprocessing use\n * exactly the same trailing-suffix rule without an import cycle.\n */\nexport interface TrailingOneMSuffix {\n base: string\n hadSuffix: boolean\n}\n\n/** Strip every trailing `[1m]` marker, case-insensitively. */\nexport function stripTrailingOneMSuffix(id: string): TrailingOneMSuffix {\n const match = id.match(/(?:\\[1m\\])+$/i)\n if (!match || match.index === undefined) {\n return { base: id, hadSuffix: false }\n }\n return { base: id.slice(0, match.index), hadSuffix: true }\n}\n\n/** Reapply at most one canonical `[1m]` marker when the input had one. */\nexport function normalizeTrailingOneMSuffix(id: string): string {\n const { base, hadSuffix } = stripTrailingOneMSuffix(id)\n return hadSuffix ? `${base}[1m]` : base\n}\n\n/** Append one marker without ever creating a doubled suffix. */\nexport function withTrailingOneMSuffix(id: string): string {\n const { base } = stripTrailingOneMSuffix(id)\n return `${base}[1m]`\n}\n","import type { Model } from \"~/services/copilot/get-models\"\n\n// Fast endpoint policy is intentionally kept separate from the standard\n// pickEndpoint() resolver. See fastEndpointRequirement below.\n\n/** Endpoint clients used by the fast profile's fixed roster. */\nexport type FastEndpoint = \"chat\" | \"responses\" | \"messages\"\n\nconst ENDPOINTS: Readonly<Record<FastEndpoint, ReadonlySet<string>>> = {\n chat: new Set([\"/chat/completions\", \"/v1/chat/completions\"]),\n responses: new Set([\"/responses\", \"/v1/responses\"]),\n messages: new Set([\"/messages\", \"/v1/messages\"]),\n}\n\n/**\n * Return the endpoint mandated by a fast-profile roster model.\n *\n * This is intentionally independent of the standard `pickEndpoint`: that\n * resolver prefers chat when a catalog entry advertises both clients, while\n * fast roles have a fixed provider contract. Gemini stays on chat; Luna, Sol,\n * and Grok stay on Responses; the Opus Oracle stays on native Messages.\n * Unknown ids return undefined so a fast caller cannot guess a transport.\n */\nexport function fastEndpointRequirement(modelId: string): FastEndpoint | undefined {\n const id = modelId.replace(/(?:\\[1m\\])+$/i, \"\")\n if (id === \"gemini-3.7-flash\") return \"chat\"\n if (id === \"gpt-5.6-luna\" || id === \"gpt-5.6-sol\" || id === \"grok-4.6\") {\n return \"responses\"\n }\n if (id === \"claude-opus-5\") return \"messages\"\n return undefined\n}\n\n/**\n * Resolve the fixed fast transport only when the catalog explicitly advertises\n * the required endpoint. An entry that advertises both still resolves to the\n * policy endpoint, regardless of advertisement order.\n */\nexport function fastEndpointForModel(model: Model): FastEndpoint | undefined {\n const required = fastEndpointRequirement(model.id)\n if (!required) return undefined\n const advertised = model.supported_endpoints\n if (!Array.isArray(advertised) || advertised.length === 0) return undefined\n return advertised.some((endpoint) => ENDPOINTS[required].has(endpoint))\n ? required\n : undefined\n}\n\n/** Resolve a fast endpoint from a catalog id, without selecting a fallback. */\nexport function fastEndpointForCatalogId(\n modelId: string,\n catalog: ReadonlyArray<Model> | undefined,\n): FastEndpoint | undefined {\n const found = catalog?.find((model) => model.id === modelId)\n return found ? fastEndpointForModel(found) : undefined\n}\n\n/** Human-readable endpoint name for prerequisite diagnostics. */\nexport function fastEndpointLabel(endpoint: FastEndpoint): string {\n return endpoint === \"chat\"\n ? \"Chat Completions\"\n : endpoint === \"responses\"\n ? \"Responses\"\n : \"Messages\"\n}\n","import type { Model, ModelsResponse } from \"~/services/copilot/get-models\"\nimport type { Effort } from \"./reasoning-effort\"\nimport { fastEndpointForModel } from \"./fast-endpoint\"\nimport { stripTrailingOneMSuffix } from \"./model-suffix\"\nimport { state } from \"./state\"\n\n// Max uses the same context threshold as Claude Code's `[1m]` accounting.\nexport const MAX_REQUIRED_CONTEXT_TOKENS = 1_000_000\n\nconst ONE_M_TOKENS = MAX_REQUIRED_CONTEXT_TOKENS\n\nfunction catalogModels(): Array<Model> {\n return state.models?.data ?? []\n}\n\nfunction catalogModel(id: string): Model | undefined {\n return catalogModels().find((model) => model.id === id)\n}\n\n\nexport const MAX_PROFILE_MODELS = Object.freeze({\n sol: \"gpt-5.6-sol\",\n luna: \"gpt-5.6-luna\",\n gemini: \"gemini-3.7-flash\",\n grok: \"grok-4.6\",\n opus: \"claude-opus-5\",\n} as const)\n\nexport const MAX_PROFILE_NATIVE_AGENT_NAMES = [\n \"Explore\",\n \"Plan\",\n \"general-purpose\",\n \"implementer\",\n \"reviewer\",\n \"brainstorm\",\n \"peer-review-coordinator\",\n] as const\n\nexport type MaxProfileNativeAgentName =\n (typeof MAX_PROFILE_NATIVE_AGENT_NAMES)[number]\n\nexport const MAX_PROFILE_NATIVE_EFFORTS = Object.freeze({\n Explore: \"high\",\n Plan: \"high\",\n \"general-purpose\": \"max\",\n implementer: \"high\",\n reviewer: \"high\",\n brainstorm: \"medium\",\n \"peer-review-coordinator\": \"max\",\n} as const satisfies Record<MaxProfileNativeAgentName, Effort>)\n\n/** Default model family behind each native role's frontmatter. The optional\n * Grok brainstorm path may fall back to Gemini, whose allowed effort ladder is\n * identical for the values accepted by the max dispatch guard. */\nexport const MAX_PROFILE_NATIVE_MODELS = Object.freeze({\n Explore: MAX_PROFILE_MODELS.luna,\n Plan: MAX_PROFILE_MODELS.sol,\n \"general-purpose\": MAX_PROFILE_MODELS.luna,\n implementer: MAX_PROFILE_MODELS.gemini,\n reviewer: MAX_PROFILE_MODELS.gemini,\n brainstorm: MAX_PROFILE_MODELS.grok,\n \"peer-review-coordinator\": MAX_PROFILE_MODELS.luna,\n} as const satisfies Record<MaxProfileNativeAgentName, string>)\n\nexport const MAX_PROFILE_LEAD_MODEL = MAX_PROFILE_MODELS.sol\nexport const MAX_PROFILE_ADVISOR_MODEL = MAX_PROFILE_MODELS.opus\nexport const MAX_PROFILE_ADVISOR_EFFORT = \"high\" as const\nexport const MAX_PROFILE_ADVISOR_INSTRUCTIONS = `# Advisor Tool\n\nYou have access to an optional, lead-only, transcript-aware Max Advisor. It offers a focused second opinion; it is not a supervisor, approver, workflow gate, or substitute for your own reasoning. You keep decision ownership.\n\nUse it only when a consequential uncertainty remains after direct investigation and cannot be settled by repository evidence, a focused command or test, Plan, reviewer, or a fresh-context peer: conflicting evidence, a materially changed assumption, a genuinely non-converging approach, or a hard-to-reverse trade-off. State the precise unresolved question immediately before calling it.\n\nDo not call it automatically before substantive work or completion, for routine progress, while waiting, after ordinary tool output, for directly verifiable facts, planner approval, reviewer verification, or as reassurance for a decision the evidence already supports.\n\nTreat the result as advice, not authority. Weigh it against the user's intent and verified evidence. Consult again only when materially new evidence creates a different question or directly conflicts with the earlier advice.`\n\nexport function maxAdvisorModelFromPin(pinned: string | undefined, opusModel?: string): string {\n const trimmed = pinned?.trim()\n const base = trimmed ? stripTrailingOneMSuffix(trimmed).base : undefined\n if (base === MAX_PROFILE_MODELS.sol || base === MAX_PROFILE_MODELS.opus) {\n return base\n }\n return opusModel ?? MAX_PROFILE_MODELS.opus\n}\n\nexport function maxAdvisorPinIsValid(pinned: string | undefined): boolean {\n const trimmed = pinned?.trim()\n const base = trimmed ? stripTrailingOneMSuffix(trimmed).base : trimmed\n return base === undefined\n || base === \"\"\n || base === MAX_PROFILE_MODELS.sol\n || base === MAX_PROFILE_MODELS.opus\n}\n\nexport function maxAdvisorModelFromPinStrict(pinned: string | undefined, opusModel?: string): string {\n if (!maxAdvisorPinIsValid(pinned)) return opusModel ?? MAX_PROFILE_MODELS.opus\n return maxAdvisorModelFromPin(pinned, opusModel)\n}\n\nexport function maxStandInAvailable(): boolean {\n return usableSol(catalogModel(MAX_PROFILE_MODELS.sol))\n && maxOpusModel() !== undefined\n && (maxGrokHighModel() !== undefined || maxGeminiModel() !== undefined)\n}\nexport function maxAdvisorEffortForModel(_model: string): Effort {\n return MAX_PROFILE_ADVISOR_EFFORT\n}\n\nexport const MAX_PROFILE_NATIVE_MODEL_IDS = Object.freeze([\n MAX_PROFILE_MODELS.luna,\n MAX_PROFILE_MODELS.gemini,\n MAX_PROFILE_MODELS.grok,\n] as const)\n\nexport const MAX_PROFILE_ALLOWED_LEAD_MODEL_IDS = Object.freeze([\n MAX_PROFILE_MODELS.sol,\n MAX_PROFILE_MODELS.luna,\n MAX_PROFILE_MODELS.gemini,\n MAX_PROFILE_MODELS.opus,\n] as const)\n\nexport type MaxProfileAllowedLeadModel =\n (typeof MAX_PROFILE_ALLOWED_LEAD_MODEL_IDS)[number]\n\nexport interface MaxProfilePrerequisiteCheck {\n ok: boolean\n missing: ReadonlyArray<string>\n /** Resolved optional/third-lab assignments for the launch. */\n models: {\n sol?: Model\n luna?: Model\n gemini?: Model\n grok?: Model\n opus?: Model\n thirdLab?: \"gemini\" | \"grok\"\n }\n}\n\nfunction findModel(\n catalog: ModelsResponse | undefined,\n id: string,\n): Model | undefined {\n return catalog?.data?.find((model) => model.id === id)\n}\n\nfunction hasToolCalls(model: Model | undefined): boolean {\n return model?.capabilities?.supports?.tool_calls === true\n}\n\nfunction hasContextAtLeast(model: Model | undefined, tokens: number): boolean {\n return (model?.capabilities?.limits?.max_context_window_tokens ?? 0) >= tokens\n}\n\nfunction supportsEffort(model: Model | undefined, effort: Effort): boolean {\n const ladder = model?.capabilities?.supports?.reasoning_effort\n return Array.isArray(ladder) && ladder.includes(effort)\n}\n\nfunction hasUsableLimits(model: Model | undefined): boolean {\n const limits = model?.capabilities?.limits\n const prompt = limits?.max_prompt_tokens\n const output = limits?.max_output_tokens\n return (\n typeof prompt === \"number\"\n && Number.isFinite(prompt)\n && prompt > 0\n && typeof output === \"number\"\n && Number.isFinite(output)\n && output > 0\n && (limits?.max_context_window_tokens ?? 0) >= prompt\n )\n}\n\nfunction supportsEndpoint(\n model: Model | undefined,\n endpoint: \"chat\" | \"responses\" | \"messages\",\n): boolean {\n return model !== undefined && fastEndpointForModel(model) === endpoint\n}\n\nfunction validateRequiredModel(\n model: Model | undefined,\n id: string,\n requirements: ReadonlyArray<[string, boolean]>,\n missing: string[],\n): void {\n if (!model) {\n missing.push(`${id}: absent from the live catalog`)\n return\n }\n for (const [message, ok] of requirements) {\n if (!ok) missing.push(`${id}: ${message}`)\n }\n}\n\nfunction usableSol(model: Model | undefined): boolean {\n return Boolean(\n model\n && hasToolCalls(model)\n && hasContextAtLeast(model, ONE_M_TOKENS)\n && supportsEffort(model, \"high\")\n && supportsEndpoint(model, \"responses\")\n && hasUsableLimits(model)\n )\n}\n\nfunction usableGemini(model: Model | undefined): boolean {\n return Boolean(\n model\n && hasToolCalls(model)\n && hasContextAtLeast(model, ONE_M_TOKENS)\n && supportsEffort(model, \"high\")\n && supportsEndpoint(model, \"chat\")\n && hasUsableLimits(model),\n )\n}\n\nfunction usableGrok(model: Model | undefined): boolean {\n return Boolean(\n model\n && hasToolCalls(model)\n && supportsEffort(model, \"medium\")\n && supportsEndpoint(model, \"responses\")\n && hasUsableLimits(model),\n )\n}\n\n/**\n * Validate the fixed prerequisites for the raw `-m max` launch.\n *\n * Max is a deliberately strong, closed profile. Its lead, planning, reviewer,\n * and transcript-aware Advisor paths must all be present before any runtime\n * artifact is written: Sol, Luna, Gemini 3.7 Flash, and Opus 5 are mandatory.\n * Grok 4.6 is the only optional model. When present it supplies the preferred\n * medium-effort brainstorm/critic path, but it is never a max lead and its\n * sub-1M context must remain undecorated.\n */\nexport function validateMaxProfilePrerequisites(\n catalog: ModelsResponse | undefined,\n): MaxProfilePrerequisiteCheck {\n const missing: string[] = []\n const sol = findModel(catalog, MAX_PROFILE_MODELS.sol)\n const luna = findModel(catalog, MAX_PROFILE_MODELS.luna)\n const gemini = findModel(catalog, MAX_PROFILE_MODELS.gemini)\n const grok = findModel(catalog, MAX_PROFILE_MODELS.grok)\n const opus = findModel(catalog, MAX_PROFILE_MODELS.opus)\n\n validateRequiredModel(\n sol,\n MAX_PROFILE_MODELS.sol,\n [\n [\"does not advertise tool_calls\", hasToolCalls(sol)],\n [\"advertised context window is below 1M\", hasContextAtLeast(sol, ONE_M_TOKENS)],\n [\"does not advertise a high reasoning effort\", supportsEffort(sol, \"high\")],\n [\"does not advertise a supported Responses endpoint\", supportsEndpoint(sol, \"responses\")],\n [\"has no usable max_prompt_tokens/max_output_tokens limits\", hasUsableLimits(sol)],\n ],\n missing,\n )\n validateRequiredModel(\n luna,\n MAX_PROFILE_MODELS.luna,\n [\n [\"does not advertise tool_calls\", hasToolCalls(luna)],\n [\"advertised context window is below 1M\", hasContextAtLeast(luna, ONE_M_TOKENS)],\n [\"does not advertise a high reasoning effort\", supportsEffort(luna, \"high\")],\n [\"does not advertise a max reasoning effort\", supportsEffort(luna, \"max\")],\n [\"does not advertise a supported Responses endpoint\", supportsEndpoint(luna, \"responses\")],\n [\"has no usable max_prompt_tokens/max_output_tokens limits\", hasUsableLimits(luna)],\n ],\n missing,\n )\n validateRequiredModel(\n gemini,\n MAX_PROFILE_MODELS.gemini,\n [\n [\"does not advertise tool_calls\", hasToolCalls(gemini)],\n [\"advertised context window is below 1M\", hasContextAtLeast(gemini, ONE_M_TOKENS)],\n [\"does not advertise a high reasoning effort\", supportsEffort(gemini, \"high\")],\n [\"does not advertise a supported Chat Completions endpoint\", supportsEndpoint(gemini, \"chat\")],\n [\"has no usable max_prompt_tokens/max_output_tokens limits\", hasUsableLimits(gemini)],\n ],\n missing,\n )\n validateRequiredModel(\n opus,\n MAX_PROFILE_MODELS.opus,\n [\n [\"advertised context window is below 1M\", hasContextAtLeast(opus, ONE_M_TOKENS)],\n [\"does not advertise adaptive_thinking\", opus?.capabilities?.supports?.adaptive_thinking === true],\n [\"does not advertise a high reasoning effort\", supportsEffort(opus, \"high\")],\n [\"does not advertise a supported Messages endpoint\", supportsEndpoint(opus, \"messages\")],\n [\"has no usable max_prompt_tokens/max_output_tokens limits\", hasUsableLimits(opus)],\n ],\n missing,\n )\n\n // Grok is intentionally optional. A malformed optional entry is simply\n // omitted from the max projection; it must never make launch fail or be\n // decorated as a 1M model.\n const geminiUsable = usableGemini(gemini)\n const grokUsable = usableGrok(grok)\n\n return {\n ok: missing.length === 0,\n missing,\n models: {\n sol: sol && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.sol}:`)) ? sol : undefined,\n luna: luna && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.luna}:`)) ? luna : undefined,\n gemini: geminiUsable ? gemini : undefined,\n grok: grokUsable ? grok : undefined,\n opus: opus && !missing.some((entry) => entry.startsWith(`${MAX_PROFILE_MODELS.opus}:`)) ? opus : undefined,\n thirdLab: grokUsable && supportsEffort(grok, \"high\")\n ? \"grok\"\n : geminiUsable\n ? \"gemini\"\n : undefined,\n },\n }\n}\n\nexport function formatMaxPrerequisiteFailure(\n missing: ReadonlyArray<string>,\n): string {\n return (\n \"github-router claude -m max requires the following live-catalog capabilities, \"\n + \"which this account's catalog does not fully provide:\\n\"\n + missing.map((entry) => ` - ${entry}`).join(\"\\n\")\n + \"\\n\\nMax launches do not fall back to arbitrary older models. \"\n + \"Use plain `github-router claude` for the standard profile.\"\n )\n}\n\nexport function maxModelIsOneM(\n model: Model | undefined,\n): boolean {\n return (\n (model?.capabilities?.limits?.max_context_window_tokens ?? 0) >= ONE_M_TOKENS\n )\n}\n\nexport function maxModelSupportsEffort(\n model: Model | undefined,\n effort: Effort,\n): boolean {\n return supportsEffort(model, effort)\n}\n\nexport function maxModelHasUsableLimits(model: Model | undefined): boolean {\n return hasUsableLimits(model)\n}\n\nexport function maxThirdLabModel(): string | undefined {\n const gemini = catalogModel(MAX_PROFILE_MODELS.gemini)\n if (usableGemini(gemini)) return MAX_PROFILE_MODELS.gemini\n const grok = catalogModel(MAX_PROFILE_MODELS.grok)\n return usableGrok(grok) ? MAX_PROFILE_MODELS.grok : undefined\n}\n\nexport function maxGeminiModel(): string | undefined {\n const model = catalogModel(MAX_PROFILE_MODELS.gemini)\n return model && usableGemini(model) ? model.id : undefined\n}\n\nexport function maxGrokModel(): string | undefined {\n const model = catalogModel(MAX_PROFILE_MODELS.grok)\n return model && usableGrok(model) ? model.id : undefined\n}\n\n/** Grok replacement for max-profile surfaces that require high effort. */\nexport function maxGrokHighModel(): string | undefined {\n const model = catalogModel(MAX_PROFILE_MODELS.grok)\n return model && usableGrok(model) && supportsEffort(model, \"high\")\n ? model.id\n : undefined\n}\n\n/** Max-only replacement for any standard Gemini Pro assignment. */\nexport function maxProReplacementModel():\n | typeof MAX_PROFILE_MODELS.grok\n | typeof MAX_PROFILE_MODELS.gemini\n | undefined {\n if (maxGrokHighModel()) return MAX_PROFILE_MODELS.grok\n if (maxGeminiModel()) return MAX_PROFILE_MODELS.gemini\n return undefined\n}\n\nexport function maxOpusModel(): string | undefined {\n const model = catalogModel(MAX_PROFILE_MODELS.opus)\n return model && hasContextAtLeast(model, ONE_M_TOKENS)\n && model.capabilities?.supports?.adaptive_thinking === true\n && supportsEffort(model, \"high\")\n && supportsEndpoint(model, \"messages\")\n && hasUsableLimits(model)\n ? model.id\n : undefined\n}\n\nexport function maxCatalogModel(id: string): Model | undefined {\n return catalogModel(id)\n}\n\nexport function maxCatalogModels(): ReadonlyArray<Model> {\n return catalogModels()\n}"],"mappings":";;;AAeA,SAAgB,wBAAwB,IAAgC;CACtE,MAAM,QAAQ,GAAG,MAAM,eAAe;CACtC,IAAI,CAAC,SAAS,MAAM,UAAU,KAAA,GAC5B,OAAO;EAAE,MAAM;EAAI,WAAW;CAAM;CAEtC,OAAO;EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,KAAK;EAAG,WAAW;CAAK;AAC3D;;AAGA,SAAgB,4BAA4B,IAAoB;CAC9D,MAAM,EAAE,MAAM,cAAc,wBAAwB,EAAE;CACtD,OAAO,YAAY,GAAG,KAAK,QAAQ;AACrC;;;ACnBA,MAAM,YAAiE;CACrE,sBAAM,IAAI,IAAI,CAAC,qBAAqB,sBAAsB,CAAC;CAC3D,2BAAW,IAAI,IAAI,CAAC,cAAc,eAAe,CAAC;CAClD,0BAAU,IAAI,IAAI,CAAC,aAAa,cAAc,CAAC;AACjD;;;;;;;;;;AAWA,SAAgB,wBAAwB,SAA2C;CACjF,MAAM,KAAK,QAAQ,QAAQ,iBAAiB,EAAE;CAC9C,IAAI,OAAO,oBAAoB,OAAO;CACtC,IAAI,OAAO,kBAAkB,OAAO,iBAAiB,OAAO,YAC1D,OAAO;CAET,IAAI,OAAO,iBAAiB,OAAO;AAErC;;;;;;AAOA,SAAgB,qBAAqB,OAAwC;CAC3E,MAAM,WAAW,wBAAwB,MAAM,EAAE;CACjD,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,MAAM,aAAa,MAAM;CACzB,IAAI,CAAC,MAAM,QAAQ,UAAU,KAAK,WAAW,WAAW,GAAG,OAAO,KAAA;CAClE,OAAO,WAAW,MAAM,aAAa,UAAU,SAAS,CAAC,IAAI,QAAQ,CAAC,IAClE,WACA,KAAA;AACN;;AAGA,SAAgB,yBACd,SACA,SAC0B;CAC1B,MAAM,QAA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O,SAAS,aAAa,KAAK,IAAI,MAAM,KAAK,KAAA;AACnD;AAEA,SAAgB,eAAmC;CACjD,MAAM,QAAQ,aAAa,mBAAmB,IAAI;CAClD,OAAO,SAAS,WAAW,KAAK,IAAI,MAAM,KAAK,KAAA;AACjD;;AAGA,SAAgB,mBAAuC;CACrD,MAAM,QAAQ,aAAa,mBAAmB,IAAI;CAClD,OAAO,SAAS,WAAW,KAAK,KAAK,eAAe,OAAO,MAAM,IAC7D,MAAM,KACN,KAAA;AACN;;AAGA,SAAgB,yBAGF;CACZ,IAAI,iBAAiB,GAAG,OAAO,mBAAmB;CAClD,IAAI,eAAe,GAAG,OAAO,mBAAmB;AAElD;AAEA,SAAgB,eAAmC;CACjD,MAAM,QAAQ,aAAa,mBAAmB,IAAI;CAClD,OAAO,SAAS,kBAAkB,OAAO,YAAY,KAChD,MAAM,cAAc,UAAU,sBAAsB,QACpD,eAAe,OAAO,MAAM,KAC5B,iBAAiB,OAAO,UAAU,KAClC,gBAAgB,KAAK,IACtB,MAAM,KACN,KAAA;AACN"}
@@ -1,4 +1,4 @@
1
- import { t as buildSelfCommand } from "./self-invocation-DAB_od0C.js";
1
+ import { t as buildSelfCommand } from "./self-invocation-BJWbA8ka.js";
2
2
  //#region src/lib/mcp-workspace-header.ts
3
3
  /** Header the per-session MCP headersHelper emits, carrying the calling Claude
4
4
  * session's working directory. The /mcp handler uses it as the default
@@ -17,4 +17,4 @@ function buildWorkspaceHeaderHelperCommand(invocation) {
17
17
  //#endregion
18
18
  export { buildWorkspaceHeaderHelperCommand as n, buildWorkspaceHeaderJson as r, MCP_WORKSPACE_HEADER as t };
19
19
 
20
- //# sourceMappingURL=mcp-workspace-header-dERl2YTT.js.map
20
+ //# sourceMappingURL=mcp-workspace-header-NzFD0Wgd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-workspace-header-dERl2YTT.js","names":[],"sources":["../src/lib/mcp-workspace-header.ts"],"sourcesContent":["import { buildSelfCommand, type SelfInvocation } from \"./hook-launcher/self-invocation\"\n\n/** Header the per-session MCP headersHelper emits, carrying the calling Claude\n * session's working directory. The /mcp handler uses it as the default\n * `workspace` for repo-scoped tools so a machine-wide `serve` targets the\n * active repo, not the proxy launch cwd. */\nexport const MCP_WORKSPACE_HEADER = \"X-GH-Workspace\"\n\n/** stdout JSON the headersHelper prints; Claude merges it into the connection\n * headers. `cwd` is the helper's own process cwd = the session's project dir. */\nexport function buildWorkspaceHeaderJson(cwd: string): string {\n return JSON.stringify({ [MCP_WORKSPACE_HEADER]: cwd })\n}\n\n/** Command string Claude runs as the headersHelper. */\nexport function buildWorkspaceHeaderHelperCommand(invocation: SelfInvocation): string {\n return buildSelfCommand(invocation, \"internal-workspace-header\")\n}\n"],"mappings":";;;;;;AAMA,MAAa,uBAAuB;;;AAIpC,SAAgB,yBAAyB,KAAqB;CAC5D,OAAO,KAAK,UAAU,GAAG,uBAAuB,IAAI,CAAC;AACvD;;AAGA,SAAgB,kCAAkC,YAAoC;CACpF,OAAO,iBAAiB,YAAY,2BAA2B;AACjE"}
1
+ {"version":3,"file":"mcp-workspace-header-NzFD0Wgd.js","names":[],"sources":["../src/lib/mcp-workspace-header.ts"],"sourcesContent":["import { buildSelfCommand, type SelfInvocation } from \"./hook-launcher/self-invocation\"\n\n/** Header the per-session MCP headersHelper emits, carrying the calling Claude\n * session's working directory. The /mcp handler uses it as the default\n * `workspace` for repo-scoped tools so a machine-wide `serve` targets the\n * active repo, not the proxy launch cwd. */\nexport const MCP_WORKSPACE_HEADER = \"X-GH-Workspace\"\n\n/** stdout JSON the headersHelper prints; Claude merges it into the connection\n * headers. `cwd` is the helper's own process cwd = the session's project dir. */\nexport function buildWorkspaceHeaderJson(cwd: string): string {\n return JSON.stringify({ [MCP_WORKSPACE_HEADER]: cwd })\n}\n\n/** Command string Claude runs as the headersHelper. */\nexport function buildWorkspaceHeaderHelperCommand(invocation: SelfInvocation): string {\n return buildSelfCommand(invocation, \"internal-workspace-header\")\n}\n"],"mappings":";;;;;;AAMA,MAAa,uBAAuB;;;AAIpC,SAAgB,yBAAyB,KAAqB;CAC5D,OAAO,KAAK,UAAU,GAAG,uBAAuB,IAAI,CAAC;AACvD;;AAGA,SAAgB,kCAAkC,YAAoC;CACpF,OAAO,iBAAiB,YAAY,2BAA2B;AACjE"}
@@ -1,5 +1,5 @@
1
- import { i as ensurePaths } from "./paths-Ci485qSJ.js";
2
- import { p as getModels, r as setupGitHubToken, t as setupCopilotToken } from "./token-BtJhjXXu.js";
1
+ import { i as ensurePaths } from "./paths-IcZW8gZx.js";
2
+ import { p as getModels, r as setupGitHubToken, t as setupCopilotToken } from "./token-CbuFyx-B.js";
3
3
  import { defineCommand } from "citty";
4
4
  import consola from "consola";
5
5
  //#region src/models.ts
@@ -160,4 +160,4 @@ function formatTokens(n) {
160
160
  //#endregion
161
161
  export { models };
162
162
 
163
- //# sourceMappingURL=models-DZ4hYsR7.js.map
163
+ //# sourceMappingURL=models-1KwEUgzd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models-DZ4hYsR7.js","names":[],"sources":["../src/models.ts"],"sourcesContent":["import { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { ensurePaths } from \"./lib/paths\"\nimport { setupCopilotToken, setupGitHubToken, type StopCopilotTokenRefresh } from \"./lib/token\"\nimport { getModels, type Model } from \"./services/copilot/get-models\"\n\nexport const models = defineCommand({\n meta: {\n name: \"models\",\n description:\n \"List available GitHub Copilot models and their capabilities. Pass an optional pattern to filter (case-insensitive substring match on id, name, vendor, family).\",\n },\n args: {\n pattern: {\n type: \"positional\",\n required: false,\n description:\n \"Substring to filter models by (matches id, name, vendor, or family).\",\n },\n json: {\n type: \"boolean\",\n default: false,\n description: \"Emit raw JSON instead of the pretty layout.\",\n },\n },\n async run({ args }) {\n await ensurePaths()\n await setupGitHubToken()\n // One-shot command: stop the background refresh loop before returning, so\n // the timer is never what decides whether this process exits. (It is also\n // `unref()`d, so this is belt-and-braces — but ownership stays explicit.)\n let stopRefresh: StopCopilotTokenRefresh | undefined\n try {\n stopRefresh = await setupCopilotToken()\n } catch (err) {\n consola.error(\"Failed to obtain Copilot token:\", err)\n process.exit(1)\n }\n\n try {\n let catalog: Awaited<ReturnType<typeof getModels>>\n try {\n catalog = await getModels()\n } catch (err) {\n consola.error(\"Failed to fetch Copilot model catalog:\", err)\n process.exit(1)\n }\n\n const all = catalog.data\n const pattern = args.pattern?.toString().trim()\n const filtered = pattern ? filterModels(all, pattern) : all\n\n if (args.json) {\n process.stdout.write(`${JSON.stringify(filtered, null, 2)}\\n`)\n return\n }\n\n if (filtered.length === 0) {\n consola.warn(\n `No models matched \"${pattern}\". ${all.length} models available — try a different substring or run without an argument to list everything.`,\n )\n process.exit(1)\n }\n\n const grouped = groupByVendor(filtered)\n const lines: Array<string> = []\n const header = pattern\n ? `${filtered.length}/${all.length} models match \"${pattern}\"`\n : `${all.length} models available`\n lines.push(header)\n lines.push(\"\")\n for (const [vendor, list] of grouped) {\n lines.push(`▾ ${vendor} (${list.length})`)\n for (const model of list) {\n lines.push(...formatModel(model))\n }\n lines.push(\"\")\n }\n process.stdout.write(lines.join(\"\\n\"))\n } finally {\n stopRefresh?.()\n }\n },\n})\n\nfunction filterModels(models: Array<Model>, pattern: string): Array<Model> {\n const needle = pattern.toLowerCase()\n return models.filter((m) => {\n const haystack = [\n m.id,\n m.name,\n m.vendor,\n m.capabilities.family,\n m.capabilities.type,\n m.model_picker_category ?? \"\",\n ]\n .join(\" \")\n .toLowerCase()\n return haystack.includes(needle)\n })\n}\n\nfunction groupByVendor(models: Array<Model>): Array<[string, Array<Model>]> {\n const map = new Map<string, Array<Model>>()\n for (const m of models) {\n const key = m.vendor || \"(unknown vendor)\"\n const bucket = map.get(key)\n if (bucket) bucket.push(m)\n else map.set(key, [m])\n }\n // Stable vendor order: alphabetical for predictability.\n return [...map.entries()].sort(([a], [b]) => a.localeCompare(b))\n}\n\n/**\n * Test-only exports. Not part of the public CLI surface — kept out of\n * the default export so they don't show up in IDE autocomplete on\n * `import { ... } from \"github-router/models\"` consumers.\n */\nexport const __testing = { filterModels, groupByVendor, formatModel, formatTokens }\n\nfunction formatModel(model: Model): Array<string> {\n const lines: Array<string> = []\n const tags: Array<string> = []\n if (model.preview) tags.push(\"preview\")\n if (model.is_chat_default) tags.push(\"chat-default\")\n if (model.is_chat_fallback) tags.push(\"chat-fallback\")\n if (model.billing?.is_premium) tags.push(\"premium\")\n if (model.billing?.restricted_to?.length) {\n tags.push(`restricted:${model.billing.restricted_to.join(\"/\")}`)\n }\n if (model.policy && model.policy.state !== \"enabled\") {\n tags.push(`policy:${model.policy.state}`)\n }\n const tagStr = tags.length > 0 ? ` [${tags.join(\", \")}]` : \"\"\n lines.push(` • ${model.id}${tagStr}`)\n if (model.name && model.name !== model.id) {\n lines.push(` name: ${model.name}`)\n }\n const meta: Array<string> = [\n `family: ${model.capabilities.family}`,\n `type: ${model.capabilities.type}`,\n ]\n if (model.capabilities.tokenizer) {\n meta.push(`tokenizer: ${model.capabilities.tokenizer}`)\n }\n if (model.version) {\n meta.push(`version: ${model.version}`)\n }\n lines.push(` ${meta.join(\" · \")}`)\n\n const limits = model.capabilities.limits\n const limitParts: Array<string> = []\n if (limits) {\n if (limits.max_context_window_tokens) {\n limitParts.push(`ctx ${formatTokens(limits.max_context_window_tokens)}`)\n } else if (limits.max_prompt_tokens) {\n limitParts.push(`prompt ${formatTokens(limits.max_prompt_tokens)}`)\n }\n if (limits.max_output_tokens) {\n limitParts.push(`out ${formatTokens(limits.max_output_tokens)}`)\n }\n if (\n limits.max_non_streaming_output_tokens\n && limits.max_non_streaming_output_tokens !== limits.max_output_tokens\n ) {\n limitParts.push(\n `out-non-stream ${formatTokens(limits.max_non_streaming_output_tokens)}`,\n )\n }\n if (limits.max_inputs) limitParts.push(`inputs ${limits.max_inputs}`)\n if (limits.vision?.max_prompt_images) {\n limitParts.push(`images ${limits.vision.max_prompt_images}`)\n }\n }\n if (limitParts.length > 0) {\n lines.push(` limits: ${limitParts.join(\" · \")}`)\n }\n\n const supports = model.capabilities.supports\n const supportFlags: Array<string> = []\n if (supports) {\n if (supports.tool_calls) supportFlags.push(\"tools\")\n if (supports.parallel_tool_calls) supportFlags.push(\"parallel-tools\")\n if (supports.streaming) supportFlags.push(\"streaming\")\n if (supports.vision) supportFlags.push(\"vision\")\n if (supports.structured_outputs) supportFlags.push(\"structured-outputs\")\n if (supports.dimensions) supportFlags.push(\"dimensions\")\n if (supports.adaptive_thinking) {\n const min = supports.min_thinking_budget\n const max = supports.max_thinking_budget\n const range\n = min !== undefined && max !== undefined\n ? `(${formatTokens(min)}-${formatTokens(max)})`\n : \"\"\n supportFlags.push(`adaptive-thinking${range}`)\n }\n if (supports.reasoning_effort && supports.reasoning_effort.length > 0) {\n supportFlags.push(`reasoning:${supports.reasoning_effort.join(\"/\")}`)\n }\n }\n if (supportFlags.length > 0) {\n lines.push(` supports: ${supportFlags.join(\", \")}`)\n }\n\n if (model.supported_endpoints && model.supported_endpoints.length > 0) {\n lines.push(` endpoints: ${model.supported_endpoints.join(\", \")}`)\n }\n if (model.billing) {\n const billParts: Array<string> = []\n if (model.billing.is_premium) billParts.push(\"premium\")\n if (typeof model.billing.multiplier === \"number\") {\n billParts.push(`×${model.billing.multiplier}`)\n }\n if (billParts.length > 0) {\n lines.push(` billing: ${billParts.join(\" \")}`)\n }\n }\n return lines\n}\n\n/**\n * Format a token count in a compact human-readable form: `1024` →\n * `1k`, `4096` → `4k`, `131072` → `128k`, `1048576` → `1M`. Prefer\n * binary multiples (mebi, kibi) since Claude Code / Copilot context\n * windows are reported in binary units (`1M context` = 1024 × 1024\n * tokens). Fall back to decimal (`64k` for `64000`) when the value\n * is a clean decimal multiple but not binary.\n */\nfunction formatTokens(n: number): string {\n if (n >= 1_048_576 && n % 1_048_576 === 0) return `${n / 1_048_576}M`\n if (n >= 1024 && n % 1024 === 0) return `${n / 1024}k`\n if (n >= 1_000_000 && n % 1_000_000 === 0) return `${n / 1_000_000}M`\n if (n >= 1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QAAS,GAAG,OAAO,GAAG,IAAI,IAAK;CACpD,OAAO,GAAG;AACZ"}
1
+ {"version":3,"file":"models-1KwEUgzd.js","names":[],"sources":["../src/models.ts"],"sourcesContent":["import { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { ensurePaths } from \"./lib/paths\"\nimport { setupCopilotToken, setupGitHubToken, type StopCopilotTokenRefresh } from \"./lib/token\"\nimport { getModels, type Model } from \"./services/copilot/get-models\"\n\nexport const models = defineCommand({\n meta: {\n name: \"models\",\n description:\n \"List available GitHub Copilot models and their capabilities. Pass an optional pattern to filter (case-insensitive substring match on id, name, vendor, family).\",\n },\n args: {\n pattern: {\n type: \"positional\",\n required: false,\n description:\n \"Substring to filter models by (matches id, name, vendor, or family).\",\n },\n json: {\n type: \"boolean\",\n default: false,\n description: \"Emit raw JSON instead of the pretty layout.\",\n },\n },\n async run({ args }) {\n await ensurePaths()\n await setupGitHubToken()\n // One-shot command: stop the background refresh loop before returning, so\n // the timer is never what decides whether this process exits. (It is also\n // `unref()`d, so this is belt-and-braces — but ownership stays explicit.)\n let stopRefresh: StopCopilotTokenRefresh | undefined\n try {\n stopRefresh = await setupCopilotToken()\n } catch (err) {\n consola.error(\"Failed to obtain Copilot token:\", err)\n process.exit(1)\n }\n\n try {\n let catalog: Awaited<ReturnType<typeof getModels>>\n try {\n catalog = await getModels()\n } catch (err) {\n consola.error(\"Failed to fetch Copilot model catalog:\", err)\n process.exit(1)\n }\n\n const all = catalog.data\n const pattern = args.pattern?.toString().trim()\n const filtered = pattern ? filterModels(all, pattern) : all\n\n if (args.json) {\n process.stdout.write(`${JSON.stringify(filtered, null, 2)}\\n`)\n return\n }\n\n if (filtered.length === 0) {\n consola.warn(\n `No models matched \"${pattern}\". ${all.length} models available — try a different substring or run without an argument to list everything.`,\n )\n process.exit(1)\n }\n\n const grouped = groupByVendor(filtered)\n const lines: Array<string> = []\n const header = pattern\n ? `${filtered.length}/${all.length} models match \"${pattern}\"`\n : `${all.length} models available`\n lines.push(header)\n lines.push(\"\")\n for (const [vendor, list] of grouped) {\n lines.push(`▾ ${vendor} (${list.length})`)\n for (const model of list) {\n lines.push(...formatModel(model))\n }\n lines.push(\"\")\n }\n process.stdout.write(lines.join(\"\\n\"))\n } finally {\n stopRefresh?.()\n }\n },\n})\n\nfunction filterModels(models: Array<Model>, pattern: string): Array<Model> {\n const needle = pattern.toLowerCase()\n return models.filter((m) => {\n const haystack = [\n m.id,\n m.name,\n m.vendor,\n m.capabilities.family,\n m.capabilities.type,\n m.model_picker_category ?? \"\",\n ]\n .join(\" \")\n .toLowerCase()\n return haystack.includes(needle)\n })\n}\n\nfunction groupByVendor(models: Array<Model>): Array<[string, Array<Model>]> {\n const map = new Map<string, Array<Model>>()\n for (const m of models) {\n const key = m.vendor || \"(unknown vendor)\"\n const bucket = map.get(key)\n if (bucket) bucket.push(m)\n else map.set(key, [m])\n }\n // Stable vendor order: alphabetical for predictability.\n return [...map.entries()].sort(([a], [b]) => a.localeCompare(b))\n}\n\n/**\n * Test-only exports. Not part of the public CLI surface — kept out of\n * the default export so they don't show up in IDE autocomplete on\n * `import { ... } from \"github-router/models\"` consumers.\n */\nexport const __testing = { filterModels, groupByVendor, formatModel, formatTokens }\n\nfunction formatModel(model: Model): Array<string> {\n const lines: Array<string> = []\n const tags: Array<string> = []\n if (model.preview) tags.push(\"preview\")\n if (model.is_chat_default) tags.push(\"chat-default\")\n if (model.is_chat_fallback) tags.push(\"chat-fallback\")\n if (model.billing?.is_premium) tags.push(\"premium\")\n if (model.billing?.restricted_to?.length) {\n tags.push(`restricted:${model.billing.restricted_to.join(\"/\")}`)\n }\n if (model.policy && model.policy.state !== \"enabled\") {\n tags.push(`policy:${model.policy.state}`)\n }\n const tagStr = tags.length > 0 ? ` [${tags.join(\", \")}]` : \"\"\n lines.push(` • ${model.id}${tagStr}`)\n if (model.name && model.name !== model.id) {\n lines.push(` name: ${model.name}`)\n }\n const meta: Array<string> = [\n `family: ${model.capabilities.family}`,\n `type: ${model.capabilities.type}`,\n ]\n if (model.capabilities.tokenizer) {\n meta.push(`tokenizer: ${model.capabilities.tokenizer}`)\n }\n if (model.version) {\n meta.push(`version: ${model.version}`)\n }\n lines.push(` ${meta.join(\" · \")}`)\n\n const limits = model.capabilities.limits\n const limitParts: Array<string> = []\n if (limits) {\n if (limits.max_context_window_tokens) {\n limitParts.push(`ctx ${formatTokens(limits.max_context_window_tokens)}`)\n } else if (limits.max_prompt_tokens) {\n limitParts.push(`prompt ${formatTokens(limits.max_prompt_tokens)}`)\n }\n if (limits.max_output_tokens) {\n limitParts.push(`out ${formatTokens(limits.max_output_tokens)}`)\n }\n if (\n limits.max_non_streaming_output_tokens\n && limits.max_non_streaming_output_tokens !== limits.max_output_tokens\n ) {\n limitParts.push(\n `out-non-stream ${formatTokens(limits.max_non_streaming_output_tokens)}`,\n )\n }\n if (limits.max_inputs) limitParts.push(`inputs ${limits.max_inputs}`)\n if (limits.vision?.max_prompt_images) {\n limitParts.push(`images ${limits.vision.max_prompt_images}`)\n }\n }\n if (limitParts.length > 0) {\n lines.push(` limits: ${limitParts.join(\" · \")}`)\n }\n\n const supports = model.capabilities.supports\n const supportFlags: Array<string> = []\n if (supports) {\n if (supports.tool_calls) supportFlags.push(\"tools\")\n if (supports.parallel_tool_calls) supportFlags.push(\"parallel-tools\")\n if (supports.streaming) supportFlags.push(\"streaming\")\n if (supports.vision) supportFlags.push(\"vision\")\n if (supports.structured_outputs) supportFlags.push(\"structured-outputs\")\n if (supports.dimensions) supportFlags.push(\"dimensions\")\n if (supports.adaptive_thinking) {\n const min = supports.min_thinking_budget\n const max = supports.max_thinking_budget\n const range\n = min !== undefined && max !== undefined\n ? `(${formatTokens(min)}-${formatTokens(max)})`\n : \"\"\n supportFlags.push(`adaptive-thinking${range}`)\n }\n if (supports.reasoning_effort && supports.reasoning_effort.length > 0) {\n supportFlags.push(`reasoning:${supports.reasoning_effort.join(\"/\")}`)\n }\n }\n if (supportFlags.length > 0) {\n lines.push(` supports: ${supportFlags.join(\", \")}`)\n }\n\n if (model.supported_endpoints && model.supported_endpoints.length > 0) {\n lines.push(` endpoints: ${model.supported_endpoints.join(\", \")}`)\n }\n if (model.billing) {\n const billParts: Array<string> = []\n if (model.billing.is_premium) billParts.push(\"premium\")\n if (typeof model.billing.multiplier === \"number\") {\n billParts.push(`×${model.billing.multiplier}`)\n }\n if (billParts.length > 0) {\n lines.push(` billing: ${billParts.join(\" \")}`)\n }\n }\n return lines\n}\n\n/**\n * Format a token count in a compact human-readable form: `1024` →\n * `1k`, `4096` → `4k`, `131072` → `128k`, `1048576` → `1M`. Prefer\n * binary multiples (mebi, kibi) since Claude Code / Copilot context\n * windows are reported in binary units (`1M context` = 1024 × 1024\n * tokens). Fall back to decimal (`64k` for `64000`) when the value\n * is a clean decimal multiple but not binary.\n */\nfunction formatTokens(n: number): string {\n if (n >= 1_048_576 && n % 1_048_576 === 0) return `${n / 1_048_576}M`\n if (n >= 1024 && n % 1024 === 0) return `${n / 1024}k`\n if (n >= 1_000_000 && n % 1_000_000 === 0) return `${n / 1_000_000}M`\n if (n >= 1000 && n % 1000 === 0) return `${n / 1000}k`\n return `${n}`\n}\n"],"mappings":";;;;;AAOA,MAAa,SAAS,cAAc;CAClC,MAAM;EACJ,MAAM;EACN,aACE;CACJ;CACA,MAAM;EACJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,aACE;EACJ;EACA,MAAM;GACJ,MAAM;GACN,SAAS;GACT,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,YAAY;EAClB,MAAM,iBAAiB;EAIvB,IAAI;EACJ,IAAI;GACF,cAAc,MAAM,kBAAkB;EACxC,SAAS,KAAK;GACZ,QAAQ,MAAM,mCAAmC,GAAG;GACpD,QAAQ,KAAK,CAAC;EAChB;EAEA,IAAI;GACF,IAAI;GACJ,IAAI;IACF,UAAU,MAAM,UAAU;GAC5B,SAAS,KAAK;IACZ,QAAQ,MAAM,0CAA0C,GAAG;IAC3D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aAAa,KAAK,IAAI,GAAG;CAGzD,IAAI,MAAM,uBAAuB,MAAM,oBAAoB,SAAS,GAClE,MAAM,KAAK,oBAAoB,MAAM,oBAAoB,KAAK,IAAI,GAAG;CAEvE,IAAI,MAAM,SAAS;EACjB,MAAM,YAA2B,CAAC;EAClC,IAAI,MAAM,QAAQ,YAAY,UAAU,KAAK,SAAS;EACtD,IAAI,OAAO,MAAM,QAAQ,eAAe,UACtC,UAAU,KAAK,IAAI,MAAM,QAAQ,YAAY;EAE/C,IAAI,UAAU,SAAS,GACrB,MAAM,KAAK,kBAAkB,UAAU,KAAK,GAAG,GAAG;CAEtD;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAS,aAAa,GAAmB;CACvC,IAAI,KAAK,WAAa,IAAI,YAAc,GAAG,OAAO,GAAG,IAAI,QAAU;CACnE,IAAI,KAAK,QAAQ,IAAI,SAAS,GAAG,OAAO,GAAG,IAAI,KAAK;CACpD,IAAI,KAAK,OAAa,IAAI,QAAc,GAAG,OAAO,GAAG,IAAI,IAAU;CACnE,IAAI,KAAK,OAAQ,IAAI,QAAS,GAAG,OAAO,GAAG,IAAI,IAAK;CACpD,OAAO,GAAG;AACZ"}
@@ -1,5 +1,5 @@
1
1
  import { i as parseIntEnv, o as runCommandCapture } from "./exec-y8C_MU8A.js";
2
- import "./stop-gate-hook-DQnh_KfI.js";
2
+ import "./stop-gate-hook-CJOk28zd.js";
3
3
  //#region src/lib/orchestration/live-exec.ts
4
4
  /**
5
5
  * Live `ExecFn` for the gate runner — runs the kernel's SEALED gate command in a
@@ -36,4 +36,4 @@ const liveExec = async ({ command, cwd }) => {
36
36
  //#endregion
37
37
  export { liveExec as t };
38
38
 
39
- //# sourceMappingURL=orchestration-BiGCEwbH.js.map
39
+ //# sourceMappingURL=orchestration-CYyp9w-t.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration-BiGCEwbH.js","names":[],"sources":["../src/lib/orchestration/live-exec.ts"],"sourcesContent":["/**\n * Live `ExecFn` for the gate runner — runs the kernel's SEALED gate command in a\n * workspace via the project's Windows-safe exec helper (`runCommandCapture` →\n * `buildExecInvocation`, which handles cmd.exe quoting on Windows). Only the\n * kernel's sealed gate commands flow through here (tests/types/lint/build),\n * never a producer-authored string, so a simple whitespace split into argv is\n * safe for these fixed commands. A command that can't run (spawn error / killed)\n * counts as a non-zero exit, never a throw — the gate runner treats it as\n * not-passed.\n *\n * This is the one piece of the gate engine that touches a real subprocess; it is\n * model-free and cross-platform, so it is exercised directly in CI (unlike the\n * worker/worktree/model adapters, which need the gated E2E harness).\n */\n\nimport { runCommandCapture } from \"~/lib/exec\"\n\nimport { type ExecFn } from \"./gate-runner\"\nimport { parseIntEnv } from \"../exec\"\n\n/** Per-command wall-clock cap so a hung gate command (watch-mode test, a process\n * waiting on stdin, a stale lockfile) is tree-killed instead of hanging the\n * caller forever. Generous (a real typecheck/test/lint can take minutes) but\n * bounded; override with GH_ROUTER_GATE_CMD_TIMEOUT_MS. A timeout kills the\n * command (code null) which the gate runner treats as not-passed. */\nconst CMD_TIMEOUT_MS =\n parseIntEnv(process.env.GH_ROUTER_GATE_CMD_TIMEOUT_MS) ?? 600_000\n\nexport const liveExec: ExecFn = async ({ command, cwd }) => {\n const argv = command.trim().split(/\\s+/).filter(Boolean)\n if (argv.length === 0) return { exitCode: 1 }\n try {\n const r = await runCommandCapture(argv, { cwd, timeoutMs: CMD_TIMEOUT_MS })\n // `code` is null when killed by signal/timeout → treat as a failed gate.\n return { exitCode: r.code ?? 1 }\n } catch {\n return { exitCode: 1 }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,iBACJ,YAAY,QAAQ,IAAI,6BAA6B,KAAK;AAE5D,MAAa,WAAmB,OAAO,EAAE,SAAS,UAAU;CAC1D,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CACvD,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,UAAU,EAAE;CAC5C,IAAI;EAGF,OAAO,EAAE,WAAU,MAFH,kBAAkB,MAAM;GAAE;GAAK,WAAW;EAAe,CAAC,EAAA,CAErD,QAAQ,EAAE;CACjC,QAAQ;EACN,OAAO,EAAE,UAAU,EAAE;CACvB;AACF"}
1
+ {"version":3,"file":"orchestration-CYyp9w-t.js","names":[],"sources":["../src/lib/orchestration/live-exec.ts"],"sourcesContent":["/**\n * Live `ExecFn` for the gate runner — runs the kernel's SEALED gate command in a\n * workspace via the project's Windows-safe exec helper (`runCommandCapture` →\n * `buildExecInvocation`, which handles cmd.exe quoting on Windows). Only the\n * kernel's sealed gate commands flow through here (tests/types/lint/build),\n * never a producer-authored string, so a simple whitespace split into argv is\n * safe for these fixed commands. A command that can't run (spawn error / killed)\n * counts as a non-zero exit, never a throw — the gate runner treats it as\n * not-passed.\n *\n * This is the one piece of the gate engine that touches a real subprocess; it is\n * model-free and cross-platform, so it is exercised directly in CI (unlike the\n * worker/worktree/model adapters, which need the gated E2E harness).\n */\n\nimport { runCommandCapture } from \"~/lib/exec\"\n\nimport { type ExecFn } from \"./gate-runner\"\nimport { parseIntEnv } from \"../exec\"\n\n/** Per-command wall-clock cap so a hung gate command (watch-mode test, a process\n * waiting on stdin, a stale lockfile) is tree-killed instead of hanging the\n * caller forever. Generous (a real typecheck/test/lint can take minutes) but\n * bounded; override with GH_ROUTER_GATE_CMD_TIMEOUT_MS. A timeout kills the\n * command (code null) which the gate runner treats as not-passed. */\nconst CMD_TIMEOUT_MS =\n parseIntEnv(process.env.GH_ROUTER_GATE_CMD_TIMEOUT_MS) ?? 600_000\n\nexport const liveExec: ExecFn = async ({ command, cwd }) => {\n const argv = command.trim().split(/\\s+/).filter(Boolean)\n if (argv.length === 0) return { exitCode: 1 }\n try {\n const r = await runCommandCapture(argv, { cwd, timeoutMs: CMD_TIMEOUT_MS })\n // `code` is null when killed by signal/timeout → treat as a failed gate.\n return { exitCode: r.code ?? 1 }\n } catch {\n return { exitCode: 1 }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,iBACJ,YAAY,QAAQ,IAAI,6BAA6B,KAAK;AAE5D,MAAa,WAAmB,OAAO,EAAE,SAAS,UAAU;CAC1D,MAAM,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;CACvD,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,UAAU,EAAE;CAC5C,IAAI;EAGF,OAAO,EAAE,WAAU,MAFH,kBAAkB,MAAM;GAAE;GAAK,WAAW;EAAe,CAAC,EAAA,CAErD,QAAQ,EAAE;CACjC,QAAQ;EACN,OAAO,EAAE,UAAU,EAAE;CACvB;AACF"}
@@ -0,0 +1,2 @@
1
+ import { t as PATHS } from "./paths-IcZW8gZx.js";
2
+ export { PATHS };
@@ -245,12 +245,12 @@ async function ensurePaths() {
245
245
  consola.debug("Peer-agent .md sweep skipped:", err);
246
246
  });
247
247
  await (async () => {
248
- await (await import("./lifecycle-CGLt1cJQ.js")).sweepStaleWorktreesAtBoot();
248
+ await (await import("./lifecycle-4TZrJuAa.js")).sweepStaleWorktreesAtBoot();
249
249
  })().catch((err) => {
250
250
  consola.debug("Worker worktree boot sweep skipped:", err);
251
251
  });
252
252
  await (async () => {
253
- await (await import("./lifecycle-DoUwpVDB.js")).sweepStaleColbertMetaAtBoot();
253
+ await (await import("./lifecycle-O91Vzzb-.js")).sweepStaleColbertMetaAtBoot();
254
254
  })().catch((err) => {
255
255
  consola.debug("ColBERT meta boot sweep skipped:", err);
256
256
  });
@@ -1095,7 +1095,7 @@ async function sweepStalePeerAgentMdFiles() {
1095
1095
  * previously absent here, so their stale files never got reaped. Note the capitals:
1096
1096
  * the alternation is case-sensitive and those two are capitalized at the source.
1097
1097
  */
1098
- const PEER_AGENT_MD_FILENAME = /^peer-(\d+)-[0-9a-f]{8}-(?:codex-critic|codex-reviewer|gemini-critic|gemini-reviewer|opus-critic|codex-implementer|peer-review-coordinator|implementer-fast|implementer|planner|reviewer|reviewer-fast|brainstorm|scout|scribe|general-purpose-fast|critic|generic-fast|generic-cheap|generic|debugger|qa-engineer|general-purpose|Explore|Plan|worker-explore|worker-implement|worker-review|worker-plan|worker-test|worker-browse)\.md$/;
1098
+ const PEER_AGENT_MD_FILENAME = /^peer-(\d+)-[0-9a-f]{8}-(?:codex-critic|codex-reviewer|gemini-critic|gemini-reviewer|opus-critic|sol-critic|luna-reviewer|grok-critic|grok-reviewer|codex-implementer|peer-review-coordinator|implementer-fast|implementer|planner|reviewer|reviewer-fast|brainstorm|scout|scribe|general-purpose-fast|critic|generic-fast|generic-cheap|generic|debugger|qa-engineer|general-purpose|Explore|Plan|worker-explore|worker-implement|worker-review|worker-plan|worker-test|worker-browse)\.md$/;
1099
1099
  /**
1100
1100
  * Strict regex matching only per-launch claude-config mirror dirs this
1101
1101
  * proxy creates: `<pid>-<8 hex>`. Anchored to the entire entry name so
@@ -1166,4 +1166,4 @@ async function removeOwnClaudeConfigMirror() {
1166
1166
  //#endregion
1167
1167
  export { isUnderClaudeConfigMirror as a, sweepStalePeerAgentMdFiles as c, writeRuntimeFileSecure as d, ensurePaths as i, sweepStaleRuntimeFiles as l, PEER_AGENT_MD_FILENAME as n, removeOwnClaudeConfigMirror as o, ensureClaudeConfigMirror as r, sweepStaleClaudeConfigMirrors as s, PATHS as t, writeArtifactCredsToMirror as u };
1168
1168
 
1169
- //# sourceMappingURL=paths-Ci485qSJ.js.map
1169
+ //# sourceMappingURL=paths-IcZW8gZx.js.map