zcode-agent 1.0.0 → 1.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/README.md CHANGED
@@ -41,6 +41,8 @@ npx zcode-agent task \
41
41
 
42
42
  To skip `npx`, install it once with `npm install -g zcode-agent`. It needs Node 22.13 or later.
43
43
 
44
+ zcode-agent is also an [ACP](https://agentclientprotocol.com) agent: `zcode-agent acp` lets you chat with GLM-5.3 directly in T3 Code, Zed or any other Agent Client Protocol client. See [Use it in T3 Code, Zed or any ACP client](#use-it-in-t3-code-zed-or-any-acp-client).
45
+
44
46
  **With the ZCode app installed, there is nothing to configure.** zcode-agent reads the app's Z.ai API key where it is stored (it never copies or prints it) and gives every session the app's MCP servers and skills. It leaves out remote MCP servers that sign in with OAuth, because a headless session can't complete the sign-in, and it skips a server that failed to connect for the next six hours. The app's plugins, agent profiles and your global `AGENTS.md` stay out unless you pass `--inherit-desktop`. `--hermetic` leaves out the app's MCP servers and skills as well.
45
47
 
46
48
  **Without the app**, set an API key and install a browser for visual checks:
@@ -270,6 +272,54 @@ The counts come from each session's own engine database and include the executor
270
272
 
271
273
   
272
274
 
275
+ ## Use it in T3 Code, Zed or any ACP client
276
+
277
+ `zcode-agent acp` speaks the [Agent Client Protocol](https://agentclientprotocol.com) (v1) on stdio, so an ACP client drives GLM-5.3 directly: you chat with it, approve its edits and commands, and watch its tool calls, diffs and plan as they happen. `zcode-agent-acp` is the same command for clients that take only an executable. Key, MCP servers and skills work the same way as for `task`.
278
+
279
+ **T3 Code** (a build with the ACP Registry provider): install zcode-agent globally, then add a provider in Settings → Providers. Choose **ACP Registry**, set **ACP source** to **Local command** and **Executable override** to `zcode-agent-acp`. To set it in `~/.t3/userdata/settings.json` instead:
280
+
281
+ ```json
282
+ "providerInstances": {
283
+ "zcodeAgent": {
284
+ "driver": "acpRegistry",
285
+ "displayName": "zcode-agent (GLM-5.3)",
286
+ "enabled": true,
287
+ "config": { "source": "local", "commandPath": "zcode-agent-acp", "commandArgs": [] }
288
+ }
289
+ }
290
+ ```
291
+
292
+ T3 Code then offers GLM-5.3-Flash and GLM-5.3, with **Mode** and **Effort** pickers. Its runtime modes map onto the agent's approvals: in full access T3 answers every approval itself, and in approval-required it asks you. T3's plan mode switches the agent to its read-only Plan mode.
293
+
294
+ **Zed** (`settings.json`):
295
+
296
+ ```json
297
+ "agent_servers": {
298
+ "zcode-agent": { "type": "custom", "command": "zcode-agent", "args": ["acp"], "env": {} }
299
+ }
300
+ ```
301
+
302
+ | mode | the agent… |
303
+ |---|---|
304
+ | `build` (Ask, default) | asks before every edit and command |
305
+ | `edit` (Accept edits) | edits files freely and asks before commands |
306
+ | `plan` | only reads, then asks to start with a plan you approve |
307
+ | `yolo` (Full access) | runs every tool without asking |
308
+
309
+ What the client gets:
310
+
311
+ - **Live output.** Streaming text and reasoning, tool calls with titles, file locations and diffs, command output, and the to-do list as the plan.
312
+ - **Approvals.** The engine's permission prompts (allow once, always allow in this project, deny) are forwarded to you.
313
+ - **Picker updates.** Mode, model and effort as session config options; switching model keeps the effort when the new model supports it.
314
+ - **Usage.** Context use and the session's GLM cost so far at API list price, after every turn.
315
+ - **Sessions.** `session/list` and `session/load`: a session reopens in a new process with its history replayed. Every ACP session is a zcode-agent session (`kind: "acp"`), so `zcode-agent status`, `watch` and `cost` include it.
316
+ - **Inputs.** Images (saved to the session's tmp dir for GLM-5.3-Flash to read), embedded files and file links in prompts. Your client's MCP servers (stdio, HTTP, SSE) are added to the session.
317
+ - **Cancel.** Stops the running turn and its tools.
318
+
319
+ The engine starts at the first prompt, not at `session/new`, so client probes cost nothing and leave no session behind. Flags set the defaults for new sessions: `--mode`, `--model`, `--effort`, `--hermetic` (fastest start: none of the app's MCP servers to connect), `--no-browser`, `--mcp`, `--skills`, `--timeout-ms` (per prompt; default none). `ZCODE_ACP_MODE` sets the default mode for clients that take no arguments, and `ZCODE_ACP_LOG=<file>` logs every frame. Questions the model would ask through a form are asked in its reply instead, because ACP v1 has no form UI.
320
+
321
+ &nbsp;
322
+
273
323
  ## Machine interface
274
324
 
275
325
  With `--json`, stdout carries NDJSON events and then exactly one `{"type":"result",…}` line. With `--quiet`, the result line is the only output. Task sessions leave text deltas out of the events unless you pass `--stream`, so your agent pays only for the lifecycle events.
@@ -0,0 +1,11 @@
1
+ # zcode-agent (ACP)
2
+
3
+ You are the coding agent behind an editor or app that speaks the Agent Client Protocol (T3 Code, Zed, …). A person reads your messages and may be asked to approve your tool calls.
4
+
5
+ - When you need a decision only the person can make, ask it plainly at the end of your reply and stop; their next message is the answer. Otherwise act on sensible defaults and say which you chose.
6
+ - Use TodoWrite for multi-step work: the client shows your list as the plan.
7
+ - Commands must not block on input: pass non-interactive flags (`--yes`, `CI=1`, `--no-open`); no editors, pagers or watch modes. Run servers in the background and stop them when done.
8
+ - Bind `$ZCODE_PORT` for a server you start unless the person names a port. Scratch files go under `$ZCODE_TMP`.
9
+ - Don't commit, push, publish, deploy or install global packages unless asked.
10
+ - Images the person attaches are saved as files and named in their message: open them with the Read tool.
11
+ - Drive browsers only through the Playwright MCP tools.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // `zcode-agent-acp [options]` = `zcode-agent acp [options]`, for ACP clients
4
+ // whose settings take only an executable (T3 Code's provider form).
5
+ const { main } = require('./zcode-agent.js');
6
+
7
+ process.argv.splice(2, 0, 'acp');
8
+ main().catch((err) => {
9
+ process.stderr.write(`zcode-agent: internal error: ${err && err.stack ? err.stack : err}\n`);
10
+ process.exit(1);
11
+ });
@@ -30,6 +30,9 @@ const USAGE = `usage:
30
30
  engine, key, inherited setup and browser report
31
31
  zcode-agent skills [install|uninstall] [claude|codex]
32
32
  install the orchestrator skills (default: status)
33
+ zcode-agent acp [--mode m] [--model id] [--effort l]
34
+ serve the Agent Client Protocol on stdio (T3 Code,
35
+ Zed, any ACP client; see "acp" below)
33
36
 
34
37
  session:
35
38
  --id <id> name the session (letters, digits, . _ -); default zc-<random>.
@@ -83,6 +86,14 @@ plan (zcode-agent plan run <plan.json>):
83
86
  --id <name> plan name (default: the file's basename)
84
87
  --session <id> plan resume: only this session
85
88
 
89
+ acp (zcode-agent acp):
90
+ --mode <mode> default permission mode of new sessions: build (ask before
91
+ edits and commands) | edit (accept edits) | plan | yolo
92
+ (full access). default: build; clients switch it per session
93
+ --timeout-ms <n> per prompt (default: none)
94
+ also: --model, --effort, --mcp, --hermetic, --no-browser,
95
+ --skills, --no-skills, --inherit-desktop
96
+
86
97
  execution:
87
98
  --model <id> glm-5.3 | glm-5.3-flash (+aliases). default: glm-5.3-flash
88
99
  --effort <level> low | high | max for both models (zcode-agent doctor lists the
@@ -154,7 +165,9 @@ function parseMcpSpec(value) {
154
165
  return parsed;
155
166
  }
156
167
 
157
- const COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'status', 'list', 'wait', 'watch', 'cost', 'cancel', 'login', 'doctor', 'skills', 'result', 'plan', '__plan', '__exec']);
168
+ const COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'status', 'list', 'wait', 'watch', 'cost', 'cancel', 'login', 'doctor', 'skills', 'result', 'plan', 'acp', '__plan', '__exec']);
169
+ // The flags `zcode-agent acp` accepts (session defaults for the ACP agent).
170
+ const ACP_FLAGS = new Set(['model', 'effort', 'mode', 'timeoutMs', 'mcpSpecs', 'mcpInherit', 'hermetic', 'noBrowser', 'skillsDirs', 'noSkills', 'inheritDesktop']);
158
171
  const TASK_ONLY = new Set(['task', 'accept', 'check', 'file', 'context', 'touch', 'maxRepairs', 'checkTimeoutMs', 'decisions', 'units', 'visual', 'viewports', 'serve', 'preflight']);
159
172
  const FULL_COMMANDS = new Set(['run', 'task', 'agent', 'resume', 'wait', 'result', '__exec']);
160
173
  const START_ONLY = new Set(['id', 'label', 'owns', 'touch', 'preflight', 'allowOverlap', 'mcpSpecs', 'mcpInherit', 'hermetic', 'noBrowser', 'skillsDirs', 'noSkills', 'inheritDesktop', 'profile', 'cwd']);
@@ -212,6 +225,7 @@ function parseArgv(argv) {
212
225
  all: false,
213
226
  app: false,
214
227
  installBrowser: false,
228
+ mode: undefined,
215
229
  },
216
230
  };
217
231
  const valueFlags = new Map([
@@ -219,6 +233,7 @@ function parseArgv(argv) {
219
233
  ['--timeout-ms', 'timeoutMs'], ['-p', 'prompt'], ['--prompt', 'prompt'], ['--session', 'session'],
220
234
  ['--id', 'id'], ['--label', 'label'], ['--task', 'task'], ['--max-repairs', 'maxRepairs'],
221
235
  ['--check-timeout-ms', 'checkTimeoutMs'], ['--serve', 'serve'], ['--plan', 'plan'], ['--stall-min', 'stallMin'],
236
+ ['--mode', 'mode'],
222
237
  ]);
223
238
  const listFlags = new Map([
224
239
  ['--mcp', 'mcpSpecs'], ['--skills', 'skillsDirs'], ['--accept', 'accept'], ['--check', 'check'],
@@ -313,6 +328,13 @@ function parseArgv(argv) {
313
328
  if (out.given.has(key)) fail(2, `--${flagName(key)} cannot change on resume; it is fixed when the session starts.`);
314
329
  }
315
330
  }
331
+ if (cmd === 'acp') {
332
+ for (const key of out.given) {
333
+ if (!ACP_FLAGS.has(key)) fail(2, `--${flagName(key)} is not valid with "zcode-agent acp".`);
334
+ }
335
+ } else if (out.given.has('mode')) {
336
+ fail(2, '--mode is only valid with "zcode-agent acp".');
337
+ }
316
338
  if (out.given.has('all') && cmd !== 'status') fail(2, '--all is only valid with "zcode-agent status".');
317
339
  for (const k of ['plan', 'stallMin']) {
318
340
  if (out.given.has(k) && cmd !== 'watch') fail(2, `--${flagName(k)} is only valid with "zcode-agent watch".`);
@@ -401,13 +423,15 @@ async function main() {
401
423
  return require('../lib/commands/doctor.js')(parsed);
402
424
  case 'skills':
403
425
  return require('../lib/commands/skills.js')(parsed);
426
+ case 'acp':
427
+ return require('../lib/commands/acp.js')(parsed);
404
428
  default:
405
429
  return fail(2, `unknown command "${parsed.command}" (see zcode-agent --help).`);
406
430
  }
407
431
  }
408
432
 
409
433
  // Exported before main() runs: the plan supervisor reuses parseArgv.
410
- module.exports = { parseArgv, USAGE };
434
+ module.exports = { parseArgv, USAGE, main };
411
435
 
412
436
  if (require.main === module) {
413
437
  main().catch((err) => {