Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

948 B
Raw Blame
/**
 * Shared combo data-normalization helpers extracted from combo.ts.
 *
 * Tiny side-effect-free guards/normalizers that several combo submodules depend
 * on (shadow routing, combo structure resolution) plus combo.ts itself. Moving
 * them to this leaf module out of the combo.ts god-file (Quality Gate v2 /
 * Fase 9) lets the submodules import them without reaching back into the barrel
 * (no cycles). Logic unchanged; combo.ts imports them back for compatibility.
 */

import type { ResolvedComboTarget } from "./types.ts";

export function isRecord(value: unknown): value is Record<string, unknown> {
  return !!value && typeof value === "object" && !Array.isArray(value);
}

export function dedupeTargetsByExecutionKey(targets: ResolvedComboTarget[]) {
  const seen = new Set<string>();
  return targets.filter((target) => {
    if (seen.has(target.executionKey)) return false;
    seen.add(target.executionKey);
    return true;
  });
}