# 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. ```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"}`. 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. | 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