Rigwell 0.6.1 ยท Documentation

Clients: SDK, WebSocket and TUI

SDK (src/sdk/index.ts)

import { run, createSession, connectToDaemon } from "./src/sdk/index.ts";

const cwd = process.cwd();
const r = await run(
  "Explain how this project runs its tests. Read files only and do not edit or run commands.",
  { cwd, autonomyLevel: "off" },
);
console.log(r.text);

const s = await createSession({ cwd, autonomyLevel: "off" });   // spawns `rigwell exec` (stream-jsonrpc)
for await (const n of s.send("hello")) { /* notifications up to and including agent_turn_completed */ }
await s.send("and then?").done;                                                       // { reason, text, ... }
await s.interrupt(); await s.updateSettings({ autonomyLevel: "medium" }); await s.close();

const d = await connectToDaemon({ url: "ws://127.0.0.1:47822/" });                    // token from daemon.json, or pass `token`
const u = await connectToDaemon({ socketPath: "/path/to/daemon.sock" });              // Unix socket

onPermission, onAskUser, onTrust and onPickOptions answer the harness-to-client requests. Defaults when missing or throwing: cancel (onTrust: the folder stays untrusted). onTrust gets {cwd, unlocks} when a folder with project config (hooks, skills, AGENTS.md, MCP servers) is not trusted yet and returns true/false or {trust, remember}; a yes is saved in trustedFolders by the harness. With resumeSessionId, prompts the session still waits on (pendingPermissions, pendingAskUserRequests) are shown to onPermission / onAskUser again and answered through rigwell.answer_request. If you supply a permission handler, show the approver the requested tools and arguments. Return the exact option they chose from req.options. Return { selectedOption: "cancel" } when they decline, the choice is unavailable, or no approver is present. proceed_once approves the specific pending request. This includes pending Workstream proposal approvals since 0.4.1 while the same daemon Session remains alive. Request IDs remain bound to that pending request; cancellation or resolution invalidates late answers. See examples/sdk-multi-turn.ts.

Daemon WebSocket

rigwell daemon also listens on ws://127.0.0.1:47822/ (--ws-port <n>, --no-ws, or daemon.wsPort in settings). Each connection is one session; each text frame is one JSON-RPC message (same envelope and rigwell. methods as stdio). A token is required: ?token=<t> or Authorization: Bearer <t>. The token is random per daemon start and is stored with the socket path and URL in $RIGWELL_HOME/daemon.json (mode 0600). Wrong or missing token: HTTP 401. Non-loopback Host: 403.

TUI

rigwell or rigwell tui [--auto low|medium|high] [-m model] [--use-spec] [--cwd dir] runs an in-process session. --daemon, --socket <path> or --url ws://... [--token t] attach to a running daemon instead. Type /help for keys and commands.

The TUI and the desktop app show the harness's trust question (a panel / the folder trust dialog), the AskUser question, and any prompt a resumed session still waits on.