You cannot set these. They are detected, and they matter because they decide where a session is cached, whether an agent can run a command at all, and what the server is told about the caller.
env
| Value | Detected from |
|---|---|
| node | process.versions.node is a string |
| worker | the runtime identifies itself as a Cloudflare Worker |
| browser | window.document exists |
| unknown | none of the above matched |
The order matters: Node is tested first, then the worker, then the browser. So a bundler that shims process into a page makes that page answer node — and since env decides the session store, that is the first thing to read when caching behaves oddly in a bundled app.
console.log(api.env, api.framework, api.capabilities);
// "node" "next.js" { runtime: "node", shell: true, … } ← server
// "browser" "next.js" { runtime: "browser", shell: false, … } ← pageprint(api.env, api.framework, api.capabilities)
# "python" "python" {"runtime": "python", "shell": True, ...}capabilities
{
runtime: "node",
shell: true, // commands can be run here
filesystem: true, // files can be read and written here
persistentStorage: true, // a session survives a restart
http: true // always true
}{
"runtime": "python",
"shell": True, # commands can be run here
"filesystem": True, # files can be read and written here
"persistentStorage": True, # a session survives a restart
"http": True, # always True
}| Capability | node | browser | worker |
|---|---|---|---|
| shell | yes | no | no |
| filesystem | yes | no | no |
| persistentStorage | yes | yes | no |
| http | yes | yes | yes |
These describe the runtime, not a permission. Permission is a separate decision, made per call by your own callback — a runtime that can run commands still asks before it does. See Permissions.
What each one changes
| Capability | False means |
|---|---|
| shell | No bash tool, unless you supply a shell bridge. |
| filesystem | No workspace on this runtime; file tools need a files bridge. |
| persistentStorage | The session lives as long as the process, and is exchanged again after that. |
A bridge is how a runtime without a capability gets the behaviour anyway: the tool call is relayed to somewhere that can run it, and the answer comes back. That is exactly how a phone — no shell, no filesystem — still reads files and runs commands. See Bridges.
const tools = api.capabilities.shell
? api.tools.all
: api.tools.all.filter((name) => name !== "bash" && name !== "terminal");
const agent = api.agents.create({ runtime: "local", machine: pc, tools });tools = (
list(api.tools.all)
if api.capabilities["shell"]
else [name for name in api.tools.all if name not in ("bash", "terminal")]
)
agent = api.agents.create(runtime="local", machine=pc, model=model, tools=tools)framework
| Value | Detected from |
|---|---|
| next.js | the page carries Next's own globals |
| gatsby | the page carries Gatsby's global |
| vite | the module URL names Vite |
| browser | a page, and none of the above |
| node | there is no window at all |
Framework detection looks at the page. With no window — Node, and a Worker too — it answers node. Read env when you want the runtime; read framework only to learn which page framework is around you.
What of it reaches the server
The runtime and the framework travel with the key exchange, together with a machine id derived from the host's own name, platform, architecture and runtime version. Each later request carries that id and whatever resources could be detected.
| What is sent | Why it exists |
|---|---|
| runtime and framework | So a session can be told apart from another on the same account. |
| machine id | So one machine is recognised across restarts instead of registered twice. |
| detected resources | So a machine storage can report its own disk, CPU and GPU. |
Resource detection is best-effort and silent: anything it cannot read is simply absent, and nothing fails for it. The full list of headers, and how to print exactly what your process sends, is on Request headers.
Branching on it
if (!api.capabilities.persistentStorage) {
// Nothing is cached between runs: each one exchanges the key once.
// Supply a storage you control if you want the session to outlive the process.
}
if (api.env === "browser") {
// A real key must not be here. Call your own server instead.
}
if (api.env === "unknown") {
// An unrecognised runtime. HTTP works; assume nothing else does.
}if not api.capabilities["persistentStorage"]:
# Nothing is cached between runs: each one exchanges the key once.
# Supply a storage you control if you want the session to outlive the process.
pass
# A Python process is always a server or a script: a real key belongs here,
# never in the browser pages it serves.