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

1.0 KB
Raw Blame
import { registerBuiltinCompressionEngines } from "./index.ts";
import { getCompressionEngine } from "./registry.ts";
import type { CompressionEngineApplyOptions } from "./types.ts";
import type { CompressionResult } from "../types.ts";

/**
 * Single-mode resolution for the async-only "omniglyph" engine. Selecting the
 * "omniglyph" mode IS the enable signal — run it alone, same pattern as the
 * "rtk" single mode. (B-MODE-ENGINE-DECOUPLE)
 *
 * Kept out of strategySelector's runCompressionAsync so the dispatcher stays
 * under the complexity gate; this helper owns the registry lookup + the
 * fail-safe pass-through when the engine (or its async entry) is unavailable.
 */
export async function applyOmniglyphSingleMode(
  body: Record<string, unknown>,
  options?: CompressionEngineApplyOptions
): Promise<CompressionResult> {
  registerBuiltinCompressionEngines();
  const engine = getCompressionEngine("omniglyph");
  if (!engine?.applyAsync) return { body, compressed: false, stats: null };
  return engine.applyAsync(body, options);
}