github-router 0.3.378 → 0.3.380

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 (164) hide show
  1. package/README.md +62 -0
  2. package/dist/ado-tools-CsfbnY8x.js +1 -0
  3. package/dist/{aic-ledger-CeSXqTEE.js → aic-ledger-6GKI28nY.js} +3 -3
  4. package/dist/{aic-ledger-CeSXqTEE.js.map → aic-ledger-6GKI28nY.js.map} +1 -1
  5. package/dist/{aic-statusline-settings-BKveu679.js → aic-statusline-settings-wLL1l_Z6.js} +2 -2
  6. package/dist/{aic-statusline-settings-BKveu679.js.map → aic-statusline-settings-wLL1l_Z6.js.map} +1 -1
  7. package/dist/atomic-file-Dif1kLKM.js +198 -0
  8. package/dist/atomic-file-Dif1kLKM.js.map +1 -0
  9. package/dist/{attribution-settings-BR5Umj2L.js → attribution-settings-BJ1fjX7V.js} +10 -10
  10. package/dist/{attribution-settings-BR5Umj2L.js.map → attribution-settings-BJ1fjX7V.js.map} +1 -1
  11. package/dist/{auth-BZHpTtfF.js → auth-5TKcQbbH.js} +3 -3
  12. package/dist/{auth-BZHpTtfF.js.map → auth-5TKcQbbH.js.map} +1 -1
  13. package/dist/bin.js +1479 -0
  14. package/dist/bin.js.map +1 -0
  15. package/dist/browser-ext/manifest.json +1 -1
  16. package/dist/{check-usage-BlIWDuV2.js → check-usage-DM39fdel.js} +4 -4
  17. package/dist/{check-usage-BlIWDuV2.js.map → check-usage-DM39fdel.js.map} +1 -1
  18. package/dist/{claude--4O3wHRq.js → claude-BWwkOMi3.js} +26 -25
  19. package/dist/{claude--4O3wHRq.js.map → claude-BWwkOMi3.js.map} +1 -1
  20. package/dist/{claude-md-injection-Biq_Xhve.js → claude-md-injection-DNMDcw1W.js} +15 -24
  21. package/dist/claude-md-injection-DNMDcw1W.js.map +1 -0
  22. package/dist/{codex-DHRMLpSo.js → codex-C6ix3BaY.js} +8 -7
  23. package/dist/{codex-DHRMLpSo.js.map → codex-C6ix3BaY.js.map} +1 -1
  24. package/dist/{copilot-discount-UXC6NQbN.js → copilot-discount-DM98PuAF.js} +2 -2
  25. package/dist/{copilot-discount-UXC6NQbN.js.map → copilot-discount-DM98PuAF.js.map} +1 -1
  26. package/dist/{debug-1HUHCWFl.js → debug-Df0Kuzi3.js} +2 -2
  27. package/dist/{debug-1HUHCWFl.js.map → debug-Df0Kuzi3.js.map} +1 -1
  28. package/dist/diagnostics-cXjCT_JQ.js +12 -0
  29. package/dist/diagnostics-cXjCT_JQ.js.map +1 -0
  30. package/dist/engine-B6la_uIW.js +1 -0
  31. package/dist/{gate-discovery-DjH9YXoN.js → gate-discovery-2ILpM2fi.js} +5 -5
  32. package/dist/{gate-discovery-DjH9YXoN.js.map → gate-discovery-2ILpM2fi.js.map} +1 -1
  33. package/dist/{get-copilot-usage-CKg42gSH.js → get-copilot-usage-BZ6t2hFZ.js} +2 -2
  34. package/dist/{get-copilot-usage-CKg42gSH.js.map → get-copilot-usage-BZ6t2hFZ.js.map} +1 -1
  35. package/dist/hooks.mjs +13 -0
  36. package/dist/hooks.sha256 +1 -1
  37. package/dist/{index-cmd-sKwchRJz.js → index-cmd-DsK6VFs8.js} +4 -4
  38. package/dist/{index-cmd-sKwchRJz.js.map → index-cmd-DsK6VFs8.js.map} +1 -1
  39. package/dist/{internal-aic-status-B_hEeM37.js → internal-aic-status-CUZ7-trf.js} +3 -3
  40. package/dist/{internal-aic-status-B_hEeM37.js.map → internal-aic-status-CUZ7-trf.js.map} +1 -1
  41. package/dist/{internal-artifact-open-DbHjipxU.js → internal-artifact-open-DRBg1PpV.js} +2 -2
  42. package/dist/{internal-artifact-open-DbHjipxU.js.map → internal-artifact-open-DRBg1PpV.js.map} +1 -1
  43. package/dist/{internal-fast-dispatch-guard-DMzqs-r8.js → internal-fast-dispatch-guard-D6-Ees_6.js} +1 -1
  44. package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js → internal-fast-dispatch-guard-ZeS9u0A3.js} +2 -2
  45. package/dist/{internal-fast-dispatch-guard-PDdlkPU3.js.map → internal-fast-dispatch-guard-ZeS9u0A3.js.map} +1 -1
  46. package/dist/{internal-first-mate-guard-BxPDUsV3.js → internal-first-mate-guard-BijeVpi9.js} +1 -1
  47. package/dist/{internal-first-mate-guard-4Yro9xNM.js → internal-first-mate-guard-DsEEsLKJ.js} +3 -3
  48. package/dist/{internal-first-mate-guard-4Yro9xNM.js.map → internal-first-mate-guard-DsEEsLKJ.js.map} +1 -1
  49. package/dist/{internal-max-dispatch-guard-0teaxIc1.js → internal-max-dispatch-guard-4RLca1i5.js} +2 -2
  50. package/dist/{internal-max-dispatch-guard-0teaxIc1.js.map → internal-max-dispatch-guard-4RLca1i5.js.map} +1 -1
  51. package/dist/{internal-max-dispatch-guard-5LSaHN_y.js → internal-max-dispatch-guard-DeEfWqfP.js} +1 -1
  52. package/dist/{internal-plan-review-BfHLeszV.js → internal-plan-review-bzqGNdtw.js} +3 -3
  53. package/dist/{internal-plan-review-BfHLeszV.js.map → internal-plan-review-bzqGNdtw.js.map} +1 -1
  54. package/dist/{internal-prompt-submit-BixNLmM3.js → internal-prompt-submit-BZ2-CExM.js} +4 -4
  55. package/dist/{internal-prompt-submit-BixNLmM3.js.map → internal-prompt-submit-BZ2-CExM.js.map} +1 -1
  56. package/dist/{internal-prompt-submit-Ou8xtRXj.js → internal-prompt-submit-ZBhH-SQ1.js} +2 -2
  57. package/dist/{internal-rebrief-BBGM0PMv.js → internal-rebrief-BIWbN7Sr.js} +4 -4
  58. package/dist/{internal-rebrief-BBGM0PMv.js.map → internal-rebrief-BIWbN7Sr.js.map} +1 -1
  59. package/dist/{internal-session-bind-pN1V11Mn.js → internal-session-bind-BL6hFRLO.js} +2 -2
  60. package/dist/{internal-session-bind-pN1V11Mn.js.map → internal-session-bind-BL6hFRLO.js.map} +1 -1
  61. package/dist/{internal-stop-hook-DO9Iiaes.js → internal-stop-hook-cDF1MuJZ.js} +5 -5
  62. package/dist/{internal-stop-hook-DO9Iiaes.js.map → internal-stop-hook-cDF1MuJZ.js.map} +1 -1
  63. package/dist/{internal-stop-review-BWp-4XWW.js → internal-stop-review-y8zjpK_3.js} +2 -2
  64. package/dist/{internal-stop-review-BWp-4XWW.js.map → internal-stop-review-y8zjpK_3.js.map} +1 -1
  65. package/dist/{internal-worker-guard-C9OZPgzu.js → internal-worker-guard-DdyYBZR0.js} +2 -2
  66. package/dist/{internal-worker-guard-C9OZPgzu.js.map → internal-worker-guard-DdyYBZR0.js.map} +1 -1
  67. package/dist/{internal-workspace-header-B4TXFBLU.js → internal-workspace-header-BMKbO8yX.js} +2 -2
  68. package/dist/{internal-workspace-header-B4TXFBLU.js.map → internal-workspace-header-BMKbO8yX.js.map} +1 -1
  69. package/dist/lib/tree-sitter-pool/worker.js +268 -21
  70. package/dist/lifecycle-BOjgq9_l.js +1 -0
  71. package/dist/{lifecycle-vjHAFCaY.js → lifecycle-BlC_kzNt.js} +2 -2
  72. package/dist/{lifecycle-vjHAFCaY.js.map → lifecycle-BlC_kzNt.js.map} +1 -1
  73. package/dist/{lifecycle-Dh9y8OF1.js → lifecycle-COZhARmE.js} +2 -2
  74. package/dist/{lifecycle-Dh9y8OF1.js.map → lifecycle-COZhARmE.js.map} +1 -1
  75. package/dist/lifecycle-NQvr4flt.js +1 -0
  76. package/dist/main.js +39 -24
  77. package/dist/main.js.map +1 -1
  78. package/dist/{mcp-workspace-header-C5-dOWNa.js → mcp-workspace-header-Bpa4BId8.js} +2 -2
  79. package/dist/{mcp-workspace-header-C5-dOWNa.js.map → mcp-workspace-header-Bpa4BId8.js.map} +1 -1
  80. package/dist/{models-B6nH1sS6.js → models-BDV-YLf2.js} +3 -3
  81. package/dist/{models-B6nH1sS6.js.map → models-BDV-YLf2.js.map} +1 -1
  82. package/dist/npm-env-H60tX76c.js +130 -0
  83. package/dist/npm-env-H60tX76c.js.map +1 -0
  84. package/dist/optional-DGAeyguL.js +586 -0
  85. package/dist/optional-DGAeyguL.js.map +1 -0
  86. package/dist/{orchestration-B93jxrWI.js → orchestration-Bto5Nc1Y.js} +2 -2
  87. package/dist/{orchestration-B93jxrWI.js.map → orchestration-Bto5Nc1Y.js.map} +1 -1
  88. package/dist/origin-BXtpcKP9.js +382 -0
  89. package/dist/origin-BXtpcKP9.js.map +1 -0
  90. package/dist/origin-DbFUCiGp.js +1 -0
  91. package/dist/paths-CquOjytP.js +1 -0
  92. package/dist/paths-DK_b2ihK.js +176 -0
  93. package/dist/paths-DK_b2ihK.js.map +1 -0
  94. package/dist/{paths-CVEO8jEH.js → paths-DeFmYJhO.js} +16 -3
  95. package/dist/paths-DeFmYJhO.js.map +1 -0
  96. package/dist/{peer-mcp-personas-OWsSm6To.js → peer-mcp-personas-Dny0r5Am.js} +14 -14
  97. package/dist/{peer-mcp-personas-OWsSm6To.js.map → peer-mcp-personas-Dny0r5Am.js.map} +1 -1
  98. package/dist/{pi-B0EFY6l7.js → pi-YhoA26wi.js} +718 -119
  99. package/dist/pi-YhoA26wi.js.map +1 -0
  100. package/dist/pi-foreign-artifacts-CNt6wQ1P.js +660 -0
  101. package/dist/pi-foreign-artifacts-CNt6wQ1P.js.map +1 -0
  102. package/dist/pi-memory-bridge-BxmCIIbk.js +618 -0
  103. package/dist/pi-memory-bridge-BxmCIIbk.js.map +1 -0
  104. package/dist/pi-memory-bridge-D5A0h_Kf.js +1 -0
  105. package/dist/pi-version-check-BeBB0Ny9.js +551 -0
  106. package/dist/pi-version-check-BeBB0Ny9.js.map +1 -0
  107. package/dist/pi-version-check-D5RvdLsG.js +1 -0
  108. package/dist/{plan-review-hook-MhjK92wq.js → plan-review-hook-D_yyjOgO.js} +3 -3
  109. package/dist/{plan-review-hook-MhjK92wq.js.map → plan-review-hook-D_yyjOgO.js.map} +1 -1
  110. package/dist/{provision-DPL8aGe2.js → provision-BWtuDq_v.js} +30 -36
  111. package/dist/provision-BWtuDq_v.js.map +1 -0
  112. package/dist/rerank-cross-encoder-BhjImuwG.js +192 -0
  113. package/dist/rerank-cross-encoder-BhjImuwG.js.map +1 -0
  114. package/dist/{self-invocation-DMUnXVGT.js → self-invocation-Dnq4iVD6.js} +4 -31
  115. package/dist/{self-invocation-DMUnXVGT.js.map → self-invocation-Dnq4iVD6.js.map} +1 -1
  116. package/dist/{serve-C13q-9w0.js → serve-DrHAX2Bh.js} +15 -14
  117. package/dist/{serve-C13q-9w0.js.map → serve-DrHAX2Bh.js.map} +1 -1
  118. package/dist/{server-setup-CptI7SUT.js → server-setup-DLwejgVA.js} +12 -638
  119. package/dist/server-setup-DLwejgVA.js.map +1 -0
  120. package/dist/{service-backend-Cdgz6WPx.js → service-backend-BdhWVRSz.js} +17 -62
  121. package/dist/service-backend-BdhWVRSz.js.map +1 -0
  122. package/dist/{start-DioCGjM8.js → start-DvV3Lbwy.js} +5 -4
  123. package/dist/{start-DioCGjM8.js.map → start-DvV3Lbwy.js.map} +1 -1
  124. package/dist/{static-context-pack-CtnBwHSd.js → static-context-pack-BKFelEbM.js} +3 -3
  125. package/dist/{static-context-pack-CtnBwHSd.js.map → static-context-pack-BKFelEbM.js.map} +1 -1
  126. package/dist/{stop-gate-hook-CBVLD8iB.js → stop-gate-hook-DBOj0TqL.js} +3 -3
  127. package/dist/{stop-gate-hook-CBVLD8iB.js.map → stop-gate-hook-DBOj0TqL.js.map} +1 -1
  128. package/dist/{stop-gate-policy-BehNiNix.js → stop-gate-policy-Bp2wGh_W.js} +2 -2
  129. package/dist/{stop-gate-policy-BehNiNix.js.map → stop-gate-policy-Bp2wGh_W.js.map} +1 -1
  130. package/dist/{token-CPzYxU4Y.js → token-CKPOBdO0.js} +23 -88
  131. package/dist/{token-CPzYxU4Y.js.map → token-CKPOBdO0.js.map} +1 -1
  132. package/dist/{token-DHEkiO4g.js → token-Ygd7D32L.js} +3 -3
  133. package/dist/{token-DHEkiO4g.js.map → token-Ygd7D32L.js.map} +1 -1
  134. package/dist/update-CB21YRKz.js +1 -0
  135. package/dist/update-T1L7yFon.js +1548 -0
  136. package/dist/update-T1L7yFon.js.map +1 -0
  137. package/dist/update-fEgWTrIx.js +214 -0
  138. package/dist/update-fEgWTrIx.js.map +1 -0
  139. package/dist/update-lock-BeS_WmC8.js +1 -0
  140. package/dist/update-lock-BmXx6QaR.js +171 -0
  141. package/dist/update-lock-BmXx6QaR.js.map +1 -0
  142. package/dist/volatile-root-DQNNvQ7Z.js +50 -0
  143. package/dist/volatile-root-DQNNvQ7Z.js.map +1 -0
  144. package/dist/{worker-dispatch-C7RtNOXv.js → worker-dispatch-DBWKTMda.js} +2 -2
  145. package/dist/{worker-dispatch-C7RtNOXv.js.map → worker-dispatch-DBWKTMda.js.map} +1 -1
  146. package/dist/{workiq-CQauEAMc.js → workiq-D5b7xlbr.js} +2 -2
  147. package/dist/{workiq-CQauEAMc.js.map → workiq-D5b7xlbr.js.map} +1 -1
  148. package/dist/{workiq-tools-DL6rC4bP.js → workiq-tools-DdiQ2DOW.js} +1 -1
  149. package/package.json +16 -4
  150. package/dist/ado-tools-CRkyU51J.js +0 -1
  151. package/dist/claude-md-injection-Biq_Xhve.js.map +0 -1
  152. package/dist/engine-V46un8Xl.js +0 -1
  153. package/dist/lifecycle-BENRuuX6.js +0 -1
  154. package/dist/lifecycle-Dli9vGI2.js +0 -1
  155. package/dist/paths-Be9_ujQ3.js +0 -1
  156. package/dist/paths-CVEO8jEH.js.map +0 -1
  157. package/dist/pi-B0EFY6l7.js.map +0 -1
  158. package/dist/pi-memory-bridge-Dvj1T3e3.js +0 -403
  159. package/dist/pi-memory-bridge-Dvj1T3e3.js.map +0 -1
  160. package/dist/provision-DPL8aGe2.js.map +0 -1
  161. package/dist/rerank-cross-encoder-B87lZgvc.js +0 -110
  162. package/dist/rerank-cross-encoder-B87lZgvc.js.map +0 -1
  163. package/dist/server-setup-CptI7SUT.js.map +0 -1
  164. package/dist/service-backend-Cdgz6WPx.js.map +0 -1
@@ -1,18 +1,18 @@
1
- import { t as getPackageVersion } from "./version-CTqwKr26.js";
2
- import { i as ensurePaths, t as PATHS } from "./paths-CVEO8jEH.js";
1
+ import { i as ensurePaths, t as PATHS } from "./paths-DeFmYJhO.js";
3
2
  import { t as state } from "./state-CCGDJ43X.js";
4
- import { C as copilotHeaders, S as copilotBaseUrl, c as cacheVSCodeVersion, f as resolveModel, i as tryRefreshAndRetry, l as filterBetaHeader, n as setupGitHubAgentToken, o as cacheCopilotVersion, p as sleep, r as setupGitHubToken, s as cacheModels, t as setupCopilotToken, u as isNullish, v as HTTPError, y as forwardError } from "./token-CPzYxU4Y.js";
3
+ import { C as copilotHeaders, S as copilotBaseUrl, c as cacheVSCodeVersion, f as resolveModel, i as tryRefreshAndRetry, l as filterBetaHeader, n as setupGitHubAgentToken, o as cacheCopilotVersion, p as sleep, r as setupGitHubToken, s as cacheModels, t as setupCopilotToken, u as isNullish, v as HTTPError, y as forwardError } from "./token-CKPOBdO0.js";
5
4
  import { r as fetchWithTransientRetry } from "./upstream-retry-VNR-bCuT.js";
6
- import { t as getCopilotUsage } from "./get-copilot-usage-CKg42gSH.js";
7
- import { a as parseBoolEnv, c as runCommandCapture, i as killManagedTree, s as resolveExecutable, u as runCommandVoid } from "./exec-BC0MAnoA.js";
8
- import { I as provisionTreeSitterAssets, L as withInstallLock } from "./service-backend-Cdgz6WPx.js";
5
+ import { t as getCopilotUsage } from "./get-copilot-usage-BZ6t2hFZ.js";
6
+ import { a as parseBoolEnv, i as killManagedTree, s as resolveExecutable } from "./exec-BC0MAnoA.js";
7
+ import { l as resolvePiRegistry } from "./pi-version-check-BeBB0Ny9.js";
9
8
  import { c as FAST_PROFILE_MODELS, l as FAST_PROFILE_NATIVE_AGENT_NAMES, r as FAST_PROFILE_ADVISOR_MODEL } from "./fast-profile-contract-BLnKg0Ay.js";
10
- import { $ as buildAnthropicErrorEvent, An as parseJsonOrDiagnose, B as FAST_ADVISOR_TOOL_INSTRUCTIONS, Cn as assembleResponsesPayload, Ct as ADO_DEFAULT_TOOLSETS, D as toolbeltEnabled, Dn as createChatCompletions, En as createResponses, Et as agentToolsEnabled, F as ADVISOR_TOOL_INSTRUCTIONS, Fn as normalizeKustoClusterUri, G as isAdvisorRequested, H as LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, I as CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS, J as resolveCuratedAdvisorModel, K as resolveAdvisorEffort, L as CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, N as searchWeb, On as MAX_RESPONSE_BODY_BYTES, P as ADVISOR_INTERNAL_TOOL_NAME, Pn as normalizeCloudAgentEnvironment, Q as repairRejectedThinkingHistory, R as CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS, Rn as assertCopilotModelAllowed, St as provisionAdoTools, Tn as resolveMcpToolTimeoutMs, U as buildAdvisorStream, V as LOCAL_ADVISOR_TOOL_INSTRUCTIONS, W as injectAdvisorTool, X as rememberThinkingHistoryRepair, Y as formatThinkingRepairDecline, Yn as BUDGET_SMALL_FAST_SLUG, Z as repairKnownThinkingHistory, _n as LAUNCH_BOUND_TOKEN_PREFIX, _t as provisionWorkiqTools, at as EFFORT_ORDER, cn as shimDefaultsToXhigh, cr as classifyMessagesRoute, ct as clampEffort, dn as getTokenizerFromModel, dr as withOneMSuffix, dt as normalizeAnthropicUsageInPlace, er as UPSTREAM_FETCH_TIMEOUT_MS, et as buildOpenAIErrorEvent, fr as withOneMSuffixForLead, ft as handleMcpDelete, gn as createMessages, hn as countTokens, hr as CHEAP_PROFILE_NATIVE_AGENT_NAMES, i as assertMcpToolSurfaceConsistent, it as relayAnthropicStream, jn as normalizeOpenAIUsage, kn as readResponseBodyCapped, ln as getTextTokenCount, lr as catalogAdvertises1M, lt as anthropicUsageNormalizeDisabled, mn as localSessionId, mr as CHEAP_PROFILE_MODELS, nr as generateRandomPort, nt as logStreamError, or as upstreamAllowH2, ot as UNKNOWN_EFFORT_ANCHOR, pn as localBaseUrl, pr as CHEAP_PROFILE_ADVISOR_CLIENT_MODEL, pt as handleMcpPost, q as resolveAdvisorModel, qn as toolbeltPathOverride, rr as isBudgetClaudeLead, rt as readIteratorWithTimeout, sr as upstreamMaxConnections, st as bucketEffort, tr as UPSTREAM_INACTIVITY_TIMEOUT_MS, tt as isControllerClosedError, un as getTokenCount, ur as oneMContextDisabled, ut as createAnthropicUsageRewriteTransform, vn as findLaunchBySecret, vr as CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS, wn as warnOnTokenPriceDrift, wt as normalizeAdoToolsets, xn as rememberLaunchSessionId, z as CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, zn as effectiveLocalProfile } from "./peer-mcp-personas-OWsSm6To.js";
11
- import { C as localContractFor, I as CHEAPEST_PROFILE_MODELS, L as CHEAPEST_PROFILE_NATIVE_AGENT_NAMES, O as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, g as displayModelName, j as CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL, p as cheapestContractFor, v as isCheapestFamily, x as isPinnedLaunchProfile } from "./static-context-pack-CtnBwHSd.js";
9
+ import { $ as buildAnthropicErrorEvent, An as parseJsonOrDiagnose, B as FAST_ADVISOR_TOOL_INSTRUCTIONS, Cn as assembleResponsesPayload, Ct as ADO_DEFAULT_TOOLSETS, D as toolbeltEnabled, Dn as createChatCompletions, En as createResponses, Et as agentToolsEnabled, F as ADVISOR_TOOL_INSTRUCTIONS, Fn as normalizeKustoClusterUri, G as isAdvisorRequested, H as LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, I as CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS, J as resolveCuratedAdvisorModel, K as resolveAdvisorEffort, L as CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, N as searchWeb, On as MAX_RESPONSE_BODY_BYTES, P as ADVISOR_INTERNAL_TOOL_NAME, Pn as normalizeCloudAgentEnvironment, Q as repairRejectedThinkingHistory, R as CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS, Rn as assertCopilotModelAllowed, St as provisionAdoTools, Tn as resolveMcpToolTimeoutMs, U as buildAdvisorStream, V as LOCAL_ADVISOR_TOOL_INSTRUCTIONS, W as injectAdvisorTool, X as rememberThinkingHistoryRepair, Y as formatThinkingRepairDecline, Yn as BUDGET_SMALL_FAST_SLUG, Z as repairKnownThinkingHistory, _n as LAUNCH_BOUND_TOKEN_PREFIX, _t as provisionWorkiqTools, at as EFFORT_ORDER, cn as shimDefaultsToXhigh, cr as classifyMessagesRoute, ct as clampEffort, dn as getTokenizerFromModel, dr as withOneMSuffix, dt as normalizeAnthropicUsageInPlace, er as UPSTREAM_FETCH_TIMEOUT_MS, et as buildOpenAIErrorEvent, fr as withOneMSuffixForLead, ft as handleMcpDelete, gn as createMessages, hn as countTokens, hr as CHEAP_PROFILE_NATIVE_AGENT_NAMES, i as assertMcpToolSurfaceConsistent, it as relayAnthropicStream, jn as normalizeOpenAIUsage, kn as readResponseBodyCapped, ln as getTextTokenCount, lr as catalogAdvertises1M, lt as anthropicUsageNormalizeDisabled, mn as localSessionId, mr as CHEAP_PROFILE_MODELS, nr as generateRandomPort, nt as logStreamError, or as upstreamAllowH2, ot as UNKNOWN_EFFORT_ANCHOR, pn as localBaseUrl, pr as CHEAP_PROFILE_ADVISOR_CLIENT_MODEL, pt as handleMcpPost, q as resolveAdvisorModel, qn as toolbeltPathOverride, rr as isBudgetClaudeLead, rt as readIteratorWithTimeout, sr as upstreamMaxConnections, st as bucketEffort, tr as UPSTREAM_INACTIVITY_TIMEOUT_MS, tt as isControllerClosedError, un as getTokenCount, ur as oneMContextDisabled, ut as createAnthropicUsageRewriteTransform, vn as findLaunchBySecret, vr as CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS, wn as warnOnTokenPriceDrift, wt as normalizeAdoToolsets, xn as rememberLaunchSessionId, z as CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, zn as effectiveLocalProfile } from "./peer-mcp-personas-Dny0r5Am.js";
10
+ import { C as localContractFor, I as CHEAPEST_PROFILE_MODELS, L as CHEAPEST_PROFILE_NATIVE_AGENT_NAMES, O as LOCAL_PROFILE_TIER_MODELS, S as local2AdvisorContract, _ as isBalancedFamily, b as isLocalFamily, f as balancedContractFor, g as displayModelName, j as CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL, p as cheapestContractFor, v as isCheapestFamily, x as isPinnedLaunchProfile } from "./static-context-pack-BKFelEbM.js";
12
11
  import { i as BALANCED_PROFILE_NATIVE_AGENT_NAMES, r as BALANCED_PROFILE_MODELS } from "./balanced-profile-contract-B6pSoWjm.js";
13
12
  import { A as normalizeTrailingOneMSuffix, a as MAX_PROFILE_NATIVE_AGENT_NAMES, d as maxAdvisorPinIsValid, h as maxOpusModel, i as MAX_PROFILE_MODELS, j as stripTrailingOneMSuffix, k as fastEndpointForModel, l as maxAdvisorEffortForModel, n as MAX_PROFILE_ALLOWED_LEAD_MODEL_IDS, t as MAX_PROFILE_ADVISOR_INSTRUCTIONS, u as maxAdvisorModelFromPin, y as validateMaxProfilePrerequisites } from "./max-profile-contract-DbHwiLTx.js";
14
13
  import { f as getAzureRepoFromGit } from "./bluebird-client-BasIdv5J.js";
15
- import { a as extractAndRecordPricedAic, g as nanoAiuToCredits, h as formatAic, i as extractAndRecordAic, l as recordAic, m as extractCopilotUsage, p as copilotUsageToWire, u as recordZeroCostRequest } from "./aic-ledger-CeSXqTEE.js";
14
+ import { I as provisionTreeSitterAssets } from "./service-backend-BdhWVRSz.js";
15
+ import { a as extractAndRecordPricedAic, g as nanoAiuToCredits, h as formatAic, i as extractAndRecordAic, l as recordAic, m as extractCopilotUsage, p as copilotUsageToWire, u as recordZeroCostRequest } from "./aic-ledger-6GKI28nY.js";
16
16
  import consola from "consola";
17
17
  import fs, { existsSync } from "node:fs";
18
18
  import path from "node:path";
@@ -28,353 +28,6 @@ import { createBodyTooLargeError, limitRequestBody } from "srvx/body-limit";
28
28
  import { getProxyForUrl } from "proxy-from-env";
29
29
  import { Hono } from "hono";
30
30
  import { cors } from "hono/cors";
31
- // src/lib/claude-version-check.ts
32
- const NPM_PACKAGE$1 = "@anthropic-ai/claude-code";
33
- const THROTTLE_HOURS$2 = 1;
34
- const NPM_VIEW_TIMEOUT_MS$2 = 5e3;
35
- const CLAUDE_VERSION_TIMEOUT_MS = 3e3;
36
- const NPM_INSTALL_TIMEOUT_MS$1 = 12e4;
37
- /** Path to the throttle cache. Created on demand. */
38
- function cacheFilePath$2() {
39
- return path.join(os.homedir(), ".local", "share", "github-router", "last-update-check");
40
- }
41
- /**
42
- * Read the throttle cache. Returns null on missing/corrupt file —
43
- * triggers a fresh check.
44
- */
45
- async function readCache$2() {
46
- try {
47
- const raw = await fs$1.readFile(cacheFilePath$2(), "utf8");
48
- const parsed = JSON.parse(raw);
49
- if (typeof parsed.checkedAt !== "string" || parsed.installedVersion !== null && typeof parsed.installedVersion !== "string" || parsed.latestVersion !== null && typeof parsed.latestVersion !== "string") return null;
50
- return parsed;
51
- } catch {
52
- return null;
53
- }
54
- }
55
- async function writeCache$2(cache) {
56
- try {
57
- await fs$1.mkdir(path.dirname(cacheFilePath$2()), { recursive: true });
58
- await fs$1.writeFile(cacheFilePath$2(), JSON.stringify(cache), { mode: 384 });
59
- } catch (err) {
60
- consola.debug("Failed to write claude version-check cache:", err);
61
- }
62
- }
63
- /** Check if it's been more than THROTTLE_HOURS since the last check. */
64
- function shouldCheckNow$2(cache) {
65
- if (!cache) return true;
66
- const lastCheck = new Date(cache.checkedAt).getTime();
67
- if (Number.isNaN(lastCheck)) return true;
68
- return (Date.now() - lastCheck) / 1e3 / 3600 >= THROTTLE_HOURS$2;
69
- }
70
- /**
71
- * Read the installed `claude` version. Returns null if claude is not
72
- * on PATH or the version probe fails (e.g. older versions that don't
73
- * support `--version` cleanly).
74
- *
75
- * Windows-safe: `claude` is a `.cmd` shim that `execFile` cannot launch
76
- * directly. We resolve it to an absolute path (excluding the cwd, so a
77
- * planted `claude.cmd` in an untrusted repo can't run) and invoke it
78
- * through the shared exec helper.
79
- */
80
- async function getInstalledVersion() {
81
- const claudePath = resolveExecutable("claude");
82
- if (!claudePath) return null;
83
- try {
84
- const { stdout, code } = await runCommandCapture([claudePath, "--version"], { timeoutMs: CLAUDE_VERSION_TIMEOUT_MS });
85
- if (code !== 0) return null;
86
- const match = stdout.match(/(\d+\.\d+\.\d+)/);
87
- return match ? match[1] : null;
88
- } catch {
89
- return null;
90
- }
91
- }
92
- /**
93
- * Fetch the latest version of @anthropic-ai/claude-code from the npm
94
- * registry. Returns null on network failure / npm unavailable.
95
- *
96
- * Windows-safe: `npm` is `npm.cmd`; resolved to an absolute path
97
- * (excluding cwd) before invocation.
98
- */
99
- async function getLatestVersion$1() {
100
- const npmPath = resolveExecutable("npm");
101
- if (!npmPath) return null;
102
- try {
103
- const { stdout, code } = await runCommandCapture([
104
- npmPath,
105
- "view",
106
- NPM_PACKAGE$1,
107
- "version",
108
- "--silent"
109
- ], { timeoutMs: NPM_VIEW_TIMEOUT_MS$2 });
110
- if (code !== 0) return null;
111
- const v = stdout.trim();
112
- return /^\d+\.\d+\.\d+/.test(v) ? v : null;
113
- } catch {
114
- return null;
115
- }
116
- }
117
- /**
118
- * Compare two semver-shaped strings (only the leading X.Y.Z, no
119
- * pre-release / metadata handling — sufficient for npm-published
120
- * stable releases). Returns true if `latest` is strictly higher than
121
- * `installed`.
122
- */
123
- function isNewer(installed, latest) {
124
- if (!installed || !latest) return false;
125
- const a = installed.split(".").map((n) => parseInt(n, 10));
126
- const b = latest.split(".").map((n) => parseInt(n, 10));
127
- for (let i = 0; i < 3; i++) {
128
- const av = a[i] ?? 0;
129
- const bv = b[i] ?? 0;
130
- if (av < bv) return true;
131
- if (av > bv) return false;
132
- }
133
- return false;
134
- }
135
- /**
136
- * Run a version check (subject to throttle). Side-effect: updates the
137
- * throttle cache. Returns the comparison result.
138
- */
139
- async function checkClaudeVersion(opts = {}) {
140
- if (opts.noCheck) return {
141
- installed: false,
142
- installedVersion: null,
143
- latestVersion: null,
144
- needsUpdate: false,
145
- skipped: true,
146
- skipReason: "disabled"
147
- };
148
- const cache = await readCache$2();
149
- if (!opts.force && !shouldCheckNow$2(cache)) return {
150
- installed: cache?.installedVersion !== null,
151
- installedVersion: cache?.installedVersion ?? null,
152
- latestVersion: cache?.latestVersion ?? null,
153
- needsUpdate: isNewer(cache?.installedVersion ?? null, cache?.latestVersion ?? null),
154
- skipped: true,
155
- skipReason: "throttled"
156
- };
157
- const installedVersion = await getInstalledVersion();
158
- if (installedVersion === null) return {
159
- installed: false,
160
- installedVersion: null,
161
- latestVersion: null,
162
- needsUpdate: false,
163
- skipped: true,
164
- skipReason: "no-claude"
165
- };
166
- const latestVersion = await getLatestVersion$1();
167
- await writeCache$2({
168
- checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
169
- installedVersion,
170
- latestVersion
171
- });
172
- if (latestVersion === null) return {
173
- installed: true,
174
- installedVersion,
175
- latestVersion: null,
176
- needsUpdate: false,
177
- skipped: true,
178
- skipReason: "no-npm"
179
- };
180
- return {
181
- installed: true,
182
- installedVersion,
183
- latestVersion,
184
- needsUpdate: isNewer(installedVersion, latestVersion),
185
- skipped: false
186
- };
187
- }
188
- /**
189
- * Heuristic: did `claude update` fail because the subcommand does not
190
- * exist (a build predating `claude update`), as opposed to a transient
191
- * update error? We only npm-fall-back on this specific signal — falling
192
- * back on any failure would install a conflicting npm copy on
193
- * native-installer machines.
194
- *
195
- * Matches the usage/Commander-style "unknown command" messages CLIs emit
196
- * for an unrecognized subcommand. Deliberately narrow.
197
- */
198
- function looksLikeUnknownUpdateCommand(output) {
199
- return /unknown command|unknown subcommand|unrecognized (sub)?command|invalid command|command not found|is not a (known|valid) command/i.test(output);
200
- }
201
- async function updateClaude(latestVersion, deps = {}) {
202
- const _resolve = deps.resolveExecutable ?? resolveExecutable;
203
- const _capture = deps.runCommandCapture ?? runCommandCapture;
204
- const _void = deps.runCommandVoid ?? runCommandVoid;
205
- const _lock = deps.withInstallLock ?? withInstallLock;
206
- const claudePath = _resolve("claude");
207
- if (!claudePath) throw new Error("claude not found on PATH");
208
- if (!await _lock("claude-update.lock", async () => {
209
- consola.info(`Updating Claude Code to ${latestVersion} via \`claude update\`...`);
210
- const { code, stdout, stderr } = await _capture([claudePath, "update"], { timeoutMs: NPM_INSTALL_TIMEOUT_MS$1 });
211
- const combined = `${stdout}${stderr}`;
212
- const trimmed = combined.trim();
213
- if (trimmed) process.stdout.write(trimmed.endsWith("\n") ? trimmed : `${trimmed}\n`);
214
- if (code === 0) {
215
- consola.success(`Claude Code updated to ${latestVersion}`);
216
- return;
217
- }
218
- if (!looksLikeUnknownUpdateCommand(combined)) throw new Error(`\`claude update\` exited with code ${code}`);
219
- const npmPath = _resolve("npm");
220
- if (!npmPath) throw new Error(`this Claude Code build predates \`claude update\` and npm is not on PATH; update manually: npm install -g ${NPM_PACKAGE$1}@latest`);
221
- consola.warn(`This Claude Code build predates \`claude update\`; falling back to \`npm install -g ${NPM_PACKAGE$1}@latest\`.`);
222
- const { code: npmCode, stderr: npmStderr } = await _void([
223
- npmPath,
224
- "install",
225
- "-g",
226
- `${NPM_PACKAGE$1}@latest`,
227
- "--silent"
228
- ], { timeoutMs: NPM_INSTALL_TIMEOUT_MS$1 });
229
- if (npmCode !== 0) throw new Error(`npm install failed: ${npmStderr.trim() || `exit ${npmCode}`}`);
230
- consola.success(`${NPM_PACKAGE$1} updated to ${latestVersion}`);
231
- })) consola.debug("Claude Code update already in progress in another process; skipping.");
232
- }
233
- // src/lib/self-update.ts
234
- /**
235
- * Self-update for the `github-router` proxy.
236
- *
237
- * The proxy is a *running* process, so updating its own global install
238
- * in place (`npm install -g github-router@latest`) deletes/overwrites
239
- * files the OS holds open — on Windows that fails deterministically
240
- * (EPERM/EBUSY) and can corrupt the install. So we never install in
241
- * place: when a newer version exists we spawn a **detached updater that
242
- * waits for this process to exit**, then installs. The update takes
243
- * effect on the next launch — no re-exec, no restart prompt.
244
- *
245
- * Best-effort throughout: every failure is swallowed to debug/warn and
246
- * never blocks startup. The startup probe is bounded and the install is
247
- * off the critical path (detached), so even a blackholed network can't
248
- * delay the proxy from serving.
249
- */
250
- const NPM_PACKAGE = "github-router";
251
- const THROTTLE_HOURS$1 = 1;
252
- const NPM_VIEW_TIMEOUT_MS$1 = 5e3;
253
- function cacheFilePath$1() {
254
- return path.join(os.homedir(), ".local", "share", "github-router", "last-self-update-check");
255
- }
256
- async function readCache$1() {
257
- try {
258
- const parsed = JSON.parse(await fs$1.readFile(cacheFilePath$1(), "utf8"));
259
- if (typeof parsed.checkedAt !== "string") return null;
260
- return parsed;
261
- } catch {
262
- return null;
263
- }
264
- }
265
- async function writeCache$1(cache) {
266
- try {
267
- await fs$1.mkdir(path.dirname(cacheFilePath$1()), { recursive: true });
268
- await fs$1.writeFile(cacheFilePath$1(), JSON.stringify(cache), { mode: 384 });
269
- } catch (err) {
270
- consola.debug("Failed to write self-update cache:", err);
271
- }
272
- }
273
- function shouldCheckNow$1(cache) {
274
- if (!cache) return true;
275
- const last = new Date(cache.checkedAt).getTime();
276
- if (Number.isNaN(last)) return true;
277
- return (Date.now() - last) / 1e3 / 3600 >= THROTTLE_HOURS$1;
278
- }
279
- async function getLatestVersion(npmPath) {
280
- try {
281
- const { stdout, code } = await runCommandCapture([
282
- npmPath,
283
- "view",
284
- NPM_PACKAGE,
285
- "version",
286
- "--silent"
287
- ], { timeoutMs: NPM_VIEW_TIMEOUT_MS$1 });
288
- if (code !== 0) return null;
289
- const v = stdout.trim();
290
- return /^\d+\.\d+\.\d+/.test(v) ? v : null;
291
- } catch {
292
- return null;
293
- }
294
- }
295
- /**
296
- * Spawn a detached process that waits for THIS proxy (pid) to exit,
297
- * then runs `npm install -g <spec>`. Fully detached and unref'd so it
298
- * outlives the proxy; output discarded.
299
- *
300
- * The waiter is a tiny inline Node script (Node is guaranteed present —
301
- * the proxy runs on it) that polls `process.kill(pid, 0)` until the
302
- * parent is gone, then execs npm. This avoids the Windows file-lock by
303
- * never touching the global install while the proxy holds it open.
304
- *
305
- * Shared by the proxy self-update (`github-router@latest`) and the Pi
306
- * background refresh (`@earendil-works/pi-coding-agent@<version>`):
307
- * both must update a global install without delaying startup, holding
308
- * shutdown, or racing each other (callers hold `withInstallLock`
309
- * before queueing).
310
- */
311
- function queueDetachedGlobalInstall(npmPath, spec, extraArgs = []) {
312
- const parentPid = process.pid;
313
- const installArgs = [
314
- "install",
315
- "-g",
316
- spec,
317
- ...extraArgs
318
- ];
319
- const waiter = `
320
- const pid = ${parentPid};
321
- const { spawn } = require("node:child_process");
322
- function alive() { try { process.kill(pid, 0); return true } catch { return false } }
323
- const timer = setInterval(() => {
324
- if (alive()) return;
325
- clearInterval(timer);
326
- const args = [...${JSON.stringify(installArgs)}, "--silent"];
327
- const isWin = process.platform === "win32";
328
- const child = spawn(${JSON.stringify(npmPath)}, args, {
329
- stdio: "ignore", windowsHide: true, shell: isWin, detached: !isWin,
330
- });
331
- child.on("error", () => process.exit(0));
332
- child.on("exit", () => process.exit(0));
333
- // Safety: never hang forever.
334
- setTimeout(() => process.exit(0), 180000).unref();
335
- }, 500);
336
- // Safety cap on the wait itself (e.g. extremely long sessions still
337
- // eventually give up rather than leak the waiter).
338
- setTimeout(() => { clearInterval(timer); process.exit(0); }, 24 * 3600 * 1000).unref();
339
- `.trim();
340
- spawn(process.execPath, ["-e", waiter], {
341
- detached: true,
342
- stdio: "ignore",
343
- windowsHide: true
344
- }).unref();
345
- }
346
- function spawnDetachedUpdater(npmPath) {
347
- queueDetachedGlobalInstall(npmPath, `${NPM_PACKAGE}@latest`);
348
- }
349
- /**
350
- * Probe npm for a newer `github-router` and, if found, queue a detached
351
- * post-exit update. Returns quickly; never throws. Call AFTER the
352
- * server is listening so the bounded probe can't delay binding.
353
- */
354
- async function runSelfUpdate(opts) {
355
- if (!opts.selfUpdate) return;
356
- if (parseBoolEnv(process.env.GH_ROUTER_NO_SELF_UPDATE) === true) return;
357
- try {
358
- const cache = await readCache$1();
359
- if (!opts.force && !shouldCheckNow$1(cache)) return;
360
- const installed = getPackageVersion();
361
- if (installed === "unknown") return;
362
- const npmPath = resolveExecutable("npm");
363
- if (!npmPath) return;
364
- const latest = await getLatestVersion(npmPath);
365
- await writeCache$1({
366
- checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
367
- installedVersion: installed,
368
- latestVersion: latest
369
- });
370
- if (!latest || !isNewer(installed, latest)) return;
371
- if (await withInstallLock("self-update.lock", async () => {
372
- spawnDetachedUpdater(npmPath);
373
- })) consola.info(`github-router ${installed} → ${latest} update queued; it takes effect on the next launch.`);
374
- } catch (err) {
375
- consola.debug("Self-update check failed:", err);
376
- }
377
- }
378
31
  // src/lib/launch-profile.ts
379
32
  const STANDARD_PROFILE = Object.freeze({
380
33
  id: "standard",
@@ -2905,285 +2558,6 @@ async function sweepStalePiAgentMirrors() {
2905
2558
  }
2906
2559
  }));
2907
2560
  }
2908
- // src/lib/pi-version-check.ts
2909
- const PI_NPM_PACKAGE = "@earendil-works/pi-coding-agent";
2910
- /**
2911
- * Minimum Pi version the `pi` launcher supports.
2912
- *
2913
- * The floor is pinned to the first release whose `before_agent_start` event
2914
- * carries the `messageType` discriminator (present at 1.3.0, absent at 1.1.0).
2915
- * The generated extension's prompt hook stands down for non-user events using
2916
- * that field, and without it the hook would fire on subagent and system turns
2917
- * the user never typed, which is a wrong brief rather than a missing one.
2918
- * Below-floor Pi hard-exits at the launcher (`src/pi.ts`), but only where the
2919
- * gate actually runs: the install probe, the background refresh, and this floor
2920
- * check all sit inside `--update-check` (default on), so `--no-update-check`
2921
- * (documented for offline/CI) skips the floor as well. That path is still
2922
- * fail-closed rather than silently wrong: the generated extension's own shape
2923
- * probe sees the missing `messageType`, warns once with the fix, and injects
2924
- * nothing.
2925
- */
2926
- const PI_MIN_VERSION = "1.3.0";
2927
- /**
2928
- * Registry used for the PI PACKAGE ONLY.
2929
- *
2930
- * Pi must come from a registry that actually carries it. A corporate npm mirror
2931
- * can lag npmjs far enough that its `latest` sits below `PI_MIN_VERSION`, and
2932
- * the launcher then fail-closes on an upgrade command the user cannot satisfy
2933
- * (their `npm install -g` resolves through the same lagging mirror). Pointing
2934
- * the Pi probe and install at npmjs by default keeps the floor reachable;
2935
- * `GH_ROUTER_NPM_REGISTRY` overrides it for a mirror that does carry the
2936
- * package. Everything else this repo installs still resolves through the user's
2937
- * configured registry.
2938
- */
2939
- const PI_DEFAULT_REGISTRY = "https://registry.npmjs.org/";
2940
- /**
2941
- * Resolve the registry for Pi package operations. Accepts `GH_ROUTER_NPM_REGISTRY`
2942
- * when it is an http(s) URL and falls back to `PI_DEFAULT_REGISTRY` with a
2943
- * warning otherwise, so a typo degrades to the working default rather than
2944
- * bricking the launcher.
2945
- */
2946
- function resolvePiRegistry() {
2947
- const raw = process.env.GH_ROUTER_NPM_REGISTRY?.trim();
2948
- if (!raw) return PI_DEFAULT_REGISTRY;
2949
- if (!/^https?:\/\//i.test(raw)) {
2950
- consola.warn(`Ignoring GH_ROUTER_NPM_REGISTRY=${JSON.stringify(raw)}: expected an http(s) URL. Using ${PI_DEFAULT_REGISTRY}.`);
2951
- return PI_DEFAULT_REGISTRY;
2952
- }
2953
- return raw.endsWith("/") ? raw : `${raw}/`;
2954
- }
2955
- /** `npm` args that pin an operation to the resolved Pi registry. */
2956
- function piRegistryArgs(registry = resolvePiRegistry()) {
2957
- return [`--registry=${registry}`];
2958
- }
2959
- const THROTTLE_HOURS = 1;
2960
- const NPM_VIEW_TIMEOUT_MS = 5e3;
2961
- const PI_VERSION_TIMEOUT_MS = 3e3;
2962
- const NPM_INSTALL_TIMEOUT_MS = 3e5;
2963
- /** Path to the throttle cache. Created on demand. Separate file from the Claude check. */
2964
- function cacheFilePath() {
2965
- return path.join(os.homedir(), ".local", "share", "github-router", "last-pi-update-check");
2966
- }
2967
- async function readCache() {
2968
- try {
2969
- const raw = await fs$1.readFile(cacheFilePath(), "utf8");
2970
- const parsed = JSON.parse(raw);
2971
- if (typeof parsed.checkedAt !== "string" || parsed.installedVersion !== null && typeof parsed.installedVersion !== "string" || parsed.latestVersion !== null && typeof parsed.latestVersion !== "string") return null;
2972
- return parsed;
2973
- } catch {
2974
- return null;
2975
- }
2976
- }
2977
- async function writeCache(cache) {
2978
- try {
2979
- await fs$1.mkdir(path.dirname(cacheFilePath()), { recursive: true });
2980
- await fs$1.writeFile(cacheFilePath(), JSON.stringify(cache), { mode: 384 });
2981
- } catch (err) {
2982
- consola.debug("Failed to write pi version-check cache:", err);
2983
- }
2984
- }
2985
- function shouldCheckNow(cache) {
2986
- if (!cache) return true;
2987
- const lastCheck = new Date(cache.checkedAt).getTime();
2988
- if (Number.isNaN(lastCheck)) return true;
2989
- return (Date.now() - lastCheck) / 1e3 / 3600 >= THROTTLE_HOURS;
2990
- }
2991
- /**
2992
- * Read the installed `pi` version. Returns null if pi is not on PATH
2993
- * or the version probe fails.
2994
- *
2995
- * Windows-safe: `pi` may be a `.cmd` shim; resolved to an absolute path
2996
- * (excluding the cwd) before invocation via the shared exec helper.
2997
- */
2998
- async function getInstalledPiVersion() {
2999
- const piPath = resolveExecutable("pi");
3000
- if (!piPath) return null;
3001
- try {
3002
- const { stdout, code } = await runCommandCapture([piPath, "--version"], { timeoutMs: PI_VERSION_TIMEOUT_MS });
3003
- if (code !== 0) return null;
3004
- const match = stdout.match(/(\d+\.\d+\.\d+)/);
3005
- return match ? match[1] : null;
3006
- } catch {
3007
- return null;
3008
- }
3009
- }
3010
- /** Fetch the latest Pi version from npm. Null on network/npm failure. */
3011
- async function getLatestPiVersion() {
3012
- const npmPath = resolveExecutable("npm");
3013
- if (!npmPath) return null;
3014
- try {
3015
- const { stdout, code } = await runCommandCapture([
3016
- npmPath,
3017
- "view",
3018
- PI_NPM_PACKAGE,
3019
- "version",
3020
- "--silent",
3021
- ...piRegistryArgs()
3022
- ], { timeoutMs: NPM_VIEW_TIMEOUT_MS });
3023
- if (code !== 0) return null;
3024
- const v = stdout.trim();
3025
- return /^\d+\.\d+\.\d+/.test(v) ? v : null;
3026
- } catch {
3027
- return null;
3028
- }
3029
- }
3030
- /**
3031
- * Compare two semver-shaped strings (leading X.Y.Z only). True when
3032
- * `latest` is strictly higher than `installed`.
3033
- */
3034
- function isPiNewer(installed, latest) {
3035
- if (!installed || !latest) return false;
3036
- const a = installed.split(".").map((n) => parseInt(n, 10));
3037
- const b = latest.split(".").map((n) => parseInt(n, 10));
3038
- for (let i = 0; i < 3; i++) {
3039
- const av = a[i] ?? 0;
3040
- const bv = b[i] ?? 0;
3041
- if (av < bv) return true;
3042
- if (av > bv) return false;
3043
- }
3044
- return false;
3045
- }
3046
- /** True when `version` satisfies the minimum Pi floor (>= PI_MIN_VERSION). */
3047
- function meetsPiMinVersion(version) {
3048
- if (!version) return false;
3049
- return !isPiNewer(version, PI_MIN_VERSION);
3050
- }
3051
- /** Run a version check (subject to throttle). Side-effect: updates the cache. */
3052
- async function checkPiVersion(opts = {}) {
3053
- if (opts.noCheck) return {
3054
- installed: false,
3055
- installedVersion: null,
3056
- latestVersion: null,
3057
- needsUpdate: false,
3058
- needsMinUpgrade: false,
3059
- skipped: true,
3060
- skipReason: "disabled"
3061
- };
3062
- const cache = await readCache();
3063
- if (!opts.force && !shouldCheckNow(cache)) {
3064
- const installedVersion = cache?.installedVersion ?? null;
3065
- const latestVersion = cache?.latestVersion ?? null;
3066
- return {
3067
- installed: installedVersion !== null,
3068
- installedVersion,
3069
- latestVersion,
3070
- needsUpdate: isPiNewer(installedVersion, latestVersion),
3071
- needsMinUpgrade: !meetsPiMinVersion(installedVersion),
3072
- skipped: true,
3073
- skipReason: "throttled"
3074
- };
3075
- }
3076
- const installedVersion = await getInstalledPiVersion();
3077
- if (installedVersion === null) return {
3078
- installed: false,
3079
- installedVersion: null,
3080
- latestVersion: null,
3081
- needsUpdate: false,
3082
- needsMinUpgrade: true,
3083
- skipped: true,
3084
- skipReason: "no-pi"
3085
- };
3086
- const latestVersion = await getLatestPiVersion();
3087
- await writeCache({
3088
- checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
3089
- installedVersion,
3090
- latestVersion
3091
- });
3092
- if (latestVersion === null) return {
3093
- installed: true,
3094
- installedVersion,
3095
- latestVersion: null,
3096
- needsUpdate: false,
3097
- needsMinUpgrade: !meetsPiMinVersion(installedVersion),
3098
- skipped: true,
3099
- skipReason: "no-npm"
3100
- };
3101
- return {
3102
- installed: true,
3103
- installedVersion,
3104
- latestVersion,
3105
- needsUpdate: isPiNewer(installedVersion, latestVersion),
3106
- needsMinUpgrade: !meetsPiMinVersion(installedVersion),
3107
- skipped: false
3108
- };
3109
- }
3110
- /**
3111
- * Install (or upgrade) Pi from npm under the cross-process install lock.
3112
- * Returns `true` when this call performed the install, `false` when
3113
- * another process holds the lock (caller skips — its install will land
3114
- * for a later launch). Best-effort: throws on failure; callers fall
3115
- * back to the installed version with a visible warning rather than
3116
- * stranding the launch.
3117
- */
3118
- function updatePi(version, opts = {}) {
3119
- const npmPath = resolveExecutable("npm");
3120
- if (!npmPath) throw new Error("npm not found on PATH; cannot install Pi automatically");
3121
- return withInstallLock("pi-install.lock", async () => {
3122
- const registry = resolvePiRegistry();
3123
- consola.info(`Installing ${PI_NPM_PACKAGE}@${version} from ${registry}...`);
3124
- await runCommandVoid([
3125
- npmPath,
3126
- "install",
3127
- "-g",
3128
- `${PI_NPM_PACKAGE}@${version}`,
3129
- ...piRegistryArgs(registry)
3130
- ], {
3131
- timeoutMs: NPM_INSTALL_TIMEOUT_MS,
3132
- signal: opts.signal
3133
- });
3134
- });
3135
- }
3136
- /**
3137
- * Blocking fresh install for when Pi is absent entirely. Installs
3138
- * `@latest`, then force re-checks; throws when Pi still is not on PATH
3139
- * (caller exits with the install command). Only used when there is no
3140
- * usable Pi at all — the healthy path never blocks on npm.
3141
- */
3142
- async function ensurePiInstalled(opts = {}) {
3143
- const acquired = await updatePi("latest", opts);
3144
- const retry = await checkPiVersion({ force: true });
3145
- if (retry.installed && retry.installedVersion) return retry.installedVersion;
3146
- throw new Error(acquired ? "install did not place pi on PATH" : "another Pi install is already running; retry in a moment");
3147
- }
3148
- /**
3149
- * Fire-and-forget freshness refresh for a healthy Pi install. Never
3150
- * blocks launch and never throws: on the throttled schedule it probes
3151
- * npm for a newer Pi and, when one exists, queues a DETACHED post-exit
3152
- * install (same pattern as the proxy self-update) so neither startup
3153
- * nor the running session nor shutdown ever waits on npm. The
3154
- * cross-process install lock serializes against concurrent launches;
3155
- * every failure degrades to a debug log.
3156
- *
3157
- * Deliberately never touches a below-floor install: the floor is
3158
- * enforced foreground by the launcher (fail-closed), and a background
3159
- * task must not change what the running session validated.
3160
- */
3161
- function refreshPiInBackground(opts) {
3162
- if (!opts.autoUpdate) return;
3163
- (async () => {
3164
- try {
3165
- if (!shouldCheckNow(await readCache())) return;
3166
- const installedVersion = await getInstalledPiVersion();
3167
- if (!meetsPiMinVersion(installedVersion)) return;
3168
- const npmPath = resolveExecutable("npm");
3169
- const latestVersion = await getLatestPiVersion();
3170
- await writeCache({
3171
- checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
3172
- installedVersion,
3173
- latestVersion
3174
- });
3175
- if (!npmPath) return;
3176
- if (!latestVersion || !isPiNewer(installedVersion, latestVersion)) return;
3177
- if (await withInstallLock("pi-install.lock", async () => {
3178
- queueDetachedGlobalInstall(npmPath, `@earendil-works/pi-coding-agent@${latestVersion}`, piRegistryArgs());
3179
- })) consola.info(`Pi ${installedVersion} → ${latestVersion} update queued; it takes effect on the next launch.`);
3180
- } catch (err) {
3181
- consola.debug("Background Pi refresh failed:", err);
3182
- }
3183
- })().catch((err) => {
3184
- consola.debug("Background Pi refresh failed:", err);
3185
- });
3186
- }
3187
2561
  // src/lib/proxy.ts
3188
2562
  let socketCounter = 0;
3189
2563
  /**
@@ -3535,7 +2909,7 @@ function collectToolFieldKeys(body) {
3535
2909
  }
3536
2910
  // package.json
3537
2911
  var name = "github-router";
3538
- var version = "0.3.378";
2912
+ var version = "0.3.380";
3539
2913
  // src/lib/approval.ts
3540
2914
  const awaitApproval = async () => {
3541
2915
  if (!await consola.prompt(`Accept incoming request?`, { type: "confirm" })) throw new HTTPError("Request rejected by user", Response.json({ message: "Request rejected by user" }, { status: 403 }));
@@ -9533,6 +8907,6 @@ function getPiLaunchEnvVars(mirrorDir) {
9533
8907
  if (toolbeltEnabled()) Object.assign(vars, toolbeltPathOverride(process.env, PATHS.TOOLBELT_BIN_DIR));
9534
8908
  return vars;
9535
8909
  }
9536
- export { updateClaude as $, CHEAP_EXPLORE_ALIAS_ID as A, formatFastPrerequisiteFailure as B, BALANCED_EXPLORE_ALIAS_ID as C, CHEAPEST_EXPLORE_ALIAS_ID as D, BROWSE_LOW_ALIAS_ID as E, MAX_BROWSE_LOW_ALIAS_ID as F, validateCheap1mProfilePrerequisites as G, profileDescriptor as H, formatBalancedPrerequisiteFailure as I, validateFastProfilePrerequisites as J, validateCheapProfilePrerequisites as K, formatCheap1mPrerequisiteFailure as L, CHEAP_PLAN_ALIAS_ID as M, CHEAP_REVIEWER_ALIAS_ID as N, CHEAPEST_GENERAL_PURPOSE_ALIAS_ID as O, LUNA_SCOUT_ALIAS_ID as P, checkClaudeVersion as Q, formatCheapPrerequisiteFailure as R, enableFileLogging as S, BALANCED_REVIEWER_ALIAS_ID as T, resolveLaunchProfile as U, formatLocalPrerequisiteFailure as V, validateBalancedProfilePrerequisites as W, validateMaxProfileLaunch as X, validateLocalProfilePrerequisites as Y, runSelfUpdate as Z, sweepStalePiAgentMirrors as _, setupAndServe as a, injectModelPickerSettingsFile as b, PI_MIN_VERSION as c, meetsPiMinVersion as d, refreshPiInBackground as f, removeOwnPiAgentMirror as g, ensurePiAgentMirror as h, parseSharedArgs as i, CHEAP_GENERAL_PURPOSE_ALIAS_ID as j, CHEAPEST_REVIEWER_ALIAS_ID as k, ensurePiInstalled as l, updatePi as m, getCodexEnvVars as n, sharedServerArgs as o, resolvePiRegistry as p, validateCheapestProfilePrerequisites as q, getPiLaunchEnvVars as r, LAUNCH_SECRET_HEADER as s, getClaudeCodeEnvVars as t, getInstalledPiVersion as u, startKeepAwake as v, BALANCED_GENERAL_PURPOSE_ALIAS_ID as w, listModelsForEndpoint as x, stopKeepAwake as y, formatCheapestPrerequisiteFailure as z };
8910
+ export { formatCheap1mPrerequisiteFailure as A, validateCheapestProfilePrerequisites as B, CHEAP_EXPLORE_ALIAS_ID as C, LUNA_SCOUT_ALIAS_ID as D, CHEAP_REVIEWER_ALIAS_ID as E, profileDescriptor as F, validateLocalProfilePrerequisites as H, resolveLaunchProfile as I, validateBalancedProfilePrerequisites as L, formatCheapestPrerequisiteFailure as M, formatFastPrerequisiteFailure as N, MAX_BROWSE_LOW_ALIAS_ID as O, formatLocalPrerequisiteFailure as P, validateCheap1mProfilePrerequisites as R, CHEAPEST_REVIEWER_ALIAS_ID as S, CHEAP_PLAN_ALIAS_ID as T, validateMaxProfileLaunch as U, validateFastProfilePrerequisites as V, BALANCED_GENERAL_PURPOSE_ALIAS_ID as _, setupAndServe as a, CHEAPEST_EXPLORE_ALIAS_ID as b, ensurePiAgentMirror as c, startKeepAwake as d, stopKeepAwake as f, BALANCED_EXPLORE_ALIAS_ID as g, enableFileLogging as h, parseSharedArgs as i, formatCheapPrerequisiteFailure as j, formatBalancedPrerequisiteFailure as k, removeOwnPiAgentMirror as l, listModelsForEndpoint as m, getCodexEnvVars as n, sharedServerArgs as o, injectModelPickerSettingsFile as p, getPiLaunchEnvVars as r, LAUNCH_SECRET_HEADER as s, getClaudeCodeEnvVars as t, sweepStalePiAgentMirrors as u, BALANCED_REVIEWER_ALIAS_ID as v, CHEAP_GENERAL_PURPOSE_ALIAS_ID as w, CHEAPEST_GENERAL_PURPOSE_ALIAS_ID as x, BROWSE_LOW_ALIAS_ID as y, validateCheapProfilePrerequisites as z };
9537
8911
 
9538
- //# sourceMappingURL=server-setup-CptI7SUT.js.map
8912
+ //# sourceMappingURL=server-setup-DLwejgVA.js.map