host: expose harness state and actions over the world API

This commit is contained in:
2026-11-07 19:22:06 +00:00
parent c3c5b36d09
commit 5dc4833e28
33 changed files with 33178 additions and 112 deletions
+36 -2
View File
@@ -4,8 +4,8 @@
The `wasi:http` hook supplies the caller from the process table.
It must not accept caller identity from headers, environment variables, or JSON.
Reads are open to every caller.
JSON routes return 200 on success.
Errors use `{"error":"kind","message":"kind"}` with static, secret-free text.
Credential JSON routes return 200 on success.
Credential errors use `{"error":"kind","message":"kind"}` with static, secret-free text.
Missing routes return 404. Invalid parameters return 400. Authorization failures return 403.
Conflicts return 409. The filing budget returns 429.
@@ -65,6 +65,40 @@ Explicit requests, automatic SSH requests, and new ceremonies share a per-proces
The budget permits 32 attempts per 60-second window.
Reads and granted SSH operations do not spend that budget.
## Harness routes in the world
The WASI transport dispatches buffered and streaming responses through one route table.
Harness routes use `http://host.sausage/harness/` and the console's input channel.
The host listener does not expose these routes.
The V8 harness answers queries and invokes actions without a second storage reader.
- `GET /harness/conversations`: `{conversations:[...]}` with records, titles, agents, starters, concluded state, and running state.
Records retain their owner and parent references.
- `GET /harness/conversations/{id}/entries?after=0`: `{entries:[...]}` in ascending entry order.
- `GET /harness/conversations/{id}/stream?after=0`: newline-delimited entry records, then new entries as commits arrive.
- `POST /harness/conversations/{id}/submit`: `{content:"text",requestId:"stable-id"}`.
The response is 202 with `{submissionId:number}`.
Duplicate request IDs use pi-durable's existing idempotent admission.
- `POST /harness/conversations/{id}/stop`: abort the conversation's active turns, including their owned work.
The response is `{ok:true}`. Queued inputs remain.
- `GET /harness/events?after=0`: newline-delimited T43 event records in ascending event order.
- `POST /harness/extensions/{name}/actions/{action}`: `{args:{...},conversationId?:number}`.
Only names in the extension's `userActions` export are callable.
The response is `{result:...}`. Disconnect aborts the action's signal.
- `GET /harness/models`: `{models:[...]}` with public catalog fields, without provider authentication data.
- `GET /harness/families`: `{families:{...}}` from the world's model definitions.
- `GET /harness/extensions`: the loaded extension status, also visible through `/proc/extensions`.
- `GET /harness/credential-requests`: `{requests:[...]}` with pending conversation requests and host approval links.
Approval stays on the host page.
The `after` cursor is an exclusive entry ID. Streams replay retained records before live records.
Commit observation starts before replay, so a concurrent commit cannot create a gap.
Clients resume from the last record ID after a disconnect.
Disconnect closes the observation. Harness shutdown closes all streams.
Responses use JSON, except streams use `application/x-ndjson`.
Invalid inputs return 400. Missing routes, conversations, and actions return 404.
An unavailable harness returns 503. Action failures return 500 with the action's error message.
## Decisions
- `POST /cred/requests/{id}/challenge`: `{"decision":"approve","overrides":{...}}`.