@easbot/acp 0.3.29 → 0.3.32
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.en.md +54 -27
- package/README.md +85 -34
- package/dist/chunks/bootstrap-GGS3N5CF.cjs +1 -0
- package/dist/chunks/bootstrap-MZQICOGZ.mjs +1 -0
- package/dist/chunks/cache-3R3ORBTY.cjs +1 -0
- package/dist/chunks/cache-76CBF3LU.mjs +1 -0
- package/dist/chunks/chunk-2KOCPHVP.mjs +1 -0
- package/dist/chunks/chunk-33M2R2US.mjs +1 -0
- package/dist/chunks/chunk-3DHMW4DB.mjs +11 -0
- package/dist/chunks/chunk-5HWD3B3N.cjs +11 -0
- package/dist/chunks/chunk-7RWES66A.cjs +2 -0
- package/dist/chunks/chunk-B3ANZALB.mjs +2 -0
- package/dist/chunks/chunk-BNSJ6COS.cjs +1 -0
- package/dist/chunks/chunk-D4TSQ2TT.mjs +0 -0
- package/dist/chunks/chunk-D7S7ARXV.mjs +8 -0
- package/dist/chunks/chunk-DX35VSAT.cjs +1 -0
- package/dist/chunks/chunk-ITV7SWGU.cjs +8 -0
- package/dist/chunks/chunk-JLO7UYKQ.cjs +1 -0
- package/dist/chunks/chunk-NHXAYBZH.mjs +1 -0
- package/dist/chunks/chunk-PATHHDWE.mjs +1 -0
- package/dist/chunks/chunk-RHW6YR3D.mjs +2 -0
- package/dist/chunks/chunk-SNWAB3QJ.cjs +2 -0
- package/dist/chunks/chunk-VVGGER23.cjs +1 -0
- package/dist/chunks/chunk-Z3YEK7DD.cjs +1 -0
- package/dist/chunks/cli-handler-6XB6B5DV.mjs +1 -0
- package/dist/chunks/cli-handler-IU3YUTOU.cjs +1 -0
- package/dist/chunks/config-FTGKCGYZ.mjs +1 -0
- package/dist/chunks/config-ZVDYJ7TW.cjs +1 -0
- package/dist/chunks/interfaces-6ZCF5T55.cjs +1 -0
- package/dist/chunks/{interfaces-UB3BFHJN.mjs → interfaces-TXNKX4HT.mjs} +1 -1
- package/dist/chunks/loader-3KX33KJQ.cjs +1 -0
- package/dist/chunks/loader-6HBCWO6Y.mjs +1 -0
- package/dist/chunks/types-BZWPIPG6.mjs +1 -0
- package/dist/chunks/types-R3VOD4XE.cjs +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1157 -374
- package/dist/index.d.ts +1157 -374
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
- package/dist/chunks/bootstrap-5LQOAO3Q.cjs +0 -1
- package/dist/chunks/bootstrap-VXDGNMPK.mjs +0 -1
- package/dist/chunks/cache-EJ4Y2PSY.cjs +0 -1
- package/dist/chunks/cache-SOYLU2DS.mjs +0 -1
- package/dist/chunks/chunk-3OTURNTA.cjs +0 -11
- package/dist/chunks/chunk-CIOYWMQM.cjs +0 -1
- package/dist/chunks/chunk-DS4SO4NN.cjs +0 -2
- package/dist/chunks/chunk-ER7EK5Z3.mjs +0 -8
- package/dist/chunks/chunk-F44AHCPJ.cjs +0 -8
- package/dist/chunks/chunk-HA3RF4AE.cjs +0 -1
- package/dist/chunks/chunk-MFINI6BI.mjs +0 -1
- package/dist/chunks/chunk-PEMSMRYT.mjs +0 -1
- package/dist/chunks/chunk-RTXRNSMY.mjs +0 -1
- package/dist/chunks/chunk-SHXWJMFY.mjs +0 -11
- package/dist/chunks/chunk-UTBY7IJT.mjs +0 -2
- package/dist/chunks/chunk-Z4D2PWDQ.cjs +0 -1
- package/dist/chunks/cli-handler-2KK2I4DG.mjs +0 -1
- package/dist/chunks/cli-handler-EM2BY47U.cjs +0 -1
- package/dist/chunks/config-KX5CSYLV.mjs +0 -1
- package/dist/chunks/config-YIR7GKPG.cjs +0 -1
- package/dist/chunks/interfaces-6BMD3FTB.cjs +0 -1
- package/dist/chunks/types-CHN33Z37.mjs +0 -1
- package/dist/chunks/types-XGBPFI7X.cjs +0 -1
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@ English | [中文](./README.md)
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.32
|
|
10
10
|
## Introduction
|
|
11
11
|
|
|
12
12
|
`@easbot/acp` is the **ACP adapter layer** (v0.1, split from `@easbot/agent`'s `adapter/` submodule) of the EASBot ecosystem. Built on top of [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk), it implements the server / client communication layer of the ACP protocol with multi-channel connections, JSON-RPC routing, configuration management, cache management, and a standalone CLI entry point.
|
|
@@ -16,13 +16,13 @@ v0.3.29
|
|
|
16
16
|
- ✅ **Decouple business complexity**: agent package strips the ACP protocol layer; business modules (session / mcp / gateway) depend on a lighter surface
|
|
17
17
|
- ✅ **Standalone publishing**: `@easbot/acp` can be published independently; host projects (web / cli / monitor) can import on demand
|
|
18
18
|
- ✅ **Standalone CLI**: `easbot-acp <command>` starts server / config / status / doctor directly without going through agent
|
|
19
|
-
- ✅ **Independent configuration**: `<workspaceDir>/.easbot/acp.json` + `~/.config/easbot/acp.json` +
|
|
19
|
+
- ✅ **Independent configuration**: `<workspaceDir>/.easbot/acp.json` + `~/.config/easbot/acp.json` + `easbot.json` top-level `acp` field (four-layer merge loading, mirrors gateway)
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
23
|
- **Three transports**: stdio (subprocess) / http (REST + JSON-RPC) / websocket (full-duplex)
|
|
24
24
|
- **JSON-RPC routing**: `acp-rpc-handler` auto-dispatches `initialize / new_session / prompt / cancel` and other methods
|
|
25
|
-
- **
|
|
25
|
+
- **Four-layer config loader**: mirrors `packages/gateway/src/config/loader.ts` — global / `easbot.json` field / project-level merge + JSONC + env substitution
|
|
26
26
|
- **L2 cache namespace**: `AcpCache` (State.holder pattern, same source as `NoteCache`) manages project-level `.easbot/acp.json`
|
|
27
27
|
- **Error namespace**: `AcpError` (built on `NamedError.create` + ADR 0102 Phase 2.1 business feedback channel)
|
|
28
28
|
- **Standalone CLI**: `easbot-acp <command>` (init / start / status / doctor / config)
|
|
@@ -152,24 +152,44 @@ await EasbotAdapter.init({
|
|
|
152
152
|
await EasbotAdapter.ensureACPService(serverCfg);
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
### 3.
|
|
155
|
+
### 3. Config loading (four-layer merge, mirrors gateway)
|
|
156
156
|
|
|
157
|
-
ACP config is layered **from low to high priority
|
|
157
|
+
ACP config is layered **from low to high priority** (later layers override earlier ones, deep-merged across `server` / `clients` blocks):
|
|
158
158
|
|
|
159
|
-
| Priority | Path
|
|
160
|
-
| -------- |
|
|
161
|
-
| Lowest | `~/.config/easbot/
|
|
162
|
-
| ↑ |
|
|
163
|
-
| ↑ |
|
|
164
|
-
|
|
|
165
|
-
|
|
159
|
+
| Priority | Path | Notes |
|
|
160
|
+
| -------- | ---------------------------------------------- | ------------------------------------------------ |
|
|
161
|
+
| Lowest | `~/.config/easbot/easbot.json` top-level `acp` | agent-integration wrapper (global) |
|
|
162
|
+
| ↑ | `~/.config/easbot/acp.json` | Global standalone config |
|
|
163
|
+
| ↑ | `<workspaceDir>/easbot.json` top-level `acp` | agent-integration wrapper (project-level) |
|
|
164
|
+
| Highest | `<workspaceDir>/.easbot/acp.json` | Project-level standalone config (via `AcpCache`) |
|
|
165
|
+
|
|
166
|
+
Two override rules:
|
|
167
|
+
|
|
168
|
+
- **Project-level overrides global** (`<workspaceDir>` wins over `~/.config/easbot/`)
|
|
169
|
+
- **`acp.json` overrides `easbot.json`** (standalone config beats the agent-integration wrapper)
|
|
170
|
+
|
|
171
|
+
Key points:
|
|
172
|
+
|
|
173
|
+
- Project-level `acp.json` lives in **exactly one place**: `.easbot/acp.json` (held by `AcpCache`).
|
|
174
|
+
Bare `<workspaceDir>/acp.json` is no longer supported, and `EASBOT_CONFIG_DIR` no longer
|
|
175
|
+
participates in the resolution chain.
|
|
176
|
+
- `<workspaceDir>` comes from `getInstance().directory` (Instance is injected uniformly by the CLI entry point).
|
|
177
|
+
- **Single schema source**: raw reads apply **no** schema; validation + defaults are applied exactly
|
|
178
|
+
once at the end via `ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)` — applying them
|
|
179
|
+
per-layer would let defaults leak across layers (a defaulted low-priority field overriding a real one).
|
|
180
|
+
- **No config file → no initial values**: `server` in `ACPInfoACPConfigSchema` is `.optional()` with
|
|
181
|
+
**no** transform fallback. When all four layers are missing, `loadConfig()` returns `{}`
|
|
182
|
+
(`server` is `undefined` — it never fabricates a port-3000 server). Use `getServerConfig()`
|
|
183
|
+
(which merges over `ACP_DEFAULT_SERVER_CONFIG`) or `ACPServerConfigSchema.parse({})` when you need
|
|
184
|
+
server defaults.
|
|
185
|
+
- Semantics identical to `packages/gateway`'s `GatewayCache` loader (same structure).
|
|
166
186
|
|
|
167
187
|
Supports:
|
|
168
188
|
|
|
169
189
|
- **JSONC comments** (`//` / `/* ... */`)
|
|
170
190
|
- **`{env:VAR_NAME}` substitution** (auto-read from `process.env`)
|
|
171
|
-
- **Deep merge
|
|
172
|
-
- **State.holder caching** (per
|
|
191
|
+
- **Deep merge + schema defaults** (`ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)`)
|
|
192
|
+
- **State.holder caching** (bucketed per workspace + `AcpCache.resetState()` / `clearConfigCache()`)
|
|
173
193
|
|
|
174
194
|
### 4. L2 cache: `AcpCache` namespace
|
|
175
195
|
|
|
@@ -178,7 +198,7 @@ ACP subsystem owns an independent L2 config file `<workspaceDir>/.easbot/acp.jso
|
|
|
178
198
|
```typescript
|
|
179
199
|
import { AcpCache } from '@easbot/acp';
|
|
180
200
|
|
|
181
|
-
// 1. Explicit
|
|
201
|
+
// 1. Explicit warm-up — already invoked by EasbotAdapter.init(), usually no need to call manually
|
|
182
202
|
await AcpCache.init();
|
|
183
203
|
|
|
184
204
|
// 2. Read
|
|
@@ -194,6 +214,8 @@ await AcpCache.writeAcpJson({ server: { channel: 'http', port: 8080 } });
|
|
|
194
214
|
AcpCache.resetState(); // clear holder + idempotent flag
|
|
195
215
|
```
|
|
196
216
|
|
|
217
|
+
> `EasbotAdapter.init()` warms up `AcpCache` right after `initInstance()` (it must run after `Instance.provide` because the cache is bucketed by `Instance.directory`). A failed warm-up only degrades to a warn log (subsequent reads fall back to lazy load) and never blocks adapter startup.
|
|
218
|
+
|
|
197
219
|
### 5. Error handling
|
|
198
220
|
|
|
199
221
|
Layered per `spec/error-handling-standard.md` v1.5:
|
|
@@ -398,6 +420,11 @@ $ easbot-acp start --channel websocket
|
|
|
398
420
|
$ easbot acp start --channel http --port 3000
|
|
399
421
|
```
|
|
400
422
|
|
|
423
|
+
> The **`address` row** of the start banner is a full protocol URL (built by the single
|
|
424
|
+
> source of truth `getAcpEndpointUrl`): `ws://<hostname>:<port>` / `http://<hostname>:<port>` /
|
|
425
|
+
> `stdio://easbot`. The same rule backs the server-side `getServerUrl` and the `address` the
|
|
426
|
+
> agent registers with Gateway, so the three can never drift apart.
|
|
427
|
+
|
|
401
428
|
## Architecture
|
|
402
429
|
|
|
403
430
|
```
|
|
@@ -417,7 +444,7 @@ $ easbot acp start --channel http --port 3000
|
|
|
417
444
|
│ ├─ interfaces.ts (host ↔ package decoupling) │
|
|
418
445
|
│ ├─ server/ (acp-server / http-server / ws-server) │
|
|
419
446
|
│ ├─ client/ (acp-client / stdio / http / ws subscriber) │
|
|
420
|
-
│ ├─ connection/ (registry / router)
|
|
447
|
+
│ ├─ connection/ (registry / router / types — types is a re-export layer; source of truth in @easbot/utils) │
|
|
421
448
|
│ ├─ event/ (acp-event-bridge) │
|
|
422
449
|
│ ├─ performance/ (performance-monitor / streaming) │
|
|
423
450
|
│ ├─ error/ (error-handler / timeout-manager) │
|
|
@@ -429,15 +456,15 @@ $ easbot acp start --channel http --port 3000
|
|
|
429
456
|
|
|
430
457
|
## Differences from note / gateway / memory
|
|
431
458
|
|
|
432
|
-
| Dimension | note | gateway
|
|
433
|
-
| ----------------------- | --------------------- |
|
|
434
|
-
| L2 config file name | `note.json` | `gateway.json`
|
|
435
|
-
| L2 cache name | `NoteCache` | (no L2 cache)
|
|
436
|
-
| Error namespace | `NoteError` | `GatewayError`
|
|
437
|
-
| Business code whitelist | 13 | (not registered)
|
|
438
|
-
| Command count | 11 | 0 (no standalone CLI)
|
|
439
|
-
| Top-level deps | LLM / DB / parser | hono / undici / ws
|
|
440
|
-
| Config loading | single-file NoteCache |
|
|
459
|
+
| Dimension | note | gateway | acp |
|
|
460
|
+
| ----------------------- | --------------------- | ------------------------------------------------------- | ------------------------------------------------------- |
|
|
461
|
+
| L2 config file name | `note.json` | `gateway.json` | `acp.json` |
|
|
462
|
+
| L2 cache name | `NoteCache` | (no L2 cache) | `AcpCache` |
|
|
463
|
+
| Error namespace | `NoteError` | `GatewayError` | `AcpError` |
|
|
464
|
+
| Business code whitelist | 13 | (not registered) | 5 |
|
|
465
|
+
| Command count | 11 | 0 (no standalone CLI) | 5 |
|
|
466
|
+
| Top-level deps | LLM / DB / parser | hono / undici / ws | @agentclientprotocol/sdk |
|
|
467
|
+
| Config loading | single-file NoteCache | four-layer merge (global + easbot.json field + project) | four-layer merge (global + easbot.json field + project) |
|
|
441
468
|
|
|
442
469
|
## Development commands
|
|
443
470
|
|
|
@@ -470,7 +497,7 @@ pnpm --filter @easbot/acp test:clean
|
|
|
470
497
|
## Design principles
|
|
471
498
|
|
|
472
499
|
1. **host ↔ package decoupling**: all runtime dependencies are explicitly injected via `setGlobalAdapter / setInstanceAdapter`; agent package / standalone CLI / tests share the same semantics
|
|
473
|
-
2. **
|
|
500
|
+
2. **Four-layer config loading**: mirrors `packages/gateway/src/config/loader.ts`, with JSONC + env substitution + State.holder three-piece set
|
|
474
501
|
3. **Error layering**: in-package `AcpError` (business semantics) + `NameErrors` (generic) + `ServiceError + ServiceErrorBus` (LLM business feedback)
|
|
475
502
|
4. **CLI / handler separation**: `handleAcpCli(args, deps)` entry is independently testable; agent / standalone CLI / MCP server reuse the same dispatch logic
|
|
476
503
|
5. **No business-instance ownership**: acp package does not depend on `@easbot/agent` internal modules; only exposes server startup via `EasbotAdapter` (AdapterRegistry injected by agent bootstrap)
|
|
@@ -488,7 +515,7 @@ pnpm --filter @easbot/acp test:clean
|
|
|
488
515
|
|
|
489
516
|
- [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk) — official TypeScript SDK for ACP protocol
|
|
490
517
|
- `packages/note/src/cli-handler.ts` — CLI handler reference
|
|
491
|
-
- `packages/gateway/src/config/loader.ts` —
|
|
518
|
+
- `packages/gateway/src/config/loader.ts` — four-layer config loader reference
|
|
492
519
|
- `packages/note/src/cache/index.ts` — same-source reference for AcpCache (Pattern E)
|
|
493
520
|
- `packages/note/src/errors.ts` — same-source reference for AcpError
|
|
494
521
|
- `ADR 0066` — host ↔ package decoupling specification
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.32
|
|
10
10
|
## 简介
|
|
11
11
|
|
|
12
12
|
`@easbot/acp` 是 EASBot 生态的 **ACP 适配层**(v0.1,从 `@easbot/agent` 的 `adapter/` 子模块拆分独立)。基于 [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk),实现 ACP 协议的 server / client 通信层,提供多通道连接、JSON-RPC 路由、配置管理、缓存管理以及独立 CLI 入口。
|
|
@@ -16,15 +16,15 @@ v0.3.29
|
|
|
16
16
|
- ✅ **解耦业务复杂度**:agent 包剥离 acp 协议层,业务模块(session / mcp / gateway)依赖更轻
|
|
17
17
|
- ✅ **独立发布**:acp 包可独立 npm 发布,宿主项目(web / cli / monitor)按需引入
|
|
18
18
|
- ✅ **独立 CLI**:`easbot-acp <command>` 直接启动 server / config / status / doctor,无需走 agent
|
|
19
|
-
- ✅ **独立配置**:`<workspaceDir>/.easbot/acp.json`
|
|
19
|
+
- ✅ **独立配置**:`<workspaceDir>/.easbot/acp.json`(由 `AcpCache` 持有)+ `~/.config/easbot/acp.json` + `easbot.json` 顶层 `acp` 字段(四层合并加载,与 gateway 同构)
|
|
20
20
|
|
|
21
21
|
## 特性
|
|
22
22
|
|
|
23
23
|
- **三通道传输**:stdio(子进程)/ http(REST + JSON-RPC)/ websocket(全双工)
|
|
24
24
|
- **JSON-RPC 路由**:`acp-rpc-handler` 自动 dispatch `initialize / new_session / prompt / cancel` 等 method
|
|
25
|
-
-
|
|
25
|
+
- **四层配置加载**:参考 `packages/gateway/src/config/loader.ts` 的四层合并 + JSONC + env 替换
|
|
26
26
|
- **L2 缓存命名空间**:`AcpCache`(State.holder 模式,与 `NoteCache` 同源)管理项目级 `.easbot/acp.json`
|
|
27
|
-
- **错误 namespace**:`AcpError`(按 `spec/error-handling-standard.md` v1.
|
|
27
|
+
- **错误 namespace**:`AcpError`(按 `spec/error-handling-standard.md` v1.9 分层;L2 包内 5 个核心错误 + L3 业务反馈注册)
|
|
28
28
|
- **i18n 国际化**:`t()` / `I18n` / `registerI18nResources`(zh-CN / en-US;与 note / gateway 完全同源)
|
|
29
29
|
- **独立 CLI 入口**:`easbot-acp <command>`(init / start / status / doctor / config)
|
|
30
30
|
- **host ↔ 包解耦**:与 note / memory / codebase / skills 完全对齐的 `setGlobalAdapter / setInstanceAdapter` 接口
|
|
@@ -165,24 +165,42 @@ await EasbotAdapter.init({
|
|
|
165
165
|
await EasbotAdapter.ensureACPService(serverCfg);
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
### 3.
|
|
168
|
+
### 3. 配置加载(四层合并,与 gateway 同构)
|
|
169
169
|
|
|
170
|
-
acp
|
|
170
|
+
acp 配置按优先级**从低到高**叠加(后者覆盖前者,深度合并 `server` / `clients` 块):
|
|
171
171
|
|
|
172
|
-
| 优先级 | 路径
|
|
173
|
-
| ------ |
|
|
174
|
-
| 最低 | `~/.config/easbot/
|
|
175
|
-
| ↑ |
|
|
176
|
-
| ↑ |
|
|
177
|
-
|
|
|
178
|
-
|
|
172
|
+
| 优先级 | 路径 | 说明 |
|
|
173
|
+
| ------ | -------------------------------------------- | ------------------------------------ |
|
|
174
|
+
| 最低 | `~/.config/easbot/easbot.json` 的 `acp` 字段 | agent 集成层包装格式(全局) |
|
|
175
|
+
| ↑ | `~/.config/easbot/acp.json` | 全局独立配置 |
|
|
176
|
+
| ↑ | `<workspaceDir>/easbot.json` 的 `acp` 字段 | agent 集成层包装格式(项目级) |
|
|
177
|
+
| 最高 | `<workspaceDir>/.easbot/acp.json` | 项目级独立配置(由 `AcpCache` 持有) |
|
|
178
|
+
|
|
179
|
+
两条覆盖规则:
|
|
180
|
+
|
|
181
|
+
- **项目级覆盖全局级**(`<workspaceDir>` 优先于 `~/.config/easbot/`)
|
|
182
|
+
- **`acp.json` 覆盖 `easbot.json`**(独立配置覆盖 agent 集成层的包装字段)
|
|
183
|
+
|
|
184
|
+
要点:
|
|
185
|
+
|
|
186
|
+
- 项目级 `acp.json` **只有** `.easbot/acp.json` 一个位置(由 `AcpCache` 读写),
|
|
187
|
+
不再支持项目根裸 `acp.json`;`EASBOT_CONFIG_DIR` 环境变量目录也不再参与加载链。
|
|
188
|
+
- `<workspaceDir>` 来自 `getInstance().directory`(Instance 由 CLI 入口统一注入)。
|
|
189
|
+
- **schema 单一来源**:各层读盘时**不套 schema**,仅在最后
|
|
190
|
+
`ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)` 统一校验 + 应用默认值一次 ——
|
|
191
|
+
避免每层各自填默认值造成「默认值污染」(错误的层覆盖真实的层)。
|
|
192
|
+
- **无配置文件 = 无初始值**:`ACPInfoACPConfigSchema` 的 `server` 是 `.optional()` 且**无 transform 兜底**,
|
|
193
|
+
四层配置全部缺失时 `loadConfig()` 返回 `{}`(`server` 为 `undefined`,不会凭空造出 port=3000 的 server)。
|
|
194
|
+
需要 server 默认值时用 `getServerConfig()`(内部以 `ACP_DEFAULT_SERVER_CONFIG` 为 base 合并)
|
|
195
|
+
或 `ACPServerConfigSchema.parse({})`。
|
|
196
|
+
- 与 `packages/gateway` 的 `GatewayCache` 加载语义完全一致(同构范本)。
|
|
179
197
|
|
|
180
198
|
支持:
|
|
181
199
|
|
|
182
200
|
- **JSONC 注释**(`//` / `/* ... */`)
|
|
183
201
|
- **`{env:VAR_NAME}` 替换**(自动从 `process.env` 读值)
|
|
184
|
-
-
|
|
185
|
-
- **State.holder
|
|
202
|
+
- **深度合并 + schema 默认值**(`ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)`)
|
|
203
|
+
- **State.holder 缓存**(按 workspace 分桶 + `AcpCache.resetState()` / `clearConfigCache()`)
|
|
186
204
|
|
|
187
205
|
### 4. L2 缓存:AcpCache 命名空间
|
|
188
206
|
|
|
@@ -191,7 +209,7 @@ acp 子系统拥有独立的 L2 配置文件 `<workspaceDir>/.easbot/acp.json`
|
|
|
191
209
|
```typescript
|
|
192
210
|
import { AcpCache } from '@easbot/acp';
|
|
193
211
|
|
|
194
|
-
// 1.
|
|
212
|
+
// 1. 显式预热 —— EasbotAdapter.init() 已自动调用,通常无需手动调
|
|
195
213
|
await AcpCache.init();
|
|
196
214
|
|
|
197
215
|
// 2. 读取
|
|
@@ -207,9 +225,11 @@ await AcpCache.writeAcpJson({ server: { channel: 'http', port: 8080 } });
|
|
|
207
225
|
AcpCache.resetState(); // 清 holder + 幂等标志
|
|
208
226
|
```
|
|
209
227
|
|
|
228
|
+
> `EasbotAdapter.init()` 在 `initInstance()` 之后预热 `AcpCache`(必须晚于 `Instance.provide`,因为 cache 按 `Instance.directory` 分桶)。预热失败只降级为 warn 日志(后续首次读取走 lazy load 兜底),不阻塞 adapter 启动。
|
|
229
|
+
|
|
210
230
|
### 5. 错误处理
|
|
211
231
|
|
|
212
|
-
按 `spec/error-handling-standard.md` v1.
|
|
232
|
+
按 `spec/error-handling-standard.md` v1.9 分层:
|
|
213
233
|
|
|
214
234
|
| 层 | 路径 | acp 用法 |
|
|
215
235
|
| ----------- | ---------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
@@ -271,7 +291,34 @@ throw new ServiceError({
|
|
|
271
291
|
| `AcpError.ClientConnectionFailedError` | client 连接失败 | `ClientConnectionFailedError` + `ClientDisconnectedError` |
|
|
272
292
|
| `AcpError.RpcParseFailedError` | JSON-RPC frame 损坏 | `RpcParseFailedError` |
|
|
273
293
|
|
|
274
|
-
|
|
294
|
+
**错误统一收敛到 `src/errors.ts`(v1.8)**:
|
|
295
|
+
|
|
296
|
+
ACP 的错误类、错误分类、类型守卫和错误工厂**全部定义在 `src/errors.ts`**,`src/types/` 只保留纯类型,不定义 error。
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import {
|
|
300
|
+
AcpError, // NamedError.create 生成的错误类集合
|
|
301
|
+
ErrorType, // Adapter 错误分类枚举
|
|
302
|
+
createAdapterError,
|
|
303
|
+
isAdapterError,
|
|
304
|
+
} from '@easbot/acp';
|
|
305
|
+
|
|
306
|
+
// 错误类本体全部是 NamedError.create,schema 字段统一走 .data 读取
|
|
307
|
+
throw new AcpError.RoutingError({ message, code: 'session_not_found' });
|
|
308
|
+
console.log(error.data.code);
|
|
309
|
+
|
|
310
|
+
// 或走工厂
|
|
311
|
+
throw createAdapterError(ErrorType.NETWORK_ERROR, 'remote unreachable', { clientId: 'remote-1' });
|
|
312
|
+
|
|
313
|
+
// 类型判断用显式守卫(NamedError.create 的 isInstance 在跨包 d.ts 下不收窄)
|
|
314
|
+
if (isAdapterError(err)) {
|
|
315
|
+
console.log(err.data.type, err.data.context);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
`src/errors.ts` 额外收敛:4 个错误类(`AdapterError` / `RoutingError` / `ServiceModeConflictError` / `AdapterEnvironmentInitializationError`)、`ErrorType` 枚举、4 个 `InstanceType` 类型别名、4 个带类型谓词的守卫、`isAdapterErrorRetryable` / `isAdapterErrorFatal` 分类 helper、5 个错误工厂。
|
|
320
|
+
|
|
321
|
+
**已删除的 v1.0 错误类**(按 v1.9 分层走 utils `NameErrors`):
|
|
275
322
|
|
|
276
323
|
- ❌ `ConfigLoadFailedError` → `NameErrors.FileParseError({ filePath, cause })`
|
|
277
324
|
- ❌ `InvalidHostnameError` → `NameErrors.ValidationError({ message, param: 'hostname' })`
|
|
@@ -411,6 +458,10 @@ $ easbot-acp start --channel websocket
|
|
|
411
458
|
$ easbot acp start --channel http --port 3000
|
|
412
459
|
```
|
|
413
460
|
|
|
461
|
+
> **start banner 的「地址」行按协议给出完整 URL**(由 `getAcpEndpointUrl` 单一真源构造):
|
|
462
|
+
> `ws://<hostname>:<port>` / `http://<hostname>:<port>` / `stdio://easbot`。
|
|
463
|
+
> 同一规则也用于 server 侧 `getServerUrl` 与 agent 注册到 Gateway 的 `address`,三处不会出现口径分裂。
|
|
464
|
+
|
|
414
465
|
## 架构关系
|
|
415
466
|
|
|
416
467
|
```
|
|
@@ -426,15 +477,15 @@ $ easbot acp start --channel http --port 3000
|
|
|
426
477
|
│ ├─ cli.ts / cli-handler.ts (独立 CLI 入口) │
|
|
427
478
|
│ ├─ cache/ (AcpCache 命名空间) │
|
|
428
479
|
│ ├─ config/ (schema + loader + 便捷访问) │
|
|
429
|
-
│ ├─ errors.ts (AcpError namespace)
|
|
480
|
+
│ ├─ errors.ts (AcpError namespace + ErrorType + 工厂 + 守卫) │
|
|
430
481
|
│ ├─ interfaces.ts (host ↔ 包解耦) │
|
|
431
482
|
│ ├─ server/ (acp-server / http-server / ws-server) │
|
|
432
483
|
│ ├─ client/ (acp-client / stdio / http / ws subscriber) │
|
|
433
|
-
│ ├─ connection/ (registry / router)
|
|
484
|
+
│ ├─ connection/ (registry / router / types — types 为透出层,真源在 @easbot/utils) │
|
|
434
485
|
│ ├─ event/ (acp-event-bridge) │
|
|
435
486
|
│ ├─ performance/ (performance-monitor / streaming) │
|
|
436
487
|
│ ├─ error/ (error-handler / timeout-manager) │
|
|
437
|
-
│ ├─ types/ (adapter / channel /
|
|
488
|
+
│ ├─ types/ (adapter / channel / event — 只放纯类型,不含 error) │
|
|
438
489
|
│ ├─ bootstrap/ (EasbotAdapter) │
|
|
439
490
|
│ └─ easbot-agent.ts (EasBotAgent 实例) │
|
|
440
491
|
└─────────────────────────────────────────────────────────┘
|
|
@@ -442,15 +493,15 @@ $ easbot acp start --channel http --port 3000
|
|
|
442
493
|
|
|
443
494
|
## 与 note / gateway / memory 的差异
|
|
444
495
|
|
|
445
|
-
| 维度 | note | gateway
|
|
446
|
-
| ----------------- | ----------------- |
|
|
447
|
-
| L2 配置文件名 | `note.json` | `gateway.json`
|
|
448
|
-
| L2 cache 命名 | `NoteCache` | (无 L2 缓存)
|
|
449
|
-
| 错误 namespace | `NoteError` | `GatewayError`
|
|
450
|
-
| 业务 codes 白名单 | 13 个 | (未注册 ServiceErrorBus)
|
|
451
|
-
| 命令数 | 11 | 0(不走独立 CLI)
|
|
452
|
-
| 顶层依赖 | LLM / DB / parser | hono / undici / ws
|
|
453
|
-
| 配置加载 | 单文件 NoteCache |
|
|
496
|
+
| 维度 | note | gateway | acp |
|
|
497
|
+
| ----------------- | ----------------- | -------------------------------------------- | -------------------------------------------- |
|
|
498
|
+
| L2 配置文件名 | `note.json` | `gateway.json` | `acp.json` |
|
|
499
|
+
| L2 cache 命名 | `NoteCache` | (无 L2 缓存) | `AcpCache` |
|
|
500
|
+
| 错误 namespace | `NoteError` | `GatewayError` | `AcpError` |
|
|
501
|
+
| 业务 codes 白名单 | 13 个 | (未注册 ServiceErrorBus) | 5 个 |
|
|
502
|
+
| 命令数 | 11 | 0(不走独立 CLI) | 5 |
|
|
503
|
+
| 顶层依赖 | LLM / DB / parser | hono / undici / ws | @agentclientprotocol/sdk |
|
|
504
|
+
| 配置加载 | 单文件 NoteCache | 四层合并(全局 + easbot.json 字段 + 项目级) | 四层合并(全局 + easbot.json 字段 + 项目级) |
|
|
454
505
|
|
|
455
506
|
## 开发命令
|
|
456
507
|
|
|
@@ -526,7 +577,7 @@ packages/acp/
|
|
|
526
577
|
| `tests/cli-e2e.test.ts` | 29 (1 skip) | 真 subprocess 端到端 5 cmd |
|
|
527
578
|
| `src/__tests__/cli-handler.test.ts` | 26 | 5 cmd dispatch + COMMANDS_HELP + 错误路径(mock start 阻塞) |
|
|
528
579
|
| `src/config/__tests__/types.test.ts` | 30 | Zod schema 校验(Stdio / Http / WS / server / client / clients) |
|
|
529
|
-
| `src/config/__tests__/loader.test.ts` | 24 |
|
|
580
|
+
| `src/config/__tests__/loader.test.ts` | 24 | 四层合并 + JSONC + env 替换 + 便捷访问 |
|
|
530
581
|
| `src/i18n/__tests__/translator.test.ts` | 23 | t() 翻译 + vars 插值 + locale 优先级 4 级 + formatLog |
|
|
531
582
|
| `src/__tests__/interfaces.test.ts` | 21 | IGlobal / IInstance / SDK 注入 + 便捷访问器 |
|
|
532
583
|
| `src/cache/__tests__/cache.test.ts` | 17 | AcpCache namespace 全 API |
|
|
@@ -544,7 +595,7 @@ packages/acp/
|
|
|
544
595
|
| ---------------------------------------- | -------- | ------------------------------------ |
|
|
545
596
|
| `src/cache/index.ts` | **93%** | AcpCache namespace |
|
|
546
597
|
| `src/config/types.ts` | **96%** | Zod schema 校验 |
|
|
547
|
-
| `src/config/loader.ts` | **92%** |
|
|
598
|
+
| `src/config/loader.ts` | **92%** | 四层合并加载 + 便捷访问 |
|
|
548
599
|
| `src/config/jsonc.ts` | **87%** | JSONC 注释剥离 + env 替换 |
|
|
549
600
|
| `src/interfaces.ts` | **95%** | host ↔ 包解耦三件套 |
|
|
550
601
|
| `src/i18n/translator.ts` | **84%** | t() 翻译 + locale 优先级 |
|
|
@@ -593,7 +644,7 @@ packages/acp/
|
|
|
593
644
|
## 设计原则
|
|
594
645
|
|
|
595
646
|
1. **host ↔ 包解耦**:所有运行时依赖通过 `setGlobalAdapter / setInstanceAdapter` 显式注入;agent 包 / 独立 CLI / 测试 统一语义
|
|
596
|
-
2.
|
|
647
|
+
2. **四层配置加载**:参考 `packages/gateway/src/config/loader.ts`,JSONC + env 替换 + State.holder 三件套
|
|
597
648
|
3. **错误分层**:包内 `AcpError`(业务语义)+ `NameErrors`(通用)+ `ServiceError + ServiceErrorBus`(LLM 业务反馈)
|
|
598
649
|
4. **CLI 与 handler 分离**:`handleAcpCli(args, deps)` 入口独立可测;agent / 独立 CLI / MCP server 复用同一份派发逻辑
|
|
599
650
|
5. **不持有业务实例**:acp 包不依赖 `@easbot/agent` 内部模块;只通过 `EasbotAdapter` 暴露 server 启动能力(由 agent bootstrap 注入 AdapterRegistry)
|
|
@@ -610,7 +661,7 @@ packages/acp/
|
|
|
610
661
|
|
|
611
662
|
- [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk) —— ACP 协议官方 TypeScript SDK
|
|
612
663
|
- `packages/note/src/cli-handler.ts` —— CLI handler 范本
|
|
613
|
-
- `packages/gateway/src/config/loader.ts` ——
|
|
664
|
+
- `packages/gateway/src/config/loader.ts` —— 四层配置加载范本
|
|
614
665
|
- `packages/note/src/cache/index.ts` —— AcpCache 模式 E 同源参考
|
|
615
666
|
- `packages/note/src/errors.ts` —— AcpError 模式同源参考
|
|
616
667
|
- `ADR 0066` —— host ↔ 包解耦接口规范
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkITV7SWGU_cjs=require('./chunk-ITV7SWGU.cjs');require('./chunk-SNWAB3QJ.cjs'),require('./chunk-DX35VSAT.cjs'),require('./chunk-BNSJ6COS.cjs'),require('./chunk-VVGGER23.cjs'),require('./chunk-Z3YEK7DD.cjs'),require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"AdapterBootstrap",{enumerable:true,get:function(){return chunkITV7SWGU_cjs.t}});Object.defineProperty(exports,"EasbotAdapter",{enumerable:true,get:function(){return chunkITV7SWGU_cjs.s}});Object.defineProperty(exports,"createAdapterEnvironmentInitializationError",{enumerable:true,get:function(){return chunkITV7SWGU_cjs.r}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as AdapterBootstrap,s as EasbotAdapter,r as createAdapterEnvironmentInitializationError}from'./chunk-D7S7ARXV.mjs';import'./chunk-B3ANZALB.mjs';import'./chunk-33M2R2US.mjs';import'./chunk-PATHHDWE.mjs';import'./chunk-2KOCPHVP.mjs';import'./chunk-NHXAYBZH.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkVVGGER23_cjs=require('./chunk-VVGGER23.cjs');require('./chunk-Z3YEK7DD.cjs'),require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"ACP_JSON_REL_PATH",{enumerable:true,get:function(){return chunkVVGGER23_cjs.q}});Object.defineProperty(exports,"AcpCache",{enumerable:true,get:function(){return chunkVVGGER23_cjs.r}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{q as ACP_JSON_REL_PATH,r as AcpCache}from'./chunk-2KOCPHVP.mjs';import'./chunk-NHXAYBZH.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-NHXAYBZH.mjs';import {existsSync,mkdirSync,writeFileSync}from'fs';import {Log,State,Filesystem,ConfigFileParse,errorMeta,NameErrors}from'@easbot/utils';import {ChannelType}from'@easbot/types';export{ACPStdioConnectionConfigSchema as g,ACPHttpConnectionConfigSchema as h,ACPWebSocketConnectionConfigSchema as i,ACPConnectionConfigSchema as j,ACPModelConfigSchema as k,ACPAgentRuntimeConfigSchema as l,ACPInfoACPServerConfigSchema as m,ACPInfoACPClientsConfigSchema as n,ACP_DEFAULT_SERVER_CONFIG as o,ACP_DEFAULT_CLIENT_CONFIG as p}from'@easbot/types';import {z}from'zod';var S=e=>e==="local"?ChannelType.STDIO:e,w=z.object({directory:z.string().default(process.cwd()),enabled:z.boolean().default(true),channel:z.preprocess(S,z.enum(["stdio","http","websocket"])).default("websocket"),port:z.number().int().min(1).max(65535).default(3e3),hostname:z.hostname().default("localhost"),timeout:z.number().positive().default(3e4),name:z.string().optional(),agentId:z.string().optional(),stdio:z.object({command:z.string(),args:z.array(z.string())}).optional(),http:z.object({baseUrl:z.string().url(),timeout:z.number().positive().default(6e4)}).optional(),ws:z.object({url:z.string().url(),timeout:z.number().positive().default(3e4),batchSize:z.number().positive().default(10),batchInterval:z.number().positive().default(50),heartbeatInterval:z.number().positive().default(3e4)}).optional(),agent:z.object({agent:z.string().optional(),model:z.object({id:z.string().min(1),options:z.record(z.string(),z.unknown()).optional()}).optional()}).optional()}).transform(e=>({...e,channel:e.channel})),y=z.object({id:z.string().min(1),type:z.enum(["easbot","custom"]),name:z.string().optional(),agentId:z.string().optional(),channel:z.preprocess(S,z.enum(["stdio","http","websocket"])).optional(),connection:z.object({stdio:z.object({command:z.string(),args:z.array(z.string())}).optional(),http:z.object({baseUrl:z.string().url(),timeout:z.number().positive().default(6e4)}).optional(),ws:z.object({url:z.string().url(),timeout:z.number().positive().default(3e4),batchSize:z.number().positive().default(10),batchInterval:z.number().positive().default(50),heartbeatInterval:z.number().positive().default(3e4)}).optional()}),autoConnect:z.boolean().default(false),priority:z.number().int().nonnegative().default(0)}).transform(e=>{let t=e.channel;return t||(e.connection.ws?t="websocket":e.connection.http?t="http":e.connection.stdio?t="stdio":t="websocket"),{...e,channel:t}}),x=z.object({clients:z.array(y).min(1),defaultClientId:z.string().optional()}),r=z.object({server:w.optional(),clients:x.optional(),client:z.object({autoRegister:z.boolean().default(true),gatewayUrl:z.url().optional()}).optional()});function J(e){let t=r.safeParse(e);if(t.success)return t.data;let s=r.safeParse({});return s.success?s.data:{}}function F(e){return r.parse(e)}var a=Log.create({service:"acp.cache"}),O=[".easbot","acp.json"],k=new Set;function R(){try{let t=f().directory;if(t&&t.length>0)return t}catch{}return process.cwd()}function l(e){return Filesystem.join(e,...O)}async function U(e){let t=l(e);if(k.add(Filesystem.normalize(t)),!existsSync(t))return {acpJson:{},exists:false,rootDir:e};try{return {acpJson:await ConfigFileParse.loadFile(t),exists:!0,rootDir:e}}catch(c){return a.warn("acp.json parse failed",{configPath:t,error:errorMeta(c)}),{acpJson:void 0,exists:true,rootDir:e}}}var v=State.holder(()=>{try{let t=f().directory;return t?Filesystem.normalize(t):"__acp_cache_global__"}catch{return "__acp_cache_global__"}},async()=>U(R())),I;(q=>{let e=false;async function t(){return v.get()}q.state=t;function s(o){v.clear(),e=false,ConfigFileParse.invalidate(o??l(R()),"acp.resetState");}q.resetState=s;function c(){d||(d=ConfigFileParse.onChange(o=>{k.has(o)&&(a.info("acp.json changed externally, reloading",{configPath:o}),ConfigFileParse.invalidateNormalized(o,"acp.externalChange"),s(o));}));}let d;async function V(){e||(e=true,c(),a.info("AcpCache init"),await t());}q.init=V;async function H(){return (await t()).acpJson}q.getAcpJson=H;async function M(){return (await t()).exists}q.exists=M;async function G(){return (await t()).rootDir}q.getRootDir=G;async function W(o){let A=await t(),i=l(A.rootDir),g={...A.acpJson??{},...o},f=r.safeParse(g);if(!f.success)throw a.error("acp.json validation failed on write",{configPath:i,issues:f.error.issues}),new NameErrors.ValidationError({message:`acp.json validation failed: ${f.error.message}`,location:i,issues:f.error.issues});let h=Filesystem.dirname(i);existsSync(h)||mkdirSync(h,{recursive:true});try{writeFileSync(i,JSON.stringify(g,null,2),"utf-8");}catch(b){throw a.error("acp.json write failed",{configPath:i,error:errorMeta(b)}),b}return s(i),a.debug("acp.json written",{configPath:i}),g}q.writeAcpJson=W;async function $(){let o=await t();return l(o.rootDir)}q.getConfigPath=$;})(I||(I={}));export{w as a,y as b,x as c,r as d,J as e,F as f,O as q,I as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{ChannelType as b}from'@easbot/types';import {z}from'zod';var o=(t=>(t.INITIALIZING="initializing",t.READY="ready",t.RUNNING="running",t.STOPPED="stopped",t.ERROR="error",t))(o||{});var d=z.object({agentId:z.string(),agentType:z.string(),directory:z.string(),timestamp:z.number()}),l=z.object({agentId:z.string(),reason:z.enum(["normal","error","timeout"]),timestamp:z.number()}),y=z.object({sessionId:z.string(),messageType:z.enum(["text","tool_call","tool_result"]),content:z.any(),timestamp:z.number()}),b=z.object({agentId:z.string(),error:z.string(),context:z.record(z.string(),z.any()).optional(),timestamp:z.number()}),u=z.object({agentId:z.string(),status:z.enum(["idle","busy","error"]),timestamp:z.number()}),v={STARTED:"agent.started",STOPPED:"agent.stopped",MESSAGE:"agent.message",ERROR:"agent.error",STATUS:"agent.status"};export{o as a,d as c,l as d,y as e,b as f,u as g,v as h};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {t,r}from'./chunk-B3ANZALB.mjs';import {b}from'./chunk-33M2R2US.mjs';import {Log,errorMeta}from'@easbot/utils';import {emitJsonOk,printHuman,emitJsonError,formatSuccess,formatKeyValue,formatError,Symbol,colorize,isRich,theme}from'@easbot/terminal';var H={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var de=H.languages,pe=de.filter(e=>e.supported).map(e=>e.value),S={defaultLocale:"zh-CN",timeZone:"Asia/Shanghai",locales:pe},L={},N=(e,r)=>{let t=L[e]||{translation:{}};return L[e]={translation:{...t.translation,...r.translation}},L[e]},T=(e=S.defaultLocale)=>(L[e]||N(e,{translation:{}}),{locale:e,resources:L[e]||{translation:{}}}),Je=e=>T(e),Ue=e=>L[e];var fe={translation:{"cli.banner.title":"easbot-acp \u2014 EASBot ACP\uFF08Agent Communication Protocol\uFF09\u9002\u914D\u5C42","cli.banner.usage":"\u7528\u6CD5: easbot-acp <command> [options]","cli.banner.section.lifecycle":"\u547D\u4EE4\uFF08\u751F\u547D\u5468\u671F\uFF09:","cli.banner.section.server":"\u547D\u4EE4\uFF08\u670D\u52A1\uFF09:","cli.banner.section.external":"\u5916\u90E8\u63A5\u53E3:","cli.banner.hint.run_help":"\u8FD0\u884C `easbot-acp <command> --help` \u67E5\u770B\u8BE6\u60C5\u3002","cli.banner.global_flags":"\u5168\u5C40\u9009\u9879: --cwd <dir> --config <path> --log-level <L> --print-logs --debug","cli.banner.local.title":"\u72EC\u7ACB CLI:","cli.banner.local.agent":"Agent CLI \u7528\u6237: `easbot acp <command> ...`","cli.banner.local.standalone":"\u72EC\u7ACB\u7528\u6237: `easbot-acp <command> ...`","cli.cmd.init.description":"\u521D\u59CB\u5316 acp \u5DE5\u4F5C\u533A\uFF08\u521B\u5EFA .easbot/acp.json\uFF09","cli.cmd.status.description":"\u663E\u793A acp \u914D\u7F6E\u6458\u8981\uFF08\u670D\u52A1\u901A\u9053 / \u7AEF\u53E3 / \u5BA2\u6237\u7AEF\uFF09","cli.cmd.doctor.description":"\u8FD0\u884C\u5065\u5EB7\u68C0\u67E5\uFF08\u914D\u7F6E\u53EF\u52A0\u8F7D / schema \u5408\u6CD5 / \u4F9D\u8D56\u5B8C\u6574\uFF09","cli.cmd.start.description":"\u542F\u52A8 ACP \u670D\u52A1\uFF08stdio / http / websocket\uFF09\u5E76\u963B\u585E","cli.cmd.config.description":"\u663E\u793A / \u66F4\u65B0 acp \u914D\u7F6E\uFF08get / set key=value\uFF09","cli.shared.show_help":"\u663E\u793A\u6B64\u5E2E\u52A9","cli.init.usage":"\u7528\u6CD5: easbot-acp init [--channel <stdio|http|websocket>] [--port <n>] [--hostname <addr>] [--force] [--json]","cli.init.opt.channel":"--channel \u9ED8\u8BA4\u901A\u9053\uFF08\u9ED8\u8BA4 websocket\uFF09","cli.init.opt.port":"--port HTTP/WebSocket \u7AEF\u53E3\uFF08\u9ED8\u8BA4 3000\uFF09","cli.init.opt.hostname":"--hostname \u4E3B\u673A\u540D\uFF08\u9ED8\u8BA4 localhost\uFF09","cli.init.opt.force":"--force, -f \u8986\u76D6\u5DF2\u5B58\u5728\u7684\u914D\u7F6E","cli.init.opt.json":"--json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA\uFF08\u65E0 ANSI\uFF09","cli.init.exists":"acp \u914D\u7F6E\u5DF2\u5B58\u5728\u4E8E {{path}}\uFF08\u4F7F\u7528 --force \u8986\u76D6\uFF09","cli.init.created":"\u2713 acp \u914D\u7F6E\u5DF2\u521D\u59CB\u5316\u5230 {{path}}","cli.init.title":"\u521D\u59CB\u5316 acp \u5DE5\u4F5C\u533A","cli.init.error.title":"\u521D\u59CB\u5316\u5931\u8D25","cli.init.error.field":"\u8DEF\u5F84","cli.init.error.hint":"\u4F7F\u7528 --force \u8986\u76D6\uFF0C\u6216\u76F4\u63A5\u7F16\u8F91\u5DF2\u6709\u6587\u4EF6\u3002","cli.start.usage":"\u7528\u6CD5: easbot-acp start [--channel <stdio|http|websocket>] [--port <n>] [--hostname <addr>] [--timeout <ms>]","cli.start.description":"\u542F\u52A8 ACP \u670D\u52A1\uFF0C\u963B\u585E\u76F4\u5230 Ctrl+C / SIGTERM\u3002","cli.start.channel_default":"\u901A\u9053\u9ED8\u8BA4\u503C\u4E3A acp.json \u4E2D\u7684 server.channel\uFF08\u9ED8\u8BA4: websocket\uFF09\u3002","cli.start.opt.channel":"--channel \u901A\u9053\u7C7B\u578B\uFF08\u8986\u76D6\u914D\u7F6E\u6587\u4EF6\uFF09","cli.start.opt.port":"--port \u7AEF\u53E3\uFF08\u9ED8\u8BA4 3000\uFF09","cli.start.opt.hostname":"--hostname \u4E3B\u673A\u540D\uFF08\u9ED8\u8BA4 localhost\uFF09","cli.start.opt.timeout":"--timeout <ms> \u8BF7\u6C42\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09","cli.status.usage":"\u7528\u6CD5: easbot-acp status [--json]","cli.status.field.directory":"\u5DE5\u4F5C\u76EE\u5F55","cli.status.field.server":"\u670D\u52A1","cli.status.field.server_channel":"\u670D\u52A1\u901A\u9053","cli.status.field.server_port":"\u670D\u52A1\u7AEF\u53E3","cli.status.field.server_hostname":"\u670D\u52A1\u4E3B\u673A\u540D","cli.status.field.server_enabled":"\u670D\u52A1\u542F\u7528","cli.status.field.clients":"\u5BA2\u6237\u7AEF\u6570\u91CF","cli.doctor.usage":"\u7528\u6CD5: easbot-acp doctor [--json]","cli.doctor.field.acp_json_path":"acp.json \u8DEF\u5F84","cli.doctor.field.acp_json_exists":"acp.json \u5B58\u5728","cli.doctor.field.config_loadable":"\u914D\u7F6E\u53EF\u52A0\u8F7D","cli.doctor.field.config_error":"\u914D\u7F6E\u9519\u8BEF","cli.doctor.field.sdk_version":"SDK \u7248\u672C","cli.doctor.yes":"\u662F","cli.doctor.no":"\u5426","cli.config.usage":"\u7528\u6CD5: easbot-acp config <get|set> [key] [value] [--json]","cli.config.description":"\u8BFB\u53D6\u6216\u5199\u5165 acp \u914D\u7F6E\u3002","cli.config.subcommands":"\u5B50\u547D\u4EE4:","cli.config.get_help":"get [key] \u663E\u793A\u5168\u90E8\u5B57\u6BB5\uFF08\u6216\u6307\u5B9A key\uFF09","cli.config.set_help":"set <key> <value> \u66F4\u65B0\u5B57\u6BB5\uFF08\u81EA\u52A8\u8BC6\u522B number / boolean\uFF09","cli.config.examples":"\u793A\u4F8B:","cli.config.example_get":" easbot-acp config get server.channel","cli.config.example_set":" easbot-acp config set server.port 8080","cli.config.opt.json":"--json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA","cli.config.no_subcommand":"config \u9700\u8981\u5B50\u547D\u4EE4: get | set","cli.config.invalid_key":"\u65E0\u6548\u7684 key: {{key}}","cli.config.set_done":"\u2713 \u5DF2\u8BBE\u7F6E {{key}} = {{value}}","cli.config.get_done":"{{key}}: {{value}}","cli.config.field.key":"key","cli.config.field.value":"\u503C","cli.config.error.invalid_key.title":"\u65E0\u6548\u7684 key","cli.config.error.field.key":"key","cli.config.error.invalid_key.hint":'\u4F7F\u7528\u70B9\u53F7\u8DEF\u5F84\uFF0C\u4F8B\u5982 "server.channel"\u3002',"cli.config.error.no_subcommand.title":"\u7F3A\u5C11\u5B50\u547D\u4EE4","cli.config.error.no_subcommand.hint":'\u4F7F\u7528 "easbot-acp config get [key]" \u6216 "easbot-acp config set <key> <value>"\u3002',"acp.cli.command_failed":"acp CLI \u547D\u4EE4\u5931\u8D25","acp.cli.command_failed_title":"\u547D\u4EE4\u6267\u884C\u5931\u8D25","acp.cli.error_prefix":"[acp] {{cwd}} :: {{command}} \u5931\u8D25: {{message}}","acp.cli.error.field.command":"\u547D\u4EE4","acp.cli.error_hint":"\u4F7F\u7528 --debug \u91CD\u8DD1\u4EE5\u67E5\u770B\u5B8C\u6574\u5806\u6808\u3002","acp.cli.json_error_failed":"JSON \u8F93\u51FA\u5931\u8D25: {{message}}","acp.error.unknown_command":"\u672A\u77E5\u547D\u4EE4: {{command}}","acp.error.unknown_command.title":"\u672A\u77E5\u547D\u4EE4","acp.error.unknown_command.field":"\u547D\u4EE4","acp.error.field_label":"\u5B57\u6BB5","acp.error.message_label":"\u6D88\u606F","acp.error.hint_label":"\u63D0\u793A","acp.start.bootstrapping":"\u6B63\u5728\u542F\u52A8 ACP \u670D\u52A1","acp.start.started":"ACP \u670D\u52A1\u542F\u52A8\u6210\u529F","acp.server.started":"ACP \u670D\u52A1\u5DF2\u542F\u52A8","acp.server.started_head":"ACP \u670D\u52A1\u5DF2\u542F\u52A8","acp.field.directory":"\u5DE5\u4F5C\u76EE\u5F55","acp.field.channel":"\u901A\u9053","acp.field.host":"\u5730\u5740","acp.field.timeout":"\u8D85\u65F6","acp.shutdown.received":"\u6536\u5230\u4FE1\u53F7 {{signal}}\uFF0C\u6B63\u5728\u5173\u95ED","acp.shutdown.error":"\u5173\u95ED\u8FC7\u7A0B\u4E2D\u51FA\u9519","acp.shutdown.destroy_error":"EasbotAdapter.destroy \u5931\u8D25","acp.shutdown.stdout_broken":"stdout pipe \u65AD\u5F00\uFF0C\u8FDB\u7A0B\u9000\u51FA","acp.error.config_not_found":"acp \u914D\u7F6E\u672A\u627E\u5230; \u8BF7\u5148\u8FD0\u884C `easbot-acp init` \u521B\u5EFA .easbot/acp.json","acp.error.config_validation":"acp \u914D\u7F6E schema \u6821\u9A8C\u5931\u8D25: {{path}}","acp.error.server_start_failed":"\u670D\u52A1\u542F\u52A8\u5931\u8D25\uFF08\u901A\u9053={{channel}}, \u7AEF\u53E3={{port}}, code={{code}}\uFF09","acp.error.client_connection_failed":"\u5BA2\u6237\u7AEF\u8FDE\u63A5\u5931\u8D25\uFF08clientId={{clientId}}, \u901A\u9053={{channel}}\uFF09","acp.error.rpc_parse_failed":"JSON-RPC frame \u89E3\u6790\u5931\u8D25\uFF08method={{method}}\uFF09"}},M=fe;var ge={translation:{"cli.banner.title":"easbot-acp \u2014 EASBot ACP (Agent Communication Protocol) Adapter","cli.banner.usage":"Usage: easbot-acp <command> [options]","cli.banner.section.lifecycle":"Commands (lifecycle):","cli.banner.section.server":"Commands (server):","cli.banner.section.external":"External:","cli.banner.hint.run_help":"Run `easbot-acp <command> --help` for details.","cli.banner.global_flags":"Global flags: --cwd <dir> --config <path> --log-level <L> --print-logs --debug","cli.banner.local.title":"Standalone CLI:","cli.banner.local.agent":"Agent CLI users: `easbot acp <command> ...`","cli.banner.local.standalone":"Standalone users: `easbot-acp <command> ...`","cli.cmd.init.description":"Initialize acp workspace (creates .easbot/acp.json)","cli.cmd.status.description":"Show acp config summary (server channel / port / clients)","cli.cmd.doctor.description":"Run health checks (config loadable / schema valid / deps)","cli.cmd.start.description":"Start ACP server (stdio / http / websocket) and block","cli.cmd.config.description":"Show / update acp configuration (get / set key=value)","cli.shared.show_help":"Show this help","cli.init.usage":"Usage: easbot-acp init [--channel <stdio|http|websocket>] [--port <n>] [--hostname <addr>] [--force] [--json]","cli.init.opt.channel":"--channel Default channel (default: websocket)","cli.init.opt.port":"--port HTTP/WebSocket port (default: 3000)","cli.init.opt.hostname":"--hostname Hostname (default: localhost)","cli.init.opt.force":"--force, -f Overwrite existing config","cli.init.opt.json":"--json Output as JSON (no ANSI)","cli.init.exists":"acp config already exists at {{path}} (use --force to overwrite)","cli.init.created":"\u2713 acp config initialized at {{path}}","cli.init.title":"init acp workspace","cli.init.error.title":"init failed","cli.init.error.field":"path","cli.init.error.hint":"Pass --force to overwrite, or edit the existing file.","cli.start.usage":"Usage: easbot-acp start [--channel <stdio|http|websocket>] [--port <n>] [--hostname <addr>] [--timeout <ms>]","cli.start.description":"Start an ACP server. Blocks until Ctrl+C / SIGTERM.","cli.start.channel_default":"Channel defaults to acp.json server.channel (default: websocket).","cli.start.opt.channel":"--channel Channel type (overrides config file)","cli.start.opt.port":"--port Port (default: 3000)","cli.start.opt.hostname":"--hostname Hostname (default: localhost)","cli.start.opt.timeout":"--timeout <ms> Request timeout in milliseconds","cli.status.usage":"Usage: easbot-acp status [--json]","cli.status.field.directory":"directory","cli.status.field.server":"server","cli.status.field.server_channel":"server.channel","cli.status.field.server_port":"server.port","cli.status.field.server_hostname":"server.hostname","cli.status.field.server_enabled":"server.enabled","cli.status.field.clients":"clients","cli.doctor.usage":"Usage: easbot-acp doctor [--json]","cli.doctor.field.acp_json_path":"acp.json path","cli.doctor.field.acp_json_exists":"acp.json exists","cli.doctor.field.config_loadable":"config loadable","cli.doctor.field.config_error":"config error","cli.doctor.field.sdk_version":"SDK version","cli.doctor.yes":"yes","cli.doctor.no":"no","cli.config.usage":"Usage: easbot-acp config <get|set> [key] [value] [--json]","cli.config.description":"Read or write acp configuration.","cli.config.subcommands":"Subcommands:","cli.config.get_help":"get [key] Show all fields (or a specific key)","cli.config.set_help":"set <key> <value> Update a field (auto-detects number / boolean)","cli.config.examples":"Examples:","cli.config.example_get":" easbot-acp config get server.channel","cli.config.example_set":" easbot-acp config set server.port 8080","cli.config.opt.json":"--json Output as JSON","cli.config.no_subcommand":"config requires a subcommand: get | set","cli.config.invalid_key":"Invalid key: {{key}}","cli.config.set_done":"\u2713 set {{key}} = {{value}}","cli.config.get_done":"{{key}}: {{value}}","cli.config.field.key":"key","cli.config.field.value":"value","cli.config.error.invalid_key.title":"invalid key","cli.config.error.field.key":"key","cli.config.error.invalid_key.hint":'Use dotted path like "server.channel".',"cli.config.error.no_subcommand.title":"missing subcommand","cli.config.error.no_subcommand.hint":'Use "easbot-acp config get [key]" or "easbot-acp config set <key> <value>".',"acp.cli.command_failed":"acp CLI command failed","acp.cli.command_failed_title":"command failed","acp.cli.error_prefix":"[acp] {{cwd}} :: {{command}} failed: {{message}}","acp.cli.error.field.command":"command","acp.cli.error_hint":"Re-run with --debug for full stack.","acp.cli.json_error_failed":"JSON output failed: {{message}}","acp.error.unknown_command":"Unknown command: {{command}}","acp.error.unknown_command.title":"unknown command","acp.error.unknown_command.field":"command","acp.error.field_label":"field","acp.error.message_label":"message","acp.error.hint_label":"hint","acp.start.bootstrapping":"Bootstrapping ACP server","acp.start.started":"ACP server started successfully","acp.server.started":"ACP Server Started","acp.server.started_head":"ACP Server Started","acp.field.directory":"directory","acp.field.channel":"channel","acp.field.host":"address","acp.field.timeout":"timeout","acp.shutdown.received":"Received signal {{signal}}, shutting down...","acp.shutdown.error":"Error during shutdown","acp.shutdown.destroy_error":"EasbotAdapter.destroy failed","acp.shutdown.stdout_broken":"stdout pipe broken, exiting","acp.error.config_not_found":"acp config not found; run `easbot-acp init` first to create .easbot/acp.json","acp.error.config_validation":"acp config schema validation failed: {{path}}","acp.error.server_start_failed":"server start failed (channel={{channel}}, port={{port}}, code={{code}})","acp.error.client_connection_failed":"client connection failed (clientId={{clientId}}, channel={{channel}})","acp.error.rpc_parse_failed":"JSON-RPC frame parse failed (method={{method}})"}},F=ge;var ue=()=>{T("zh-CN"),T("en-US"),N("zh-CN",M),N("en-US",F);};ue();var J=new Map;var me=e=>{if(J.has(e))return J.get(e);let r=/{{\s*(\w+)\s*}}/g,t=[],o;for(;(o=r.exec(e))!==null;){let c=o[1];c&&!t.includes(c)&&t.push(c);}let s=new RegExp("{{\\s*("+t.join("|")+")\\s*}}","g"),i={keys:t,regex:s};return J.set(e,i),i},V=(e,r)=>{if(!e||typeof e!="string")return "";if(!r||Object.keys(r).length===0)return e;let{regex:t,keys:o}=me(e);return o.length===0||!o.some(i=>i in r)?e:e.replace(t,(i,c)=>{let p=r[c];return p==null?"":String(p)})},W=e=>{if(e&&S.locales.includes(e))return e;let r=process.env.EASBOT_LANG?.trim()||process.env.LANG?.trim();if(r){let t=r.replace(/_/g,"-");if(S.locales.includes(t))return t;let o=t.split("-")[0];if(o==="zh")return "zh-CN";if(o==="en")return "en-US"}return S.defaultLocale},q=e=>T(e).resources,Z=(e,r={})=>{let t=W(r.locale),s=q(t)?.translation[e];if(s&&typeof s=="string"){let i=V(s,r.vars);return i!=null?String(i):String(e)}if(t!==S.defaultLocale){let c=q(S.defaultLocale)?.translation[e];if(c&&typeof c=="string"){let p=V(c,r.vars);return p!=null?String(p):String(e)}}return String(r.fallback??e)},n=Z,Ve=(e,r={})=>({message:Z(e,r),locale:W(r.locale),context:r.context??{}});function Q(){return {version:1,created_at:new Date().toISOString(),server:{enabled:true,channel:"websocket",port:3e3,hostname:"localhost",timeout:3e4,http:{baseUrl:"http://localhost:3000",timeout:3e5},ws:{url:"ws://localhost:3000",timeout:3e5,batchSize:10,batchInterval:50,heartbeatInterval:3e4}},clients:{clients:[{id:"easbot-self",name:"EasBot Self",type:"easbot",channel:"websocket",connection:{ws:{url:"ws://localhost:3000",timeout:3e5,batchSize:10,batchInterval:50,heartbeatInterval:3e4}},autoConnect:false,priority:0}],defaultClientId:"easbot-self"}}}b.WS;var ye={directory:"directory",server:"server",channel:"channel",port:"port",hostname:"hostname",enabled:"enabled",clients:"clients"},_e={acpJsonPath:"acp.json path",acpJsonExists:"acp.json exists",configLoadable:"config loadable",configError:"config error",sdkVersion:"SDK version"},we={directory:"directory",channel:"channel",host:"address",timeout:"timeout"},Ae={key:"key",value:"value"};function U(e){return e?Symbol.colorize("\u2713","success"):Symbol.colorize("\u2717","error")}function xe(e){return colorize(isRich(),theme.heading,e)}function Y(e){let r=[],t=e.skipped?"config already exists at":"initialized at",o=formatSuccess(`acp ${t} ${e.configPath}`);return r.push(o),e.channel!==void 0&&r.push(formatKeyValue("channel",e.channel)),r.join(`
|
|
2
|
+
`)}function ee(e,r){let t={...ye,...r},o=[];o.push(formatKeyValue(t.directory,e.directory)),o.push(` ${xe(t.server)}`);let s=e.server??{},i=s.channel??"websocket",c=s.port??3e3,p=s.hostname??"localhost",g=s.enabled??true;return o.push(` ${formatKeyValue(t.channel,i)}`),o.push(` ${formatKeyValue(t.port,String(c))}`),o.push(` ${formatKeyValue(t.hostname,p)}`),o.push(` ${formatKeyValue(t.enabled,U(g))}`),o.push(formatKeyValue(t.clients,String(e.clientCount))),o.join(`
|
|
3
|
+
`)}function te(e,r){let t={..._e,...r},o=[];return o.push(formatKeyValue(t.acpJsonPath,e.acpJsonPath)),o.push(formatKeyValue(t.acpJsonExists,U(e.acpJsonExists))),o.push(formatKeyValue(t.configLoadable,U(e.configLoadable))),o.push(formatKeyValue(t.sdkVersion,e.sdkVersion)),!e.configLoadable&&e.configError&&o.push(formatKeyValue(t.configError,e.configError)),o.join(`
|
|
4
|
+
`)}function ne(e,r){let t={...we,...r},o=[];return e.head&&o.push(formatSuccess(e.head)),o.push(formatKeyValue(t.directory,e.directory)),o.push(formatKeyValue(t.channel,e.channel)),o.push(formatKeyValue(t.host,e.host)),o.push(formatKeyValue(t.timeout,e.timeout)),o.join(`
|
|
5
|
+
`)}function oe(e,r){let t={...Ae,...r},o=[],s=e.key??"(root)";return o.push(formatKeyValue(t.key,s)),o.push(formatKeyValue(t.value,e.value)),o.join(`
|
|
6
|
+
`)}function re(e){return formatSuccess(`set ${e.key} = ${e.value}`)}var Se={field:"field",message:"message",hint:"hint"};function ie(e,r){let t={...Se,...r},o=[];return o.push(formatError(e.title)),e.field!==void 0&&o.push(formatKeyValue(t.field,e.value??"")),o.push(formatKeyValue(t.message,e.message)),e.hint&&o.push(formatKeyValue(t.hint,e.hint)),o.join(`
|
|
7
|
+
`)}var Ee=[{i18nKey:"cli.cmd.init.description",name:"init",description:"Initialize acp workspace (.easbot/acp.json)",group:"lifecycle"},{i18nKey:"cli.cmd.status.description",name:"status",description:"Show acp config summary (server channel / port / clients)",group:"lifecycle"},{i18nKey:"cli.cmd.doctor.description",name:"doctor",description:"Run health checks (config loadable, schema valid, deps)",group:"lifecycle"},{i18nKey:"cli.cmd.start.description",name:"start",description:"Start ACP server (stdio / http / websocket) and block",group:"server"},{i18nKey:"cli.cmd.config.description",name:"config",description:"Show / update acp configuration (get / set key=value)",group:"external"}];function j(e){return `\x1B[2m${e}\x1B[0m`}function se(e){return `\x1B[1m${e}\x1B[0m`}function Re(e){return `\x1B[36m${e}\x1B[0m`}function Te(){return j("$")}function $(e,r){let t=Ee.filter(s=>s.group===e),o=n(r);return `${se(o)}
|
|
8
|
+
`+t.map(s=>` ${Te()} easbot-acp ${s.name.padEnd(14)} ${j(n(s.i18nKey,{fallback:s.description}))}`).join(`
|
|
9
|
+
`)}function Ie(){let e=[`${se(Re("easbot-acp"))} \xB7 ${n("cli.banner.title",{fallback:"EASBot ACP (Agent Communication Protocol) Adapter"})}`,n("cli.banner.usage",{fallback:"Usage: easbot-acp <command> [options]"}),"",$("lifecycle","cli.banner.section.lifecycle"),"",$("server","cli.banner.section.server"),"",$("external","cli.banner.section.external")];console.log(e.join(`
|
|
10
|
+
`));}function Pe(){Ie(),console.log(""),console.log(j(n("cli.banner.global_flags",{fallback:"Global flags: --cwd <dir> --config <path> --log-level <L> --print-logs --debug"}))),console.log(j(`${n("cli.banner.local.standalone",{fallback:"Standalone users"})}: easbot-acp <command>`)),console.log(j(`${n("cli.banner.local.agent",{fallback:"Agent CLI users"})}: easbot acp <command>`));}var y=Log.create({service:"acp.cli"}),ce=false;async function je(){if(!ce){ce=true;try{await r();}catch(e){y.warn("registerBusinessErrors failed",{error:errorMeta(e)});}}}function P(e,r,t,o){let s=o?.exitCode??1;if(r)emitJsonError(e,t.message);else {let i=o?.labels??{field:n("acp.error.field_label",{fallback:"field"}),message:n("acp.error.message_label",{fallback:"message"}),hint:n("acp.error.hint_label",{fallback:"hint"})};printHuman([ie(t,i)],{title:"error",boxed:true,tone:"error",stream:"stderr"});}return {code:s,handled:s===1,command:s===1?e:null}}async function ut(e,r){let[t$1,...o]=e;if(!t$1)return Pe(),{code:0,handled:true,command:null};await je();let s=o.includes("--json");try{switch(t$1){case "init":{if(o.includes("--help")||o.includes("-h"))return console.log(n("cli.init.usage")),console.log(""),console.log(n("cli.init.opt.channel")),console.log(n("cli.init.opt.port")),console.log(n("cli.init.opt.hostname")),console.log(n("cli.init.opt.force")),console.log(n("cli.init.opt.json")),{code:0,handled:!0,command:t$1};let{AcpCache:i}=await import('./cache-76CBF3LU.mjs'),c=await i.getConfigPath(),p=await i.exists(),g=o.includes("--force");if(p&&!g){let d=n("cli.init.exists",{vars:{path:c}});return y.warn(d),P(t$1,s,{title:n("cli.init.error.title",{fallback:"init failed"}),field:n("cli.init.error.field",{fallback:"path"}),value:c,message:d,hint:n("cli.init.error.hint",{fallback:"Pass --force to overwrite, or edit the existing file."})})}let a=Q();for(let d=0;d<o.length;d++){let m=o[d],u=o[d+1];m==="--channel"&&u?(a.server={...a.server??{},channel:u},d++):m==="--port"&&u?(a.server={...a.server??{},port:Number(u)},d++):m==="--hostname"&&u&&(a.server={...a.server??{},hostname:u},d++);}await i.writeAcpJson(a);let h={configPath:c},l=a.server?.channel;return s?emitJsonOk(h,{command:t$1}):printHuman([Y({configPath:c,channel:l})],{title:n("cli.init.title",{fallback:"init acp workspace"}),boxed:!0}),{code:0,handled:!0,command:t$1}}case "start":{if(o.includes("--help")||o.includes("-h"))return console.log(n("cli.start.usage")),console.log(""),console.log(n("cli.start.description")),console.log(n("cli.start.channel_default")),console.log(""),console.log(n("cli.start.opt.channel")),console.log(n("cli.start.opt.port")),console.log(n("cli.start.opt.hostname")),console.log(n("cli.start.opt.timeout")),{code:0,handled:!0,command:t$1};let i={};for(let b=0;b<o.length;b++){let w=o[b],v=o[b+1];w==="--channel"&&v?(i.channel=v,b++):w==="--port"&&v?(i.port=Number(v),b++):w==="--hostname"&&v?(i.hostname=v,b++):w==="--timeout"&&v&&(i.timeout=Number(v),b++);}let{loadConfig:c}=await import('./config-FTGKCGYZ.mjs'),a={...(await c()).server??{}};i.channel!==void 0&&(a.channel=i.channel),i.port!==void 0&&(a.port=i.port),i.hostname!==void 0&&(a.hostname=i.hostname),i.timeout!==void 0&&(a.timeout=i.timeout);let h=a.channel??"websocket",l=h==="stdio"||h==="http"||h==="websocket"?h:"websocket",d=typeof a.port=="number"?a.port:3e3,m=typeof a.hostname=="string"?a.hostname:"localhost",u=typeof a.timeout=="number"?a.timeout:3e4;y.info("Bootstrapping ACP server",{channel:l,port:d,hostname:m,timeout:u});let{EasbotAdapter:k}=await import('./bootstrap-MZQICOGZ.mjs'),{ChannelType:_}=await import('./types-BZWPIPG6.mjs');await k.init({directory:r?.cwd??process.cwd(),printLogs:!1,logLevel:"INFO",channel:l==="stdio"?_.STDIO:l==="http"?_.HTTP:_.WS});let E=await k.ensureACPService({directory:r?.cwd??process.cwd(),enabled:!0,channel:l,port:d,hostname:m,timeout:u}),B=t({channel:l,hostname:m,port:d})??`unknown://${m}:${d}`;y.info("ACP server started successfully",{type:E.server?.type,url:B});let ae={directory:n("acp.field.directory"),channel:n("acp.field.channel"),host:n("acp.field.host"),timeout:n("acp.field.timeout")};printHuman([ne({directory:r?.cwd??process.cwd(),channel:l,host:B,timeout:`${u}ms`,head:n("acp.server.started_head",{fallback:"ACP Server Started"})},ae)],{title:n("acp.server.started"),boxed:!0}),await new Promise(b=>{let w=!1,v=R=>{w||(w=!0,y.info(`Received ${R}, shutting down ACP server`,{signal:R}),b());};process.once("SIGINT",()=>v("SIGINT")),process.once("SIGTERM",()=>v("SIGTERM")),process.stdout.on("error",R=>{(R.code==="EPIPE"||R.code==="EIO")&&(y.info("stdout pipe broken, exiting ACP server"),v("STDOUT-BROKEN"));});});try{await k.destroy();}catch(b){y.warn("EasbotAdapter.destroy failed",{error:errorMeta(b)});}return {code:0,handled:!0,command:t$1}}case "status":{if(o.includes("--help")||o.includes("-h"))return console.log(n("cli.status.usage")),{code:0,handled:!0,command:t$1};let{loadConfig:i,getConfigDirectory:c}=await import('./config-FTGKCGYZ.mjs'),p=await i(),g={directory:c(),server:p.server,clientCount:p.clients?.clients?.length??0};if(s)emitJsonOk(g,{command:t$1});else {let a={directory:n("cli.status.field.directory"),server:n("cli.status.field.server"),channel:n("cli.status.field.server_channel"),port:n("cli.status.field.server_port"),hostname:n("cli.status.field.server_hostname"),enabled:n("cli.status.field.server_enabled"),clients:n("cli.status.field.clients")};printHuman([ee({directory:g.directory,server:g.server,clientCount:g.clientCount},a)],{title:"acp status",boxed:!0});}return {code:0,handled:!0,command:t$1}}case "doctor":{if(o.includes("--help")||o.includes("-h"))return console.log(n("cli.doctor.usage")),{code:0,handled:!0,command:t$1};let{AcpCache:i}=await import('./cache-76CBF3LU.mjs'),{loadConfig:c}=await import('./config-FTGKCGYZ.mjs'),p=await i.getConfigPath(),g=await i.exists(),a=!1,h;try{await c(),a=!0;}catch(d){h=errorMeta(d).message;}let l={acpJson:{path:p,exists:g},configLoadable:a,configError:h,sdkVersion:"@agentclientprotocol/sdk (workspace dep)"};if(s)emitJsonOk(l,{command:t$1});else {let d={acpJsonPath:n("cli.doctor.field.acp_json_path"),acpJsonExists:n("cli.doctor.field.acp_json_exists"),configLoadable:n("cli.doctor.field.config_loadable"),configError:n("cli.doctor.field.config_error"),sdkVersion:n("cli.doctor.field.sdk_version")};printHuman([te({acpJsonPath:p,acpJsonExists:g,configLoadable:a,configError:h,sdkVersion:"@agentclientprotocol/sdk (workspace dep)"},d)],{title:"acp doctor",boxed:!0});}return {code:0,handled:!0,command:t$1}}case "config":{if(o.includes("--help")||o.includes("-h"))return console.log(n("cli.config.usage")),console.log(""),console.log(n("cli.config.description")),console.log(n("cli.config.subcommands")),console.log(` ${n("cli.config.get_help")}`),console.log(` ${n("cli.config.set_help")}`),console.log(""),console.log(n("cli.config.examples")),console.log(n("cli.config.example_get")),console.log(n("cli.config.example_set")),{code:0,handled:!0,command:t$1};let i=o[0],c=o[1],p=o[2],{AcpCache:g}=await import('./cache-76CBF3LU.mjs'),{clearConfigCache:a}=await import('./config-FTGKCGYZ.mjs');if(i==="set"&&c!==void 0&&p!==void 0){let h=await g.getAcpJson()??{},l=c.split(".").filter(k=>k.length>0);if(l.length===0)return P(t$1,s,{title:n("cli.config.error.invalid_key.title",{fallback:"invalid key"}),field:n("cli.config.error.field.key",{fallback:"key"}),value:c,message:n("cli.config.invalid_key",{vars:{key:c}}),hint:n("cli.config.error.invalid_key.hint",{fallback:'Use dotted path like "server.channel".'})});let d=h;for(let k=0;k<l.length-1;k++){let _=l[k],E=d[_];(typeof E!="object"||E===null||Array.isArray(E))&&(d[_]={}),d=d[_];}let m=l[l.length-1],u=p;return p==="true"?u=!0:p==="false"?u=!1:/^-?\d+(\.\d+)?$/.test(p)&&(u=Number(p)),d[m]=u,await g.writeAcpJson(h),a(),s?emitJsonOk({key:c,value:u},{command:t$1}):printHuman([re({key:c,value:JSON.stringify(u)})],{title:"acp config set",boxed:!0}),{code:0,handled:!0,command:t$1}}if(i==="get"){let l=await g.getAcpJson()??{};if(c){let d=c.split(".");for(let m of d)if(l&&typeof l=="object"&&m in l)l=l[m];else {l=void 0;break}}if(s)emitJsonOk({key:c,value:l},{command:t$1});else {let d={key:n("cli.config.field.key"),value:n("cli.config.field.value")},m=l==null?String(l):typeof l=="object"?JSON.stringify(l,null,2):String(l);printHuman([oe({key:c,value:m},d)],{title:"acp config get",boxed:!0});}return {code:0,handled:!0,command:t$1}}return console.error(n("cli.config.usage")),P(t$1,s,{title:n("cli.config.error.no_subcommand.title",{fallback:"missing subcommand"}),message:n("cli.config.usage"),hint:n("cli.config.error.no_subcommand.hint",{fallback:'Use "easbot-acp config get [key]" or "easbot-acp config set <key> <value>".'})})}default:{let i=n("acp.error.unknown_command",{vars:{command:t$1}}),c=n("cli.banner.hint.run_help");return y.warn(i),P(t$1??"__unknown__",s,{title:n("acp.error.unknown_command.title",{fallback:"unknown command"}),field:n("acp.error.unknown_command.field",{fallback:"command"}),value:t$1,message:i,hint:c},{exitCode:2})}}}catch(i){let c=errorMeta(i),p=c.message;y.error(`acp command ${t$1} failed`,{command:t$1,error:c});let g=r?.cwd??"",a=n("acp.cli.error_prefix",{vars:{cwd:g,command:t$1,message:p}});return P(t$1??"__unknown__",s,{title:n("acp.cli.command_failed_title",{fallback:"command failed"}),message:a,hint:n("acp.cli.error_hint",{fallback:"Re-run with --debug for full stack."})})}}
|
|
11
|
+
export{de as a,pe as b,S as c,N as d,T as e,Je as f,Ue as g,Z as h,n as i,Ve as j,Ee as k,Ie as l,Pe as m,ut as n};
|