Run Artifacts

View as Markdown

Artifacts are durable outputs attached to a run. Browser downloads, screenshots, reports, recordings, and collected runtime files appear here when BCTRL can observe or capture them.

Use runtime.currentRun() to reach the active run, then list artifacts from the run.

1const run = await runtime.currentRun();
2
3const { artifacts, nextCursor } = await run.artifacts.list({
4 kind: ["download", "screenshot"],
5 limit: 100,
6});
7
8for (const artifact of artifacts) {
9 console.log(artifact.kind, artifact.name, artifact.path, artifact.sizeBytes);
10}

Artifacts are returned newest first. Use nextCursor to page through older artifacts.

Download an artifact

1const artifact = artifacts[0];
2
3if (!artifact?.downloadUrl) {
4 throw new Error("No downloadable artifact found");
5}
6
7const response = await fetch(artifact.downloadUrl, {
8 headers: {
9 Authorization: `Bearer ${process.env.BCTRL_API_KEY}`,
10 },
11});
12
13const bytes = Buffer.from(await response.arrayBuffer());

downloadUrl is authenticated by your BCTRL API key. Treat it as opaque.

Artifact shape

1type RunArtifact = {
2 id: string;
3 runId: string;
4 runtimeId: string;
5 runtimeKind: "browser" | "desktop" | "spreadsheet";
6 kind: string;
7 name: string;
8 fileId: string;
9 path: string;
10 contentType: string;
11 sizeBytes: number;
12 createdAt: string;
13 downloadUrl?: string;
14};

fileId points at the durable storage file behind the artifact. path is the artifact path presented for this run.

HTTP equivalent

1GET /v1/runs/{runId}/artifacts?kind=download&limit=100