@coda-console/plugin-check 0.8.3 → 0.8.5

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
@@ -12,7 +12,7 @@ plugins/codex/ Codex:入口在同一进程里运行锁定版本的 c
12
12
  plugins/claude/ Claude SDK:基于 Claude Agent SDK 的 ACP 入口(npm 依赖),资源「Claude」
13
13
  plugins/kimi/ Kimi Code:在运行机的 kimi acp 与 Coda 之间转发,资源「Kimi」
14
14
  plugins/grok/ Grok:转发运行机上 Grok CLI 的 ACP,并适配审批模式,资源「Grok」
15
- plugins/grok-bot/ Grok Bot:把 xAI 云端 Bot 接成长期会话,原生主会话、Grok Routine 运行记录与用户审批;数据工具依赖 Coda 远端 Agent 入口
15
+ plugins/grok-bot/ Grok Bot:每个云端 Bot 的原生主会话是一条会话 Provider 记录,资源页登录
16
16
  plugins/opencode/ OpenCode:在运行机的 opencode acp 与 Coda 之间转发,送入会话指令与所选模型服务,模型按来源分组
17
17
  plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管资源「Codex」
18
18
  plugins/cursor/ Cursor:在运行机的 cursor-agent acp 与 Coda 之间转发,送入会话指令
@@ -21,6 +21,7 @@ plugins/host/ 宿主资源:发布本机 coda/executor@1 执行环
21
21
  plugins/magpie/ Magpie:把本机的 Magpie 网关作为模型服务提供给 Pi 等插件,安装时装好 Magpie 并让网关常驻
22
22
  plugins/network-log/ 网络记录:默认关闭,按需开启建连等待与定时探测采集;关闭后仍可查看历史
23
23
  plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布;也是写 PR 流程的样例
24
+ plugins/desktop-pet/ 桌面宠物:Coda 娘待在 Mac 桌面上,Agent 在跑时打字,有事等你时举卡片叫你(Coda 的浮窗)
24
25
  plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
25
26
  plugins/composer/ 输入框模式与开发流程:Ultra 用 develop 委派代码修改,主 Agent 审查,设备验收后检查、批准、合并与部署;名单引用 composer.templates
26
27
  templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
@@ -245,6 +246,48 @@ Codex 调用 `clock.sleep` 时,会话底部显示一个后台等待项(例
245
246
  Codex 没有只取消单个 sleep 的接口,因此等待项不提供单独的停止按钮。正常结束、插话唤醒、整轮取消或失败都会了结等待,
246
247
  子 Agent 的等待归它自己的会话。
247
248
 
249
+ ### Codex 异步消息与提问
250
+
251
+ OpenAI 的模型目录给模型开了 `send_user_message_async` 与 `request_user_input_async`(不随 Codex 版本,本地设置关不掉)。
252
+ Codex 把每次调用报成一条 `delivery: "async"` 的完整 Agent 消息、提问另带 `questions`,不发增量;codex-acp 1.12.0 只从增量显示 Agent 消息,
253
+ 插件打补丁接住它(适配器一变就启动失败)。Codex 的这一轮不等回答,回答之后作为新的用户消息到达它。
254
+
255
+ - **消息**:没有收到过增量的异步消息,把它的文字作为 Agent 消息显示。
256
+ - **提问**:文字照常作为 Agent 消息显示(Codex 把问题与选项写在里面,链接可以点开);这次调用的全部问题再作为一张表单卡片,只用来收回答。
257
+ 字段同 Claude 的提问:第 i 题是必填字段 `q{i}`,标题是问题;有选项时单选,末尾多一项「其他(写在下面)」配可选字段 `q{i}_other`;没有选项时填文字。
258
+ - **这一轮**:卡片都有结果之前,Coda 的这一轮一直在进行,codex-acp 那次 `session/prompt` 的答复先不转给 Coda。
259
+ 回答作为用户消息交给 Codex,每题一行:「回答你的提问「<问题>」:<答案>」;用户取消或卡片被撤回,就说「用户没有回答「<问题>」」。
260
+ codex-acp 那次 prompt 还在跑时经插话(`idleBehavior: "promptRequired"`)加进去;回 `promptRequired` 或已经跑完,入口自己向 codex-acp 发 `session/prompt`,
261
+ 它的输出照常算在 Coda 的这一轮里,最后一次答复才结束这一轮。
262
+ - **等卡片时**:停止会话撤回没答的卡片(`$/cancel_request`),把取消转给 codex-acp,这一轮按取消结束;
263
+ Codex 已停下时收到的插话作为下一次 `session/prompt` 跑、回 `injected`,仍算这一轮,卡片保留。
264
+
265
+ ### Codex 没适配的东西
266
+
267
+ Codex 或 OpenAI 的服务端加了新东西(新的 item 类型、字段取值、通知,模型能用的新工具),入口不认识就会悄悄丢掉,谁也不知道。
268
+ codex 入口分三层,让这类情况在升级时或运行时被发现,经 `_coda/unrecognized`(协议[没适配的东西](https://github.com/coda-console/coda-protocol/blob/main/docs/agent-protocol.md#没适配的东西))报给 Coda:
269
+
270
+ - **登记表与升级检查**:`agent/registry.json` 对锁定的 `@openai/codex` 的 app-server 协议,列出每种 ThreadItem 类型、agentMessage 的每个字段与
271
+ `delivery`、`phase` 的每个取值、codex-acp 收到的每个服务端通知与服务端请求,各注明转给 Coda(`shown: true`)还是明确不显示,附一句原因。
272
+ `scripts/check-codex-protocol.mjs` 用插件锁定的 Codex 跑 `codex app-server generate-json-schema --experimental`,有没登记的就失败并列出来。
273
+ `npm test` 跑它(`test/plugins/codex/protocol.test.mjs`),所以升级 `@openai/codex` 的 PR 要先登记新东西。
274
+ 它要这个平台的 Codex 二进制:`@openai/codex` 的可选依赖,`install-plugins.mjs` 带 `--include=optional` 装上(CI 的 ubuntu x64 是 `@openai/codex-linux-x64`);
275
+ 没装上就失败,并说明怎么装,不跳过。
276
+ - **运行时报告**:codex-acp 的补丁(适配器一变就启动失败)把到了却没登记的报上来。Coda 在握手里声明了 `_meta.coda.unrecognized` 才发,同一会话同一 `name` 只报一次。
277
+ - 没登记的 item 类型,完成时报 `item:<类型>`:有 `text`、`message` 或 `summary` 文字的照样作为 Agent 消息显示,报 `lost: false`;显示不了的报 `lost: true`。
278
+ - agentMessage 完成时有文字、没收到过增量,又不是已接住的 async:照样显示,报 `item:agentMessage.unstreamed`(`lost: false`)。这是「文字没送到 Coda」的通用兜底。
279
+ - agentMessage 没登记的字段(有值时)与 `delivery`、`phase` 的取值,报 `lost: false`,文字照常显示。
280
+ - 没登记的通知报 `notification:<方法>`(`lost: false`);没登记的服务端请求报 `request:<方法>`(`lost: true`),照 codex-acp 原来的做法回 MethodNotFound。
281
+ - **工具清单对照**:codex-acp 开的线程(`thread/start`、`thread/resume`,答复里有 rollout 的 `path`)一轮结束后,读 rollout 里给模型的 `additional_tools`,
282
+ 按 `namespace.name`(托管的工具没有名字,按类型,如 `web_search`)对照 `agent/known-tools.json`,新出现的报 `tool:<namespace.name>`(`kind: tool`)。
283
+ MCP 工具(`mcp__<服务器>`)是用户配的,不比。每个线程读到工具为止,读文件不挡开会话,也不挡这一轮。
284
+
285
+ 升级 `@openai/codex` 时:
286
+
287
+ 1. 跑 `node scripts/check-codex-protocol.mjs`(`npm test` 也跑),把列出的新东西登记进 `agent/registry.json`;要转给 Coda 的,先在入口补上。
288
+ 2. 用新 Codex 跑一轮真实会话,看它的 rollout(`~/.codex/sessions/…`)里 `additional_tools` 的原生工具,把新的加进 `agent/known-tools.json`;入口专门接住的标「已适配」。
289
+ 3. codex-acp 跟着变了,补丁对不上会启动失败,照新代码改补丁。
290
+
248
291
  ### Codex 权限默认值与 Coda 工具
249
292
 
250
293
  从 codex 插件 1.9.0 起,未指定模式的会话默认「完全访问」(`agent-full-access`):Codex 原生轮次使用
@@ -342,6 +385,9 @@ Codex 会话、资源与登录用的 Codex CLI 就是 `codex` 插件依赖的 `@
342
385
  Dependabot(`.github/dependabot.yml`)每周为它们各开一个 PR,连同 `package-lock.json` 一起改;合并后在 Coda「设置 › 插件」
343
386
  对该插件点「检查更新」;合并时勾选「部署」,`sync-coda` 给 Coda 开升级依赖的 PR。升 `@openai/codex` 时 codex-acp 经 `overrides` 跟着用新版本,
344
387
  Coda 根上的同一条 overrides 由 `sync-coda` 一起改(npm 只认根的,Coda 的测试会核对);合并前用真实会话跑一轮。
388
+ 升 `@openai/codex` 还要登记新 Codex 带来的东西,见 [Codex 没适配的东西](#codex-没适配的东西)。
389
+ 升 `@anthropic-ai/claude-agent-sdk` 要先把新 SDK 的消息类型与内容块登记进 `plugins/claude/agent/registry.mjs`,`npm test` 里的升级检查会列出没登记的,
390
+ 见 [plugins/claude/README.md](plugins/claude/README.md)「认不出的东西」。
345
391
 
346
392
  ## 在 Coda 里安装
347
393
 
@@ -15,6 +15,9 @@ export function providerAPI({ call, watch, connection, plugin, operations, repor
15
15
  setStatus: (kind, id, status, revision) => call('setStatus', [kind, id, status, revision]),
16
16
  delete: (kind, id) => call('delete', [kind, id]),
17
17
  publish: (kind, id, enabled = true) => call('publish', [kind, id, enabled]),
18
+ // An upload of this machine a post to a session names (`upload`): `{ id, name, size, mime?, duration?, …, path }`.
19
+ remoteCode: id => call('remoteCode', [id]),
20
+ upload: id => call('upload', [id]),
18
21
  observe,
19
22
  handle(kind, operation, handler) {
20
23
  if (typeof kind !== 'string' || !kind || typeof operation !== 'string' || !operation || typeof handler !== 'function')
@@ -222,7 +222,7 @@
222
222
  "id": "github",
223
223
  "displayName": "GitHub",
224
224
  "description": "登录账号,推送时自动选对账号",
225
- "version": "1.9.0",
225
+ "version": "1.10.0",
226
226
  "category": "模型与账号",
227
227
  "icon": {
228
228
  "symbol": "arrow.triangle.pull",
@@ -327,6 +327,7 @@
327
327
  {
328
328
  "id": "accounts",
329
329
  "title": "GitHub",
330
+ "kind": "github-accounts",
330
331
  "command": "node \"$CODA_PLUGIN_PATH/scripts/resources.mjs\"",
331
332
  "maxAge": "PT1M",
332
333
  "actions": {
@@ -357,7 +358,7 @@
357
358
  "id": "guide",
358
359
  "displayName": "Coda 使用指南",
359
360
  "description": "让 Agent 会回答 Coda 怎么用",
360
- "version": "1.0.6",
361
+ "version": "1.0.9",
361
362
  "category": "工作流程",
362
363
  "icon": {
363
364
  "symbol": "book.fill",
@@ -467,7 +468,7 @@
467
468
  "id": "resources",
468
469
  "displayName": "资源",
469
470
  "description": "各台电脑的账号、额度与负载",
470
- "version": "2.1.0",
471
+ "version": "2.4.0",
471
472
  "category": "机器与资源",
472
473
  "icon": {
473
474
  "symbol": "gauge.with.dots.needle.67percent",
@@ -481,6 +482,7 @@
481
482
  "title": "资源",
482
483
  "properties": {},
483
484
  "main": "main.mjs",
485
+ "startup": true,
484
486
  "workflows": [],
485
487
  "services": [],
486
488
  "agents": [],
@@ -536,6 +538,18 @@
536
538
  "command": {
537
539
  "$ref": "common.json#/$defs/command"
538
540
  },
541
+ "kind": {
542
+ "description": "种类名:声明后这类资源成为节点内核里的可引用种类,由这台电脑上报读数;小写字母、数字和「-」,全空间唯一",
543
+ "type": "string",
544
+ "maxLength": 63,
545
+ "pattern": "^[a-z][a-z0-9-]{0,62}$"
546
+ },
547
+ "report": {
548
+ "description": "定时读这类资源并上报的间隔:ISO 8601 时长,最短 PT1M(分钟、小时、天或周);只在写了 kind 时有意义,不写就只在打开页面、刷新或动作后读到时上报",
549
+ "type": "string",
550
+ "maxLength": 200,
551
+ "pattern": "^P(?!$)(?:(?!0+W)\\d+W)?(?:(?!0+D)\\d+D)?(?:T(?!0*H?0*M?$)(?:\\d+H)?(?:\\d+M)?)?$"
552
+ },
539
553
  "maxAge": {
540
554
  "description": "读数不重读还能再显示多久:ISO 8601 时长,如 PT5M(周、天与时分秒,不用年和月)",
541
555
  "type": "string",
@@ -611,7 +625,18 @@
611
625
  "title",
612
626
  "command"
613
627
  ],
614
- "additionalProperties": false
628
+ "additionalProperties": false,
629
+ "if": {
630
+ "required": [
631
+ "report"
632
+ ]
633
+ },
634
+ "then": {
635
+ "required": [
636
+ "kind"
637
+ ],
638
+ "description": "report 只在写了 kind 时有意义"
639
+ }
615
640
  },
616
641
  "$defs": {
617
642
  "question": {
@@ -854,7 +879,7 @@
854
879
  "id": "space",
855
880
  "displayName": "空间",
856
881
  "description": "把几台电脑组成一个空间",
857
- "version": "1.1.0",
882
+ "version": "1.3.0",
858
883
  "category": "机器与资源",
859
884
  "icon": {
860
885
  "symbol": "square.stack.3d.up.fill",
@@ -866,12 +891,28 @@
866
891
  },
867
892
  "dir": "src/resources/plugins/space",
868
893
  "title": "空间",
869
- "properties": {},
894
+ "properties": {
895
+ "space.notes": {
896
+ "type": "string",
897
+ "description": "写给 Agent 看的这台电脑的用法与注意事项,例如命令要怎么执行、哪些事不要在这台上做。Agent 在这台上做事之前会先读它;空间里每台各写各的。",
898
+ "title": "这台电脑的说明"
899
+ }
900
+ },
870
901
  "workflows": [],
871
902
  "services": [
872
903
  "space"
873
904
  ],
874
905
  "agents": [],
906
+ "instructions": {
907
+ "command": "\"$CODA_NODE\" \"$CODA_PLUGIN_PATH/scripts/machines.mjs\""
908
+ },
909
+ "skills": [
910
+ {
911
+ "name": "space",
912
+ "path": "src/resources/plugins/space/skills/space",
913
+ "description": "Coda 空间里的机器怎么查、怎么用:每台机器是一个资源,在一台上做事之前先读它的说明;机器离线或信息过期时怎么办;把活派到另一台走跨机器会话。要在别的机器上做事、选哪台机器、或用户问空间里有哪些机器时读。"
914
+ }
915
+ ],
875
916
  "commands": [],
876
917
  "capabilities": [],
877
918
  "groups": [],
@@ -941,7 +982,29 @@
941
982
  },
942
983
  "dir": "src/resources/plugins/workflows",
943
984
  "title": "工作流",
944
- "properties": {},
985
+ "properties": {
986
+ "workflows.remoteCallerWorkflows": {
987
+ "type": "array",
988
+ "description": "本机所有绑定的会话记录共用;project 填本机目录 ID,workflow 填流程名。",
989
+ "title": "远端调用方可发起的流程",
990
+ "rows": {
991
+ "type": "object",
992
+ "columns": {
993
+ "project": {
994
+ "type": "string"
995
+ },
996
+ "workflow": {
997
+ "type": "string"
998
+ }
999
+ },
1000
+ "required": [
1001
+ "project",
1002
+ "workflow"
1003
+ ]
1004
+ },
1005
+ "default": []
1006
+ }
1007
+ },
945
1008
  "main": "main.mjs",
946
1009
  "workflows": [],
947
1010
  "services": [],
@@ -991,7 +1054,7 @@
991
1054
  "id": "claude",
992
1055
  "displayName": "Claude",
993
1056
  "description": "用 Claude Agent SDK 跑会话",
994
- "version": "1.10.0",
1057
+ "version": "1.11.0",
995
1058
  "category": "Agent",
996
1059
  "icon": {
997
1060
  "light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c1Xwwo/cTtw2/gNUTblXlumr8lgLb88lDl9vzFo2atEAD6d3z4oTCLvGN28S/EStu+Zfq1wndFtYBXdMvwB5vsQplbmRzdHJlYW0KZW5kb2JqCjEyIDAgb2JqCiAgIDI3OQplbmRvYmoKMTMgMCBvYmoKPDwgL1R5cGUgL1hSZWYKICAgL0xlbmd0aCA1OQogICAvRmlsdGVyIC9GbGF0ZURlY29kZQogICAvU2l6ZSAxNAogICAvVyBbMSAyIDJdCiAgIC9Sb290IDExIDAgUgogICAvSW5mbyAxMCAwIFIKPj4Kc3RyZWFtCnicY2Bg+P+fiYGTgQFEMDGy2DAwMDLwAwkWNZAYO4jVAiRY2UCENEQdI4hgZmRbBhRj28vAAADC2ATdCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjE3MjUKJSVFT0YK",
@@ -1002,8 +1065,8 @@
1002
1065
  "kind": "builtin",
1003
1066
  "package": "@coda-console/claude",
1004
1067
  "tag": "latest",
1005
- "version": "1.10.0",
1006
- "integrity": "sha512-iG7lXu3xtzuvuMKDZiIBEzvidrMn8mPmi+WFLrJl9iY1XoLyJYyPuZa4rY3f+HNB6L0jAz2P4NsgzEtJxEry6g==",
1068
+ "version": "1.11.0",
1069
+ "integrity": "sha512-/xVoMX+X7IWim490qMjLPH4TK9Ck686kYbAYWEHcm0c30bBfiIawffTwJRCkdIOTXt3bbb1hyk6BbgAkhQy2Qw==",
1007
1070
  "repo": "https://github.com/coda-console/coda-plugins.git",
1008
1071
  "path": "plugins/claude"
1009
1072
  },
@@ -1087,7 +1150,7 @@
1087
1150
  "id": "codex",
1088
1151
  "displayName": "Codex",
1089
1152
  "description": "用 OpenAI Codex 跑会话",
1090
- "version": "1.11.0",
1153
+ "version": "1.12.0",
1091
1154
  "category": "Agent",
1092
1155
  "icon": {
1093
1156
  "light": "JVBERi0xLjcKJbXtrvsKNCAwIG9iago8PCAvTGVuZ3RoIDUgMCBSCiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlC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OCFEPTLn1j+yFi8mPzFwgNZB30trQ45QrIJvOlzJ/fmh+IyeoKxJCvyDXiRJzT5nr73pHNY34VHa8YBZRmKUM9mE13QiaiVvRuCqbou+AXejnqpDtRV6e9O6ea4D5DCB95oZ0artEN29zyRUPl5B0fn+LfnQXr5ZdrbmnSK25bU9AutgHCpCmVuZHN0cmVhbQplbmRvYmoKMTIgMCBvYmoKICAgMjg0CmVuZG9iagoxMyAwIG9iago8PCAvVHlwZSAvWFJlZgogICAvTGVuZ3RoIDU5CiAgIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlCiAgIC9TaXplIDE0CiAgIC9XIFsxIDIgMl0KICAgL1Jvb3QgMTEgMCBSCiAgIC9JbmZvIDEwIDAgUgo+PgpzdHJlYW0KeJxjYGD4/5+JgZOBAUQwMbIcY2BgZOAHEizrQWLsQBYrH4iYACKWQtQxgghmRnZToBi7DwMDAP4JBa8KZW5kc3RyZWFtCmVuZG9iagpzdGFydHhyZWYKMTg2OAolJUVPRgo=",
@@ -1098,8 +1161,8 @@
1098
1161
  "kind": "builtin",
1099
1162
  "package": "@coda-console/codex",
1100
1163
  "tag": "latest",
1101
- "version": "1.11.0",
1102
- "integrity": "sha512-/Vri1yv+QOGIHZ/PIvL1A8Ai9hYcT4LbJOvZ9AcLJIACJ4tK5Mq8WBIkAPYvZgxY37rnH1EqwNAChGFlsPl75A==",
1164
+ "version": "1.12.0",
1165
+ "integrity": "sha512-6bNcN5xsKWL5AnPWCW6ciTIGjbMy81cvywKCAUtSAVfaF7w/F4m9t3/2/EQk+6fnKkuRYb24DRe7HRgKjzPzLA==",
1103
1166
  "repo": "https://github.com/coda-console/coda-plugins.git",
1104
1167
  "path": "plugins/codex"
1105
1168
  },
@@ -1254,7 +1317,7 @@
1254
1317
  "id": "composer",
1255
1318
  "displayName": "输入框模式",
1256
1319
  "description": "交接、子会话、! 命令、Ultra 与循环",
1257
- "version": "5.0.0",
1320
+ "version": "5.1.0",
1258
1321
  "category": "工作流程",
1259
1322
  "icon": {
1260
1323
  "symbol": "character.cursor.ibeam",
@@ -1265,8 +1328,8 @@
1265
1328
  "kind": "builtin",
1266
1329
  "package": "@coda-console/composer",
1267
1330
  "tag": "latest",
1268
- "version": "5.0.0",
1269
- "integrity": "sha512-eWf93Kg/lokcmt+TuDIAmxds2U+QFs0S5KT1Jr68ebtBxN1+h1AObTZjrimH1sRpZrlYWZJhMW+iL1YXhibDeg==",
1331
+ "version": "5.1.0",
1332
+ "integrity": "sha512-mXPyYaRoKUbDJ4iPRn4nKifrwWSiOrdl2nGQSkdVLMdhGMvfpPezkkyFdXoiaiB2wgUoEnW4Jet3zCUmFeS87g==",
1270
1333
  "repo": "https://github.com/coda-console/coda-plugins.git",
1271
1334
  "path": "plugins/composer"
1272
1335
  },
@@ -1309,10 +1372,12 @@
1309
1372
  "startup": true,
1310
1373
  "workflows": [
1311
1374
  "deliver",
1312
- "develop"
1375
+ "develop",
1376
+ "kickoff"
1313
1377
  ],
1314
1378
  "services": [],
1315
1379
  "agents": [],
1380
+ "instructions": "要把改动合进默认分支时,先用 workflow_run 发起 kickoff(给 title、goal、建议的 way、要不要设备验收),用户在开工卡上选定后,流程会把下一步交给你;不要先改完再补开开发流程。",
1316
1381
  "commands": [],
1317
1382
  "capabilities": [],
1318
1383
  "groups": [],
@@ -1842,7 +1907,7 @@
1842
1907
  "id": "review",
1843
1908
  "displayName": "PR 生命流程",
1844
1909
  "description": "PR 从检查、评审到批准合并;简易开发",
1845
- "version": "2.12.0",
1910
+ "version": "2.14.0",
1846
1911
  "category": "工作流程",
1847
1912
  "icon": {
1848
1913
  "symbol": "checkmark.bubble.fill",
@@ -1853,14 +1918,21 @@
1853
1918
  "kind": "builtin",
1854
1919
  "package": "@coda-console/review",
1855
1920
  "tag": "latest",
1856
- "version": "2.12.0",
1857
- "integrity": "sha512-WjP7W8vQqfdF/l4jMgHqUz5VITx0JpyHY1oK0a1wEdbKHfIM+LuyY0LITR7k80mmc17QxXUOdRn8eq7vuSqNow==",
1921
+ "version": "2.14.0",
1922
+ "integrity": "sha512-TWiRGiDK+D8mABjBqUIQw3MlEu1zO6J17lzCdpuCTN9ODz6Lt1DL1K9G7QgzZedNI3B8rFEr6u9emPoKd4aOZg==",
1858
1923
  "repo": "https://github.com/coda-console/coda-plugins.git",
1859
1924
  "path": "plugins/review"
1860
1925
  },
1861
1926
  "dir": "node_modules/@coda-console/review",
1862
1927
  "title": "PR 生命流程",
1863
1928
  "properties": {
1929
+ "review.autoRun": {
1930
+ "type": "boolean",
1931
+ "description": "会话开的 PR 新建或有新提交时自动开始 PR 生命流程。关掉后只能手动发起;会话或目录在「工作流」里单独设过的,按它们的。不影响简易开发。",
1932
+ "title": "PR 自动运行",
1933
+ "order": 0,
1934
+ "default": true
1935
+ },
1864
1936
  "review.reviewers": {
1865
1937
  "type": "object",
1866
1938
  "description": "一行是一类作者和评审它的 Agent。作者只选到哪一级,就只按那一级区分;越具体的一行越优先。",
@@ -1,5 +1,5 @@
1
1
  import { requireCondition as check } from '../../domain/errors.mjs';
2
- import { AGENT_ID, keys, object, text } from '../../domain/values.mjs';
2
+ import { AGENT_ID, attachments, keys, object, text } from '../../domain/values.mjs';
3
3
 
4
4
  // What a session runs with: its model, effort and mode, and the agent's other config options by their ID (`options`: a
5
5
  // choice's ID, or on and off for a switch), as the agent's catalog offers them (coda-protocol docs/agent-protocol.md「ACP 部分」).
@@ -25,12 +25,8 @@ export function settings(value = {}) {
25
25
  ...(options ? { options } : {}) };
26
26
  }
27
27
 
28
- // Upload IDs as the client names them are the request's identity. What is on disk is read once, when the
29
- // message is first accepted: an agent may since have changed or removed the file, and a replay must still match.
30
- export function attachments(value = []) {
31
- check(Array.isArray(value) && value.length <= 20 && new Set(value).size === value.length, 'invalid_input', '附件列表无效');
32
- return value.map(id => text(id, '附件标识', 100));
33
- }
28
+ // Upload IDs as the client names them (domain/values.mjs), as a message and a card's answer take them.
29
+ export { attachments };
34
30
  // A message without files keeps the request identity it always had.
35
31
  export const withAttachments = (value, ids) => ids.length ? { ...value, attachments: ids } : value;
36
32
  // Passages the user picked from the conversation, kept apart from their own words. Together they stay
@@ -56,7 +56,12 @@ defineContributionPoint({ key: 'agents', schema: SCHEMAS['agents.json'], read: (
56
56
  claim: plugin => plugin.agents.map(a => `Agent ${a.id}`), icon: plugin => plugin.agents.length === 1 ? plugin.agents[0].icon : null,
57
57
  confirm: plugin => ({ agents: plugin.agents.map(a => ({ id: a.id, displayName: a.displayName, command: a.command })) }),
58
58
  formats: { 'coda-agent': agentValue } });
59
- defineContributionPoint({ key: 'instructions', schema: SCHEMAS['instructions.json'], read: raw => raw ? { instructions: raw.trim() } : {},
59
+ // Its words to every agent: a text as written, or a command whose output they are as each session opens
60
+ // (session-config/service.mjs pluginInstructions), declared as its other commands are (`{ command }`).
61
+ const INSTRUCTIONS = { title: SCHEMAS['instructions.json'].title, description: '一段文字(不超过 200 字),或 { command }:开会话时运行,输出拼进会话指令',
62
+ anyOf: [{ $ref: 'instructions.json' }, { $ref: 'common.json#/$defs/commandHolder' }] };
63
+ defineContributionPoint({ key: 'instructions', schema: INSTRUCTIONS,
64
+ read: raw => typeof raw === 'string' ? { instructions: raw.trim() } : raw ? { instructions: { command: raw.command } } : {},
60
65
  confirm: plugin => plugin.instructions ? { instructions: plugin.instructions } : {} });
61
66
  // Confirmed by name, each with what its SKILL.md says it is for.
62
67
  defineContributionPoint({ key: 'skills', schema: SCHEMAS['skills.json'], read: (raw, dir) => raw?.length ? { skills: skills(raw, dir) } : {},
@@ -1,9 +1,9 @@
1
1
  {
2
- "commit": "7c868b9eb75cc10ce781dd560ed1c85607741300",
2
+ "commit": "469576ec25e0ce0bf34f3f596723eca8c5838f62",
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "1.4.0",
6
- "@coda-console/protocol": "git+https://github.com/coda-console/coda-protocol.git#3dc8cbccb73d6ba854f79d18ab9400cb69039c24",
6
+ "@coda-console/protocol": "5.9.0",
7
7
  "ajv": "8.20.0",
8
8
  "yaml": "2.9.1"
9
9
  },
@@ -11,7 +11,7 @@
11
11
  "check/coda/application/contributions.mjs": "7460dc676171e24802b165a72e83ec72c4115f5ed169abcad08963bd2d9d251f",
12
12
  "check/coda/components/protocols/creation.mjs": "2b4a400d3064af4b5106077dc783c567910fef3c47b2d52af3f0d838c5accf19",
13
13
  "check/coda/components/protocols/types.mjs": "6876689142866bd45fc085951f6ea9e1fc303334e3657e97cc9cf5e277311248",
14
- "check/coda/adapters/provider-api.mjs": "a584316c3e0dafa19667f4288c54b8f894b49de72d9f62098d592b9084dec482",
14
+ "check/coda/adapters/provider-api.mjs": "e8f622cc4d70dc641399b8a26d678d566006edd506893773b18a58f21fa8ed7b",
15
15
  "check/coda/adapters/admission-api.mjs": "461b5a8a1ad73d7afed5db308813d02324e29c643b8e773ad127d4bdb00fb524",
16
16
  "check/coda/components/composers/contributions.mjs": "43d3e15fb1f63b7b5c20716030d9537613809ed5cc2fb466a3678bfa308f9f92",
17
17
  "check/coda/components/composers/schemas.mjs": "6d497f58147756e789f9a566b2366f2fe36c0c72310421fb02508bf24a04f2c0",
@@ -24,21 +24,21 @@
24
24
  "check/coda/components/plugins/plugin-source-rules.mjs": "375bd284d4c29278d9ad0a476b743a378cca40be550fc68c6e86a78ffcd60a39",
25
25
  "check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
26
26
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
27
- "check/coda/components/session-config/commands.mjs": "b8505802e25590435bf48d741522d85c8b185e8f2ae190d49e53eebd35a1d453",
28
- "check/coda/components/session-config/contributions.mjs": "830be1bf9e158d0090f16ed4be0ead4e33c7392531312299a3a637db8f470aa8",
27
+ "check/coda/components/session-config/commands.mjs": "7ce6b7872b3bf4dbc73b2af9a53cca4b5356ad32656903218757f449bb5abed4",
28
+ "check/coda/components/session-config/contributions.mjs": "47936c682f23737a0e451e0600a9a88e5ed8088c406342bbfe36cd20558037eb",
29
29
  "check/coda/components/workflows/contributions.mjs": "824c9b29584821b5e75bad00f02f21adc5031369db4ee9a4a5a836dfd44f98f5",
30
30
  "check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
31
- "check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
32
- "check/coda/domain/duration.mjs": "d6d7235c6166e8fcf4155999b1e9a514cf2ef91da179d4c0e48162cff4b692f5",
31
+ "check/coda/domain/agent-protocol.mjs": "df1424f562d6c3d83c703262f5ce50afe7b18aa6e29c4226cbe5e7148bff818a",
32
+ "check/coda/domain/duration.mjs": "3f07411812362adcacfc288b1513f10e7d0ea1addcdc1b47ae553561f1d3430b",
33
33
  "check/coda/domain/errors.mjs": "8319c6759c5b16b692f5e0a6208d066e43882c571da1075bff8698761020daef",
34
34
  "check/coda/domain/resource-admission.mjs": "775b1d7067f9d8487a3504d737f3f4bea31adf77af3357ed42e313805e5188e7",
35
35
  "check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
36
- "check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
36
+ "check/coda/domain/values.mjs": "afb8bf30e374bed27fe41ee4b6d8c3c0b4dbe1dcfb6b62dad9d3d53b966706a1",
37
37
  "check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
38
38
  "check/coda/resources/plugins/resources/panels/command.mjs": "606f28bf87f87dded9df2db892bc7624c770d795ffab88f2409998346920ae42",
39
- "check/coda/resources/plugins/resources/panels/panels.mjs": "4862dccd91c29db76caf1033ffeab743c7943befaca7406a56467c470b90a1b8",
40
- "check/coda/resources/plugins/resources/panels/rules.mjs": "d5b12f3e0e5040224314e5d2de2bd49f5b1ed24ea205590ff99a54e8b4e96d7f",
39
+ "check/coda/resources/plugins/resources/panels/panels.mjs": "452860c6b1b39dd9a67a8dadf4dac8f7773741b3608274494a8ac518a01f5b33",
40
+ "check/coda/resources/plugins/resources/panels/rules.mjs": "80da2709985c3866fff1698ea4d1c1afdf59cac2cc955605d3ec6c35f181eec6",
41
41
  "check/coda/resources/plugins/resources/panels/sign-in.mjs": "1271a24e33b1b882a1fb9bee03b8e240db8b9bee1b5208f0e1c84499cfb1be7e",
42
- "check/coda/builtin.json": "a92e59edb50e444394daef8160ed9bc9d593fccc57d09df7b4ec4f9997850624"
42
+ "check/coda/builtin.json": "52ea5d8d20aceecd84597b55af8a931fe83a82c69b71d9334a3171d7e9897d9a"
43
43
  }
44
44
  }
@@ -9,8 +9,9 @@ export const clientCapabilities = () => ({
9
9
  elicitation: { form: {}, url: {} },
10
10
  // A config option may be a switch: shown as one, its value on or off (`options`).
11
11
  session: { compaction: {}, configOptions: { boolean: {} } },
12
- // Coda takes the agent's own waits, and relays what is asked of the session from outside to an agent that takes it.
13
- _meta: { coda: { waits: {}, remote: {} } },
12
+ // Coda takes the agent's own waits and what its entry could not adapt, and relays what is asked of the session from
13
+ // outside to an agent that takes it.
14
+ _meta: { coda: { waits: {}, remote: {}, unrecognized: {} } },
14
15
  });
15
16
  // The remote entry (「远端入口」): an agent whose work is done elsewhere (a bot on its own computer) declares it; the code to
16
17
  // bind that place to its session is asked of Coda (`REMOTE_CODE`), and what that place then asks of the session is handed
@@ -37,6 +38,8 @@ export const currentModel = session => session?.configOptions?.find?.(x => x?.ca
37
38
  // What an agent may say of a wait of its own (「_coda/wait」); anything else is dropped unread.
38
39
  export const WAIT_STATES = new Set(AGENT_SCHEMAS['wait.json'].properties.state.enum);
39
40
  export const validWait = p => agentMessageProblem('_coda/wait', p) === null;
41
+ // What an agent's entry got and could not adapt (「没适配的东西」); anything else is dropped unread.
42
+ export const validUnrecognized = p => agentMessageProblem('_coda/unrecognized', p) === null;
40
43
  // What the agent's own check of a tool call said before running it (「工具调用的审核」): `_meta.coda.review` of the call's
41
44
  // `tool_call` or `tool_call_update`, as Coda keeps it; null for anything else. A risk it does not know is left out.
42
45
  export const toolReview = r => agentValueProblem('review.json', r) === null
@@ -2,6 +2,7 @@
2
2
  // (@0dep/piso): what plugin settings, panels and workflows all write a length of time in. And a length of time as whoever
3
3
  // is told it reads it, in words.
4
4
  import { parseDuration } from '@0dep/piso';
5
+ import { requireCondition as check } from './errors.mjs';
5
6
 
6
7
  // A duration, not negative.
7
8
  export function isDuration(text) {
@@ -11,6 +12,12 @@ export function isDuration(text) {
11
12
  // How long a duration is, counted back from `at` (a month is the one before it).
12
13
  export const durationMs = (text, at = Date.now()) => at - parseDuration(text).getStartAt(new Date(at)).getTime();
13
14
 
15
+ // The time a duration before `now`: what an action's `…After` parameter leaves alone.
16
+ export function before(text, now, where) {
17
+ check(isDuration(text), 'invalid_input', `${where} 须为 ISO 8601 时长,如 P30D、PT6H;现为 ${text || '(空)'}`);
18
+ return parseDuration(text).getStartAt(new Date(now)).getTime();
19
+ }
20
+
14
21
  // How long, in words, for whom it is told to: to the second under a minute, to the minute after.
15
22
  export function duration(ms) {
16
23
  const seconds = Math.max(0, Math.round(ms / 1000));
@@ -1,4 +1,5 @@
1
1
  // Shapes every layer checks what it is given against, and the stable serialization requests are compared by.
2
+ import { createHash } from 'node:crypto';
2
3
  import { isAbsolute, normalize } from 'node:path';
3
4
  import { requireCondition as check } from './errors.mjs';
4
5
 
@@ -16,6 +17,13 @@ export function text(value, name, max = 200) {
16
17
  return value;
17
18
  }
18
19
 
20
+ // Upload IDs as the client names them are the request's identity. What is on disk is read once, when the
21
+ // message is first accepted: an agent may since have changed or removed the file, and a replay must still match.
22
+ export function attachments(value = []) {
23
+ check(Array.isArray(value) && value.length <= 20 && new Set(value).size === value.length, 'invalid_input', '附件列表无效');
24
+ return value.map(id => text(id, '附件标识', 100));
25
+ }
26
+
19
27
  export function keys(value, allowed) {
20
28
  check(Object.keys(value).every(key => allowed.includes(key)), 'invalid_input', '包含不支持的字段');
21
29
  }
@@ -31,6 +39,13 @@ export function canonical(value) {
31
39
  return encoded;
32
40
  }
33
41
 
42
+ // A UUID derived from the parts that name a call: the same parts make the same one, so a retry finds its call and the
43
+ // session it opened, and two callers naming the same request are two calls.
44
+ export function derivedUUID(...parts) {
45
+ const hex = createHash('sha256').update(canonical(parts)).digest('hex');
46
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
47
+ }
48
+
34
49
  // A path the user gave, as an absolute one.
35
50
  export function absolutePath(value) {
36
51
  text(value, '路径', 4096);
@@ -3,7 +3,8 @@
3
3
  // (`coda.watch("plugins")`), and each command runs with that plugin's own environment (`coda.environment(null, { plugin })`),
4
4
  // as Coda gives every process of the plugin's. A plugin declaring `resources` has those; one still declaring the panels
5
5
  // before them has its panels, read as they were (`format`), for the page to take as resources (docs/plugins.md「旧的面板」).
6
- // A type is read only when a page asks (opening it, refreshing), never in the background, and no reading is kept on disk.
6
+ // A type is read when a page asks (opening it, refreshing, an action), or, for a kind declaring `report`, on its period
7
+ // while this machine shows it; nothing else is read in the background, and no reading is kept on disk.
7
8
  // What every type gets from here and not from its plugin: one reading at a time (a second ask joins it), the last good
8
9
  // reading shown again within the type's `maxAge` and listed with it, and on failure the last good one kept and marked as
9
10
  // such. The machine keeps which it shows and which not, in this plugin's state; their order is their plugins'
@@ -21,13 +22,15 @@ const fail = (code, message) => { throw new PanelError(code, message); };
21
22
  export class Panels {
22
23
  // `onChange(key)`: a panel moved (its reading, its login, whether it is hidden); none for the list as a whole.
23
24
  // `run`: how a command runs (panels/command.mjs runCommand); `now()`: the time, as readings are dated by it.
24
- constructor(coda, { run = runCommand, now = Date.now, readTimeoutMs = 30_000, actionTimeoutMs = 10 * 60_000 } = {}) {
25
- this.coda = coda; this.run = run; this.now = now; this.readTimeoutMs = readTimeoutMs; this.actionTimeoutMs = actionTimeoutMs;
25
+ constructor(coda, { run = runCommand, now = Date.now, readTimeoutMs = 30_000, actionTimeoutMs = 10 * 60_000, timer = true } = {}) {
26
+ this.coda = coda; this.run = run; this.now = now; this.readTimeoutMs = readTimeoutMs; this.actionTimeoutMs = actionTimeoutMs; this.timerOn = timer;
26
27
  // `last`: each panel's last good items, for a failed reading to show again; `shown`: what its last reading answered.
27
28
  this.plugins = new Map(); this.last = new Map(); this.shown = new Map(); this.reading = new Map(); this.acting = new Map(); this.failures = new Map();
28
29
  this.logins = new Map(); this.envs = new Map(); this.listeners = new Set(); this.closing = new AbortController();
29
30
  this.file = join(coda.plugin.state ?? tmpdir(), 'hidden.json');
30
31
  this.hides = Promise.resolve();
32
+ // The kind types this module reported, by kind (`{ plugin, type }`), and why an upload last failed, said once.
33
+ this.reportedKinds = new Map(); this.reportSaid = new Map(); this.reportedAt = new Map(); this.timer = null;
31
34
  }
32
35
  listen(fn) { this.listeners.add(fn); return () => this.listeners.delete(fn); }
33
36
  // Nothing is told before the plugins' environments are there (`ready`): what a login says of whether its program is
@@ -45,11 +48,14 @@ export class Panels {
45
48
  // A login of a panel gone (its plugin removed, or a version without it) goes with it.
46
49
  const keys = new Set(this.installed().map(e => e.key));
47
50
  for (const [key, login] of this.logins) if (!keys.has(key)) { login.close(); this.logins.delete(key); }
48
- if (this.ready) this.prepare().then(() => this.changed());
51
+ if (this.ready) this.prepare().then(() => { this.dropMissing(); this.forgetHidden(); this.changed(); });
49
52
  });
50
53
  this.unwatch = () => watched.dispose();
51
54
  await this.prepare();
52
55
  this.ready = true;
56
+ // A kind declaring a report is read on its own period while this machine shows it (none before it is chosen).
57
+ this.forgetHidden();
58
+ if (this.timerOn) { this.timer = setInterval(() => this.tick(), 1000); this.timer.unref?.(); }
53
59
  })();
54
60
  return this.started;
55
61
  }
@@ -89,6 +95,7 @@ export class Panels {
89
95
  view(entry, index) {
90
96
  const { plugin, panel, key, format } = entry, shown = this.shown.get(key), acting = this.acting.get(key);
91
97
  return { plugin: plugin.id, pluginName: plugin.name, panel: panel.id, title: panel.title, format, version: plugin.version ?? '', source: plugin.source ?? { kind: 'builtin' },
98
+ ...(panel.kind ? { kind: panel.kind } : {}),
92
99
  actions: Object.fromEntries(Object.entries(panel.actions ?? {}).map(([name, a]) => [name, a.confirm ? { confirm: a.confirm } : {}])),
93
100
  configurable: !!panel.displaySetting, signsIn: !!panel.signIn, hidden: this.hiddenOf(entry), index,
94
101
  signIn: panel.signIn ? this.login(entry).view() : null,
@@ -133,6 +140,7 @@ export class Panels {
133
140
  }
134
141
  async fetch(entry) {
135
142
  const { plugin, panel, key } = entry;
143
+ if (panel.reportMs) this.reportedAt.set(key, this.now());
136
144
  let failure;
137
145
  try {
138
146
  const result = await this.run(panel.command, { env: await this.env(plugin.id), timeoutMs: this.readTimeoutMs, signal: this.closing.signal });
@@ -140,6 +148,8 @@ export class Panels {
140
148
  const content = this.content(entry, result.stdout), at = this.now();
141
149
  this.last.set(key, { content, at }); this.failures.delete(key);
142
150
  this.shown.set(key, { ...content, readAt: at });
151
+ // A kind's reading is what this machine reports of it: a failed one reports nothing, so the last good objects stay.
152
+ if (entry.panel.kind) await this.report(entry, content.resources, at);
143
153
  return this.present(entry, { ...content, readAt: at });
144
154
  }
145
155
  failure = outcome(result, '读取');
@@ -158,6 +168,59 @@ export class Panels {
158
168
  const items = panelItems(output, panel, plugin.views ?? []);
159
169
  return { items: panel.displaySetting ? keepMissingMetrics(items, this.last.get(key)?.content.items ?? []) : items };
160
170
  }
171
+ // A kind's reading reported to this machine's backend (GET /v1/resources gives it back to the page and explain): the
172
+ // fields Coda keeps are the name, the outside identity it is, its values, what is wrong, and when it was read. Buttons
173
+ // and what they send stay here; a failure reports nothing, so the last good objects stay.
174
+ async report(entry, resources, at) {
175
+ const { plugin, panel } = entry;
176
+ const body = { plugin: plugin.id, type: panel.id, kind: panel.kind, observedAt: new Date(at).toISOString(),
177
+ resources: resources.map(({ name, identity, values, error }) => ({ ...(name !== undefined ? { name } : {}), ...(identity !== undefined ? { identity } : {}),
178
+ values: values ?? [], ...(error !== undefined ? { error } : {}) })) };
179
+ try {
180
+ await this.coda.api('resource-reports', body);
181
+ this.reportedKinds.set(panel.kind, { plugin: plugin.id, type: panel.id });
182
+ this.reportSaid.delete(entry.key);
183
+ } catch (e) {
184
+ if (this.reportSaid.get(entry.key) === e.message) return;
185
+ this.reportSaid.set(entry.key, e.message);
186
+ console.error(`[资源] ${panel.title} 没有上报读数:${e.message}`);
187
+ }
188
+ }
189
+ // This machine no longer shows or has the type: its objects go, and it is not read on its period.
190
+ // This machine no longer shows or has the type: its objects go, and it is not read on its period. Asked whether this
191
+ // module reported it or not: after a restart neither it nor the backend remembers, while the kernel still has them.
192
+ forgetKind(kind) {
193
+ if (!kind) return Promise.resolve();
194
+ return this.coda.api('resource-reports/forget', { kind }).then(() => { this.reportedKinds.delete(kind); }, e => {
195
+ const said = `forget ${kind}`;
196
+ if (this.reportSaid.get(said) === e.message) return;
197
+ this.reportSaid.set(said, e.message);
198
+ console.error(`[资源] ${kind} 没有停止上报:${e.message}`);
199
+ });
200
+ }
201
+ // The kinds this machine hides now: their objects go once the module starts (and when they are hidden), even when this
202
+ // module has no memory of reading them.
203
+ forgetHidden() {
204
+ for (const entry of this.installed()) if (entry.panel.kind && this.hiddenOf(entry)) void this.forgetKind(entry.panel.kind);
205
+ }
206
+ // Kinds no longer declared by an installed plugin: their objects go.
207
+ dropMissing() {
208
+ const kinds = new Set(this.installed().filter(entry => entry.panel.kind).map(entry => entry.panel.kind));
209
+ for (const kind of [...this.reportedKinds.keys()]) if (!kinds.has(kind)) void this.forgetKind(kind);
210
+ }
211
+ // The kinds due to report now: each shown one with a report period, read again (and so reported once it ends).
212
+ tick() {
213
+ if (!this.ready) return;
214
+ const now = this.now();
215
+ for (const entry of this.installed()) {
216
+ const { panel } = entry;
217
+ if (!panel.kind || !panel.reportMs || this.hiddenOf(entry)) continue;
218
+ const last = this.reportedAt.get(entry.key);
219
+ if (last !== undefined && now - last < panel.reportMs) continue;
220
+ this.reportedAt.set(entry.key, now);
221
+ this.read(entry.key, { force: true }).catch(() => {});
222
+ }
223
+ }
161
224
  // Runs one of a panel's actions with what its button sent, then reads the panel again. One action of a panel at a time;
162
225
  // one under way goes on to its end even when whoever asked has gone.
163
226
  async act(key, name, args, button = name) {
@@ -182,10 +245,13 @@ export class Panels {
182
245
  }
183
246
  // One type hidden or shown on this machine, the others as they were: one change at a time.
184
247
  hide(key, hidden) {
185
- const change = this.hides.then(() => {
248
+ const entry = this.installed().find(e => e.key === key);
249
+ const change = this.hides.then(async () => {
186
250
  const next = { ...this.choices, [key]: !!hidden };
187
251
  this.keepHidden(next);
188
252
  this.choices = next;
253
+ // Hidden, a kind is neither read nor reported: what it gave the kernel goes.
254
+ if (hidden && entry?.panel.kind) await this.forgetKind(entry.panel.kind);
189
255
  this.changed(key);
190
256
  });
191
257
  this.hides = change.catch(() => {});
@@ -234,5 +300,5 @@ export class Panels {
234
300
  }
235
301
  }
236
302
  // The module going (the plugin host stopping): what runs in a process group of its own is made to end, as nothing would later.
237
- close() { this.closing.abort(); this.unwatch?.(); for (const login of this.logins.values()) login.close('SIGKILL'); }
303
+ close() { this.closing.abort(); clearInterval(this.timer); this.unwatch?.(); for (const login of this.logins.values()) login.close('SIGKILL'); }
238
304
  }
@@ -41,9 +41,10 @@ const object = (value, where, code) => check(value && typeof value === 'object'
41
41
 
42
42
  // ---- Declarations (`contributes.resources`, or the panels before them) ----
43
43
  // A plugin's types as it declares them, in its order, each with the actions its buttons may take (none when it declares
44
- // none) and, with a `maxAge`, how long a reading may be shown again without asking.
44
+ // none), how long a reading may be shown again without asking (`maxAge`), and how often a kind's reading is reported.
45
45
  export function panelDeclarations(raw = []) {
46
- return raw.map(panel => ({ ...panel, actions: panel.actions ?? {}, ...(panel.maxAge ? { maxAgeMs: durationMs(panel.maxAge) } : {}) }));
46
+ return raw.map(panel => ({ ...panel, actions: panel.actions ?? {}, ...(panel.maxAge ? { maxAgeMs: durationMs(panel.maxAge) } : {}),
47
+ ...(panel.report ? { reportMs: durationMs(panel.report) } : {}) }));
47
48
  }
48
49
 
49
50
  // ---- What a panel's command prints ----
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读资源类型(与旧的面板)。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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": "git+https://github.com/coda-console/coda-protocol.git#3dc8cbccb73d6ba854f79d18ab9400cb69039c24",
27
+ "@coda-console/protocol": "5.9.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },
@@ -32,6 +32,7 @@
32
32
  "access": "public"
33
33
  },
34
34
  "devDependencies": {
35
- "feelin": "8.2.0"
35
+ "feelin": "8.2.0",
36
+ "typescript": "6.0.3"
36
37
  }
37
38
  }