agentp 0.10.0 → 0.11.1
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/CONTRIBUTING.md +139 -0
- package/README.md +23 -6
- package/bin/agentp +93 -33
- package/bin/ocmux +56 -41
- package/bin/tgagentp +921 -251
- package/docs/specification.md +391 -0
- package/lib/ocmux.js +113 -2
- package/lib/opencode.js +60 -21
- package/package.json +9 -2
- package/AGENTS.md +0 -182
- package/CHANGELOG.md +0 -36
- package/devto-article.md +0 -121
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Pipe prompts into a running OpenCode TUI session and stream the final answer",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agentp": "bin/agentp",
|
|
7
7
|
"ocmux": "bin/ocmux",
|
|
8
8
|
"tgagentp": "bin/tgagentp"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"lib/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"CONTRIBUTING.md",
|
|
15
|
+
"docs/"
|
|
16
|
+
],
|
|
10
17
|
"keywords": [
|
|
11
18
|
"ai",
|
|
12
19
|
"cli",
|
|
@@ -24,7 +31,7 @@
|
|
|
24
31
|
"node": ">=18"
|
|
25
32
|
},
|
|
26
33
|
"scripts": {
|
|
27
|
-
"test": "
|
|
34
|
+
"test": "node --test tests/*.test.js"
|
|
28
35
|
},
|
|
29
36
|
"type": "commonjs"
|
|
30
37
|
}
|
package/AGENTS.md
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# agentp — agent notes
|
|
2
|
-
|
|
3
|
-
## Three binaries, all registered
|
|
4
|
-
|
|
5
|
-
- `bin/agentp` (Node.js) — registered in `package.json` `"bin"` — pipes stdin → opencode session
|
|
6
|
-
- `bin/ocmux` (Node.js) — registered in `package.json` `"bin"` — manages opencode tmux sessions
|
|
7
|
-
- `bin/tgagentp` (Node.js) — registered in `package.json` `"bin"` — bridges Telegram bot ↔ opencode TUI
|
|
8
|
-
|
|
9
|
-
## Package facts
|
|
10
|
-
|
|
11
|
-
- **Zero npm dependencies.** All scripts use only Node.js stdlib (`http`, `https`, `readline`, `url`, `child_process`, `fs`, `path`, `crypto`, `os`).
|
|
12
|
-
- **No tests, no CI, no lint, no formatter.** `npm test` is a stub that exits 1.
|
|
13
|
-
- **No lockfile.** Versions resolve at install time.
|
|
14
|
-
- **`"type": "commonjs"`**, requires Node >= 18.
|
|
15
|
-
- **Linux and macOS compatible.** All tools use portable Node.js APIs only.
|
|
16
|
-
|
|
17
|
-
## Logging conventions (tgagentp)
|
|
18
|
-
|
|
19
|
-
- **stdout** — informational messages (startup, discovery, session switches)
|
|
20
|
-
- **stderr** — errors (always shown) + trace/debug (only with `--verbose` flag)
|
|
21
|
-
- Default usage for clean console: `tgagentp 2>/dev/null`
|
|
22
|
-
- The `log` helper object at the top of `bin/tgagentp` provides `log.info()`, `log.error()`, and `log.debug()`.
|
|
23
|
-
|
|
24
|
-
## `.ocmux.json`
|
|
25
|
-
|
|
26
|
-
Runtime state file created by `bin/ocmux` (contains URL, log path, and window index). **Not in `.gitignore`** — avoid committing it.
|
|
27
|
-
|
|
28
|
-
## Shared `lib/opencode.js`
|
|
29
|
-
|
|
30
|
-
Extracted from `bin/agentp`; used by both `agentp` and `tgagentp`:
|
|
31
|
-
|
|
32
|
-
- `getAuthHeaders()` — reads `OPENCODE_SERVER_PASSWORD` / `OPENCODE_SERVER_USERNAME`
|
|
33
|
-
- `makeRequest(options, data)` — thin `http.request` wrapper returning a Promise
|
|
34
|
-
- `buildJsonRequest(url, method, body)` — builds request options for JSON POST/GET (no Content-Type/Length for bodyless requests)
|
|
35
|
-
- `clearPrompt(server)`, `appendPrompt(server, text)`, `submitPrompt(server)` — TUI prompt endpoints
|
|
36
|
-
- `sendText(server, text)` — convenience: clear + append + submit in one call
|
|
37
|
-
- `listenForFinalAnswer(server, onText?, cancelRef?)` — SSE event stream listener; `cancelRef` allows true server-side abort via `req.destroy()`
|
|
38
|
-
- `listSessions(server, directory?)` — `GET /session`; returns parsed JSON array; optional `?directory=` filter
|
|
39
|
-
- `createSession(server, title?)` — `POST /session`; returns the created `Session` object; optional `title`
|
|
40
|
-
- `updateSession(server, sessionId, title, agent?)` — `PATCH /session/:id`; returns the updated `Session` object; optional `agent` to set the session's agent
|
|
41
|
-
- `sendToSession(server, sessionId, text, agent?, cancelRef?)` — `POST /session/:id/message`; returns concatenated text parts from response; optional `agent`, optional `cancelRef` for aborting the request
|
|
42
|
-
- `sendToSessionAsync(server, sessionId, text, agent?)` — `POST /session/:id/prompt_async`; returns 204; non-blocking, answer delivered via SSE
|
|
43
|
-
- `respondToPermission(server, sessionId, permissionId, response)` — `POST /session/:id/permissions/:id`
|
|
44
|
-
- `selectSession(server, sessionId)` — `POST /session/:id/select`; tells the TUI to navigate to the given session (silently ignores 404 if the endpoint isn't available in older opencode versions)
|
|
45
|
-
- `listAgents(server)` — `GET /agent`; returns parsed JSON array of agent objects
|
|
46
|
-
- `listProviders(server)` — `GET /provider`; returns parsed JSON array of provider objects
|
|
47
|
-
- `listenForSessionEvents(server, sessionId, callbacks, cancelRef?)` — SSE listener for session events (text parts, permissions, thinking, session.idle)
|
|
48
|
-
|
|
49
|
-
## Shared `lib/ocmux.js`
|
|
50
|
-
|
|
51
|
-
Shared ocmux session discovery; used by both `bin/ocmux` and `bin/tgagentp`:
|
|
52
|
-
|
|
53
|
-
- `readState(file)` — parses `.ocmux.json`, returns `null` on error
|
|
54
|
-
- `statefileFor(dir)` — `path.join(dir, '.ocmux.json')`
|
|
55
|
-
- `tuiPaneId(windowIndex)` — returns pane ID of the TUI pane (pane index != 0), `null` if dead
|
|
56
|
-
- `windowByDir(dir)` — returns window index by name match
|
|
57
|
-
- `windowNameByIndex(idx)` — reverse: name from index
|
|
58
|
-
- `activeWindowIndex()` — returns index of currently selected tmux window
|
|
59
|
-
- `paneCount(windowIndex)` — number of panes in a window
|
|
60
|
-
- `listServers()` — scans all tmux windows for `.ocmux.json` state files; returns `{ url, dir, index, status }` array
|
|
61
|
-
- `activateServer(dir, index, url)` — pin window name, restart dead TUI pane, select window, zoom pane
|
|
62
|
-
|
|
63
|
-
## OpenCode HTTP protocol
|
|
64
|
-
|
|
65
|
-
These endpoints are consumed but not documented elsewhere in the repo:
|
|
66
|
-
|
|
67
|
-
- `POST /tui/clear-prompt`
|
|
68
|
-
- `POST /tui/append-prompt`
|
|
69
|
-
- `POST /tui/submit-prompt`
|
|
70
|
-
- `GET /event` (SSE stream)
|
|
71
|
-
- `GET /session` — list sessions (optional `?directory=` filter)
|
|
72
|
-
- `POST /session` — create a new session (optional `{ title? }` body)
|
|
73
|
-
- `PATCH /session/:id` — update session properties (`{ title }`, optional `{ agent }`)
|
|
74
|
-
- `POST /session/:id/select` — tell the TUI to navigate to a session (only with TUI attached)
|
|
75
|
-
- `POST /session/:id/message` — send message to session (returns parts synchronously; optional `agent` field)
|
|
76
|
-
- `POST /session/:id/prompt_async` — send message to session (returns 204; answer via SSE)
|
|
77
|
-
- `GET /agent` — list available agents
|
|
78
|
-
- `GET /provider` — list connected providers/models
|
|
79
|
-
|
|
80
|
-
## Agentp gateway (tgagentp ↔ agentp interop)
|
|
81
|
-
|
|
82
|
-
- tgagentp starts a tiny HTTP server (POST /send) on `127.0.0.1`, port from `TGAGENTP_PORT` (default 0 = random).
|
|
83
|
-
- Port is written to `/tmp/tgagentp-port` for agentp discovery.
|
|
84
|
-
- Validates `Authorization` header against `OPENCODE_SERVER_PASSWORD`.
|
|
85
|
-
- agentp `--tg` reads the port file and POSTs `{ text, server }` to the gateway.
|
|
86
|
-
- Messages for the active server are delivered immediately; others are queued per-server.
|
|
87
|
-
- Debounced Telegram notification (configurable via `TGAGENTP_DEBOUNCE_MS`, default 5000ms).
|
|
88
|
-
- Queued messages are flushed on `/servers switch`.
|
|
89
|
-
- Gateway response includes `{ buffered: [...] }` — recorded conversation messages (see `/record` command) flushed on each POST.
|
|
90
|
-
- agentp `--qa` prepends the buffered context to stdout; `--flush` bypasses prepending but still triggers the flush.
|
|
91
|
-
|
|
92
|
-
## OpenCode tmux session model (ocmux)
|
|
93
|
-
|
|
94
|
-
- Single tmux session named `"Opencode"`
|
|
95
|
-
- Windows named by full project directory path
|
|
96
|
-
- Server pane runs `opencode serve --port 0` (via send-keys → interactive shell for env var support), TUI pane runs `opencode attach --continue`; `ocmux serve --print-logs` adds `--print-logs` to the serve command
|
|
97
|
-
- Log file per project: `/tmp/opencode-serve-<hashDir(dir)>.log` — captured via `tee`, read by ocmux polling loop
|
|
98
|
-
- Per-project `.ocmux.json` with upward directory search (git-like)
|
|
99
|
-
- Auto-restarts dead TUI panes on switch (respawn-pane or split-window)
|
|
100
|
-
- Auto-zooms TUI pane on switch/create
|
|
101
|
-
|
|
102
|
-
## Commands
|
|
103
|
-
|
|
104
|
-
| Command | What |
|
|
105
|
-
|---|---|---|
|
|
106
|
-
| `npm link` | local dev install |
|
|
107
|
-
| `npm install -g .` | alternative local install |
|
|
108
|
-
| `agentp [--qa] [--tg|--no-tg] [--flush] [--getLast n] [port]` | pipe stdin → opencode session, stream answer to stdout (uses session API); `--tg` forwards answer to Telegram; `--flush` clears recorded buffer; `--getLast n` retrieves last n answers |
|
|
109
|
-
| `tgagentp [port]` | bridge Telegram bot ↔ opencode TUI (needs `TELEGRAM_BOT_TOKEN`) |
|
|
110
|
-
| `tgagentp --dev` | enable `/shutdown` command for remote restart |
|
|
111
|
-
| `ocmux serve [--print-logs] [dir]` | start opencode serve in a tmux window (primary verb) |
|
|
112
|
-
| `ocmux new [dir]` | alias for `serve` (backwards compat, to be removed in 1.0) |
|
|
113
|
-
| `ocmux kill [dir]` | kill server + tmux window |
|
|
114
|
-
| `ocmux list [-l]` | list running servers |
|
|
115
|
-
| `ocmux [dir]` | switch to existing opencode tmux window |
|
|
116
|
-
|
|
117
|
-
## TODO
|
|
118
|
-
|
|
119
|
-
### Pending
|
|
120
|
-
|
|
121
|
-
*(none)*
|
|
122
|
-
|
|
123
|
-
### In Progress
|
|
124
|
-
|
|
125
|
-
*(none)*
|
|
126
|
-
|
|
127
|
-
### Done
|
|
128
|
-
|
|
129
|
-
- `/queue` command: queue messages when server is busy, auto-sent after current task finishes preserves replyTo chain — 0.10.0
|
|
130
|
-
- `agentp --getLast n` — retrieve last n answers from session history — 0.10.0
|
|
131
|
-
- `/record` command with ring buffer (100 msgs / 100KB), gateway returns `{ buffered }`, agentp `--qa` prepends recorded context, `--flush` flushes without prepending — 0.10.0
|
|
132
|
-
- agentp `--qa` full context forwarding to Telegram (rulers, prompt, answer) — 0.9.0
|
|
133
|
-
- agentp resilience: 5s HTTP timeout, pre-send gate check, post-send warning (not hard error) for `--tg`; auto mode silently degrades — 0.9.0
|
|
134
|
-
- tgagentp: `lockedChatId` set at startup to fix race condition with agentp gateway — 0.9.0
|
|
135
|
-
- tgagentp: server error handler + try-catch in gateway handler (no crash on socket errors) — 0.9.0
|
|
136
|
-
- agentp `--tg`/`--no-tg` — gateway forwards answer to Telegram via tgagentp HTTP server; per-server queue with debounced notifications; auto-flush on server switch
|
|
137
|
-
- agentp session API migration — uses `POST /session/:id/message` instead of TUI endpoints
|
|
138
|
-
- ocmux `--print-logs` flag — pass-through to `opencode serve --print-logs` (prints server logs to stderr in the server pane)
|
|
139
|
-
- /agents lists only primary agents with ▶ active marker
|
|
140
|
-
- /agents switch calls `updateSession(agent)` to persist agent on session + `selectSession` to refresh TUI
|
|
141
|
-
- Logging rebalance: stdout for info, stderr for errors/debug/trace, `--verbose` flag, `2>/dev/null` default usage
|
|
142
|
-
- `/shutdown force` — refuses shutdown when busy unless `force` flag is given; goodbye message includes state
|
|
143
|
-
- `/think [on|off|switch]` — toggle real-time forwarding of model thinking messages to the chat; `--think` CLI flag to start enabled
|
|
144
|
-
- Event-driven permission handling (`POST /session/:id/prompt_async` + SSE listener + `/allow`, `/reject`, `/always` commands) — included in v0.7.0
|
|
145
|
-
- TUI navigation on `/sessions switch` and `/sessions new` — `POST /tui/select-session` now works in opencode 1.15.13 (was: tried second, never reached)
|
|
146
|
-
- /sessions new [name] — create a new session, TUI follows via /session/:id/select
|
|
147
|
-
- /sessions rename <name> — rename the current active session
|
|
148
|
-
- Merge /session into /sessions (keep /session as alias)
|
|
149
|
-
- Case-insensitive matching for all switch subcommands (/servers, /sessions, /agents)
|
|
150
|
-
- Fix: /sessions filter includes sessions with directory (TUI sessions) + active session exception
|
|
151
|
-
- Fix: /sessions now shows the active session even without agent set (exception in filter)
|
|
152
|
-
- Fix: /sessions switch and /sessions new call selectSession (TUI navigation didn't work in opencode < 1.15.x)
|
|
153
|
-
- Fix: active session highlighted with ▶ bullet in session list
|
|
154
|
-
- Fix: discover TUI session on startup and server switch via `discoverActiveSession()`
|
|
155
|
-
- Message splitting (>4096 chars, breaks at newlines)
|
|
156
|
-
- Fix: tuiPaneId detects 'bun' (opencode 1.15.x) in addition to 'node'
|
|
157
|
-
- Fix: URL polling in ocmux doNew takes last match, not first (more robust with bun startup)
|
|
158
|
-
- lib/ocmux.js shared session discovery, refactor ocmux + tgagentp
|
|
159
|
-
- /cancel with true server-side SSE abort via cancelRef
|
|
160
|
-
- /shutdown (--dev mode) with Telegram offset acknowledgment
|
|
161
|
-
|
|
162
|
-
### Verified
|
|
163
|
-
|
|
164
|
-
- Password auth support (OPENCODE_SERVER_PASSWORD) for agentp, ocmux, tgagentp
|
|
165
|
-
- agentp HTTP Basic Auth headers on all requests (POST and SSE)
|
|
166
|
-
- agentp clear 401 error reporting
|
|
167
|
-
- ocmux interactive shells (send-keys) for env var propagation
|
|
168
|
-
- tgagentp Telegram bridge bot with long-polling
|
|
169
|
-
- Markdown→HTML converter (**bold**, *italic*, `code`, code blocks, headings, tables)
|
|
170
|
-
- Chat allowlist (TGAGENTP_ALLOWED_CHAT_IDS)
|
|
171
|
-
- Slash command system (/help, /servers, /sessions, /session, /agents, /agents switch, /models, /status, /cancel, /shutdown)
|
|
172
|
-
- Per-server state tracking (busy/idle, pendingResponse, activeSessionId, activeAgentName, taskId)
|
|
173
|
-
- Background async processing (non-commands fire without await)
|
|
174
|
-
- /servers switch activates tmux window (pin, restart TUI, select, zoom)
|
|
175
|
-
- Startup greeting with /status-style info persisted via temp file
|
|
176
|
-
- Fix port mismatch bug: truncate stale log file before send-keys in doNew
|
|
177
|
-
- Update README with full tgagentp features (slash commands, --dev, env vars)
|
|
178
|
-
- Update AGENTS.md with lib/ocmux.js, missing API endpoints, current architecture
|
|
179
|
-
- Single-user lock: first chat to connect owns the session
|
|
180
|
-
- Fix startup greeting markdown not being converted to HTML
|
|
181
|
-
|
|
182
|
-
*(Keep this TODO up to date: move items between categories as their status changes.)*
|
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
## [0.10.0] - 2026-06-04
|
|
6
|
-
|
|
7
|
-
- `/queue` command: queue messages when server is busy, auto-sent after current task finishes, preserves replyTo chain.
|
|
8
|
-
- `/record` command with ring buffer (100 msgs / 100KB), `/record stop` to clear; gateway returns `{ buffered }` JSON.
|
|
9
|
-
- agentp `--flush`: flush tgagentp's recorded buffer without prepending to stdout.
|
|
10
|
-
- agentp `--getLast n`: retrieve last n assistant answers from session history.
|
|
11
|
-
- agentp `--qa` prepends recorded Telegram context (with rulers) to stdout.
|
|
12
|
-
- `getSession()` in lib/opencode: `GET /session/:id` with fallback to session list.
|
|
13
|
-
- `makeRequest` optional timeout parameter (used only for getSession; all other calls wait indefinitely).
|
|
14
|
-
- Minimum 3-backtick code fence for reply quoting.
|
|
15
|
-
|
|
16
|
-
## [0.9.0] - 2026-06-04
|
|
17
|
-
|
|
18
|
-
- agentp `--tg`/`--no-tg` flags: gateway forwards answer to Telegram; auto mode silently degrades.
|
|
19
|
-
- Agentp resilience: 5s HTTP timeout, pre-send gate check, post-send warning.
|
|
20
|
-
- Full `--qa` output (rulers + prompt + answer) forwarded to Telegram.
|
|
21
|
-
- Rulers changed from `—` to `─`, shortened to 17 chars.
|
|
22
|
-
|
|
23
|
-
## [0.8.0] - 2026-06-03
|
|
24
|
-
|
|
25
|
-
- Fix `/servers` crash: `serverBase is not defined` error.
|
|
26
|
-
- Logging rebalance: stdout for info, stderr for errors/debug with `--verbose` flag (`2>/dev/null` for clean console).
|
|
27
|
-
- `/shutdown force`: refuse shutdown when busy unless `force` flag given.
|
|
28
|
-
- `/think [on|off|switch]`: toggle real-time forwarding of model thinking messages; `--think` CLI flag.
|
|
29
|
-
- Reply quoting: when replying to a Telegram message, prepend quoted text with safe backtick fencing.
|
|
30
|
-
- Reply chaining: answers use `reply_to_message_id` to appear as replies.
|
|
31
|
-
- TUI navigation: `POST /tui/select-session` tried first (works in opencode 1.15.13).
|
|
32
|
-
|
|
33
|
-
## [0.1.0] - 2026-05-08
|
|
34
|
-
|
|
35
|
-
- Initial release.
|
|
36
|
-
- Add project documentation and usage examples.
|
package/devto-article.md
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# Agentp: Turn OpenCode Into a Headless AI Engine for Your Editor, Terminal, and Telegram
|
|
2
|
-
|
|
3
|
-
OpenCode is great, but its TUI locks you in. You type in one window, watch it stream, and that's it. What if you could:
|
|
4
|
-
|
|
5
|
-
- Pipe a prompt straight from Vim and replace your selection with the answer?
|
|
6
|
-
- Queue messages from Telegram while it's busy and get replies threaded?
|
|
7
|
-
- Keep a permanent tmux server per project and switch between them?
|
|
8
|
-
- Pull the last N answers from session history without sending a new prompt?
|
|
9
|
-
- Record your Telegram conversation and inject it as context into your next `agentp` call?
|
|
10
|
-
|
|
11
|
-
That's what **agentp** — a set of three zero-dependency Node.js CLI tools — does.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## The Three Tools
|
|
16
|
-
|
|
17
|
-
### `agentp` — The Pipe
|
|
18
|
-
|
|
19
|
-
Stdin in, answer out. That's the core loop.
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
printf "Summarize this file" | agentp
|
|
23
|
-
cat prompt.txt | agentp 4096
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
From Vim/Neovim:
|
|
27
|
-
|
|
28
|
-
```vim
|
|
29
|
-
:'<,'>!agentp --qa
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
This replaces your visual selection with the answer. `--qa` preserves the prompt + answer with labels, so you keep the full context.
|
|
33
|
-
|
|
34
|
-
### `ocmux` — The Project Manager
|
|
35
|
-
|
|
36
|
-
Each project gets its own tmux window with a dedicated `opencode serve` + TUI pane. Auto-restarts dead panes, pins window names, stores state in `.ocmux.json` (discovered upward like `.git`).
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
ocmux serve ~/projects/myapp # create
|
|
40
|
-
ocmux list # list all
|
|
41
|
-
ocmux ~/projects/myapp # switch
|
|
42
|
-
ocmux kill ~/projects/myapp # remove
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### `tgagentp` — The Telegram Bridge
|
|
46
|
-
|
|
47
|
-
A Telegram bot that routes messages to your OpenCode servers. Multi-server aware, slash-commands for everything.
|
|
48
|
-
|
|
49
|
-
**Slash commands:**
|
|
50
|
-
|
|
51
|
-
| Command | What it does |
|
|
52
|
-
|---|---|
|
|
53
|
-
| `/servers` | List/switch between ocmux projects |
|
|
54
|
-
| `/sessions` | List/switch/create/rename sessions |
|
|
55
|
-
| `/agents` | List/switch active agent |
|
|
56
|
-
| `/models` | List providers and models |
|
|
57
|
-
| `/queue <msg>` | Queue message when busy — auto-sent after current task finishes (replies chain!) |
|
|
58
|
-
| `/record` | Record conversation for `agentp` context injection |
|
|
59
|
-
| `/think` | Toggle real-time thinking message forwarding |
|
|
60
|
-
| `/cancel` | Abort the running prompt |
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## The Agentp Gateway
|
|
65
|
-
|
|
66
|
-
The killer integration: `agentp` and `tgagentp` talk to each other through a tiny HTTP gateway.
|
|
67
|
-
|
|
68
|
-
- **`agentp --tg`** forwards the answer to your Telegram chat after every pipe.
|
|
69
|
-
- **`agentp --qa`** auto-detects tgagentp and sends the full QA pair (rulers + prompt + answer).
|
|
70
|
-
- **`/record`** buffers the Telegram conversation. On the next `agentp` call, the gateway returns the buffer, and `--qa` prepends it to stdout with rulers — so OpenCode sees the full Telegram thread as context.
|
|
71
|
-
- **`agentp --flush`** clears the buffer without prepending.
|
|
72
|
-
- **`agentp --getLast 5`** retrieves the last 5 assistant answers from session history.
|
|
73
|
-
|
|
74
|
-
```vim
|
|
75
|
-
:'<,'>!agentp --qa --tg " answer in editor + Telegram
|
|
76
|
-
:'<,'>!agentp --qa --flush " flush recorded buffer
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
All of this with **zero npm dependencies** — just Node.js 18+ stdlib.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Why This Setup Works
|
|
84
|
-
|
|
85
|
-
1. **Session API, not TUI hooks** — messages go through `POST /session/:id/message`, which returns synchronously. No fragile TUI scraping.
|
|
86
|
-
2. **Per-project tmux isolation** — each project gets its own `opencode serve` process. Switch with a single command.
|
|
87
|
-
3. **Graceful degradation** — `--tg` in auto mode silently skips Telegram if tgagentp isn't running. Explicit `--tg` errors pre-send, warns post-send.
|
|
88
|
-
4. **10s HTTP timeout on every request** — nothing ever hangs.
|
|
89
|
-
5. **Async processing** — tgagentp never blocks the polling loop. Commands stay responsive even while a prompt runs.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Quick Start
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
npm install -g agentp
|
|
97
|
-
|
|
98
|
-
# Start a project server
|
|
99
|
-
ocmux serve ~/projects/myapp
|
|
100
|
-
|
|
101
|
-
# Pipe a prompt
|
|
102
|
-
printf "Explain this codebase" | agentp
|
|
103
|
-
|
|
104
|
-
# With Telegram (set up a bot with @BotFather first)
|
|
105
|
-
export TELEGRAM_BOT_TOKEN="your-token"
|
|
106
|
-
tgagentp
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
If your OpenCode server is password-protected, set `OPENCODE_SERVER_PASSWORD`.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## Links
|
|
114
|
-
|
|
115
|
-
- **GitHub:** [github.com/bitifet/agentp](https://github.com/bitifet/agentp)
|
|
116
|
-
- **npm:** [npmjs.com/package/agentp](https://www.npmjs.com/package/agentp)
|
|
117
|
-
- **OpenCode:** [github.com/anthropics/claude-code](https://github.com/anthropics/claude-code)
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
*Feedback? Issues? PRs welcome.*
|