Storage

View as Markdown

BCTRL has two file surfaces:

  • Space storage stores durable files scoped to a space.
  • Runtime files move files into or out of a live runtime.

Space storage

Use space storage for reusable inputs and durable outputs.

1const uploaded = await space.storage.files.upload(csvBuffer, {
2 path: "inputs/accounts.csv",
3 contentType: "text/csv",
4});
5
6const { files } = await space.storage.files.list({
7 prefix: "inputs/",
8});

Runtime files

Use runtime files when a browser or agent needs a real file path inside the live runtime.

1const staged = await runtime.files.stage({
2 fileId: uploaded.id,
3});
4
5console.log(staged.path);

Collect a runtime-local file back into storage.

1const collected = await runtime.files.collect({
2 path: "/tmp/export.csv",
3 storagePath: "outputs/export.csv",
4});

Artifacts

When collected or captured files are outputs of a run, read them through run artifacts.

1const run = await runtime.currentRun();
2const { artifacts } = await run.artifacts.list();