mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 12:22:34 +03:00
* feat(chaos+ponytail): parallel chaos-mode dispatch + ponytail output style (rebased on v3.8.49)
- Chaos mode: new auto/chaos variant fans the prompt out to the top-N
stable models in parallel and returns a single merged SSE stream.
- Progressive streaming: each panel model's answer is enqueued as it
lands (omni-chaos-part event), instead of awaiting the whole panel.
- withTimeout now aborts the underlying request (modelAbortSignal) on
timeout so the connection is released, not leaked.
- concatSseText parses both OpenAI and Anthropic SSE wire formats.
- autoPrefix/modePacks add the chaos-mode weight pack; virtualFactory
materializes auto/chaos with fusion strategy + chaos config flag.
- Ponytail (lazy-senior-dev mode) integrated into the existing
OUTPUT_STYLE_CATALOG registry (id 'ponytail') so it rides the production
output-style injector, instead of a bespoke duplicate module. Dev-only
scripts and the duplicate ponytail/ module are removed.
- Tests: chaosEngine/chaosVirtualCombo cover panel dispatch, progressive
broadcast, timeout abort, and Anthropic parsing; autoCombo pack count
updated to 6.
Rebased onto release/v3.8.49 (no provider-registry or validation changes —
those are split out per review).
* fix(combo): align chaos dispatch callback with ChaosTarget signature
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
* fix(combo): extract chaos dispatch to chaosEngine.ts to fix combo.ts file-size gate
combo.ts's chaos-detection block pushed the frozen file-size gate over its
cap (3387 lines) after merging release/v3.8.49. Extracted the config
detection + model-list building into dispatchChaosFromCombo() in
chaosEngine.ts (the module this PR already introduces), mirroring the
existing fusion-strategy short-circuit pattern. combo.ts now does a 9-line
early-return; no behavior change.
combo.ts: 3406 -> 3386 lines (frozen cap 3387).
handleComboChat complexity/cognitive/lines all decrease as a side effect
(120->118 / 153->152 / 1541->1524) since the block moved out.
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
---------
Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
Co-authored-by: Moseyuh333 <Moseyuh333@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
export type AutoVariant = "coding" | "fast" | "cheap" | "offline" | "smart" | "lkgp" | "chaos";
|
|
|
|
export interface AutoPrefixParseResult {
|
|
valid: boolean;
|
|
variant?: AutoVariant;
|
|
error?: string;
|
|
}
|
|
|
|
export const VALID_VARIANTS: AutoVariant[] = [
|
|
"coding",
|
|
"fast",
|
|
"cheap",
|
|
"offline",
|
|
"smart",
|
|
"lkgp",
|
|
"chaos",
|
|
];
|
|
|
|
/**
|
|
* Parses a model name to determine if it's an auto-prefixed model and extracts the variant.
|
|
*
|
|
* Examples:
|
|
* - "auto" -> { valid: true, variant: undefined } (default)
|
|
* - "auto/coding" -> { valid: true, variant: "coding" }
|
|
* - "auto/lkgp" -> { valid: true, variant: "lkgp" }
|
|
* - "auto/" -> { valid: true, variant: undefined } (default)
|
|
* - "autocoding" -> { valid: false, error: "Invalid auto prefix format" }
|
|
* - "otherModel" -> { valid: false, error: "Not an auto-prefixed model" }
|
|
*/
|
|
export function parseAutoPrefix(model: string | null | undefined): AutoPrefixParseResult {
|
|
// Guard against null/undefined (called with non-string inputs)
|
|
if (typeof model !== "string") {
|
|
return { valid: false, error: "Not an auto-prefixed model" };
|
|
}
|
|
if (!model.startsWith("auto")) {
|
|
return { valid: false, error: "Not an auto-prefixed model" };
|
|
}
|
|
|
|
const parts = model.split("/");
|
|
|
|
if (parts.length === 1) {
|
|
if (parts[0] === "auto") {
|
|
return { valid: true, variant: undefined }; // Default auto
|
|
} else {
|
|
return { valid: false, error: "Invalid auto prefix format" };
|
|
}
|
|
}
|
|
|
|
if (parts.length === 2) {
|
|
if (parts[0] !== "auto") {
|
|
return { valid: false, error: "Invalid auto prefix format" };
|
|
}
|
|
const variantStr: string = parts[1];
|
|
if (variantStr === "" || VALID_VARIANTS.includes(variantStr as AutoVariant)) {
|
|
return { valid: true, variant: variantStr === "" ? undefined : (variantStr as AutoVariant) };
|
|
} else {
|
|
return { valid: false, error: `Invalid auto variant: ${variantStr}` };
|
|
}
|
|
}
|
|
|
|
return { valid: false, error: "Invalid auto prefix format" };
|
|
}
|