@roll-agent/protocol 0.0.0

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.md ADDED
@@ -0,0 +1,58 @@
1
+ # `@roll-agent/protocol`
2
+
3
+ Roll Runtime Protocol v1 的 TypeScript Schema、类型与跨语言 JSON Schema。
4
+
5
+ 这个包只定义公共领域契约,不启动 Runtime,也不提供 Transport。Node.js 宿主可配合
6
+ [`@roll-agent/client-node`](https://www.npmjs.com/package/@roll-agent/client-node) 使用;
7
+ 其他技术栈可直接实现 JSON-RPC + NDJSON + stdio Transport。
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ pnpm add @roll-agent/protocol
13
+ ```
14
+
15
+ ## TypeScript API
16
+
17
+ ```ts
18
+ import {
19
+ RUNTIME_METHODS,
20
+ RUNTIME_PROTOCOL_VERSION,
21
+ parseRuntimeMethodParams,
22
+ type RuntimeEventEnvelope,
23
+ } from "@roll-agent/protocol";
24
+
25
+ const params = parseRuntimeMethodParams(RUNTIME_METHODS.threadSnapshot, {
26
+ threadId: "00000000-0000-4000-8000-000000000001",
27
+ limit: 100,
28
+ });
29
+
30
+ console.log(RUNTIME_PROTOCOL_VERSION, params);
31
+
32
+ function handleEvent(event: RuntimeEventEnvelope): void {
33
+ console.log(event.event.type);
34
+ }
35
+ ```
36
+
37
+ 主要导出包括:
38
+
39
+ - 协议常量:`RUNTIME_PROTOCOL_VERSION`、`RUNTIME_METHODS`、`RUNTIME_FEATURES`、
40
+ `RUNTIME_ERROR_CODES`;
41
+ - 全部 Zod Schema 与派生类型;
42
+ - `runtimeMethodSchemas`、`parseRuntimeMethodParams()`、
43
+ `parseRuntimeMethodResult()`;
44
+ - JSON-RPC 与 Runtime Event Envelope 类型。
45
+
46
+ ## JSON Schema 与 fixtures
47
+
48
+ - `@roll-agent/protocol/schema`:JSON Schema Draft 2020-12 根 Schema;
49
+ - `@roll-agent/protocol/fixtures/v1/*`:跨语言有效/无效消息 fixtures。
50
+
51
+ 协议版本与 npm 包版本相互独立;Runtime Protocol v1 的 wire version 是 `"1.0"`。
52
+
53
+ ## 文档
54
+
55
+ - [Runtime Protocol v1 参考](https://github.com/steveoon/roll-agent/blob/main/docs/runtime-protocol-v1-reference.md)
56
+ - [架构与安全边界](https://github.com/steveoon/roll-agent/blob/main/docs/runtime-protocol-architecture.md)
57
+ - [创建第一个 Runtime UI 客户端](https://github.com/steveoon/roll-agent/blob/main/docs/tutorial-runtime-ui-quickstart.md)
58
+ - [使用自己的技术栈接入 Roll](https://github.com/steveoon/roll-agent/blob/main/docs/how-to-build-roll-runtime-ui.md)