@agentproto/cli 0.1.2 → 0.3.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/dist/cli.mjs +59584 -10574
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +18306 -5925
- package/dist/index.mjs.map +1 -1
- package/dist/registry/builtins.mjs +6 -2
- package/dist/registry/builtins.mjs.map +1 -1
- package/dist/registry/manifest.mjs +6 -2
- package/dist/registry/manifest.mjs.map +1 -1
- package/dist/registry/plugins.mjs +8 -4
- package/dist/registry/plugins.mjs.map +1 -1
- package/dist/registry/runtime.mjs +7 -1
- package/dist/registry/runtime.mjs.map +1 -1
- package/dist/util/credentials.mjs +6 -2
- package/dist/util/credentials.mjs.map +1 -1
- package/package.json +24 -7
- package/skill/agentproto/SKILL.md +261 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentproto
|
|
3
|
+
description:
|
|
4
|
+
Operate the agentproto daemon — spawn agent sessions (claude-code,
|
|
5
|
+
hermes, …), drive imported MCP tools through the proxy, manage PTY
|
|
6
|
+
terminals, and control the optional cloud tunnel. Use when a task needs
|
|
7
|
+
to start / check / troubleshoot the runtime, drive a long-lived agent
|
|
8
|
+
session, or author tools/drivers in @agentproto/*.
|
|
9
|
+
metadata:
|
|
10
|
+
tags: agentproto, daemon, mcp, sessions, tunnel, adapters, agent-cli
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to use
|
|
14
|
+
|
|
15
|
+
- Start / check / troubleshoot the agentproto daemon.
|
|
16
|
+
- Spawn or continue a multi-turn agent session (`start_agent_session`,
|
|
17
|
+
`prompt_agent_session`).
|
|
18
|
+
- Drive imported MCP tools proxied through the daemon (`mcp_imported_call`).
|
|
19
|
+
- Diagnose why `mcp__agentproto__*` tools are missing from a client session.
|
|
20
|
+
- Author or extend a tool/driver in `@agentproto/driver-agent-cli`.
|
|
21
|
+
|
|
22
|
+
## Daemon vs tunnel — which to run
|
|
23
|
+
|
|
24
|
+
| What you need | What to run |
|
|
25
|
+
|---|---|
|
|
26
|
+
| Local-only: Claude Code (or another same-machine client) drives sessions | `agentproto serve` — daemon only, loopback |
|
|
27
|
+
| Cloud / remote clients need the daemon (web app, mobile, another machine) | `agentproto serve --connect wss://<host>/api/v1/agentproto/tunnel` |
|
|
28
|
+
|
|
29
|
+
The tunnel is an outbound WebSocket from your machine to the host. Remote
|
|
30
|
+
operators drive local spawns through it. Without it, the daemon is reachable
|
|
31
|
+
only at `127.0.0.1:<port>`.
|
|
32
|
+
|
|
33
|
+
## Health check + startup
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 1. Is it up?
|
|
37
|
+
curl -s http://127.0.0.1:18790/health
|
|
38
|
+
# → {"status":"ok","workspace":"…","uptimeMs":…}
|
|
39
|
+
|
|
40
|
+
# Note: when daemon.port is set to a non-default value (e.g. 18791),
|
|
41
|
+
# adjust the port in the URL above. /health is always authoritative;
|
|
42
|
+
# runtime.json may not exist for all launch configurations.
|
|
43
|
+
|
|
44
|
+
# 2. If dead, start it:
|
|
45
|
+
agentproto serve & # foreground, local only
|
|
46
|
+
agentproto daemon start # if installed as a launchd/systemd service
|
|
47
|
+
# Or with tunnel:
|
|
48
|
+
agentproto serve --connect wss://<host>/api/v1/agentproto/tunnel
|
|
49
|
+
|
|
50
|
+
# 3. After daemon is up, reconnect the MCP client:
|
|
51
|
+
# Claude Desktop / Cursor / Claude Code → disconnect and reconnect
|
|
52
|
+
# the agentproto server in settings. The mcp__agentproto__* tools
|
|
53
|
+
# reappear once reconnected.
|
|
54
|
+
|
|
55
|
+
# 4. Adapters not resolving?
|
|
56
|
+
agentproto install claude-code # re-install the adapter
|
|
57
|
+
agentproto install hermes
|
|
58
|
+
agentproto sessions start claude-code --workspace my-project
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## MCP bridge for Claude Desktop
|
|
62
|
+
|
|
63
|
+
The daemon exposes an MCP endpoint at `POST /mcp`. To use it from Claude
|
|
64
|
+
Desktop, add a stdio bridge in `claude_desktop_config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
"agentproto": {
|
|
68
|
+
"command": "node",
|
|
69
|
+
"args": ["/path/to/@agentproto/cli/apps/mcp-bridge.mjs"],
|
|
70
|
+
"env": {
|
|
71
|
+
"AGENTPROTO_MCP_URL": "http://127.0.0.1:18790/mcp"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Port gotcha:** if `daemon.port` in your `~/.agentproto/config.json` is not
|
|
77
|
+
`18790` (the default), set `AGENTPROTO_MCP_URL` to match. Without it the
|
|
78
|
+
bridge silently connects to the wrong port and the tools don't appear.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Check your configured port:
|
|
82
|
+
agentproto config get daemon.port
|
|
83
|
+
# → 18791
|
|
84
|
+
|
|
85
|
+
# Then update AGENTPROTO_MCP_URL in claude_desktop_config.json:
|
|
86
|
+
# "AGENTPROTO_MCP_URL": "http://127.0.0.1:18791/mcp"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
After editing `claude_desktop_config.json`, restart Claude Desktop.
|
|
90
|
+
|
|
91
|
+
## Adapters
|
|
92
|
+
|
|
93
|
+
| Slug | Protocol | When to pick |
|
|
94
|
+
|------|----------|-------------|
|
|
95
|
+
| `claude-code` | acp | Long-lived ACP process via `@agentclientprotocol/claude-agent-acp`. Bidirectional, multimodal. Best for extended interactive sessions. |
|
|
96
|
+
| `claude-code-print` | print | `claude -p --output-format stream-json` — one subprocess per turn, no ACP wrapper, no stale-proxy race. Session continuity via `--resume`. ~200–400 ms cold-start per turn. Simpler and more reliable. |
|
|
97
|
+
| `hermes` | acp | Hermes via ACP. |
|
|
98
|
+
| `mastra-agent` | acp | First-party agent — an AIP-42 `AGENT.md` run as a live Mastra agent (our loop, our models, routed from the spawn env). SQLite memory + workspace tools. Standalone via `agentproto-mastra acp`. |
|
|
99
|
+
| `opencode` / `codex` / `openclaw` | acp / proprietary | Various. |
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
agentproto install claude-code # idempotent (skips if already installed)
|
|
103
|
+
agentproto install claude-code --force # reinstall regardless
|
|
104
|
+
|
|
105
|
+
# One-shot turn
|
|
106
|
+
agentproto run claude-code --cwd . --prompt "summarise this repo"
|
|
107
|
+
agentproto run claude-code-print --cwd . --prompt "summarise this repo"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Resolver parent-package fallback:** slug `claude-code-print` resolves via
|
|
111
|
+
`@agentproto/adapter-claude-code` (the `claudeCodePrint` named export). No
|
|
112
|
+
separate npm package is needed for variant adapters exported from the same
|
|
113
|
+
package.
|
|
114
|
+
|
|
115
|
+
## MCP tools reference
|
|
116
|
+
|
|
117
|
+
These appear as `mcp__agentproto__*` (or whatever alias your client uses) when
|
|
118
|
+
the daemon is connected.
|
|
119
|
+
|
|
120
|
+
**Sessions — agents:**
|
|
121
|
+
|
|
122
|
+
| Tool | Purpose |
|
|
123
|
+
|------|---------|
|
|
124
|
+
| `list_adapters` | Installed `@agentproto/adapter-*` slugs |
|
|
125
|
+
| `start_agent_session { adapter, cwd?, prompt?, label?, model? }` | Spawn a long-lived agent session → `{ sessionId }` |
|
|
126
|
+
| `prompt_agent_session { sessionId, prompt }` | Follow-up turn (queued if session is mid-turn) |
|
|
127
|
+
| `get_agent_session_output { sessionId, since?, lastN?, waitForTurnEnd?, timeoutMs? }` | Incremental cursor read; long-poll until turn ends |
|
|
128
|
+
| `kill_agent_session { sessionId }` | SIGTERM the session |
|
|
129
|
+
| `list_sessions { kind?, onlyAlive?, status? }` | All sessions |
|
|
130
|
+
|
|
131
|
+
**`get_agent_session_output` cursor pattern (eliminates polling):**
|
|
132
|
+
```
|
|
133
|
+
# First call — get initial context + seed cursor
|
|
134
|
+
out = get_agent_session_output { sessionId, lastN: 20 }
|
|
135
|
+
cursor = out.nextCursor
|
|
136
|
+
|
|
137
|
+
# Send prompt, then long-poll for turn end
|
|
138
|
+
prompt_agent_session { sessionId, prompt: "..." }
|
|
139
|
+
out = get_agent_session_output { sessionId, since: cursor, waitForTurnEnd: true }
|
|
140
|
+
# out.lines contains only the new lines from that turn
|
|
141
|
+
cursor = out.nextCursor
|
|
142
|
+
|
|
143
|
+
# Repeat — only new lines, no repeated context
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Sessions — PTY terminals:**
|
|
147
|
+
|
|
148
|
+
| Tool | Purpose |
|
|
149
|
+
|------|---------|
|
|
150
|
+
| `start_terminal_session { argv, cwd?, cols?, rows?, name? }` | PTY-backed process |
|
|
151
|
+
| `write_terminal_input { sessionId, text }` | Send keystrokes |
|
|
152
|
+
| `read_terminal_output { sessionId, lastBytes? }` | Snapshot (base64) |
|
|
153
|
+
| `kill_terminal_session { sessionId }` | SIGTERM |
|
|
154
|
+
|
|
155
|
+
**Tunnel:**
|
|
156
|
+
|
|
157
|
+
| Tool | Purpose |
|
|
158
|
+
|------|---------|
|
|
159
|
+
| `remote_enable { provider?, targetPort? }` | Open tunnel → `{ url, token }` |
|
|
160
|
+
| `remote_disable` | Close tunnel |
|
|
161
|
+
| `remote_status` | Tunnel health |
|
|
162
|
+
|
|
163
|
+
**Imported MCP proxy:**
|
|
164
|
+
|
|
165
|
+
| Tool | Purpose |
|
|
166
|
+
|------|---------|
|
|
167
|
+
| `mcp_imported_status` | Health of every imported alias |
|
|
168
|
+
| `list_imported_mcps` / `list_discovered_mcps` | Available MCPs |
|
|
169
|
+
| `import_mcp { sourceMcpId, alias? }` / `remove_imported_mcp { id }` | Curate |
|
|
170
|
+
| `mcp_imported_list_tools { alias }` | Tool list from an alias |
|
|
171
|
+
| `mcp_imported_call { alias, toolName, args? }` | Invoke a proxied tool |
|
|
172
|
+
|
|
173
|
+
**Filesystem (workspace-scoped):**
|
|
174
|
+
|
|
175
|
+
`read_file`, `write_file`, `list_directory`, `create_directory`, `delete_file`, `get_file_info`
|
|
176
|
+
|
|
177
|
+
**Shell (allowlist-gated):**
|
|
178
|
+
|
|
179
|
+
| Tool | Purpose |
|
|
180
|
+
|------|---------|
|
|
181
|
+
| `execute_command { command, args?, cwd?, stdin?, timeoutMs?, async? }` | Sync by default; `async: true` → returns `{ commandId }` immediately |
|
|
182
|
+
| `get_command_output { commandId }` | Poll stdout/stderr/status of an async command |
|
|
183
|
+
| `cancel_command { commandId }` | SIGTERM a running async command |
|
|
184
|
+
|
|
185
|
+
**Async pattern for long commands (builds, `claude -p`, tests):**
|
|
186
|
+
```
|
|
187
|
+
# Start without blocking MCP transport
|
|
188
|
+
r = execute_command { command: "pnpm", args: ["test"], async: true }
|
|
189
|
+
commandId = r.commandId
|
|
190
|
+
|
|
191
|
+
# Poll until done
|
|
192
|
+
loop:
|
|
193
|
+
out = get_command_output { commandId }
|
|
194
|
+
if out.status != "running": break
|
|
195
|
+
sleep 3s
|
|
196
|
+
|
|
197
|
+
# Result available
|
|
198
|
+
out.exitCode, out.stdout, out.stderr
|
|
199
|
+
|
|
200
|
+
# Or cancel if needed
|
|
201
|
+
cancel_command { commandId }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Allowlist setup (if execute_command is blocked):**
|
|
205
|
+
```bash
|
|
206
|
+
# Dev preset — one-liner:
|
|
207
|
+
echo '{"version":1,"commands":["claude","gh","pnpm","node","git","npx"]}' > .agentproto/allowed-commands.json
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## ToolSearch note
|
|
211
|
+
|
|
212
|
+
The daemon's session tools are **deferred** in Claude Code. Keyword search
|
|
213
|
+
finds nothing — use exact-name `select:`:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
ToolSearch("select:mcp__agentproto__start_agent_session,mcp__agentproto__list_sessions,mcp__agentproto__get_agent_session_output,mcp__agentproto__prompt_agent_session")
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Recovery playbook
|
|
220
|
+
|
|
221
|
+
**"list_adapters returns empty"** — daemon was restarted but adapters weren't
|
|
222
|
+
re-installed on the global `NODE_PATH`:
|
|
223
|
+
```bash
|
|
224
|
+
agentproto install claude-code
|
|
225
|
+
agentproto install hermes # if needed
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**"mcp__agentproto__* tools missing from session"** — MCP bridge disconnected:
|
|
229
|
+
1. Verify daemon: `curl -s http://127.0.0.1:<port>/health`
|
|
230
|
+
2. If dead: `agentproto serve &` or `agentproto daemon start`
|
|
231
|
+
3. Reconnect the server in Claude Desktop / Cursor settings
|
|
232
|
+
|
|
233
|
+
**"bridge connects but tools still empty"** — port mismatch:
|
|
234
|
+
```bash
|
|
235
|
+
agentproto config get daemon.port # e.g. 18791
|
|
236
|
+
# Update AGENTPROTO_MCP_URL in claude_desktop_config.json to match
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## CLI quick reference
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
agentproto auth <login|status|logout> authenticate against a remote host
|
|
243
|
+
agentproto config <show|get|set|unset|edit> ~/.agentproto/config.json
|
|
244
|
+
agentproto daemon <install|uninstall|start|stop|status|logs> OS service management
|
|
245
|
+
agentproto install <slug> install an adapter's underlying CLI
|
|
246
|
+
agentproto setup <slug> re-run adapter setup (idempotent)
|
|
247
|
+
agentproto run <slug> --cwd . --prompt … one-shot turn, exit
|
|
248
|
+
agentproto serve [--connect <wss>] long-running daemon (HTTP+MCP+sessions)
|
|
249
|
+
agentproto workspace <add|list|remove|use> register spawn directories
|
|
250
|
+
agentproto sessions [...] browse + control live sessions
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Safety rails
|
|
254
|
+
|
|
255
|
+
The daemon executes shell commands gated by `.agentproto/allowed-commands.json`
|
|
256
|
+
and can drive imported tools that act as the user (browser, social, payments).
|
|
257
|
+
- Confirm before anything that posts, pays, sends, or deletes.
|
|
258
|
+
- `runtime.json`, `credentials.json`, `remote.json` carry auth tokens — never
|
|
259
|
+
print or commit them.
|
|
260
|
+
- Don't kill the daemon casually if remote clients are attached — check
|
|
261
|
+
`GET /sessions` first.
|