@harapter/adapter-hermes 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 +108 -0
- package/README.md +28 -1
- package/README.zh-CN.md +101 -0
- package/package.json +8 -6
package/README.ja.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-hermes</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Hermes Agent API Server を HTTP/SSE で 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-hermes"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-hermes/next?style=flat-square&label=npm%20next" alt="npm next バージョン"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-hermes"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-hermes?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-hermes` は公式 Hermes Agent API
|
|
23
|
+
Server の Session、Run、Status、SSE
|
|
24
|
+
Event、Stop、Approval を Harapter に mapping します。Hermes の導入、認証、起動、停止、設定はホストが所有し、Adapter は指定 HTTP
|
|
25
|
+
Endpoint にだけ接続します。
|
|
26
|
+
|
|
27
|
+
## インストール
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @harapter/core@next @harapter/adapter-hermes@next
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## クイックスタート
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
37
|
+
import {
|
|
38
|
+
HERMES_PROVIDER_ID,
|
|
39
|
+
createHermesProviderFactory,
|
|
40
|
+
} from '@harapter/adapter-hermes';
|
|
41
|
+
|
|
42
|
+
const registry = new HarnessRegistry();
|
|
43
|
+
registry.register(createHermesProviderFactory());
|
|
44
|
+
|
|
45
|
+
const client = await registry.connect({
|
|
46
|
+
profileId: profileId('hermes-local'),
|
|
47
|
+
providerId: HERMES_PROVIDER_ID,
|
|
48
|
+
displayName: 'Hermes Agent',
|
|
49
|
+
connection: {
|
|
50
|
+
kind: 'endpoint',
|
|
51
|
+
url: 'http://127.0.0.1:8642/',
|
|
52
|
+
transport: 'http',
|
|
53
|
+
ownership: 'host',
|
|
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
|
+
認証する場合、Factory にホスト実装の `resolveAuthHeaders` を渡し、Connection は
|
|
74
|
+
`authRef`
|
|
75
|
+
だけを保持します。Harapter は実 Header を読み取り・出力・保存しません。
|
|
76
|
+
|
|
77
|
+
## Session と Run
|
|
78
|
+
|
|
79
|
+
- Connection は `/v1/capabilities` で必要 Route を宣言する必要があります;
|
|
80
|
+
- Session 作成は System Context と Model を受け、Resume は native
|
|
81
|
+
ownership を再検証します;
|
|
82
|
+
- Workspace は unsupported、close は local handle の解放だけです;
|
|
83
|
+
- Session ごとに active Run は一つで、現在の portable input は text のみです;
|
|
84
|
+
- Submit Ack は終端ではなく、SSE と Run Status Route を照合します;
|
|
85
|
+
- `completed` は Session/Run ownership と最後の `run.completed`
|
|
86
|
+
evidence も必要です;
|
|
87
|
+
- SSE
|
|
88
|
+
EOF、disconnect、重複・矛盾 terminal、不正 payload は success になりません;
|
|
89
|
+
- Stop と Approval は Runtime が feature と exact
|
|
90
|
+
Route を宣言した時だけ利用できます。
|
|
91
|
+
|
|
92
|
+
non-idempotent
|
|
93
|
+
mutation の response が失われると Session を quarantine し、安全でない retry を防ぎます。Harapter
|
|
94
|
+
timeout は emulated control で、Provider の authoritative `cancelled`
|
|
95
|
+
Status だけが cancellation terminal です。
|
|
96
|
+
|
|
97
|
+
## Compatibility と制限
|
|
98
|
+
|
|
99
|
+
Capability は Provider 名や Version ではなく `/v1/capabilities`
|
|
100
|
+
から得ます。Lifecycle authority に使う Response と SSE Event はすべて runtime
|
|
101
|
+
validation されます。API Server は protocol version negotiation を持たないため
|
|
102
|
+
`experimental` ですが、実 Runtime の completion、Resume、Native
|
|
103
|
+
Cancel は検証済みです。新 Version は試行し、不互換 structure で fail
|
|
104
|
+
closed します。
|
|
105
|
+
|
|
106
|
+
Portable Workspace、remote Session delete、automatic SSE
|
|
107
|
+
reconnect、未宣言 Route は対象外です。全 options、Approval、Native Client、live
|
|
108
|
+
test、検証 Version は [英語の詳細ドキュメント](./README.md)を参照してください。
|
package/README.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-hermes</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Connect the Hermes Agent API Server to Harapter over HTTP and SSE.</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-hermes"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-hermes/next?style=flat-square&label=npm%20next" alt="npm next version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-hermes"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-hermes?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-hermes` maps the official Hermes Agent API Server HTTP and
|
|
4
23
|
Server-Sent Events interface to the portable Harapter lifecycle.
|
|
@@ -8,6 +27,14 @@ The Adapter connects only to a host-selected endpoint. It does not install the
|
|
|
8
27
|
Hermes Agent Runtime or SDK, start a server, configure models or tools, or own
|
|
9
28
|
the host security policy.
|
|
10
29
|
|
|
30
|
+
## Use this Adapter when
|
|
31
|
+
|
|
32
|
+
- your host operates the official Hermes Agent API Server;
|
|
33
|
+
- you need HTTP Session creation and Run submission with SSE progress behind the
|
|
34
|
+
portable lifecycle; or
|
|
35
|
+
- endpoint credentials, model configuration, and server ownership must remain
|
|
36
|
+
controlled by the host.
|
|
37
|
+
|
|
11
38
|
## Installation
|
|
12
39
|
|
|
13
40
|
```bash
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-hermes</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>通过 HTTP 与 SSE 把 Hermes Agent API Server 接入 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.zh-CN.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-hermes"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-hermes/next?style=flat-square&label=npm%20next" alt="npm next 版本"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-hermes"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-hermes?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-hermes` 把 Hermes Agent 官方 API
|
|
23
|
+
Server 的 Session、Run、状态查询、SSE
|
|
24
|
+
Event、Stop 和 Approval 映射为 Harapter。宿主负责安装、认证、启动、停止和配置 Hermes
|
|
25
|
+
Agent;Adapter 只连接指定 HTTP Endpoint。
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @harapter/core@next @harapter/adapter-hermes@next
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
37
|
+
import {
|
|
38
|
+
HERMES_PROVIDER_ID,
|
|
39
|
+
createHermesProviderFactory,
|
|
40
|
+
} from '@harapter/adapter-hermes';
|
|
41
|
+
|
|
42
|
+
const registry = new HarnessRegistry();
|
|
43
|
+
registry.register(createHermesProviderFactory());
|
|
44
|
+
|
|
45
|
+
const client = await registry.connect({
|
|
46
|
+
profileId: profileId('hermes-local'),
|
|
47
|
+
providerId: HERMES_PROVIDER_ID,
|
|
48
|
+
displayName: 'Hermes Agent',
|
|
49
|
+
connection: {
|
|
50
|
+
kind: 'endpoint',
|
|
51
|
+
url: 'http://127.0.0.1:8642/',
|
|
52
|
+
transport: 'http',
|
|
53
|
+
ownership: 'host',
|
|
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
|
+
需要认证时,Factory 接收宿主实现的 `resolveAuthHeaders`,Connection 只保存
|
|
74
|
+
`authRef`。Harapter 不读取、打印或持久化真实 Header。
|
|
75
|
+
|
|
76
|
+
## Session 与 Run
|
|
77
|
+
|
|
78
|
+
- Connection 必须通过 `/v1/capabilities` 声明 Adapter 使用的 Route;
|
|
79
|
+
- Session 创建可传 System Context 和 Model;Resume 会重新校验 Native
|
|
80
|
+
Session 与所有权;
|
|
81
|
+
- Workspace 不受支持,`session.close()` 只释放 Handle,不删除远端 Session;
|
|
82
|
+
- 一个 Session 同时只有一个 Run,输入目前只支持文本;
|
|
83
|
+
- Submit Ack 不是终态,Adapter 会消费 SSE 并用 Run Status Route 做权威对账;
|
|
84
|
+
- `completed` 还必须匹配 Session、Run 与最后的 `run.completed` Evidence;
|
|
85
|
+
- SSE EOF、断连、重复或矛盾终态、畸形 Payload 都不会变成成功;
|
|
86
|
+
- Stop 和 Approval 只在 Runtime 明确声明对应 Feature 与 Route 时提供。
|
|
87
|
+
|
|
88
|
+
非幂等 Mutation 在响应丢失或结果不确定后会隔离 Session,避免不安全重试。Timeout 由 Harapter 发起时属于模拟控制;只有 Provider 权威
|
|
89
|
+
`cancelled` Status 才是取消终态。
|
|
90
|
+
|
|
91
|
+
## 兼容性与限制
|
|
92
|
+
|
|
93
|
+
Capability 来自实际 `/v1/capabilities`
|
|
94
|
+
响应,而不是 Hermes 名称或版本。每个用于生命周期判断的 Response 与 SSE
|
|
95
|
+
Event 都会进行结构校验。API Server 没有协议版本协商,所以 Adapter 保持
|
|
96
|
+
`experimental`;已记录真实 Runtime 完成、Resume 与 Native Cancel
|
|
97
|
+
Evidence,新版本默认尝试并在不兼容结构处 fail closed。
|
|
98
|
+
|
|
99
|
+
目前不支持 Portable Workspace、Remote Session Delete、自动 SSE
|
|
100
|
+
Reconnect 或未声明 Route。完整 Provider Options、Approval、Native Client、Live
|
|
101
|
+
Test 和最后验证版本见 [英文详细文档](./README.md)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harapter/adapter-hermes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Hermes Agent HTTP and SSE 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/hermes#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-http-sse": "0.1.
|
|
46
|
+
"@harapter/core": "0.1.2",
|
|
47
|
+
"@harapter/transport-http-sse": "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"
|