refactor(proxy): store captures in shared state database

This commit is contained in:
Vincent Koc
2026-06-17 06:46:53 +02:00
parent 88bc08c124
commit 0876ed59e0
19 changed files with 391 additions and 532 deletions

View File

@@ -39,8 +39,7 @@ vi.mock("../infra/net/proxy/proxy-validation.js", () => ({
describe("proxy cli runtime", () => {
const envKeys = [
"OPENCLAW_DEBUG_PROXY_DB_PATH",
"OPENCLAW_DEBUG_PROXY_BLOB_DIR",
"OPENCLAW_STATE_DIR",
"OPENCLAW_DEBUG_PROXY_CERT_DIR",
"OPENCLAW_DEBUG_PROXY_SESSION_ID",
"OPENCLAW_DEBUG_PROXY_ENABLED",
@@ -52,8 +51,7 @@ describe("proxy cli runtime", () => {
beforeEach(() => {
tempDir = mkdtempSync(path.join(os.tmpdir(), "openclaw-proxy-cli-runtime-"));
process.env.OPENCLAW_DEBUG_PROXY_DB_PATH = path.join(tempDir, "capture.sqlite");
process.env.OPENCLAW_DEBUG_PROXY_BLOB_DIR = path.join(tempDir, "blobs");
process.env.OPENCLAW_STATE_DIR = tempDir;
process.env.OPENCLAW_DEBUG_PROXY_CERT_DIR = path.join(tempDir, "certs");
delete process.env.OPENCLAW_DEBUG_PROXY_ENABLED;
delete process.env.OPENCLAW_DEBUG_PROXY_SESSION_ID;
@@ -92,7 +90,9 @@ describe("proxy cli runtime", () => {
afterEach(async () => {
const { closeDebugProxyCaptureStore } = await import("../proxy-capture/store.sqlite.js");
const { closeOpenClawStateDatabaseForTest } = await import("../state/openclaw-state-db.js");
closeDebugProxyCaptureStore();
closeOpenClawStateDatabaseForTest();
vi.restoreAllMocks();
vi.resetModules();
process.exitCode = undefined;
@@ -503,10 +503,7 @@ describe("proxy cli runtime", () => {
expect(serverStopSpy).toHaveBeenCalledTimes(1);
const store = getDebugProxyCaptureStore(
process.env.OPENCLAW_DEBUG_PROXY_DB_PATH!,
process.env.OPENCLAW_DEBUG_PROXY_BLOB_DIR!,
);
const store = getDebugProxyCaptureStore();
const [session] = store.listSessions(5);
expect(session?.mode).toBe("proxy-run");
expect(session?.endedAt).toBeGreaterThanOrEqual(beforeRun);