@coda-console/protocol 5.0.0 → 5.2.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,16 @@
2
2
 
3
3
  按 semver。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
4
4
 
5
+ ## 5.2.0 — 2026-11-09
6
+
7
+ - 新核心协议 `coda/card@1`(复数名 `cards`,`CARD_PROTOCOL`,在 `CORE_PROTOCOLS` 里):会话向用户或上层 Agent 要的一个输入,由提出它的会话所在的后端持有,可按持有方自己的表读穿给出、不另存。spec 是 `{ kind, title, thread, location?, answers: "user"|"any", shown? }`,不带答案的 schema;status 是 `{ state: "pending"|"submitting"|"answered"|"expired"|"unknown", holder?, reason?, note?, toldAlong?, setAside? }`,`holder` 是字符串(`user` 或会话 ID),不是引用;没有操作。
8
+ - `coda/run@1` 加操作 `answer`(立即结果 `{ state? }`,`idempotent`):回答运行在等的卡片,输入 `{ card, answer, answeredBy?, attachments? }`,`card` 须等于 `status.awaiting`。答案里可能有密钥原文,调用双方都不按 `requestId` 保存这次调用,重复提交由持有者按卡片挡住。`answer` 和 `cancel` 一样按 `spec.record.kind` 交给运行的持有者;`status.awaiting` 指向 `coda/card@1`(Coda S2)。
9
+ - `coda/agent@1` 的说明补上:`spawn` 的 `parent` 不是会话、是登记过的调用方记录时,开的是顶层会话,不是子会话。
10
+
11
+ ## 5.1.0 — 2026-11-09
12
+
13
+ - `coda/session@1` 的媒体 part(`read` 的消息与 `post` 的输入)加可选的 `preview`:同一个 `service` 里预览图的服务内路径(1 到 2048 字符,须和 `service` 一起出现),图片是长边一般不超过约 1280 像素的静图,视频是封面帧。文档把媒体写成三档:内嵌的 `thumb`(只限至多 8192 字符,自己生成时长边取 64 像素左右,Provider 已有的小缩略图可原样放)、会话里画的 `preview`、打开时才取的原文件 `path`;取 `path` 回 404 而有 `preview` 时显示预览图并注明原图不在持有方,不当成文件已清理,`preview` 也取不到时退回 `thumb`,都没有时显示文件卡(Coda #2342)。
14
+
5
15
  ## 5.0.0 — 2026-11-09
6
16
 
7
17
  不兼容变更:
package/README.md CHANGED
@@ -4,7 +4,7 @@ Coda 与插件之间的约定,Coda 和插件都引用它,独立演进:
4
4
 
5
5
  - **插件清单的类型**(`schemas/plugin/`):插件目录 `package.json` 里 `contributes` 的每个键是一种类型,各有一份 JSON Schema(draft 2020-12,`$id` 为 `https://coda.pub/schemas/plugin/v2/<文件>`)。`plugin.json` 是整份清单,只列通用键(`configuration`、`extensionPoints`、`extensions`、`services`、`setup`、`environment`、`path`、`endpoints`、`views`、`protocols`、`protocolImplementations`);`setting.json` 是一项设置的声明。其余键由 Coda 的贡献点登记表或某个插件的扩展点声明:Coda 自己的(`agents`、`composerModes`、`modelProviders` 等)的 schema 仍放在这里作公开数据(如 `agents.json`、`composer-modes.json`),由登记它的 provider 引用;扩展点可以带自己的 schema(`extensionPoints.<名>.schema`,声明它的插件目录里的一个文件),写给它的东西合乎那份 schema 才对。
6
6
  - **通用校验器**(`validate.mjs`):用 Ajv 对清单做 schema 校验。JSON Schema 说不了的只用五个通用关键字(`x-unique-by`、`x-max-contains`、`x-ref`、`x-placeholders`、`x-file`,照 Kubernetes 的 `x-kubernetes-*`),每个在哪里写都是同一个意思,写法见文件开头。校验器不随功能变长:类型加字段就是改 schema。
7
- - **协议定义与调用**(`schemas/protocol/`、`protocol.mjs`、`docs/protocol.md`):协议是 `命名空间/名字@大版本` + spec/status 的 JSON Schema + 操作;插件在 `contributes.protocols` 里定义自己命名空间下的协议,在 `contributes.protocolImplementations` 里声明实现哪些协议。调用是 `{ record, operation, input, requestId, parent, awaited }`,回答是 `{ result }` 或 `{ run }`;`coda/run@1`、`coda/executor@1`、`coda/agent@1`、`coda/session@1`、`coda/environment@1` 是五个核心协议。
7
+ - **协议定义与调用**(`schemas/protocol/`、`protocol.mjs`、`docs/protocol.md`):协议是 `命名空间/名字@大版本` + spec/status 的 JSON Schema + 操作;插件在 `contributes.protocols` 里定义自己命名空间下的协议,在 `contributes.protocolImplementations` 里声明实现哪些协议。调用是 `{ record, operation, input, requestId, parent, awaited }`,回答是 `{ result }` 或 `{ run }`;`coda/run@1`、`coda/executor@1`、`coda/agent@1`、`coda/session@1`、`coda/environment@1`、`coda/card@1` 是六个核心协议。
8
8
  - **流程方言**(`workflow/`):项目和插件的流程(`.coda/workflows/*.bpmn`,BPMN 2.0)在 Coda 的命名空间 `https://coda.pub/schema/bpmn/1.0` 里能写什么。`moddle.json` 是 `coda:` 属性与元素(bpmn-moddle 的描述格式),`values.json` 是每个值能写什么(每个 `coda:` 类型的属性组成的对象的 JSON Schema,一个元素里同种 `coda:` 元素成组的 schema),`actions.json` 是 `coda:action` 的各个动作和它们接受的参数,`dialect.json` 是流程种类、Coda 自己发的事件、步骤失败的错误码、表达式能读的运行变量和运行的输入能是哪些类型。`workflow.mjs` 用它们读一份流程:方言里没有的、值不合 schema 的都拒绝,说法是「位置:schema 对那里的说明」。值的 schema 用清单的那几个关键字,另加三个:`x-feel`(是 FEEL:「=」开头是表达式,否则文字里的 `{{ … }}` 是,按这份流程里的名字读得通)、`x-duration`(ISO 8601 时长,不为负)、`x-number`(文字换算成数字是个有限的数)。`structure.json` 声明流程结构规则,`structure.mjs` 负责跨节点检查。
9
9
  - **Agent 接入扩展**(`schemas/agent/`、`agent.mjs`、`docs/agent-protocol.md`):Coda 怎样用 ACP 接 Agent,以及 Coda 加的扩展(会话指令、插话、`_coda/wait`、执行失败、工具调用的审核)。
10
10
 
@@ -42,7 +42,7 @@ pointProblem(panelsSchema, manifest.contributes.panels, 'contributes.panels', 'p
42
42
 
43
43
  ```js
44
44
  import {
45
- RUN_PROTOCOL, EXECUTOR_PROTOCOL, AGENT_PROTOCOL, SESSION_PROTOCOL, ENVIRONMENT_PROTOCOL, CORE_PROTOCOLS,
45
+ RUN_PROTOCOL, EXECUTOR_PROTOCOL, AGENT_PROTOCOL, SESSION_PROTOCOL, ENVIRONMENT_PROTOCOL, CARD_PROTOCOL, CORE_PROTOCOLS,
46
46
  definitionProblem, ownedProtocolsProblem, runStatusProblem,
47
47
  invocationRequestProblem, invocationResponseProblem,
48
48
  parseProtocolName, formatProtocolName, protocolShortName,
package/docs/protocol.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  - 协议定义文档的 JSON Schema 与校验:`schemas/protocol/v1/definition.json`、`@coda-console/protocol/protocol`;
8
8
  - 统一调用信封:`schemas/protocol/v1/request.json`、`response.json`;
9
- - 五个核心协议:`coda/run@1`、`coda/executor@1`、`coda/agent@1`、`coda/session@1`、`coda/environment@1`;
9
+ - 六个核心协议:`coda/run@1`、`coda/executor@1`、`coda/agent@1`、`coda/session@1`、`coda/environment@1`、`coda/card@1`;
10
10
  - 插件清单里的 `contributes.protocols` 与 `contributes.protocolImplementations`。
11
11
 
12
12
  `executor` 与 `execution` 两个旧对象协议和 `@coda-console/protocol/executor` 在 3.0.0 删除;`execution` 的输入并入 `coda/executor@1` 的 `execute` 操作,运行由 `coda/run@1` 表达。
@@ -217,7 +217,7 @@ status:
217
217
  | `state` | `working`、`input-required`、`completed`、`failed`、`canceled`;后三个是终态 |
218
218
  | `result` | 完成、失败或取消时的结果:`completed`/`failed` 必带;`canceled` 可带取消前说过的话和留下的东西;`working`/`input-required` 不带 |
219
219
  | `progress` | 进展说明,可选 |
220
- | `awaiting` | 等输入时那张卡片的引用;`input-required` 必填,其他状态不写 |
220
+ | `awaiting` | 等输入时那张卡片的引用,指向一条 `coda/card@1`;`input-required` 必填,其他状态不写 |
221
221
 
222
222
  `failed` 的 `result` 约定为 `{ code, message }`。`code: "unknown"` 表示结局不明(例如执行连接中断),调用方据此显示「结果未知」,不当作失败。
223
223
 
@@ -225,6 +225,10 @@ status:
225
225
 
226
226
  操作 `cancel` 的输入是空对象,立即返回空结果;是否真的停下看 status。
227
227
 
228
+ 操作 `answer` 回答运行在等的那张卡片,立即返回 `{ state? }`,运行接着怎样看 status。输入是 `{ card, answer, answeredBy?, attachments? }`:`card` 须等于 `status.awaiting`;`answer` 是对象,形状由卡片种类定;`answeredBy` 是代答的会话,用户答时不写;`attachments` 是随答案带的上传文件 ID(至多 20 个)。它标 `idempotent`:答案里可能有密钥原文,调用双方都不按 `requestId` 保存这次调用;重复提交由持有者按卡片挡住。
229
+
230
+ `cancel` 和 `answer` 都交给运行的持有者处理:被调用方按 `spec.record.kind` 找到持有这条运行的一方。
231
+
228
232
  ```json
229
233
  {
230
234
  "spec": {
@@ -267,7 +271,7 @@ status:
267
271
 
268
272
  `models[].efforts` 是 `[{ id, name?, shortName? }]`;`models[].options` 是 `{ id, name?, shortName?, type: "boolean"|"select", choices? }`,`select` 带 `choices`,`boolean` 不带。status 是空对象。
269
273
 
270
- 操作 `spawn`(`run: true`):在这台机器上用这个 Agent 开一个子会话,返回运行引用。输入是 `{ projectId, threadId, title, text, settings?, checkout?, parentTitle, parentUnattended }`:子会话所在的项目与工作树(`checkout`)、Agent 的设置(`settings`,如模型与推理强度)、标题与第一条任务(`text`);`threadId` 是调用方给的子会话 ID,重试找到的是同一个;`parentTitle` 是发起方在这里显示的名字,`parentUnattended` 说发起方是否无人值守。子会话为谁工作由调用信封的 `parent` 说,不写在输入里。
274
+ 操作 `spawn`(`run: true`):在这台机器上用这个 Agent 开一个子会话,返回运行引用。输入是 `{ projectId, threadId, title, text, settings?, checkout?, parentTitle, parentUnattended }`:子会话所在的项目与工作树(`checkout`)、Agent 的设置(`settings`,如模型与推理强度)、标题与第一条任务(`text`);`threadId` 是调用方给的子会话 ID,重试找到的是同一个;`parentTitle` 是发起方在这里显示的名字,`parentUnattended` 说发起方是否无人值守。子会话为谁工作由调用信封的 `parent` 说,不写在输入里;`parent` 不是会话、是登记过的调用方记录时,开的是顶层会话,不是子会话。
271
275
 
272
276
  ```json
273
277
  {
@@ -335,7 +339,7 @@ status:
335
339
  `parts` 的每一项是下面之一:
336
340
 
337
341
  - `{ type: "text", text }`;
338
- - `{ type: "image"|"video"|"file", name, size?, mime?, width?, height?, duration?, thumb?, service?, path? }`:媒体,大文件只给引用,字段见下;
342
+ - `{ type: "image"|"video"|"file", name, size?, mime?, width?, height?, duration?, thumb?, service?, path?, preview? }`:媒体,大文件只给引用,字段见下;
339
343
  - `{ type: "thinking"|"tool", text }`。
340
344
 
341
345
  媒体 part 在 `read` 的消息和 `post` 的输入里是同一种形状,`type`、`name` 以外都可选:
@@ -345,25 +349,40 @@ status:
345
349
  | `name`、`size`、`mime` | 文件名、字节数、MIME 类型 |
346
350
  | `width`、`height` | 像素,整数,至少 1,已按拍摄方向转正;图片和视频用 |
347
351
  | `duration` | 时长,秒,不为负;视频用 |
348
- | `thumb` | 内嵌 JPEG 的 base64(不带 `data:` 前缀),长边不超过 64 像素,至多 8192 个字符;视频用封面帧 |
352
+ | `thumb` | 内嵌 JPEG 的 base64(不带 `data:` 前缀),至多 8192 个字符;视频用封面帧 |
349
353
  | `service` | provider 插件登记的本机流式服务 ID |
350
- | `path` | 服务内路径,1 到 2048 个字符;有 `path` 就必须有 `service` |
354
+ | `path` | 原文件的服务内路径,1 到 2048 个字符 |
355
+ | `preview` | 预览图的服务内路径,在同一个 `service` 里,1 到 2048 个字符 |
356
+
357
+ 有 `path` 或 `preview` 就必须有 `service`。
358
+
359
+ 一个媒体分三档,从小到大:
351
360
 
352
- 尺寸和缩略图让框在原图到达前就是最终大小:先显示放大、模糊的 `thumb`,原图到了在原地换上。
353
- 原文件:观察方读记录持有方的 `/v1/plugins/<provider 插件>/services/<service>/<path>`(别的机器经空间到达持有方);`path` 原样接在后面,Provider 写它时就按 URL 路径编码好,不以 `/` 开头。
361
+ - **`thumb`**:内嵌在消息里,框一出现就能画。约束只是至多 8192 个字符:自己生成时长边取 64 像素左右;Provider 手上已有的小缩略图,只要在上限以内,可以原样放进来。
362
+ - **`preview`**:持有方本地就有的较小版本。图片是一张静图,长边一般不超过约 1280 像素;视频是封面帧。观察方在会话里画它,原图只在打开时取。
363
+ - **`path`**:原文件。
364
+
365
+ 尺寸和 `thumb` 让框在图到达前就是最终大小:先显示放大、模糊的 `thumb`,`preview` 到了在原地换上;没有 `preview` 的,照旧换上原图。
366
+ 观察方读记录持有方的 `/v1/plugins/<provider 插件>/services/<service>/<preview 或 path>`(别的机器经空间到达持有方);路径原样接在后面,Provider 写它时就按 URL 路径编码好,不以 `/` 开头。
354
367
  字节、Range 和流中断语义沿用 Coda 的本机流式服务。
355
368
 
369
+ 取不到时这样降级:
370
+
371
+ - 取 `path` 回 404 而有 `preview`:显示预览图,并注明原图不在持有方(比如微信还没下载),不当成「文件已清理」;
372
+ - 没有 `preview` 或 `preview` 也取不到:退回 `thumb`;
373
+ - 三档都没有或都取不到:显示文件卡。
374
+
356
375
  缺字段时这样降级,旧消息不补算:
357
376
 
358
377
  - 缺 `width`、`height`:按默认比例占位;
359
- - 缺 `thumb`:空框;
360
- - 缺 `service`(或有 `service` 没有 `path`):只显示文件卡,不能打开原文件。
378
+ - 缺 `thumb`:图到之前是空框;
379
+ - 缺 `service`(或有 `service`,`path` 和 `preview` 都没有):只显示文件卡,不能打开原文件。
361
380
 
362
381
  一个图片 part:
363
382
 
364
383
  ```json
365
384
  {"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"}
385
+ "thumb": "/9j/4AAQSkZJRgABAQ…", "service": "media", "path": "msg/m7/IMG_0412.jpg", "preview": "msg/m7/IMG_0412.preview.jpg"}
367
386
  ```
368
387
 
369
388
  一条记录:
@@ -414,6 +433,43 @@ status 是 `{ state: "available"|"unreachable", reason? }`。
414
433
  }
415
434
  ```
416
435
 
436
+ ## coda/card@1
437
+
438
+ 会话向用户或上层 Agent 要的一个输入。复数名是 `cards`。由提出它的会话所在的后端持有;持有方可以按自己的表读穿给出,不另存。运行等它时,`coda/run@1` 的 `status.awaiting` 指向这条记录,回答走那条运行的 `answer`。卡片自己没有操作。
439
+
440
+ spec:
441
+
442
+ | 字段 | 含义 |
443
+ | --- | --- |
444
+ | `kind` | 卡片种类,如 `permission`、`form`、`workflow_task` |
445
+ | `title` | 一行标题 |
446
+ | `thread` | 提出它的会话,持有方给的 ID |
447
+ | `location` | 提出它的会话在哪台机器,给人看;本机的不写 |
448
+ | `answers` | 谁能答:`user` 只有用户,`any` 上层 Agent 也能代答 |
449
+ | `shown` | 代答的 Agent 要看的内容,对象;`answers` 为 `user` 时不写 |
450
+
451
+ spec 不带答案的 schema:答案的形状由卡片种类定,持有者在 `answer` 里校验。
452
+
453
+ status:
454
+
455
+ | 字段 | 含义 |
456
+ | --- | --- |
457
+ | `state` | `pending`、`submitting`、`answered`、`expired`、`unknown` |
458
+ | `holder` | `pending` 时在谁手上:`user`,或持有它的会话 ID(持有方给的) |
459
+ | `reason` | 到这个持有者手上的原因 |
460
+ | `note` | 说明 |
461
+ | `toldAlong` | `true`:持有它的会话还没被告知,下一条输入时才告诉它 |
462
+ | `setAside` | `true`:用户把它搁置了,仍在等,不再要人处理 |
463
+
464
+ `holder` 是字符串,不是 `{ kind, id }` 引用:镜像发布时会改写 status 里的引用,而持有者可能是别台的会话,本机不一定认得它的持有方。
465
+
466
+ ```json
467
+ {
468
+ "spec": {"kind": "workflow_task", "title": "确认发布", "thread": "t1", "answers": "any", "shown": {"text": "要发布 5.2.0 吗?"}},
469
+ "status": {"state": "pending", "holder": "t1", "reason": "assigned", "toldAlong": true}
470
+ }
471
+ ```
472
+
417
473
  ## 版本
418
474
 
419
475
  - 协议名里的大版本是协议自己的版本,和 npm 包版本、插件清单的 v2 独立。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/protocol",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Coda 的协议:插件清单的类型(JSON Schema)、通用校验器、协议定义与调用信封、流程方言与 Agent 接入协议",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/protocol.mjs CHANGED
@@ -15,8 +15,9 @@ export const EXECUTOR_PROTOCOL = read('executor.json');
15
15
  export const AGENT_PROTOCOL = read('agent.json');
16
16
  export const SESSION_PROTOCOL = read('session.json');
17
17
  export const ENVIRONMENT_PROTOCOL = read('environment.json');
18
+ export const CARD_PROTOCOL = read('card.json');
18
19
  export const CORE_PROTOCOLS = Object.freeze(Object.fromEntries(
19
- [RUN_PROTOCOL, EXECUTOR_PROTOCOL, AGENT_PROTOCOL, SESSION_PROTOCOL, ENVIRONMENT_PROTOCOL].map(protocol => [protocol.name, protocol])));
20
+ [RUN_PROTOCOL, EXECUTOR_PROTOCOL, AGENT_PROTOCOL, SESSION_PROTOCOL, ENVIRONMENT_PROTOCOL, CARD_PROTOCOL].map(protocol => [protocol.name, protocol])));
20
21
 
21
22
  const ajv = newAjv({ ownProperties: true, addUsedSchema: false, strict: false });
22
23
  const definitionCheck = ajv.compile(PROTOCOL_DEFINITION);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "coda/agent@1",
3
3
  "title": "Agent",
4
- "description": "一台机器上装着的 Agent 程序及其模型与审批模式,照 Coda 的 Agent 资源 spec。记录的 provider 是写记录的一方(编排),提供 Agent 程序的插件写在 spec.plugin;spawn 在那台机器上用它开一个子会话。",
4
+ "description": "一台机器上装着的 Agent 程序及其模型与审批模式,照 Coda 的 Agent 资源 spec。记录的 provider 是写记录的一方(编排),提供 Agent 程序的插件写在 spec.plugin;spawn 在那台机器上用它开一个子会话;parent 不是会话、是登记过的调用方记录时,开的是顶层会话,不是子会话。",
5
5
  "plural": "agents",
6
6
  "spec": {
7
7
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "coda/card@1",
3
+ "title": "卡片",
4
+ "description": "会话向用户或上层 Agent 要的一个输入。由提出它的会话所在的后端持有;运行等它时,status.awaiting 指向这条记录,回答走那条运行的 answer。持有方可以按自己的表读穿给出,不另存。",
5
+ "plural": "cards",
6
+ "spec": {
7
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
8
+ "type": "object",
9
+ "properties": {
10
+ "kind": {"type": "string", "minLength": 1, "maxLength": 64, "description": "卡片种类,如 permission、form、workflow_task"},
11
+ "title": {"type": "string", "maxLength": 200, "description": "一行标题"},
12
+ "thread": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "提出它的会话,持有方给的 ID"},
13
+ "location": {"type": "string", "maxLength": 200, "description": "提出它的会话在哪台机器,给人看;本机的不写"},
14
+ "answers": {"enum": ["user", "any"], "description": "谁能答:只有用户,或者上层 Agent 也能代答"},
15
+ "shown": {"type": "object", "description": "代答的 Agent 要看的内容;answers 为 user 时不写"}
16
+ },
17
+ "required": ["kind", "title", "thread", "answers"],
18
+ "additionalProperties": false
19
+ },
20
+ "status": {
21
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
22
+ "type": "object",
23
+ "properties": {
24
+ "state": {"enum": ["pending", "submitting", "answered", "expired", "unknown"]},
25
+ "holder": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "pending 时在谁手上:user,或持有它的会话 ID(持有方给的);不用引用,镜像发布时不改写它"},
26
+ "reason": {"type": "string", "maxLength": 64, "description": "到这个持有者手上的原因"},
27
+ "note": {"type": "string", "maxLength": 2000},
28
+ "toldAlong": {"const": true, "description": "持有它的会话还没被告知,下一条输入时才告诉它"},
29
+ "setAside": {"const": true, "description": "用户把它搁置了:仍在等,不再要人处理"}
30
+ },
31
+ "required": ["state"],
32
+ "additionalProperties": false
33
+ },
34
+ "operations": {}
35
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "coda/run@1",
3
3
  "title": "运行",
4
- "description": "被调用方为一次调用开出的运行记录,由被调用方持有和写入。调用方 watch 这条记录取结果;状态到 completed、failed、canceled 后不再改变。",
4
+ "description": "被调用方为一次调用开出的运行记录,由被调用方持有和写入。调用方 watch 这条记录取结果;状态到 completed、failed、canceled 后不再改变。等输入时 status.awaiting 指向一条 coda/card@1;answer 和 cancel 一样,按 spec.record.kind 交给运行的持有者。",
5
5
  "spec": {
6
6
  "$schema": "https://json-schema.org/draft/2020-12/schema",
7
7
  "type": "object",
@@ -70,6 +70,34 @@
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}
73
101
  }
74
102
  }
75
103
  }
@@ -94,12 +94,13 @@
94
94
  "width": {"type": "integer", "minimum": 1, "description": "像素宽,已按拍摄方向转正;图片和视频用"},
95
95
  "height": {"type": "integer", "minimum": 1, "description": "像素高,已按拍摄方向转正;图片和视频用"},
96
96
  "duration": {"type": "number", "minimum": 0, "description": "时长,秒;视频用"},
97
- "thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀,长边不超过 64 像素;视频用封面帧"},
97
+ "thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀;自己生成时长边取 64 像素左右,已有的小缩略图在上限内可原样放;视频用封面帧"},
98
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>/ 之后"}
99
+ "path": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "原文件的服务内路径,原样接在 /v1/plugins/<provider 插件>/services/<service>/ 之后"},
100
+ "preview": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "预览图在同一个 service 里的服务内路径:图片是长边一般不超过约 1280 像素的静图,视频是封面帧"}
100
101
  },
101
102
  "required": ["type", "name"],
102
- "dependentRequired": {"path": ["service"]},
103
+ "dependentRequired": {"path": ["service"], "preview": ["service"]},
103
104
  "additionalProperties": false
104
105
  },
105
106
  {
@@ -172,12 +173,13 @@
172
173
  "width": {"type": "integer", "minimum": 1, "description": "像素宽,已按拍摄方向转正;图片和视频用"},
173
174
  "height": {"type": "integer", "minimum": 1, "description": "像素高,已按拍摄方向转正;图片和视频用"},
174
175
  "duration": {"type": "number", "minimum": 0, "description": "时长,秒;视频用"},
175
- "thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀,长边不超过 64 像素;视频用封面帧"},
176
+ "thumb": {"type": "string", "maxLength": 8192, "description": "内嵌 JPEG 的 base64,不带 data: 前缀;自己生成时长边取 64 像素左右,已有的小缩略图在上限内可原样放;视频用封面帧"},
176
177
  "service": {"type": "string", "minLength": 1, "maxLength": 200, "description": "provider 插件登记的本机流式服务 ID"},
177
- "path": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "服务内路径,原样接在 /v1/plugins/<provider 插件>/services/<service>/ 之后"}
178
+ "path": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "原文件的服务内路径,原样接在 /v1/plugins/<provider 插件>/services/<service>/ 之后"},
179
+ "preview": {"type": "string", "minLength": 1, "maxLength": 2048, "description": "预览图在同一个 service 里的服务内路径:图片是长边一般不超过约 1280 像素的静图,视频是封面帧"}
178
180
  },
179
181
  "required": ["type", "name"],
180
- "dependentRequired": {"path": ["service"]},
182
+ "dependentRequired": {"path": ["service"], "preview": ["service"]},
181
183
  "additionalProperties": false
182
184
  },
183
185
  {