@bitkyc08/opencodex 2.100.1 → 2.100.2

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 (163) hide show
  1. package/gui/dist/assets/App-BpJOzw4F.js +59 -0
  2. package/gui/dist/assets/Tray-BcaI-VCr.js +1 -0
  3. package/gui/dist/assets/{brand-mark-nr3ziR-T.js → brand-mark-DU-0Vdkr.js} +1 -1
  4. package/gui/dist/assets/index-Bbor_y80.js +94 -0
  5. package/gui/dist/assets/index-DJEkIDAi.css +2 -0
  6. package/gui/dist/assets/{segment-thumb-features-DKCVUUTi.js → segment-thumb-features-e9A_FogJ.js} +1 -1
  7. package/gui/dist/classic/assets/{App-CgPBKUP-.js → App-BrIlUiLc.js} +18 -18
  8. package/gui/dist/classic/assets/{Tray-BedmOsE7.js → Tray-DT146AhS.js} +1 -1
  9. package/gui/dist/classic/assets/index-DyJHagvT.js +94 -0
  10. package/gui/dist/classic/assets/quota-summary-CakPe9Ni.js +1 -0
  11. package/gui/dist/classic/index.html +1 -1
  12. package/gui/dist/index.html +2 -2
  13. package/package.json +2 -2
  14. package/src/adapters/client-fingerprint.ts +5 -3
  15. package/src/adapters/cursor/native-exec.ts +3 -2
  16. package/src/adapters/cursor/tool-guidance.ts +3 -3
  17. package/src/adapters/cursor/tool-wording.ts +10 -1
  18. package/src/adapters/devin/cloud-direct/tool-schema.ts +20 -2
  19. package/src/adapters/google-antigravity-wire.ts +13 -6
  20. package/src/adapters/google-truncation.ts +4 -2
  21. package/src/adapters/google.ts +8 -2
  22. package/src/adapters/openai-chat/tool-schema.ts +9 -0
  23. package/src/adapters/openai-responses/tool-schema.ts +18 -4
  24. package/src/adapters/run-turn-queue.ts +139 -5
  25. package/src/adapters/upstream-http-error.ts +4 -2
  26. package/src/bridge/sse.ts +8 -1
  27. package/src/claude/chat-tool-dispatch.ts +233 -0
  28. package/src/claude/inbound-tool-loading.ts +42 -17
  29. package/src/cli/account-api.ts +6 -0
  30. package/src/cli/account-extended.ts +60 -6
  31. package/src/cli/account-key-quota.ts +22 -2
  32. package/src/cli/account.ts +1 -1
  33. package/src/cli/capabilities-access-remote.ts +10 -0
  34. package/src/cli/capabilities-agents-routing.ts +2 -2
  35. package/src/cli/capabilities-base.ts +2 -2
  36. package/src/cli/claude.ts +19 -14
  37. package/src/cli/config-command.ts +24 -1
  38. package/src/cli/connect.ts +36 -3
  39. package/src/cli/gui-pair-client.ts +23 -2
  40. package/src/cli/help.ts +1 -1
  41. package/src/cli/hub.ts +18 -1
  42. package/src/cli/link-child-ops.ts +136 -0
  43. package/src/cli/link-status-child.ts +94 -0
  44. package/src/cli/link.ts +22 -9
  45. package/src/cli/registry.ts +3 -2
  46. package/src/cli/sync-command.ts +3 -1
  47. package/src/cli/sync-fanout.ts +8 -81
  48. package/src/client/link-readiness.ts +16 -6
  49. package/src/client/link-tunnel-status.ts +76 -0
  50. package/src/clients/config-export.ts +14 -1
  51. package/src/codex/account-resume-health.ts +41 -0
  52. package/src/codex/auth-api/login-flow.ts +6 -0
  53. package/src/codex/auth-api/routes.ts +35 -2
  54. package/src/codex/catalog/gather-capture.ts +2 -0
  55. package/src/codex/catalog/provider-models.ts +13 -8
  56. package/src/codex/convergence-types.ts +2 -0
  57. package/src/codex/quota.ts +111 -6
  58. package/src/combos/cooldown-store.ts +208 -0
  59. package/src/combos/failover.ts +432 -35
  60. package/src/config/salvage.ts +1 -0
  61. package/src/config/schema/config-schema.ts +6 -3
  62. package/src/config/schema/leaf-validators.ts +34 -12
  63. package/src/generated/compatibility-version.json +213 -121
  64. package/src/lib/catalog-etag.ts +10 -0
  65. package/src/lib/client-error-body.ts +15 -0
  66. package/src/lib/context-overflow-verdict.ts +266 -9
  67. package/src/lib/failure-detail.ts +72 -3
  68. package/src/lib/hard-refusal.ts +259 -0
  69. package/src/link/child-activity.ts +57 -0
  70. package/src/link/child-catalog-freshness.ts +149 -0
  71. package/src/link/child-gated-ocx.ts +117 -0
  72. package/src/link/child-observations.ts +205 -0
  73. package/src/link/child-observe.ts +121 -0
  74. package/src/link/child-ops-engine.ts +162 -0
  75. package/src/link/child-update-contract.ts +165 -0
  76. package/src/link/paths.ts +5 -0
  77. package/src/link/remote-windows.ts +42 -6
  78. package/src/link/ssh-argv.ts +126 -32
  79. package/src/link/status-projection.ts +73 -0
  80. package/src/link/sync-fanout-classify.ts +98 -0
  81. package/src/link/tunnel-state.ts +10 -4
  82. package/src/messaging/mcp-queue-rpc.ts +2 -1
  83. package/src/messaging/mcp-queue-server.ts +5 -0
  84. package/src/messaging/mcp-reply-tools.ts +24 -9
  85. package/src/messaging/mcp-reply-wait.ts +70 -0
  86. package/src/oauth/account-resume-health.ts +60 -0
  87. package/src/oauth/index.ts +1 -0
  88. package/src/oauth/store.ts +44 -1
  89. package/src/providers/api-key-pause-state.ts +23 -0
  90. package/src/providers/api-key-pause.ts +68 -10
  91. package/src/providers/api-key-selection-capture.ts +3 -1
  92. package/src/providers/api-key-selection.ts +3 -2
  93. package/src/providers/api-keys.ts +18 -5
  94. package/src/providers/claude-cli-usage-state.ts +11 -6
  95. package/src/providers/claude-cli-usage.ts +27 -9
  96. package/src/providers/codex-capacity.ts +11 -2
  97. package/src/providers/key-failover.ts +13 -6
  98. package/src/providers/model-discovery-config.ts +31 -0
  99. package/src/providers/model-discovery-diagnostic.ts +34 -3
  100. package/src/providers/model-discovery.ts +43 -7
  101. package/src/providers/model-rename-fields.ts +2 -0
  102. package/src/providers/openai-sidecar.ts +15 -2
  103. package/src/providers/provider-id-rewrite.ts +3 -0
  104. package/src/providers/quota/account-cache.ts +52 -34
  105. package/src/providers/quota/anthropic-usage-windows.ts +19 -9
  106. package/src/providers/quota/report-cache.ts +53 -5
  107. package/src/providers/quota/vendor-probes-key.ts +73 -0
  108. package/src/providers/quota/vendor-probes-oauth.ts +57 -3
  109. package/src/providers/quota-key-accounts.ts +12 -5
  110. package/src/providers/quota-mistral-budget.ts +18 -0
  111. package/src/providers/quota-types.ts +25 -0
  112. package/src/providers/quota.ts +22 -22
  113. package/src/providers/reasoning-metadata.ts +1051 -12
  114. package/src/quota/reset-observer.ts +4 -2
  115. package/src/quota/reset-seen-store.ts +9 -0
  116. package/src/quota/window-mapping.ts +1 -0
  117. package/src/quota-pool/assemble.ts +4 -1
  118. package/src/responses/hosted-tool-policy.ts +56 -12
  119. package/src/router.ts +2 -0
  120. package/src/server/auth-cors.ts +11 -8
  121. package/src/server/catalog-download.ts +3 -5
  122. package/src/server/chat-native.ts +11 -2
  123. package/src/server/claude-messages.ts +2 -1
  124. package/src/server/images.ts +41 -13
  125. package/src/server/index/link-listener.ts +16 -2
  126. package/src/server/index/link-relay-sessions.ts +43 -2
  127. package/src/server/index/optional-listeners.ts +18 -0
  128. package/src/server/management/config-routes.ts +7 -1
  129. package/src/server/management/context.ts +1 -1
  130. package/src/server/management/link-child-ops-routes.ts +116 -0
  131. package/src/server/management/link-route-state.ts +10 -0
  132. package/src/server/management/link-routes.ts +10 -0
  133. package/src/server/management/oauth-account-routes.ts +33 -4
  134. package/src/server/management/provider-overwrite-carry.ts +28 -3
  135. package/src/server/management/provider-routes.ts +16 -11
  136. package/src/server/management/route-registry.ts +3 -0
  137. package/src/server/messages-native.ts +5 -0
  138. package/src/server/request-log-failure-detail.ts +59 -1
  139. package/src/server/responses/adapter-dispatch.ts +35 -44
  140. package/src/server/responses/combo-stream-preflight.ts +146 -29
  141. package/src/server/responses/compact.ts +16 -5
  142. package/src/server/responses/context-overflow.ts +58 -2
  143. package/src/server/responses/core-combo-failure.ts +29 -4
  144. package/src/server/responses/core-combo-native.ts +3 -1
  145. package/src/server/responses/core-combo.ts +30 -3
  146. package/src/server/responses/core-errors.ts +3 -1
  147. package/src/server/responses/core-opaque-recovery.ts +45 -2
  148. package/src/server/responses/core-options.ts +12 -0
  149. package/src/server/responses/passthrough-dispatch.ts +30 -38
  150. package/src/server/responses/request-transport.ts +43 -14
  151. package/src/server/responses/reset-replay.ts +58 -2
  152. package/src/server/responses/run-turn-execution.ts +56 -30
  153. package/src/types/claude-tool-loading.ts +48 -0
  154. package/src/types/config.ts +5 -35
  155. package/src/types/provider.ts +21 -0
  156. package/src/types.ts +1 -0
  157. package/src/web-search/parse.ts +21 -2
  158. package/gui/dist/assets/App-g3Cm2xhZ.js +0 -59
  159. package/gui/dist/assets/Tray-BMDkAiXy.js +0 -1
  160. package/gui/dist/assets/index-Bziu8gTy.css +0 -2
  161. package/gui/dist/assets/index-OYzhQUNP.js +0 -94
  162. package/gui/dist/classic/assets/index-BR-HhNrp.js +0 -94
  163. package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.js +0 -1
@@ -8,7 +8,7 @@ import type { ResponsesEffects } from "./response-effects";
8
8
  import type { ResponsesSendBudget } from "./request-send-budget";
9
9
  import type { ResponsesCompletionPolicy } from "./completion-policy";
10
10
  import { linkAbortSignal, runTurnAdapterSseResponses } from "./core-lifetime";
11
- import { createAdapterEventQueue, preflightAdapterEvents, type AdapterEventPreflight } from "../../adapters/run-turn-queue";
11
+ import { createAdapterEventQueue, preflightAdapterEvents, classifyZeroOutputTokenLimit, isContentEvent, DEFAULT_MAX_REASONING_HOLD_MS, type AdapterEventPreflight } from "../../adapters/run-turn-queue";
12
12
  import {
13
13
  bindRouteReasoningReplayScope,
14
14
  adapterNeedsForcedContinuation,
@@ -283,6 +283,7 @@ export async function executeResponsesRunTurn(
283
283
  const failedKeys = new Set<string>();
284
284
  const keyAttemptLimit = route.provider.apiKeyPool?.length ?? 0;
285
285
  let lastKeyFailure: Extract<AdapterEvent, { type: "error" }> | undefined;
286
+ let authRecoveryRefusal: Response | undefined;
286
287
  let runTurnAttemptSeq = 0;
287
288
  const runTurnAttempt = async (
288
289
  targetQueue: AdapterEventQueue,
@@ -389,8 +390,13 @@ export async function executeResponsesRunTurn(
389
390
  Object.assign(parsed, routeState);
390
391
  }
391
392
  } catch (err) {
392
- const storageRefusal = mapSpendLedgerStorageError(err, logCtx);
393
- emit(storageRefusal ? { type: "error", ...storageRefusal } : err instanceof RequestPacingQueueOverloadError
393
+ if (err instanceof OAuthAccountPausedError) {
394
+ const message = publicOAuthAuthenticationErrorMessage(err);
395
+ authRecoveryRefusal ??= formatErrorResponse(403, "permission_error", message);
396
+ emit({ type: "error", status: 403, errorType: "permission_error", message });
397
+ } else {
398
+ const storageRefusal = mapSpendLedgerStorageError(err, logCtx);
399
+ emit(storageRefusal ? { type: "error", ...storageRefusal } : err instanceof RequestPacingQueueOverloadError
394
400
  ? {
395
401
  type: "error",
396
402
  status: 429,
@@ -414,6 +420,7 @@ export async function executeResponsesRunTurn(
414
420
  type: "error",
415
421
  message: err instanceof Error ? err.message : String(err),
416
422
  });
423
+ }
417
424
  } finally {
418
425
  if (attemptSeq === 1) options.comboInitialSend?.permit.release();
419
426
  devinProducers.delete(producerAbort);
@@ -492,7 +499,6 @@ export async function executeResponsesRunTurn(
492
499
  // selected; the turn then moves to a surviving stored account, or, with none, the client
493
500
  // gets the login instruction instead of an opaque upstream 401.
494
501
  let oauth401ReplayAttempted = false;
495
- let authRecoveryRefusal: Response | undefined;
496
502
  const refuseLocalAuthRecovery = (error: Extract<AdapterEvent, { type: "error" }>, cause: unknown): boolean => {
497
503
  const cancelled = runTurnAbort.signal.aborted;
498
504
  if (!cancelled && !(cause instanceof OAuthTokenRefreshBusyError) && !(cause instanceof OAuthAccountPausedError)) return false;
@@ -775,6 +781,11 @@ export async function executeResponsesRunTurn(
775
781
  const classifyUndeclaredFirstTool = (
776
782
  event: AdapterEvent,
777
783
  ): Extract<AdapterEvent, { type: "error" }> | undefined => {
784
+ // Called only at the first meaningful event; preflight protects side effects.
785
+ const zeroOutputLimit = options.comboAttempt
786
+ ? classifyZeroOutputTokenLimit(event, { allowCompactionWithContent: routedCompaction })
787
+ : undefined;
788
+ if (zeroOutputLimit) return zeroOutputLimit;
778
789
  // This tool is declared to the adapter by the private search loop.
779
790
  if (wsPlan && event.type === "tool_call_start" && event.name === WEB_SEARCH_TOOL_NAME) return undefined;
780
791
  const emptyCatalogRefusal = emptyToolCatalogRefusal(event, clientToolCatalog);
@@ -822,17 +833,19 @@ export async function executeResponsesRunTurn(
822
833
  ? Date.now() + (resolveStallTimeoutSec(stallTimeoutSec) || DEFAULT_STALL_TIMEOUT_SEC) * 1_000
823
834
  : undefined;
824
835
  if (runTurnFailoverArmed()) {
825
- // Preflight holds only heartbeats and the first meaningful event. A first-event 429 can be
826
- // replayed transparently; after any output reaches the bridge, a later error stays terminal.
836
+ // Preflight holds heartbeats, pre-output reasoning up to the reasoning hold bound,
837
+ // and the first meaningful event. A first-event 429 or zero-output token-limit terminal
838
+ // can be replayed transparently; after any output reaches the bridge or the reasoning
839
+ // hold expires, a later error stays terminal.
827
840
  eventSource = await preflightRunTurnFailover(eventSource, wsFirstParsed, preflightDeadlineAt);
828
- if (authRecoveryRefusal) {
829
- cancelResponseCompletion();
830
- runTurnAbort.abort();
831
- queue.close();
832
- cleanupRunTurnAbort();
833
- releaseSearchProbeLease();
834
- return authRecoveryRefusal;
835
- }
841
+ }
842
+ if (authRecoveryRefusal) {
843
+ cancelResponseCompletion();
844
+ runTurnAbort.abort();
845
+ queue.close();
846
+ cleanupRunTurnAbort();
847
+ releaseSearchProbeLease();
848
+ return authRecoveryRefusal;
836
849
  }
837
850
  if (grokDevinPreflight) {
838
851
  const preflight = await preflightAdapterEvents(eventSource, undefined, {
@@ -844,9 +857,14 @@ export async function executeResponsesRunTurn(
844
857
  }
845
858
  if (options.comboAttempt) {
846
859
  const preflight = await preflightAdapterEvents(
847
- eventSource, classifyUndeclaredFirstTool, { honorReady: false },
860
+ eventSource, classifyUndeclaredFirstTool, {
861
+ honorReady: false,
862
+ bufferCompaction: routedCompaction,
863
+ maxReasoningHoldMs: DEFAULT_MAX_REASONING_HOLD_MS,
864
+ },
848
865
  );
849
866
  if (preflight.error || preflight.empty) {
867
+ if (preflight.error?.usage) transportState.bindKeyUsageFromBridge(preflight.error.usage);
850
868
  runTurnAbort.abort();
851
869
  queue.close();
852
870
  const classified = adapterFailureFromEvent(preflight.error ?? {
@@ -982,14 +1000,14 @@ export async function executeResponsesRunTurn(
982
1000
  for await (const event of await preflightRunTurnFailover(
983
1001
  (async function* () { yield* firstAttemptEvents; })(),
984
1002
  )) runTurnEvents.push(event);
985
- if (authRecoveryRefusal) {
986
- cancelResponseCompletion();
987
- runTurnAbort.abort();
988
- queue.close();
989
- cleanupRunTurnAbort();
990
- releaseSearchProbeLease();
991
- return authRecoveryRefusal;
992
- }
1003
+ }
1004
+ if (authRecoveryRefusal) {
1005
+ cancelResponseCompletion();
1006
+ runTurnAbort.abort();
1007
+ queue.close();
1008
+ cleanupRunTurnAbort();
1009
+ releaseSearchProbeLease();
1010
+ return authRecoveryRefusal;
993
1011
  }
994
1012
  if (grokDevinPreflight) {
995
1013
  const preflight = await preflightAdapterEvents(
@@ -1052,15 +1070,21 @@ export async function executeResponsesRunTurn(
1052
1070
  const firstMeaningfulIndex = events.findIndex(event => event.type !== "heartbeat");
1053
1071
  const firstMeaningful = firstMeaningfulIndex === -1 ? undefined : events[firstMeaningfulIndex];
1054
1072
  // Same boundary as the streaming preflight: a replay-unsafe heartbeat means the adapter
1055
- // already ran a local side effect, so an undeclared tool call after it keeps the bridge's
1073
+ // already ran a local side effect, so an undeclared tool call or error after it keeps the bridge's
1056
1074
  // fail-closed refusal instead of becoming a hop that sends the turn to another target.
1057
- const replayUnsafe = events
1058
- .slice(0, firstMeaningfulIndex === -1 ? events.length : firstMeaningfulIndex)
1059
- .some(event => event.type === "heartbeat" && event.replayUnsafe === true);
1060
- const classifiedError = firstMeaningful && !replayUnsafe
1061
- ? classifyUndeclaredFirstTool(firstMeaningful)
1075
+ // Fail closed: any replay-unsafe heartbeat anywhere in the buffered turn disables replaying
1076
+ // undeclared tools or zero-output token-limit terminals.
1077
+ const replayUnsafe = events.some(event => event.type === "heartbeat" && event.replayUnsafe === true);
1078
+ const sawContent = events.some(isContentEvent);
1079
+ const terminalEvent = [...events].reverse().find(event => event.type === "done" || event.type === "incomplete");
1080
+ const zeroOutputLimit = (!sawContent || routedCompaction) && terminalEvent
1081
+ ? classifyZeroOutputTokenLimit(terminalEvent, { allowCompactionWithContent: routedCompaction })
1082
+ : undefined;
1083
+ const classifiedError = !replayUnsafe
1084
+ ? (zeroOutputLimit ?? (firstMeaningful ? classifyUndeclaredFirstTool(firstMeaningful) : undefined))
1062
1085
  : undefined;
1063
1086
  if (!firstMeaningful || firstMeaningful.type === "error" || classifiedError) {
1087
+ if (classifiedError?.usage) transportState.bindKeyUsageFromBridge(classifiedError.usage);
1064
1088
  const classified = adapterFailureFromEvent(classifiedError ?? (firstMeaningful?.type === "error"
1065
1089
  ? firstMeaningful
1066
1090
  : { type: "error", status: 502, message: "Adapter ended before producing a response" }));
@@ -1117,10 +1141,12 @@ export async function executeResponsesRunTurn(
1117
1141
  commitReasoningReplayServingRoute();
1118
1142
  }
1119
1143
  notifyResponseComplete(json);
1120
- return new Response(JSON.stringify(json), {
1144
+ const response = new Response(JSON.stringify(json), {
1121
1145
  status: (json.error as OcxErrorPayload | undefined)?.code === SPEND_LEDGER_STORAGE_UNAVAILABLE_CODE ? 503 : 200,
1122
1146
  headers: { "Content-Type": "application/json" },
1123
1147
  });
1148
+ runTurnAdapterSseResponses.add(response);
1149
+ return response;
1124
1150
  } catch (error) {
1125
1151
  if (!isTranslatorBudgetExceededError(error)) throw error;
1126
1152
  runTurnAbort.abort();
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Tool-loading settings of the Claude Code inbound (`claudeCode.*`). `OcxClaudeCodeConfig` in
3
+ * ./config extends this interface, so every reader still sees one `claudeCode` block; the fields
4
+ * live here because they share one contract (data-planes/claude-tool-loading.md).
5
+ */
6
+ export interface OcxClaudeCodeToolLoadingConfig {
7
+ /**
8
+ * Opt-in resolved provider/model routes verified to accept Responses additional_tools.
9
+ * A single trailing '*' matches a provider-qualified prefix (for example 'gateway/gpt-*').
10
+ * Replays successful client ToolSearch discoveries in place without growing the initial
11
+ * catalog. Requires metadata.user_id. Absent/empty is off; native passthrough is unchanged.
12
+ * Applies only after routing settles on a direct openai-responses route; combos and policies are skipped.
13
+ */
14
+ appendOnlyToolLoadingModels?: string[];
15
+ /**
16
+ * Opt-in direct openai-chat routes (same selector syntax, validation and skips): the catalog
17
+ * carries one stable `use_loaded_tool` dispatcher across ToolSearch loads, loaded definitions
18
+ * ride the ToolSearch result as text, and dispatcher calls are rewritten to the named tool
19
+ * before the client sees them. Absent/empty is off and byte-identical to an unset key.
20
+ */
21
+ chatToolDispatchModels?: string[];
22
+ /**
23
+ * Opt-in ENABLE_TOOL_SEARCH injection for launched Claude Code sessions (#4838).
24
+ *
25
+ * Claude Code v2.1.304+ turns tool search on by default behind an
26
+ * ANTHROPIC_BASE_URL gateway; earlier versions keep it off there unless
27
+ * ENABLE_TOOL_SEARCH is true / auto / auto:N (#7963). Unset leaves the client's
28
+ * default; `false` injects nothing either, so a user who wants upfront loading
29
+ * exports ENABLE_TOOL_SEARCH=false themselves.
30
+ *
31
+ * Default OFF. Native Anthropic passthrough retains server-side search; the
32
+ * ordinary translated route drops the typed search tool and sends function schemas
33
+ * eagerly. appendOnlyToolLoadingModels (verified final Responses destinations) and
34
+ * chatToolDispatchModels (verified direct Chat routes) are separate opt-ins for an
35
+ * eager client-executed ToolSearch function: they keep currently declared deferred
36
+ * definitions out of the initial catalog and project them at successful discovery
37
+ * results. This launcher switch alone enables neither projection nor server-side search.
38
+ * Compatibility-enforcement admission remains unchanged and can reject unsupported
39
+ * tool_search/tool_reference/deferred_tools requests; no native-search parity or
40
+ * cache-hit guarantee is implied.
41
+ *
42
+ * `true` injects "true"; a string is passed through verbatim so Claude Code's own
43
+ * vocabulary (`auto`, `auto:N`, `force`) stays reachable. `false` and absent
44
+ * inject nothing — they do not force the variable off, because a value the
45
+ * operator exported themselves always wins.
46
+ */
47
+ toolSearch?: boolean | string;
48
+ }
@@ -4,8 +4,10 @@ import type { AnthropicAccountPoolConfig, OcxAccountPoolRotationStrategy } from
4
4
  import type { AnthropicInstanceId } from "../providers/anthropic-instance-id";
5
5
  import type { OcxFallbackConfig } from "./fallback";
6
6
  import type { OcxTelemetryConfig } from "./telemetry";
7
+ import type { OcxClaudeCodeToolLoadingConfig } from "./claude-tool-loading";
7
8
  export type { AnthropicAccountPoolConfig, AnthropicModelRoute, OcxAccountPoolRotationStrategy, OcxAccountPoolQuotaWindow } from "./anthropic-account-pool";
8
9
  export type { OcxFallbackConfig, OcxFallbackDeviceConfig, OcxFallbackKind, OcxFallbackSwitches } from "./fallback";
10
+ export type { OcxClaudeCodeToolLoadingConfig } from "./claude-tool-loading";
9
11
 
10
12
  /** Public inference API exposure. Responses and Chat Completions are always served. */
11
13
  export interface OcxApiSurfacesConfig {
@@ -45,9 +47,10 @@ export interface OcxProtocolsConfig {
45
47
 
46
48
  /**
47
49
  * Claude Code inbound settings (devlog/260711_claude_inbound). Consumed by the
48
- * /v1/messages surface, the `ocx claude` launcher, and the GUI Claude page.
50
+ * /v1/messages surface, the `ocx claude` launcher, and the GUI Claude page. Tool-loading
51
+ * fields (toolSearch and the two tool-loading opt-ins) live in ./claude-tool-loading.
49
52
  */
50
- export interface OcxClaudeCodeConfig {
53
+ export interface OcxClaudeCodeConfig extends OcxClaudeCodeToolLoadingConfig {
51
54
  /** Route the standalone Claude Code CLI through the first-party intercept (settings.json env).
52
55
  * Independent of Desktop's first-party mode. Absent/false = off. */
53
56
  cliFirstParty?: boolean;
@@ -57,14 +60,6 @@ export interface OcxClaudeCodeConfig {
57
60
  * Default: false; only literal true enables it. Native passthrough is unchanged.
58
61
  */
59
62
  stabilizePromptCache?: boolean;
60
- /**
61
- * Opt-in resolved provider/model routes verified to accept Responses additional_tools.
62
- * A single trailing '*' matches a provider-qualified prefix (for example 'gateway/gpt-*').
63
- * Replays successful client ToolSearch discoveries in place without growing the initial
64
- * catalog. Requires metadata.user_id. Absent/empty is off; native passthrough is unchanged.
65
- * Applies only after routing settles on a direct openai-responses route; combos and policies are skipped.
66
- */
67
- appendOnlyToolLoadingModels?: string[];
68
63
  /** Opt-in translated Messages admission; unset keeps legacy behavior. Native passthrough is exempt. */
69
64
  compatibility?: "shadow" | "enforce";
70
65
  /** Kill switch for the /v1/messages inbound (GUI "Claude ON" toggle). Default: enabled. */
@@ -147,31 +142,6 @@ export interface OcxClaudeCodeConfig {
147
142
  * forcing effort on every request can leak reasoning params to non-reasoning routes.
148
143
  */
149
144
  alwaysEnableEffort?: boolean;
150
- /**
151
- * Opt-in ENABLE_TOOL_SEARCH injection for launched Claude Code sessions (#4838).
152
- *
153
- * Claude Code turns MCP tool deferral off whenever ANTHROPIC_BASE_URL names a
154
- * non-first-party host, so an `ocx claude` session ships every tool schema in
155
- * full on every request. Its own diagnostic states the precondition for turning
156
- * that back on: "Set ENABLE_TOOL_SEARCH=true (or auto / auto:N) if your proxy
157
- * forwards tool_reference blocks."
158
- *
159
- * Default OFF. Native Anthropic passthrough retains server-side search; the
160
- * ordinary translated route drops the typed search tool and sends function schemas
161
- * eagerly. appendOnlyToolLoadingModels is a separate opt-in for verified final
162
- * Responses destinations and an eager client-executed ToolSearch function: it
163
- * projects currently declared deferred definitions at successful discovery results.
164
- * This launcher switch alone enables neither that projection nor server-side search.
165
- * Compatibility-enforcement admission remains unchanged and can reject unsupported
166
- * tool_search/tool_reference/deferred_tools requests; no native-search parity or
167
- * cache-hit guarantee is implied.
168
- *
169
- * `true` injects "true"; a string is passed through verbatim so Claude Code's own
170
- * vocabulary (`auto`, `auto:N`, `force`) stays reachable. `false` and absent
171
- * inject nothing — they do not force the variable off, because a value the
172
- * operator exported themselves always wins.
173
- */
174
- toolSearch?: boolean | string;
175
145
  /**
176
146
  * Subagent tier slots (devlog 260712 B2): injected as ANTHROPIC_DEFAULT_*_MODEL so
177
147
  * Claude Code's Agent-tool aliases (opus/sonnet/haiku/fable + parent-inherit) route
@@ -616,6 +616,14 @@ export interface OcxProviderConfig {
616
616
  * or too flaky for startup/catalog sync.
617
617
  */
618
618
  liveModels?: boolean;
619
+ /**
620
+ * Per-provider live-discovery compatibility (#7910). `skipInvalidRows: true` skips individual
621
+ * `/models` rows whose id is missing, non-string, empty or otherwise invalid (and non-object
622
+ * rows) instead of rejecting the whole listing; a listing with no surviving row stays malformed.
623
+ * Absent or false keeps strict discovery. Unrelated to the top-level `OcxConfig.modelDiscovery`,
624
+ * which is persisted discovery state rather than provider configuration.
625
+ */
626
+ modelDiscovery?: { skipInvalidRows?: boolean };
619
627
  /**
620
628
  * Per-provider catalog allowlist. When non-empty, ONLY these model ids are emitted to Codex's
621
629
  * catalog and `/v1/models` — live discovery still runs, this just narrows what ships (so a proxy
@@ -899,6 +907,19 @@ export interface OcxProviderConfig {
899
907
  * tools; the two capabilities are independent and denied independently.
900
908
  */
901
909
  unsupportedHostedTools?: string[];
910
+ /**
911
+ * Hosted tool declarations this Responses destination rejects only in combination with
912
+ * client tools, so they are stripped when the same request also declares a `function` or
913
+ * `custom` tool, or a namespace with members, in `tools`, a client-loaded
914
+ * `additional_tools` catalog, or a `tool_search_output` result. A request that declares
915
+ * only hosted tools keeps them.
916
+ *
917
+ * This describes a gateway that serves hosted `web_search` alone and function calling
918
+ * alone, but answers HTTP 400 when one request carries both (#8204). Same vocabulary and
919
+ * alias expansion as `unsupportedHostedTools`, which stays authoritative: a tool listed
920
+ * there is removed whether or not client tools are present.
921
+ */
922
+ unsupportedHostedToolsWithClientTools?: string[];
902
923
  /**
903
924
  * Provider-local repair for Responses gateways whose lifecycle snapshots omit canonical
904
925
  * fields or closing events (#893). Disabled by default and applied only to client-facing
package/src/types.ts CHANGED
@@ -117,6 +117,7 @@ export type {
117
117
  OcxSearchConfig,
118
118
  OcxVisionSidecarConfig,
119
119
  OcxWebSearchSidecarConfig,
120
+ OcxClaudeCodeToolLoadingConfig,
120
121
  } from "./types/config";
121
122
 
122
123
  export type {
@@ -315,15 +315,34 @@ export const MAX_SIDECAR_RESPONSE_BYTES = 64 * 1024;
315
315
  export const MAX_SIDECAR_STREAM_BYTES = MAX_SIDECAR_RESPONSE_BYTES * 16;
316
316
  export const MAX_SIDECAR_DECODED_CHARS = 64 * 1024;
317
317
 
318
- /** Push a `url_citation` annotation as a source, de-duplicated by URL. */
318
+ /**
319
+ * Push a `url_citation` annotation as a source, de-duplicated by URL. A repeated URL whose kept
320
+ * entry has no usable title takes the first later valid title (#8351), in place and within the
321
+ * same source caps; an entry that already has a title keeps it.
322
+ */
319
323
  function collectAnnotation(ann: AnnotationLike | undefined, sources: WebSearchSource[], seen: Set<string>): void {
320
- if (!ann || ann.type !== "url_citation" || typeof ann.url !== "string" || seen.has(ann.url)) return;
324
+ if (!ann || ann.type !== "url_citation" || typeof ann.url !== "string") return;
325
+ if (seen.has(ann.url)) {
326
+ fillMissingTitle(sources, ann.url, ann.title);
327
+ return;
328
+ }
321
329
  if (appendSafeWebSearchSource(sources, {
322
330
  url: ann.url,
323
331
  ...(ann.title !== undefined ? { title: ann.title } : {}),
324
332
  })) seen.add(ann.url);
325
333
  }
326
334
 
335
+ function fillMissingTitle(sources: WebSearchSource[], url: string, title: unknown): void {
336
+ if (title === undefined) return;
337
+ const index = sources.findIndex(source => source.url === url);
338
+ if (index < 0 || sources[index]!.title !== undefined) return;
339
+ const candidate = sources.map((source, at) => at === index ? { url, title } : source);
340
+ // Re-run the shared checks: an invalid title is dropped, and a title that would push the
341
+ // list past its byte cap drops a source, so either outcome leaves the list unchanged.
342
+ const checked = safeWebSearchSources(candidate);
343
+ if (checked.length === sources.length && checked[index]!.title !== undefined) sources[index] = checked[index]!;
344
+ }
345
+
327
346
  /**
328
347
  * Hosted web_search (gpt-mini) rarely emits structured `url_citation` annotations; instead it ends
329
348
  * its answer with a markdown `Sources:` section. Extract sources from that TRAILING section only