github-router 0.3.270 → 0.3.271

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 (27) hide show
  1. package/dist/{attribution-settings-of5gJM5a.js → attribution-settings-DLRQEKpU.js} +3 -3
  2. package/dist/{attribution-settings-of5gJM5a.js.map → attribution-settings-DLRQEKpU.js.map} +1 -1
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/{claude-BlzCUbVq.js → claude-BpQVQE0T.js} +6 -6
  5. package/dist/{claude-BlzCUbVq.js.map → claude-BpQVQE0T.js.map} +1 -1
  6. package/dist/{codex-BaFcXOyg.js → codex-CGMiGJy1.js} +4 -4
  7. package/dist/{codex-BaFcXOyg.js.map → codex-CGMiGJy1.js.map} +1 -1
  8. package/dist/engine-DUJyXWZn.js +2 -0
  9. package/dist/{gate-discovery-AUAjqSpV.js → gate-discovery-BBA7cV1D.js} +2 -2
  10. package/dist/{gate-discovery-AUAjqSpV.js.map → gate-discovery-BBA7cV1D.js.map} +1 -1
  11. package/dist/{internal-stop-hook-B1MIwmTR.js → internal-stop-hook-CO2NDmGL.js} +2 -2
  12. package/dist/{internal-stop-hook-B1MIwmTR.js.map → internal-stop-hook-CO2NDmGL.js.map} +1 -1
  13. package/dist/main.js +5 -5
  14. package/dist/{peer-mcp-personas-pWP3Eyt7.js → peer-mcp-personas-CN8xaXcV.js} +226 -18
  15. package/dist/peer-mcp-personas-CN8xaXcV.js.map +1 -0
  16. package/dist/{provision-CsYUVdMT.js → provision-CiPjSx7J.js} +2 -2
  17. package/dist/{provision-CsYUVdMT.js.map → provision-CiPjSx7J.js.map} +1 -1
  18. package/dist/{serve--c9n9hk4.js → serve-CpTMr5D9.js} +5 -5
  19. package/dist/{serve--c9n9hk4.js.map → serve-CpTMr5D9.js.map} +1 -1
  20. package/dist/{server-setup-BmyWS4WU.js → server-setup-B02Myghc.js} +8 -116
  21. package/dist/server-setup-B02Myghc.js.map +1 -0
  22. package/dist/{start-CXnLBouJ.js → start-CIV9eXVb.js} +3 -3
  23. package/dist/{start-CXnLBouJ.js.map → start-CIV9eXVb.js.map} +1 -1
  24. package/package.json +1 -1
  25. package/dist/engine-mwIgHJoi.js +0 -2
  26. package/dist/peer-mcp-personas-pWP3Eyt7.js.map +0 -1
  27. package/dist/server-setup-BmyWS4WU.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { A as searchWeb, B as readIteratorWithTimeout, Dt as toolbeltPathOverride, F as isAdvisorRequested, H as handleMcpDelete, I as buildAnthropicErrorEvent, It as withOneMSuffix, L as buildOpenAIErrorEvent, Lt as withInstallLock, M as ADVISOR_TOOL_INSTRUCTIONS, Mt as UPSTREAM_FETCH_TIMEOUT_MS, N as buildAdvisorStream, Nt as UPSTREAM_INACTIVITY_TIMEOUT_MS, P as injectAdvisorTool, Pt as generateRandomPort, R as isControllerClosedError, U as handleMcpPost, V as relayAnthropicStream, W as agentToolsEnabled, at as countTokens, ct as assembleResponsesPayload, dt as createResponses, ft as createChatCompletions, ht as parseJsonOrDiagnose, it as shimDefaultsToXhigh, j as ADVISOR_INTERNAL_TOOL_NAME, lt as resolveMcpToolTimeoutMs, mt as readResponseBodyCapped, ot as createMessages, pt as MAX_RESPONSE_BODY_BYTES, r as assertMcpToolSurfaceConsistent, st as getTokenCount, ut as pickEndpoint, w as toolbeltEnabled, z as logStreamError } from "./peer-mcp-personas-pWP3Eyt7.js";
1
+ import { A as searchWeb, B as buildAnthropicErrorEvent, Bt as withOneMSuffix, F as isAdvisorRequested, G as relayAnthropicStream, H as isControllerClosedError, I as formatThinkingRepairDecline, It as UPSTREAM_FETCH_TIMEOUT_MS, J as agentToolsEnabled, K as handleMcpDelete, L as rememberThinkingHistoryRepair, Lt as UPSTREAM_INACTIVITY_TIMEOUT_MS, M as ADVISOR_TOOL_INSTRUCTIONS, N as buildAdvisorStream, P as injectAdvisorTool, R as repairKnownThinkingHistory, Rt as generateRandomPort, U as logStreamError, V as buildOpenAIErrorEvent, Vt as withInstallLock, W as readIteratorWithTimeout, _t as MAX_RESPONSE_BODY_BYTES, ct as shimDefaultsToXhigh, dt as getTokenCount, ft as assembleResponsesPayload, gt as createChatCompletions, ht as createResponses, j as ADVISOR_INTERNAL_TOOL_NAME, jt as toolbeltPathOverride, lt as countTokens, mt as pickEndpoint, pt as resolveMcpToolTimeoutMs, q as handleMcpPost, r as assertMcpToolSurfaceConsistent, ut as createMessages, vt as readResponseBodyCapped, w as toolbeltEnabled, yt as parseJsonOrDiagnose, z as repairRejectedThinkingHistory } from "./peer-mcp-personas-CN8xaXcV.js";
2
2
  import { t as getPackageVersion } from "./version-_Q1WpsQp.js";
3
3
  import { i as ensurePaths, t as PATHS } from "./paths-Bg1_DWhi.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-iaSGp76k.js";
@@ -9,7 +9,7 @@ import * as fs$2 from "node:fs";
9
9
  import fs, { existsSync } from "node:fs";
10
10
  import * as nodePath from "node:path";
11
11
  import path from "node:path";
12
- import { createHash, randomBytes, randomUUID } from "node:crypto";
12
+ import { createHash, randomUUID } from "node:crypto";
13
13
  import fs$1 from "node:fs/promises";
14
14
  import os from "node:os";
15
15
  import process$1 from "node:process";
@@ -1357,7 +1357,7 @@ function collectToolFieldKeys(body) {
1357
1357
  //#endregion
1358
1358
  //#region package.json
1359
1359
  var name = "github-router";
1360
- var version = "0.3.270";
1360
+ var version = "0.3.271";
1361
1361
  //#endregion
1362
1362
  //#region src/lib/approval.ts
1363
1363
  const awaitApproval = async () => {
@@ -3654,117 +3654,6 @@ async function handleNonClaudeChat(c, opts) {
3654
3654
  return c.json(anthropic, 200);
3655
3655
  }
3656
3656
  //#endregion
3657
- //#region src/lib/thinking-history-repair.ts
3658
- const THINKING_INTEGRITY_ERROR_RES = [/messages\.(\d+)\.content\.\d+:\s*`thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified/, /messages\.(\d+)\.content\.\d+:\s*Invalid `signature` in `thinking` block/];
3659
- const MAX_REMEMBERED_REPAIRS = 1e3;
3660
- const OMITTED_THINKING_PLACEHOLDER = "[prior reasoning omitted]";
3661
- const repairSalt = randomBytes(32);
3662
- const rememberedRepairs = /* @__PURE__ */ new Set();
3663
- function isRecord(value) {
3664
- return typeof value === "object" && value !== null;
3665
- }
3666
- function signedBlockFingerprint(_messageIndex, content) {
3667
- const hash = createHash("sha256");
3668
- hash.update(repairSalt);
3669
- let signedBlocks = 0;
3670
- for (let index = 0; index < content.length; index++) {
3671
- const block = content[index];
3672
- if (!isRecord(block)) continue;
3673
- if (block.type !== "thinking" && block.type !== "redacted_thinking") continue;
3674
- signedBlocks++;
3675
- hash.update(String(index));
3676
- hash.update(String(block.type));
3677
- if (typeof block.signature === "string") hash.update(block.signature);
3678
- if (typeof block.data === "string") hash.update(block.data);
3679
- }
3680
- return signedBlocks > 0 ? hash.digest("hex") : void 0;
3681
- }
3682
- function repairMessageAt(parsed, messageIndex) {
3683
- if (!Array.isArray(parsed.messages)) return void 0;
3684
- const messages = [...parsed.messages];
3685
- const message = messages[messageIndex];
3686
- if (!isRecord(message) || message.role !== "assistant") return void 0;
3687
- if (!Array.isArray(message.content)) return void 0;
3688
- const fingerprint = signedBlockFingerprint(messageIndex, message.content);
3689
- if (!fingerprint) return void 0;
3690
- const repairedContent = message.content.filter((block) => !isRecord(block) || block.type !== "thinking" && block.type !== "redacted_thinking");
3691
- const removedBlocks = message.content.length - repairedContent.length;
3692
- if (removedBlocks === 0) return void 0;
3693
- if (repairedContent.length === 0) repairedContent.push({
3694
- type: "text",
3695
- text: OMITTED_THINKING_PLACEHOLDER
3696
- });
3697
- messages[messageIndex] = {
3698
- ...message,
3699
- content: repairedContent
3700
- };
3701
- parsed.messages = messages;
3702
- return {
3703
- body: JSON.stringify(parsed),
3704
- fingerprint,
3705
- messageIndex,
3706
- removedBlocks
3707
- };
3708
- }
3709
- /**
3710
- * Build a one-shot repair only for Copilot's known signed-thinking integrity
3711
- * rejections. The upstream error is the oracle: valid omitted-display thinking
3712
- * also has an empty `thinking` string, so request shape alone cannot identify a
3713
- * corrupt signature safely.
3714
- */
3715
- function repairRejectedThinkingHistory(rawBody, upstreamErrorText) {
3716
- const match = THINKING_INTEGRITY_ERROR_RES.map((pattern) => pattern.exec(upstreamErrorText)).find((candidate) => candidate !== null);
3717
- if (!match) return void 0;
3718
- const messageIndex = Number(match[1]);
3719
- if (!Number.isSafeInteger(messageIndex) || messageIndex < 0) return void 0;
3720
- let parsed;
3721
- try {
3722
- parsed = JSON.parse(rawBody);
3723
- } catch {
3724
- return;
3725
- }
3726
- return repairMessageAt(parsed, messageIndex);
3727
- }
3728
- /**
3729
- * Reapply a repair already proven successful in this process. Only salted
3730
- * digests are retained; no message, thinking, signature, or tool content is
3731
- * stored.
3732
- */
3733
- function repairKnownThinkingHistory(rawBody) {
3734
- if (rememberedRepairs.size === 0) return void 0;
3735
- let parsed;
3736
- try {
3737
- parsed = JSON.parse(rawBody);
3738
- } catch {
3739
- return;
3740
- }
3741
- if (!Array.isArray(parsed.messages)) return void 0;
3742
- let repaired;
3743
- let totalRemovedBlocks = 0;
3744
- for (let index = parsed.messages.length - 1; index >= 0; index--) {
3745
- const message = parsed.messages[index];
3746
- if (!isRecord(message) || !Array.isArray(message.content)) continue;
3747
- const fingerprint = signedBlockFingerprint(index, message.content);
3748
- if (!fingerprint || !rememberedRepairs.has(fingerprint)) continue;
3749
- const attempt = repairMessageAt(parsed, index);
3750
- if (!attempt) continue;
3751
- totalRemovedBlocks += attempt.removedBlocks;
3752
- repaired = {
3753
- ...attempt,
3754
- removedBlocks: totalRemovedBlocks
3755
- };
3756
- }
3757
- return repaired;
3758
- }
3759
- function rememberThinkingHistoryRepair(fingerprint) {
3760
- if (rememberedRepairs.has(fingerprint)) return;
3761
- if (rememberedRepairs.size >= MAX_REMEMBERED_REPAIRS) {
3762
- const oldest = rememberedRepairs.values().next().value;
3763
- if (typeof oldest === "string") rememberedRepairs.delete(oldest);
3764
- }
3765
- rememberedRepairs.add(fingerprint);
3766
- }
3767
- //#endregion
3768
3657
  //#region src/routes/messages/handler.ts
3769
3658
  const MAX_THINKING_REPAIR_ATTEMPTS = 5;
3770
3659
  const isWebSearchTool$1 = (tool) => !!tool && typeof tool === "object" && (typeof tool.type === "string" && tool.type.startsWith("web_search") || tool.name === "web_search");
@@ -3985,8 +3874,11 @@ async function handleCompletion(c) {
3985
3874
  } catch (error) {
3986
3875
  if (!(error instanceof HTTPError)) throw error;
3987
3876
  const errorBody = await error.response.clone().text().catch(() => "");
3988
- const thinkingRepair = attempt < MAX_THINKING_REPAIR_ATTEMPTS ? repairRejectedThinkingHistory(nativeBody, errorBody) : void 0;
3877
+ const outcome = attempt < MAX_THINKING_REPAIR_ATTEMPTS ? repairRejectedThinkingHistory(nativeBody, errorBody) : void 0;
3878
+ const thinkingRepair = outcome?.ok ? outcome.repair : void 0;
3989
3879
  if (!thinkingRepair || repairedMessageIndices.has(thinkingRepair.messageIndex)) {
3880
+ if (outcome && !outcome.ok) consola.warn(`Thinking-history repair declined: ${formatThinkingRepairDecline(outcome.decline)}`);
3881
+ else if (thinkingRepair) consola.warn(`Thinking-history repair made no progress; upstream re-named message=${thinkingRepair.messageIndex} after it was already repaired`);
3990
3882
  logRequest({
3991
3883
  method: "POST",
3992
3884
  path: c.req.path,
@@ -5557,4 +5449,4 @@ function getCodexEnvVars(serverUrl) {
5557
5449
  //#endregion
5558
5450
  export { sharedServerArgs as a, listModelsForEndpoint as c, checkClaudeVersion as d, updateClaude as f, setupAndServe as i, enableFileLogging as l, getCodexEnvVars as n, startKeepAwake as o, parseSharedArgs as r, stopKeepAwake as s, getClaudeCodeEnvVars as t, runSelfUpdate as u };
5559
5451
 
5560
- //# sourceMappingURL=server-setup-BmyWS4WU.js.map
5452
+ //# sourceMappingURL=server-setup-B02Myghc.js.map