github-router 0.3.370 → 0.3.372

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 (49) hide show
  1. package/dist/ado-tools-CAtopk36.js +1 -0
  2. package/dist/{attribution-settings-Cppl9atx.js → attribution-settings-HI_5bN_-.js} +6 -6
  3. package/dist/{attribution-settings-Cppl9atx.js.map → attribution-settings-HI_5bN_-.js.map} +1 -1
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/{claude-B3qNFwtc.js → claude-BBSsqwln.js} +10 -10
  6. package/dist/claude-BBSsqwln.js.map +1 -0
  7. package/dist/{claude-md-injection-K3DKhsfI.js → claude-md-injection-BMon6WUD.js} +19 -22
  8. package/dist/claude-md-injection-BMon6WUD.js.map +1 -0
  9. package/dist/{codex-3DEffjlm.js → codex-PRWoBiOH.js} +5 -5
  10. package/dist/{codex-3DEffjlm.js.map → codex-PRWoBiOH.js.map} +1 -1
  11. package/dist/engine-CDZdAx8N.js +1 -0
  12. package/dist/{gate-discovery-BV6UGGVd.js → gate-discovery-BNy8GKsC.js} +2 -2
  13. package/dist/{gate-discovery-BV6UGGVd.js.map → gate-discovery-BNy8GKsC.js.map} +1 -1
  14. package/dist/hooks.mjs +45 -10
  15. package/dist/hooks.sha256 +1 -1
  16. package/dist/{internal-prompt-submit-bi7F7pKk.js → internal-prompt-submit-BW5g3MjD.js} +2 -2
  17. package/dist/{internal-prompt-submit-bi7F7pKk.js.map → internal-prompt-submit-BW5g3MjD.js.map} +1 -1
  18. package/dist/{internal-prompt-submit-B-kKTl-8.js → internal-prompt-submit-C4uDwr7G.js} +2 -2
  19. package/dist/{internal-rebrief-B6ZJS6Mp.js → internal-rebrief-DvBS8myn.js} +3 -3
  20. package/dist/{internal-rebrief-B6ZJS6Mp.js.map → internal-rebrief-DvBS8myn.js.map} +1 -1
  21. package/dist/{internal-stop-hook-covotLvl.js → internal-stop-hook-CXlOsW63.js} +2 -2
  22. package/dist/{internal-stop-hook-covotLvl.js.map → internal-stop-hook-CXlOsW63.js.map} +1 -1
  23. package/dist/main.js +8 -8
  24. package/dist/{peer-mcp-personas-6zWkXHQW.js → peer-mcp-personas-Dxxw5X1g.js} +615 -274
  25. package/dist/peer-mcp-personas-Dxxw5X1g.js.map +1 -0
  26. package/dist/{pi-DJJlBHP9.js → pi-IYAvKF50.js} +805 -68
  27. package/dist/pi-IYAvKF50.js.map +1 -0
  28. package/dist/{provision-C_aTowyW.js → provision-CIn6I4w_.js} +33 -2
  29. package/dist/provision-CIn6I4w_.js.map +1 -0
  30. package/dist/{serve-CfizTkRS.js → serve-CttHP8dJ.js} +7 -7
  31. package/dist/{serve-CfizTkRS.js.map → serve-CttHP8dJ.js.map} +1 -1
  32. package/dist/{server-setup-rm8ELtYa.js → server-setup-D7XHUrhM.js} +37 -24
  33. package/dist/server-setup-D7XHUrhM.js.map +1 -0
  34. package/dist/{start-D7RcHG8T.js → start-XU5HwLd9.js} +3 -3
  35. package/dist/{start-D7RcHG8T.js.map → start-XU5HwLd9.js.map} +1 -1
  36. package/dist/{static-context-pack-DvwLWlbe.js → static-context-pack-CsOAC87F.js} +98 -18
  37. package/dist/static-context-pack-CsOAC87F.js.map +1 -0
  38. package/dist/workiq-tools-CMoDjrO0.js +1 -0
  39. package/package.json +1 -1
  40. package/dist/ado-tools-B5MNQMFs.js +0 -1
  41. package/dist/claude-B3qNFwtc.js.map +0 -1
  42. package/dist/claude-md-injection-K3DKhsfI.js.map +0 -1
  43. package/dist/engine-C2YCclx0.js +0 -1
  44. package/dist/peer-mcp-personas-6zWkXHQW.js.map +0 -1
  45. package/dist/pi-DJJlBHP9.js.map +0 -1
  46. package/dist/provision-C_aTowyW.js.map +0 -1
  47. package/dist/server-setup-rm8ELtYa.js.map +0 -1
  48. package/dist/static-context-pack-DvwLWlbe.js.map +0 -1
  49. package/dist/workiq-tools-BeTneKco.js +0 -1
@@ -7,7 +7,7 @@ import { C as copilotHeaders, E as githubAgentHeaders, S as copilotBaseUrl, T as
7
7
  import { a as withTransientRetry, i as sanitizeTransportText, n as classifyTransportError, r as fetchWithTransientRetry } from "./upstream-retry-i1k1Xai2.js";
8
8
  import { a as parseBoolEnv, d as runManagedExeCapture, o as parseIntEnv, s as resolveExecutable } from "./exec-Bf8g_bIR.js";
9
9
  import { a as FAST_PROFILE_ASTRA_MODEL, c as FAST_PROFILE_MODELS, d as FAST_PROFILE_NATIVE_MODELS, f as FAST_PROFILE_ORACLE_EFFORT, n as FAST_PROFILE_ADVISOR_EFFORT, p as FAST_PROFILE_ORACLE_MODEL, r as FAST_PROFILE_ADVISOR_MODEL, u as FAST_PROFILE_NATIVE_EFFORTS } from "./fast-profile-contract-JOnZBgFB.js";
10
- import { A as CHEAPEST_PROFILE_ADVISOR_MODEL, C as BALANCED2_PROFILE_MODELS, M as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MAX, N as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MIN, O as CHEAPEST2_PROFILE_MODELS, P as CHEAPEST_PROFILE_MODELS, S as localContractFor, _ as isCheapestFamily, a as decidePromptSubmitV2, b as isPinnedLaunchProfile, c as CHEAPEST_REWRITE_EFFORT, f as balancedContractFor, g as isBalancedFamily, h as displayModelName, j as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_DEFAULT, m as cheapestRewriteModelFor, p as cheapestContractFor, t as buildStaticPack, u as isCheapestRewriteDisabledEnv, v as isCheaplocalProfile, w as LOCAL_PROFILE_LEAD_MODEL, y as isLocalFamily } from "./static-context-pack-DvwLWlbe.js";
10
+ import { A as CHEAPEST2_PROFILE_MODELS, C as localContractFor, F as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MIN, I as CHEAPEST_PROFILE_MODELS, M as CHEAPEST_PROFILE_ADVISOR_MODEL, N as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_DEFAULT, P as CHEAPEST_PROFILE_ADVISOR_TRANSCRIPT_TOKENS_MAX, T as LOCAL_PROFILE_LEAD_MODEL, _ as isBalancedFamily, a as decidePromptSubmitV2, b as isLocalFamily, c as CHEAPEST_REWRITE_EFFORT, f as balancedContractFor, g as displayModelName, h as consultIsLocalTransport, k as LOCAL_CONSULT_MAX_OUTPUT_TOKENS, m as cheapestRewriteModelFor, p as cheapestContractFor, t as buildStaticPack, u as isCheapestRewriteDisabledEnv, v as isCheapestFamily, w as BALANCED2_PROFILE_MODELS, x as isPinnedLaunchProfile, y as isCheaplocalProfile } from "./static-context-pack-CsOAC87F.js";
11
11
  import { r as BALANCED_PROFILE_MODELS } from "./balanced-profile-contract-Dm_usmw7.js";
12
12
  import { A as normalizeTrailingOneMSuffix, D as maxPeerInstructions, E as maxPeerDescription, O as fastEndpointForCatalogId, b as MAX_ADVISOR_SYSTEM_PROMPT, f as maxCodexReviewerModel, g as maxProReplacementModel, h as maxOpusModel, i as MAX_PROFILE_MODELS, k as fastEndpointForModel, m as maxGrokModel, p as maxGeminiModel, r as MAX_PROFILE_LEAD_MODEL, v as maxSonnetModel } from "./max-profile-contract-CRj7N211.js";
13
13
  import { i as registerExitHandlers$1, n as getInstanceUuid, r as recordWorkerRepo, t as WorktreeRegistry } from "./lifecycle-Gge2Dadd.js";
@@ -5912,6 +5912,195 @@ async function verifyAndConsumeApproval(args) {
5912
5912
  return { ok: true };
5913
5913
  });
5914
5914
  }
5915
+ //#endregion
5916
+ //#region src/lib/copilot-model-policy.ts
5917
+ /**
5918
+ * Which Copilot models a running proxy is allowed to bill.
5919
+ *
5920
+ * A `-m local` / `-m local2` launch exists so that the agent's work runs on the
5921
+ * operator's own inference endpoint. The profiles keep the whole Claude Code
5922
+ * surface (native subagents, agent-team teammates, every CLI feature) but every
5923
+ * one of those turns must land on that endpoint, not on Copilot.
5924
+ *
5925
+ * Prompting cannot enforce that. A teammate's model is whatever its frontmatter
5926
+ * or the client's tier picker says, and a runtime `/model` switch can name any
5927
+ * catalog id. So the restriction lives here, at the Copilot egress: the three
5928
+ * functions that talk to Copilot (`createResponses`, `createChatCompletions`,
5929
+ * and the non-local branch of `createMessages`/`countTokens`) consult
5930
+ * `assertCopilotModelAllowed` before they build a request. Everything that can
5931
+ * reach Copilot funnels through them — the `/v1/*` routes, the peer personas,
5932
+ * `stand_in`, the orchestration tools, and the Pi worker runtime (whose
5933
+ * `stream-fn` imports the same services).
5934
+ *
5935
+ * `local` allows no Copilot model inference on an agent turn at all. `local2`
5936
+ * allows the two families `sol` and `luna`. The non-model Copilot services are
5937
+ * untouched: `web` search goes through Copilot's MCP endpoint with the GitHub
5938
+ * PAT, and the browser tools drive a local extension.
5939
+ *
5940
+ * `cheaplocal` is the mirror image: its lead and every native stay on Copilot,
5941
+ * and only its Advisor and Oracle leave. It therefore caps Copilot egress to the
5942
+ * same two families without being a local launch: `activeLocalLaunchProfile`
5943
+ * ignores it, because returning it would send the whole main loop to the local
5944
+ * endpoint.
5945
+ *
5946
+ * The one model-backed exception is the browser page compressor, which runs on
5947
+ * both profiles so the compound browse tools can answer at all. It is exempt
5948
+ * from the profile ceiling entirely and bounded by its own fixed chain instead;
5949
+ * see `CopilotEgressSurface`.
5950
+ */
5951
+ /**
5952
+ * The hardcoded Copilot allow-list for `-m local2`: the Advisor and the Oracle
5953
+ * both run on `gpt-6.1-sol`, and `luna` is the cheap tier of the same declared
5954
+ * ceiling. Anything else a teammate or a `/model` switch names is refused.
5955
+ *
5956
+ * `luna`'s one Copilot consumer on this profile is the browser page
5957
+ * compressor, whose fixed chain falls back to `gpt-6-luna` when
5958
+ * `gpt-5.4-mini` is absent from the catalog. That surface is exempt from the
5959
+ * ceiling, so the entry is not what admits it; it keeps the two lists agreeing
5960
+ * if the exemption ever narrows. No other local surface selects Luna: no local
5961
+ * launch publishes the `workers` group. The ceiling stays an operator
5962
+ * decision, so moving it later is a policy change rather than a code change.
5963
+ *
5964
+ * `cheaplocal` shares the set for the same reason: its lead and natives are
5965
+ * Luna, its Copilot rewrite is Sol, and its consultants are not Copilot calls
5966
+ * at all.
5967
+ */
5968
+ const LOCAL2_COPILOT_MODEL_FAMILIES = /* @__PURE__ */ new Set(["sol", "luna"]);
5969
+ /** The policy a launch profile imposes on Copilot egress. Every profile other
5970
+ * than the local pair and `cheaplocal` is unrestricted. */
5971
+ function copilotModelPolicyForProfile(profileId) {
5972
+ if (profileId === "local") return {
5973
+ kind: "forbidden",
5974
+ profileId
5975
+ };
5976
+ if (profileId === "local2" || profileId === "cheaplocal") return {
5977
+ kind: "families",
5978
+ profileId,
5979
+ families: LOCAL2_COPILOT_MODEL_FAMILIES
5980
+ };
5981
+ return { kind: "unrestricted" };
5982
+ }
5983
+ /**
5984
+ * The policy in force for this process.
5985
+ *
5986
+ * Derived from the live launch registry rather than a mutable global: the
5987
+ * proxy and the `claude` launch that fronts it share a process, so the
5988
+ * registered launches ARE the set of sessions whose traffic can arrive here.
5989
+ * Requests that never passed the identity preflight (a BYO client pointed at
5990
+ * `github-router start`) still funnel through the same egress, which is why
5991
+ * this is process-wide rather than per-request.
5992
+ *
5993
+ * Most restrictive wins: if a `local` launch is registered at the same time as
5994
+ * a `local2` one, Copilot inference is forbidden outright. Registering both in
5995
+ * one process is not a supported arrangement, and resolving the ambiguity
5996
+ * toward the stricter profile is the fail-closed direction.
5997
+ */
5998
+ function activeCopilotModelPolicy() {
5999
+ let active = { kind: "unrestricted" };
6000
+ for (const entry of state.launchRegistry.values()) {
6001
+ const policy = copilotModelPolicyForProfile(entry.profileId);
6002
+ if (policy.kind === "forbidden") return policy;
6003
+ if (policy.kind === "families") active = policy;
6004
+ }
6005
+ return active;
6006
+ }
6007
+ /** The local-family profile this process is serving, if any. Used by the
6008
+ * `/v1/messages` routes to send traffic that carries no launch identity to
6009
+ * the local endpoint rather than to Copilot.
6010
+ *
6011
+ * A restricted policy is not enough: `cheaplocal` caps Copilot egress to the
6012
+ * same families as `local2` while keeping its whole main loop on Copilot.
6013
+ * Returning it here would route that loop to the local endpoint, so only an
6014
+ * actual local-family id answers. */
6015
+ function activeLocalLaunchProfile() {
6016
+ const policy = activeCopilotModelPolicy();
6017
+ if (policy.kind === "unrestricted") return void 0;
6018
+ if (policy.kind === "forbidden") return policy.profileId;
6019
+ return isLocalFamily(policy.profileId) ? policy.profileId : void 0;
6020
+ }
6021
+ /**
6022
+ * Effective local profile for one request.
6023
+ *
6024
+ * A bound identity wins: a request authenticated as `local`/`local2` is local,
6025
+ * and one authenticated as any other profile keeps that profile's behaviour
6026
+ * even when a local launch shares the process. Only an identity-less request
6027
+ * falls back to the process-wide answer, which is the case `-m local` needs:
6028
+ * a spawned teammate that lost its launch header still has to reach the local
6029
+ * endpoint instead of being answered by Copilot.
6030
+ */
6031
+ function effectiveLocalProfile(boundProfileId) {
6032
+ if (isLocalFamily(boundProfileId)) return boundProfileId;
6033
+ if (boundProfileId !== void 0 && boundProfileId !== null) return void 0;
6034
+ return activeLocalLaunchProfile();
6035
+ }
6036
+ /**
6037
+ * The family token of a Copilot model id: the trailing dash-separated segment,
6038
+ * lowercased, after removing a `[1m]` accounting suffix and any `-1m` sibling
6039
+ * marker. `gpt-6.1-sol` → `sol`, `gpt-6-luna` → `luna`,
6040
+ * `gemini-3.1-pro-preview` → `preview`, `claude-opus-5.5` → `5.5`.
6041
+ *
6042
+ * Matching on the tier token rather than a prefix keeps the allow-list honest:
6043
+ * `gpt-5.6-sol`, `gpt-6-sol` and `gpt-6.1-sol` are one family, while
6044
+ * `gpt-6-sol-like` is not silently admitted.
6045
+ */
6046
+ function copilotModelFamily(modelId) {
6047
+ return (modelId.trim().replace(/\[[^\]]*\]$/, "").replace(/-1m$/i, "").split("-").at(-1) ?? "").toLowerCase();
6048
+ }
6049
+ /** Whether `modelId` may be sent to Copilot under `policy`. */
6050
+ function isCopilotModelAllowedUnder(policy, modelId, surface) {
6051
+ if (surface === "browse") return true;
6052
+ if (policy.kind === "unrestricted") return true;
6053
+ if (policy.kind === "forbidden") return false;
6054
+ return policy.families.has(copilotModelFamily(modelId));
6055
+ }
6056
+ /** Whether `modelId` may be sent to Copilot in this process right now. */
6057
+ function isCopilotModelAllowed(modelId, surface) {
6058
+ return isCopilotModelAllowedUnder(activeCopilotModelPolicy(), modelId, surface);
6059
+ }
6060
+ /** Raised when a request names a Copilot model the active policy refuses.
6061
+ * Carries `model` and the active policy so a caller can turn it into an
6062
+ * actionable `isError` rather than a bare 500. */
6063
+ var CopilotModelRestrictedError = class extends Error {
6064
+ model;
6065
+ policy;
6066
+ constructor(model, policy) {
6067
+ const source = policy.kind === "unrestricted" ? "the active policy" : `the \`-m ${policy.profileId}\` profile`;
6068
+ const allowed = policy.kind === "families" ? ` Only ${[...policy.families].sort().join(", ")} families are allowed.` : " No Copilot model inference is allowed for this profile.";
6069
+ super(`Model ${model} cannot be used: ${source} does not permit it on Copilot.${allowed}` + (policy.kind === "forbidden" ? " Run the work on the local endpoint instead, or relaunch as `-m local2` to allow the Advisor and Oracle families." : ""));
6070
+ this.name = "CopilotModelRestrictedError";
6071
+ this.model = model;
6072
+ this.policy = policy;
6073
+ }
6074
+ };
6075
+ /** Throw unless `modelId` is permitted. Called at every Copilot egress. */
6076
+ function assertCopilotModelAllowed(modelId, surface) {
6077
+ const policy = activeCopilotModelPolicy();
6078
+ if (!isCopilotModelAllowedUnder(policy, modelId, surface)) throw new CopilotModelRestrictedError(modelId, policy);
6079
+ }
6080
+ /**
6081
+ * Same guard for callers that hold a serialized request body rather than a
6082
+ * resolved model id (`createMessages` / `countTokens` take the body as a
6083
+ * string). Parsing is deferred behind the policy check so the common
6084
+ * unrestricted path pays one registry scan and no JSON work.
6085
+ *
6086
+ * A restrictive policy fails closed on an unparseable body: there is no model
6087
+ * to inspect, so there is no basis for letting the request through.
6088
+ */
6089
+ function assertCopilotMessagesBodyAllowed(body) {
6090
+ if (activeCopilotModelPolicy().kind === "unrestricted") return;
6091
+ let model;
6092
+ try {
6093
+ const parsed = JSON.parse(body);
6094
+ if (parsed && typeof parsed === "object" && "model" in parsed) {
6095
+ const raw = parsed.model;
6096
+ if (typeof raw === "string") model = raw;
6097
+ }
6098
+ } catch {
6099
+ model = void 0;
6100
+ }
6101
+ if (model === void 0) throw new CopilotModelRestrictedError("<unparseable body>", activeCopilotModelPolicy());
6102
+ assertCopilotModelAllowed(model);
6103
+ }
5915
6104
  const TIER_CHAINS = {
5916
6105
  T0: [
5917
6106
  "gemini-3.5-flash",
@@ -6013,6 +6202,10 @@ function classifierSystemPrompt(system, schemaHint) {
6013
6202
  async function microClassify(opts) {
6014
6203
  const model = resolveTierModel("T0");
6015
6204
  if (!model) return null;
6205
+ if (!isCopilotModelAllowed(model)) {
6206
+ consola.debug(`first-mate classifier skipped: ${model} is not permitted on this launch`);
6207
+ return null;
6208
+ }
6016
6209
  let response;
6017
6210
  try {
6018
6211
  response = await fetch(`${copilotBaseUrl(state)}/chat/completions`, {
@@ -11244,6 +11437,10 @@ const SYSTEM_PROMPT = "You are a SHADOW judge for a GitHub coding-agent controll
11244
11437
  const defaultTier1Judge = async (req, opts) => {
11245
11438
  const model = resolveTierModel("T1", opts);
11246
11439
  if (!model) return null;
11440
+ if (!isCopilotModelAllowed(model)) {
11441
+ consola.debug(`first-mate Tier1 judge skipped: ${model} is not permitted on this launch`);
11442
+ return null;
11443
+ }
11247
11444
  const user = JSON.stringify({
11248
11445
  kind: req.kind,
11249
11446
  trusted: {
@@ -18461,7 +18658,7 @@ const GPT56_EXPLICIT_CACHE_MODELS = /* @__PURE__ */ new Set([
18461
18658
  "gpt-5.6-luna"
18462
18659
  ]);
18463
18660
  const priorSignatures = /* @__PURE__ */ new Map();
18464
- function nonNegativeInt(value) {
18661
+ function nonNegativeInt$1(value) {
18465
18662
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return 0;
18466
18663
  return Math.floor(value);
18467
18664
  }
@@ -18504,15 +18701,15 @@ function normalizeOpenAIUsage(usage) {
18504
18701
  cacheWrite: 0,
18505
18702
  totalTokens: 0
18506
18703
  };
18507
- const totalInput = nonNegativeInt(usage.input_tokens ?? usage.prompt_tokens);
18508
- const output = nonNegativeInt(usage.output_tokens ?? usage.completion_tokens);
18704
+ const totalInput = nonNegativeInt$1(usage.input_tokens ?? usage.prompt_tokens);
18705
+ const output = nonNegativeInt$1(usage.output_tokens ?? usage.completion_tokens);
18509
18706
  const details = usageDetails(usage);
18510
- const cacheRead = Math.min(totalInput, nonNegativeInt(details.cached_tokens));
18707
+ const cacheRead = Math.min(totalInput, nonNegativeInt$1(details.cached_tokens));
18511
18708
  const remaining = Math.max(0, totalInput - cacheRead);
18512
- const cacheWrite = Math.min(remaining, nonNegativeInt(details.cache_write_tokens ?? details.cache_creation_tokens));
18709
+ const cacheWrite = Math.min(remaining, nonNegativeInt$1(details.cache_write_tokens ?? details.cache_creation_tokens));
18513
18710
  const uncachedInput = Math.max(0, totalInput - cacheRead - cacheWrite);
18514
- const reportedTotal = nonNegativeInt(usage.total_tokens);
18515
- const cacheTtlSeconds = nonNegativeInt(details.cache_ttl_seconds);
18711
+ const reportedTotal = nonNegativeInt$1(usage.total_tokens);
18712
+ const cacheTtlSeconds = nonNegativeInt$1(details.cache_ttl_seconds);
18516
18713
  return {
18517
18714
  totalInput,
18518
18715
  uncachedInput,
@@ -18781,191 +18978,6 @@ function applyClaudeCachePolicy(rawBody, opts) {
18781
18978
  return JSON.stringify(body);
18782
18979
  }
18783
18980
  //#endregion
18784
- //#region src/lib/copilot-model-policy.ts
18785
- /**
18786
- * Which Copilot models a running proxy is allowed to bill.
18787
- *
18788
- * A `-m local` / `-m local2` launch exists so that the agent's work runs on the
18789
- * operator's own inference endpoint. The profiles keep the whole Claude Code
18790
- * surface (native subagents, agent-team teammates, every CLI feature) but every
18791
- * one of those turns must land on that endpoint, not on Copilot.
18792
- *
18793
- * Prompting cannot enforce that. A teammate's model is whatever its frontmatter
18794
- * or the client's tier picker says, and a runtime `/model` switch can name any
18795
- * catalog id. So the restriction lives here, at the Copilot egress: the three
18796
- * functions that talk to Copilot (`createResponses`, `createChatCompletions`,
18797
- * and the non-local branch of `createMessages`/`countTokens`) consult
18798
- * `assertCopilotModelAllowed` before they build a request. Everything that can
18799
- * reach Copilot funnels through them — the `/v1/*` routes, the peer personas,
18800
- * `stand_in`, the orchestration tools, and the Pi worker runtime (whose
18801
- * `stream-fn` imports the same services).
18802
- *
18803
- * `local` allows no Copilot model inference on an agent turn at all. `local2`
18804
- * allows the two families `sol` and `luna`. The non-model Copilot services are
18805
- * untouched: `web` search goes through Copilot's MCP endpoint with the GitHub
18806
- * PAT, and the browser tools drive a local extension.
18807
- *
18808
- * `cheaplocal` is the mirror image: its lead and every native stay on Copilot,
18809
- * and only its Advisor and Oracle leave. It therefore caps Copilot egress to the
18810
- * same two families without being a local launch: `activeLocalLaunchProfile`
18811
- * ignores it, because returning it would send the whole main loop to the local
18812
- * endpoint.
18813
- *
18814
- * The one model-backed exception is the browser page compressor, which runs on
18815
- * both profiles so the compound browse tools can answer at all. It is exempt
18816
- * from the profile ceiling entirely and bounded by its own fixed chain instead;
18817
- * see `CopilotEgressSurface`.
18818
- */
18819
- /**
18820
- * The hardcoded Copilot allow-list for `-m local2`: the Advisor and the Oracle
18821
- * both run on `gpt-6.1-sol`, and `luna` is the cheap tier of the same declared
18822
- * ceiling. Anything else a teammate or a `/model` switch names is refused.
18823
- *
18824
- * `luna`'s one Copilot consumer on this profile is the browser page
18825
- * compressor, whose fixed chain falls back to `gpt-6-luna` when
18826
- * `gpt-5.4-mini` is absent from the catalog. That surface is exempt from the
18827
- * ceiling, so the entry is not what admits it; it keeps the two lists agreeing
18828
- * if the exemption ever narrows. No other local surface selects Luna: no local
18829
- * launch publishes the `workers` group. The ceiling stays an operator
18830
- * decision, so moving it later is a policy change rather than a code change.
18831
- *
18832
- * `cheaplocal` shares the set for the same reason: its lead and natives are
18833
- * Luna, its Copilot rewrite is Sol, and its consultants are not Copilot calls
18834
- * at all.
18835
- */
18836
- const LOCAL2_COPILOT_MODEL_FAMILIES = /* @__PURE__ */ new Set(["sol", "luna"]);
18837
- /** The policy a launch profile imposes on Copilot egress. Every profile other
18838
- * than the local pair and `cheaplocal` is unrestricted. */
18839
- function copilotModelPolicyForProfile(profileId) {
18840
- if (profileId === "local") return {
18841
- kind: "forbidden",
18842
- profileId
18843
- };
18844
- if (profileId === "local2" || profileId === "cheaplocal") return {
18845
- kind: "families",
18846
- profileId,
18847
- families: LOCAL2_COPILOT_MODEL_FAMILIES
18848
- };
18849
- return { kind: "unrestricted" };
18850
- }
18851
- /**
18852
- * The policy in force for this process.
18853
- *
18854
- * Derived from the live launch registry rather than a mutable global: the
18855
- * proxy and the `claude` launch that fronts it share a process, so the
18856
- * registered launches ARE the set of sessions whose traffic can arrive here.
18857
- * Requests that never passed the identity preflight (a BYO client pointed at
18858
- * `github-router start`) still funnel through the same egress, which is why
18859
- * this is process-wide rather than per-request.
18860
- *
18861
- * Most restrictive wins: if a `local` launch is registered at the same time as
18862
- * a `local2` one, Copilot inference is forbidden outright. Registering both in
18863
- * one process is not a supported arrangement, and resolving the ambiguity
18864
- * toward the stricter profile is the fail-closed direction.
18865
- */
18866
- function activeCopilotModelPolicy() {
18867
- let active = { kind: "unrestricted" };
18868
- for (const entry of state.launchRegistry.values()) {
18869
- const policy = copilotModelPolicyForProfile(entry.profileId);
18870
- if (policy.kind === "forbidden") return policy;
18871
- if (policy.kind === "families") active = policy;
18872
- }
18873
- return active;
18874
- }
18875
- /** The local-family profile this process is serving, if any. Used by the
18876
- * `/v1/messages` routes to send traffic that carries no launch identity to
18877
- * the local endpoint rather than to Copilot.
18878
- *
18879
- * A restricted policy is not enough: `cheaplocal` caps Copilot egress to the
18880
- * same families as `local2` while keeping its whole main loop on Copilot.
18881
- * Returning it here would route that loop to the local endpoint, so only an
18882
- * actual local-family id answers. */
18883
- function activeLocalLaunchProfile() {
18884
- const policy = activeCopilotModelPolicy();
18885
- if (policy.kind === "unrestricted") return void 0;
18886
- if (policy.kind === "forbidden") return policy.profileId;
18887
- return isLocalFamily(policy.profileId) ? policy.profileId : void 0;
18888
- }
18889
- /**
18890
- * Effective local profile for one request.
18891
- *
18892
- * A bound identity wins: a request authenticated as `local`/`local2` is local,
18893
- * and one authenticated as any other profile keeps that profile's behaviour
18894
- * even when a local launch shares the process. Only an identity-less request
18895
- * falls back to the process-wide answer, which is the case `-m local` needs:
18896
- * a spawned teammate that lost its launch header still has to reach the local
18897
- * endpoint instead of being answered by Copilot.
18898
- */
18899
- function effectiveLocalProfile(boundProfileId) {
18900
- if (isLocalFamily(boundProfileId)) return boundProfileId;
18901
- if (boundProfileId !== void 0 && boundProfileId !== null) return void 0;
18902
- return activeLocalLaunchProfile();
18903
- }
18904
- /**
18905
- * The family token of a Copilot model id: the trailing dash-separated segment,
18906
- * lowercased, after removing a `[1m]` accounting suffix and any `-1m` sibling
18907
- * marker. `gpt-6.1-sol` → `sol`, `gpt-6-luna` → `luna`,
18908
- * `gemini-3.1-pro-preview` → `preview`, `claude-opus-5.5` → `5.5`.
18909
- *
18910
- * Matching on the tier token rather than a prefix keeps the allow-list honest:
18911
- * `gpt-5.6-sol`, `gpt-6-sol` and `gpt-6.1-sol` are one family, while
18912
- * `gpt-6-sol-like` is not silently admitted.
18913
- */
18914
- function copilotModelFamily(modelId) {
18915
- return (modelId.trim().replace(/\[[^\]]*\]$/, "").replace(/-1m$/i, "").split("-").at(-1) ?? "").toLowerCase();
18916
- }
18917
- /** Whether `modelId` may be sent to Copilot under `policy`. */
18918
- function isCopilotModelAllowedUnder(policy, modelId, surface) {
18919
- if (surface === "browse") return true;
18920
- if (policy.kind === "unrestricted") return true;
18921
- if (policy.kind === "forbidden") return false;
18922
- return policy.families.has(copilotModelFamily(modelId));
18923
- }
18924
- /** Raised when a request names a Copilot model the active policy refuses.
18925
- * Carries `model` and the active policy so a caller can turn it into an
18926
- * actionable `isError` rather than a bare 500. */
18927
- var CopilotModelRestrictedError = class extends Error {
18928
- model;
18929
- policy;
18930
- constructor(model, policy) {
18931
- const source = policy.kind === "unrestricted" ? "the active policy" : `the \`-m ${policy.profileId}\` profile`;
18932
- const allowed = policy.kind === "families" ? ` Only ${[...policy.families].sort().join(", ")} families are allowed.` : " No Copilot model inference is allowed for this profile.";
18933
- super(`Model ${model} cannot be used: ${source} does not permit it on Copilot.${allowed}` + (policy.kind === "forbidden" ? " Run the work on the local endpoint instead, or relaunch as `-m local2` to allow the Advisor and Oracle families." : ""));
18934
- this.name = "CopilotModelRestrictedError";
18935
- this.model = model;
18936
- this.policy = policy;
18937
- }
18938
- };
18939
- /** Throw unless `modelId` is permitted. Called at every Copilot egress. */
18940
- function assertCopilotModelAllowed(modelId, surface) {
18941
- const policy = activeCopilotModelPolicy();
18942
- if (!isCopilotModelAllowedUnder(policy, modelId, surface)) throw new CopilotModelRestrictedError(modelId, policy);
18943
- }
18944
- /**
18945
- * Same guard for callers that hold a serialized request body rather than a
18946
- * resolved model id (`createMessages` / `countTokens` take the body as a
18947
- * string). Parsing is deferred behind the policy check so the common
18948
- * unrestricted path pays one registry scan and no JSON work.
18949
- *
18950
- * A restrictive policy fails closed on an unparseable body: there is no model
18951
- * to inspect, so there is no basis for letting the request through.
18952
- */
18953
- function assertCopilotMessagesBodyAllowed(body) {
18954
- if (activeCopilotModelPolicy().kind === "unrestricted") return;
18955
- let model;
18956
- try {
18957
- const parsed = JSON.parse(body);
18958
- if (parsed && typeof parsed === "object" && "model" in parsed) {
18959
- const raw = parsed.model;
18960
- if (typeof raw === "string") model = raw;
18961
- }
18962
- } catch {
18963
- model = void 0;
18964
- }
18965
- if (model === void 0) throw new CopilotModelRestrictedError("<unparseable body>", activeCopilotModelPolicy());
18966
- assertCopilotModelAllowed(model);
18967
- }
18968
- //#endregion
18969
18981
  //#region src/lib/vision-preflight.ts
18970
18982
  /**
18971
18983
  * Outbound vision handling.
@@ -26544,17 +26556,6 @@ async function countTokens(body, extraHeaders, callerSignal, retryTransient = fa
26544
26556
  return response;
26545
26557
  }
26546
26558
  const LOCAL_DEFAULT_BASE_URL = `https://localhost:11111/v1`;
26547
- /**
26548
- * Output cap for a local consultant turn (Advisor and Oracle).
26549
- *
26550
- * One number for both, and deliberately a small one: a consultant answers a
26551
- * single question, and every larger value would be a claim about how much room
26552
- * the model behind the endpoint has. The Copilot paths keep their own
26553
- * catalog-derived budgets; this is only ever the catalog-less fallback, so a
26554
- * launch whose consultants left Copilot is no worse off than the branch that
26555
- * existed before it.
26556
- */
26557
- const LOCAL_CONSULT_MAX_OUTPUT_TOKENS = 4096;
26558
26559
  let cliOverride;
26559
26560
  let warnedInert = false;
26560
26561
  function trimTrailingSlashes(value) {
@@ -26685,8 +26686,13 @@ function localSessionId(c, launchSessionId) {
26685
26686
  *
26686
26687
  * `output_config.effort` is the exception, and it is not a claim: it is the
26687
26688
  * same Anthropic spelling Claude Code itself sends, and it states what the
26688
- * operator asked for (`LOCAL_CONSULT_EFFORT`) rather than what the endpoint is.
26689
- * The proxy does not clamp it against a reasoning ladder it has never read.
26689
+ * profile DECLARED for this consult rather than what the endpoint is. The proxy
26690
+ * does not clamp it against a reasoning ladder it has never read.
26691
+ *
26692
+ * `effort` is therefore a parameter, not a constant read in here. The value is
26693
+ * declared on the profile contract (`oracleEffort` / `advisorEffort`) and this
26694
+ * function must send the declaration rather than a second copy of it: a copy is
26695
+ * exactly how the wire came to say `max` while `local`'s contract said `high`.
26690
26696
  *
26691
26697
  * `maxTokens` is a caller decision rather than a constant here so the two
26692
26698
  * consultants can keep their own budgets; both pass the catalog-less fallback,
@@ -26709,7 +26715,7 @@ async function sendLocalMessages(req) {
26709
26715
  role: "user",
26710
26716
  content: req.userText
26711
26717
  }],
26712
- output_config: { effort: "max" }
26718
+ output_config: { effort: req.effort }
26713
26719
  }), {}, req.signal, false, req.egress)).json();
26714
26720
  const blocks = Array.isArray(json.content) ? json.content : [];
26715
26721
  const texts = [];
@@ -27544,10 +27550,11 @@ function cheapestAdvisorModel(profileId) {
27544
27550
  * present, serve enough prompt/window for the family's subagent budget, offer
27545
27551
  * the contract's effort, and route over `/responses`.
27546
27552
  *
27547
- * The local profiles use it too. Their LEAD turns go to the local endpoint, but
27548
- * the Oracle is still a Copilot persona, so it is gated against the live
27549
- * catalog exactly like the cheapest family's rather than falling back to the
27550
- * fast-profile default.
27553
+ * This is the COPILOT gate and nothing else: a contract whose consult runs
27554
+ * locally (`cheaplocal`, and `local` since its Oracle moved to the lead's own
27555
+ * endpoint) must not reach it at all, because there is no slug to look up. The
27556
+ * two callers branch on `consultTransport` first — `cheapestFamilyOracleGate`
27557
+ * and `localOracleModel` — so this function stays one job.
27551
27558
  */
27552
27559
  function familyOracleModelFor(contract) {
27553
27560
  const found = state.models?.data.find((m) => m.id === contract.oracleModel);
@@ -27564,22 +27571,34 @@ function cheapestOracleModel(profileId) {
27564
27571
  return familyOracleModelFor(cheapestContractFor(profileId));
27565
27572
  }
27566
27573
  /**
27567
- * Oracle gate for `cheaplocal`, whose Oracle is a local consult.
27574
+ * Oracle gate for a local consult: `local` and `cheaplocal`.
27568
27575
  *
27569
- * Always true, and it says nothing about a catalog because there is nothing to
27570
- * check: the persona resolves no Copilot slug, sends no catalog-derived
27571
- * effort, and routes no `/responses` call. Running `familyOracleModelFor`
27572
- * here would DROP the tool on
27573
- * any catalog that happens not to carry an Opus row, and would gate a local
27574
- * consult on a Copilot model's window, which is exactly the assumption this
27575
- * profile refuses to make. The launch's own `allowedPersonas` still gates it.
27576
+ * Answers the sentinel rather than a slug, and says nothing about a catalog
27577
+ * because there is nothing to check. Running the catalog gate here would DROP
27578
+ * the tool on any catalog that happens not to carry an Opus row, and would gate
27579
+ * a local consult on a Copilot model's window, which is exactly the assumption
27580
+ * these profiles refuse to make. The launch's own `allowedPersonas` still gates
27581
+ * it.
27576
27582
  */
27577
27583
  function cheaplocalOracleModel() {
27578
27584
  return true;
27579
27585
  }
27580
- /** Copilot-served Oracle for `local` / `local2` at the 200K default window. */
27586
+ /**
27587
+ * Oracle gate for the `local` family, whose two transports need different
27588
+ * checks.
27589
+ *
27590
+ * `local` consults the endpoint its lead already uses: no Copilot slug is
27591
+ * resolved and no `/responses` call is routed, so every check in
27592
+ * `familyOracleModelFor` would be a gate on a model that is not answering — an
27593
+ * Opus row missing from the catalog would DROP a tool that works, and the
27594
+ * window/effort assertions are Copilot facts the local endpoint was never asked
27595
+ * to satisfy. It answers `true` (the same shape `cheaplocalOracleModel` uses);
27596
+ * `local2` kept a billed Copilot Oracle and is catalog-gated exactly like the
27597
+ * cheapest family's. The launch's own `allowedPersonas` still gates the tool.
27598
+ */
27581
27599
  function localOracleModel(profileId) {
27582
- return familyOracleModelFor(localContractFor(profileId));
27600
+ const contract = localContractFor(profileId);
27601
+ return contract.consultTransport === "local" ? true : familyOracleModelFor(contract);
27583
27602
  }
27584
27603
  /** Luna/max reviewer for the cheapest family at the 200K default window. */
27585
27604
  function cheapestReviewerModel(profileId) {
@@ -28817,7 +28836,7 @@ function activePersonas(launch) {
28817
28836
  /** Oracle descriptor derived from the family contract, so a model swap in the
28818
28837
  * contract renames itself here instead of leaving stale prose behind. */
28819
28838
  function familyOracleDescriptor(profileId) {
28820
- if (isCheaplocalProfile(profileId)) return "the local model";
28839
+ if (consultIsLocalTransport(profileId)) return "the local model";
28821
28840
  if (isCheapestFamily(profileId)) {
28822
28841
  const contract = cheapestContractFor(profileId);
28823
28842
  return `${displayModelName(contract.oracleModel)} (200K context, ${contract.oracleEffort} effort)`;
@@ -29035,8 +29054,9 @@ function toolEntries(scope, launch, audience = "shared") {
29035
29054
  const astraAvailable = astraWired && (isCheap && !isCheapest ? cheapAstraModel() : isCheapest ? void 0 : fastAstraModel()) != null;
29036
29055
  const oracleGate = isLocal ? localOracleModel(launch.profileId) : isCheapest ? cheapestFamilyOracleGate(launch.profileId) : isBalanced ? balancedOracleModel(launch.profileId) : isCheap ? cheapOracleModel() : fastOracleModel();
29037
29056
  const oracleDescriptor = familyOracleDescriptor(launch.profileId);
29057
+ const oracleRedactsBrief = consultIsLocalTransport(launch.profileId);
29038
29058
  const entries = [];
29039
- if ((scope === "all" || scope === "peers") && launch.allowedGroups?.has("peers") && launch.allowedPersonas?.has("oracle") && oracleGate) entries.push(oracleToolEntry(isCheap, astraAvailable, oracleDescriptor, advisorAvailable, isCheaplocalProfile(launch.profileId)));
29059
+ if ((scope === "all" || scope === "peers") && launch.allowedGroups?.has("peers") && launch.allowedPersonas?.has("oracle") && oracleGate) entries.push(oracleToolEntry(isCheap, astraAvailable, oracleDescriptor, advisorAvailable, oracleRedactsBrief));
29040
29060
  if ((scope === "all" || scope === "peers") && launch.allowedGroups?.has("peers") && launch.allowedPersonas?.has("astra") && audience === "lead-peers" && astraWired && (isCheap ? cheapAstraModel() : fastAstraModel())) entries.push(astraToolEntry(isCheap));
29041
29061
  for (const tool of listableNonPersonaTools()) {
29042
29062
  if (!fastAllowsTool(scope, launch, {
@@ -29568,12 +29588,13 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
29568
29588
  const isCheapestOracle = isCheapestFamily(launch.profileId);
29569
29589
  const isBalancedOracle = isBalancedFamily(launch.profileId);
29570
29590
  const isLocalOracle = isLocalFamily(launch.profileId);
29571
- const isCheaplocalOracle = isCheapestOracle && cheapestContractFor(launch.profileId).consultTransport === "local";
29591
+ const oracleContract = isLocalOracle ? localContractFor(launch.profileId) : isCheapestOracle ? cheapestContractFor(launch.profileId) : isBalancedOracle ? balancedContractFor(launch.profileId) : void 0;
29592
+ const oracleIsLocalConsult = oracleContract?.consultTransport === "local";
29572
29593
  const isCheapOracle = launch.profileId === "cheap" || launch.profileId === "cheap1m" || isCheapestOracle || isBalancedOracle;
29573
- const oracleModel = isLocalOracle ? localContractFor(launch.profileId).oracleModel : isCheapestOracle ? cheapestContractFor(launch.profileId).oracleModel : isBalancedOracle ? balancedContractFor(launch.profileId).oracleModel : isCheapOracle ? CHEAP_PROFILE_ORACLE_MODEL : "claude-opus-5.5";
29574
- const oracleEndpoint = isCheaplocalOracle ? "/v1/messages" : isCheapOracle || isLocalOracle ? "/v1/responses" : "/v1/messages";
29575
- const oracleEffort = isLocalOracle ? localContractFor(launch.profileId).oracleEffort : isCheapestOracle ? cheapestContractFor(launch.profileId).oracleEffort : isBalancedOracle ? balancedContractFor(launch.profileId).oracleEffort : isCheapOracle ? CHEAP_PROFILE_ORACLE_EFFORT : "high";
29576
- const oracleGateFn = isLocalOracle ? () => localOracleModel(launch.profileId) : isCheapestOracle ? () => cheapestFamilyOracleGate(launch.profileId) : isBalancedOracle ? () => balancedOracleModel(launch.profileId) : isCheapOracle ? cheapOracleModel : fastOracleModel;
29594
+ const oracleModel = oracleContract ? oracleContract.oracleModel : isCheapOracle ? CHEAP_PROFILE_ORACLE_MODEL : "claude-opus-5.5";
29595
+ const oracleEndpoint = oracleIsLocalConsult ? "/v1/messages" : isCheapOracle && !isLocalOracle ? "/v1/responses" : isLocalOracle && oracleContract?.consultTransport === "copilot" ? "/v1/responses" : "/v1/messages";
29596
+ const oracleEffort = oracleContract ? oracleContract.oracleEffort : isCheapOracle ? CHEAP_PROFILE_ORACLE_EFFORT : "high";
29597
+ const oracleGateFn = oracleIsLocalConsult ? () => true : isLocalOracle ? () => localOracleModel(launch.profileId) : isCheapestOracle ? () => cheapestFamilyOracleGate(launch.profileId) : isBalancedOracle ? () => balancedOracleModel(launch.profileId) : isCheapOracle ? cheapOracleModel : fastOracleModel;
29577
29598
  if (scope !== "all" && scope !== "peers" || !launch.allowedGroups?.has("peers") || !launch.allowedPersonas?.has("oracle") || !oracleGateFn()) return rpcError(body.id, RPC_METHOD_NOT_FOUND, `tools/call: unknown tool "${name}"`);
29578
29599
  const query = typeof args.query === "string" ? args.query.trim() : "";
29579
29600
  const context = typeof args.context === "string" ? args.context.trim() : "";
@@ -29582,20 +29603,22 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
29582
29603
  const oracleInput = `Query:\n${query}\n\nContext:\n${context}`;
29583
29604
  const inputBytes = Buffer.byteLength(oracleInput, "utf8");
29584
29605
  if (inputBytes > MAX_ORACLE_INPUT_BYTES) return rpcResult(body.id, toolError(`pre-flight rejected: oracle input is ${inputBytes} bytes, over the ${MAX_ORACLE_INPUT_BYTES}-byte cap; narrow the context without silently truncating it`));
29606
+ const oracleInstructions = oracleIsLocalConsult ? `You are Oracle, an expert architectural and technical consultant. You have no tools or repository access. Answer from the supplied context and state assumptions explicitly, noting which facts would change the recommendation. Never claim to execute, verify, approve, merge, or authorize an action. ${LOCAL_CONSULT_REDACTION_NOTE}` : `You are Oracle, an expert architectural and technical consultant running on ${displayModelName(oracleModel)}. You have no tools or repository access. Answer from the supplied context and state assumptions explicitly, noting which facts would change the recommendation. Never claim to execute, verify, approve, merge, or authorize an action.`;
29607
+ const oraclePersonaEffort = isEffort(oracleEffort) ? oracleEffort : "high";
29585
29608
  const oraclePersona = {
29586
29609
  agentName: "oracle",
29587
29610
  toolNameHttp: "oracle",
29588
29611
  model: oracleModel,
29589
29612
  endpoint: oracleEndpoint,
29590
29613
  description: "Oracle: self-contained consultant",
29591
- baseInstructions: isCheaplocalOracle ? `You are Oracle, an expert architectural and technical consultant. You have no tools or repository access. Answer from the supplied context and state assumptions explicitly, noting which facts would change the recommendation. Never claim to execute, verify, approve, merge, or authorize an action. ${LOCAL_CONSULT_REDACTION_NOTE}` : `You are Oracle, an expert architectural and technical consultant running on ${displayModelName(oracleModel)}. You have no tools or repository access. Answer from the supplied context and state assumptions explicitly, noting which facts would change the recommendation. Never claim to execute, verify, approve, merge, or authorize an action.`,
29614
+ baseInstructions: oracleInstructions,
29592
29615
  agentPrompt: "",
29593
29616
  writeCapable: false,
29594
29617
  requiresHttp: true,
29595
- allowedEfforts: [oracleEffort],
29596
- defaultEffort: oracleEffort
29618
+ allowedEfforts: [oraclePersonaEffort],
29619
+ defaultEffort: oraclePersonaEffort
29597
29620
  };
29598
- if (!isCheaplocalOracle) {
29621
+ if (!oracleIsLocalConsult) {
29599
29622
  const overflow = await predictedWindowOverflow(oraclePersona, oracleInput, void 0);
29600
29623
  if (overflow) return rpcResult(body.id, toolError(overflow));
29601
29624
  }
@@ -29611,7 +29634,7 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
29611
29634
  if (abortKey !== void 0) inflightAborts.set(abortKey, inflightEntry);
29612
29635
  try {
29613
29636
  let text;
29614
- if (isCheaplocalOracle) {
29637
+ if (oracleIsLocalConsult) {
29615
29638
  const egress = localConsultEgress ?? {
29616
29639
  baseUrl: localBaseUrl(),
29617
29640
  sessionId: launch.sessionId?.trim() || state.sessionId
@@ -29622,6 +29645,7 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
29622
29645
  system: oraclePersona.baseInstructions,
29623
29646
  userText: oracleInput,
29624
29647
  maxTokens: LOCAL_CONSULT_MAX_OUTPUT_TOKENS,
29648
+ effort: oracleEffort,
29625
29649
  signal: aborter.signal
29626
29650
  }), {
29627
29651
  signal: aborter.signal,
@@ -29633,7 +29657,7 @@ async function handleToolsCall(body, scope, launch, audience = "shared", session
29633
29657
  endpoint: oracleEndpoint,
29634
29658
  instructions: oraclePersona.baseInstructions,
29635
29659
  userText: oracleInput,
29636
- effort: oracleEffort,
29660
+ effort: oraclePersonaEffort,
29637
29661
  signal: aborter.signal
29638
29662
  });
29639
29663
  logTelemetry({
@@ -29927,7 +29951,7 @@ async function handleMcpPost(c, scopeArg = "all") {
29927
29951
  return c.json(rpcError(null, RPC_PARSE_ERROR, "request body is not valid JSON"), 200);
29928
29952
  }
29929
29953
  const sessionWorkspace = c.req.header(MCP_WORKSPACE_HEADER);
29930
- const localConsultEgress = isCheaplocalProfile(launch.profileId) ? {
29954
+ const localConsultEgress = consultIsLocalTransport(launch.profileId) ? {
29931
29955
  baseUrl: localBaseUrl(),
29932
29956
  sessionId: localSessionId(c, launch.sessionId)
29933
29957
  } : void 0;
@@ -30069,6 +30093,257 @@ function handleMcpDelete(c) {
30069
30093
  return c.body(null, 200);
30070
30094
  }
30071
30095
  //#endregion
30096
+ //#region src/lib/anthropic-usage.ts
30097
+ const ENCODER$2 = new TextEncoder();
30098
+ const DECODER = new TextDecoder();
30099
+ /** The usage fields this module reasons about, in log order. */
30100
+ const USAGE_KEYS = [
30101
+ "input_tokens",
30102
+ "cache_creation_input_tokens",
30103
+ "cache_read_input_tokens",
30104
+ "output_tokens"
30105
+ ];
30106
+ /**
30107
+ * Cap on a single un-terminated SSE record held in the transform buffer.
30108
+ * A record that grows past this is emitted verbatim rather than buffered
30109
+ * forever, so a pathological upstream event is passed through instead of
30110
+ * being truncated or held in memory.
30111
+ */
30112
+ const MAX_PENDING_RECORD_BYTES = 1 << 20;
30113
+ function nonNegativeInt(value) {
30114
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return 0;
30115
+ return Math.floor(value);
30116
+ }
30117
+ /**
30118
+ * True when the operator has opted out of the Anthropic usage rewrite.
30119
+ *
30120
+ * The rewrite targets an upstream that reports `input_tokens` as the TOTAL
30121
+ * prompt with the cached prefix as a DETAIL of that total (OpenAI semantics)
30122
+ * rather than as the uncached remainder (the Anthropic contract). BOTH shapes
30123
+ * have been measured in real traffic through this proxy: session `ec65e3f9`
30124
+ * was inclusive on the native Copilot path, the same path captured exclusive
30125
+ * on 2026-11-05, and the local endpoint of session `a1ab11a5` was inclusive.
30126
+ * An operator pointing `--localurl` at an upstream whose shape the
30127
+ * `input < cached` guard cannot discriminate can disable the rewrite here.
30128
+ */
30129
+ function anthropicUsageNormalizeDisabled() {
30130
+ return parseBoolEnv(process.env.GH_ROUTER_DISABLE_ANTHROPIC_USAGE_NORMALIZE) === true;
30131
+ }
30132
+ /**
30133
+ * Rewrite an Anthropic-shaped `usage` object so its three input buckets are
30134
+ * mutually exclusive, which is what Anthropic clients (and Claude Code's
30135
+ * context meter) sum.
30136
+ *
30137
+ * The problem this fixes: some upstreams report `input_tokens` INCLUSIVE of
30138
+ * `cache_read_input_tokens` — OpenAI semantics inside an Anthropic-shaped
30139
+ * usage object. Claude Code computes context size as `input_tokens +
30140
+ * cache_creation_input_tokens + cache_read_input_tokens + output_tokens`, so
30141
+ * forwarding the inclusive figure counts the cached prefix twice. Measured on
30142
+ * a warm turn in session `ec65e3f9` (native Copilot path): turn 1 `55931/0`
30143
+ * followed by turn 2 `56423/55808` across an exchange whose entire new
30144
+ * payload was under 2 KB. Under the exclusive reading that turn would have
30145
+ * added ~56,300 tokens; inclusive predicts +492, which is what happened. The
30146
+ * local egress is inclusive too: a 2026-11-05 capture of `-m local` showed a
30147
+ * warm `message_delta` of `input_tokens=45620 cache_read_input_tokens=45440`,
30148
+ * and the client meter read 91,060 for a 45,620-token prompt. The doubled
30149
+ * meter halves the effective context window and makes autocompact thrash on
30150
+ * sessions with a large static prefix.
30151
+ *
30152
+ * NOT every upstream is inclusive, and the Copilot path is not guaranteed to
30153
+ * be: an advisor-off capture of it on 2026-11-05 reported `message_start
30154
+ * input_tokens=2 cache_creation_input_tokens=66941`, which only the exclusive
30155
+ * reading explains. Every capture so far delivered `input_tokens` and the
30156
+ * cache buckets on the SAME SSE record, so the guard below is what
30157
+ * discriminates the two shapes rather than across-frame reassembly.
30158
+ *
30159
+ * The math mirrors `normalizeOpenAIUsage` in `~/lib/prompt-cache`:
30160
+ * `uncached = total - cacheRead - cacheWrite`.
30161
+ *
30162
+ * The guard is what lets this run unconditionally. An exclusive (conformant)
30163
+ * upstream reports the uncached remainder as `input_tokens`, which on a warm
30164
+ * turn is SMALLER than the cached prefix — a shape that is impossible under
30165
+ * inclusive semantics. Such a response is left byte-for-byte alone. A cold
30166
+ * turn reports no cache at all, where both conventions agree, so it is a
30167
+ * no-op too.
30168
+ *
30169
+ * Residual ambiguity: an exclusive upstream whose uncached remainder exceeds
30170
+ * its cached prefix (`input >= cached`) is misread as inclusive and
30171
+ * under-reported by the cached total. That takes a single turn adding more
30172
+ * new tokens than the whole cached prefix, and it applies to EITHER egress,
30173
+ * since the native Copilot path has been measured exclusive. The error
30174
+ * direction is the safe one: the meter under-reads, so the client compacts
30175
+ * later rather than earlier.
30176
+ * `GH_ROUTER_DISABLE_ANTHROPIC_USAGE_NORMALIZE` exists for an upstream whose
30177
+ * shape the guard cannot discriminate.
30178
+ *
30179
+ * CALL ONCE PER USAGE OBJECT. The rewrite is not idempotent: a second pass
30180
+ * over an already-corrected object subtracts the cache buckets again whenever
30181
+ * the remainder is at least the cached total. Every caller applies it exactly
30182
+ * once — one call per SSE record, one call per non-streaming response, and a
30183
+ * freshly built map per advisor `message_delta`.
30184
+ *
30185
+ * Never throws. Returns true iff `usage.input_tokens` was rewritten.
30186
+ */
30187
+ function normalizeAnthropicUsageInPlace(usage) {
30188
+ if (!usage || typeof usage !== "object" || Array.isArray(usage)) return false;
30189
+ const record = usage;
30190
+ const input = nonNegativeInt(record.input_tokens);
30191
+ const cached = nonNegativeInt(record.cache_read_input_tokens) + nonNegativeInt(record.cache_creation_input_tokens);
30192
+ if (cached <= 0) return false;
30193
+ if (input < cached) return false;
30194
+ const next = Math.max(0, input - cached);
30195
+ if (next === record.input_tokens) return false;
30196
+ record.input_tokens = next;
30197
+ return true;
30198
+ }
30199
+ /**
30200
+ * Length of the SSE record terminator beginning at `index` (a `\n`), or 0 if
30201
+ * no blank-line terminator starts there. Handles both `\n\n` and `\r\n\r\n`.
30202
+ */
30203
+ function terminatorLengthAt(buffer, index) {
30204
+ if (buffer[index + 1] === 10) return 2;
30205
+ if (buffer[index + 1] === 13 && buffer[index + 2] === 10) return 3;
30206
+ return 0;
30207
+ }
30208
+ /** First complete SSE record terminator in `buffer`, if any. */
30209
+ function findRecordTerminator(buffer) {
30210
+ for (let index = 0; index < buffer.byteLength - 1; index++) {
30211
+ if (buffer[index] !== 10) continue;
30212
+ const length = terminatorLengthAt(buffer, index);
30213
+ if (length > 0 && index + length <= buffer.byteLength) return {
30214
+ index,
30215
+ length
30216
+ };
30217
+ }
30218
+ }
30219
+ /**
30220
+ * Opt-in wire diagnostic (`GH_ROUTER_LOG_ANTHROPIC_USAGE_FRAMES=1`), matching
30221
+ * the `GH_ROUTER_LOG_FIELDS` / `GH_ROUTER_LOG_CACHE` convention.
30222
+ *
30223
+ * The rewrite rests on an upstream wire detail Copilot does not version:
30224
+ * whether `input_tokens` and the cache buckets arrive on the SAME SSE record.
30225
+ * Only a record carrying both is rewritten, so a split shape would silently
30226
+ * turn the rewrite into a no-op — and no unit test can observe the real
30227
+ * upstream shape. Logs one line per `message_start` / `message_delta` with
30228
+ * numeric usage fields only: no prompt text, no payloads, no identifiers.
30229
+ *
30230
+ * Called BEFORE normalization, so the values are exactly what upstream sent.
30231
+ * Writes to stderr directly (the `GH_ROUTER_LOG_PEER_MCP` pattern) so it is
30232
+ * visible regardless of consola level and can never interleave with a
30233
+ * JSONL-speaking client's stdout.
30234
+ *
30235
+ * Both egresses captured on 2026-11-05 (native Copilot, and `-m local` against
30236
+ * an LM Studio-backed gateway) delivered `input_tokens` and the cache buckets
30237
+ * on the same `message_delta` record, which is why the transform needs no
30238
+ * across-frame state. That is an unversioned upstream detail: if it ever
30239
+ * splits, the rewrite becomes a silent no-op and these lines are the only
30240
+ * signal, so the flag stays in the product rather than in a one-off script.
30241
+ *
30242
+ * It runs inside the rewrite transform, so it is silent when
30243
+ * `GH_ROUTER_DISABLE_ANTHROPIC_USAGE_NORMALIZE` is set — that path installs no
30244
+ * transform at all.
30245
+ */
30246
+ function logUsageFrame(eventType, usage) {
30247
+ if (process.env.GH_ROUTER_LOG_ANTHROPIC_USAGE_FRAMES !== "1") return;
30248
+ if (!usage || typeof usage !== "object" || Array.isArray(usage)) {
30249
+ process.stderr.write(`[anthropic-usage] ${eventType} usage=absent\n`);
30250
+ return;
30251
+ }
30252
+ const record = usage;
30253
+ const fields = USAGE_KEYS.map((key) => {
30254
+ const value = record[key];
30255
+ return `${key}=${typeof value === "number" ? value : "absent"}`;
30256
+ });
30257
+ process.stderr.write(`[anthropic-usage] ${eventType} ${fields.join(" ")}\n`);
30258
+ }
30259
+ /**
30260
+ * Rewrite one complete SSE record if it carries usage. Records that need no
30261
+ * correction — every event type other than `message_start` / `message_delta`,
30262
+ * unparseable payloads, and already-disjoint usage — are returned as the
30263
+ * exact bytes they arrived as.
30264
+ */
30265
+ function rewriteRecord(record) {
30266
+ const text = DECODER.decode(record);
30267
+ const dataMatch = /(?:^|\n)data:/.exec(text);
30268
+ if (!dataMatch) return record;
30269
+ const dataStart = dataMatch.index + (dataMatch[0].length - 5);
30270
+ const dataLines = [];
30271
+ for (const line of text.slice(dataStart).split("\n")) {
30272
+ if (!line.startsWith("data:")) break;
30273
+ dataLines.push(line.slice(5).replace(/^ /, ""));
30274
+ }
30275
+ if (dataLines.length === 0) return record;
30276
+ let payload;
30277
+ try {
30278
+ payload = JSON.parse(dataLines.join("\n"));
30279
+ } catch {
30280
+ return record;
30281
+ }
30282
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) return record;
30283
+ const event = payload;
30284
+ let changed = false;
30285
+ if (event.type === "message_start") {
30286
+ const message = event.message;
30287
+ if (message && typeof message === "object" && !Array.isArray(message)) {
30288
+ const usage = message.usage;
30289
+ logUsageFrame("message_start", usage);
30290
+ changed = normalizeAnthropicUsageInPlace(usage) || changed;
30291
+ }
30292
+ } else if (event.type === "message_delta") {
30293
+ logUsageFrame("message_delta", event.usage);
30294
+ changed = normalizeAnthropicUsageInPlace(event.usage) || changed;
30295
+ }
30296
+ if (!changed) return record;
30297
+ const prefix = text.slice(0, dataStart);
30298
+ return ENCODER$2.encode(`${prefix}data: ${JSON.stringify(event)}\n\n`);
30299
+ }
30300
+ function concat(left, right) {
30301
+ if (left.byteLength === 0) return right;
30302
+ if (right.byteLength === 0) return left;
30303
+ const out = new Uint8Array(left.byteLength + right.byteLength);
30304
+ out.set(left, 0);
30305
+ out.set(right, left.byteLength);
30306
+ return out;
30307
+ }
30308
+ /**
30309
+ * Streaming counterpart of `normalizeAnthropicUsageInPlace`, shaped for
30310
+ * `relayAnthropicStream`'s `transform` hook.
30311
+ *
30312
+ * Buffers across arbitrary chunk boundaries and only ever emits COMPLETE SSE
30313
+ * records, so an event split mid-record is never corrupted. `flush()` releases
30314
+ * a trailing partial record at upstream EOF; a stream that ends without its
30315
+ * terminator must not lose bytes.
30316
+ */
30317
+ function createAnthropicUsageRewriteTransform() {
30318
+ let pending = /* @__PURE__ */ new Uint8Array(0);
30319
+ return {
30320
+ push(bytes) {
30321
+ pending = concat(pending, bytes);
30322
+ let emitted;
30323
+ for (;;) {
30324
+ const terminator = findRecordTerminator(pending);
30325
+ if (!terminator) break;
30326
+ const end = terminator.index + terminator.length;
30327
+ const record = pending.subarray(0, end);
30328
+ pending = pending.subarray(end);
30329
+ const rewritten = rewriteRecord(record);
30330
+ emitted = emitted ? concat(emitted, rewritten) : rewritten;
30331
+ }
30332
+ if (pending.byteLength > MAX_PENDING_RECORD_BYTES) {
30333
+ emitted = emitted ? concat(emitted, pending) : pending;
30334
+ pending = /* @__PURE__ */ new Uint8Array(0);
30335
+ }
30336
+ return emitted;
30337
+ },
30338
+ flush() {
30339
+ if (pending.byteLength === 0) return void 0;
30340
+ const tail = pending;
30341
+ pending = /* @__PURE__ */ new Uint8Array(0);
30342
+ return tail;
30343
+ }
30344
+ };
30345
+ }
30346
+ //#endregion
30072
30347
  //#region src/lib/reasoning-effort.ts
30073
30348
  /**
30074
30349
  * Reasoning-effort bucketing + clamping shared by the `/v1/messages` handler
@@ -30163,6 +30438,15 @@ function clampEffort(bucketed, supported) {
30163
30438
  //#endregion
30164
30439
  //#region src/lib/stream-relay.ts
30165
30440
  const ENCODER$1 = new TextEncoder();
30441
+ /** Concatenate two byte runs, preserving order (left first). */
30442
+ function concatBytes(left, right) {
30443
+ if (left.byteLength === 0) return right;
30444
+ if (right.byteLength === 0) return left;
30445
+ const out = new Uint8Array(left.byteLength + right.byteLength);
30446
+ out.set(left, 0);
30447
+ out.set(right, left.byteLength);
30448
+ return out;
30449
+ }
30166
30450
  /**
30167
30451
  * Detect the family of "controller has already closed" errors that Bun and
30168
30452
  * the WHATWG streams runtime throw when an enqueue/close call races with
@@ -30205,11 +30489,67 @@ function relayAnthropicStream(body, opts) {
30205
30489
  let bytesRelayed = 0;
30206
30490
  let upstreamFinished = false;
30207
30491
  let consumerCancelled = false;
30492
+ let transform = opts.transform;
30208
30493
  const safeClose = (controller) => {
30209
30494
  try {
30210
30495
  controller.close();
30211
30496
  } catch {}
30212
30497
  };
30498
+ /**
30499
+ * Enqueue transform output, tolerating the consumer-cancel race exactly like
30500
+ * the untransformed path. Returns false when the consumer has gone away, in
30501
+ * which case the caller must stop pulling.
30502
+ */
30503
+ const enqueueBytes = (controller, bytes) => {
30504
+ if (!bytes || bytes.byteLength === 0) return true;
30505
+ try {
30506
+ controller.enqueue(bytes);
30507
+ return true;
30508
+ } catch (enqueueError) {
30509
+ if (isControllerClosedError(enqueueError)) {
30510
+ consumerCancelled = true;
30511
+ return false;
30512
+ }
30513
+ throw enqueueError;
30514
+ }
30515
+ };
30516
+ /**
30517
+ * Run the optional transform. A throw retires the transform and delivers this
30518
+ * chunk verbatim — a rewriter bug must never break delivery.
30519
+ *
30520
+ * Bytes the transform buffered from EARLIER chunks are not recoverable from
30521
+ * this chunk, so they are flushed out best-effort ahead of it. Without that,
30522
+ * a transform that held a partial record and then threw would silently
30523
+ * truncate everything it was holding.
30524
+ */
30525
+ const applyTransform = (bytes) => {
30526
+ const active = transform;
30527
+ if (!active) return bytes;
30528
+ try {
30529
+ return active.push(bytes);
30530
+ } catch (error) {
30531
+ transform = void 0;
30532
+ consola.warn(`Stream byte transform disabled at ${opts.routePath}: ${error instanceof Error ? error.message : String(error)}`);
30533
+ let buffered;
30534
+ try {
30535
+ buffered = active.flush();
30536
+ } catch {}
30537
+ if (!buffered || buffered.byteLength === 0) return bytes;
30538
+ return concatBytes(buffered, bytes);
30539
+ }
30540
+ };
30541
+ /** Release any bytes the transform buffered, at a clean upstream EOF. */
30542
+ const flushTransform = () => {
30543
+ const active = transform;
30544
+ if (!active) return void 0;
30545
+ transform = void 0;
30546
+ try {
30547
+ return active.flush();
30548
+ } catch (error) {
30549
+ consola.warn(`Stream byte transform flush failed at ${opts.routePath}: ${error instanceof Error ? error.message : String(error)}`);
30550
+ return;
30551
+ }
30552
+ };
30213
30553
  return new ReadableStream({
30214
30554
  async pull(controller) {
30215
30555
  if (consumerCancelled || upstreamFinished) {
@@ -30217,30 +30557,28 @@ function relayAnthropicStream(body, opts) {
30217
30557
  return;
30218
30558
  }
30219
30559
  try {
30220
- const result = await readWithInactivityTimeout(reader, inactivityMs);
30221
- if (consumerCancelled) {
30222
- safeClose(controller);
30223
- return;
30224
- }
30225
- if (result.done) {
30226
- if (bytesRelayed === 0) consola.warn(`Upstream returned empty SSE stream at ${opts.routePath}`);
30227
- upstreamFinished = true;
30228
- safeClose(controller);
30229
- return;
30230
- }
30231
- if (result.value) {
30232
- bytesRelayed += result.value.byteLength;
30233
- if (opts.onBytes) try {
30234
- opts.onBytes(result.value);
30235
- } catch {}
30236
- try {
30237
- controller.enqueue(result.value);
30238
- } catch (enqueueError) {
30239
- if (isControllerClosedError(enqueueError)) {
30240
- consumerCancelled = true;
30241
- return;
30242
- }
30243
- throw enqueueError;
30560
+ for (;;) {
30561
+ const result = await readWithInactivityTimeout(reader, inactivityMs);
30562
+ if (consumerCancelled) {
30563
+ safeClose(controller);
30564
+ return;
30565
+ }
30566
+ if (result.done) {
30567
+ if (bytesRelayed === 0) consola.warn(`Upstream returned empty SSE stream at ${opts.routePath}`);
30568
+ upstreamFinished = true;
30569
+ if (!enqueueBytes(controller, flushTransform())) return;
30570
+ safeClose(controller);
30571
+ return;
30572
+ }
30573
+ if (result.value) {
30574
+ bytesRelayed += result.value.byteLength;
30575
+ if (opts.onBytes) try {
30576
+ opts.onBytes(result.value);
30577
+ } catch {}
30578
+ const out = applyTransform(result.value);
30579
+ if (!out || out.byteLength === 0) continue;
30580
+ if (!enqueueBytes(controller, out)) return;
30581
+ return;
30244
30582
  }
30245
30583
  }
30246
30584
  } catch (error) {
@@ -31025,12 +31363,12 @@ const LOCAL_ADVISOR_TOOL_INSTRUCTIONS = buildCheapestAdvisorToolInstructions("a
31025
31363
  /** `cheaplocal` lead variant. The consult leaves Copilot, and this launch has
31026
31364
  * been told nothing about what answers its local endpoint, so the prose names
31027
31365
  * no model, no window, no effort and no cost: it states only that the
31028
- * consultant is local and what it is shown. The request still asks for `max`
31029
- * effort (`LOCAL_CONSULT_EFFORT`), but that is a field of the consult body,
31030
- * not a property to teach the lead; every surface states the transport and
31031
- * stops there. It is also the only variant that asks for a redacted brief: it
31032
- * is the only profile whose consult leaves Copilot for an endpoint the proxy
31033
- * knows nothing about. */
31366
+ * consultant is local and what it is shown. The request asks for the profile's
31367
+ * declared effort, but that is a field of the consult body, not a property to
31368
+ * teach the lead; every surface states the transport and stops there. It asks
31369
+ * for a redacted brief because its consult leaves Copilot for an endpoint the
31370
+ * proxy knows nothing about — the rule that decides that is the transport,
31371
+ * `consultIsLocalTransport`, which also covers `local`'s Oracle. */
31034
31372
  const CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS = buildCheapestAdvisorToolInstructions("which sees a curated view of this session", "the local model", true);
31035
31373
  /** Protege-facing tool description for the cheapest reviewer. Unlike the lead
31036
31374
  * variants, this names the mentor relationship and the hard consult budget so
@@ -31524,7 +31862,7 @@ async function runAdvisor(conversation, advisorModel, advisorEffort, signal, adv
31524
31862
  transcript: transcriptText
31525
31863
  }) : transcriptText;
31526
31864
  const transport = advisorLocalEgress ? "local" : advisorTransport(resolvedAdvisorModel, fastProfile);
31527
- const dispatchEffort = advisorLocalEgress ? "max" : advisorEffort;
31865
+ const dispatchEffort = advisorEffort;
31528
31866
  if (fastProfile) consola.warn(`fast Advisor dispatch: model=${resolvedAdvisorModel} transport=${transport} effort=${dispatchEffort}`);
31529
31867
  if (cheapProfile) {
31530
31868
  const transcriptCap = cheapestProfile ? `${resolveCheapestAdvisorTranscriptTokens()} tokens (curated digest)` : "200K";
@@ -31538,6 +31876,7 @@ async function runAdvisor(conversation, advisorModel, advisorEffort, signal, adv
31538
31876
  system: advisorSystem,
31539
31877
  userText: conversationText,
31540
31878
  maxTokens: ADVISOR_FALLBACK_MAX_OUTPUT_TOKENS,
31879
+ effort: dispatchEffort,
31541
31880
  signal
31542
31881
  }), {
31543
31882
  signal,
@@ -31791,6 +32130,7 @@ function buildAdvisorStream(opts) {
31791
32130
  }
31792
32131
  const nextUsage = {};
31793
32132
  for (const [key, value] of Object.entries(usage)) if (typeof value === "number" && Number.isFinite(value)) nextUsage[key] = value;
32133
+ if (!anthropicUsageNormalizeDisabled()) normalizeAnthropicUsageInPlace(nextUsage);
31794
32134
  pendingMessageDelta.usage = nextUsage;
31795
32135
  const turnAic = extractCopilotUsage(payload.copilot_usage);
31796
32136
  if (!turnAic || turnAic.totalNanoAiu <= 0) return;
@@ -31848,7 +32188,9 @@ function buildAdvisorStream(opts) {
31848
32188
  continue;
31849
32189
  }
31850
32190
  switch (ev.event) {
31851
- case "message_start":
32191
+ case "message_start": {
32192
+ const startMessage = payload.message;
32193
+ if (!anthropicUsageNormalizeDisabled() && startMessage && typeof startMessage === "object" && !Array.isArray(startMessage)) normalizeAnthropicUsageInPlace(startMessage.usage);
31852
32194
  if (!messageStartForwarded) {
31853
32195
  if (!safeEnqueueEvent(ev.event, payload)) return {
31854
32196
  capturedBlocks,
@@ -31858,6 +32200,7 @@ function buildAdvisorStream(opts) {
31858
32200
  messageStartForwarded = true;
31859
32201
  }
31860
32202
  continue;
32203
+ }
31861
32204
  case "content_block_start": {
31862
32205
  const block = payload.content_block;
31863
32206
  const upstreamIndex = payload.index;
@@ -37029,7 +37372,6 @@ function buildPeerAwarenessSnippet(opts) {
37029
37372
  const isBalanced = isBalancedFamily(opts.profile);
37030
37373
  const isLocal = isLocalFamily(opts.profile);
37031
37374
  const hasAdvisor = !isBalanced && !(isLocal && opts.profile !== "local2");
37032
- const hasOracle = !(isLocal && opts.profile === "local");
37033
37375
  const profileLabel = isCheapest || isBalanced || isLocal ? opts.profile : isCheap ? "cheap" : "fast";
37034
37376
  const familyContract = isCheapest ? cheapestContractFor(opts.profile) : isBalanced ? balancedContractFor(opts.profile) : isLocal ? localContractFor(opts.profile) : void 0;
37035
37377
  const consultIsLocal = familyContract?.consultTransport === "local";
@@ -37048,12 +37390,12 @@ function buildPeerAwarenessSnippet(opts) {
37048
37390
  const rosterClause = isCheapest || isLocal ? `Native Task roster: \`Explore\` (broad repository discovery spanning more than a couple of files), \`General-Purpose\` (mixed investigation and execution), and \`reviewer\` (repo-aware verification of behavior-changing or risk-sensitive changes). The lead plans directly: in plan mode, produce the plan and acceptance criteria without editing files${hasAdvisor ? ", and review the final plan with the Advisor before presenting it to the user" : ""}. Handle straightforward tasks directly and verify claims with concrete repository evidence and tests before declaring done.` : "Native Task roster: `Explore` (mandatory cheap broad discovery, launch in parallel; lead/`Plan` delegate rather than self-sweep), `Plan` (sequencing, interfaces, migration risk, acceptance criteria in plan mode; delegate discovery to `Explore` and write handoff-ready steps for `General-Purpose`), `General-Purpose` (mixed execution; follows a Plan handoff when one exists and drives to a verified end state), and `reviewer` (repo-aware verification after non-trivial changes, before done). In plan mode, delegate planning to `Plan` and do not edit files. Verify claims with concrete repository evidence and tests before declaring done.";
37049
37391
  const balancedRosterClause = "Native Task roster: the lead owns planning, implementation, and verification by default. `Explore` (targeted breadth only when search is insufficient, launch in parallel), `General-Purpose` (mixed execution; delegate FREELY for multi-step work and drive to a verified end state), and `reviewer` (repo-aware verification; invoke ONLY when genuinely behavior-changing, cross-boundary, or risk-sensitive, lead owns verification by default; narrows scope with search first and may invoke `Explore` for targeted discovery). Verify claims with concrete repository evidence and tests before declaring done.";
37050
37392
  const escalationOpener = isLocal ? `This is the ${profileLabel} launch profile. Verify claims against real evidence first: settle factual claims with ` : `This is the ${profileLabel} launch profile. Funnel unknowns cheapest-first: settle factual claims with `;
37051
- const escalationOracle = hasOracle ? ` \`mcp__${fastPeersKey}__oracle\` is ${oracleDescriptor}, a second opinion for precise, self-contained architectural/spec trade-offs that search and \`Explore\` cannot settle, available to the lead; \`reviewer\` and other subagents cannot call Oracle.` : "";
37393
+ const escalationOracle = ` \`mcp__${fastPeersKey}__oracle\` is ${oracleDescriptor}, a second opinion for precise, self-contained architectural/spec trade-offs that search and \`Explore\` cannot settle, available to the lead; \`reviewer\` and other subagents cannot call Oracle.`;
37052
37394
  const escalationClause = !hasAdvisor ? escalationOpener + `\`mcp__${fastSearchKey}__code\` + \`mcp__${fastSearchKey}__web\` search first (narrow scope, rule out hypotheses), then \`Explore\` for targeted breadth.` + escalationOracle + astraClause : `This is the ${profileLabel} launch profile. Follow an evidence-first escalation ladder: settle factual claims directly through code, tests, and builds. ${hasAdvisor && (isCheapest || isLocal) ? "Advisor is an optional, non-binding, transcript-aware sounding board available to the lead and `reviewer` (at most 5 rounds per review) for trajectory guidance, framing checks, or conflicting signals (direction, not dictation), not routine progress, waiting, verification, or completion." : "Advisor is an optional, non-binding, lead-only transcript-aware sounding board for trajectory guidance, framing checks, or conflicting signals (direction, not dictation), not routine progress, waiting, verification, or completion."} \`mcp__${fastPeersKey}__oracle\` is ${oracleDescriptor}, an expert consultant ${isCheapest || isLocal ? "available to the lead" : "available to the lead and `Plan`"}, preferred over advisor for difficult conceptual, algorithmic, spec/protocol, or architectural tradeoffs evaluated in a self-contained brief; \`reviewer\` and other subagents cannot call Oracle.${astraClause}`;
37053
37395
  const leadLeaf = workerBrowseAvailable ? "`Explore`, `reviewer`, and `worker-browse`" : "`Explore` and `reviewer`";
37054
37396
  const delegationClause = isBalanced ? "Native delegation is ACL-scoped: the lead may invoke all three; `General-Purpose` may invoke `reviewer`; `reviewer` may invoke `Explore` for targeted discovery; " + (workerBrowseAvailable ? "`Explore` and `worker-browse`" : "`Explore`") + " cannot invoke native subagents." : isCheapest || isLocal ? "Native delegation is ACL-scoped: the lead may invoke all three; `General-Purpose` may invoke `reviewer`; " + leadLeaf + " cannot invoke native subagents." : "Native delegation is ACL-scoped: the lead may invoke all four; `Plan` may invoke `Explore` and `reviewer`; `General-Purpose` may invoke `reviewer`; " + leadLeaf + " cannot invoke native subagents.";
37055
37397
  return [
37056
- isLocal && !hasOracle ? "## Native roster and search" : isLocal && !hasAdvisor ? "## Peer review and Oracle" : "## Peer review and advisor",
37398
+ isLocal && !hasAdvisor ? "## Peer review and Oracle" : "## Peer review and advisor",
37057
37399
  "",
37058
37400
  escalationClause,
37059
37401
  "",
@@ -37126,7 +37468,6 @@ function buildPeerAwarenessSummary(opts) {
37126
37468
  const isBalanced = isBalancedFamily(opts.profile);
37127
37469
  const isLocal = isLocalFamily(opts.profile);
37128
37470
  const hasAdvisor = !isBalanced && !(isLocal && opts.profile !== "local2");
37129
- const hasOracle = !(isLocal && opts.profile === "local");
37130
37471
  const advisorReviewerGranted = hasAdvisor && (isCheapest || isLocal);
37131
37472
  const profileLabel = isCheapest || isBalanced || isLocal ? opts.profile.charAt(0).toUpperCase() + opts.profile.slice(1) : isCheap ? "Cheap" : "Fast";
37132
37473
  const familyContract = isCheapest ? cheapestContractFor(opts.profile) : isBalanced ? balancedContractFor(opts.profile) : isLocal ? localContractFor(opts.profile) : void 0;
@@ -37140,7 +37481,7 @@ function buildPeerAwarenessSummary(opts) {
37140
37481
  const astraClause = opts.astraAvailable && (opts.profile === "fast" || opts.profile === "cheap1m") ? ` \`mcp__${key("peers")}__astra\` is GPT-6 Astra (${astraDescriptor}), lead-only escalation for hardest dead ends.` : "";
37141
37482
  const rosterLine = isCheapest || isLocal ? `${profileLabel} launch profile. Task roster: \`Explore\` (broad discovery), \`General-Purpose\` (mixed execution), \`reviewer\` (verification of behavior-changing or risk-sensitive changes). The lead plans directly${hasAdvisor ? " and reviews the final plan with the Advisor before presenting it to the user" : ""}. Handle straightforward tasks directly. Verify claims with concrete repository evidence and tests before declaring done.` : `${profileLabel} launch profile. Task roster: \`Explore\` (mandatory parallel discovery delegate), \`Plan\` (planning in plan mode, writes handoff-ready steps for \`General-Purpose\`), \`General-Purpose\` (mixed execution, follows a Plan handoff when one exists), \`reviewer\` (verification after implementation, before done). Verify claims with concrete repository evidence and tests before declaring done.`;
37142
37483
  const balancedRosterLine = `${profileLabel} launch profile. The lead owns planning, implementation, and verification by default. Task roster: \`Explore\` (targeted breadth when search is insufficient), \`General-Purpose\` (delegate FREELY for multi-step work), \`reviewer\` (invoke ONLY when genuinely behavior-changing, cross-boundary, or risk-sensitive). Verify claims with concrete repository evidence and tests before declaring done.`;
37143
- const summaryOracle = hasOracle ? `\`mcp__${key("peers")}__oracle\` is ${oracleDescriptor}, a second opinion for precise, self-contained architectural/spec trade-offs that search and \`Explore\` cannot settle, for the lead.${astraClause} ` : "";
37484
+ const summaryOracle = `\`mcp__${key("peers")}__oracle\` is ${oracleDescriptor}, a second opinion for precise, self-contained architectural/spec trade-offs that search and \`Explore\` cannot settle, for the lead.${astraClause} `;
37144
37485
  const peerLine = !hasAdvisor ? summaryOracle + `\`mcp__${key("search")}__code\` provides ${opts.bluebirdEnabled === true ? "Bluebird semantic + lexical search with visible no-fallback errors and local exact/regex/AST" : opts.semanticSearchAvailable === true ? "local ColBERT semantic search with lexical fallback" : "local lexical search"}; \`mcp__${key("search")}__web\` provides web search.${browserClause}${workerBrowseClause}${artifactClause}` : `${advisorReviewerGranted ? "Advisor is optional, non-binding, transcript-aware, and available to the lead and `reviewer` (at most 5 rounds per review) for trajectory guidance or framing checks (direction, not dictation)." : "Advisor is optional, non-binding, transcript-aware, and lead-only for trajectory guidance or framing checks (direction, not dictation)."} \`mcp__${key("peers")}__oracle\` is ${oracleDescriptor}, an expert consultant for ${isCheapest || isLocal ? "the lead" : "the lead and `Plan`"}, preferred over advisor for substantive trade-offs.${astraClause} \`mcp__${key("search")}__code\` provides ${opts.bluebirdEnabled === true ? "Bluebird semantic + lexical search with visible no-fallback errors and local exact/regex/AST" : opts.semanticSearchAvailable === true ? "local ColBERT semantic search with lexical fallback" : "local lexical search"}; \`mcp__${key("search")}__web\` provides web search.${browserClause}${workerBrowseClause}${artifactClause}`;
37145
37486
  const summaryLeadLeaf = workerBrowseAvailable ? "`Explore`, `reviewer`, and `worker-browse`" : "`Explore` and `reviewer`";
37146
37487
  const summaryDelegation = isBalanced ? "Native delegation is ACL-scoped: the lead may invoke all three; `General-Purpose` may invoke `reviewer`; `reviewer` may invoke `Explore` for targeted discovery; " + (workerBrowseAvailable ? "`Explore` and `worker-browse`" : "`Explore`") + " cannot invoke native subagents." : isCheapest || isLocal ? "Native delegation is ACL-scoped: the lead may invoke all three; `General-Purpose` may invoke `reviewer`; " + summaryLeadLeaf + " cannot invoke native subagents." : "Native delegation is ACL-scoped: the lead may invoke all four; `Plan` may invoke `Explore` and `reviewer`; `General-Purpose` may invoke `reviewer`; " + summaryLeadLeaf + " cannot invoke native subagents.";
@@ -38715,6 +39056,6 @@ function enumerateInjectedMcpToolNames(groupKeys, opts = {}) {
38715
39056
  return [...new Set(names)];
38716
39057
  }
38717
39058
  //#endregion
38718
- export { buildAnthropicErrorEvent as $, isBudgetClaudeLead as $n, reviewerModel as $t, TOOLBELT_TOOLS$1 as A, normalizeOpenAIUsage as An, browserToolsEnabled as At, FAST_ADVISOR_TOOL_INSTRUCTIONS as B, shouldUseInsecureTls as Bn, fastGeneralPurposeModel as Bt, runWorkerAgent as C, createResponses as Cn, agentToolsEnabled as Ct, toolbeltEnabled as D, parseJsonOrDiagnose as Dn, brainstormModel as Dt, buildToolbeltAwareness as E, readResponseBodyCapped as En, balancedReviewerModel as Et, ADVISOR_TOOL_INSTRUCTIONS as F, CONDENSED_OPERATING_SEQUENCE as Fn, cheapestOracleModel as Ft, isAdvisorRequested as G, BUDGET_SMALL_FAST_SLUG as Gn, fleetToolsEnabled as Gt, LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as H, collapsePathKeys as Hn, fastPlanModel as Ht, CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS as I, DEFINITION_OF_GREATNESS as In, cheapestReviewerModel as It, resolveCuratedAdvisorModel as J, DEFAULT_CODEX_MODEL_FALLBACKS as Jn, implementerFastModel as Jt, resolveAdvisorEffort as K, DEFAULT_CLAUDE_MODEL_FALLBACKS as Kn, geminiAvailable as Kt, CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as L, colbertDegradedWarning as Ln, cloudAgentToolsEnabled as Lt, satisfiesMinVersion as M, hasSupportedBrowserInstalled as Mn, cheapOracleModel as Mt, searchWeb as N, normalizeCloudAgentEnvironment as Nn, cheapReviewerModel as Nt, toolbeltSkipSet as O, assertCopilotModelAllowed as On, browseAgentEnabled as Ot, ADVISOR_INTERNAL_TOOL_NAME as P, normalizeKustoClusterUri as Pn, cheapestAdvisorModel as Pt, repairRejectedThinkingHistory as Q, generateRandomPort as Qn, reviewerFastModel as Qt, CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS as R, provisionAndIndexColbert as Rn, fastAdvisorModel as Rt, resolveWorkerRunOpts as S, resolveMcpToolTimeoutMs as Sn, adoToolsEnabled as St, availableToolCommands as T, MAX_RESPONSE_BODY_BYTES as Tn, balancedOracleModel as Tt, buildAdvisorStream as U, toolbeltPathOverride as Un, fastReviewerModel as Ut, LOCAL_ADVISOR_TOOL_INSTRUCTIONS as V, LOCAL_CONSULT_REDACTION_LINE as Vn, fastOracleModel as Vt, injectAdvisorTool as W, BUDGET_SMALL_FAST_CATALOG_ID as Wn, fastScoutModel as Wt, rememberThinkingHistoryRepair as X, UPSTREAM_FETCH_TIMEOUT_MS as Xn, nativeSubagentModel as Xt, formatThinkingRepairDecline as Y, DEFAULT_PORT as Yn, kustoToolsEnabled as Yt, repairKnownThinkingHistory as Z, UPSTREAM_INACTIVITY_TIMEOUT_MS as Zn, resolveGeminiReviewModel as Zt, REVIEW_DEFAULT_MODEL as _, registerLaunch as _n, buildAdoToolEntries as _t, buildAgentPrompt as a, shimDefaultsToXhigh as an, catalogAdvertises1M as ar, EFFORT_ORDER as at, resolveDefaultModel as b, assembleResponsesPayload as bn, ADO_DEFAULT_TOOLSETS as bt, enumerateInjectedMcpToolNames as c, getTokenizerFromModel as cn, withOneMSuffixForLead as cr, clampEffort as ct, BROWSE_DEFAULT_MODEL as d, localSessionId as dn, CHEAP_PROFILE_NATIVE_AGENT_NAMES as dr, WORKIQ_TOOL_ALIASES as dt, scoutModel as en, pickClaudeDefault as er, buildOpenAIErrorEvent as et, DEFAULT_MODEL_CHAIN as f, countTokens as fn, CHEAP_PROFILE_NATIVE_EFFORTS as fr, buildWorkiqToolEntries as ft, PLAN_DEFAULT_MODEL as g, launchBoundAccessToken as gn, adoMcpToolEntries as gt, IMPLEMENT_DEFAULT_MODEL as h, findLaunchBySecret as hn, workiqMcpToolEntries as ht, assertMcpToolSurfaceConsistent as i, workiqToolsEnabled as in, classifyMessagesRoute as ir, relayAnthropicStream as it, assetFor as j, provisionBrowserAssets as jn, cheapAdvisorModel as jt, vscodeRipgrepPath as k, effectiveLocalProfile as kn, browserCompoundToolsEnabled as kt, maxPersonasFor as l, configureLocalEgress as ln, CHEAP_PROFILE_ADVISOR_CLIENT_MODEL as lr, handleMcpDelete as lt, EXPLORE_DEFAULT_THINKING as m, LAUNCH_BOUND_TOKEN_PREFIX as mn, CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS as mr, provisionWorkiqTools as mt, MCP_GROUPS as n, standInToolEnabled as nn, upstreamAllowH2 as nr, logStreamError as nt, buildPeerAwarenessSnippet as o, getTextTokenCount as on, oneMContextDisabled as or, UNKNOWN_EFFORT_ANCHOR as ot, EXPLORE_DEFAULT_MODEL as p, createMessages as pn, CHEAP_PROFILE_NATIVE_MODELS as pr, disposeWorkiqClients as pt, resolveAdvisorModel as q, DEFAULT_CODEX_MODEL as qn, generalPurposeFastModel as qt, agentNamesForToolAllowlist as r, workerToolsEnabled as rn, upstreamMaxConnections as rr, readIteratorWithTimeout as rt, buildPeerAwarenessSummary as s, getTokenCount as sn, withOneMSuffix as sr, bucketEffort as st, GROUP_META as t, scribeModel as tn, resolveLeadSlugArg as tr, isControllerClosedError as tt, personasFor as u, localBaseUrl as un, CHEAP_PROFILE_MODELS as ur, handleMcpPost as ut, TEST_DEFAULT_MODEL as v, rememberLaunchSessionId as vn, disposeAdoClients as vt, buildEnv as w, createChatCompletions as wn, artifactToolsEnabled as wt, resolveModeDefaults as x, warnOnTokenPriceDrift as xn, normalizeAdoToolsets as xt, appendPlanReminder as y, unregisterLaunch as yn, provisionAdoTools as yt, CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as z, semanticSearchOptedIn as zn, fastAstraModel as zt };
39059
+ export { buildAnthropicErrorEvent as $, DEFAULT_PORT as $n, nativeSubagentModel as $t, TOOLBELT_TOOLS$1 as A, parseJsonOrDiagnose as An, brainstormModel as At, FAST_ADVISOR_TOOL_INSTRUCTIONS as B, colbertDegradedWarning as Bn, cloudAgentToolsEnabled as Bt, runWorkerAgent as C, assembleResponsesPayload as Cn, ADO_DEFAULT_TOOLSETS as Ct, toolbeltEnabled as D, createChatCompletions as Dn, artifactToolsEnabled as Dt, buildToolbeltAwareness as E, createResponses as En, agentToolsEnabled as Et, ADVISOR_TOOL_INSTRUCTIONS as F, normalizeKustoClusterUri as Fn, cheapOracleModel as Ft, isAdvisorRequested as G, LOCAL_CONSULT_REDACTION_NOTE as Gn, fastPlanModel as Gt, LOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as H, semanticSearchOptedIn as Hn, fastAstraModel as Ht, CHEAPEST_ADVISOR_TOOL_INSTRUCTIONS as I, CONDENSED_OPERATING_SEQUENCE as In, cheapReviewerModel as It, resolveCuratedAdvisorModel as J, BUDGET_SMALL_FAST_CATALOG_ID as Jn, fleetToolsEnabled as Jt, resolveAdvisorEffort as K, collapsePathKeys as Kn, fastReviewerModel as Kt, CHEAPEST_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as L, DEFINITION_OF_GREATNESS as Ln, cheapestAdvisorModel as Lt, satisfiesMinVersion as M, provisionBrowserAssets as Mn, browserCompoundToolsEnabled as Mt, searchWeb as N, hasSupportedBrowserInstalled as Nn, browserToolsEnabled as Nt, toolbeltSkipSet as O, MAX_RESPONSE_BODY_BYTES as On, balancedOracleModel as Ot, ADVISOR_INTERNAL_TOOL_NAME as P, normalizeCloudAgentEnvironment as Pn, cheapAdvisorModel as Pt, repairRejectedThinkingHistory as Q, DEFAULT_CODEX_MODEL_FALLBACKS as Qn, kustoToolsEnabled as Qt, CHEAPLOCAL_ADVISOR_TOOL_INSTRUCTIONS as R, assertCopilotModelAllowed as Rn, cheapestOracleModel as Rt, resolveWorkerRunOpts as S, unregisterLaunch as Sn, provisionAdoTools as St, availableToolCommands as T, resolveMcpToolTimeoutMs as Tn, adoToolsEnabled as Tt, buildAdvisorStream as U, shouldUseInsecureTls as Un, fastGeneralPurposeModel as Ut, LOCAL_ADVISOR_TOOL_INSTRUCTIONS as V, provisionAndIndexColbert as Vn, fastAdvisorModel as Vt, injectAdvisorTool as W, LOCAL_CONSULT_REDACTION_LINE as Wn, fastOracleModel as Wt, rememberThinkingHistoryRepair as X, DEFAULT_CLAUDE_MODEL_FALLBACKS as Xn, generalPurposeFastModel as Xt, formatThinkingRepairDecline as Y, BUDGET_SMALL_FAST_SLUG as Yn, geminiAvailable as Yt, repairKnownThinkingHistory as Z, DEFAULT_CODEX_MODEL as Zn, implementerFastModel as Zt, REVIEW_DEFAULT_MODEL as _, LAUNCH_BOUND_TOKEN_PREFIX as _n, CHEAP_PROFILE_NATIVE_MODELS as _r, provisionWorkiqTools as _t, buildAgentPrompt as a, standInToolEnabled as an, resolveLeadSlugArg as ar, EFFORT_ORDER as at, resolveDefaultModel as b, registerLaunch as bn, buildAdoToolEntries as bt, enumerateInjectedMcpToolNames as c, shimDefaultsToXhigh as cn, classifyMessagesRoute as cr, clampEffort as ct, BROWSE_DEFAULT_MODEL as d, getTokenizerFromModel as dn, withOneMSuffix as dr, normalizeAnthropicUsageInPlace as dt, resolveGeminiReviewModel as en, UPSTREAM_FETCH_TIMEOUT_MS as er, buildOpenAIErrorEvent as et, DEFAULT_MODEL_CHAIN as f, configureLocalEgress as fn, withOneMSuffixForLead as fr, handleMcpDelete as ft, PLAN_DEFAULT_MODEL as g, createMessages as gn, CHEAP_PROFILE_NATIVE_EFFORTS as gr, disposeWorkiqClients as gt, IMPLEMENT_DEFAULT_MODEL as h, countTokens as hn, CHEAP_PROFILE_NATIVE_AGENT_NAMES as hr, buildWorkiqToolEntries as ht, assertMcpToolSurfaceConsistent as i, scribeModel as in, pickClaudeDefault as ir, relayAnthropicStream as it, assetFor as j, normalizeOpenAIUsage as jn, browseAgentEnabled as jt, vscodeRipgrepPath as k, readResponseBodyCapped as kn, balancedReviewerModel as kt, maxPersonasFor as l, getTextTokenCount as ln, catalogAdvertises1M as lr, anthropicUsageNormalizeDisabled as lt, EXPLORE_DEFAULT_THINKING as m, localSessionId as mn, CHEAP_PROFILE_MODELS as mr, WORKIQ_TOOL_ALIASES as mt, MCP_GROUPS as n, reviewerModel as nn, generateRandomPort as nr, logStreamError as nt, buildPeerAwarenessSnippet as o, workerToolsEnabled as on, upstreamAllowH2 as or, UNKNOWN_EFFORT_ANCHOR as ot, EXPLORE_DEFAULT_MODEL as p, localBaseUrl as pn, CHEAP_PROFILE_ADVISOR_CLIENT_MODEL as pr, handleMcpPost as pt, resolveAdvisorModel as q, toolbeltPathOverride as qn, fastScoutModel as qt, agentNamesForToolAllowlist as r, scoutModel as rn, isBudgetClaudeLead as rr, readIteratorWithTimeout as rt, buildPeerAwarenessSummary as s, workiqToolsEnabled as sn, upstreamMaxConnections as sr, bucketEffort as st, GROUP_META as t, reviewerFastModel as tn, UPSTREAM_INACTIVITY_TIMEOUT_MS as tr, isControllerClosedError as tt, personasFor as u, getTokenCount as un, oneMContextDisabled as ur, createAnthropicUsageRewriteTransform as ut, TEST_DEFAULT_MODEL as v, findLaunchBySecret as vn, CHEAP_PROFILE_SUBAGENT_CONTEXT_TOKENS as vr, workiqMcpToolEntries as vt, buildEnv as w, warnOnTokenPriceDrift as wn, normalizeAdoToolsets as wt, resolveModeDefaults as x, rememberLaunchSessionId as xn, disposeAdoClients as xt, appendPlanReminder as y, launchBoundAccessToken as yn, adoMcpToolEntries as yt, CHEAPLOCAL_REVIEWER_ADVISOR_TOOL_INSTRUCTIONS as z, effectiveLocalProfile as zn, cheapestReviewerModel as zt };
38719
39060
 
38720
- //# sourceMappingURL=peer-mcp-personas-6zWkXHQW.js.map
39061
+ //# sourceMappingURL=peer-mcp-personas-Dxxw5X1g.js.map