@bitkyc08/opencodex 2.100.3 → 2.100.5-preview.20261118.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_INSTALL.md +23 -1
- package/bin/ocx.mjs +8 -1
- package/gui/dist/assets/{App-Dnb6VMsP.js → App-BiOGtxDS.js} +21 -20
- package/gui/dist/assets/{Tray-BV4ms9U9.js → Tray-BwsMejUO.js} +1 -1
- package/gui/dist/assets/brand-mark-BY1dgACL.js +1 -0
- package/gui/dist/assets/{index-DCdXsMyZ.js → index-CwHSKMdG.js} +46 -13
- package/gui/dist/assets/index-DJxM-imn.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-DXSidY6D.js → segment-thumb-features-Bds9Hb_7.js} +1 -1
- package/gui/dist/classic/assets/{App-DA-scMPq.js → App-CGLOiqQL.js} +20 -19
- package/gui/dist/classic/assets/{Tray-BrHaVRAq.js → Tray-Da4r2O70.js} +1 -1
- package/gui/dist/classic/assets/{index-BqOaGLf5.js → index-CvoKXKL9.js} +46 -13
- package/gui/dist/classic/assets/quota-summary-DvqzfCmr.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/src/cli.rs +5 -3
- package/native/ocx-child/src/codex_home.rs +1 -0
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic/per-message-effort.ts +296 -0
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +4 -63
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +95 -14
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/google-errors.ts +14 -2
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/qoder/adapter.ts +9 -1
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/adapters/zed.ts +4 -2
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/claude/desktop-remote-store.ts +60 -10
- package/src/cli/account-api.ts +4 -0
- package/src/cli/account-auth.ts +30 -2
- package/src/cli/account-extended.ts +33 -2
- package/src/cli/capabilities-access-remote.ts +3 -3
- package/src/cli/capabilities-accounts.ts +3 -3
- package/src/cli/capabilities-base.ts +11 -6
- package/src/cli/capabilities-observe-system.ts +2 -2
- package/src/cli/claude.ts +3 -3
- package/src/cli/disconnect-runtime.ts +16 -6
- package/src/cli/dispatch.ts +7 -1
- package/src/cli/index.ts +2 -2
- package/src/cli/link-apply-restart.ts +4 -2
- package/src/cli/link-routes.ts +4 -1
- package/src/cli/link.ts +5 -4
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/preflight-exemptions.ts +3 -0
- package/src/cli/provider.ts +3 -2
- package/src/cli/registry.ts +5 -2
- package/src/cli/resolve.ts +23 -8
- package/src/cli/restart-failure.ts +11 -1
- package/src/cli/runtime-api.ts +4 -0
- package/src/cli/status.ts +4 -1
- package/src/cli/system-command.ts +1 -1
- package/src/cli/system-restart-client.ts +9 -3
- package/src/cli/system-settings-parity.ts +2 -1
- package/src/client/connect.ts +73 -11
- package/src/client/desktop-refusal.ts +38 -0
- package/src/client/lifecycle-lock.ts +29 -4
- package/src/client/runtime-restart.ts +27 -15
- package/src/client/runtime.ts +4 -2
- package/src/client/state.ts +14 -0
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/account-pause.ts +4 -0
- package/src/codex/account-runtime-state.ts +4 -0
- package/src/codex/auth-api/main-account-probe.ts +3 -1
- package/src/codex/auth-api/main-hard-lock-refusal-read.ts +172 -0
- package/src/codex/auth-context.ts +40 -2
- package/src/codex/catalog/build-entries.ts +10 -0
- package/src/codex/catalog/derive-entry.ts +7 -0
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog/reserve-warn.ts +7 -5
- package/src/codex/catalog/reserve.ts +4 -3
- package/src/codex/catalog/retained-sync.ts +2 -0
- package/src/codex/catalog/routed-defaults.ts +35 -0
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/convergence.ts +2 -0
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/loopback-target.ts +22 -8
- package/src/codex/main-account.ts +94 -30
- package/src/codex/native-main-auth-file.ts +14 -0
- package/src/codex/native-main-credentials.ts +276 -0
- package/src/codex/native-main-owner.ts +3 -0
- package/src/codex/native-main-refresh-mode.ts +14 -1
- package/src/codex/quota.ts +63 -14
- package/src/combos/failover.ts +195 -1
- package/src/combos/index.ts +5 -0
- package/src/combos/resolve.ts +115 -19
- package/src/config/diagnostics.ts +3 -0
- package/src/config/live-reconcile.ts +6 -3
- package/src/config/load-degrade.ts +2 -0
- package/src/config/persisted-mutation.ts +2 -2
- package/src/config/persisted-projections.ts +18 -0
- package/src/config/process-state.ts +4 -3
- package/src/config/reserve-capability.ts +96 -0
- package/src/config/schema/config-schema.ts +6 -0
- package/src/config/schema/leaf-validators.ts +2 -0
- package/src/config/schema/routed-catalog-defaults.ts +49 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/config.ts +7 -7
- package/src/desktop-update/acquire.ts +202 -0
- package/src/desktop-update/cli.ts +168 -0
- package/src/desktop-update/drain.ts +40 -0
- package/src/desktop-update/headless.ts +285 -0
- package/src/desktop-update/image.ts +85 -0
- package/src/desktop-update/install.ts +53 -0
- package/src/desktop-update/msi.ts +72 -0
- package/src/desktop-update/release.ts +128 -0
- package/src/desktop-update/runtime.ts +155 -0
- package/src/desktop-update/staging.ts +118 -0
- package/src/desktop-update/trust.ts +45 -0
- package/src/generated/compatibility-version.json +327 -195
- package/src/generated/model-metadata.ts +3 -3
- package/src/images/fulfill-video.ts +3 -3
- package/src/images/loop.ts +6 -2
- package/src/images/plan.ts +147 -11
- package/src/images/types.ts +13 -4
- package/src/images/xai-video-client.ts +72 -10
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/gcp-adc.ts +48 -4
- package/src/lib/offline-resend.ts +150 -0
- package/src/lib/paced-stream.ts +3 -3
- package/src/lib/provider-outbound.ts +17 -6
- package/src/lib/request-failure-model.ts +2 -0
- package/src/lib/response-body-inactivity.ts +23 -1
- package/src/lib/upstream-retry.ts +39 -6
- package/src/link/explicit-route.ts +4 -4
- package/src/link/remote-windows.ts +79 -31
- package/src/link/residual-recovery.ts +20 -8
- package/src/messaging/budget.ts +23 -5
- package/src/messaging/remote-ports.ts +22 -10
- package/src/messaging/rpc.ts +4 -4
- package/src/oauth/antigravity-risk.ts +126 -0
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +113 -30
- package/src/oauth/generic-session-affinity.ts +10 -3
- package/src/oauth/index.ts +22 -14
- package/src/oauth/login-cli.ts +35 -1
- package/src/oauth/pool-kernel.ts +3 -3
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-billing-refusal.ts +27 -3
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +49 -15
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/quota/workbuddy.ts +6 -2
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/providers/workbuddy-credit-balance.ts +125 -16
- package/src/responses/citation-markers.ts +26 -23
- package/src/responses/effort-history.ts +732 -0
- package/src/routing/history/integrity.ts +41 -4
- package/src/server/auth-cors.ts +13 -3
- package/src/server/codex-model-list.ts +2 -1
- package/src/server/direct-local-http.ts +26 -3
- package/src/server/index/link-listener.ts +20 -14
- package/src/server/index/serve-options.ts +1 -0
- package/src/server/index.ts +3 -2
- package/src/server/link-turn.ts +17 -5
- package/src/server/management/config-routes.ts +39 -3
- package/src/server/management/link-child-preflight.ts +1 -1
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-edit.ts +20 -1
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +43 -13
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-overwrite-carry.ts +3 -0
- package/src/server/management/provider-routes.ts +12 -12
- package/src/server/management/static-catalog-probe.ts +33 -0
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/proxy-liveness.ts +54 -9
- package/src/server/relay.ts +6 -1
- package/src/server/request-log-conversation.ts +8 -4
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/request-log.ts +5 -1
- package/src/server/reserve-capability-startup.ts +32 -0
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-delivery.ts +2 -0
- package/src/server/responses/adapter-dispatch.ts +39 -18
- package/src/server/responses/antigravity-fault-rotation.ts +24 -0
- package/src/server/responses/antigravity-validation-refusal.ts +43 -6
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-selection-keepalive.ts +254 -0
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +67 -28
- package/src/server/responses/core-errors.ts +9 -6
- package/src/server/responses/core-options.ts +10 -0
- package/src/server/responses/core.ts +21 -0
- package/src/server/responses/estimated-usage.ts +115 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/jev-model-invoke.ts +7 -2
- package/src/server/responses/passthrough-completion.ts +6 -3
- package/src/server/responses/passthrough-delivery.ts +47 -8
- package/src/server/responses/passthrough-dispatch.ts +3 -0
- package/src/server/responses/request-prepare.ts +9 -5
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +11 -4
- package/src/service/desktop-supervision.d.mts +2 -0
- package/src/service/desktop-supervision.mjs +5 -0
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/stall-timeout.ts +11 -0
- package/src/types/config.ts +15 -92
- package/src/types/provider.ts +13 -0
- package/src/types/request.ts +23 -3
- package/src/types/routed-catalog-defaults.ts +17 -0
- package/src/types/routing-profile.ts +90 -0
- package/src/types.ts +1 -0
- package/src/update/index.ts +1 -1
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/usage/log.ts +14 -4
- package/src/usage/telemetry-contract.ts +1 -0
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/passthrough-bridge.ts +7 -0
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/brand-mark-XOLJbomA.js +0 -1
- package/gui/dist/assets/index-DQtCRNAw.css +0 -2
- package/gui/dist/classic/assets/quota-summary-Dy5_wfTT.js +0 -1
package/src/types/request.ts
CHANGED
|
@@ -38,9 +38,10 @@ export interface OcxReasoningReplayScopeRef {
|
|
|
38
38
|
*/
|
|
39
39
|
readonly clientPrincipalId?: string;
|
|
40
40
|
/**
|
|
41
|
-
* Conversation namespace for replay state.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* Conversation namespace for replay state. The request's own thread-id wins so a child agent
|
|
42
|
+
* cannot write its route into the parent's record (#8632); otherwise this is the Codex
|
|
43
|
+
* parent-thread id, and headerless Responses callers use a raw sanitized thread/Cursor/session
|
|
44
|
+
* fallback, never the hashed request-log conversation id.
|
|
44
45
|
*/
|
|
45
46
|
readonly clientThreadId: string;
|
|
46
47
|
current?: Readonly<OcxReasoningReplayIdentity>;
|
|
@@ -221,6 +222,14 @@ export interface OcxParsedRequest {
|
|
|
221
222
|
* provider-private continuation caches again on every later turn.
|
|
222
223
|
*/
|
|
223
224
|
_contextCompactionBoundary?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Codex's own per-turn metadata for this request says `history_initialization: "New"` (HTTP header,
|
|
227
|
+
* or a WebSocket frame's own `client_metadata`). Read once in request preparation; the experimental
|
|
228
|
+
* Anthropic `perMessageEffort` option takes it as the new-transcript receipt (#6895).
|
|
229
|
+
*/
|
|
230
|
+
_codexNewHistory?: boolean;
|
|
231
|
+
/** This turn's per-message effort bookkeeping (src/adapters/anthropic/per-message-effort.ts). */
|
|
232
|
+
_perMessageEffort?: PerMessageEffortTurn;
|
|
224
233
|
/**
|
|
225
234
|
* Core-owned registration slot for the optional advisor subsystem (src/advisor). Set per request
|
|
226
235
|
* by the sidecar planner, never at module load: the core Responses path only sees this
|
|
@@ -563,6 +572,17 @@ export interface OcxUrlCitation {
|
|
|
563
572
|
title?: string;
|
|
564
573
|
}
|
|
565
574
|
|
|
575
|
+
/**
|
|
576
|
+
* One turn's per-message effort state (#6895). Spread copies of the parsed request share it, so a
|
|
577
|
+
* rebuild of the same turn is seen as a second build.
|
|
578
|
+
*/
|
|
579
|
+
export interface PerMessageEffortTurn {
|
|
580
|
+
/** The pending decision this turn owns, until it commits or is abandoned. */
|
|
581
|
+
token?: string;
|
|
582
|
+
generation: string;
|
|
583
|
+
builds: number;
|
|
584
|
+
}
|
|
585
|
+
|
|
566
586
|
/**
|
|
567
587
|
* Canonical usage convention (devlog/260711_claude_inbound/070):
|
|
568
588
|
* - `inputTokens` is the TOTAL prompt size, INCLUDING cache reads and cache writes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator defaults for routed Codex catalog rows (#6872), stored as top-level
|
|
3
|
+
* `routedCatalogDefaults` in config.json. Every field is optional: omission keeps the derived
|
|
4
|
+
* value and explicit `false` stays `false`. Concrete provider/model declarations still win, and
|
|
5
|
+
* a row without verbosity support never carries `default_verbosity`. Validation lives in
|
|
6
|
+
* src/config/schema/routed-catalog-defaults.ts; derivation in src/codex/catalog/routed-defaults.ts.
|
|
7
|
+
*/
|
|
8
|
+
export interface OcxRoutedCatalogDefaultsConfig {
|
|
9
|
+
/** Serialized as `include_skills_usage_instructions`. */
|
|
10
|
+
includeSkillsUsageInstructions?: boolean;
|
|
11
|
+
/** Serialized as `include_apps_usage_instructions`. */
|
|
12
|
+
includeAppsUsageInstructions?: boolean;
|
|
13
|
+
/** Serialized as `include_plugin_usage_instructions`. */
|
|
14
|
+
includePluginUsageInstructions?: boolean;
|
|
15
|
+
/** Serialized as `default_verbosity`; applies only to rows that support verbosity, and never turns support on. */
|
|
16
|
+
defaultVerbosity?: "low" | "medium" | "high";
|
|
17
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** Routing-profile configuration types (`routingProfiles` in config.json). */
|
|
2
|
+
|
|
3
|
+
export type OcxRoutingUnknownEvidenceMode = "allow" | "penalize" | "exclude";
|
|
4
|
+
|
|
5
|
+
export interface OcxRoutingProfileCandidate {
|
|
6
|
+
provider: string;
|
|
7
|
+
model: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OcxRoutingProfileRequirements {
|
|
11
|
+
/** Minimum model context window in tokens. */
|
|
12
|
+
minContextWindow?: number;
|
|
13
|
+
/** Minimum remaining quota headroom fraction (0..1). */
|
|
14
|
+
minQuotaHeadroom?: number;
|
|
15
|
+
tools?: boolean;
|
|
16
|
+
imageInput?: boolean;
|
|
17
|
+
structuredOutput?: boolean;
|
|
18
|
+
reasoningEffort?: string;
|
|
19
|
+
serviceTier?: string;
|
|
20
|
+
localOnly?: boolean;
|
|
21
|
+
remoteAllowed?: boolean;
|
|
22
|
+
/** Special encrypted Codex task readability (ChatGPT forward pool). */
|
|
23
|
+
encryptedCodexTasks?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface OcxRoutingProfileOptimize {
|
|
27
|
+
latency?: number;
|
|
28
|
+
health?: number;
|
|
29
|
+
cost?: number;
|
|
30
|
+
quota?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Policy for the hard cost ceiling when a candidate has no finite cost
|
|
35
|
+
* estimate. `"allow"` (default) preserves the documented dry-run contract:
|
|
36
|
+
* the cap only excludes evidence known to exceed it, and the candidate's
|
|
37
|
+
* `cost.capOutcome` is `"unknown-allowed"`. `"exclude"` makes the ceiling
|
|
38
|
+
* fail-closed (`cost-limit-unknown` + `capOutcome: "unknown-excluded"`).
|
|
39
|
+
*/
|
|
40
|
+
export type OcxRoutingUnknownCostCapMode = "allow" | "exclude";
|
|
41
|
+
|
|
42
|
+
export interface OcxRoutingProfileLimits {
|
|
43
|
+
/** Hard per-request estimated-cost ceiling in USD. */
|
|
44
|
+
maxEstimatedCostUsd?: number;
|
|
45
|
+
/**
|
|
46
|
+
* How `maxEstimatedCostUsd` behaves when the estimate is unknown.
|
|
47
|
+
* Defaults to `"allow"` (eligible + `cost.capOutcome: "unknown-allowed"`);
|
|
48
|
+
* opt in to `"exclude"` for a true hard ceiling.
|
|
49
|
+
*/
|
|
50
|
+
onUnknownCost?: OcxRoutingUnknownCostCapMode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface OcxRoutingProfileUnknownEvidence {
|
|
54
|
+
capability?: OcxRoutingUnknownEvidenceMode;
|
|
55
|
+
health?: OcxRoutingUnknownEvidenceMode;
|
|
56
|
+
quota?: OcxRoutingUnknownEvidenceMode;
|
|
57
|
+
cost?: OcxRoutingUnknownEvidenceMode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface OcxRoutingProfileCompatibilitySuite {
|
|
61
|
+
suiteId: string;
|
|
62
|
+
evidenceLayer: "protocol_conformance" | "live_route_compatibility";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface OcxRoutingProfileCompatibility {
|
|
66
|
+
requiredSuites?: OcxRoutingProfileCompatibilitySuite[];
|
|
67
|
+
minStatus?: "PROBED" | "VERIFIED";
|
|
68
|
+
maxEvidenceAgeMs?: number;
|
|
69
|
+
unknownEvidence?: OcxRoutingUnknownEvidenceMode;
|
|
70
|
+
degradedEvidence?: OcxRoutingUnknownEvidenceMode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface OcxRoutingProfileConfig {
|
|
74
|
+
/**
|
|
75
|
+
* Explicit candidate allowlist (`provider/model` refs). No implicit
|
|
76
|
+
* expansion in v1.
|
|
77
|
+
*/
|
|
78
|
+
candidates: OcxRoutingProfileCandidate[];
|
|
79
|
+
/** Optional public model name replacing the default `policy/<id>` slug. */
|
|
80
|
+
alias?: string;
|
|
81
|
+
/** Hard requirements evaluated before scoring. */
|
|
82
|
+
require?: OcxRoutingProfileRequirements;
|
|
83
|
+
/** Optimization weights; normalized deterministically. */
|
|
84
|
+
optimize?: OcxRoutingProfileOptimize;
|
|
85
|
+
limits?: OcxRoutingProfileLimits;
|
|
86
|
+
/** How unknown evidence is handled per dimension. */
|
|
87
|
+
unknownEvidence?: OcxRoutingProfileUnknownEvidence;
|
|
88
|
+
/** Optional Compatibility Lab policy (CL-06). */
|
|
89
|
+
compatibility?: OcxRoutingProfileCompatibility;
|
|
90
|
+
}
|
package/src/types.ts
CHANGED
package/src/update/index.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const PKG = "@bitkyc08/opencodex";
|
|
|
76
76
|
const HERE = dirname(fileURLToPath(import.meta.url)); // .../opencodex/src/update
|
|
77
77
|
|
|
78
78
|
export type Installer = DetectedInstall | "standalone";
|
|
79
|
-
export const STANDALONE_UPDATE_HINT = "Update via OpenCodex Desktop (Check for Updates…) or reinstall the standalone binary from GitHub Releases.";
|
|
79
|
+
export const STANDALONE_UPDATE_HINT = "Update via OpenCodex Desktop (Check for Updates…), on a Windows Desktop installation from a terminal or remote session with 'ocx update --desktop', or reinstall the standalone binary from GitHub Releases.";
|
|
80
80
|
export type Channel = "latest" | "preview";
|
|
81
81
|
export type InstallOwnership = PackageInstallOwnership | { installer: "standalone" };
|
|
82
82
|
export type { MiseInstallOwner };
|
|
@@ -317,7 +317,26 @@ const DEVIN_PRICING = "https://docs.devin.ai/desktop/models (official modelCostD
|
|
|
317
317
|
const DEVIN_FABLE_52_SOURCE = "https://docs.devin.ai/desktop/models (Claude Fable 5.2 listed at 8 / 40, cache read 0.20, cache write 10, 2026-11-10; uid claude-fable-5-2-<effort>, seed collapses to the base)";
|
|
318
318
|
const DEVIN_SWE2_NOTE = "list rate; $0 self-serve through 2026-10-08 and 75%-off enterprise through 2026-12-31 are time-boxed promos, not baked in";
|
|
319
319
|
|
|
320
|
+
const GPT62_PRICING = [
|
|
321
|
+
{ modelId: "gpt-6.2-sol", cost4: { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5 } },
|
|
322
|
+
{ modelId: "gpt-6.2-astra", cost4: { input: 8, output: 40, cacheRead: 0.4, cacheWrite: 10 } },
|
|
323
|
+
];
|
|
324
|
+
const GPT62_VERIFIED_AT = "2026-11-18";
|
|
325
|
+
|
|
320
326
|
export const EXPECTED_PRICE_OVERLAYS: readonly ExpectedPriceOverlay[] = [
|
|
327
|
+
...GPT62_PRICING.flatMap(({ modelId, cost4 }): ExpectedPriceOverlay[] => {
|
|
328
|
+
const source = `https://developers.openai.com/api/docs/models/${modelId}`;
|
|
329
|
+
return [
|
|
330
|
+
{ provider: "openai-apikey", modelId, cost4, source, verifiedAt: GPT62_VERIFIED_AT, status: "verified" },
|
|
331
|
+
{ provider: "openai", modelId, cost4, source: `API-reference comparison estimate: ${source}`, verifiedAt: GPT62_VERIFIED_AT, status: "verified-derived" },
|
|
332
|
+
{ provider: "openrouter", modelId: `openai/${modelId}`, cost4, source: "https://openrouter.ai/api/v1/models", verifiedAt: GPT62_VERIFIED_AT, status: "verified" },
|
|
333
|
+
// 261118 preemptive: Devin uid follows gpt-6-1-sol; API-reference estimate, not billing.
|
|
334
|
+
...(["devin-cli", "devin"] as const).map((provider): ExpectedPriceOverlay => ({
|
|
335
|
+
provider, modelId: modelId.replaceAll(".", "-"), cost4,
|
|
336
|
+
source: `derived: OpenAI API list price ${source}; Devin uid mirrors gpt-6-1-sol`, verifiedAt: GPT62_VERIFIED_AT, status: "verified-derived",
|
|
337
|
+
})),
|
|
338
|
+
];
|
|
339
|
+
}),
|
|
321
340
|
{ provider: "openai-apikey", modelId: "gpt-6-astra", cost4: GPT6_ASTRA, source: ASTRA_API_PRICING, verifiedAt: "2026-09-05", status: "verified" },
|
|
322
341
|
// Display estimates use API prices for both login and API-key routes, including cache writes.
|
|
323
342
|
{ provider: "openai", modelId: "gpt-6-astra", cost4: GPT6_ASTRA, source: `API-reference comparison estimate: ${ASTRA_API_PRICING}`, verifiedAt: "2026-09-05", status: "verified-derived" },
|
|
@@ -719,6 +738,10 @@ const ANTHROPIC_FAST_PRICING = "https://platform.claude.com/docs/en/about-claude
|
|
|
719
738
|
* because they reuse its model slug. Multipliers apply uniformly after cache discounts.
|
|
720
739
|
*/
|
|
721
740
|
export const PRIORITY_PRICING_RULES: readonly PriorityPricingRule[] = [
|
|
741
|
+
...GPT62_PRICING.flatMap(({ modelId }) => ["openai", "openai-apikey"].map((provider): PriorityPricingRule => ({
|
|
742
|
+
provider, modelId, multiplier: 2,
|
|
743
|
+
source: "https://developers.openai.com/api/docs/pricing", verifiedAt: GPT62_VERIFIED_AT,
|
|
744
|
+
}))),
|
|
722
745
|
...["openai", "openai-apikey"].flatMap(provider =>
|
|
723
746
|
Object.entries(PRIORITY_MULTIPLIERS)
|
|
724
747
|
// Daybreak's `gpt-` selector belongs to ChatGPT/Codex accounts; its bare selector belongs
|
|
@@ -841,6 +864,18 @@ const OPENAI_CONTEXT_MODELS = [
|
|
|
841
864
|
];
|
|
842
865
|
|
|
843
866
|
export const CONTEXT_TIERS: readonly ContextTier[] = [
|
|
867
|
+
...GPT62_PRICING.flatMap(({ modelId }): ContextTier[] => [
|
|
868
|
+
...["openai", "openai-apikey"].map((provider): ContextTier => ({
|
|
869
|
+
provider, modelId, thresholdInputTokens: 272_000, inclusive: false,
|
|
870
|
+
multiplier: OPENAI_LONG_CONTEXT, confirmedPriorityRelation: "stack",
|
|
871
|
+
source: `https://developers.openai.com/api/docs/models/${modelId}`, verifiedAt: GPT62_VERIFIED_AT,
|
|
872
|
+
})),
|
|
873
|
+
{
|
|
874
|
+
provider: "openrouter", modelId: `openai/${modelId}`, thresholdInputTokens: 272_000, inclusive: true,
|
|
875
|
+
multiplier: OPENAI_LONG_CONTEXT,
|
|
876
|
+
source: "https://openrouter.ai/api/v1/models", verifiedAt: GPT62_VERIFIED_AT,
|
|
877
|
+
},
|
|
878
|
+
]),
|
|
844
879
|
// Reference bands on preemptive/subscription surfaces follow their reference price, not billing.
|
|
845
880
|
...[
|
|
846
881
|
...["anthropic", "anthropic-apikey", "opencode-go", "opencode-zen", "venice", "github-copilot", "devin", "devin-cli", "claude-cli"].map(provider => [provider, "claude-haiku-5-5"]),
|
|
@@ -486,6 +486,12 @@ export async function scanUsageLedgerCooperatively(
|
|
|
486
486
|
export interface ReadUsageLedgerRowsOptions {
|
|
487
487
|
/** Ascending, distinct row-start offsets reported by an earlier scan of the same file. */
|
|
488
488
|
offsets: readonly number[];
|
|
489
|
+
/**
|
|
490
|
+
* Folds rows as they are decoded instead of retaining them in `entries`. Callback work shares
|
|
491
|
+
* the cooperative time slice. Results are provisional until this read resolves: discard them
|
|
492
|
+
* if identity or content validation fails, as with the full-ledger scanner's callback.
|
|
493
|
+
*/
|
|
494
|
+
onEntry?: (entry: PersistedUsageEntry, rowStartBytes: number) => void;
|
|
489
495
|
/** Identity those offsets were captured under; a replaced file invalidates all of them. */
|
|
490
496
|
expectedIdentityKey: string;
|
|
491
497
|
/** Revision the offsets were captured under. Any movement re-validates the boundary. */
|
|
@@ -503,6 +509,7 @@ export interface ReadUsageLedgerRowsOptions {
|
|
|
503
509
|
}
|
|
504
510
|
|
|
505
511
|
export interface UsageLedgerRowRead {
|
|
512
|
+
/** Empty when an onEntry callback consumes the rows. */
|
|
506
513
|
entries: PersistedUsageEntry[];
|
|
507
514
|
/** Offsets that no longer frame a complete, normalizable row. */
|
|
508
515
|
unreadableOffsets: number[];
|
|
@@ -626,27 +633,32 @@ export async function readUsageLedgerRowsAtOffsets(
|
|
|
626
633
|
return null;
|
|
627
634
|
};
|
|
628
635
|
|
|
629
|
-
const walk = (visit: (bytes: Buffer, offset: number) => boolean): number[] => {
|
|
636
|
+
const walk = async (visit: (bytes: Buffer, offset: number) => boolean): Promise<number[]> => {
|
|
630
637
|
const unreadableOffsets: number[] = [];
|
|
638
|
+
let lastYieldAt = performance.now();
|
|
631
639
|
for (const offset of options.offsets) {
|
|
632
640
|
throwIfAborted(options.signal);
|
|
633
641
|
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= size) {
|
|
634
642
|
unreadableOffsets.push(offset);
|
|
635
|
-
|
|
643
|
+
} else {
|
|
644
|
+
const bytes = lineAt(offset);
|
|
645
|
+
if (!bytes || !visit(bytes, offset)) unreadableOffsets.push(offset);
|
|
636
646
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
647
|
+
// A bounded candidate count does not bound decoding or aggregation time. Include the
|
|
648
|
+
// visitor in the same slice as the full scanner, and let timers/cancellation run even
|
|
649
|
+
// within one page. A single row remains atomic.
|
|
650
|
+
if (performance.now() - lastYieldAt >= MAX_SCAN_SLICE_MS) {
|
|
651
|
+
await new Promise<void>(resolve => setTimeout(resolve, 0));
|
|
652
|
+
throwIfAborted(options.signal);
|
|
653
|
+
lastYieldAt = performance.now();
|
|
641
654
|
}
|
|
642
|
-
if (!visit(bytes, offset)) unreadableOffsets.push(offset);
|
|
643
655
|
}
|
|
644
656
|
return unreadableOffsets;
|
|
645
657
|
};
|
|
646
658
|
|
|
647
659
|
const entries: PersistedUsageEntry[] = [];
|
|
648
660
|
const captured = createHash("sha256");
|
|
649
|
-
const unreadableOffsets = walk((bytes, offset) => {
|
|
661
|
+
const unreadableOffsets = await walk((bytes, offset) => {
|
|
650
662
|
captured.update(bytes);
|
|
651
663
|
captured.update("\0");
|
|
652
664
|
captured.update(String(offset));
|
|
@@ -660,7 +672,8 @@ export async function readUsageLedgerRowsAtOffsets(
|
|
|
660
672
|
// normalizes means the ledger moved under the projection, so it is unreadable rather than
|
|
661
673
|
// silently dropped: the caller rebuilds instead of reporting a smaller complete result.
|
|
662
674
|
if (!entry) return false;
|
|
663
|
-
|
|
675
|
+
if (options.onEntry) options.onEntry(entry, offset);
|
|
676
|
+
else entries.push(entry);
|
|
664
677
|
return true;
|
|
665
678
|
});
|
|
666
679
|
const capturedDigest = captured.digest("hex");
|
|
@@ -675,6 +688,7 @@ export async function readUsageLedgerRowsAtOffsets(
|
|
|
675
688
|
if (!pathRevision || usageLogIdentityKey(pathRevision) !== options.expectedIdentityKey) {
|
|
676
689
|
throw rebuildRequired("identity_mismatch");
|
|
677
690
|
}
|
|
691
|
+
if (pathRevision.size < size) throw rebuildRequired("shrink");
|
|
678
692
|
// Any write during the read can be an in-place rewrite, not just an append. Re-read the
|
|
679
693
|
// same offsets and compare, so a rewrite that lands between two batches cannot publish a
|
|
680
694
|
// mixture of old and new rows. A pure append leaves every selected row unchanged.
|
|
@@ -686,8 +700,11 @@ export async function readUsageLedgerRowsAtOffsets(
|
|
|
686
700
|
if (physical !== undefined && endingRevision.size <= physical) {
|
|
687
701
|
throw rebuildRequired("content_changed");
|
|
688
702
|
}
|
|
703
|
+
// Verification must read the file again, not re-hash a small page still in the read cache.
|
|
704
|
+
windowStart = -1;
|
|
705
|
+
windowLength = 0;
|
|
689
706
|
const verified = createHash("sha256");
|
|
690
|
-
const recheck = walk((bytes, offset) => {
|
|
707
|
+
const recheck = await walk((bytes, offset) => {
|
|
691
708
|
verified.update(bytes);
|
|
692
709
|
verified.update("\0");
|
|
693
710
|
verified.update(String(offset));
|
|
@@ -697,7 +714,24 @@ export async function readUsageLedgerRowsAtOffsets(
|
|
|
697
714
|
|| verified.digest("hex") !== capturedDigest) {
|
|
698
715
|
throw rebuildRequired("content_changed");
|
|
699
716
|
}
|
|
717
|
+
const verifiedFdRevision = revisionFromStat(path, fd, fstatSync(fd));
|
|
718
|
+
const verifiedPathRevision = currentUsageLogRevision();
|
|
719
|
+
if (!verifiedPathRevision
|
|
720
|
+
|| usageLogIdentityKey(verifiedFdRevision) !== options.expectedIdentityKey
|
|
721
|
+
|| usageLogIdentityKey(verifiedPathRevision) !== options.expectedIdentityKey) {
|
|
722
|
+
throw rebuildRequired("identity_mismatch");
|
|
723
|
+
}
|
|
724
|
+
if (verifiedFdRevision.size < size || verifiedPathRevision.size < size) {
|
|
725
|
+
throw rebuildRequired("shrink");
|
|
726
|
+
}
|
|
727
|
+
// Verification yields too. A later write could change bytes already checked, so retry
|
|
728
|
+
// rather than publish a result whose verification raced another mutation.
|
|
729
|
+
if (usageLogRevisionKey(verifiedFdRevision) !== usageLogRevisionKey(endingRevision)
|
|
730
|
+
|| usageLogRevisionKey(verifiedPathRevision) !== usageLogRevisionKey(pathRevision)) {
|
|
731
|
+
throw rebuildRequired("content_changed");
|
|
732
|
+
}
|
|
700
733
|
}
|
|
734
|
+
throwIfAborted(options.signal);
|
|
701
735
|
return { entries, unreadableOffsets };
|
|
702
736
|
} finally {
|
|
703
737
|
closeSync(fd);
|
package/src/usage/log.ts
CHANGED
|
@@ -1490,17 +1490,27 @@ function usageLogRevision(path: string, fd: number, stat: ReturnType<typeof fsta
|
|
|
1490
1490
|
};
|
|
1491
1491
|
}
|
|
1492
1492
|
|
|
1493
|
-
|
|
1493
|
+
/**
|
|
1494
|
+
* ChangeTime is part of the key on POSIX only. On NTFS the config home's background icacls
|
|
1495
|
+
* harden re-applies inherited ACEs to usage.jsonl and moves its ChangeTime with every other
|
|
1496
|
+
* field unchanged, and content cannot change without moving mtime; counting it rebuilt the
|
|
1497
|
+
* filter index and every retained aggregate. On POSIX it still exposes an mtime-restoring rewrite.
|
|
1498
|
+
*/
|
|
1499
|
+
export function usageLogRevisionKey(
|
|
1500
|
+
revision: UsageLogRevision | null,
|
|
1501
|
+
platform: NodeJS.Platform = process.platform,
|
|
1502
|
+
): string {
|
|
1494
1503
|
if (!revision) return "missing";
|
|
1495
|
-
|
|
1504
|
+
const parts: Array<string | number> = [
|
|
1496
1505
|
revision.path,
|
|
1497
1506
|
revision.dev,
|
|
1498
1507
|
revision.ino,
|
|
1499
1508
|
revision.birthtimeMs,
|
|
1500
1509
|
revision.size,
|
|
1501
1510
|
revision.mtimeMs,
|
|
1502
|
-
|
|
1503
|
-
|
|
1511
|
+
];
|
|
1512
|
+
if (platform !== "win32") parts.push(revision.ctimeMs);
|
|
1513
|
+
return parts.join("\0");
|
|
1504
1514
|
}
|
|
1505
1515
|
|
|
1506
1516
|
/** Identity of the usage ledger file, excluding size/mtime/ctime so appends can share work. */
|
package/src/web-search/loop.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { AttemptRecoveryKind } from "../usage/log";
|
|
|
12
12
|
import { isTruncatedStopReason } from "../responses/truncated-stop-reason";
|
|
13
13
|
import { bridgeToResponsesSSE } from "../bridge";
|
|
14
14
|
import { guardEmptyToolCatalogStream, type ClientToolCatalogRestriction } from "../lib/empty-tool-catalog";
|
|
15
|
-
import { mergeUsage } from "../server/responses/empty-completion-guard";
|
|
15
|
+
import { emptyCompletionRetryFailedEvent, mergeUsage } from "../server/responses/empty-completion-guard";
|
|
16
16
|
import { markSidecarContextOverflow, sidecarLoopTerminalEvent, upstreamErrorCode, type SidecarLoopFailure } from "../server/responses/context-overflow";
|
|
17
17
|
import { markVerifiedModelNotInPlanResponse, MODEL_NOT_IN_PLAN_CODE, UNDECLARED_TOOL_CALL_ERROR_CODE, verifiedPlanRefusalMessage } from "../lib/errors";
|
|
18
18
|
import { runWebSearch, type SidecarOutcome, type SidecarOutcomeRecorder, type SidecarSettings } from "./executor";
|
|
@@ -358,6 +358,8 @@ function loopFailure(e: LoopError): SidecarLoopFailure {
|
|
|
358
358
|
*/
|
|
359
359
|
export interface WebSearchLoopDeps {
|
|
360
360
|
parsed: OcxParsedRequest;
|
|
361
|
+
/** The global emptyCompletionRetry opt-in; the loop applies it only to final openai-chat iterations. */
|
|
362
|
+
emptyCompletionRetry?: boolean;
|
|
361
363
|
advisor?: AdvisorSidecarStep;
|
|
362
364
|
/** Chat delivery only; never copied into parsed generation options. */
|
|
363
365
|
chatRawReasoningVisible?: boolean;
|
|
@@ -514,8 +516,12 @@ export async function runWithWebSearch(deps: WebSearchLoopDeps): Promise<Respons
|
|
|
514
516
|
|
|
515
517
|
// Hard iteration bound (termination safety net); forceAnswer normally ends the loop sooner.
|
|
516
518
|
// One iteration beyond the forced answer is reserved for its empty-answer recovery below.
|
|
519
|
+
// An authorized Chat empty-completion retry adds its own iteration (see completionRetries in the
|
|
520
|
+
// loop bound), so ordinary iterations, including repeat placeholders for a failed query that never
|
|
521
|
+
// advance searchesExecuted, cannot use up the slot the retry needs.
|
|
517
522
|
const HARD_CAP = maxSearches + 3 + (deps.advisor ? MAX_ADVISOR_CONTINUATIONS_PER_REQUEST : 0);
|
|
518
523
|
let emptyAnswerRetries = 0;
|
|
524
|
+
let completionRetries = 0;
|
|
519
525
|
// Every iteration re-sends the full context, but only the last one's terminal reaches the bridge.
|
|
520
526
|
// Search-calling passes and the discarded empty forced answer are summed here and added to what
|
|
521
527
|
// onUsage reports, so the request log meters what was actually sent. The client-facing terminal
|
|
@@ -1166,7 +1172,7 @@ export async function runWithWebSearch(deps: WebSearchLoopDeps): Promise<Respons
|
|
|
1166
1172
|
async function* produce(): AsyncGenerator<AdapterEvent> {
|
|
1167
1173
|
let prepared = firstPrepared;
|
|
1168
1174
|
try {
|
|
1169
|
-
for (let i = 0; i < HARD_CAP; i++) {
|
|
1175
|
+
for (let i = 0; i < HARD_CAP + completionRetries; i++) {
|
|
1170
1176
|
const forceAnswer = searchesExecuted >= maxSearches;
|
|
1171
1177
|
try {
|
|
1172
1178
|
// First loop turn reuses the eager HEADERS. Subsequent header acquisitions run here.
|
|
@@ -1191,6 +1197,18 @@ export async function runWithWebSearch(deps: WebSearchLoopDeps): Promise<Respons
|
|
|
1191
1197
|
&& !split.passthrough.some(event => event.type === "incomplete" || event.type === "error"
|
|
1192
1198
|
|| (event.type === "done" && isTruncatedStopReason(event.stopReason)));
|
|
1193
1199
|
if (!shouldLoop) {
|
|
1200
|
+
// Validate every final Chat iteration, even when no search was called. Retry
|
|
1201
|
+
// only this model leg: already executed search results stay in messages.
|
|
1202
|
+
const final = split.passthrough.find(event => event.type === "done");
|
|
1203
|
+
if (deps.emptyCompletionRetry && !forceAnswer && adapter.name === "openai-chat"
|
|
1204
|
+
&& final?.type === "done" && !isTruncatedStopReason(final.stopReason)
|
|
1205
|
+
&& !split.passthrough.some(event => event.type === "error" || event.type === "incomplete")
|
|
1206
|
+
&& !signal.aborted && !split.hasMalformedToolCall && !split.hasRealToolCall
|
|
1207
|
+
&& split.streamedPassthroughCount === 0 && !hasVisibleAssistantText(split.passthrough)) {
|
|
1208
|
+
hiddenUsage = mergeUsage(hiddenUsage, final.usage);
|
|
1209
|
+
if (completionRetries++ === 0) { yield { type: "heartbeat" }; continue; }
|
|
1210
|
+
throw new LoopError(502, "Provider completed without usable output after one retry", emptyCompletionRetryFailedEvent());
|
|
1211
|
+
}
|
|
1194
1212
|
// #1001: a forced-answer pass that ends `done` must have produced
|
|
1195
1213
|
// usable output — never a malformed tool call, and never silence.
|
|
1196
1214
|
if (forceAnswer) {
|
package/src/web-search/parse.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sseFieldValue } from "../lib/sse-decoder";
|
|
2
2
|
import {
|
|
3
3
|
appendSafeWebSearchSource,
|
|
4
|
+
fillMissingWebSearchSourceTitle,
|
|
4
5
|
safeWebSearchSources,
|
|
5
6
|
type SafeWebSearchSource,
|
|
6
7
|
} from "./sources";
|
|
@@ -323,7 +324,7 @@ export const MAX_SIDECAR_DECODED_CHARS = 64 * 1024;
|
|
|
323
324
|
function collectAnnotation(ann: AnnotationLike | undefined, sources: WebSearchSource[], seen: Set<string>): void {
|
|
324
325
|
if (!ann || ann.type !== "url_citation" || typeof ann.url !== "string") return;
|
|
325
326
|
if (seen.has(ann.url)) {
|
|
326
|
-
|
|
327
|
+
fillMissingWebSearchSourceTitle(sources, ann.url, ann.title);
|
|
327
328
|
return;
|
|
328
329
|
}
|
|
329
330
|
if (appendSafeWebSearchSource(sources, {
|
|
@@ -332,17 +333,6 @@ function collectAnnotation(ann: AnnotationLike | undefined, sources: WebSearchSo
|
|
|
332
333
|
})) seen.add(ann.url);
|
|
333
334
|
}
|
|
334
335
|
|
|
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
|
-
|
|
346
336
|
/**
|
|
347
337
|
* Hosted web_search (gpt-mini) rarely emits structured `url_citation` annotations; instead it ends
|
|
348
338
|
* its answer with a markdown `Sources:` section. Extract sources from that TRAILING section only
|
|
@@ -76,6 +76,7 @@ import {
|
|
|
76
76
|
} from "./sidecar-providers";
|
|
77
77
|
import { providerDestinationConfigError } from "../lib/destination-policy";
|
|
78
78
|
import { redactSecretString } from "../lib/redact";
|
|
79
|
+
import { ExplicitBodyStallError } from "../lib/response-body-inactivity";
|
|
79
80
|
import { rememberBridgeSearchReplay } from "../responses/bridge-search-replay-cache";
|
|
80
81
|
import { withAnthropicHelperRefusal } from "../sidecar/auth";
|
|
81
82
|
|
|
@@ -1050,6 +1051,12 @@ async function* bridgeStreamBlocks(
|
|
|
1050
1051
|
const message = error instanceof Error ? error.message : String(error);
|
|
1051
1052
|
// A held-event overflow is this proxy's own bound. Attributing it to an upstream read
|
|
1052
1053
|
// failure would blame the provider for a refusal the bridge made.
|
|
1054
|
+
// The operator's explicit stallTimeoutSec expiring is a stall, reported with the same
|
|
1055
|
+
// `upstream_stall_timeout` terminal the relay and adapter paths use (#8206).
|
|
1056
|
+
if (error instanceof ExplicitBodyStallError) {
|
|
1057
|
+
yield* emit(state.failLegFrames("upstream_stall_timeout", message));
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1053
1060
|
yield* emit(state.failLegFrames(
|
|
1054
1061
|
WEB_SEARCH_BRIDGE_ERROR_CODE,
|
|
1055
1062
|
error instanceof HeldCallBudgetExceededError
|
|
@@ -52,6 +52,19 @@ export function appendSafeWebSearchSource(target: SafeWebSearchSource[], source:
|
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/** Fill one validated citation's missing title without rebuilding or revalidating its peers. */
|
|
56
|
+
export function fillMissingWebSearchSourceTitle(target: SafeWebSearchSource[], url: string, value: unknown): void {
|
|
57
|
+
const title = safeTitle(value);
|
|
58
|
+
if (title === undefined) return;
|
|
59
|
+
const index = target.findIndex(source => source.url === url);
|
|
60
|
+
if (index < 0 || target[index]!.title !== undefined) return;
|
|
61
|
+
const previous = target[index]!;
|
|
62
|
+
const next = { url: previous.url, title };
|
|
63
|
+
const delta = serializedSourceBytes(next) - serializedSourceBytes(previous);
|
|
64
|
+
const usedBytes = target.reduce((sum, source) => sum + serializedSourceBytes(source), 0);
|
|
65
|
+
if (usedBytes + delta <= MAX_WEB_SEARCH_SOURCE_BYTES) target[index] = next;
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
export function safeWebSearchSources(sources: unknown): SafeWebSearchSource[] {
|
|
56
69
|
if (!Array.isArray(sources)) return [];
|
|
57
70
|
const safe: SafeWebSearchSource[] = [];
|