@coda-console/plugin-check 0.5.33 → 0.7.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/README.md CHANGED
@@ -2,30 +2,29 @@
2
2
 
3
3
  Coda 的公开插件仓库,和给插件作者用的契约检查。Coda 自带的 Agent 插件(Codex、Claude、Kimi、Grok、OpenCode 与 Codex 多账号)和 PR 生命流程也在这里维护。
4
4
 
5
- Coda 是一个多 Agent 客户端(Mac、iPhone 与运行在你机器上的后端)。Agent 与资源页的面板都以插件接入:
6
- 插件是一个目录,清单就是它的 `package.json`(`contributes.agents`、`contributes.panels` 等,照 VS Code 扩展的写法);
5
+ Coda 是一个多 Agent 客户端(Mac、iPhone 与运行在你机器上的后端)。Agent 与资源页上的资源都以插件接入:
6
+ 插件是一个目录,清单就是它的 `package.json`(`contributes.agents`、`contributes.resources` 等,照 VS Code 扩展的写法);
7
7
  Agent 讲 [ACP](https://agentclientprotocol.com),外加 Coda 的 Agent 活动报告 `_coda/wait`,见 [接入协议](https://github.com/coda-console/coda-protocol/blob/main/docs/agent-protocol.md)。
8
8
  插件清单的类型、它们的 schema 与接入协议都在协议包 `@coda-console/protocol`([coda-console/coda-protocol](https://github.com/coda-console/coda-protocol))里;本仓库文中与代码注释说的 `docs/agent-protocol.md` 指那里的那份。
9
9
 
10
10
  ```
11
- plugins/codex/ Codex:入口在同一进程里运行锁定版本的 codex-acp(npm 依赖),面板「Codex」
12
- plugins/claude/ Claude SDK:基于 Claude Agent SDK 的 ACP 入口(npm 依赖),面板「Claude」
13
- plugins/kimi/ Kimi Code:在运行机的 kimi acp 与 Coda 之间转发,面板「Kimi」
14
- plugins/grok/ Grok:转发运行机上 Grok CLI 的 ACP,并适配审批模式,面板「Grok」
11
+ plugins/codex/ Codex:入口在同一进程里运行锁定版本的 codex-acp(npm 依赖),资源「Codex」
12
+ plugins/claude/ Claude SDK:基于 Claude Agent SDK 的 ACP 入口(npm 依赖),资源「Claude」
13
+ plugins/kimi/ Kimi Code:在运行机的 kimi acp 与 Coda 之间转发,资源「Kimi」
14
+ plugins/grok/ Grok:转发运行机上 Grok CLI 的 ACP,并适配审批模式,资源「Grok」
15
15
  plugins/grok-bot/ Grok Bot:把 xAI 云端 Bot 接成长期会话,原生主会话、Grok Routine 运行记录与用户审批;数据工具依赖 Coda 远端 Agent 入口
16
16
  plugins/opencode/ OpenCode:在运行机的 opencode acp 与 Coda 之间转发,送入会话指令与所选模型服务,模型按来源分组
17
- plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管 Codex 额度面板
17
+ plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管资源「Codex」
18
18
  plugins/cursor/ Cursor:在运行机的 cursor-agent acp 与 Coda 之间转发,送入会话指令
19
19
  plugins/git/ Git 源与快照:本机仓库 provider、运行关联的工作树/提交快照、临时 ref 回收与只读 smart HTTP v2
20
- plugins/host/ 宿主资源:Xcode 构建、Apple 模拟器与项目要求排队的命令共用这台机器的一组名额(组 host、持锁执行 run-held、host-sim),面板「构建与模拟器名额」
21
- plugins/scheduler/ 执行调度:为本机 execution 选择可用运行器,本机优先、按名额选择、安全改派与取消;政策和排队原因见插件 README
20
+ plugins/host/ 宿主资源:发布本机 coda/executor@1 执行环境,执行 execute 并写 coda/run@1;Xcode 构建、Apple 模拟器与项目要求排队的命令共用这台机器的一组名额(组 host、持锁执行 run-held、host-sim),资源「构建名额」
22
21
  plugins/magpie/ Magpie:把本机的 Magpie 网关作为模型服务提供给 Pi 等插件,安装时装好 Magpie 并让网关常驻
23
22
  plugins/network-log/ 网络记录:默认关闭,按需开启建连等待与定时探测采集;关闭后仍可查看历史
24
23
  plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布;也是写 PR 流程的样例
25
24
  plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
26
25
  plugins/composer/ 输入框模式与开发流程:Ultra 用 develop 委派代码修改,主 Agent 审查,设备验收后检查、批准、合并与部署;名单引用 composer.templates
27
26
  templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
28
- templates/panel/ 最小的面板插件:一张卡片、一条进度条、一个按钮
27
+ templates/resource/ 最小的资源插件:一个资源、两个读数、一个按钮
29
28
  bin/、check/ 契约检查(仓库根的 package.json 就是它,@coda-console/plugin-check);check/coda/ 是 Coda 同步来的规则副本,不要手改
30
29
  test/ 检查包的测试;test/plugins/ 是各插件的测试(插件目录里只放运行要用的文件)
31
30
  .coda/workflows/ 本仓库自己的流程:sync-coda 等新版本发到 npm,再给 Coda 开升级依赖的 PR
@@ -63,8 +62,8 @@ Coda 插件页的「商店」列出 Coda 自带的插件,以及 npm 上 `@coda
63
62
  | `codex` | `@agentclientprotocol/codex-acp` 1.12.0、`@openai/codex` 0.165.0;`overrides` 让 codex-acp 用同一个 `@openai/codex` | — |
64
63
  | `claude` | `@agentclientprotocol/sdk` 1.4.0、`@anthropic-ai/claude-agent-sdk` 0.3.312(平台二进制是 SDK 自己的可选依赖) | — |
65
64
  | `codex-accounts` | `proper-lockfile` 4.1.2;用依赖插件 `codex` 的 Codex CLI | 无;依赖 `codex` 插件 |
66
- | `kimi` | 无 | Kimi CLI 2.1.1 及以上(设置动作安装或升级;面板可从 Coda 安装、登录) |
67
- | `grok` | 无 | Grok CLI 1.0.52 及以上(设置动作安装或升级;面板可从 Coda 安装、登录) |
65
+ | `kimi` | 无 | Kimi CLI 2.1.1 及以上(设置动作安装或升级;资源页上可从 Coda 安装、登录) |
66
+ | `grok` | 无 | Grok CLI 1.0.52 及以上(设置动作安装或升级;资源页上可从 Coda 安装、登录) |
68
67
  | `opencode` | `jsonc-parser` 3.3.1 | 已登录的 OpenCode CLI 2.1.4 及以上(设置动作安装或升级,OpenCode 1 升到 2) |
69
68
 
70
69
  带依赖的插件各有自己的 `package-lock.json`(`node_modules` 不提交);Coda 在插件的版本目录里 `npm ci` 装它们,
@@ -291,11 +290,11 @@ Coda 升级依赖时也一起升这两个包。
291
290
  - 首次使用会把运行机 `$CODEX_HOME/auth.json`(默认 `~/.codex/auth.json`)里的 ChatGPT 登录导入插件,作为第一个
292
291
  普通受控账号并默认选用。原文件保留;之后的凭据、续期与选择都由插件维护,原登录文件后续变化不会替换受控账号。
293
292
  只有系统钥匙串里的凭据无法从文件导入,需要在插件中登录一次。
294
- - 没有已有登录时,从「资源 › 添加资源 › Codex 多账号」完成设备码登录。已有账号后,通过面板菜单的「重新登录」
293
+ - 没有已有登录时,从「资源 › 添加资源 › Codex」完成设备码登录。已有账号后,通过账号那一行「···」里的「重新登录」
295
294
  添加其他账号;登录同一身份会更新其凭据。添加第二个账号不会改变已选账号。
296
- - 接入后「Codex」自带的额度看板隐藏,只显示「Codex 多账号」里的账号额度。原 Codex 登录入口也委托给账号插件,
297
- 避免建立另一套登录;面板中没有「使用本机账号」。卸载账号插件后,Codex 自带看板恢复。
298
- - 每个账号支持选择、查看额度、使用完全重置和移除。选择在新会话和轮次交界处生效;移除已选账号后须重新选择或添加,
295
+ - 接入后「Codex」不再显示 Codex 自己的登录,只显示账号插件管理的账号(同一类型「Codex」,同一账号在几台上合成一行)。原 Codex 登录入口也委托给账号插件,
296
+ 避免建立另一套登录;没有「使用本机账号」。卸载账号插件后,Codex 自己的登录恢复显示。
297
+ - 每个账号支持选择(会话正在用的那一行写「正在使用」)、查看额度、使用完全重置和移除。选择在新会话和轮次交界处生效;移除已选账号后须重新选择或添加,
299
298
  会话不会回退到原登录。首次导入只发生一次,移除的账号不会再次被自动导入。
300
299
 
301
300
  账号存放于 `CODA_PLUGIN_STATE/accounts/<身份摘要>/auth.json`,目录权限 0700、文件权限 0600。
@@ -309,8 +308,8 @@ Coda 升级依赖时也一起升这两个包。
309
308
 
310
309
  `codex/account-source` 的完整进程约定在 `plugins/codex/agent/account-source.mjs`:`selected` 返回身份和名称,
311
310
  `tokens` 返回该身份的 access token,`refresh: true` 要求续期;无可用选择应返回错误。来源还通过 `--login` 接受
312
- 原 Codex 登录入口的委托,并自行提供额度面板。Codex 把自己的依赖目录通过 `CODA_PLUGIN_DEPENDENCIES.codex`
313
- 交给来源,来源与面板使用同一份 Codex CLI。
311
+ 原 Codex 登录入口的委托,并自行提供账号与额度资源。Codex 把自己的依赖目录通过 `CODA_PLUGIN_DEPENDENCIES.codex`
312
+ 交给来源,来源与资源读取使用同一份 Codex CLI。
314
313
 
315
314
  ### Agent 的错误
316
315
 
@@ -330,11 +329,15 @@ Kimi 插件在 `session/prompt` 的回执中将这条已知错误改为普通执
330
329
  同时按[执行失败协议](https://github.com/coda-console/coda-protocol/blob/main/docs/agent-protocol.md#执行失败)报告 `error.data._meta.coda.failure: {kind: "quota_exhausted"}`。
331
330
  Coda 按这个通用类别显示「额度不足」,不触发服务故障重试;其他 ACP 客户端仍能读取完整原因。
332
331
  插件不推算额度重置时间;其他认证失败、403、短时限流与普通错误原样保留。
332
+ Kimi 2.1.1 的 ACP 把失败的一轮(包括现在以 429 报的五小时额度耗尽)答成 `end_turn`,错误只记在它主 wire 的 `turn.ended` 里。
333
+ 插件在交出 `session/prompt` 的回执前读到这一轮以 `failed` 结束,就改答 -32603,`error.message` 是这一轮的错误原文;
334
+ Kimi 自己归为 `APIProviderQuotaExhaustedError` 的另报 `quota_exhausted`,其他失败不带类别。被过滤的回复 Kimi 已答 `refusal`,不改。
335
+ Kimi 在一轮失败后暂停 goal,goal 的定时随之以 `failed` 结束,说明是那一轮的原因,额度耗尽时标题为「额度不足」。
333
336
  `CODA_DISABLE_RUNTIME_PATCHES=kimi` 关闭这层适配。
334
337
 
335
338
  ### 升级 Agent 的 CLI 与 SDK
336
339
 
337
- Codex 会话、面板与登录用的 Codex CLI 就是 `codex` 插件依赖的 `@openai/codex`;Claude 的是 `claude` 插件依赖的
340
+ Codex 会话、资源与登录用的 Codex CLI 就是 `codex` 插件依赖的 `@openai/codex`;Claude 的是 `claude` 插件依赖的
338
341
  `@anthropic-ai/claude-agent-sdk`。插件按包名从自己的依赖里找它们,Coda 不另给路径。升级就是改这两个版本:
339
342
  Dependabot(`.github/dependabot.yml`)每周为它们各开一个 PR,连同 `package-lock.json` 一起改;合并后在 Coda「设置 › 插件」
340
343
  对该插件点「检查更新」;合并时勾选「部署」,`sync-coda` 给 Coda 开升级依赖的 PR。升 `@openai/codex` 时 codex-acp 经 `overrides` 跟着用新版本,
@@ -346,7 +349,7 @@ Coda 根上的同一条 overrides 由 `sync-coda` 一起改(npm 只认根的
346
349
 
347
350
  1. **仓库**填 `coda-console/coda-plugins`(或 `https://github.com/coda-console/coda-plugins`);**版本**留空是默认分支,也可以填分支、标签或完整的提交号。
348
351
  2. **读取**:Coda 拉取那个提交,把仓库根与两层以内 `package.json` 带 `contributes` 的目录各列成一个插件——这个仓库里是 `plugins/` 下的七个与两个模板。Coda 内置的那几个只能从 npm 上自己的包单独更新;在 Coda 里先卸载它,才能从这里装同名的。
349
- 3. 选一个,确认里逐条列出它会运行的命令(Agent 的 `command`、面板的命令与动作),确认就是批准:这些命令以你的账户在空间里每台机器上运行,Coda 不做隔离,只装你信任的来源。
352
+ 3. 选一个,确认里逐条列出它会运行的命令(Agent 的 `command`、资源的命令与动作),确认就是批准:这些命令以你的账户在空间里每台机器上运行,Coda 不做隔离,只装你信任的来源。
350
353
 
351
354
  **Coda 只认提交**:安装时钉在读取到的那个提交上,每台机器各自取同一个提交。「检查更新」用记下的仓库与版本再读一次,提交变了才有更新;
352
355
  上一个提交留着,可以回退。清单里的 `version` 只作显示,不参与比较——改了行为就把它加一,方便人看。这个仓库不打标签、不发 npm、不发 release。
@@ -355,15 +358,15 @@ Coda 根上的同一条 overrides 由 `sync-coda` 一起改(npm 只认根的
355
358
 
356
359
  ## 写一个插件
357
360
 
358
- 从模板开始:把 `templates/agent` 或 `templates/panel` 复制成自己的目录,改掉 `name`(插件 ID)与 Agent 的 `id`。
361
+ 从模板开始:把 `templates/agent` 或 `templates/resource` 复制成自己的目录,改掉 `name`(插件 ID)与 Agent 的 `id`。
359
362
 
360
363
  **清单**(`package.json`)
361
364
 
362
365
  - `name` 是包名;另写 `id` 时以它为 Coda 插件 ID,否则以 `name` 为 ID。ID 只能用小写字母、数字和 `-`,以字母开头,至多 40 个字符。
363
366
  本仓库的包名是 `@coda-console/<id>`,设置名与 Agent ID 仍使用原来的插件 ID。可以与 Coda 内置插件同名;从其他来源替换时,须先在目标机器卸载内置插件。契约检查照刚装好的 Coda 读:与它默认装着的内置插件同名、又不是那个插件的同一来源的,判不通过。
364
367
  - `displayName`、`description`、`version` 显示在安装确认与插件页。
365
- - `contributes` 只能有 Coda 认识的贡献:`agents`、`panels`、`configuration`、`capabilities`、`instructions`、`extensionPoints`、`extensions`、`groups`、`commands`、`services`、`setup`;读不懂的键一律报错,不会被悄悄忽略。
366
- - `setup` 是插件的设置动作:`{ "command": "…" }`,一行、不超过 4000 字(与面板命令同样的规则),没有别的键。
368
+ - `contributes` 只能有 Coda 认识的贡献:`agents`、`resources`(旧的 `panels` 仍认)、`configuration`、`capabilities`、`instructions`、`extensionPoints`、`extensions`、`groups`、`commands`、`services`、`setup`;读不懂的键一律报错,不会被悄悄忽略。
369
+ - `setup` 是插件的设置动作:`{ "command": "…" }`,一行、不超过 4000 字(与资源命令同样的规则),没有别的键。
367
370
 
368
371
  **从仓库安装的限制**:带 npm 依赖(`dependencies`、`optionalDependencies`)就要把 `package-lock.json` 一起提交,Coda 在插件的版本目录里
369
372
  `npm ci`(较早的 Coda 不收带 npm 依赖的插件);不能有符号链接或子模块;整个目录不超过 10 MiB(`node_modules` 不算,也不该提交);
@@ -380,7 +383,7 @@ Coda 根上的同一条 overrides 由 `sync-coda` 一起改(npm 只认根的
380
383
  | `modes` | 可省:`title`、`unset`、`note` 是模式选择的标题与说明;`auto`、`full` 是这个 Agent 的「自动审批」「全部放行」各是哪个 ACP 模式 |
381
384
  | `skillsDir`、`configFiles`、`setupHint` | 可省:Agent 在工作副本里找 skills 的目录;它读模型列表的配置文件(变了 Coda 重读);用不了时给用户的一句话 |
382
385
 
383
- Agent 进程的环境是会话的环境再加插件进程的那组变量(面板与面板的动作、放在会话 `PATH` 上的命令也一样;继承来的同名变量先去掉,一个插件的进程拿不到别的插件的):
386
+ Agent 进程的环境是会话的环境再加插件进程的那组变量(资源的命令与动作、放在会话 `PATH` 上的命令也一样;继承来的同名变量先去掉,一个插件的进程拿不到别的插件的):
384
387
  `CODA_NODE`(Coda 后端自己的 Node,插件自带的入口用它运行,不在 Agent 的 `PATH` 上)、`CODA_PLUGIN_PATH`(插件目录,从仓库装的是它钉住的版本目录)、
385
388
  `CODA_PLUGIN_STATE`(插件在这台机器上的状态目录,跨会话、跨版本保留)、`CODA_PLUGIN_SETTINGS`(插件设置的 JSON)、
386
389
  `CODA_PLUGIN_EXTENSIONS`(别的插件接在它扩展点上的东西,没有就不设)、`CODA_PLUGIN_DEPENDENCIES`(它依赖的插件的目录,没有就不设)、
@@ -401,21 +404,22 @@ Agent 进程的环境是会话的环境再加插件进程的那组变量(面
401
404
  - Coda 关会话是对 Agent 的进程组发 SIGTERM,0.8 秒后 SIGKILL:收到 SIGTERM 要尽快退出。
402
405
  - 一轮之外的审批与提问 Coda 一律拒绝,除非正有活动在 `handling`(那是一轮自主轮次)。
403
406
 
404
- **面板**(`contributes.panels`,例子见 `templates/panel`):`command` 用 `sh -c` 运行,标准输出是 `{ "items": [...] }`:
407
+ **资源**(`contributes.resources`,例子见 `templates/resource`):一项一个资源类型,`id`、`title`(类型名,如「CPU」「Claude」:资源页上只写它,不写插件)、
408
+ `command`,可选 `maxAge`、`hidden`(默认不显示,在「显示的资源」里打开)、`actions`、`signIn`。`command` 用 `sh -c` 运行,标准输出是 `{ "resources": [...] }`,至多 50 个资源:
405
409
 
406
- | 项 | 字段 |
410
+ | 字段 | 内容 |
407
411
  | --- | --- |
408
- | `card` | `title`、可选 `subtitle`、`items`(至多 20 项,不能再放卡片) |
409
- | `meter` | `label`,可选 `value`、`fraction`(0–1,**还剩多少**,不知道就不写)、`note`、`time`(ISO 8601)与 `timeLabel` |
410
- | `stat` | `label`、`value` |
411
- | `markdown` | `text`(不超过 4000 字) |
412
- | `button` | `label`、`action`(须是这个面板声明的动作)、可选 `args`、`disabled`、`confirm` |
413
- | `error` | `text` |
414
-
415
- 只在打开资源页或点「刷新」时读,30 秒没结束或输出超过 64 KiB 就停下;读不懂的键或类型算这次读取失败。`items` 为空的面板不显示。
412
+ | `name` | 可省:资源的名字(账号、磁盘、设备),一行不超过 80 字;类型只有一个资源时不写 |
413
+ | `identity` | 可省:它是哪个外部身份(如 `codex:<哈希>`):几台机器、几个插件说同一个身份时资源页只显示一行 |
414
+ | `values` | 至多 8 个读数,每个可选 `label`(只有一个读数时不写)、`value`、`fraction`(0–1,**还剩多少**,不知道就不写)、`time`(ISO 8601,如额度何时恢复),`value` 与 `fraction` 至少有一个 |
415
+ | `error` | 可省:哪里不对,一行不超过 80 字 |
416
+ | `actions` | 至多 8 个按钮,每个 `label` 和 `action`(须是这个类型声明的动作)、`view`(插件的视图)或 `url`(`https://` 网页)之一,可选 `args`、`disabled`、`confirm` |
417
+
418
+ `name` 与 `values` 至少有一个。没有副标题、说明行或整段文字:资源页上只有类型名、名字、读数与按钮,要说明的写进插件自己的文档或视图。
419
+ 只在打开资源页或点「刷新」时读,30 秒没结束或输出超过 64 KiB 就停下;读不懂的键算这次读取失败。`resources` 为空的类型不显示。
416
420
  命令的环境是后端的环境(不带会话 ID)加上插件进程的那组变量(同上),`PATH` 最前面是 Coda 后端的 `node`;`CODA_GROUPS_STATE` 是这一刻这个后端各并发组的占用与排队
417
421
  (`{now, groups}`);动作另有 `CODA_PANEL_ARGS`(按钮的 `args`)。
418
- 动作至多跑 10 分钟,成功后 Coda 立即重读面板。
422
+ 动作至多跑 10 分钟,成功后 Coda 立即重读这个类型。之前的写法 `contributes.panels`(`{ "items": [...] }`,卡片与说明行)Coda 仍读,当作资源显示、说明文字丢掉;新插件写 `resources`。
419
423
 
420
424
  ## npm 发布
421
425
 
@@ -444,7 +448,7 @@ gh workflow run publish.yml --repo coda-console/coda-plugins --ref main
444
448
 
445
449
  ## 契约检查
446
450
 
447
- 扮演 Coda 去读一个插件目录:清单对 Coda 的类型 schema 校验,流程按 Coda 的流程方言读,Agent 照 Coda 的样子启动、说 Coda 说的话,面板由 Coda 的资源插件模块读一次。
451
+ 扮演 Coda 去读一个插件目录:清单对 Coda 的类型 schema 校验,流程按 Coda 的流程方言读,Agent 照 Coda 的样子启动、说 Coda 说的话,资源类型(或旧的面板)由 Coda 的资源插件模块读一次。
448
452
  插件写的合乎它用到的类型就对:清单的写法只在协议包 `@coda-console/protocol`([coda-console/coda-protocol](https://github.com/coda-console/coda-protocol))的 schema 里,由 Coda 自己用的同一个校验器判,
449
453
  检查包不另写规则,Coda 加字段只是改 schema。`check/coda/` 是 Coda 文件的原样副本(见[契约副本](#契约副本)),检查包手写的只有怎样扮演 Coda、怎样判。
450
454
  只在装到一台机器上才知道的(仓库里扫不扫得到、npm 锁文件、和那台已装插件冲突)是那台 Coda 安装时说的,不是插件类型的问题,检查不跑。
@@ -459,8 +463,8 @@ npx github:coda-console/coda-plugins#<提交> <插件目录>
459
463
 
460
464
  | 级 | 要不要登录 | 查什么 |
461
465
  | --- | --- | --- |
462
- | 清单(总是) | 不要 | `package.json` 对 Coda 的类型 schema 校验(`manifestProblem`),再照 Coda 读成插件(`readPlugin`:ID、设置名在 ID 之下);写给别的插件扩展点的键,要有 Coda 自带的或旁边依赖的插件声明这个类型。面板写法按资源插件给扩展点 `panels` 带的 schema 查。`.coda/workflows/` 里的每个流程(含能力)按协议的流程方言读(`workflowProblem`):不是 BPMN、认不出的 `coda:` 属性或元素、没有的动作或动作不接受的参数都算失败。另有只提醒的:分类、版本、图标页面太小、旧的 Agent ID `claude` |
463
- | 握手(默认) | 不要 | `sh -c` 启动 `command`(环境是 Coda 的 `pluginEnv` 给的:`CODA_NODE`、`CODA_PLUGIN_PATH`、临时的 `CODA_PLUGIN_STATE`、设置默认值的 `CODA_PLUGIN_SETTINGS`;依赖的插件在旁边(同一个父目录里同名的目录)时 `CODA_PLUGIN_DEPENDENCIES` 给它的目录,Coda 自带的不在这里、不给),发与 Coda 相同的 `initialize`,要求 `protocolVersion` 为 1;能力声明的 `_meta.coda` 与顶层插话声明交协议 schema 校验;声明会话指令(`sessionCapabilities.systemPrompt`,没声明算失败);`session/new` 带会话指令,给出会话与当前模型,配置选项的 `_meta.coda.default` 交协议校验;错误里声明的执行失败也查协议 schema,回 -32000 记为未登录、跳过后面的检查(不算失败);像 Coda 一样对进程组发 SIGTERM,5 秒内要退出(超过 0.8 秒提醒);另起一个进程,关掉标准输入后 5 秒内不退出只提醒。面板由 Coda 资源插件的 `Panels` 读一次(30 秒),输出合格式 |
466
+ | 清单(总是) | 不要 | `package.json` 对 Coda 的类型 schema 校验(`manifestProblem`),再照 Coda 读成插件(`readPlugin`:ID、设置名在 ID 之下);写给别的插件扩展点的键,要有 Coda 自带的或旁边依赖的插件声明这个类型。资源类型与旧的面板按资源插件给扩展点 `resources`、`panels` 带的 schema 查。`.coda/workflows/` 里的每个流程(含能力)按协议的流程方言读(`workflowProblem`):不是 BPMN、认不出的 `coda:` 属性或元素、没有的动作或动作不接受的参数都算失败。另有只提醒的:分类、版本、图标页面太小、旧的 Agent ID `claude` |
467
+ | 握手(默认) | 不要 | `sh -c` 启动 `command`(环境是 Coda 的 `pluginEnv` 给的:`CODA_NODE`、`CODA_PLUGIN_PATH`、临时的 `CODA_PLUGIN_STATE`、设置默认值的 `CODA_PLUGIN_SETTINGS`;依赖的插件在旁边(同一个父目录里同名的目录)时 `CODA_PLUGIN_DEPENDENCIES` 给它的目录,Coda 自带的不在这里、不给),发与 Coda 相同的 `initialize`,要求 `protocolVersion` 为 1;能力声明的 `_meta.coda` 与顶层插话声明交协议 schema 校验;声明会话指令(`sessionCapabilities.systemPrompt`,没声明算失败);`session/new` 带会话指令,给出会话与当前模型,配置选项的 `_meta.coda.default` 交协议校验;错误里声明的执行失败也查协议 schema,回 -32000 记为未登录、跳过后面的检查(不算失败);像 Coda 一样对进程组发 SIGTERM,5 秒内要退出(超过 0.8 秒提醒);另起一个进程,关掉标准输入后 5 秒内不退出只提醒。资源类型(或旧的面板)由 Coda 资源插件的 `Panels` 读一次(30 秒),输出合格式 |
464
468
  | 一轮(`--live`) | 要 | 第一轮问会话指令里的检查词(一个随机词),回复里要有它;再发一轮提示词(默认「只回复 ok」)收到 `stopReason`;每条 `session/update` 先过 ACP SDK 的 schema,工具审核、用量与默认选项标记再过协议 schema;`_coda/wait` 用协议的 `agentMessageProblem` 校验形状,另查会话归属、登记与终态(子 Agent 不带 `childSessionId`、定时不带 `at` 只提醒);扩展形状问题按现有规则报告协议返回的「位置:说明」;远端绑定码请求先查协议参数再查本会话归属;执行失败的形状交协议校验,重试预算照 Coda 策略;审批与提问一律回拒绝,在一轮之外发来的算失败;再发一轮并 `session/cancel`,30 秒内要结束,读到取消后还在做事或拖过 5 秒才答复却不回 `cancelled` 算失败(见下);有自主轮次的也取消一次;声明插话的,答复用协议的 `agentResultProblem` 校验,一轮结束后插话要回 `promptRequired` 且不自己另开一轮,一轮进行中插话要回 `injected` 或 `promptRequired`(`injected` 的那一轮照常回 `stopReason`);声明 `loadSession` 的,新开进程 `session/load`(同样带会话指令)要成功,随后在新进程里再跑一轮也要收到 `stopReason` |
465
469
 
466
470
  **取消后的 `stopReason` 怎么判**:检查发 `session/cancel` 时紧跟一个只会得到 -32601 的探测请求(`_codaCheck/barrier`)。Agent 按顺序读,
@@ -469,7 +473,7 @@ npx github:coda-console/coda-plugins#<提交> <插件目录>
469
473
  答复先于读到取消写出(取消送到前这一轮已经结束),或读到取消时已经做完、随即答复的(如 Codex 做完后等标题时被取消),只记一条说明。
470
474
 
471
475
  `--manifest` 只查清单(什么也不运行);`--agent <id>` 只查一个 Agent。退出码:0 通过,1 有失败,2 用法不对。
472
- 面板的动作与插件的设置动作(`contributes.setup`)不运行(可能改动东西、装软件);Coda 自己的 MCP 服务器不给(`mcpServers` 为空)。
476
+ 资源的动作与插件的设置动作(`contributes.setup`)不运行(可能改动东西、装软件);Coda 自己的 MCP 服务器不给(`mcpServers` 为空)。
473
477
  检查给的会话指令不是 Coda 的全文,是一段替身加一句检查词。
474
478
 
475
479
  在自己插件仓库的 CI 里:
@@ -1,20 +1,30 @@
1
- // The plugin host's local API. Controllers consume accepted objects serially per ID; they choose their own actions.
1
+ // The plugin host's local API. A provider's own observations consume accepted objects serially per ID; the plugin chooses
2
+ // its own actions. `handle` keeps a plugin's operation handlers in `operations`, by kind and operation, for the protocols
3
+ // its manifest implements.
2
4
  import { checkCreationReadOnly } from '../components/protocols/creation.mjs';
3
- export function providerAPI({ call, watch, connection, report = console.error }) {
4
- const observe = (kind, fn, scope = 'available') => watch(`provider:${kind}`, fn, { scope });
5
+ export function providerAPI({ call, watch, connection, plugin, operations, report = console.error }) {
6
+ const observe = (kind, fn, scope = 'available') => watch(kind, fn, { scope });
5
7
  return {
6
8
  async resolve(ref, service) {
7
9
  const { resource, path } = await call('resolve', [ref, service]);
8
10
  const api = connection();
9
11
  return { resource, url: `${api.url}${path}`, headers: { authorization: `Bearer ${api.token}` } };
10
12
  },
11
- define: definition => call('define', [definition]),
12
13
  put: async object => { checkCreationReadOnly(object); return call('put', [object]); },
13
14
  update: (kind, id, spec, revision) => call('update', [kind, id, spec, revision]),
14
15
  setStatus: (kind, id, status, revision) => call('setStatus', [kind, id, status, revision]),
15
16
  delete: (kind, id) => call('delete', [kind, id]),
16
17
  publish: (kind, id, enabled = true) => call('publish', [kind, id, enabled]),
17
18
  observe,
19
+ handle(kind, operation, handler) {
20
+ if (typeof kind !== 'string' || !kind || typeof operation !== 'string' || !operation || typeof handler !== 'function')
21
+ throw new TypeError('protocols.handle(协议名, 操作, handler)');
22
+ if (!(plugin.protocolImplementations ?? []).includes(kind)) throw new TypeError(`插件 ${plugin.id} 没有实现 ${kind}`);
23
+ const id = JSON.stringify([kind, operation]);
24
+ if (operations.has(id)) throw new TypeError(`协议操作已登记:${kind}/${operation}`);
25
+ operations.set(id, handler);
26
+ return { dispose: () => { if (operations.get(id) === handler) operations.delete(id); } };
27
+ },
18
28
  async control(kind, handler, scope = 'local') {
19
29
  if (typeof handler !== 'function') throw new TypeError('controller 须为函数');
20
30
  const pending = new Map(), running = new Set();
@@ -80,7 +80,7 @@
80
80
  "id": "cliproxy",
81
81
  "displayName": "CLIProxy",
82
82
  "description": "显示额度,把 CLIProxy 提供为模型服务",
83
- "version": "1.2.0",
83
+ "version": "1.3.0",
84
84
  "category": "模型与账号",
85
85
  "icon": {
86
86
  "symbol": "bolt.fill",
@@ -118,10 +118,10 @@
118
118
  "endpoints": [],
119
119
  "views": [],
120
120
  "offers": {
121
- "panels": [
121
+ "resources": [
122
122
  {
123
123
  "id": "antigravity",
124
- "title": "Antigravity · CLIProxy",
124
+ "title": "Antigravity",
125
125
  "command": "node \"$CODA_PLUGIN_PATH/scripts/antigravity.mjs\"",
126
126
  "maxAge": "PT5M"
127
127
  }
@@ -189,7 +189,7 @@
189
189
  "id": "github",
190
190
  "displayName": "GitHub",
191
191
  "description": "登录账号,推送时自动选对账号",
192
- "version": "1.8.0",
192
+ "version": "1.9.0",
193
193
  "category": "模型与账号",
194
194
  "icon": {
195
195
  "symbol": "arrow.triangle.pull",
@@ -270,28 +270,31 @@
270
270
  "command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/scripts/credential.mjs\""
271
271
  }
272
272
  ],
273
- "endpoints": [],
274
- "views": [],
273
+ "endpoints": [
274
+ {
275
+ "id": "accounts",
276
+ "command": "exec node \"$CODA_PLUGIN_PATH/scripts/endpoint.mjs\""
277
+ }
278
+ ],
279
+ "views": [
280
+ {
281
+ "id": "accounts",
282
+ "title": "GitHub 账号",
283
+ "entry": "view/accounts.html",
284
+ "frame": "document"
285
+ }
286
+ ],
275
287
  "offers": {
276
- "panels": [
288
+ "resources": [
277
289
  {
278
290
  "id": "accounts",
279
- "title": "GitHub 账号",
280
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
291
+ "title": "GitHub",
292
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
281
293
  "maxAge": "PT1M",
282
294
  "actions": {
283
295
  "remove": {
284
296
  "command": "node \"$CODA_PLUGIN_PATH/scripts/action.mjs\" remove",
285
297
  "confirm": "移除这个账号的登录?\n它负责的 owner 之后会重新试出用哪个账号。"
286
- },
287
- "assign": {
288
- "command": "node \"$CODA_PLUGIN_PATH/scripts/action.mjs\" assign"
289
- },
290
- "forget": {
291
- "command": "node \"$CODA_PLUGIN_PATH/scripts/action.mjs\" forget"
292
- },
293
- "move": {
294
- "command": "node \"$CODA_PLUGIN_PATH/scripts/action.mjs\" move"
295
298
  }
296
299
  },
297
300
  "signIn": {
@@ -321,7 +324,7 @@
321
324
  "id": "guide",
322
325
  "displayName": "Coda 使用指南",
323
326
  "description": "让 Agent 会回答 Coda 怎么用",
324
- "version": "1.0.0",
327
+ "version": "1.0.3",
325
328
  "category": "工作流程",
326
329
  "icon": {
327
330
  "symbol": "book.fill",
@@ -431,7 +434,7 @@
431
434
  "id": "resources",
432
435
  "displayName": "资源",
433
436
  "description": "各台电脑的账号、额度与负载",
434
- "version": "2.0.0",
437
+ "version": "2.1.0",
435
438
  "category": "机器与资源",
436
439
  "icon": {
437
440
  "symbol": "gauge.with.dots.needle.67percent",
@@ -784,21 +787,6 @@
784
787
  "order": 5,
785
788
  "default": "PT1H"
786
789
  },
787
- "session.handToUser": {
788
- "type": "boolean",
789
- "description": "流程交给会话 Agent 的任务,Agent 停下没答复、也没有别的东西会叫醒它时,转成你的卡片;关掉就一直留在 Agent 那里,等它下次被叫醒。",
790
- "title": "Agent 停下没答复的任务转给你",
791
- "order": 8,
792
- "default": true
793
- },
794
- "session.handToUserAfter": {
795
- "type": "string",
796
- "format": "duration",
797
- "description": "从 Agent 最后一次干活算起。期间它刚做完的事让流程撤掉了任务(如推送新提交),就不转;进程已停就立即转。",
798
- "title": "Agent 停下多久后转给你",
799
- "order": 9,
800
- "default": "PT2M"
801
- },
802
790
  "session.subagents": {
803
791
  "type": "integer",
804
792
  "minimum": 1,
@@ -970,7 +958,7 @@
970
958
  "id": "claude",
971
959
  "displayName": "Claude",
972
960
  "description": "用 Claude Agent SDK 跑会话",
973
- "version": "1.9.0",
961
+ "version": "1.10.0",
974
962
  "category": "Agent",
975
963
  "icon": {
976
964
  "light": "JVBERi0xLjcKJbXtrvsKNCAwIG9iago8PCAvTGVuZ3RoIDUgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+CnN0cmVhbQp4nG1WSY4YNxC76xX6QBTtyzP8hCCAnUP74OT/QFhkqWcMewaYaUrqWlisUpeY8ftHwZ/T0hrx7+/hR/gSf4Sc9shnx5z6xM/CQ+ulrBn//Rb//CvHb/+FntPaJe6T8qzxe+w15dPjbqmO+MTe0gBcwwwD9rRLjfM4HOm0HWeF3R5sYfL4OOnk6djQKkcot2LYjAAjMBybK5mxVtKG1XXskBmrIxUEsWcqw4xVxILXgfV6zbS7B60AY68yGzxXBrKzvRI+rM+dJhNr5nSWVBVZoY+x9GxUjJk6cmOU9qawmSqTcS24mBZHKYxjNS4/keSsYpzYbmbScCxzwGeeGDzrslOzuKofb8gOD6PyLcZpVkdhWT72881jGNXh00IlPcDyByaasFgsjTn340x1bgPavyfEyuz7ppsHovKq4TGVvU0CcuQHm7Pfac/18sSAPKeOZ7F0uPPx+tT7noQtvp48aeGgBUY5SNbLQvfnDkI/DC/G2V7Cl0lZ9Wf5aqzbHR0e9VCeuJhD7amSmkWmavbSsK6wZiIML5FYkByLMi3u0065Qh8zaY1Sr6ZaJzmtpTlmUBJW39a9KsBwBihyXyiF3dPtiiKTjuAdwtZhbO2jHcyft22VuMSp9Q1PiUYAhjSUABFqi6liSZjgs8u+qi+z/Fsgdwdcm7diQg/Klg2TvPFM/2gibz3R9pYENbZcYENCgggsOjHDGbPoF5r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sApLKQVxeys9hDi4gWIkiaX77Zv4Z0sJhMyPeXlvGAokoAQyEjCgGQ0ohXSfB2UJyfttREga3qMJACB5lZ2BD2BAoIXPGVVqGizQ4HicFY1W3SRQQyi41ApoTPN4B+HV2tEckmSmvebjVQoTK91H0fKNRm6lGmpuEcL6wAh7JgUtGHOv/Inkj4REm8lfLHhw1l7fcI0+h082gzfsJD+pHxeXuFOk8T5b7y34YJ3EwO6uOWs1jVCWvvD14jPTDV0c1Xwwo/cTtw2/gNUTblXlumr8lgLb88lDl9vzFo2atEAD6d3z4oTCLvGN28S/EStu+Zfq1wndFtYBXdMvwB5vsQplbmRzdHJlYW0KZW5kb2JqCjEyIDAgb2JqCiAgIDI3OQplbmRvYmoKMTMgMCBvYmoKPDwgL1R5cGUgL1hSZWYKICAgL0xlbmd0aCA1OQogICAvRmlsdGVyIC9GbGF0ZURlY29kZQogICAvU2l6ZSAxNAogICAvVyBbMSAyIDJdCiAgIC9Sb290IDExIDAgUgogICAvSW5mbyAxMCAwIFIKPj4Kc3RyZWFtCnicY2Bg+P+fiYGTgQFEMDGy2DAwMDLwAwkWNZAYO4jVAiRY2UCENEQdI4hgZmRbBhRj28vAAADC2ATdCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjE3MjUKJSVFT0YK",
@@ -981,8 +969,8 @@
981
969
  "kind": "builtin",
982
970
  "package": "@coda-console/claude",
983
971
  "tag": "latest",
984
- "version": "1.9.0",
985
- "integrity": "sha512-DfJ32fNdk1bfD0/e4H38otvoL3gqu77EvQaFvpLtycm0OzSKGQ+6eSZQybrVncohoEFe0Rd7hcUfA4OKo6rW5A==",
972
+ "version": "1.10.0",
973
+ "integrity": "sha512-iG7lXu3xtzuvuMKDZiIBEzvidrMn8mPmi+WFLrJl9iY1XoLyJYyPuZa4rY3f+HNB6L0jAz2P4NsgzEtJxEry6g==",
986
974
  "repo": "https://github.com/coda-console/coda-plugins.git",
987
975
  "path": "plugins/claude"
988
976
  },
@@ -1018,11 +1006,11 @@
1018
1006
  "endpoints": [],
1019
1007
  "views": [],
1020
1008
  "offers": {
1021
- "panels": [
1009
+ "resources": [
1022
1010
  {
1023
1011
  "id": "limits",
1024
1012
  "title": "Claude",
1025
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
1013
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
1026
1014
  "signIn": {
1027
1015
  "command": "exec node \"$CODA_PLUGIN_PATH/scripts/login.mjs\"",
1028
1016
  "installed": "node \"$CODA_PLUGIN_PATH/scripts/login.mjs\" --installed",
@@ -1066,7 +1054,7 @@
1066
1054
  "id": "codex",
1067
1055
  "displayName": "Codex",
1068
1056
  "description": "用 OpenAI Codex 跑会话",
1069
- "version": "1.10.0",
1057
+ "version": "1.11.0",
1070
1058
  "category": "Agent",
1071
1059
  "icon": {
1072
1060
  "light": "JVBERi0xLjcKJbXtrvsKNCAwIG9iago8PCAvTGVuZ3RoIDUgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+CnN0cmVhbQp4nG2WXW4cOQyE33UKXWAVUb/UMXKEoIEkD56H7N4f2I9sqT1eLAzYUxy1mixWkZaY+flL+CVL08grXq/wJ3yPf0L27/7+Fb/9yPHXP2GOpKPGWVJZNb7ixr2mVkb8eLAkrSPOmVqfsec0Wo9TkzaNbSXtJcQriow0tceiKefG01IkLU6WnnKpQE2SgTWNCqwttSEH8nxXSyM8B2ZNVWdsxR87cEia044fXJOMT9TSbDcU1RDHSJXUOV6r19IqL5mWXZVk+ZNj5oGyUl5vkFqkn9NXiL+DjJ5akyitU6dA1xPJULK6Xboja6YlDdhS6XH1tOBTSF3HDHG11OtyykrKZM9TFvhwjmqW2EcquXpgcTUB7rULa06qdcMApnWznvPGSubTtO7kLnaBSqL2qLBthala1Se/G4kIHfIe7gDli1gLVuqNvy1zIH5hwJvwOxACQsHghQtSGrrgwxqpF6ugoZqxjAPybAhqyiHgoIJMlr1+B9BU6WrP3ngranea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pzdGFydHhyZWYKMTg2OAolJUVPRgo=",
@@ -1077,8 +1065,8 @@
1077
1065
  "kind": "builtin",
1078
1066
  "package": "@coda-console/codex",
1079
1067
  "tag": "latest",
1080
- "version": "1.10.0",
1081
- "integrity": "sha512-NVj+4zdggzf8mhwGiVgI9FROdeSB27SeyW2evopnz5y/29Pinv+S6AIj/hX6Z1T0ksdAvxFL2uqhf2/0oI8SSg==",
1068
+ "version": "1.11.0",
1069
+ "integrity": "sha512-/Vri1yv+QOGIHZ/PIvL1A8Ai9hYcT4LbJOvZ9AcLJIACJ4tK5Mq8WBIkAPYvZgxY37rnH1EqwNAChGFlsPl75A==",
1082
1070
  "repo": "https://github.com/coda-console/coda-plugins.git",
1083
1071
  "path": "plugins/codex"
1084
1072
  },
@@ -1105,11 +1093,11 @@
1105
1093
  "endpoints": [],
1106
1094
  "views": [],
1107
1095
  "offers": {
1108
- "panels": [
1096
+ "resources": [
1109
1097
  {
1110
1098
  "id": "login",
1111
1099
  "title": "Codex",
1112
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
1100
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
1113
1101
  "maxAge": "PT0S",
1114
1102
  "actions": {
1115
1103
  "reset": {
@@ -1151,7 +1139,7 @@
1151
1139
  "dependencies": [],
1152
1140
  "extensionPoints": {
1153
1141
  "account-source": {
1154
- "description": "Codex 的账号与登录入口:来源给出当前账号和令牌,响应 --login,并提供账号与额度面板;接入后 Codex 自带的额度面板隐藏。"
1142
+ "description": "Codex 的账号与登录入口:来源给出当前账号和令牌,响应 --login,并提供账号与额度资源;接入后 Codex 自带的那一行不再显示。"
1155
1143
  }
1156
1144
  },
1157
1145
  "extensions": [],
@@ -1161,7 +1149,7 @@
1161
1149
  "id": "codex-accounts",
1162
1150
  "displayName": "Codex 多账号",
1163
1151
  "description": "管理多个 Codex 账号与额度",
1164
- "version": "2.2.0",
1152
+ "version": "2.3.0",
1165
1153
  "category": "模型与账号",
1166
1154
  "icon": {
1167
1155
  "symbol": "person.2.fill",
@@ -1172,8 +1160,8 @@
1172
1160
  "kind": "builtin",
1173
1161
  "package": "@coda-console/codex-accounts",
1174
1162
  "tag": "latest",
1175
- "version": "2.2.0",
1176
- "integrity": "sha512-k/mF1HBQxWE5vc9S6fPg58+oBWmpUQqBbbVYD8WPd4T794yIqOI3/2FuIRmN+WEowYKZL+Og1C2rEZvwSroq1Q==",
1163
+ "version": "2.3.0",
1164
+ "integrity": "sha512-CM1cYx8TbkpXa/PY+9XYmS7LQY+UnsovxbglzSCGN8m40AqGofgDpBmUlm8hf2kvYbz5/S4OBfUwH+YW7Zj4rA==",
1177
1165
  "repo": "https://github.com/coda-console/coda-plugins.git",
1178
1166
  "path": "plugins/codex-accounts"
1179
1167
  },
@@ -1189,11 +1177,11 @@
1189
1177
  "endpoints": [],
1190
1178
  "views": [],
1191
1179
  "offers": {
1192
- "panels": [
1180
+ "resources": [
1193
1181
  {
1194
1182
  "id": "accounts",
1195
- "title": "Codex 多账号",
1196
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
1183
+ "title": "Codex",
1184
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
1197
1185
  "maxAge": "PT5M",
1198
1186
  "actions": {
1199
1187
  "select": {
@@ -1210,7 +1198,7 @@
1210
1198
  },
1211
1199
  "signIn": {
1212
1200
  "command": "NO_COLOR=1 exec node \"$CODA_PLUGIN_PATH/scripts/login.mjs\"",
1213
- "note": "登录其他账号即可添加;登录已有账号会更新其凭据。首个账号会自动选用,之后可在面板切换。"
1201
+ "note": "登录其他账号即可添加;登录已有账号会更新其凭据。首个账号会自动选用,之后在账号那一行的「···」里切换。"
1214
1202
  }
1215
1203
  }
1216
1204
  ]
@@ -1233,7 +1221,7 @@
1233
1221
  "id": "composer",
1234
1222
  "displayName": "输入框模式",
1235
1223
  "description": "交接、子会话、! 命令、Ultra 与循环",
1236
- "version": "3.9.0",
1224
+ "version": "3.10.1",
1237
1225
  "category": "工作流程",
1238
1226
  "icon": {
1239
1227
  "symbol": "character.cursor.ibeam",
@@ -1244,8 +1232,8 @@
1244
1232
  "kind": "builtin",
1245
1233
  "package": "@coda-console/composer",
1246
1234
  "tag": "latest",
1247
- "version": "3.9.0",
1248
- "integrity": "sha512-o3yN3ED6XjYLG7a+gZlxA34Hj4vpRpdW23od+hSJgXfwayhb9G2hW7VNEJ9xfexe2VUjVRashtSz0Xe67uEK1Q==",
1235
+ "version": "3.10.1",
1236
+ "integrity": "sha512-21uk17cG/JCC8ohPzJy5bvJnY8e75c0SAec77hr6hxv00SvyoZtKrfeG2sz3bbOZqz/v3lxOoJ1AeVBZ81gfOw==",
1249
1237
  "repo": "https://github.com/coda-console/coda-plugins.git",
1250
1238
  "path": "plugins/composer"
1251
1239
  },
@@ -1584,7 +1572,7 @@
1584
1572
  "id": "grok",
1585
1573
  "displayName": "Grok",
1586
1574
  "description": "用 Grok CLI 跑会话",
1587
- "version": "1.5.0",
1575
+ "version": "1.6.0",
1588
1576
  "category": "Agent",
1589
1577
  "icon": {
1590
1578
  "light": "JVBERi0xLjcKJbXtrvsKNCAwIG9iago8PCAvTGVuZ3RoIDUgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+CnN0cmVhbQp4nFVTTcoVQQzc9ymyFoxJ57eP4RFkwG/zXKj3Byv9UJCBGZLupCpVGSXB81nx0rPp+bF+Lrm5Xx/05ZvQx+9Vzpqke7Nt+kFqxaedKlg96EXqyqpGtbm3IwyOTirjMkTF0puqUL3oIQ3nszed5D3noezapHpY7KB7cIvi65y1p2AL60EmhE2CTrNnLMQA2EXVnHIu7EGjhyIvgAYSQHhRN1oHKTjsxMEeCFSU8jmJTn7eHLzZfFpo9h1O9+E4mAnDnInF361wHtuoBVL8LYha1Mrig6kpXFKE8RU3tIRDmsw4AxQOwiIQvMUHVaEIbfRDFKaLIED22MIiTjZcLxLkRZkJu/VF+pewOEiMX1ZvwyxpvSjlO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LqyQhpYXX3PPlB4ebo1l/h33o1d/xL97ft/AVuy3nRLxI/bsgKZW5kc3RyZWFtCmVuZG9iagoxMiAwIG9iagogICAyNzcKZW5kb2JqCjEzIDAgb2JqCjw8IC9UeXBlIC9YUmVmCiAgIC9MZW5ndGggNTkKICAgL0ZpbHRlciAvRmxhdGVEZWNvZGUKICAgL1NpemUgMTQKICAgL1cgWzEgMiAyXQogICAvUm9vdCAxMSAwIFIKICAgL0luZm8gMTAgMCBSCj4+CnN0cmVhbQp4nGNgYPj/n4mBk4EBRDAxMoUxMDAy8AMJJgeQGDuINQ9IMCuACFOIOkYQwczIsg8oxnKVgQEA1JwFgQplbmRzdHJlYW0KZW5kb2JqCnN0YXJ0eHJlZgoxMjM3CiUlRU9GCg==",
@@ -1595,8 +1583,8 @@
1595
1583
  "kind": "builtin",
1596
1584
  "package": "@coda-console/grok",
1597
1585
  "tag": "latest",
1598
- "version": "1.5.0",
1599
- "integrity": "sha512-eMrRAGwSDOhkVER7Kh0yFwFwnuLdg92k/JTXC+1HUu80RE56zf1HcFjDp8BgEL6HxDxz9gqqk+L34f5Yymq9Ng==",
1586
+ "version": "1.6.0",
1587
+ "integrity": "sha512-BPmNhauZXOTCdnyuVoydvVdH/szTHFDlaISF0CfcgIFyMv2jMKrElDy7+H97nGexKIpLLp+iZuUmSIj7L4sxog==",
1600
1588
  "repo": "https://github.com/coda-console/coda-plugins.git",
1601
1589
  "path": "plugins/grok"
1602
1590
  },
@@ -1612,11 +1600,11 @@
1612
1600
  "endpoints": [],
1613
1601
  "views": [],
1614
1602
  "offers": {
1615
- "panels": [
1603
+ "resources": [
1616
1604
  {
1617
1605
  "id": "account",
1618
1606
  "title": "Grok",
1619
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
1607
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
1620
1608
  "maxAge": "PT5M",
1621
1609
  "signIn": {
1622
1610
  "command": "g=\"$HOME/.grok/bin/grok\"; [ -x \"$g\" ] || g=grok; BROWSER=/usr/bin/true NO_COLOR=1 exec \"$g\" login --device-auth",
@@ -1662,7 +1650,7 @@
1662
1650
  "id": "kimi",
1663
1651
  "displayName": "Kimi Code",
1664
1652
  "description": "用 Kimi Code 跑会话",
1665
- "version": "1.3.0",
1653
+ "version": "1.4.1",
1666
1654
  "category": "Agent",
1667
1655
  "icon": {
1668
1656
  "light": "JVBERi0xLjcKJbXtrvsKNCAwIG9iago8PCAvTGVuZ3RoIDUgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+CnN0cmVhbQp4nGWUTY4cIQyF95yCC4RgDMY+Ro4QtdSTRc0iyf2lvEcV1Z1EI03xgY2ff2jJFX9fBP9ER358pp+prr1fH/nr95o/fifVMgd2PrNUKY3LI4tE8dh+4sW6rOVp/Ti3T/tjQdou9/dlsWJfrlzDYxSpsQAhxIqO4GrZJxjXy/zg7mV8fvZJhdWPN/XPVEuNKmGQXYboZGQmKrUX7Z7bLOpzJepFbhZBUJestXT3F8KpMdPN8OmetnOn0n7ffeEjh5emG48cs8w5N4O69NwrK5TesKvT9+Qz8nHjpasiq3aL/iuntGrxX57PhDacNbBRukU2ysFJyOooZHllkaMV0SVbxXjqY1CXQgioSVzESHPCeO7jI08r4X0zyNUWxSBNWVcNYTW7Y2HZHDn1BGds1OncCJYCKbd1PFRumuvGx2aoxBXHjbVYRCJKu1V3BB6+CdM3S33ldGS1Yn6fg1iyfdXGFeixEa01P10XBgZC9kWgUX2HOYnFunRcx8dWefGVwnXVphXnTtdRXpP0SthZ02WNeQD0qQSb60iX5IFtTClaxT4fZGtB7oq6A6O1hbXlAU3DSAPP8JEd3dLI0cs0FtoxVzY5j9p7dv4aOFVGs8TRiWhMgf3GEGvRGWQONYj9B9UhN6G9Zqct2ZnJZIavDcFcgjpeM/O1RpImO3s4Q6WtAih+FpxzlH0Uzig+jnFzxXjTFNPPgMYyc9zBeMscMzcl1egkNuH9pZzv6p+380zf0h/YMwmkCm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+PgpzdHJlYW0KeJxjYGD4/5+JgZOBAUQwMTItZ2BgZOAHEkwTQWLsINZ7IMFcCCLaIOoYQQQzI6sAUIxVnYEBAAYyBbwKZW5kc3RyZWFtCmVuZG9iagpzdGFydHhyZWYKMTMxOQolJUVPRgo=",
@@ -1674,8 +1662,8 @@
1674
1662
  "kind": "builtin",
1675
1663
  "package": "@coda-console/kimi",
1676
1664
  "tag": "latest",
1677
- "version": "1.3.0",
1678
- "integrity": "sha512-Q/qiUPshiQO7xFEvk8n8TKguBHmmpEkqrS5BR+3mTdq3i3HxpV/Q8gKKaa11KqE6I2tUlReBXt5e/l/PAcgLSQ==",
1665
+ "version": "1.4.1",
1666
+ "integrity": "sha512-bBLlDqgdZWnEDb3l7LPKYWamyd05jV9Ptelwcjz/DQpzfw/YbBN316crIgk7L2dVOvcmZgdL+VFtGU83nXA7+A==",
1679
1667
  "repo": "https://github.com/coda-console/coda-plugins.git",
1680
1668
  "path": "plugins/kimi"
1681
1669
  },
@@ -1691,11 +1679,11 @@
1691
1679
  "endpoints": [],
1692
1680
  "views": [],
1693
1681
  "offers": {
1694
- "panels": [
1682
+ "resources": [
1695
1683
  {
1696
1684
  "id": "account",
1697
1685
  "title": "Kimi",
1698
- "command": "node \"$CODA_PLUGIN_PATH/scripts/panel.mjs\"",
1686
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
1699
1687
  "maxAge": "PT5M",
1700
1688
  "signIn": {
1701
1689
  "command": "exec sh \"$CODA_PLUGIN_PATH/scripts/login.sh\"",
@@ -2001,29 +1989,23 @@
2001
1989
  {
2002
1990
  "id": "machine-stats",
2003
1991
  "displayName": "机器负载",
2004
- "description": "在资源页显示 CPU、内存、各磁盘、网络、温度、GPU、电池与风扇数值;在插件设置中选择显示项,打开或刷新时采样。",
2005
- "version": "1.0.2",
1992
+ "description": "CPU、内存、磁盘、网络与温度读数",
1993
+ "version": "2.0.0",
2006
1994
  "category": "机器与资源",
1995
+ "icon": {
1996
+ "symbol": "cpu",
1997
+ "color": "green"
1998
+ },
2007
1999
  "readme": true,
2008
2000
  "source": {
2009
2001
  "kind": "builtin",
2010
2002
  "repo": "https://github.com/coda-console/machine-stats.git",
2011
2003
  "path": "",
2012
- "commit": "22e991f41d467389d485ac995f8d0f753f5ef608"
2004
+ "commit": "957498f60cdd2fdd95f431ad07060f3f8e8ff84b"
2013
2005
  },
2014
2006
  "dir": "node_modules/machine-stats",
2015
2007
  "title": "机器负载",
2016
- "properties": {
2017
- "machine-stats.display": {
2018
- "type": "object",
2019
- "description": "资源页显示的指标,按磁盘与网卡分别选择。",
2020
- "title": "显示指标",
2021
- "entries": {
2022
- "type": "boolean"
2023
- },
2024
- "default": {}
2025
- }
2026
- },
2008
+ "properties": {},
2027
2009
  "workflows": [],
2028
2010
  "capabilities": [],
2029
2011
  "services": [],
@@ -2033,12 +2015,61 @@
2033
2015
  "endpoints": [],
2034
2016
  "views": [],
2035
2017
  "offers": {
2036
- "panels": [
2018
+ "resources": [
2019
+ {
2020
+ "id": "cpu",
2021
+ "title": "CPU",
2022
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" cpu"
2023
+ },
2024
+ {
2025
+ "id": "memory",
2026
+ "title": "内存",
2027
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" memory"
2028
+ },
2029
+ {
2030
+ "id": "swap",
2031
+ "title": "交换空间",
2032
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" swap",
2033
+ "hidden": true
2034
+ },
2035
+ {
2036
+ "id": "disks",
2037
+ "title": "磁盘",
2038
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" disks"
2039
+ },
2040
+ {
2041
+ "id": "disk-io",
2042
+ "title": "磁盘读写",
2043
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" disk-io",
2044
+ "hidden": true
2045
+ },
2046
+ {
2047
+ "id": "network",
2048
+ "title": "网络",
2049
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" network"
2050
+ },
2051
+ {
2052
+ "id": "temperature",
2053
+ "title": "温度",
2054
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" temperature"
2055
+ },
2056
+ {
2057
+ "id": "gpu",
2058
+ "title": "GPU",
2059
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" gpu",
2060
+ "hidden": true
2061
+ },
2062
+ {
2063
+ "id": "battery",
2064
+ "title": "电池",
2065
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" battery",
2066
+ "hidden": true
2067
+ },
2037
2068
  {
2038
- "id": "load",
2039
- "title": "机器负载",
2040
- "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\"",
2041
- "displaySetting": "machine-stats.display"
2069
+ "id": "fans",
2070
+ "title": "风扇",
2071
+ "command": "node \"$CODA_PLUGIN_PATH/scripts/stats.mjs\" fans",
2072
+ "hidden": true
2042
2073
  }
2043
2074
  ]
2044
2075
  },
@@ -17,13 +17,14 @@ export const target = {
17
17
  ],
18
18
  };
19
19
  const snapshotMode = object({ mode, values, sent: { type: 'integer', minimum: 0 }, changedSinceSent: { type: 'boolean' } });
20
- export const composerType = { kind: 'composers', participants: () => [],
20
+ export const COMPOSER = 'coda/composer@1', SUBMISSION = 'coda/submission@1';
21
+ export const composerType = { kind: COMPOSER, participants: () => [],
21
22
  spec: { ...object({ thread: string, project: string, modes: array(object({ mode, values })) }, ['modes']),
22
23
  oneOf: [{ required: ['thread'], not: { required: ['project'] } }, { required: ['project'], not: { required: ['thread'] } }] },
23
24
  status: object({ modes: array(object({ mode, sent: { type: 'integer', minimum: 0 }, changedSinceSent: { type: 'boolean' }, presets: { type: 'object', additionalProperties: array(object({ name: {}, values: array(values) })) } })) }) };
24
25
  const tell = array({ type: 'string', minLength: 1, pattern:'^[^\\u0000]*\\S[^\\u0000]*$' });
25
26
  const targets = array(target), divert = { type: 'boolean' };
26
- export const submissionType = { kind: 'submissions',
27
+ export const submissionType = { kind: SUBMISSION,
27
28
  participants: object => object.spec.modes.map(({ mode }) => { const [plugin, key] = mode.split('/'); return { plugin, key }; }),
28
29
  spec: object({ composer: string, thread: { type: ['string', 'null'] }, projectId: string, text: { type: 'string', minLength: 1, maxLength: 100000 },
29
30
  attachments: { ...array(string), maxItems: 20, uniqueItems: true }, quotes: { ...array({ type: 'string', maxLength: 20000 }), maxItems: 20 },
@@ -19,6 +19,7 @@ import { AGENT_ID } from '../../domain/values.mjs';
19
19
  import { agentDeclarations, iconFiles } from './agent-plugins.mjs';
20
20
  import { checkCatalog, extensionsFor } from './plugin-extensions.mjs';
21
21
  import { manifestProblem, TYPES } from '@coda-console/protocol/validate';
22
+ import { ownedProtocolsProblem } from '@coda-console/protocol/protocol';
22
23
  import { claims, COMMIT, INTEGRITY, NPM_VERSION, npmPluginId, repoAddress, sourcePath } from './plugin-source-rules.mjs';
23
24
  import { readSkillDocument } from './skill-document.mjs';
24
25
  import { executorLabels } from '../workflows/executor-labels.mjs';
@@ -125,6 +126,8 @@ export function readPlugin(dir, source) {
125
126
  if (!named && source?.package && typeof manifest.name === 'string') try { id = npmPluginId(manifest.name); } catch {}
126
127
  check(typeof id === 'string' && ID.test(id), 'invalid_plugin', `package.json 的 ${named ? 'id' : 'name'} 只能用小写字母、数字和「-」`);
127
128
  const contributes = manifest.contributes ?? {}, configuration = contributes.configuration ?? {};
129
+ const protocolsProblem = ownedProtocolsProblem({ id, contributes: { protocols: contributes.protocols } });
130
+ check(!protocolsProblem, 'invalid_plugin', protocolsProblem);
128
131
  const properties = Object.fromEntries(Object.entries(configuration.properties ?? {}).map(([key, value]) => {
129
132
  check(key.split('.')[0] === id, 'invalid_plugin', `设置名须以「${id}.」开头:${key}`);
130
133
  return [key, setting(value, key)];
@@ -152,6 +155,8 @@ export function readPlugin(dir, source) {
152
155
  ...(v.icon ? { icon: v.icon } : {}), ...(v.handles?.length ? { handles: [...v.handles] } : {}), ...(v.readout ? { readout: v.readout } : {}),
153
156
  ...(v.checkout ? { checkout: v.checkout } : {}), ...(v.frame ? { frame: v.frame } : {}) })),
154
157
  ...(contributes.composerModes?.length ? { composerModes: composerModes(contributes.composerModes) } : {}),
158
+ ...(contributes.protocols?.length ? { protocols: structuredClone(contributes.protocols) } : {}),
159
+ ...(contributes.protocolImplementations?.length ? { protocolImplementations: [...contributes.protocolImplementations] } : {}),
155
160
  ...(Object.keys(offers).length ? { offers } : {}),
156
161
  agents,
157
162
  dependencies: [...dependencies], extensionPoints: extensionPoints(contributes.extensionPoints, dir),
@@ -279,6 +279,10 @@ export function catalogProblem(plugin, catalog, builtin, installed) {
279
279
  const owner = [...catalog.values()].find(p => p.id !== plugin.id && claims(p).includes(claim));
280
280
  if (owner) return `${claim} 已由插件 ${owner.displayName} 声明`;
281
281
  }
282
+ for (const definition of plugin.protocols ?? []) {
283
+ const owner = [...catalog.values()].find(p => p.id !== plugin.id && p.protocols?.some(other => other.name === definition.name));
284
+ if (owner) return `协议 ${definition.name} 已由插件 ${owner.displayName} 定义`;
285
+ }
282
286
  return null;
283
287
  }
284
288
  // What installing a plugin from a repository brings along, in the order installing does it (components/plugins/plugin-extensions.mjs
@@ -2,6 +2,7 @@
2
2
  import { requireCondition as check } from '../../domain/errors.mjs';
3
3
 
4
4
  export const creationProperties = {
5
+ provider: { type: 'string' },
5
6
  createdAt: { type: 'string' },
6
7
  creationSequence: { type: 'integer', minimum: 1, maximum: Number.MAX_SAFE_INTEGER },
7
8
  };
@@ -1,9 +1,17 @@
1
- import Ajv from 'ajv';
1
+ import Ajv2020 from 'ajv/dist/2020.js';
2
+ import { parseProtocolName } from '@coda-console/protocol/protocol';
3
+ import { AGENTS, GROUPS, THREADS } from '../../domain/resource-kinds.mjs';
4
+
5
+ // The resource kinds an invocation may name until the resource is a protocol of its own (docs/plugins.md「调用」): `threads`,
6
+ // `agents`, `groups`. Only Coda's own core operations use these; a plugin defines protocols under its namespace.
7
+ const KINDS = new Set([AGENTS, GROUPS, THREADS]);
8
+ export const resourceKind = value => KINDS.has(value);
2
9
 
3
10
  // Only JSON Schema rules: no coercion, custom keywords or executable constraints. Only the type's schemas
4
11
  // supply defaults. An absent field without a declared default stays absent.
5
- const ajv = new Ajv({ allErrors: true, addUsedSchema: false });
6
- const defaults = new Ajv({ allErrors: true, addUsedSchema: false, useDefaults: true });
12
+ const options = { allErrors: true, addUsedSchema: false, strict: true, strictTypes: false, strictRequired: false, allowUnionTypes: true };
13
+ const ajv = new Ajv2020(options);
14
+ const defaults = new Ajv2020({ ...options, useDefaults: true });
7
15
  const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
8
16
  const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
9
17
 
@@ -19,10 +27,23 @@ export function validate(check, value, who) {
19
27
 
20
28
  export class ProtocolTypes {
21
29
  constructor() { this.types = new Map(); }
22
- register({ kind, spec, status, contributions = {}, participants }, registered = () => {}) {
23
- if (typeof kind !== 'string' || !/^[a-z][a-zA-Z0-9-]*$/.test(kind) || this.types.has(kind)) throw new TypeError(`协议类型无效或已登记:${kind}`);
30
+ register({ kind, spec, status, operations = {}, contributions = {}, participants = () => [] }, registered = () => {}, replace = false) {
31
+ if (!(parseProtocolName(kind) || resourceKind(kind)) || (this.types.has(kind) && !replace)) throw new TypeError(`协议名无效或已登记:${kind}`);
24
32
  if (spec?.type !== 'object' || status?.type !== 'object') throw new TypeError(`${kind}: spec 与 status 须为对象 schema`);
25
33
  if (typeof participants !== 'function' || !object(contributions)) throw new TypeError(`${kind}: 需要 participants 与 contributions`);
34
+ // Each operation is an input and either an immediate result or a run reference, as the protocol package defines them.
35
+ // `join` names an input field holding the run of an open call that the operation adds to instead of opening one;
36
+ // `safe`, one that only reads and answers at once, whose request and answer neither side keeps.
37
+ if (!object(operations)) throw new TypeError(`${kind}: operations 须为对象`);
38
+ const compiled = new Map();
39
+ for (const [name, operation] of Object.entries(operations)) {
40
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(name) || !object(operation)) throw new TypeError(`${kind}.${name}: 操作名或定义无效`);
41
+ const run = operation.run === true, join = operation.join;
42
+ if (run === Object.hasOwn(operation, 'result') || !operation.input) throw new TypeError(`${kind}.${name}: 操作要写 input,并恰写 result 或 run`);
43
+ if (join !== undefined && (!run || typeof join !== 'string' || !join)) throw new TypeError(`${kind}.${name}: join 只能用于运行,并写出输入里的字段`);
44
+ compiled.set(name, { input: compile(operation.input), ...(run ? { run } : { result: compile(operation.result) }), ...(join ? { join } : {}),
45
+ ...(operation.safe === true ? { safe: true } : {}) });
46
+ }
26
47
  const properties = {};
27
48
  for (const [field, { merge, schema }] of Object.entries(contributions)) {
28
49
  const type = merge === 'append' ? 'array' : merge === 'or' ? 'boolean' : null;
@@ -31,7 +52,7 @@ export class ProtocolTypes {
31
52
  }
32
53
  Object.defineProperty(properties, field, { value: schema, enumerable: true });
33
54
  }
34
- const type = { kind, participants, contributions: structuredClone(contributions),
55
+ const type = { kind, participants, contributions: structuredClone(contributions), operations: compiled,
35
56
  spec: compile(spec, defaults), status: compile(status, defaults),
36
57
  // Before supplementation only merge operands must be shaped correctly. Required fields and counts apply to the
37
58
  // complete spec, so a participant can supply a required list that the initial object does not have yet.
@@ -60,16 +60,26 @@ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
60
60
  export function firstMessage(value) {
61
61
  object(value, '首次发送');
62
62
  keys(value, ['requestId', 'projectId', 'title', 'agent', 'checkout', 'settings', 'text', 'attachments', 'quotes', 'handoffSource', 'parentThreadId',
63
- 'replyTo', 'threadId', 'extensionParent', 'modes', 'initiatedBy']);
63
+ 'replyTo', 'threadId', 'modes', 'initiatedBy', 'link']);
64
64
  const initiatedBy = value.initiatedBy === undefined ? {} : (() => {
65
65
  const source = object(value.initiatedBy, '发起会话');
66
66
  keys(source, ['threadId', 'title']);
67
67
  check(UUID.test(source.threadId ?? ''), 'invalid_input', '发起会话标识须为 UUID');
68
- check(!value.parentThreadId && !value.extensionParent && !value.handoffSource, 'invalid_input', '发起的会话须为独立会话');
68
+ check(!value.parentThreadId && !value.handoffSource, 'invalid_input', '发起的会话须为独立会话');
69
69
  return { initiatedBy: { threadId: source.threadId, title: text(source.title, '发起会话标题') } };
70
70
  })();
71
71
  const handoff = value.handoffSource === undefined ? {} : { handoffSource: text(value.handoffSource, '交接来源', 100) };
72
72
  const parent = value.parentThreadId === undefined ? {} : { parentThreadId: text(value.parentThreadId, '父会话', 100) };
73
+ // A session made in a session a plugin provides, as its bot (components/session-links): the `coda/session@1` record, this
74
+ // machine's or another's by its `remote:` reference, and what there wakes it — a message that @s or answers it
75
+ // (`mention`, the default), or any (`all`). That the record is one a provider has is checked as the session is made.
76
+ const link = value.link === undefined ? {} : (() => {
77
+ const named = object(value.link, '外部会话');
78
+ keys(named, ['record', 'wake']);
79
+ check(!parent.parentThreadId && !value.initiatedBy, 'invalid_input', '外部会话里的会话须为用户新建的独立会话');
80
+ check([undefined, 'mention', 'all'].includes(named.wake), 'invalid_input', 'wake 须为 mention 或 all');
81
+ return { link: { record: text(named.record, '外部会话', 2048), wake: named.wake ?? 'mention' } };
82
+ })();
73
83
  check(!parent.parentThreadId || handoff.handoffSource === parent.parentThreadId, 'invalid_input', '子会话必须引用父会话上下文');
74
84
  // Whom a child the user starts answers (#1904「回复权」): its parent, as a call of the parent's would (`parent`, the
75
85
  // default), or the user who started it (`sender`): under its parent all the same, which is where it belongs, not whom it
@@ -78,21 +88,9 @@ export function firstMessage(value) {
78
88
  const reply = value.replyTo === 'sender' ? { replyTo: 'sender' } : {};
79
89
  // Which agents may run is the store's to say (its plugin installed); here only that it names one.
80
90
  check(typeof value.agent === 'string' && AGENT_ID.test(value.agent), 'invalid_input', 'Agent 不可用');
81
- // A session an extension starts for a parent session this kernel does not keep (docs/subagent-design.md「扩展作为调用方」):
82
- // the extension names it, so that a retry finds it and the parent knows it before the answer comes, and says who calls
83
- // it — `caller`, which every later call of that parent's must name again, `threadId` and `title` of the parent, and
84
- // `location`, where the parent is, in words — all as the extension knows them. Only an extension may say so
85
- // (transport/http.mjs); the child works in a worktree of its own, and is nobody's child here.
86
- const outside = value.extensionParent === undefined ? {} : (() => {
87
- const p = object(value.extensionParent, '父会话');
88
- keys(p, ['caller', 'threadId', 'title', 'location']);
89
- check(UUID.test(value.threadId ?? ''), 'invalid_input', '扩展发起的子会话须带会话标识(UUID)');
90
- check(value.parentThreadId === undefined && value.handoffSource === undefined && value.checkout?.kind === 'worktree', 'invalid_input',
91
- '扩展发起的子会话只在新工作树里开始');
92
- return { threadId: value.threadId, extensionParent: { caller: text(p.caller, '调用方', 200), threadId: text(p.threadId, '父会话', 100),
93
- title: typeof p.title === 'string' ? p.title.slice(0, 200) : '', ...(typeof p.location === 'string' && p.location ? { location: p.location.slice(0, 200) } : {}) } };
94
- })();
95
- check(value.threadId === undefined || value.extensionParent !== undefined || value.initiatedBy !== undefined,
91
+ // A session an agent started of its own (initiatedBy) names its own ID, so that a retry finds it; the child the user
92
+ // starts from the interface is under its parent, in a checkout it names.
93
+ check(value.threadId === undefined || value.initiatedBy !== undefined,
96
94
  'invalid_input', '只有 Agent 发起的会话可以指定会话标识');
97
95
  if (value.threadId !== undefined) check(UUID.test(value.threadId), 'invalid_input', '会话标识须为 UUID');
98
96
  const checkout = object(value.checkout, '工作位置');
@@ -110,8 +108,8 @@ export function firstMessage(value) {
110
108
  ...handoff,
111
109
  ...initiatedBy,
112
110
  ...parent,
111
+ ...link,
113
112
  ...reply,
114
- ...outside,
115
113
  ...(value.threadId === undefined ? {} : { threadId: value.threadId }),
116
114
  requestId: text(value.requestId, '请求标识', 100),
117
115
  projectId: text(value.projectId, '目录标识', 100),
@@ -1,38 +1,38 @@
1
1
  {
2
- "commit": "d75bc18652da406a03a9d5665fa1f05034837206",
2
+ "commit": "c5dcba044bf07a0c0466c04765f32b717c6b7cf7",
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "1.4.0",
6
- "@coda-console/protocol": "2.5.0",
6
+ "@coda-console/protocol": "3.0.0",
7
7
  "ajv": "8.20.0",
8
8
  "yaml": "2.9.1"
9
9
  },
10
10
  "files": {
11
- "check/coda/components/protocols/creation.mjs": "d061194dafc615fff490869e90d252deb2429a12a3d5e046a886212ec3afede4",
12
- "check/coda/components/protocols/provider-definition.mjs": "98327f1900f84109fd5493d2de8f683eb020754245f3049869ca3b30468821f9",
13
- "check/coda/components/protocols/types.mjs": "94bb3f30a3fcbe50e5a5c286fa84f4bd80951932adb582046a7820622415a229",
14
- "check/coda/adapters/provider-api.mjs": "8a2b5d7b4a3766f9e28270bd355f4b4081d3069b4cedad120671995bea160253",
11
+ "check/coda/components/protocols/creation.mjs": "2b4a400d3064af4b5106077dc783c567910fef3c47b2d52af3f0d838c5accf19",
12
+ "check/coda/components/protocols/types.mjs": "b101452e2638b1dd27e103e58f6c56ee2e19d598840d8f59c4bb8e06687bf4da",
13
+ "check/coda/adapters/provider-api.mjs": "a584316c3e0dafa19667f4288c54b8f894b49de72d9f62098d592b9084dec482",
15
14
  "check/coda/adapters/admission-api.mjs": "461b5a8a1ad73d7afed5db308813d02324e29c643b8e773ad127d4bdb00fb524",
16
- "check/coda/components/composers/schemas.mjs": "282052bb58bdbf612a55b275456c6fea04d979136cf8a3700a4641380e501b3f",
15
+ "check/coda/components/composers/schemas.mjs": "6d497f58147756e789f9a566b2366f2fe36c0c72310421fb02508bf24a04f2c0",
17
16
  "check/coda/components/plugins/agent-plugins.mjs": "7ca5c0303c6fedffa7b0bcd90546273356ebc410b101f203f2ee8e7503063403",
18
17
  "check/coda/components/plugins/plugin-extensions.mjs": "4d7963185195ba6d21a4e49a66987613d5892210b1eb1dc02cffb7b816407776",
19
- "check/coda/components/plugins/plugin-rules.mjs": "6a0e534aefb2256c4e88486a4727dc7ad88cb29bec755a854d5bf2f4bf773a24",
20
- "check/coda/components/plugins/plugin-source-rules.mjs": "d894d55a3272df5ef3b108b68820c64aefdf6b69346404b58954f2a3503cb4a5",
18
+ "check/coda/components/plugins/plugin-rules.mjs": "5c6aeb7025337098f33844b743faaaa4cf122c343c3a897d755b00098a5d4938",
19
+ "check/coda/components/plugins/plugin-source-rules.mjs": "cdbe62cc3264469ec91ef7b8ff011a4b8313210f02bd44feb6bfb19eb4624fb9",
21
20
  "check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
22
21
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
23
- "check/coda/components/session-config/commands.mjs": "2e4c80b0280db32fe220fa360f18a8e66f12e6a16e3e7bce545c762c9c6340e1",
22
+ "check/coda/components/session-config/commands.mjs": "b8505802e25590435bf48d741522d85c8b185e8f2ae190d49e53eebd35a1d453",
24
23
  "check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
25
24
  "check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
26
25
  "check/coda/domain/duration.mjs": "15dd64ef9b02342ad521c66e5968a569432a89dc7568d11afd3e6f3fe37e104b",
27
26
  "check/coda/domain/errors.mjs": "ddc00aef9bb6f9a56845a9926c82200628a906230d31212d88fcde48e36dfd36",
28
27
  "check/coda/domain/resource-admission.mjs": "775b1d7067f9d8487a3504d737f3f4bea31adf77af3357ed42e313805e5188e7",
29
28
  "check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
29
+ "check/coda/domain/resource-kinds.mjs": "32d020457484823ce8c2ce1c6ec10cef9d6dabafc4d0c640b4084a8339622930",
30
30
  "check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
31
31
  "check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
32
32
  "check/coda/resources/plugins/resources/panels/command.mjs": "606f28bf87f87dded9df2db892bc7624c770d795ffab88f2409998346920ae42",
33
33
  "check/coda/resources/plugins/resources/panels/panels.mjs": "4862dccd91c29db76caf1033ffeab743c7943befaca7406a56467c470b90a1b8",
34
- "check/coda/resources/plugins/resources/panels/rules.mjs": "8de0c45df3b252d49a5a012696db95c9c46f29262213b2f846928cd512dd7213",
34
+ "check/coda/resources/plugins/resources/panels/rules.mjs": "d5b12f3e0e5040224314e5d2de2bd49f5b1ed24ea205590ff99a54e8b4e96d7f",
35
35
  "check/coda/resources/plugins/resources/panels/sign-in.mjs": "1271a24e33b1b882a1fb9bee03b8e240db8b9bee1b5208f0e1c84499cfb1be7e",
36
- "check/coda/builtin.json": "5a597073d8188733dda85977c4ba7ed83fe011b9968146e4b567b3b7219435ad"
36
+ "check/coda/builtin.json": "1f1b4562e78e797c8e27411b785aa20ffa001b727b09d107e7b79376e3174c7a"
37
37
  }
38
38
  }
@@ -0,0 +1,4 @@
1
+ // The resource kinds Coda's own resources are named by until they are protocols (components/protocols/core-operations.mjs).
2
+ export const AGENTS = 'agents';
3
+ export const THREADS = 'threads';
4
+ export const GROUPS = 'groups';
@@ -25,7 +25,7 @@ const RESOURCES = 50, VALUES = 8, ACTIONS = 8;
25
25
  // What a panel's command may print: past these, the reading fails rather than being cut short.
26
26
  export const OUTPUT_LIMIT = 64 * 1024;
27
27
  export const ARGS_LIMIT = 4 * 1024;
28
- const ITEMS = 50, CARD_ITEMS = 20, LABEL = 80, IDENTITY = 200, MARKDOWN = 4000, ERROR = 500, CONFIRM = 200;
28
+ const ITEMS = 50, CARD_ITEMS = 20, LABEL = 80, IDENTITY = 200, MARKDOWN = 4000, ERROR = 500, CONFIRM = 200, LINK = 2000;
29
29
  const fail = (code, message) => check(false, code, message);
30
30
  const keys = (value, allowed, where, code) => {
31
31
  const extra = Object.keys(value).filter(k => !allowed.includes(k));
@@ -108,18 +108,22 @@ function plainItem(raw, where, scope, inCard) {
108
108
  return fail(code, `${where} 的 type 不受支持`);
109
109
  }
110
110
  const BUTTON_KEYS = ['label', 'action', 'view', 'args', 'disabled', 'confirm'];
111
- // What a button does: run one of the type's actions here, or open one of its plugin's views in the client.
112
- function button(raw, where, scope) {
111
+ // What a button does: run one of the type's actions here, open one of its plugin's views in the client, or (a resource's,
112
+ // `url` among `keys`) open a web page on the device.
113
+ function button(raw, where, scope, keys = BUTTON_KEYS) {
113
114
  const code = 'invalid_panel';
114
- const opens = raw.view !== undefined;
115
- check(opens !== (raw.action !== undefined), code, `${where} 须有 action 或 view 之一`);
116
- if (opens) check(typeof raw.view === 'string' && scope.views.includes(raw.view), code, `${where} 的 view 须是插件声明的视图:${raw.view}`);
117
- else check(typeof raw.action === 'string' && Object.hasOwn(scope.actions, raw.action), code, `${where} 的 action 须是声明的动作:${raw.action}`);
115
+ const does = ['action', 'view', 'url'].filter(k => keys.includes(k) && raw[k] !== undefined);
116
+ check(does.length === 1, code, `${where} 须有 ${keys.includes('url') ? 'action、view 或 url' : 'action 或 view'} 之一`);
117
+ const [kind] = does;
118
+ if (kind === 'view') check(typeof raw.view === 'string' && scope.views.includes(raw.view), code, `${where} 的 view 须是插件声明的视图:${raw.view}`);
119
+ else if (kind === 'action') check(typeof raw.action === 'string' && Object.hasOwn(scope.actions, raw.action), code, `${where} 的 action 须是声明的动作:${raw.action}`);
120
+ else check(typeof raw.url === 'string' && raw.url.length <= LINK && /^https:\/\/[^\s]+$/.test(raw.url), code, `${where} 的 url 须为不超过 ${LINK} 字的 https 地址`);
121
+ check(kind !== 'url' || (raw.args === undefined && raw.confirm === undefined), code, `${where}:打开网页的按钮不带 args 与 confirm`);
118
122
  check(raw.args === undefined || (raw.args && typeof raw.args === 'object' && !Array.isArray(raw.args) && JSON.stringify(raw.args).length <= ARGS_LIMIT), code,
119
123
  `${where} 的 args 须为不超过 ${ARGS_LIMIT} 字节的对象`);
120
124
  check(raw.disabled === undefined || typeof raw.disabled === 'boolean', code, `${where} 的 disabled 须为开或关`);
121
125
  // Its own question, for what this one button does (which account, which credit), in place of its action's.
122
- return { label: text(raw.label, LABEL, `${where} 的 label`, code), ...(opens ? { view: raw.view } : { action: raw.action }),
126
+ return { label: text(raw.label, LABEL, `${where} 的 label`, code), [kind]: raw[kind],
123
127
  ...(raw.args ? { args: raw.args } : {}), ...(raw.disabled ? { disabled: true } : {}),
124
128
  ...(raw.confirm !== undefined ? { confirm: text(raw.confirm, CONFIRM, `${where} 的 confirm`, code, { line: false }) } : {}) };
125
129
  }
@@ -165,8 +169,8 @@ function resource(raw, where, scope) {
165
169
  const actions = list(raw.actions, ACTIONS, 'actions').map((b, i) => {
166
170
  const at = `${where}.actions[${i}]`;
167
171
  object(b, at, code);
168
- keys(b, BUTTON_KEYS, at, code);
169
- return button(b, at, scope);
172
+ keys(b, [...BUTTON_KEYS, 'url'], at, code);
173
+ return button(b, at, scope, [...BUTTON_KEYS, 'url']);
170
174
  });
171
175
  check(name !== undefined || values.length, code, `${where} 须有 name 或 values`);
172
176
  return { ...(name !== undefined ? { name } : {}),
package/check/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // The contract check of one plugin directory: the manifest and its workflows, then each agent's handshake (and with `live`, a
2
- // turn) and each panel's reading. The manifest is checked against Coda's schemas of its types and its workflows against Coda's
2
+ // turn) and each resource type's (or panel's) reading. The manifest is checked against Coda's schemas of its types and its workflows against Coda's
3
3
  // dialect of BPMN (both the protocol's), the rest by Coda's own code (check/coda/), run where a plugin is written.
4
4
  import { resolve } from 'node:path';
5
5
  import { checkAgent } from './agent.mjs';
@@ -17,10 +17,10 @@ export async function checkPlugin(dir, { agent: only = null, manifestOnly = fals
17
17
  const agents = only ? plugin.agents.filter(a => a.id === only) : plugin.agents;
18
18
  if (only && !agents.length) report.scope('manifest').fail('options.agent', `清单里没有能检查的 Agent ${only}`);
19
19
  if (manifestOnly) {
20
- if (agents.length || plugin.panels.length) report.scope('handshake').skip('options.manifest', '只查清单(--manifest):不启动 Agent、不读面板');
20
+ if (agents.length || plugin.panels.length) report.scope('handshake').skip('options.manifest', '只查清单(--manifest):不启动 Agent、不读资源');
21
21
  return { report, plugin };
22
22
  }
23
23
  for (const agent of agents) await checkAgent({ agent, checked: plugin, live, prompt, limits, say: level => report.scope(level, `Agent ${agent.id}`) });
24
- if (!only) for (const panel of plugin.panels) await checkPanel({ panel, checked: plugin, say: report.scope('handshake', `面板 ${panel.id}`) });
24
+ if (!only) for (const panel of plugin.panels) await checkPanel({ panel, checked: plugin, say: report.scope('handshake', `${panel.format === 'resources' ? '资源类型' : '面板'} ${panel.id}`) });
25
25
  return { report, plugin };
26
26
  }
@@ -107,9 +107,11 @@ export function checkManifest(dir, say) {
107
107
  const found = besideAll(dir, plugin.dependencies);
108
108
  const offered = offerProblem(plugin, new Map([...builtin, ...found]));
109
109
  if (offered) say.fail('manifest.offers', offered);
110
- // Its panels, as the resources plugin reads what is written for its point once that is of the point's schema.
111
- const panels = offered ? [] : panelDeclarations(plugin.offers?.panels);
112
- for (const panel of panels) say.pass('manifest.panels', `面板 ${panel.id}「${panel.title}」:动作 ${Object.keys(panel.actions).join('、') || '无'}${panel.signIn ? ',可从 Coda 登录' : ''}`);
110
+ // Its resource types, or the panels before them, as the resources plugin reads what is written for its point once that is
111
+ // of the point's schema: one declaring types has those alone.
112
+ const format = plugin.offers?.resources ? 'resources' : 'panels', what = format === 'resources' ? '资源类型' : '面板';
113
+ const panels = offered ? [] : panelDeclarations(plugin.offers?.[format]).map(panel => ({ ...panel, format }));
114
+ for (const panel of panels) say.pass('manifest.panels', `${what} ${panel.id}「${panel.title}」:动作 ${Object.keys(panel.actions).join('、') || '无'}${panel.signIn ? ',可从 Coda 登录' : ''}`);
113
115
 
114
116
  // What its processes are given (pluginEnv): the plugins it depends on, those beside it here; one Coda ships has its
115
117
  // directory in Coda, not here, even with one of its ID beside it (Coda picks its own), and one found nowhere is not named.
package/check/panel.mjs CHANGED
@@ -1,12 +1,13 @@
1
- // A panel at the handshake level: read once by Coda's own resources module (check/coda/resources/plugins/resources/panels/,
2
- // Panels), given what Coda's plugin host gives it (components/plugins/plugin-host.mjs): the installed plugins as it watches
3
- // them, here the one checked, and each one's environment, as Coda gives every process of the plugin's.
1
+ // A resource type (or a panel before them) at the handshake level: read once by Coda's own resources module
2
+ // (check/coda/resources/plugins/resources/panels/, Panels), given what Coda's plugin host gives it
3
+ // (components/plugins/plugin-host.mjs): the installed plugins as it watches them, here the one checked, and each one's
4
+ // environment, as Coda gives every process of the plugin's.
4
5
  // Its actions are not run: a button may change things (switch an account, spend a reset), and only a person presses it.
5
6
  import { dirname } from 'node:path';
6
7
  import { cleared } from './coda/components/plugins/plugin-rules.mjs';
7
8
  import { ended, runCommand } from './coda/resources/plugins/resources/panels/command.mjs';
8
9
  import { Panels } from './coda/resources/plugins/resources/panels/panels.mjs';
9
- import { OUTPUT_LIMIT, panelItems } from './coda/resources/plugins/resources/panels/rules.mjs';
10
+ import { OUTPUT_LIMIT, panelItems, resourceItems } from './coda/resources/plugins/resources/panels/rules.mjs';
10
11
  import { closing, temporary } from './leftovers.mjs';
11
12
 
12
13
  // The session a process would belong to: the host's belong to none.
@@ -17,6 +18,12 @@ const typesOf = items => items.flatMap(item => item.type === 'card' ? ['card', .
17
18
  // What a panel's command printed as Coda takes it (panelItems), by type; throws PanelError with where it went wrong. For the
18
19
  // tests of a plugin's panel.
19
20
  export const panelTypes = (output, panel, views = []) => typesOf(panelItems(output, panel, views));
21
+ // What a resource type's command printed as Coda takes it (resourceItems): its resources, each with only the keys it has and
22
+ // its values and buttons; throws PanelError with where it went wrong. For the tests of a plugin's resources.
23
+ export const readResources = (output, type, views = []) => resourceItems(output, type, views);
24
+ // A reading of resources in a line: how many, and how many values and buttons they have.
25
+ const counted = resources => `${resources.length} 个资源,读数 ${resources.reduce((n, r) => n + r.values.length, 0)} 个,按钮 ${resources.reduce((n, r) => n + r.actions.length, 0)} 个${
26
+ resources.some(r => r.error) ? `,${resources.filter(r => r.error).length} 个写了错误` : ''}`;
20
27
 
21
28
  // `checked`: the plugin as the manifest level read it (manifest.mjs checkManifest). `limit`: how long a reading may take, as
22
29
  // Panels has it unless given.
@@ -44,16 +51,23 @@ export async function checkPanel({ panel, checked, say, limit }) {
44
51
  try {
45
52
  await panels.start();
46
53
  const started = Date.now(), reading = await panels.read(`${plugin.id}/${panel.id}`), took = ((Date.now() - started) / 1000).toFixed(1);
47
- if (reading.error && result && ended(result)) return say.fail('panel.output', `输出不合面板格式:资源页显示「${reading.error}」`);
54
+ const kind = panel.format === 'resources' ? '资源' : '面板';
55
+ if (reading.error && result && ended(result)) return say.fail('panel.output', `输出不合${kind}格式:资源页显示「${reading.error}」`);
48
56
  if (reading.error) {
49
57
  const why = !result ? '没有运行' : result.timedOut ? `${panels.readTimeoutMs / 1000} 秒没读完,Coda 停下这次读取` : result.overflow ? `标准输出超过 ${OUTPUT_LIMIT / 1024} KiB,Coda 停下这次读取`
50
58
  : result.error ? '命令起不来' : `退出码 ${result.code}`;
51
59
  return say.fail('panel.read', `读取没成功(${why}):资源页显示「${reading.error}」`);
52
60
  }
53
- const types = typesOf(reading.items);
54
- const counts = Object.entries(Object.groupBy(types, t => t)).map(([t, list]) => `${t} ×${list.length}`).join(',');
55
- if (!types.length) say.info('panel.read', `读出空的 items(${took} 秒):资源页不显示它${panel.signIn ? ',它出现在「添加资源」里' : ''}`);
56
- else say.pass('panel.read', `读取 ${took} 秒,输出合面板格式:${counts}`);
61
+ const empty = `资源页不显示它${panel.signIn ? ',它出现在「添加资源」里' : ''}`;
62
+ if (panel.format === 'resources') {
63
+ if (!reading.resources.length) say.info('panel.read', `读出空的 resources(${took} 秒):${empty}`);
64
+ else say.pass('panel.read', `读取 ${took} 秒,输出合资源格式:${counted(reading.resources)}`);
65
+ } else {
66
+ const types = typesOf(reading.items);
67
+ const counts = Object.entries(Object.groupBy(types, t => t)).map(([t, list]) => `${t} ×${list.length}`).join(',');
68
+ if (!types.length) say.info('panel.read', `读出空的 items(${took} 秒):${empty}`);
69
+ else say.pass('panel.read', `读取 ${took} 秒,输出合面板格式:${counts}`);
70
+ }
57
71
  if (Object.keys(panel.actions).length) say.skip('panel.actions', `动作 ${Object.keys(panel.actions).join('、')} 不运行:按钮可能改动东西,只由人点`);
58
72
  } finally {
59
73
  panels.close();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.5.33",
4
- "description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读面板。",
3
+ "version": "0.7.0",
4
+ "description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读资源类型(与旧的面板)。",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@0dep/piso": "5.2.0",
26
26
  "@agentclientprotocol/sdk": "1.4.0",
27
- "@coda-console/protocol": "2.5.0",
27
+ "@coda-console/protocol": "3.0.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },
@@ -1,11 +0,0 @@
1
- // The provider declaration contract, shared verbatim with plugin-check. No topology or runtime policy here.
2
- import { ProtocolTypes } from './types.mjs';
3
- import { requireCondition as check } from '../../domain/errors.mjs';
4
-
5
- export function providerDefinition(input) {
6
- const { kind, spec, status, controllers = [], target = null } = input ?? {};
7
- check(Array.isArray(controllers) && controllers.every(id => typeof id === 'string' && id), 'invalid_input', 'controllers 须为插件 ID 列表');
8
- check(target === null || (typeof target === 'string' && Object.hasOwn(spec?.properties ?? {}, target)), 'invalid_input', 'target 须为 spec 声明的资源引用栏');
9
- new ProtocolTypes().register({ kind, spec, status, participants: () => [] });
10
- return structuredClone({ kind, spec, status, controllers, target });
11
- }