@@ -79,6 +79,62 @@ describe("DebugProxyCaptureStore", () => {
|
79 | 79 | second.release(); |
80 | 80 | }); |
81 | 81 | |
| 82 | +it("preserves the shipped path-based Plugin SDK overloads", () => { |
| 83 | +const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-proxy-capture-legacy-sdk-")); |
| 84 | +cleanupDirs.push(root); |
| 85 | +const dbPath = path.join(root, "capture.sqlite"); |
| 86 | +const blobDir = path.join(root, "blobs"); |
| 87 | +const lease = acquireDebugProxyCaptureStore(dbPath, blobDir); |
| 88 | + |
| 89 | +expect(getDebugProxyCaptureStore(dbPath, blobDir)).toBe(lease.store); |
| 90 | +lease.store.upsertSession({ |
| 91 | +id: "legacy-sdk-session", |
| 92 | +startedAt: 1, |
| 93 | +mode: "sdk", |
| 94 | +sourceScope: "openclaw", |
| 95 | +sourceProcess: "plugin", |
| 96 | + dbPath, |
| 97 | + blobDir, |
| 98 | +}); |
| 99 | +const blob = lease.store.persistPayload(Buffer.from("legacy sdk payload"), "text/plain"); |
| 100 | +lease.store.recordEvent({ |
| 101 | +sessionId: "legacy-sdk-session", |
| 102 | +ts: 2, |
| 103 | +sourceScope: "openclaw", |
| 104 | +sourceProcess: "plugin", |
| 105 | +protocol: "https", |
| 106 | +direction: "outbound", |
| 107 | +kind: "request", |
| 108 | +flowId: "legacy-sdk-flow", |
| 109 | +dataBlobId: blob.blobId, |
| 110 | +dataSha256: blob.sha256, |
| 111 | +}); |
| 112 | + |
| 113 | +expect(lease.store.readBlob(blob.blobId)).toBe("legacy sdk payload"); |
| 114 | +expect(blob.path).toBe(path.join(blobDir, `${blob.blobId}.bin.gz`)); |
| 115 | +expect(fs.existsSync(dbPath)).toBe(true); |
| 116 | +expect(fs.existsSync(blob.path ?? "")).toBe(true); |
| 117 | +expect( |
| 118 | +lease.store.db |
| 119 | +.prepare("SELECT db_path AS dbPath, blob_dir AS blobDir FROM capture_sessions WHERE id = ?") |
| 120 | +.get("legacy-sdk-session"), |
| 121 | +).toEqual({ dbPath, blobDir }); |
| 122 | +expect( |
| 123 | +lease.store.db |
| 124 | +.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'capture_blobs'") |
| 125 | +.get(), |
| 126 | +).toBeUndefined(); |
| 127 | +expect(lease.store.deleteSessions(["legacy-sdk-session"])).toEqual({ |
| 128 | +sessions: 1, |
| 129 | +events: 1, |
| 130 | +blobs: 1, |
| 131 | +}); |
| 132 | +expect(fs.existsSync(blob.path ?? "")).toBe(false); |
| 133 | + |
| 134 | +lease.release(); |
| 135 | +expect(lease.store.isClosed).toBe(true); |
| 136 | +}); |
| 137 | + |
82 | 138 | it("uses rollback journaling for captures on NFS-backed volumes", () => { |
83 | 139 | vi.spyOn(fs, "statfsSync").mockReturnValue({ |
84 | 140 | type: 0x6969, |
|