@harapter/transport-acp 0.1.1 → 0.1.2
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.ja.md +97 -0
- package/README.md +29 -2
- package/README.zh-CN.md +94 -0
- package/package.json +6 -4
package/README.ja.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-acp</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>stable Agent Client Protocol v1 の strict Provider-neutral client。</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.ja.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-acp/next?style=flat-square&label=npm%20next" alt="npm next バージョン"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-acp?style=flat-square" alt="npm ダウンロード数"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI ステータス"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 以上">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 ライセンス"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha ステータス">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
21
|
+
|
|
22
|
+
`@harapter/transport-jsonrpc-stdio` を組み合わせ、stable ACP v1
|
|
23
|
+
negotiation、Session method、Prompt、typed update、Permission
|
|
24
|
+
Request、Capability Gate、未知 message の bounded observation を実装します。ACP
|
|
25
|
+
Agent の起動、Provider 選択、Harapter Event mapping は行いません。
|
|
26
|
+
|
|
27
|
+
## インストール
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @harapter/transport-acp@next
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## クイックスタート
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { AcpClient } from '@harapter/transport-acp';
|
|
37
|
+
|
|
38
|
+
const client = new AcpClient({
|
|
39
|
+
readable: controlledProcess.stdout,
|
|
40
|
+
writable: controlledProcess.stdin,
|
|
41
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
42
|
+
requestPermission: async (request) =>
|
|
43
|
+
decidePermissionWithoutLoggingRawFields(request),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
await client.initialize({
|
|
47
|
+
clientInfo: { name: 'harapter-provider', version: 'current' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const session = await client.newSession({
|
|
51
|
+
cwd: controlledWorkspace,
|
|
52
|
+
mcpServers: [],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const eventTask = (async () => {
|
|
56
|
+
for await (const event of client.events()) {
|
|
57
|
+
await handleValidatedAcpEvent(event);
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
|
|
61
|
+
await client.prompt({
|
|
62
|
+
sessionId: session.sessionId,
|
|
63
|
+
prompt: [{ type: 'text', text: controlledPrompt }],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await client.close();
|
|
67
|
+
await eventTask;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 実装済み ACP v1 範囲
|
|
71
|
+
|
|
72
|
+
- JSON-RPC `"2.0"` と `protocolVersion: 1` の厳密な negotiation;
|
|
73
|
+
- `session/new` と Capability-gated load/list/delete/resume/close;
|
|
74
|
+
- `session/prompt`、stable v1 `session/update`、`session/cancel`;
|
|
75
|
+
- `session/request_permission` と `_` で始まる明示的 extension method;
|
|
76
|
+
- 将来・未知 message の bounded redacted observation。
|
|
77
|
+
|
|
78
|
+
ACP v2、authentication、logout、terminal、filesystem、elicitation、Session
|
|
79
|
+
mode、Session configuration method は現在の stable profile 外です。未実装 Client
|
|
80
|
+
Service を Capability として宣言することはできません。
|
|
81
|
+
|
|
82
|
+
## ライフサイクル要点
|
|
83
|
+
|
|
84
|
+
- connection ごとに initialize は一回、Session ごとに active Prompt は一つです;
|
|
85
|
+
- 検証済み `session/prompt` response と stable stop
|
|
86
|
+
reason だけが終端 authority です;
|
|
87
|
+
- `cancelSession()` の notification
|
|
88
|
+
write 成功だけでは cancellation を証明しません;
|
|
89
|
+
- local
|
|
90
|
+
timeout/abort は cancel を送らず、未確認 Prompt は Session 再利用を止めます;
|
|
91
|
+
- `events()` の consumer は一つで、既定の未読上限は 128 です;
|
|
92
|
+
- 未知 message は success に変換されず、raw
|
|
93
|
+
observation の文字列や ID は hash または除去されます。
|
|
94
|
+
|
|
95
|
+
Extension callback、Permission Payload、Tool Raw Input/Output、Remote
|
|
96
|
+
Error は明示的 unredacted boundary です。全 protocol と race semantics は
|
|
97
|
+
[英語の詳細ドキュメント](./README.md)を参照してください。
|
package/README.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-acp</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>A strict, Provider-neutral client for the stable Agent Client Protocol v1.</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-acp/next?style=flat-square&label=npm%20next" alt="npm next version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-acp?style=flat-square" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI status"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 or newer">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 license"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha status">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
2
21
|
|
|
3
22
|
`@harapter/transport-acp` is Harapter's Provider-neutral client for the stable
|
|
4
23
|
Agent Client Protocol v1 wire contract. It composes
|
|
@@ -12,6 +31,14 @@ portable Harapter lifecycle events, or infer capabilities from an Agent name.
|
|
|
12
31
|
The consuming Provider Adapter owns process policy, Provider meaning, Session
|
|
13
32
|
ownership, compatibility, and portable event and error mapping.
|
|
14
33
|
|
|
34
|
+
## Use this package when
|
|
35
|
+
|
|
36
|
+
- an Adapter connects to an Agent that implements stable ACP v1;
|
|
37
|
+
- you need negotiated Session methods, typed updates, permission requests, and
|
|
38
|
+
bounded unknown-message observation; or
|
|
39
|
+
- you want ACP validation without importing Provider identity or process policy
|
|
40
|
+
into a reusable transport layer.
|
|
41
|
+
|
|
15
42
|
## Installation
|
|
16
43
|
|
|
17
44
|
```bash
|
|
@@ -127,7 +154,7 @@ payloads, negotiated `_meta`, known tool `rawInput` and `rawOutput`, remote
|
|
|
127
154
|
errors, and authentication-method values must not be logged or attached to
|
|
128
155
|
portable errors without Adapter-owned validation and redaction.
|
|
129
156
|
|
|
130
|
-
##
|
|
157
|
+
## Quick start
|
|
131
158
|
|
|
132
159
|
```ts
|
|
133
160
|
import { AcpClient } from '@harapter/transport-acp';
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-acp</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>严格、Provider 无关的稳定 Agent Client Protocol v1 客户端。</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.zh-CN.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-acp/next?style=flat-square&label=npm%20next" alt="npm next 版本"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-acp"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-acp?style=flat-square" alt="npm 下载量"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI 状态"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 或更高版本">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 许可证"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha 状态">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
21
|
+
|
|
22
|
+
这个包组合 `@harapter/transport-jsonrpc-stdio`,实现稳定 ACP
|
|
23
|
+
v1 的协商、Session 方法、Prompt、类型化更新、Permission Request、Capability
|
|
24
|
+
Gate 和有界未知消息观测。它不启动 ACP Agent,也不选择 Provider 或把 ACP
|
|
25
|
+
Event 映射成 Harapter Event。
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @harapter/transport-acp@next
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { AcpClient } from '@harapter/transport-acp';
|
|
37
|
+
|
|
38
|
+
const client = new AcpClient({
|
|
39
|
+
readable: controlledProcess.stdout,
|
|
40
|
+
writable: controlledProcess.stdin,
|
|
41
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
42
|
+
requestPermission: async (request) =>
|
|
43
|
+
decidePermissionWithoutLoggingRawFields(request),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
await client.initialize({
|
|
47
|
+
clientInfo: { name: 'harapter-provider', version: 'current' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const session = await client.newSession({
|
|
51
|
+
cwd: controlledWorkspace,
|
|
52
|
+
mcpServers: [],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const eventTask = (async () => {
|
|
56
|
+
for await (const event of client.events()) {
|
|
57
|
+
await handleValidatedAcpEvent(event);
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
|
|
61
|
+
await client.prompt({
|
|
62
|
+
sessionId: session.sessionId,
|
|
63
|
+
prompt: [{ type: 'text', text: controlledPrompt }],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await client.close();
|
|
67
|
+
await eventTask;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 已实现的 ACP v1 范围
|
|
71
|
+
|
|
72
|
+
- 精确 JSON-RPC `"2.0"` 和 `protocolVersion: 1` 协商;
|
|
73
|
+
- `session/new`、按能力启用的 load/list/delete/resume/close;
|
|
74
|
+
- `session/prompt`、稳定 v1 `session/update`、`session/cancel`;
|
|
75
|
+
- `session/request_permission` 与 `_` 开头的显式扩展方法;
|
|
76
|
+
- 未来或未知消息的有界、脱敏结构观测。
|
|
77
|
+
|
|
78
|
+
ACP v2、认证、logout、terminal、filesystem、elicitation、Session mode 和 Session
|
|
79
|
+
configuration 方法不在当前稳定 Profile 中。未实现的 Client
|
|
80
|
+
Service 不能被伪装成已支持能力。
|
|
81
|
+
|
|
82
|
+
## 生命周期要点
|
|
83
|
+
|
|
84
|
+
- 一条连接只初始化一次,同一 Session 同时只有一个 Prompt;
|
|
85
|
+
- 只有验证通过的 `session/prompt` 响应和稳定 stop reason 才是权威终态;
|
|
86
|
+
- `cancelSession()` 会发送原生通知,但写入成功本身不是取消终态;
|
|
87
|
+
- 本地 timeout/abort 不发送取消,未确认的远端 Prompt 会阻止 Session 复用;
|
|
88
|
+
- `events()` 只有一个消费者,默认最多缓存 128 个未读事件;
|
|
89
|
+
- 未知消息不会被猜测为成功,任意字符串和标识符会在 Raw
|
|
90
|
+
Observation 中被散列或移除。
|
|
91
|
+
|
|
92
|
+
扩展回调、Permission Payload、Tool Raw Input/Output 和 Remote
|
|
93
|
+
Error 是显式不脱敏边界,调用方必须自行执行数据策略。完整协议范围与竞态语义见
|
|
94
|
+
[英文详细文档](./README.md)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harapter/transport-acp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Provider-neutral stable ACP v1 client for Harapter providers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/yunfeizhu/harapter/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://github.com/yunfeizhu/harapter#readme",
|
|
20
|
+
"homepage": "https://github.com/yunfeizhu/harapter/tree/main/packages/transport-acp#readme",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"files": [
|
|
24
|
-
"dist"
|
|
24
|
+
"dist",
|
|
25
|
+
"README.zh-CN.md",
|
|
26
|
+
"README.ja.md"
|
|
25
27
|
],
|
|
26
28
|
"main": "./dist/index.js",
|
|
27
29
|
"types": "./dist/index.d.ts",
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"tag": "next"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@harapter/transport-jsonrpc-stdio": "0.1.
|
|
46
|
+
"@harapter/transport-jsonrpc-stdio": "0.1.2"
|
|
45
47
|
},
|
|
46
48
|
"scripts": {
|
|
47
49
|
"build": "tsc --project tsconfig.build.json"
|