Dashboard › opencode › Distillation
e7134e79-d7b5-4b86-8288-20cc6f49e385["lore_tm_v1_jacKOCMhhglEARksH1XWCgcnS5dZ17SW3Z8RoBmdlDY","lore_tm_v1_OxkAmGUOlsk7HEnZALXMMmAcjc9rIAchyOzUOyQk0sE","lore_tm_v1_KhumIRQbw5SvgcAzG9M7avCBuY_C0lU1gTqOhTfdbiQ","lore_tm_v1_tez-fBQn5KfWkz2CbhpljrLyYnnP9O2QW4OqoH5lmiU"]
🔴 (09:53) packages/core/test/fetch-interceptor-body.test.ts defines OpenAI Responses detection markers: an input array, max_output_tokens, or previous_response_id; an input array takes precedence even when messages is also present.
🔴 (09:53) detectProtocolFromBody() intentionally does not use ambiguous store or instructions fields as OpenAI Responses markers; bodies containing model + messages with either store or instructions remain classified as openai.
🔴 (09:53) Anthropic body detection requires model, a top-level system field, and a messages array; system may be a string or array. A Claude-model body with messages but no system falls back to openai.
🔴 (09:53) OpenAI body detection is the fallback for model + a messages array and tolerates extra fields such as temperature: 0.7.
🔴 (09:53) detectProtocolFromBody() returns null for {}, missing model, non-array messages, prompt-based bodies such as { model: "gpt-4", prompt: "" }, invalid JSON, null, and top-level arrays.
🔴 (09:53) packages/core/test/fetch-interceptor-paths.test.ts additionally verifies interception of /v1/messages/foo, /api/v1/messages, /api/v1/responses, /api/chat/completions, /api/messages, /openai/v1/chat/completions, /anthropic/v1/messages, and /codex/responses on non-ChatGPT hosts.
🔴 (09:53) shouldIntercept() intentionally excludes metadata and unsupported endpoints including /health, /v1/models, /v1/embeddings, and /api/foo/embeddings; malformed URLs and the empty string return false without throwing.
🔴 (09:54) packages/core/test/fetch-interceptor-global.test.ts uses ORIGINAL_FETCH_KEY = Symbol.for("lore.fetchInterceptor.originalFetch") to inspect and clear the process-global original-fetch slot.
🔴 (09:54) User required the shared original-fetch slot to hold the real pre-install fetch, never the installed interceptor; a self-referential interceptor handle would cause request loops.
🔴 (09:54) The shared-slot regression tests reference issues #1027 and #1107 and simulate two independent @loreai/core module instances using vi.resetModules() plus dynamic imports.
🔴 (09:54) Cross-copy installation invariant: module copy A installs the interceptor and stores trueOriginal; module copy B must see the shared slot, avoid re-patching globalThis.fetch, and leave the slot untouched.
🔴 (09:54) Cross-copy cleanup ownership invariant: when copy B’s installation no-ops, its returned cleanup must also be a no-op; only copy A’s cleanup may restore globalThis.fetch and clear the shared slot.
🔴 (09:54) Search for fetch-interceptor/routing references found exactly 25 matches. Relevant locations include packages/core/src/index.ts:359, packages/core/src/fetch-interceptor.ts:403,417,514,538,549, packages/gateway/script/bundle.ts:143,150, packages/gateway/src/pipeline.ts:5086,5121,5124,6211,6390,14247,14250, and packages/gateway/test/bundle-exports.test.ts:206.