@qilin-agent/acp 0.0.0-stage → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kkutysllb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,82 @@
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/acp/acp/README.md
5
+ /:
6
+ en: b360d0052dfc5542
7
+ zh: 7aec4db9e8e9c442
8
+ /qilin-acp:
9
+ en: 0be98274c6724fb6
10
+ zh: 9d79352e225e1359
11
+ /qilin-acp/summary:
12
+ en: bf65128192214b7f
13
+ zh: 27b09c10d947f6a1
14
+ /qilin-acp/table-of-contents:
15
+ en: d152484eb41ac6b4
16
+ zh: 09388d293f9be9cb
17
+ /qilin-acp/use-this-package:
18
+ en: 014a5573a8c05663
19
+ zh: e45302786655eea5
20
+ /qilin-acp/use-this-package/when-to-choose-it:
21
+ en: 58290e9360ae5091
22
+ zh: 672d438827ce5f1a
23
+ /qilin-acp/use-this-package/minimal-configuration:
24
+ en: 7bdf9d9fa5794dc6
25
+ zh: 2390e7af629db5dc
26
+ /qilin-acp/use-this-package/start-a-server:
27
+ en: 9f70acea98c1c235
28
+ zh: 43f7cdd133fda80e
29
+ /qilin-acp/use-this-package/protocol-contract:
30
+ en: 804b87d8ebed9f8d
31
+ zh: 1b0c1c7269cdf040
32
+ /qilin-acp/understand-the-implementation:
33
+ en: ea8afe89dbdd1934
34
+ zh: 6567979f92f34afd
35
+ /qilin-acp/understand-the-implementation/design-philosophy:
36
+ en: 009136a2e340bf99
37
+ zh: 35b33047ed9802ab
38
+ /qilin-acp/understand-the-implementation/source-map:
39
+ en: 9f85ae4ecdb5d022
40
+ zh: dc2b911360768b9e
41
+ /qilin-acp/understand-the-implementation/admission-and-prompt-settlement:
42
+ en: 6485d449b5945b4a
43
+ zh: 90e56a9b410c9c42
44
+ /qilin-acp/understand-the-implementation/teardown-and-connection-ownership:
45
+ en: 83e7a3b268ffbb86
46
+ zh: 9ec7e32ce259f6c2
47
+ /qilin-acp/further-exploration:
48
+ en: 70100881dc8023eb
49
+ zh: eeedfdabf0d70cba
50
+ /qilin-acp/model-experience:
51
+ en: 215e7ba838619b7b
52
+ zh: a311da3843709f90
53
+ /qilin-acp/model-experience/prompt-content:
54
+ en: 7fca865c9895801f
55
+ zh: 78a0ab12c0bb0499
56
+ /qilin-acp/model-experience/prompt-content/what-the-model-sees:
57
+ en: e3adbb072da5ff1d
58
+ zh: 0af2105dd9e171d3
59
+ /qilin-acp/model-experience/prompt-content/token-effect:
60
+ en: 93b8f76c67bef353
61
+ zh: 354fa2dca0804f72
62
+ /qilin-acp/model-experience/prompt-content/kv-cache-effect:
63
+ en: 54946b64b26a3171
64
+ zh: 09550292ccfb36b0
65
+ /qilin-acp/model-experience/permission-decisions:
66
+ en: 2e6d83c846a3a5e1
67
+ zh: 8d4339c26f3d8f68
68
+ /qilin-acp/model-experience/permission-decisions/what-the-model-sees:
69
+ en: 87b55e04137085c3
70
+ zh: cdba4acf2e38b872
71
+ /qilin-acp/model-experience/permission-decisions/token-effect:
72
+ en: bd0ded535cbedb19
73
+ zh: 47bcaa76827f88f2
74
+ /qilin-acp/model-experience/permission-decisions/kv-cache-effect:
75
+ en: 83120763a07c4b72
76
+ zh: 6a1a181dc4da869d
77
+ /qilin-acp/known-limitations-and-deferred-work:
78
+ en: c7ec5c39a44e6e41
79
+ zh: cd45b7744413faee
80
+ /qilin-acp/known-limitations-and-deferred-work/dev-note:
81
+ en: e67f633dc6fe7773
82
+ zh: 3bb0c20c93f16f98
package/README.md CHANGED
@@ -1,3 +1,181 @@
1
- # Temporary Holding Version
1
+ ---
2
+ description: "Automation-only ACP (Agent Client Protocol) server for programmatic clients and maintainers driving QiLin agents over JSON-RPC stdio."
3
+ kind: "package-reference"
4
+ ---
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ # @qilin-agent/acp
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ `qilin-acp` lets trusted programs automate persistent QiLin agents through the standard [ACP](https://agentclientprotocol.com): create or resume sessions, select a model and reasoning effort, attach MCP servers, submit or cancel work, receive semantic updates, and close sessions independently. Choose it for out-of-process subagents, test runners, and scripted controllers; it intentionally omits QILIN-specific presentation data and interactive UI features. Persistence supports listing, resuming, and closing sessions across process restarts, but deletion, forks, transcript replay, and additional directories are unsupported. Run `pnpm qilin --profile acp` to start the server; use `qilin-subagent-acp` as the repository client.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Use this package when a script, test runner, or another harness needs to run agent work end to end through a standard automation protocol. The common path is: start the server, create or resume a session, optionally mount MCP servers and select model options, send a prompt, consume semantic updates, and close the session.
29
+
30
+ ### When to choose it
31
+
32
+ Choose it when automation should own the interaction: an out-of-process subagent, test runner, or scripted controller that manages persistent sessions, tools, model selection, and permissions. Avoid it when a human needs QILIN-specific presentation cards, plans, titles, todos, terminal views, or elicitation; this server intentionally exposes only the standard ACP v1 surface.
33
+
34
+ ### Minimal configuration
35
+
36
+ Every session the server creates uses the provider and model configured here. Both fields are optional so another agent or request listener can supply them; the runnable demo composition sets both. Stdout carries only protocol traffic, so keep logging off it.
37
+
38
+ ```yaml
39
+ - name: '@qilin-agent/acp'
40
+ config:
41
+ provider: deepseek-official
42
+ model: deepseek-v4-pro
43
+ ```
44
+
45
+ | Field | Default | Meaning |
46
+ |---|---|---|
47
+ | `provider` | — | Provider route for every session's agent |
48
+ | `model` | — | Model for every session's agent |
49
+ | `sessionListPageSize` | `100` | Maximum summaries returned in one `session/list` page |
50
+
51
+ The generated [configuration catalog](../../../docs/config-catalog.md#qilin-agentacp) is the exhaustive source for every accepted field and its JSDoc.
52
+
53
+ ### Start a server
54
+
55
+ `pnpm qilin --profile acp` starts the shipped stdio server. The `acp` profile mounts session persistence, so clients can list, resume, and close persistent sessions. [`@qilin-agent/subagent-acp`](../../subagent/subagent-acp/README.md) starts the same profile for out-of-process delegation.
56
+
57
+ <a id="protocol-contract"></a><a id="standard-acp-v1-surface"></a>
58
+ ### Protocol contract
59
+
60
+ One connection can run several sessions at once, each independent. The calls a client makes:
61
+
62
+ | Call | What you get |
63
+ |---|---|
64
+ | `initialize` | Stable ACP v1 plus `session/list`, `session/resume`, `session/close`, and Streamable HTTP MCP support; image prompts only when the durable attachment store and configured exact route support them. |
65
+ | `authenticate` | Immediate success; the server requires no authentication. |
66
+ | `session/new` | A fresh persistent agent whose absolute workspace and stdio or HTTP MCP servers are validated before publication, plus its complete configuration-option state. |
67
+ | `session/list` | Deterministic newest-first pages of persisted, resumable root sessions; an optional absolute `cwd` filter uses physical-directory identity where possible. |
68
+ | `session/resume` | A persisted inactive session whose canonical workspace is verified before composition; its log is restored without replaying old updates. |
69
+ | `session/close` | Quiescent cancellation, update draining, descendant disposal, persistence flush, and disposal of only the addressed Agent scope. |
70
+ | `session/set_config_option` | A serialized update to the advertised `model` or `reasoning_effort`, returning the complete resulting state. |
71
+ | `session/prompt` | Ordered text, resource links, and supported images, one prompt at a time per session; settlement follows Agent idle and ordered update delivery. |
72
+ | `session/cancel` / `$/cancel_request` | The prompt-owned cancellation path; without an ACP prompt in flight it cancels autonomous work, while unknown session ids are no-ops. |
73
+ | `session/update` | Committed assistant messages and thoughts, generic tool lifecycle, configuration changes, and context usage, serialized per session. |
74
+ | `session/request_permission` | A permission prompt with one-shot allow/reject choices; your client can answer automatically. |
75
+
76
+ Session configuration offers opaque provider/model choices from the live LLM service catalog and a `reasoning_effort` selector when the exact model declares one. A prompt snapshots that selection before asynchronous image admission and pins it across every model step in that turn; a concurrent option change applies to the next turn. ACP clients are trusted controllers: stdio MCP entries authorize their absolute commands and environment, HTTP entries authorize their absolute HTTP(S) URLs and headers, and any initial connection or discovery failure rolls back the unpublished Agent. Unsupported surfaces are omitted or rejected: `session/load`, deletion, fork, additional directories, SSE or ACP-transport MCP, modes, commands, plans, terminals, client filesystem operations, and elicitation.
77
+
78
+ -----
79
+
80
+ <a id="understand-the-implementation"></a>
81
+ ## Understand the implementation
82
+
83
+ <details>
84
+ <summary>Implementation internals — click to expand</summary>
85
+
86
+ This section explains how the server realizes the behavior above and points at the code that implements it; the observable behavior is fully covered in [Use this package](#use-this-package).
87
+
88
+ ### Design philosophy
89
+
90
+ The server is an automation transport with an intentionally standard public protocol. Three commitments shape it:
91
+
92
+ - **Standard semantic updates only.** The wire carries committed messages and thoughts, generic tool lifecycle, configuration, and context usage; raw provider deltas, retry attempts, QILIN presentation data, and unsupported content stay off the wire.
93
+ - **Truthful capability and configuration state.** `initialize` advertises only mounted support, topology changes publish complete configuration options, and a prompt pins the exact route it admitted.
94
+ - **Quiescence before settlement.** Prompt and close operations settle only after their owned admission, Agent activity, ordered updates, descendants, persistence, and disposal have reached the required terminal state.
95
+
96
+ The decision history lives in the [ACP as an automation-only protocol note](../../../.agents/notes/implemented/simplification/2026-07-23-acp-automation-only-protocol.md) and the [multi-session note](../../../.agents/notes/archived/feature/2026-06-14-acp-multi-session.md).
97
+
98
+ ### Source map
99
+
100
+ | File | Role |
101
+ |---|---|
102
+ | [`src/index.ts`](src/index.ts) | Plugin entry: `Config` schema, `AgentSideConnection` wiring, per-session records, admission and settlement, teardown |
103
+ | [`src/content.ts`](src/content.ts) | Wire-content admission and projection: image validation, route recheck, prompt reconstruction, assistant block conversion |
104
+ | [`src/codec.ts`](src/codec.ts) | Pure turn-ending to ACP `stopReason` mapping |
105
+
106
+ ### Admission and prompt settlement
107
+
108
+ Each session permits one in-flight prompt. Admission validates the whole prompt batch, snapshots the selected route, rechecks the exact Agent identity and image capability, persists image attachments, and only then queues the user message — a cancellation that wins admission never enqueues a late turn. Once queued, the session module associates the snapshot with the inbox message until claim and pins the same provider, model, and reasoning effort across prompt variables and every model step in that turn. Per-session update delivery is serialized; committed images are re-read and integrity-verified, so a missing or corrupt image fails the correlated prompt instead of emitting a placeholder. Settlement precedence is explicit cancellation, committed-output failure, interval-wide Agent failure, then the correlated turn ending.
109
+
110
+ ### Teardown and connection ownership
111
+
112
+ Each session module owns its Agent handle, MCP mounts, future and turn-pinned model selections, prompt slot, update chain, and memoized close operation. Explicit close, client disconnect, and Kylin disposal use the same quiescent teardown: stop new work, cancel prompt admission and Agent activity, drain committed updates, dispose continuable descendants child-first, flush persistence, and release the owned Agent scope. A session close leaves persisted state available for list and resume, and other sessions or frontends sharing the Context remain untouched.
113
+
114
+ </details>
115
+
116
+ -----
117
+
118
+ <a id="further-exploration"></a>
119
+ ## Further Exploration
120
+
121
+ Read these pages when the package-level contract is not enough. They move from the matching client to the design records behind the automation contract.
122
+
123
+ - [qilin-subagent-acp](../../subagent/subagent-acp/README.md) — the out-of-process ACP client that spawns and drives this server.
124
+ - [ACP as an automation-only protocol](../../../.agents/notes/implemented/simplification/2026-07-23-acp-automation-only-protocol.md) — the design record for the automation contract and its wire boundaries.
125
+ - [Multiplex concurrent ACP sessions over one connection](../../../.agents/notes/archived/feature/2026-06-14-acp-multi-session.md) — per-session isolation, ownership, and teardown decisions.
126
+ - [Extension cookbook](../../../docs/cookbook/extension-cookbook.md) — this package as the automation-only worked example for extension authors.
127
+
128
+ -----
129
+
130
+ <a id="model-experience"></a>
131
+ ## Model Experience
132
+
133
+ ### Prompt content
134
+
135
+ #### What the model sees
136
+
137
+ `session/prompt` preserves text and image order in one user message: adjacent text concatenates, and a resource link appears as a bracketed `[resource_link name=… uri=…]` reference the model may open with its own tools. Inline image base64 is discarded after batch admission, so the durable message contains only verified attachment references. Protocol metadata, client capabilities, permission choices, and session ids never enter the model request.
138
+
139
+ #### Token effect
140
+
141
+ Prompt content, tool calls/results, and durable image references remain in that session until compaction. Concurrent sessions retain independent contexts.
142
+
143
+ #### KV Cache effect
144
+
145
+ Append-only while the selected route and assembled prefix stay unchanged. A model change starts the next ACP turn on the new route.
146
+
147
+ ### Permission decisions
148
+
149
+ #### What the model sees
150
+
151
+ Nothing directly. The owning tool records its allowed, rejected, cancelled, or unavailable outcome through the normal tool-result path.
152
+
153
+ #### Token effect
154
+
155
+ Only the owning tool result contributes tokens.
156
+
157
+ #### KV Cache effect
158
+
159
+ Append-only through the owning tool result.
160
+
161
+ ## Known Limitations and Deferred Work
162
+
163
+ <a id="known-limitations-and-deferred-work"></a>
164
+
165
+
166
+ These limits define when this package is a poor fit or needs special operational care. They are current package constraints, not a protocol comparison or a task backlog.
167
+
168
+ - **One primary workspace** — additional directories remain unsupported.
169
+ - **Raster prompt images only** — PNG, JPEG, WebP, and GIF require a durable attachment store and an exact image-capable route.
170
+ - **MCP tools only** — MCP resources and prompts have no QILIN consumer.
171
+ - **No transcript replay or interactive extensions** — session deletion, fork, `session/load`, modes, commands, plans, terminals, client filesystem operations, and elicitation remain outside this automation surface.
172
+
173
+ <a id="dev-note"></a>
174
+ ### Dev Note
175
+
176
+ <details>
177
+ <summary>Working context for maintainers — click to expand</summary>
178
+
179
+ None.
180
+
181
+ </details>
package/README.zh.md ADDED
@@ -0,0 +1,181 @@
1
+ ---
2
+ description: "面向程序化客户端与维护者的仅自动化 ACP(Agent Client Protocol)服务器,用于通过 JSON-RPC stdio 驱动 QiLin agent(智能体)。"
3
+ kind: "package-reference"
4
+ ---
5
+
6
+ # @qilin-agent/acp
7
+
8
+ [English](README.md) | 中文
9
+
10
+ ## 概述
11
+
12
+ `qilin-acp` 让受信程序通过标准 [ACP](https://agentclientprotocol.com) 自动操作持久 QiLin agent:创建或恢复会话、选择模型与推理强度、挂载 MCP 服务器、提交或取消工作、接收语义更新,并独立关闭会话。进程外 subagent、测试运行器与脚本化控制器适合选择它;它刻意不提供 QILIN 专用呈现数据与交互式 UI 功能。持久化支持跨进程重启列出、恢复与关闭会话,但不支持删除、fork、transcript(文本记录)回放与附加目录。运行 `pnpm qilin --profile acp` 可启动服务器;仓库客户端使用 `qilin-subagent-acp`。
13
+
14
+ ## 目录
15
+
16
+ - [使用本包](#use-this-package)
17
+ - [理解实现](#understand-the-implementation)
18
+ - [进一步探索](#further-exploration)
19
+ - [模型体验](#model-experience)
20
+ - [已知限制与延期工作](#known-limitations-and-deferred-work)
21
+ - [开发备注](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## 使用本包
27
+
28
+ 当脚本、测试运行器或另一个 harness 需要通过标准自动化协议端到端运行 agent 工作时,使用本包。常用路径是:启动服务器、创建或恢复会话、按需挂载 MCP 服务器并选择模型选项、发送提示词、消费语义更新,再关闭会话。
29
+
30
+ ### 何时选择
31
+
32
+ 当自动化应拥有交互时选择它:管理持久会话、工具、模型选择与权限的进程外 subagent、测试运行器或脚本化控制器。当人类需要 QILIN 专用呈现卡片、计划、标题、todo、终端视图或 elicitation 时请避开;本服务器刻意只提供标准 ACP v1 界面。
33
+
34
+ ### 最小配置
35
+
36
+ 服务器创建的每个会话都使用此处配置的提供方与模型。两个字段都是可选的,以便由另一个 agent/request 监听器提供;可运行的演示组合会同时设置两者。Stdout 只承载协议流量,因此请让日志远离它。
37
+
38
+ ```yaml
39
+ - name: '@qilin-agent/acp'
40
+ config:
41
+ provider: deepseek-official
42
+ model: deepseek-v4-pro
43
+ ```
44
+
45
+ | 字段 | 默认值 | 含义 |
46
+ |---|---|---|
47
+ | `provider` | — | 每个会话 agent 的提供方路由 |
48
+ | `model` | — | 每个会话 agent 的模型 |
49
+ | `sessionListPageSize` | `100` | 单页 `session/list` 返回的最大摘要数量 |
50
+
51
+ 生成的[配置目录](../../../docs/config-catalog.zh.md#qilin-agentacp)是每个受支持字段及其 JSDoc 的穷尽式真源。
52
+
53
+ ### 启动服务器
54
+
55
+ `pnpm qilin --profile acp` 会启动随附的 stdio 服务器。`acp` profile 会挂载会话持久化,因此客户端可以列出、恢复和关闭持久会话。[`@qilin-agent/subagent-acp`](../../subagent/subagent-acp/README.zh.md) 会启动同一 profile 来执行进程外委派。
56
+
57
+ <a id="protocol-contract"></a><a id="standard-acp-v1-surface"></a>
58
+ ### 协议约定
59
+
60
+ 一个连接可以同时运行多个会话,彼此独立。客户端发出的调用如下:
61
+
62
+ | 调用 | 你会得到什么 |
63
+ |---|---|
64
+ | `initialize` | 稳定 ACP v1,以及 `session/list`、`session/resume`、`session/close` 与 Streamable HTTP MCP 支持;图片提示词只在持久附件存储和配置的确切路由支持时公布。 |
65
+ | `authenticate` | 立即成功;服务器不需要身份验证。 |
66
+ | `session/new` | 全新持久 agent;其绝对工作区与 stdio 或 HTTP MCP 服务器会在发布前通过校验,并返回完整配置选项状态。 |
67
+ | `session/list` | 按确定的新到旧顺序分页返回已持久化、可恢复的根会话;可选绝对 `cwd` 筛选会尽可能使用物理目录标识。 |
68
+ | `session/resume` | 恢复一个已持久化且非活跃的会话;组合前校验其规范工作区,并恢复日志但不回放旧更新。 |
69
+ | `session/close` | 停稳式取消、更新 drain、后代释放、持久化 flush,并且只释放指定 Agent 作用域。 |
70
+ | `session/set_config_option` | 串行更新公布的 `model` 或 `reasoning_effort`,并返回完整结果状态。 |
71
+ | `session/prompt` | 有序文本、资源链接与受支持图片,每个会话一次一个提示词;Agent 空闲且有序更新交付后才结算。 |
72
+ | `session/cancel` / `$/cancel_request` | 提示词所拥有的取消路径;没有进行中的 ACP 提示词时取消自主工作,未知会话 id 则为空操作。 |
73
+ | `session/update` | 已提交 assistant 消息与 thought、通用工具生命周期、配置变化与上下文用量,按会话串行交付。 |
74
+ | `session/request_permission` | 带一次性允许/拒绝选项的权限提示;你的客户端可以自动回答。 |
75
+
76
+ 会话配置从实时 LLM(大语言模型)服务目录提供不透明的提供方/模型选项,并在确切模型声明推理选项时提供 `reasoning_effort`。提示词会在异步图片准入前快照该选择,并在该轮次的每个模型步骤中固定它;并发选项变更从下一轮次开始生效。ACP 客户端是受信控制器:stdio MCP 条目授权其绝对命令与环境,HTTP 条目授权其绝对 HTTP(S) URL 与 header;初始连接或发现失败会回滚尚未发布的 Agent。不支持的界面会被省略或拒绝:`session/load`、删除、fork、附加目录、SSE(Server-Sent Events)或 ACP 传输 MCP、mode、命令、计划、终端、客户端文件系统操作与 elicitation。
77
+
78
+ -----
79
+
80
+ <a id="understand-the-implementation"></a>
81
+ ## 理解实现
82
+
83
+ <details>
84
+ <summary>实现细节——点击展开</summary>
85
+
86
+ 本节解释服务器如何实现上述行为,并指出实现它的代码位置;可观察行为已在[使用本包](#use-this-package)中完整说明。
87
+
88
+ ### 设计理念
89
+
90
+ 服务器是刻意采用标准公开协议的自动化传输。三项承诺塑造了它:
91
+
92
+ - **只发送标准语义更新。** 协议承载已提交消息与 thought、通用工具生命周期、配置与上下文用量;原始提供方增量、重试尝试、QILIN 呈现数据与不受支持内容不会进入协议。
93
+ - **诚实的能力与配置状态。** `initialize` 只公布已挂载支持,拓扑变化会发布完整配置选项,提示词则固定其准入时的确切路由。
94
+ - **停稳后才结算。** 提示词与关闭操作只在其拥有的准入、Agent 活动、有序更新、后代、持久化与释放达到所需终态后才结算。
95
+
96
+ 决策历史记录在 [ACP 作为仅面向自动化的协议笔记](../../../.agents/notes/implemented/simplification/2026-07-23-acp-automation-only-protocol.zh.md) 与[多会话笔记](../../../.agents/notes/archived/feature/2026-06-14-acp-multi-session.md) 中。
97
+
98
+ ### 源码地图
99
+
100
+ | 文件 | 职责 |
101
+ |---|---|
102
+ | [`src/index.ts`](src/index.ts) | 插件入口:`Config` schema、`AgentSideConnection` 接线、按会话记录、准入与结算、清理 |
103
+ | [`src/content.ts`](src/content.ts) | 协议内容准入与投影:图片校验、路由重查、提示词重建、assistant 块转换 |
104
+ | [`src/codec.ts`](src/codec.ts) | 轮次结束到 ACP `stopReason` 的纯映射 |
105
+
106
+ ### 准入与提示词结算
107
+
108
+ 每个会话只允许一个正在处理的提示词。准入先校验整个提示词批次、快照所选路由、重新检查 Agent 是否为同一对象与图片能力、持久化图片附件,然后才把用户消息入队——先于准入完成的取消绝不会让迟到的轮次入队。入队后,会话模块会将该快照与 inbox 消息关联起来,直至该消息被认领,并在提示词变量与该轮次的每个模型步骤中固定相同的提供方、模型与推理强度。按会话更新会串行交付;已提交图片会重新读取并验证完整性,因此图片缺失或损坏会让关联提示词失败,而不是发出占位符。结算优先级依次为显式取消、已提交输出失败、区间内 Agent 失败、关联轮次结束。
109
+
110
+ ### 清理与连接归属
111
+
112
+ 每个会话模块拥有其 Agent 句柄、MCP 挂载、未来与轮次固定的模型选择、提示词槽位、更新链和记忆化关闭操作。显式关闭、客户端断开与 Kylin 释放使用同一停稳式清理流程:停止新工作、取消提示词准入与 Agent 活动、drain 已提交更新、按子优先顺序释放可继续后代、flush 持久化并释放所拥有的 Agent 作用域。会话关闭后,已持久化的状态仍可供列出与恢复;共享上下文的其他会话或前端不受影响。
113
+
114
+ </details>
115
+
116
+ -----
117
+
118
+ <a id="further-exploration"></a>
119
+ ## 进一步探索
120
+
121
+ 当包级约定不够用时阅读以下页面。它们从匹配的客户端逐步进入自动化约定背后的设计记录。
122
+
123
+ - [qilin-subagent-acp](../../subagent/subagent-acp/README.zh.md)——spawn 并驱动本服务器的进程外 ACP 客户端。
124
+ - [ACP 作为仅面向自动化的协议](../../../.agents/notes/implemented/simplification/2026-07-23-acp-automation-only-protocol.zh.md)——自动化约定及其协议边界的决策记录。
125
+ - [在单个连接上多路复用并发 ACP 会话](../../../.agents/notes/archived/feature/2026-06-14-acp-multi-session.md)——按会话隔离、归属与清理决策。
126
+ - [扩展实操手册](../../../docs/cookbook/extension-cookbook.zh.md)——本包作为扩展作者的仅自动化完整示例。
127
+
128
+ -----
129
+
130
+ <a id="model-experience"></a>
131
+ ## 模型体验
132
+
133
+ ### 提示词内容
134
+
135
+ #### 模型看到什么
136
+
137
+ `session/prompt` 会在一条用户消息中保留文本与图片顺序:相邻文本会拼接,资源链接则表示为带方括号的 `[resource_link name=… uri=…]` 引用,模型可以使用自身工具打开它。内联图片 base64 在批量准入后即被丢弃,因此持久消息只包含经过校验的附件引用。协议元数据、客户端能力、权限选择与会话 id 绝不进入模型请求。
138
+
139
+ #### Token 影响
140
+
141
+ 提示词内容、工具调用/结果和持久图片引用会保留在该会话中直到上下文压缩(context compaction)。并发会话保留独立上下文。
142
+
143
+ #### KV Cache 影响
144
+
145
+ 只要所选路由与组装后的前缀保持不变,就仅追加。模型变更会使下一个 ACP 轮次改用新路由。
146
+
147
+ ### 权限决策
148
+
149
+ #### 模型看到什么
150
+
151
+ 不会直接看到任何内容。所属工具通过常规工具结果路径记录其结果:允许、拒绝、取消或不可用。
152
+
153
+ #### Token 影响
154
+
155
+ 只有所属工具的结果会贡献 token。
156
+
157
+ #### KV Cache 影响
158
+
159
+ 仅通过所属工具的结果追加。
160
+
161
+ ## 已知限制与延期工作
162
+
163
+ <a id="known-limitations-and-deferred-work"></a>
164
+
165
+
166
+ 这些限制说明本包何时不合适,或何时需要特别的运维注意。它们是当前包约束,不是协议对比或任务积压。
167
+
168
+ - **仅一个主 workspace**——附加目录仍不支持。
169
+ - **仅光栅提示词图片**——PNG、JPEG、WebP 与 GIF 要求持久附件存储及确切的图片能力路由。
170
+ - **仅 MCP 工具**——MCP resource 与 prompt 没有 QILIN 消费方。
171
+ - **没有 transcript 回放或交互式扩展**——会话删除、fork、`session/load`、mode、命令、计划、终端、客户端文件系统操作与 elicitation 仍不属于此自动化界面。
172
+
173
+ <a id="dev-note"></a>
174
+ ### 开发备注
175
+
176
+ <details>
177
+ <summary>维护者的工作上下文——点击展开</summary>
178
+
179
+ 无。
180
+
181
+ </details>