evolcore 0.0.43-test.2 → 0.0.43-test.4
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 +44 -1
- package/bin/ecmsg.js +229 -0
- package/bin/install-codex-managed-hooks.mjs +130 -8
- package/dist/ability/application-service.js +37 -0
- package/dist/ability/resources.js +28 -0
- package/dist/ability/runtime.js +6 -1
- package/dist/agents/claude-runner.js +7 -5
- package/dist/agents/codex/app-server-client.js +0 -12
- package/dist/agents/codex-runner.js +0 -37
- package/dist/agents/ecagent-runner.js +138 -36
- package/dist/aun/aid/agentmd.js +52 -13
- package/dist/aun/menu/client.js +8 -7
- package/dist/aun/menu/index.js +1 -1
- package/dist/aun/menu/transport.js +8 -5
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/aun/service-proxy.js +3 -0
- package/dist/channels/aun.js +105 -53
- package/dist/channels/daemon.js +14 -2
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +31 -11
- package/dist/cli/agent.js +9 -3
- package/dist/cli/aun-commands.js +19 -21
- package/dist/cli/daemon-commands.js +30 -18
- package/dist/cli/directory.js +98 -56
- package/dist/cli/getmeta-command.js +2 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/init.js +13 -5
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/trigger-command.js +20 -14
- package/dist/config/access-policy.js +0 -1
- package/dist/config/boot-log.js +12 -2
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -0
- package/dist/config/config-manager.js +30 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +25 -1
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/config/schema-migration.js +121 -0
- package/dist/core/agent-application-service.js +11 -0
- package/dist/core/agent-ipc-registration.js +2 -0
- package/dist/core/agent-runtime.js +41 -9
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +19 -1
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/baseagent-loader.js +11 -3
- package/dist/core/bootstrap-service.js +8 -0
- package/dist/core/channel-loader.js +61 -23
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +5 -2
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/chatmode-config.js +46 -0
- package/dist/core/command/command-handler.js +44 -17
- package/dist/core/command/daemon-diagnostics.js +2 -1
- package/dist/core/command/menu-catalog.js +14 -1
- package/dist/core/command/menu-handler.js +74 -24
- package/dist/core/command/menu-protocol.js +8 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +52 -47
- package/dist/core/daemon-lifecycle.js +43 -17
- package/dist/core/event-catalog.js +19 -0
- package/dist/core/evolagent-registry.js +3 -0
- package/dist/core/evolagent.js +5 -4
- package/dist/core/ipc-registration.js +6 -0
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/message/aun-ipc-sender.js +30 -24
- package/dist/core/message/contact-admission.js +1 -19
- package/dist/core/message/im-renderer.js +81 -40
- package/dist/core/message/message-admission.js +21 -62
- package/dist/core/message/message-bridge.js +18 -5
- package/dist/core/message/message-utils.js +9 -0
- package/dist/core/message/peer-mode.js +16 -8
- package/dist/core/message/response-engine.js +67 -47
- package/dist/core/model/model-capabilities.js +37 -0
- package/dist/core/model/model-catalog.js +6 -2
- package/dist/core/ownership/owner-resolver.js +74 -36
- package/dist/core/permission/ec-command-parser.js +62 -13
- package/dist/core/plugin-lifecycle.js +6 -2
- package/dist/core/relation/pa-team.js +132 -0
- package/dist/core/role/runtime-policy.js +4 -3
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/owner-directory-admission.js +0 -3
- package/dist/directory/owner-directory-cache.js +201 -17
- package/dist/directory/owner-directory-markdown.js +44 -21
- package/dist/directory/owner-directory-policy.js +1 -1
- package/dist/directory/owner-directory-query-operation.js +218 -98
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +76 -23
- package/dist/directory/owner-directory-store.js +5 -38
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +6 -3
- package/dist/eck/message-renderer.js +2 -5
- package/dist/ecweb/message-context-service.js +4 -0
- package/dist/ecweb/runtime/lifecycle.js +29 -5
- package/dist/ecweb/runtime/supervisor.js +83 -27
- package/dist/index.js +209 -38
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/proxy/service-supervisor.js +377 -141
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/audit.js +3 -2
- package/dist/trigger/authorization.js +2 -3
- package/dist/trigger/history.js +4 -3
- package/dist/trigger/ipc-service.js +24 -19
- package/dist/trigger/manager.js +3 -5
- package/dist/trigger/parser.js +4 -21
- package/dist/trigger/patch.js +3 -15
- package/dist/trigger/scheduler.js +53 -13
- package/dist/trigger/validation.js +0 -13
- package/dist/utils/error-utils.js +15 -5
- package/dist/utils/macos-autostart.js +31 -0
- package/dist/utils/model-prices.jsonl +15 -8
- package/dist/utils/process-introspect.js +21 -1
- package/dist/utils/startup-trace.js +7 -1
- package/dist/utils/windows-autostart.js +1 -0
- package/ecagent/README.md +18 -0
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
- package/ecagent/dist/harness/compaction/compaction.js +7 -4
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +279 -0
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +5 -3
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +4 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +1 -1
- package/kits/docs/evolcore/tool-authorization.md +4 -1
- package/kits/docs/evolcore/trigger.md +10 -7
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +6 -23
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/rules/01-overview.md +42 -44
- package/kits/rules/02-navigation.md +44 -53
- package/kits/rules/03-identity.md +21 -25
- package/kits/rules/04-relation.md +23 -33
- package/kits/rules/05-venue.md +24 -25
- package/kits/schemas/_meta.json +10 -10
- package/kits/schemas/agent-config.schema.19.json +10 -6
- package/kits/schemas/relation-config.schema.12.json +2 -2
- package/kits/schemas/role-config.schema.2.json +5 -5
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-service-proxy/SKILL.md +10 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +20 -42
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/directory-contacts.md +1 -1
- package/kits/templates/system-fragments/identity.md +0 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -17
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +18 -13
- package/dist/eck/paactive-context.js +0 -45
- package/dist/response-system/engines/v1/paactive-flow.js +0 -18
- package/kits/eck_manifest.paactive.json +0 -528
- package/kits/eck_message_manifest.paactive.json +0 -233
- package/kits/templates/message-fragments/paactive/item.md +0 -3
- package/kits/templates/system-fragments/paactive/channel.md +0 -25
- package/kits/templates/system-fragments/paactive/reply.md +0 -25
- package/kits/templates/system-fragments/paactive/session.md +0 -32
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ import { createDelegationAuthorizer } from './core/auth/delegation-authorization
|
|
|
47
47
|
import { registerProxyIpcExecutor } from './proxy/ipc-service.js';
|
|
48
48
|
import { ownerResolver, getDaemonOwners, getPrimaryOwner } from './core/ownership/owner-resolver.js';
|
|
49
49
|
import { cleanupStartupHandoffs, recoverStartupHandoffs, releaseRestoredQueue, resumePendingSessions, createDaemonShutdown, daemonConversationTotalExecutionMs, daemonConversationWatchdogMs, daemonIdleTimeoutMs, } from './core/daemon-lifecycle.js';
|
|
50
|
+
import { createLifecycleNoticeService } from './core/lifecycle-notice.js';
|
|
50
51
|
import { BootstrapService, createBootstrapCompletionHandler, createBootstrapOwnerBoundHandler } from './core/bootstrap-service.js';
|
|
51
52
|
import { MessageCache } from './core/message/message-cache.js';
|
|
52
53
|
import { createAunHandoffSender } from './core/message/aun-ipc-sender.js';
|
|
@@ -77,7 +78,7 @@ import { EvolAgentRegistry } from './core/evolagent-registry.js';
|
|
|
77
78
|
import { createAgentInitializationRuntime, createAgentReloadRuntime, createAgentRuntimeOperations, createStartupAgentRunners, completeStartupAgentRuntime, bindAgentCreationOwner, loadStartupAgentRegistry, recoverIncompleteAgentInitializations, } from './core/agent-runtime.js';
|
|
78
79
|
import { IpcServer } from './ipc.js';
|
|
79
80
|
import { installChannelSdkConsoleFilter, logger, logOwnershipEvent, ownershipErrorCode, setChannelLogsEnabled, setLogLevel } from './utils/logger.js';
|
|
80
|
-
import { StartupTracer
|
|
81
|
+
import { StartupTracer } from './utils/startup-trace.js';
|
|
81
82
|
import { DiagService } from './core/command/diag-service.js';
|
|
82
83
|
import { createEcwebSupervisor } from './ecweb/runtime/supervisor.js';
|
|
83
84
|
import { writeMain, removeAll, isMainWinner, scanInstances } from './utils/instance-registry.js';
|
|
@@ -101,11 +102,10 @@ export function readEvolcoreVersion() {
|
|
|
101
102
|
}
|
|
102
103
|
async function main() {
|
|
103
104
|
// 启动甘特图埋点。firstPhase 之前的时间(node 启动 + 模块加载 + tsx/dist 编译)
|
|
104
|
-
// 全部记进 daemon.bootstrap
|
|
105
|
+
// 全部记进 daemon.bootstrap;计时器消费 `ec start` 传入的一次性 traceId,
|
|
105
106
|
// 没传说明是 restart-monitor 或其它途径拉起的,自己生成一个。
|
|
106
107
|
const trace = new StartupTracer('daemon', {
|
|
107
108
|
firstPhase: 'daemon.bootstrap',
|
|
108
|
-
traceId: process.env[STARTUP_TRACE_ID_ENV] || undefined,
|
|
109
109
|
});
|
|
110
110
|
trace.setMeta('launchedBy', process.env.EVOLCORE_LAUNCHED_BY || 'start');
|
|
111
111
|
trace.setMeta('node', process.version);
|
|
@@ -288,6 +288,7 @@ async function main() {
|
|
|
288
288
|
const { primaryAgent, runtimeStatus } = loadStartupAgentRegistry(agentRegistry);
|
|
289
289
|
let agentRuntimeState = runtimeStatus.state;
|
|
290
290
|
let agentRuntimeError = runtimeStatus.error;
|
|
291
|
+
const startupAgents = [...agentRegistry.runnableAgents()];
|
|
291
292
|
// 进程级设置独立来自 daemon.json,不进入 Agent 覆盖链。
|
|
292
293
|
const globalSettings = {
|
|
293
294
|
idleMonitor: daemonCfg.idleMonitor,
|
|
@@ -334,16 +335,114 @@ async function main() {
|
|
|
334
335
|
agentLoader.register(new CodexAgentPlugin());
|
|
335
336
|
agentLoader.register(new GeminiAgentPlugin());
|
|
336
337
|
agentLoader.register(new EcagentAgentPluginLazy());
|
|
337
|
-
trace.mark('daemon.agentRunners');
|
|
338
|
-
const { agentInstances, agentMap, primaryBaseagent, primaryRunnerKey, runtimeError: runnerStartupError, } = await createStartupAgentRunners({ agentRegistry, agentLoader, sessionManager, primaryAgent });
|
|
339
|
-
if (runnerStartupError) {
|
|
340
|
-
agentRuntimeState = 'error';
|
|
341
|
-
agentRuntimeError = runnerStartupError;
|
|
342
|
-
}
|
|
343
338
|
// 权限审批网关
|
|
344
339
|
const permissionGateway = new PermissionGateway();
|
|
345
340
|
permissionGateway.setEventBus(eventBus);
|
|
346
341
|
const removePermissionConfigListener = permissionGateway.registerConfigRevalidation();
|
|
342
|
+
const agentInstances = [];
|
|
343
|
+
const agentMap = new Map();
|
|
344
|
+
const primaryBaseagent = primaryAgent?.baseagent ?? 'claude';
|
|
345
|
+
const primaryRunnerKey = primaryAgent ? `${primaryAgent.aid}::${primaryBaseagent}` : '<empty>::claude';
|
|
346
|
+
const startupRunnerInstances = new Map();
|
|
347
|
+
const startupRunnerReadyResolvers = new Map();
|
|
348
|
+
const startupRunnerReady = new Map();
|
|
349
|
+
const startupOperationReadyResolvers = new Map();
|
|
350
|
+
const startupOperationReady = new Map();
|
|
351
|
+
const channelInstancesByAgent = new Map();
|
|
352
|
+
const runnerResultsByAgent = new Map();
|
|
353
|
+
const runnerSettledAgents = new Set();
|
|
354
|
+
let startupChannelsRegistered = false;
|
|
355
|
+
let startupCancelled = false;
|
|
356
|
+
const resolveStartupOperation = (aid) => {
|
|
357
|
+
if (startupCancelled || (startupChannelsRegistered && runnerSettledAgents.has(aid))) {
|
|
358
|
+
startupOperationReadyResolvers.get(aid)?.(runnerResultsByAgent.get(aid) ?? []);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
const boundStartupAgents = new Set();
|
|
362
|
+
const bindStartupAgentChannels = (agent, runners) => {
|
|
363
|
+
if (boundStartupAgents.has(agent.aid) || startupCancelled
|
|
364
|
+
|| agent.status === 'error' || agent.status === 'disabled' || runners.length === 0)
|
|
365
|
+
return;
|
|
366
|
+
const channels = channelInstancesByAgent.get(agent.aid);
|
|
367
|
+
if (!channels)
|
|
368
|
+
return;
|
|
369
|
+
bindStartupChannelsToAgents(channels, agentRegistry, runners);
|
|
370
|
+
boundStartupAgents.add(agent.aid);
|
|
371
|
+
};
|
|
372
|
+
for (const agent of startupAgents) {
|
|
373
|
+
startupRunnerReady.set(agent.aid, new Promise(resolve => {
|
|
374
|
+
startupRunnerReadyResolvers.set(agent.aid, resolve);
|
|
375
|
+
}));
|
|
376
|
+
startupOperationReady.set(agent.aid, new Promise(resolve => {
|
|
377
|
+
startupOperationReadyResolvers.set(agent.aid, resolve);
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
let baseagentSnapshot;
|
|
381
|
+
const refreshLoadedBaseagents = () => {
|
|
382
|
+
if (!baseagentSnapshot)
|
|
383
|
+
return;
|
|
384
|
+
const loaded = new Set(loadedBaseagentIds(agentMap.keys()));
|
|
385
|
+
for (const baseagent of baseagentSnapshot.baseagents)
|
|
386
|
+
baseagent.loaded = loaded.has(baseagent.id);
|
|
387
|
+
};
|
|
388
|
+
let configureRunnerCallbacks;
|
|
389
|
+
const agentDelegationRegistry = new AgentDelegationRegistry();
|
|
390
|
+
process.env[DAEMON_RUNTIME_EPOCH_ENV] = agentDelegationRegistry.getRuntimeEpoch();
|
|
391
|
+
const startupRunnersStartedAtMs = Date.now();
|
|
392
|
+
trace.mark('daemon.agentRunnerDispatch');
|
|
393
|
+
const baseagentSnapshotPromise = getBaseagentSnapshot({ loaded: [], probe: true });
|
|
394
|
+
const startupRunnersPromise = createStartupAgentRunners({
|
|
395
|
+
agentRegistry,
|
|
396
|
+
agentLoader,
|
|
397
|
+
sessionManager,
|
|
398
|
+
primaryAgent,
|
|
399
|
+
agentInstances,
|
|
400
|
+
agentMap,
|
|
401
|
+
isCancelled: () => startupCancelled,
|
|
402
|
+
configureInstances: instances => {
|
|
403
|
+
for (const instance of instances) {
|
|
404
|
+
instance.agent.setPermissionGateway?.(permissionGateway);
|
|
405
|
+
configureRunnerCallbacks?.(instance);
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
onAgentCreated: (agent, instances, timing) => {
|
|
409
|
+
runnerResultsByAgent.set(agent.aid, instances);
|
|
410
|
+
runnerSettledAgents.add(agent.aid);
|
|
411
|
+
startupRunnerInstances.set(agent.aid, instances);
|
|
412
|
+
bindStartupAgentChannels(agent, instances);
|
|
413
|
+
refreshLoadedBaseagents();
|
|
414
|
+
startupRunnerReadyResolvers.get(agent.aid)?.(instances);
|
|
415
|
+
resolveStartupOperation(agent.aid);
|
|
416
|
+
trace.addSpan('daemon.agentRunner', timing.startedAtMs, timing.completedAtMs, `aid=${agent.aid}; runners=${instances.map(instance => instance.baseagent).join(',') || 'none'}`);
|
|
417
|
+
logger.info(`[startup] Agent runners ready: aid=${agent.aid} runners=${instances.length}`
|
|
418
|
+
+ ` duration=${timing.completedAtMs - timing.startedAtMs}ms`);
|
|
419
|
+
},
|
|
420
|
+
}).then(result => {
|
|
421
|
+
if (result.runtimeError) {
|
|
422
|
+
agentRuntimeState = 'error';
|
|
423
|
+
agentRuntimeError = result.runtimeError;
|
|
424
|
+
}
|
|
425
|
+
logger.info(`[startup] Agent runner batch complete: agents=${startupAgents.length}`
|
|
426
|
+
+ ` runners=${agentMap.size} duration=${Date.now() - startupRunnersStartedAtMs}ms`);
|
|
427
|
+
trace.addSpan('daemon.agentRunners', startupRunnersStartedAtMs, Date.now(), `${startupAgents.length} 个 Agent; ${agentMap.size} 个 runner`);
|
|
428
|
+
return result;
|
|
429
|
+
});
|
|
430
|
+
void startupRunnersPromise.catch(error => {
|
|
431
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
432
|
+
agentRuntimeState = 'error';
|
|
433
|
+
agentRuntimeError = message;
|
|
434
|
+
logger.error(`[startup] Agent runner batch failed: ${message}`);
|
|
435
|
+
for (const agent of startupAgents) {
|
|
436
|
+
if (!startupRunnerInstances.has(agent.aid)) {
|
|
437
|
+
agent.status = 'error';
|
|
438
|
+
agent.error = message;
|
|
439
|
+
runnerSettledAgents.add(agent.aid);
|
|
440
|
+
runnerResultsByAgent.set(agent.aid, []);
|
|
441
|
+
startupRunnerReadyResolvers.get(agent.aid)?.([]);
|
|
442
|
+
resolveStartupOperation(agent.aid);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
347
446
|
// 交互路由器
|
|
348
447
|
const interactionRouter = new InteractionRouter();
|
|
349
448
|
const groupInviteReviewService = new GroupInviteReviewService(interactionRouter);
|
|
@@ -351,10 +450,6 @@ async function main() {
|
|
|
351
450
|
if (target === ConfigTarget.Agent && selector.self)
|
|
352
451
|
groupInviteReviewService.configurationChanged(selector.self);
|
|
353
452
|
});
|
|
354
|
-
// 为所有支持权限的 agent 设置 gateway
|
|
355
|
-
for (const inst of agentInstances) {
|
|
356
|
-
inst.agent.setPermissionGateway?.(permissionGateway);
|
|
357
|
-
}
|
|
358
453
|
// 创建消息缓存
|
|
359
454
|
trace.mark('daemon.messageCache');
|
|
360
455
|
const messageCache = new MessageCache();
|
|
@@ -369,10 +464,12 @@ async function main() {
|
|
|
369
464
|
await registerBuiltinChannelPlugins(channelLoader);
|
|
370
465
|
// Create channel instances: 每个 self-agent 各自的 channels
|
|
371
466
|
const evolagentInstances = [];
|
|
372
|
-
for (const agent of
|
|
467
|
+
for (const agent of startupAgents) {
|
|
373
468
|
try {
|
|
374
469
|
const instances = await channelLoader.createForAgent(agent);
|
|
470
|
+
channelInstancesByAgent.set(agent.aid, instances);
|
|
375
471
|
evolagentInstances.push(...instances);
|
|
472
|
+
bindStartupAgentChannels(agent, startupRunnerInstances.get(agent.aid) ?? []);
|
|
376
473
|
}
|
|
377
474
|
catch (e) {
|
|
378
475
|
logger.error(`[Agent ${agent.aid}] Failed to create channels: ${e}`);
|
|
@@ -430,10 +527,6 @@ async function main() {
|
|
|
430
527
|
}
|
|
431
528
|
});
|
|
432
529
|
onShutdown(() => { stopOwnerNotifications(); ownerResolver.stop(); });
|
|
433
|
-
const agentDelegationRegistry = new AgentDelegationRegistry();
|
|
434
|
-
// Replace any inherited marker from a parent/previous daemon before child
|
|
435
|
-
// runners or in-process IPC clients are created.
|
|
436
|
-
process.env[DAEMON_RUNTIME_EPOCH_ENV] = agentDelegationRegistry.getRuntimeEpoch();
|
|
437
530
|
// 创建命令处理器
|
|
438
531
|
const cmdHandler = new CommandHandler(sessionManager, agentMap, messageCache, eventBus, primaryRunnerKey);
|
|
439
532
|
cmdHandler.setAgentDelegationRegistry(agentDelegationRegistry);
|
|
@@ -456,6 +549,13 @@ async function main() {
|
|
|
456
549
|
}, primaryRunnerKey);
|
|
457
550
|
responseEngine.setAgentDelegationRegistry(agentDelegationRegistry);
|
|
458
551
|
const processor = responseEngine;
|
|
552
|
+
configureRunnerCallbacks = instance => {
|
|
553
|
+
instance.agent.setCompactStartCallback?.((sessionId) => {
|
|
554
|
+
processor.handleCompactStart(sessionId);
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
for (const inst of agentInstances)
|
|
558
|
+
configureRunnerCallbacks(inst);
|
|
459
559
|
responseEngine.setObserverHintConsumed((hint, target, meta) => {
|
|
460
560
|
const observerChannel = channelInstances.find(candidate => candidate.adapter.channelKey === target.channelKey
|
|
461
561
|
&& candidate.channelType === 'aun')?.channel;
|
|
@@ -477,14 +577,13 @@ async function main() {
|
|
|
477
577
|
}
|
|
478
578
|
// 设置交互路由器
|
|
479
579
|
processor.setInteractionRouter(interactionRouter);
|
|
480
|
-
// 设置 compact 开始回调(对所有支持的 agent)
|
|
481
|
-
for (const inst of agentInstances) {
|
|
482
|
-
inst.agent.setCompactStartCallback?.((sessionId) => {
|
|
483
|
-
processor.handleCompactStart(sessionId);
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
580
|
// 创建消息队列
|
|
487
581
|
const messageQueue = new MessageQueue(async (message) => {
|
|
582
|
+
const owner = message.selfAID || agentRegistry.resolveByChannel(message.channel)?.aid;
|
|
583
|
+
if (owner)
|
|
584
|
+
await startupRunnerReady.get(owner);
|
|
585
|
+
if (startupCancelled)
|
|
586
|
+
return;
|
|
488
587
|
await processor.processMessage(message);
|
|
489
588
|
}, {
|
|
490
589
|
persistencePath: daemonQueuePath(),
|
|
@@ -598,7 +697,7 @@ async function main() {
|
|
|
598
697
|
fs.chmodSync(resolvePaths().controlToken, 0o600);
|
|
599
698
|
}
|
|
600
699
|
catch { }
|
|
601
|
-
const triggerStartupAgents =
|
|
700
|
+
const triggerStartupAgents = startupAgents;
|
|
602
701
|
const controlAid = daemonCfg.aid || '__daemon__';
|
|
603
702
|
const daemonTriggerOwner = {
|
|
604
703
|
aid: triggerStartupAgents.some(agent => agent.aid === controlAid) ? `${controlAid}#daemon` : controlAid,
|
|
@@ -669,9 +768,17 @@ async function main() {
|
|
|
669
768
|
};
|
|
670
769
|
cmdHandler.setTriggerSchedulerResolver((agentAid) => triggerSchedulers.get(agentAid));
|
|
671
770
|
const ensureTriggerSchedulerStarted = async (agent) => {
|
|
771
|
+
await startupRunnerReady.get(agent.aid);
|
|
772
|
+
if (startupCancelled || agent.status === 'error' || agent.status === 'disabled')
|
|
773
|
+
return;
|
|
672
774
|
await triggerSchedulers.ensureStarted(agent.aid, () => startTriggerScheduler(agent));
|
|
673
775
|
};
|
|
674
776
|
const ensureDaemonTriggerSchedulerStarted = async () => {
|
|
777
|
+
const primaryRunners = primaryAgent ? await startupRunnerReady.get(primaryAgent.aid) : undefined;
|
|
778
|
+
if (startupCancelled)
|
|
779
|
+
return;
|
|
780
|
+
if (primaryAgent && (!primaryRunners?.length || primaryAgent.status === 'error'))
|
|
781
|
+
return;
|
|
675
782
|
await triggerSchedulers.ensureStarted(daemonTriggerOwner.aid, () => startTriggerScheduler(daemonTriggerOwner, { seedUpgradeCheck: true }));
|
|
676
783
|
};
|
|
677
784
|
const defaultPolicy = createDefaultChannelPolicy();
|
|
@@ -736,9 +843,18 @@ async function main() {
|
|
|
736
843
|
for (const inst of channelInstances) {
|
|
737
844
|
registerChannelInstance(inst);
|
|
738
845
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
846
|
+
startupChannelsRegistered = true;
|
|
847
|
+
for (const aid of startupRunnerReady.keys())
|
|
848
|
+
resolveStartupOperation(aid);
|
|
849
|
+
const startupAgentRuntimePromise = startupRunnersPromise.then(async (result) => {
|
|
850
|
+
if (startupCancelled)
|
|
851
|
+
return;
|
|
852
|
+
({ state: agentRuntimeState, error: agentRuntimeError } = await completeStartupAgentRuntime(agentRegistry, { state: agentRuntimeState, error: result.runtimeError ?? agentRuntimeError }));
|
|
853
|
+
}).catch(error => {
|
|
854
|
+
agentRuntimeState = 'error';
|
|
855
|
+
agentRuntimeError = error instanceof Error ? error.message : String(error);
|
|
856
|
+
logger.error(`[startup] Agent runtime initialization failed: ${agentRuntimeError}`);
|
|
857
|
+
});
|
|
742
858
|
// ── 配置快照 + 启动日志(启动完毕锚点,网络无关)──────────────────
|
|
743
859
|
trace.mark('daemon.startupConfigRecord');
|
|
744
860
|
recordStartupConfig(configSnapshotsEnabled);
|
|
@@ -763,6 +879,11 @@ async function main() {
|
|
|
763
879
|
// handoff 启动恢复是否还在收集 hint。与"队列是否已放行"是两件事:
|
|
764
880
|
// 队列有超时兜底会提前放行,而恢复可能还在等渠道。
|
|
765
881
|
let startupRecoveryPending = true;
|
|
882
|
+
// AUN 上下线系统提示(volatile)。系统行为,无配置开关。
|
|
883
|
+
const lifecycleNotices = createLifecycleNoticeService({
|
|
884
|
+
channelInstances,
|
|
885
|
+
resolveAgent: (channelKey, channelName) => agentRegistry.resolveByChannel(channelKey) ?? agentRegistry.resolveByChannel(channelName),
|
|
886
|
+
});
|
|
766
887
|
const { markChannelConnected, unregisterRuntimeChannel, queuePendingObserverHints } = createChannelConnectionRuntime({
|
|
767
888
|
...channelRuntimeDependencies,
|
|
768
889
|
channelInstances,
|
|
@@ -770,6 +891,7 @@ async function main() {
|
|
|
770
891
|
bootstrapService,
|
|
771
892
|
ensureTriggerSchedulerStarted,
|
|
772
893
|
sendOnlineNoticeForChannel,
|
|
894
|
+
sendLifecycleNoticeForChannel: instance => lifecycleNotices.online(instance),
|
|
773
895
|
trySendPendingRestartNotice,
|
|
774
896
|
sessionsDir: paths.sessionsDir,
|
|
775
897
|
startupObserverRecoveries,
|
|
@@ -791,7 +913,8 @@ async function main() {
|
|
|
791
913
|
let pendingShutdownReason;
|
|
792
914
|
let pendingShutdownTraceId;
|
|
793
915
|
trace.mark('daemon.baseagentProbe');
|
|
794
|
-
|
|
916
|
+
baseagentSnapshot = await baseagentSnapshotPromise;
|
|
917
|
+
refreshLoadedBaseagents();
|
|
795
918
|
const getStatusSnapshot = () => {
|
|
796
919
|
const now = Date.now();
|
|
797
920
|
const todayStart = new Date(new Date(now).getFullYear(), new Date(now).getMonth(), new Date(now).getDate()).getTime();
|
|
@@ -900,6 +1023,7 @@ async function main() {
|
|
|
900
1023
|
aidStatsCollector,
|
|
901
1024
|
handoffRuntime,
|
|
902
1025
|
messageQueue,
|
|
1026
|
+
awaitStartupAgent: async (aid) => { await startupOperationReady.get(aid); },
|
|
903
1027
|
});
|
|
904
1028
|
registerRelationConsolidationEvents({ eventBus, agentRegistry, responseEngine, enqueueConsolidation });
|
|
905
1029
|
globalThis.__evolcore_reloadHooks = reloadHooks;
|
|
@@ -925,8 +1049,18 @@ async function main() {
|
|
|
925
1049
|
setAgentRuntimeState: state => { agentRuntimeState = state; },
|
|
926
1050
|
setAgentRuntimeError: error => { agentRuntimeError = error; },
|
|
927
1051
|
});
|
|
928
|
-
globalThis.__evolcore_hotLoadAgent =
|
|
929
|
-
|
|
1052
|
+
globalThis.__evolcore_hotLoadAgent = async (aid) => {
|
|
1053
|
+
await startupRunnerReady.get(aid);
|
|
1054
|
+
if (startupCancelled)
|
|
1055
|
+
throw new Error('Daemon is shutting down');
|
|
1056
|
+
return agentRuntimeOperations.hotLoad(aid);
|
|
1057
|
+
};
|
|
1058
|
+
globalThis.__evolcore_resyncAgents = async () => {
|
|
1059
|
+
await Promise.all(startupRunnerReady.values());
|
|
1060
|
+
if (startupCancelled)
|
|
1061
|
+
throw new Error('Daemon is shutting down');
|
|
1062
|
+
return agentRuntimeOperations.resync();
|
|
1063
|
+
};
|
|
930
1064
|
const coreHotLoadAgent = async (aid) => {
|
|
931
1065
|
const hotLoad = globalThis.__evolcore_hotLoadAgent;
|
|
932
1066
|
if (typeof hotLoad !== 'function')
|
|
@@ -961,6 +1095,12 @@ async function main() {
|
|
|
961
1095
|
return state ? [state] : [];
|
|
962
1096
|
}),
|
|
963
1097
|
aunAidStats: () => aidStatsCollector.getAllSnapshots(),
|
|
1098
|
+
beforeAgentOperation: async (aid) => {
|
|
1099
|
+
if (aid)
|
|
1100
|
+
await startupOperationReady.get(aid);
|
|
1101
|
+
else
|
|
1102
|
+
await Promise.all(startupOperationReady.values());
|
|
1103
|
+
},
|
|
964
1104
|
});
|
|
965
1105
|
const agentInitializationService = createAgentInitializationRuntime({
|
|
966
1106
|
agentRegistry,
|
|
@@ -1049,6 +1189,27 @@ async function main() {
|
|
|
1049
1189
|
logger.info(`🚀 EvolCore core is ready; connecting ${channelInstances.length} channel(s) in background`);
|
|
1050
1190
|
const connectAllPromise = channelLoader.connectAll(channelInstances, {
|
|
1051
1191
|
concurrency: 10,
|
|
1192
|
+
beforeConnect: async (instance) => {
|
|
1193
|
+
const owner = agentRegistry.resolveByChannel(instance.adapter.channelKey)
|
|
1194
|
+
?? agentRegistry.resolveByChannel(instance.adapter.channelName);
|
|
1195
|
+
if (!owner)
|
|
1196
|
+
return !startupCancelled;
|
|
1197
|
+
const readiness = startupRunnerReady.get(owner.aid);
|
|
1198
|
+
if (!readiness)
|
|
1199
|
+
return false;
|
|
1200
|
+
const runners = await readiness;
|
|
1201
|
+
if (startupCancelled || runners.length === 0 || owner.status === 'error' || owner.status === 'disabled')
|
|
1202
|
+
return false;
|
|
1203
|
+
bindStartupAgentChannels(owner, runners);
|
|
1204
|
+
return true;
|
|
1205
|
+
},
|
|
1206
|
+
shouldConnect: instance => {
|
|
1207
|
+
if (startupCancelled || !channelInstances.includes(instance))
|
|
1208
|
+
return false;
|
|
1209
|
+
const owner = agentRegistry.resolveByChannel(instance.adapter.channelKey)
|
|
1210
|
+
?? agentRegistry.resolveByChannel(instance.adapter.channelName);
|
|
1211
|
+
return !owner || owner.status === 'running';
|
|
1212
|
+
},
|
|
1052
1213
|
onConnected: markChannelConnected,
|
|
1053
1214
|
onFailed: (inst, error) => {
|
|
1054
1215
|
logger.warn(`[startup] ${inst.adapter.channelName} initial connect failed: ${error}`);
|
|
@@ -1193,13 +1354,11 @@ async function main() {
|
|
|
1193
1354
|
startRestoredQueue: () => messageQueue.startRestored(),
|
|
1194
1355
|
}).catch(error => logger.error('[Queue] restored queue release failed:', error));
|
|
1195
1356
|
trace.mark('daemon.resumeSessions');
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
droppedTriggerSessionIds,
|
|
1200
|
-
|
|
1201
|
-
agentMap,
|
|
1202
|
-
});
|
|
1357
|
+
void startupRunnersPromise.then(() => {
|
|
1358
|
+
if (startupCancelled)
|
|
1359
|
+
return;
|
|
1360
|
+
resumePendingSessions({ sessionManager, messageQueue, droppedTriggerSessionIds, agentRegistry, agentMap });
|
|
1361
|
+
}).catch(error => logger.error(`[Resume] startup runner gate failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
1203
1362
|
trace.mark('daemon.cpuTracking');
|
|
1204
1363
|
ipcServer.startCpuTracking();
|
|
1205
1364
|
// IPC was bound before channel connection. At this point all handlers are
|
|
@@ -1230,6 +1389,10 @@ async function main() {
|
|
|
1230
1389
|
// 显式触发更可控。
|
|
1231
1390
|
shutdown = createDaemonShutdown({
|
|
1232
1391
|
disposePluginResources: () => daemonPluginLifecycle.dispose(),
|
|
1392
|
+
lifecycleNotices: {
|
|
1393
|
+
beginShutdown: () => lifecycleNotices.beginShutdown(),
|
|
1394
|
+
sendOffline: signal => lifecycleNotices.sendOffline(signal),
|
|
1395
|
+
},
|
|
1233
1396
|
ipcServer,
|
|
1234
1397
|
readySignalPath,
|
|
1235
1398
|
bindService,
|
|
@@ -1245,6 +1408,14 @@ async function main() {
|
|
|
1245
1408
|
groupInviteReviewService,
|
|
1246
1409
|
channelLoader,
|
|
1247
1410
|
channelInstances,
|
|
1411
|
+
startupRunners: Promise.allSettled([startupRunnersPromise, startupAgentRuntimePromise]),
|
|
1412
|
+
cancelStartup: () => {
|
|
1413
|
+
startupCancelled = true;
|
|
1414
|
+
for (const aid of startupRunnerReady.keys()) {
|
|
1415
|
+
startupRunnerReadyResolvers.get(aid)?.([]);
|
|
1416
|
+
startupOperationReadyResolvers.get(aid)?.([]);
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1248
1419
|
controlChannel,
|
|
1249
1420
|
sessionManager,
|
|
1250
1421
|
removeAll,
|
package/dist/paths.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
|
-
import { DAEMON_CONFIG_FILENAME, DEFAULT_RUNTIME_HOME_DIRNAME, INSTANCE_SOCKET_FILENAME, RUNTIME_HOME_ENV, WINDOWS_PIPE_PREFIX, } from './product.js';
|
|
5
|
+
import { DAEMON_CONFIG_FILENAME, DEFAULT_RUNTIME_HOME_DIRNAME, INSTANCE_SOCKET_FILENAME, RUNTIME_HOME_ENV, TEST_TMPDIR_ENV, WINDOWS_PIPE_PREFIX, } from './product.js';
|
|
6
6
|
import { migrateLegacyAgentJsonlLogs } from './core/audit/log-integrity.js';
|
|
7
7
|
const isWindows = process.platform === 'win32';
|
|
8
8
|
let _root = null;
|
|
@@ -12,7 +12,9 @@ export function resolveRoot() {
|
|
|
12
12
|
// than falling back to the developer's live runtime directory.
|
|
13
13
|
if (process.env.EVOLCORE_TEST === '1') {
|
|
14
14
|
const testRoot = process.env[RUNTIME_HOME_ENV] || process.env.EVOLCORE_TEST_ROOT;
|
|
15
|
-
|
|
15
|
+
// Managed children narrow TMPDIR to their session directory. The test
|
|
16
|
+
// harness retains the original boundary across that deliberate change.
|
|
17
|
+
const tempDir = process.env[TEST_TMPDIR_ENV] || process.env.TMPDIR;
|
|
16
18
|
if (!testRoot || !path.isAbsolute(testRoot) || !tempDir || !path.isAbsolute(tempDir)) {
|
|
17
19
|
throw new Error('Test runtime requires an absolute isolated root inside TMPDIR');
|
|
18
20
|
}
|
package/dist/product.js
CHANGED
|
@@ -16,6 +16,7 @@ export const MIN_ECWEB_VERSION = '0.0.8';
|
|
|
16
16
|
export const DAEMON_CONFIG_FILENAME = 'daemon.json';
|
|
17
17
|
export const DAEMON_SCHEMA_NAME = 'daemon';
|
|
18
18
|
export const RUNTIME_HOME_ENV = 'EVOLCORE_HOME';
|
|
19
|
+
export const TEST_TMPDIR_ENV = 'EVOLCORE_TEST_TMPDIR';
|
|
19
20
|
export const TARGET_PACKAGE_ROOT_ENV = 'EVOLCORE_TARGET_PACKAGE_ROOT';
|
|
20
21
|
export const SESSION_ID_ENV = 'EVOLCORE_SESSION_ID';
|
|
21
22
|
export const SELF_AID_ENV = 'EVOLCORE_SELF_AID';
|