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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* Conductor bridge persistence — SSE cursor (`last_event_id`) for the hub mirror.
*
* Uses the existing `key_value` table under a dedicated namespace (no migration
* needed — same pattern as settings.ts). The cursor lets the bridge resume the
* hub SSE from where it stopped; the hub replay covers the gap.
*/
import { getDbInstance } from "./core";
const NAMESPACE = "conductor";
const CURSOR_KEY = "last_event_id";
export function getConductorCursor(): string | null {
const db = getDbInstance();
const row = db
.prepare("SELECT value FROM key_value WHERE namespace = ? AND key = ?")
.get(NAMESPACE, CURSOR_KEY) as { value: string } | undefined;
if (!row) return null;
try {
const parsed = JSON.parse(row.value);
return typeof parsed === "string" ? parsed : null;
} catch {
return null;
}
}
export function setConductorCursor(value: string): void {
const db = getDbInstance();
db.prepare("INSERT OR REPLACE INTO key_value (namespace, key, value) VALUES (?, ?, ?)").run(
NAMESPACE,
CURSOR_KEY,
JSON.stringify(value)
);
}