@roll-agent/protocol 0.6.0 → 0.6.1
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 +6 -5
- package/dist/index.js +20 -4
- package/fixtures/v1.4/invalid-attachment-stage-sha256-request.json +14 -0
- package/fixtures/v1.4/invalid-turn-start-too-many-attachments-request.json +24 -0
- package/fixtures/v1.4/valid-attachment-chunk-request.json +12 -0
- package/fixtures/v1.4/valid-attachment-commit-request.json +10 -0
- package/fixtures/v1.4/valid-attachment-commit-response.json +16 -0
- package/fixtures/v1.4/valid-attachment-release-request.json +10 -0
- package/fixtures/v1.4/valid-attachment-stage-request.json +14 -0
- package/fixtures/v1.4/valid-attachment-stage-response.json +8 -0
- package/fixtures/v1.4/valid-initialize-response.json +34 -0
- package/fixtures/v1.4/valid-runtime-durable-event-notification.json +20 -0
- package/fixtures/v1.4/valid-thread-snapshot-attachment-part-response.json +44 -0
- package/fixtures/v1.4/valid-turn-start-with-attachments-request.json +14 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -86,22 +86,23 @@ function handleEvent(event: RuntimeEventEnvelopeV13): void {
|
|
|
86
86
|
|
|
87
87
|
- `@roll-agent/protocol/schema` 与 `@roll-agent/protocol/schema/latest`:最新版本
|
|
88
88
|
JSON Schema Draft 2020-12 根 Schema;
|
|
89
|
-
- `@roll-agent/protocol/schema/1.3`、`/1.2`、`/1.1`、`/1.0`:严格按协商版本隔离的 Schema;
|
|
89
|
+
- `@roll-agent/protocol/schema/1.4`、`/1.3`、`/1.2`、`/1.1`、`/1.0`:严格按协商版本隔离的 Schema;
|
|
90
|
+
- `@roll-agent/protocol/fixtures/v1.4/*`:Protocol 1.4 attachment / turn.start / snapshot fixtures;
|
|
90
91
|
- `@roll-agent/protocol/fixtures/v1.3/*`:Protocol 1.3 durable event/replay fixtures;
|
|
91
92
|
- `@roll-agent/protocol/fixtures/v1/*`:冻结的 1.1/1.0 跨语言有效/无效消息 fixtures。
|
|
92
93
|
- `@roll-agent/protocol/fixtures/v1.2/*`:Protocol 1.2 capability/interaction fixtures。
|
|
93
94
|
|
|
94
95
|
协议版本与 npm 包版本相互独立。`RUNTIME_PROTOCOL_VERSION` 表示这个包提供的最新 wire
|
|
95
96
|
schema,并不代表调用方已实现对应 Client 能力。当前支持顺序为
|
|
96
|
-
`["1.3", "1.2", "1.1", "1.0"]`。`initialize` 请求保持旧 strict 形状;协商到 `"1.2"
|
|
97
|
-
或 `"1.
|
|
97
|
+
`["1.4", "1.3", "1.2", "1.1", "1.0"]`。`initialize` 请求保持旧 strict 形状;协商到 `"1.2"`、
|
|
98
|
+
`"1.3"` 或 `"1.4"` 后,
|
|
98
99
|
Client 必须用 `client.capabilities.set` 提交单调 `revision` 与当前 Handler methods,Runtime
|
|
99
100
|
返回 registry 交集后才进入 interaction-ready。ACK 可以为空或为请求集的任意子集,顺序按
|
|
100
101
|
Runtime registry;Client 必须按集合语义处理。未知的未来 method 名可安全发送但不会被接受。
|
|
101
102
|
|
|
102
|
-
广告 `"1.3"` 同时声明 Client 能接收至少 `17 MiB` 的单个 Runtime→Client NDJSON 帧:
|
|
103
|
+
广告 `"1.4"` 或 `"1.3"` 同时声明 Client 能接收至少 `17 MiB` 的单个 Runtime→Client NDJSON 帧:
|
|
103
104
|
durable record 的绝对上限为 `16 MiB`,额外 1 MiB 留给 envelope 与 JSON-RPC 元数据。本地
|
|
104
|
-
入站预算低于 17 MiB 的 Client
|
|
105
|
+
入站预算低于 17 MiB 的 Client 必须同时省略 `"1.4"` 与 `"1.3"`。这不会扩大 Client→Runtime 出站额度;
|
|
105
106
|
初始化后的出站上限仍取本地预算与 Runtime 返回的 `limits.maxFrameBytes` 的较小值。
|
|
106
107
|
官方 Node 恢复管理器的默认 replay 暂存窗口为 10,000 条 / 32 MiB。
|
|
107
108
|
|
package/dist/index.js
CHANGED
|
@@ -129,6 +129,19 @@ export const REQUIRED_RUNTIME_SERVER_REQUEST_METHODS_BY_VERSION = {
|
|
|
129
129
|
export function getRuntimeProtocolCapabilities(version) {
|
|
130
130
|
return RUNTIME_PROTOCOL_CAPABILITIES[version];
|
|
131
131
|
}
|
|
132
|
+
const RUNTIME_SERVER_REQUEST_WIRE_SHAPES = {
|
|
133
|
+
interaction: "interaction",
|
|
134
|
+
legacy: "legacy",
|
|
135
|
+
};
|
|
136
|
+
function resolveRuntimeServerRequestWireShape(version) {
|
|
137
|
+
const capabilities = getRuntimeProtocolCapabilities(version);
|
|
138
|
+
if (!capabilities.serverRequests) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return capabilities.serverRequestCapabilityNegotiation
|
|
142
|
+
? RUNTIME_SERVER_REQUEST_WIRE_SHAPES.interaction
|
|
143
|
+
: RUNTIME_SERVER_REQUEST_WIRE_SHAPES.legacy;
|
|
144
|
+
}
|
|
132
145
|
export function isRuntimeServerRequestMethodRequired(version, method) {
|
|
133
146
|
return getRuntimeProtocolCapabilities(version).requiredServerRequestMethods.some((requiredMethod) => requiredMethod === method);
|
|
134
147
|
}
|
|
@@ -2121,10 +2134,12 @@ export function parseRuntimeProtocolErrorDataForVersion(version, value) {
|
|
|
2121
2134
|
}
|
|
2122
2135
|
export function projectRuntimeServerRequestParams(version, method, value) {
|
|
2123
2136
|
const latest = parseRuntimeServerRequestParamsForVersion("1.3", method, value);
|
|
2124
|
-
|
|
2137
|
+
const shape = resolveRuntimeServerRequestWireShape(version);
|
|
2138
|
+
if (shape === RUNTIME_SERVER_REQUEST_WIRE_SHAPES.interaction) {
|
|
2125
2139
|
return latest;
|
|
2126
2140
|
}
|
|
2127
|
-
if (
|
|
2141
|
+
if (shape === RUNTIME_SERVER_REQUEST_WIRE_SHAPES.legacy &&
|
|
2142
|
+
method === RUNTIME_SERVER_REQUEST_METHODS.approvalRequest) {
|
|
2128
2143
|
const approval = approvalRequestParamsV12Schema.parse(latest);
|
|
2129
2144
|
return approvalRequestParamsV11Schema.parse({
|
|
2130
2145
|
threadId: approval.threadId,
|
|
@@ -2136,13 +2151,14 @@ export function projectRuntimeServerRequestParams(version, method, value) {
|
|
|
2136
2151
|
}
|
|
2137
2152
|
export function projectRuntimeServerRequestCancelParams(version, value) {
|
|
2138
2153
|
const input = runtimeServerRequestCancelProjectionInputSchema.parse(value);
|
|
2139
|
-
|
|
2154
|
+
const shape = resolveRuntimeServerRequestWireShape(version);
|
|
2155
|
+
if (shape === RUNTIME_SERVER_REQUEST_WIRE_SHAPES.interaction) {
|
|
2140
2156
|
return runtimeServerRequestCancelParamsV12Schema.parse({
|
|
2141
2157
|
interactionId: input.interactionId,
|
|
2142
2158
|
reason: input.reason,
|
|
2143
2159
|
});
|
|
2144
2160
|
}
|
|
2145
|
-
if (
|
|
2161
|
+
if (shape === RUNTIME_SERVER_REQUEST_WIRE_SHAPES.legacy) {
|
|
2146
2162
|
return runtimeServerRequestCancelParamsV11Schema.parse({
|
|
2147
2163
|
serverRequestId: input.serverRequestId,
|
|
2148
2164
|
...(input.approvalId === undefined ? {} : { approvalId: input.approvalId }),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 26,
|
|
4
|
+
"method": "attachment.stage",
|
|
5
|
+
"params": {
|
|
6
|
+
"requestId": "00000000-0000-4000-8000-0000000000b1",
|
|
7
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
8
|
+
"fileName": "diagram.png",
|
|
9
|
+
"mediaType": "image/png",
|
|
10
|
+
"bytes": 2048,
|
|
11
|
+
"sha256": "not-a-sha256",
|
|
12
|
+
"source": "chunks"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 25,
|
|
4
|
+
"method": "turn.start",
|
|
5
|
+
"params": {
|
|
6
|
+
"requestId": "00000000-0000-4000-8000-0000000000b5",
|
|
7
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
8
|
+
"turnId": "00000000-0000-4000-8000-000000000003",
|
|
9
|
+
"input": {
|
|
10
|
+
"text": "too many",
|
|
11
|
+
"attachments": [
|
|
12
|
+
"00000000-0000-4000-8000-0000000000a1",
|
|
13
|
+
"00000000-0000-4000-8000-0000000000a2",
|
|
14
|
+
"00000000-0000-4000-8000-0000000000a3",
|
|
15
|
+
"00000000-0000-4000-8000-0000000000a4",
|
|
16
|
+
"00000000-0000-4000-8000-0000000000a5",
|
|
17
|
+
"00000000-0000-4000-8000-0000000000a6",
|
|
18
|
+
"00000000-0000-4000-8000-0000000000a7",
|
|
19
|
+
"00000000-0000-4000-8000-0000000000a8",
|
|
20
|
+
"00000000-0000-4000-8000-0000000000a9"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 21,
|
|
4
|
+
"method": "attachment.chunk",
|
|
5
|
+
"params": {
|
|
6
|
+
"requestId": "00000000-0000-4000-8000-0000000000b2",
|
|
7
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
8
|
+
"attachmentId": "00000000-0000-4000-8000-0000000000a1",
|
|
9
|
+
"sequence": 0,
|
|
10
|
+
"dataBase64": "iVBORw0KGgo="
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 22,
|
|
4
|
+
"result": {
|
|
5
|
+
"descriptor": {
|
|
6
|
+
"attachmentId": "00000000-0000-4000-8000-0000000000a1",
|
|
7
|
+
"fileName": "diagram.png",
|
|
8
|
+
"displayName": "diagram.png",
|
|
9
|
+
"mediaType": "image/png",
|
|
10
|
+
"bytes": 2048,
|
|
11
|
+
"sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
12
|
+
"source": "chunks",
|
|
13
|
+
"createdAt": "2026-08-21T12:00:00.000Z"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 20,
|
|
4
|
+
"method": "attachment.stage",
|
|
5
|
+
"params": {
|
|
6
|
+
"requestId": "00000000-0000-4000-8000-0000000000b1",
|
|
7
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
8
|
+
"fileName": "diagram.png",
|
|
9
|
+
"mediaType": "image/png",
|
|
10
|
+
"bytes": 2048,
|
|
11
|
+
"sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
12
|
+
"source": "chunks"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 1,
|
|
4
|
+
"result": {
|
|
5
|
+
"protocolVersion": "1.4",
|
|
6
|
+
"runtimeInstanceId": "00000000-0000-4000-8000-000000000001",
|
|
7
|
+
"server": {
|
|
8
|
+
"name": "roll-runtime",
|
|
9
|
+
"version": "0.18.0",
|
|
10
|
+
"runtimeVersion": "0.18.0"
|
|
11
|
+
},
|
|
12
|
+
"features": [
|
|
13
|
+
"thread-management",
|
|
14
|
+
"snapshots",
|
|
15
|
+
"turns",
|
|
16
|
+
"approvals",
|
|
17
|
+
"tool-streaming",
|
|
18
|
+
"reasoning-summary",
|
|
19
|
+
"operation-projection",
|
|
20
|
+
"process-local-sequence",
|
|
21
|
+
"attachments"
|
|
22
|
+
],
|
|
23
|
+
"limits": {
|
|
24
|
+
"maxFrameBytes": 4194304,
|
|
25
|
+
"maxPageSize": 500,
|
|
26
|
+
"eventReplay": true,
|
|
27
|
+
"idempotencyCacheEntries": 10000,
|
|
28
|
+
"maxAttachmentBytes": 16777216,
|
|
29
|
+
"maxAttachmentChunkBytes": 2097152,
|
|
30
|
+
"maxTurnAttachments": 8,
|
|
31
|
+
"maxStagedAttachments": 16
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"method": "runtime.event",
|
|
4
|
+
"params": {
|
|
5
|
+
"protocolVersion": "1.4",
|
|
6
|
+
"runtimeInstanceId": "00000000-0000-4000-8000-000000000001",
|
|
7
|
+
"sequence": 8,
|
|
8
|
+
"timestamp": "2026-07-30T12:00:00.000Z",
|
|
9
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
10
|
+
"turnId": "00000000-0000-4000-8000-000000000003",
|
|
11
|
+
"durability": "durable",
|
|
12
|
+
"eventId": "00000000-0000-4000-8000-000000000007",
|
|
13
|
+
"cursor": "rte1:00000000-0000-4000-8000-000000000008:0:00000000-0000-4000-8000-000000000007",
|
|
14
|
+
"event": {
|
|
15
|
+
"type": "message.completed",
|
|
16
|
+
"streamId": "00000000-0000-4000-8000-000000000004",
|
|
17
|
+
"text": "hello"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 27,
|
|
4
|
+
"result": {
|
|
5
|
+
"thread": {
|
|
6
|
+
"id": "00000000-0000-4000-8000-000000000002",
|
|
7
|
+
"title": "Attachment transcript",
|
|
8
|
+
"model": "fixture-model",
|
|
9
|
+
"createdAt": "2026-08-21T12:00:00.000Z",
|
|
10
|
+
"updatedAt": "2026-08-21T12:00:00.000Z",
|
|
11
|
+
"messageCount": 1
|
|
12
|
+
},
|
|
13
|
+
"messages": {
|
|
14
|
+
"items": [
|
|
15
|
+
{
|
|
16
|
+
"sequence": 0,
|
|
17
|
+
"role": "user",
|
|
18
|
+
"createdAt": "2026-08-21T12:00:00.000Z",
|
|
19
|
+
"parts": [
|
|
20
|
+
{
|
|
21
|
+
"type": "text",
|
|
22
|
+
"text": "看看这张图"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "attachment",
|
|
26
|
+
"mediaType": "image/png",
|
|
27
|
+
"bytes": 2048,
|
|
28
|
+
"displayName": "diagram.png"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"nextBeforeSequence": null
|
|
34
|
+
},
|
|
35
|
+
"operations": {
|
|
36
|
+
"items": [],
|
|
37
|
+
"nextBeforeSequence": null
|
|
38
|
+
},
|
|
39
|
+
"pendingApprovals": [],
|
|
40
|
+
"pendingInteractions": [],
|
|
41
|
+
"transcriptCompleteness": "complete",
|
|
42
|
+
"eventCursor": null
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsonrpc": "2.0",
|
|
3
|
+
"id": 24,
|
|
4
|
+
"method": "turn.start",
|
|
5
|
+
"params": {
|
|
6
|
+
"requestId": "00000000-0000-4000-8000-0000000000b5",
|
|
7
|
+
"threadId": "00000000-0000-4000-8000-000000000002",
|
|
8
|
+
"turnId": "00000000-0000-4000-8000-000000000003",
|
|
9
|
+
"input": {
|
|
10
|
+
"text": "",
|
|
11
|
+
"attachments": ["00000000-0000-4000-8000-0000000000a1"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roll-agent/protocol",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"./schema": "./dist/schema/roll-runtime-protocol-v1.schema.json",
|
|
19
19
|
"./schema/latest": "./dist/schema/roll-runtime-protocol-v1.schema.json",
|
|
20
|
+
"./schema/1.4": "./dist/schema/roll-runtime-protocol-v1.4.schema.json",
|
|
20
21
|
"./schema/1.3": "./dist/schema/roll-runtime-protocol-v1.3.schema.json",
|
|
21
22
|
"./schema/1.2": "./dist/schema/roll-runtime-protocol-v1.2.schema.json",
|
|
22
23
|
"./schema/1.1": "./dist/schema/roll-runtime-protocol-v1.1.schema.json",
|