@harapter/transport-jsonl-process 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 +81 -0
- package/README.md +29 -2
- package/README.zh-CN.md +74 -0
- package/package.json +5 -3
package/README.ja.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-jsonl-process</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>process-based Harness protocol 向けの strict bounded JSONL transport。</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-jsonl-process"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-jsonl-process/next?style=flat-square&label=npm%20next" alt="npm next バージョン"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-jsonl-process"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-jsonl-process?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
|
+
非 JSON-RPC の process protocol に、strict JSONL
|
|
23
|
+
framing、順序付き inbound、serialized
|
|
24
|
+
write、backpressure、timeout、cleanup を提供します。process 起動、request
|
|
25
|
+
correlation、message の意味、redaction、Harapter mapping は Provider
|
|
26
|
+
Adapter が所有します。
|
|
27
|
+
|
|
28
|
+
## インストール
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add @harapter/transport-jsonl-process@next
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## クイックスタート
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { JsonlProcessTransport } from '@harapter/transport-jsonl-process';
|
|
38
|
+
|
|
39
|
+
const transport = new JsonlProcessTransport({
|
|
40
|
+
readable: controlledProcess.stdout,
|
|
41
|
+
writable: controlledProcess.stdin,
|
|
42
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const incoming = (async () => {
|
|
46
|
+
for await (const message of transport.incoming()) {
|
|
47
|
+
await validateAndMapProviderMessage(message);
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
|
|
51
|
+
await transport.send({ id: 'request-1', type: 'prompt', message: 'Hello' });
|
|
52
|
+
await transport.close();
|
|
53
|
+
await incoming;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 動作境界
|
|
57
|
+
|
|
58
|
+
- 一つの UTF-8 JSON object を一つの LF record とし、CRLF も受け入れます;
|
|
59
|
+
- 空 record、array、primitive、無効 UTF-8、不正 JSON、切れた最終 record は失敗します;
|
|
60
|
+
- 既定値は message 1 MiB、未読 message 128、pending write 128、write wait
|
|
61
|
+
30 秒です;
|
|
62
|
+
- `send()` 成功は Node write
|
|
63
|
+
callback の完了だけを示し、Provider の受理や完了を示しません;
|
|
64
|
+
- `incoming()` の consumer は一つだけで、consumer 終了は logical
|
|
65
|
+
connection を閉じます。
|
|
66
|
+
|
|
67
|
+
Stream は呼び出し側が所有します。Transport は spawn、kill、restart、end、destroy を行いません。任意の
|
|
68
|
+
`cleanup`
|
|
69
|
+
は明示 close または終端 failure 後に最大一回だけ実行されます。timeout と
|
|
70
|
+
`AbortSignal` は local write wait のみを制御します。
|
|
71
|
+
|
|
72
|
+
## Error と安全性
|
|
73
|
+
|
|
74
|
+
`JsonlTransportError` は固定の content-free
|
|
75
|
+
message を使い、frame、ID、path、Stream Error、Provider
|
|
76
|
+
Payload を保持しません。inbound object は untrusted
|
|
77
|
+
data なので、Event、Error、Fixture、log にする前に Adapter が検証・redact します。
|
|
78
|
+
|
|
79
|
+
process manager、request/response protocol、Provider Adapter、retry layer、Agent
|
|
80
|
+
Loop ではありません。全設定と lifecycle は[英語の詳細ドキュメント](./README.md)
|
|
81
|
+
を参照してください。
|
package/README.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-jsonl-process</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Strict, bounded JSONL messaging for process-backed harness protocols.</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-jsonl-process"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-jsonl-process/next?style=flat-square&label=npm%20next" alt="npm next version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-jsonl-process"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-jsonl-process?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-jsonl-process` is a bounded strict-JSONL transport for
|
|
4
23
|
Provider Adapters that communicate with a host-supplied harness process.
|
|
@@ -9,6 +28,14 @@ limits. It does not spawn or discover executables, correlate protocol requests,
|
|
|
9
28
|
interpret Provider messages, or assign Harapter Session, Run, Event, error, or
|
|
10
29
|
cancellation semantics.
|
|
11
30
|
|
|
31
|
+
## Use this package when
|
|
32
|
+
|
|
33
|
+
- a harness exchanges one JSON object per line without JSON-RPC correlation;
|
|
34
|
+
- your Adapter owns the process protocol but needs safe framing, bounded queues,
|
|
35
|
+
serialized writes, and cleanup; or
|
|
36
|
+
- malformed, oversized, or truncated input must fail closed without leaking the
|
|
37
|
+
original payload.
|
|
38
|
+
|
|
12
39
|
## Installation
|
|
13
40
|
|
|
14
41
|
```bash
|
|
@@ -75,7 +102,7 @@ contain sensitive data. The consuming Provider Adapter must validate and redact
|
|
|
75
102
|
them before producing Harapter events, errors, diagnostics, logs, fixtures, or
|
|
76
103
|
raw-channel observations.
|
|
77
104
|
|
|
78
|
-
##
|
|
105
|
+
## Quick start
|
|
79
106
|
|
|
80
107
|
```ts
|
|
81
108
|
import { JsonlProcessTransport } from '@harapter/transport-jsonl-process';
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/transport-jsonl-process</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>面向进程型 Harness 协议的严格、有界 JSONL 传输。</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-jsonl-process"><img src="https://img.shields.io/npm/v/%40harapter%2Ftransport-jsonl-process/next?style=flat-square&label=npm%20next" alt="npm next 版本"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/transport-jsonl-process"><img src="https://img.shields.io/npm/dm/%40harapter%2Ftransport-jsonl-process?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
|
+
这个包为非 JSON-RPC 的进程协议提供严格 JSONL
|
|
23
|
+
framing、有序入站迭代、串行写入、背压、超时和清理。Provider
|
|
24
|
+
Adapter 仍然负责启动进程、关联请求、解释消息、脱敏以及映射 Harapter 生命周期。
|
|
25
|
+
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @harapter/transport-jsonl-process@next
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { JsonlProcessTransport } from '@harapter/transport-jsonl-process';
|
|
36
|
+
|
|
37
|
+
const transport = new JsonlProcessTransport({
|
|
38
|
+
readable: controlledProcess.stdout,
|
|
39
|
+
writable: controlledProcess.stdin,
|
|
40
|
+
cleanup: () => stopControlledProcess(controlledProcess),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const incoming = (async () => {
|
|
44
|
+
for await (const message of transport.incoming()) {
|
|
45
|
+
await validateAndMapProviderMessage(message);
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
|
|
49
|
+
await transport.send({ id: 'request-1', type: 'prompt', message: 'Hello' });
|
|
50
|
+
await transport.close();
|
|
51
|
+
await incoming;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 行为边界
|
|
55
|
+
|
|
56
|
+
- 每条记录必须是一个 UTF-8 JSON 对象,以 LF 结尾;CRLF 也可接受;
|
|
57
|
+
- 空记录、array、primitive、无效 UTF-8、畸形 JSON 和截断的尾记录会关闭连接;
|
|
58
|
+
- 默认消息 1 MiB、未读消息 128、待写操作 128,写等待 30 秒;
|
|
59
|
+
- `send()` 成功只表示 Node 写回调完成,不表示 Provider 已接受或完成工作;
|
|
60
|
+
- 只有一个调用方可以消费 `incoming()`,停止消费会关闭逻辑连接。
|
|
61
|
+
|
|
62
|
+
调用方拥有 Stream。Transport 不会 spawn、kill、restart、end 或 destroy;可选
|
|
63
|
+
`cleanup` 由显式关闭或终态失败触发,最多执行一次。timeout 与 `AbortSignal`
|
|
64
|
+
仅控制本地写等待,不会发出 Provider 取消。
|
|
65
|
+
|
|
66
|
+
## 错误与安全
|
|
67
|
+
|
|
68
|
+
`JsonlTransportError`
|
|
69
|
+
使用固定、不含内容的错误消息,不保留 frame、标识符、路径、Stream
|
|
70
|
+
Error 或 Provider
|
|
71
|
+
Payload。入站对象仍是不可信数据,必须由 Adapter 在生成 Event、Error、Fixture 或日志前校验和脱敏。
|
|
72
|
+
|
|
73
|
+
该包不是进程管理器、请求响应协议、Provider Adapter、重试层或 Agent
|
|
74
|
+
Loop。完整配置和生命周期细节见[英文详细文档](./README.md)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harapter/transport-jsonl-process",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Bounded strict JSONL transport for Harapter process 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-jsonl-process#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",
|