zcode-acp-server 0.1.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/LICENSE +201 -0
- package/README.md +167 -0
- package/README.zh-CN.md +163 -0
- package/dist/backend/client.d.ts +103 -0
- package/dist/backend/client.d.ts.map +1 -0
- package/dist/backend/client.js +344 -0
- package/dist/backend/client.js.map +1 -0
- package/dist/backend/credentials.d.ts +31 -0
- package/dist/backend/credentials.d.ts.map +1 -0
- package/dist/backend/credentials.js +93 -0
- package/dist/backend/credentials.js.map +1 -0
- package/dist/backend/index.d.ts +7 -0
- package/dist/backend/index.d.ts.map +1 -0
- package/dist/backend/index.js +6 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/backend/listener.d.ts +63 -0
- package/dist/backend/listener.d.ts.map +1 -0
- package/dist/backend/listener.js +138 -0
- package/dist/backend/listener.js.map +1 -0
- package/dist/backend/resolve.d.ts +11 -0
- package/dist/backend/resolve.d.ts.map +1 -0
- package/dist/backend/resolve.js +116 -0
- package/dist/backend/resolve.js.map +1 -0
- package/dist/backend/types.d.ts +164 -0
- package/dist/backend/types.d.ts.map +1 -0
- package/dist/backend/types.js +15 -0
- package/dist/backend/types.js.map +1 -0
- package/dist/config/model-cache.d.ts +20 -0
- package/dist/config/model-cache.d.ts.map +1 -0
- package/dist/config/model-cache.js +62 -0
- package/dist/config/model-cache.js.map +1 -0
- package/dist/config/options.d.ts +36 -0
- package/dist/config/options.d.ts.map +1 -0
- package/dist/config/options.js +171 -0
- package/dist/config/options.js.map +1 -0
- package/dist/config/runtime-model.d.ts +33 -0
- package/dist/config/runtime-model.d.ts.map +1 -0
- package/dist/config/runtime-model.js +96 -0
- package/dist/config/runtime-model.js.map +1 -0
- package/dist/handlers/dispatch.d.ts +15 -0
- package/dist/handlers/dispatch.d.ts.map +1 -0
- package/dist/handlers/dispatch.js +183 -0
- package/dist/handlers/dispatch.js.map +1 -0
- package/dist/handlers/extensions.d.ts +43 -0
- package/dist/handlers/extensions.d.ts.map +1 -0
- package/dist/handlers/extensions.js +310 -0
- package/dist/handlers/extensions.js.map +1 -0
- package/dist/handlers/io.d.ts +40 -0
- package/dist/handlers/io.d.ts.map +1 -0
- package/dist/handlers/io.js +55 -0
- package/dist/handlers/io.js.map +1 -0
- package/dist/handlers/server-requests.d.ts +34 -0
- package/dist/handlers/server-requests.d.ts.map +1 -0
- package/dist/handlers/server-requests.js +357 -0
- package/dist/handlers/server-requests.js.map +1 -0
- package/dist/handlers/session.d.ts +46 -0
- package/dist/handlers/session.d.ts.map +1 -0
- package/dist/handlers/session.js +738 -0
- package/dist/handlers/session.js.map +1 -0
- package/dist/handlers/slash.d.ts +16 -0
- package/dist/handlers/slash.d.ts.map +1 -0
- package/dist/handlers/slash.js +107 -0
- package/dist/handlers/slash.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/adapter.d.ts +136 -0
- package/dist/interaction/adapter.d.ts.map +1 -0
- package/dist/interaction/adapter.js +353 -0
- package/dist/interaction/adapter.js.map +1 -0
- package/dist/server.d.ts +73 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +97 -0
- package/dist/server.js.map +1 -0
- package/dist/tasks-index.d.ts +39 -0
- package/dist/tasks-index.d.ts.map +1 -0
- package/dist/tasks-index.js +152 -0
- package/dist/tasks-index.js.map +1 -0
- package/dist/translators/event-translator.d.ts +40 -0
- package/dist/translators/event-translator.d.ts.map +1 -0
- package/dist/translators/event-translator.js +214 -0
- package/dist/translators/event-translator.js.map +1 -0
- package/dist/translators/index.d.ts +6 -0
- package/dist/translators/index.d.ts.map +1 -0
- package/dist/translators/index.js +5 -0
- package/dist/translators/index.js.map +1 -0
- package/dist/translators/projection-differ.d.ts +48 -0
- package/dist/translators/projection-differ.d.ts.map +1 -0
- package/dist/translators/projection-differ.js +239 -0
- package/dist/translators/projection-differ.js.map +1 -0
- package/dist/translators/tool-helpers.d.ts +60 -0
- package/dist/translators/tool-helpers.d.ts.map +1 -0
- package/dist/translators/tool-helpers.js +308 -0
- package/dist/translators/tool-helpers.js.map +1 -0
- package/dist/translators/types.d.ts +58 -0
- package/dist/translators/types.d.ts.map +1 -0
- package/dist/translators/types.js +27 -0
- package/dist/translators/types.js.map +1 -0
- package/dist/utils.d.ts +111 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +110 -0
- package/dist/utils.js.map +1 -0
- package/docs/ARCHITECTURE.md +299 -0
- package/docs/DEVELOPMENT.md +193 -0
- package/docs/PROTOCOL.md +649 -0
- package/docs/TROUBLESHOOTING.md +251 -0
- package/package.json +66 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Common Issues Quick Reference
|
|
4
|
+
|
|
5
|
+
### Backend fails to start
|
|
6
|
+
|
|
7
|
+
**Symptom:**
|
|
8
|
+
```
|
|
9
|
+
[zcode-acp] backend: started zcode app-server (pid=12345)
|
|
10
|
+
[zcode-acp] backend: reader exited (stdout closed)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Troubleshooting steps:**
|
|
14
|
+
|
|
15
|
+
1. Check the ZCode CLI version:
|
|
16
|
+
```bash
|
|
17
|
+
zcode --version
|
|
18
|
+
```
|
|
19
|
+
- Must be >= 0.14.8
|
|
20
|
+
|
|
21
|
+
2. Check whether `zcode` is on PATH:
|
|
22
|
+
```bash
|
|
23
|
+
which zcode
|
|
24
|
+
```
|
|
25
|
+
- If not found, set: `export ZCODE_BIN=/path/to/zcode`
|
|
26
|
+
|
|
27
|
+
3. Check the ZCode configuration:
|
|
28
|
+
```bash
|
|
29
|
+
cat ~/.zcode/v2/config.json
|
|
30
|
+
```
|
|
31
|
+
- Confirm a `provider` is enabled
|
|
32
|
+
- Confirm `models` are defined
|
|
33
|
+
|
|
34
|
+
### session/subscribe fails
|
|
35
|
+
|
|
36
|
+
**Symptom:**
|
|
37
|
+
```
|
|
38
|
+
session/subscribe failed (ZCode CLI 0.14.8+ required)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Troubleshooting steps:**
|
|
42
|
+
|
|
43
|
+
1. Confirm ZCode CLI >= 0.14.8:
|
|
44
|
+
```bash
|
|
45
|
+
zcode --version
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. If the version is correct but it still fails, check whether the zcode
|
|
49
|
+
app-server supports subscribe:
|
|
50
|
+
```bash
|
|
51
|
+
cd /path/to/project
|
|
52
|
+
zcode app-server --stdio
|
|
53
|
+
# send manually:
|
|
54
|
+
{ "id": 1, "method": "session/subscribe", "params": { "sessionId": "test", "deliveryKind": "desktop-continuous", "includeSnapshot": true, "afterSeq": 0 } }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
3. Check whether other zcode processes are running:
|
|
58
|
+
```bash
|
|
59
|
+
ps aux | grep zcode
|
|
60
|
+
killall -9 zcode # caution: this kills all zcode processes
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Bash terminal output lost
|
|
64
|
+
|
|
65
|
+
**Symptom:** Bash terminal output disappears after the turn completes.
|
|
66
|
+
|
|
67
|
+
**Troubleshooting steps:**
|
|
68
|
+
|
|
69
|
+
1. Confirm the client declares `terminal_output`:
|
|
70
|
+
```typescript
|
|
71
|
+
// should be present in clientCapabilities:
|
|
72
|
+
{ "_meta": { "terminal_output": true } }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. Check whether `dispatchTerminalUpdate` correctly sends the 2-notification split:
|
|
76
|
+
- `terminal_output` (data)
|
|
77
|
+
- `terminal_exit` (status)
|
|
78
|
+
|
|
79
|
+
3. Check whether `seenToolIds` synchronization is in effect:
|
|
80
|
+
- Without sync, ProjectionDiffer re-emits a content-less ToolCallNew
|
|
81
|
+
- This overwrites the terminal output
|
|
82
|
+
|
|
83
|
+
### Events lost / not streaming in real time
|
|
84
|
+
|
|
85
|
+
**Symptom:** Text output appears all at once, without a streaming effect.
|
|
86
|
+
|
|
87
|
+
**Troubleshooting steps:**
|
|
88
|
+
|
|
89
|
+
1. Check whether `EventStreamListener` subscribed successfully:
|
|
90
|
+
```
|
|
91
|
+
[zcode-acp] backend: started zcode app-server (pid=12345)
|
|
92
|
+
```
|
|
93
|
+
If this log is missing, the backend did not start.
|
|
94
|
+
|
|
95
|
+
2. Check whether `session/event` pushes arrive:
|
|
96
|
+
- Add logging in `client.ts:route()`
|
|
97
|
+
- Or add logging in `listener.handleEvent()`
|
|
98
|
+
|
|
99
|
+
3. Check the zcode version: 0.14.5 ~ 0.14.7 do not support subscribe (this
|
|
100
|
+
project has removed the polling fallback)
|
|
101
|
+
|
|
102
|
+
### Interaction request timeout
|
|
103
|
+
|
|
104
|
+
**Symptom:** The tool permission or AskUserQuestion popup does not appear.
|
|
105
|
+
|
|
106
|
+
**Troubleshooting steps:**
|
|
107
|
+
|
|
108
|
+
1. Check whether zcode sent an interaction request:
|
|
109
|
+
```
|
|
110
|
+
[zcode-acp] -> interaction/requestPermission (zcode_id=100)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. Check which protocol path the client takes (elicitation vs request_permission):
|
|
114
|
+
- `⟳ AskUserQuestion forwarding elicitation/create (form, N fields)` → elicitation path
|
|
115
|
+
- `⟳ AskUserQuestion forwarding session/request_permission` → fallback path
|
|
116
|
+
- The path is decided by `clientCapabilities.elicitation.form`
|
|
117
|
+
|
|
118
|
+
3. Check whether `askOnce` (fallback path) or `handleAskUserViaElicitation`
|
|
119
|
+
(elicitation path) successfully sent the request:
|
|
120
|
+
- `⚠ elicitation/create failed: ...` → the client does not support it or the request failed
|
|
121
|
+
- `⚠ request_permission failed: ...` → the fallback path failed
|
|
122
|
+
|
|
123
|
+
### `/` completion menu is empty
|
|
124
|
+
|
|
125
|
+
**Symptom:** Typing `/` shows no command completion.
|
|
126
|
+
|
|
127
|
+
**Troubleshooting steps:**
|
|
128
|
+
|
|
129
|
+
1. Check whether `available_commands_update` is sent after the session response:
|
|
130
|
+
- `sendAvailableCommandsDeferred` should fire after the `session/new`/`resume`/`load` response
|
|
131
|
+
- The 50ms delay ensures the client's session state machine is ready
|
|
132
|
+
|
|
133
|
+
2. Confirm `SLASH_COMMANDS` (`utils.ts`) contains the expected commands
|
|
134
|
+
|
|
135
|
+
3. If it is lost intermittently, the client's state machine may not be ready
|
|
136
|
+
when the response arrives; check whether the delay is long enough
|
|
137
|
+
|
|
138
|
+
### Memory leak / zombie processes
|
|
139
|
+
|
|
140
|
+
**Symptom:** Many zcode processes remain; memory keeps growing.
|
|
141
|
+
|
|
142
|
+
**Troubleshooting steps:**
|
|
143
|
+
|
|
144
|
+
1. Check whether `ZcodeBackend.close()` is called:
|
|
145
|
+
- SIGTERM / SIGINT / SIGHUP signals
|
|
146
|
+
- stdin close
|
|
147
|
+
- backend reader death
|
|
148
|
+
|
|
149
|
+
2. Manually inspect zombie processes:
|
|
150
|
+
```bash
|
|
151
|
+
ps aux | grep zcode
|
|
152
|
+
killall -9 zcode # cleanup
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
3. Confirm the `detached: true` and `process.kill(-pid)` logic:
|
|
156
|
+
- `client.ts:spawn` sets `detached: true`
|
|
157
|
+
- `close()` uses `process.kill(-pid, "SIGTERM")`
|
|
158
|
+
- Falls back to `SIGKILL` after 3s
|
|
159
|
+
|
|
160
|
+
### Configuration option does not take effect
|
|
161
|
+
|
|
162
|
+
**Symptom:** After switching model/mode/thought, the UI does not update.
|
|
163
|
+
|
|
164
|
+
**Troubleshooting steps:**
|
|
165
|
+
|
|
166
|
+
1. Check whether the switch went through the right path. There are four entry
|
|
167
|
+
points, and each must notify the editor:
|
|
168
|
+
- `session/setMode` request → `extensions.ts:setMode`
|
|
169
|
+
- `session/set_config_option` (configId `mode`/`model`/`thought`) →
|
|
170
|
+
`session.ts:setConfigOptionHandler` → `emitConfigOptionUpdate`
|
|
171
|
+
- `/mode` or `/thought` slash command → `slash.ts` (also calls
|
|
172
|
+
`emitConfigOptionUpdate` since the fix; previously this path was silent)
|
|
173
|
+
- In-turn `EnterPlanMode`/`ExitPlanMode` → reconciled by `emitModeIfChanged`
|
|
174
|
+
at turn completion (`session.ts`)
|
|
175
|
+
|
|
176
|
+
2. Check whether `emitConfigOptionUpdate` sent the `config_option_update`
|
|
177
|
+
notification:
|
|
178
|
+
- mode also needs a `current_mode_update`
|
|
179
|
+
- the mode value advertised to the client is recorded in `server.lastMode`
|
|
180
|
+
so the turn-completion reconciliation does not re-emit it
|
|
181
|
+
|
|
182
|
+
3. Check whether `buildConfigOptions` reads the current value from `session/read`:
|
|
183
|
+
- Not `projection.mode` (that is a stale value)
|
|
184
|
+
- But `settings.mode.current`
|
|
185
|
+
|
|
186
|
+
### "A prompt is already running" after stop
|
|
187
|
+
|
|
188
|
+
**Symptom:** Pressing stop and then sending a new message fails with
|
|
189
|
+
`zcode send failed: A prompt is already running for this session`.
|
|
190
|
+
|
|
191
|
+
**Troubleshooting steps:**
|
|
192
|
+
|
|
193
|
+
1. Confirm the bridge version includes `ensureTurnStopped` (`session.ts`). It
|
|
194
|
+
sends `session/stop` and then probes `session/goal show` until the lock is
|
|
195
|
+
released, covering the startup-delay race where stop arrives before the
|
|
196
|
+
turn holds the lock.
|
|
197
|
+
|
|
198
|
+
2. If the lock is still stuck on an older bridge, the zcode subprocess must be
|
|
199
|
+
killed manually:
|
|
200
|
+
```bash
|
|
201
|
+
ps aux | grep zcode
|
|
202
|
+
killall -9 zcode # caution: kills all zcode processes
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
3. If the lock leaks again, check whether the watchdog (`backend/client.ts`)
|
|
206
|
+
is present — it reaps the zcode process group when the bridge is SIGKILLed,
|
|
207
|
+
so a reconnect starts from a clean state.
|
|
208
|
+
|
|
209
|
+
### Tasks-index sync failure
|
|
210
|
+
|
|
211
|
+
**Symptom:** Sessions created via ACP are not visible in the ZCode App UI.
|
|
212
|
+
|
|
213
|
+
**Troubleshooting steps:**
|
|
214
|
+
|
|
215
|
+
1. Check whether `node:sqlite` is available:
|
|
216
|
+
- Requires Node.js >= 22
|
|
217
|
+
- Check whether `loadSqlite()` returns null
|
|
218
|
+
|
|
219
|
+
2. Check whether `~/.zcode/v2/tasks-index.sqlite` exists:
|
|
220
|
+
- May not exist if the App has never been installed
|
|
221
|
+
- tasks-index sync is best-effort; failure does not block session creation
|
|
222
|
+
|
|
223
|
+
3. Check whether the tasks-index table schema matches:
|
|
224
|
+
- Table name: `tasks`
|
|
225
|
+
- Fields: workspace_key, task_id, title, task_status, ...
|
|
226
|
+
|
|
227
|
+
## Log Debugging
|
|
228
|
+
|
|
229
|
+
### Enable verbose logging
|
|
230
|
+
|
|
231
|
+
Add a timestamp and richer context in `src/utils.ts`:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
export function log(msg: string): void {
|
|
235
|
+
const ts = new Date().toISOString();
|
|
236
|
+
process.stderr.write(`[zcode-acp] [${ts}] ${msg}\n`);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Common log patterns
|
|
241
|
+
|
|
242
|
+
| Log | Meaning |
|
|
243
|
+
|------|------|
|
|
244
|
+
| `backend: started zcode app-server (pid=...)` | Backend started successfully |
|
|
245
|
+
| `backend: reader exited (...)` | Backend reader exited (backend may have crashed) |
|
|
246
|
+
| `session/new -> sess_xxx` | New session created successfully |
|
|
247
|
+
| `[event] turn.started` | Turn started |
|
|
248
|
+
| `[event] turn.completed (resultType=...)` | Turn completed |
|
|
249
|
+
| `-> interaction/... (zcode_id=...)` | Interaction request received |
|
|
250
|
+
| `<- replied to zcode (N request(s))` | Interaction request replied |
|
|
251
|
+
| `⚠ ...` | Warning / error |
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zcode-acp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent Client Protocol (ACP) server bridging headless ZCode to editors like Zed and JetBrains.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "ZCode ACP Server Contributors",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/zcode-org/zcode-acp-server.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/zcode-org/zcode-acp-server#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zcode-org/zcode-acp-server/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"acp",
|
|
18
|
+
"agent-client-protocol",
|
|
19
|
+
"zed",
|
|
20
|
+
"jetbrains",
|
|
21
|
+
"coding-agent",
|
|
22
|
+
"llm",
|
|
23
|
+
"zcode"
|
|
24
|
+
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"zcode-acp-server": "dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"docs"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@agentclientprotocol/sdk": "^1.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.0.0",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
46
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
47
|
+
"eslint": "^9.0.0",
|
|
48
|
+
"prettier": "^3.3.0",
|
|
49
|
+
"typescript": "^5.4.0",
|
|
50
|
+
"vitest": "^2.0.0",
|
|
51
|
+
"zod": "^3.25.0"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.0.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc",
|
|
58
|
+
"dev": "tsc --watch",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:watch": "vitest",
|
|
62
|
+
"format": "prettier --write src",
|
|
63
|
+
"lint": "eslint .",
|
|
64
|
+
"smoke": "node dist/index.js < /dev/null"
|
|
65
|
+
}
|
|
66
|
+
}
|