@coda-console/plugin-check 0.8.21 → 0.8.22

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.
@@ -95,7 +95,7 @@ export function pluginModules({ send }) {
95
95
  // One of Coda's collections, whole or as `selector` has it (a session's runs), watched once for each plugin (`plugin`)
96
96
  // however many of its modules' watchers watch it, asked with its token (`asks`): `fn` is given every object as `ADDED`
97
97
  // first, then each change. Done once the first are given. The last watcher gone, the backend stops reading it. A kind's
98
- // records (coda#2749 3.7, `{ scope?, id? }` as `list` takes them) are each told as an entry, as `get` and `list` give it
98
+ // records (coda#2749 3.7, `{ scope?, id?, labels? }` as `list` takes them) are each told as an entry, as `get` and `list` give it
99
99
  // to the plugin (its own with their keys), by its ID: `{ type, id, entry }`.
100
100
  // A change as a watcher is told it: of a kind, its entry by the record's ID; the backend tells it by its holder's too.
101
101
  const told = (watched, type, id, object) => watched.entries ? { type, id: object.id, entry: object } : { type, id, object };
@@ -232,7 +232,7 @@ export function pluginModules({ send }) {
232
232
  // `put({ kind, key }, { spec, status?, labels? })` made or replaced (a status not given kept), answered with its entry,
233
233
  // `delete({ kind, key })`, and `replace(kind, entries)`, every one of a kind the plugin holds given (`[{ key, spec,
234
234
  // status?, labels? }]`), those it no longer gives gone, answered with the entries given, in their order: each named by
235
- // the plugin's own key, its ID the host's. `get({ kind, id })`, one record or null, and `list(kind, { scope?, id? })`,
235
+ // the plugin's own key, its ID the host's. `get({ kind, id })`, one record or null, and `list(kind, { scope?, id?, labels? })`,
236
236
  // the records of any kind, each an entry `{ owner, location, id, plugin, key?, local, spec, status, labels, version }`, `key`
237
237
  // only of this plugin's own here: read after what this module wrote before.
238
238
  get: record => writing.then(() => asks('provider', { method: 'getRecord', args: [record] })),
@@ -282,8 +282,8 @@ export function pluginModules({ send }) {
282
282
  get: () => asks('settings', {}),
283
283
  onChange: listen(settingsChanges),
284
284
  }),
285
- // Coda's own collections, as a page watches the module's (`workflow-runs`: the runs this machine lists, or by a selector
286
- // a session's or a run's).
285
+ // Coda's own collections, as a page watches the module's (`threads`: the sessions this machine lists), or a kind's
286
+ // records by its protocol's name.
287
287
  watch: watching,
288
288
  });
289
289
  return { coda, views, protocols, operations, services, querying, calling, spawnFor, settingsChanges };
@@ -30,7 +30,7 @@ import { ProtocolTypes } from '../components/protocols/types.mjs';
30
30
  import { commandOf, implementations } from '../components/plugins/plugin-rules.mjs';
31
31
  import { checkGiven, checkHeld, checkKept, groupType, keptStatus } from '../components/concurrency-groups/schemas.mjs';
32
32
  import { validate } from '../components/protocols/types.mjs';
33
- import { LOCAL_KINDS, checkLabels, checkReplace, checkWrite, picked, readFilter, readRef, recordId, writeRef } from '../components/protocols/record-rules.mjs';
33
+ import { LOCAL_KINDS, checkLabels, checkReplace, checkWrite, labelled, picked, readFilter, readRef, recordId, writeRef } from '../components/protocols/record-rules.mjs';
34
34
  import { canonical } from '../domain/values.mjs';
35
35
  import { checkInput, checkRequest, checkResult, limit, stopped } from './call-limit.mjs';
36
36
  import { Clock } from './clock.mjs';
@@ -94,8 +94,8 @@ export function createTestHost({ plugin = {}, call = null, clock = new Clock(),
94
94
  kindOf(kind).set(keyOf({ owner, id }), entryOf({ owner, location, id, plugin, spec, status, labels }));
95
95
  // As the plugin reads them: its own with their keys.
96
96
  const listed = (kind, filter) => {
97
- const { scope, id } = readFilter(filter), records = kindOf(kind), mine = held.get(kind);
98
- return [...records.values()].filter(({ local, id: of }) => (scope === 'available' || local) && (id === undefined || of === id))
97
+ const { scope, id, labels } = readFilter(filter), records = kindOf(kind), mine = held.get(kind);
98
+ return [...records.values()].filter(entry => (scope === 'available' || entry.local) && (id === undefined || entry.id === id) && labelled(entry.labels, labels))
99
99
  .sort(({ local: one }, { local: other }) => Number(other) - Number(one))
100
100
  .map(entry => entry.local && mine.has(entry.id) ? { ...entry, key: mine.get(entry.id) } : entry);
101
101
  };
@@ -99,7 +99,7 @@
99
99
  "id": "changes",
100
100
  "displayName": "变更",
101
101
  "description": "看会话改了哪些文件",
102
- "version": "1.0.3",
102
+ "version": "1.1.0",
103
103
  "category": "工作流程",
104
104
  "icon": {
105
105
  "symbol": "plusminus",
@@ -118,7 +118,6 @@
118
118
  "changes"
119
119
  ]
120
120
  },
121
- "main": "main.mjs",
122
121
  "workflows": [],
123
122
  "services": [],
124
123
  "agents": [],
@@ -1001,7 +1000,7 @@
1001
1000
  "id": "workflows",
1002
1001
  "displayName": "工作流",
1003
1002
  "description": "流程模板、运行进度与流程图",
1004
- "version": "1.0.5",
1003
+ "version": "1.1.0",
1005
1004
  "category": "工作流程",
1006
1005
  "icon": {
1007
1006
  "symbol": "flowchart.fill",
@@ -1019,20 +1018,19 @@
1019
1018
  "read",
1020
1019
  "workflows"
1021
1020
  ],
1022
- "coda/plugin@1": [
1021
+ "coda/project@1": [
1023
1022
  "read"
1024
1023
  ],
1025
1024
  "coda/workflow@1": [
1026
- "read",
1027
1025
  "run",
1028
1026
  "configure"
1029
1027
  ],
1030
1028
  "coda/workflow-run@1": [
1031
1029
  "read",
1032
- "control"
1030
+ "control",
1031
+ "task"
1033
1032
  ]
1034
1033
  },
1035
- "main": "main.mjs",
1036
1034
  "workflows": [],
1037
1035
  "services": [],
1038
1036
  "agents": [],
@@ -1340,7 +1338,7 @@
1340
1338
  "id": "composer",
1341
1339
  "displayName": "输入框模式",
1342
1340
  "description": "交接、子会话、! 命令、Ultra 与循环",
1343
- "version": "12.0.0",
1341
+ "version": "12.2.0",
1344
1342
  "category": "工作流程",
1345
1343
  "icon": {
1346
1344
  "symbol": "character.cursor.ibeam",
@@ -1351,8 +1349,8 @@
1351
1349
  "kind": "builtin",
1352
1350
  "package": "@coda-console/composer",
1353
1351
  "tag": "latest",
1354
- "version": "12.0.0",
1355
- "integrity": "sha512-z791eL8Rb7UPF1RAmwWDy69DXA6d0oa+kMyMKeAhwrpOWGpEPz4u2KelhyuL3BwhmX46MFM/byqFOgjffDYX1g==",
1352
+ "version": "12.2.0",
1353
+ "integrity": "sha512-kU/c1ACDNCLNGtclKXDebNXjyrvlubbxkR3VQDL7iyUNA3Ic/S/xSP2o1VQJM937+fbtJOSd2/ND51szrnFJlg==",
1356
1354
  "repo": "https://github.com/coda-console/coda-plugins.git",
1357
1355
  "path": "plugins/composer"
1358
1356
  },
@@ -1934,7 +1932,7 @@
1934
1932
  "id": "review",
1935
1933
  "displayName": "PR 生命流程",
1936
1934
  "description": "PR 从检查、评审到批准合并;简易开发",
1937
- "version": "4.0.0",
1935
+ "version": "4.2.0",
1938
1936
  "category": "工作流程",
1939
1937
  "icon": {
1940
1938
  "symbol": "checkmark.bubble.fill",
@@ -1945,8 +1943,8 @@
1945
1943
  "kind": "builtin",
1946
1944
  "package": "@coda-console/review",
1947
1945
  "tag": "latest",
1948
- "version": "4.0.0",
1949
- "integrity": "sha512-+gtDCqQ6yOjeIh31actweYsWBHe4dbThMTPD2bsHpuD3E8iFgLTBs0a1pCNQGMb8C0JJLLnh4KLhKk24599pEw==",
1946
+ "version": "4.2.0",
1947
+ "integrity": "sha512-6dBPujNw968CvJW+A1kSfTG/GjAReUzpnFixWLeRpbbtuWqcNartzVDqyxj7LVCHtBdJbaF1YzA/xfFjO0BkJg==",
1950
1948
  "repo": "https://github.com/coda-console/coda-plugins.git",
1951
1949
  "path": "plugins/review"
1952
1950
  },
@@ -71,32 +71,73 @@ export function operationProblem(plugin, plugins) {
71
71
  return null;
72
72
  }
73
73
  // A protocol's definition as this machine has it with `plugins` (the catalog): one of Coda's (namespace coda), a core
74
- // protocol of the protocol package or one Coda's components registered (`defined`: kind → its registered type, with the
75
- // title and permission groups it was registered with), else the one a plugin of the catalog defines; none without one.
74
+ // protocol of the protocol package or one of Coda's own (`defined`: kind → its definition, application/host-protocols.mjs),
75
+ // else the one a plugin of the catalog defines; none without one.
76
76
  export function protocolDefinition(kind, plugins, defined) {
77
77
  if (kind.startsWith('coda/')) return CORE_PROTOCOLS[kind] ?? defined(kind);
78
78
  return [...plugins.values()].flatMap(plugin => plugin.protocols ?? []).find(one => one.name === kind);
79
79
  }
80
- // Why a permission group a plugin uses (docs/plugins.md「用到的权限」) is not one of its protocol's definition in `plugins`
81
- // (the catalog once it is installed) or Coda's (`defined`), or null.
82
- export function usesProblem(plugin, plugins, defined) {
80
+ // What of the protocols a plugin uses (docs/plugins.md「用到的权限」) neither its definition in `plugins` (the catalog beside
81
+ // it) nor Coda's (`defined`) has: the protocol (`{ protocol }`), or one of its permission groups (`{ protocol, group }`);
82
+ // null when they have all of it.
83
+ export function usesMissing(plugin, plugins, defined) {
83
84
  for (const [kind, groups] of Object.entries(plugin.uses ?? {})) {
84
85
  const definition = protocolDefinition(kind, plugins, defined);
85
- if (!definition) return `插件 ${plugin.id} 用到的协议 ${kind} 不在这台机器上,也不随它一起装`;
86
- const missing = groups.find(group => !Object.hasOwn(definition.permissions ?? {}, group));
87
- if (missing) return `插件 ${plugin.id} 用到的协议 ${kind} 没有权限组 ${missing}`;
86
+ if (!definition) return { protocol: kind };
87
+ const group = groups.find(each => !Object.hasOwn(definition.permissions ?? {}, each));
88
+ if (group) return { protocol: kind, group };
88
89
  }
89
90
  return null;
90
91
  }
91
- // Why a plugin installing `id` installs uses a permission group `catalog` (the catalog once they are installed) or Coda
92
- // (`defined`) does not define, or null: it, and what it needs this machine has not installed (`installed`: the installed
93
- // rows by ID), as reading it and installing it both say. The plugins installed already are not checked again: what they
94
- // use is theirs to answer for (docs/plugins.md「用到的权限」). One needed and nowhere is said missing, not here.
95
- export function installingUsesProblem(catalog, installed, id, defined) {
92
+ // The first protocol a plugin implements (`protocolImplementations`) that neither it, `plugins` (the catalog beside it) nor
93
+ // Coda (`defined`) defines, as `{ protocol }`; null when all are here.
94
+ export function implementsMissing(plugin, plugins, defined) {
95
+ const found = (plugin.protocolImplementations ?? []).find(({ kind }) => !(plugin.protocols ?? []).some(one => one.name === kind) && !protocolDefinition(kind, plugins, defined));
96
+ return found ? { protocol: found.kind } : null;
97
+ }
98
+ // This Coda's API Level (docs/plugins.md「兼容」): what it offers plugins, counted. A manifest's `engines.coda` names the least
99
+ // a plugin needs; one naming none needs 0, which any Coda has.
100
+ export const API_LEVEL = 1;
101
+ // The API Level a package's registry metadata asks for in its `engines`: a positive integer, or its digits as text (what
102
+ // npm's registry may make of one); undefined when it asks for none, null when it is anything else. A manifest read from
103
+ // its directory has the schema's shape (plugin-rules.mjs readPlugin).
104
+ export function wantedLevel(engines) {
105
+ const value = engines?.coda;
106
+ if (value === undefined) return undefined;
107
+ if (Number.isInteger(value) && value >= 1) return value;
108
+ return typeof value === 'string' && /^[1-9][0-9]{0,8}$/.test(value) ? Number(value) : null;
109
+ }
110
+ // Whether a plugin runs on this machine (docs/plugins.md「兼容」): the one judgment reading a source, installing, the store and
111
+ // the catalog take. Null when it does; else what it needs (`need`), what is missing (`missing`) and why, as the user is
112
+ // told (`error`). `host`: this machine — its API Level (`level`), its backend's channel, the catalog beside the plugin and
113
+ // Coda's own protocols (`defined`, as usesMissing takes them). A Level above this Coda's is Coda's to catch up with
114
+ // (`coda`); short of that, a channel it is not for, or a protocol or permission group it uses or a protocol it implements
115
+ // that is not here, is the plugin's to update (`update`): Coda no longer offers what it was made for.
116
+ export function compatibility(plugin, { catalog = new Map(), defined = () => null, ...here }) {
117
+ const own = ownIncompatibility(plugin, here);
118
+ if (own) return own;
119
+ const used = usesMissing(plugin, catalog, defined), missing = used ?? implementsMissing(plugin, catalog, defined);
120
+ if (!missing) return null;
121
+ const { protocol, group } = missing, coda = protocol.startsWith('coda/');
122
+ const error = group ? (coda ? `本机的 Coda 已不提供 ${protocol} 的权限组 ${group},插件需要更新` : `协议 ${protocol} 已没有权限组 ${group},插件需要更新`)
123
+ : coda ? `本机的 Coda 已不提供协议 ${protocol},插件需要更新` : `${used ? '用到' : '实现'}的协议 ${protocol} 不在这台机器上,也不随它一起装`;
124
+ return { need: 'update', missing, error };
125
+ }
126
+ // What of that a plugin answers by itself, whatever else is here: the API Level it needs, the channels it is for.
127
+ export function ownIncompatibility(plugin, { level = API_LEVEL, channel = null }) {
128
+ const wanted = plugin.engines?.coda ?? 0;
129
+ if (wanted > level) return { need: 'coda', missing: { level: wanted }, error: `这个版本要 Coda API Level ≥ ${wanted}(本机 ${level}),请先升级 Coda` };
130
+ const channelProblem = pluginChannelProblem(plugin, channel);
131
+ return channelProblem ? { need: 'update', missing: { channel }, error: channelProblem } : null;
132
+ }
133
+ // The same for installing `id`, `here` this machine but for the catalog (`catalog`: the catalog once it and what comes along are installed; `installed`: the
134
+ // installed rows by ID): it, and what it needs that this machine has not installed, that one named. Those installed
135
+ // already are the catalog's to judge (components/plugins/plugins.mjs refresh). One needed and nowhere is said missing, not here.
136
+ export function installingIncompatibility(catalog, installed, id, here) {
96
137
  for (const each of withDependencies(catalog, id)) {
97
138
  if ((each !== id && installed.has(each)) || !catalog.has(each)) continue;
98
- const problem = usesProblem(catalog.get(each), catalog, defined);
99
- if (problem) return problem;
139
+ const found = compatibility(catalog.get(each), { ...here, catalog });
140
+ if (found) return each === id ? found : { ...found, error: `${each}:${found.error}` };
100
141
  }
101
142
  return null;
102
143
  }
@@ -142,7 +183,7 @@ export function withDependencies(catalog, id) {
142
183
  return order;
143
184
  }
144
185
  // A channel restriction is the target backend's, never the client's. An unknown channel cannot satisfy an explicit list.
145
- // The store reads registry metadata; installation reads the package itself. Both use the same schema and rule.
186
+ // The store reads registry metadata; installation reads the package itself. Both judge it so (compatibility).
146
187
  export function pluginChannelProblem(plugin, channel) {
147
188
  if (plugin.coda === undefined) return null;
148
189
  const problem = valueProblem('plugin.json#/properties/coda', plugin.coda, 'coda');
@@ -152,14 +193,6 @@ export function pluginChannelProblem(plugin, channel) {
152
193
  const names = channels.map(value => value === 'preview' ? '预览版' : '正式版').join('或');
153
194
  return `此插件仅支持 Coda ${names}后端${channel ? '' : ',当前后端没有发布通道记录'}`;
154
195
  }
155
- // The same dependency closure used by installation, after resolving each dependency to its actual local or source version.
156
- export function catalogChannelProblem(catalog, id, channel) {
157
- for (const each of withDependencies(catalog, id)) {
158
- const plugin = catalog.get(each), problem = plugin && pluginChannelProblem(plugin, channel);
159
- if (problem) return each === id ? problem : `${each}:${problem}`;
160
- }
161
- return null;
162
- }
163
196
  // The installed plugins that need this one, directly or through another, by ID.
164
197
  export function dependents(catalog, installed, id) {
165
198
  const found = new Set();
@@ -131,8 +131,10 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
131
131
  category: manifestCategory(manifest), ...(icon ? { icon } : {}), ...(readmeFile(dir) ? { readme: true } : {}),
132
132
  source, dir, title: typeof configuration.title === 'string' ? configuration.title : displayName, properties,
133
133
  ...(manifest.coda !== undefined ? { coda: manifest.coda } : {}),
134
+ // The API Level it needs (plugin-extensions.mjs compatibility).
135
+ ...(manifest.engines?.coda !== undefined ? { engines: { coda: manifest.engines.coda } } : {}),
134
136
  // The permission groups of others' protocols it uses (docs/plugins.md「用到的权限」), by protocol: checked against the
135
- // catalog as it is installed (plugin-extensions.mjs usesProblem).
137
+ // catalog it is installed into, and whenever the catalog is read (plugin-extensions.mjs compatibility).
136
138
  ...(manifest.uses && Object.keys(manifest.uses).length ? { uses: structuredClone(manifest.uses) } : {}),
137
139
  ...(manifest.main ? { main: posix.normalize(manifest.main) } : {}), ...(activation.includes('onStartupFinished') ? { startup: true } : {}),
138
140
  ...(required.length ? { required: [...required] } : {}), workflows: files('.coda/workflows'),
@@ -7,7 +7,7 @@
7
7
  import { createHash } from 'node:crypto';
8
8
  import { normalize } from 'node:path';
9
9
  import { requireCondition as check } from '../../domain/errors.mjs';
10
- import { catalogChannelProblem, installingUsesProblem, offerPoint, offeredCommands, offerProblem, protocolDefinition, withDependencies } from './plugin-extensions.mjs';
10
+ import { installingIncompatibility, offerPoint, offeredCommands, offerProblem, protocolDefinition, withDependencies } from './plugin-extensions.mjs';
11
11
  import { CONTRIBUTION_POINTS } from './contribution-points.mjs';
12
12
 
13
13
  export const COMMIT = /^[0-9a-f]{40}$/;
@@ -169,7 +169,8 @@ export function npmManifest(id, own, skills) {
169
169
  }
170
170
  if (!Object.keys(contributes).length) return { problem: '这个 npm 包读不成插件:package.json 没有 contributes,没有 Skill 目录,也不是写了 mcpName 的 MCP 服务器' };
171
171
  return { manifest: { name: id, displayName: own.name, description: typeof own.description === 'string' ? own.description.slice(0, 500) : '',
172
- version: String(own.version ?? ''), ...(own.coda !== undefined ? { coda: own.coda } : {}), contributes } };
172
+ version: String(own.version ?? ''), ...(own.coda !== undefined ? { coda: own.coda } : {}),
173
+ ...(own.engines?.coda !== undefined ? { engines: { coda: own.engines.coda } } : {}), contributes } };
173
174
  }
174
175
  // The packages npm installs for a package from npm, by name with the range it asks for: its dependencies are not pinned
175
176
  // (docs/plugins.md「从 npm 安装」), unless it brings an `npm-shrinkwrap.json`, whose versions they then are. Among them the
@@ -349,7 +350,7 @@ export function contributions(plugin, catalog = new Map(), defined = () => null)
349
350
  }
350
351
  // Each permission group it uses (docs/plugins.md「用到的权限」): its protocol, by the definition's title (its name without
351
352
  // one), and what the group lets it do, whether on trial; by protocol, then group. One its protocol does not define is
352
- // why it cannot be installed (usesProblem), not listed.
353
+ // why it cannot be installed (plugin-extensions.mjs compatibility), not listed.
353
354
  function permissions(plugin, catalog, defined) {
354
355
  return Object.entries(plugin.uses ?? {}).flatMap(([kind, groups]) => {
355
356
  const definition = protocolDefinition(kind, catalog, defined), declared = definition?.permissions ?? {};
@@ -365,20 +366,21 @@ export const manifestId = manifest => manifest?.id ?? manifest?.name;
365
366
  // One plugin of a source as its reading lists it, said against what this machine has (`known`: the catalog, the installed
366
367
  // rows, the built-in plugins): what it is, the one of its ID installed here, why it cannot be installed, what comes along
367
368
  // with it (`siblings`: the other plugins of the same commit, by ID) and what it brings. `manifest`: what is known of it
368
- // when it does not read as a plugin, its ID `fallback` without a name. `defined`: the protocols Coda defines, for the
369
- // permission groups it and what comes along use (plugin-extensions.mjs installingUsesProblem).
370
- export function candidate({ path, manifest, plugin, problem, fallback }, { catalog, installed, builtin, channel, defined = () => null }, siblings) {
369
+ // when it does not read as a plugin, its ID `fallback` without a name. `channel`, `level` and `defined` (the protocols
370
+ // Coda defines): this machine, which it and what comes along are judged against (plugin-extensions.mjs compatibility);
371
+ // one that does not run here says why in `incompatible`, as installing it and the store say.
372
+ export function candidate({ path, manifest, plugin, problem, fallback }, { catalog, installed, builtin, channel, level, defined = () => null }, siblings) {
371
373
  const id = plugin?.id ?? (typeof manifestId(manifest) === 'string' ? manifestId(manifest) : fallback);
372
374
  const row = installed.get(id), along = plugin ? together(plugin, { catalog, installed, siblings, defined }) : [];
373
375
  const missing = along.filter(each => each.from === 'missing').map(each => each.id);
374
376
  // What this machine has once it is installed, those installed with it among them: the points it may write for.
375
377
  const after = plugin ? catalogAfter(plugin, { catalog, siblings }) : catalog;
378
+ const incompatible = plugin ? installingIncompatibility(after, installed, id, { channel, level, defined }) : null;
376
379
  return { path, id, displayName: plugin?.displayName ?? (typeof manifest?.displayName === 'string' ? manifest.displayName : id),
377
380
  description: plugin?.description ?? (typeof manifest?.description === 'string' ? manifest.description : ''), version: plugin?.version ?? '',
378
381
  installed: row ? row.source ?? builtin.get(id)?.source ?? { kind: 'builtin' } : null,
379
- problem: problem ?? (plugin ? catalogChannelProblem(after, id, channel) ?? catalogProblem(plugin, catalog, builtin, installed) ?? offerProblem(plugin, after)
380
- ?? installingUsesProblem(after, installed, id, defined) : null)
382
+ problem: problem ?? incompatible?.error ?? (plugin ? catalogProblem(plugin, catalog, builtin, installed) ?? offerProblem(plugin, after) : null)
381
383
  ?? (missing.length ? `要一起装的 ${missing.join('、')} 不在这台机器上${plugin.source?.kind === 'npm' ? '' : ',也不在这个提交里'}` : null),
382
- together: along.filter(each => each.from !== 'missing'),
384
+ ...(!problem && incompatible ? { incompatible } : {}), together: along.filter(each => each.from !== 'missing'),
383
385
  ...(plugin ? { contributes: contributions(plugin, after, defined) } : {}) };
384
386
  }
@@ -6,22 +6,27 @@ import { derivedUUID } from '../../domain/values.mjs';
6
6
 
7
7
  // Where a kind's records are, said once for every kind (Protocols `register` reads it). The kinds only this machine keeps:
8
8
  // Coda's composers and what is submitted through them, the runs of its posts to sessions, and the kinds it serves whole
9
- // from its own tables: `coda/thread@1`, `coda/card@1`, `coda/plugin@1` and the workflows' `coda/workflow@1` and
10
- // `coda/workflow-run@1` (one of another backend is found by asking the space: mirror.mjs `place`). `coda/session@1` is shared (Coda's sessions are served beside
9
+ // from its own tables: `coda/thread@1`, `coda/project@1`, `coda/card@1`, `coda/plugin@1` and the workflows' `coda/workflow@1`
10
+ // and `coda/workflow-run@1` (one of another backend is found by asking the space: mirror.mjs `place`). `coda/session@1` is shared (Coda's sessions are served beside
11
11
  // it, a plugin's external sessions are written in the record directory). They are never in the record directory, and no
12
12
  // plugin writes one. Every other kind, every one a plugin defines among them, is shared: its records are this machine's rows of
13
13
  // the record directory, which the other backends of a space copy.
14
- export const LOCAL_KINDS = new Set(['coda/composer@1', 'coda/submission@1', 'coda/run@1', 'coda/thread@1', 'coda/card@1',
14
+ export const LOCAL_KINDS = new Set(['coda/composer@1', 'coda/submission@1', 'coda/run@1', 'coda/thread@1', 'coda/project@1', 'coda/card@1',
15
15
  'coda/plugin@1', 'coda/workflow@1', 'coda/workflow-run@1']);
16
- // `list(kind, { scope?, id? })`: this machine's records (`local`) or this machine's and the others' (`available`, unsaid),
17
- // all of them or those of an ID.
16
+ // `list(kind, { scope?, id?, labels? })`: this machine's records (`local`) or this machine's and the others' (`available`,
17
+ // unsaid), all of them, those of an ID, or those whose labels have each of these values (`labels`, as Kubernetes' equality
18
+ // selector: nothing but equality).
18
19
  export function readFilter(filter) {
19
20
  check(filter == null || (typeof filter === 'object' && !Array.isArray(filter)), 'invalid_input', '筛选须为对象');
20
- const { scope = 'available', id, ...rest } = filter ?? {};
21
+ const { scope = 'available', id, labels, ...rest } = filter ?? {};
21
22
  check(['local', 'available'].includes(scope) && !Object.keys(rest).length && (id === undefined || (typeof id === 'string' && id)),
22
- 'invalid_input', '筛选只认 scope(local 或 available)和 id');
23
- return { scope, id };
23
+ 'invalid_input', '筛选只认 scope(local 或 available)、id 和 labels');
24
+ check(labels === undefined || (labels && typeof labels === 'object' && !Array.isArray(labels) && Object.values(labels).every(value => typeof value === 'string')),
25
+ 'invalid_input', '筛选的 labels 须为文本键值对象');
26
+ return { scope, id, labels };
24
27
  }
28
+ // Whether a record's labels have each value a filter's `labels` asks for (none asked, any record has).
29
+ export const labelled = (labels, asked) => asked === undefined || Object.entries(asked).every(([name, value]) => labels?.[name] === value);
25
30
  // `get({ kind, id })`.
26
31
  export function readRef(ref) {
27
32
  const { kind, id, ...rest } = ref ?? {};
@@ -23,7 +23,7 @@ export class ProtocolTypes {
23
23
  constructor() { this.types = new Map(); }
24
24
  // `side`: for one of Coda's own protocols, the side of the call kernel on each backend that does its doing operations
25
25
  // (`<backend ID>/<side>`, components/plugins/plugin-callers.mjs `route`); none for one a plugin implements.
26
- register({ kind, title, spec, status, operations = {}, streams = {}, permissions, contributions = {}, participants = () => [], side }, registered = () => {}, replace = false) {
26
+ register({ kind, title, spec, status, operations = {}, streams = {}, contributions = {}, participants = () => [], side }, registered = () => {}, replace = false) {
27
27
  if (!parseProtocolName(kind) || (this.types.has(kind) && !replace)) throw new TypeError(`协议名无效或已登记:${kind}`);
28
28
  if (spec?.type !== 'object' || status?.type !== 'object') throw new TypeError(`${kind}: spec 与 status 须为对象 schema`);
29
29
  if (typeof participants !== 'function' || !object(contributions)) throw new TypeError(`${kind}: 需要 participants 与 contributions`);
@@ -62,9 +62,9 @@ export class ProtocolTypes {
62
62
  }
63
63
  Object.defineProperty(properties, field, { value: schema, enumerable: true });
64
64
  }
65
- // Its title and permission groups as defined (@coda-console/protocol definition.json), for what a plugin's `uses` names
66
- // (components/plugins/plugin-extensions.mjs usesProblem).
67
- const type = { kind, ...(title ? { title } : {}), ...(permissions ? { permissions: structuredClone(permissions) } : {}), ...(side ? { side } : {}),
65
+ // Its title as defined (@coda-console/protocol definition.json). Its permission groups are judged as defined, not as
66
+ // registered (components/plugins/plugin-extensions.mjs compatibility).
67
+ const type = { kind, ...(title ? { title } : {}), ...(side ? { side } : {}),
68
68
  participants, contributions: structuredClone(contributions), operations: compiled, streams: readable,
69
69
  spec: compile(spec, defaults), status: compile(status, defaults),
70
70
  // Before supplementation only merge operands must be shaped correctly. Required fields and counts apply to the
@@ -1,24 +1,24 @@
1
1
  {
2
- "commit": "800586932a72dd97f24e3011c01031df3e4d4160",
2
+ "commit": "8ff481af89b9da86e09a5af2134884c78da0a011",
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "2.6.0",
6
- "@coda-console/protocol": "6.12.0",
6
+ "@coda-console/protocol": "6.13.0",
7
7
  "ajv": "8.20.0",
8
8
  "yaml": "2.9.1"
9
9
  },
10
10
  "files": {
11
11
  "check/coda/application/contributions.mjs": "861c363d06cdabfc4ce15435126fbc7ad7dafd3c93ca2ad9e9534a6f5a237942",
12
- "check/coda/components/protocols/record-rules.mjs": "6ef49b4fe4db4b39368c71181fe27d8e1f3317a139bbeceee1e0845cb7ebb0fc",
13
- "check/coda/components/protocols/types.mjs": "5999f705b352c83f6a02f9419b7e71a7fc0e54f927abf149bf55ad45f57f1eef",
12
+ "check/coda/components/protocols/record-rules.mjs": "116bd103102afb94589d1df69786a780d2745165f46b878ddd48ac6d630694b1",
13
+ "check/coda/components/protocols/types.mjs": "283cd0f4516f10637d6fe257fe645ead87912219d471c06408d56617f244e1d1",
14
14
  "check/coda/adapters/provider-api.mjs": "70441ea2a417ede13e04113ec254496883be3186f291ef5ee65834f35009eb9e",
15
15
  "check/coda/adapters/call-limit.mjs": "7e86d95ff7b0a88955015904ec91ae55e78fad816d06f710d6e62af53ccbdeab",
16
16
  "check/coda/adapters/clock.mjs": "79733b9ac3807b3da147fe8b782318a1cb42d1d51b9c8b81a507c13c7a8025fd",
17
17
  "check/coda/adapters/plugin-command.mjs": "526b4f57a549d9f74bac508f5803a592210cbf24ab67148260262f02d2bc75b5",
18
- "check/coda/adapters/plugin-modules.mjs": "6053604b3f3c59e1ef5b77cde5be163178e0d20286077c70bc088faed0a2de13",
18
+ "check/coda/adapters/plugin-modules.mjs": "5b02f9fd8eab68fb1564ab3640d137e383b59576e90a8d41f9a7feb804e13ff5",
19
19
  "check/coda/adapters/plugin-stream-services.mjs": "1e92eb3dd9d844d4f2773a60bc2941aae3c9cda10d9e96e31de9f09f51e672e5",
20
20
  "check/coda/adapters/plugin-test-host.d.mts": "71d10d545761a2013b87f29815f42d779722e211484d70e0a732de31c5972c7d",
21
- "check/coda/adapters/plugin-test-host.mjs": "6d9d1f8984c0f42f2d1b95aab682baacd418ec9dbd7b3c88841172626e9ae7d5",
21
+ "check/coda/adapters/plugin-test-host.mjs": "314ce4af2d0cdd1d3076f3e5af551ee3d3759ae01b6f670d2b84735e54fdfdac",
22
22
  "check/coda/adapters/process-relay.mjs": "5d379bd7ad07138d69c7accbe769d71294843399539bdf1fab8b6a1ddf13b9d8",
23
23
  "check/coda/components/composers/contributions.mjs": "43d3e15fb1f63b7b5c20716030d9537613809ed5cc2fb466a3678bfa308f9f92",
24
24
  "check/coda/components/concurrency-groups/schemas.mjs": "3c422044c637dee10565fb1b8bdc75b9c6a31e3b600ed223b7e5e345e1baf092",
@@ -26,10 +26,10 @@
26
26
  "check/coda/components/plugins/contribution-points.mjs": "2dade9fe4f3fa2b4e89f49a1ac4378ab2621e5ac542eb175967091f04568b45c",
27
27
  "check/coda/components/plugins/git-contributions.mjs": "532917cd3ec45e12535e9e6c206ae14fa598bebc789ab0c8f15609d1699fa1cd",
28
28
  "check/coda/components/plugins/model-contributions.mjs": "018a7157954b2326887ba1a780b37d3beb33338e41a28936b313562c2939d563",
29
- "check/coda/components/plugins/plugin-extensions.mjs": "540e5c3c15ba9f0d02b262e95286ccf12ad6ae5508d301bdd833cac3bb866b15",
29
+ "check/coda/components/plugins/plugin-extensions.mjs": "64089e6f0c58b60f922d93ac49cf5fa20d4541b39995e5170671d8a3d03f556f",
30
30
  "check/coda/components/plugins/plugin-icons.mjs": "ec29cadce4948ecacabfe911a2ceb45414b96e28971358acbc4e952bedc78e1a",
31
- "check/coda/components/plugins/plugin-rules.mjs": "3993928a786326142c4ded8f52f363a9fb6966abba4704551d6f0ee924420346",
32
- "check/coda/components/plugins/plugin-source-rules.mjs": "0e75a0be417177798dde8f9f953d732474958c180a7219120cca704b3aaf76fb",
31
+ "check/coda/components/plugins/plugin-rules.mjs": "ee2d9fef03d5e82050114840444601b7f7d2e8b9645ea388cba0d6e3dede3432",
32
+ "check/coda/components/plugins/plugin-source-rules.mjs": "099a2250cca737722c32524e40fc975c73abcfd4b99be7a9e5abcd5a68c211af",
33
33
  "check/coda/components/plugins/process-contributions.mjs": "6d39a904f52956b87c04351398f79a4fc34981fa01453195bd7a3b9f2c5d237b",
34
34
  "check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
35
35
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "25477742af8a9134ae343af6ab702926692bdd8dd07844f3cba47e8b702c0e49",
@@ -47,6 +47,6 @@
47
47
  "check/coda/resources/plugins/resources/panels/panels.mjs": "37ffc6a4ede3e4612cd13cf1a973a90892f8ce7e8a0f055e7cfe86313aae5224",
48
48
  "check/coda/resources/plugins/resources/panels/rules.mjs": "a433d4e84138937297ec31a8912aab7bd48bba4b66da3a10978edb1367613c96",
49
49
  "check/coda/resources/plugins/resources/panels/sign-in.mjs": "6eb016ef9a7f8aa03e0f4b2fa35ce139b8b1ff0deb4ec6e6a34139aed4f2841a",
50
- "check/coda/builtin.json": "c2e45a425ac512770102d0ff67e0ea3a855c06ce44a43c1dd77faabd7c951d74"
50
+ "check/coda/builtin.json": "6d8a803dc3503ea1fb68d526b2785fd73c7564d2ecd0cf24299055d0dda674dc"
51
51
  }
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.8.21",
3
+ "version": "0.8.22",
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": "2.6.0",
27
- "@coda-console/protocol": "6.12.0",
27
+ "@coda-console/protocol": "6.13.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },