@coda-console/protocol 6.11.0 → 6.12.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,12 @@
2
2
 
3
3
  版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
4
4
 
5
+ ## 6.12.0 — 2026-11-18
6
+
7
+ - 这是在 6.11.0 之上的次版本。依据 README「版本」一节:`contributes.groups` 与流程方言都是内部面,删改、新增可选参数升次版本。`stable/manifest.json` 里没有 `groups`,删它不动稳定面,`stable-grows` 与 `test/stable.test.mjs` 不受影响。
8
+ - 流程方言:`hold-group` 加参数 `select`,按池子借:逗号分隔的 `键=值`,全部与组记录的 `attributes` 相等才算匹配,只匹配 `attributes`,如 `platform=android`、`platform=ios,model=duo`;`group`、`select` 恰写一个,两个都写或都不写,读流程就拒(`group、select 须恰写一个`)。`select` 写成纯文本时读流程就按 `键=值(,键=值)*` 查(键是 1–100 个不含空白、「=」「,」的字符;值是 1–100 个不含「=」「,」的字符,中间可有空格如 `model=Mi 10 Pro`,首尾不能是空白;长度按字符计,补充平面字符算一个),写成表达式或含 `{{ … }}` 时留到运行时。输出 `group` 是实际排到的那个组的名字。脚本步骤上的 `coda:group` 不加选择器。`workflow/actions.json` 的动作定义因此多了 `oneOf`(列出的参数恰写一个)与 `pattern`(参数写成文字时的写法)。
9
+ - 不兼容:删掉 `contributes.groups`:删去 `schemas/plugin/groups.json`。名额不再由插件在清单里声明,改由插件写 `coda/group@1` 记录,容量取记录的 `capacity`(不写为 1)。`extension-points.json` 里保留键名单的 `groups` 留着,第三方仍不能把它当扩展点的键。清单里再写 `contributes.groups` 的结果与别的不认识的键一样:不查形状,`manifestProblem` 通过。README 里 `contributionProblem` 的示例改用 `modelProviders`。
10
+
5
11
  ## 6.11.0 — 2026-11-18
6
12
 
7
13
  - 这是在 6.10.0 之上的次版本。依据 README「版本」一节:协议定义是内部面,新增可选字段升次版本;`stable/` 不动,`stable/manifest.json` 与 `stable/view.json` 没有任何协议定义的字段,清单与页面接口都没变,旧清单、旧定义照旧通过(Coda 宿主设计 coda#2749 第 12 节,只读记录流)。
package/README.md CHANGED
@@ -40,7 +40,7 @@ import { contributionProblem, manifestProblem, pointProblem, valueProblem, TYPES
40
40
  // 整份清单的外壳与通用键;给出插件目录时,连同它点名的文件一起查(x-file)。合乎类型返回 null,否则是一句说明:哪里、schema 怎么说。
41
41
  const manifest = JSON.parse(readFileSync('plugin/package.json', 'utf8'));
42
42
  const problem = manifestProblem(manifest, 'plugin');
43
- // 不是通用键的一个键,按声明它的一方给的 schema,放在整份清单里查:指针从清单的根算(groups 的 capacity 指向本插件的设置)。
43
+ // 不是通用键的一个键,按声明它的一方给的 schema,放在整份清单里查:指针从清单的根算(modelProviders 的 ${config:…} 指向本插件的设置)。
44
44
  contributionProblem(SCHEMAS['agents.json'], manifest, 'agents', 'plugin');
45
45
  // 某个类型里的一部分,如输入框模式声明的参数。
46
46
  valueProblem('composer-modes.json#/$defs/parameters', parameters, '插件给出的参数');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/protocol",
3
- "version": "6.11.0",
3
+ "version": "6.12.0",
4
4
  "description": "Coda 的协议:插件清单的类型(JSON Schema)、通用校验器、协议定义与调用信封、流程方言与 Agent 接入协议",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "coda:action:serviceTask 上写它,就是 Coda 在后端里做的一步,不写脚本。参数写成 <coda:param name value>,只认 params 列出的,required 列出的必须写;requires 写了某参数就必须同时写它列出的参数;enum 限定某参数写成文字(不是表达式、不含 {{ … }})时的取值",
2
+ "description": "coda:action:serviceTask 上写它,就是 Coda 在后端里做的一步,不写脚本。参数写成 <coda:param name value>,只认 params 列出的,required 列出的必须写;requires 写了某参数就必须同时写它列出的参数;oneOf 列出的参数恰写一个;enum 限定某参数写成文字(不是表达式、不含 {{ … }})时的取值;pattern 限定某参数写成文字时的写法",
3
3
  "actions": {
4
4
  "publish-stage": {"params": ["stage", "detail"],
5
5
  "description": "发布运行主体的会话此刻在流程里的阶段(stage)和放在状态旁的说明(detail),两者都空就是清掉;只用于由会话事件启动的运行"},
@@ -9,8 +9,10 @@
9
9
  "description": "停掉运行主体的会话托管的 Agent 进程,下次发消息时透明恢复;result 是 stopped、absent 或 busy"},
10
10
  "compact-session": {"params": [],
11
11
  "description": "请运行主体的会话的 Agent 压缩上下文(_coda/session/compact,见 docs/agent-protocol.md),从不失败:没压缩就写明原因"},
12
- "hold-group": {"params": ["group", "capacity", "borrow", "exclusive"],
13
- "description": "为这一步所在的那一段排进并发组 group,离开这一段或运行结束才放开;borrow 为 only 只借不排、no 从不借,exclusive 为 true 占满整组"},
12
+ "hold-group": {"params": ["group", "select", "capacity", "borrow", "exclusive"],
13
+ "oneOf": ["group", "select"],
14
+ "pattern": {"select": {"regex": "^[^\\s=,]{1,100}=[^\\s=,](?:[^=,]{0,98}[^\\s=,])?(,[^\\s=,]{1,100}=[^\\s=,](?:[^=,]{0,98}[^\\s=,])?)*$", "hint": "键=值,多个用逗号隔开,值的首尾不能是空白,如 platform=android,model=Mi 10 Pro"}},
15
+ "description": "为这一步所在的那一段排进并发组,离开这一段或运行结束才放开:group 点名一个组;select 按池子借,是逗号分隔的 键=值,全部与组记录的 attributes 相等才算匹配(如 platform=android),从匹配的组里挑一个排;group、select 恰写一个,输出 group 是实际排到的那个组的名字;borrow 为 only 只借不排、no 从不借,exclusive 为 true 占满整组"},
14
16
  "run-workflows": {"params": ["hook", "only", "commit", "inputs"], "required": ["hook"],
15
17
  "description": "在 commit(默认本次运行的)上启动项目里加入挂点 hook 的全部流程(项目自己的和启用插件的),only(流程名的 JSON 数组或逗号分隔)只启动其中这几个;各给它声明了的 inputs(JSON 对象),等它们都结束;有一个失败就失败"},
16
18
  "hook-joiners": {"params": ["hook", "commit"],
package/workflow.mjs CHANGED
@@ -37,9 +37,10 @@ export const CODA_OPTIONS = options;
37
37
  export const CODA_ACTIONS = Object.fromEntries(Object.entries(actions.actions).map(([name, action]) => [name, action.params]));
38
38
  // The parameters an action must be given, by its name; an action with none is not listed.
39
39
  const REQUIRED_PARAMS = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.required).map(([name, action]) => [name, action.required]));
40
- // What an action's parameters must keep to besides being named: the others one needs (`requires`, by parameter), and the
41
- // values a parameter written as plain text may take (`enum`); an action with neither is not listed.
42
- const PARAM_RULES = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.requires || action.enum).map(([name, action]) => [name, action]));
40
+ // What an action's parameters must keep to besides being named: the others one needs (`requires`, by parameter), exactly
41
+ // one of which to write (`oneOf`), and the values (`enum`) or the form (`pattern`) a parameter written as plain text may
42
+ // take; an action with none of them is not listed.
43
+ const PARAM_RULES = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.requires || action.oneOf || action.enum || action.pattern).map(([name, action]) => [name, action]));
43
44
  // The events Coda sends (dialect.json says what each is).
44
45
  export const CODA_EVENTS = Object.keys(dialect.events);
45
46
  export const { lifecycleStart: SESSION_OPENED, lifecycleFacts: SESSION_FACTS, dispatch: DISPATCH_EVENT, cancel: CANCEL_EVENT } = dialect.eventRoles;
@@ -310,6 +311,14 @@ export async function readWorkflow(source, file = 'workflow') {
310
311
  for (const [name, needs] of Object.entries(PARAM_RULES[task.action]?.requires ?? {}))
311
312
  if (given.some(p => p.name === name) && needs.some(need => !given.some(p => p.name === need)))
312
313
  return { problem: `${task.id}:coda:action ${task.action} 写了参数 ${name} 就须写参数 ${needs.join('、')}` };
314
+ const oneOf = PARAM_RULES[task.action]?.oneOf;
315
+ if (oneOf && given.filter(p => oneOf.includes(p.name)).length !== 1)
316
+ return { problem: `${task.id}:coda:action ${task.action} 的参数 ${oneOf.join('、')} 须恰写一个` };
317
+ for (const [name, { regex, hint }] of Object.entries(PARAM_RULES[task.action]?.pattern ?? {})) {
318
+ const value = given.find(p => p.name === name)?.value;
319
+ if (value !== undefined && !isExpression(value) && !value.includes('{{') && !new RegExp(regex, 'u').test(value))
320
+ return { problem: `${task.id}:coda:action ${task.action} 的参数 ${name} 须为 ${hint}` };
321
+ }
313
322
  for (const [name, values] of Object.entries(PARAM_RULES[task.action]?.enum ?? {})) {
314
323
  const value = given.find(p => p.name === name)?.value;
315
324
  if (value !== undefined && !isExpression(value) && !value.includes('{{') && !values.includes(value))
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://coda.pub/schemas/plugin/v2/groups.json",
4
- "title": "contributes.groups:并发组",
5
- "description": "有名字、有容量的锁:name 是任何进程都能拿的组名,capacity 是本插件的一项整数设置,说同时放进几个。",
6
- "type": "array",
7
- "items": {
8
- "type": "object",
9
- "properties": {
10
- "name": {"description": "组名:1–100 个非空白字符", "type": "string", "pattern": "^\\S{1,100}$"},
11
- "capacity": {
12
- "description": "capacity 是本插件声明的一项整数设置",
13
- "type": "string",
14
- "x-ref": {"pointer": "/contributes/configuration/properties", "match": {"properties": {"type": {"const": "integer"}}, "required": ["type"]}}
15
- }
16
- },
17
- "required": ["name", "capacity"],
18
- "additionalProperties": false
19
- },
20
- "x-unique-by": ["name"]
21
- }