# CADCraft control protocol Start the desktop app with `--control PORT` (or `CADCRAFT_CONTROL_PORT=PORT`). It listens on `127.0.0.1:PORT` for JSON lines: one request per line, one reply per line. A port given with `--control` wins over the variable; a bare `--control` keeps the variable's port. ```json {"id": 1, "method": "cmdline.input", "params": {"text": "circle 0,0 5"}} {"id": 1, "ok": true, "result": {"prompt": "Command:", "output": ["Command: CIRCLE"], ...}} ``` Errors come back as `{"id": …, "ok": false, "error": "message"}`. An unknown method's error points to `control.methods`, which lists the methods the server answers. The server waits up to 60 s for the app to answer a request. After that it replies with a timeout, and `state` tells whether sending the request again is safe: - `{"id": …, "ok": false, "error": "timeout", "state": "not-run"}`: the app had not started the request. It is cancelled and will never run, so sending it again is safe. - `{"id": …, "ok": false, "error": "timeout", "state": "may-have-run"}`: the app had already started it. It may still finish and change the drawing, and its late result is discarded. Inspect the drawing (`drawing.inspect`) before sending it again. The table below describes top-level control-protocol methods: names for the request's `method` field. `engine.commands` returns a separate command catalog, not a list of additional methods. | Method | Params | What it does | |---|---|---| | `cmdline.input` | `{text}` | Type a line at the command line exactly like a user. Starts commands by name/alias and answers prompts (points `x,y`, `@dx,dy`, `@d