@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
|
@@ -277,7 +277,7 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
|
|
|
277
277
|
// only the old devin entry carried. Degraded-mode seed only either way —
|
|
278
278
|
// `liveModels` discovers the account's real roster.
|
|
279
279
|
// 261027 preemptive: GPT-6.1 Terra (same degraded seed policy as GPT-6.1 Sol).
|
|
280
|
-
models: ["swe-2", "swe-1-7", "gpt-5-6-sol", "gpt-6-astra", "gpt-6-1-sol", "gpt-6-1-terra", "gpt-6-sol", "gpt-6-luna", "claude-opus-5-5", "claude-opus-5", "claude-fable-5-2", "claude-fable-5-1", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-sonnet-5", "glm-5-3", "kimi-k3", "gemini-3-8-flash", "grok-4-6", "grok-4-7", "swe-1-7-lightning", "gpt-5-6-luna", "gpt-5-6-terra", "claude-opus-4-8", "glm-5-2", "kimi-k2-7", "grok-4-5"],
|
|
280
|
+
models: ["swe-2", "swe-1-7", "gpt-5-6-sol", "gpt-6-astra", "gpt-6-2-sol", "gpt-6-2-astra", "gpt-6-1-sol", "gpt-6-1-terra", "gpt-6-sol", "gpt-6-luna", "claude-opus-5-5", "claude-opus-5", "claude-fable-5-2", "claude-fable-5-1", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-sonnet-5", "glm-5-3", "kimi-k3", "gemini-3-8-flash", "grok-4-6", "grok-4-7", "swe-1-7-lightning", "gpt-5-6-luna", "gpt-5-6-terra", "claude-opus-4-8", "glm-5-2", "kimi-k2-7", "grok-4-5"],
|
|
281
281
|
liveModels: true,
|
|
282
282
|
defaultModel: "swe-2",
|
|
283
283
|
modelContextWindows: DEVIN_MODEL_CONTEXT_WINDOWS,
|
|
@@ -672,8 +672,11 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
|
|
|
672
672
|
// its matching result (#4726); the flag is live on this wire.
|
|
673
673
|
requiresAdjacentResponsesToolResults: true,
|
|
674
674
|
featured: false,
|
|
675
|
-
//
|
|
676
|
-
//
|
|
675
|
+
// Listed in the add-provider picker (#8087). It is not an OAUTH_PROVIDERS login, so the
|
|
676
|
+
// Accounts tab still draws Kimi once; the row signs in through src/oauth/credential-siblings.ts.
|
|
677
|
+
dashboardPreset: true,
|
|
678
|
+
// Shares the kimi OAuth account: OAUTH_CREDENTIAL_SIBLINGS maps this row to the kimi
|
|
679
|
+
// auth-store slot, so adding this preset after logging into kimi needs no second login.
|
|
677
680
|
oauthId: "kimi",
|
|
678
681
|
jawcodeBundle: "moonshot",
|
|
679
682
|
note: "Same Kimi account login, routed over the OpenAI Responses wire. Thinking content stays encrypted server-side; tool calls and results stay visible. Chat wire remains the default preset for transparency.",
|
|
@@ -1127,6 +1130,9 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
|
|
|
1127
1130
|
// Listed 2026-09-29 as an OpenAI-backed route like GPT-6 Sol.
|
|
1128
1131
|
"openai/gpt-6.1-sol": true,
|
|
1129
1132
|
"openai/gpt-6.1-terra": true,
|
|
1133
|
+
// Listed 2026-11-18 as OpenAI-backed routes like GPT-6.1 Sol.
|
|
1134
|
+
"openai/gpt-6.2-sol": true,
|
|
1135
|
+
"openai/gpt-6.2-astra": true,
|
|
1130
1136
|
},
|
|
1131
1137
|
// Deliberately no OpenRouter route pin: it bills the endpoint actually used and reports the
|
|
1132
1138
|
// actual service_tier. B0 confirmation therefore owns downgrade safety. Forcing `only` plus
|
|
@@ -963,6 +963,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
963
963
|
noVisionModels: ALIBABA_TOKEN_PLAN_NO_VISION,
|
|
964
964
|
// The gateway accepts prompt_cache_key on every Token Plan chat model (probed 260902).
|
|
965
965
|
promptCacheKey: true,
|
|
966
|
+
// DashScope compatible-mode answers `400 developer is not one of ['system','assistant','user','tool','function']`
|
|
967
|
+
// (#5664, #8864). The native /v1/chat/completions passthrough folds only on an explicit record.
|
|
968
|
+
foldDeveloperRoleToSystem: true,
|
|
966
969
|
},
|
|
967
970
|
{
|
|
968
971
|
id: "alibaba-token-plan-intl",
|
|
@@ -1010,6 +1013,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1010
1013
|
noReasoningModels: ["kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "glm-5.1", "glm-5", "MiniMax-M2.5"],
|
|
1011
1014
|
modelDefaultReasoningEfforts: { ...Object.fromEntries(QWEN38_FAMILY.map(id => [id, "xhigh"])), "deepseek-v4.1-flash-1017": "high" },
|
|
1012
1015
|
promptCacheKey: true,
|
|
1016
|
+
// DashScope compatible-mode answers `400 developer is not one of ['system','assistant','user','tool','function']`
|
|
1017
|
+
// (#5664, #8864). The native /v1/chat/completions passthrough folds only on an explicit record.
|
|
1018
|
+
foldDeveloperRoleToSystem: true,
|
|
1013
1019
|
},
|
|
1014
1020
|
// NEEDS_HUMAN 2026-07-10: kept for config compatibility, but this is a dashboard URL,
|
|
1015
1021
|
// no /models endpoint is documented, and tools are silently ignored upstream per docs.parallel.ai.
|
|
@@ -1304,10 +1310,11 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1304
1310
|
preserveCustomDestination: true,
|
|
1305
1311
|
defaultModel: "gpt-5.6-terra",
|
|
1306
1312
|
// 261027 preemptive: GPT-6.1 Terra (OpenAI API limits; TokenLab listing unverified).
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1313
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra, same basis.
|
|
1314
|
+
models: ["gpt-5.6-terra", "gpt-6.1-terra", "gpt-6.2-sol", "gpt-6.2-astra"],
|
|
1315
|
+
modelContextWindows: { "gpt-5.6-terra": 1_050_000, "gpt-6.1-terra": 1_050_000, "gpt-6.2-sol": 1_050_000, "gpt-6.2-astra": 1_050_000 },
|
|
1316
|
+
modelMaxOutputTokens: { "gpt-5.6-terra": 128_000, "gpt-6.1-terra": 128_000, "gpt-6.2-sol": 128_000, "gpt-6.2-astra": 128_000 },
|
|
1317
|
+
modelInputModalities: { "gpt-5.6-terra": ["text", "image"], "gpt-6.1-terra": ["text", "image"], "gpt-6.2-sol": ["text", "image"], "gpt-6.2-astra": ["text", "image"] },
|
|
1311
1318
|
// Per-model wires from `tokenlab.accepted_request_formats` (GET /v1/models/{id}, 2026-09-30).
|
|
1312
1319
|
// The provider stays on Chat, the released and end-to-end verified path, and every model
|
|
1313
1320
|
// accepts it. Models that also declare Responses use it for Codex (Responses inbound) only,
|
|
@@ -1316,8 +1323,8 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1316
1323
|
// gemini-3.8-flash declares Chat + Gemini native and stays on Chat. No delivery-policy
|
|
1317
1324
|
// header is sent: the API key's own policy stays authoritative.
|
|
1318
1325
|
modelWireDefaults: Object.fromEntries([
|
|
1319
|
-
// 261027 preemptive: GPT-6.1 Terra (mirrors TokenLab's GPT-6.1 Sol wire).
|
|
1320
|
-
"gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "grok-4.7",
|
|
1326
|
+
// 261027 preemptive: GPT-6.1 Terra (mirrors TokenLab's GPT-6.1 Sol wire); 261118: GPT-6.2 likewise.
|
|
1327
|
+
"gpt-6-astra", "gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna", "grok-4.7",
|
|
1321
1328
|
"deepseek-v4.1-flash", "deepseek-v4-pro", "kimi-k3", "glm-5.3",
|
|
1322
1329
|
].map(id => [id, { wire: "openai-responses", inbound: ["responses"] }])),
|
|
1323
1330
|
modelDiscovery: {
|
|
@@ -1349,8 +1356,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1349
1356
|
preserveCustomDestination: true,
|
|
1350
1357
|
defaultModel: "glm-5.3-flash",
|
|
1351
1358
|
// 261027 preemptive: GPT-6.1 Terra (mirrors Modelflare's GPT-6.1 Sol seed; provider listing unverified).
|
|
1352
|
-
|
|
1353
|
-
|
|
1359
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra, same basis.
|
|
1360
|
+
models: ["glm-5.3-flash", "claude-sonnet-5-5", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6.2-sol", "gpt-6.2-astra", "deepseek-v4-flash"],
|
|
1361
|
+
note: "OpenAI-compatible relay for Claude, GPT, GLM and DeepSeek chat models. The original four seeded models were verified with chat, streaming and tool calls; GPT-6.1 Terra, GPT-6.2 Sol and GPT-6.2 Astra are preemptive seeds pending provider verification. deepseek-v4.1-flash is listed upstream but currently answers 503 and is left out. An ordinary key only reaches its own routing group's models; a Smart key reaches the verified seeded models. Image and video models are not served through this Chat preset. Upstream latency varies widely (a few seconds to about 30 s) with occasional transient 503s.",
|
|
1354
1362
|
},
|
|
1355
1363
|
{
|
|
1356
1364
|
// AI Stupid Level Smart Router, operated by S.C. Studio Platforms S.R.L. Contract checked
|
|
@@ -1548,7 +1556,7 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1548
1556
|
featured: false,
|
|
1549
1557
|
dashboardUrl: "https://github.com/settings/copilot",
|
|
1550
1558
|
liveModels: true,
|
|
1551
|
-
models: ["gpt-4o", "gpt-4.1", "gpt-4.1-mini", "claude-sonnet-4", "gemini-2.5-pro", "gpt-5-mini", "gpt-5.3-codex", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"],
|
|
1559
|
+
models: ["gpt-4o", "gpt-4.1", "gpt-4.1-mini", "claude-sonnet-4", "gemini-2.5-pro", "gpt-5-mini", "gpt-5.3-codex", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"],
|
|
1552
1560
|
defaultModel: "gpt-4o",
|
|
1553
1561
|
// Copilot fronts a mixed-wire catalog: these models reject /chat/completions for
|
|
1554
1562
|
// real Codex-agent traffic (function tools + reasoning), so every inbound wire
|
|
@@ -1572,6 +1580,9 @@ export const PROVIDER_REGISTRY_EXTENDED: readonly ProviderRegistryEntry[] = [
|
|
|
1572
1580
|
"gpt-6.1-sol": "openai-responses",
|
|
1573
1581
|
// GPT-6.1 Terra: GA in Copilot 2026-10-26; rides Responses like GPT-6.1 Sol.
|
|
1574
1582
|
"gpt-6.1-terra": "openai-responses",
|
|
1583
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra ride Responses like GPT-6.1 Sol (Copilot listing unverified).
|
|
1584
|
+
"gpt-6.2-sol": "openai-responses",
|
|
1585
|
+
"gpt-6.2-astra": "openai-responses",
|
|
1575
1586
|
"grok-4.5": "openai-responses",
|
|
1576
1587
|
"grok-4.6": "openai-responses",
|
|
1577
1588
|
"mai-code-1.1-flash": "openai-responses",
|
|
@@ -226,7 +226,8 @@ export const OPENAI_API_GPT56_REASONING_EFFORTS = ["low", "medium", "high", "xhi
|
|
|
226
226
|
* (https://developers.openai.com/api/docs/models/gpt-6.1-sol, checked 2026-09-30).
|
|
227
227
|
*/
|
|
228
228
|
// GPT-6.1 Terra (2026-10-26): same API limits; its none..max ladder is set per model.
|
|
229
|
-
|
|
229
|
+
// GPT-6.2 Sol and Astra publish the same API limits and disallow none.
|
|
230
|
+
export const OPENAI_GPT6_MODELS = ["gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"];
|
|
230
231
|
/*
|
|
231
232
|
* Meta Model API (https://api.meta.ai/v1) — published ladder, deliberately NOT the
|
|
232
233
|
* house set. dev.meta.ai/docs/reasoning lists "none", "minimal", "low", "medium",
|
|
@@ -334,6 +335,8 @@ export const OPENROUTER_GPT56_CONTEXT_WINDOWS = {
|
|
|
334
335
|
"openai/gpt-6-luna": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
335
336
|
// Live /api/v1/models on 2026-09-30: context_length 1,050,000, max_completion_tokens 128,000.
|
|
336
337
|
"openai/gpt-6.1-sol": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
338
|
+
"openai/gpt-6.2-sol": 1_050_000,
|
|
339
|
+
"openai/gpt-6.2-astra": 1_050_000,
|
|
337
340
|
// OpenRouter listing checked 2026-10-27: context_length 1,050,000.
|
|
338
341
|
"openai/gpt-6.1-terra": OPENROUTER_GPT56_CONTEXT_WINDOW,
|
|
339
342
|
};
|
|
@@ -43,6 +43,8 @@ export interface StaleContextWindowProjection {
|
|
|
43
43
|
* the degraded-mode figures, and live discovery supersedes them when it runs.
|
|
44
44
|
*/
|
|
45
45
|
export const STALE_CONTEXT_WINDOWS: readonly StaleContextWindow[] = [
|
|
46
|
+
// swe-2 shipped 262_000 (a stale vendor figure) before the measured 850_000 window.
|
|
47
|
+
{ provider: "devin", model: "swe-2", from: 262_000, to: 850_000 },
|
|
46
48
|
{ provider: "devin", model: "swe-1-7", from: 256_000, to: 262_000 },
|
|
47
49
|
{ provider: "devin", model: "swe-1-7-lightning", from: 256_000, to: 202_752 },
|
|
48
50
|
{ provider: "devin", model: "gpt-5-6-sol", from: 1_050_000, to: 1_000_000 },
|
|
@@ -8,10 +8,18 @@ export interface WorkBuddyCreditAmount {
|
|
|
8
8
|
export const WORKBUDDY_CREDIT_KINDS = ["plan_base", "plan_bonus", "addon", "benefit", "other"] as const;
|
|
9
9
|
export type WorkBuddyCreditKind = typeof WORKBUDDY_CREDIT_KINDS[number];
|
|
10
10
|
|
|
11
|
+
/** Plain decimal text (no sign or exponent) of a validated, bounded credit amount. */
|
|
12
|
+
export interface WorkBuddyExactCredits {
|
|
13
|
+
total: string;
|
|
14
|
+
remaining: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
/** Display-only credits; they are neither USD nor provider-wide model eligibility. */
|
|
12
18
|
export interface WorkBuddyCreditBalance extends WorkBuddyCreditAmount {
|
|
13
19
|
groups: Array<WorkBuddyCreditAmount & { kind: WorkBuddyCreditKind }>;
|
|
14
20
|
expiring?: { amount: number; at: number };
|
|
21
|
+
/** Optional exact companions of `total` and `remaining`; the numeric fields stay the contract. */
|
|
22
|
+
exact?: WorkBuddyExactCredits;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export function workBuddyRecord(value: unknown): Record<string, unknown> {
|
|
@@ -24,19 +32,69 @@ export function workBuddyCapacity(value: unknown): number | undefined {
|
|
|
24
32
|
return Number.isFinite(number) && number >= 0 && number <= Number.MAX_SAFE_INTEGER ? number : undefined;
|
|
25
33
|
}
|
|
26
34
|
|
|
35
|
+
interface Decimal { digits: bigint; scale: number }
|
|
36
|
+
|
|
37
|
+
const ZERO: Decimal = { digits: 0n, scale: 0 };
|
|
38
|
+
// Exact metadata bounds: balances above MAX_SAFE_INTEGER (16 digits) are already rejected.
|
|
39
|
+
const EXACT_TEXT = /^(\d{1,16})(?:\.(\d{1,32}))?$/;
|
|
40
|
+
const EXACT_SCALE = 32;
|
|
41
|
+
|
|
42
|
+
/** Decimal value of a number's shortest round-trip text, as the summed capacities always used. */
|
|
43
|
+
function numberDecimal(value: number): Decimal {
|
|
44
|
+
const [coefficient, exponent = "0"] = value.toString().split("e");
|
|
45
|
+
const [whole, fraction = ""] = coefficient!.split(".");
|
|
46
|
+
let digits = BigInt(`${whole}${fraction}`);
|
|
47
|
+
let scale = fraction.length - Number(exponent);
|
|
48
|
+
if (scale < 0) { digits *= 10n ** BigInt(-scale); scale = 0; }
|
|
49
|
+
return { digits, scale };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Bounded plain decimal text as digits and scale; signs, exponents and spaces are refused. */
|
|
53
|
+
function textDecimal(text: string): Decimal | undefined {
|
|
54
|
+
const match = EXACT_TEXT.exec(text);
|
|
55
|
+
return match ? { digits: BigInt(`${match[1]}${match[2] ?? ""}`), scale: match[2]?.length ?? 0 } : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Exact value of a validated capacity: quoted decimals keep their text, and numbers (already
|
|
60
|
+
* rounded by JSON.parse) use their shortest decimal. Values outside the bounds, such as subnormal
|
|
61
|
+
* numbers or long quoted fractions, have no exact form and leave only the numeric projection.
|
|
62
|
+
*/
|
|
63
|
+
function exactCapacity(value: unknown): Decimal | undefined {
|
|
64
|
+
if (workBuddyCapacity(value) === undefined) return undefined;
|
|
65
|
+
const decimal = typeof value === "string" ? textDecimal(value) : numberDecimal(value as number);
|
|
66
|
+
return decimal && decimal.scale <= EXACT_SCALE ? decimal : undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Exact sum, aligned to the largest scale among the values. */
|
|
70
|
+
function addDecimals(values: readonly Decimal[]): Decimal {
|
|
71
|
+
const scale = Math.max(0, ...values.map(value => value.scale));
|
|
72
|
+
return { digits: values.reduce((sum, value) => sum + value.digits * 10n ** BigInt(scale - value.scale), 0n), scale };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function decimalNumber(value: Decimal): number {
|
|
76
|
+
return Number(`${value.digits}e-${value.scale}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Canonical plain text without trailing fractional zeros; undefined outside the exact bounds. */
|
|
80
|
+
function decimalText(value: Decimal): string | undefined {
|
|
81
|
+
if (value.digits < 0n) return undefined;
|
|
82
|
+
let { digits, scale } = value;
|
|
83
|
+
while (scale > 0 && digits % 10n === 0n) { digits /= 10n; scale--; }
|
|
84
|
+
const raw = digits.toString().padStart(scale + 1, "0");
|
|
85
|
+
const text = scale ? `${raw.slice(0, -scale)}.${raw.slice(-scale)}` : raw;
|
|
86
|
+
return textDecimal(text) ? text : undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Exact `[numerator, denominator]` of bounded exact text, for display rounding. */
|
|
90
|
+
export function workBuddyExactRatio(text: string): [bigint, bigint] | undefined {
|
|
91
|
+
const value = textDecimal(text);
|
|
92
|
+
return value && [value.digits, 10n ** BigInt(value.scale)];
|
|
93
|
+
}
|
|
94
|
+
|
|
27
95
|
/** Sum bounded numeric capacities as decimals before converting the result back to a number. */
|
|
28
96
|
function sumCapacities(values: readonly number[]): number {
|
|
29
|
-
|
|
30
|
-
const [coefficient, exponent = "0"] = value.toString().split("e");
|
|
31
|
-
const [whole, fraction = ""] = coefficient!.split(".");
|
|
32
|
-
let digits = BigInt(`${whole}${fraction}`);
|
|
33
|
-
let scale = fraction.length - Number(exponent);
|
|
34
|
-
if (scale < 0) { digits *= 10n ** BigInt(-scale); scale = 0; }
|
|
35
|
-
return { digits, scale };
|
|
36
|
-
});
|
|
37
|
-
const scale = Math.max(0, ...parts.map(part => part.scale));
|
|
38
|
-
const digits = parts.reduce((sum, part) => sum + part.digits * 10n ** BigInt(scale - part.scale), 0n);
|
|
39
|
-
return Number(`${digits}e-${scale}`);
|
|
97
|
+
return decimalNumber(addDecimals(values.map(numberDecimal)));
|
|
40
98
|
}
|
|
41
99
|
|
|
42
100
|
function sumAmounts(rows: readonly WorkBuddyCreditAmount[]): WorkBuddyCreditAmount {
|
|
@@ -53,6 +111,29 @@ export function remainingWorkBuddyCredits(total: number, used: number, frozen =
|
|
|
53
111
|
return Math.max(0, sumCapacities([total, -used, -frozen]));
|
|
54
112
|
}
|
|
55
113
|
|
|
114
|
+
/** Exact remaining credits when the provider omits them, bounded below by zero. */
|
|
115
|
+
function exactRemaining(total: Decimal, used: Decimal, frozen: Decimal): Decimal {
|
|
116
|
+
const remaining = addDecimals([total, { ...used, digits: -used.digits }, { ...frozen, digits: -frozen.digits }]);
|
|
117
|
+
return remaining.digits < 0n ? ZERO : remaining;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Exact total/remaining for raw amounts, or undefined when any lacks a bounded exact form. */
|
|
121
|
+
export function workBuddyExactCredits(total: unknown, used: unknown): WorkBuddyExactCredits | undefined {
|
|
122
|
+
const exactTotal = exactCapacity(total), exactUsed = exactCapacity(used);
|
|
123
|
+
if (!exactTotal || !exactUsed) return undefined;
|
|
124
|
+
const totalText = decimalText(exactTotal), remainingText = decimalText(exactRemaining(exactTotal, exactUsed, ZERO));
|
|
125
|
+
return totalText !== undefined && remainingText !== undefined ? { total: totalText, remaining: remainingText } : undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Exact text must be bounded plain decimal text encoding the same numeric fields; null rejects. */
|
|
129
|
+
function exactCredits(value: unknown, balance: WorkBuddyCreditAmount): WorkBuddyExactCredits | undefined | null {
|
|
130
|
+
if (value === undefined) return undefined;
|
|
131
|
+
const row = workBuddyRecord(value), { total, remaining } = row;
|
|
132
|
+
if (Object.keys(row).length !== 2 || typeof total !== "string" || typeof remaining !== "string") return null;
|
|
133
|
+
if (!textDecimal(total) || !textDecimal(remaining)) return null;
|
|
134
|
+
return Number(total) === balance.total && Number(remaining) === balance.remaining ? { total, remaining } : null;
|
|
135
|
+
}
|
|
136
|
+
|
|
56
137
|
function amount(value: unknown): WorkBuddyCreditAmount | undefined {
|
|
57
138
|
const row = workBuddyRecord(value);
|
|
58
139
|
const total = workBuddyCapacity(row.total), used = workBuddyCapacity(row.used);
|
|
@@ -73,29 +154,57 @@ export function normalizeWorkBuddyCredits(value: unknown): WorkBuddyCreditBalanc
|
|
|
73
154
|
if (!quantities || !kind || seen.has(kind)) return undefined;
|
|
74
155
|
seen.add(kind); groups.push({ kind, ...quantities });
|
|
75
156
|
}
|
|
157
|
+
const exact = exactCredits(row.exact, balance);
|
|
158
|
+
if (exact === null) return undefined;
|
|
76
159
|
const expiring = workBuddyRecord(row.expiring), quantity = workBuddyCapacity(expiring.amount);
|
|
77
160
|
const at = typeof expiring.at === "number" && expiring.at > 0 && Number.isFinite(new Date(expiring.at).getTime()) ? expiring.at : undefined;
|
|
78
|
-
return { ...balance, groups, ...(
|
|
161
|
+
return { ...balance, groups, ...(exact ? { exact } : {}),
|
|
162
|
+
...(quantity !== undefined && quantity > 0 && at !== undefined ? { expiring: { amount: quantity, at } } : {}) };
|
|
79
163
|
}
|
|
80
164
|
|
|
81
|
-
|
|
165
|
+
interface PackageAmount extends WorkBuddyCreditAmount { exact?: { total: Decimal; remaining: Decimal } }
|
|
166
|
+
|
|
167
|
+
/** One summary package or credit group, with exact total/remaining when both have a bounded form. */
|
|
168
|
+
function packageAmount(row: Record<string, unknown>): PackageAmount | undefined {
|
|
82
169
|
const total = workBuddyCapacity(row.CycleTotalCapacity), used = workBuddyCapacity(row.CycleUsedCapacity);
|
|
83
170
|
const frozen = row.CycleFrozenCapacity === undefined ? 0 : workBuddyCapacity(row.CycleFrozenCapacity);
|
|
84
171
|
if (total === undefined || used === undefined || frozen === undefined) return undefined;
|
|
85
|
-
const
|
|
86
|
-
|
|
172
|
+
const estimated = row.CycleRemainCapacity === undefined;
|
|
173
|
+
const remaining = estimated ? remainingWorkBuddyCredits(total, used, frozen) : workBuddyCapacity(row.CycleRemainCapacity);
|
|
174
|
+
if (remaining === undefined) return undefined;
|
|
175
|
+
const exactTotal = exactCapacity(row.CycleTotalCapacity);
|
|
176
|
+
let exactLeft: Decimal | undefined;
|
|
177
|
+
if (!estimated) exactLeft = exactCapacity(row.CycleRemainCapacity);
|
|
178
|
+
else {
|
|
179
|
+
const exactUsed = exactCapacity(row.CycleUsedCapacity);
|
|
180
|
+
const exactFrozen = row.CycleFrozenCapacity === undefined ? ZERO : exactCapacity(row.CycleFrozenCapacity);
|
|
181
|
+
if (exactTotal && exactUsed && exactFrozen) exactLeft = exactRemaining(exactTotal, exactUsed, exactFrozen);
|
|
182
|
+
}
|
|
183
|
+
return { total, used, remaining, frozen, ...(exactTotal && exactLeft ? { exact: { total: exactTotal, remaining: exactLeft } } : {}) };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Exact package sums, present only when every package has bounded exact amounts. */
|
|
187
|
+
function sumExact(rows: readonly PackageAmount[]): WorkBuddyExactCredits | undefined {
|
|
188
|
+
if (rows.some(row => !row.exact)) return undefined;
|
|
189
|
+
const total = decimalText(addDecimals(rows.map(row => row.exact!.total)));
|
|
190
|
+
const remaining = decimalText(addDecimals(rows.map(row => row.exact!.remaining)));
|
|
191
|
+
return total !== undefined && remaining !== undefined ? { total, remaining } : undefined;
|
|
87
192
|
}
|
|
88
193
|
|
|
194
|
+
/** Balance from the resource summary: Packages summed once, CreditGroups as a breakdown. */
|
|
89
195
|
export function parseWorkBuddyCredits(value: unknown): WorkBuddyCreditBalance | undefined {
|
|
90
196
|
const summary = workBuddyRecord(value);
|
|
91
197
|
if (!Array.isArray(summary.Packages) || summary.Packages.length > 512) return undefined;
|
|
92
|
-
const packages:
|
|
198
|
+
const packages: PackageAmount[] = [];
|
|
93
199
|
for (const raw of summary.Packages) {
|
|
94
200
|
const quantities = packageAmount(workBuddyRecord(raw));
|
|
95
201
|
if (!quantities) return undefined;
|
|
96
202
|
packages.push(quantities);
|
|
97
203
|
}
|
|
98
204
|
const balance: WorkBuddyCreditBalance = { ...sumAmounts(packages), groups: [] };
|
|
205
|
+
const exact = sumExact(packages);
|
|
206
|
+
// The numeric fields are the nearest numbers to the exact sums, which normalization re-checks.
|
|
207
|
+
if (exact) Object.assign(balance, { total: Number(exact.total), remaining: Number(exact.remaining), exact });
|
|
99
208
|
// CreditGroups is a breakdown of Packages, not another balance to add to it.
|
|
100
209
|
if (Array.isArray(summary.CreditGroups) && summary.CreditGroups.length <= 16) {
|
|
101
210
|
const grouped = new Map<WorkBuddyCreditKind, WorkBuddyCreditAmount[]>();
|
|
@@ -215,8 +215,8 @@ export const passthroughMemoryCitationEscaper: MemoryCitationEscaper = {
|
|
|
215
215
|
*
|
|
216
216
|
* A tag can straddle delta boundaries, so a per-delta regex would miss the mention that matters
|
|
217
217
|
* most: the model writing the tag name one token at a time. The escaper buffers until it can tell
|
|
218
|
-
* a mention from a real block. A real block is emitted verbatim, tags included,
|
|
219
|
-
*
|
|
218
|
+
* a mention from a real block. A real block is emitted verbatim, tags included, once its closing
|
|
219
|
+
* tag and body prove it valid — the client keeps it, which is the whole point of the block.
|
|
220
220
|
* Everything else is a mention and gets `<`.
|
|
221
221
|
*/
|
|
222
222
|
export function createMemoryCitationEscaper(): MemoryCitationEscaper {
|
|
@@ -235,57 +235,60 @@ export function createMemoryCitationEscaper(): MemoryCitationEscaper {
|
|
|
235
235
|
held = "";
|
|
236
236
|
let out = "";
|
|
237
237
|
let i = 0;
|
|
238
|
+
// Ordinary text stays one input span, even when it contains many literal '<' characters.
|
|
239
|
+
// Flush that span only at a rewrite or hold boundary, rather than building one rope per '<'.
|
|
240
|
+
let literalStart = 0;
|
|
238
241
|
while (i < input.length) {
|
|
239
242
|
const next = input.indexOf("<", i);
|
|
240
|
-
if (next === -1)
|
|
241
|
-
out += input.slice(i);
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
out += input.slice(i, next);
|
|
245
|
-
// Look no further than one hold limit ahead: a real block never exceeds it, and slicing the
|
|
246
|
-
// whole remainder for every tag would make one large delta of many tags quadratic.
|
|
247
|
-
const tail = input.slice(next, next + MAX_MEMORY_CITATION_HOLD + 1);
|
|
243
|
+
if (next === -1) break;
|
|
248
244
|
const remaining = input.length - next;
|
|
249
|
-
if (
|
|
245
|
+
if (input.startsWith(MEMORY_CITATION_CLOSE, next)) {
|
|
250
246
|
// A close tag outside a claimed block is prose.
|
|
251
|
-
out += escapeClose;
|
|
247
|
+
out += input.slice(literalStart, next) + escapeClose;
|
|
252
248
|
i = next + MEMORY_CITATION_CLOSE.length;
|
|
249
|
+
literalStart = i;
|
|
253
250
|
continue;
|
|
254
251
|
}
|
|
255
|
-
if (!
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
if (!input.startsWith(MEMORY_CITATION_OPEN, next)) {
|
|
253
|
+
if (remaining < MEMORY_CITATION_CLOSE.length) {
|
|
254
|
+
const tail = input.slice(next);
|
|
255
|
+
if (MEMORY_CITATION_OPEN.startsWith(tail) || MEMORY_CITATION_CLOSE.startsWith(tail)) {
|
|
256
|
+
// A tag is still arriving.
|
|
257
|
+
held = tail;
|
|
258
|
+
return out + input.slice(literalStart, next);
|
|
259
|
+
}
|
|
260
260
|
}
|
|
261
|
-
out += "<";
|
|
262
261
|
i = next + 1;
|
|
263
262
|
continue;
|
|
264
263
|
}
|
|
264
|
+
// Only an opening-tag candidate needs a bounded body lookahead. Ordinary '<' characters
|
|
265
|
+
// above use offsets in the original string, without allocating a tail for every match.
|
|
266
|
+
const tail = input.slice(next, next + MAX_MEMORY_CITATION_HOLD + 1);
|
|
265
267
|
const afterOpen = tail.slice(MEMORY_CITATION_OPEN.length);
|
|
266
268
|
if (!bodyCouldBeReal(afterOpen)) {
|
|
267
|
-
out += escapeOpen;
|
|
269
|
+
out += input.slice(literalStart, next) + escapeOpen;
|
|
268
270
|
i = next + MEMORY_CITATION_OPEN.length;
|
|
271
|
+
literalStart = i;
|
|
269
272
|
continue;
|
|
270
273
|
}
|
|
271
274
|
const end = opensRealBlock(tail, 0);
|
|
272
275
|
if (end !== undefined) {
|
|
273
276
|
// A complete real block is released verbatim, both tags included, so the delta stream
|
|
274
277
|
// equals what `escapeMemoryCitationMentions` keeps in the final text.
|
|
275
|
-
out += tail.slice(0, end);
|
|
276
278
|
i = next + end;
|
|
277
279
|
continue;
|
|
278
280
|
}
|
|
279
281
|
if (!tail.includes(MEMORY_CITATION_CLOSE, MEMORY_CITATION_OPEN.length) && remaining <= MAX_MEMORY_CITATION_HOLD) {
|
|
280
282
|
// The block may still close; hold it whole.
|
|
281
283
|
held = tail;
|
|
282
|
-
return out;
|
|
284
|
+
return out + input.slice(literalStart, next);
|
|
283
285
|
}
|
|
284
286
|
// Closed without a valid body, or too large to keep holding: a mention.
|
|
285
|
-
out += escapeOpen;
|
|
287
|
+
out += input.slice(literalStart, next) + escapeOpen;
|
|
286
288
|
i = next + MEMORY_CITATION_OPEN.length;
|
|
289
|
+
literalStart = i;
|
|
287
290
|
}
|
|
288
|
-
return out;
|
|
291
|
+
return out + input.slice(literalStart);
|
|
289
292
|
},
|
|
290
293
|
pending(): string {
|
|
291
294
|
return held;
|