@coda-console/protocol 4.0.0 → 4.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,14 @@
2
2
 
3
3
  按 semver。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
4
4
 
5
+ ## 4.2.0 — 2026-11-09
6
+
7
+ - `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 步)。
8
+
9
+ ## 4.1.0 — 2026-11-09
10
+
11
+ - 流程属性 `coda:autoRun`:事件(如 PR)来时,会话与目录都没设「自动运行」的,按它决定起不起运行:`true`、`false`,或插件的一项设置 `=vars.<插件>.<设置>`(如 `=vars.review.autoRun`;事件来时还没有运行,别的都读不到,所以只收这种写法),不写为起。手动发起不受它影响(Coda #2303 后续:在插件设置里关掉 PR 生命流程的自动运行)。
12
+
5
13
  ## 4.0.0 — 2026-11-09
6
14
 
7
15
  不兼容变更:
package/docs/protocol.md CHANGED
@@ -323,9 +323,39 @@ status:
323
323
  `parts` 的每一项是下面之一:
324
324
 
325
325
  - `{ type: "text", text }`;
326
- - `{ type: "image"|"video"|"file", name, size?, mime?, service? }`:大文件只给引用,`service` 是插件登记的流式服务 ID,本版本只定字段;
326
+ - `{ type: "image"|"video"|"file", name, size?, mime?, width?, height?, duration?, thumb?, service?, path? }`:媒体,大文件只给引用,字段见下;
327
327
  - `{ type: "thinking"|"tool", text }`。
328
328
 
329
+ 媒体 part 在 `read` 的消息和 `post` 的输入里是同一种形状,`type`、`name` 以外都可选:
330
+
331
+ | 字段 | 含义 |
332
+ | --- | --- |
333
+ | `name`、`size`、`mime` | 文件名、字节数、MIME 类型 |
334
+ | `width`、`height` | 像素,整数,至少 1,已按拍摄方向转正;图片和视频用 |
335
+ | `duration` | 时长,秒,不为负;视频用 |
336
+ | `thumb` | 内嵌 JPEG 的 base64(不带 `data:` 前缀),长边不超过 64 像素,至多 8192 个字符;视频用封面帧 |
337
+ | `service` | provider 插件登记的本机流式服务 ID |
338
+ | `path` | 服务内路径,1 到 2048 个字符;有 `path` 就必须有 `service` |
339
+
340
+ 尺寸和缩略图让框在原图到达前就是最终大小:先显示放大、模糊的 `thumb`,原图到了在原地换上。
341
+ 原文件:观察方读记录持有方的 `/v1/plugins/<provider 插件>/services/<service>/<path>`(别的机器经空间到达持有方);`path` 原样接在后面,Provider 写它时就按 URL 路径编码好,不以 `/` 开头。
342
+ 字节、Range 和流中断语义沿用 Coda 的本机流式服务。
343
+
344
+ 缺字段时这样降级,旧消息不补算:
345
+
346
+ - 缺 `width`、`height`:按默认比例占位;
347
+ - 缺 `thumb`:空框;
348
+ - 缺 `service`(或有 `service` 没有 `path`):只显示文件卡,不能打开原文件。
349
+
350
+ 一个图片 part:
351
+
352
+ ```json
353
+ {"type": "image", "name": "IMG_0412.jpg", "size": 2310144, "mime": "image/jpeg", "width": 3024, "height": 4032,
354
+ "thumb": "/9j/4AAQSkZJRgABAQ…", "service": "media", "path": "msg/m7/IMG_0412.jpg"}
355
+ ```
356
+
357
+ 一条记录:
358
+
329
359
  ```json
330
360
  {
331
361
  "spec": {"title": "项目群", "container": {"id": "wx-1", "title": "我的微信"}},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/protocol",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Coda 的协议:插件清单的类型(JSON Schema)、通用校验器、协议定义与调用信封、流程方言与 Agent 接入协议",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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
- "service": {"type": "string", "minLength": 1, "maxLength": 200, "description": "插件登记的流式服务 ID"}
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
  {
@@ -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
- "service": {"type": "string", "minLength": 1, "maxLength": 200, "description": "插件登记的流式服务 ID"}
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
  {
@@ -10,7 +10,7 @@
10
10
  "name": "ProcessProperties",
11
11
  "isAbstract": true,
12
12
  "extends": ["bpmn:Process"],
13
- "description": "流程本身:concurrency 并发、key 未结束运行的业务键、deploy 只跑默认分支的提交、title 运行在卡片上的名字(同 GitHub 的 run-name)、kind 种类(见 dialect.json 的 kinds)、dispatch 能否手动发起、inline Agent 用 workflow_run 发起时等它结束再回答、subagents 为 false 时会话 Agent 的原生子 Agent 不能发起、agents 生命周期流程跟随哪些 Agent 的会话(ID,逗号或空格分隔,不写是全部)",
13
+ "description": "流程本身:concurrency 并发、key 未结束运行的业务键、deploy 只跑默认分支的提交、title 运行在卡片上的名字(同 GitHub 的 run-name)、kind 种类(见 dialect.json 的 kinds)、dispatch 能否手动发起、inline Agent 用 workflow_run 发起时等它结束再回答、subagents 为 false 时会话 Agent 的原生子 Agent 不能发起、agents 生命周期流程跟随哪些 Agent 的会话(ID,逗号或空格分隔,不写是全部)、autoRun 事件(如 PR)来时会话与目录都没设「自动运行」的,按它决定起不起运行:true、false 或 =vars.<插件>.<设置>(不写为起)",
14
14
  "properties": [
15
15
  {"name": "concurrency", "isAttr": true, "type": "String"},
16
16
  {"name": "key", "isAttr": true, "type": "String"},
@@ -20,7 +20,8 @@
20
20
  {"name": "dispatch", "isAttr": true, "type": "Boolean"},
21
21
  {"name": "inline", "isAttr": true, "type": "Boolean"},
22
22
  {"name": "subagents", "isAttr": true, "type": "Boolean"},
23
- {"name": "agents", "isAttr": true, "type": "String"}
23
+ {"name": "agents", "isAttr": true, "type": "String"},
24
+ {"name": "autoRun", "isAttr": true, "type": "String"}
24
25
  ]
25
26
  },
26
27
  {
@@ -12,7 +12,9 @@
12
12
  "title": {"type": "string", "pattern": "\\S", "maxLength": 200, "x-feel": true, "description": "coda:title 须为 1–200 个字符"},
13
13
  "kind": {"enum": ["deploy", "preview", "release", "check", "premerge", "prebuild"], "description": "coda:kind 只能是 deploy、preview、release、check、premerge、prebuild"},
14
14
  "agents": {"type": "string", "pattern": "^[\\s,]*[a-z][a-z0-9-]{0,39}(?:[\\s,]+[a-z][a-z0-9-]{0,39})*[\\s,]*$",
15
- "description": "coda:agents 写 Agent 的 ID,用逗号或空格分隔(小写字母、数字和「-」,以字母开头,至多 40 个字符),不能为空"}
15
+ "description": "coda:agents 写 Agent 的 ID,用逗号或空格分隔(小写字母、数字和「-」,以字母开头,至多 40 个字符),不能为空"},
16
+ "autoRun": {"type": "string", "anyOf": [{"enum": ["true", "false"]}, {"pattern": "^\\s*=\\s*vars(\\.[A-Za-z_][A-Za-z0-9_-]*)+\\s*$"}], "x-feel": {"names": ["vars"]},
17
+ "description": "coda:autoRun 须为 true、false 或 =vars.<插件>.<设置>:事件来时还没有运行,能读的只有插件设置"}
16
18
  }
17
19
  },
18
20
  "ScriptTaskProperties": {