github-router 0.3.295 → 0.3.297

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{attribution-settings-pkIop1NU.js → attribution-settings-B70GmZ68.js} +10 -9
  2. package/dist/attribution-settings-B70GmZ68.js.map +1 -0
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/{claude-DNmxk-Rm.js → claude-DMMfvfns.js} +96 -44
  5. package/dist/claude-DMMfvfns.js.map +1 -0
  6. package/dist/{codex-Dl4gpHn-.js → codex-DVOyVv2B.js} +4 -4
  7. package/dist/{codex-Dl4gpHn-.js.map → codex-DVOyVv2B.js.map} +1 -1
  8. package/dist/engine-BkGRuUNs.js +2 -0
  9. package/dist/fast-profile-contract-K3P58nj3.js +57 -0
  10. package/dist/fast-profile-contract-K3P58nj3.js.map +1 -0
  11. package/dist/{gate-discovery-WcduofL4.js → gate-discovery-G6PAG61j.js} +2 -2
  12. package/dist/{gate-discovery-WcduofL4.js.map → gate-discovery-G6PAG61j.js.map} +1 -1
  13. package/dist/hooks.mjs +64 -16
  14. package/dist/hooks.sha256 +1 -1
  15. package/dist/{internal-fast-dispatch-guard-Xyu17k9X.js → internal-fast-dispatch-guard-Bkr_iGOu.js} +21 -17
  16. package/dist/internal-fast-dispatch-guard-Bkr_iGOu.js.map +1 -0
  17. package/dist/{internal-fast-dispatch-guard-CPlCrTlU.js → internal-fast-dispatch-guard-N-RaLrOn.js} +1 -1
  18. package/dist/{internal-stop-hook-DJFtGCsE.js → internal-stop-hook-BjzrF1zd.js} +2 -2
  19. package/dist/{internal-stop-hook-DJFtGCsE.js.map → internal-stop-hook-BjzrF1zd.js.map} +1 -1
  20. package/dist/main.js +6 -6
  21. package/dist/{peer-mcp-personas-BwNtC8jt.js → peer-mcp-personas-ce6_YMnX.js} +77 -76
  22. package/dist/peer-mcp-personas-ce6_YMnX.js.map +1 -0
  23. package/dist/{provision-DeNqzvSM.js → provision-BhCtm3md.js} +2 -2
  24. package/dist/{provision-DeNqzvSM.js.map → provision-BhCtm3md.js.map} +1 -1
  25. package/dist/{serve-BS5EmCpM.js → serve-Blj_dRSr.js} +5 -5
  26. package/dist/{serve-BS5EmCpM.js.map → serve-Blj_dRSr.js.map} +1 -1
  27. package/dist/{server-setup-DsGJnJ_O.js → server-setup-DhG3YZPj.js} +62 -11
  28. package/dist/server-setup-DhG3YZPj.js.map +1 -0
  29. package/dist/{start-vJdt2MiM.js → start-8QaqICtd.js} +3 -3
  30. package/dist/{start-vJdt2MiM.js.map → start-8QaqICtd.js.map} +1 -1
  31. package/package.json +1 -1
  32. package/dist/attribution-settings-pkIop1NU.js.map +0 -1
  33. package/dist/claude-DNmxk-Rm.js.map +0 -1
  34. package/dist/engine-XnluJUs6.js +0 -2
  35. package/dist/internal-fast-dispatch-guard-Xyu17k9X.js.map +0 -1
  36. package/dist/peer-mcp-personas-BwNtC8jt.js.map +0 -1
  37. package/dist/server-setup-DsGJnJ_O.js.map +0 -1
@@ -1,9 +1,10 @@
1
- import { $ as bucketEffort, $t as assembleResponsesPayload, An as isBudgetClaudeLead, B as resolveAdvisorModel, Bn as stripTrailingOneMSuffix, Dn as UPSTREAM_FETCH_TIMEOUT_MS, E as toolbeltEnabled, F as FAST_ADVISOR_TOOL_INSTRUCTIONS, Fn as classifyMessagesRoute, G as buildAnthropicErrorEvent, Gt as countTokens, H as rememberThinkingHistoryRepair, Ht as resolveModelAlias, I as buildAdvisorStream, In as catalogAdvertises1M, J as logStreamError, Jt as getTokenCount, K as buildOpenAIErrorEvent, Kt as createMessages, L as injectAdvisorTool, Ln as oneMContextDisabled, Lt as LUNA_SONNET_ALIAS_ID, M as searchWeb, Mt as LUNA_DRIVER_ALIAS_ID, N as ADVISOR_INTERNAL_TOOL_NAME, Nn as upstreamAllowH2, Nt as LUNA_HAIKU_ALIAS_ID, On as UPSTREAM_INACTIVITY_TIMEOUT_MS, P as ADVISOR_TOOL_INSTRUCTIONS, Pn as upstreamMaxConnections, Q as UNKNOWN_EFFORT_ANCHOR, R as isAdvisorRequested, Rn as withOneMSuffix, Rt as canonicalizeAliasModel, Sn as BUDGET_SMALL_FAST_SLUG, U as repairKnownThinkingHistory, V as formatThinkingRepairDecline, Vn as withInstallLock, W as repairRejectedThinkingHistory, Wt as shimDefaultsToXhigh, X as relayAnthropicStream, Xt as findLaunchBySecret, Y as readIteratorWithTimeout, Yt as getTokenizerFromModel, Z as EFFORT_ORDER, an as readResponseBodyCapped, bn as toolbeltPathOverride, en as warnOnTokenPriceDrift, et as clampEffort, hn as provisionTreeSitterAssets, i as assertMcpToolSurfaceConsistent, in as MAX_RESPONSE_BODY_BYTES, kn as generateRandomPort, nn as createResponses, nt as handleMcpPost, on as parseJsonOrDiagnose, q as isControllerClosedError, qt as getTextTokenCount, rn as createChatCompletions, sn as normalizeOpenAIUsage, st as agentToolsEnabled, tn as resolveMcpToolTimeoutMs, tt as handleMcpDelete, z as resolveAdvisorEffort, zn as withOneMSuffixForLead } from "./peer-mcp-personas-BwNtC8jt.js";
1
+ import { $ as bucketEffort, An as generateRandomPort, B as resolveAdvisorModel, Bn as withOneMSuffixForLead, Cn as BUDGET_SMALL_FAST_SLUG, E as toolbeltEnabled, F as FAST_ADVISOR_TOOL_INSTRUCTIONS, Fn as upstreamMaxConnections, G as buildAnthropicErrorEvent, Gt as shimDefaultsToXhigh, H as rememberThinkingHistoryRepair, Hn as withInstallLock, I as buildAdvisorStream, In as classifyMessagesRoute, It as LUNA_REAL_MODEL_ID, J as logStreamError, Jt as getTextTokenCount, K as buildOpenAIErrorEvent, Kt as countTokens, L as injectAdvisorTool, Ln as catalogAdvertises1M, M as searchWeb, N as ADVISOR_INTERNAL_TOOL_NAME, Nt as LUNA_DRIVER_ALIAS_ID, On as UPSTREAM_FETCH_TIMEOUT_MS, P as ADVISOR_TOOL_INSTRUCTIONS, Pn as upstreamAllowH2, Pt as LUNA_HAIKU_ALIAS_ID, Q as UNKNOWN_EFFORT_ANCHOR, R as isAdvisorRequested, Rn as oneMContextDisabled, Rt as LUNA_SONNET_ALIAS_ID, U as repairKnownThinkingHistory, Ut as resolveModelAlias, V as formatThinkingRepairDecline, Vn as stripTrailingOneMSuffix, W as repairRejectedThinkingHistory, X as relayAnthropicStream, Xt as getTokenizerFromModel, Y as readIteratorWithTimeout, Yt as getTokenCount, Z as EFFORT_ORDER, Zt as findLaunchBySecret, an as MAX_RESPONSE_BODY_BYTES, cn as normalizeOpenAIUsage, ct as agentToolsEnabled, en as assembleResponsesPayload, et as clampEffort, gn as provisionTreeSitterAssets, i as assertMcpToolSurfaceConsistent, in as createChatCompletions, jn as isBudgetClaudeLead, kn as UPSTREAM_INACTIVITY_TIMEOUT_MS, nn as resolveMcpToolTimeoutMs, nt as handleMcpPost, on as readResponseBodyCapped, q as isControllerClosedError, qt as createMessages, rn as createResponses, sn as parseJsonOrDiagnose, tn as warnOnTokenPriceDrift, tt as handleMcpDelete, xn as toolbeltPathOverride, z as resolveAdvisorEffort, zn as withOneMSuffix, zt as canonicalizeAliasModel } from "./peer-mcp-personas-ce6_YMnX.js";
2
2
  import { t as getPackageVersion } from "./version-C8x2hQrZ.js";
3
3
  import { i as ensurePaths, t as PATHS } from "./paths-Ci485qSJ.js";
4
4
  import { A as state, T as copilotHeaders, _ as forwardError, a as cacheCopilotVersion, 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, w as copilotBaseUrl, y as fetchWithTransientRetry } from "./token-BtJhjXXu.js";
5
5
  import { t as getCopilotUsage } from "./get-copilot-usage-B7Z4XVWj.js";
6
6
  import { a as resolveExecutable, n as killManagedTree, o as runCommandCapture, r as parseBoolEnv, s as runCommandVoid } from "./exec-y8C_MU8A.js";
7
+ import { r as FAST_PROFILE_ADVISOR_MODEL } from "./fast-profile-contract-K3P58nj3.js";
7
8
  import consola from "consola";
8
9
  import * as fs$2 from "node:fs";
9
10
  import fs, { existsSync } from "node:fs";
@@ -1497,7 +1498,7 @@ function collectToolFieldKeys(body) {
1497
1498
  //#endregion
1498
1499
  //#region package.json
1499
1500
  var name = "github-router";
1500
- var version = "0.3.295";
1501
+ var version = "0.3.297";
1501
1502
  //#endregion
1502
1503
  //#region src/lib/approval.ts
1503
1504
  const awaitApproval = async () => {
@@ -4700,6 +4701,32 @@ function stripWebSearchTool(body) {
4700
4701
  * in probes `shim_advisor_degrade_gpt55` and
4701
4702
  * `shim_advisor_degrade_gemini35flash`.
4702
4703
  */
4704
+ function hasNonEmptyTools(rawBody) {
4705
+ let body;
4706
+ try {
4707
+ body = JSON.parse(rawBody);
4708
+ } catch {
4709
+ return false;
4710
+ }
4711
+ return Array.isArray(body.tools) && body.tools.length > 0;
4712
+ }
4713
+ function fastAdvisorMetadataMismatch(rawBody) {
4714
+ let body;
4715
+ try {
4716
+ body = JSON.parse(rawBody);
4717
+ } catch {
4718
+ return;
4719
+ }
4720
+ if (!Array.isArray(body.tools) || body.tools.length === 0) return void 0;
4721
+ for (const tool of body.tools) {
4722
+ if (!tool || typeof tool !== "object") continue;
4723
+ const type = tool.type;
4724
+ if (typeof type !== "string" || !type.startsWith("advisor_")) continue;
4725
+ const model = tool.model;
4726
+ if (typeof model !== "string") return "the native Advisor tool omitted its fixed model";
4727
+ if (stripTrailingOneMSuffix(model).base !== FAST_PROFILE_ADVISOR_MODEL) return `the native Advisor tool requested ${JSON.stringify(model)} instead of ${JSON.stringify(FAST_PROFILE_ADVISOR_MODEL)}`;
4728
+ }
4729
+ }
4703
4730
  function stripAdvisorTool(rawBody) {
4704
4731
  let body;
4705
4732
  try {
@@ -4836,6 +4863,30 @@ async function handleCompletion(c) {
4836
4863
  const fastSubagentRequest = fastProfileRequest && Boolean(c.req.header("x-claude-code-agent-id"));
4837
4864
  const fastLeadAdvisor = fastProfileRequest && !fastSubagentRequest;
4838
4865
  const advisorEnabled = advisorRequested && !fastSubagentRequest;
4866
+ const fastAdvisorEnabled = fastLeadAdvisor && advisorRequested && hasNonEmptyTools(rawBody);
4867
+ const advisorBehaviorEnabled = fastLeadAdvisor ? fastAdvisorEnabled : advisorEnabled;
4868
+ let fastAdvisorChoice;
4869
+ if (fastAdvisorEnabled) {
4870
+ const mismatch = fastAdvisorMetadataMismatch(rawBody);
4871
+ if (mismatch) return c.json({
4872
+ type: "error",
4873
+ error: {
4874
+ type: "invalid_request_error",
4875
+ message: `Fast Advisor model mismatch: ${mismatch}. Run \`/advisor ${FAST_PROFILE_ADVISOR_MODEL}[1m]\` to restore the fixed fast profile, or relaunch with \`github-router claude -m fast\`.`
4876
+ }
4877
+ }, 400, { "x-should-retry": "false" });
4878
+ try {
4879
+ fastAdvisorChoice = resolveAdvisorModel(void 0, true);
4880
+ } catch (error) {
4881
+ return c.json({
4882
+ type: "error",
4883
+ error: {
4884
+ type: "api_error",
4885
+ message: error instanceof Error ? error.message : String(error)
4886
+ }
4887
+ }, 503);
4888
+ }
4889
+ }
4839
4890
  const fastPreprocess = preprocessFastRequest(rawBody, identity.launch);
4840
4891
  if (fastPreprocess.rejectedAlias || fastPreprocess.rejectedModel) {
4841
4892
  const message = fastPreprocess.rejectedAlias ? `Router-owned model alias ${JSON.stringify(fastPreprocess.rejectedAlias)} is valid only for an authenticated -m fast launch.` : `Model ${JSON.stringify(fastPreprocess.rejectedModel)} is outside the fixed -m fast model set.`;
@@ -4859,7 +4910,7 @@ async function handleCompletion(c) {
4859
4910
  }
4860
4911
  }, 400, { "x-should-retry": "false" });
4861
4912
  if (loopGuard.body !== void 0) finalBody = loopGuard.body;
4862
- if (advisorEnabled) {
4913
+ if (advisorBehaviorEnabled) {
4863
4914
  finalBody = injectAdvisorTool(finalBody, fastLeadAdvisor ? FAST_ADVISOR_TOOL_INSTRUCTIONS : void 0);
4864
4915
  consola.info("ADVISOR enabled for this request — injecting __anthropic_advisor tool; will translate tool_use → server_tool_use{advisor} on the SSE stream");
4865
4916
  }
@@ -4884,7 +4935,7 @@ async function handleCompletion(c) {
4884
4935
  parsedBase = JSON.parse(promptWindowBody);
4885
4936
  } catch {}
4886
4937
  const wantsStream = parsedBase?.stream === true;
4887
- if (advisorEnabled && wantsStream && fastLeadAdvisor) {
4938
+ if (fastAdvisorEnabled && wantsStream) {
4888
4939
  const initialConversation = Array.isArray(parsedBase.messages) ? parsedBase.messages : [];
4889
4940
  const parsedInitial = parseAnthropicRequest(parsedBase, modelId, selectedModel);
4890
4941
  const fastAdvisorAborter = new AbortController();
@@ -4902,7 +4953,7 @@ async function handleCompletion(c) {
4902
4953
  status: 200,
4903
4954
  streaming: true
4904
4955
  }, selectedModel, startTime);
4905
- const advisorChoice = resolveAdvisorModel(modelId, fastLeadAdvisor);
4956
+ const advisorChoice = fastAdvisorChoice;
4906
4957
  return new Response(buildAdvisorStream({
4907
4958
  firstResponse,
4908
4959
  initialConversation,
@@ -4928,7 +4979,7 @@ async function handleCompletion(c) {
4928
4979
  });
4929
4980
  }
4930
4981
  const shimBody = stripAdvisorTool(promptWindowBody);
4931
- if (advisorEnabled) consola.info("ADVISOR requested with a non-Claude model — stripping the injected __anthropic_advisor tool and proceeding without advisor (Claude-only feature; gracefully degraded).");
4982
+ if (advisorBehaviorEnabled) consola.info("ADVISOR requested with a non-Claude model — stripping the injected __anthropic_advisor tool and proceeding without advisor (Claude-only feature; gracefully degraded).");
4932
4983
  const shimOpts = {
4933
4984
  rawBody: shimBody,
4934
4985
  modelId,
@@ -4940,7 +4991,7 @@ async function handleCompletion(c) {
4940
4991
  }
4941
4992
  if (modelId) logEndpointMismatch(modelId, "/v1/messages");
4942
4993
  const effectiveBetas = applyDefaultBetas(betaHeaders, resolvedModel ?? originalModel);
4943
- const advisorAborter = advisorEnabled ? new AbortController() : void 0;
4994
+ const advisorAborter = advisorBehaviorEnabled ? new AbortController() : void 0;
4944
4995
  const requestHeaders = {
4945
4996
  ...selectedModel?.requestHeaders,
4946
4997
  ...effectiveBetas
@@ -5014,13 +5065,13 @@ async function handleCompletion(c) {
5014
5065
  if (requestId) streamHeaders["x-request-id"] = requestId;
5015
5066
  const reqId = response.headers.get("request-id");
5016
5067
  if (reqId) streamHeaders["request-id"] = reqId;
5017
- if (advisorEnabled && response.body) {
5068
+ if (advisorBehaviorEnabled && response.body) {
5018
5069
  let parsedBase = {};
5019
5070
  try {
5020
5071
  parsedBase = JSON.parse(nativeBody);
5021
5072
  } catch {}
5022
5073
  const initialConversation = Array.isArray(parsedBase.messages) ? parsedBase.messages : [];
5023
- const advisorChoice = resolveAdvisorModel(originalModel, fastLeadAdvisor);
5074
+ const advisorChoice = fastAdvisorChoice ?? resolveAdvisorModel(originalModel, false);
5024
5075
  return new Response(buildAdvisorStream({
5025
5076
  firstResponse: response,
5026
5077
  initialConversation,
@@ -6552,7 +6603,7 @@ function clearGatewayModelCache(configDir = PATHS.CLAUDE_CONFIG_DIR) {
6552
6603
  */
6553
6604
  function oneMSuffixForAlias(aliasId) {
6554
6605
  if (oneMContextDisabled()) return aliasId;
6555
- return catalogAdvertises1M("gpt-5.6-luna") ? `${aliasId}[1m]` : aliasId;
6606
+ return catalogAdvertises1M(LUNA_REAL_MODEL_ID) ? `${aliasId}[1m]` : aliasId;
6556
6607
  }
6557
6608
  function getClaudeCodeEnvVars(serverUrl, model, launchProfileId = "standard") {
6558
6609
  const vars = {
@@ -6690,4 +6741,4 @@ function getCodexEnvVars(serverUrl) {
6690
6741
  //#endregion
6691
6742
  export { sharedServerArgs as a, stopKeepAwake as c, runSelfUpdate as d, checkClaudeVersion as f, setupAndServe as i, listModelsForEndpoint as l, getCodexEnvVars as n, LAUNCH_SECRET_HEADER as o, updateClaude as p, parseSharedArgs as r, startKeepAwake as s, getClaudeCodeEnvVars as t, enableFileLogging as u };
6692
6743
 
6693
- //# sourceMappingURL=server-setup-DsGJnJ_O.js.map
6744
+ //# sourceMappingURL=server-setup-DhG3YZPj.js.map