Implement claw.md in Go: goclaw/.
Structure as Go API and then a cmd goclaw that exposes that that API
via HTTP.
Any program should be able to use the Go API.
Persistence based on SQLite.
Start the (long-lived process): goclaw serve.
goclaw server starts an HTTP server. The primary endpoint is just
/do, which reads JSON payload that describes the operation request.
Supported operations are all of the the pi-level and claw-level
operations described in claw.md.
The /doc endpoint returns a detailed Markdown string that describes
everything that this thing can do. It's a user's guide for an agent
that wants to use the service.
The serve subcommand has these optional args:
--model MODELlike--model openai/gpt-5:online(and that's the default).--model-provider PROVIDERlike--model-provider openrouter(and that's the default).--listen PORTdefaulting to:8000.
The only tool available to LLMs is bash. Args:
scriptstring to executetimeoutin seconds or Go duration (optional)stdoutLineEvent: optional object template and bus for publishing a line written tostdoutstderrLineEvent: optional object template and bus to send lines written tostderrexitEvent: optional template and bus for ending exit code.timeoutEvent: optional template and bus for sending Boolean indicating if the task timed out.
An object template is just an object that somewhere has a value
{payload}. That value is replaced by desired output.
The bash tool result has the following properties:
stdout: stringstderr: stringexitCode: inttimeout: Boolean
bash execution is synchronous to the caller. However, internally
stdout, stderr, etc are monitored if those events are specified in
the input args. When such an event arrives, it's it published via
out. The bus defaults to thebus.
start_session takes bus so that session events can be published.
LLM I/O is via openai "responses" with streaming. For now, only tool
call streaming events are processed. Each is published via an out
call to the session's bus.
Implement the event bus from scratch, but this code should be inspired
directly by fyi-ace/.