@coda-console/protocol 6.25.0 → 6.27.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 +14 -0
- package/README.md +5 -3
- package/docs/agent-protocol.md +3 -1
- package/docs/protocol.md +6 -0
- package/package.json +1 -1
- package/plugin.d.mts +11 -0
- package/schemas/agent/elicitation-denial.json +33 -0
- package/schemas/plugin/optional-protocol-implementations.json +10 -0
- package/schemas/plugin/plugin.json +2 -0
- package/schemas/plugin/reserved-accord-kinds.json +13 -0
- package/validate.mjs +18 -2
- package/workflow/moddle.json +3 -2
- package/workflow/values.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.27.0 — 2026-11-24
|
|
6
|
+
|
|
7
|
+
- 这是在 6.26.0 之上的次版本。依据 README「版本」一节:新增可选的清单键升次版本;这两个键暂不进稳定面,`stable/` 不动,旧清单不受影响(没写这两个键的清单照旧合法)。
|
|
8
|
+
- `contributes` 加两个可选键,各有一份 schema:`optionalProtocolImplementations`(`schemas/plugin/optional-protocol-implementations.json`)是可选实现的协议名数组,每项同 `protocolImplementations` 的文本项,不收 `{ kind, commands }`,至多 100 项、不重复;协议本机没有时插件照常运行、这一项不生效。`reservedAccordKinds`(`schemas/plugin/reserved-accord-kinds.json`)是只归本插件的 Accord 签名记录种类数组,每项匹配 `^[a-z0-9-]{1,64}/[a-z0-9-]{1,64}$`(命名空间必带),至多 32 项、不重复;只有本插件能直接发布、撤回、读这些种类。
|
|
9
|
+
- 两条跨键规则,由 `validate.mjs` 的 `manifestProblem` 在整份清单的 schema 通过后用代码查(没有新增 schema 关键字,两个键的 schema 文件单独用时只校验形状):`optionalProtocolImplementations` 的每项不能已在 `protocolImplementations` 里(文本项或对象项的 `kind` 都算);`reservedAccordKinds` 每项的命名空间须等于清单的 `id`(没写 `id` 用 `name`)。报错说明是哪个键、哪一项。`TYPES` 随之多这两个键。
|
|
10
|
+
- `./types`(`plugin.d.mts`)新增导出 `ManifestContributions`,只含这两个可选键;清单的其余键还没有类型。
|
|
11
|
+
- 协议包只校验形状;协议在不在、这一项生不生效、谁被拒绝由 Coda 宿主判定。
|
|
12
|
+
|
|
13
|
+
## 6.26.0 — 2026-11-24
|
|
14
|
+
|
|
15
|
+
- 这是在 6.25.0 之上的次版本。依据 README「版本」一节:流程方言与 Agent 接入协议是内部面,只加可选属性与约定,升次版本;`stable/` 不动,清单 schema 没改。6.25.0 下合法的流程仍合法。
|
|
16
|
+
- 流程属性 `coda:questionDenial`(字符串):写了它,运行期间,持有这个运行或它的子运行里没结束的 agent 任务的会话向用户提问时,宿主当场拒绝,把这段文字回给 Agent;不写就不拦。权限审批、链接表单、密钥卡、请用户操作桌面、指给用户的流程任务都不拦。父子运行都声明时:从会话所持任务所在的运行开始往上找,用离它最近的一段;子运行没声明,就沿用祖先的声明。写了就须非空白,1–2000 个字符(以 `workflow/values.json` 里的定义为准),空串与全空白读流程时报错(不想拦就不写)。README 的流程方言补这条。
|
|
17
|
+
- Agent 接入协议:宿主因流程声明(`coda:questionDenial`)拦下轮内的 `elicitation/create` 表单时,回 `action: decline` 且必须带 `_meta.coda.reason`;Agent 插件见到 reason 就把这段文字原样交给模型。没带 reason 的 `decline` 语义不变,仍是用户拒绝;轮次限制无条件,拦截只适用于轮内 form,轮次之外的表单照旧回 `cancel`。`docs/agent-protocol.md` 补 `_meta.coda.reason`,新增 `schemas/agent/elicitation-denial.json`(`reason` 须为非空字符串,只出现在 `decline` 的表单结果里,不带 reason 的普通 `decline` 仍合法),登记在文中的 schema 索引表,`agentValueProblem('elicitation-denial.json', result)` 可校验。
|
|
18
|
+
|
|
5
19
|
## 6.25.0 — 2026-11-24
|
|
6
20
|
|
|
7
21
|
- 这是在 6.24.0 之上的次版本。依据 README「版本」一节:协议定义是内部面,只加可选的键和类型字段,升次版本;`stable/` 不动,清单 schema 没改。三处都是只增:6.24.0 下合法的定义仍合法。
|
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Coda 与插件之间的约定,Coda 和插件都引用它,独立演进:
|
|
4
4
|
|
|
5
|
-
- **插件清单的类型**(`schemas/plugin/`):插件目录 `package.json` 里 `contributes` 的每个键是一种类型,各有一份 JSON Schema(draft 2020-12,`$id` 为 `https://coda.pub/schemas/plugin/v2/<文件>`)。`plugin.json` 是整份清单,只列通用键(`configuration`、`services`、`setup`、`environment`、`path`、`views`、`protocols`、`protocolImplementations`、`records`);`setting.json` 是一项设置的声明。其余键由 Coda 的贡献点登记表声明:Coda 自己的(`agents`、`composerModes`、`modelProviders` 等)的 schema 仍放在这里作公开数据(如 `agents.json`、`composer-modes.json`),由登记它的 provider 引用;`contributes` 里只有 Coda 认得的键。
|
|
6
|
-
- **通用校验器**(`validate.mjs`):用 Ajv 对清单做 schema 校验。JSON Schema 说不了的只用五个通用关键字(`x-unique-by`、`x-max-contains`、`x-ref`、`x-placeholders`、`x-file`,照 Kubernetes 的 `x-kubernetes-*`),每个在哪里写都是同一个意思,写法见文件开头。校验器不随功能变长:类型加字段就是改 schema
|
|
5
|
+
- **插件清单的类型**(`schemas/plugin/`):插件目录 `package.json` 里 `contributes` 的每个键是一种类型,各有一份 JSON Schema(draft 2020-12,`$id` 为 `https://coda.pub/schemas/plugin/v2/<文件>`)。`plugin.json` 是整份清单,只列通用键(`configuration`、`services`、`setup`、`environment`、`path`、`views`、`protocols`、`protocolImplementations`、`optionalProtocolImplementations`、`reservedAccordKinds`、`records`);`setting.json` 是一项设置的声明。其余键由 Coda 的贡献点登记表声明:Coda 自己的(`agents`、`composerModes`、`modelProviders` 等)的 schema 仍放在这里作公开数据(如 `agents.json`、`composer-modes.json`),由登记它的 provider 引用;`contributes` 里只有 Coda 认得的键。
|
|
6
|
+
- **通用校验器**(`validate.mjs`):用 Ajv 对清单做 schema 校验。JSON Schema 说不了的只用五个通用关键字(`x-unique-by`、`x-max-contains`、`x-ref`、`x-placeholders`、`x-file`,照 Kubernetes 的 `x-kubernetes-*`),每个在哪里写都是同一个意思,写法见文件开头。校验器不随功能变长:类型加字段就是改 schema。例外是清单级的两条跨字段约束:`manifestProblem` 在 schema 通过后还会检查,同一协议不能既是必需实现(`protocolImplementations`)又是可选实现(`optionalProtocolImplementations`),保留种类(`reservedAccordKinds`)的命名空间须等于插件 ID;只拿 `plugin.json` 校验,只查形状,这两条不在内。
|
|
7
7
|
- **协议定义与调用**(`schemas/protocol/`、`protocol.mjs`、`docs/protocol.md`):协议是 `命名空间/名字@大版本` + spec/status 的 JSON Schema + 操作;插件在 `contributes.protocols` 里定义自己命名空间下的协议,在 `contributes.protocolImplementations` 里声明实现哪些协议;定义可写 `streams` 声明记录流(读、写、原样 HTTP 三种形状,字节或帧),可写 `events` 声明事件(载荷格式与 `starts`、`ends`;只有事件的协议可以不写 `spec`、`status`、`operations`,`protocolHasRecords` 判断一份定义有没有记录),可写 `permissions` 把操作、流、事件与记录的读取分成权限组,插件在清单根的 `uses`(必需)或 `optionalUses`(可选)里按组申请。调用是 `{ record, operation, input, requestId, parent, awaited }`,回答是 `{ result }` 或 `{ run }`;`coda/run@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`、执行失败、工具调用的审核、配置探测)。
|
|
@@ -16,6 +16,8 @@ Coda 与插件之间的约定,Coda 和插件都引用它,独立演进:
|
|
|
16
16
|
|
|
17
17
|
流程方言的 **挂点**是流程之间互相找到的方式:被调用的流程在自己的 extensionElements 里写 `<coda:join hook name? detail? default? order?/>` 加入一个挂点(`hook` 是小写字母开头的名字,一个流程每个挂点只加入一次),`name`、`detail` 是它作为勾选项时的名字与说明,`default` 是否默认勾上(只写 true 或 false:挂点的列表在任何运行之外读出),`order` 是整数,小的在前;`inputs` 是它要从卡片拿的自己的文字参数(`coda:input`,type 为 string,逗号或空格分隔,最多 4 个,读流程时检查),`joinInputNames(join)` 读出这些名字。宿主用动作 `hook-joiners` 列出一个挂点的加入者(勾选项形状,带上各自的 `inputs`,可直接给 `coda:optionList`),用 `run-workflows` 的 `hook`(必写)调用它们,`only` 只调用勾中的几个。挂点名是普通字符串,传哪些参数、怎么选由声明它的宿主写在自己的说明里。流程属性 `coda:mergedOnly` 说它是否只运行已合并进默认分支的提交,不写为 false(任何提交都能跑)。
|
|
18
18
|
|
|
19
|
+
流程方言的 **拦下提问**由流程属性 `coda:questionDenial` 声明(字符串):写了它,这个运行进行期间,持有这个运行或它的子运行里没结束的 agent 任务的会话,向用户提问时,宿主当场拒绝,把这段文字回给 Agent(表单回 `decline`,文字放在 `_meta.coda.reason`,见 [Agent 接入协议](docs/agent-protocol.md));不写就不拦。父子运行都声明时:从会话所持任务所在的运行开始往上找,用离它最近的一段;子运行没声明,就沿用祖先的声明。它自己的要求:非空白,1–2000 个字符(以 `workflow/values.json` 里的定义为准),空串或全空白读流程时报错,不想拦就别写。权限审批、链接表单、密钥卡、请用户操作桌面、指给用户的流程任务(`coda:assignee="user"`),都不拦。
|
|
20
|
+
|
|
19
21
|
流程方言的 **勾选项**写在答复(外层的 `coda:choice`)里:`coda:option` 是一项,`coda:optionList` 的 `value` 是一个表达式,任务打开时读出一组勾选项(列表或它的 JSON),在它写的位置展开,两者按写的顺序排。`<coda:options>` 不是它的写法(那个名字是答复自己的勾选项集合)。定义里每个 `coda:optionList` 算一项;打开后的整组由 `workflow/options.json` 定义:每项是 `{ id, name, detail?, default?, inputs? }`(`default` 为布尔值,没有 `shown`),最多 12 项,id 不重复;`inputs` 是勾上这一项时卡片上出现的文字输入,每个 `{ id, label }`,一项最多 4 个、id 不重复,几项带同一个 id 时卡上只出一个。`optionsProblem(options, where)` 检查一个答复打开后的整组(静态项已求值、各组已展开),合法时返回 `null`,否则返回「位置:说明」;表达式求值与展开仍由 Coda 完成。
|
|
20
22
|
|
|
21
23
|
流程方言的 **卡片字段**由 `workflow/fields.json` 定义:九种字段各能写哪些属性、必填项、文字长度与单行限制、路径与网址、视图参数、输入框与密钥选项、多选的选项表、一组客户端操作;`values.json` 的 `Field` 引用它,`Fields` 声明读出 JSON 字段列表的表达式,`UserTask.children` 限定最多 12 个静态字段、id 不重复,以及全部字段已知时答复的 `fields` 只能引用输入字段(含按住出现的答复)。
|
|
@@ -168,7 +170,7 @@ agentValueProblem('review.json', review, '工具的审核');
|
|
|
168
170
|
## 协议定义与核心协议
|
|
169
171
|
|
|
170
172
|
从 3.0.0 起,协议是 `命名空间/名字@大版本` + 记录格式(spec、status 的 JSON Schema)+ 操作,见[协议正文](docs/protocol.md)。
|
|
171
|
-
插件用 `contributes.protocols` 定义自己命名空间下的协议,用 `contributes.protocolImplementations` 声明实现哪些协议,用根上的 `uses` 申请别的协议的权限组(必需),用 `optionalUses` 声明可选用到的权限组(对应协议或提供方缺席时不阻止插件运行,可用性判定与鉴权由 Coda
|
|
173
|
+
插件用 `contributes.protocols` 定义自己命名空间下的协议,用 `contributes.protocolImplementations` 声明实现哪些协议,用根上的 `uses` 申请别的协议的权限组(必需),用 `optionalUses` 声明可选用到的权限组(对应协议或提供方缺席时不阻止插件运行,可用性判定与鉴权由 Coda 宿主负责);`contributes.optionalProtocolImplementations` 列可选实现的协议(本机没有这个协议时插件照常运行、这一项不生效),`contributes.reservedAccordKinds` 声明只归本插件的 Accord 签名记录种类(命名空间须是插件 ID);这两个键协议包只校验形状与两条跨键规则(可选实现不与 `protocolImplementations` 重复、保留种类的命名空间等于插件 ID),协议在不在、谁被拒绝由 Coda 宿主判定;
|
|
172
174
|
命名空间 `coda` 保留给核心协议。
|
|
173
175
|
|
|
174
176
|
- **`coda/run@1`**:被调用方自己的运行记录。spec 记录调用的记录、操作、输入、请求 ID、父引用和是否被等待;status 是 `working`、`input-required`、`completed`、`failed`、`canceled`,后三个是终态。`completed`/`failed` 必带 `result`,`failed` 的 `result` 约定为 `{ code, message }`(`code: "unknown"` 表示结局不明),`canceled` 可带取消前的话和留下的东西;另有可选的 `progress` 和等输入时的 `awaiting`。操作是 `cancel`。
|
package/docs/agent-protocol.md
CHANGED
|
@@ -31,6 +31,7 @@ ACP 的消息、内容块、会话指令和能力由 ACP SDK 校验,这里只
|
|
|
31
31
|
| `session/prompt` 答复的 `usage` | [prompt-usage.json](../schemas/agent/prompt-usage.json) |
|
|
32
32
|
| 配置选项的 `_meta.coda.default` | [default.json](../schemas/agent/default.json)(传入 `_meta.coda` 对象) |
|
|
33
33
|
| 模型、模式、配置项及其选项的 `_meta.coda.shortName` | [display.json](../schemas/agent/display.json)(传入 `_meta.coda` 对象) |
|
|
34
|
+
| `elicitation/create` 表单结果的 `_meta.coda.reason`(宿主拦下表单时) | [elicitation-denial.json](../schemas/agent/elicitation-denial.json)(传入整个结果对象,如 `{"action":"decline","_meta":…}`) |
|
|
34
35
|
|
|
35
36
|
`@coda-console/protocol/agent` 导出 `agentMessageProblem(method, params)`、`agentResultProblem(method, result)`、
|
|
36
37
|
`agentCapabilitiesProblem(meta, party = 'agent')` 和 `agentValueProblem(ref, value, where)`,合法返回 `null`,
|
|
@@ -67,7 +68,7 @@ Coda 是 ACP 的客户端。每个会话的 Agent 进程由一个会话托管进
|
|
|
67
68
|
| `_coda/session/compact` | Coda → Agent | [压缩上下文](#压缩上下文):请 Agent 压缩这个会话的上下文;只对声明支持的 Agent 发,两轮之间也发 |
|
|
68
69
|
| `session/set_config_option`、`session/set_mode`、`session/set_model` | Coda → Agent | 模型、推理强度与模式 |
|
|
69
70
|
| `session/update` | Agent → Coda | 回复、思考、工具调用(可带它的[审核](#工具调用的审核))、计划、用量(可带给流程的[数据](#用量里的数据))、可用命令、会话信息;只收本会话与它的子会话的 |
|
|
70
|
-
| `session/request_permission`、`elicitation/create`(`mode: form` 或 `mode: url`) | Agent → Coda |
|
|
71
|
+
| `session/request_permission`、`elicitation/create`(`mode: form` 或 `mode: url`) | Agent → Coda | 审批与提问,作为卡片交给用户;只在一轮里受理(轮次限制无条件,见[规则](#规则)第 3 条);拦截只适用于轮内 `mode: form` 表单:若被流程声明拦下(`coda:questionDenial`),不展示卡片,当场回 `decline` 并带 `_meta.coda.reason`(见下文「宿主当场拒绝表单」) |
|
|
71
72
|
| `_coda/unrecognized` | Agent → Coda | [没适配的东西](#没适配的东西):入口报上游发来、它没按登记处理的输出,以及模型能用、它没登记的原生工具;用户因此没看到的在会话里记一条说明,都计入遥测 |
|
|
72
73
|
| `_coda/remote/code`、`_coda/remote` | Agent → Coda、Coda → Agent | [远端入口](#远端入口):Agent 要绑定码;Coda 转交远端来的请求 |
|
|
73
74
|
| `$/cancel_request` | Agent → Coda | 撤回它发出、还没得到回答的审批或提问:卡片失效,Coda 回 `cancelled`(表单回 `cancel`),之后用户的回答不再转交 |
|
|
@@ -79,6 +80,7 @@ ACP 只允许在一轮(`session/prompt`)进行时交互。Agent 在两轮之
|
|
|
79
80
|
- **表单**:`requestedSchema` 是标准 JSON Schema,Coda 按它展示并校验回答;单选、多选用
|
|
80
81
|
`enum` 或 `oneOf`/`anyOf` 的 `{const, title}`,不认私有键。
|
|
81
82
|
- **链接**(`mode: url`):带 `url` 与 `elicitationId`,没有要填的字段;Coda 展示链接,用户打开、办完后确认,回 `{action}`(`accept`、`decline` 或 `cancel`)。
|
|
83
|
+
- **宿主当场拒绝表单**:流程可以声明运行期间拦下会话向用户的提问(流程属性 `coda:questionDenial`,见 README 的流程方言)。被拦的 `elicitation/create` 表单,Coda 不展示卡片,回 `{action: "decline"}`,且**必须**在结果的 `_meta.coda.reason` 里带一段文字(拦它的流程写的):`{"action":"decline","_meta":{"coda":{"reason":"……"}}}`。Agent 插件见到 `_meta.coda.reason` 就把这段文字原样交给模型(作为这次提问的结果),不改写、不丢弃;`reason` 须为非空字符串,只出现在 `action: "decline"` 的结果里([elicitation-denial.json](../schemas/agent/elicitation-denial.json));没有 `_meta.coda.reason` 的 `decline` 仍合法,语义不变,仍是用户拒绝。轮次之外的表单照旧回 `cancel`(见上文),不在此例。审批、链接(`mode: url`)不被这样拦。
|
|
82
84
|
- **模型的分组**:`category: model` 的配置项可以按来源分组,用 ACP 选择型配置项的分组写法:`options` 是一组 `{ group, name, options }`,
|
|
83
85
|
如 Agent 自己的模型一组、它接的每个模型服务一组(模型服务(Coda 的 docs/plugins.md「模型服务」))。Coda 记下每个模型所在组的 `name`,两端选模型时按组分段、
|
|
84
86
|
以组名为段标题,组内与输入框上只写模型的 `name`;不分组的照旧列成一串。模型 ID 在各组之间不重复,设模型照旧按 ID。
|
package/docs/protocol.md
CHANGED
|
@@ -358,6 +358,12 @@ const body = writeFrames(frames, { heartbeatMs: 15000 });
|
|
|
358
358
|
|
|
359
359
|
同一个协议在数组里只能出现一次,写成文本还是对象都算。
|
|
360
360
|
|
|
361
|
+
`contributes.optionalProtocolImplementations` 是插件可选实现的协议列表:协议名的数组,至多 100 项、不重复,只收文本,不收 `{ kind, commands }`。这些协议本机没有时,插件照常运行,只是这一项不生效;同一个协议不能既写在这里又写在 `protocolImplementations` 里(文本项、对象项的 `kind` 都算)。
|
|
362
|
+
|
|
363
|
+
`contributes.reservedAccordKinds` 声明哪几种 Accord 签名记录(AIP-01)的种类只归本插件:「命名空间/名字」的数组,至多 32 项、不重复,每项须匹配 `^[a-z0-9-]{1,64}/[a-z0-9-]{1,64}$`(比 Accord 的种类规则少了可选的命名空间:必须带),命名空间须等于插件 ID(没写 `id` 时用 `name`)。只有本插件能直接发布、撤回、读这些种类。
|
|
364
|
+
|
|
365
|
+
这两个键协议包只校验形状与上面两条跨键规则;协议在不在、这一项生不生效、谁被拒绝由 Coda 宿主判定。
|
|
366
|
+
|
|
361
367
|
`contributes.records` 声明哪些种类的记录由命令给出,每种一项,至多 20 项:
|
|
362
368
|
|
|
363
369
|
```json
|
package/package.json
CHANGED
package/plugin.d.mts
CHANGED
|
@@ -423,3 +423,14 @@ export interface ViewInstance {
|
|
|
423
423
|
onContext(fn: (context: ViewInstance['context']) => void): Disposable;
|
|
424
424
|
onClose(fn: () => void): Disposable;
|
|
425
425
|
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The keys of the manifest's `contributes` that are typed here: only these two so far, the rest of the manifest has no type
|
|
429
|
+
* here yet. Their shape is checked by `schemas/plugin/`; whether a protocol is on this machine and who is refused is the host's.
|
|
430
|
+
*/
|
|
431
|
+
export interface ManifestContributions {
|
|
432
|
+
/** Protocols the plugin implements if they are on this machine (`namespace/name@major`); with one absent the plugin still runs, only that implementation does not take effect. */
|
|
433
|
+
optionalProtocolImplementations?: string[];
|
|
434
|
+
/** Accord signature record kinds (`namespace/name`, the namespace the plugin's own ID) that only this plugin may publish, revoke or read. */
|
|
435
|
+
reservedAccordKinds?: string[];
|
|
436
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/elicitation-denial.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "表单结果须为对象",
|
|
6
|
+
"properties": {
|
|
7
|
+
"_meta": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"description": "_meta 须为对象",
|
|
10
|
+
"properties": {
|
|
11
|
+
"coda": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "_meta.coda 须为对象",
|
|
14
|
+
"properties": {
|
|
15
|
+
"reason": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"minLength": 1,
|
|
18
|
+
"description": "reason 须为非空字符串,只出现在 action 为 decline 的表单结果里;普通 decline 不带它"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"if": {
|
|
26
|
+
"required": ["_meta"],
|
|
27
|
+
"properties": {"_meta": {"type": "object", "required": ["coda"], "properties": {"coda": {"type": "object", "required": ["reason"]}}}}
|
|
28
|
+
},
|
|
29
|
+
"then": {
|
|
30
|
+
"required": ["action"],
|
|
31
|
+
"properties": {"action": {"const": "decline", "description": "action 须为 decline:_meta.coda.reason 只出现在 decline 的表单结果里"}}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/plugin/v2/optional-protocol-implementations.json",
|
|
4
|
+
"title": "contributes.optionalProtocolImplementations:插件可选实现的协议",
|
|
5
|
+
"description": "插件可选实现哪些协议,写协议名「命名空间/名字@大版本」的数组,至多 100 项,不重复,只收文本、不收 { kind, commands }。这些协议本机没有时,插件照常运行,只是这一项不生效;协议在不在、这一项生不生效由 Coda 宿主判定,这里只管清单形状。同一个协议不能同时写在 protocolImplementations 里,这条跨键规则由整份清单的校验(manifestProblem)查。",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"maxItems": 100,
|
|
8
|
+
"uniqueItems": true,
|
|
9
|
+
"items": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/name"}
|
|
10
|
+
}
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
"views": {"$ref": "views.json"},
|
|
74
74
|
"protocols": {"$ref": "protocols.json"},
|
|
75
75
|
"protocolImplementations": {"$ref": "protocol-implementations.json"},
|
|
76
|
+
"optionalProtocolImplementations": {"$ref": "optional-protocol-implementations.json"},
|
|
77
|
+
"reservedAccordKinds": {"$ref": "reserved-accord-kinds.json"},
|
|
76
78
|
"records": {"$ref": "records.json"}
|
|
77
79
|
},
|
|
78
80
|
"propertyNames": {"description": "contributes 的键:字母和数字,以小写字母开头", "pattern": "^[a-z][A-Za-z0-9]{0,39}$"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/plugin/v2/reserved-accord-kinds.json",
|
|
4
|
+
"title": "contributes.reservedAccordKinds:只归本插件的 Accord 签名记录种类",
|
|
5
|
+
"description": "插件声明哪几种 Accord 签名记录(AIP-01)的种类只归自己,写「命名空间/名字」的数组,至多 32 项,不重复;命名空间必须带,名字与命名空间都是小写字母、数字和「-」,各至多 64 个字符。只有本插件能直接发布、撤回、读这些种类;谁被拒绝由 Coda 宿主判定,这里只管清单形状。命名空间须是本插件的 ID,这条跨键规则由整份清单的校验(manifestProblem)查。",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"maxItems": 32,
|
|
8
|
+
"uniqueItems": true,
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[a-z0-9-]{1,64}/[a-z0-9-]{1,64}$"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/validate.mjs
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// JSON Schema of its own. The manifest's schema names only the general ones (schemas/plugin/,
|
|
3
3
|
// `https://coda.pub/schemas/plugin/v2/…`); every other key is one Coda's registry of contribution points declares, with a
|
|
4
4
|
// schema of its provider's (those of Coda's own still kept here, by file). Checking one is checking it against those
|
|
5
|
-
// schemas, nothing else: a field joins a type by joining its schema, never by a rule here
|
|
5
|
+
// schemas, nothing else: a field joins a type by joining its schema, never by a rule here, but for two
|
|
6
|
+
// rules across a manifest's keys: after the schema, `manifestProblem` checks that a protocol is not both implemented and optionally
|
|
7
|
+
// implemented, and that a reserved Accord kind is in the plugin's own namespace, its ID; checked against plugin.json alone, a
|
|
8
|
+
// manifest is checked for its shape only. Coda checks a plugin with this
|
|
6
9
|
// module when it reads one, and coda-plugins' contract check does where a plugin is written.
|
|
7
10
|
// What JSON Schema cannot say of one value alone it says with five keywords, each meaning one thing wherever it is written,
|
|
8
11
|
// as Kubernetes extends its OpenAPI with `x-kubernetes-*`:
|
|
@@ -311,7 +314,20 @@ export function explain(errors, base = '', schemas = [], { style = 'keyword', re
|
|
|
311
314
|
// A manifest checked against its schema, the files it names in `dir` when given. Returns null, or what is wrong.
|
|
312
315
|
export function manifestProblem(manifest, dir = null) {
|
|
313
316
|
const validate = validator('plugin.json');
|
|
314
|
-
return validate.call({ dir }, manifest) ?
|
|
317
|
+
return validate.call({ dir }, manifest) ? crossKeyProblem(manifest) : explain(validate.errors, '', [PROTOCOL_DEFINITION]);
|
|
318
|
+
}
|
|
319
|
+
// What the manifest's schema cannot say of one key alone, as its keys stand to each other; the shapes are right by now.
|
|
320
|
+
// An optional implementation is none that is implemented already (a text, or the `kind` of an object); a reserved Accord kind
|
|
321
|
+
// is in the plugin's own namespace, the plugin's `id` (its `name` when it has none).
|
|
322
|
+
function crossKeyProblem({ id, name, contributes }) {
|
|
323
|
+
const { protocolImplementations = [], optionalProtocolImplementations = [], reservedAccordKinds = [] } = contributes ?? {};
|
|
324
|
+
const implemented = new Set(protocolImplementations.map(item => typeof item === 'string' ? item : item.kind));
|
|
325
|
+
const twice = optionalProtocolImplementations.findIndex(kind => implemented.has(kind));
|
|
326
|
+
if (twice !== -1) return `contributes.optionalProtocolImplementations[${twice}]:已写在 protocolImplementations 里,不能再写:${optionalProtocolImplementations[twice]}`;
|
|
327
|
+
const owner = id ?? name;
|
|
328
|
+
const other = reservedAccordKinds.findIndex(kind => kind.split('/')[0] !== owner);
|
|
329
|
+
if (other === -1) return null;
|
|
330
|
+
return `contributes.reservedAccordKinds[${other}]:${owner === undefined ? '须先写插件的 id 或 name' : `命名空间须是本插件的 ID「${owner}」`}:${reservedAccordKinds[other]}`;
|
|
315
331
|
}
|
|
316
332
|
// A value checked against one of the schemas (`ref`: a file, with a fragment, as `composer-modes.json#/$defs/parameters`),
|
|
317
333
|
// as a plugin gives it while it runs: null, or what is wrong, at `where`.
|
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 未结束运行的业务键、title 运行在卡片上的名字(同 GitHub 的 run-name)、dispatch 能否手动发起、inline Agent 用 workflow_run 发起时等它结束再回答、subagents 为 false 时会话 Agent 的原生子 Agent 不能发起、agents 生命周期流程跟随哪些 Agent 的会话(ID,逗号或空格分隔,不写是全部)、autoRun 事件(如 PR)来时会话与目录都没设「自动运行」的,按它决定起不起运行:true、false 或 =vars.<插件>.<设置>(不写为起)、mergedOnly 只运行已合并进默认分支的提交(不写为 false
|
|
13
|
+
"description": "流程本身:concurrency 并发、key 未结束运行的业务键、title 运行在卡片上的名字(同 GitHub 的 run-name)、dispatch 能否手动发起、inline Agent 用 workflow_run 发起时等它结束再回答、subagents 为 false 时会话 Agent 的原生子 Agent 不能发起、agents 生命周期流程跟随哪些 Agent 的会话(ID,逗号或空格分隔,不写是全部)、autoRun 事件(如 PR)来时会话与目录都没设「自动运行」的,按它决定起不起运行:true、false 或 =vars.<插件>.<设置>(不写为起)、mergedOnly 只运行已合并进默认分支的提交(不写为 false:任何提交都能跑)、questionDenial 运行期间持有这个运行(或它的子运行)里没结束的 agent 任务的会话向用户提问时,宿主当场拒绝并把这段文字回给 Agent(有值才启用;父子运行都声明时,从会话所持任务所在的运行开始往上找,用离它最近的一段,子运行没声明就沿用祖先的声明;权限审批、链接表单、密钥卡、请用户操作桌面与指给用户的流程任务(`coda:assignee=\"user\"`)不拦)",
|
|
14
14
|
"properties": [
|
|
15
15
|
{"name": "concurrency", "isAttr": true, "type": "String"},
|
|
16
16
|
{"name": "key", "isAttr": true, "type": "String"},
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
{"name": "inline", "isAttr": true, "type": "Boolean"},
|
|
20
20
|
{"name": "subagents", "isAttr": true, "type": "Boolean"},
|
|
21
21
|
{"name": "agents", "isAttr": true, "type": "String"},
|
|
22
|
-
{"name": "autoRun", "isAttr": true, "type": "String"}, {"name": "mergedOnly", "isAttr": true, "type": "Boolean"}
|
|
22
|
+
{"name": "autoRun", "isAttr": true, "type": "String"}, {"name": "mergedOnly", "isAttr": true, "type": "Boolean"},
|
|
23
|
+
{"name": "questionDenial", "isAttr": true, "type": "String"}
|
|
23
24
|
]
|
|
24
25
|
},
|
|
25
26
|
{
|
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
|
"mergedOnly": {"type": "boolean", "description": "coda:mergedOnly 只能是 true 或 false"},
|
|
14
|
+
"questionDenial": {"type": "string", "pattern": "\\S", "maxLength": 2000, "description": "coda:questionDenial 须为 1–2000 个字符(不想拦提问就不写)"},
|
|
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"]},
|