Files
openclaw/src/proxy-capture/blob-store.ts
Tak Hoffman 958c34e82c feat(qa-lab): Add proxy capture stack and QA Lab inspector (#64895)
* Add proxy capture core and CLI

* Expand transport capture coverage

* Add QA Lab capture backend

* Refine QA Lab capture UI

* Fix proxy capture review feedback

* Fix proxy run cleanup and TTS capture

* Fix proxy capture transport follow-ups

* Fix debug proxy CONNECT target parsing

* Harden QA Lab asset path containment
2026-04-11 12:34:57 -05:00

36 lines
1.0 KiB
TypeScript

import { createHash } from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { gzipSync, gunzipSync } from "node:zlib";
import type { CaptureBlobRecord } from "./types.js";
function ensureDir(dir: string) {
fs.mkdirSync(dir, { recursive: true });
}
export function writeCaptureBlob(params: {
blobDir: string;
data: Buffer;
contentType?: string;
}): CaptureBlobRecord {
ensureDir(params.blobDir);
const sha256 = createHash("sha256").update(params.data).digest("hex");
const blobId = sha256.slice(0, 24);
const outputPath = path.join(params.blobDir, `${blobId}.bin.gz`);
if (!fs.existsSync(outputPath)) {
fs.writeFileSync(outputPath, gzipSync(params.data));
}
return {
blobId,
path: outputPath,
encoding: "gzip",
sizeBytes: params.data.byteLength,
sha256,
...(params.contentType ? { contentType: params.contentType } : {}),
};
}
export function readCaptureBlobText(blobPath: string): string {
return gunzipSync(fs.readFileSync(blobPath)).toString("utf8");
}