| 37 | } |
| 38 | |
| 39 | export interface WorkspaceBackend { |
| 40 | // User-supplied selector. Passed in `ExecOptions.backend` and |
| 41 | // `Workspace.push(id)` / `Workspace.pull(id)` to address this |
| 42 | // backend. The Workspace constructor rejects duplicate ids. |
| 43 | // |
| 44 | // Each concrete backend constructor accepts an `id` option |
| 45 | // and defaults it to a sensible string when omitted: "test" |
| 46 | // for TestBackend, "container-shell" for the container |
| 47 | // backend, and "worker-shell" for the worker shell backend. Single-backend |
| 48 | // setups can ride the default and never touch the field. |
| 49 | readonly id: string; |
| 50 | |
| 51 | // Diagnostic kind of backend, fixed by the implementation |
| 52 | // ("test", "cloudflare-container", "worker-shell"). Used for |
| 53 | // tracing spans and stub-leak counters; not consumed by |
| 54 | // Workspace selection logic. |
| 55 | readonly type: string; |
| 56 | |
| 57 | // Whether the backend accepts a structured `input` value and |
| 58 | // returns a structured `result` value. Independent of the |
| 59 | // implementation kind: a shell backend that coerces JSON to |
| 60 | // argv/stdin and parses stdout back to a value can be callable |
| 61 | // too. Defaults to false when omitted. |
| 62 | readonly callable?: boolean; |
| 63 | |
| 64 | // Materialise a connection. Called lazily on first use, once |
| 65 | // per backend per workspace lifetime. The Workspace caches the |
| 66 | // resulting handle by `id`; subsequent exec / push / pull |
| 67 | // calls reuse it. The Workspace always passes its host bag; |
| 68 | // backends that reach the host through their own transport |
| 69 | // ignore it. |
| 70 | connect(host: WorkspaceBackendHost): Promise<BackendHandle>; |
| 71 | } |
| 72 | |
| 73 | export interface BackendHandle { |
| 74 | // The composite WorkspaceRPC stub pointing at the computerd |
no outgoing calls
no test coverage detected