feat: add synchronized OpenCode worker service, adaptive animations and auto-updates

This commit is contained in:
KoDer committed 2026-11-24 23:16:07 +07:00
1 parent 390e8657d3
commit b7f66a6566
23 files changed
+4714 -94

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
---
name: AiRouter Workers
description: Auto-invoke when the user wants OpenCode workers shown in the AiRouter console, synchronized worker chats, or a local agent dashboard.
---
# AiRouter Workers
Use AiRouter as the local console for OpenCode-driven work. Keep the service,
workers, and console synchronized; never run a second, disconnected worker loop.
## Workflow
1. Ensure the local service is running:
```sh
airouter service start
```
2. Create each worker explicitly and use the requested role and workspace:
```sh
airouter ctl worker create --task "Describe the task" --role coder --workspace "/absolute/workspace"
```
Optional flags are `--name`, `--model`, and `--provider`. Read the returned
worker ID (for example, `w1`) and use that exact ID in later commands. Do not
invent IDs or assume creation order.
3. Open the AiRouter console **inside OpenCode** by creating a PTY through the
OpenCode V2 API. Replace `<absolute cwd>` with the real absolute path:
```sh
opencode api post /api/pty --data '{"command":"airouter","args":["attach"],"cwd":"<absolute cwd>","title":"AiRouter Workers"}'
```
Switch to the created PTY to use the console. Do **not** run blocking
`airouter attach` directly in a shell tool.
4. Keep worker chats synchronized through the service SSE stream. The console
receives worker messages, progress, completion, failures, and direct-chat
events without starting local worker tasks. Use the console to inspect the
conversation and reports.
5. Message, retry, or cancel workers through `airouter ctl` using their IDs:
```sh
airouter ctl worker message w1 --message "Additional context or next step"
airouter ctl worker retry w1
airouter ctl worker cancel w1 --reason "No longer needed"
```
Use `airouter ctl worker list` to confirm current IDs and statuses. Wait for a
worker to finish before sending a follow-up or retrying it.
## Security
The service token authenticates local clients. Do not print it, paste it into a
worker prompt, commit it, or read it from the runtime file just to configure the
console. Let `airouter service` and `airouter attach` manage authentication.
## Updates
AiRouter checks remote Git tags for `vMAJOR.MINOR.PATCH` releases and caches a
successful check for six hours:
```sh
airouter update
```
If an update is available, tell the user and install it with:
```sh
airouter update install
```
Updates only fast-forward a clean Git checkout. If the working tree is dirty or
history is not fast-forward, stop and report that the update was refused; never
stash, reset, or discard the user's changes. Restart AiRouter after source files
change.