@coda-console/protocol 5.13.0 → 5.14.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 +6 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/workflow/actions.json +4 -2
- package/workflow/moddle.json +14 -2
- package/workflow/values.json +15 -1
- package/workflow.mjs +14 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 5.14.0 — 2026-11-13
|
|
6
|
+
|
|
7
|
+
- 流程方言加挂点:流程可写多个 `coda:join`(`hook` 必填,`name`、`detail`、`default` 为 true/false、`order` 为整数,同一流程 hook 不重复),流程属性加 `coda:mergedOnly`(只运行已合并进默认分支的提交,由流程自己声明)。动作加 `hook-joiners`(参数 `hook`、`commit`),`run-workflows` 加参数 `hook`、`only`。只加写法,`coda:kind` 与 `coda:deploy` 不变(Coda #2521 第 2 步)。
|
|
8
|
+
- 报错位置里 `coda:join` 以 hook 称呼。
|
|
9
|
+
- `coda:mergedOnly` 只认 true、false:与字段的布尔、整数属性一样先按文字读、核对拼写后才换成布尔值,写错的读流程时拒绝,不会被当成 false 放开只跑已合并提交的限制。
|
|
10
|
+
|
|
5
11
|
## 5.13.0 — 2026-11-13
|
|
6
12
|
|
|
7
13
|
- 流程方言的答复加 `coda:optionList`:`value` 是表达式,任务打开时读出一组勾选项,在它写的位置展开,与 `coda:option` 按写的顺序排(moddle 里两者同属答复的 `options`,类型 `ChoiceOption`)。打开后的整组由新的 `workflow/options.json` 定义(`{ id, name, detail?, default? }`,最多 12 项,id 不重复),`optionsProblem` 检查它,`CODA_OPTIONS` 导出同一份 schema。只加写法,已有流程不变(Coda #2521 第 1 步)。
|
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ Coda 与插件之间的约定,Coda 和插件都引用它,独立演进:
|
|
|
14
14
|
|
|
15
15
|
读取定义时原有的 Coda 结构规则已全部纳入协议。Coda 接入 1.8.0 后,`parseBpmn` 只需调用 `readWorkflow`,再把 `root` 编译成引擎、任务、调度和图所需的结构;运行时才能知道的表达式结果、动态字段引用、调度设置实际值及能力是否存在,仍由宿主在运行时检查。
|
|
16
16
|
|
|
17
|
+
流程方言的 **挂点**是流程之间互相找到的方式:被调用的流程在自己的 extensionElements 里写 `<coda:join hook name? detail? default? order?/>` 加入一个挂点(`hook` 是小写字母开头的名字,一个流程每个挂点只加入一次),`name`、`detail` 是它作为勾选项时的名字与说明,`default` 是否默认勾上(只写 true 或 false:挂点的列表在任何运行之外读出),`order` 是整数,小的在前。宿主用动作 `hook-joiners` 列出一个挂点的加入者(勾选项形状,可直接给 `coda:optionList`),用 `run-workflows` 的 `hook` 调用它们,`only` 只调用勾中的几个。挂点名是普通字符串,传哪些参数、怎么选由声明它的宿主写在自己的说明里。流程属性 `coda:mergedOnly` 说它是否只运行已合并进默认分支的提交。
|
|
18
|
+
|
|
17
19
|
流程方言的 **勾选项**写在答复(外层的 `coda:choice`)里:`coda:option` 是一项,`coda:optionList` 的 `value` 是一个表达式,任务打开时读出一组勾选项(列表或它的 JSON),在它写的位置展开,两者按写的顺序排。`<coda:options>` 不是它的写法(那个名字是答复自己的勾选项集合)。定义里每个 `coda:optionList` 算一项;打开后的整组由 `workflow/options.json` 定义:每项是 `{ id, name, detail?, default? }`(`default` 为布尔值,没有 `shown`),最多 12 项,id 不重复。`optionsProblem(options, where)` 检查一个答复打开后的整组(静态项已求值、各组已展开),合法时返回 `null`,否则返回「位置:说明」;表达式求值与展开仍由 Coda 完成。
|
|
18
20
|
|
|
19
21
|
流程方言的 **卡片字段**由 `workflow/fields.json` 定义:七种字段各能写哪些属性、必填项、文字长度与单行限制、路径与网址、视图参数、输入框与密钥选项;`values.json` 的 `Field` 引用它,`Fields` 声明读出 JSON 字段列表的表达式,`UserTask.children` 限定最多 12 个静态字段、id 不重复,以及全部字段已知时答复的 `fields` 只能引用输入字段(含按住出现的答复)。
|
package/package.json
CHANGED
package/workflow/actions.json
CHANGED
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
"description": "请运行主体的会话的 Agent 压缩上下文(_coda/session/compact,见 docs/agent-protocol.md),从不失败:没压缩就写明原因"},
|
|
12
12
|
"hold-group": {"params": ["group", "capacity", "borrow", "exclusive"],
|
|
13
13
|
"description": "为这一步所在的那一段排进并发组 group,离开这一段或运行结束才放开;borrow 为 only 只借不排、no 从不借,exclusive 为 true 占满整组"},
|
|
14
|
-
"run-workflows": {"params": ["kind", "commit", "inputs"],
|
|
15
|
-
"description": "在 commit(默认本次运行的)上启动项目里所选种类(kind
|
|
14
|
+
"run-workflows": {"params": ["kind", "hook", "only", "commit", "inputs"],
|
|
15
|
+
"description": "在 commit(默认本次运行的)上启动项目里所选种类(kind,逗号分隔)或加入挂点 hook 的全部流程(两者写一个),only(流程名的 JSON 数组或逗号分隔)只启动其中这几个;各给它声明了的 inputs(JSON 对象),等它们都结束;有一个失败就失败"},
|
|
16
16
|
"workflow-kinds": {"params": ["commit"],
|
|
17
17
|
"description": "项目在这个提交上有没有各种类可调用的流程(项目自己的和启用插件的),各是布尔值"},
|
|
18
|
+
"hook-joiners": {"params": ["hook", "commit"],
|
|
19
|
+
"description": "项目在这个提交上加入挂点 hook 的流程(项目自己的和启用插件的):list 是勾选项形状的数组(id 为流程名、name、detail、default),按 order 排好,可直接给 coda:optionList;count 是个数"},
|
|
18
20
|
"expire-tool-details": {"params": ["olderThan"],
|
|
19
21
|
"description": "运行所属项目的会话里,已结束、最后活动距今超过 olderThan(ISO 8601 时长,如 P7D)的工具调用(含后台任务、用户自己的命令,不含原生子 Agent 卡片),删除完整输入输出,只留卡片摘要;删除不可恢复"},
|
|
20
22
|
"cold-store": {"params": ["anyAfter", "archivedAfter"],
|
package/workflow/moddle.json
CHANGED
|
@@ -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,逗号或空格分隔,不写是全部)、autoRun 事件(如 PR)来时会话与目录都没设「自动运行」的,按它决定起不起运行:true、false 或 =vars
|
|
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.<插件>.<设置>(不写为起)、mergedOnly 只运行已合并进默认分支的提交(写了就按它,不写由 kind 推出)",
|
|
14
14
|
"properties": [
|
|
15
15
|
{"name": "concurrency", "isAttr": true, "type": "String"},
|
|
16
16
|
{"name": "key", "isAttr": true, "type": "String"},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
{"name": "inline", "isAttr": true, "type": "Boolean"},
|
|
22
22
|
{"name": "subagents", "isAttr": true, "type": "Boolean"},
|
|
23
23
|
{"name": "agents", "isAttr": true, "type": "String"},
|
|
24
|
-
{"name": "autoRun", "isAttr": true, "type": "String"}
|
|
24
|
+
{"name": "autoRun", "isAttr": true, "type": "String"}, {"name": "mergedOnly", "isAttr": true, "type": "Boolean"}
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
{
|
|
@@ -119,6 +119,18 @@
|
|
|
119
119
|
{"name": "noteLabel", "isAttr": true, "type": "String"}
|
|
120
120
|
]
|
|
121
121
|
},
|
|
122
|
+
{
|
|
123
|
+
"name": "Join",
|
|
124
|
+
"superClass": ["Element"],
|
|
125
|
+
"description": "流程加入一个挂点:hook 是挂点名,宿主按它找到这个流程;name、detail 是它作为勾选项时的名字与说明,default 是否默认勾上,order 排序(小的在前,不写排最后,同序按流程名)",
|
|
126
|
+
"properties": [
|
|
127
|
+
{"name": "hook", "isAttr": true, "type": "String"},
|
|
128
|
+
{"name": "name", "isAttr": true, "type": "String"},
|
|
129
|
+
{"name": "detail", "isAttr": true, "type": "String"},
|
|
130
|
+
{"name": "default", "isAttr": true, "type": "String"},
|
|
131
|
+
{"name": "order", "isAttr": true, "type": "String"}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
122
134
|
{
|
|
123
135
|
"name": "Input",
|
|
124
136
|
"superClass": ["Element"],
|
package/workflow/values.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"key": {"type": "string", "pattern": "\\S", "maxLength": 4000, "x-feel": {"names": ["inputs", "github", "vars"]}, "description": "coda:key 须为 1–4000 个字符"},
|
|
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", "develop"], "description": "coda:kind 只能是 deploy、preview、release、check、premerge、prebuild、develop"},
|
|
14
|
+
"mergedOnly": {"type": "boolean", "description": "coda:mergedOnly 只能是 true 或 false"},
|
|
14
15
|
"agents": {"type": "string", "pattern": "^[\\s,]*[a-z][a-z0-9-]{0,39}(?:[\\s,]+[a-z][a-z0-9-]{0,39})*[\\s,]*$",
|
|
15
16
|
"description": "coda:agents 写 Agent 的 ID,用逗号或空格分隔(小写字母、数字和「-」,以字母开头,至多 40 个字符),不能为空"},
|
|
16
17
|
"autoRun": {"type": "string", "anyOf": [{"enum": ["true", "false"]}, {"pattern": "^\\s*=\\s*vars(\\.[A-Za-z_][A-Za-z0-9_-]*)+\\s*$"}], "x-feel": {"names": ["vars"]},
|
|
@@ -191,9 +192,22 @@
|
|
|
191
192
|
"Process.children": {
|
|
192
193
|
"type": "object",
|
|
193
194
|
"properties": {
|
|
194
|
-
"input": {"type": "array", "x-unique-by": ["name"], "description": "coda:input 的 name 不能重复"}
|
|
195
|
+
"input": {"type": "array", "x-unique-by": ["name"], "description": "coda:input 的 name 不能重复"},
|
|
196
|
+
"join": {"type": "array", "x-unique-by": ["hook"], "description": "coda:join 的 hook 不能重复:一个流程在一个挂点只加入一次"}
|
|
195
197
|
}
|
|
196
198
|
},
|
|
199
|
+
"Join": {
|
|
200
|
+
"type": "object",
|
|
201
|
+
"properties": {
|
|
202
|
+
"hook": {"type": "string", "pattern": "^[a-z][a-z0-9-]{0,63}$", "description": "hook 须为小写字母开头的小写字母、数字、「-」(至多 64 个字符)"},
|
|
203
|
+
"name": {"type": "string", "pattern": "\\S", "maxLength": 40, "description": "name 须为 1–40 个字"},
|
|
204
|
+
"detail": {"type": "string", "maxLength": 200, "description": "detail 不超过 200 字"},
|
|
205
|
+
"default": {"enum": ["true", "false"], "description": "default 只能是 true 或 false:挂点的列表在任何运行之外读出,不写表达式"},
|
|
206
|
+
"order": {"type": "string", "pattern": "^-?[0-9]{1,6}$", "description": "order 须为整数(至多 6 位)"}
|
|
207
|
+
},
|
|
208
|
+
"required": ["hook"],
|
|
209
|
+
"description": "coda:join 需要 hook"
|
|
210
|
+
},
|
|
197
211
|
"UserTask.children": {
|
|
198
212
|
"type": "object",
|
|
199
213
|
"properties": {
|
package/workflow.mjs
CHANGED
|
@@ -111,12 +111,15 @@ const SIZE_LIMIT = 1_000_000;
|
|
|
111
111
|
// bpmn-moddle rewrites a descriptor as it takes it in (its names get their prefix), and whoever imports CODA_MODDLE may hand
|
|
112
112
|
// it to one: what is read here is a copy taken as this loads, and each parse is given a copy of its own.
|
|
113
113
|
const DESCRIPTOR = structuredClone(moddle);
|
|
114
|
-
// moddle's Boolean/Integer coercion accepts `no` as false and `1.5` as 1. Keep
|
|
115
|
-
// complete spelling is known; valid ones are restored to the descriptor's types before returning the parsed workflow
|
|
116
|
-
|
|
114
|
+
// moddle's Boolean/Integer coercion accepts `no` as false and `1.5` as 1. Keep these attributes as text until their
|
|
115
|
+
// complete spelling is known; valid ones are restored to the descriptor's types before returning the parsed workflow,
|
|
116
|
+
// and the schemas say no to the rest. A field's, and coda:mergedOnly: a misspelling there would quietly run unmerged
|
|
117
|
+
// commits.
|
|
118
|
+
const SCALARS = [['Field', 'coda:Field'], ['ProcessProperties', 'bpmn:Process', ['mergedOnly']]].map(([name, on, only]) => ({ name, on,
|
|
119
|
+
properties: DESCRIPTOR.types.find(type => type.name === name).properties.filter(p => ['Boolean', 'Integer'].includes(p.type) && (!only || only.includes(p.name))) }));
|
|
117
120
|
const PARSER_DESCRIPTOR = structuredClone(DESCRIPTOR);
|
|
118
|
-
for (const property of PARSER_DESCRIPTOR.types.find(type => type.name ===
|
|
119
|
-
if (
|
|
121
|
+
for (const { name, properties } of SCALARS) for (const property of PARSER_DESCRIPTOR.types.find(type => type.name === name).properties)
|
|
122
|
+
if (properties.some(p => p.name === property.name)) property.type = 'String';
|
|
120
123
|
const children = element => Object.values(element).flatMap(v => (Array.isArray(v) ? v : [v])).filter(v => v?.$type && v.$parent === element);
|
|
121
124
|
// Everything in the definition under `element`, depth first, by a stack of its own, pushed one at a time: a definition may
|
|
122
125
|
// nest deeper than the call stack goes, and hold more in one place than a call takes arguments.
|
|
@@ -214,7 +217,8 @@ function valuesProblem(root) {
|
|
|
214
217
|
for (const element of elements) {
|
|
215
218
|
const type = codaType(element);
|
|
216
219
|
if (type) {
|
|
217
|
-
|
|
220
|
+
// What names the element where it is said: its id, a join's hook, or its own name.
|
|
221
|
+
const name = element.id ?? element.hook ?? element.name, kind = type.name === 'Choice' && element.$parent?.$type === 'coda:Choice' ? 'NestedChoice' : type.name;
|
|
218
222
|
const problem = failed(check(kind), codaObject(element), `${owner(element)?.id} 的 coda:${lower(type.name)}${name ? ` ${name}` : ''}`, false, ['Field', 'Fields'].includes(kind));
|
|
219
223
|
if (problem) return problem;
|
|
220
224
|
continue;
|
|
@@ -257,10 +261,10 @@ export async function readWorkflow(source, file = 'workflow') {
|
|
|
257
261
|
catch (e) { return { problem: `${file}.bpmn 不是有效的 BPMN 2.0:${e.message}` }; }
|
|
258
262
|
const { rootElement: root, warnings } = parsed;
|
|
259
263
|
if (warnings.length) return { problem: `${file}.bpmn 有无法识别的内容:${warnings.slice(0, 3).map(w => w.message).join(';')}` };
|
|
260
|
-
for (const
|
|
261
|
-
const value =
|
|
262
|
-
if (type === 'Boolean' && ['true', 'false'].includes(value))
|
|
263
|
-
if (type === 'Integer' && typeof value === 'string' && /^[+-]?\d+$/.test(value))
|
|
264
|
+
for (const { on, properties } of SCALARS) for (const element of all(root).filter(e => e.$type === on)) for (const { name, type } of properties) {
|
|
265
|
+
const value = element[name];
|
|
266
|
+
if (type === 'Boolean' && ['true', 'false'].includes(value)) element[name] = value === 'true';
|
|
267
|
+
if (type === 'Integer' && typeof value === 'string' && /^[+-]?\d+$/.test(value)) element[name] = Number(value);
|
|
264
268
|
}
|
|
265
269
|
for (const task of all(root).filter(e => e.$type === 'bpmn:ServiceTask' && e.action !== undefined)) {
|
|
266
270
|
if (!Object.hasOwn(CODA_ACTIONS, task.action)) return { problem: `${task.id}:coda:action 只能是 ${Object.keys(CODA_ACTIONS).join('、')}` };
|