File metadata
Attach string key-value metadata while writing a file. AgentBox stores it with the file and returns it from getInfo / get_info, list, and rename.
mjs
import { Sandbox } from "@abox-dev/sdk";
const sandbox = await Sandbox.create();
try {
await sandbox.files.write("/tmp/report.txt", "Quarterly report", {
metadata: { author: "alice", status: "draft" },
});
const info = await sandbox.files.getInfo("/tmp/report.txt");
console.log(info.metadata);
} finally {
await sandbox.kill();
}py
from agentbox import Sandbox
sandbox = Sandbox.create()
try:
sandbox.files.write(
"/tmp/report.txt",
"Quarterly report",
metadata={"author": "alice", "status": "draft"},
)
info = sandbox.files.get_info("/tmp/report.txt")
print(info.metadata)
finally:
sandbox.kill()Metadata has a few constraints:
- keys and values must contain printable US-ASCII characters;
- keys are converted to lowercase;
- writing a file again replaces its previous metadata;
- one metadata object applies to every file in a multi-file write.
Inside the sandbox, the values are available as user.agentbox.* extended attributes.