@coda-console/plugin-check 0.8.4 → 0.8.6
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 +1 -1
- package/check/coda/adapters/admission-api.mjs +10 -1
- package/check/coda/adapters/provider-api.mjs +1 -0
- package/check/coda/builtin.json +79 -14
- package/check/coda/components/plugins/plugin-rules.mjs +1 -1
- package/check/coda/components/plugins/plugin-source-rules.mjs +1 -1
- package/check/coda/components/session-config/contributions.mjs +6 -1
- package/check/coda/contract.json +11 -11
- package/check/coda/domain/duration.mjs +7 -0
- package/check/coda/resources/plugins/resources/panels/panels.mjs +72 -6
- package/check/coda/resources/plugins/resources/panels/rules.mjs +3 -2
- package/package.json +2 -2
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
|
|
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 之间转发,送入会话指令
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { admissionFeatures } from '../domain/resource-admission.mjs';
|
|
2
2
|
|
|
3
3
|
// The module's local ledger API, exported unchanged to plugin-check.
|
|
4
|
-
export function admissionAPI(call) {
|
|
4
|
+
export function admissionAPI(call, handlers = new Map()) {
|
|
5
5
|
return {
|
|
6
|
+
handle(operation, fn) {
|
|
7
|
+
if (!['lend', 'return'].includes(operation) || typeof fn !== 'function') throw new TypeError('resources.handle(lend|return, fn)');
|
|
8
|
+
if (handlers.has(operation)) throw new TypeError(`资源钩子已登记:${operation}`);
|
|
9
|
+
handlers.set(operation, fn);
|
|
10
|
+
return { dispose: () => handlers.delete(operation) };
|
|
11
|
+
},
|
|
12
|
+
declareEntities: entities => call('declareEntities', [entities]),
|
|
13
|
+
declareLinks: links => call('declareLinks', [links]),
|
|
14
|
+
links: entity => call('links', [entity]),
|
|
6
15
|
features: admissionFeatures,
|
|
7
16
|
declareGroups: groups => call('declareGroups', [groups]),
|
|
8
17
|
groupOwner: name => call('groupOwner', [name]),
|
|
@@ -16,6 +16,7 @@ export function providerAPI({ call, watch, connection, plugin, operations, repor
|
|
|
16
16
|
delete: (kind, id) => call('delete', [kind, id]),
|
|
17
17
|
publish: (kind, id, enabled = true) => call('publish', [kind, id, enabled]),
|
|
18
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]),
|
|
19
20
|
upload: id => call('upload', [id]),
|
|
20
21
|
observe,
|
|
21
22
|
handle(kind, operation, handler) {
|
package/check/coda/builtin.json
CHANGED
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
"id": "github",
|
|
223
223
|
"displayName": "GitHub",
|
|
224
224
|
"description": "登录账号,推送时自动选对账号",
|
|
225
|
-
"version": "1.
|
|
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.
|
|
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.
|
|
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.
|
|
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": [],
|
|
@@ -1254,7 +1317,7 @@
|
|
|
1254
1317
|
"id": "composer",
|
|
1255
1318
|
"displayName": "输入框模式",
|
|
1256
1319
|
"description": "交接、子会话、! 命令、Ultra 与循环",
|
|
1257
|
-
"version": "5.
|
|
1320
|
+
"version": "5.1.1",
|
|
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.
|
|
1269
|
-
"integrity": "sha512-
|
|
1331
|
+
"version": "5.1.1",
|
|
1332
|
+
"integrity": "sha512-mNqhja3Lw5nrBX7i+r+iU+i0wShOUs7OtEOedstqnMkY6WQPiimOATz43AYR7mKblbfLDB9zh+rrx8BUeb90HA==",
|
|
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、要不要设备验收;开在别的目录或要指定分支时给 branch),用户在开工卡上选定后,流程会把下一步交给你;不要先改完再补开开发流程。",
|
|
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.
|
|
1910
|
+
"version": "2.15.0",
|
|
1846
1911
|
"category": "工作流程",
|
|
1847
1912
|
"icon": {
|
|
1848
1913
|
"symbol": "checkmark.bubble.fill",
|
|
@@ -1853,8 +1918,8 @@
|
|
|
1853
1918
|
"kind": "builtin",
|
|
1854
1919
|
"package": "@coda-console/review",
|
|
1855
1920
|
"tag": "latest",
|
|
1856
|
-
"version": "2.
|
|
1857
|
-
"integrity": "sha512-
|
|
1921
|
+
"version": "2.15.0",
|
|
1922
|
+
"integrity": "sha512-YSVt911nBNnBQo3oePfQxnXNeKfFg+QvJd8YkPqKBWXP5OYyO8NrDg48PNnwav8SztVDT6OO42iOw4UsQwebLg==",
|
|
1858
1923
|
"repo": "https://github.com/coda-console/coda-plugins.git",
|
|
1859
1924
|
"path": "plugins/review"
|
|
1860
1925
|
},
|
|
@@ -139,7 +139,7 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
|
|
|
139
139
|
// The entry as one path in its directory (`./view/a.html`, `view//a.html` are `view/a.html`): the clients load it by that.
|
|
140
140
|
views: (contributes.views ?? []).map(v => ({ id: v.id, title: v.title, entry: posix.normalize(v.entry), ...(v.in?.length ? { in: [...v.in] } : {}),
|
|
141
141
|
...(v.icon ? { icon: v.icon } : {}), ...(v.handles?.length ? { handles: [...v.handles] } : {}), ...(v.readout ? { readout: v.readout } : {}),
|
|
142
|
-
...(v.checkout ? { checkout: v.checkout } : {}), ...(v.frame ? { frame: v.frame } : {}) })),
|
|
142
|
+
...(v.checkout ? { checkout: v.checkout } : {}), ...(v.frame ? { frame: v.frame } : {}), ...(v.provides?.length ? { provides: [...v.provides] } : {}) })),
|
|
143
143
|
...(contributes.protocols?.length ? { protocols: structuredClone(contributes.protocols) } : {}),
|
|
144
144
|
...(contributes.protocolImplementations?.length ? { protocolImplementations: [...contributes.protocolImplementations] } : {}),
|
|
145
145
|
...(Object.keys(offers).length ? { offers } : {}),
|
|
@@ -331,7 +331,7 @@ export function contributions(plugin, catalog = new Map()) {
|
|
|
331
331
|
// The pages it opens in the clients, by name, with where they stay and their icon there: they run in the client's
|
|
332
332
|
// sandbox, not as commands here.
|
|
333
333
|
...(plugin.views?.length ? { views: plugin.views.map(v => ({ id: v.id, title: v.title, ...(v.in ? { in: v.in } : {}), ...(v.icon ? { icon: v.icon } : {}), ...(v.handles ? { handles: v.handles } : {}), ...(v.readout ? { readout: v.readout } : {}),
|
|
334
|
-
...(v.checkout ? { checkout: v.checkout } : {}) })) } : {}),
|
|
334
|
+
...(v.checkout ? { checkout: v.checkout } : {}), ...(v.provides ? { provides: v.provides } : {}) })) } : {}),
|
|
335
335
|
...Object.assign({}, ...[...CONTRIBUTION_POINTS.values()].map(point => point.confirm?.(plugin))),
|
|
336
336
|
extensions: plugin.extensions.map(e => ({ plugin: e.plugin, point: e.point, command: e.command })),
|
|
337
337
|
// What it writes for points under keys of `contributes` (the resources plugin's panels): by point, how many and the
|
|
@@ -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
|
-
|
|
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) } : {},
|
package/check/coda/contract.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "8cb0da14acae31719a5021e1d5e04aa705f63175",
|
|
3
3
|
"packages": {
|
|
4
4
|
"@0dep/piso": "5.2.0",
|
|
5
5
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
6
|
-
"@coda-console/protocol": "5.
|
|
6
|
+
"@coda-console/protocol": "5.10.0",
|
|
7
7
|
"ajv": "8.20.0",
|
|
8
8
|
"yaml": "2.9.1"
|
|
9
9
|
},
|
|
@@ -11,8 +11,8 @@
|
|
|
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": "
|
|
15
|
-
"check/coda/adapters/admission-api.mjs": "
|
|
14
|
+
"check/coda/adapters/provider-api.mjs": "e8f622cc4d70dc641399b8a26d678d566006edd506893773b18a58f21fa8ed7b",
|
|
15
|
+
"check/coda/adapters/admission-api.mjs": "f19706eb66e598fceb1a72ac81c51e48f4dc0179a18a73edaccb4d68ca629f56",
|
|
16
16
|
"check/coda/components/composers/contributions.mjs": "43d3e15fb1f63b7b5c20716030d9537613809ed5cc2fb466a3678bfa308f9f92",
|
|
17
17
|
"check/coda/components/composers/schemas.mjs": "6d497f58147756e789f9a566b2366f2fe36c0c72310421fb02508bf24a04f2c0",
|
|
18
18
|
"check/coda/components/plugins/contribution-points.mjs": "2dade9fe4f3fa2b4e89f49a1ac4378ab2621e5ac542eb175967091f04568b45c",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"check/coda/components/plugins/model-contributions.mjs": "018a7157954b2326887ba1a780b37d3beb33338e41a28936b313562c2939d563",
|
|
21
21
|
"check/coda/components/plugins/plugin-extensions.mjs": "4d7963185195ba6d21a4e49a66987613d5892210b1eb1dc02cffb7b816407776",
|
|
22
22
|
"check/coda/components/plugins/plugin-icons.mjs": "ec29cadce4948ecacabfe911a2ceb45414b96e28971358acbc4e952bedc78e1a",
|
|
23
|
-
"check/coda/components/plugins/plugin-rules.mjs": "
|
|
24
|
-
"check/coda/components/plugins/plugin-source-rules.mjs": "
|
|
23
|
+
"check/coda/components/plugins/plugin-rules.mjs": "54e063391e1091e403364cc2dc1f34630ccba065996462a81e4b437f39ce0bef",
|
|
24
|
+
"check/coda/components/plugins/plugin-source-rules.mjs": "3e0e3267d43546c131255d7c13dea80959efad95be698fe1a4a0f6a211419364",
|
|
25
25
|
"check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
|
|
26
26
|
"check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
|
|
27
27
|
"check/coda/components/session-config/commands.mjs": "7ce6b7872b3bf4dbc73b2af9a53cca4b5356ad32656903218757f449bb5abed4",
|
|
28
|
-
"check/coda/components/session-config/contributions.mjs": "
|
|
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
31
|
"check/coda/domain/agent-protocol.mjs": "df1424f562d6c3d83c703262f5ce50afe7b18aa6e29c4226cbe5e7148bff818a",
|
|
32
|
-
"check/coda/domain/duration.mjs": "
|
|
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
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": "
|
|
40
|
-
"check/coda/resources/plugins/resources/panels/rules.mjs": "
|
|
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": "
|
|
42
|
+
"check/coda/builtin.json": "b2f7cb8f69bf270b84bbe4c49bfe27440482fba729eb53287cd4b5e2955943bd"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -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));
|
|
@@ -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
|
|
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
|
|
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)
|
|
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
|
+
"version": "0.8.6",
|
|
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": "5.
|
|
27
|
+
"@coda-console/protocol": "5.10.0",
|
|
28
28
|
"ajv": "8.20.0",
|
|
29
29
|
"yaml": "2.9.1"
|
|
30
30
|
},
|