github-router 0.3.357 → 0.3.369
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.
- package/dist/ado-tools-C0sY_rX1.js +1 -0
- package/dist/{aic-ledger-BuFrsGur.js → aic-ledger-_mvGW2Ev.js} +42 -7
- package/dist/aic-ledger-_mvGW2Ev.js.map +1 -0
- package/dist/{aic-statusline-settings-DBS9sEGC.js → aic-statusline-settings-B5EMMSFC.js} +2 -2
- package/dist/{aic-statusline-settings-DBS9sEGC.js.map → aic-statusline-settings-B5EMMSFC.js.map} +1 -1
- package/dist/{attribution-settings-D9PxJxkL.js → attribution-settings-zoBxw08y.js} +374 -218
- package/dist/attribution-settings-zoBxw08y.js.map +1 -0
- package/dist/{auth-DFawaLJU.js → auth-B3UvYB2r.js} +3 -3
- package/dist/{auth-DFawaLJU.js.map → auth-B3UvYB2r.js.map} +1 -1
- package/dist/{balanced-profile-contract-DtnTIBjL.js → balanced-profile-contract-Dm_usmw7.js} +7 -1
- package/dist/{balanced-profile-contract-DtnTIBjL.js.map → balanced-profile-contract-Dm_usmw7.js.map} +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/{check-usage-BkVEl-Su.js → check-usage-45vyaLfl.js} +4 -4
- package/dist/{check-usage-BkVEl-Su.js.map → check-usage-45vyaLfl.js.map} +1 -1
- package/dist/{claude-BTYQjK-K.js → claude-BbIfnWbm.js} +92 -42
- package/dist/claude-BbIfnWbm.js.map +1 -0
- package/dist/{claude-md-injection-Cpzolxin.js → claude-md-injection-BtBG1RBZ.js} +153 -37
- package/dist/claude-md-injection-BtBG1RBZ.js.map +1 -0
- package/dist/{codex-TdsG6C9K.js → codex-CZVlP2tB.js} +7 -7
- package/dist/{codex-TdsG6C9K.js.map → codex-CZVlP2tB.js.map} +1 -1
- package/dist/{copilot-discount-Bsmv_3OX.js → copilot-discount-BuDbQOHq.js} +2 -2
- package/dist/{copilot-discount-Bsmv_3OX.js.map → copilot-discount-BuDbQOHq.js.map} +1 -1
- package/dist/{debug-DkNTuErv.js → debug-DL2JsRqY.js} +2 -2
- package/dist/{debug-DkNTuErv.js.map → debug-DL2JsRqY.js.map} +1 -1
- package/dist/engine-DeIo-VIR.js +1 -0
- package/dist/{gate-discovery-NNQg0t0H.js → gate-discovery-BYyYeUnn.js} +5 -5
- package/dist/{gate-discovery-NNQg0t0H.js.map → gate-discovery-BYyYeUnn.js.map} +1 -1
- package/dist/{get-copilot-usage-P9chc-X2.js → get-copilot-usage-BbGmK03C.js} +2 -2
- package/dist/{get-copilot-usage-P9chc-X2.js.map → get-copilot-usage-BbGmK03C.js.map} +1 -1
- package/dist/hooks.mjs +262 -117
- package/dist/hooks.sha256 +1 -1
- package/dist/{index-cmd-BkfYr9FH.js → index-cmd-CjRcmYk3.js} +4 -4
- package/dist/{index-cmd-BkfYr9FH.js.map → index-cmd-CjRcmYk3.js.map} +1 -1
- package/dist/{internal-aic-status-C6L4-ncP.js → internal-aic-status-BAVomi5A.js} +4 -4
- package/dist/{internal-aic-status-C6L4-ncP.js.map → internal-aic-status-BAVomi5A.js.map} +1 -1
- package/dist/{internal-artifact-open-DgJ3PCtt.js → internal-artifact-open-NAGn9Mgt.js} +2 -2
- package/dist/{internal-artifact-open-DgJ3PCtt.js.map → internal-artifact-open-NAGn9Mgt.js.map} +1 -1
- package/dist/{internal-fast-dispatch-guard-CicGz6oM.js → internal-fast-dispatch-guard-De_DJOyZ.js} +1 -1
- package/dist/{internal-fast-dispatch-guard-CgBtUsQI.js → internal-fast-dispatch-guard-_n-A8hgo.js} +3 -3
- package/dist/{internal-fast-dispatch-guard-CgBtUsQI.js.map → internal-fast-dispatch-guard-_n-A8hgo.js.map} +1 -1
- package/dist/{internal-first-mate-guard-DTXPT7JW.js → internal-first-mate-guard-C8GwLbaX.js} +1 -1
- package/dist/{internal-first-mate-guard-BfWYN6Jb.js → internal-first-mate-guard-GufCUMl3.js} +3 -3
- package/dist/{internal-first-mate-guard-BfWYN6Jb.js.map → internal-first-mate-guard-GufCUMl3.js.map} +1 -1
- package/dist/{internal-max-dispatch-guard-mNl9CCir.js → internal-max-dispatch-guard-BB0vwiPx.js} +1 -1
- package/dist/{internal-max-dispatch-guard-CY8l9SDw.js → internal-max-dispatch-guard-BodVFHRC.js} +2 -2
- package/dist/{internal-max-dispatch-guard-CY8l9SDw.js.map → internal-max-dispatch-guard-BodVFHRC.js.map} +1 -1
- package/dist/{internal-plan-review-2OHTs8Nk.js → internal-plan-review-ChFx8wTX.js} +3 -3
- package/dist/{internal-plan-review-2OHTs8Nk.js.map → internal-plan-review-ChFx8wTX.js.map} +1 -1
- package/dist/{internal-prompt-submit-DZ_-2A6a.js → internal-prompt-submit-B-kKTl-8.js} +2 -2
- package/dist/{internal-prompt-submit-CkfUcu34.js → internal-prompt-submit-bi7F7pKk.js} +4 -4
- package/dist/{internal-prompt-submit-CkfUcu34.js.map → internal-prompt-submit-bi7F7pKk.js.map} +1 -1
- package/dist/{internal-rebrief-EhBHAHsz.js → internal-rebrief-B6ZJS6Mp.js} +4 -4
- package/dist/{internal-rebrief-EhBHAHsz.js.map → internal-rebrief-B6ZJS6Mp.js.map} +1 -1
- package/dist/{internal-session-bind-Bv50ju2n.js → internal-session-bind-dsUOcKxU.js} +2 -2
- package/dist/{internal-session-bind-Bv50ju2n.js.map → internal-session-bind-dsUOcKxU.js.map} +1 -1
- package/dist/{internal-stop-hook-Iz8XXE07.js → internal-stop-hook-BbyobGUU.js} +5 -5
- package/dist/{internal-stop-hook-Iz8XXE07.js.map → internal-stop-hook-BbyobGUU.js.map} +1 -1
- package/dist/{internal-stop-review-K6f8xsCh.js → internal-stop-review-D_KEV_04.js} +2 -2
- package/dist/{internal-stop-review-K6f8xsCh.js.map → internal-stop-review-D_KEV_04.js.map} +1 -1
- package/dist/{internal-worker-guard-GVhTjVlR.js → internal-worker-guard-DB6shBIn.js} +2 -2
- package/dist/{internal-worker-guard-GVhTjVlR.js.map → internal-worker-guard-DB6shBIn.js.map} +1 -1
- package/dist/{internal-workspace-header-d2hFf9Jy.js → internal-workspace-header-DBg5Y7oN.js} +2 -2
- package/dist/{internal-workspace-header-d2hFf9Jy.js.map → internal-workspace-header-DBg5Y7oN.js.map} +1 -1
- package/dist/{lifecycle-C6cxM_Nk.js → lifecycle-9nX09dBl.js} +2 -2
- package/dist/{lifecycle-C6cxM_Nk.js.map → lifecycle-9nX09dBl.js.map} +1 -1
- package/dist/lifecycle-C_CT13c9.js +1 -0
- package/dist/lifecycle-DibiH857.js +1 -0
- package/dist/{lifecycle-pl9QpvqD.js → lifecycle-Gge2Dadd.js} +2 -2
- package/dist/{lifecycle-pl9QpvqD.js.map → lifecycle-Gge2Dadd.js.map} +1 -1
- package/dist/main.js +23 -23
- package/dist/{mcp-workspace-header-Su8uUxJg.js → mcp-workspace-header-Xw9B1W6T.js} +2 -2
- package/dist/{mcp-workspace-header-Su8uUxJg.js.map → mcp-workspace-header-Xw9B1W6T.js.map} +1 -1
- package/dist/{models-D8v8OTbN.js → models-BR6i348u.js} +3 -3
- package/dist/{models-D8v8OTbN.js.map → models-BR6i348u.js.map} +1 -1
- package/dist/{orchestration-Bov4rZEi.js → orchestration-D3-2ulhX.js} +2 -2
- package/dist/{orchestration-Bov4rZEi.js.map → orchestration-D3-2ulhX.js.map} +1 -1
- package/dist/{paths-BSI_EtDT.js → paths-C5477RGC.js} +48 -4
- package/dist/paths-C5477RGC.js.map +1 -0
- package/dist/paths-CEswtFj5.js +1 -0
- package/dist/{peer-mcp-personas-GANlrtNR.js → peer-mcp-personas-DNtWI2C1.js} +1139 -398
- package/dist/peer-mcp-personas-DNtWI2C1.js.map +1 -0
- package/dist/{pi-TKFwPyLA.js → pi-Bc-MVgAo.js} +397 -603
- package/dist/pi-Bc-MVgAo.js.map +1 -0
- package/dist/{plan-review-hook-CHK1wL3-.js → plan-review-hook-C9K-em4D.js} +3 -3
- package/dist/{plan-review-hook-CHK1wL3-.js.map → plan-review-hook-C9K-em4D.js.map} +1 -1
- package/dist/{provision-BNN6yRk8.js → provision-DUWdcY_a.js} +5 -5
- package/dist/{provision-BNN6yRk8.js.map → provision-DUWdcY_a.js.map} +1 -1
- package/dist/{self-invocation-Dk_UHD_v.js → self-invocation-BtcGj-lY.js} +2 -2
- package/dist/{self-invocation-Dk_UHD_v.js.map → self-invocation-BtcGj-lY.js.map} +1 -1
- package/dist/{serve-BaeLm9Um.js → serve-CmWOTR7m.js} +14 -14
- package/dist/{serve-BaeLm9Um.js.map → serve-CmWOTR7m.js.map} +1 -1
- package/dist/{server-setup-BcUQv5ac.js → server-setup-CIzmDJzT.js} +848 -103
- package/dist/server-setup-CIzmDJzT.js.map +1 -0
- package/dist/{service-backend-DHyd9vjW.js → service-backend-B6D_DY1Z.js} +3 -3
- package/dist/{service-backend-DHyd9vjW.js.map → service-backend-B6D_DY1Z.js.map} +1 -1
- package/dist/{start-BdoGJc36.js → start-rlpaeAtx.js} +4 -4
- package/dist/{start-BdoGJc36.js.map → start-rlpaeAtx.js.map} +1 -1
- package/dist/state-CiwCLVDZ.js.map +1 -1
- package/dist/{static-context-pack-dKrzbfIN.js → static-context-pack-DvwLWlbe.js} +371 -64
- package/dist/static-context-pack-DvwLWlbe.js.map +1 -0
- package/dist/{stop-gate-hook-CC7VWkZM.js → stop-gate-hook-DnLC09Lg.js} +3 -3
- package/dist/{stop-gate-hook-CC7VWkZM.js.map → stop-gate-hook-DnLC09Lg.js.map} +1 -1
- package/dist/{stop-gate-policy-CoR8xKNQ.js → stop-gate-policy-Dx9c98_d.js} +2 -2
- package/dist/{stop-gate-policy-CoR8xKNQ.js.map → stop-gate-policy-Dx9c98_d.js.map} +1 -1
- package/dist/{token-CA2s70qj.js → token-OTb61rOC.js} +2 -2
- package/dist/{token-CA2s70qj.js.map → token-OTb61rOC.js.map} +1 -1
- package/dist/{worker-dispatch-B_rriT7z.js → worker-dispatch-B1w2qfjX.js} +2 -2
- package/dist/{worker-dispatch-B_rriT7z.js.map → worker-dispatch-B1w2qfjX.js.map} +1 -1
- package/docs/azure-mcp.md +29 -31
- package/package.json +1 -1
- package/dist/ado-tools-DqLJ-u19.js +0 -1
- package/dist/aic-ledger-BuFrsGur.js.map +0 -1
- package/dist/attribution-settings-D9PxJxkL.js.map +0 -1
- package/dist/claude-BTYQjK-K.js.map +0 -1
- package/dist/claude-md-injection-Cpzolxin.js.map +0 -1
- package/dist/engine-CmhUwYI5.js +0 -1
- package/dist/lifecycle-BU_d2QMs.js +0 -1
- package/dist/lifecycle-ByFyew_w.js +0 -1
- package/dist/paths-BSI_EtDT.js.map +0 -1
- package/dist/paths-BYxX9DfA.js +0 -1
- package/dist/peer-mcp-personas-GANlrtNR.js.map +0 -1
- package/dist/pi-TKFwPyLA.js.map +0 -1
- package/dist/server-setup-BcUQv5ac.js.map +0 -1
- package/dist/static-context-pack-dKrzbfIN.js.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { I as provisionTreeSitterAssets, L as withInstallLock } from "./service-backend-
|
|
1
|
+
import { I as provisionTreeSitterAssets, L as withInstallLock } from "./service-backend-B6D_DY1Z.js";
|
|
2
2
|
import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
|
|
3
|
-
import { i as ensurePaths, t as PATHS } from "./paths-
|
|
3
|
+
import { i as ensurePaths, t as PATHS } from "./paths-C5477RGC.js";
|
|
4
4
|
import { t as state } from "./state-CiwCLVDZ.js";
|
|
5
|
-
import { _ as forwardError, a as cacheCopilotVersion, b as copilotBaseUrl, c as filterBetaHeader, d as resolveModel, f as sleep, g as HTTPError, i as tryRefreshAndRetry, l as isNullish, n as setupGitHubAgentToken, o as cacheModels, r as setupGitHubToken, s as cacheVSCodeVersion, t as setupCopilotToken, x as copilotHeaders } from "./token-
|
|
5
|
+
import { _ as forwardError, a as cacheCopilotVersion, b as copilotBaseUrl, c as filterBetaHeader, d as resolveModel, f as sleep, g as HTTPError, i as tryRefreshAndRetry, l as isNullish, n as setupGitHubAgentToken, o as cacheModels, r as setupGitHubToken, s as cacheVSCodeVersion, t as setupCopilotToken, x as copilotHeaders } from "./token-OTb61rOC.js";
|
|
6
6
|
import { r as fetchWithTransientRetry } from "./upstream-retry-i1k1Xai2.js";
|
|
7
|
-
import { t as getCopilotUsage } from "./get-copilot-usage-
|
|
7
|
+
import { t as getCopilotUsage } from "./get-copilot-usage-BbGmK03C.js";
|
|
8
8
|
import { a as parseBoolEnv, c as runCommandCapture, i as killManagedTree, s as resolveExecutable, u as runCommandVoid } from "./exec-Bf8g_bIR.js";
|
|
9
9
|
import { c as FAST_PROFILE_MODELS, l as FAST_PROFILE_NATIVE_AGENT_NAMES, r as FAST_PROFILE_ADVISOR_MODEL } from "./fast-profile-contract-JOnZBgFB.js";
|
|
10
|
-
import { $ as
|
|
11
|
-
import { D as
|
|
12
|
-
import { i as BALANCED_PROFILE_NATIVE_AGENT_NAMES, r as BALANCED_PROFILE_MODELS } from "./balanced-profile-contract-
|
|
10
|
+
import { $ as buildAnthropicErrorEvent, $n as catalogAdvertises1M, $t as shimDefaultsToXhigh, B as FAST_ADVISOR_TOOL_INSTRUCTIONS, Cn as effectiveLocalProfile, D as toolbeltEnabled, Dn as normalizeCloudAgentEnvironment, F as ADVISOR_TOOL_INSTRUCTIONS, G as isAdvisorRequested, Gn as UPSTREAM_INACTIVITY_TIMEOUT_MS, H as LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, I as CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS, J as resolveCuratedAdvisorModel, K as resolveAdvisorEffort, Kn as generateRandomPort, L as CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, Ln as toolbeltPathOverride, N as searchWeb, On as normalizeKustoClusterUri, P as ADVISOR_INTERNAL_TOOL_NAME, Q as repairRejectedThinkingHistory, Qn as classifyMessagesRoute, R as CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS, Sn as assertCopilotModelAllowed, U as buildAdvisorStream, V as LOCAL_ADVISOR_TOOL_INSTRUCTIONS, W as injectAdvisorTool, Wn as UPSTREAM_FETCH_TIMEOUT_MS, X as rememberThinkingHistoryRepair, Xn as upstreamAllowH2, Y as formatThinkingRepairDecline, Z as repairKnownThinkingHistory, Zn as upstreamMaxConnections, _n as createResponses, an as localSessionId, ar as CHEAP_PROFILE_NATIVE_AGENT_NAMES, at as EFFORT_ORDER, bn as readResponseBodyCapped, cn as LAUNCH_BOUND_TOKEN_PREFIX, cr as CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS, ct as clampEffort, en as getTextTokenCount, er as oneMContextDisabled, et as buildOpenAIErrorEvent, fn as rememberLaunchSessionId, gn as resolveMcpToolTimeoutMs, gt as normalizeAdoToolsets, hn as warnOnTokenPriceDrift, ht as ADO_DEFAULT_TOOLSETS, i as assertMcpToolSurfaceConsistent, in as localBaseUrl, ir as CHEAP_PROFILE_MODELS, it as relayAnthropicStream, ln as findLaunchBySecret, lt as handleMcpDelete, mn as assembleResponsesPayload, mt as provisionAdoTools, nn as getTokenizerFromModel, nr as withOneMSuffixForLead, nt as logStreamError, on as countTokens, ot as UNKNOWN_EFFORT_ANCHOR, q as resolveAdvisorModel, qn as isBudgetClaudeLead, rr as CHEAP_PROFILE_ADVISOR_CLIENT_MODEL, rt as readIteratorWithTimeout, sn as createMessages, st as bucketEffort, tn as getTokenCount, tr as withOneMSuffix, tt as isControllerClosedError, ut as handleMcpPost, vn as createChatCompletions, vt as agentToolsEnabled, wn as normalizeOpenAIUsage, xn as parseJsonOrDiagnose, yn as MAX_RESPONSE_BODY_BYTES, z as CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS, zn as BUDGET_SMALL_FAST_SLUG } from "./peer-mcp-personas-DNtWI2C1.js";
|
|
11
|
+
import { D as LOCAL_PROFILE_TIER_MODELS, F as CHEAPEST_PROFILE_NATIVE_AGENT_NAMES, P as CHEAPEST_PROFILE_MODELS, S as localContractFor, _ as isCheapestFamily, b as isPinnedLaunchProfile, f as balancedContractFor, g as isBalancedFamily, h as displayModelName, k as CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL, p as cheapestContractFor, x as local2AdvisorContract, y as isLocalFamily } from "./static-context-pack-DvwLWlbe.js";
|
|
12
|
+
import { i as BALANCED_PROFILE_NATIVE_AGENT_NAMES, r as BALANCED_PROFILE_MODELS } from "./balanced-profile-contract-Dm_usmw7.js";
|
|
13
13
|
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-Cx5_Z1Y7.js";
|
|
14
14
|
import { f as getAzureRepoFromGit } from "./bluebird-client-C29-JOkG.js";
|
|
15
|
-
import { a as extractAndRecordPricedAic,
|
|
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-_mvGW2Ev.js";
|
|
16
16
|
import consola from "consola";
|
|
17
17
|
import fs, { existsSync } from "node:fs";
|
|
18
18
|
import path from "node:path";
|
|
19
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
19
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
20
20
|
import fs$1 from "node:fs/promises";
|
|
21
21
|
import os from "node:os";
|
|
22
22
|
import process$1 from "node:process";
|
|
@@ -30,21 +30,21 @@ import { Hono } from "hono";
|
|
|
30
30
|
import { cors } from "hono/cors";
|
|
31
31
|
//#region src/lib/claude-version-check.ts
|
|
32
32
|
const NPM_PACKAGE$1 = "@anthropic-ai/claude-code";
|
|
33
|
-
const THROTTLE_HOURS$
|
|
34
|
-
const NPM_VIEW_TIMEOUT_MS$
|
|
33
|
+
const THROTTLE_HOURS$2 = 1;
|
|
34
|
+
const NPM_VIEW_TIMEOUT_MS$2 = 5e3;
|
|
35
35
|
const CLAUDE_VERSION_TIMEOUT_MS = 3e3;
|
|
36
|
-
const NPM_INSTALL_TIMEOUT_MS = 12e4;
|
|
36
|
+
const NPM_INSTALL_TIMEOUT_MS$1 = 12e4;
|
|
37
37
|
/** Path to the throttle cache. Created on demand. */
|
|
38
|
-
function cacheFilePath$
|
|
38
|
+
function cacheFilePath$2() {
|
|
39
39
|
return path.join(os.homedir(), ".local", "share", "github-router", "last-update-check");
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Read the throttle cache. Returns null on missing/corrupt file —
|
|
43
43
|
* triggers a fresh check.
|
|
44
44
|
*/
|
|
45
|
-
async function readCache$
|
|
45
|
+
async function readCache$2() {
|
|
46
46
|
try {
|
|
47
|
-
const raw = await fs$1.readFile(cacheFilePath$
|
|
47
|
+
const raw = await fs$1.readFile(cacheFilePath$2(), "utf8");
|
|
48
48
|
const parsed = JSON.parse(raw);
|
|
49
49
|
if (typeof parsed.checkedAt !== "string" || parsed.installedVersion !== null && typeof parsed.installedVersion !== "string" || parsed.latestVersion !== null && typeof parsed.latestVersion !== "string") return null;
|
|
50
50
|
return parsed;
|
|
@@ -52,20 +52,20 @@ async function readCache$1() {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
async function writeCache$
|
|
55
|
+
async function writeCache$2(cache) {
|
|
56
56
|
try {
|
|
57
|
-
await fs$1.mkdir(path.dirname(cacheFilePath$
|
|
58
|
-
await fs$1.writeFile(cacheFilePath$
|
|
57
|
+
await fs$1.mkdir(path.dirname(cacheFilePath$2()), { recursive: true });
|
|
58
|
+
await fs$1.writeFile(cacheFilePath$2(), JSON.stringify(cache), { mode: 384 });
|
|
59
59
|
} catch (err) {
|
|
60
60
|
consola.debug("Failed to write claude version-check cache:", err);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/** Check if it's been more than THROTTLE_HOURS since the last check. */
|
|
64
|
-
function shouldCheckNow$
|
|
64
|
+
function shouldCheckNow$2(cache) {
|
|
65
65
|
if (!cache) return true;
|
|
66
66
|
const lastCheck = new Date(cache.checkedAt).getTime();
|
|
67
67
|
if (Number.isNaN(lastCheck)) return true;
|
|
68
|
-
return (Date.now() - lastCheck) / 1e3 / 3600 >= THROTTLE_HOURS$
|
|
68
|
+
return (Date.now() - lastCheck) / 1e3 / 3600 >= THROTTLE_HOURS$2;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Read the installed `claude` version. Returns null if claude is not
|
|
@@ -106,7 +106,7 @@ async function getLatestVersion$1() {
|
|
|
106
106
|
NPM_PACKAGE$1,
|
|
107
107
|
"version",
|
|
108
108
|
"--silent"
|
|
109
|
-
], { timeoutMs: NPM_VIEW_TIMEOUT_MS$
|
|
109
|
+
], { timeoutMs: NPM_VIEW_TIMEOUT_MS$2 });
|
|
110
110
|
if (code !== 0) return null;
|
|
111
111
|
const v = stdout.trim();
|
|
112
112
|
return /^\d+\.\d+\.\d+/.test(v) ? v : null;
|
|
@@ -145,8 +145,8 @@ async function checkClaudeVersion(opts = {}) {
|
|
|
145
145
|
skipped: true,
|
|
146
146
|
skipReason: "disabled"
|
|
147
147
|
};
|
|
148
|
-
const cache = await readCache$
|
|
149
|
-
if (!opts.force && !shouldCheckNow$
|
|
148
|
+
const cache = await readCache$2();
|
|
149
|
+
if (!opts.force && !shouldCheckNow$2(cache)) return {
|
|
150
150
|
installed: cache?.installedVersion !== null,
|
|
151
151
|
installedVersion: cache?.installedVersion ?? null,
|
|
152
152
|
latestVersion: cache?.latestVersion ?? null,
|
|
@@ -164,7 +164,7 @@ async function checkClaudeVersion(opts = {}) {
|
|
|
164
164
|
skipReason: "no-claude"
|
|
165
165
|
};
|
|
166
166
|
const latestVersion = await getLatestVersion$1();
|
|
167
|
-
await writeCache$
|
|
167
|
+
await writeCache$2({
|
|
168
168
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
169
169
|
installedVersion,
|
|
170
170
|
latestVersion
|
|
@@ -207,7 +207,7 @@ async function updateClaude(latestVersion, deps = {}) {
|
|
|
207
207
|
if (!claudePath) throw new Error("claude not found on PATH");
|
|
208
208
|
if (!await _lock("claude-update.lock", async () => {
|
|
209
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 });
|
|
210
|
+
const { code, stdout, stderr } = await _capture([claudePath, "update"], { timeoutMs: NPM_INSTALL_TIMEOUT_MS$1 });
|
|
211
211
|
const combined = `${stdout}${stderr}`;
|
|
212
212
|
const trimmed = combined.trim();
|
|
213
213
|
if (trimmed) process.stdout.write(trimmed.endsWith("\n") ? trimmed : `${trimmed}\n`);
|
|
@@ -225,7 +225,7 @@ async function updateClaude(latestVersion, deps = {}) {
|
|
|
225
225
|
"-g",
|
|
226
226
|
`${NPM_PACKAGE$1}@latest`,
|
|
227
227
|
"--silent"
|
|
228
|
-
], { timeoutMs: NPM_INSTALL_TIMEOUT_MS });
|
|
228
|
+
], { timeoutMs: NPM_INSTALL_TIMEOUT_MS$1 });
|
|
229
229
|
if (npmCode !== 0) throw new Error(`npm install failed: ${npmStderr.trim() || `exit ${npmCode}`}`);
|
|
230
230
|
consola.success(`${NPM_PACKAGE$1} updated to ${latestVersion}`);
|
|
231
231
|
})) consola.debug("Claude Code update already in progress in another process; skipping.");
|
|
@@ -249,33 +249,33 @@ async function updateClaude(latestVersion, deps = {}) {
|
|
|
249
249
|
* delay the proxy from serving.
|
|
250
250
|
*/
|
|
251
251
|
const NPM_PACKAGE = "github-router";
|
|
252
|
-
const THROTTLE_HOURS = 1;
|
|
253
|
-
const NPM_VIEW_TIMEOUT_MS = 5e3;
|
|
254
|
-
function cacheFilePath() {
|
|
252
|
+
const THROTTLE_HOURS$1 = 1;
|
|
253
|
+
const NPM_VIEW_TIMEOUT_MS$1 = 5e3;
|
|
254
|
+
function cacheFilePath$1() {
|
|
255
255
|
return path.join(os.homedir(), ".local", "share", "github-router", "last-self-update-check");
|
|
256
256
|
}
|
|
257
|
-
async function readCache() {
|
|
257
|
+
async function readCache$1() {
|
|
258
258
|
try {
|
|
259
|
-
const parsed = JSON.parse(await fs$1.readFile(cacheFilePath(), "utf8"));
|
|
259
|
+
const parsed = JSON.parse(await fs$1.readFile(cacheFilePath$1(), "utf8"));
|
|
260
260
|
if (typeof parsed.checkedAt !== "string") return null;
|
|
261
261
|
return parsed;
|
|
262
262
|
} catch {
|
|
263
263
|
return null;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
async function writeCache(cache) {
|
|
266
|
+
async function writeCache$1(cache) {
|
|
267
267
|
try {
|
|
268
|
-
await fs$1.mkdir(path.dirname(cacheFilePath()), { recursive: true });
|
|
269
|
-
await fs$1.writeFile(cacheFilePath(), JSON.stringify(cache), { mode: 384 });
|
|
268
|
+
await fs$1.mkdir(path.dirname(cacheFilePath$1()), { recursive: true });
|
|
269
|
+
await fs$1.writeFile(cacheFilePath$1(), JSON.stringify(cache), { mode: 384 });
|
|
270
270
|
} catch (err) {
|
|
271
271
|
consola.debug("Failed to write self-update cache:", err);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
function shouldCheckNow(cache) {
|
|
274
|
+
function shouldCheckNow$1(cache) {
|
|
275
275
|
if (!cache) return true;
|
|
276
276
|
const last = new Date(cache.checkedAt).getTime();
|
|
277
277
|
if (Number.isNaN(last)) return true;
|
|
278
|
-
return (Date.now() - last) / 1e3 / 3600 >= THROTTLE_HOURS;
|
|
278
|
+
return (Date.now() - last) / 1e3 / 3600 >= THROTTLE_HOURS$1;
|
|
279
279
|
}
|
|
280
280
|
async function getLatestVersion(npmPath) {
|
|
281
281
|
try {
|
|
@@ -285,7 +285,7 @@ async function getLatestVersion(npmPath) {
|
|
|
285
285
|
NPM_PACKAGE,
|
|
286
286
|
"version",
|
|
287
287
|
"--silent"
|
|
288
|
-
], { timeoutMs: NPM_VIEW_TIMEOUT_MS });
|
|
288
|
+
], { timeoutMs: NPM_VIEW_TIMEOUT_MS$1 });
|
|
289
289
|
if (code !== 0) return null;
|
|
290
290
|
const v = stdout.trim();
|
|
291
291
|
return /^\d+\.\d+\.\d+/.test(v) ? v : null;
|
|
@@ -356,14 +356,14 @@ async function runSelfUpdate(opts) {
|
|
|
356
356
|
if (!opts.selfUpdate) return;
|
|
357
357
|
if (parseBoolEnv(process.env.GH_ROUTER_NO_SELF_UPDATE) === true) return;
|
|
358
358
|
try {
|
|
359
|
-
const cache = await readCache();
|
|
360
|
-
if (!opts.force && !shouldCheckNow(cache)) return;
|
|
359
|
+
const cache = await readCache$1();
|
|
360
|
+
if (!opts.force && !shouldCheckNow$1(cache)) return;
|
|
361
361
|
const installed = getPackageVersion();
|
|
362
362
|
if (installed === "unknown") return;
|
|
363
363
|
const npmPath = resolveExecutable("npm");
|
|
364
364
|
if (!npmPath) return;
|
|
365
365
|
const latest = await getLatestVersion(npmPath);
|
|
366
|
-
await writeCache({
|
|
366
|
+
await writeCache$1({
|
|
367
367
|
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
368
368
|
installedVersion: installed,
|
|
369
369
|
latestVersion: latest
|
|
@@ -515,6 +515,30 @@ const CHEAPEST2_PROFILE = Object.freeze({
|
|
|
515
515
|
]),
|
|
516
516
|
hasCoordinator: false
|
|
517
517
|
});
|
|
518
|
+
/**
|
|
519
|
+
* The `-m cheaplocal` roster: `cheapest` exactly, with its Advisor and Oracle
|
|
520
|
+
* served by the local Anthropic-Messages endpoint rather than Copilot.
|
|
521
|
+
*
|
|
522
|
+
* The surface is inherited from the family contract and the group set is the
|
|
523
|
+
* cheapest one unchanged: the lead and natives are still Copilot calls, and the
|
|
524
|
+
* `workers` group works as it does on `cheapest` (subject to the profile's
|
|
525
|
+
* Copilot family ceiling, enforced at egress).
|
|
526
|
+
*/
|
|
527
|
+
const CHEAPLOCAL_PROFILE = Object.freeze({
|
|
528
|
+
id: "cheaplocal",
|
|
529
|
+
nativeRoster: new Set(cheapestContractFor("cheaplocal").nativeAgentNames),
|
|
530
|
+
personaAllowlist: /* @__PURE__ */ new Set(["oracle"]),
|
|
531
|
+
allowedGroups: /* @__PURE__ */ new Set([
|
|
532
|
+
"peers",
|
|
533
|
+
"search",
|
|
534
|
+
"workers",
|
|
535
|
+
"browser",
|
|
536
|
+
"ado",
|
|
537
|
+
"kusto",
|
|
538
|
+
"cloudagent"
|
|
539
|
+
]),
|
|
540
|
+
hasCoordinator: false
|
|
541
|
+
});
|
|
518
542
|
/** The `-m balanced2` roster: `balanced` with the Sol lead/reviewer at
|
|
519
543
|
* `gpt-6.1-sol` and the Oracle at `grok-4.7`. Roster unchanged. */
|
|
520
544
|
const BALANCED2_PROFILE = Object.freeze({
|
|
@@ -533,6 +557,59 @@ const BALANCED2_PROFILE = Object.freeze({
|
|
|
533
557
|
hasCoordinator: false
|
|
534
558
|
});
|
|
535
559
|
/**
|
|
560
|
+
* The `-m local` roster: the cheapest surface (same three-agent roster, no
|
|
561
|
+
* coordinator), with every role's model swapped for the local endpoint's tier
|
|
562
|
+
* id.
|
|
563
|
+
*
|
|
564
|
+
* No agent turn on a local launch reaches a Copilot model, so every group
|
|
565
|
+
* whose tools spawn one is absent: `workers` (the Pi workers resolve Copilot
|
|
566
|
+
* models) and every group built for model ties. `peers` is permitted only
|
|
567
|
+
* because the artifact tools live there and human review is not model
|
|
568
|
+
* inference, and the empty allow-list means no persona is listed or callable:
|
|
569
|
+
* with the artifact panel off the group holds nothing and neither launcher
|
|
570
|
+
* publishes it. What remains is the surface that is not an agent model call —
|
|
571
|
+
* `search` (in-process lexical/ColBERT plus the PAT-backed web search),
|
|
572
|
+
* `browser` (a local extension, whose page compressor is the one model-backed
|
|
573
|
+
* exception and carries its own fixed chain), and the three Azure data groups.
|
|
574
|
+
* The egress guard in `copilot-model-policy.ts` enforces the same rule from
|
|
575
|
+
* the other side, so a path that somehow reaches Copilot still refuses.
|
|
576
|
+
*/
|
|
577
|
+
const LOCAL_PROFILE = Object.freeze({
|
|
578
|
+
id: "local",
|
|
579
|
+
nativeRoster: new Set(localContractFor("local").nativeAgentNames),
|
|
580
|
+
personaAllowlist: /* @__PURE__ */ new Set(),
|
|
581
|
+
allowedGroups: /* @__PURE__ */ new Set([
|
|
582
|
+
"peers",
|
|
583
|
+
"search",
|
|
584
|
+
"browser",
|
|
585
|
+
"ado",
|
|
586
|
+
"kusto",
|
|
587
|
+
"cloudagent"
|
|
588
|
+
]),
|
|
589
|
+
hasCoordinator: false
|
|
590
|
+
});
|
|
591
|
+
/**
|
|
592
|
+
* The `-m local2` roster: `local` plus the curated `gpt-6.1-sol`/high Advisor.
|
|
593
|
+
* The Advisor and the Oracle are the only two Copilot consumers the profile
|
|
594
|
+
* has, so `peers` gains the Oracle persona next to the model-free artifact
|
|
595
|
+
* tools. `workers` stays absent as on `local`: a Pi worker is neither of the
|
|
596
|
+
* two exceptions.
|
|
597
|
+
*/
|
|
598
|
+
const LOCAL2_PROFILE = Object.freeze({
|
|
599
|
+
id: "local2",
|
|
600
|
+
nativeRoster: new Set(localContractFor("local2").nativeAgentNames),
|
|
601
|
+
personaAllowlist: /* @__PURE__ */ new Set(["oracle"]),
|
|
602
|
+
allowedGroups: /* @__PURE__ */ new Set([
|
|
603
|
+
"peers",
|
|
604
|
+
"search",
|
|
605
|
+
"browser",
|
|
606
|
+
"ado",
|
|
607
|
+
"kusto",
|
|
608
|
+
"cloudagent"
|
|
609
|
+
]),
|
|
610
|
+
hasCoordinator: false
|
|
611
|
+
});
|
|
612
|
+
/**
|
|
536
613
|
* The `-m max` profile: Sol/Luna-led, browse-only workers, and explicit
|
|
537
614
|
* cross-lab peer names. The descriptor is a hard projection for bound launch
|
|
538
615
|
* requests; unbound/BYO traffic remains standard because it has no registry
|
|
@@ -572,8 +649,11 @@ function profileDescriptor(id) {
|
|
|
572
649
|
if (id === "cheap") return CHEAP_PROFILE;
|
|
573
650
|
if (id === "cheapest") return CHEAPEST_PROFILE;
|
|
574
651
|
if (id === "cheapest2") return CHEAPEST2_PROFILE;
|
|
652
|
+
if (id === "cheaplocal") return CHEAPLOCAL_PROFILE;
|
|
575
653
|
if (id === "balanced") return BALANCED_PROFILE;
|
|
576
654
|
if (id === "balanced2") return BALANCED2_PROFILE;
|
|
655
|
+
if (id === "local") return LOCAL_PROFILE;
|
|
656
|
+
if (id === "local2") return LOCAL2_PROFILE;
|
|
577
657
|
return STANDARD_PROFILE;
|
|
578
658
|
}
|
|
579
659
|
/**
|
|
@@ -595,8 +675,11 @@ function resolveLaunchProfile(modelArg) {
|
|
|
595
675
|
if (arg === "cheap") return "cheap";
|
|
596
676
|
if (arg === "cheapest") return "cheapest";
|
|
597
677
|
if (arg === "cheapest2") return "cheapest2";
|
|
678
|
+
if (arg === "cheaplocal") return "cheaplocal";
|
|
598
679
|
if (arg === "balanced") return "balanced";
|
|
599
680
|
if (arg === "balanced2") return "balanced2";
|
|
681
|
+
if (arg === "local") return "local";
|
|
682
|
+
if (arg === "local2") return "local2";
|
|
600
683
|
return "standard";
|
|
601
684
|
}
|
|
602
685
|
function validateMaxProfileLaunch(catalog) {
|
|
@@ -1123,7 +1206,7 @@ function validateCheapestProfilePrerequisites(catalog, opts = {}, profileId = "c
|
|
|
1123
1206
|
if (!supportsEffort(luna, "high") || !supportsEffort(luna, "max") || !supportsEffort(luna, "xhigh")) missing.push(`${contract.models.lead}: does not advertise "high", "max", and "xhigh" reasoning effort`);
|
|
1124
1207
|
if (!supportsEndpoint(luna, "responses")) missing.push(`${contract.models.lead}: does not advertise a supported Responses endpoint`);
|
|
1125
1208
|
}
|
|
1126
|
-
if (peers) {
|
|
1209
|
+
if (peers && contract.consultTransport !== "local") {
|
|
1127
1210
|
const oracle = findModel(catalog, contract.oracleModel);
|
|
1128
1211
|
if (!oracle) missing.push(`${contract.oracleModel}: absent from the live catalog`);
|
|
1129
1212
|
else {
|
|
@@ -1132,6 +1215,8 @@ function validateCheapestProfilePrerequisites(catalog, opts = {}, profileId = "c
|
|
|
1132
1215
|
if (!supportsEndpoint(oracle, "responses")) missing.push(`${contract.oracleModel}: does not advertise a supported Responses endpoint`);
|
|
1133
1216
|
if (!hasUsablePromptMetadata(oracle)) missing.push(`${contract.oracleModel}: no usable max_prompt_tokens metadata (Oracle brief)`);
|
|
1134
1217
|
}
|
|
1218
|
+
}
|
|
1219
|
+
if (peers) {
|
|
1135
1220
|
const reviewer = findModel(catalog, contract.models.reviewer);
|
|
1136
1221
|
if (!reviewer) missing.push(`${contract.models.reviewer}: absent from the live catalog`);
|
|
1137
1222
|
else {
|
|
@@ -1229,6 +1314,61 @@ function validateBalancedProfilePrerequisites(catalog, opts = {}, profileId = "b
|
|
|
1229
1314
|
function formatBalancedPrerequisiteFailure(missing, profileId = "balanced") {
|
|
1230
1315
|
return `github-router claude -m ${profileId} requires the following live-catalog capabilities, which this account's catalog does not fully provide:\n` + missing.map((m) => ` - ${m}`).join("\n") + `\n\nFalling back or silently dropping an agent is not supported for the ${profileId} profile's exact roster. Run plain \`github-router claude\` instead.`;
|
|
1231
1316
|
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Validate the launch prerequisites for the `local` family.
|
|
1319
|
+
*
|
|
1320
|
+
* The LOCAL roster needs nothing from the Copilot catalog: its lead and its
|
|
1321
|
+
* native roles are the bare tier ids `opus` / `sonnet` / `haiku`, which the
|
|
1322
|
+
* local server resolves, and this profile deliberately makes no claim about
|
|
1323
|
+
* what that server can do (no context, effort, tool-call or endpoint check —
|
|
1324
|
+
* we do not know, and refusing to launch on a guess would be worse than
|
|
1325
|
+
* letting the server answer for itself).
|
|
1326
|
+
*
|
|
1327
|
+
* The ONE Copilot model the family still consumes is `local2`'s Advisor:
|
|
1328
|
+
* `gpt-6.1-sol`, server-side, at its default context and `high` effort. That
|
|
1329
|
+
* model is checked here, and only for `local2`. `local` has no advisor at the
|
|
1330
|
+
* type level, so passing its contract would be a programming error rather
|
|
1331
|
+
* than a launch to validate.
|
|
1332
|
+
*
|
|
1333
|
+
* Contrast with `validateCheapestProfilePrerequisites`: there the whole roster
|
|
1334
|
+
* IS the catalog, so every role is checked.
|
|
1335
|
+
*/
|
|
1336
|
+
function validateLocalProfilePrerequisites(catalog, profileId = "local") {
|
|
1337
|
+
if (profileId !== "local2") return {
|
|
1338
|
+
ok: true,
|
|
1339
|
+
missing: []
|
|
1340
|
+
};
|
|
1341
|
+
const contract = local2AdvisorContract();
|
|
1342
|
+
const advisorModel = contract.advisorModel;
|
|
1343
|
+
const missing = [];
|
|
1344
|
+
const advisor = findModel(catalog, advisorModel);
|
|
1345
|
+
if (!advisor) {
|
|
1346
|
+
missing.push(`${advisorModel}: absent from the live catalog (the ${profileId} Advisor)`);
|
|
1347
|
+
return {
|
|
1348
|
+
ok: false,
|
|
1349
|
+
missing
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
if (!hasToolCalls(advisor)) missing.push(`${advisorModel}: does not advertise tool_calls`);
|
|
1353
|
+
if (!hasContextAtLeast(advisor, contract.subagentContextTokens)) missing.push(`${advisorModel}: advertised context window is below the 200K subagent floor`);
|
|
1354
|
+
if (!supportsEffort(advisor, contract.advisorEffort)) missing.push(`${advisorModel}: does not advertise a "${contract.advisorEffort}" reasoning effort`);
|
|
1355
|
+
if (!supportsEndpoint(advisor, "responses")) missing.push(`${advisorModel}: does not advertise a supported Responses endpoint`);
|
|
1356
|
+
return {
|
|
1357
|
+
ok: missing.length === 0,
|
|
1358
|
+
missing
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Format `validateLocalProfilePrerequisites`'s failure list. The local roles
|
|
1363
|
+
* themselves are never in the list — they need no catalog entry — so the
|
|
1364
|
+
* message names the Advisor explicitly rather than implying the roster failed.
|
|
1365
|
+
*
|
|
1366
|
+
* `command` is the subcommand whose launch failed (`claude` or `pi`), so the
|
|
1367
|
+
* remedy the message prints is one the user can actually type.
|
|
1368
|
+
*/
|
|
1369
|
+
function formatLocalPrerequisiteFailure(missing, profileId = "local", command = "claude") {
|
|
1370
|
+
return `github-router ${command} -m ${profileId} requires the following Copilot capabilities for its server-side Advisor, which this account's catalog does not fully provide:\n` + missing.map((m) => ` - ${m}`).join("\n") + "\n\nThe lead and native roles run on the local endpoint and need no catalog entry; only the Advisor is served by Copilot. Drop the Advisor by launching `-m local` instead.";
|
|
1371
|
+
}
|
|
1232
1372
|
//#endregion
|
|
1233
1373
|
//#region src/lib/file-log-reporter.ts
|
|
1234
1374
|
const MAX_LOG_BYTES = 1048576;
|
|
@@ -1653,6 +1793,34 @@ const CHEAPEST2_PICKER_MODELS = pinnedRows(cheapestContractFor("cheapest2").advi
|
|
|
1653
1793
|
const BALANCED_PICKER_MODELS = pinnedRows(balancedContractFor("balanced").models.lead, balancedContractFor("balanced").oracleModel);
|
|
1654
1794
|
const BALANCED2_PICKER_MODELS = pinnedRows(balancedContractFor("balanced2").models.lead, balancedContractFor("balanced2").oracleModel);
|
|
1655
1795
|
/**
|
|
1796
|
+
* The `local` / `local2` rows: the three tier ids the local endpoint itself
|
|
1797
|
+
* resolves, emitted BARE and never catalog-filtered.
|
|
1798
|
+
*
|
|
1799
|
+
* These are not Copilot ids and must never be resolved through the catalog:
|
|
1800
|
+
* the proxy deliberately knows nothing about what is loaded behind the port.
|
|
1801
|
+
* `behavesAs` exists only because Claude Code 2.1.260 does not OFFER an
|
|
1802
|
+
* otherwise-unknown picker row without it; it supplies the closest
|
|
1803
|
+
* client-known capability profile and changes neither the label nor the id
|
|
1804
|
+
* that is sent.
|
|
1805
|
+
*/
|
|
1806
|
+
const LOCAL_PICKER_MODELS = Object.freeze([
|
|
1807
|
+
{
|
|
1808
|
+
id: "opus",
|
|
1809
|
+
label: "Opus",
|
|
1810
|
+
behavesAs: "claude-opus-5.5"
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
id: "sonnet",
|
|
1814
|
+
label: "Sonnet",
|
|
1815
|
+
behavesAs: "claude-sonnet-5"
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
id: "haiku",
|
|
1819
|
+
label: "Haiku",
|
|
1820
|
+
behavesAs: "claude-haiku-4-5"
|
|
1821
|
+
}
|
|
1822
|
+
]);
|
|
1823
|
+
/**
|
|
1656
1824
|
* Return the ordered, profile-specific `/model` rows supported by the live
|
|
1657
1825
|
* Copilot catalog. Fast intentionally shares Standard's four-row inventory;
|
|
1658
1826
|
* Max replaces Grok with Opus because Grok is not an allowed Max lead.
|
|
@@ -1666,6 +1834,11 @@ const BALANCED2_PICKER_MODELS = pinnedRows(balancedContractFor("balanced2").mode
|
|
|
1666
1834
|
* each profile's actual model/effort contract.
|
|
1667
1835
|
*/
|
|
1668
1836
|
function selectableModelsInCatalog(profile) {
|
|
1837
|
+
if (isLocalFamily(profile)) return LOCAL_PICKER_MODELS.map((entry) => ({
|
|
1838
|
+
model: entry.id,
|
|
1839
|
+
label: entry.label,
|
|
1840
|
+
behavesAs: entry.behavesAs
|
|
1841
|
+
}));
|
|
1669
1842
|
const catalog = state.models?.data;
|
|
1670
1843
|
if (!catalog || catalog.length === 0) return [];
|
|
1671
1844
|
const present = new Set(catalog.map((entry) => entry.id));
|
|
@@ -1707,7 +1880,7 @@ async function renameSettingsWithRetry(temp, target) {
|
|
|
1707
1880
|
* 200K session's `/model` UI.
|
|
1708
1881
|
*/
|
|
1709
1882
|
function routerWinsPicker(profile) {
|
|
1710
|
-
return profile === "fast" || profile === "cheap" || profile === "cheap1m" || isCheapestFamily(profile) || isBalancedFamily(profile);
|
|
1883
|
+
return profile === "fast" || profile === "cheap" || profile === "cheap1m" || isCheapestFamily(profile) || isBalancedFamily(profile) || isLocalFamily(profile);
|
|
1711
1884
|
}
|
|
1712
1885
|
function modelIdsFromExistingPicker(value) {
|
|
1713
1886
|
if (!value || typeof value !== "object" || Array.isArray(value)) return [];
|
|
@@ -2605,6 +2778,413 @@ function deriveAutoCompactWindowTokens(maxPromptTokens, maxOutputTokens) {
|
|
|
2605
2778
|
return Math.min(ENV_WINDOW_MAX_TOKENS, Math.max(ENV_WINDOW_MIN_TOKENS, window));
|
|
2606
2779
|
}
|
|
2607
2780
|
//#endregion
|
|
2781
|
+
//#region src/lib/pi-paths.ts
|
|
2782
|
+
function appDir() {
|
|
2783
|
+
return path.join(os.homedir(), ".local", "share", "github-router");
|
|
2784
|
+
}
|
|
2785
|
+
/** Where the user's real Pi agent dir lives (`PI_CODING_AGENT_DIR` wins). */
|
|
2786
|
+
function userPiAgentDir() {
|
|
2787
|
+
const override = (process.env.PI_CODING_AGENT_DIR ?? "").trim();
|
|
2788
|
+
if (override.length > 0) return override;
|
|
2789
|
+
return path.join(os.homedir(), ".pi", "agent");
|
|
2790
|
+
}
|
|
2791
|
+
/**
|
|
2792
|
+
* Per-launch suffix for the Pi mirror. Lazily generated once per process
|
|
2793
|
+
* so every path getter in this module agrees on the directory.
|
|
2794
|
+
*/
|
|
2795
|
+
let launchSuffix;
|
|
2796
|
+
function perLaunchSuffix() {
|
|
2797
|
+
launchSuffix ??= `pi-agent-${process.pid}-${randomBytes(4).toString("hex")}`;
|
|
2798
|
+
return launchSuffix;
|
|
2799
|
+
}
|
|
2800
|
+
/** Router-owned, per-launch Pi agent dir for the spawned `pi` child. */
|
|
2801
|
+
function piMirrorDir() {
|
|
2802
|
+
return path.join(appDir(), "pi-mirrors", perLaunchSuffix());
|
|
2803
|
+
}
|
|
2804
|
+
/**
|
|
2805
|
+
* Router-owned, durable Pi session store, shared by every launch.
|
|
2806
|
+
*
|
|
2807
|
+
* Pi's default session root is `<agent dir>/sessions/`, and the agent dir is
|
|
2808
|
+
* the per-launch mirror we delete on shutdown, so quitting used to take the
|
|
2809
|
+
* whole transcript history with it and `--continue` / `--resume` had nothing
|
|
2810
|
+
* left to resume. One stable root, handed to the child as
|
|
2811
|
+
* `PI_CODING_AGENT_SESSION_DIR`, outlives every launch. Pi groups sessions by
|
|
2812
|
+
* working directory under that root, so per-workspace history stays separate
|
|
2813
|
+
* and `--continue` still picks the right one.
|
|
2814
|
+
*
|
|
2815
|
+
* Deliberately outside `sweepStalePiAgentMirrors`: that sweep reaps mirrors by
|
|
2816
|
+
* PID because they are scratch, and this directory is history. Nothing here
|
|
2817
|
+
* ages it out either — Pi documents no retention policy, and the session
|
|
2818
|
+
* picker's delete is the user-facing pruning surface.
|
|
2819
|
+
*/
|
|
2820
|
+
function piSessionsDir() {
|
|
2821
|
+
return path.join(appDir(), "pi-sessions");
|
|
2822
|
+
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Provision the per-launch Pi mirror: snapshot-copy the user's real Pi
|
|
2825
|
+
* agent dir (settings, models, skills, prompts, extensions the user owns)
|
|
2826
|
+
* so the spawned `pi` starts from the user's own setup, then let the
|
|
2827
|
+
* launcher overlay the mode's generated files on top.
|
|
2828
|
+
*
|
|
2829
|
+
* Copy failures of individual user files are debug-logged and skipped —
|
|
2830
|
+
* a corrupt user file must not strand the launch. Throws only when the
|
|
2831
|
+
* mirror directory itself cannot be created.
|
|
2832
|
+
*/
|
|
2833
|
+
async function ensurePiAgentMirror() {
|
|
2834
|
+
const mirror = piMirrorDir();
|
|
2835
|
+
await fs$1.mkdir(mirror, { recursive: true });
|
|
2836
|
+
await fs$1.mkdir(piSessionsDir(), { recursive: true });
|
|
2837
|
+
const source = userPiAgentDir();
|
|
2838
|
+
let entries;
|
|
2839
|
+
try {
|
|
2840
|
+
entries = await fs$1.readdir(source);
|
|
2841
|
+
} catch {
|
|
2842
|
+
return mirror;
|
|
2843
|
+
}
|
|
2844
|
+
const keepUserExtensions = process.env.GH_ROUTER_PI_KEEP_USER_EXTENSIONS === "1";
|
|
2845
|
+
const SKIP = /* @__PURE__ */ new Set([
|
|
2846
|
+
"auth.json",
|
|
2847
|
+
"sessions",
|
|
2848
|
+
"models-store.json",
|
|
2849
|
+
...keepUserExtensions ? [] : ["extensions"]
|
|
2850
|
+
]);
|
|
2851
|
+
await Promise.all(entries.filter((e) => !SKIP.has(e)).map(async (entry) => {
|
|
2852
|
+
try {
|
|
2853
|
+
await fs$1.cp(path.join(source, entry), path.join(mirror, entry), { recursive: true });
|
|
2854
|
+
} catch (err) {
|
|
2855
|
+
consola.debug(`Pi mirror: skipping ${entry}:`, err);
|
|
2856
|
+
}
|
|
2857
|
+
}));
|
|
2858
|
+
return mirror;
|
|
2859
|
+
}
|
|
2860
|
+
/** Remove THIS launch's Pi mirror on shutdown. Best-effort, never throws. */
|
|
2861
|
+
async function removeOwnPiAgentMirror() {
|
|
2862
|
+
try {
|
|
2863
|
+
await fs$1.rm(piMirrorDir(), {
|
|
2864
|
+
recursive: true,
|
|
2865
|
+
force: true
|
|
2866
|
+
});
|
|
2867
|
+
} catch (err) {
|
|
2868
|
+
consola.debug("Pi mirror cleanup failed:", err);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Sweep stale Pi mirrors left behind by crashed launches (dirs whose PID
|
|
2873
|
+
* no longer exists, or older than 24h). Best-effort, never throws.
|
|
2874
|
+
*/
|
|
2875
|
+
async function sweepStalePiAgentMirrors() {
|
|
2876
|
+
const root = path.join(appDir(), "pi-mirrors");
|
|
2877
|
+
let entries;
|
|
2878
|
+
try {
|
|
2879
|
+
entries = await fs$1.readdir(root);
|
|
2880
|
+
} catch {
|
|
2881
|
+
return;
|
|
2882
|
+
}
|
|
2883
|
+
await Promise.all(entries.map(async (entry) => {
|
|
2884
|
+
const dir = path.join(root, entry);
|
|
2885
|
+
try {
|
|
2886
|
+
const stat = await fs$1.stat(dir);
|
|
2887
|
+
const ageMs = Date.now() - stat.mtimeMs;
|
|
2888
|
+
const pidMatch = /^pi-agent-(\d+)-[0-9a-f]+$/.exec(entry);
|
|
2889
|
+
let dead = ageMs > 864e5;
|
|
2890
|
+
if (pidMatch && !dead) {
|
|
2891
|
+
const pid = Number.parseInt(pidMatch[1], 10);
|
|
2892
|
+
try {
|
|
2893
|
+
process.kill(pid, 0);
|
|
2894
|
+
} catch {
|
|
2895
|
+
dead = true;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
if (dead) await fs$1.rm(dir, {
|
|
2899
|
+
recursive: true,
|
|
2900
|
+
force: true
|
|
2901
|
+
});
|
|
2902
|
+
} catch (err) {
|
|
2903
|
+
consola.debug(`Pi mirror sweep: skipping ${entry}:`, err);
|
|
2904
|
+
}
|
|
2905
|
+
}));
|
|
2906
|
+
}
|
|
2907
|
+
//#endregion
|
|
2908
|
+
//#region 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
|
+
//#endregion
|
|
2608
3188
|
//#region src/lib/proxy.ts
|
|
2609
3189
|
let socketCounter = 0;
|
|
2610
3190
|
/**
|
|
@@ -2958,7 +3538,7 @@ function collectToolFieldKeys(body) {
|
|
|
2958
3538
|
//#endregion
|
|
2959
3539
|
//#region package.json
|
|
2960
3540
|
var name = "github-router";
|
|
2961
|
-
var version = "0.3.
|
|
3541
|
+
var version = "0.3.369";
|
|
2962
3542
|
//#endregion
|
|
2963
3543
|
//#region src/lib/approval.ts
|
|
2964
3544
|
const awaitApproval = async () => {
|
|
@@ -3826,6 +4406,7 @@ completionRoutes.post("/", async (c) => {
|
|
|
3826
4406
|
//#endregion
|
|
3827
4407
|
//#region src/services/copilot/create-embeddings.ts
|
|
3828
4408
|
const createEmbeddings = async (payload) => {
|
|
4409
|
+
assertCopilotModelAllowed(payload.model);
|
|
3829
4410
|
if (!state.copilotToken) throw new Error("Copilot token not found");
|
|
3830
4411
|
const body = JSON.stringify(payload);
|
|
3831
4412
|
const response = await fetchWithTransientRetry(() => tryRefreshAndRetry(() => fetch(`${copilotBaseUrl(state)}/embeddings`, {
|
|
@@ -5996,11 +6577,23 @@ const LAUNCH_SECRET_HEADER = "X-GH-Router-Launch-Secret";
|
|
|
5996
6577
|
*/
|
|
5997
6578
|
function runMessagesIdentityPreflight(c) {
|
|
5998
6579
|
const header = c.req.header(LAUNCH_SECRET_HEADER);
|
|
5999
|
-
if (
|
|
6000
|
-
|
|
6580
|
+
if (header) {
|
|
6581
|
+
const launch = findLaunchBySecret(header);
|
|
6582
|
+
if (!launch) return {
|
|
6583
|
+
ok: false,
|
|
6584
|
+
reason: "X-GH-Router-Launch-Secret header did not match any registered launch (the launch may have been restarted, or the header was tampered with)"
|
|
6585
|
+
};
|
|
6586
|
+
return {
|
|
6587
|
+
ok: true,
|
|
6588
|
+
launch
|
|
6589
|
+
};
|
|
6590
|
+
}
|
|
6591
|
+
const bearerSecret = launchSecretFromBearer(c.req.header("authorization"));
|
|
6592
|
+
if (bearerSecret === void 0) return { ok: true };
|
|
6593
|
+
const launch = bearerSecret ? findLaunchBySecret(bearerSecret) : void 0;
|
|
6001
6594
|
if (!launch) return {
|
|
6002
6595
|
ok: false,
|
|
6003
|
-
reason:
|
|
6596
|
+
reason: `Authorization bearer carried a ${LAUNCH_BOUND_TOKEN_PREFIX} launch token that did not match any registered launch (the launch may have been restarted, or the token was tampered with)`
|
|
6004
6597
|
};
|
|
6005
6598
|
return {
|
|
6006
6599
|
ok: true,
|
|
@@ -6008,6 +6601,24 @@ function runMessagesIdentityPreflight(c) {
|
|
|
6008
6601
|
};
|
|
6009
6602
|
}
|
|
6010
6603
|
/**
|
|
6604
|
+
* Pull the launch secret out of an `Authorization: Bearer` value.
|
|
6605
|
+
*
|
|
6606
|
+
* Returns `undefined` for anything that does not assert a launch identity:
|
|
6607
|
+
* a missing header, another scheme, or the shared `github-router-synthetic`
|
|
6608
|
+
* token. Returns an empty string for a prefixed but empty token, which the
|
|
6609
|
+
* caller treats as a failed match rather than as unbound traffic — a request
|
|
6610
|
+
* that says "I am this launch" and names nobody is never silently downgraded
|
|
6611
|
+
* to BYO.
|
|
6612
|
+
*/
|
|
6613
|
+
function launchSecretFromBearer(authorization) {
|
|
6614
|
+
if (!authorization) return void 0;
|
|
6615
|
+
const match = /^Bearer\s+(.+)$/i.exec(authorization.trim());
|
|
6616
|
+
if (!match) return void 0;
|
|
6617
|
+
const token = match[1].trim();
|
|
6618
|
+
if (!token.startsWith("github-router-launch:")) return void 0;
|
|
6619
|
+
return token.slice(LAUNCH_BOUND_TOKEN_PREFIX.length);
|
|
6620
|
+
}
|
|
6621
|
+
/**
|
|
6011
6622
|
* Anthropic-shaped rejection for a failed identity preflight. 403, never
|
|
6012
6623
|
* 401 — see the no-401 invariant note on `runMessagesIdentityPreflight`.
|
|
6013
6624
|
*/
|
|
@@ -6169,6 +6780,11 @@ function preprocessFastRequest(rawBody, launch, subagentRequest = false) {
|
|
|
6169
6780
|
body: rawBody,
|
|
6170
6781
|
modified: false
|
|
6171
6782
|
};
|
|
6783
|
+
if (isLocalFamily(launch?.profileId)) return {
|
|
6784
|
+
body: rawBody,
|
|
6785
|
+
originalModel,
|
|
6786
|
+
modified: false
|
|
6787
|
+
};
|
|
6172
6788
|
if (isRetiredFastModelAlias(originalModel)) return {
|
|
6173
6789
|
body: rawBody,
|
|
6174
6790
|
originalModel,
|
|
@@ -6453,6 +7069,22 @@ function extractBetaHeaders(c) {
|
|
|
6453
7069
|
return headers;
|
|
6454
7070
|
}
|
|
6455
7071
|
/**
|
|
7072
|
+
* Beta headers for a local-profile request: forwarded VERBATIM.
|
|
7073
|
+
*
|
|
7074
|
+
* `filterBetaHeader`'s allowlist is a list of capabilities COPILOT supports.
|
|
7075
|
+
* A local server's capabilities are unknowable by construction (the profile
|
|
7076
|
+
* assumes nothing about the stack behind the endpoint), so filtering here would
|
|
7077
|
+
* strip features the server may well implement. The one value removed is the
|
|
7078
|
+
* proxy's own `advisor-tool-` beta: the router consumes that marker rather than
|
|
7079
|
+
* forwarding it, on every profile.
|
|
7080
|
+
*/
|
|
7081
|
+
function rawLocalBetaHeaders(c) {
|
|
7082
|
+
const anthropicBeta = c.req.header("anthropic-beta");
|
|
7083
|
+
if (!anthropicBeta) return {};
|
|
7084
|
+
const kept = anthropicBeta.split(",").map((part) => part.trim()).filter((part) => part.length > 0 && !part.startsWith("advisor-tool-"));
|
|
7085
|
+
return kept.length > 0 ? { "anthropic-beta": kept.join(",") } : {};
|
|
7086
|
+
}
|
|
7087
|
+
/**
|
|
6456
7088
|
* Extract the text content from the last user message for web search.
|
|
6457
7089
|
* Handles both string content and content block arrays (multimodal).
|
|
6458
7090
|
*/
|
|
@@ -6625,6 +7257,7 @@ async function handleCompletion(c) {
|
|
|
6625
7257
|
const startTime = Date.now();
|
|
6626
7258
|
const identity = runMessagesIdentityPreflight(c);
|
|
6627
7259
|
if (!identity.ok) return identityPreflightErrorResponse(c, identity.reason);
|
|
7260
|
+
rememberLaunchSessionId(identity.launch, c.req.header("x-claude-code-session-id"));
|
|
6628
7261
|
await checkRateLimit(state);
|
|
6629
7262
|
const rawBody = await c.req.text();
|
|
6630
7263
|
recordBodySize(rawBody.length);
|
|
@@ -6697,7 +7330,8 @@ async function handleCompletion(c) {
|
|
|
6697
7330
|
});
|
|
6698
7331
|
}
|
|
6699
7332
|
if (state.manualApprove) await awaitApproval();
|
|
6700
|
-
const
|
|
7333
|
+
const localProfileRequest = effectiveLocalProfile(identity.launch?.profileId) !== void 0;
|
|
7334
|
+
const betaHeaders = localProfileRequest ? rawLocalBetaHeaders(c) : extractBetaHeaders(c);
|
|
6701
7335
|
const incomingBeta = c.req.header("anthropic-beta");
|
|
6702
7336
|
const advisorRequested = isAdvisorRequested(incomingBeta);
|
|
6703
7337
|
const fastProfileRequest = identity.launch?.profileId === "fast";
|
|
@@ -6705,8 +7339,12 @@ async function handleCompletion(c) {
|
|
|
6705
7339
|
const cheapProfileRequest = identity.launch?.profileId === "cheap" || identity.launch?.profileId === "cheap1m";
|
|
6706
7340
|
const cheapestProfileRequest = isCheapestFamily(identity.launch?.profileId);
|
|
6707
7341
|
const balancedProfileRequest = isBalancedFamily(identity.launch?.profileId);
|
|
6708
|
-
const
|
|
6709
|
-
const
|
|
7342
|
+
const localAdvisorRequest = identity.launch?.profileId === "local2";
|
|
7343
|
+
const curatedAdvisorContract = localAdvisorRequest ? local2AdvisorContract() : cheapestProfileRequest ? cheapestContractFor(identity.launch?.profileId) : void 0;
|
|
7344
|
+
const curatedAdvisorModel = curatedAdvisorContract?.advisorModel;
|
|
7345
|
+
const curatedAdvisorClientModel = curatedAdvisorContract?.advisorClientModel;
|
|
7346
|
+
const curatedLocalConsult = curatedAdvisorContract?.consultTransport === "local";
|
|
7347
|
+
const curatedAdvisorLocalEffort = curatedLocalConsult ? curatedAdvisorContract?.advisorEffort : void 0;
|
|
6710
7348
|
const subagentAgentId = (c.req.header("x-claude-code-agent-id") ?? "").trim();
|
|
6711
7349
|
const subagentRequest = subagentAgentId.length > 0;
|
|
6712
7350
|
const fastSubagentRequest = fastProfileRequest && subagentRequest;
|
|
@@ -6717,16 +7355,18 @@ async function handleCompletion(c) {
|
|
|
6717
7355
|
const fastLeadAdvisor = fastProfileRequest && !fastSubagentRequest;
|
|
6718
7356
|
const maxLeadAdvisor = maxProfileRequest && !maxSubagentRequest;
|
|
6719
7357
|
const cheapLeadAdvisor = cheapProfileRequest && !cheapSubagentRequest;
|
|
6720
|
-
const
|
|
7358
|
+
const curatedLeadAdvisor = cheapestProfileRequest && !cheapestSubagentRequest || localAdvisorRequest && !subagentRequest;
|
|
6721
7359
|
const cheapestReviewerAdvisor = cheapestProfileRequest && (subagentAgentId === "reviewer" || isCheapestReviewerModel(rawBody));
|
|
6722
|
-
|
|
6723
|
-
|
|
7360
|
+
const localReviewerAdvisor = localAdvisorRequest && (subagentAgentId === "reviewer" || subagentAgentId.startsWith("reviewer-"));
|
|
7361
|
+
if ((cheapestProfileRequest || localAdvisorRequest) && subagentRequest) consola.debug(`curated subagent advisor gate: agentId=${JSON.stringify(subagentAgentId)} reviewerModel=${isCheapestReviewerModel(rawBody)} granted=${(cheapestReviewerAdvisor || localReviewerAdvisor) && advisorRequested}`);
|
|
7362
|
+
const advisorEnabled = advisorRequested && !localProfileRequest && !fastSubagentRequest && !maxSubagentRequest && !cheapSubagentRequest && (!cheapestSubagentRequest || cheapestReviewerAdvisor) && !balancedSubagentRequest;
|
|
6724
7363
|
const fastAdvisorEnabled = fastLeadAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
|
|
6725
7364
|
const maxAdvisorEnabled = maxLeadAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
|
|
6726
7365
|
const cheapAdvisorEnabled = cheapLeadAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
|
|
6727
|
-
const
|
|
6728
|
-
const
|
|
6729
|
-
const
|
|
7366
|
+
const curatedAdvisorEnabled = curatedLeadAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
|
|
7367
|
+
const curatedReviewerAdvisor = cheapestReviewerAdvisor || localReviewerAdvisor;
|
|
7368
|
+
const curatedReviewerEnabled = curatedReviewerAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
|
|
7369
|
+
const advisorBehaviorEnabled = balancedProfileRequest ? false : localProfileRequest ? curatedAdvisorEnabled || curatedReviewerEnabled : fastLeadAdvisor ? fastAdvisorEnabled : cheapLeadAdvisor ? cheapAdvisorEnabled : curatedLeadAdvisor ? curatedAdvisorEnabled : maxLeadAdvisor ? maxAdvisorEnabled : curatedReviewerAdvisor ? curatedReviewerEnabled : advisorEnabled;
|
|
6730
7370
|
let fastAdvisorChoice;
|
|
6731
7371
|
let maxAdvisorChoice;
|
|
6732
7372
|
if (maxAdvisorEnabled) {
|
|
@@ -6787,17 +7427,21 @@ async function handleCompletion(c) {
|
|
|
6787
7427
|
}, 503);
|
|
6788
7428
|
}
|
|
6789
7429
|
}
|
|
6790
|
-
if (
|
|
6791
|
-
const mismatch = cheapestAdvisorMetadataMismatch(rawBody,
|
|
6792
|
-
if (mismatch)
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
7430
|
+
if (curatedAdvisorEnabled) {
|
|
7431
|
+
const mismatch = cheapestAdvisorMetadataMismatch(rawBody, curatedAdvisorClientModel ?? CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL);
|
|
7432
|
+
if (mismatch) {
|
|
7433
|
+
const curatedLabel = localAdvisorRequest ? "Local Advisor" : curatedLocalConsult ? "Cheap local Advisor" : "Cheapest Advisor";
|
|
7434
|
+
const curatedAlias = localAdvisorRequest ? "local2" : curatedLocalConsult ? "cheaplocal" : "cheapest";
|
|
7435
|
+
return c.json({
|
|
7436
|
+
type: "error",
|
|
7437
|
+
error: {
|
|
7438
|
+
type: "invalid_request_error",
|
|
7439
|
+
message: `${curatedLabel} model mismatch: ${mismatch}. Run \`/advisor ${curatedAdvisorClientModel ?? CHEAPEST_PROFILE_ADVISOR_CLIENT_MODEL}\` to restore the fixed ${curatedAlias} profile, or relaunch with \`github-router claude -m ${identity.launch?.profileId ?? curatedAlias}\`.`
|
|
7440
|
+
}
|
|
7441
|
+
}, 400);
|
|
7442
|
+
}
|
|
6799
7443
|
try {
|
|
6800
|
-
fastAdvisorChoice =
|
|
7444
|
+
fastAdvisorChoice = resolveCuratedAdvisorModel(curatedAdvisorModel, curatedAdvisorContract?.consultTransport ?? "copilot");
|
|
6801
7445
|
} catch (error) {
|
|
6802
7446
|
return c.json({
|
|
6803
7447
|
type: "error",
|
|
@@ -6808,8 +7452,8 @@ async function handleCompletion(c) {
|
|
|
6808
7452
|
}, 503);
|
|
6809
7453
|
}
|
|
6810
7454
|
}
|
|
6811
|
-
if (
|
|
6812
|
-
fastAdvisorChoice =
|
|
7455
|
+
if (curatedReviewerEnabled && !fastAdvisorChoice) try {
|
|
7456
|
+
fastAdvisorChoice = resolveCuratedAdvisorModel(curatedAdvisorModel, curatedAdvisorContract?.consultTransport ?? "copilot");
|
|
6813
7457
|
} catch (error) {
|
|
6814
7458
|
return c.json({
|
|
6815
7459
|
type: "error",
|
|
@@ -6834,7 +7478,7 @@ async function handleCompletion(c) {
|
|
|
6834
7478
|
}
|
|
6835
7479
|
let finalBody = await processWebSearch(fastPreprocess.body);
|
|
6836
7480
|
finalBody = sanitizeAnthropicBody(finalBody);
|
|
6837
|
-
if (fastSubagentRequest || maxSubagentRequest || cheapestSubagentRequest && !cheapestReviewerAdvisor) finalBody = stripAdvisorTool(finalBody);
|
|
7481
|
+
if (fastSubagentRequest || maxSubagentRequest || cheapestSubagentRequest && !cheapestReviewerAdvisor || localProfileRequest && !advisorBehaviorEnabled) finalBody = stripAdvisorTool(finalBody);
|
|
6838
7482
|
const loopGuard = guardAnthropicBody(finalBody);
|
|
6839
7483
|
if (loopGuard.action === "abort") return c.json({
|
|
6840
7484
|
type: "error",
|
|
@@ -6845,7 +7489,17 @@ async function handleCompletion(c) {
|
|
|
6845
7489
|
}, 400, { "x-should-retry": "false" });
|
|
6846
7490
|
if (loopGuard.body !== void 0) finalBody = loopGuard.body;
|
|
6847
7491
|
if (advisorBehaviorEnabled) {
|
|
6848
|
-
|
|
7492
|
+
const curatedAdvisorInstructions = localAdvisorRequest ? {
|
|
7493
|
+
lead: LOCAL_ADVISOR_TOOL_INSTRUCTIONS,
|
|
7494
|
+
reviewer: LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS
|
|
7495
|
+
} : curatedLocalConsult ? {
|
|
7496
|
+
lead: CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS,
|
|
7497
|
+
reviewer: CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS
|
|
7498
|
+
} : {
|
|
7499
|
+
lead: CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS,
|
|
7500
|
+
reviewer: CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS
|
|
7501
|
+
};
|
|
7502
|
+
finalBody = injectAdvisorTool(finalBody, curatedReviewerAdvisor ? curatedAdvisorInstructions.reviewer : curatedLeadAdvisor ? curatedAdvisorInstructions.lead : fastLeadAdvisor ? FAST_ADVISOR_TOOL_INSTRUCTIONS : maxLeadAdvisor ? MAX_PROFILE_ADVISOR_INSTRUCTIONS : void 0);
|
|
6849
7503
|
consola.info("ADVISOR enabled for this request — injecting __anthropic_advisor tool; will translate tool_use → server_tool_use{advisor} on the SSE stream");
|
|
6850
7504
|
}
|
|
6851
7505
|
if (finalBody.includes("\"mcp_servers\"")) try {
|
|
@@ -6858,10 +7512,10 @@ async function handleCompletion(c) {
|
|
|
6858
7512
|
}
|
|
6859
7513
|
}, 400);
|
|
6860
7514
|
} catch {}
|
|
6861
|
-
const { body: resolvedBody, originalModel, resolvedModel, selectedModel } = resolveModelInBody$1(finalBody);
|
|
7515
|
+
const { body: resolvedBody, originalModel, resolvedModel, selectedModel } = localProfileRequest ? localModelInBody$1(finalBody) : resolveModelInBody$1(finalBody);
|
|
6862
7516
|
const modelId = resolvedModel ?? originalModel;
|
|
6863
7517
|
const { body: promptWindowBody } = await salvageOversizedPrompt(resolvedBody, selectedModel);
|
|
6864
|
-
const messagesRoute = classifyMessagesRoute(modelId, selectedModel, originalModel, fastProfileRequest);
|
|
7518
|
+
const messagesRoute = localProfileRequest ? "claude-passthrough" : classifyMessagesRoute(modelId, selectedModel, originalModel, fastProfileRequest);
|
|
6865
7519
|
if (messagesRoute !== "claude-passthrough") {
|
|
6866
7520
|
const endpoint = messagesRoute === "chat-shim" ? "chat" : "responses";
|
|
6867
7521
|
let parsedBase;
|
|
@@ -6869,7 +7523,7 @@ async function handleCompletion(c) {
|
|
|
6869
7523
|
parsedBase = JSON.parse(promptWindowBody);
|
|
6870
7524
|
} catch {}
|
|
6871
7525
|
const wantsStream = parsedBase?.stream === true;
|
|
6872
|
-
if ((fastAdvisorEnabled || cheapAdvisorEnabled ||
|
|
7526
|
+
if ((fastAdvisorEnabled || cheapAdvisorEnabled || curatedAdvisorEnabled || maxAdvisorEnabled || curatedReviewerEnabled) && wantsStream) {
|
|
6873
7527
|
const initialConversation = Array.isArray(parsedBase.messages) ? parsedBase.messages : [];
|
|
6874
7528
|
const parsedInitial = parseAnthropicRequest(parsedBase, modelId, selectedModel);
|
|
6875
7529
|
const translatedAdvisorAborter = new AbortController();
|
|
@@ -6892,9 +7546,9 @@ async function handleCompletion(c) {
|
|
|
6892
7546
|
effort: maxAdvisorChoice.effort,
|
|
6893
7547
|
escalated: false,
|
|
6894
7548
|
fastProfile: false
|
|
6895
|
-
} : cheapAdvisorEnabled ||
|
|
7549
|
+
} : cheapAdvisorEnabled || curatedAdvisorEnabled || curatedReviewerEnabled ? {
|
|
6896
7550
|
model: fastAdvisorChoice.model,
|
|
6897
|
-
effort: resolveAdvisorEffort(rawBody, fastAdvisorChoice.model, true),
|
|
7551
|
+
effort: curatedAdvisorLocalEffort ?? resolveAdvisorEffort(rawBody, fastAdvisorChoice.model, true),
|
|
6898
7552
|
escalated: fastAdvisorChoice.escalated,
|
|
6899
7553
|
fastProfile: true
|
|
6900
7554
|
} : {
|
|
@@ -6910,12 +7564,17 @@ async function handleCompletion(c) {
|
|
|
6910
7564
|
requestHeaders: {},
|
|
6911
7565
|
advisorModel: advisorChoice.model,
|
|
6912
7566
|
advisorEscalated: advisorChoice.escalated,
|
|
6913
|
-
advisorFastProfile: advisorChoice.fastProfile && !
|
|
7567
|
+
advisorFastProfile: advisorChoice.fastProfile && !curatedReviewerEnabled,
|
|
6914
7568
|
advisorMaxProfile: maxAdvisorEnabled,
|
|
6915
|
-
advisorCheapProfile: cheapAdvisorEnabled ||
|
|
6916
|
-
advisorCheapestProfile:
|
|
6917
|
-
advisorReviewerProfile:
|
|
6918
|
-
|
|
7569
|
+
advisorCheapProfile: cheapAdvisorEnabled || curatedAdvisorEnabled || curatedReviewerEnabled,
|
|
7570
|
+
advisorCheapestProfile: curatedAdvisorEnabled || curatedReviewerEnabled,
|
|
7571
|
+
advisorReviewerProfile: curatedReviewerEnabled,
|
|
7572
|
+
advisorLocalProfile: localAdvisorRequest,
|
|
7573
|
+
advisorLocalEgress: curatedLocalConsult ? {
|
|
7574
|
+
baseUrl: localBaseUrl(),
|
|
7575
|
+
sessionId: localSessionId(c, identity.launch?.sessionId)
|
|
7576
|
+
} : void 0,
|
|
7577
|
+
advisorMaxTurns: curatedReviewerEnabled ? 5 : void 0,
|
|
6919
7578
|
advisorEffort: advisorChoice.effort,
|
|
6920
7579
|
externalAborter: translatedAdvisorAborter,
|
|
6921
7580
|
continueTurn: makeShimContinueTurn(endpoint, {
|
|
@@ -6943,7 +7602,7 @@ async function handleCompletion(c) {
|
|
|
6943
7602
|
};
|
|
6944
7603
|
return messagesRoute === "chat-shim" ? handleNonClaudeChat(c, shimOpts) : handleNonClaudeResponses(c, shimOpts);
|
|
6945
7604
|
}
|
|
6946
|
-
if (modelId) logEndpointMismatch(modelId, "/v1/messages");
|
|
7605
|
+
if (modelId && !localProfileRequest) logEndpointMismatch(modelId, "/v1/messages");
|
|
6947
7606
|
const effectiveBetas = applyDefaultBetas(betaHeaders, resolvedModel ?? originalModel);
|
|
6948
7607
|
const advisorAborter = advisorBehaviorEnabled ? new AbortController() : void 0;
|
|
6949
7608
|
const requestHeaders = {
|
|
@@ -6960,7 +7619,10 @@ async function handleCompletion(c) {
|
|
|
6960
7619
|
let acceptedRepair;
|
|
6961
7620
|
const repairedMessageIndices = /* @__PURE__ */ new Set();
|
|
6962
7621
|
for (let attempt = 0; response === void 0; attempt++) try {
|
|
6963
|
-
response = await createMessages(nativeBody, requestHeaders, advisorAborter?.signal, true
|
|
7622
|
+
response = await createMessages(nativeBody, requestHeaders, advisorAborter?.signal, true, localProfileRequest ? {
|
|
7623
|
+
baseUrl: localBaseUrl(),
|
|
7624
|
+
sessionId: localSessionId(c)
|
|
7625
|
+
} : void 0);
|
|
6964
7626
|
if (acceptedRepair) {
|
|
6965
7627
|
rememberThinkingHistoryRepair(acceptedRepair.fingerprint);
|
|
6966
7628
|
consola.warn(`Thinking-history repair succeeded: message=${acceptedRepair.messageIndex} removed_blocks=${acceptedRepair.removedBlocks} attempts=${attempt}`);
|
|
@@ -6989,6 +7651,7 @@ async function handleCompletion(c) {
|
|
|
6989
7651
|
acceptedRepair = thinkingRepair;
|
|
6990
7652
|
repairedMessageIndices.add(thinkingRepair.messageIndex);
|
|
6991
7653
|
}
|
|
7654
|
+
if (localProfileRequest && response.ok) recordZeroCostRequest(originalModel);
|
|
6992
7655
|
const contentType = response.headers.get("content-type") ?? "";
|
|
6993
7656
|
const clientAcceptsSSE = (c.req.header("accept") ?? "").includes("text/event-stream");
|
|
6994
7657
|
let isStreaming = contentType.includes("text/event-stream");
|
|
@@ -7038,22 +7701,32 @@ async function handleCompletion(c) {
|
|
|
7038
7701
|
requestHeaders,
|
|
7039
7702
|
advisorModel: advisorChoice.model,
|
|
7040
7703
|
advisorEscalated: advisorChoice.escalated,
|
|
7041
|
-
advisorFastProfile: (fastLeadAdvisor || cheapLeadAdvisor ||
|
|
7704
|
+
advisorFastProfile: (fastLeadAdvisor || cheapLeadAdvisor || curatedLeadAdvisor) && !curatedReviewerEnabled,
|
|
7042
7705
|
advisorMaxProfile: maxAdvisorEnabled,
|
|
7043
|
-
advisorCheapProfile: cheapLeadAdvisor ||
|
|
7044
|
-
advisorCheapestProfile:
|
|
7045
|
-
advisorReviewerProfile:
|
|
7046
|
-
|
|
7047
|
-
|
|
7706
|
+
advisorCheapProfile: cheapLeadAdvisor || curatedLeadAdvisor || curatedReviewerEnabled,
|
|
7707
|
+
advisorCheapestProfile: curatedAdvisorEnabled || curatedReviewerEnabled,
|
|
7708
|
+
advisorReviewerProfile: curatedReviewerEnabled,
|
|
7709
|
+
advisorLocalProfile: localAdvisorRequest,
|
|
7710
|
+
localEgress: localProfileRequest ? {
|
|
7711
|
+
baseUrl: localBaseUrl(),
|
|
7712
|
+
sessionId: localSessionId(c)
|
|
7713
|
+
} : void 0,
|
|
7714
|
+
advisorLocalEgress: curatedLocalConsult ? {
|
|
7715
|
+
baseUrl: localBaseUrl(),
|
|
7716
|
+
sessionId: localSessionId(c, identity.launch?.sessionId)
|
|
7717
|
+
} : void 0,
|
|
7718
|
+
advisorMaxTurns: curatedReviewerEnabled ? 5 : void 0,
|
|
7719
|
+
advisorEffort: maxAdvisorChoice ? maxAdvisorChoice.effort : curatedAdvisorLocalEffort ?? resolveAdvisorEffort(rawBody, advisorChoice.model, fastLeadAdvisor || cheapLeadAdvisor || curatedLeadAdvisor),
|
|
7048
7720
|
externalAborter: advisorAborter
|
|
7049
7721
|
}), {
|
|
7050
7722
|
status: response.status,
|
|
7051
7723
|
headers: streamHeaders
|
|
7052
7724
|
});
|
|
7053
7725
|
}
|
|
7726
|
+
const aicTap = localProfileRequest ? void 0 : createAnthropicAicTap((usage) => recordAic(resolvedModel, usage));
|
|
7054
7727
|
return new Response(response.body ? relayAnthropicStream(response.body, {
|
|
7055
7728
|
routePath: c.req.path,
|
|
7056
|
-
onBytes:
|
|
7729
|
+
...aicTap ? { onBytes: aicTap.onBytes } : {}
|
|
7057
7730
|
}) : null, {
|
|
7058
7731
|
status: response.status,
|
|
7059
7732
|
headers: streamHeaders
|
|
@@ -7063,7 +7736,7 @@ async function handleCompletion(c) {
|
|
|
7063
7736
|
if (!cappedResult.ok) return c.json(cappedResult.errorResponse, cappedResult.status);
|
|
7064
7737
|
const responseBody = cappedResult.value;
|
|
7065
7738
|
const usage = responseBody.usage;
|
|
7066
|
-
const aicNano = extractAndRecordAic(resolvedModel, responseBody);
|
|
7739
|
+
const aicNano = localProfileRequest ? void 0 : extractAndRecordAic(resolvedModel, responseBody);
|
|
7067
7740
|
logRequest({
|
|
7068
7741
|
method: "POST",
|
|
7069
7742
|
path: c.req.path,
|
|
@@ -7084,6 +7757,37 @@ async function handleCompletion(c) {
|
|
|
7084
7757
|
return c.json(responseBody, response.status);
|
|
7085
7758
|
}
|
|
7086
7759
|
/**
|
|
7760
|
+
* Verbatim alternative to `resolveModelInBody` for the local profiles.
|
|
7761
|
+
*
|
|
7762
|
+
* The body is forwarded byte-for-byte: no model rewrite (the tier ids
|
|
7763
|
+
* `opus` / `sonnet` / `haiku` are the local server's own, and `resolveModel`'s
|
|
7764
|
+
* opus-family preference would map `opus` onto a Copilot `claude-opus-*`), no
|
|
7765
|
+
* thinking translation or effort clamp (both consult a Copilot catalog entry
|
|
7766
|
+
* that does not describe this model), and no Anthropic-only field strip (the
|
|
7767
|
+
* local server is the thing those fields were written for).
|
|
7768
|
+
*
|
|
7769
|
+
* `selectedModel` is deliberately `undefined` — the catalog knows nothing
|
|
7770
|
+
* about this model, and `salvageOversizedPrompt` / `logEndpointMismatch`
|
|
7771
|
+
* correctly no-op on it.
|
|
7772
|
+
*/
|
|
7773
|
+
function localModelInBody$1(rawBody) {
|
|
7774
|
+
let originalModel;
|
|
7775
|
+
try {
|
|
7776
|
+
const parsed = JSON.parse(rawBody);
|
|
7777
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
7778
|
+
const model = parsed.model;
|
|
7779
|
+
if (typeof model === "string" && model.length > 0) originalModel = model;
|
|
7780
|
+
}
|
|
7781
|
+
} catch {}
|
|
7782
|
+
return {
|
|
7783
|
+
body: rawBody,
|
|
7784
|
+
...originalModel ? {
|
|
7785
|
+
originalModel,
|
|
7786
|
+
resolvedModel: originalModel
|
|
7787
|
+
} : {}
|
|
7788
|
+
};
|
|
7789
|
+
}
|
|
7790
|
+
/**
|
|
7087
7791
|
* Parse the JSON body, resolve the model name, sanitize cache_control
|
|
7088
7792
|
* fields, translate thinking-mode shape for adaptive-thinking models,
|
|
7089
7793
|
* and re-serialize. Returns the body string, original/resolved model
|
|
@@ -7409,19 +8113,23 @@ async function handleCountTokens(c) {
|
|
|
7409
8113
|
}
|
|
7410
8114
|
}, 400);
|
|
7411
8115
|
} catch {}
|
|
7412
|
-
const
|
|
8116
|
+
const localProfileRequest = effectiveLocalProfile(identity.launch?.profileId) !== void 0;
|
|
8117
|
+
const { body: finalBody, originalModel, resolvedModel } = localProfileRequest ? localModelInBody(strippedBody) : resolveModelInBody(strippedBody);
|
|
7413
8118
|
const extraHeaders = {};
|
|
7414
8119
|
const anthropicBeta = c.req.header("anthropic-beta");
|
|
7415
8120
|
if (anthropicBeta) {
|
|
7416
|
-
const filtered = filterBetaHeader(anthropicBeta);
|
|
8121
|
+
const filtered = localProfileRequest ? anthropicBeta.split(",").map((part) => part.trim()).filter((part) => part.length > 0 && !part.startsWith("advisor-tool-")).join(",") : filterBetaHeader(anthropicBeta);
|
|
7417
8122
|
if (filtered) extraHeaders["anthropic-beta"] = filtered;
|
|
7418
8123
|
}
|
|
7419
8124
|
const modelId = resolvedModel ?? originalModel;
|
|
7420
|
-
const selectedModel = state.models?.data.find((m) => m.id === modelId);
|
|
8125
|
+
const selectedModel = localProfileRequest ? void 0 : state.models?.data.find((m) => m.id === modelId);
|
|
7421
8126
|
const response = await countTokens(finalBody, {
|
|
7422
8127
|
...selectedModel?.requestHeaders,
|
|
7423
8128
|
...extraHeaders
|
|
7424
|
-
}, void 0, true
|
|
8129
|
+
}, void 0, true, localProfileRequest ? {
|
|
8130
|
+
baseUrl: localBaseUrl(),
|
|
8131
|
+
sessionId: localSessionId(c)
|
|
8132
|
+
} : void 0);
|
|
7425
8133
|
const responseBody = await parseJsonOrDiagnose(response, c.req.path);
|
|
7426
8134
|
logRequest({
|
|
7427
8135
|
method: "POST",
|
|
@@ -7434,6 +8142,28 @@ async function handleCountTokens(c) {
|
|
|
7434
8142
|
return c.json(responseBody);
|
|
7435
8143
|
}
|
|
7436
8144
|
/**
|
|
8145
|
+
* Verbatim alternative to `resolveModelInBody` for the local profiles: read
|
|
8146
|
+
* the body's own `model` and change nothing else. See the sibling helper in
|
|
8147
|
+
* `handler.ts` for the full rationale.
|
|
8148
|
+
*/
|
|
8149
|
+
function localModelInBody(rawBody) {
|
|
8150
|
+
let originalModel;
|
|
8151
|
+
try {
|
|
8152
|
+
const parsed = JSON.parse(rawBody);
|
|
8153
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
8154
|
+
const model = parsed.model;
|
|
8155
|
+
if (typeof model === "string" && model.length > 0) originalModel = model;
|
|
8156
|
+
}
|
|
8157
|
+
} catch {}
|
|
8158
|
+
return {
|
|
8159
|
+
body: rawBody,
|
|
8160
|
+
...originalModel ? {
|
|
8161
|
+
originalModel,
|
|
8162
|
+
resolvedModel: originalModel
|
|
8163
|
+
} : {}
|
|
8164
|
+
};
|
|
8165
|
+
}
|
|
8166
|
+
/**
|
|
7437
8167
|
* Parse the JSON body, resolve the model name, sanitize cache_control, and re-serialize.
|
|
7438
8168
|
*/
|
|
7439
8169
|
function resolveModelInBody(rawBody) {
|
|
@@ -7850,6 +8580,7 @@ async function handleResponsesCompact(c) {
|
|
|
7850
8580
|
if (!state.copilotToken) throw new Error("Copilot token not found");
|
|
7851
8581
|
if (state.manualApprove) await awaitApproval();
|
|
7852
8582
|
const body = await c.req.json();
|
|
8583
|
+
assertCopilotModelAllowed(body.model);
|
|
7853
8584
|
const compactUrl = `${copilotBaseUrl(state)}/responses/compact`;
|
|
7854
8585
|
const doFetch = () => fetch(compactUrl, {
|
|
7855
8586
|
method: "POST",
|
|
@@ -8610,8 +9341,9 @@ function getClaudeCodeEnvVars(serverUrl, model, launchProfileId = "standard", pi
|
|
|
8610
9341
|
const isFastProfile = launchProfileId === "fast";
|
|
8611
9342
|
const isMaxProfile = launchProfileId === "max";
|
|
8612
9343
|
const isCheapProfile = launchProfileId === "cheap" || launchProfileId === "cheap1m" || isCheapestFamily(launchProfileId);
|
|
8613
|
-
const
|
|
8614
|
-
const
|
|
9344
|
+
const isLocalProfile = isLocalFamily(launchProfileId);
|
|
9345
|
+
const routerWinsTiers = isFastProfile || isCheapProfile || isLocalProfile;
|
|
9346
|
+
const pinStrict200K = launchProfileId === "cheap" || isCheapestFamily(launchProfileId) || isBalancedFamily(launchProfileId) || isLocalProfile;
|
|
8615
9347
|
if (pinStrict200K) {
|
|
8616
9348
|
if (process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT === void 0 || process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT === "") vars.CLAUDE_CODE_DISABLE_1M_CONTEXT = "1";
|
|
8617
9349
|
}
|
|
@@ -8619,12 +9351,12 @@ function getClaudeCodeEnvVars(serverUrl, model, launchProfileId = "standard", pi
|
|
|
8619
9351
|
if (pinLeadEffort !== void 0) {
|
|
8620
9352
|
if ((process.env.CLAUDE_CODE_EFFORT_LEVEL ?? "").trim() === "") vars.CLAUDE_CODE_EFFORT_LEVEL = pinLeadEffort;
|
|
8621
9353
|
}
|
|
8622
|
-
const smallFastModel = isMaxProfile ? MAX_LUNA_HIGH_ALIAS_ID : isFastProfile ? LUNA_HAIKU_ALIAS_ID : isCheapProfile ? LUNA_HAIKU_ALIAS_ID : isBudgetClaudeLead(model) && (state.models?.data?.some((m) => m.id === "claude-haiku-4.5") ?? false) ? BUDGET_SMALL_FAST_SLUG : "claude-sonnet-5";
|
|
9354
|
+
const smallFastModel = isMaxProfile ? MAX_LUNA_HIGH_ALIAS_ID : isFastProfile ? LUNA_HAIKU_ALIAS_ID : isCheapProfile ? LUNA_HAIKU_ALIAS_ID : isLocalProfile ? LOCAL_PROFILE_TIER_MODELS.haiku : isBudgetClaudeLead(model) && (state.models?.data?.some((m) => m.id === "claude-haiku-4.5") ?? false) ? BUDGET_SMALL_FAST_SLUG : "claude-sonnet-5";
|
|
8623
9355
|
if (process.env.ANTHROPIC_SMALL_FAST_MODEL === void 0 || routerWinsTiers) vars.ANTHROPIC_SMALL_FAST_MODEL = (isFastProfile || isMaxProfile) && !isCheapProfile ? oneMSuffixForAlias(smallFastModel) : smallFastModel;
|
|
8624
|
-
const seedTierRow = (modelKey, nameKey, bareSlug) => {
|
|
8625
|
-
if (process.env[modelKey] !== void 0) return;
|
|
9356
|
+
const seedTierRow = (modelKey, nameKey, bareSlug, force = false) => {
|
|
9357
|
+
if (!force && process.env[modelKey] !== void 0) return;
|
|
8626
9358
|
vars[modelKey] = pinStrict200K ? bareSlug : withOneMSuffixForLead(bareSlug);
|
|
8627
|
-
if (process.env[nameKey] === void 0) vars[nameKey] = bareSlug;
|
|
9359
|
+
if (force || process.env[nameKey] === void 0) vars[nameKey] = bareSlug;
|
|
8628
9360
|
};
|
|
8629
9361
|
const seedFastAliasTierRow = (modelKey, nameKey, aliasId, displayName, force = false) => {
|
|
8630
9362
|
if (!force && process.env[modelKey] !== void 0) return;
|
|
@@ -8671,11 +9403,15 @@ function getClaudeCodeEnvVars(serverUrl, model, launchProfileId = "standard", pi
|
|
|
8671
9403
|
if (routerWinsTiers || process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME === void 0) vars.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME = "GPT-6 Luna (max)";
|
|
8672
9404
|
if (routerWinsTiers || process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES === void 0) vars.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES = fastAliasCapabilities;
|
|
8673
9405
|
}
|
|
9406
|
+
} else if (isLocalProfile) {
|
|
9407
|
+
seedTierRow("ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME", LOCAL_PROFILE_TIER_MODELS.opus, routerWinsTiers);
|
|
9408
|
+
seedTierRow("ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL_NAME", LOCAL_PROFILE_TIER_MODELS.sonnet, routerWinsTiers);
|
|
9409
|
+
seedTierRow("ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME", LOCAL_PROFILE_TIER_MODELS.haiku, routerWinsTiers);
|
|
8674
9410
|
} else {
|
|
8675
9411
|
seedTierRow("ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL_NAME", "claude-sonnet-5");
|
|
8676
9412
|
seedTierRow("ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME", smallFastModel);
|
|
8677
9413
|
}
|
|
8678
|
-
if (!isMaxProfile) seedTierRow("ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME", "claude-opus-5.5");
|
|
9414
|
+
if (!isMaxProfile && !isLocalProfile) seedTierRow("ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME", "claude-opus-5.5");
|
|
8679
9415
|
if (process.env.CLAUDE_CODE_PLAN_V2_AGENT_COUNT === void 0) vars.CLAUDE_CODE_PLAN_V2_AGENT_COUNT = "7";
|
|
8680
9416
|
for (const key of [
|
|
8681
9417
|
"CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL",
|
|
@@ -8684,6 +9420,10 @@ function getClaudeCodeEnvVars(serverUrl, model, launchProfileId = "standard", pi
|
|
|
8684
9420
|
"CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING",
|
|
8685
9421
|
"CLAUDE_CODE_ENABLE_TASKS"
|
|
8686
9422
|
]) if (process.env[key] === void 0) vars[key] = "1";
|
|
9423
|
+
if (launchProfileId === "local") {
|
|
9424
|
+
delete vars.CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL;
|
|
9425
|
+
if (process.env.CLAUDE_CODE_DISABLE_ADVISOR_TOOL === void 0) vars.CLAUDE_CODE_DISABLE_ADVISOR_TOOL = "1";
|
|
9426
|
+
}
|
|
8687
9427
|
applyAutoCompactWindow(vars, launchProfileId, pickerModels);
|
|
8688
9428
|
if (toolbeltEnabled()) Object.assign(vars, toolbeltPathOverride(process.env, PATHS.TOOLBELT_BIN_DIR));
|
|
8689
9429
|
return vars;
|
|
@@ -8778,7 +9518,10 @@ function getCodexEnvVars(serverUrl) {
|
|
|
8778
9518
|
* shell export can't re-route the session off the proxy.
|
|
8779
9519
|
*/
|
|
8780
9520
|
function getPiLaunchEnvVars(mirrorDir) {
|
|
8781
|
-
const vars = {
|
|
9521
|
+
const vars = {
|
|
9522
|
+
PI_CODING_AGENT_DIR: mirrorDir,
|
|
9523
|
+
PI_CODING_AGENT_SESSION_DIR: piSessionsDir()
|
|
9524
|
+
};
|
|
8782
9525
|
if (process.env.GH_ROUTER_PI_VERBOSE_NPM !== "1") {
|
|
8783
9526
|
vars.npm_config_loglevel = "error";
|
|
8784
9527
|
vars.npm_config_audit = "false";
|
|
@@ -8786,10 +9529,12 @@ function getPiLaunchEnvVars(mirrorDir) {
|
|
|
8786
9529
|
vars.npm_config_update_notifier = "false";
|
|
8787
9530
|
}
|
|
8788
9531
|
vars.npm_config_allow_scripts = "";
|
|
9532
|
+
vars.npm_config_registry = resolvePiRegistry();
|
|
9533
|
+
vars.npm_config_min_release_age = "0";
|
|
8789
9534
|
if (toolbeltEnabled()) Object.assign(vars, toolbeltPathOverride(process.env, PATHS.TOOLBELT_BIN_DIR));
|
|
8790
9535
|
return vars;
|
|
8791
9536
|
}
|
|
8792
9537
|
//#endregion
|
|
8793
|
-
export {
|
|
9538
|
+
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 };
|
|
8794
9539
|
|
|
8795
|
-
//# sourceMappingURL=server-setup-
|
|
9540
|
+
//# sourceMappingURL=server-setup-CIzmDJzT.js.map
|