@coda-console/protocol 6.3.0 → 6.4.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.4.0 — 2026-11-16
|
|
6
|
+
|
|
7
|
+
- 这是在 6.3.0 之上的次版本。依据 README「版本」一节:协议定义是内部面,删改升次版本,先例见 6.3.0(#59)、6.2.0(#58)。
|
|
8
|
+
- 统一调用的请求信封(`schemas/protocol/v1/request.json`)加可选字段 `deadline`:调用方给的截止时刻,绝对时刻的毫秒时间戳(自 1970 年起的毫秒数,正整数),与调用内核 `@coda-console/kernel` 定时器的 `due` 同一表示;持有方到点触发处理函数的取消,不带时持有方从收到请求起按操作定义里的 `timeout` 算,操作没写就用宿主的默认期限。`invocationRequestProblem` 不带照样通过,带了必须是正整数,字符串、负数、零、小数、null 报问题。可选字段,旧请求不受影响(Coda 宿主设计 coda#2749 6.4)。
|
|
9
|
+
- 操作定义(`schemas/protocol/v1/definition.json`)加可选字段 `timeout`:这个操作的默认期限,毫秒数,正整数;调用方没给 `deadline` 时,持有方从收到请求起按它算,不写就用宿主的默认期限,具体数由宿主定,协议不规定。`definitionProblem` 认它,0、负数、小数、字符串、null 报问题。可选字段,已有定义不受影响。
|
|
10
|
+
- 不兼容:`coda/run@1` 删去操作 `answer`(连同它的输入、结果格式与测试);它没有实现也没有调用方,卡片的回答已改走调用内核(coda#2749 6.1)。现在 `coda/run@1` 只有 `cancel`,`idempotent` 的核心操作只剩 `coda/session@1 draft`。`coda/card@1` 的说明不再写「回答走运行的 `answer`」。
|
|
11
|
+
|
|
5
12
|
## 6.3.0 — 2026-11-15
|
|
6
13
|
|
|
7
14
|
- 这是在 6.2.0 之上的次版本(6.2.0 见下)。
|
package/docs/protocol.md
CHANGED
|
@@ -73,7 +73,7 @@ protocolShortName('coda/run@1'); // 'coda-1run-21'
|
|
|
73
73
|
| `plural` | 复数名(见「复数名」),可选;不写就是短名 |
|
|
74
74
|
| `spec` | 记录的 spec 的 JSON Schema,必填 |
|
|
75
75
|
| `status` | 记录的 status 的 JSON Schema,必填 |
|
|
76
|
-
| `operations` | 操作名 → `{ description?, input, result, safe?, idempotent? }` 或 `{ description?, input, run: true }`,必填;不定义操作写 `{}` |
|
|
76
|
+
| `operations` | 操作名 → `{ description?, input, result, safe?, idempotent?, timeout? }` 或 `{ description?, input, run: true, timeout? }`,必填;不定义操作写 `{}` |
|
|
77
77
|
|
|
78
78
|
`spec`、`status`、`input`、`result` 都是 JSON Schema draft 2020-12,只引用自己文档里的 `#/$defs/...`,不引用别的文件。`input` 必有。操作的输出二选一:
|
|
79
79
|
|
|
@@ -84,6 +84,8 @@ protocolShortName('coda/run@1'); // 'coda-1run-21'
|
|
|
84
84
|
|
|
85
85
|
`idempotent: true` 也只能和 `result` 一起写,不能和 `run` 一起写,表示可以改状态、但重发做的是同一件事的立即结果操作,比如把草稿设成某一段:调用双方和 `safe` 一样,都不按 `requestId` 留请求和回答。两者是 HTTP 的 safe 与 idempotent 之分:`safe` 只读,`idempotent` 可以改状态。`safe` 已含 `idempotent`,两个不同时写。
|
|
86
86
|
|
|
87
|
+
`timeout` 可选,是这个操作的默认期限:毫秒数,正整数。调用方没给截止时刻(请求信封的 `deadline`,见「调用信封」)时,持有方从收到请求起按它算;不写就用宿主的默认期限,具体数由宿主定。
|
|
88
|
+
|
|
87
89
|
```json
|
|
88
90
|
{
|
|
89
91
|
"name": "my-plugin/task@1",
|
|
@@ -150,6 +152,8 @@ definitionProblem(definition, { namespace: 'my-plugin' }); // 同时核对命名
|
|
|
150
152
|
|
|
151
153
|
`parent` 是发起这次调用的一方(调用方的运行、会话或其他记录),`awaited` 表示调用方是否在等它。被调用方建运行时把这两项照抄进 `coda/run@1` 的 spec。
|
|
152
154
|
|
|
155
|
+
可选的 `deadline` 是调用方给的截止时刻:绝对时刻的毫秒时间戳,即自 1970 年起的毫秒数,正整数,与调用内核(`@coda-console/kernel`)定时器的 `due` 是同一种表示。持有方到点就触发处理函数的取消。不带 `deadline` 时,持有方从收到请求起按操作定义里的 `timeout`(毫秒数)算;操作没写 `timeout` 就用宿主的默认期限。
|
|
156
|
+
|
|
153
157
|
回答二选一:
|
|
154
158
|
|
|
155
159
|
```json
|
|
@@ -225,9 +229,7 @@ status:
|
|
|
225
229
|
|
|
226
230
|
操作 `cancel` 的输入是空对象,立即返回空结果;是否真的停下看 status。
|
|
227
231
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
`cancel` 和 `answer` 都交给运行的持有者处理:被调用方按 `spec.record.kind` 找到持有这条运行的一方。
|
|
232
|
+
`cancel` 交给运行的持有者处理:被调用方按 `spec.record.kind` 找到持有这条运行的一方。
|
|
231
233
|
|
|
232
234
|
```json
|
|
233
235
|
{
|
|
@@ -473,7 +475,7 @@ status 是 `{ state: "available"|"unreachable", reason? }`。
|
|
|
473
475
|
|
|
474
476
|
## coda/card@1
|
|
475
477
|
|
|
476
|
-
会话向用户或上层 Agent 要的一个输入。复数名是 `cards`。由提出它的会话所在的后端持有;持有方可以按自己的表读穿给出,不另存。运行等它时,`coda/run@1` 的 `status.awaiting`
|
|
478
|
+
会话向用户或上层 Agent 要的一个输入。复数名是 `cards`。由提出它的会话所在的后端持有;持有方可以按自己的表读穿给出,不另存。运行等它时,`coda/run@1` 的 `status.awaiting` 指向这条记录。卡片自己没有操作。
|
|
477
479
|
|
|
478
480
|
spec:
|
|
479
481
|
|
|
@@ -486,7 +488,7 @@ spec:
|
|
|
486
488
|
| `answers` | 谁能答:`user` 只有用户,`any` 上层 Agent 也能代答 |
|
|
487
489
|
| `shown` | 代答的 Agent 要看的内容,对象;`answers` 为 `user` 时不写 |
|
|
488
490
|
|
|
489
|
-
spec 不带答案的 schema
|
|
491
|
+
spec 不带答案的 schema:答案的形状由卡片种类定,持有者在收到答案时校验。
|
|
490
492
|
|
|
491
493
|
status:
|
|
492
494
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coda/card@1",
|
|
3
3
|
"title": "卡片",
|
|
4
|
-
"description": "会话向用户或上层 Agent 要的一个输入。由提出它的会话所在的后端持有;运行等它时,status.awaiting
|
|
4
|
+
"description": "会话向用户或上层 Agent 要的一个输入。由提出它的会话所在的后端持有;运行等它时,status.awaiting 指向这条记录。持有方可以按自己的表读穿给出,不另存。",
|
|
5
5
|
"plural": "cards",
|
|
6
6
|
"spec": {
|
|
7
7
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://coda.pub/schemas/protocol/v1/definition.json",
|
|
4
4
|
"title": "协议定义",
|
|
5
|
-
"description": "一个协议的名字、记录格式与操作。名字是「命名空间/名字@大版本」;spec、status 与每个操作的输入、结果都是 JSON Schema(draft 2020-12),只引用定义自身的 $defs。操作要么立刻返回结果(result),要么返回运行引用(run: true);只读的立即结果可标 safe: true,可改状态但重发做同一件事的立即结果可标 idempotent: true
|
|
5
|
+
"description": "一个协议的名字、记录格式与操作。名字是「命名空间/名字@大版本」;spec、status 与每个操作的输入、结果都是 JSON Schema(draft 2020-12),只引用定义自身的 $defs。操作要么立刻返回结果(result),要么返回运行引用(run: true);只读的立即结果可标 safe: true,可改状态但重发做同一件事的立即结果可标 idempotent: true。操作可写 timeout 给出默认期限。",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"name": {"$ref": "#/$defs/name"},
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"result": {"$ref": "#/$defs/schema"},
|
|
54
54
|
"run": {"const": true, "description": "返回运行引用,而不是立即结果"},
|
|
55
55
|
"safe": {"const": true, "description": "只读、没有副作用:调用双方都不按 requestId 留请求和回答,重发就再做一次"},
|
|
56
|
-
"idempotent": {"const": true, "description": "可改状态,但重发做的是同一件事:调用双方都不按 requestId 留请求和回答,重发就再做一次"}
|
|
56
|
+
"idempotent": {"const": true, "description": "可改状态,但重发做的是同一件事:调用双方都不按 requestId 留请求和回答,重发就再做一次"},
|
|
57
|
+
"timeout": {"type": "integer", "minimum": 1, "description": "这个操作的默认期限,毫秒数,正整数:调用方没给截止时刻(请求的 deadline)时,持有方从收到请求起按它算;不写就用宿主的默认期限"}
|
|
57
58
|
},
|
|
58
59
|
"required": ["input"],
|
|
59
60
|
"additionalProperties": false,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://coda.pub/schemas/protocol/v1/request.json",
|
|
4
4
|
"title": "统一调用请求",
|
|
5
|
-
"description": "对一条记录的一次操作:记录引用、操作名、输入、请求 ID
|
|
5
|
+
"description": "对一条记录的一次操作:记录引用、操作名、输入、请求 ID、发起方引用、是否被等待和可选的截止时刻。同一个请求 ID 重发只做一次;被调用方建运行时照抄 parent 与 awaited。",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"$defs": {
|
|
8
8
|
"reference": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"input": true,
|
|
23
23
|
"requestId": {"type": "string", "minLength": 1, "maxLength": 2048},
|
|
24
24
|
"parent": {"$ref": "#/$defs/reference", "description": "发起这次调用的一方:调用方的运行、会话或其他记录"},
|
|
25
|
-
"awaited": {"type": "boolean", "description": "调用方是否在等它"}
|
|
25
|
+
"awaited": {"type": "boolean", "description": "调用方是否在等它"},
|
|
26
|
+
"deadline": {"type": "integer", "minimum": 1, "description": "调用方给的截止时刻:绝对时刻的毫秒时间戳(自 1970 年起的毫秒数,正整数),与调用内核定时器的 due 同一表示;持有方到点触发处理函数的取消。不带时由持有方按操作定义里的 timeout 或默认期限处理"}
|
|
26
27
|
},
|
|
27
28
|
"required": ["record", "operation", "input", "requestId", "parent", "awaited"],
|
|
28
29
|
"additionalProperties": false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coda/run@1",
|
|
3
3
|
"title": "运行",
|
|
4
|
-
"description": "被调用方为一次调用开出的运行记录,由被调用方持有和写入。调用方 watch 这条记录取结果;状态到 completed、failed、canceled 后不再改变。等输入时 status.awaiting 指向一条 coda/card@1;
|
|
4
|
+
"description": "被调用方为一次调用开出的运行记录,由被调用方持有和写入。调用方 watch 这条记录取结果;状态到 completed、failed、canceled 后不再改变。等输入时 status.awaiting 指向一条 coda/card@1;cancel 按 spec.record.kind 交给运行的持有者。",
|
|
5
5
|
"spec": {
|
|
6
6
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
7
7
|
"type": "object",
|
|
@@ -70,34 +70,6 @@
|
|
|
70
70
|
"description": "请求取消;立即回答空结果,实际是否停止看状态。",
|
|
71
71
|
"input": {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "maxProperties": 0, "additionalProperties": false},
|
|
72
72
|
"result": {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "maxProperties": 0, "additionalProperties": false}
|
|
73
|
-
},
|
|
74
|
-
"answer": {
|
|
75
|
-
"description": "回答运行在等的那张卡片(status.awaiting),交给运行的持有者处理;立即回答,运行接着怎样看 status。答案里可能有密钥原文,所以标 idempotent:调用双方都不按 requestId 保存这次调用,重复提交由持有者按卡片挡住。",
|
|
76
|
-
"idempotent": true,
|
|
77
|
-
"input": {
|
|
78
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
79
|
-
"type": "object",
|
|
80
|
-
"$defs": {
|
|
81
|
-
"reference": {
|
|
82
|
-
"type": "object",
|
|
83
|
-
"properties": {
|
|
84
|
-
"kind": {"type": "string", "minLength": 1, "maxLength": 128},
|
|
85
|
-
"id": {"type": "string", "minLength": 1, "maxLength": 2048}
|
|
86
|
-
},
|
|
87
|
-
"required": ["kind", "id"],
|
|
88
|
-
"additionalProperties": false
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"properties": {
|
|
92
|
-
"card": {"$ref": "#/$defs/reference", "description": "须等于 status.awaiting"},
|
|
93
|
-
"answer": {"type": "object", "description": "回答卡片时提交的内容,形状由卡片种类定"},
|
|
94
|
-
"answeredBy": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "代答的会话;用户答时不写"},
|
|
95
|
-
"attachments": {"type": "array", "maxItems": 20, "items": {"type": "string", "minLength": 1, "maxLength": 100}, "description": "随答案带的上传文件 ID"}
|
|
96
|
-
},
|
|
97
|
-
"required": ["card", "answer"],
|
|
98
|
-
"additionalProperties": false
|
|
99
|
-
},
|
|
100
|
-
"result": {"$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": {"state": {"type": "string"}}, "additionalProperties": false}
|
|
101
73
|
}
|
|
102
74
|
}
|
|
103
75
|
}
|