Expand description
The code-mode worker process (a host binary started with its worker flag).
The code-mode worker: one restricted JavaScript execution in a process of
its own, on Boa, unchanged. A host binary becomes this process when it is
started with the hidden worker flag (BREP_mcp_core cad::code::worker_entry).
The host that starts this process owns it: it watches the process’s CPU
time, memory and age, and KILLS it — on an agent’s halt
(cad_code_cancel) or a limit — which stops any running script, however
it loops. Nothing in the host’s address space is reachable from the
script, and a killed worker leaves nothing behind but the CAD operations
it had already handed to the service.
Protocol, one JSON object per line:
- stdin, first line:
{"source", "sdk", "manifest"}— the program (an ES module withexport default async function main()), the@brep/cadmodule source, and the manifest identity as JSON text; - stdin, then:
{"reply": id, "body": text}— a host call’s answer; - stdout:
{"call": id, "method": m, "body": text}— a host call (the global__brep_host(method, body)the SDK uses, answered by a Promise);{"log": line}; and last{"done": {"ok": json}}or{"done": {"error": {"code", "message"}}}.
The only importable module is @brep/cad; there is no filesystem,
network, process, timer or environment binding.
The same protocol drives the browser’s code worker (a Web Worker running
this crate in the app’s wasm, messages in place of lines): Realm is the
event-driven core both share — Realm::begin runs the program until it
waits on the host or ends, Realm::answer delivers one host reply and
runs on. main is that core over stdin and stdout.
Structs§
- Realm
- One execution, driven by its host’s messages.
Functions§
- main
- Run one execution reading stdin and writing stdout; the process exits
after the
doneline.