@coda-console/protocol 4.1.0 → 5.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/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/docs/protocol.md +48 -6
- package/package.json +1 -1
- package/schemas/protocol/v1/definition.json +6 -4
- package/schemas/protocol/v1/session.json +43 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
按 semver。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 5.0.0 — 2026-11-09
|
|
6
|
+
|
|
7
|
+
不兼容变更:
|
|
8
|
+
|
|
9
|
+
- `coda/session@1` 的 `post` 从立即结果改为开运行(`run: true`),输入不变:发一条消息可能要十几秒到几十秒(排队、按真人节奏输入、发出后确认)。发送者固定是 `self`,重发同一个 `requestId` 得到同一个运行、只发一次;`completed` 的 `result` 是 `{ message: { id, cursor } }`,即以后 `read` 读到的那条;`failed` 的 `result` 是 `{ code, message }`,不确定发没发出去时 `code` 为 `unknown`,调用方显示「结果未知」、不自动重发;取消沿用 `coda/run@1`。协议名仍是 `coda/session@1`,不升大版本:目前还没有第三方实现 `post`。
|
|
10
|
+
|
|
11
|
+
新增:
|
|
12
|
+
|
|
13
|
+
- 操作定义的 `idempotent: true`:可以改状态、但重发做的是同一件事的立即结果操作;调用双方和 `safe` 一样,都不按 `requestId` 留请求和回答。只能与 `result` 一起写,不能与 `run` 同时出现;`safe` 已含 `idempotent`,两者不同时写。
|
|
14
|
+
- `coda/session@1` 的操作 `draft`(`idempotent`):设定 `self` 还没发出去的草稿,结果 `{}`。输入 `{ text, version, steps? }`:`text` 是全文(空串为清空),`version` 是非负整数、比大小,Provider 丢掉不大于已见最大版本的,建议用毫秒时间;`steps` 是从上一版到这一版的中间状态 `{ text, delayMs }`,可照节奏回放,最后一步等于 `text`。用户发出时仍调 `post`,全文在 `post` 的输入里,没写过草稿的 `post` 也照常发。
|
|
15
|
+
|
|
16
|
+
## 4.2.0 — 2026-11-09
|
|
17
|
+
|
|
18
|
+
- `coda/session@1` 的媒体 part(`read` 的消息与 `post` 的输入)加可选的 `width`、`height`(像素,已按拍摄方向转正)、`duration`(秒)、`thumb`(内嵌 JPEG 的 base64,长边不超过 64 像素,至多 8192 字符)与 `path`(服务内路径,须和 `service` 一起出现);文档写清原文件在记录持有方的 `/v1/plugins/<provider 插件>/services/<service>/<path>`,Range 与流中断沿用本机流式服务,以及缺尺寸、缩略图、`service` 时怎么显示(Coda #2342 第 1 步)。
|
|
19
|
+
|
|
5
20
|
## 4.1.0 — 2026-11-09
|
|
6
21
|
|
|
7
22
|
- 流程属性 `coda:autoRun`:事件(如 PR)来时,会话与目录都没设「自动运行」的,按它决定起不起运行:`true`、`false`,或插件的一项设置 `=vars.<插件>.<设置>`(如 `=vars.review.autoRun`;事件来时还没有运行,别的都读不到,所以只收这种写法),不写为起。手动发起不受它影响(Coda #2303 后续:在插件设置里关掉 PR 生命流程的自动运行)。
|
package/README.md
CHANGED
|
@@ -127,7 +127,7 @@ agentValueProblem('review.json', review, '工具的审核');
|
|
|
127
127
|
- **`coda/run@1`**:被调用方自己的运行记录。spec 记录调用的记录、操作、输入、请求 ID、父引用和是否被等待;status 是 `working`、`input-required`、`completed`、`failed`、`canceled`,后三个是终态。`completed`/`failed` 必带 `result`,`failed` 的 `result` 约定为 `{ code, message }`(`code: "unknown"` 表示结局不明),`canceled` 可带取消前的话和留下的东西;另有可选的 `progress` 和等输入时的 `awaiting`。操作是 `cancel`。
|
|
128
128
|
- **`coda/executor@1`**:执行器。操作 `execute` 接一份执行工作并返回运行引用,运行记录在执行器那边;没有 `target`、`executor` 或 `assignmentId` 绑定,也不回写调用方的记录。
|
|
129
129
|
- **`coda/agent@1`**:Agent 资源,复数名 `agents`;spec 照 Coda 的 Agent 资源(`agent`、`title`、`plugin?`、`defaultModel`、`models`、`modes` 等),`plugin` 是提供 Agent 程序的插件、不是记录的 provider;status 为空对象;操作 `spawn`(`run: true`)开一个子会话。
|
|
130
|
-
- **`coda/session@1`**:插件提供的外部会话。spec 是标题、容器和可选的环境引用;status 是 `head` 游标与参与者;操作 `read
|
|
130
|
+
- **`coda/session@1`**:插件提供的外部会话。spec 是标题、容器和可选的环境引用;status 是 `head` 游标与参与者;操作 `read`(`safe`)与 `draft`(`idempotent`)是立即结果,`post` 开运行;撤回、编辑、表情是用 `about` 指向旧消息的新消息。
|
|
131
131
|
- **`coda/environment@1`**:插件提供的只读外部环境。spec 带 `actions`;操作 `list` 列目录、`read` 读文件(一次至多 1 MiB)。
|
|
132
132
|
|
|
133
133
|
统一调用是 `{ record: {kind,id}, operation, input, requestId, parent: {kind,id}, awaited }`,回答恰为 `{ result }` 或 `{ run: {kind,id} }` 之一。同一 `requestId` 重发只做一次;慢操作返回运行引用,调用方 watch 运行记录取结果,没有推送或回写。
|
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? }` 或 `{ description?, input, run: true }`,必填;不定义操作写 `{}` |
|
|
76
|
+
| `operations` | 操作名 → `{ description?, input, result, safe?, idempotent? }` 或 `{ description?, input, run: true }`,必填;不定义操作写 `{}` |
|
|
77
77
|
|
|
78
78
|
`spec`、`status`、`input`、`result` 都是 JSON Schema draft 2020-12,只引用自己文档里的 `#/$defs/...`,不引用别的文件。`input` 必有。操作的输出二选一:
|
|
79
79
|
|
|
@@ -82,6 +82,8 @@ protocolShortName('coda/run@1'); // 'coda-1run-21'
|
|
|
82
82
|
|
|
83
83
|
`safe: true` 只能和 `result` 一起写,不能和 `run` 一起写,表示只读、没有副作用、立即给结果的操作;调用方和被调用方都不按 `requestId` 留它的请求和回答(见「调用信封」)。
|
|
84
84
|
|
|
85
|
+
`idempotent: true` 也只能和 `result` 一起写,不能和 `run` 一起写,表示可以改状态、但重发做的是同一件事的立即结果操作,比如把草稿设成某一段:调用双方和 `safe` 一样,都不按 `requestId` 留请求和回答。两者是 HTTP 的 safe 与 idempotent 之分:`safe` 只读,`idempotent` 可以改状态。`safe` 已含 `idempotent`,两个不同时写。
|
|
86
|
+
|
|
85
87
|
```json
|
|
86
88
|
{
|
|
87
89
|
"name": "my-plugin/task@1",
|
|
@@ -158,7 +160,7 @@ definitionProblem(definition, { namespace: 'my-plugin' }); // 同时核对命名
|
|
|
158
160
|
{"run": {"kind": "coda/run@1", "id": "run-1"}}
|
|
159
161
|
```
|
|
160
162
|
|
|
161
|
-
`requestId` 由调用方给,重发同一个请求只做一次。`safe` 的操作例外:调用双方都不按 `requestId`
|
|
163
|
+
`requestId` 由调用方给,重发同一个请求只做一次。`safe` 与 `idempotent` 的操作例外:调用双方都不按 `requestId` 留请求和回答,重发就再做一次。`safe` 读回来的是对方的数据,比如群消息、环境里的文件内容,留在调用双方的库里就成了镜像;`idempotent` 重做一遍结果相同,留着也没用。立即结果用 `result`;慢的操作用 `run` 指向被调用方自己的 `coda/run@1` 记录,调用方 watch 这条记录取结果,被调用方不推送。取消也是一次调用(`coda/run@1` 的 `cancel` 操作),不是写别人的记录。
|
|
162
164
|
|
|
163
165
|
```js
|
|
164
166
|
import { invocationRequestProblem, invocationResponseProblem } from '@coda-console/protocol/protocol';
|
|
@@ -283,7 +285,7 @@ status:
|
|
|
283
285
|
|
|
284
286
|
## coda/session@1
|
|
285
287
|
|
|
286
|
-
|
|
288
|
+
插件提供的外部会话,比如一个微信群:参与者、消息、草稿和发消息。
|
|
287
289
|
|
|
288
290
|
spec:
|
|
289
291
|
|
|
@@ -302,14 +304,24 @@ status:
|
|
|
302
304
|
| `state` | 可选,`active` 或 `unreachable` |
|
|
303
305
|
| `reason` | 可选,状态说明 |
|
|
304
306
|
|
|
305
|
-
观察方 watch 这条记录,`head` 变了就用 `read`
|
|
307
|
+
观察方 watch 这条记录,`head` 变了就用 `read` 读游标之后的消息。`read` 与 `draft` 是立即结果,`read` 是 `safe` 的,`draft` 是 `idempotent` 的;`post` 开运行:
|
|
306
308
|
|
|
307
309
|
- `read`:输入 `{ after?, before?, limit? }`,`after`、`before` 是游标,`limit` 为 1 到 100;结果 `{ messages, cursor, more }`,没有消息时 `cursor` 为 `null`。`messages` 总按先后排,旧的在前:
|
|
308
310
|
- 都不带游标:最新的 `limit` 条,`more` 表示更早还有没有;客户端打开会话时先读这一页;
|
|
309
311
|
- 只带 `after`:这个游标之后的,`more` 表示之后还有没有;
|
|
310
312
|
- 只带 `before`:这个游标之前最新的 `limit` 条,`more` 表示更早还有没有;往前翻页就拿这一页第一条的 `cursor` 作下一次的 `before`;
|
|
311
313
|
- `after` 与 `before` 不能同时带。
|
|
312
|
-
- `post
|
|
314
|
+
- `post`(`run: true`):输入 `{ text, parts?, replyTo?, mentions? }`,以 `self` 发一条消息。发一条可能要十几秒到几十秒(排队、按真人节奏输入、发出后确认),所以开运行:
|
|
315
|
+
- 发送者固定是 `self`;重发同一个 `requestId`,得到的是同一个运行,只发一次;
|
|
316
|
+
- 运行 `completed` 时,`result` 是 `{ message: { id, cursor } }`,就是以后 `read` 会读到的那条消息;
|
|
317
|
+
- 发送失败时运行为 `failed`,`result` 是 `{ code, message }`;不确定发没发出去时(例如输入到一半进程没了)`code` 为 `unknown`,调用方显示「结果未知」,不自动重发;
|
|
318
|
+
- 取消沿用 `coda/run@1` 的 `cancel`:还没开始发的停下,得到 `canceled`;已经开始发的,Provider 可以不停,是否停下看 status;
|
|
319
|
+
- 全文总在 `post` 的输入里;没有先写过草稿的 `post` 也照常发出去。
|
|
320
|
+
- `draft`(`idempotent`):设定 `self` 在这个会话里还没发出去的文字,结果 `{}`。输入 `{ text, version, steps? }`:
|
|
321
|
+
- `text` 是当前草稿的全文,至多 65536 个字符;空串表示清空或放弃;
|
|
322
|
+
- `version` 是调用方给的非负整数版本号,比大小:Provider 收到不大于已见最大版本的直接丢掉,多台设备都在写时后写的为准;建议用毫秒时间;
|
|
323
|
+
- `steps` 可选,至多 1000 项,是从上一版到这一版之间按先后排的中间状态 `{ text, delayMs }`:每一步的全文,以及距上一步的间隔(毫秒,0 到 600000);Provider 可以照这个节奏回放,最后一步等于 `text`;
|
|
324
|
+
- Provider 可以把草稿同步到对方平台的输入框,用户发出时那边基本已经打完;用不上草稿的 Provider 直接答 `{}`。
|
|
313
325
|
|
|
314
326
|
消息是 `{ id, cursor, sender, senderName?, text, parts?, replyTo?, mentions?, about?, createdAt? }`:
|
|
315
327
|
|
|
@@ -323,9 +335,39 @@ status:
|
|
|
323
335
|
`parts` 的每一项是下面之一:
|
|
324
336
|
|
|
325
337
|
- `{ type: "text", text }`;
|
|
326
|
-
- `{ type: "image"|"video"|"file", name, size?, mime?, service? }
|
|
338
|
+
- `{ type: "image"|"video"|"file", name, size?, mime?, width?, height?, duration?, thumb?, service?, path? }`:媒体,大文件只给引用,字段见下;
|
|
327
339
|
- `{ type: "thinking"|"tool", text }`。
|
|
328
340
|
|
|
341
|
+
媒体 part 在 `read` 的消息和 `post` 的输入里是同一种形状,`type`、`name` 以外都可选:
|
|
342
|
+
|
|
343
|
+
| 字段 | 含义 |
|
|
344
|
+
| --- | --- |
|
|
345
|
+
| `name`、`size`、`mime` | 文件名、字节数、MIME 类型 |
|
|
346
|
+
| `width`、`height` | 像素,整数,至少 1,已按拍摄方向转正;图片和视频用 |
|
|
347
|
+
| `duration` | 时长,秒,不为负;视频用 |
|
|
348
|
+
| `thumb` | 内嵌 JPEG 的 base64(不带 `data:` 前缀),长边不超过 64 像素,至多 8192 个字符;视频用封面帧 |
|
|
349
|
+
| `service` | provider 插件登记的本机流式服务 ID |
|
|
350
|
+
| `path` | 服务内路径,1 到 2048 个字符;有 `path` 就必须有 `service` |
|
|
351
|
+
|
|
352
|
+
尺寸和缩略图让框在原图到达前就是最终大小:先显示放大、模糊的 `thumb`,原图到了在原地换上。
|
|
353
|
+
原文件:观察方读记录持有方的 `/v1/plugins/<provider 插件>/services/<service>/<path>`(别的机器经空间到达持有方);`path` 原样接在后面,Provider 写它时就按 URL 路径编码好,不以 `/` 开头。
|
|
354
|
+
字节、Range 和流中断语义沿用 Coda 的本机流式服务。
|
|
355
|
+
|
|
356
|
+
缺字段时这样降级,旧消息不补算:
|
|
357
|
+
|
|
358
|
+
- 缺 `width`、`height`:按默认比例占位;
|
|
359
|
+
- 缺 `thumb`:空框;
|
|
360
|
+
- 缺 `service`(或有 `service` 没有 `path`):只显示文件卡,不能打开原文件。
|
|
361
|
+
|
|
362
|
+
一个图片 part:
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{"type": "image", "name": "IMG_0412.jpg", "size": 2310144, "mime": "image/jpeg", "width": 3024, "height": 4032,
|
|
366
|
+
"thumb": "/9j/4AAQSkZJRgABAQ…", "service": "media", "path": "msg/m7/IMG_0412.jpg"}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
一条记录:
|
|
370
|
+
|
|
329
371
|
```json
|
|
330
372
|
{
|
|
331
373
|
"spec": {"title": "项目群", "container": {"id": "wx-1", "title": "我的微信"}},
|
package/package.json
CHANGED
|
@@ -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。",
|
|
5
|
+
"description": "一个协议的名字、记录格式与操作。名字是「命名空间/名字@大版本」;spec、status 与每个操作的输入、结果都是 JSON Schema(draft 2020-12),只引用定义自身的 $defs。操作要么立刻返回结果(result),要么返回运行引用(run: true);只读的立即结果可标 safe: true,可改状态但重发做同一件事的立即结果可标 idempotent: true。",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"name": {"$ref": "#/$defs/name"},
|
|
@@ -45,19 +45,21 @@
|
|
|
45
45
|
"title": {"description": "给人看的名字", "type": "string", "maxLength": 100, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
46
46
|
"description": {"description": "一句话说明", "type": "string", "maxLength": 1000, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
47
47
|
"operation": {
|
|
48
|
-
"description": "操作:input 必有;result 是立即结果的 schema,或写 run: true 表示返回运行引用。两者恰写一个。safe: true 只能与 result
|
|
48
|
+
"description": "操作:input 必有;result 是立即结果的 schema,或写 run: true 表示返回运行引用。两者恰写一个。safe: true、idempotent: true 只能与 result 一起写,两者不同时写(safe 已含 idempotent)。",
|
|
49
49
|
"type": "object",
|
|
50
50
|
"properties": {
|
|
51
51
|
"description": {"$ref": "#/$defs/description"},
|
|
52
52
|
"input": {"$ref": "#/$defs/schema"},
|
|
53
53
|
"result": {"$ref": "#/$defs/schema"},
|
|
54
54
|
"run": {"const": true, "description": "返回运行引用,而不是立即结果"},
|
|
55
|
-
"safe": {"const": true, "description": "只读、没有副作用:调用双方都不按 requestId 留请求和回答,重发就再做一次"}
|
|
55
|
+
"safe": {"const": true, "description": "只读、没有副作用:调用双方都不按 requestId 留请求和回答,重发就再做一次"},
|
|
56
|
+
"idempotent": {"const": true, "description": "可改状态,但重发做的是同一件事:调用双方都不按 requestId 留请求和回答,重发就再做一次"}
|
|
56
57
|
},
|
|
57
58
|
"required": ["input"],
|
|
58
59
|
"additionalProperties": false,
|
|
59
60
|
"oneOf": [{"required": ["result"]}, {"required": ["run"]}],
|
|
60
|
-
"dependentRequired": {"safe": ["result"]}
|
|
61
|
+
"dependentRequired": {"safe": ["result"], "idempotent": ["result"]},
|
|
62
|
+
"not": {"required": ["safe", "idempotent"]}
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coda/session@1",
|
|
3
3
|
"title": "会话",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "插件提供的外部会话:参与者、消息、草稿与发消息。Provider 每追加一条消息就推进 status.head,观察方 watch 记录后用 read 读游标之后的消息;撤回、编辑、表情回应都是一条用 about 指向旧消息的新消息。",
|
|
5
5
|
"spec": {
|
|
6
6
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
7
7
|
"type": "object",
|
|
@@ -91,9 +91,15 @@
|
|
|
91
91
|
"name": {"type": "string", "maxLength": 1024},
|
|
92
92
|
"size": {"type": "integer", "minimum": 0},
|
|
93
93
|
"mime": {"type": "string", "maxLength": 255},
|
|
94
|
-
"
|
|
94
|
+
"width": {"type": "integer", "minimum": 1, "description": "像素宽,已按拍摄方向转正;图片和视频用"},
|
|
95
|
+
"height": {"type": "integer", "minimum": 1, "description": "像素高,已按拍摄方向转正;图片和视频用"},
|
|
96
|
+
"duration": {"type": "number", "minimum": 0, "description": "时长,秒;视频用"},
|
|
97
|
+
"thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀,长边不超过 64 像素;视频用封面帧"},
|
|
98
|
+
"service": {"type": "string", "minLength": 1, "maxLength": 200, "description": "provider 插件登记的本机流式服务 ID"},
|
|
99
|
+
"path": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "服务内路径,原样接在 /v1/plugins/<provider 插件>/services/<service>/ 之后"}
|
|
95
100
|
},
|
|
96
101
|
"required": ["type", "name"],
|
|
102
|
+
"dependentRequired": {"path": ["service"]},
|
|
97
103
|
"additionalProperties": false
|
|
98
104
|
},
|
|
99
105
|
{
|
|
@@ -142,7 +148,7 @@
|
|
|
142
148
|
}
|
|
143
149
|
},
|
|
144
150
|
"post": {
|
|
145
|
-
"description": "以 self
|
|
151
|
+
"description": "以 self 发一条消息,开运行;重发同一个 requestId 得到同一个运行,只发一次。completed 的 result 是 { message: { id, cursor } },即以后 read 读到的那条;failed 的 result 是 { code, message },不确定发没发出去时 code 为 unknown,调用方显示结果未知、不自动重发。还没开始发时取消得到 canceled,已开始的看 status。没先写草稿也照常发。",
|
|
146
152
|
"input": {
|
|
147
153
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
148
154
|
"type": "object",
|
|
@@ -163,9 +169,15 @@
|
|
|
163
169
|
"name": {"type": "string", "maxLength": 1024},
|
|
164
170
|
"size": {"type": "integer", "minimum": 0},
|
|
165
171
|
"mime": {"type": "string", "maxLength": 255},
|
|
166
|
-
"
|
|
172
|
+
"width": {"type": "integer", "minimum": 1, "description": "像素宽,已按拍摄方向转正;图片和视频用"},
|
|
173
|
+
"height": {"type": "integer", "minimum": 1, "description": "像素高,已按拍摄方向转正;图片和视频用"},
|
|
174
|
+
"duration": {"type": "number", "minimum": 0, "description": "时长,秒;视频用"},
|
|
175
|
+
"thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀,长边不超过 64 像素;视频用封面帧"},
|
|
176
|
+
"service": {"type": "string", "minLength": 1, "maxLength": 200, "description": "provider 插件登记的本机流式服务 ID"},
|
|
177
|
+
"path": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "服务内路径,原样接在 /v1/plugins/<provider 插件>/services/<service>/ 之后"}
|
|
167
178
|
},
|
|
168
179
|
"required": ["type", "name"],
|
|
180
|
+
"dependentRequired": {"path": ["service"]},
|
|
169
181
|
"additionalProperties": false
|
|
170
182
|
},
|
|
171
183
|
{
|
|
@@ -186,22 +198,39 @@
|
|
|
186
198
|
"required": ["text"],
|
|
187
199
|
"additionalProperties": false
|
|
188
200
|
},
|
|
189
|
-
"
|
|
201
|
+
"run": true
|
|
202
|
+
},
|
|
203
|
+
"draft": {
|
|
204
|
+
"description": "设定 self 在这个会话里还没发出去的草稿,立即结果。text 是全文,空串为清空;version 只增,Provider 丢掉不大于已见最大版本的;steps 是从上一版到这一版的中间状态,可照 delayMs 回放,最后一步等于 text。用不上草稿的 Provider 直接答 {}。",
|
|
205
|
+
"idempotent": true,
|
|
206
|
+
"input": {
|
|
190
207
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
191
208
|
"type": "object",
|
|
192
209
|
"properties": {
|
|
193
|
-
"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"
|
|
200
|
-
|
|
210
|
+
"text": {"type": "string", "maxLength": 65536, "description": "草稿全文;空串表示清空或放弃"},
|
|
211
|
+
"version": {"type": "integer", "minimum": 0, "maximum": 9007199254740991, "description": "调用方给的版本号,比大小,后写的为准;建议用毫秒时间"},
|
|
212
|
+
"steps": {
|
|
213
|
+
"type": "array",
|
|
214
|
+
"maxItems": 1000,
|
|
215
|
+
"description": "从上一版到这一版的中间状态,按先后排;最后一步等于 text",
|
|
216
|
+
"items": {
|
|
217
|
+
"type": "object",
|
|
218
|
+
"properties": {
|
|
219
|
+
"text": {"type": "string", "maxLength": 65536, "description": "这一步的全文"},
|
|
220
|
+
"delayMs": {"type": "integer", "minimum": 0, "maximum": 600000, "description": "距上一步的间隔(毫秒)"}
|
|
221
|
+
},
|
|
222
|
+
"required": ["text", "delayMs"],
|
|
223
|
+
"additionalProperties": false
|
|
224
|
+
}
|
|
201
225
|
}
|
|
202
226
|
},
|
|
203
|
-
"required": ["
|
|
227
|
+
"required": ["text", "version"],
|
|
204
228
|
"additionalProperties": false
|
|
229
|
+
},
|
|
230
|
+
"result": {
|
|
231
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
232
|
+
"type": "object",
|
|
233
|
+
"maxProperties": 0
|
|
205
234
|
}
|
|
206
235
|
}
|
|
207
236
|
}
|