zapagent 1.14.6 → 1.14.7
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 +120 -78
- package/README.zh-CN.md +117 -76
- package/npm/cli.cjs +19 -0
- package/npm/install.cjs +80 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -1,134 +1,178 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/images/readme/
|
|
2
|
+
<img src="docs/images/readme/logo.png" alt="zapAgent logo" width="360" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<h1 align="center">One task. A
|
|
5
|
+
<h1 align="center">One task. A team of agents.</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
Delegate work.
|
|
9
|
-
|
|
8
|
+
Delegate independent work. Review isolated edits. Watch the run unfold.<br />
|
|
9
|
+
An open-source, general-purpose agent and TypeScript SDK.
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/zapagent"><img src="https://img.shields.io/npm/v/zapagent?style=flat-square&color=b4e66e" alt="npm version" /></a>
|
|
14
|
+
<a href="https://github.com/JackCaow/zapagent/releases"><img src="https://img.shields.io/github/v/release/JackCaow/zapagent?style=flat-square" alt="Latest release" /></a>
|
|
15
|
+
<a href="https://github.com/JackCaow/zapagent/actions/workflows/ci.yml"><img src="https://github.com/JackCaow/zapagent/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/CLI_%26_SDK-MIT-blue?style=flat-square" alt="CLI and SDK: MIT" /></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="#what-can-you-do-with-it">Use cases</a> ·
|
|
13
21
|
<a href="#quick-start">Quick start</a> ·
|
|
14
|
-
<a href="#
|
|
15
|
-
<a href="#
|
|
16
|
-
<a href="
|
|
22
|
+
<a href="#give-your-agents-a-task">Try it</a> ·
|
|
23
|
+
<a href="#watch-the-work-happen">Live view</a> ·
|
|
24
|
+
<a href="#how-it-works">Architecture</a> ·
|
|
25
|
+
<a href="docs/usage.md">Docs</a> ·
|
|
17
26
|
<a href="README.zh-CN.md">简体中文</a>
|
|
18
27
|
</p>
|
|
19
28
|
|
|
20
|
-
zapAgent
|
|
29
|
+
zapAgent works from your terminal to understand tasks, call tools, and deliver results. Use it to research a topic, organize documents, analyze data, develop software, or automate a workflow. For complex tasks, a coordinator can delegate work to child agents and bring their findings and artifacts together.
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
- **Work in parallel.** Split research, analysis, execution, and review into independent tasks, with dependencies and messages connecting the agents.
|
|
32
|
+
- **Keep edits isolated.** Agents produce files and edits in separate workspaces. Collect and review their artifacts before merging, with a clear delivery boundary for each change.
|
|
33
|
+
- **See the whole run.** `zap --watch` opens a local view of agents, tool calls, approvals, and completion states alongside your terminal.
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
Bring your own model connection: **Anthropic Messages, OpenAI Chat Completions, and OpenAI Responses API**, including compatible services. Connect your existing files, tools, and workflows.
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
| :--- | :--- | :--- |
|
|
28
|
-
| Delegate exploration, planning, and implementation to child agents. The coordinator manages dependencies, concurrency, messages, and run state. | Writing agents get private workspaces, including in non-Git projects. Their edits return as artifacts for an explicit merge. | `--watch` opens a live graph of model requests, tools, approvals, and child agents alongside the terminal. |
|
|
29
|
-
| **Independent work can happen together.** | **Child edits reach your project through a merge gate.** | **See what is running, waiting, or finished.** |
|
|
37
|
+
## What can you do with it?
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
+
| Task | Try asking |
|
|
40
|
+
| :--- | :--- |
|
|
41
|
+
| Research | “Read these materials, compare the viewpoints, and summarize the findings with sources.” |
|
|
42
|
+
| Organize documents | “Turn the notes in this folder into a structured report.” |
|
|
43
|
+
| Analyze data | “Find trends and anomalies in this dataset and explain the evidence.” |
|
|
44
|
+
| Automate a workflow | “Organize these files by the given rules and produce an inventory and summary.” |
|
|
45
|
+
| Develop software | “Understand this project, implement the change, add tests, and review the result.” |
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
Start with a task in plain language. When it benefits from delegation, agents can explore, analyze, and execute separate parts, then combine their results. Available capabilities depend on your model connection, configured tools, and permissions.
|
|
41
48
|
|
|
42
49
|
## Quick start
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
**1. Install zapAgent**
|
|
52
|
+
|
|
53
|
+
Requires Node.js 22+ (includes npm). Installation fetches the native program for your platform; no separate Bun installation is needed:
|
|
45
54
|
|
|
46
55
|
```bash
|
|
47
|
-
|
|
48
|
-
cd zapagent
|
|
49
|
-
bun install --frozen-lockfile
|
|
50
|
-
bun start
|
|
56
|
+
npm install -g zapagent
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
**2. Start in your working folder**
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
Open a terminal in the folder containing your materials or project and run:
|
|
56
62
|
|
|
57
63
|
```bash
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
zap --watch
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Interact in the terminal and follow task progress in the live browser view.
|
|
68
|
+
|
|
69
|
+
**3. Connect a model and describe your task**
|
|
70
|
+
|
|
71
|
+
On first use, enter `/connect` and follow the setup prompts to connect your model service. Then describe what you want: “Read the materials in this folder, summarize the key points, and write a report.”
|
|
72
|
+
|
|
73
|
+
You need your own model service account and API key; usage is billed by your provider. [Connection guide](docs/usage.md#getting-started).
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
<details>
|
|
76
|
+
<summary>Other installation options and advanced setup: Bun, binaries, source, API protocols</summary>
|
|
77
|
+
|
|
78
|
+
**Install with Bun**:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bun add --global zapagent
|
|
64
82
|
```
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
Git workspaces also require [Git](https://git-scm.com).
|
|
85
|
+
|
|
86
|
+
**Native binaries** — download from the [latest release](https://github.com/JackCaow/zapagent/releases/latest) and follow the [launch instructions](docs/usage.md#native-binary-setup):
|
|
87
|
+
|
|
88
|
+
| Platform | Downloads |
|
|
89
|
+
| :--- | :--- |
|
|
90
|
+
| macOS | [Apple Silicon](https://github.com/JackCaow/zapagent/releases/latest/download/zap-macos-arm64) · [Intel](https://github.com/JackCaow/zapagent/releases/latest/download/zap-macos-x64) |
|
|
91
|
+
| Linux | [ARM64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-linux-arm64) · [x64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-linux-x64) |
|
|
92
|
+
| Windows | [x64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-windows-x64.exe) |
|
|
67
93
|
|
|
68
|
-
|
|
94
|
+
**Model configuration** — use `/model` to choose a model and `/effort` to adjust supported reasoning settings. For custom services, enter the Base URL and API key in `/connect` and select the service's API protocol; choose **OpenAI Responses** for a Responses endpoint. [Responses configuration](docs/usage.md#openai-responses-api).
|
|
69
95
|
|
|
70
|
-
|
|
96
|
+
**From source** — the repository pins Bun 1.3.14:
|
|
71
97
|
|
|
72
98
|
```bash
|
|
73
|
-
|
|
99
|
+
git clone https://github.com/JackCaow/zapagent.git
|
|
100
|
+
cd zapagent
|
|
101
|
+
bun install --frozen-lockfile
|
|
102
|
+
bun start
|
|
74
103
|
```
|
|
75
104
|
|
|
76
|
-
|
|
105
|
+
Run `bun link` in the checkout, then use `zapdev` from your working folder. Or run `bun run build` and use `dist/zap`.
|
|
77
106
|
|
|
78
|
-
|
|
107
|
+
Binaries include SHA-256 checksums. macOS binaries are ad-hoc signed, not Developer ID signed or notarized. See the [release guide](docs/releasing.md).
|
|
79
108
|
|
|
80
|
-
|
|
109
|
+
</details>
|
|
81
110
|
|
|
82
|
-
|
|
83
|
-
- **Understand waits:** distinguish model activity, tool execution, approval, and completion.
|
|
84
|
-
- **Keep the terminal in control:** Watch is read-only. Refreshing the page does not replay tools or change the run.
|
|
85
|
-
- **Keep content out of the viewer:** Watch projects runtime metadata; prompts, tool arguments, and tool output are excluded. Its loopback URL contains a private access token.
|
|
111
|
+
## Give your agents a task
|
|
86
112
|
|
|
87
|
-
|
|
113
|
+
Start with a task that benefits from several perspectives:
|
|
88
114
|
|
|
89
|
-
|
|
115
|
+
```text
|
|
116
|
+
Read the materials in this directory and prepare a project assessment.
|
|
117
|
+
Delegate independent parts to child agents: map the project background,
|
|
118
|
+
analyze risks, and review the conclusions against the evidence.
|
|
119
|
+
Combine the results in report.md. Cite sources and flag missing information.
|
|
120
|
+
Ask before merging the report into my workspace.
|
|
121
|
+
```
|
|
90
122
|
|
|
91
|
-
|
|
123
|
+
The coordinator manages child-agent dependencies, concurrency, messages, and lifecycle states. Delegation follows the task and model decisions; independent work can run together, while dependent work waits for prerequisites.
|
|
92
124
|
|
|
93
|
-
|
|
94
|
-
2. **The coordinator delegates.** Child runs have their own identities, lifecycle states, dependencies, and messaging. Independent work can run concurrently within configured limits.
|
|
95
|
-
3. **Writing agents work in isolation.** Git projects use private clones of a working-tree snapshot, including eligible uncommitted changes. Non-Git projects use controlled copy snapshots. Read-only agents can share the parent workspace view.
|
|
96
|
-
4. **Results come back through a merge gate.** Writing agents produce frozen artifacts. Merging checks conflicts and parent-workspace drift before applying changes. Child staging and commits stay private; merging delivers file changes, not child commit history.
|
|
97
|
-
5. **Runtime events make progress visible.** Watch observes the execution lifecycle without controlling it. The runtime distinguishes execution outcomes from acceptance; task acceptance requires an explicit evaluator or human review.
|
|
125
|
+
Writing agents can process files, write reports, and run scripts in their private workspaces. Development tasks can also install dependencies, run tests, and stage or commit changes, subject to tool permissions and the platform sandbox. Merging applies file changes to the parent workspace; it does not import the child's commit history. See [workspace isolation](docs/architecture/48-non-git-workspace-isolation.md).
|
|
98
126
|
|
|
99
|
-
|
|
127
|
+
## Watch the work happen
|
|
100
128
|
|
|
101
|
-
|
|
102
|
-
| :--- | :--- |
|
|
103
|
-
| [`src/`](src/) | Terminal UI, provider setup, sessions, headless/ACP hosts, and Watch. |
|
|
104
|
-
| [`zapsdk/`](zapsdk/) | Reusable TypeScript agent runtime: model loop, orchestration, tools, policy, workspaces, merge, context, memory, and events. |
|
|
105
|
-
| [`zapvm/`](zapvm/) | Independent Go execution runtime. Optional VM execution sits behind the SDK's execution protocol; the VM does not own agent prompts, permissions, or completion decisions. |
|
|
129
|
+

|
|
106
130
|
|
|
107
|
-
|
|
131
|
+
*Captured from the actual Watch UI using synthetic preview events. This illustrates the interface, not a benchmark or a recorded model run.*
|
|
108
132
|
|
|
109
|
-
|
|
133
|
+
Run `zap --watch` to follow the agent tree and tool lifecycle in a local browser. See which agents are active, which tools are executing, and where approval is needed.
|
|
110
134
|
|
|
111
|
-
|
|
112
|
-
- **Keep long tasks moving.** Context compaction, project memory, saved sessions, and a follow-up queue help carry work across turns. Steer the active task or queue the next request with `/queue`.
|
|
113
|
-
- **Control tool access.** Inspect permissions and scoped approvals with `/permissions`. Commands use the host OS sandbox by default; VM execution is opt-in. See the [execution boundary](docs/architecture/39-local-sandbox-default.md) for platform-specific restrictions.
|
|
114
|
-
- **Return to earlier work.** `/rewind` can restore conversation, tracked code changes, or both. Checkpoints have coverage limits; external effects and every filesystem topology change are not fully reversible.
|
|
115
|
-
- **Bring your tools.** Built-in file, search, shell, HTTP, and document tools sit alongside MCP integrations and skills.
|
|
116
|
-
- **Build your own host.** Reuse the SDK, stream structured headless output, or connect an ACP-compatible client.
|
|
135
|
+
Watch is **read-only** and displays runtime metadata rather than prompts, tool arguments, or tool output. Refreshing the page does not replay tools. Its loopback URL contains a private access token; do not share it. Use `--watch-no-open` to print the URL without opening a browser. [Watch details →](docs/architecture/57-watch-runtime-observability.md)
|
|
117
136
|
|
|
118
|
-
|
|
137
|
+
## Fit it into your workflow
|
|
119
138
|
|
|
120
|
-
|
|
139
|
+
| What you need | What zapAgent provides |
|
|
140
|
+
| :--- | :--- |
|
|
141
|
+
| Use your model provider | `/connect`, `/model`, and `/effort`; Anthropic, Chat Completions, and Responses protocols. |
|
|
142
|
+
| Continue a long task | Context compaction, project memory, saved sessions, and `/queue` for follow-up requests. |
|
|
143
|
+
| Control tool access | `/permissions`, scoped approvals, and the host OS sandbox by default. [Platform boundaries](docs/architecture/39-local-sandbox-default.md). |
|
|
144
|
+
| Return to earlier work | `/rewind` for conversation, tracked code changes, or both. External effects and some filesystem changes are outside checkpoint coverage. |
|
|
145
|
+
| Bring existing tools | Built-in file, search, shell, HTTP, and document tools, plus MCP integrations and skills. |
|
|
146
|
+
| Automate or build a host | Structured headless output, an ACP adapter, and a reusable TypeScript SDK. |
|
|
147
|
+
|
|
148
|
+
After configuring a provider, use the CLI in scripts:
|
|
121
149
|
|
|
122
150
|
```bash
|
|
123
|
-
zap -p "
|
|
124
|
-
zap --watch -p "
|
|
151
|
+
zap -p "Organize the materials in this directory into themes, findings, and open questions" --output-format json
|
|
152
|
+
zap --watch -p "Analyze the data in this directory and write a report" --output-format stream-json --watch-linger 30
|
|
125
153
|
```
|
|
126
154
|
|
|
127
|
-
|
|
155
|
+
See `zap --help-headless` and the [CLI reference](docs/usage.md) for commands, configuration, approvals, and automation.
|
|
156
|
+
|
|
157
|
+
## How it works
|
|
158
|
+
|
|
159
|
+

|
|
128
160
|
|
|
129
|
-
|
|
161
|
+
The host starts a run through `AgentRuntime`. `LoopAgent` manages the model/tool loop, context, and execution budgets. The coordinator manages child runs; writing agents return frozen artifacts that pass conflict and workspace-drift checks before merging. Runtime events feed Watch. Execution success and task acceptance are separate: acceptance requires an explicit evaluator or human review.
|
|
130
162
|
|
|
131
|
-
|
|
163
|
+
| Module | Responsibility |
|
|
164
|
+
| :--- | :--- |
|
|
165
|
+
| [`src/`](src/) | Terminal UI, provider setup, sessions, headless/ACP hosts, and Watch. |
|
|
166
|
+
| [`zapsdk/`](zapsdk/) | TypeScript agent runtime: model loop, orchestration, tools, permissions, workspaces, merge, context, memory, and events. |
|
|
167
|
+
| [`zapvm/`](zapvm/) | Independent Go execution runtime. Optional VM execution connects through the SDK protocol; the VM does not own agent prompts, permissions, or completion decisions. |
|
|
168
|
+
|
|
169
|
+
Git workspaces use private clones of a working-tree snapshot, including eligible uncommitted changes. Non-Git projects use controlled copy snapshots. Read-only agents can share the parent workspace view.
|
|
170
|
+
|
|
171
|
+
Read the [architecture guide](docs/architecture/README.md) and [multi-agent design](docs/architecture/26-multi-agent-orchestration.md) for implementation details.
|
|
172
|
+
|
|
173
|
+
## Contributing
|
|
174
|
+
|
|
175
|
+
Help improve provider compatibility, sandbox behavior, collaboration, or the live view. Bug reports are most useful with expected behavior and a minimal reproduction, with credentials and private code removed.
|
|
132
176
|
|
|
133
177
|
```bash
|
|
134
178
|
bun run typecheck
|
|
@@ -136,9 +180,7 @@ bun test
|
|
|
136
180
|
bun run build
|
|
137
181
|
```
|
|
138
182
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
If this is the workflow you want in your terminal, star the repository and help shape it.
|
|
183
|
+
For the independent VM module, use `bun run check:vm`; `bun run build:all` builds both host components. See [CONTRIBUTING.md](CONTRIBUTING.md), [open issues](https://github.com/JackCaow/zapagent/issues), and [SECURITY.md](SECURITY.md).
|
|
142
184
|
|
|
143
185
|
## License
|
|
144
186
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,134 +1,177 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/images/readme/
|
|
2
|
+
<img src="docs/images/readme/logo.png" alt="zapAgent 品牌标志" width="360" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">一个任务,一组协作的 agent。</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
分工并行,隔离修改,实时看见进展。<br />
|
|
9
|
+
开源通用 agent,以及可复用的 TypeScript SDK。
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/zapagent"><img src="https://img.shields.io/npm/v/zapagent?style=flat-square&color=b4e66e" alt="npm 版本" /></a>
|
|
14
|
+
<a href="https://github.com/JackCaow/zapagent/releases"><img src="https://img.shields.io/github/v/release/JackCaow/zapagent?style=flat-square" alt="最新版本" /></a>
|
|
15
|
+
<a href="https://github.com/JackCaow/zapagent/actions/workflows/ci.yml"><img src="https://github.com/JackCaow/zapagent/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/CLI_%26_SDK-MIT-blue?style=flat-square" alt="CLI 与 SDK:MIT" /></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="#你可以让它做什么">能做什么</a> ·
|
|
13
21
|
<a href="#快速开始">快速开始</a> ·
|
|
22
|
+
<a href="#交给-agent-一个任务">协作示例</a> ·
|
|
14
23
|
<a href="#看见任务如何推进">实时可视化</a> ·
|
|
15
|
-
<a href="
|
|
16
|
-
<a href="docs/usage.md"
|
|
24
|
+
<a href="#它如何工作">架构</a> ·
|
|
25
|
+
<a href="docs/usage.md">文档</a> ·
|
|
17
26
|
<a href="README.md">English</a>
|
|
18
27
|
</p>
|
|
19
28
|
|
|
20
|
-
zapAgent
|
|
29
|
+
zapAgent 在终端中理解任务、调用工具并交付结果。用它调研信息、整理文档、分析数据、开发软件,或将多个步骤串成自动化流程。面对复杂任务,协调器可以分派多个子 agent,汇总它们的发现和产物。
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
- **分工并行。** 将调研、分析、执行、审查拆成独立任务,通过依赖关系和消息组织协作。
|
|
32
|
+
- **隔离修改。** 让不同 agent 在独立工作区中产出文件和修改,收集产物后再检查、合并。每份改动都有清晰的交付边界。
|
|
33
|
+
- **实时可见。** `zap --watch` 在终端旁打开本地运行视图,展示 agent、工具调用、审批和完成状态。
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
支持自带模型连接:**Anthropic Messages、OpenAI Chat Completions、OpenAI Responses API** 及兼容服务,接入你现有的文件、工具和工作流。
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
| :--- | :--- | :--- |
|
|
28
|
-
| 把探索、规划、实现交给子 agent。协调器管理依赖、并发、消息和运行状态。 | 写入型 agent 使用独立工作区,非 Git 项目同样适用。修改收集为产物,经显式合并回到项目。 | `--watch` 打开实时运行图,在终端旁查看模型请求、工具执行、审批和子 agent 状态。 |
|
|
29
|
-
| **独立的工作可以一起推进。** | **子 agent 的修改通过合并检查进入项目。** | **看清谁在运行、谁在等待、谁已完成。** |
|
|
37
|
+
## 你可以让它做什么
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
+
| 场景 | 试着这样说 |
|
|
40
|
+
| :--- | :--- |
|
|
41
|
+
| 资料调研 | “阅读这些材料,对比不同观点,整理结论并标明来源。” |
|
|
42
|
+
| 文档整理 | “把这个文件夹里的零散记录整理成一份结构清晰的报告。” |
|
|
43
|
+
| 数据分析 | “分析这份数据,找出变化趋势和异常,说明判断依据。” |
|
|
44
|
+
| 流程自动化 | “按规则整理这些文件,生成目录清单和处理结果。” |
|
|
45
|
+
| 软件开发 | “理解这个项目,完成改动、补充测试,再审查结果。” |
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
任务可以从一句话开始。需要分工时,让多个 agent 分别探索、分析和执行,最后汇总成你需要的结果。可用范围取决于连接的模型、已配置的工具和授权。
|
|
41
48
|
|
|
42
49
|
## 快速开始
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
**1. 安装 zapAgent**
|
|
52
|
+
|
|
53
|
+
需要 Node.js 22+(包含 npm)。安装时自动获取对应平台的独立程序,无需单独安装 Bun:
|
|
45
54
|
|
|
46
55
|
```bash
|
|
47
|
-
|
|
48
|
-
cd zapagent
|
|
49
|
-
bun install --frozen-lockfile
|
|
50
|
-
bun start
|
|
56
|
+
npm install -g zapagent
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
**2. 在你的工作文件夹中启动**
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
在存放资料或项目的文件夹中打开终端,运行:
|
|
56
62
|
|
|
57
63
|
```bash
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
zap --watch
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
终端用于交互,浏览器中的实时视图展示任务进展。
|
|
68
|
+
|
|
69
|
+
**3. 连接模型,描述任务**
|
|
70
|
+
|
|
71
|
+
首次使用时,输入 `/connect`,按界面引导连接你的模型服务。然后直接告诉它你要完成什么,例如:“阅读这个文件夹里的资料,整理重点并生成一份报告。”
|
|
72
|
+
|
|
73
|
+
需要你自己的模型服务账号和 API Key,调用费用由模型服务商收取。[连接指南](docs/usage.md#getting-started)。
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
<details>
|
|
76
|
+
<summary>其他安装方式与高级配置:Bun、二进制、源码、API 协议</summary>
|
|
77
|
+
|
|
78
|
+
**Bun 安装**:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bun add --global zapagent
|
|
64
82
|
```
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
Git 工作区还需要安装 [Git](https://git-scm.com)。
|
|
67
85
|
|
|
68
|
-
|
|
86
|
+
**独立二进制**——从 [最新版本](https://github.com/JackCaow/zapagent/releases/latest) 下载,并按[启动步骤](docs/usage.md#native-binary-setup)运行:
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
| 平台 | 下载 |
|
|
89
|
+
| :--- | :--- |
|
|
90
|
+
| macOS | [Apple Silicon](https://github.com/JackCaow/zapagent/releases/latest/download/zap-macos-arm64) · [Intel](https://github.com/JackCaow/zapagent/releases/latest/download/zap-macos-x64) |
|
|
91
|
+
| Linux | [ARM64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-linux-arm64) · [x64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-linux-x64) |
|
|
92
|
+
| Windows | [x64](https://github.com/JackCaow/zapagent/releases/latest/download/zap-windows-x64.exe) |
|
|
93
|
+
|
|
94
|
+
**模型配置**——用 `/model` 选择模型,用 `/effort` 调整模型支持的推理档位。自定义服务时,在 `/connect` 填入 Base URL 和 API Key,并选择服务支持的协议;Responses 端点选择 **OpenAI Responses**。[Responses 配置](docs/usage.md#openai-responses-api)。
|
|
95
|
+
|
|
96
|
+
**从源码运行**——仓库固定使用 Bun 1.3.14:
|
|
71
97
|
|
|
72
98
|
```bash
|
|
73
|
-
|
|
99
|
+
git clone https://github.com/JackCaow/zapagent.git
|
|
100
|
+
cd zapagent
|
|
101
|
+
bun install --frozen-lockfile
|
|
102
|
+
bun start
|
|
74
103
|
```
|
|
75
104
|
|
|
76
|
-
|
|
105
|
+
在源码目录执行 `bun link` 后,可在自己的工作目录中使用 `zapdev`;也可以执行 `bun run build`,使用 `dist/zap`。
|
|
77
106
|
|
|
78
|
-
|
|
107
|
+
二进制附带 SHA-256 校验文件。macOS 二进制使用临时签名,尚未进行 Developer ID 签名或公证。详见[发布说明](docs/releasing.md)。
|
|
79
108
|
|
|
80
|
-
|
|
109
|
+
</details>
|
|
81
110
|
|
|
82
|
-
|
|
83
|
-
- **区分等待原因:** 查看模型活动、工具执行、审批和完成状态。
|
|
84
|
-
- **在终端掌握控制权:** Watch 只读;刷新页面不会重放工具或改变任务。
|
|
85
|
-
- **只展示运行元数据:** 页面排除提示词、工具参数和工具输出。本地回环地址包含访问令牌,请勿分享。
|
|
111
|
+
## 交给 agent 一个任务
|
|
86
112
|
|
|
87
|
-
|
|
113
|
+
从一个需要多方协作的任务开始:
|
|
88
114
|
|
|
89
|
-
|
|
115
|
+
```text
|
|
116
|
+
阅读当前目录的资料,整理一份项目评估报告。
|
|
117
|
+
把独立部分交给子 agent:梳理项目背景、分析风险、审查结论与依据。
|
|
118
|
+
汇总为 report.md,引用资料来源,标明信息缺口。
|
|
119
|
+
将报告合并回我的工作区之前,先请求审批。
|
|
120
|
+
```
|
|
90
121
|
|
|
91
|
-
|
|
122
|
+
协调器管理子 agent 的依赖、并发、消息和生命周期。实际分工由任务和模型决策驱动;独立步骤可以并行,有依赖的步骤等待前置结果。
|
|
92
123
|
|
|
93
|
-
|
|
94
|
-
2. **协调器组织分工。** 子 agent 拥有独立身份、生命周期、依赖和消息通道。独立任务可以在配置的并发额度内同时推进。
|
|
95
|
-
3. **写入任务进入隔离工作区。** Git 项目从工作树快照创建私有克隆,包含符合快照规则的未提交修改;非 Git 项目使用受控复制快照。只读 agent 可以共享父工作区视图。
|
|
96
|
-
4. **通过产物合并交付修改。** 写入型 agent 生成冻结产物;合并前检查冲突和父工作区是否发生变化。子 agent 的暂存和提交留在私有仓库,合并交付文件修改,不搬运子 agent 的提交历史。
|
|
97
|
-
5. **事件流让过程可见。** Watch 观察执行生命周期,不控制任务。运行时区分执行结果与任务验收;任务是否满足要求,需要显式评估器或人工审查。
|
|
124
|
+
写入型 agent 在私有工作区中处理文件、编写报告、运行脚本;开发任务也可以安装依赖、运行测试,以及暂存或提交修改,具体受工具权限和平台沙箱约束。合并交付文件修改,不搬运子 agent 的提交历史。详见[工作区隔离](docs/architecture/48-non-git-workspace-isolation.md)。
|
|
98
125
|
|
|
99
|
-
|
|
126
|
+
## 看见任务如何推进
|
|
100
127
|
|
|
101
|
-
|
|
102
|
-
| :--- | :--- |
|
|
103
|
-
| [`src/`](src/) | 终端交互、模型配置、会话、Headless/ACP 宿主和 Watch。 |
|
|
104
|
-
| [`zapsdk/`](zapsdk/) | 可复用的 TypeScript agent 运行时:模型循环、协作、工具、权限、工作区、合并、上下文、记忆与事件。 |
|
|
105
|
-
| [`zapvm/`](zapvm/) | 独立 Go 执行运行时。可选 VM 通过 SDK 执行协议接入,不负责 agent 提示词、权限或完成判定。 |
|
|
128
|
+

|
|
106
129
|
|
|
107
|
-
|
|
130
|
+
*截图来自真实 Watch 界面,使用内置模拟事件展示,不代表基准测试或一次真实模型任务。*
|
|
108
131
|
|
|
109
|
-
|
|
132
|
+
运行 `zap --watch`,在本地浏览器中跟随 agent 协作关系和工具生命周期:谁在运行、哪个工具正在执行、哪里需要审批,都有对应状态。
|
|
110
133
|
|
|
111
|
-
|
|
112
|
-
- **持续推进长任务。** 上下文压缩、项目记忆、保存的会话和后续消息队列帮助跨轮次工作。用 `/queue` 追加下一步,或调整当前任务方向。
|
|
113
|
-
- **掌握工具权限。** 通过 `/permissions` 查看权限和授权范围。命令默认使用宿主 OS 沙箱,VM 按需启用;平台差异见[执行边界说明](docs/architecture/39-local-sandbox-default.md)。
|
|
114
|
-
- **回到之前的工作。** `/rewind` 支持恢复对话、已跟踪的代码修改或两者。恢复点有覆盖范围,外部副作用和所有文件目录结构变化并非都能完整撤销。
|
|
115
|
-
- **接入已有工具。** 内置文件、搜索、Shell、HTTP 和文档工具,并支持 MCP 与 skills。
|
|
116
|
-
- **构建自己的宿主。** 复用 SDK,通过 Headless 输出结构化事件,或接入兼容 ACP 的客户端。
|
|
134
|
+
Watch **只读**,展示运行元数据,不展示提示词、工具参数或工具输出。刷新页面不会重放工具。本地回环地址包含私有访问令牌,请勿分享。使用 `--watch-no-open` 可以只输出地址,不自动打开浏览器。[Watch 详细说明 →](docs/architecture/57-watch-runtime-observability.md)
|
|
117
135
|
|
|
118
|
-
|
|
136
|
+
## 接入你的工作流
|
|
119
137
|
|
|
120
|
-
|
|
138
|
+
| 你的需求 | zapAgent 提供的能力 |
|
|
139
|
+
| :--- | :--- |
|
|
140
|
+
| 使用自己的模型服务 | `/connect`、`/model`、`/effort`;支持 Anthropic、Chat Completions 和 Responses 协议。 |
|
|
141
|
+
| 持续推进长任务 | 上下文压缩、项目记忆、保存的会话,以及 `/queue` 后续请求队列。 |
|
|
142
|
+
| 掌握工具权限 | `/permissions`、限定范围的审批,默认使用宿主 OS 沙箱。[平台边界](docs/architecture/39-local-sandbox-default.md)。 |
|
|
143
|
+
| 回到之前的工作 | `/rewind` 恢复对话、已跟踪的代码修改或两者;外部副作用和部分文件系统变化不在恢复范围内。 |
|
|
144
|
+
| 接入现有工具 | 内置文件、搜索、Shell、HTTP 和文档工具,以及 MCP 集成和 skills。 |
|
|
145
|
+
| 自动化或构建自己的宿主 | 结构化 Headless 输出、ACP 适配器,以及可复用的 TypeScript SDK。 |
|
|
146
|
+
|
|
147
|
+
配置模型服务后,可以接入脚本:
|
|
121
148
|
|
|
122
149
|
```bash
|
|
123
|
-
zap -p "
|
|
124
|
-
zap --watch -p "
|
|
150
|
+
zap -p "整理当前目录的资料,列出主题、结论与待确认的问题" --output-format json
|
|
151
|
+
zap --watch -p "分析当前目录的数据并生成报告" --output-format stream-json --watch-linger 30
|
|
125
152
|
```
|
|
126
153
|
|
|
127
|
-
|
|
154
|
+
完整命令、配置、审批和自动化选项见 `zap --help-headless` 与 [CLI 手册](docs/usage.md)。
|
|
155
|
+
|
|
156
|
+
## 它如何工作
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
宿主通过 `AgentRuntime` 发起任务,`LoopAgent` 管理模型与工具循环、上下文和执行预算。协调器组织子任务;写入型 agent 返回冻结产物,经过冲突和工作区漂移检查后合并。运行事件驱动 Watch。执行成功与任务验收分别记录,验收需要显式评估器或人工审查。
|
|
161
|
+
|
|
162
|
+
| 模块 | 职责 |
|
|
163
|
+
| :--- | :--- |
|
|
164
|
+
| [`src/`](src/) | 终端交互、模型配置、会话、Headless/ACP 宿主和 Watch。 |
|
|
165
|
+
| [`zapsdk/`](zapsdk/) | TypeScript agent 运行时:模型循环、协作、工具、权限、工作区、合并、上下文、记忆与事件。 |
|
|
166
|
+
| [`zapvm/`](zapvm/) | 独立 Go 执行运行时;可选 VM 通过 SDK 协议接入,不负责 agent 提示词、权限或完成判定。 |
|
|
128
167
|
|
|
129
|
-
|
|
168
|
+
Git 项目使用工作树快照的私有克隆,包含符合规则的未提交修改;非 Git 项目使用受控复制快照。只读 agent 可以共享父工作区视图。
|
|
130
169
|
|
|
131
|
-
|
|
170
|
+
实现细节见[架构索引](docs/architecture/README.md)与[多 agent 设计](docs/architecture/26-multi-agent-orchestration.md)。
|
|
171
|
+
|
|
172
|
+
## 参与贡献
|
|
173
|
+
|
|
174
|
+
欢迎改进模型兼容性、沙箱行为、多 agent 协作和运行可视化。反馈问题时,请附上预期行为与最小复现,并移除凭据和私有代码。
|
|
132
175
|
|
|
133
176
|
```bash
|
|
134
177
|
bun run typecheck
|
|
@@ -136,9 +179,7 @@ bun test
|
|
|
136
179
|
bun run build
|
|
137
180
|
```
|
|
138
181
|
|
|
139
|
-
修改独立 VM 模块时使用 `bun run check:vm`;`bun run build:all`
|
|
140
|
-
|
|
141
|
-
如果这也是你期待的终端工作方式,欢迎 Star 并参与完善。
|
|
182
|
+
修改独立 VM 模块时使用 `bun run check:vm`;`bun run build:all` 构建两部分宿主组件。详见 [CONTRIBUTING.md](CONTRIBUTING.md)、[Issues](https://github.com/JackCaow/zapagent/issues) 和 [SECURITY.md](SECURITY.md)。
|
|
142
183
|
|
|
143
184
|
## 许可证
|
|
144
185
|
|
package/npm/cli.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("node:child_process");
|
|
3
|
+
const { constants } = require("node:os");
|
|
4
|
+
const { ensureBinary } = require("./install.cjs");
|
|
5
|
+
(async () => {
|
|
6
|
+
const binary = await ensureBinary();
|
|
7
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit", env: process.env });
|
|
8
|
+
const forward = signal => { if (!child.killed) child.kill(signal); };
|
|
9
|
+
const handlers = Object.fromEntries(["SIGINT", "SIGTERM", "SIGHUP"].map(signal => [signal, () => forward(signal)]));
|
|
10
|
+
for (const [signal, handler] of Object.entries(handlers)) process.on(signal, handler);
|
|
11
|
+
child.on("error", error => { console.error(`Could not start zapAgent: ${error.message}`); process.exitCode = 1; });
|
|
12
|
+
child.on("exit", (code, signal) => {
|
|
13
|
+
for (const [name, handler] of Object.entries(handlers)) process.removeListener(name, handler);
|
|
14
|
+
process.exitCode = code ?? (signal ? 128 + (constants.signals[signal] || 1) : 1);
|
|
15
|
+
});
|
|
16
|
+
})().catch(error => {
|
|
17
|
+
console.error(`zapAgent: ${error.message}\nCheck network access to GitHub Releases, then run zap again.`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
});
|
package/npm/install.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The CLI is a compiled executable; only SDK/source development needs Bun.
|
|
2
|
+
const { createHash, randomUUID } = require("node:crypto");
|
|
3
|
+
const { chmodSync, createReadStream, createWriteStream, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } = require("node:fs");
|
|
4
|
+
const { Readable, Transform } = require("node:stream");
|
|
5
|
+
const { pipeline } = require("node:stream/promises");
|
|
6
|
+
const { homedir } = require("node:os");
|
|
7
|
+
const { dirname, join } = require("node:path");
|
|
8
|
+
|
|
9
|
+
const assets = Object.freeze({
|
|
10
|
+
"darwin-arm64": "zap-macos-arm64", "darwin-x64": "zap-macos-x64",
|
|
11
|
+
"linux-arm64": "zap-linux-arm64", "linux-x64": "zap-linux-x64",
|
|
12
|
+
"win32-x64": "zap-windows-x64.exe",
|
|
13
|
+
});
|
|
14
|
+
function target(platform = process.platform, arch = process.arch) {
|
|
15
|
+
const asset = assets[`${platform}-${arch}`];
|
|
16
|
+
if (!asset) throw new Error(`zapAgent does not provide a binary for ${platform}/${arch}. Supported: ${Object.keys(assets).join(", ")}`);
|
|
17
|
+
return asset;
|
|
18
|
+
}
|
|
19
|
+
function digest(bytes) { return createHash("sha256").update(bytes).digest("hex"); }
|
|
20
|
+
async function validBinary(file, checksum) {
|
|
21
|
+
if (typeof checksum !== "string" || !/^[a-f0-9]{64}$/.test(checksum)) return false;
|
|
22
|
+
try {
|
|
23
|
+
const hash = createHash("sha256");
|
|
24
|
+
for await (const bytes of createReadStream(file)) hash.update(bytes);
|
|
25
|
+
return hash.digest("hex") === checksum;
|
|
26
|
+
} catch { return false; }
|
|
27
|
+
}
|
|
28
|
+
async function ensureBinary(options = {}) {
|
|
29
|
+
const platform = options.platform ?? process.platform, arch = options.arch ?? process.arch;
|
|
30
|
+
const asset = target(platform, arch);
|
|
31
|
+
const version = options.version ?? require("../package.json").version;
|
|
32
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) throw new Error("Invalid zapAgent package version");
|
|
33
|
+
const env = options.env ?? process.env;
|
|
34
|
+
const cache = env.ZAPAGENT_CACHE_DIR || (platform === "win32" ? env.LOCALAPPDATA : env.XDG_CACHE_HOME) || join(homedir(), ".cache");
|
|
35
|
+
const file = join(cache, "zapagent", version, `${platform}-${arch}`, platform === "win32" ? "zap.exe" : "zap");
|
|
36
|
+
const checksumFile = `${file}.sha256`;
|
|
37
|
+
let checksum;
|
|
38
|
+
try { checksum = readFileSync(checksumFile, "utf8").trim(); } catch {}
|
|
39
|
+
if (await validBinary(file, checksum)) return file;
|
|
40
|
+
const base = new URL(env.ZAPAGENT_DOWNLOAD_BASE_URL || "https://github.com/JackCaow/zapagent/releases/download/");
|
|
41
|
+
if (base.protocol !== "https:" && !(base.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(base.hostname))) {
|
|
42
|
+
throw new Error("Binary downloads require HTTPS (HTTP is allowed only for loopback tests)");
|
|
43
|
+
}
|
|
44
|
+
const url = `${base.href.replace(/\/$/, "")}/v${version}/${asset}`;
|
|
45
|
+
const fetcher = options.fetch ?? fetch;
|
|
46
|
+
async function download(address) {
|
|
47
|
+
const response = await fetcher(address, { signal: AbortSignal.timeout(180_000), redirect: "follow" });
|
|
48
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} downloading ${address}`);
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
// Validate metadata before fetching executable bytes. Never run a partial download.
|
|
52
|
+
const metadata = await (await download(`${url}.sha256`)).text();
|
|
53
|
+
const match = metadata.trim().match(/^([a-fA-F0-9]{64})\s+\*?([^\r\n]+)$/);
|
|
54
|
+
if (!match || match[2] !== asset) throw new Error(`Invalid checksum metadata for ${asset}`);
|
|
55
|
+
checksum = match[1].toLowerCase();
|
|
56
|
+
const response = await download(url);
|
|
57
|
+
if (!response.body) throw new Error(`Empty binary response for ${asset}`);
|
|
58
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
59
|
+
const pending = `${file}.${randomUUID()}.tmp`;
|
|
60
|
+
try {
|
|
61
|
+
const hash = createHash("sha256");
|
|
62
|
+
const meter = new Transform({ transform(bytes, _encoding, done) { hash.update(bytes); done(null, bytes); } });
|
|
63
|
+
await pipeline(Readable.fromWeb(response.body), meter, createWriteStream(pending, { flags: "wx", mode: 0o600 }));
|
|
64
|
+
if (hash.digest("hex") !== checksum) throw new Error(`Checksum verification failed for ${asset}`);
|
|
65
|
+
chmodSync(pending, 0o755);
|
|
66
|
+
try { renameSync(pending, file); } catch (error) {
|
|
67
|
+
// Concurrent installers may finish the same verified download on Windows.
|
|
68
|
+
if (!await validBinary(file, checksum)) throw error;
|
|
69
|
+
}
|
|
70
|
+
writeFileSync(checksumFile, `${checksum}\n`);
|
|
71
|
+
} finally { rmSync(pending, { force: true }); }
|
|
72
|
+
return file;
|
|
73
|
+
}
|
|
74
|
+
module.exports = { assets, target, digest, ensureBinary };
|
|
75
|
+
if (require.main === module) {
|
|
76
|
+
ensureBinary().catch(error => {
|
|
77
|
+
// npm/Bun --ignore-scripts and temporary network failures are recoverable at launch.
|
|
78
|
+
console.warn(`zapAgent binary setup deferred: ${error.message}\nRun zap to retry. No separate Bun installation is needed.`);
|
|
79
|
+
});
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zapagent",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.7",
|
|
4
4
|
"packageManager": "bun@1.3.14",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "src/index.tsx",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"zod": "4.6.7"
|
|
68
68
|
},
|
|
69
69
|
"bin": {
|
|
70
|
-
"zap": "
|
|
70
|
+
"zap": "npm/cli.cjs"
|
|
71
71
|
},
|
|
72
72
|
"description": "Terminal-based AI coding agent for fast, agentic software development.",
|
|
73
73
|
"repository": {
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"files": [
|
|
82
82
|
"src",
|
|
83
|
+
"npm",
|
|
83
84
|
"zapsdk",
|
|
84
85
|
"patches",
|
|
85
86
|
"third_party/yoga-layout/LICENSE",
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
],
|
|
101
102
|
"license": "MIT",
|
|
102
103
|
"engines": {
|
|
103
|
-
"
|
|
104
|
+
"node": ">=22"
|
|
104
105
|
},
|
|
105
106
|
"type": "module",
|
|
106
107
|
"devDependencies": {
|
|
@@ -112,5 +113,8 @@
|
|
|
112
113
|
"ink-spinner",
|
|
113
114
|
"ink-text-input",
|
|
114
115
|
"react"
|
|
115
|
-
]
|
|
116
|
+
],
|
|
117
|
+
"scripts": {
|
|
118
|
+
"postinstall": "node npm/install.cjs"
|
|
119
|
+
}
|
|
116
120
|
}
|