agentp 1.12.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -10
- package/bin/agentp +372 -135
- package/bin/ocmux +334 -7
- package/docs/specification.md +26 -4
- package/lib/ocmux.js +30 -5
- package/lib/opencode.js +518 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Notes:
|
|
|
47
47
|
|
|
48
48
|
- `agentp` connects to the OpenCode event endpoint over HTTP.
|
|
49
49
|
- In practice this means running `opencode serve` (or equivalent serve mode) so the port is open.
|
|
50
|
-
- `opencode attach` is optional but useful to monitor the full conversation in another terminal/tmux pane.
|
|
50
|
+
- `opencode attach` (older OpenCode) / `opencode --server <url>` (OpenCode v2) is optional but useful to monitor the full conversation in another terminal/tmux pane. `ocmux` picks the right form automatically.
|
|
51
51
|
- If the OpenCode server is password-protected (`OPENCODE_SERVER_PASSWORD`), both `agentp` and `ocmux` automatically send the required HTTP Basic Auth credentials.
|
|
52
52
|
|
|
53
53
|
## Usage
|
|
@@ -59,7 +59,8 @@ agentp [options] [url]
|
|
|
59
59
|
Options:
|
|
60
60
|
|
|
61
61
|
- `--qa`: print the original prompt and answer with labels (useful when used as a filter)
|
|
62
|
-
- `--defer`: deferred execution — submit prompt
|
|
62
|
+
- `--defer [N]`: deferred execution — submit a prompt and get a ticket immediately (or wait up to N seconds for the answer and print it if it arrives); pipe the ticket back to retrieve the result later
|
|
63
|
+
- `--onlineTicket`: print deferred tickets on a single line (default: pretty-printed JSON)
|
|
63
64
|
- `--tg`: forward the answer to Telegram via tgagentp gateway (error if unreachable)
|
|
64
65
|
- `--no-tg`: do not forward to Telegram
|
|
65
66
|
- `--flush`: flush tgagentp's recorded buffer without prepending it to output
|
|
@@ -72,9 +73,17 @@ Options:
|
|
|
72
73
|
By default, `--qa` auto-detects tgagentp (silently degrades if unavailable); standalone mode implies `--no-tg`.
|
|
73
74
|
With `--tg`, errors if tgagentp is unavailable.
|
|
74
75
|
|
|
76
|
+
> **Telegram notification from deferred jobs:** Use `--defer --tg` (or
|
|
77
|
+
> `--defer N --tg`) to forward the answer to Telegram automatically when the
|
|
78
|
+
> background job completes. The detached child process runs the full `--tg`
|
|
79
|
+
> flow, including gateway detection and notification. If the gateway is
|
|
80
|
+
> unreachable at completion time, a warning is printed on stderr; the answer
|
|
81
|
+
> is still saved in the temp file and retrievable via ticket re-submission.
|
|
82
|
+
|
|
75
83
|
Arguments:
|
|
76
84
|
|
|
77
85
|
- `url`: OpenCode TUI server URL or port number (defaults to `4096`). Examples: `4096`, `http://localhost:4096`, `http://192.168.1.50:4096`
|
|
86
|
+
- Tip: `$(ocmux)` expands to the URL of the current project's server, so you can run `agentp $(ocmux)` from any shell.
|
|
78
87
|
|
|
79
88
|
## Examples
|
|
80
89
|
|
|
@@ -147,18 +156,83 @@ context for a new topic.
|
|
|
147
156
|
|
|
148
157
|
Deferred execution with `--defer`:
|
|
149
158
|
|
|
150
|
-
Submit a prompt and get
|
|
159
|
+
Submit a prompt and get a ticket to retrieve the result later:
|
|
151
160
|
|
|
152
161
|
```bash
|
|
153
|
-
# Submit a prompt and get a deferred
|
|
162
|
+
# Submit a prompt and get a deferred ticket (optionally wait up to N seconds)
|
|
154
163
|
DEFERRED=$(printf "Refactor the authentication module" | agentp --defer)
|
|
155
|
-
# Output:
|
|
164
|
+
# Output: agentp_ticket {
|
|
165
|
+
# "ctime": "2026-08-03T14:30:00.000Z",
|
|
166
|
+
# "path": "/tmp/agentp_deferred_20260803_1430_a1b2.tmp",
|
|
167
|
+
# "server": "http://localhost:4096",
|
|
168
|
+
# "sessionId": "ses_abc123"
|
|
169
|
+
# }
|
|
170
|
+
|
|
171
|
+
# Or wait up to 60s for the answer; only get a ticket if it's not ready in time
|
|
172
|
+
DEFERRED=$(printf "Refactor the authentication module" | agentp --defer 60)
|
|
156
173
|
|
|
157
174
|
# Continue working... retrieve the result when ready
|
|
158
175
|
printf '%s\n' "$DEFERRED" | agentp --defer
|
|
159
176
|
# Output: (the agent's response)
|
|
160
177
|
```
|
|
161
178
|
|
|
179
|
+
`--defer` takes an optional numeric timeout in seconds (default `0`). With a
|
|
180
|
+
timeout, the invocation blocks until the answer arrives or the timeout expires:
|
|
181
|
+
if the answer arrives in time it is printed immediately; otherwise a ticket is
|
|
182
|
+
returned and the agent keeps working in the background.
|
|
183
|
+
|
|
184
|
+
The ticket is `agentp_ticket` followed by a JSON object with these fields:
|
|
185
|
+
|
|
186
|
+
- `ctime` — creation timestamp (ISO 8601). Only used to compute `elapsed`.
|
|
187
|
+
- `path` — path to the temp file holding the result.
|
|
188
|
+
- `server` — OpenCode server URL used by the deferred job.
|
|
189
|
+
- `sessionId` — OpenCode session ID used by the deferred job.
|
|
190
|
+
- `elapsed` — seconds since `ctime`, included only when the ticket is re-printed (not on first print).
|
|
191
|
+
- `defer` — the timeout requested at submission, included only when it was > 0.
|
|
192
|
+
|
|
193
|
+
Tickets are printed as pretty-printed (multi-line) JSON for easier reading and
|
|
194
|
+
editing; pass `--onlineTicket` to print them on a single line instead:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
printf "Refactor the auth module" | agentp --defer --onlineTicket
|
|
198
|
+
# Output: agentp_ticket {"ctime":"...","path":"/tmp/agentp_deferred_....tmp"}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Both formats are accepted when piping a ticket back to `agentp --defer`.
|
|
202
|
+
|
|
203
|
+
You can also append follow-up text after a not-yet-ready ticket to queue more
|
|
204
|
+
input into the original running task, similar to typing into the OpenCode TUI
|
|
205
|
+
while the agent is busy:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
cat <<'EOF' | agentp --defer
|
|
209
|
+
agentp_ticket {
|
|
210
|
+
"ctime": "2026-08-03T14:30:00.000Z",
|
|
211
|
+
"path": "/tmp/agentp_deferred_...tmp",
|
|
212
|
+
"server": "http://localhost:4096",
|
|
213
|
+
"sessionId": "ses_abc123"
|
|
214
|
+
}
|
|
215
|
+
Also make sure the migration is reversible.
|
|
216
|
+
EOF
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
If the answer is already ready, the appended text is not sent to OpenCode; it is
|
|
220
|
+
printed after the returned answer so you can edit and re-submit it if needed. In
|
|
221
|
+
`--qa` output, it appears after the final ruler. If the answer is not ready, the
|
|
222
|
+
appended text is sent through OpenCode's async prompt endpoint for the ticket's
|
|
223
|
+
`server`/`sessionId`, stored with the ticket, and the ticket is re-printed with
|
|
224
|
+
updated `elapsed` without echoing the extra text in that interim output. When
|
|
225
|
+
the final answer is later retrieved with `--qa`, all stored follow-ups are
|
|
226
|
+
printed inside the prompt block under `📝` separators. Without `--qa`, stored
|
|
227
|
+
follow-ups are not printed. Older tickets without `server` and `sessionId` can
|
|
228
|
+
still retrieve results, but cannot queue follow-up text.
|
|
229
|
+
|
|
230
|
+
Piping a ticket back to `agentp --defer` ignores the `--defer` argument and uses
|
|
231
|
+
the ticket's own `defer` value as the timeout (default `0`):
|
|
232
|
+
|
|
233
|
+
- If the answer is ready, it is returned and the temp file is removed.
|
|
234
|
+
- If not, the ticket is re-printed with the elapsed time updated.
|
|
235
|
+
|
|
162
236
|
Works as a Vim/Neovim filter with deferred execution:
|
|
163
237
|
|
|
164
238
|
```vim
|
|
@@ -166,15 +240,18 @@ Works as a Vim/Neovim filter with deferred execution:
|
|
|
166
240
|
:'<,'>!agentp --defer --qa
|
|
167
241
|
|
|
168
242
|
" Later, retrieve the result
|
|
169
|
-
:r !printf '%s\n' "
|
|
243
|
+
:r !printf '%s\n' "$(cat <<'EOF'
|
|
244
|
+
agentp_ticket {"ctime":"2026-08-03T14:30:00.000Z","path":"/tmp/agentp_deferred_...tmp","server":"http://localhost:4096","sessionId":"ses_abc123"}
|
|
245
|
+
EOF
|
|
246
|
+
)" | agentp --defer
|
|
170
247
|
```
|
|
171
248
|
|
|
172
249
|
The deferred workflow:
|
|
173
|
-
1. Submit prompt with `--defer` → get
|
|
250
|
+
1. Submit prompt with `--defer` → get a ticket (`agentp_ticket {...}`)
|
|
174
251
|
2. Continue working (the agent processes in background)
|
|
175
252
|
3. When ready, pipe the ticket back to `agentp --defer` to retrieve the result
|
|
176
|
-
4. If the agent is still processing, you get
|
|
177
|
-
|
|
253
|
+
4. If the agent is still processing, you get the ticket back with the elapsed time updated
|
|
254
|
+
5. If complete, you get the agent's response and the temp file is cleaned up
|
|
178
255
|
|
|
179
256
|
Useful for long-running tasks where you don't want to block your editor.
|
|
180
257
|
|
|
@@ -204,6 +281,8 @@ Subcommands:
|
|
|
204
281
|
- `--print-logs` passes `--print-logs` to `opencode serve`, which prints server logs to stderr in the server tmux pane.
|
|
205
282
|
- **`kill [dir]`** — Kill the server found upward from `dir`. Removes its tmux window and state file.
|
|
206
283
|
- **`resurrect [--print-logs] [dir]`** — Recover a dead/crashed server: reads `.ocmux.json`, kills old tmux window, removes state file, then creates a fresh server + TUI in the same directory. Works even if no tmux window exists (stale state file).
|
|
284
|
+
- **`model [ref]`** — Switch the model of the newest session on the current project's server. With no `ref`, shows an interactive model picker (TTY required). With `ref`, switches directly and prints the server URL on stdout so `agentp $(ocmux model <ref>)` composes: the switch (a side effect) takes effect before agentp sends the next prompt. `ref` supports partial matches when unique (`ocmux model deepseek`, `opencode-go/deepseek`, `...#high`); multiple matches open the picker (or error when not a TTY).
|
|
285
|
+
- **`switch`** — Interactive session picker: an interactive menu of all running servers (columns: dirname, status, url, full path). Arrow keys or `j`/`k` move the selection; `Enter`/`Space` switches to the selected server's tmux window (the menu stays open, so you can hop between servers); `q` or `Ctrl+C` exits. The currently active server (queried live from tmux on every redraw) is highlighted across the full line width. Prints the URL of the last selected server on exit. Requires a TTY.
|
|
207
286
|
- **`list`** — List all running servers with their directories, URLs, and status.
|
|
208
287
|
|
|
209
288
|
Options:
|
|
@@ -217,6 +296,7 @@ Notes:
|
|
|
217
296
|
|
|
218
297
|
- If `<directory>` is not a valid path, `ocmux` tries to match it against the basenames of existing sessions (exact unique match).
|
|
219
298
|
- When using `--git`/`--GIT`, `ocmux` refuses to create a new server above an existing `.ocmux.json` found while searching for the git root.
|
|
299
|
+
- In default mode, if no server is found, the primary error line is printed to stdout. This intentionally makes `agentp $(ocmux)` fail instead of silently falling back to `agentp`'s default `localhost:4096` server.
|
|
220
300
|
|
|
221
301
|
### Requirements
|
|
222
302
|
|
|
@@ -246,7 +326,7 @@ The session API ensures the request is processed even when no TUI is attached, a
|
|
|
246
326
|
|
|
247
327
|
Operational hint:
|
|
248
328
|
|
|
249
|
-
- You can keep a separate
|
|
329
|
+
- You can keep a separate TUI view open to see the full run context while `agentp` is used from shell scripts or editor buffers: `opencode --server '<url>' --continue` on OpenCode v2, or `opencode attach --continue '<url>'` on older versions (`ocmux` uses the right one automatically).
|
|
250
330
|
|
|
251
331
|
## tgagentp
|
|
252
332
|
|