docs(opencode): document TUI control endpoints
This commit is contained in:
parent
d7ec0bef1c
commit
651864017c
@ -133,16 +133,40 @@ opencode attach http://127.0.0.1:4096
|
||||
opencode attach http://127.0.0.1:4096 --session ses_abc123
|
||||
```
|
||||
|
||||
To send messages to the session currently open in the TUI, set `opencc.session_id` in CC to the session ID shown in the TUI, then run `ai-helloworld`.
|
||||
To send messages to the session currently open in the TUI, set `opencc.session_id` in CC to the session ID shown in the TUI, then run `ai-helloworld`:
|
||||
|
||||
## TUI control (bonus)
|
||||
```sh
|
||||
set opencc.session_id ses_abc123
|
||||
```
|
||||
|
||||
When a TUI is attached, these endpoints drive it programmatically:
|
||||
## TUI control
|
||||
|
||||
| Method | Path | Effect |
|
||||
|---|---|---|
|
||||
| `POST` | `/tui/append-prompt` | Append text to the input field |
|
||||
| `POST` | `/tui/submit-prompt` | Submit the current input |
|
||||
| `POST` | `/tui/show-toast` | Show a notification |
|
||||
When a TUI is attached, these endpoints drive that TUI programmatically. They operate on the attached TUI prompt/dialog state, not on a specific `/session/:id`.
|
||||
|
||||
Body for append/submit: `{ "text": "..." }`.
|
||||
| Method | Path | Effect | Body |
|
||||
|---|---|---|---|
|
||||
| `POST` | `/tui/append-prompt` | Append text to the prompt | `{ "text": "..." }` |
|
||||
| `POST` | `/tui/submit-prompt` | Submit the current prompt | none |
|
||||
| `POST` | `/tui/clear-prompt` | Clear the prompt | none |
|
||||
| `POST` | `/tui/open-help` | Open the help dialog | none |
|
||||
| `POST` | `/tui/open-sessions` | Open the session selector | none |
|
||||
| `POST` | `/tui/open-themes` | Open the theme selector | none |
|
||||
| `POST` | `/tui/open-models` | Open the model selector | none |
|
||||
| `POST` | `/tui/execute-command` | Execute a TUI command | `{ "command": "prompt.submit" }` |
|
||||
| `POST` | `/tui/show-toast` | Show a notification | `{ "message": "...", "variant": "info" }` |
|
||||
| `GET` | `/tui/control/next` | Wait for the next TUI control request | none |
|
||||
| `POST` | `/tui/control/response` | Respond to a TUI control request | response body |
|
||||
|
||||
`/tui/show-toast` also accepts optional `title` and `duration` fields. `variant` is one of `info`, `success`, `warning`, or `error`.
|
||||
|
||||
Example: prefill and submit the attached TUI prompt:
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:4096/tui/append-prompt \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"text":"reply with exactly: pong"}'
|
||||
|
||||
curl -X POST http://127.0.0.1:4096/tui/submit-prompt
|
||||
```
|
||||
|
||||
`POST /tui/publish` also exists as a lower-level endpoint for publishing TUI events such as `tui.prompt.append`, `tui.command.execute`, and `tui.toast.show`. Prefer the specific endpoints above unless you need that raw event surface.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user