@harapter/adapter-pi 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 +105 -0
- package/README.md +28 -1
- package/README.zh-CN.md +102 -0
- package/package.json +8 -6
package/README.ja.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-pi</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Pi Agent の strict JSONL RPC mode を Harapter から実行します。</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/adapter-pi"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-pi/next?style=flat-square&label=npm%20next" alt="npm next バージョン"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-pi"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-pi?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/adapter-pi` は公式 Pi Agent `--mode rpc`
|
|
23
|
+
を Harapter に mapping します。Session ごとに独立 Process を使い、stream
|
|
24
|
+
Event、persisted Resume、native Abort を提供します。Extension、Skill、Prompt
|
|
25
|
+
Template discovery は無効化されます。
|
|
26
|
+
|
|
27
|
+
## 前提条件とインストール
|
|
28
|
+
|
|
29
|
+
Pi Agent の導入、設定、認証、Model、absolute executable
|
|
30
|
+
path はホストが所有します。Harapter は Session
|
|
31
|
+
File や Credential を読み取らず Runtime を導入しません。
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @harapter/core@next @harapter/adapter-pi@next
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## クイックスタート
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
41
|
+
import { PI_PROVIDER_ID, createPiProviderFactory } from '@harapter/adapter-pi';
|
|
42
|
+
|
|
43
|
+
const registry = new HarnessRegistry();
|
|
44
|
+
registry.register(createPiProviderFactory());
|
|
45
|
+
|
|
46
|
+
const client = await registry.connect({
|
|
47
|
+
profileId: profileId('pi-local'),
|
|
48
|
+
providerId: PI_PROVIDER_ID,
|
|
49
|
+
displayName: 'Pi Agent',
|
|
50
|
+
connection: {
|
|
51
|
+
kind: 'process',
|
|
52
|
+
command: '/opt/harapter-runtimes/bin/pi',
|
|
53
|
+
args: [],
|
|
54
|
+
ownership: 'adapter',
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const session = await client.createSession();
|
|
59
|
+
try {
|
|
60
|
+
const run = await session.start({
|
|
61
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
62
|
+
});
|
|
63
|
+
for await (const event of run.events()) console.log(event.type);
|
|
64
|
+
console.log((await run.result()).status);
|
|
65
|
+
} finally {
|
|
66
|
+
try {
|
|
67
|
+
await session.close();
|
|
68
|
+
} finally {
|
|
69
|
+
await client.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Process、Session、Run
|
|
75
|
+
|
|
76
|
+
- `--version` probe 後、Session ごとに独立 RPC Process を起動します;
|
|
77
|
+
- `--no-extensions --no-skills --no-prompt-templates --mode rpc` を追加します;
|
|
78
|
+
- `persistSessions: false` は `--no-session` を追加して Resume を無効にします;
|
|
79
|
+
- Resume は Native ID で新 Process を開き、同じ Session の返却を要求します;
|
|
80
|
+
- Workspace、System Context、Session Model、Metadata は unsupported です;
|
|
81
|
+
- Run は text のみで、複数 part は改行結合し、`/`
|
|
82
|
+
から始まる input は拒否します;
|
|
83
|
+
- `prompt` Response は受付だけで、`agent_settled` と最後の valid Assistant
|
|
84
|
+
`message_end` が terminal authority です;
|
|
85
|
+
- `run.cancel()` は `abort` Response と `stopReason: 'aborted'`
|
|
86
|
+
の相関で native になります;
|
|
87
|
+
- Tool ID は hash され、Tool Argument/Result は portable Event に残りません。
|
|
88
|
+
|
|
89
|
+
Pi Extension UI の select、confirm、input、editor は Provider
|
|
90
|
+
Interaction ですが、generic Approval/User Input
|
|
91
|
+
Capability にはしません。未知 Event は bounded redacted
|
|
92
|
+
observation に残り、Native Client は ownership-preserving read
|
|
93
|
+
command のみです。
|
|
94
|
+
|
|
95
|
+
## Compatibility と制限
|
|
96
|
+
|
|
97
|
+
Pi RPC は Runtime Version を返しますが negotiated protocol
|
|
98
|
+
version はありません。Version は lock せず、使用する Response、Event、Terminal
|
|
99
|
+
Structure を検証します。そのため状態は `experimental` ですが、real
|
|
100
|
+
completion、Resume、Native Cancel、cleanup の evidence はあります。
|
|
101
|
+
|
|
102
|
+
Image/File、Portable Model、Workspace、generic Approval、Runtime
|
|
103
|
+
Extension/Skill、shared Process、Session multiplex、auto restart、Session
|
|
104
|
+
File、任意 native mutation は対象外です。全 options、live test、検証 Version は
|
|
105
|
+
[英語の詳細ドキュメント](./README.md)を参照してください。
|
package/README.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-pi</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Run Pi Agent's strict JSONL RPC mode through Harapter.</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/adapter-pi"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-pi/next?style=flat-square&label=npm%20next" alt="npm next version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-pi"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-pi?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/adapter-pi` maps the official Pi Agent RPC mode to the portable
|
|
4
23
|
Harapter lifecycle.
|
|
@@ -8,6 +27,14 @@ starts only the exact adapter-owned command selected by the Profile. It does not
|
|
|
8
27
|
install a Pi Runtime or SDK, select models, manage credentials, read Session
|
|
9
28
|
files, or change host security policy.
|
|
10
29
|
|
|
30
|
+
## Use this Adapter when
|
|
31
|
+
|
|
32
|
+
- your host supplies the official Pi Agent executable in strict RPC mode;
|
|
33
|
+
- you need one isolated process per Session with streamed Events, persisted
|
|
34
|
+
resume, and native abort; or
|
|
35
|
+
- you want Pi-specific reads and UI interactions behind explicit native and
|
|
36
|
+
Provider-extension boundaries.
|
|
37
|
+
|
|
11
38
|
## Installation
|
|
12
39
|
|
|
13
40
|
```bash
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-pi</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>通过 Harapter 运行 Pi Agent 的严格 JSONL RPC 模式。</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/adapter-pi"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-pi/next?style=flat-square&label=npm%20next" alt="npm next 版本"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-pi"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-pi?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/adapter-pi` 将官方 Pi Agent `--mode rpc`
|
|
23
|
+
接口映射为 Harapter。每个 Session 使用独立进程,支持流式 Event、持久化 Resume 和原生 Abort,同时禁用 Extension、Skill 与 Prompt
|
|
24
|
+
Template 自动发现,防止普通文本绕过 Agent 生命周期。
|
|
25
|
+
|
|
26
|
+
## 前置条件与安装
|
|
27
|
+
|
|
28
|
+
宿主安装、配置并认证 Pi
|
|
29
|
+
Agent,选择模型和绝对可执行文件路径。Harapter 不读取 Session
|
|
30
|
+
File、不管理 Credential,也不会安装 Runtime。
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @harapter/core@next @harapter/adapter-pi@next
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 快速开始
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
40
|
+
import { PI_PROVIDER_ID, createPiProviderFactory } from '@harapter/adapter-pi';
|
|
41
|
+
|
|
42
|
+
const registry = new HarnessRegistry();
|
|
43
|
+
registry.register(createPiProviderFactory());
|
|
44
|
+
|
|
45
|
+
const client = await registry.connect({
|
|
46
|
+
profileId: profileId('pi-local'),
|
|
47
|
+
providerId: PI_PROVIDER_ID,
|
|
48
|
+
displayName: 'Pi Agent',
|
|
49
|
+
connection: {
|
|
50
|
+
kind: 'process',
|
|
51
|
+
command: '/opt/harapter-runtimes/bin/pi',
|
|
52
|
+
args: [],
|
|
53
|
+
ownership: 'adapter',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const session = await client.createSession();
|
|
58
|
+
try {
|
|
59
|
+
const run = await session.start({
|
|
60
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
61
|
+
});
|
|
62
|
+
for await (const event of run.events()) console.log(event.type);
|
|
63
|
+
console.log((await run.result()).status);
|
|
64
|
+
} finally {
|
|
65
|
+
try {
|
|
66
|
+
await session.close();
|
|
67
|
+
} finally {
|
|
68
|
+
await client.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 进程、Session 与 Run
|
|
74
|
+
|
|
75
|
+
- Adapter 探测 `--version`,再为每个 Session 启动独立 RPC Process;
|
|
76
|
+
- 自动追加 `--no-extensions --no-skills --no-prompt-templates --mode rpc`;
|
|
77
|
+
- `persistSessions: false` 会加 `--no-session` 并关闭 Resume;
|
|
78
|
+
- Resume 会用 Native ID 启动新进程,并要求 Runtime 返回相同 Session;
|
|
79
|
+
- Workspace、System Context、Session Model 与 Metadata 不受支持;
|
|
80
|
+
- Portable Run 只接受文本,多段文本用换行连接;以 `/` 开头的输入会被拒绝;
|
|
81
|
+
- `prompt` Response 只表示接受,`agent_settled` 和最后一个有效 Assistant
|
|
82
|
+
`message_end` 共同提供终态 Authority;
|
|
83
|
+
- `run.cancel()` 只有 `abort` Response 与 `stopReason: 'aborted'`
|
|
84
|
+
终态相关联时才是 Native Cancel;
|
|
85
|
+
- Tool ID 会散列,Tool Argument/Result 不进入 Portable Event。
|
|
86
|
+
|
|
87
|
+
Pi Extension UI 的 select、confirm、input 和 editor 会映射为 Provider
|
|
88
|
+
Interaction,但不被提升为通用 Approval 或 User Input
|
|
89
|
+
Capability。未知 Event 会进入有界、脱敏的 Observation;Native
|
|
90
|
+
Client 只提供保持所有权的只读命令。
|
|
91
|
+
|
|
92
|
+
## 兼容性与限制
|
|
93
|
+
|
|
94
|
+
Pi RPC 会报告语义化 Runtime
|
|
95
|
+
Version,但没有可协商的协议版本。Adapter 不锁版本,会校验每个实际使用的 Response、Event 和 Terminal
|
|
96
|
+
Structure;因此当前状态为 `experimental`,同时已有真实完成、Resume、Native
|
|
97
|
+
Cancel 与清理 Evidence。
|
|
98
|
+
|
|
99
|
+
不支持 Image/File Input、Portable Model、Workspace、通用 Approval、Runtime
|
|
100
|
+
Extension/Skill、共享 Process、多 Session Multiplex、自动重启、Session File
|
|
101
|
+
Access 或任意 Native Mutation。完整 Options、Live Test 和最后验证版本见
|
|
102
|
+
[英文详细文档](./README.md)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harapter/adapter-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pi Agent RPC provider adapter for Harapter.",
|
|
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/providers/pi#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,11 +43,11 @@
|
|
|
41
43
|
"tag": "next"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@harapter/core": "0.1.
|
|
45
|
-
"@harapter/transport-jsonl-process": "0.1.
|
|
46
|
+
"@harapter/core": "0.1.2",
|
|
47
|
+
"@harapter/transport-jsonl-process": "0.1.2"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@harapter/conformance": "0.1.
|
|
50
|
+
"@harapter/conformance": "0.1.2"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
53
|
"build": "tsc --project tsconfig.build.json"
|