evolcore 0.0.43-test.7 → 0.0.43-test.8
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 +47 -0
- package/bin/ecmsg.js +22 -9
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/claude-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +1 -1
- package/dist/channels/aun.js +47 -32
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +5 -1
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +5 -0
- package/dist/cli/ecmsg-gateway.js +2 -2
- package/dist/cli/events-command.js +45 -9
- package/dist/cli/index.js +29 -0
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +115 -36
- package/dist/cli/services-command.js +29 -3
- package/dist/cli/thread-command.js +97 -11
- package/dist/config/boot-log.js +8 -8
- package/dist/config/schema-migration.js +41 -16
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-runtime.js +2 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +11 -2
- package/dist/core/channel-runtime.js +16 -9
- package/dist/core/command/agent-control.js +11 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/command-handler.js +27 -6
- package/dist/core/command/eventcenter-menu.js +158 -28
- package/dist/core/command/menu-catalog.js +8 -1
- package/dist/core/command/menu-handler.js +18 -6
- package/dist/core/command/menu-protocol.js +11 -2
- package/dist/core/daemon-control.js +14 -0
- package/dist/core/daemon-lifecycle.js +262 -189
- package/dist/core/handoff/runtime.js +42 -10
- package/dist/core/ipc-registration.js +5 -1
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/message/aun-ipc-sender.js +118 -13
- package/dist/core/message/im-renderer.js +88 -1
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +37 -7
- package/dist/core/message/send-routing.js +13 -6
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +49 -16
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-fs-store.js +66 -26
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/thread/thread-route.js +2 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +2 -0
- package/dist/event-center/admission-materializer.js +22 -12
- package/dist/event-center/bus-gate.js +20 -2
- package/dist/event-center/bus-host.js +46 -29
- package/dist/event-center/bus-resolver.js +1 -1
- package/dist/event-center/center-config.js +41 -14
- package/dist/event-center/daemon.js +1 -2
- package/dist/event-center/directory-source.js +3 -1
- package/dist/event-center/index-generator.js +12 -2
- package/dist/event-center/ipc-operation.js +140 -25
- package/dist/event-center/pack-loader.js +61 -56
- package/dist/event-center/pack-manager.js +2 -2
- package/dist/event-center/registry.js +242 -17
- package/dist/event-center/runtime.js +271 -75
- package/dist/event-center/types.js +20 -4
- package/dist/event-center/validation.js +34 -12
- package/dist/index.js +147 -44
- package/dist/ipc.js +44 -4
- package/dist/paths.js +2 -2
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/services/index.js +3 -3
- package/dist/services/ipc-operation.js +99 -7
- package/dist/services/pack-manager.js +17 -6
- package/dist/services/router.js +8 -5
- package/dist/services/validation.js +5 -5
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +52 -2
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/kits/docs/aun/ABILITY_CALLING.md +4 -3
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -3
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/event-center.md +30 -10
- package/kits/docs/evolcore/fs.md +4 -3
- package/kits/docs/evolcore/menu-protocol.md +7 -1
- package/kits/docs/evolcore/msg.md +8 -8
- package/kits/docs/evolcore/response.md +2 -2
- package/kits/docs/evolcore/services.md +27 -10
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/rules/06-channel.md +1 -0
- package/kits/skills/ability/references/calling.md +2 -2
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/thread.md +3 -2
- package/package.json +4 -3
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/event-center/client-factory.js +0 -50
|
@@ -12,12 +12,15 @@ import { agentServicesDir, resolveRoot } from '../paths.js';
|
|
|
12
12
|
import { classifyProtectedPath } from '../core/permission/protected-paths.js';
|
|
13
13
|
import { ServiceLedger } from './ledger.js';
|
|
14
14
|
import { ServiceMessageLog } from './message-log.js';
|
|
15
|
-
import {
|
|
15
|
+
import { SERVICES_CONFIG_JSON, loadRouterConfig } from './router.js';
|
|
16
|
+
import { PACK_JSON } from './pack-manager.js';
|
|
16
17
|
import { readLocalSelfIdentity } from './identity.js';
|
|
17
18
|
import { createOfflineServiceRouter, listServiceRouterAids, peekServiceRouter, } from './index.js';
|
|
18
19
|
import { isReservedServiceType, RESERVED_TYPES } from './service-payload.js';
|
|
19
20
|
import { getAunRequestRegistry } from '../core/message/aun-request-registry.js';
|
|
20
21
|
import { ServiceError, errorMessage } from './types.js';
|
|
22
|
+
import { authorizePackTarget, isManagingServicesCommand } from '../core/pack-auth.js';
|
|
23
|
+
import { installPack, listPackDirs, removePack } from '../core/pack-install.js';
|
|
21
24
|
const HELP = `ec services — 服务路由运维
|
|
22
25
|
|
|
23
26
|
用法:
|
|
@@ -29,6 +32,14 @@ const HELP = `ec services — 服务路由运维
|
|
|
29
32
|
ec services reload [<包名>] [--aid <aid>] 重载
|
|
30
33
|
ec services enable / disable [--aid <aid>] 总闸
|
|
31
34
|
|
|
35
|
+
安装与卸载(L 类目录只能由 daemon 代写):
|
|
36
|
+
ec services pack add <包名> --from <源目录> [--aid <aid>]
|
|
37
|
+
ec services pack remove <包名> [--aid <aid>] [--purge]
|
|
38
|
+
|
|
39
|
+
add 遇到已安装的包直接报错,先 remove 再装。
|
|
40
|
+
remove 默认把日志与台账归档到 <包>/logs/archive-<时间戳>/;--purge 连归档一起删。
|
|
41
|
+
ec services pack list [--aid <aid>]
|
|
42
|
+
|
|
32
43
|
对端:
|
|
33
44
|
ec services describe <aid>
|
|
34
45
|
ec services schema <aid> <type>
|
|
@@ -92,8 +103,23 @@ export function parseServicesArgv(argv) {
|
|
|
92
103
|
parsed.noWait = true;
|
|
93
104
|
args.splice(args.indexOf('--no-wait'), 1);
|
|
94
105
|
}
|
|
106
|
+
parsed.from = consumeValue('--from');
|
|
107
|
+
if (args.includes('--purge')) {
|
|
108
|
+
parsed.purge = true;
|
|
109
|
+
args.splice(args.indexOf('--purge'), 1);
|
|
110
|
+
}
|
|
111
|
+
if (args.includes('--force')) {
|
|
112
|
+
// 覆盖安装已取消:重装前必须先 `pack remove`。识别出来是为了给明确提示。
|
|
113
|
+
return { error: '--force is no longer supported; run "pack remove <包名>" before reinstalling' };
|
|
114
|
+
}
|
|
95
115
|
const positional = args.filter(item => !item.startsWith('-'));
|
|
96
|
-
|
|
116
|
+
if (command === 'pack') {
|
|
117
|
+
parsed.action = positional[0];
|
|
118
|
+
parsed.pack = positional[1];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
parsed.pack = positional[0];
|
|
122
|
+
}
|
|
97
123
|
// `--service` 已给出时不被位置参数覆盖。
|
|
98
124
|
if (parsed.type === undefined)
|
|
99
125
|
parsed.type = positional[1];
|
|
@@ -139,6 +165,7 @@ export function createServicesOperationExecutor(deps) {
|
|
|
139
165
|
const withCreate = {
|
|
140
166
|
listAids: () => deps.listAids?.() ?? listServiceRouterAids(),
|
|
141
167
|
defaultAid: deps.defaultAid,
|
|
168
|
+
daemonAid: deps.daemonAid,
|
|
142
169
|
getChannel: deps.getChannel,
|
|
143
170
|
create: deps.create ?? ((aid) => createOfflineServiceRouter(aid, agentServicesDir(aid), {
|
|
144
171
|
aid,
|
|
@@ -156,6 +183,8 @@ export function createServicesOperationExecutor(deps) {
|
|
|
156
183
|
}
|
|
157
184
|
if ('error' in parsed)
|
|
158
185
|
return { ok: false, code: 'INVALID_ARGV', error: parsed.error };
|
|
186
|
+
// 调用方身份随请求传入,不参与 argv 解析(argv 来自 agent,可伪造)。
|
|
187
|
+
parsed.caller = request.caller;
|
|
159
188
|
try {
|
|
160
189
|
return await execute(withCreate, parsed);
|
|
161
190
|
}
|
|
@@ -178,6 +207,16 @@ async function execute(deps, parsed) {
|
|
|
178
207
|
return target.error;
|
|
179
208
|
const aid = target.aid;
|
|
180
209
|
const router = target.router;
|
|
210
|
+
// 授权:只读与 call 不限;enable/disable/pack 需要本机 owner|admin,
|
|
211
|
+
// 跨 AID 需三重 owner(见 core/pack-auth.ts)。
|
|
212
|
+
const auth = authorizePackTarget({
|
|
213
|
+
caller: parsed.caller ?? { kind: 'local-control' },
|
|
214
|
+
targetAid: aid,
|
|
215
|
+
...(deps.daemonAid?.() ? { daemonAid: deps.daemonAid() } : {}),
|
|
216
|
+
requiresManagement: isManagingServicesCommand(command),
|
|
217
|
+
});
|
|
218
|
+
if (!auth.allowed)
|
|
219
|
+
return { ok: false, code: auth.code, error: auth.error };
|
|
181
220
|
const snapshot = router.snapshot();
|
|
182
221
|
const servicesDir = agentServicesDir(aid);
|
|
183
222
|
switch (command) {
|
|
@@ -242,6 +281,59 @@ async function execute(deps, parsed) {
|
|
|
242
281
|
case 'enable':
|
|
243
282
|
case 'disable':
|
|
244
283
|
return setRouterEnabled(aid, command === 'enable');
|
|
284
|
+
case 'pack': {
|
|
285
|
+
const servicesDirForPack = agentServicesDir(aid);
|
|
286
|
+
if (parsed.action === 'list') {
|
|
287
|
+
return { ok: true, result: { aid, servicesDir: servicesDirForPack, packs: listPackDirs(servicesDirForPack, PACK_JSON) } };
|
|
288
|
+
}
|
|
289
|
+
if (!parsed.pack)
|
|
290
|
+
return { ok: false, code: 'INVALID_ARGV', error: `pack ${parsed.action ?? ''} requires <包名>` };
|
|
291
|
+
if (parsed.action === 'add') {
|
|
292
|
+
if (!parsed.from)
|
|
293
|
+
return { ok: false, code: 'INVALID_ARGV', error: 'pack add requires --from <源目录>' };
|
|
294
|
+
const installed = installPack({
|
|
295
|
+
sourceDir: parsed.from,
|
|
296
|
+
targetRoot: servicesDirForPack,
|
|
297
|
+
name: parsed.pack,
|
|
298
|
+
manifestFile: PACK_JSON,
|
|
299
|
+
legacyManifestFile: 'service.json',
|
|
300
|
+
});
|
|
301
|
+
// 装包后若还没有 services-config.json,顺手建一份 enabled=true 的总闸:
|
|
302
|
+
// 没有它所有 services.* 请求都被静默丢弃,包"active"却调不通。
|
|
303
|
+
const routerPath = path.join(servicesDirForPack, SERVICES_CONFIG_JSON);
|
|
304
|
+
let createdRouter = false;
|
|
305
|
+
if (!fs.existsSync(routerPath)) {
|
|
306
|
+
fs.mkdirSync(servicesDirForPack, { recursive: true });
|
|
307
|
+
fs.writeFileSync(routerPath, `${JSON.stringify({
|
|
308
|
+
v: 1,
|
|
309
|
+
enabled: true,
|
|
310
|
+
rateLimit: {
|
|
311
|
+
builtin: { perMinute: 20, perHour: 200 },
|
|
312
|
+
service: { perMinute: 50, perHour: 1000 },
|
|
313
|
+
},
|
|
314
|
+
}, null, 2)}
|
|
315
|
+
`, 'utf8');
|
|
316
|
+
createdRouter = true;
|
|
317
|
+
}
|
|
318
|
+
const live = peekServiceRouter(aid);
|
|
319
|
+
if (live)
|
|
320
|
+
live.reload();
|
|
321
|
+
else
|
|
322
|
+
router.reload();
|
|
323
|
+
return { ok: true, result: { aid, ...installed, ...(createdRouter ? { createdRouter: true } : {}) } };
|
|
324
|
+
}
|
|
325
|
+
if (parsed.action === 'remove') {
|
|
326
|
+
const removed = removePack({ pack: parsed.pack, targetRoot: servicesDirForPack, purge: parsed.purge === true });
|
|
327
|
+
const live = peekServiceRouter(aid);
|
|
328
|
+
if (live)
|
|
329
|
+
live.reload();
|
|
330
|
+
else
|
|
331
|
+
router.reload();
|
|
332
|
+
return { ok: true, result: { aid, ...removed } };
|
|
333
|
+
}
|
|
334
|
+
return { ok: false, code: 'UNKNOWN_COMMAND', error: `unknown pack action: ${parsed.action ?? '(none)'}
|
|
335
|
+
${HELP}` };
|
|
336
|
+
}
|
|
245
337
|
default:
|
|
246
338
|
return { ok: false, code: 'UNKNOWN_COMMAND', error: `unknown services command: ${command}\n${HELP}` };
|
|
247
339
|
}
|
|
@@ -376,10 +468,10 @@ function doctor(aid, router, only) {
|
|
|
376
468
|
findings.push({ level: 'warn', check: 'packs', detail: 'no service packs found under services/' });
|
|
377
469
|
}
|
|
378
470
|
if (!snapshot.enabled) {
|
|
379
|
-
findings.push({ level: 'warn', check:
|
|
471
|
+
findings.push({ level: 'warn', check: SERVICES_CONFIG_JSON, detail: 'services/services-config.json enabled=false; all services.* messages are dropped' });
|
|
380
472
|
}
|
|
381
473
|
for (const error of snapshot.routerErrors) {
|
|
382
|
-
findings.push({ level: 'error', check:
|
|
474
|
+
findings.push({ level: 'error', check: SERVICES_CONFIG_JSON, detail: error });
|
|
383
475
|
}
|
|
384
476
|
const packs = only
|
|
385
477
|
? snapshot.packs.activePacks.filter(pack => pack.id === only)
|
|
@@ -410,7 +502,7 @@ function doctor(aid, router, only) {
|
|
|
410
502
|
for (const item of snapshot.packs.invalidPacks) {
|
|
411
503
|
if (only && item.id !== only)
|
|
412
504
|
continue;
|
|
413
|
-
findings.push({ level: 'error', check: `${item.id}.
|
|
505
|
+
findings.push({ level: 'error', check: `${item.id}.pack.json`, detail: item.errors.join('; ') });
|
|
414
506
|
}
|
|
415
507
|
for (const conflict of snapshot.packs.conflicts) {
|
|
416
508
|
findings.push({ level: 'error', check: 'listen.type', detail: `${conflict.type} declared by ${conflict.packs.join(', ')}` });
|
|
@@ -432,10 +524,10 @@ function lClassFinding() {
|
|
|
432
524
|
return { level: 'warn', check: 'l-class', detail: `cannot verify: ${errorMessage(error)}` };
|
|
433
525
|
}
|
|
434
526
|
}
|
|
435
|
-
/** enable / disable 只改
|
|
527
|
+
/** enable / disable 只改 services-config.json 的 enabled 字段;v 与其他字段原样保留。 */
|
|
436
528
|
function setRouterEnabled(aid, enabled) {
|
|
437
529
|
const servicesDir = agentServicesDir(aid);
|
|
438
|
-
const filePath = path.join(servicesDir,
|
|
530
|
+
const filePath = path.join(servicesDir, SERVICES_CONFIG_JSON);
|
|
439
531
|
const loaded = loadRouterConfig(servicesDir);
|
|
440
532
|
const base = loaded.exists
|
|
441
533
|
? JSON.parse(fs.readFileSync(filePath, 'utf8'))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 服务包扫描、加载与激活:services/<
|
|
2
|
+
* 服务包扫描、加载与激活:services/<pack>/pack.json (+脚本 realpath 校验),
|
|
3
3
|
* requires 对本机名片判定,跨包 listen.type 冲突检测。
|
|
4
4
|
*
|
|
5
5
|
* 三层判据的落点在这里:
|
|
@@ -11,7 +11,13 @@ import fs from 'node:fs';
|
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { sha256 } from '../trigger/validation.js';
|
|
13
13
|
import { requiresSatisfied, validateServiceJson } from './validation.js';
|
|
14
|
-
|
|
14
|
+
import { migrateLegacyFileName } from '../core/legacy-rename.js';
|
|
15
|
+
import { PACK_ARCHIVED_MARKER } from '../core/pack-install.js';
|
|
16
|
+
/**
|
|
17
|
+
* 服务包声明文件。与事件包统一叫 `pack.json`(不留 `service.json` 别名):
|
|
18
|
+
* 包主要由 agent 生成,两侧同名能省掉一次"这里该写哪个名"的判断。
|
|
19
|
+
*/
|
|
20
|
+
export const PACK_JSON = 'pack.json';
|
|
15
21
|
export const SCRIPTS_DIR = 'scripts';
|
|
16
22
|
export const LEDGER_FILE = 'ledger.jsonl';
|
|
17
23
|
export const LOGS_DIR = 'logs';
|
|
@@ -36,13 +42,15 @@ function assertInsidePackDir(packDir, target, errors, field) {
|
|
|
36
42
|
/** 加载单个包目录。返回 null 表示该包 invalid(errors 已填)。 */
|
|
37
43
|
export function loadPackDir(packDir, errors) {
|
|
38
44
|
const packId = path.basename(packDir);
|
|
39
|
-
|
|
45
|
+
// 旧名 service.json 一次性迁移成 pack.json(与事件包统一)。
|
|
46
|
+
migrateLegacyFileName(packDir, 'service.json', PACK_JSON, `services pack ${packId}`);
|
|
47
|
+
const serviceJsonPath = path.join(packDir, PACK_JSON);
|
|
40
48
|
let rawText;
|
|
41
49
|
try {
|
|
42
50
|
rawText = fs.readFileSync(serviceJsonPath, 'utf8');
|
|
43
51
|
}
|
|
44
52
|
catch (error) {
|
|
45
|
-
errors.push(`cannot read ${
|
|
53
|
+
errors.push(`cannot read ${PACK_JSON}: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
54
|
return null;
|
|
47
55
|
}
|
|
48
56
|
let raw;
|
|
@@ -50,7 +58,7 @@ export function loadPackDir(packDir, errors) {
|
|
|
50
58
|
raw = JSON.parse(rawText);
|
|
51
59
|
}
|
|
52
60
|
catch (error) {
|
|
53
|
-
errors.push(`${
|
|
61
|
+
errors.push(`${PACK_JSON} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
54
62
|
return null;
|
|
55
63
|
}
|
|
56
64
|
const validated = validateServiceJson(raw);
|
|
@@ -59,7 +67,7 @@ export function loadPackDir(packDir, errors) {
|
|
|
59
67
|
return null;
|
|
60
68
|
}
|
|
61
69
|
const canonicalScripts = path.join(packDir, SCRIPTS_DIR);
|
|
62
|
-
const scriptsDir =
|
|
70
|
+
const scriptsDir = canonicalScripts;
|
|
63
71
|
if (!fs.existsSync(scriptsDir)) {
|
|
64
72
|
errors.push(`scripts directory not found: expected ${SCRIPTS_DIR}/`);
|
|
65
73
|
return null;
|
|
@@ -123,6 +131,9 @@ export function loadPacks(servicesDir) {
|
|
|
123
131
|
if (entry.name.startsWith('.') || entry.name.startsWith('_'))
|
|
124
132
|
continue;
|
|
125
133
|
const packDir = path.join(servicesDir, entry.name);
|
|
134
|
+
// 已卸载但保留归档的目录:不是包,也不是坏包(见 pack-install 的 removePack)。
|
|
135
|
+
if (fs.existsSync(path.join(packDir, PACK_ARCHIVED_MARKER)))
|
|
136
|
+
continue;
|
|
126
137
|
const errors = [];
|
|
127
138
|
const pack = loadPackDir(packDir, errors);
|
|
128
139
|
if (pack)
|
package/dist/services/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* services/
|
|
2
|
+
* services/services-config.json 加载 + 两套按来源 AID 独立计数的限流。
|
|
3
3
|
*
|
|
4
4
|
* builtin 用于内置查询服务与 services 模式下给非 Owner 的错误回复;
|
|
5
5
|
* service 用于业务服务调用。两套分开计,按 fromAid 独立。
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { validateRouterConfig } from './validation.js';
|
|
10
|
-
|
|
10
|
+
import { migrateLegacyFileName } from '../core/legacy-rename.js';
|
|
11
|
+
export const SERVICES_CONFIG_JSON = 'services-config.json';
|
|
11
12
|
export const DEFAULT_ROUTER_CONFIG = {
|
|
12
13
|
v: 1,
|
|
13
14
|
enabled: false,
|
|
@@ -16,9 +17,11 @@ export const DEFAULT_ROUTER_CONFIG = {
|
|
|
16
17
|
service: { perMinute: 50, perHour: 1000 },
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
|
-
/** 读取 services/
|
|
20
|
+
/** 读取 services/services-config.json;不存在或缺 v 时返回缺省(enabled=false)。 */
|
|
20
21
|
export function loadRouterConfig(servicesDir) {
|
|
21
|
-
|
|
22
|
+
// 旧名 router.json 一次性迁移成 services-config.json。
|
|
23
|
+
migrateLegacyFileName(servicesDir, 'router.json', SERVICES_CONFIG_JSON, 'services config');
|
|
24
|
+
const filePath = path.join(servicesDir, SERVICES_CONFIG_JSON);
|
|
22
25
|
let rawText;
|
|
23
26
|
try {
|
|
24
27
|
rawText = fs.readFileSync(filePath, 'utf8');
|
|
@@ -34,7 +37,7 @@ export function loadRouterConfig(servicesDir) {
|
|
|
34
37
|
return {
|
|
35
38
|
config: DEFAULT_ROUTER_CONFIG,
|
|
36
39
|
exists: true,
|
|
37
|
-
errors: [`${
|
|
40
|
+
errors: [`${SERVICES_CONFIG_JSON} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`],
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
const validated = validateRouterConfig(raw);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* pack.json / services-config.json 校验。
|
|
3
3
|
* 约束 1:1 映射 docs/services/schema/{service,router}.schema.json;Schema 为权威,
|
|
4
4
|
* 两者不一致改这里并同步 Schema。手写校验器(不引 ajv),失败逐条报错。
|
|
5
5
|
*/
|
|
@@ -185,11 +185,11 @@ function validateReplyPolicy(raw, errors) {
|
|
|
185
185
|
}
|
|
186
186
|
return { allowed: raw.allowed === true, payloadTypes };
|
|
187
187
|
}
|
|
188
|
-
/** 校验
|
|
188
|
+
/** 校验 pack.json 原始对象(不做文件系统检查)。 */
|
|
189
189
|
export function validateServiceJson(raw) {
|
|
190
190
|
const errors = [];
|
|
191
191
|
if (!isRecord(raw))
|
|
192
|
-
return { ok: false, errors: ['
|
|
192
|
+
return { ok: false, errors: ['pack.json must be a JSON object'] };
|
|
193
193
|
const extra = Object.keys(raw).filter(key => !['v', 'name', 'description', 'enabled', 'requires', 'listen', 'unmatched', 'reply'].includes(key));
|
|
194
194
|
if (extra.length)
|
|
195
195
|
errors.push(`unknown top-level fields: ${extra.join(', ')}`);
|
|
@@ -258,11 +258,11 @@ function validateQuota(raw, field, fallback, errors) {
|
|
|
258
258
|
const perHour = intInRange(raw.perHour, `${field}.perHour`, 1, Number.MAX_SAFE_INTEGER, errors);
|
|
259
259
|
return { perMinute: perMinute ?? fallback.perMinute, perHour: perHour ?? fallback.perHour };
|
|
260
260
|
}
|
|
261
|
-
/** 校验
|
|
261
|
+
/** 校验 services-config.json 原始对象。 */
|
|
262
262
|
export function validateRouterConfig(raw) {
|
|
263
263
|
const errors = [];
|
|
264
264
|
if (!isRecord(raw))
|
|
265
|
-
return { ok: false, errors: ['
|
|
265
|
+
return { ok: false, errors: ['services-config.json must be a JSON object'] };
|
|
266
266
|
const extra = Object.keys(raw).filter(key => !['v', 'enabled', 'rateLimit'].includes(key));
|
|
267
267
|
if (extra.length)
|
|
268
268
|
errors.push(`unknown top-level fields: ${extra.join(', ')}`);
|
|
@@ -41,6 +41,25 @@ export class TriggerRuntimeScheduler {
|
|
|
41
41
|
initialized = false;
|
|
42
42
|
stopping = false;
|
|
43
43
|
lifecycleGeneration = 0;
|
|
44
|
+
mutationPaused = false;
|
|
45
|
+
pendingMutationStarts = 0;
|
|
46
|
+
/** Hold scheduling without changing definitions or consuming one-shot triggers. */
|
|
47
|
+
async pauseForMutation() {
|
|
48
|
+
if (this.mutationPaused || this.running.size || this.runStartLocks.size || this.pendingMutationStarts) {
|
|
49
|
+
throw Object.assign(new Error('Trigger scheduler has active work'), { code: 'AGENT_BUSY' });
|
|
50
|
+
}
|
|
51
|
+
this.mutationPaused = true;
|
|
52
|
+
for (const timer of this.timers.values())
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
this.timers.clear();
|
|
55
|
+
this.eventSource?.stop();
|
|
56
|
+
return async () => {
|
|
57
|
+
this.mutationPaused = false;
|
|
58
|
+
if (!this.stopping)
|
|
59
|
+
for (const definition of this.manager.list())
|
|
60
|
+
this.schedule(definition);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
44
63
|
constructor(manager, state, audit, scriptExecutor, feedback, daemonChannel, runtime, eventBus, targetSessionLocks = new TargetSessionLockRegistry()) {
|
|
45
64
|
this.manager = manager;
|
|
46
65
|
this.state = state;
|
|
@@ -329,6 +348,8 @@ export class TriggerRuntimeScheduler {
|
|
|
329
348
|
return this.manager.delete(triggerId);
|
|
330
349
|
}
|
|
331
350
|
async run(triggerId, opts = {}) {
|
|
351
|
+
if (this.mutationPaused)
|
|
352
|
+
throw Object.assign(new Error('Agent installation is in progress'), { code: 'AGENT_BUSY' });
|
|
332
353
|
const definition = this.manager.require(triggerId);
|
|
333
354
|
const firedAt = Date.now();
|
|
334
355
|
let sourcePayload = this.sourcePayload(definition.source);
|
|
@@ -366,6 +387,8 @@ export class TriggerRuntimeScheduler {
|
|
|
366
387
|
});
|
|
367
388
|
}
|
|
368
389
|
schedule(definition) {
|
|
390
|
+
if (this.mutationPaused)
|
|
391
|
+
return;
|
|
369
392
|
this.clearTimer(definition.id);
|
|
370
393
|
this.unregisterEvent(definition.id);
|
|
371
394
|
if (definition.limits)
|
|
@@ -404,6 +427,8 @@ export class TriggerRuntimeScheduler {
|
|
|
404
427
|
this.timers.set(definition.id, timer);
|
|
405
428
|
}
|
|
406
429
|
async handleScheduledFire(triggerId, scheduledAt) {
|
|
430
|
+
if (this.mutationPaused)
|
|
431
|
+
return;
|
|
407
432
|
const definition = this.manager.get(triggerId);
|
|
408
433
|
if (!definition?.enabled)
|
|
409
434
|
return;
|
|
@@ -455,6 +480,17 @@ export class TriggerRuntimeScheduler {
|
|
|
455
480
|
}
|
|
456
481
|
}
|
|
457
482
|
async startRun(definition, payload) {
|
|
483
|
+
if (this.mutationPaused)
|
|
484
|
+
return { ok: false, runId: 'mutation', triggerId: definition.id, status: 'skipped', reason: 'stopped' };
|
|
485
|
+
this.pendingMutationStarts++;
|
|
486
|
+
try {
|
|
487
|
+
return await this.startRunUnpaused(definition, payload);
|
|
488
|
+
}
|
|
489
|
+
finally {
|
|
490
|
+
this.pendingMutationStarts--;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
async startRunUnpaused(definition, payload) {
|
|
458
494
|
const firedAt = payload.firedAt;
|
|
459
495
|
const runId = `run_${firedAt}_${crypto.randomBytes(3).toString('hex')}`;
|
|
460
496
|
if (this.stopping) {
|
|
@@ -1975,6 +2011,8 @@ export class TriggerRuntimeScheduler {
|
|
|
1975
2011
|
return { status: 'inactive', warning: 'event subscription is not registered' };
|
|
1976
2012
|
}
|
|
1977
2013
|
async fireEventTrigger(triggerId, event) {
|
|
2014
|
+
if (this.mutationPaused)
|
|
2015
|
+
return;
|
|
1978
2016
|
const definition = this.manager.get(triggerId);
|
|
1979
2017
|
if (!definition?.enabled || definition.source.type !== 'event')
|
|
1980
2018
|
return;
|
|
@@ -135,8 +135,7 @@ export function buildTriggerScriptLaunch(input) {
|
|
|
135
135
|
const snapshotDir = path.join(runDir, 'script');
|
|
136
136
|
fs.mkdirSync(workDir, { mode: 0o700 });
|
|
137
137
|
fs.mkdirSync(snapshotDir, { mode: 0o700 });
|
|
138
|
-
const scriptPath =
|
|
139
|
-
fs.writeFileSync(scriptPath, scriptBytes, { flag: 'wx', mode: 0o400 });
|
|
138
|
+
const scriptPath = stageScriptSnapshot(input.scriptPath, triggerDir, scriptBytes, snapshotDir);
|
|
140
139
|
preserveNodeModuleType(runtime, input.scriptPath, snapshotDir);
|
|
141
140
|
const env = buildSandboxEnvironment(workDir);
|
|
142
141
|
const scriptArgs = [scriptPath, ...input.scriptArgs];
|
|
@@ -375,6 +374,57 @@ function readScriptSnapshot(value, triggerDir) {
|
|
|
375
374
|
fs.closeSync(descriptor);
|
|
376
375
|
}
|
|
377
376
|
}
|
|
377
|
+
/** 暂存总量上限:脚本目录可能混入大文件(数据/日志),超限拒跑沙箱而不是拖垮磁盘。 */
|
|
378
|
+
const SCRIPT_STAGING_TOTAL_LIMIT = 32 * 1024 * 1024;
|
|
379
|
+
/** 暂存文件数上限:node_modules/.git 已跳过,剩余仍超此数说明目录不是脚手架。 */
|
|
380
|
+
const SCRIPT_STAGING_FILE_COUNT = 2_000;
|
|
381
|
+
/**
|
|
382
|
+
* 暂存脚本快照:入口脚本(原 `readScriptSnapshot` 字节)+ 其所在目录的兄弟文件树。
|
|
383
|
+
*
|
|
384
|
+
* 原实现只写入口单文件,相对导入(`./lib/*.mjs`)在暂存目录里不存在——沙箱一生效
|
|
385
|
+
* 就 `ERR_MODULE_NOT_FOUND`,沙箱降级(fallback 跑原路径)时反而能跑,症状时隐时现。
|
|
386
|
+
* 现在按原目录结构整树暂存(跳过 node_modules/.git 与顶层 package.json——后者由
|
|
387
|
+
* `preserveNodeModuleType` 统一合成,避免 `wx` 冲突)。每个文件走与入口相同的
|
|
388
|
+
* lstat/fd 校验(防 TOCTOU/软链),越界文件直接抛错走沙箱不可用降级。
|
|
389
|
+
*/
|
|
390
|
+
function stageScriptSnapshot(scriptSource, triggerDir, scriptBytes, snapshotDir) {
|
|
391
|
+
const scriptName = path.basename(scriptSource);
|
|
392
|
+
const scriptPath = path.join(snapshotDir, scriptName);
|
|
393
|
+
fs.writeFileSync(scriptPath, scriptBytes, { flag: 'wx', mode: 0o400 });
|
|
394
|
+
const scriptDir = path.dirname(path.resolve(scriptSource));
|
|
395
|
+
assertRealDirectory(scriptDir, 'Trigger script directory');
|
|
396
|
+
let total = scriptBytes.length;
|
|
397
|
+
let count = 1;
|
|
398
|
+
const stage = (dir, rel) => {
|
|
399
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
|
|
400
|
+
for (const entry of entries) {
|
|
401
|
+
const name = entry.name;
|
|
402
|
+
const relPath = rel ? path.join(rel, name) : name;
|
|
403
|
+
if (!rel && (name === scriptName || name === 'package.json' || name === 'node_modules' || name === '.git'))
|
|
404
|
+
continue;
|
|
405
|
+
if (entry.isSymbolicLink())
|
|
406
|
+
throw new Error(`script snapshot must not contain symlinks: ${relPath}`);
|
|
407
|
+
if (entry.isDirectory()) {
|
|
408
|
+
fs.mkdirSync(path.join(snapshotDir, relPath), { mode: 0o700 });
|
|
409
|
+
stage(path.join(dir, name), relPath);
|
|
410
|
+
}
|
|
411
|
+
else if (entry.isFile()) {
|
|
412
|
+
if (++count > SCRIPT_STAGING_FILE_COUNT)
|
|
413
|
+
throw new Error(`script snapshot exceeds ${SCRIPT_STAGING_FILE_COUNT} files`);
|
|
414
|
+
const bytes = readScriptSnapshot(path.join(dir, name), triggerDir);
|
|
415
|
+
total += bytes.length;
|
|
416
|
+
if (total > SCRIPT_STAGING_TOTAL_LIMIT)
|
|
417
|
+
throw new Error('script snapshot exceeds 32 MiB total');
|
|
418
|
+
fs.writeFileSync(path.join(snapshotDir, relPath), bytes, { flag: 'wx', mode: 0o400 });
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
throw new Error(`script snapshot has unsupported entry: ${relPath}`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
stage(scriptDir, '');
|
|
426
|
+
return scriptPath;
|
|
427
|
+
}
|
|
378
428
|
function preserveNodeModuleType(runtime, scriptPath, snapshotDir) {
|
|
379
429
|
if (!/^node(?:\.exe)?$/i.test(path.basename(runtime)) || path.extname(scriptPath) !== '.js')
|
|
380
430
|
return;
|
package/dist/utils/npm-ops.js
CHANGED
|
@@ -493,7 +493,7 @@ export async function queryPackageVersion(pkg, selection, signal, distTag = 'lat
|
|
|
493
493
|
return isPackageVersion(version) ? { version, registry, npmConfig: selection.npmConfig } : null;
|
|
494
494
|
}
|
|
495
495
|
/** No registry lookup: callers must validate cache freshness before each install. */
|
|
496
|
-
export async function installExactPackageVersion(pkg, target, registry, resolveInstalled, npmConfig) {
|
|
496
|
+
export async function installExactPackageVersion(pkg, target, registry, resolveInstalled, npmConfig, beforeInstall) {
|
|
497
497
|
if (![MAIN_PACKAGE_NAME, WEB_PACKAGE_NAME].includes(pkg)
|
|
498
498
|
|| !isPackageVersion(target) || normalizeVersionRegistry(registry) !== registry) {
|
|
499
499
|
return { status: 'failed', error: 'Invalid cached install target' };
|
|
@@ -510,6 +510,7 @@ export async function installExactPackageVersion(pkg, target, registry, resolveI
|
|
|
510
510
|
result = { status: 'no-update', from };
|
|
511
511
|
return;
|
|
512
512
|
}
|
|
513
|
+
await beforeInstall?.();
|
|
513
514
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
514
515
|
try {
|
|
515
516
|
await npmInstallGlobal(`${pkg}@${target}`, { registry, preferOffline: true, npmConfig });
|
|
@@ -273,11 +273,14 @@ export async function applyCachedPackageUpgrades(names = AUTO_UPGRADE_PACKAGES,
|
|
|
273
273
|
}
|
|
274
274
|
else {
|
|
275
275
|
options.log?.(`Applying cached version information: ${name}@${entry.latestVersion}`);
|
|
276
|
-
result = await installExactPackageVersion(name, entry.latestVersion, registry, () => resolveVersionInfoPackage(name), options.npmConfig ?? entry.npmConfig);
|
|
276
|
+
result = await installExactPackageVersion(name, entry.latestVersion, registry, () => resolveVersionInfoPackage(name), options.npmConfig ?? entry.npmConfig, options.beforeInstall ? () => options.beforeInstall(name) : undefined);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
catch {
|
|
280
|
-
|
|
279
|
+
catch (error) {
|
|
280
|
+
const reason = error instanceof Error && error.message === 'Package backup unavailable; upgrade was not attempted'
|
|
281
|
+
? error.message
|
|
282
|
+
: 'Cached upgrade could not acquire installation lock or read installed version';
|
|
283
|
+
result = { status: 'failed', error: reason };
|
|
281
284
|
}
|
|
282
285
|
if (result.status === 'upgraded' || result.status === 'failed') {
|
|
283
286
|
await recordPackageUpgrade(name, {
|
|
@@ -33,7 +33,7 @@ EvolCore 不负责:
|
|
|
33
33
|
推荐按三层发现:
|
|
34
34
|
|
|
35
35
|
```text
|
|
36
|
-
L1 <provider-aid
|
|
36
|
+
L1 <provider-aid>:/.well-known/ability/index.json
|
|
37
37
|
发布者能力快照,可缓存但可能过期
|
|
38
38
|
|
|
39
39
|
L2 protocol/discover
|
|
@@ -46,10 +46,11 @@ L3 detail_ref 指向的 JSON
|
|
|
46
46
|
通过 `ec fs cat` 读取该 Provider 发布的 L1 索引:
|
|
47
47
|
|
|
48
48
|
```text
|
|
49
|
-
ec fs cat <provider-aid
|
|
49
|
+
ec fs cat <provider-aid>:/.well-known/ability/index.json
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
能力发现不能依赖目录枚举;只读取明确的 `index.json` 和契约给出的 `detail_ref
|
|
52
|
+
能力发现不能依赖目录枚举;只读取明确的 `index.json` 和契约给出的 `detail_ref`。该位置
|
|
53
|
+
object not found 时,旧版 Provider 仍在 `/ability/index.json` 发布,可回退读取一次。
|
|
53
54
|
|
|
54
55
|
L1/L2/L3 中用于机器决策的字段只有结构化字段:
|
|
55
56
|
|
|
@@ -49,7 +49,7 @@ evolcore 收到消息 → 构造一份 **vars**(运行时变量,见下)→
|
|
|
49
49
|
渲染时按 `session.sessionType`(缺省 `'main'`)依次查:`sessionManifests` 覆盖 → 内置映射 → `eck_manifest.json`(`resolveSessionManifest`)。bootstrapping 阶段固定用 `eck_manifest.json`。
|
|
50
50
|
**每个 manifest 文件各自两级合并**(`$KITS/<file>` + `$ECK/<file>`),互不干扰。
|
|
51
51
|
|
|
52
|
-
`chatMode` 只支持 interactive/proactive,均复用按生命周期、sessionType 和 sessionManifests 选择的 system/message manifest 与基础 vars。派生变量 `activePush` 仅在 proactive 时为 true,工具门禁变量也按 proactive 注入。PA 身份不改变 Agent 可见的模式、manifest 或 vars;仅在 active AUN 人类 Owner 私聊主会话及话题中,将 PA 的 proactive activity 经 message.send
|
|
52
|
+
`chatMode` 只支持 interactive/proactive,均复用按生命周期、sessionType 和 sessionManifests 选择的 system/message manifest 与基础 vars。派生变量 `activePush` 仅在 proactive 时为 true,工具门禁变量也按 proactive 注入。PA 身份不改变 Agent 可见的模式、manifest 或 vars;仅在 active AUN 人类 Owner 私聊主会话及话题中,将 PA 的 proactive 过程 activity 经 message.send 可靠投递,任务成功提交后的自动最终正文为 custom/agent_final。其他 proactive 场景使用 thought.put,群聊固定 proactive。默认逐条消息头显示本轮可信 chatMode;两种模式均不展示明文/密文标签;原始 encrypted 变量及发送加密语义不变。
|
|
53
53
|
|
|
54
54
|
## section 字段
|
|
55
55
|
|
|
@@ -47,7 +47,7 @@ Windows 上 Codex 托管任务出现 `helper_sandbox_lock_failed`、`SetNamedSec
|
|
|
47
47
|
| `ec aid` | AID 身份、名片与头像管理 | 身份/证书/名片/头像/换头像/探测对端 | 任意有渠道场景 | `aid.md` |
|
|
48
48
|
| `ec fs` | AUN 文件系统统一入口 | 上传/下载/看文件/列目录/删文件/配额/群空间 | 任意有渠道场景 | `fs.md` |
|
|
49
49
|
| `ec storage` | 文件存储底层调试入口 | storage 调试/旧命令/底层上传下载 | 任意有渠道场景 | `storage.md` |
|
|
50
|
-
| `ec agent` | EvolAgent
|
|
50
|
+
| `ec agent` | EvolAgent 生命周期、主机信息与模板 | 创建/启停/热重载/改配置/查主机信息/打包模板/安装模板 | 管理操作按目标与角色鉴权;template 要求双 Owner | `agent.md`;创建流程用 `ec-agent-create` 技能,Bootstrap 参考见 `agent-create.md` |
|
|
51
51
|
| `ec peer` | 对端身份与本地拉黑 | 查已登记对端、拉黑/解除拉黑 | 拉黑为 Agent 自身行为;添加联系人与审批归 Owner | `peer.md` |
|
|
52
52
|
| `ec directory` | Owner 名录查询、入录申请与本地备注 | 联系人/通讯录/名录/找人的 AID/申请添加联系人/这个人是谁/内外联系人/拉黑名单/记备注 | 查询需 Owner 名录授权;申请通过 `request` 发给本端 Owner | `directory.md` |
|
|
53
53
|
| `ec rpc` | 底层 AUN RPC(逃生通道) | 直接调协议方法 | 仅宿主终端;托管会话仅可查看帮助 | `rpc.md` |
|
|
@@ -83,8 +83,8 @@ Windows 上 Codex 托管任务出现 `helper_sandbox_lock_failed`、`SetNamedSec
|
|
|
83
83
|
| `ec stats` | Token 用量与费用统计 | 用量/费用/统计/预算/token/cost | `stats.md` |
|
|
84
84
|
| `ec trigger` | 定时与事件触发器管理(创建用 `create`,`set` 为兼容别名) | 触发器/定时任务/cron/提醒/定时检查/自动执行/巡检/禁用 trigger/删除 trigger | `trigger.md` |
|
|
85
85
|
| `ec trigger event` | EventBus 事件目录 | 事件触发/事件目录/EventBus/source.type=event/filter.match | `event.md` |
|
|
86
|
-
| `ec events` | AUN 事件中心:注册/发布/订阅事件,事件到达跑脚本 | 事件中心/注册事件/发布事件/订阅事件/事件包/pack.json/
|
|
87
|
-
| `ec services` | 服务路由:服务包状态/诊断/重载,对端 describe/schema/call | 服务路由/服务包/提供接口/被对端调用/
|
|
86
|
+
| `ec events` | AUN 事件中心:注册/发布/订阅事件,事件到达跑脚本 | 事件中心/注册事件/发布事件/订阅事件/事件包/pack.json/events-config.json/scripts/AUN 事件 | `event-center.md` |
|
|
87
|
+
| `ec services` | 服务路由:服务包状态/诊断/重载,对端 describe/schema/call | 服务路由/服务包/提供接口/被对端调用/pack.json/services.call/服务节点 | `services.md` |
|
|
88
88
|
| `ec task` | 恢复暂停或异常中断的会话任务 | 任务恢复/异常中断/继续任务/resume | `task.md` |
|
|
89
89
|
| `ec skill` | EC 技能管理(新建/安装/删除/启用/禁用/校验/查路径) | 创建技能/新建 skill/安装技能/装个 skill/删除技能/禁用技能/启用技能/看看有哪些技能/技能为什么没生效 | `ec-capabilities.md` |
|
|
90
90
|
| `ec pa-workspace` | 在 Owner 的 AUN 私聊中查看和维护 PA 工作区入口导航 | 个人助理工作区/工作区入口调整/产物入口/报告入口/任务入口/隐藏入口/改名入口/排序入口 | `pa-workspace.md` |
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
# ec agent — EvolAgent 生命周期管理
|
|
2
2
|
|
|
3
|
-
管理本机托管的 EvolAgent
|
|
3
|
+
管理本机托管的 EvolAgent(创建、启停、配置、热重载、模板)。触发词:创建/新建/列出/查看/启用/禁用/删除/热重载/改配置/打包模板/安装模板。
|
|
4
|
+
|
|
5
|
+
## Agent 模板
|
|
6
|
+
|
|
7
|
+
一期覆盖现有 agent,保留其 AID、Owner、角色和默认项目目录。打包不带记忆、消息、私钥或 Provider 凭证;只将本次安装的 Trigger 停用,并携带其脚本。执行要求操作者同时是 DaemonOwner 和来源/目标 Agent 的协议 Owner。
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ec agent template inspect <aid>
|
|
11
|
+
ec agent template build <aid> --version 1.0.0 --name '研究助理' --workspace dist,docs --skill paper-digest
|
|
12
|
+
ec agent template push <buildId> --owner <owner-aid> --path /templates/<id>/<id>-1.0.0.ectpl
|
|
13
|
+
ec agent template pull <owner-aid>:/templates/<id>/<id>-1.0.0.ectpl --share-id <短码> --digest sha256:<摘要> --agent <target-aid>
|
|
14
|
+
ec agent template deploy <pullId> --providers-json '{"claude":{"provider":"provider-12345678","model":"opus"}}'
|
|
15
|
+
ec agent template status <jobId>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
外来模板包可以包含多个成员。导入时用 `--targets-json '{"assistant":"assistant.agentid.cn","writer":"writer.agentid.cn"}'` 替代 `--agent`,将所有成员一对一映射到已有 Agent;不新建身份。deploy 可用 `--members-json '{"writer":{"providers":{"claude":{"provider":"provider-12345678","model":"writer-model"}}}}'` 指定逐成员选项。每个目标都须由请求者拥有,同包备份、安装与恢复作为一笔事务;不完整映射、重复目标或共享内容冲突会被拒绝。
|
|
19
|
+
|
|
20
|
+
完整选项用 `ec agent template --help` 查看。build 版本显式传入;App 从 Owner 空间列版本后建议 patch +1。上传前由 App 授予打包 host 目录写权限;普通私有下载使用 `storage.create_share_link.allowed_aids` 指定目标 host,pull 接收其 Storage 分享短码;Owner/subaid 动态授权等待新 SDK,不由 daemon 代设权限。
|
|
21
|
+
|
|
22
|
+
异步命令默认等待 60 秒,可用 `--wait 0..300`;超时返回可查询状态,不表示任务取消。`--request-id` 固定原请求用于恢复,Menu 还支持按原 requestId 查询。相同 pullId 的 deploy 只执行一次。预览后文件改变返回 CONFLICT;有活动任务返回 AGENT_BUSY。安装失败自动恢复实际写入文件与名片;INSTALL_BROKEN 表示恢复未完成,保留备份并停止目标接收新任务,需人工修复。
|
|
23
|
+
|
|
24
|
+
工具随包位于 `scripts/agent-template/`。Evol App 调用、Provider 模型目录查询和事件契约详见仓库 `docs/agent-template/agent-template-app-integration.md`;真实 AUN 跨主机流程已在隔离实验室验证,本轮修复需宿主重新构建并重启,App 界面待联调。宿主 CLI 在 Control AUN 连接完成后可直接调用,不需要先发送一次 Menu 来刷新 Owner。
|
|
4
25
|
|
|
5
26
|
## 子命令
|
|
6
27
|
|