feat(claw): the scoped agent token and the client-tool routes
The claw is the server half of the client tools. The middleware now knows two bearer classes: the human token answers every /v1 route as before; the agent token answers only the routes the contract allowlists, and only with the contract header at the matching version — consents, sessions, ingest, and the phones answer it 403, so a model holding the token cannot prompt-inject its way past the scoping to answer its own secret asks. Boot refuses the configuration where agent_token is the human token: the scoping is the safety, and one value playing both roles silently unscopes everything the shell holds. Three new routes write the tables the resident already reads: push to the notification queue, schedule and cancel tasks the resident's tick fires — the tools get native-shaped writes without the daemon growing a second brain. A JSON fallback gives the one error shape everywhere, unknown routes included. The daemon composes the tools' environment (RHEMA_URL, RHEMA_TOKEN, the tools' bin dir on PATH) and hands it to the resident's shell through the agent-tools env layer; with no agent_token it provisions nothing, exactly as before. The proof is the contract's conformance suite run against this router over real HTTP — same answers as the mock, checked at test time.
This commit is contained in:
1 parent
2fbd93fd79
commit
98bc0fd623
9 files changed
+422
-28
No files matched your search
@@ -66,6 +66,8 @@ provider: anthropic
|
||||
model: claude-sonnet-4-5
|
||||
listen: 127.0.0.1:7799
|
||||
token: change-me # optional; when set, /v1/* requires it
|
||||
agent_token: change-me-too # the client tools' scoped bearer (rhema-tools)
|
||||
tools_bin: ~/.local/share/rhema-tools/bin # put the client tools on PATH
|
||||
poll_interval_secs: 120
|
||||
max_turn_steps: 2048 # tool rounds one chat turn may run
|
||||
watches: # a seed: imported while the table is empty
|
||||
@@ -101,6 +103,20 @@ its approval seam auto-approved: tool calls, the shell included,
|
||||
execute without a prompt. The daemon says so at startup, and the
|
||||
bearer-gated surface plus the watch list are the trust boundary.
|
||||
|
||||
`agent_token` provisions the client tools: a second bearer the daemon
|
||||
hands the agent's shell as `RHEMA_TOKEN` (with `RHEMA_URL`), valid
|
||||
only for the data routes the tool contract allowlists — watches,
|
||||
notifications, tasks — and only with the contract header at the
|
||||
matching version. It cannot reach consents, sessions, ingest, or the
|
||||
phones, so a model holding the token cannot prompt-inject its way past
|
||||
the scoping (see `specs/rhema-tools.md`; the daemon runs the
|
||||
contract's conformance suite against its own router at test time). It
|
||||
must differ from `token` — the daemon refuses to start when the two
|
||||
are the same. `tools_bin` layers a directory onto the shell PATH so
|
||||
the provisioned tools resolve. With no `agent_token`, the daemon
|
||||
provisions no tool environment: the agent's shell is exactly as it
|
||||
was.
|
||||
|
||||
The native surface:
|
||||
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user