cloudflare / cloudflare/computer

Expose backend discovery/capabilities for workspace.runtime.exec

Open
#50 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
9.2k
Forks
513
Avg merge
3d 8h
Merged PRs (30d)
24

Description

I was reading through the README and trying to think about how an agent would safely choose between registered backends. `workspace.runtime.exec(source, { backend })` is a nice single entry point, but the README notes that the selected backend determines whether `source` is a shell command or an ECMAScript module.

From the caller's perspective, it looks like you need to already know that one backend ID is shell-like and another is JS-like. If a Workspace has multiple backends registered, there doesn't seem to be a documented way to ask the runtime what backends exist, whether they're connected/lazy, or what kind of source/result they accept.

This becomes a papercut when the caller is an agent or a generic UI: it can easily pick a backend ID and pass the wrong source type, then fail only when the backend connects/executes. A small introspection API would make this much easier to use, something like:

```ts
const backends = await workspace.runtime.listBackends();
// [{ id: 'container', kind: 'shell', ready: false }, { id: 'js', kind: 'module', ready: true }]
```

or even just:

```ts
const info = await workspace.runtime.describeBackend('container');
if (info.source === 'shell') { ... }
```

That would also give a natural place to expose backend-specific limits later, such as network access, filesystem write access, or allowed imports, without changing `exec` itself. If this already exists somewhere, it might be worth calling it out in the README because it's key to using multiple backends safely.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.