claws-code 0.8.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/.claude/commands/claws-auto.md +90 -0
- package/.claude/commands/claws-bin.md +28 -0
- package/.claude/commands/claws-cleanup.md +28 -0
- package/.claude/commands/claws-do.md +82 -0
- package/.claude/commands/claws-fix.md +40 -0
- package/.claude/commands/claws-goal.md +111 -0
- package/.claude/commands/claws-help.md +54 -0
- package/.claude/commands/claws-plan.md +103 -0
- package/.claude/commands/claws-report.md +29 -0
- package/.claude/commands/claws-status.md +37 -0
- package/.claude/commands/claws-update.md +32 -0
- package/.claude/commands/claws.md +64 -0
- package/.claude/rules/claws-default-behavior.md +76 -0
- package/.claude/settings.json +112 -0
- package/.claude/settings.local.json +19 -0
- package/.claude/skills/claws-auto-engine/SKILL.md +97 -0
- package/.claude/skills/claws-goal-tracker/SKILL.md +106 -0
- package/.claude/skills/claws-prompt-templates/SKILL.md +203 -0
- package/.claude/skills/claws-wave-lead/SKILL.md +126 -0
- package/.claude/skills/claws-wave-subworker/SKILL.md +60 -0
- package/CHANGELOG.md +1949 -0
- package/LICENSE +21 -0
- package/README.md +420 -0
- package/bin/cli.js +84 -0
- package/cli.js +223 -0
- package/docs/ARCHITECTURE.md +511 -0
- package/docs/event-protocol.md +588 -0
- package/docs/features.md +562 -0
- package/docs/guide.md +891 -0
- package/docs/index.html +716 -0
- package/docs/protocol.md +323 -0
- package/extension/.vscodeignore +15 -0
- package/extension/CHANGELOG.md +1906 -0
- package/extension/LICENSE +21 -0
- package/extension/README.md +137 -0
- package/extension/docs/features.md +424 -0
- package/extension/docs/protocol.md +197 -0
- package/extension/esbuild.mjs +25 -0
- package/extension/icon.png +0 -0
- package/extension/native/.metadata.json +10 -0
- package/extension/native/node-pty/LICENSE +69 -0
- package/extension/native/node-pty/README.md +165 -0
- package/extension/native/node-pty/lib/conpty_console_list_agent.js +16 -0
- package/extension/native/node-pty/lib/conpty_console_list_agent.js.map +1 -0
- package/extension/native/node-pty/lib/eventEmitter2.js +47 -0
- package/extension/native/node-pty/lib/eventEmitter2.js.map +1 -0
- package/extension/native/node-pty/lib/index.js +52 -0
- package/extension/native/node-pty/lib/index.js.map +1 -0
- package/extension/native/node-pty/lib/interfaces.js +7 -0
- package/extension/native/node-pty/lib/interfaces.js.map +1 -0
- package/extension/native/node-pty/lib/shared/conout.js +11 -0
- package/extension/native/node-pty/lib/shared/conout.js.map +1 -0
- package/extension/native/node-pty/lib/terminal.js +190 -0
- package/extension/native/node-pty/lib/terminal.js.map +1 -0
- package/extension/native/node-pty/lib/types.js +7 -0
- package/extension/native/node-pty/lib/types.js.map +1 -0
- package/extension/native/node-pty/lib/unixTerminal.js +346 -0
- package/extension/native/node-pty/lib/unixTerminal.js.map +1 -0
- package/extension/native/node-pty/lib/utils.js +39 -0
- package/extension/native/node-pty/lib/utils.js.map +1 -0
- package/extension/native/node-pty/lib/windowsConoutConnection.js +125 -0
- package/extension/native/node-pty/lib/windowsConoutConnection.js.map +1 -0
- package/extension/native/node-pty/lib/windowsPtyAgent.js +320 -0
- package/extension/native/node-pty/lib/windowsPtyAgent.js.map +1 -0
- package/extension/native/node-pty/lib/windowsTerminal.js +199 -0
- package/extension/native/node-pty/lib/windowsTerminal.js.map +1 -0
- package/extension/native/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/extension/native/node-pty/lib/worker/conoutSocketWorker.js.map +1 -0
- package/extension/native/node-pty/package.json +64 -0
- package/extension/native/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/extension/native/node-pty/prebuilds/darwin-x64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
- package/extension/package-lock.json +605 -0
- package/extension/package.json +343 -0
- package/extension/scripts/bundle-native.mjs +104 -0
- package/extension/scripts/deploy-dev.mjs +60 -0
- package/extension/src/ansi-strip.ts +52 -0
- package/extension/src/backends/vscode/claws-pty.ts +483 -0
- package/extension/src/backends/vscode/status-bar.ts +99 -0
- package/extension/src/backends/vscode/vscode-backend.ts +282 -0
- package/extension/src/capture-store.ts +125 -0
- package/extension/src/event-log.ts +629 -0
- package/extension/src/event-schemas.ts +478 -0
- package/extension/src/extension.js +492 -0
- package/extension/src/extension.ts +873 -0
- package/extension/src/lifecycle-engine.ts +60 -0
- package/extension/src/lifecycle-rules.ts +171 -0
- package/extension/src/lifecycle-store.ts +506 -0
- package/extension/src/peer-registry.ts +176 -0
- package/extension/src/pipeline-registry.ts +82 -0
- package/extension/src/platform.ts +64 -0
- package/extension/src/protocol.ts +532 -0
- package/extension/src/server-config.ts +98 -0
- package/extension/src/server.ts +2210 -0
- package/extension/src/task-registry.ts +51 -0
- package/extension/src/terminal-backend.ts +211 -0
- package/extension/src/terminal-manager.ts +395 -0
- package/extension/src/topic-registry.ts +70 -0
- package/extension/src/topic-utils.ts +46 -0
- package/extension/src/transport.ts +45 -0
- package/extension/src/uninstall-cleanup.ts +232 -0
- package/extension/src/wave-registry.ts +314 -0
- package/extension/src/websocket-transport.ts +153 -0
- package/extension/tsconfig.json +23 -0
- package/lib/capabilities.js +145 -0
- package/lib/dry-run.js +43 -0
- package/lib/install.js +1018 -0
- package/lib/mcp-setup.js +92 -0
- package/lib/platform.js +240 -0
- package/lib/preflight.js +152 -0
- package/lib/shell-hook.js +343 -0
- package/lib/uninstall.js +162 -0
- package/lib/verify.js +166 -0
- package/mcp_server.js +3529 -0
- package/package.json +48 -0
- package/rules/claws-default-behavior.md +72 -0
- package/scripts/_helpers/atomic-file.mjs +137 -0
- package/scripts/_helpers/fix-repair.js +64 -0
- package/scripts/_helpers/json-safe.mjs +218 -0
- package/scripts/bump-version.sh +84 -0
- package/scripts/codegen/gen-docs.mjs +61 -0
- package/scripts/codegen/gen-json-schema.mjs +62 -0
- package/scripts/codegen/gen-mcp-tools.mjs +358 -0
- package/scripts/codegen/gen-types.mjs +172 -0
- package/scripts/codegen/index.mjs +42 -0
- package/scripts/dev-hooks/check-extension-dirs.js +77 -0
- package/scripts/dev-hooks/check-open-claws-terminals.js +70 -0
- package/scripts/dev-hooks/check-stale-main.js +55 -0
- package/scripts/dev-hooks/check-tag-pushed.js +51 -0
- package/scripts/dev-hooks/check-tag-vs-main.js +56 -0
- package/scripts/dev-vsix-install.sh +60 -0
- package/scripts/fix.sh +702 -0
- package/scripts/gen-client-types.mjs +81 -0
- package/scripts/git-hooks/pre-commit +31 -0
- package/scripts/hooks/lifecycle-state.js +61 -0
- package/scripts/hooks/package.json +4 -0
- package/scripts/hooks/post-tool-use-claws.js +292 -0
- package/scripts/hooks/pre-bash-no-verify-block.js +72 -0
- package/scripts/hooks/pre-tool-use-claws.js +206 -0
- package/scripts/hooks/session-start-claws.js +97 -0
- package/scripts/hooks/stop-claws.js +88 -0
- package/scripts/inject-claude-md.js +205 -0
- package/scripts/inject-dev-hooks.js +96 -0
- package/scripts/inject-global-claude-md.js +140 -0
- package/scripts/inject-settings-hooks.js +370 -0
- package/scripts/install.ps1 +146 -0
- package/scripts/install.sh +1729 -0
- package/scripts/monitor-arm-watch.js +155 -0
- package/scripts/rebuild-node-pty.sh +245 -0
- package/scripts/report.sh +232 -0
- package/scripts/shell-hook.fish +164 -0
- package/scripts/shell-hook.ps1 +33 -0
- package/scripts/shell-hook.sh +232 -0
- package/scripts/stream-events.js +399 -0
- package/scripts/terminal-wrapper.sh +36 -0
- package/scripts/test-enforcement.sh +132 -0
- package/scripts/test-install.sh +174 -0
- package/scripts/test-installer-parity.sh +135 -0
- package/scripts/test-template-enforcement.sh +76 -0
- package/scripts/uninstall.sh +143 -0
- package/scripts/update.sh +337 -0
- package/scripts/verify-release.sh +323 -0
- package/scripts/verify-wrapped.sh +194 -0
- package/templates/CLAUDE.global.md +135 -0
- package/templates/CLAUDE.project.md +37 -0
package/docs/protocol.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# Claws Protocol Specification v1
|
|
2
|
+
|
|
3
|
+
## Transport
|
|
4
|
+
|
|
5
|
+
- **Unix socket** (default): workspace-relative path, default `.claws/claws.sock`. Multi-root workspaces get one socket per folder.
|
|
6
|
+
- **WebSocket** (planned, v0.6): `ws://host:port` with token auth.
|
|
7
|
+
|
|
8
|
+
## Framing
|
|
9
|
+
|
|
10
|
+
Newline-delimited JSON. Each message is one JSON object terminated by `\n`. Client sends requests; server sends responses.
|
|
11
|
+
|
|
12
|
+
## Requests
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{ "id": 1, "cmd": "list" }
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| Field | Type | Required | Description |
|
|
19
|
+
|---|---|---|---|
|
|
20
|
+
| `id` | number \| string | yes | Echoed back by the server. Clients use it to correlate responses. |
|
|
21
|
+
| `cmd` | string | yes | Command name (see below). |
|
|
22
|
+
| `protocol` | string | no | Must be `"claws/1"` if present. Absent = treated as `claws/1`. Any other value → rejected with `ok:false, error:"incompatible protocol version"`. |
|
|
23
|
+
| `clientName` | string | no | Optional client label (e.g. `"claws-mcp"`) for server-side logging. |
|
|
24
|
+
| `clientVersion` | string | no | SemVer string. If present, the server compares against its own extension version and logs a one-shot drift warning at ≥ 1 minor release behind. |
|
|
25
|
+
|
|
26
|
+
## Responses
|
|
27
|
+
|
|
28
|
+
Every response includes the following envelope fields:
|
|
29
|
+
|
|
30
|
+
| Field | Type | Always present | Description |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| `ok` | boolean | yes | `true` on success, `false` on error. |
|
|
33
|
+
| `id` | number \| string | yes | The request's `id`, echoed for legacy clients. |
|
|
34
|
+
| `rid` | number \| string | yes | The request's `id`, guaranteed un-shadowed by body fields. **New clients should read `rid`, not `id`** — some command responses put their own `id` field in the body (e.g. `create` returns a new terminal id). |
|
|
35
|
+
| `protocol` | string | yes | Always `"claws/1"`. |
|
|
36
|
+
| `error` | string | on error only | Human-readable description. |
|
|
37
|
+
|
|
38
|
+
On error:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{ "id": 1, "rid": 1, "ok": false, "protocol": "claws/1", "error": "unknown cmd: xyz" }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
### `list`
|
|
49
|
+
|
|
50
|
+
Enumerate all open VS Code terminals.
|
|
51
|
+
|
|
52
|
+
**Request:** `{ "id": N, "cmd": "list" }`
|
|
53
|
+
|
|
54
|
+
**Response:**
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
58
|
+
"terminals": [
|
|
59
|
+
{
|
|
60
|
+
"id": "1",
|
|
61
|
+
"name": "Terminal Name",
|
|
62
|
+
"pid": 12345,
|
|
63
|
+
"hasShellIntegration": true,
|
|
64
|
+
"active": false,
|
|
65
|
+
"logPath": "/absolute/path/to/pty.log"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `create`
|
|
72
|
+
|
|
73
|
+
Open a new terminal.
|
|
74
|
+
|
|
75
|
+
**Request:**
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"id": N,
|
|
79
|
+
"cmd": "create",
|
|
80
|
+
"name": "my-terminal", // optional, default "claws"
|
|
81
|
+
"cwd": "/path/to/dir", // optional, default workspace root
|
|
82
|
+
"wrapped": true, // optional, default false — Pseudoterminal with in-memory capture
|
|
83
|
+
"show": true // optional, default true
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Response:**
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
91
|
+
"id": "5", // NEW terminal id — prefer reading `rid` for the request correlation
|
|
92
|
+
"wrapped": true,
|
|
93
|
+
"logPath": null // always null for Pseudoterminal-backed wrapped terminals (buffer is in-memory)
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `show`
|
|
98
|
+
|
|
99
|
+
Focus a terminal in the panel.
|
|
100
|
+
|
|
101
|
+
**Request:** `{ "id": N, "cmd": "show", "id": "5", "preserveFocus": true }`
|
|
102
|
+
|
|
103
|
+
**Response:** `{ "id": N, "rid": N, "protocol": "claws/1", "ok": true }`
|
|
104
|
+
|
|
105
|
+
### `send`
|
|
106
|
+
|
|
107
|
+
Send text into a terminal. Automatically wraps multi-line text in bracketed paste.
|
|
108
|
+
|
|
109
|
+
**Request:**
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"id": N,
|
|
113
|
+
"cmd": "send",
|
|
114
|
+
"id": "5",
|
|
115
|
+
"text": "echo hello",
|
|
116
|
+
"newline": true, // optional, default true — append Enter after text
|
|
117
|
+
"paste": false // optional — force bracketed paste off
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Response:**
|
|
122
|
+
```json
|
|
123
|
+
{ "id": N, "rid": N, "protocol": "claws/1", "ok": true, "mode": "wrapped" }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`mode` is `"wrapped"` if the send went through the Pseudoterminal write path (byte-accurate) or `"unwrapped"` if it went through VS Code's `terminal.sendText` API (user-visible text substitution possible).
|
|
127
|
+
|
|
128
|
+
### `exec`
|
|
129
|
+
|
|
130
|
+
Run a shell command and wait for completion. Uses VS Code shell integration when available; falls back to a "degraded" mode when not.
|
|
131
|
+
|
|
132
|
+
**Request:**
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"id": N,
|
|
136
|
+
"cmd": "exec",
|
|
137
|
+
"id": "5",
|
|
138
|
+
"command": "npm test",
|
|
139
|
+
"timeoutMs": 120000 // optional — falls back to claws.execTimeoutMs (default 180000)
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Response (integration available):**
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
147
|
+
"event": {
|
|
148
|
+
"seq": 42, "terminalId": "5", "terminalName": "worker",
|
|
149
|
+
"commandLine": "npm test", "output": "PASS ...", "exitCode": 0,
|
|
150
|
+
"startedAt": 1713168000000, "endedAt": 1713168001000
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Response (no shell integration):**
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
159
|
+
"degraded": true,
|
|
160
|
+
"note": "no shell integration active; output not captured via exec — use readLog on wrapped terminals"
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `readLog`
|
|
165
|
+
|
|
166
|
+
Read a wrapped terminal's capture buffer with optional ANSI stripping.
|
|
167
|
+
|
|
168
|
+
**Request:**
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"id": N,
|
|
172
|
+
"cmd": "readLog",
|
|
173
|
+
"id": "5",
|
|
174
|
+
"offset": 0,
|
|
175
|
+
"limit": 524288,
|
|
176
|
+
"strip": true
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Response:**
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
184
|
+
"bytes": "cleaned text content...",
|
|
185
|
+
"offset": 0,
|
|
186
|
+
"nextOffset": 1234,
|
|
187
|
+
"totalSize": 5678,
|
|
188
|
+
"truncated": false,
|
|
189
|
+
"logPath": null
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### `poll`
|
|
194
|
+
|
|
195
|
+
Drain shell-integration command-completion events since a cursor.
|
|
196
|
+
|
|
197
|
+
**Request:** `{ "id": N, "cmd": "poll", "since": 0, "limit": 50 }`
|
|
198
|
+
|
|
199
|
+
**Response:**
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"id": N, "rid": N, "protocol": "claws/1", "ok": true,
|
|
203
|
+
"events": [ /* HistoryEvent[] */ ],
|
|
204
|
+
"cursor": 42,
|
|
205
|
+
"limit": 50,
|
|
206
|
+
"truncated": false
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
- `limit` — effective cap applied to this response. Client-requested `limit` is an upper bound; the server additionally clamps to `claws.pollLimit` (default 100).
|
|
211
|
+
- `truncated` — `true` when more events matched `since` than the limit allowed; you're reading the tail slice.
|
|
212
|
+
|
|
213
|
+
Note: `poll` relies on VS Code shell integration (`onDidEndTerminalShellExecution`), which is unreliable in wrapped terminals and TUI sessions. For reliable output capture, use `readLog` on wrapped terminals.
|
|
214
|
+
|
|
215
|
+
### `close`
|
|
216
|
+
|
|
217
|
+
Dispose a terminal. Idempotent — closing an already-closed or never-known id is not an error.
|
|
218
|
+
|
|
219
|
+
**Request:** `{ "id": N, "cmd": "close", "id": "5" }`
|
|
220
|
+
|
|
221
|
+
**Response:** `{ "id": N, "rid": N, "protocol": "claws/1", "ok": true, "alreadyClosed": false }`
|
|
222
|
+
|
|
223
|
+
When the id was unknown (already closed, never created, or race with auto-cleanup):
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{ "id": N, "rid": N, "protocol": "claws/1", "ok": true, "alreadyClosed": true }
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Clients don't need local bookkeeping to avoid racing their cleanup with the extension's.
|
|
230
|
+
|
|
231
|
+
### `introspect`
|
|
232
|
+
|
|
233
|
+
Return a structured snapshot of extension + host state. Powers both the `/claws-introspect` slash command and the in-UI `Claws: Health Check` command — both paths render identical data.
|
|
234
|
+
|
|
235
|
+
**Request:** `{ "id": N, "cmd": "introspect" }`
|
|
236
|
+
|
|
237
|
+
**Response:**
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"id": N, "rid": N, "ok": true, "protocol": "claws/1",
|
|
241
|
+
"extensionVersion": "0.5.0",
|
|
242
|
+
"nodeVersion": "v20.11.1",
|
|
243
|
+
"electronAbi": 125,
|
|
244
|
+
"platform": "darwin-arm64",
|
|
245
|
+
"nodePty": {
|
|
246
|
+
"loaded": true,
|
|
247
|
+
"loadedFrom": "/path/to/extension/native/node-pty",
|
|
248
|
+
"error": null
|
|
249
|
+
},
|
|
250
|
+
"servers": [
|
|
251
|
+
{ "workspace": "/absolute/workspace/path", "socket": "/absolute/workspace/path/.claws/claws.sock" }
|
|
252
|
+
],
|
|
253
|
+
"terminals": 3,
|
|
254
|
+
"uptime_ms": 1234567
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- `nodePty.loaded = false` indicates pipe-mode fallback is active — the status bar goes warning-yellow.
|
|
259
|
+
- `servers` is an array because multi-root workspaces run one server per folder.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Error Codes
|
|
264
|
+
|
|
265
|
+
All errors return `{ "ok": false, "error": "message" }`. Common errors:
|
|
266
|
+
|
|
267
|
+
| Error | Meaning |
|
|
268
|
+
|---|---|
|
|
269
|
+
| `unknown terminal id X` | Terminal ID not found (closed or never existed). Most commands return this on unknown id; `close` returns `ok:true, alreadyClosed:true` instead. |
|
|
270
|
+
| `terminal X is not wrapped (no log available)` | `readLog` called on an unwrapped terminal |
|
|
271
|
+
| `bad json` | Request could not be parsed as JSON |
|
|
272
|
+
| `unknown cmd: X` | Unrecognized command name |
|
|
273
|
+
| `incompatible protocol version (server: claws/1, client: …)` | Request's `protocol` field is not `"claws/1"` |
|
|
274
|
+
| `request too large` | A single request exceeded 1 MB — the connection is dropped |
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Versioning
|
|
279
|
+
|
|
280
|
+
Protocol version is exchanged in-band via the optional `protocol` field on every request (absent = `claws/1`). Every response carries the server's `protocol` string so clients can detect server-side upgrades.
|
|
281
|
+
|
|
282
|
+
For richer server metadata (extension version, node-pty state, socket list, uptime), call `introspect` after connecting.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Bus Topic Catalog (claws/2)
|
|
287
|
+
|
|
288
|
+
The claws/2 message bus carries server-push frames to subscribed peers. Subscribe with `claws_subscribe(topic)` (or the `subscribe` socket command); push frames arrive as:
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{ "push": "message", "protocol": "claws/2", "topic": "...", "from": "peerId", "payload": { ... }, "sentAt": 1234567890000 }
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Topic patterns: `*` matches one segment; `**` matches any depth. All topics are lowercase, dot-separated.
|
|
295
|
+
|
|
296
|
+
### Worker lifecycle
|
|
297
|
+
|
|
298
|
+
| Topic | Payload schema | Emitter | Consumer |
|
|
299
|
+
|---|---|---|---|
|
|
300
|
+
| `system.worker.completed` | `{ terminal_id, correlation_id, marker, completion_signal }` | `mcp_server.js` on `__CLAWS_DONE__` or `terminated` upgrade | Orchestrator, `claws_workers_wait` |
|
|
301
|
+
| `system.worker.terminated` | `{ terminal_id, correlation_id }` | Extension `onDidCloseTerminal` | `mcp_server.js` (upgrades to `completed`) |
|
|
302
|
+
| `system.worker.process_exited` | `{ terminal_id, correlation_id, exit_code, exited_at }` | Extension `ClawsPty.handleExit` (wrapped terminals) | `mcp_server.js` detach watcher |
|
|
303
|
+
| `system.worker.boot_failed` | `{ correlation_id, cause, pty_tail, timeout_ms }` | `mcp_server.js _gatePasteOnClaudeClaim` | Orchestrator |
|
|
304
|
+
|
|
305
|
+
### Terminal
|
|
306
|
+
|
|
307
|
+
| Topic | Payload schema | Emitter | Consumer |
|
|
308
|
+
|---|---|---|---|
|
|
309
|
+
| `system.terminal.paste_complete` | `{ terminalId, totalSize, ts }` | Extension send handler growth watcher (AF-3 Layer 2) | `mcp_server.js _waitForSubmitEvent` |
|
|
310
|
+
| `vehicle.<termId>.content` | `{ termId, size, ts }` | `mcp_server.js _pconnHandleData` on pty size change | `_submitWaiters`, `_workerReadyWaiters` |
|
|
311
|
+
|
|
312
|
+
### Peer lifecycle
|
|
313
|
+
|
|
314
|
+
| Topic | Payload schema | Emitter | Consumer |
|
|
315
|
+
|---|---|---|---|
|
|
316
|
+
| `system.peer.connected` | `{ peerId, role, peerName, correlationId }` | Extension on peer hello | `mcp_server.js` gate release for mission paste |
|
|
317
|
+
| `system.peer.disconnected` | `{ peerId }` | Extension on socket close | Peer registry cleanup |
|
|
318
|
+
|
|
319
|
+
### Tool invocation
|
|
320
|
+
|
|
321
|
+
| Topic | Payload schema | Emitter | Consumer |
|
|
322
|
+
|---|---|---|---|
|
|
323
|
+
| `tool.<toolName>.invoked` | `{ peerId, toolName, correlation_id }` | `mcp_server.js` on every MCP tool call | `_submitWaiters` (confirms claude is active) |
|