mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 06:02:14 +03:00
* docs(compression): Phase 3 per-request header design spec Approved brainstorming output for the x-omniroute-compression header: header-first precedence, name-first combo matching (Decision A), explicit value bypasses auto-trigger (Decision B), DerivedPlan.source, and the X-OmniRoute-Compression response header. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(compression): Phase 3 per-request header implementation plan 4-task TDD plan (resolver header-first + source, parser, chatCore wiring + response header, docs/file-size) with full code and exact commands. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(compression): header-first resolver + plan source (Phase 3 core) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(compression): resolveCompressionHeader parser (Phase 3) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(compression): wire x-omniroute-compression header + response header (Phase 3) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(compression): extract plan-resolution leaf (planResolution.ts) under size cap (Phase 3) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(compression): document x-omniroute-compression header (Phase 3) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(compression): harden named-combo map + trim engine: header id (Phase 3 review) Addresses gemini-code-assist review on #4645: - Extract buildNamedComboLookup (pure) so a blank/whitespace/null combo name contributes only its id key (no '' key, no throw that disables all combos). - Trim the engine:<id> header value so 'engine: rtk' resolves. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Diego Rodrigues de Sa e Souza <diego.souza@cdwasolutions.com.br> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Diego Rodrigues de Sa e Souza <souzamiriamrodrigues790@gmail.com>
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { deriveDefaultPlan, type DerivedPlan } from "./deriveDefaultPlan.ts";
|
|
|
|
export interface ResolveCtx {
|
|
comboId?: string | null;
|
|
combos?: Record<string, Array<{ engine: string; intensity?: string }>>; // named combo pipelines by id
|
|
}
|
|
|
|
export function resolveCompressionPlan(config: any, ctx: ResolveCtx): DerivedPlan {
|
|
if (config?.enabled === false) return { mode: "off", stackedPipeline: [] };
|
|
|
|
// routing-combo override
|
|
const ov = ctx.comboId ? config?.comboOverrides?.[ctx.comboId] : undefined;
|
|
if (ov) return modeToPlan(ov, config);
|
|
|
|
// active named combo
|
|
if (config?.activeComboId && ctx.combos?.[config.activeComboId]) {
|
|
return { mode: "stacked", stackedPipeline: ctx.combos[config.activeComboId] };
|
|
}
|
|
|
|
// derived default
|
|
return deriveDefaultPlan(config?.engines ?? {}, config?.enabled !== false);
|
|
}
|
|
|
|
function modeToPlan(mode: string, config: any): DerivedPlan {
|
|
return mode === "stacked"
|
|
? { mode: "stacked", stackedPipeline: config?.stackedPipeline ?? [] }
|
|
: { mode, stackedPipeline: [] };
|
|
}
|