@coda-console/plugin-check 0.8.28 → 0.8.30
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 +13 -23
- package/check/coda/adapters/plugin-events.mjs +3 -10
- package/check/coda/adapters/plugin-modules.mjs +19 -23
- package/check/coda/adapters/plugin-setup-api.mjs +5 -0
- package/check/coda/adapters/plugin-test-host.d.mts +0 -13
- package/check/coda/adapters/plugin-test-host.mjs +6 -25
- package/check/coda/api-surface.txt +3 -6
- package/check/coda/application/contributions.mjs +1 -0
- package/check/coda/builtin.json +15 -49
- package/check/coda/components/plugins/contribution-points.mjs +1 -2
- package/check/coda/components/plugins/git-contributions.mjs +10 -6
- package/check/coda/components/plugins/plugin-extensions.mjs +9 -72
- package/check/coda/components/plugins/plugin-rules.mjs +16 -20
- package/check/coda/components/plugins/plugin-source-rules.mjs +13 -29
- package/check/coda/components/plugins/self-contributions.mjs +13 -0
- package/check/coda/components/protocols/record-rules.mjs +8 -0
- package/check/coda/contract.json +18 -26
- package/check/manifest.mjs +10 -8
- package/package.json +2 -2
- package/templates/module/main.mjs +6 -13
- package/templates/module/package.json +7 -7
- package/templates/module/test/main.test.mjs +7 -23
- package/check/coda/application/host-protocols.mjs +0 -19
- package/check/coda/components/workflows/workflow-protocol-definitions.mjs +0 -362
- package/check/coda/domain/accord.mjs +0 -144
- package/check/coda/domain/jcs.mjs +0 -58
- package/check/coda/domain/usage.mjs +0 -56
- package/check/coda/kernel/accord-protocol.mjs +0 -168
- package/check/coda/kernel/plugin-protocol.mjs +0 -56
- package/check/coda/kernel/project-protocol.mjs +0 -52
- package/check/coda/kernel/thread-protocol.mjs +0 -167
- package/check/coda/kernel/usage-protocol.mjs +0 -97
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Coda 插件
|
|
2
2
|
|
|
3
|
-
Coda 的公开插件仓库,和给插件作者用的契约检查。Agent 插件(Codex、Claude、Kimi、Grok、OpenCode
|
|
3
|
+
Coda 的公开插件仓库,和给插件作者用的契约检查。Agent 插件(Codex、Claude、Kimi、Grok、OpenCode)和 PR 生命流程也在这里维护,用户在 Coda 的商店里安装。
|
|
4
4
|
|
|
5
5
|
Coda 是一个多 Agent 客户端(Mac、iPhone 与运行在你机器上的后端)。Agent 与资源页上的资源都以插件接入:
|
|
6
6
|
插件是一个目录,清单就是它的 `package.json`(`contributes.agents`、`contributes.records` 等,照 VS Code 扩展的写法);
|
|
@@ -8,13 +8,12 @@ Agent 讲 [ACP](https://agentclientprotocol.com),外加 Coda 的 Agent 活动
|
|
|
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
|
|
11
|
+
plugins/codex/ Codex:入口在同一进程里运行锁定版本的 codex-acp(npm 依赖),资源「Codex」;设置「多账号」管理多个账号
|
|
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
15
|
plugins/grok-bot/ Grok Bot:每个云端 Bot 的原生主会话是一条会话 Provider 记录,资源页登录
|
|
16
16
|
plugins/opencode/ OpenCode:在运行机的 opencode acp 与 Coda 之间转发,送入所选模型服务,模型按来源分组
|
|
17
|
-
plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管资源「Codex」
|
|
18
17
|
plugins/cursor/ Cursor:直接启动运行机的 cursor-agent acp
|
|
19
18
|
plugins/antigravity/ Antigravity:转发运行机的 agy acp,不把附加目录交给它,加「全部放行」模式,资源页登录
|
|
20
19
|
plugins/git/ Git 源与快照:本机仓库 provider、运行关联的工作树/提交快照、临时 ref 回收与只读 smart HTTP v2
|
|
@@ -46,7 +45,7 @@ Coda 插件页的「商店」列出 Coda 自带的插件,以及 npm 上 `@coda
|
|
|
46
45
|
|
|
47
46
|
## 常用的 Agent 与流程插件
|
|
48
47
|
|
|
49
|
-
`codex`、`claude`、`kimi`、`grok`、`opencode`、`
|
|
48
|
+
`codex`、`claude`、`kimi`、`grok`、`opencode`、`review` 的源码在这里维护。
|
|
50
49
|
合进 main 后它们发布为 npm 包 `@coda-console/<id>`([npm 发布](#npm-发布));Coda 不随安装包带它们,用户在商店里安装,装的就是 npm 上的包。
|
|
51
50
|
|
|
52
51
|
- **改它们先在这里提 PR、合并**,发布流程发出新版本就完了:不用给 Coda 开改依赖的 PR,各台 Coda 自己更新(默认自动更新插件,也可在「设置 › 插件」点「检查更新」)。
|
|
@@ -58,9 +57,8 @@ Coda 插件页的「商店」列出 Coda 自带的插件,以及 npm 上 `@coda
|
|
|
58
57
|
|
|
59
58
|
| 插件 | npm 依赖 | 运行机上另要 |
|
|
60
59
|
| --- | --- | --- |
|
|
61
|
-
| `codex` | `@agentclientprotocol/codex-acp` 1.12.0、`@openai/codex` 0.169.0;`overrides` 让 codex-acp 用同一个 `@openai/codex` | — |
|
|
60
|
+
| `codex` | `@agentclientprotocol/codex-acp` 1.12.0、`@openai/codex` 0.169.0;`overrides` 让 codex-acp 用同一个 `@openai/codex`;`proper-lockfile` 4.1.2(多账号的凭据锁) | — |
|
|
62
61
|
| `claude` | `@agentclientprotocol/sdk` 1.4.0、`@anthropic-ai/claude-agent-sdk` 0.3.312(平台二进制是 SDK 自己的可选依赖) | — |
|
|
63
|
-
| `codex-accounts` | `proper-lockfile` 4.1.2;用依赖插件 `codex` 的 Codex CLI | 无;依赖 `codex` 插件 |
|
|
64
62
|
| `kimi` | 无 | Kimi CLI 2.1.1 及以上(缺失或更旧时设置动作装入口核对过的 2.1.1,更新的不动;资源页上可从 Coda 安装、登录) |
|
|
65
63
|
| `grok` | 无 | Grok CLI 1.0.52 及以上(`sessions delete` 核对于 1.0.77,更旧的 CLI 没有它时删除会话回错误;设置动作安装或升级;资源页上可从 Coda 安装、登录) |
|
|
66
64
|
| `opencode` | `jsonc-parser` 3.3.1 | 已登录的 OpenCode CLI 2.1.4 及以上(设置动作安装或升级,OpenCode 1 升到 2) |
|
|
@@ -333,35 +331,27 @@ Codex 用普通 ACP 选择型配置项 `service-tier`(「速度」)报告速
|
|
|
333
331
|
|
|
334
332
|
### Codex 账号与额度
|
|
335
333
|
|
|
336
|
-
`codex`
|
|
337
|
-
|
|
334
|
+
多账号是 `codex` 自己的设置「多账号」(`codex.multipleAccounts`,默认关),不另装插件(原来的 `codex-accounts` 已并入 `codex` 2.0.0,商店不再列它)。
|
|
335
|
+
关着时用 Codex 原生登录与额度看板;打开后由 Codex 插件管理多个账号,关上后恢复原生登录。不需要预装账号管理器或 Python。
|
|
338
336
|
|
|
339
|
-
|
|
340
|
-
`codex` 插件;本版接管额度、登录入口和续期通知的配套入口是 `codex` 1.1.0。已有安装的更新由各台 Coda 本机做(默认自动更新),两个插件各自更新。
|
|
341
|
-
|
|
342
|
-
- 首次使用会把运行机 `$CODEX_HOME/auth.json`(默认 `~/.codex/auth.json`)里的 ChatGPT 登录导入插件,作为第一个
|
|
337
|
+
- 首次使用会把运行机 `$CODEX_HOME/auth.json`(默认 `~/.codex/auth.json`)里的 ChatGPT 登录导入,作为第一个
|
|
343
338
|
普通受控账号并默认选用。原文件保留;之后的凭据、续期与选择都由插件维护,原登录文件后续变化不会替换受控账号。
|
|
344
339
|
只有系统钥匙串里的凭据无法从文件导入,需要在插件中登录一次。
|
|
345
340
|
- 没有已有登录时,从「资源 › 添加资源 › Codex」完成设备码登录。已有账号后,通过账号那一行「···」里的「重新登录」
|
|
346
341
|
添加其他账号;登录同一身份会更新其凭据。添加第二个账号不会改变已选账号。
|
|
347
|
-
-
|
|
348
|
-
|
|
342
|
+
- 打开后「Codex」不再显示 Codex 自己的登录,只显示管理的账号(资源类型 `accounts`,标题同为「Codex」,同一账号在几台上合成一行)。原 Codex 登录入口也改为添加账号,
|
|
343
|
+
避免建立另一套登录;没有「使用本机账号」。
|
|
349
344
|
- 每个账号支持选择(会话正在用的那一行写「正在使用」)、查看额度、使用完全重置和移除。选择在新会话和轮次交界处生效;移除已选账号后须重新选择或添加,
|
|
350
345
|
会话不会回退到原登录。首次导入只发生一次,移除的账号不会再次被自动导入。
|
|
351
346
|
|
|
352
|
-
账号存放于 `CODA_PLUGIN_STATE/accounts/<身份摘要>/auth.json
|
|
347
|
+
账号存放于 `CODA_PLUGIN_STATE/accounts/`(`accounts.json`、`selection.json`,每个账号 `accounts/<身份摘要>/auth.json`),目录权限 0700、文件权限 0600。
|
|
353
348
|
每个账号有独立的 `CODEX_HOME`,由插件依赖中的 Codex 执行设备码授权及 refresh-token 续期。
|
|
354
349
|
跨进程的每账号锁覆盖续期、额度读取、重新登录和移除,避免多个会话同时使用同一个轮换凭据。
|
|
355
|
-
|
|
350
|
+
会话的账号桥(`plugins/codex/agent/accounts.mjs`)直接调账号管理(`plugins/codex/scripts/manager.mjs`)拿 access token;refresh token 留在受控登录文件中。
|
|
356
351
|
登录存储与续期采用 [Codex 官方认证机制](https://learn.chatgpt.com/docs/auth#credential-storage)。
|
|
357
352
|
|
|
358
|
-
旧版的 `selection.json` 仍然识别:`native`
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
`codex/account-source` 的完整进程约定在 `plugins/codex/agent/account-source.mjs`:`selected` 返回身份和名称,
|
|
362
|
-
`tokens` 返回该身份的 access token,`refresh: true` 要求续期;无可用选择应返回错误。来源还通过 `--login` 接受
|
|
363
|
-
原 Codex 登录入口的委托,并自行提供账号与额度资源。Codex 把自己的依赖目录通过 `CODA_PLUGIN_DEPENDENCIES.codex`
|
|
364
|
-
交给来源,来源与资源读取使用同一份 Codex CLI。
|
|
353
|
+
旧版的 `selection.json` 仍然识别:`native` 转为首次导入的账号;指向其他旧账号的选择保留,并提示重新登录该账号,
|
|
354
|
+
不会悄悄切换。
|
|
365
355
|
|
|
366
356
|
### Agent 的错误
|
|
367
357
|
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
// A module's events (docs/plugins.md「事件」), as its `coda` has them (adapters/plugin-modules.mjs): `
|
|
2
|
-
//
|
|
3
|
-
// `on` handles one its plugin subscribes to (`plugin.events`, the events of the event groups it uses, as the backend reckons
|
|
1
|
+
// A module's events (docs/plugins.md「事件」), as its `coda` has them (adapters/plugin-modules.mjs): `on` handles one its
|
|
2
|
+
// plugin subscribes to (`plugin.events`, the events of the event groups it uses, as the backend reckons
|
|
4
3
|
// them: components/plugins/plugin-events.mjs `subscribed`), as the backend delivers it (`deliver`). A handler that throws
|
|
5
4
|
// is said in the log, and is not handed the event again.
|
|
6
5
|
import { codaError } from './provider-api.mjs';
|
|
7
6
|
|
|
8
|
-
export function pluginEvents(plugin,
|
|
7
|
+
export function pluginEvents(plugin, fire) {
|
|
9
8
|
const subscribed = new Set(plugin.events ?? []), handlers = new Map();
|
|
10
9
|
return {
|
|
11
10
|
api: {
|
|
12
|
-
// `emit(name, data, { subject, project })`: published once the backend has checked it, what is handed on after not
|
|
13
|
-
// waited for; refused with its code, nothing published.
|
|
14
|
-
async emit(name, data, { subject, project } = {}) {
|
|
15
|
-
if (typeof name !== 'string' || typeof subject !== 'string' || typeof project !== 'string') throw new TypeError('emit(事件名, data, { subject, project })');
|
|
16
|
-
await asks('emit', { name, data, subject, project });
|
|
17
|
-
},
|
|
18
11
|
// `on(name, fn)`: `fn` given each event of the name delivered (`{ name, kind, subject, project, data, publisher }`)
|
|
19
12
|
// until it is disposed, or the module stops.
|
|
20
13
|
on(name, fn) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// The plugin host's modules (docs/plugins.md「插件宿主」): each plugin's that has a `main`, loaded the first time anything
|
|
2
2
|
// of it is needed, or when the backend says to, and given a `coda` of its own. What the runner (adapters/plugin-host-runner.mjs)
|
|
3
3
|
// runs over Node's IPC channel with the backend, and the test host (adapters/plugin-test-host.mjs) over a channel of its own:
|
|
4
|
-
// `send(message)` to the backend, `receive(message)` from it. `adopt(plugin, token,
|
|
5
|
-
// loaded, for whoever holds it to activate a module with; `stop()`: each module loaded
|
|
4
|
+
// `send(message)` to the backend, `receive(message)` from it. `adopt(plugin, token, pluginSetup?)`: a plugin's `coda` made with no
|
|
5
|
+
// module loaded, for whoever holds it to activate a module with, its `pluginSetup` the one given; `stop()`: each module loaded
|
|
6
|
+
// ends what it started (`deactivate`).
|
|
6
7
|
//
|
|
7
|
-
// From the backend: `start { api: { url }
|
|
8
|
+
// From the backend: `start { api: { url } }`, `activate { plugin, token }` (before anything else of the plugin's),
|
|
8
9
|
// `open { instance, plugin, view, context, caller }`, `query { plugin, request, deadline }`, `run { plugin, call }` and
|
|
9
10
|
// `resume { plugin, call }`, and `cancel { id, reason }` of any of them, `mode { plugin, mode, hook, context }` (a request
|
|
10
11
|
// each), and `message`, `callProgress { id, value }` (a `call`'s progress, by the request's ID), `context`, `close { instance, … }`, `changed { watch, events }`, `settingsChanged { plugin,
|
|
@@ -13,9 +14,9 @@
|
|
|
13
14
|
// of a process it started (adapters/process-relay.mjs). To it: `post { instance, message }`, `change { instance,
|
|
14
15
|
// collection, type, id, object }`, `unwatch { watch }`, `cancel { id }` of a `query` or a `question`, `progress { run,
|
|
15
16
|
// value }` of a `run`, `drained`, `kill` of a process, and the requests `settings`
|
|
16
|
-
// (the plugin's own, as they are now), `watch { collection, selector }`, `tell { session, text }`, `
|
|
17
|
+
// (the plugin's own, as they are now), `watch { collection, selector }`, `tell { session, text }`, `pluginSetup { method,
|
|
17
18
|
// args }`, `provider { method, args }`, `serviceRegister { id, port, secret }`, `serviceUnregister { id }`, `query { record,
|
|
18
|
-
// operation, input, timeout, deadline }`, `
|
|
19
|
+
// operation, input, timeout, deadline }`, `call { record, operation, input, id, timeout, deadline, under, progress }`, `spawn { under, process, command, args, cwd, env, name }`, each with the
|
|
19
20
|
// module's `token`, by which the backend knows the plugin it is of, never by what it names; and `question { run,
|
|
20
21
|
// question }` and `input` of a process. A query's
|
|
21
22
|
// failure crosses as `failureOf` says it, as one that did nothing (`none`); a run's end, and a resume's, as its outcome, or a resume's as null when the
|
|
@@ -27,14 +28,12 @@ import { pathToFileURL } from 'node:url';
|
|
|
27
28
|
import { callingAPI, canceled, codaError, failed, failureOf, givenUp, providerAPI, queryingAPI } from './provider-api.mjs';
|
|
28
29
|
import { queryId } from './plugin-command.mjs';
|
|
29
30
|
import { pluginEvents } from './plugin-events.mjs';
|
|
31
|
+
import { pluginSetupAPI } from './plugin-setup-api.mjs';
|
|
30
32
|
|
|
31
33
|
export function pluginModules({ send }) {
|
|
32
34
|
// This machine's Coda, as `start` gives it: its address only. Each module reaches it with its own plugin's token, given
|
|
33
35
|
// with `activate` and kept in its own `coda` only.
|
|
34
36
|
let api = null;
|
|
35
|
-
// The parts of `coda` others provide (components/plugins/plugin-host.mjs provide), as `start` names them: each made of the
|
|
36
|
-
// calls it asks by what its module exports (`make`).
|
|
37
|
-
let parts = Promise.resolve([]);
|
|
38
37
|
const loading = new Map(), instances = new Map(), asked = new Map(), watches = new Map();
|
|
39
38
|
// The queries and doing calls being handled, by the backend's request: each called off with the reason the backend gives
|
|
40
39
|
// (`cancel`).
|
|
@@ -198,17 +197,16 @@ export function pluginModules({ send }) {
|
|
|
198
197
|
return entry.value;
|
|
199
198
|
};
|
|
200
199
|
|
|
201
|
-
// What a plugin's module is given: this plugin's own
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
function codaFor(plugin, provided, token) {
|
|
200
|
+
// What a plugin's module is given: this plugin's own, `pluginSetup` asking the backend unless another is given.
|
|
201
|
+
// `token`: this plugin's for this host process, brought with every request it asks (`asks`).
|
|
202
|
+
function codaFor(plugin, token, pluginSetup = null) {
|
|
205
203
|
const views = new Map(), protocols = new Map(), operations = new Map();
|
|
206
204
|
const asks = (method, params, signal = null, progress = null) => ask(method, { ...params, token }, signal, progress);
|
|
207
205
|
const services = pluginServices(asks);
|
|
208
206
|
// The listeners of `settings.onChange`: this plugin's own settings only, told as they are written.
|
|
209
207
|
const settingsChanges = new Set();
|
|
210
208
|
// The events it publishes and those it subscribes to (adapters/plugin-events.mjs).
|
|
211
|
-
const events = pluginEvents(plugin,
|
|
209
|
+
const events = pluginEvents(plugin, fire);
|
|
212
210
|
// A query through the backend's unified call, the caller this plugin by its token.
|
|
213
211
|
const querying = queryingAPI({ send: (request, signal) => asks('query', request, signal), plugin, operations });
|
|
214
212
|
// A doing call through the call kernel, from this plugin's address (docs/plugins.md「做事的调用」).
|
|
@@ -244,7 +242,8 @@ export function pluginModules({ send }) {
|
|
|
244
242
|
put: (record, value) => write('putRecord', [record, value]),
|
|
245
243
|
delete: record => write('deleteRecord', [record]),
|
|
246
244
|
replace: (kind, entries) => write('replaceRecords', [kind, entries]),
|
|
247
|
-
|
|
245
|
+
// Another plugin's setup run again (docs/plugins.md「准备运行环境」).
|
|
246
|
+
pluginSetup: Object.freeze(pluginSetup ?? pluginSetupAPI((method, args) => asks('pluginSetup', { method, args }))),
|
|
248
247
|
views: Object.freeze({
|
|
249
248
|
register(id, provider) {
|
|
250
249
|
if (typeof id !== 'string' || typeof provider?.open !== 'function') throw new TypeError('views.register(视图 ID, { open(view) })');
|
|
@@ -285,7 +284,7 @@ export function pluginModules({ send }) {
|
|
|
285
284
|
// Coda's own collections, as a page watches the module's (`threads`: the sessions this machine lists), or a kind's
|
|
286
285
|
// records by its protocol's name.
|
|
287
286
|
watch: watching,
|
|
288
|
-
// Events (docs/plugins.md「事件」): `
|
|
287
|
+
// Events (docs/plugins.md「事件」): `on` one it subscribes to.
|
|
289
288
|
...events.api,
|
|
290
289
|
});
|
|
291
290
|
return { coda, views, protocols, operations, services, querying, calling, spawnFor, settingsChanges, events };
|
|
@@ -296,7 +295,7 @@ export function pluginModules({ send }) {
|
|
|
296
295
|
function load(plugin, token) {
|
|
297
296
|
if (!loading.has(plugin.id)) {
|
|
298
297
|
const loaded = (async () => {
|
|
299
|
-
const made = codaFor(plugin,
|
|
298
|
+
const made = codaFor(plugin, token);
|
|
300
299
|
try {
|
|
301
300
|
const module = await import(pathToFileURL(join(plugin.path, plugin.main)).href);
|
|
302
301
|
if (typeof module.activate !== 'function') throw new Error(`${plugin.main} 没有导出 activate`);
|
|
@@ -312,10 +311,7 @@ export function pluginModules({ send }) {
|
|
|
312
311
|
const activated = plugin => loading.get(plugin.id) ?? Promise.reject(new Error(`插件 ${plugin.id} 还没有激活`));
|
|
313
312
|
|
|
314
313
|
const handlers = {
|
|
315
|
-
start(params) {
|
|
316
|
-
api = params.api;
|
|
317
|
-
parts = Promise.all(params.parts.map(async ({ name, module, make }) => [name, (await import(module))[make]]));
|
|
318
|
-
},
|
|
314
|
+
start(params) { api = params.api; },
|
|
319
315
|
// A plugin's module, loaded the first time anything of it is needed, or as soon as the backend has started.
|
|
320
316
|
async activate({ plugin, token }) { await load(plugin, token); },
|
|
321
317
|
async open({ instance, plugin, view, context, caller }) {
|
|
@@ -426,7 +422,7 @@ export function pluginModules({ send }) {
|
|
|
426
422
|
return handling(plugin, call, id, async (handler, signal, made) => {
|
|
427
423
|
if (!handler?.resume) return null;
|
|
428
424
|
const { id: callId, record, operation: op, input, progress, canceled } = call;
|
|
429
|
-
return ending(() => handler.resume({ id: callId, record, op, input, progress, canceled
|
|
425
|
+
return ending(() => handler.resume({ id: callId, record, op, input, progress, canceled }, doingOf(call, signal, made, id)), signal);
|
|
430
426
|
}, call.halted);
|
|
431
427
|
},
|
|
432
428
|
// Called off: a query is let go at once, its handler's answer, if one comes, dropped by the backend; a doing call is
|
|
@@ -504,8 +500,8 @@ export function pluginModules({ send }) {
|
|
|
504
500
|
if (typeof module?.deactivate === 'function') await module.deactivate();
|
|
505
501
|
})));
|
|
506
502
|
const adopted = new Map();
|
|
507
|
-
function adopt(plugin, token,
|
|
508
|
-
const made = codaFor(plugin,
|
|
503
|
+
function adopt(plugin, token, pluginSetup = null) {
|
|
504
|
+
const made = codaFor(plugin, token, pluginSetup);
|
|
509
505
|
adopted.set(plugin.id, made);
|
|
510
506
|
loading.set(plugin.id, Promise.resolve(made));
|
|
511
507
|
return made.coda;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// What a plugin's module is given as `coda.pluginSetup` (adapters/plugin-modules.mjs `codaFor`; answered by components/plugins/plugin-setup.mjs `setupRequests`): `retry(plugin)`,
|
|
2
|
+
// an installed plugin's setup run again, asked as the module's own plugin, never as that one.
|
|
3
|
+
export function pluginSetupAPI(call) {
|
|
4
|
+
return { retry: plugin => call('retry', [plugin]) };
|
|
5
|
+
}
|
|
@@ -103,8 +103,6 @@ export interface Interrupted {
|
|
|
103
103
|
progress: Json | null;
|
|
104
104
|
/** Whether it was asked to be cancelled. */
|
|
105
105
|
canceled: boolean;
|
|
106
|
-
/** The calls it made that have ended; not filled yet: a `resume` makes its calls again by their `id` to learn how they ended. */
|
|
107
|
-
children: { record: Ref; op: string; outcome: Json }[];
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
110
108
|
* Says how such a call ended, as a handler does, once a later process of the plugin's has the module activated: its
|
|
@@ -264,12 +262,6 @@ export interface Coda {
|
|
|
264
262
|
* the entries given, in their order.
|
|
265
263
|
*/
|
|
266
264
|
replace(kind: string, entries: (RecordValue & { key: string })[]): Promise<Entry[]>;
|
|
267
|
-
/**
|
|
268
|
-
* Publishes an event of a protocol the plugin defines or implements, not one of Coda's own (those only Coda publishes),
|
|
269
|
-
* about `subject` in `project` (a project of this machine, by ID, the plugin applying there): done once Coda has checked
|
|
270
|
-
* it, its delivery not waited for; refused (`invalid_input`), nothing was published.
|
|
271
|
-
*/
|
|
272
|
-
emit(name: string, data: { [key: string]: Json }, options: { subject: string; project: string }): Promise<void>;
|
|
273
265
|
/**
|
|
274
266
|
* Handles an event the plugin subscribes to: one of an event group in its `uses`, any other throwing at once (`forbidden`).
|
|
275
267
|
* Given each one published in a project the plugin applies in, at most once, while the module is activated; not sorted by
|
|
@@ -399,11 +391,6 @@ export interface TestHost {
|
|
|
399
391
|
setSettings(settings: Json): Promise<void>;
|
|
400
392
|
/** Delivers an event to the module as Coda does: to its handlers of the name (`coda.on`) now. */
|
|
401
393
|
emit(event: Event): Promise<void>;
|
|
402
|
-
/**
|
|
403
|
-
* The events the module published (`coda.emit`), in order, each checked as Coda checks it but for its project: of a
|
|
404
|
-
* protocol the plugin defines or implements, not one of Coda's own, as its payload schema has it.
|
|
405
|
-
*/
|
|
406
|
-
emitted: Omit<Event, 'publisher'>[];
|
|
407
394
|
/** What the module has registered so far: its operations (`coda.handle`), its own queries' names (`coda.self.handle`) and the events it handles (`coda.on`). */
|
|
408
395
|
registered(): { operations: { kind: string; operation: string }[]; self: string[]; events: string[] };
|
|
409
396
|
close(): Promise<unknown>;
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
//
|
|
15
15
|
// What the module queries (`coda.query`, `ctx.query`) of a record of a protocol it implements its own handlers answer; of
|
|
16
16
|
// another's, `call` given. A doing call it makes (`coda.call`, `ctx.call`) its own handlers answer, of a protocol it implements. Its settings (`coda.settings`) are those the test gives, or sets again with `setSettings`, which
|
|
17
|
-
// tells the module's `onChange` as the backend does. The events
|
|
18
|
-
//
|
|
19
|
-
// its `uses`, as the backend has it. What it starts (`coda.spawn`, `ctx.spawn`) is a real child process of
|
|
17
|
+
// tells the module's `onChange` as the backend does. The events the test delivers (`emit`) go to its handlers (`coda.on`),
|
|
18
|
+
// which may name only what it subscribes to by its `uses`, as the backend has it. What it starts (`coda.spawn`, `ctx.spawn`) is a real child process of
|
|
20
19
|
// the test's, its streams and its end relayed as the backend relays them (adapters/process-relay.mjs), with no token and
|
|
21
20
|
// no entry in a registry: ended with the call or the module only as the test ends it, or as the host closes. The records
|
|
22
21
|
// (`coda.get`, `list`, `watch`, `put`, `delete`, `replace`, coda#2749 3.7) are those it writes, on this one machine, by its
|
|
@@ -30,9 +29,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
30
29
|
import { ContractError } from '../domain/errors.mjs';
|
|
31
30
|
import { ProtocolTypes } from '../components/protocols/types.mjs';
|
|
32
31
|
import { commandOf, implementations } from '../components/plugins/plugin-rules.mjs';
|
|
33
|
-
import {
|
|
34
|
-
import { protocolEvents } from '../components/protocols/protocol-events.mjs';
|
|
35
|
-
import { HOST_PROTOCOLS } from '../application/host-protocols.mjs';
|
|
32
|
+
import { subscribed } from '../components/plugins/plugin-extensions.mjs';
|
|
36
33
|
import { checkGiven, checkHeld, checkKept, groupType, keptStatus } from '../components/concurrency-groups/schemas.mjs';
|
|
37
34
|
import { validate } from '../components/protocols/types.mjs';
|
|
38
35
|
import { LOCAL_KINDS, checkLabels, checkReplace, checkWrite, labelled, picked, readFilter, readRef, recordId, writeRef } from '../components/protocols/record-rules.mjs';
|
|
@@ -77,8 +74,6 @@ export function createTestHost({ plugin = {}, call = null, clock = new Clock(),
|
|
|
77
74
|
const catalog = new Map([[id, entry], [' ', { protocols }]]);
|
|
78
75
|
const described = { id, path: plugin.path ?? process.cwd(), state: plugin.state ?? null, protocolImplementations: implemented,
|
|
79
76
|
events: subscribed(entry, catalog, () => null) };
|
|
80
|
-
// The events the module published (`coda.emit`), in order.
|
|
81
|
-
const emitted = [];
|
|
82
77
|
// Requests to the module waiting for its answer, the module's queries under way, and the doing calls handed to it, with what
|
|
83
78
|
// their caller is told of them, by the request's ID each.
|
|
84
79
|
const waiting = new Map(), querying = new Map(), runs = new Map();
|
|
@@ -89,9 +84,9 @@ export function createTestHost({ plugin = {}, call = null, clock = new Clock(),
|
|
|
89
84
|
const ending = new AbortController();
|
|
90
85
|
// What the module sends the backend, taken after the turn it is sent in, as over a process's channel.
|
|
91
86
|
const modules = pluginModules({ send: message => queueMicrotask(() => taken(message)) });
|
|
92
|
-
// `coda.pluginSetup
|
|
93
|
-
const setup =
|
|
94
|
-
const coda = modules.adopt(described, randomUUID(),
|
|
87
|
+
// `coda.pluginSetup` is there as the module has it, but fails: the test host has no backend to ask.
|
|
88
|
+
const setup = { retry: async () => { throw refused('unsupported', '测试宿主不提供 coda.pluginSetup'); } };
|
|
89
|
+
const coda = modules.adopt(described, randomUUID(), setup);
|
|
95
90
|
// The records, by kind, each an entry (`{ owner, location, id, plugin, local, spec, status, labels?, version }`) by its holder and
|
|
96
91
|
// ID, and the keys of those of each kind the plugin holds, by their IDs (record-rules.mjs `recordId`); and the module's
|
|
97
92
|
// watches of them, by the watch's key, each with what it was last told.
|
|
@@ -201,18 +196,6 @@ export function createTestHost({ plugin = {}, call = null, clock = new Clock(),
|
|
|
201
196
|
});
|
|
202
197
|
}
|
|
203
198
|
if (message.method === 'settings') return reply({ result: JSON.parse(JSON.stringify(current)) });
|
|
204
|
-
// An event the module publishes, checked as the backend checks it (components/plugins/plugin-extensions.mjs
|
|
205
|
-
// `publishedProblem`) but for its project, which is none here: among the events of Coda's own protocols too, which
|
|
206
|
-
// only Coda publishes.
|
|
207
|
-
if (message.method === 'emit') {
|
|
208
|
-
return answered(() => {
|
|
209
|
-
const { token, name, data, ...about } = message.params, event = protocolEvents(catalog, HOST_PROTOCOLS).get(name);
|
|
210
|
-
const problem = publishedProblem('coda.emit', entry, event, { name, subject: about.subject, payload: data });
|
|
211
|
-
if (problem) throw refused('invalid_input', problem);
|
|
212
|
-
emitted.push(structuredClone({ name, kind: event.kind, ...about, data }));
|
|
213
|
-
return null;
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
199
|
// A doing call's question, answered as its caller's `answer` says; one at a time, as the backend has it
|
|
217
200
|
// (components/plugins/hosted-calls.mjs `question`).
|
|
218
201
|
if (message.method === 'question') {
|
|
@@ -420,8 +403,6 @@ export function createTestHost({ plugin = {}, call = null, clock = new Clock(),
|
|
|
420
403
|
// An event delivered to the module as the backend delivers one (components/plugins/plugin-events.mjs), a copy of it: to
|
|
421
404
|
// the handlers of its name (`coda.on`) now, none of it kept. `{ name, kind, subject, project, data, publisher }`.
|
|
422
405
|
emit: event => modules.receive({ method: 'event', params: { plugin: described.id, event: structuredClone(event) } }),
|
|
423
|
-
// The events the module published (`coda.emit`), in order: `{ name, kind, subject, project, data }` each.
|
|
424
|
-
emitted,
|
|
425
406
|
// What the module has registered so far: `{ operations: [{ kind, operation }], self: [name], events: [name] }`, by
|
|
426
407
|
// `coda.handle`, `coda.self.handle` and `coda.on`.
|
|
427
408
|
registered: () => modules.registered(described),
|
|
@@ -120,14 +120,11 @@
|
|
|
120
120
|
1 manifest contributes.composerModes
|
|
121
121
|
1 manifest contributes.configuration
|
|
122
122
|
1 manifest contributes.environment
|
|
123
|
-
1 manifest contributes.extensionPoints
|
|
124
|
-
1 manifest contributes.extensions
|
|
125
123
|
1 manifest contributes.gitCredentials
|
|
126
124
|
1 manifest contributes.instructions
|
|
127
125
|
1 manifest contributes.mcpServers
|
|
128
126
|
1 manifest contributes.modelProviders
|
|
129
127
|
1 manifest contributes.path
|
|
130
|
-
1 manifest contributes.processes
|
|
131
128
|
1 manifest contributes.protocolImplementations
|
|
132
129
|
1 manifest contributes.protocols
|
|
133
130
|
1 manifest contributes.repositories
|
|
@@ -257,7 +254,6 @@
|
|
|
257
254
|
1 stable view window.coda.toolbar kinds toggle
|
|
258
255
|
2 bridge window.coda.refresh
|
|
259
256
|
2 manifest contributes.records
|
|
260
|
-
2 manifest contributes.self
|
|
261
257
|
3 definition description
|
|
262
258
|
3 definition events
|
|
263
259
|
3 definition events.description
|
|
@@ -290,7 +286,6 @@
|
|
|
290
286
|
3 module coda.api
|
|
291
287
|
3 module coda.call
|
|
292
288
|
3 module coda.delete
|
|
293
|
-
3 module coda.emit
|
|
294
289
|
3 module coda.error
|
|
295
290
|
3 module coda.get
|
|
296
291
|
3 module coda.handle
|
|
@@ -352,4 +347,6 @@
|
|
|
352
347
|
6 coda/resource@1 act operation sign-in
|
|
353
348
|
6 coda/resource@1 read
|
|
354
349
|
6 coda/resource@1 read records
|
|
355
|
-
|
|
350
|
+
8 manifest contributes.processes
|
|
351
|
+
8 manifest contributes.self
|
|
352
|
+
level 8
|
|
@@ -8,3 +8,4 @@ import '../components/plugins/model-contributions.mjs';
|
|
|
8
8
|
import '../components/plugins/git-contributions.mjs';
|
|
9
9
|
import '../components/composers/contributions.mjs';
|
|
10
10
|
import '../components/plugins/process-contributions.mjs';
|
|
11
|
+
import '../components/plugins/self-contributions.mjs';
|
package/check/coda/builtin.json
CHANGED
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"gitCredentials": [],
|
|
28
28
|
"views": [],
|
|
29
|
-
"dependencies": []
|
|
30
|
-
"extensionPoints": {},
|
|
31
|
-
"extensions": []
|
|
29
|
+
"dependencies": []
|
|
32
30
|
},
|
|
33
31
|
{
|
|
34
32
|
"id": "ask-user",
|
|
@@ -57,9 +55,7 @@
|
|
|
57
55
|
],
|
|
58
56
|
"gitCredentials": [],
|
|
59
57
|
"views": [],
|
|
60
|
-
"dependencies": []
|
|
61
|
-
"extensionPoints": {},
|
|
62
|
-
"extensions": []
|
|
58
|
+
"dependencies": []
|
|
63
59
|
},
|
|
64
60
|
{
|
|
65
61
|
"id": "change-setting",
|
|
@@ -88,9 +84,7 @@
|
|
|
88
84
|
],
|
|
89
85
|
"gitCredentials": [],
|
|
90
86
|
"views": [],
|
|
91
|
-
"dependencies": []
|
|
92
|
-
"extensionPoints": {},
|
|
93
|
-
"extensions": []
|
|
87
|
+
"dependencies": []
|
|
94
88
|
},
|
|
95
89
|
{
|
|
96
90
|
"id": "changes",
|
|
@@ -135,9 +129,7 @@
|
|
|
135
129
|
"frame": "document"
|
|
136
130
|
}
|
|
137
131
|
],
|
|
138
|
-
"dependencies": []
|
|
139
|
-
"extensionPoints": {},
|
|
140
|
-
"extensions": []
|
|
132
|
+
"dependencies": []
|
|
141
133
|
},
|
|
142
134
|
{
|
|
143
135
|
"id": "cliproxy",
|
|
@@ -203,9 +195,7 @@
|
|
|
203
195
|
"command": "scripts/antigravity.mjs"
|
|
204
196
|
}
|
|
205
197
|
],
|
|
206
|
-
"dependencies": []
|
|
207
|
-
"extensionPoints": {},
|
|
208
|
-
"extensions": []
|
|
198
|
+
"dependencies": []
|
|
209
199
|
},
|
|
210
200
|
{
|
|
211
201
|
"id": "diagnostics",
|
|
@@ -245,9 +235,7 @@
|
|
|
245
235
|
"views": [],
|
|
246
236
|
"dependencies": [
|
|
247
237
|
"space"
|
|
248
|
-
]
|
|
249
|
-
"extensionPoints": {},
|
|
250
|
-
"extensions": []
|
|
238
|
+
]
|
|
251
239
|
},
|
|
252
240
|
{
|
|
253
241
|
"id": "github",
|
|
@@ -1468,8 +1456,6 @@
|
|
|
1468
1456
|
}
|
|
1469
1457
|
],
|
|
1470
1458
|
"dependencies": [],
|
|
1471
|
-
"extensionPoints": {},
|
|
1472
|
-
"extensions": [],
|
|
1473
1459
|
"environment": [
|
|
1474
1460
|
{
|
|
1475
1461
|
"name": "GIT_CONFIG_PARAMETERS",
|
|
@@ -1508,9 +1494,7 @@
|
|
|
1508
1494
|
"capabilities": [],
|
|
1509
1495
|
"gitCredentials": [],
|
|
1510
1496
|
"views": [],
|
|
1511
|
-
"dependencies": []
|
|
1512
|
-
"extensionPoints": {},
|
|
1513
|
-
"extensions": []
|
|
1497
|
+
"dependencies": []
|
|
1514
1498
|
},
|
|
1515
1499
|
{
|
|
1516
1500
|
"id": "maintenance",
|
|
@@ -1586,9 +1570,7 @@
|
|
|
1586
1570
|
"capabilities": [],
|
|
1587
1571
|
"gitCredentials": [],
|
|
1588
1572
|
"views": [],
|
|
1589
|
-
"dependencies": []
|
|
1590
|
-
"extensionPoints": {},
|
|
1591
|
-
"extensions": []
|
|
1573
|
+
"dependencies": []
|
|
1592
1574
|
},
|
|
1593
1575
|
{
|
|
1594
1576
|
"id": "resources",
|
|
@@ -1637,9 +1619,7 @@
|
|
|
1637
1619
|
"frame": "document"
|
|
1638
1620
|
}
|
|
1639
1621
|
],
|
|
1640
|
-
"dependencies": []
|
|
1641
|
-
"extensionPoints": {},
|
|
1642
|
-
"extensions": []
|
|
1622
|
+
"dependencies": []
|
|
1643
1623
|
},
|
|
1644
1624
|
{
|
|
1645
1625
|
"id": "secrets",
|
|
@@ -1669,9 +1649,7 @@
|
|
|
1669
1649
|
],
|
|
1670
1650
|
"gitCredentials": [],
|
|
1671
1651
|
"views": [],
|
|
1672
|
-
"dependencies": []
|
|
1673
|
-
"extensionPoints": {},
|
|
1674
|
-
"extensions": []
|
|
1652
|
+
"dependencies": []
|
|
1675
1653
|
},
|
|
1676
1654
|
{
|
|
1677
1655
|
"id": "session",
|
|
@@ -1725,9 +1703,7 @@
|
|
|
1725
1703
|
"capabilities": [],
|
|
1726
1704
|
"gitCredentials": [],
|
|
1727
1705
|
"views": [],
|
|
1728
|
-
"dependencies": []
|
|
1729
|
-
"extensionPoints": {},
|
|
1730
|
-
"extensions": []
|
|
1706
|
+
"dependencies": []
|
|
1731
1707
|
},
|
|
1732
1708
|
{
|
|
1733
1709
|
"id": "space",
|
|
@@ -1773,15 +1749,13 @@
|
|
|
1773
1749
|
"views": [],
|
|
1774
1750
|
"dependencies": [
|
|
1775
1751
|
"tailnet"
|
|
1776
|
-
]
|
|
1777
|
-
"extensionPoints": {},
|
|
1778
|
-
"extensions": []
|
|
1752
|
+
]
|
|
1779
1753
|
},
|
|
1780
1754
|
{
|
|
1781
1755
|
"id": "tailnet",
|
|
1782
1756
|
"displayName": "网络",
|
|
1783
1757
|
"description": "空间里电脑互连的网络节点",
|
|
1784
|
-
"version": "1.
|
|
1758
|
+
"version": "1.3.0",
|
|
1785
1759
|
"category": "机器与资源",
|
|
1786
1760
|
"icon": {
|
|
1787
1761
|
"symbol": "network",
|
|
@@ -1808,13 +1782,7 @@
|
|
|
1808
1782
|
"capabilities": [],
|
|
1809
1783
|
"gitCredentials": [],
|
|
1810
1784
|
"views": [],
|
|
1811
|
-
"dependencies": []
|
|
1812
|
-
"extensionPoints": {
|
|
1813
|
-
"ports": {
|
|
1814
|
-
"description": "要发布到 tailnet 上、或到达别的节点的端口:命令按插件自己的设置打印 { publish: [{ name, port }], reach: [{ name, port, machine }] }"
|
|
1815
|
-
}
|
|
1816
|
-
},
|
|
1817
|
-
"extensions": []
|
|
1785
|
+
"dependencies": []
|
|
1818
1786
|
},
|
|
1819
1787
|
{
|
|
1820
1788
|
"id": "workflows",
|
|
@@ -1889,8 +1857,6 @@
|
|
|
1889
1857
|
"frame": "canvas"
|
|
1890
1858
|
}
|
|
1891
1859
|
],
|
|
1892
|
-
"dependencies": []
|
|
1893
|
-
"extensionPoints": {},
|
|
1894
|
-
"extensions": []
|
|
1860
|
+
"dependencies": []
|
|
1895
1861
|
}
|
|
1896
1862
|
]
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// checked in the whole manifest, @coda-console/protocol's contributionProblem), what a plugin's value of it is on the plugin (`read`, given
|
|
4
4
|
// the value written, none when it writes none), what of it only one plugin may declare (`claim`, of the plugin read), and
|
|
5
5
|
// what installing it confirms of it (`confirm`), how a plugin drawing no icon of its own is drawn (`icon`, of the plugin
|
|
6
|
-
// read, none when it says nothing),
|
|
7
|
-
// of the plugin read, none when it may), and the formats of a setting's value it defines (`formats`, by the name a
|
|
6
|
+
// read, none when it says nothing), and the formats of a setting's value it defines (`formats`, by the name a
|
|
8
7
|
// declaration writes: `(value, where, code)` checks one and returns it normalised, components/plugins/plugin-rules.mjs
|
|
9
8
|
// checkValue). The plugins' base knows none of the keys, nor those formats: it asks the point a key or a format names.
|
|
10
9
|
// A component defines its points as its module loads (components/workflows/contributions.mjs); what puts Coda together
|
|
@@ -5,11 +5,15 @@
|
|
|
5
5
|
import { defineContributionPoint } from './contribution-points.mjs';
|
|
6
6
|
import { SCHEMAS } from '@coda-console/protocol/validate';
|
|
7
7
|
|
|
8
|
-
// Git's credentials for an address are one plugin's
|
|
9
|
-
//
|
|
8
|
+
// Git's credentials for an address are one plugin's: the address as Git matches it, a port's leading zeros and https's default
|
|
9
|
+
// port dropped (the schema takes `https://` and a host in lower case alone), so that `https://host:443` is `https://host`'s
|
|
10
|
+
// and `https://host:08443` is `https://host:8443`'s. Installing one confirms
|
|
11
|
+
// each address it answers Git for, with the command; clients do not list them yet.
|
|
10
12
|
defineContributionPoint({ key: 'gitCredentials', schema: SCHEMAS['git-credentials.json'], read: (raw = []) => ({ gitCredentials: raw.map(c => ({ url: c.url, command: c.command })) }),
|
|
11
|
-
claim: plugin => (plugin.gitCredentials ?? []).map(c => `${c.url} 的 Git 凭据`),
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
claim: plugin => (plugin.gitCredentials ?? []).map(c => `${c.url.replace(/:0*(\d+)$/, ':$1').replace(/:443$/, '')} 的 Git 凭据`),
|
|
14
|
+
confirm: plugin => plugin.gitCredentials?.length
|
|
15
|
+
? { gitCredentials: plugin.gitCredentials.map(c => ({ label: `Git 凭据:为 ${c.url} 回答 Git(Git 要凭据时运行)`, command: c.command })) } : {} });
|
|
16
|
+
// Nor the command that lists repositories to choose from. Each plugin's list is read on its own and put with the others
|
|
17
|
+
// (repositories.mjs), so no plugin claims it.
|
|
14
18
|
defineContributionPoint({ key: 'repositories', schema: SCHEMAS['repositories.json'], read: raw => raw ? { repositories: { command: raw.command } } : {},
|
|
15
|
-
|
|
19
|
+
confirm: plugin => plugin.repositories ? { repositories: { label: '仓库来源(挑仓库时运行)', command: plugin.repositories.command } } : {} });
|