Skip to main content

Module serve

Module serve 

Source
Expand description

A line-oriented server: one shell, many commands.

Requests are JSON objects on stdin, one per line; responses are JSON on stdout, one per line, echoing the request’s id. This is the shape a coding agent’s tool harness wants: shell state that survives between tool calls, and checkpoints it can rewind to.

{"id":1,"op":"run","script":"cd /tmp; pwd"}
{"id":2,"op":"snapshot","key":"before-build"}
{"id":3,"op":"branch","scripts":["npm test","pnpm test"]}
{"id":4,"op":"restore","snapshot":"before-build"}
{"id":5,"op":"shutdown"}

Functions§

run
Runs the server until shutdown or end of input.