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
import type { SqliteAdapter } from "./adapters/types";
/** Recover writes that can no longer block a body-export cursor. */
export function expirePendingCallLogDetails(db: SqliteAdapter, now: number = Date.now()): void {
db.prepare(
`UPDATE call_logs
SET detail_state = 'missing', detail_pending_until = NULL
WHERE detail_state = 'pending'
AND (detail_pending_until IS NULL OR detail_pending_until <= ?)`
).run(now);
}
/** Only a still-pending write may publish its artifact after expiry recovery. */
export function publishPendingCallLogDetail(
db: SqliteAdapter,
id: string,
artifact: { relPath: string; sizeBytes: number; sha256: string }
): boolean {
const result = db
.prepare(
`UPDATE call_logs
SET detail_state = 'ready', detail_pending_until = NULL,
artifact_relpath = ?, artifact_size_bytes = ?, artifact_sha256 = ?
WHERE id = ? AND detail_state = 'pending'
AND detail_pending_until > ?`
)
.run(artifact.relPath, artifact.sizeBytes, artifact.sha256, id, Date.now());
return result.changes === 1;
}
export function failPendingCallLogDetail(db: SqliteAdapter, id: string): void {
db.prepare(
`UPDATE call_logs SET detail_state = 'missing', detail_pending_until = NULL
WHERE id = ? AND detail_state = 'pending'`
).run(id);
}