@coda-console/protocol 6.6.0 → 6.8.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,19 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.8.0 — 2026-11-17
|
|
6
|
+
|
|
7
|
+
- 这是在 6.7.0 之上的次版本。依据 README「版本」一节:清单的通用键放宽写法、旧写法照旧通过,升次版本(Coda 宿主设计 coda#2749 第 4、5 节与 6.7 节)。
|
|
8
|
+
- `contributes.protocolImplementations` 的每一项除了协议名(文本,这个协议的全部操作由模块实现),也可以是对象 `{ kind, commands }`:`kind` 是协议名;`commands` 至少一项,键是操作名(只按定义里 `operations` 键名的格式校验,在不在定义里由 Coda 装载时查),值是插件目录里的文件(`x-file`);没列在 `commands` 里的操作由模块实现;不允许别的键。上限仍是 100 项。
|
|
9
|
+
- 同一个协议在数组里只能出现一次,文本加对象、两个对象也算重复(原来的 `uniqueItems` 管不到混写)。为此 `x-unique-by` 加写法 `{ key, text: true }`:文本项按它自己的值、对象项按 `key` 属性的值一并查重;`docs/protocol.md` 同步写清两种写法。已有的纯文本写法不受影响。
|
|
10
|
+
- `contributes.commands` 的保留名单改了:宿主 H5 在同一次交付里把 `coda-run`、`coda-event`、`coda-resources` 并成一个 `coda`、删掉旧名(coda#2749 6.7 节第 3 条)。现在插件的命令不能叫 `coda`;`coda-run`、`coda-event`、`coda-resources` 不再保留,可以用。`schemas/plugin/commands.json` 的 `name` 描述同步。
|
|
11
|
+
- 版本判断:不升主版本,升到 6.8.0。`contributes.commands[].name` 虽在稳定面,但稳定面条目没有登记取值(`values`),承诺的只是「这个键存在、可写命令名」;保留名是 Coda 自己占用的命令名,插件写 `coda` 会盖掉宿主工具,本就不是被承诺的用法。三个旧名放开是放宽,只多接受;新增的 `coda` 只会拒掉一个从未被承诺、也没有已知插件在用的名字(样本里没有),三道检查都不受影响。
|
|
12
|
+
|
|
13
|
+
## 6.7.0 — 2026-11-17
|
|
14
|
+
|
|
15
|
+
- 这是在 6.6.0 之上的次版本。依据 README「版本」一节:协议定义是内部面,新增可选字段升次版本,先例见 6.4.0(`deadline`)。
|
|
16
|
+
- `coda/session@1` 的 `status` 加可选布尔字段 `notify`:Provider 写 `true` 表示这条记录来了新消息要提醒用户(观察方推到手机、电脑弹横幅,读到 `head` 后撤掉);不写或 `false` 不提醒,是缺省,旧 Provider 的记录不会开始提醒。`docs/protocol.md` 的 status 表与说明同步。
|
|
17
|
+
|
|
5
18
|
## 6.6.0 — 2026-11-17
|
|
6
19
|
|
|
7
20
|
- 这是在 6.5.0 之上的次版本。依据 README「版本」一节:Agent 接入协议是内部面,新增类别与可选字段升次版本,先例见 6.2.0(`auth_required`)。
|
package/docs/protocol.md
CHANGED
|
@@ -187,7 +187,19 @@ invocationResponseProblem(response); // 恰好有 result 或 run 之一
|
|
|
187
187
|
}
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
`contributes.protocols` 是插件拥有的定义,每份都按定义文档 schema 校验;定义里的命名空间必须等于插件 ID。`contributes.protocolImplementations`
|
|
190
|
+
`contributes.protocols` 是插件拥有的定义,每份都按定义文档 schema 校验;定义里的命名空间必须等于插件 ID。`contributes.protocolImplementations` 是插件实现的协议列表,可以包含别的命名空间下的协议(包括 `coda/...`),最多 100 项。每项有两种写法:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
"protocolImplementations": [
|
|
194
|
+
"my-plugin/task@1",
|
|
195
|
+
{"kind": "coda/run@1", "commands": {"cancel": "bin/cancel.sh"}}
|
|
196
|
+
]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- 协议名(文本):这个协议的全部操作都由模块实现。
|
|
200
|
+
- `{ "kind": "<协议名>", "commands": { "<操作名>": "<文件>" } }`:`commands` 至少一项,键是操作名(格式同定义里 `operations` 的键,这个操作在不在协议定义里由 Coda 装载时查),值是插件目录里的文件(相对路径,不离开插件目录)。`commands` 里列出的操作由这个文件实现,**没列在 `commands` 里的操作由模块实现**。对象里不能有 `kind`、`commands` 之外的键。命令怎么写、怎么跑由 Coda 的文档讲,这里不重述。
|
|
201
|
+
|
|
202
|
+
同一个协议在数组里只能出现一次,写成文本还是对象都算。
|
|
191
203
|
|
|
192
204
|
`manifestProblem` 校验清单的外壳与通用键(这两个键在其中);别的键由 Coda 的贡献点登记表或某个插件的扩展点声明,按声明方的 schema 校验,本包不管它们的形状。命名空间约束需要插件 ID,单独用:
|
|
193
205
|
|
|
@@ -311,6 +323,7 @@ status:
|
|
|
311
323
|
| `reason` | 可选,状态说明 |
|
|
312
324
|
| `activity` | 可选,`{ participant, text }`:参与者正在做什么 |
|
|
313
325
|
| `accepts` | 可选,`post` 除文字以外还收哪些媒体 part,见下 |
|
|
326
|
+
| `notify` | 可选,布尔:`true` 表示这条记录来了新消息要提醒用户,见下 |
|
|
314
327
|
|
|
315
328
|
`activity.participant` 须是 `status.participants` 中某一项的 `id`;Provider 负责保证这个对应关系。`text` 是 1 到 200 个字符的单行文字(不含换行符),如「正在搜索代码」。
|
|
316
329
|
像聊天软件的「正在输入」:Provider 不提供就不写,对方停下时删掉整个 `activity`。它不是消息,不进 `read`,不推进 `head`。
|
|
@@ -331,6 +344,9 @@ status:
|
|
|
331
344
|
{"participants": [], "accepts": {"audio": {"maxDuration": 60}}}
|
|
332
345
|
```
|
|
333
346
|
|
|
347
|
+
`notify: true` 表示这条记录来了新消息要提醒用户:观察方(Coda)在 `head` 越过用户的已读位置时推到手机、在电脑上弹横幅,读到 `head` 后撤掉。不写或写 `false` 就不提醒,这是缺省,所以不认识这个字段的旧 Provider 不会开始提醒。
|
|
348
|
+
写不写由 Provider 按记录决定,比如只给用户在设置里选中的群写 `true`;设置改了就改 status,所以它放在 status 而不在 spec。提醒只说「有新消息」,不带消息正文。
|
|
349
|
+
|
|
334
350
|
观察方 watch 这条记录,`head` 变了就用 `read` 读游标之后的消息。`read` 与 `draft` 是立即结果,`read` 是 `safe` 的,`draft` 是 `idempotent` 的;`post` 开运行:
|
|
335
351
|
|
|
336
352
|
- `read`:输入 `{ after?, before?, limit? }`,`after`、`before` 是游标,`limit` 为 1 到 100;结果 `{ messages, cursor, more }`,没有消息时 `cursor` 为 `null`。`messages` 总按先后排,旧的在前:
|
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"type": "object",
|
|
9
9
|
"properties": {
|
|
10
10
|
"name": {
|
|
11
|
-
"description": "命令名:小写字母、数字和「-」,以字母开头,不能是 Coda 自己的 coda
|
|
11
|
+
"description": "命令名:小写字母、数字和「-」,以字母开头,不能是 Coda 自己的 coda",
|
|
12
12
|
"$ref": "common.json#/$defs/id",
|
|
13
|
-
"not": {"
|
|
13
|
+
"not": {"const": "coda"}
|
|
14
14
|
},
|
|
15
15
|
"command": {"$ref": "common.json#/$defs/command"}
|
|
16
16
|
},
|
|
@@ -2,9 +2,28 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://coda.pub/schemas/plugin/v2/protocol-implementations.json",
|
|
4
4
|
"title": "contributes.protocolImplementations:插件实现的协议",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "插件实现哪些协议,写协议名「命名空间/名字@大版本」。可以实现在别的命名空间下定义的协议。每项是文本(这个协议的全部操作由模块实现),或 { kind, commands }(commands 里列出的操作由插件目录里的命令实现,没列的由模块实现)。同一个协议只能出现一次,不论写成文本还是对象。",
|
|
6
6
|
"type": "array",
|
|
7
7
|
"maxItems": 100,
|
|
8
|
-
"
|
|
9
|
-
"items": {
|
|
8
|
+
"x-unique-by": [{"key": "kind", "text": true}],
|
|
9
|
+
"items": {
|
|
10
|
+
"if": {"type": "string"},
|
|
11
|
+
"then": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/name"},
|
|
12
|
+
"else": {
|
|
13
|
+
"description": "不是协议名时须为 { kind, commands },按命令实现这个协议的部分操作:kind 是协议名,commands 的键是操作名,值是插件目录里的文件",
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"kind": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/name"},
|
|
17
|
+
"commands": {
|
|
18
|
+
"description": "操作名 → 插件目录里的文件(相对路径,不离开插件目录),至少一项;操作是否在协议定义里由 Coda 装载时查",
|
|
19
|
+
"type": "object",
|
|
20
|
+
"minProperties": 1,
|
|
21
|
+
"propertyNames": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/operationName"},
|
|
22
|
+
"additionalProperties": {"type": "string", "x-file": {"type": "file"}}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["kind", "commands"],
|
|
26
|
+
"additionalProperties": false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
10
29
|
}
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"state": {"enum": ["active", "unreachable"]},
|
|
74
74
|
"reason": {"type": "string", "maxLength": 4096, "description": "状态说明,可选"},
|
|
75
|
+
"notify": {"type": "boolean", "description": "新消息是否提醒用户:写 true 才提醒(推到手机、电脑弹横幅),不写或 false 不提醒。由 Provider 按记录决定,可随设置变化,所以放在 status"},
|
|
75
76
|
"accepts": {
|
|
76
77
|
"type": "object",
|
|
77
78
|
"description": "post 除文字以外还收哪些媒体 part,键是 part 的 type,值是这一类型的限制;不写就是只收文字。能力可能随状态变化,所以放在 status",
|
package/validate.mjs
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// as Kubernetes extends its OpenAPI with `x-kubernetes-*`:
|
|
11
11
|
// - `x-unique-by`: [name, { part } or { key, nested }] — in an array, each named property of its objects is unique among the
|
|
12
12
|
// items having it, and so is `part`'s first group of each of its texts (a directory's last name), and `key` among the
|
|
13
|
-
// items and those in their `nested` arrays, at every depth (a task's answers and those offered on holding one)
|
|
13
|
+
// items and those in their `nested` arrays, at every depth (a task's answers and those offered on holding one), and with
|
|
14
|
+
// `text: true` a text item counts as the value of `key` itself (an item written as a name or as an object with it);
|
|
14
15
|
// - `x-max-contains`: { match, max } — of an object's values, at most `max` satisfy `match` (`maxContains` of an object);
|
|
15
16
|
// - `x-ref`: { pointer, part?, key?, split?, match? } — the value (or `part`'s first group of it), or each nonempty token
|
|
16
17
|
// separated by `split`, names a key of the object, or an element (with `key`, that property of an element)
|
|
@@ -60,7 +61,8 @@ const META = {
|
|
|
60
61
|
'x-max-contains': { type: 'object', properties: { match: SCHEMA_VALUE, max: { type: 'integer', minimum: 0 } }, required: ['match', 'max'], additionalProperties: false },
|
|
61
62
|
'x-unique-by': { type: 'array', minItems: 1, items: { anyOf: [{ type: 'string' },
|
|
62
63
|
{ type: 'object', properties: { part: { type: 'string' } }, required: ['part'], additionalProperties: false },
|
|
63
|
-
{ type: 'object', properties: { key: { type: 'string' }, nested: { type: 'string' } }, required: ['key', 'nested'], additionalProperties: false }
|
|
64
|
+
{ type: 'object', properties: { key: { type: 'string' }, nested: { type: 'string' } }, required: ['key', 'nested'], additionalProperties: false },
|
|
65
|
+
{ type: 'object', properties: { key: { type: 'string' }, text: { const: true } }, required: ['key', 'text'], additionalProperties: false }] } },
|
|
64
66
|
'x-ref': { type: 'object', properties: { pointer: { type: 'string', pattern: '^(?:\\d+(?:/.*)?|/.*)$' }, part: { type: 'string' }, key: { type: 'string' }, split: { type: 'string' }, match: SCHEMA_VALUE },
|
|
65
67
|
required: ['pointer'], additionalProperties: false },
|
|
66
68
|
'x-placeholders': { type: 'object', properties: { names: { type: 'array', items: { type: 'string' } }, config: SCHEMA_VALUE }, additionalProperties: false },
|
|
@@ -111,14 +113,15 @@ function keywords(ajv) {
|
|
|
111
113
|
return found;
|
|
112
114
|
};
|
|
113
115
|
return function unique(items) {
|
|
114
|
-
for (const { key, part, nested } of by) {
|
|
116
|
+
for (const { key, part, nested, text } of by) {
|
|
115
117
|
const seen = new Set();
|
|
116
118
|
for (const item of every(items, nested)) {
|
|
117
119
|
const value = part ? (typeof item === 'string' ? part.exec(item)?.[1] : undefined)
|
|
120
|
+
: text && typeof item === 'string' ? item
|
|
118
121
|
: item && typeof item === 'object' && Object.hasOwn(item, key) ? item[key] : undefined;
|
|
119
122
|
if (value === undefined) continue;
|
|
120
123
|
const said = JSON.stringify(value);
|
|
121
|
-
if (seen.has(said)) return fail(unique, 'x-unique-by', part ? `不能重复:${value}` : `${key} 不能重复:${value}`, parentSchema);
|
|
124
|
+
if (seen.has(said)) return fail(unique, 'x-unique-by', part || text ? `不能重复:${value}` : `${key} 不能重复:${value}`, parentSchema);
|
|
122
125
|
seen.add(said);
|
|
123
126
|
}
|
|
124
127
|
}
|