@coda-console/plugin-check 0.5.27 → 0.5.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,12 +16,13 @@ plugins/grok-bot/ Grok Bot:把 xAI 云端 Bot 接成长期会话,原
16
16
  plugins/opencode/ OpenCode:在运行机的 opencode acp 与 Coda 之间转发,送入会话指令与所选模型服务,模型按来源分组
17
17
  plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管 Codex 额度面板
18
18
  plugins/cursor/ Cursor:在运行机的 cursor-agent acp 与 Coda 之间转发,送入会话指令
19
+ plugins/git/ Git 源与快照:本机仓库 provider、运行关联的工作树/提交快照、临时 ref 回收与只读 smart HTTP v2
19
20
  plugins/host/ 宿主资源:Xcode 构建、Apple 模拟器与项目要求排队的命令共用这台机器的一组名额(组 host、持锁执行 run-held、host-sim),面板「构建与模拟器名额」
20
21
  plugins/magpie/ Magpie:把本机的 Magpie 网关作为模型服务提供给 Pi 等插件,安装时装好 Magpie 并让网关常驻
21
22
  plugins/network-log/ 网络记录:默认关闭,按需开启建连等待与定时探测采集;关闭后仍可查看历史
22
23
  plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布;也是写 PR 流程的样例
23
24
  plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
24
- plugins/composer/ 输入框模式:交接到新会话、子会话、! 执行命令、Ultra 与 /loop 循环;Ultra 模板设置为 composer.templates
25
+ plugins/composer/ 输入框模式 3.0:五个模式可同时开启,通过 submissions 协议补充去向与提示;Ultra 预设引用 composer.templates
25
26
  templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
26
27
  templates/panel/ 最小的面板插件:一张卡片、一条进度条、一个按钮
27
28
  bin/、check/ 契约检查(仓库根的 package.json 就是它,@coda-console/plugin-check);check/coda/ 是 Coda 同步来的规则副本,不要手改
@@ -0,0 +1,11 @@
1
+ import { admissionFeatures } from '../domain/resource-admission.mjs';
2
+
3
+ // The module's local ledger API, exported unchanged to plugin-check.
4
+ export function admissionAPI(call) {
5
+ return {
6
+ features: admissionFeatures,
7
+ acquire: request => call('acquire', [request]),
8
+ release: lease => call('release', [lease]),
9
+ list: () => call('list', []),
10
+ };
11
+ }
@@ -1,9 +1,15 @@
1
1
  // The plugin host's local API. Controllers consume accepted objects serially per ID; they choose their own actions.
2
- export function providerAPI({ call, watch, report = console.error }) {
2
+ import { checkCreationReadOnly } from '../components/protocols/creation.mjs';
3
+ export function providerAPI({ call, watch, connection, report = console.error }) {
3
4
  const observe = (kind, fn, scope = 'available') => watch(`provider:${kind}`, fn, { scope });
4
5
  return {
6
+ async resolve(ref, service) {
7
+ const { resource, path } = await call('resolve', [ref, service]);
8
+ const api = connection();
9
+ return { resource, url: `${api.url}${path}`, headers: { authorization: `Bearer ${api.token}` } };
10
+ },
5
11
  define: definition => call('define', [definition]),
6
- put: object => call('put', [object]),
12
+ put: async object => { checkCreationReadOnly(object); return call('put', [object]); },
7
13
  update: (kind, id, spec, revision) => call('update', [kind, id, spec, revision]),
8
14
  setStatus: (kind, id, status, revision) => call('setStatus', [kind, id, status, revision]),
9
15
  delete: (kind, id) => call('delete', [kind, id]),
@@ -1031,312 +1031,6 @@
1031
1031
  ],
1032
1032
  "defaultInstalled": false
1033
1033
  },
1034
- {
1035
- "id": "composer",
1036
- "displayName": "输入框模式",
1037
- "description": "输入框的五种模式:交接到新会话、创建子会话、打 ! 执行命令、Ultra 协调模式,以及按周期重复任务的循环模式。Ultra 的主 Agent 负责决策、调度和验收,非微小任务交给 Coda 子会话执行。",
1038
- "version": "2.1.0",
1039
- "category": "工作流程",
1040
- "source": {
1041
- "kind": "builtin",
1042
- "package": "@coda-console/composer",
1043
- "tag": "latest",
1044
- "version": "2.1.0",
1045
- "integrity": "sha512-vFT4hELREpRSTWXmxAyNCAvlWi6MjiXxBj15tyGUMopGLQqY7NzJj8M81kbY0XzoBqXm96wEzPlDZL6IfuRspg==",
1046
- "repo": "https://github.com/coda-console/coda-plugins.git",
1047
- "path": "plugins/composer"
1048
- },
1049
- "dir": "node_modules/@coda-console/composer",
1050
- "title": "输入框模式",
1051
- "properties": {
1052
- "composer.templates": {
1053
- "type": "array",
1054
- "description": "进入 Ultra 时可选的名单,一行一个子 Agent:同一个模板名的几行是一个模板,排第一的模板是进入时的默认。默认没有模板,子 Agent 名单为空时沿用当前会话的 Agent 和模型。",
1055
- "title": "模板",
1056
- "rows": {
1057
- "type": "object",
1058
- "columns": {
1059
- "template": {
1060
- "type": "string",
1061
- "title": "模板",
1062
- "order": 0
1063
- },
1064
- "who": {
1065
- "type": "object",
1066
- "format": "coda-agent",
1067
- "title": "Agent",
1068
- "order": 1
1069
- },
1070
- "when": {
1071
- "type": "string",
1072
- "title": "什么时候派给它",
1073
- "order": 2
1074
- }
1075
- },
1076
- "required": [
1077
- "template",
1078
- "who"
1079
- ]
1080
- },
1081
- "default": []
1082
- }
1083
- },
1084
- "main": "main.mjs",
1085
- "workflows": [],
1086
- "capabilities": [],
1087
- "services": [],
1088
- "groups": [],
1089
- "commands": [],
1090
- "gitCredentials": [],
1091
- "endpoints": [],
1092
- "views": [],
1093
- "composerModes": [
1094
- {
1095
- "id": "handoff",
1096
- "title": "交接到新会话",
1097
- "icon": "arrow.right.square",
1098
- "hint": "新会话承接这里的上下文,共享当前工作目录及其中的文件;这个会话保留,仍可继续使用。",
1099
- "placeholder": "接下来要完成什么?",
1100
- "sendLabel": "交接",
1101
- "agent": "own",
1102
- "in": [
1103
- "session"
1104
- ]
1105
- },
1106
- {
1107
- "id": "subagent",
1108
- "title": "子会话",
1109
- "icon": "arrow.triangle.branch",
1110
- "hint": "承接父会话近期上下文,沿用父会话工作目录;只启动子会话,不向父 Agent 发送这段要求。",
1111
- "placeholder": "描述交给子会话的任务…",
1112
- "sendLabel": "启动子会话",
1113
- "agent": "own",
1114
- "in": [
1115
- "session"
1116
- ],
1117
- "parameters": {
1118
- "properties": {
1119
- "replyTo": {
1120
- "type": "string",
1121
- "enum": [
1122
- "parent",
1123
- "sender"
1124
- ],
1125
- "enumItemLabels": [
1126
- "完成后回报父会话",
1127
- "完成后回报你"
1128
- ],
1129
- "enumDescriptions": [
1130
- "结果交给父 Agent,由它接着处理",
1131
- "做完提醒你,不叫醒父 Agent"
1132
- ],
1133
- "title": "回报对象",
1134
- "default": "parent",
1135
- "order": 0
1136
- }
1137
- }
1138
- },
1139
- "schema": {
1140
- "type": "object",
1141
- "properties": {
1142
- "replyTo": {
1143
- "title": "回报对象",
1144
- "type": "string",
1145
- "enum": [
1146
- "parent",
1147
- "sender"
1148
- ],
1149
- "enumItemLabels": [
1150
- "完成后回报父会话",
1151
- "完成后回报你"
1152
- ],
1153
- "enumDescriptions": [
1154
- "结果交给父 Agent,由它接着处理",
1155
- "做完提醒你,不叫醒父 Agent"
1156
- ],
1157
- "default": "parent"
1158
- }
1159
- }
1160
- }
1161
- },
1162
- {
1163
- "id": "shell",
1164
- "title": "执行命令",
1165
- "icon": "terminal",
1166
- "hint": "在会话工作目录执行,命令和结果作为这条消息发给 Agent。",
1167
- "placeholder": "输入要执行的命令…",
1168
- "sendLabel": "执行",
1169
- "agent": "off",
1170
- "trigger": "!",
1171
- "in": [
1172
- "session",
1173
- "new"
1174
- ]
1175
- },
1176
- {
1177
- "id": "ultra",
1178
- "title": "Ultra",
1179
- "icon": "square.stack.3d.up",
1180
- "hint": "节省主 Agent 的 Token,非微小任务交给子会话执行",
1181
- "placeholder": "要完成什么?",
1182
- "agent": "session",
1183
- "in": [
1184
- "session",
1185
- "new"
1186
- ],
1187
- "parameters": {
1188
- "properties": {
1189
- "template": {
1190
- "type": "string",
1191
- "title": "模板",
1192
- "order": 0
1193
- },
1194
- "subagents": {
1195
- "type": "array",
1196
- "title": "子 Agent",
1197
- "rows": {
1198
- "type": "object",
1199
- "columns": {
1200
- "who": {
1201
- "type": "object",
1202
- "format": "coda-agent",
1203
- "title": "Agent",
1204
- "order": 0
1205
- },
1206
- "when": {
1207
- "type": "string",
1208
- "title": "什么时候派给它",
1209
- "order": 1
1210
- }
1211
- },
1212
- "required": [
1213
- "who"
1214
- ]
1215
- },
1216
- "order": 1
1217
- }
1218
- }
1219
- },
1220
- "schema": {
1221
- "type": "object",
1222
- "properties": {
1223
- "template": {
1224
- "title": "模板",
1225
- "type": "string"
1226
- },
1227
- "subagents": {
1228
- "title": "子 Agent",
1229
- "type": "array",
1230
- "items": {
1231
- "type": "object",
1232
- "properties": {
1233
- "who": {
1234
- "title": "Agent",
1235
- "type": "object",
1236
- "format": "coda-agent"
1237
- },
1238
- "when": {
1239
- "title": "什么时候派给它",
1240
- "type": "string"
1241
- }
1242
- },
1243
- "required": [
1244
- "who"
1245
- ]
1246
- }
1247
- }
1248
- }
1249
- }
1250
- },
1251
- {
1252
- "id": "loop",
1253
- "title": "循环",
1254
- "icon": "clock.arrow.2.circlepath",
1255
- "hint": "按周期把同一句话再发给 Agent,每轮做完才开始计时,7 天后自动结束",
1256
- "placeholder": "每轮要做什么?",
1257
- "sendLabel": "开始循环",
1258
- "agent": "session",
1259
- "in": [
1260
- "session"
1261
- ],
1262
- "parameters": {
1263
- "properties": {
1264
- "every": {
1265
- "type": "string",
1266
- "format": "duration",
1267
- "enum": [
1268
- "PT5M",
1269
- "PT10M",
1270
- "PT15M",
1271
- "PT30M",
1272
- "PT1H",
1273
- "PT2H",
1274
- "PT3H",
1275
- "PT6H",
1276
- "PT12H",
1277
- "P1D"
1278
- ],
1279
- "enumItemLabels": [
1280
- "5 分钟",
1281
- "10 分钟",
1282
- "15 分钟",
1283
- "30 分钟",
1284
- "1 小时",
1285
- "2 小时",
1286
- "3 小时",
1287
- "6 小时",
1288
- "12 小时",
1289
- "1 天"
1290
- ],
1291
- "title": "周期",
1292
- "default": "PT30M",
1293
- "order": 0
1294
- }
1295
- }
1296
- },
1297
- "schema": {
1298
- "type": "object",
1299
- "properties": {
1300
- "every": {
1301
- "title": "周期",
1302
- "type": "string",
1303
- "format": "duration",
1304
- "enum": [
1305
- "PT5M",
1306
- "PT10M",
1307
- "PT15M",
1308
- "PT30M",
1309
- "PT1H",
1310
- "PT2H",
1311
- "PT3H",
1312
- "PT6H",
1313
- "PT12H",
1314
- "P1D"
1315
- ],
1316
- "enumItemLabels": [
1317
- "5 分钟",
1318
- "10 分钟",
1319
- "15 分钟",
1320
- "30 分钟",
1321
- "1 小时",
1322
- "2 小时",
1323
- "3 小时",
1324
- "6 小时",
1325
- "12 小时",
1326
- "1 天"
1327
- ],
1328
- "default": "PT30M"
1329
- }
1330
- }
1331
- }
1332
- }
1333
- ],
1334
- "agents": [],
1335
- "dependencies": [],
1336
- "extensionPoints": {},
1337
- "extensions": [],
1338
- "defaultInstalled": true
1339
- },
1340
1034
  {
1341
1035
  "id": "grok",
1342
1036
  "displayName": "Grok",
@@ -0,0 +1,35 @@
1
+ const string = { type: 'string', minLength: 1 };
2
+ const object = (properties, required = Object.keys(properties)) => ({ type: 'object', properties, required, additionalProperties: false });
3
+ const array = items => ({ type: 'array', items });
4
+ const values = { type: 'object' };
5
+ const mode = { type: 'string', pattern: '^[a-z][a-z0-9-]{0,39}/[a-z][a-z0-9-]{0,39}$' };
6
+ const agent = object({ agent: string, settings: values });
7
+ // Defaults live on the selected branch, so AJV applies `open` to thread targets only.
8
+ export const target = {
9
+ type: 'object', properties: { kind: { enum: ['message', 'thread', 'loop'] } }, required: ['kind'],
10
+ allOf: [
11
+ { if: { properties: { kind: { const: 'message' } } }, then: object({ kind: { const: 'message' }, thread: string, run: { type: 'boolean' } }, ['kind', 'thread']) },
12
+ { if: { properties: { kind: { const: 'thread' } } }, then: object({ kind: { const: 'thread' }, agent: object({ agent: string, model: string, effort: string, mode: string, options: values }, ['agent']), settings: values,
13
+ checkout: object({ kind: { enum: ['original', 'worktree', 'handoff'] }, baseRef: string }, ['kind']),
14
+ handoffSource: string, parentThreadId: string, replyTo: { enum: ['parent', 'sender'] }, run: { type: 'boolean' }, open: { type: 'boolean', default: true } }, ['kind']) },
15
+ { if: { properties: { kind: { const: 'loop' } } }, then: object({ kind: { const: 'loop' }, thread: string,
16
+ every: { type: 'string', pattern: '^P(?:(?:0|1)D)?(?:T(?:[0-9]+H)?(?:[0-9]+M)?)?$' } }) },
17
+ ],
18
+ };
19
+ const snapshotMode = object({ mode, values, sent: { type: 'integer', minimum: 0 }, changedSinceSent: { type: 'boolean' } });
20
+ export const composerType = { kind: 'composers', participants: () => [],
21
+ spec: { ...object({ thread: string, project: string, modes: array(object({ mode, values })) }, ['modes']),
22
+ oneOf: [{ required: ['thread'], not: { required: ['project'] } }, { required: ['project'], not: { required: ['thread'] } }] },
23
+ status: object({ modes: array(object({ mode, sent: { type: 'integer', minimum: 0 }, changedSinceSent: { type: 'boolean' }, presets: { type: 'object', additionalProperties: array(object({ name: {}, values: array(values) })) } })) }) };
24
+ const tell = array({ type: 'string', minLength: 1, maxLength: 4000, pattern: '^[^\\u0000]*\\S[^\\u0000]*$' });
25
+ const targets = array(target), divert = { type: 'boolean' };
26
+ export const submissionType = { kind: 'submissions',
27
+ participants: object => object.spec.modes.map(({ mode }) => { const [plugin, key] = mode.split('/'); return { plugin, key }; }),
28
+ spec: object({ composer: string, thread: { type: ['string', 'null'] }, projectId: string, text: { type: 'string', minLength: 1, maxLength: 100000 },
29
+ attachments: { ...array(string), maxItems: 20, uniqueItems: true }, quotes: { ...array({ type: 'string', maxLength: 20000 }), maxItems: 20 },
30
+ agent, modes: array(snapshotMode), defaultTarget: target, tell, targets, divert },
31
+ ['composer', 'thread', 'projectId', 'text', 'attachments', 'quotes', 'agent', 'modes', 'defaultTarget']),
32
+ contributions: { tell: { merge: 'append', schema: tell }, targets: { merge: 'append', schema: targets }, divert: { merge: 'or', schema: divert } },
33
+ status: object({ clearedDraftRevision: { type: ['integer', 'null'], minimum: 0 },
34
+ results: array(object({ target, requestId: string, inputId: { type: ['string', 'null'], minLength: 1 },
35
+ state: { enum: ['done', 'refused'] }, thread: string, code: string, message: string }, ['target', 'requestId', 'inputId', 'state'])) }) };
@@ -18,7 +18,7 @@ import { isDuration } from '../../domain/duration.mjs';
18
18
  import { AGENT_ID } from '../../domain/values.mjs';
19
19
  import { agentDeclarations } from './agent-plugins.mjs';
20
20
  import { checkCatalog, extensionsFor } from './plugin-extensions.mjs';
21
- import { manifestProblem, TYPES, valueProblem } from '@coda-console/protocol/validate';
21
+ import { manifestProblem, TYPES } from '@coda-console/protocol/validate';
22
22
  import { claims, COMMIT, INTEGRITY, NPM_VERSION, npmPluginId, repoAddress, sourcePath } from './plugin-source-rules.mjs';
23
23
  import { readSkillDocument } from './skill-document.mjs';
24
24
  import { executorLabels } from '../workflows/executor-labels.mjs';
@@ -78,12 +78,11 @@ const TELL_LIMIT = 4000;
78
78
  export const checkTold = text => check(typeof text === 'string' && text.trim() && text.length <= TELL_LIMIT && !text.includes('\0'), 'invalid_input',
79
79
  `要告诉的话须为不超过 ${TELL_LIMIT} 字的文字`);
80
80
  // The modes a composer can be put in (docs/plugins.md「输入框模式」, schemas/composer-modes.json), each with the composers
81
- // that offer it (`in`, a session's by default) and whom what is sent is for (`agent`, the session's by default); its
82
- // parameters read as settings are, and as written (JSON Schema), which its hooks are given (components/composer-modes).
81
+ // that offer it (`in`, a session's by default), whether it leaves after acceptance (`once`), and declarative parameters.
83
82
  const MODE_PLACES = ['session', 'new'];
84
83
  const composerModes = (modes = []) => modes.map((m, i) => ({ id: m.id, title: m.title.trim(), icon: m.icon,
85
84
  ...(m.hint ? { hint: m.hint.trim() } : {}), ...(m.placeholder ? { placeholder: m.placeholder.trim() } : {}),
86
- ...(m.sendLabel ? { sendLabel: m.sendLabel.trim() } : {}), agent: m.agent ?? 'session', ...(m.trigger ? { trigger: m.trigger } : {}),
85
+ ...(m.sendLabel ? { sendLabel: m.sendLabel.trim() } : {}), once: m.once === true, ...(m.trigger ? { trigger: m.trigger } : {}),
87
86
  in: m.in ? MODE_PLACES.filter(place => m.in.includes(place)) : ['session'],
88
87
  ...(m.parameters !== undefined ? { parameters: parametersOf(m.parameters, `contributes.composerModes[${i}].parameters`), schema: structuredClone(m.parameters) } : {}) }));
89
88
  // A mode's parameters as read: each a setting, in the order written, which the clients show them in (JSON's objects keep
@@ -92,17 +91,10 @@ function parametersOf(value, where) {
92
91
  const ordered = fields => Object.fromEntries(Object.entries(fields).map(([name, spec], i) => [name, { ...spec, order: spec.order ?? i }]));
93
92
  const properties = Object.fromEntries(Object.entries(value.properties).map(([name, p], i) => {
94
93
  const read = setting(p, `${where}.properties.${name}`);
95
- return [name, { ...read, ...(read.rows ? { rows: { ...read.rows, columns: ordered(read.rows.columns) } } : {}), order: read.order ?? i }];
94
+ return [name, { ...read, ...(p.presets ? { presets: structuredClone(p.presets) } : {}), ...(read.rows ? { rows: { ...read.rows, columns: ordered(read.rows.columns) } } : {}), order: read.order ?? i }];
96
95
  }));
97
96
  return { properties, ...(value.required?.length ? { required: [...value.required] } : {}) };
98
97
  }
99
- // Parameters a mode's hook gives while it runs, checked against the same schema a manifest's are.
100
- export function modeParameters(value, where) {
101
- const problem = valueProblem('composer-modes.json#/$defs/parameters', value, where);
102
- check(!problem, 'invalid_plugin', problem);
103
- return parametersOf(value, where);
104
- }
105
-
106
98
  // The category it is listed under (docs/plugins.md「商店」): the first of its manifest's `categories`, as VS Code's are
107
99
  // written; empty when it names none.
108
100
  export const manifestCategory = manifest => Array.isArray(manifest?.categories) && typeof manifest.categories[0] === 'string' ? manifest.categories[0].trim().slice(0, 32) : '';
@@ -0,0 +1,18 @@
1
+ // Holder-owned envelope fields. Sequence orders originals across kinds on one holder; time is only for display.
2
+ import { requireCondition as check } from '../../domain/errors.mjs';
3
+
4
+ export const creationProperties = {
5
+ createdAt: { type: 'string' },
6
+ creationSequence: { type: 'integer', minimum: 1, maximum: Number.MAX_SAFE_INTEGER },
7
+ };
8
+
9
+ export function creationOf(object) {
10
+ const { createdAt, creationSequence } = object;
11
+ check(typeof createdAt === 'string' && Number.isFinite(Date.parse(createdAt))
12
+ && Number.isSafeInteger(creationSequence) && creationSequence > 0, 'invalid_input', '协议对象缺少有效的创建信息');
13
+ return { createdAt, creationSequence };
14
+ }
15
+
16
+ export function checkCreationReadOnly(object) {
17
+ check(Object.keys(creationProperties).every(key => !Object.hasOwn(object, key)), 'invalid_input', '创建信息由持有方写入,只读');
18
+ }
@@ -63,6 +63,7 @@ export function mergeContributions(type, spec, answers) {
63
63
  validate(type.base, spec, `${type.kind}.spec`);
64
64
  checkParticipants(answers);
65
65
  const replies = structuredClone(answers);
66
+ for (const reply of replies) if (reply.value === null) reply.value = {};
66
67
  for (const { plugin, key, value } of replies) validate(type.answer, value, `插件 ${plugin}(${key})的补充`);
67
68
  const result = structuredClone(spec);
68
69
  for (const { value } of replies.sort((a, b) => compare(a.plugin, b.plugin) || compare(a.key, b.key))) {
@@ -51,11 +51,16 @@ export function modeMark(value) {
51
51
  return { id: value.id, title: text(value.title, '模式名', 40), icon: text(value.icon, '模式图标', 100) };
52
52
  }
53
53
 
54
+ export function modeMarks(value) {
55
+ check(Array.isArray(value), 'invalid_input', '输入框模式须为数组');
56
+ return value.map(modeMark);
57
+ }
58
+
54
59
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
55
60
  export function firstMessage(value) {
56
61
  object(value, '首次发送');
57
62
  keys(value, ['requestId', 'projectId', 'title', 'agent', 'checkout', 'settings', 'text', 'attachments', 'quotes', 'handoffSource', 'parentThreadId',
58
- 'replyTo', 'threadId', 'extensionParent', 'mode', 'initiatedBy']);
63
+ 'replyTo', 'threadId', 'extensionParent', 'modes', 'initiatedBy']);
59
64
  const initiatedBy = value.initiatedBy === undefined ? {} : (() => {
60
65
  const source = object(value.initiatedBy, '发起会话');
61
66
  keys(source, ['threadId', 'title']);
@@ -116,7 +121,7 @@ export function firstMessage(value) {
116
121
  settings: settings(value.settings),
117
122
  text: message,
118
123
  ...(passages.length ? { quotes: passages } : {}),
119
- ...(value.mode === undefined ? {} : { mode: modeMark(value.mode) }),
124
+ ...(value.modes === undefined ? {} : { modes: modeMarks(value.modes) }),
120
125
  }, attachments(value.attachments));
121
126
  }
122
127
 
@@ -1,27 +1,31 @@
1
1
  {
2
- "commit": "c1d9bd9f99a2c90a446397eec21f581a71725385",
2
+ "commit": "88ade668be53bad55c8d6e8860760475d937a4cf",
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "1.4.0",
6
- "@coda-console/protocol": "1.10.0",
6
+ "@coda-console/protocol": "2.0.0",
7
7
  "ajv": "8.20.0",
8
8
  "yaml": "2.9.1"
9
9
  },
10
10
  "files": {
11
+ "check/coda/components/protocols/creation.mjs": "d061194dafc615fff490869e90d252deb2429a12a3d5e046a886212ec3afede4",
11
12
  "check/coda/components/protocols/provider-definition.mjs": "98327f1900f84109fd5493d2de8f683eb020754245f3049869ca3b30468821f9",
12
- "check/coda/components/protocols/types.mjs": "c214787505f3b493eae8c89da79a3e7ea89e54945424ce227bea1fbcf35e826e",
13
- "check/coda/adapters/provider-api.mjs": "99d5b32f9083645682e5b46d0d5f773db93e06cc72d1f98ae01e47f9b7e1253b",
13
+ "check/coda/components/protocols/types.mjs": "94bb3f30a3fcbe50e5a5c286fa84f4bd80951932adb582046a7820622415a229",
14
+ "check/coda/adapters/provider-api.mjs": "8a2b5d7b4a3766f9e28270bd355f4b4081d3069b4cedad120671995bea160253",
15
+ "check/coda/adapters/admission-api.mjs": "47524434710b250e5aa4c5b41fefe40684186a88f33ccf5a4fa44f8b0dd3a45a",
16
+ "check/coda/components/composers/schemas.mjs": "5a78aa58cfe8c1aed1ed165bf373798664abc5b4e97d2d0ad6393e4e72960335",
14
17
  "check/coda/components/plugins/agent-plugins.mjs": "d117702f83c988aa89c2e5ae26aafd6ae3e8ba0829adaeedf9e8640f5f8282be",
15
18
  "check/coda/components/plugins/plugin-extensions.mjs": "4d7963185195ba6d21a4e49a66987613d5892210b1eb1dc02cffb7b816407776",
16
- "check/coda/components/plugins/plugin-rules.mjs": "bf2eecafaf3a3c3a8b4719c3252db30a582fce5f11946926cd6a2bc03920c702",
19
+ "check/coda/components/plugins/plugin-rules.mjs": "2169dd2a9abb104dc786ac5a3c9d3eac163a383742c24f7caae72634fbba12d1",
17
20
  "check/coda/components/plugins/plugin-source-rules.mjs": "d894d55a3272df5ef3b108b68820c64aefdf6b69346404b58954f2a3503cb4a5",
18
21
  "check/coda/components/plugins/skill-document.mjs": "c5b5e815c42cd836572f7b60e22a46af6ac607fd9df0170fa36f955825636ce6",
19
22
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
20
- "check/coda/components/session-config/commands.mjs": "9114c880704253dce4f6b049ab10b2265067db4224916605a3209ff8d347fcac",
23
+ "check/coda/components/session-config/commands.mjs": "2e4c80b0280db32fe220fa360f18a8e66f12e6a16e3e7bce545c762c9c6340e1",
21
24
  "check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
22
25
  "check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
23
26
  "check/coda/domain/duration.mjs": "15dd64ef9b02342ad521c66e5968a569432a89dc7568d11afd3e6f3fe37e104b",
24
27
  "check/coda/domain/errors.mjs": "ddc00aef9bb6f9a56845a9926c82200628a906230d31212d88fcde48e36dfd36",
28
+ "check/coda/domain/resource-admission.mjs": "775b1d7067f9d8487a3504d737f3f4bea31adf77af3357ed42e313805e5188e7",
25
29
  "check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
26
30
  "check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
27
31
  "check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
@@ -29,6 +33,6 @@
29
33
  "check/coda/resources/plugins/resources/panels/panels.mjs": "9e25cfbc16ed9f68101fc7bfc34b8056c13a29d2368c5561e65e333233eb921e",
30
34
  "check/coda/resources/plugins/resources/panels/rules.mjs": "8418ed83b796f18047c154d8dea8dca7d98244af8ddfe3ddf188520c59324ee8",
31
35
  "check/coda/resources/plugins/resources/panels/sign-in.mjs": "1271a24e33b1b882a1fb9bee03b8e240db8b9bee1b5208f0e1c84499cfb1be7e",
32
- "check/coda/builtin.json": "cb4cb30ea2ae9abd67627761c2931811228a4d9084da308c3c4d5dd3519533f0"
36
+ "check/coda/builtin.json": "ecb831699268af0841bf6c9939320aadcb50e075f45093841eec1882b56c6a9a"
33
37
  }
34
38
  }
@@ -0,0 +1,15 @@
1
+ import { requireCondition as check } from './errors.mjs';
2
+
3
+ export const admissionFeatures = Object.freeze({ multiResource: false, multiUnit: false, exclusive: true });
4
+
5
+ export function admissionRequest(request) {
6
+ check(request && typeof request === 'object' && !Array.isArray(request) &&
7
+ Object.keys(request).every(key => ['requestId', 'group', 'resources', 'exclusive'].includes(key)), 'invalid_input', '无效的资源申请');
8
+ const { requestId, group, resources, exclusive = false } = request;
9
+ check(typeof requestId === 'string' && requestId.length > 0 && requestId.length <= 500, 'invalid_input', 'requestId 须为 1–500 字的稳定申请标识');
10
+ check(typeof group === 'string' && group.length > 0 && group.length <= 100, 'invalid_input', 'group 须为本机组名');
11
+ check(resources && Object.keys(resources).length === 1 && resources.slots === 1 && !Array.isArray(resources),
12
+ 'invalid_input', '只支持 resources: { slots: 1 },不支持多资源或多单位');
13
+ check(typeof exclusive === 'boolean', 'invalid_input', 'exclusive 须为 boolean');
14
+ return { requestId, group, exclusive };
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.5.27",
3
+ "version": "0.5.29",
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": "1.10.0",
27
+ "@coda-console/protocol": "2.0.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },