@easbot/acp 0.3.29 → 0.3.36

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.
Files changed (66) hide show
  1. package/README.en.md +187 -30
  2. package/README.md +293 -84
  3. package/dist/chunks/bootstrap-67LTURXQ.cjs +1 -0
  4. package/dist/chunks/bootstrap-DHON75MT.mjs +1 -0
  5. package/dist/chunks/cache-5PSUWHGW.cjs +1 -0
  6. package/dist/chunks/cache-O43SNRV2.mjs +1 -0
  7. package/dist/chunks/chunk-33M2R2US.mjs +1 -0
  8. package/dist/chunks/chunk-663BEBE4.cjs +1 -0
  9. package/dist/chunks/chunk-6VF3MZ6H.cjs +1 -0
  10. package/dist/chunks/chunk-B3ANZALB.mjs +2 -0
  11. package/dist/chunks/chunk-D4TSQ2TT.mjs +0 -0
  12. package/dist/chunks/chunk-DX35VSAT.cjs +1 -0
  13. package/dist/chunks/chunk-FAYVTNTB.mjs +1 -0
  14. package/dist/chunks/chunk-FDMRPUSH.mjs +8 -0
  15. package/dist/chunks/chunk-H57INME2.cjs +2 -0
  16. package/dist/chunks/chunk-IOEQ7YHD.cjs +8 -0
  17. package/dist/chunks/chunk-JEYD2VIG.mjs +2 -0
  18. package/dist/chunks/chunk-JLO7UYKQ.cjs +1 -0
  19. package/dist/chunks/chunk-OQH5ALTQ.cjs +1 -0
  20. package/dist/chunks/chunk-PCEPFPJO.cjs +11 -0
  21. package/dist/chunks/chunk-SNWAB3QJ.cjs +2 -0
  22. package/dist/chunks/chunk-SWK2ITXO.mjs +11 -0
  23. package/dist/chunks/chunk-ZGY6CLVQ.mjs +1 -0
  24. package/dist/chunks/chunk-ZZK2JEUF.mjs +1 -0
  25. package/dist/chunks/cli-handler-IU5ATLSM.cjs +1 -0
  26. package/dist/chunks/cli-handler-VKJJ4B6G.mjs +1 -0
  27. package/dist/chunks/config-FVZNV76C.mjs +1 -0
  28. package/dist/chunks/config-QMFC2VIL.cjs +1 -0
  29. package/dist/chunks/interfaces-CGLEY6OS.cjs +1 -0
  30. package/dist/chunks/interfaces-HUTPEB67.mjs +1 -0
  31. package/dist/chunks/loader-5EYZQR7W.mjs +1 -0
  32. package/dist/chunks/loader-63RVAVIL.cjs +1 -0
  33. package/dist/chunks/types-BZWPIPG6.mjs +1 -0
  34. package/dist/chunks/types-NFMF7IZL.cjs +1 -0
  35. package/dist/cli.cjs +1 -1
  36. package/dist/cli.mjs +1 -1
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.d.cts +1169 -374
  39. package/dist/index.d.ts +1169 -374
  40. package/dist/index.mjs +1 -1
  41. package/package.json +7 -7
  42. package/dist/chunks/bootstrap-5LQOAO3Q.cjs +0 -1
  43. package/dist/chunks/bootstrap-VXDGNMPK.mjs +0 -1
  44. package/dist/chunks/cache-EJ4Y2PSY.cjs +0 -1
  45. package/dist/chunks/cache-SOYLU2DS.mjs +0 -1
  46. package/dist/chunks/chunk-3OTURNTA.cjs +0 -11
  47. package/dist/chunks/chunk-CIOYWMQM.cjs +0 -1
  48. package/dist/chunks/chunk-DS4SO4NN.cjs +0 -2
  49. package/dist/chunks/chunk-ER7EK5Z3.mjs +0 -8
  50. package/dist/chunks/chunk-F44AHCPJ.cjs +0 -8
  51. package/dist/chunks/chunk-HA3RF4AE.cjs +0 -1
  52. package/dist/chunks/chunk-MFINI6BI.mjs +0 -1
  53. package/dist/chunks/chunk-PEMSMRYT.mjs +0 -1
  54. package/dist/chunks/chunk-RTXRNSMY.mjs +0 -1
  55. package/dist/chunks/chunk-SHXWJMFY.mjs +0 -11
  56. package/dist/chunks/chunk-UTBY7IJT.mjs +0 -2
  57. package/dist/chunks/chunk-Z4D2PWDQ.cjs +0 -1
  58. package/dist/chunks/cli-handler-2KK2I4DG.mjs +0 -1
  59. package/dist/chunks/cli-handler-EM2BY47U.cjs +0 -1
  60. package/dist/chunks/config-KX5CSYLV.mjs +0 -1
  61. package/dist/chunks/config-YIR7GKPG.cjs +0 -1
  62. package/dist/chunks/interfaces-6BMD3FTB.cjs +0 -1
  63. package/dist/chunks/interfaces-UB3BFHJN.mjs +0 -1
  64. package/dist/chunks/types-CHN33Z37.mjs +0 -1
  65. package/dist/chunks/types-XGBPFI7X.cjs +0 -1
  66. /package/dist/chunks/{chunk-M2YU5LAI.cjs → chunk-ISDIC2R6.cjs} +0 -0
package/README.en.md CHANGED
@@ -6,7 +6,7 @@ English | [中文](./README.md)
6
6
 
7
7
  ## Version
8
8
 
9
- v0.3.29
9
+ v0.3.36
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,18 +16,18 @@ 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` + `<cwd>/easbot.json` top-level `acp` field (multi-directory mixed loading)
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
- - **Multi-directory config loader**: mirrors `packages/gateway/src/config/loader.ts` — multi-dir merge + JSONC + env substitution
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)
29
29
  - **host ↔ package decoupling**: aligned with note / memory / codebase / skills `setGlobalAdapter / setInstanceAdapter` interfaces
30
- - **Reuses existing business modules**: server / client / connection / event / performance migrated from agent package
30
+ - **Reuses existing business modules**: server / client / connection / event migrated from agent package
31
31
 
32
32
  ## Install
33
33
 
@@ -109,10 +109,33 @@ import {
109
109
  getXdgData,
110
110
  getWorktree,
111
111
  getProjectDirectory,
112
+ // Gateway URL injection (2026-10-29)
113
+ setGatewayUrlAdapter,
114
+ resetGatewayUrlAdapter,
115
+ getGatewayUrlAdapter,
116
+ type GatewayUrlAdapter,
117
+ } from '@easbot/acp';
118
+
119
+ // Gateway auto-registration (2026-10-29, migrated from the agent CLI)
120
+ import {
121
+ getAgentAddress,
122
+ registerToGateway,
123
+ deregisterFromGateway,
124
+ hasRegistrationSession,
112
125
  } from '@easbot/acp';
113
126
 
114
127
  // Business modules (migrated from agent package)
115
128
  import { EasBotAgent, EasbotAdapter, ChannelType, AgentStatus } from '@easbot/acp';
129
+
130
+ // Server runtime config (three-tier priority DEFAULT < env < explicit, ADR 0135)
131
+ import {
132
+ loadACPServerConfig,
133
+ loadACPServerConfigWithEnv,
134
+ applyEnvironmentOverrides,
135
+ loadConfigFromEnv,
136
+ validateEnvironmentConfig,
137
+ getConfigDocumentation,
138
+ } from '@easbot/acp';
116
139
  ```
117
140
 
118
141
  ## Quick start
@@ -152,24 +175,80 @@ await EasbotAdapter.init({
152
175
  await EasbotAdapter.ensureACPService(serverCfg);
153
176
  ```
154
177
 
155
- ### 3. Multi-directory config loading (mirrors gateway)
178
+ ### 3. Config loading (four-layer merge, mirrors gateway)
179
+
180
+ ACP config is layered **from low to high priority** (later layers override earlier ones, deep-merged across `server` / `clients` blocks):
181
+
182
+ | Priority | Path | Notes |
183
+ | -------- | ---------------------------------------------- | ------------------------------------------------ |
184
+ | Lowest | `~/.config/easbot/easbot.json` top-level `acp` | agent-integration wrapper (global) |
185
+ | ↑ | `~/.config/easbot/acp.json` | Global standalone config |
186
+ | ↑ | `<workspaceDir>/easbot.json` top-level `acp` | agent-integration wrapper (project-level) |
187
+ | Highest | `<workspaceDir>/.easbot/acp.json` | Project-level standalone config (via `AcpCache`) |
188
+
189
+ Two override rules:
190
+
191
+ - **Project-level overrides global** (`<workspaceDir>` wins over `~/.config/easbot/`)
192
+ - **`acp.json` overrides `easbot.json`** (standalone config beats the agent-integration wrapper)
156
193
 
157
- ACP config is layered **from low to high priority**:
194
+ Key points:
158
195
 
159
- | Priority | Path | Notes |
160
- | -------- | --------------------------------------------- | --------------------------------------------- |
161
- | Lowest | `~/.config/easbot/acp.json` | Global config |
162
- | ↑ | `<cwd>/acp.json` | Project config |
163
- | ↑ | Walk-up `.easbot/` directories for `acp.json` | git-worktree compatible |
164
- | ↑ | `<cwd>/.easbot/acp.json` | Project-level (aligned with `<workspaceDir>`) |
165
- | Highest | `<cwd>/easbot.json` top-level `acp` field | Mixed field (shared with global) |
196
+ - Project-level `acp.json` lives in **exactly one place**: `.easbot/acp.json` (held by `AcpCache`).
197
+ Bare `<workspaceDir>/acp.json` is no longer supported, and `EASBOT_CONFIG_DIR` no longer
198
+ participates in the resolution chain.
199
+ - `<workspaceDir>` comes from `getInstance().directory` (Instance is injected uniformly by the CLI entry point).
200
+ - **Single schema source**: raw reads apply **no** schema; validation + defaults are applied exactly
201
+ once at the end via `ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)` — applying them
202
+ per-layer would let defaults leak across layers (a defaulted low-priority field overriding a real one).
203
+ - **No config file → no initial values**: `server` in `ACPInfoACPConfigSchema` is `.optional()` with
204
+ **no** transform fallback. When all four layers are missing, `loadConfig()` returns `{}`
205
+ (`server` is `undefined` — it never fabricates a port-3000 server). Use `getServerConfig()`
206
+ (which merges over `ACP_DEFAULT_SERVER_CONFIG`) or `ACPServerConfigSchema.parse({})` when you need
207
+ server defaults.
208
+ - Semantics identical to `packages/gateway`'s `GatewayCache` loader (same structure).
166
209
 
167
210
  Supports:
168
211
 
169
212
  - **JSONC comments** (`//` / `/* ... */`)
170
213
  - **`{env:VAR_NAME}` substitution** (auto-read from `process.env`)
171
- - **Deep merge** (`server` block + `clients` block)
172
- - **State.holder caching** (per-process singleton + explicit `clearConfigCache()`)
214
+ - **Deep merge + schema defaults** (`ConfigFileParse.merge(partials, ACPInfoACPConfigSchema)`)
215
+ - **State.holder caching** (bucketed per workspace + `AcpCache.resetState()` / `clearConfigCache()`)
216
+
217
+ ### 3.1 Server runtime config: three-tier priority
218
+
219
+ `startACPServer()` resolves its config with a **DEFAULT < environment variable < explicit config**
220
+ three-tier priority (ADR [0135](../../docs/decisions/0135-acp-server-config-priority-and-error-semantics.md)):
221
+
222
+ ```
223
+ DEFAULT_ACP_SERVER_CONFIG ← EAS_ACP_* env vars ← explicit config argument
224
+ lowest middle highest
225
+ ```
226
+
227
+ | Environment variable | Overridden field | Accepted values |
228
+ | ----------------------------- | ------------------- | ------------------------------ |
229
+ | `EAS_ACP_CHANNEL` | `channel` | `stdio` / `http` / `websocket` |
230
+ | `EAS_ACP_PORT` | `port` | 1-65535 |
231
+ | `EAS_ACP_HOSTNAME` | `hostname` | non-empty string |
232
+ | `EAS_ACP_TIMEOUT` | `timeout` | positive integer (ms) |
233
+ | `EAS_ACP_HISTORY_SCOPE` | `historyScope` | enum value |
234
+ | `EAS_ACP_HISTORY_WINDOW_SIZE` | `historyWindowSize` | positive integer |
235
+ | `EAS_ACP_DEGRADE_POLICY` | `degradePolicy` | enum value |
236
+
237
+ Key points:
238
+
239
+ - **Env vars are not dead config** — before v0.3.32, `loadACPServerConfig` filled `DEFAULT`
240
+ first, so env vars were always shadowed. Fixed by `loadACPServerConfigWithEnv()` (ADR 0135).
241
+ - **Invalid env values are ignored, not fatal** — the env parsing layer silently skips them
242
+ (falling back to DEFAULT); an invalid **explicit config** still throws `InvalidArgumentError`
243
+ (validation is not bypassed).
244
+ - Programmatic entry point: `import { loadACPServerConfigWithEnv } from '@easbot/acp'`.
245
+
246
+ ```typescript
247
+ import { loadACPServerConfigWithEnv } from '@easbot/acp';
248
+
249
+ const cfg = loadACPServerConfigWithEnv({ channel: 'websocket' });
250
+ // cfg.port ← EAS_ACP_PORT (when valid) → otherwise DEFAULT's 3000
251
+ ```
173
252
 
174
253
  ### 4. L2 cache: `AcpCache` namespace
175
254
 
@@ -178,7 +257,7 @@ ACP subsystem owns an independent L2 config file `<workspaceDir>/.easbot/acp.jso
178
257
  ```typescript
179
258
  import { AcpCache } from '@easbot/acp';
180
259
 
181
- // 1. Explicit pre-warm (called at agent bootstrap)
260
+ // 1. Explicit warm-up — already invoked by EasbotAdapter.init(), usually no need to call manually
182
261
  await AcpCache.init();
183
262
 
184
263
  // 2. Read
@@ -194,6 +273,8 @@ await AcpCache.writeAcpJson({ server: { channel: 'http', port: 8080 } });
194
273
  AcpCache.resetState(); // clear holder + idempotent flag
195
274
  ```
196
275
 
276
+ > `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.
277
+
197
278
  ### 5. Error handling
198
279
 
199
280
  Layered per `spec/error-handling-standard.md` v1.5:
@@ -330,6 +411,79 @@ setInstanceAdapter({
330
411
  });
331
412
  ```
332
413
 
414
+ **Gateway URL injection** (new in 2026-10-29):
415
+
416
+ ```typescript
417
+ import { setGatewayUrlAdapter } from '@easbot/acp';
418
+
419
+ // Host resolves the Gateway URL and injects it
420
+ // (agent CLI reads gateway.json; standalone CLI reads acp.json)
421
+ setGatewayUrlAdapter({ url: 'ws://localhost:8080/', autoRegister: true });
422
+ ```
423
+
424
+ ### 8. ACP → Gateway auto-registration (2026-10-29)
425
+
426
+ After the ACP Server starts it **auto-registers** with the Gateway, so other Gateway nodes can discover this Agent.
427
+
428
+ | Item | Description |
429
+ | ------------------ | ------------------------------------------------------------------------------------------------------ |
430
+ | Trigger | Inside `EasbotAdapter.ensureACPService()` (once the server is up and the listen address is known) |
431
+ | Covered CLIs | `easbot acp start` (agent CLI) + `easbot-acp start` (standalone CLI) — **identical behaviour** |
432
+ | URL source | agent CLI → `gateway.json` (single source of truth); standalone CLI → `acp.json`'s `client.gatewayUrl` |
433
+ | Registered address | WebSocket channel automatically gets the `/acp` path (matches the ACP server's real endpoint) |
434
+ | Agent identity | `server.agentId` (recommended, stable); falls back to a random `ag_xxx` id when absent |
435
+ | Cycle task | Every 60s: **not registered → retry registration**; **registered → send `agent_heartbeat`** |
436
+ | Deregistration | Inside `EasbotAdapter.destroy()` (graceful shutdown) |
437
+
438
+ **Gateway is an optional dependency**: the ACP server listens on its own HTTP/WebSocket port, so
439
+ agent-clients connect directly. With no Gateway URL configured it **never connects to the Gateway**
440
+ (pure standalone mode, zero log noise); when configured but unreachable, registration failure is
441
+ downgraded to DEBUG level (`log.errorDegradable`) and never affects the ACP service.
442
+
443
+ **Agent identity (`server.agentId`)**: it is this ACP process's **unique identity** on the Gateway.
444
+ Configure it explicitly:
445
+
446
+ ```json
447
+ {
448
+ "server": {
449
+ "agentId": "xiaomo",
450
+ "name": "小莫"
451
+ }
452
+ }
453
+ ```
454
+
455
+ When absent it falls back to a random id (`ag_xxx`) generated by `Identifier.ascending('agent')` —
456
+ **different on every startup**, which makes stale records pile up on the Gateway.
457
+
458
+ **Two heartbeat layers, separate responsibilities (no conflict)**:
459
+
460
+ | Layer | Frame | Purpose |
461
+ | ------------------------ | ----------------- | -------------------------------------------------------------------------------------- |
462
+ | `GatewayClient` internal | `ping` / `pong` | Keeps the **WebSocket connection** alive (cross-cycle backoff reconnect) |
463
+ | ACP cycle task | `agent_heartbeat` | Keeps the **Agent state on the Gateway registry** (`lastHeartbeat` / `status=healthy`) |
464
+
465
+ **Retry strategy**: the `retry()` helper is deliberately **not** used — its backoff only lives inside
466
+ a single call and is not reused across cycles (`packages/utils/src/gateway/gateway-client.ts` already
467
+ hit this pitfall, see the comment there). Worse: without a follow-up task, a failed registration is
468
+ never retried, and since the WS stays `connected` no further `connected` event fires — the ACP agent
469
+ would stay invisible to the Gateway forever. Instead a **single cycle task** (60s) is used: a failed
470
+ registration is retried on the next cycle (natural cross-cycle backoff), and a disconnected client is
471
+ simply skipped (the connection layer handles backoff reconnect on its own).
472
+
473
+ ```typescript
474
+ import { getAgentAddress, registerToGateway, deregisterFromGateway } from '@easbot/acp';
475
+
476
+ // Manual use (rarely needed — ensureACPService already wires it up)
477
+ const address = getAgentAddress(serverConfig); // 'ws://localhost:3000/acp'
478
+ await registerToGateway(serverConfig); // downgraded on failure, never throws
479
+ await deregisterFromGateway(); // idempotent
480
+ ```
481
+
482
+ **Dependency boundary**: the acp package does **not** depend on `@easbot/gateway` (that would drag
483
+ `gateway → llm → local-model-sdk`'s heavy dependencies into acp). The Gateway URL is **injected by the
484
+ host** (`setGatewayUrlAdapter`), following this package's existing host ↔ package decoupling pattern
485
+ (ADR 0066).
486
+
333
487
  ## CLI commands
334
488
 
335
489
  5 sub-commands (v0.1 scope):
@@ -398,6 +552,11 @@ $ easbot-acp start --channel websocket
398
552
  $ easbot acp start --channel http --port 3000
399
553
  ```
400
554
 
555
+ > The **`address` row** of the start banner is a full protocol URL (built by the single
556
+ > source of truth `getAcpEndpointUrl`): `ws://<hostname>:<port>` / `http://<hostname>:<port>` /
557
+ > `stdio://easbot`. The same rule backs the server-side `getServerUrl` and the `address` the
558
+ > agent registers with Gateway, so the three can never drift apart.
559
+
401
560
  ## Architecture
402
561
 
403
562
  ```
@@ -417,10 +576,8 @@ $ easbot acp start --channel http --port 3000
417
576
  │ ├─ interfaces.ts (host ↔ package decoupling) │
418
577
  │ ├─ server/ (acp-server / http-server / ws-server) │
419
578
  │ ├─ client/ (acp-client / stdio / http / ws subscriber) │
420
- │ ├─ connection/ (registry / router) │
579
+ │ ├─ connection/ (registry / router / types — types is a re-export layer; source of truth in @easbot/utils) │
421
580
  │ ├─ event/ (acp-event-bridge) │
422
- │ ├─ performance/ (performance-monitor / streaming) │
423
- │ ├─ error/ (error-handler / timeout-manager) │
424
581
  │ ├─ types/ (adapter / channel / error / event) │
425
582
  │ ├─ bootstrap/ (EasbotAdapter) │
426
583
  │ └─ easbot-agent.ts (EasBotAgent instance) │
@@ -429,15 +586,15 @@ $ easbot acp start --channel http --port 3000
429
586
 
430
587
  ## Differences from note / gateway / memory
431
588
 
432
- | Dimension | note | gateway | acp |
433
- | ----------------------- | --------------------- | ------------------------- | ------------------------- |
434
- | L2 config file name | `note.json` | `gateway.json` | `acp.json` |
435
- | L2 cache name | `NoteCache` | (no L2 cache) | `AcpCache` |
436
- | Error namespace | `NoteError` | `GatewayError` | `AcpError` |
437
- | Business code whitelist | 13 | (not registered) | 5 |
438
- | Command count | 11 | 0 (no standalone CLI) | 5 |
439
- | Top-level deps | LLM / DB / parser | hono / undici / ws | @agentclientprotocol/sdk |
440
- | Config loading | single-file NoteCache | multi-dir mixed (gateway) | multi-dir mixed (gateway) |
589
+ | Dimension | note | gateway | acp |
590
+ | ----------------------- | --------------------- | ------------------------------------------------------- | ------------------------------------------------------- |
591
+ | L2 config file name | `note.json` | `gateway.json` | `acp.json` |
592
+ | L2 cache name | `NoteCache` | (no L2 cache) | `AcpCache` |
593
+ | Error namespace | `NoteError` | `GatewayError` | `AcpError` |
594
+ | Business code whitelist | 13 | (not registered) | 5 |
595
+ | Command count | 11 | 0 (no standalone CLI) | 5 |
596
+ | Top-level deps | LLM / DB / parser | hono / undici / ws | @agentclientprotocol/sdk |
597
+ | Config loading | single-file NoteCache | four-layer merge (global + easbot.json field + project) | four-layer merge (global + easbot.json field + project) |
441
598
 
442
599
  ## Development commands
443
600
 
@@ -470,7 +627,7 @@ pnpm --filter @easbot/acp test:clean
470
627
  ## Design principles
471
628
 
472
629
  1. **host ↔ package decoupling**: all runtime dependencies are explicitly injected via `setGlobalAdapter / setInstanceAdapter`; agent package / standalone CLI / tests share the same semantics
473
- 2. **Multi-directory config loading**: mirrors `packages/gateway/src/config/loader.ts`, with JSONC + env substitution + State.holder three-piece set
630
+ 2. **Four-layer config loading**: mirrors `packages/gateway/src/config/loader.ts`, with JSONC + env substitution + State.holder three-piece set
474
631
  3. **Error layering**: in-package `AcpError` (business semantics) + `NameErrors` (generic) + `ServiceError + ServiceErrorBus` (LLM business feedback)
475
632
  4. **CLI / handler separation**: `handleAcpCli(args, deps)` entry is independently testable; agent / standalone CLI / MCP server reuse the same dispatch logic
476
633
  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 +645,7 @@ pnpm --filter @easbot/acp test:clean
488
645
 
489
646
  - [`@agentclientprotocol/sdk`](https://github.com/agentclientprotocol/typescript-sdk) — official TypeScript SDK for ACP protocol
490
647
  - `packages/note/src/cli-handler.ts` — CLI handler reference
491
- - `packages/gateway/src/config/loader.ts` — multi-directory config loader reference
648
+ - `packages/gateway/src/config/loader.ts` — four-layer config loader reference
492
649
  - `packages/note/src/cache/index.ts` — same-source reference for AcpCache (Pattern E)
493
650
  - `packages/note/src/errors.ts` — same-source reference for AcpError
494
651
  - `ADR 0066` — host ↔ package decoupling specification