evolcore 0.0.42-test.0 → 0.0.43-test.0
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/CHANGELOG.md +31 -2
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +4 -2
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -6,6 +6,8 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
6
6
|
'config',
|
|
7
7
|
'peer',
|
|
8
8
|
'ctl',
|
|
9
|
+
// Directory operations are authenticated by the daemon's operation gateway.
|
|
10
|
+
'directory',
|
|
9
11
|
// These commands are authenticated again by their daemon IPC entrypoints.
|
|
10
12
|
'diag',
|
|
11
13
|
'menu-client',
|
|
@@ -22,6 +24,7 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
22
24
|
'pa-workspace',
|
|
23
25
|
'proxy',
|
|
24
26
|
'provider',
|
|
27
|
+
'ability',
|
|
25
28
|
'queue',
|
|
26
29
|
'response',
|
|
27
30
|
// `role` 提交/审批关系角色提升申请,通过 role.op IPC 鉴权;
|
|
@@ -50,6 +53,9 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
50
53
|
'task',
|
|
51
54
|
'trigger',
|
|
52
55
|
'version',
|
|
56
|
+
// Upgrade commands validate both task fullaccess and current DaemonOwner via IPC.
|
|
57
|
+
'upgrade',
|
|
58
|
+
'update',
|
|
53
59
|
'-v',
|
|
54
60
|
'-V',
|
|
55
61
|
'--version',
|
package/dist/cli/model.js
CHANGED
|
@@ -221,26 +221,46 @@ Options:
|
|
|
221
221
|
ec model reset --self bot.agentid.pub
|
|
222
222
|
ec model check --self bot.agentid.pub`;
|
|
223
223
|
async function dispatch(sub, args, formatJson) {
|
|
224
|
+
if (wantsHelp(args)) {
|
|
225
|
+
console.log(HELP);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
224
228
|
switch (sub) {
|
|
225
|
-
case 'list':
|
|
226
|
-
case 'current':
|
|
227
|
-
case 'info':
|
|
229
|
+
case 'list':
|
|
230
|
+
case 'current':
|
|
231
|
+
case 'info':
|
|
232
|
+
case 'check': {
|
|
233
|
+
const sel = parseSelector(args, formatJson);
|
|
234
|
+
const modelId = sub === 'info' && args[1] && !args[1].startsWith('--') ? args[1] : undefined;
|
|
235
|
+
if (sub === 'info' && !modelId)
|
|
236
|
+
fail(formatJson, 'MISSING_MODEL_ID', 'info 需要 <model-id>');
|
|
237
|
+
const result = await executeModelRead(sub, sel, modelId);
|
|
238
|
+
emit(formatJson, result.data, result.text);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
228
241
|
case 'use': return await cmdUse(args, formatJson);
|
|
229
242
|
case 'reset': return await cmdReset(args, formatJson);
|
|
230
243
|
case 'effort': return await cmdEffort(args, formatJson);
|
|
231
|
-
case 'check': return await cmdCheck(args, formatJson);
|
|
232
244
|
default:
|
|
233
245
|
fail(formatJson, 'UNKNOWN_SUBCOMMAND', `未知子命令: ${sub}(model --help 查看用法)`);
|
|
234
246
|
}
|
|
235
247
|
}
|
|
236
|
-
|
|
237
|
-
async function
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return;
|
|
248
|
+
/** Shared read-only implementation; managed callers authorize the selector first. */
|
|
249
|
+
export async function executeModelRead(sub, selector, modelId) {
|
|
250
|
+
switch (sub) {
|
|
251
|
+
case 'list': return readModelList(selector);
|
|
252
|
+
case 'current': return readModelCurrent(selector);
|
|
253
|
+
case 'info':
|
|
254
|
+
if (!modelId)
|
|
255
|
+
throw new ModelScopeError('MISSING_MODEL_ID', 'info 需要 <model-id>');
|
|
256
|
+
return readModelInfo(selector, modelId);
|
|
257
|
+
case 'check': return readModelCheck(selector);
|
|
258
|
+
default: throw new ModelScopeError('UNKNOWN_SUBCOMMAND', `Unknown model read: ${sub}`);
|
|
241
259
|
}
|
|
242
|
-
|
|
243
|
-
|
|
260
|
+
}
|
|
261
|
+
// ── list ──────────────────────────────────────────────────────────────
|
|
262
|
+
async function readModelList(sel) {
|
|
263
|
+
const role = explicitOrDerivedRole([], sel);
|
|
244
264
|
const effectiveSel = selectorWithRole(sel, role);
|
|
245
265
|
const ba = activeBaseagent(sel.self);
|
|
246
266
|
const cat = await getCatalog(sel.self, ba);
|
|
@@ -251,88 +271,74 @@ async function cmdList(args, formatJson) {
|
|
|
251
271
|
const models = allowedModelIds
|
|
252
272
|
? allowedModelIds.map(id => cat.models.find(m => m.id === id) ?? { id })
|
|
253
273
|
: cat.models;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
return { data: {
|
|
275
|
+
ok: true,
|
|
276
|
+
effective: { model: resolved.model ?? null, source: resolved.source ?? null },
|
|
277
|
+
role: role ?? null,
|
|
278
|
+
catalogSource: cat.source,
|
|
279
|
+
freshness: cat.freshness,
|
|
280
|
+
revision: cat.revision,
|
|
281
|
+
fetchedAt: cat.fetchedAt,
|
|
282
|
+
diagnostics: cat.diagnostics,
|
|
283
|
+
models,
|
|
284
|
+
}, text: () => {
|
|
285
|
+
const lines = [];
|
|
286
|
+
lines.push(`当前生效: ${resolved.model ?? '(未配置)'}` +
|
|
287
|
+
(resolved.source ? ` (来源: ${SCOPE_LABEL[resolved.source]})` : ''));
|
|
288
|
+
lines.push('');
|
|
289
|
+
if (resolved.model && !cat.models.some(m => m.id === resolved.model))
|
|
290
|
+
lines.push('当前配置未列入目录');
|
|
291
|
+
lines.push(...cat.diagnostics.map(d => d.message));
|
|
292
|
+
const srcTag = cat.freshness === 'fallback' ? ` [${cat.source}/unverified]`
|
|
293
|
+
: cat.freshness === 'stale' ? ' [stale]' : '';
|
|
294
|
+
lines.push(`可用模型 (${models.length})${srcTag}:`);
|
|
295
|
+
for (const e of models) {
|
|
296
|
+
const live = resolved.model === e.id ? '✓' : ' ';
|
|
297
|
+
lines.push(` ${live} ${e.id}`);
|
|
298
|
+
}
|
|
299
|
+
return lines.join('\n');
|
|
300
|
+
} };
|
|
281
301
|
}
|
|
282
302
|
// ── current ───────────────────────────────────────────────────────────
|
|
283
|
-
async function
|
|
284
|
-
if (wantsHelp(args)) {
|
|
285
|
-
console.log(HELP);
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const sel = parseSelector(args, formatJson);
|
|
303
|
+
async function readModelCurrent(sel) {
|
|
289
304
|
const ba = activeBaseagent(sel.self);
|
|
290
|
-
const role = explicitOrDerivedRole(
|
|
305
|
+
const role = explicitOrDerivedRole([], sel);
|
|
291
306
|
const resolved = await resolveModelConfig(selectorWithRole(sel, role), ba);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
return { data: {
|
|
308
|
+
ok: true,
|
|
309
|
+
model: resolved.model ?? null,
|
|
310
|
+
effort: resolved.effort ?? null,
|
|
311
|
+
source: resolved.source ?? null,
|
|
312
|
+
role: role ?? null,
|
|
313
|
+
chain: resolved.chain.map((c) => ({ scope: c.scope, model: c.model ?? null, hit: c.hit })),
|
|
314
|
+
}, text: () => {
|
|
315
|
+
const lines = [];
|
|
316
|
+
lines.push(`当前生效模型: ${resolved.model ?? '(未配置)'}`);
|
|
317
|
+
lines.push(`推理强度: ${resolved.effort ?? 'auto'}`);
|
|
318
|
+
lines.push(`来源: ${resolved.source ? SCOPE_LABEL[resolved.source] : '无'}`);
|
|
319
|
+
const chain = resolved.chain.map((c) => `${SCOPE_LABEL[c.scope]}${c.hit ? ' ✓' : ''}${c.model ? `(${c.model})` : ''}`).join(' > ');
|
|
320
|
+
lines.push(`解析链: ${chain}`);
|
|
321
|
+
return lines.join('\n');
|
|
322
|
+
} };
|
|
308
323
|
}
|
|
309
324
|
// ── info ──────────────────────────────────────────────────────────────
|
|
310
|
-
async function
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
` 上下文窗口: ${info.context_window ?? '—'} tokens`,
|
|
328
|
-
` 最大输出: ${info.max_output_tokens ?? '—'} tokens`,
|
|
329
|
-
` 输入价格: ${fmtPrice(price?.input_per_mtok ?? null)}`,
|
|
330
|
-
` 输出价格: ${fmtPrice(price?.output_per_mtok ?? null)}`,
|
|
331
|
-
` 支持模态: ${info.modalities.join(', ')}${info.mocked ? ' (mock)' : ''}`,
|
|
332
|
-
` 推理强度: ${info.supports_effort ? '支持' : '不支持'}`,
|
|
333
|
-
` 状态: ${info.status === 'available' ? '✓ 可用' : info.status}`,
|
|
334
|
-
].join('\n');
|
|
335
|
-
});
|
|
325
|
+
async function readModelInfo(sel, modelId) {
|
|
326
|
+
const info = await getModelInfo(modelId, sel.self);
|
|
327
|
+
return { data: { ok: true, ...info }, text: () => {
|
|
328
|
+
const price = info.pricing;
|
|
329
|
+
const fmtPrice = (v) => v === null ? '— (mock)' : `$${v} / 1M tokens`;
|
|
330
|
+
return [
|
|
331
|
+
`模型: ${info.id}`,
|
|
332
|
+
` 厂商: ${info.owned_by}`,
|
|
333
|
+
` 上下文窗口: ${info.context_window ?? '—'} tokens`,
|
|
334
|
+
` 最大输出: ${info.max_output_tokens ?? '—'} tokens`,
|
|
335
|
+
` 输入价格: ${fmtPrice(price?.input_per_mtok ?? null)}`,
|
|
336
|
+
` 输出价格: ${fmtPrice(price?.output_per_mtok ?? null)}`,
|
|
337
|
+
` 支持模态: ${info.modalities.join(', ')}${info.mocked ? ' (mock)' : ''}`,
|
|
338
|
+
` 推理强度: ${info.supports_effort ? '支持' : '不支持'}`,
|
|
339
|
+
` 状态: ${info.status === 'available' ? '✓ 可用' : info.status}`,
|
|
340
|
+
].join('\n');
|
|
341
|
+
} };
|
|
336
342
|
}
|
|
337
343
|
// ── use / effort / reset 共用写入逻辑 ───────────────────────────────────
|
|
338
344
|
function describeWrite(scope, sel, model, effort, formatJson) {
|
|
@@ -451,13 +457,8 @@ async function cmdReset(args, formatJson) {
|
|
|
451
457
|
return `✓ 已清除 Agent 级模型设置(该 Agent 所有会话下条消息起回落到较低优先级配置)`;
|
|
452
458
|
});
|
|
453
459
|
}
|
|
454
|
-
async function
|
|
455
|
-
|
|
456
|
-
console.log(HELP);
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
const sel = parseSelector(args, formatJson);
|
|
460
|
-
const role = explicitOrDerivedRole(args, sel);
|
|
460
|
+
async function readModelCheck(sel) {
|
|
461
|
+
const role = explicitOrDerivedRole([], sel);
|
|
461
462
|
const ba = activeBaseagent(sel.self);
|
|
462
463
|
const steps = [];
|
|
463
464
|
const result = await runModelCheck({
|
|
@@ -466,8 +467,7 @@ async function cmdCheck(args, formatJson) {
|
|
|
466
467
|
baseagent: ba,
|
|
467
468
|
onStep: step => steps.push(step),
|
|
468
469
|
});
|
|
469
|
-
|
|
470
|
-
emit(true, {
|
|
470
|
+
return { data: {
|
|
471
471
|
ok: true,
|
|
472
472
|
steps,
|
|
473
473
|
configuredModel: result.configuredModel ?? null,
|
|
@@ -475,10 +475,7 @@ async function cmdCheck(args, formatJson) {
|
|
|
475
475
|
availableModels: result.availableModels,
|
|
476
476
|
role: role ?? null,
|
|
477
477
|
catalogSource: result.catalogSource,
|
|
478
|
-
}, () =>
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
console.log(formatModelCheck(result));
|
|
478
|
+
}, text: () => formatModelCheck(result) };
|
|
482
479
|
}
|
|
483
480
|
export async function cmdModel(args) {
|
|
484
481
|
const sub = args[0];
|
|
@@ -487,11 +484,11 @@ export async function cmdModel(args) {
|
|
|
487
484
|
console.log(HELP);
|
|
488
485
|
return;
|
|
489
486
|
}
|
|
490
|
-
if (process.env.EVOLCORE_SESSION_ID
|
|
491
|
-
&& (getArgValue(args, '--self') || getArgValue(args, '--peer') || getArgValue(args, '--role'))) {
|
|
492
|
-
fail(formatJson, 'NOT_ALLOWED', 'Managed model commands cannot select --self, --peer, or --role; they always use the authenticated current relation');
|
|
493
|
-
}
|
|
494
487
|
if (process.env.EVOLCORE_SESSION_ID) {
|
|
488
|
+
if (!['list', 'current', 'info', 'check'].includes(sub)
|
|
489
|
+
&& args.some(arg => ['--self', '--peer', '--role'].includes(arg))) {
|
|
490
|
+
fail(formatJson, 'NOT_ALLOWED', 'Managed model writes cannot select --self, --peer, or --role');
|
|
491
|
+
}
|
|
495
492
|
await runManagedCliOperation(['model', ...args], formatJson, sub === 'check' ? 60_000 : 10_000);
|
|
496
493
|
return;
|
|
497
494
|
}
|
|
@@ -9,7 +9,7 @@ export async function cmdProvider(args) {
|
|
|
9
9
|
console.log('用法: ec provider <命令> [--format json]\n\n'
|
|
10
10
|
+ ' list\n show <provider-id>\n create --file <path>\n import --file <path>\n'
|
|
11
11
|
+ ' update <provider-id> --file <path>\n delete <provider-id>\n\n'
|
|
12
|
-
+ '
|
|
12
|
+
+ '宿主控制终端或 daemon 验证的 trusted fullaccess 任务可管理 process 级 Provider。文件必须为 UTF-8,最大 1 MiB。\n'
|
|
13
13
|
+ 'import 接受单 Provider 对象、单项映射或 providers 包装,始终创建新 ID。\n'
|
|
14
14
|
+ 'update 替换完整对象;<redacted> 保留原密钥。输出始终脱敏。');
|
|
15
15
|
return;
|
|
@@ -17,12 +17,14 @@ export async function cmdProvider(args) {
|
|
|
17
17
|
const json = args.some((value, index) => value === '--format=json' || (value === '--format' && args[index + 1] === 'json'));
|
|
18
18
|
try {
|
|
19
19
|
const parsed = parseProviderCommand(['provider', ...args]);
|
|
20
|
-
const
|
|
20
|
+
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
21
|
+
const delegationToken = readDelegationCredential();
|
|
22
|
+
// Keep managed argv identical to the command bound by task approval.
|
|
23
|
+
// The daemon resolves relative input paths against the session project.
|
|
24
|
+
const argv = sessionId !== undefined || delegationToken ? ['provider', ...args] : ['provider', parsed.operation,
|
|
21
25
|
...(parsed.providerId ? [parsed.providerId] : []),
|
|
22
26
|
...(parsed.file ? ['--file', path.resolve(parsed.file)] : []),
|
|
23
27
|
...(parsed.json ? ['--format', 'json'] : [])];
|
|
24
|
-
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
25
|
-
const delegationToken = readDelegationCredential();
|
|
26
28
|
let controlToken;
|
|
27
29
|
if (!sessionId && !delegationToken) {
|
|
28
30
|
try {
|
|
@@ -18,6 +18,10 @@ import { rotateStdoutLog } from '../utils/log-writer.js';
|
|
|
18
18
|
import { applyDataMigration, finalizeDataMigration, planDataMigration, verifyDataMigration, } from '../core/data-migration.js';
|
|
19
19
|
import { DAEMON_SHUTDOWN_TIMEOUT_MS, requestDaemonShutdown, stopCodexAppServerOrphans } from './daemon-commands.js';
|
|
20
20
|
import { getProcessStartTime, startTimeMatches } from '../utils/process-introspect.js';
|
|
21
|
+
import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode } from '../config/daemon-services.js';
|
|
22
|
+
import { probeEcwebRestartReadiness, stopEcwebForRestart } from '../ecweb/runtime/lifecycle.js';
|
|
23
|
+
import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
24
|
+
import { WEB_PACKAGE_NAME } from '../product.js';
|
|
21
25
|
const execFileAsync = promisify(execFile);
|
|
22
26
|
/** Read-only check performed before stopping the current daemon. */
|
|
23
27
|
function preflightDataMigration(root, log) {
|
|
@@ -196,11 +200,15 @@ export async function cmdRestartMonitor() {
|
|
|
196
200
|
}
|
|
197
201
|
}
|
|
198
202
|
/** 检查服务是否已经在运行(ready signal 存在 + 至少一个活 main) */
|
|
199
|
-
const isServiceAlive = () => {
|
|
203
|
+
const isServiceAlive = async () => {
|
|
200
204
|
if (!fs.existsSync(p.readySignal))
|
|
201
205
|
return false;
|
|
202
206
|
const s = scanInstances();
|
|
203
|
-
|
|
207
|
+
if (!s.mains.some(m => m.alive))
|
|
208
|
+
return false;
|
|
209
|
+
const service = ecwebService(loadDaemonConfig().services);
|
|
210
|
+
return service?.enabled !== true || serviceRuntimeMode(service) !== 'managed'
|
|
211
|
+
|| await probeEcwebRestartReadiness(p, service.port ?? DEFAULT_ECWEB_PORT, resolveGlobalPkg(WEB_PACKAGE_NAME)?.version);
|
|
204
212
|
};
|
|
205
213
|
const markRequestReady = () => {
|
|
206
214
|
if (!hasCorrelatedRequest)
|
|
@@ -406,6 +414,23 @@ export async function cmdRestartMonitor() {
|
|
|
406
414
|
const stoppedCodex = stopCodexAppServerOrphans();
|
|
407
415
|
if (stoppedCodex)
|
|
408
416
|
log(`Cleaned ${stoppedCodex} EvolCore codex app-server orphan(s)`);
|
|
417
|
+
try {
|
|
418
|
+
const service = ecwebService(loadDaemonConfig().services);
|
|
419
|
+
if (service?.enabled && serviceRuntimeMode(service) === 'managed') {
|
|
420
|
+
await stopEcwebForRestart(p, service.port ?? DEFAULT_ECWEB_PORT, log);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
425
|
+
log(`ECWeb shutdown verification failed: ${reason}`);
|
|
426
|
+
markRestartOutcome(pendingFile, 'ecweb-stop-failed', reason, log, hasCorrelatedRequest ? requestId : undefined);
|
|
427
|
+
if (upgradeJob)
|
|
428
|
+
updateUpgradeJob(upgradeJob.jobId, {
|
|
429
|
+
status: 'failed', success: false, code: 'ECWEB_STOP_FAILED', reason,
|
|
430
|
+
}, 'ECWeb 未安全退出,未替换安装包或启动重复实例');
|
|
431
|
+
cleanupPendingFile(pendingFile, log, hasCorrelatedRequest ? requestId : undefined);
|
|
432
|
+
process.exit(1);
|
|
433
|
+
}
|
|
409
434
|
let upgradeBackup = null;
|
|
410
435
|
let upgrade;
|
|
411
436
|
if (applyPackageUpgrades) {
|
|
@@ -599,7 +624,7 @@ export async function cmdRestartMonitor() {
|
|
|
599
624
|
}
|
|
600
625
|
for (let attempt = 1; attempt <= MAX_HEAL_ATTEMPTS; attempt++) {
|
|
601
626
|
// 前置检查:服务可能已被上一轮 claude 修复并启动
|
|
602
|
-
if (isServiceAlive()) {
|
|
627
|
+
if (await isServiceAlive()) {
|
|
603
628
|
log(`✓ Service already running before attempt ${attempt}, skipping`);
|
|
604
629
|
markRequestReady();
|
|
605
630
|
await sendHealSummary(p, attempt - 1, log);
|
|
@@ -614,7 +639,7 @@ export async function cmdRestartMonitor() {
|
|
|
614
639
|
await notifyDaemonOwners(p, `🔧 自动修复中(第 ${attempt}/${MAX_HEAL_ATTEMPTS} 次)...`, log);
|
|
615
640
|
const healed = await invokeClaude(claudePath, p, attempt, MAX_HEAL_ATTEMPTS, HEAL_TIMEOUT, log);
|
|
616
641
|
// 后置检查:不管 invokeClaude 返回什么,都检查服务实际状态
|
|
617
|
-
if (isServiceAlive()) {
|
|
642
|
+
if (await isServiceAlive()) {
|
|
618
643
|
log(`✓ Service is running after attempt ${attempt}`);
|
|
619
644
|
markRequestReady();
|
|
620
645
|
await sendHealSummary(p, attempt, log);
|
|
@@ -643,7 +668,7 @@ export async function cmdRestartMonitor() {
|
|
|
643
668
|
log(`Attempt ${attempt}: still failing after fix`);
|
|
644
669
|
}
|
|
645
670
|
// 全部失败 — 最后再检查一次
|
|
646
|
-
if (isServiceAlive()) {
|
|
671
|
+
if (await isServiceAlive()) {
|
|
647
672
|
log('✓ Service recovered during final check');
|
|
648
673
|
markRequestReady();
|
|
649
674
|
await sendHealSummary(p, MAX_HEAL_ATTEMPTS, log);
|
|
@@ -1062,6 +1087,12 @@ function cleanupPendingFile(filePath, log, requestId) {
|
|
|
1062
1087
|
* 启动新进程并等待 ready.signal
|
|
1063
1088
|
*/
|
|
1064
1089
|
async function spawnAndWaitReady(p, log, timeout) {
|
|
1090
|
+
const ecweb = ecwebService(loadDaemonConfig().services);
|
|
1091
|
+
const requireEcweb = ecweb?.enabled === true && serviceRuntimeMode(ecweb) === 'managed';
|
|
1092
|
+
const ecwebPort = ecweb?.port ?? DEFAULT_ECWEB_PORT;
|
|
1093
|
+
const ecwebVersion = requireEcweb ? resolveGlobalPkg(WEB_PACKAGE_NAME)?.version : undefined;
|
|
1094
|
+
if (requireEcweb)
|
|
1095
|
+
await stopEcwebForRestart(p, ecwebPort, log);
|
|
1065
1096
|
// 删除旧的 ready signal
|
|
1066
1097
|
try {
|
|
1067
1098
|
fs.unlinkSync(p.readySignal);
|
|
@@ -1109,6 +1140,7 @@ async function spawnAndWaitReady(p, log, timeout) {
|
|
|
1109
1140
|
fs.closeSync(out);
|
|
1110
1141
|
fs.closeSync(err);
|
|
1111
1142
|
log(`Spawned new process PID: ${childPid}, waiting for ready signal...`);
|
|
1143
|
+
let waitingForEcweb = false;
|
|
1112
1144
|
// 轮询等待 ready.signal 出现
|
|
1113
1145
|
const start = Date.now();
|
|
1114
1146
|
while (Date.now() - start < timeout) {
|
|
@@ -1116,26 +1148,35 @@ async function spawnAndWaitReady(p, log, timeout) {
|
|
|
1116
1148
|
// 进程已退出则提前失败
|
|
1117
1149
|
if (!platform.isProcessRunning(childPid)) {
|
|
1118
1150
|
log('Process exited before ready signal');
|
|
1151
|
+
if (requireEcweb)
|
|
1152
|
+
await stopEcwebForRestart(p, ecwebPort, log);
|
|
1119
1153
|
return false;
|
|
1120
1154
|
}
|
|
1121
1155
|
if (fs.existsSync(p.readySignal)) {
|
|
1122
|
-
|
|
1123
|
-
|
|
1156
|
+
if (!requireEcweb || await probeEcwebRestartReadiness(p, ecwebPort, ecwebVersion)) {
|
|
1157
|
+
log(requireEcweb ? 'Daemon and ECWeb are ready' : 'Ready signal detected');
|
|
1158
|
+
return true;
|
|
1159
|
+
}
|
|
1160
|
+
if (!waitingForEcweb)
|
|
1161
|
+
log(`Daemon ready; waiting for identified ECWeb readiness on port ${ecwebPort}`);
|
|
1162
|
+
waitingForEcweb = true;
|
|
1124
1163
|
}
|
|
1125
1164
|
}
|
|
1126
|
-
log(
|
|
1165
|
+
log(`${waitingForEcweb ? 'ECWeb readiness' : 'Ready signal'} not received within ${timeout / 1000}s`);
|
|
1127
1166
|
// A timeout is still a live-process race: do not let self-heal spawn a
|
|
1128
1167
|
// replacement while the timed-out daemon owns the IPC endpoint or a port.
|
|
1129
1168
|
if (platform.isProcessRunning(childPid)) {
|
|
1130
|
-
platform.
|
|
1169
|
+
platform.killProcessOnly(childPid, false);
|
|
1131
1170
|
if (!await platform.waitForProcessExit(childPid, 5_000)) {
|
|
1132
1171
|
log(`Process ${childPid} survived graceful termination, forcing kill`);
|
|
1133
|
-
platform.
|
|
1172
|
+
platform.killProcessOnly(childPid, true);
|
|
1134
1173
|
if (!await platform.waitForProcessExit(childPid, 5_000)) {
|
|
1135
|
-
|
|
1174
|
+
throw new Error(`Process ${childPid} survived forced termination; refusing rollback or duplicate startup`);
|
|
1136
1175
|
}
|
|
1137
1176
|
}
|
|
1138
1177
|
}
|
|
1178
|
+
if (requireEcweb)
|
|
1179
|
+
await stopEcwebForRestart(p, ecwebPort, log);
|
|
1139
1180
|
cleanupInstances();
|
|
1140
1181
|
return false;
|
|
1141
1182
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { MAIN_CLI_BIN, SESSION_ID_ENV } from '../product.js';
|
|
3
|
+
import { resolvePaths } from '../paths.js';
|
|
4
|
+
import { ipcHostQuery, ipcQuery } from '../ipc.js';
|
|
5
|
+
import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
|
|
6
|
+
import { menuFailure, parseMenuResponse } from '../core/command/menu-protocol.js';
|
|
7
|
+
import { executeUpgradeAction, formatUpgradeResult } from '../utils/upgrade-jobs.js';
|
|
8
|
+
import { wantsHelp } from './help.js';
|
|
9
|
+
export async function executeUpgradeOperation(params) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = parseUpgradeCommand(params.argv);
|
|
12
|
+
const data = await executeUpgradeAction(parsed.mode, params.requestId, 'system-upgrade-singleton');
|
|
13
|
+
return { type: 'menu.response', id: params.requestId, name: 'system', data };
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
const failure = error;
|
|
17
|
+
return menuFailure({ id: params.requestId, name: 'system' }, {
|
|
18
|
+
code: failure.code ?? 'INTERNAL_ERROR', message: failure.message ?? '升级请求失败',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function parseUpgradeCommand(argv) {
|
|
23
|
+
const invalid = () => {
|
|
24
|
+
throw Object.assign(new Error(`用法: ${MAIN_CLI_BIN} upgrade [--format json] | ${MAIN_CLI_BIN} update [status] [--format json]`), { code: 'INVALID_ARGUMENT' });
|
|
25
|
+
};
|
|
26
|
+
if (!Array.isArray(argv) || argv.some(value => typeof value !== 'string')
|
|
27
|
+
|| !['upgrade', 'update'].includes(argv[0]))
|
|
28
|
+
return invalid();
|
|
29
|
+
const positional = [];
|
|
30
|
+
let json = false;
|
|
31
|
+
for (let index = 1; index < argv.length; index++) {
|
|
32
|
+
const token = argv[index];
|
|
33
|
+
if (token === '--format' || token.startsWith('--format=')) {
|
|
34
|
+
if (json)
|
|
35
|
+
return invalid();
|
|
36
|
+
const value = token === '--format' ? argv[++index] : token.slice('--format='.length);
|
|
37
|
+
if (value !== 'json')
|
|
38
|
+
return invalid();
|
|
39
|
+
json = true;
|
|
40
|
+
}
|
|
41
|
+
else if (token.startsWith('-'))
|
|
42
|
+
return invalid();
|
|
43
|
+
else
|
|
44
|
+
positional.push(token);
|
|
45
|
+
}
|
|
46
|
+
if (positional.length && (argv[0] !== 'update' || positional.length !== 1 || positional[0] !== 'status'))
|
|
47
|
+
return invalid();
|
|
48
|
+
return { mode: argv[0] === 'upgrade' ? 'check' : positional.length ? 'status' : 'update', json };
|
|
49
|
+
}
|
|
50
|
+
export async function cmdUpgrade(argv) {
|
|
51
|
+
if (wantsHelp(argv.slice(1))) {
|
|
52
|
+
console.log(`用法: ${MAIN_CLI_BIN} upgrade [--format json]\n`
|
|
53
|
+
+ ` ${MAIN_CLI_BIN} update [--format json]\n`
|
|
54
|
+
+ ` ${MAIN_CLI_BIN} update status [--format json]\n\n`
|
|
55
|
+
+ 'upgrade 检查三个组件;update 受理或复用唯一更新任务;status 查询当前或最近任务。\n'
|
|
56
|
+
+ '需要运行中的 daemon。宿主使用本机控制凭据;托管任务需要 verified fullaccess 和当前 DaemonOwner 授权。\n'
|
|
57
|
+
+ '--format json 输出标准 menu.response;更新任务异步执行,可用 update status 查看重启结果。');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const json = argv.some((value, index) => value === '--format=json'
|
|
61
|
+
|| (value === '--format' && argv[index + 1] === 'json'));
|
|
62
|
+
const header = { id: crypto.randomUUID(), name: 'system' };
|
|
63
|
+
let response;
|
|
64
|
+
try {
|
|
65
|
+
parseUpgradeCommand(argv);
|
|
66
|
+
const sessionId = process.env[SESSION_ID_ENV];
|
|
67
|
+
const delegationToken = readDelegationCredential();
|
|
68
|
+
const command = { type: 'upgrade.op', id: header.id, argv };
|
|
69
|
+
const raw = sessionId !== undefined || delegationToken
|
|
70
|
+
? await ipcQuery(resolvePaths().socket, {
|
|
71
|
+
...command, sessionId, delegationToken, delegationCommandHash: hashCurrentDelegatedCommand(),
|
|
72
|
+
}, 120_000, { throwOnError: true })
|
|
73
|
+
: await ipcHostQuery(resolvePaths().socket, command, 120_000, { throwOnError: true });
|
|
74
|
+
if (!raw)
|
|
75
|
+
throw Object.assign(new Error('无法连接 EvolCore daemon'), { code: 'DAEMON_UNAVAILABLE' });
|
|
76
|
+
// Authentication may reject the IPC envelope before the Menu adapter runs.
|
|
77
|
+
const envelope = raw;
|
|
78
|
+
const payload = envelope.response ?? envelope.data?.response;
|
|
79
|
+
if (payload && typeof payload === 'object' && payload.type === 'menu.response') {
|
|
80
|
+
response = parseMenuResponse(payload);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const code = envelope.code ?? (envelope.ok === false ? 'NOT_ALLOWED' : 'UPGRADE_REQUIRED');
|
|
84
|
+
const message = envelope.error ?? (code === 'UPGRADE_REQUIRED'
|
|
85
|
+
? '当前 daemon 不支持升级命令,请在维护窗口加载包含此功能的版本后重试'
|
|
86
|
+
: '升级请求被拒绝');
|
|
87
|
+
response = menuFailure(header, { code, message });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const failure = error;
|
|
92
|
+
response = menuFailure(header, { code: failure.code ?? 'INTERNAL_ERROR', message: failure.message ?? '升级请求失败' });
|
|
93
|
+
}
|
|
94
|
+
if (json)
|
|
95
|
+
console.log(JSON.stringify(response, null, 2));
|
|
96
|
+
else if (response.error)
|
|
97
|
+
console.error(`${response.error.code}: ${response.error.message}`);
|
|
98
|
+
else
|
|
99
|
+
console.log(formatUpgradeResult(response.data).replace('请执行 update', `请执行 ${MAIN_CLI_BIN} update`));
|
|
100
|
+
if (response.error)
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
package/dist/cli/version.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'url';
|
|
|
7
7
|
import { MAIN_PACKAGE_NAME, PRODUCT_DISPLAY_NAME, WEB_PACKAGE_NAME } from '../product.js';
|
|
8
8
|
import { getArgValue, wantsHelp } from './help.js';
|
|
9
9
|
import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
10
|
-
import { readVersionInfo } from '../utils/
|
|
10
|
+
import { readVersionInfo } from '../utils/host-info.js';
|
|
11
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
const PACKAGE_ROOT = path.resolve(__dirname, '../..');
|
|
13
13
|
const RESET = '\x1b[0m';
|
|
@@ -12,11 +12,13 @@ export class AccessPolicyError extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* 缺失 `access` 时按"只收内部联系人"执行:同 Owner 名录成员可进,外部与陌生人不进。
|
|
15
|
+
*
|
|
16
|
+
* `allowAllContacts` 是压过三档的总开关,默认关。
|
|
15
17
|
*/
|
|
16
18
|
export const DEFAULT_ACCESS_POLICY = Object.freeze({
|
|
17
19
|
allowInternalContacts: true,
|
|
18
20
|
allowExternalContacts: false,
|
|
19
|
-
|
|
21
|
+
allowAllContacts: false,
|
|
20
22
|
allowedAids: Object.freeze([]),
|
|
21
23
|
deniedAids: Object.freeze([]),
|
|
22
24
|
requestLimit: Object.freeze({ maxTimes: 600, coolDown: 60 * 60 }),
|
|
@@ -112,7 +114,7 @@ function clonePolicy(policy) {
|
|
|
112
114
|
return {
|
|
113
115
|
allowInternalContacts: policy.allowInternalContacts ?? true,
|
|
114
116
|
allowExternalContacts: policy.allowExternalContacts ?? false,
|
|
115
|
-
|
|
117
|
+
allowAllContacts: policy.allowAllContacts ?? false,
|
|
116
118
|
allowedAids: [...(policy.allowedAids ?? [])],
|
|
117
119
|
deniedAids: [...(policy.deniedAids ?? [])],
|
|
118
120
|
requestLimit: { ...policy.requestLimit },
|
|
@@ -58,6 +58,7 @@ export function getManagementCommandPermissions(role) {
|
|
|
58
58
|
'config.unset': { allow: true, scopes: ['agent', 'relation'] },
|
|
59
59
|
'role.policy.write': { allow: true, dangerous: true, scopes: ['agent'], constraints: { requireAgentAdmin: true } },
|
|
60
60
|
'ec.aid.show': { allow: true, dangerous: true, scopes: ['agent'], constraints: { targetCurrentAgentOnly: true, requireAgentAdmin: true } },
|
|
61
|
+
'ec.aid.list': { allow: true, dangerous: true, scopes: ['agent'], constraints: { requireAgentOwner: true } },
|
|
61
62
|
'ec.aid.lookup': { allow: true, scopes: ['agent'] },
|
|
62
63
|
'ec.aid.agentmd.get': { allow: true, scopes: ['agent'] },
|
|
63
64
|
'ec.aid.agentmd.put': { allow: true, dangerous: true, scopes: ['agent'], constraints: { targetCurrentAgentOnly: true, requireAgentAdmin: true } },
|
|
@@ -146,6 +146,10 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
146
146
|
// 仅 agent-config 声明该字段,relation/defaults 由 schema 路由拒绝。
|
|
147
147
|
if (field === 'baseagentSkills')
|
|
148
148
|
return scalar(field, 'boolean', 'owner-only');
|
|
149
|
+
if (field === 'ability')
|
|
150
|
+
return readonlyObject('ability');
|
|
151
|
+
if (field === 'ability.codeApproval.enabled')
|
|
152
|
+
return scalar('ability.codeApproval', 'boolean', 'owner-only');
|
|
149
153
|
if (top === 'chatmode') {
|
|
150
154
|
if (parts.length === 1)
|
|
151
155
|
return readonlyObject('chatmode');
|
|
@@ -1626,6 +1626,13 @@ export function resolveEffective(sel, opts = {}) {
|
|
|
1626
1626
|
channels: config.channels ?? [],
|
|
1627
1627
|
projects: config.projects,
|
|
1628
1628
|
capabilities: config.capabilities,
|
|
1629
|
+
ability: {
|
|
1630
|
+
...config.ability,
|
|
1631
|
+
codeApproval: {
|
|
1632
|
+
...config.ability?.codeApproval,
|
|
1633
|
+
enabled: config.ability?.codeApproval?.enabled ?? true,
|
|
1634
|
+
},
|
|
1635
|
+
},
|
|
1629
1636
|
baseagentSkills: config.baseagentSkills,
|
|
1630
1637
|
readonlySourceDiagnostics: config.readonlySourceDiagnostics,
|
|
1631
1638
|
// Schema defaults are not applied by AJV during reads; apply the current
|