evolcore 0.0.48 → 0.0.50
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 +97 -0
- package/bin/ecmsg.js +9 -4
- package/dist/ability/caller/authorization.js +21 -0
- package/dist/ability/caller/command.js +164 -0
- package/dist/ability/caller/contract.js +102 -0
- package/dist/ability/caller/daemon.js +158 -0
- package/dist/ability/caller/service.js +380 -0
- package/dist/ability/command-contract.js +5 -0
- package/dist/ability/daemon.js +5 -1
- package/dist/ability/interop-v1.js +10 -3
- package/dist/ability/management.js +1 -0
- package/dist/agent-template/jobs.js +173 -1
- package/dist/agent-template/runtime.js +285 -8
- package/dist/agent-template/service.js +1159 -40
- package/dist/agent-template/types.js +2 -1
- package/dist/agents/baseagent-availability.js +27 -3
- package/dist/agents/baseagent-capability-adapter.js +102 -0
- package/dist/agents/baseagent-plugin-descriptor.js +274 -0
- package/dist/agents/baseagent-plugin-loader.js +145 -0
- package/dist/agents/baseagent.js +68 -2
- package/dist/agents/claude-gateway/agent-registration.js +389 -0
- package/dist/agents/claude-gateway/binding.js +96 -0
- package/dist/agents/claude-gateway/inbox.js +138 -0
- package/dist/agents/claude-gateway/index.js +125 -0
- package/dist/agents/claude-gateway/listing.js +330 -0
- package/dist/agents/claude-gateway/router.js +328 -0
- package/dist/agents/claude-gateway/sessions.js +128 -0
- package/dist/agents/claude-gateway/terminal.js +250 -0
- package/dist/agents/claude-gateway/transcript.js +272 -0
- package/dist/agents/claude-gateway/types.js +14 -0
- package/dist/agents/claude-runner.js +6 -10
- package/dist/agents/codex-runner.js +9 -2
- package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
- package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
- package/dist/agents/gemini/index.js +51 -0
- package/dist/aun/aid/control-aid.js +52 -32
- package/dist/aun/group/invite-service.js +6 -36
- package/dist/aun/group/operations.js +6 -0
- package/dist/aun/msg/mention-schema.js +1 -1
- package/dist/aun/msg/p2p.js +31 -2
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +1175 -457
- package/dist/cli/ability-command.js +42 -0
- package/dist/cli/agent-command.js +20 -1
- package/dist/cli/agent-create.js +78 -18
- package/dist/cli/agent-template.js +5 -3
- package/dist/cli/agent.js +91 -0
- package/dist/cli/aun-commands.js +92 -34
- package/dist/cli/bench.js +5 -2
- package/dist/cli/config.js +22 -6
- package/dist/cli/daemon-commands.js +245 -101
- package/dist/cli/directory.js +6 -1
- package/dist/cli/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +30 -5
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +3 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/model.js +20 -5
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/quota.js +89 -0
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/role.js +1 -0
- package/dist/cli/services-command.js +12 -9
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +88 -9
- package/dist/config/config-manager.js +97 -47
- package/dist/config/config-operation-service.js +22 -1
- package/dist/config/gateway-config.js +9 -8
- package/dist/config/owner-config.js +0 -16
- package/dist/config/peer-role-resolver.js +1 -7
- package/dist/config/providers-config.js +107 -20
- package/dist/config/providers-management.js +45 -21
- package/dist/config/resolved-config-op.js +4 -44
- package/dist/config/schema-migration.js +78 -5
- package/dist/config/schema-registry.js +52 -7
- package/dist/config-store.js +1309 -17
- package/dist/core/agent-application-service.js +220 -1
- package/dist/core/agent-ipc-registration.js +19 -2
- package/dist/core/agent-reload-coordinator.js +5 -0
- package/dist/core/agent-runtime.js +198 -54
- package/dist/core/auth/agent-delegation.js +14 -0
- package/dist/core/auth/delegation-authorization.js +33 -26
- package/dist/core/auth/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +59 -7
- package/dist/core/baseagent-loader.js +30 -3
- package/dist/core/capability/capability-manager.js +16 -7
- package/dist/core/channel-runtime.js +4 -2
- package/dist/core/command/agent-control.js +20 -2
- package/dist/core/command/agent-template-menu.js +4 -3
- package/dist/core/command/cli-intent-parser.js +28 -0
- package/dist/core/command/command-handler.js +45 -2
- package/dist/core/command/menu-catalog.js +20 -4
- package/dist/core/command/menu-file-path.js +70 -0
- package/dist/core/command/menu-handler.js +97 -73
- package/dist/core/command/menu-protocol.js +29 -0
- package/dist/core/command/menu-query-batch.js +2 -2
- package/dist/core/command/private-mention-menu.js +71 -0
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/slash-handler.js +17 -26
- package/dist/core/command/team-workspace-bootstrap.js +2 -1
- package/dist/core/command/topic-slash.js +7 -1
- package/dist/core/daemon-bootstrap.js +0 -4
- package/dist/core/daemon-control.js +58 -1
- package/dist/core/daemon-lifecycle.js +29 -7
- package/dist/core/evolagent-registry.js +18 -9
- package/dist/core/handoff/runtime.js +1 -1
- package/dist/core/host-snapshot.js +8 -3
- package/dist/core/initialization/service.js +3 -0
- package/dist/core/interaction-router.js +130 -0
- package/dist/core/ipc-registration.js +5 -0
- package/dist/core/memory/consolidation-context.js +2 -1
- package/dist/core/memory/consolidation.js +35 -64
- package/dist/core/message/aun-ipc-sender.js +213 -74
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +40 -1
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +197 -45
- package/dist/core/message/message-log.js +32 -0
- package/dist/core/message/message-queue.js +102 -18
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +174 -26
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +7 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +288 -77
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +458 -0
- package/dist/core/permission/tool-policy.js +26 -10
- package/dist/core/relation/peer-identity.js +13 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
- package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
- package/dist/core/session/session-manager.js +47 -10
- package/dist/core/session/session-mapper.js +16 -0
- package/dist/core/skill/index-generator.js +2 -3
- package/dist/core/skill/switch-resolver.js +3 -0
- package/dist/core/task/task-recovery-service.js +1 -0
- package/dist/core/thread/command-parser.js +4 -1
- package/dist/core/thread/ipc-operation.js +4 -2
- package/dist/core/thread/thread-operation.js +25 -10
- package/dist/core/thread/thread-service.js +294 -55
- package/dist/core/thread/topic-id.js +67 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/directory/owner-directory-admission.js +11 -8
- package/dist/directory/owner-directory-cache.js +19 -0
- package/dist/directory/owner-directory-markdown.js +1 -1
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +3 -2
- package/dist/eck/message-renderer.js +28 -5
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/ecweb/runtime/supervisor.js +36 -8
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +20 -5
- package/dist/event-center/runtime.js +10 -7
- package/dist/index.js +120 -41
- package/dist/ipc.js +83 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +3 -2
- package/dist/outputs/protocol.js +1 -0
- package/dist/outputs/service.js +2 -15
- package/dist/paths.js +48 -1
- package/dist/pay/command.js +38 -0
- package/dist/pay/protocol.js +136 -0
- package/dist/pay/runtime.js +188 -0
- package/dist/pay/service.js +384 -0
- package/dist/pay/store.js +81 -0
- package/dist/response-system/engines/v1/proactive-flow.js +29 -2
- package/dist/services/dispatcher.js +23 -5
- package/dist/services/host/main.js +388 -0
- package/dist/services/host/protocol.js +118 -0
- package/dist/services/host/resident.js +310 -0
- package/dist/services/host-client.js +386 -0
- package/dist/services/host-deploy.js +180 -0
- package/dist/services/host-launch.js +117 -0
- package/dist/services/host-recycle.js +203 -0
- package/dist/services/host-runtime.js +802 -0
- package/dist/services/idempotency.js +44 -86
- package/dist/services/index-generator.js +4 -3
- package/dist/services/index.js +204 -22
- package/dist/services/ipc-operation.js +288 -44
- package/dist/services/pack-manager.js +1 -0
- package/dist/services/script-runner.js +515 -83
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +109 -4
- package/dist/stats/budget.js +1 -1
- package/dist/stats/model-resolver.js +2 -2
- package/dist/stats/quota-query.js +95 -0
- package/dist/trigger/application-service.js +6 -4
- package/dist/trigger/local-files.js +19 -9
- package/dist/trigger/scheduler.js +22 -12
- package/dist/trigger/script-sandbox.js +51 -8
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +173 -1
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/restart-safety.js +14 -1
- package/dist/utils/system-memory.js +113 -25
- package/dist/utils/systemd-lifecycle.js +154 -0
- package/dist/utils/windows-shell-trust.js +7 -3
- package/dist/workbench/service.js +1 -1
- package/kits/docs/INDEX.md +3 -2
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/evolcore/INDEX.md +9 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +45 -3
- package/kits/docs/evolcore/config.md +5 -2
- package/kits/docs/evolcore/directory.md +8 -9
- package/kits/docs/evolcore/group.md +2 -1
- package/kits/docs/evolcore/memory-tags.md +2 -0
- package/kits/docs/evolcore/menu-client.md +3 -3
- package/kits/docs/evolcore/menu-protocol.md +7 -0
- package/kits/docs/evolcore/model.md +3 -0
- package/kits/docs/evolcore/msg.md +77 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +22 -1
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +3 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -0
- package/kits/docs/evolcore/trigger.md +2 -0
- package/kits/rules/01-overview.md +11 -32
- package/kits/rules/02-navigation.md +7 -0
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +38 -5
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/agent-config.schema.21.json +974 -0
- package/kits/schemas/agent-config.schema.22.json +977 -0
- package/kits/schemas/agent-config.schema.23.json +958 -0
- package/kits/schemas/daemon.schema.10.json +373 -0
- package/kits/schemas/daemon.schema.9.json +12 -0
- package/kits/schemas/defaults.schema.7.json +472 -0
- package/kits/schemas/providers.schema.3.json +18 -2
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/skills/.switches.json +17 -1
- package/kits/skills/ability/SKILL.md +229 -34
- package/kits/skills/ability/STRUCTURE.md +333 -0
- package/kits/skills/ability/references/cli.md +208 -0
- package/kits/skills/ability/references/development.md +107 -37
- package/kits/skills/ability/references/management.md +106 -46
- package/kits/skills/ability/references/runtime-protocol.md +65 -63
- package/kits/skills/agent-output-cards/SKILL.md +64 -0
- package/kits/skills/ec-group/SKILL.md +8 -6
- package/kits/skills/ec-group/TASK.md +186 -0
- package/kits/skills/ec-group/WORKLOG.md +180 -0
- package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
- package/kits/skills/ec-pay/SKILL.md +101 -0
- package/kits/skills/ec-pay/references/pay-cli.md +110 -0
- package/kits/skills/ec-provider/SKILL.md +58 -9
- package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
- package/kits/skills/ec-service-call/SKILL.md +135 -0
- package/kits/skills/ec-service-pack/SKILL.md +277 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/workflow.md +46 -0
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +27 -128
- package/kits/templates/system-fragments/venue.md +27 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +79 -29
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +24 -6
- package/scripts/agent-template/shared/team-schema.json +23 -5
- package/scripts/agent-template/shared/template-contract.mjs +107 -17
- package/scripts/agent-template/shared/template-package.mjs +254 -29
- package/scripts/agent-template/shared/template-runtime.mjs +145 -2
- package/scripts/agent-template/shared/template.mjs +67 -9
- package/scripts/agent-template/team-pack.mjs +132 -41
- package/scripts/agent-template/team-preview.mjs +249 -5
- package/kits/docs/aun/ABILITY_CALLING.md +0 -280
- package/kits/docs/evolcore/ability.md +0 -185
- package/kits/skills/ability/references/calling.md +0 -56
- package/kits/skills/ability/references/contract-checklist.md +0 -37
- package/kits/skills/ability/references/recovery.md +0 -27
- /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
|
@@ -40,6 +40,21 @@ export class EventCenterRegistry {
|
|
|
40
40
|
scanLedgerSigs = new Map();
|
|
41
41
|
/** reload 串行队列:aid → 队尾 promise。 */
|
|
42
42
|
reloadQueues = new Map();
|
|
43
|
+
mutationPauses = new Map();
|
|
44
|
+
/** Freeze handler starts without replacing the Agent's AUN connection or Bus lease. */
|
|
45
|
+
pauseForMutation(aid, token) {
|
|
46
|
+
if (this.units.get(aid)?.dispatcher.isBusy()) {
|
|
47
|
+
throw Object.assign(new Error('Agent event handlers are busy: ' + aid), { code: 'AGENT_BUSY' });
|
|
48
|
+
}
|
|
49
|
+
const tokens = this.mutationPauses.get(aid) ?? new Set();
|
|
50
|
+
tokens.add(token);
|
|
51
|
+
this.mutationPauses.set(aid, tokens);
|
|
52
|
+
return () => {
|
|
53
|
+
tokens.delete(token);
|
|
54
|
+
if (!tokens.size && this.mutationPauses.get(aid) === tokens)
|
|
55
|
+
this.mutationPauses.delete(aid);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
43
58
|
/** 签名未变则跳过 append。 */
|
|
44
59
|
ledgerOnce(aid, key, sig, append) {
|
|
45
60
|
let sigs = this.scanLedgerSigs.get(aid);
|
|
@@ -67,12 +82,12 @@ export class EventCenterRegistry {
|
|
|
67
82
|
}
|
|
68
83
|
/** Publish a fixed event from an internal read-only projection when configured. */
|
|
69
84
|
async publishAgentEvent(aid, event, data) {
|
|
70
|
-
if (event !== 'team.outputs.changed' && event !== 'team.workbench.changed')
|
|
71
|
-
return;
|
|
85
|
+
if (event !== 'team.outputs.changed' && event !== 'team.output-cards.changed' && event !== 'team.workbench.changed')
|
|
86
|
+
return false;
|
|
72
87
|
const unit = this.units.get(aid);
|
|
73
88
|
if (!unit)
|
|
74
|
-
return;
|
|
75
|
-
|
|
89
|
+
return false;
|
|
90
|
+
return unit.runtime.publishNativeProjection(event, data);
|
|
76
91
|
}
|
|
77
92
|
ensureStarted(aid) {
|
|
78
93
|
const existing = this.starts.get(aid);
|
|
@@ -349,7 +364,7 @@ export class EventCenterRegistry {
|
|
|
349
364
|
}
|
|
350
365
|
},
|
|
351
366
|
});
|
|
352
|
-
const dispatcher = new EventDispatcher(scriptRunner);
|
|
367
|
+
const dispatcher = new EventDispatcher(scriptRunner, undefined, () => !this.mutationPauses.get(aid)?.size);
|
|
353
368
|
const runtime = new EventRuntime({
|
|
354
369
|
aid,
|
|
355
370
|
getClient: this.options.getClient,
|
|
@@ -105,27 +105,29 @@ export class EventRuntime {
|
|
|
105
105
|
}
|
|
106
106
|
async publishNativeProjection(event, data) {
|
|
107
107
|
if (!PRIVATE_PROJECTION_EVENTS.some(value => value === event))
|
|
108
|
-
return;
|
|
108
|
+
return false;
|
|
109
109
|
if (!this.nativeOutputAvailable)
|
|
110
|
-
return;
|
|
110
|
+
return false;
|
|
111
111
|
this.nativeOutputPending.set(event, data);
|
|
112
112
|
if (this.nativeOutputFlight)
|
|
113
113
|
return this.nativeOutputFlight;
|
|
114
114
|
this.nativeOutputFlight = (async () => {
|
|
115
115
|
// Bound a burst to one in-flight notification and one latest invalidation.
|
|
116
|
-
while (this.nativeOutputPending.size
|
|
116
|
+
while (this.nativeOutputPending.size) {
|
|
117
|
+
if (!this.nativeOutputAvailable)
|
|
118
|
+
return false;
|
|
117
119
|
const [event, latest] = this.nativeOutputPending.entries().next().value;
|
|
118
120
|
this.nativeOutputPending.delete(event);
|
|
119
121
|
const handle = await this.ensureClient();
|
|
120
122
|
if (!handle || !this.nativeOutputAvailable)
|
|
121
|
-
return;
|
|
123
|
+
return false;
|
|
122
124
|
const owner = await ownerResolver.refresh(this.options.aid, { source: 'outputs.publish',
|
|
123
125
|
maxAgeMs: OWNERSHIP_AUTHORIZATION_MAX_AGE_MS, allowTransient: false });
|
|
124
126
|
if (!await this.rematerialize())
|
|
125
|
-
return;
|
|
127
|
+
return false;
|
|
126
128
|
if (owner.authorizationStatus !== 'verified' || owner.refreshFailure?.fallbackUsed
|
|
127
129
|
|| (owner.validUntil ?? 0) <= Date.now() || !this.nativeOutputAvailable)
|
|
128
|
-
return;
|
|
130
|
+
return false;
|
|
129
131
|
const events = new Set([...PRIVATE_PROJECTION_EVENTS, ...(this.registeredPubBuses.get(this.options.aid) ?? [])]);
|
|
130
132
|
if (this.nativeOutputPublisher !== handle || PRIVATE_PROJECTION_EVENTS.some(value => !this.registeredPubBuses.get(this.options.aid)?.has(value))) {
|
|
131
133
|
await handle.EventService.authorize(this.options.aid, 'pub', 'allowlist', [...events]);
|
|
@@ -136,9 +138,10 @@ export class EventRuntime {
|
|
|
136
138
|
if (currentOwner.authorizationStatus !== 'verified' || currentOwner.refreshFailure?.fallbackUsed
|
|
137
139
|
|| (currentOwner.validUntil ?? 0) <= Date.now() || currentOwner.ownerAid !== owner.ownerAid
|
|
138
140
|
|| currentOwner.revision !== owner.revision || !this.nativeOutputAvailable)
|
|
139
|
-
return;
|
|
141
|
+
return false;
|
|
140
142
|
await handle.EventService.publish(this.options.aid, event, latest, { ttlSeconds: 30, schemaVersion: 1 });
|
|
141
143
|
}
|
|
144
|
+
return true;
|
|
142
145
|
})().finally(() => { this.nativeOutputFlight = undefined; this.nativeOutputPending.clear(); });
|
|
143
146
|
return this.nativeOutputFlight;
|
|
144
147
|
}
|
package/dist/index.js
CHANGED
|
@@ -12,14 +12,15 @@ catch {
|
|
|
12
12
|
}
|
|
13
13
|
import { ClaudeSessionFileAdapter } from './core/session/adapters/claude-session-file-adapter.js';
|
|
14
14
|
import { CodexSessionFileAdapter } from './core/session/adapters/codex-session-file-adapter.js';
|
|
15
|
-
import { GeminiSessionFileAdapter } from './core/session/adapters/gemini-session-file-adapter.js';
|
|
16
15
|
import { EcagentSessionFileAdapter } from './core/session/adapters/ecagent-session-file-adapter.js';
|
|
17
16
|
import { loadDefaults, loadAllAgents, migrateIdentitiesIfNeeded, loadDaemonConfig, initializeEckSnapshotsConfig } from './config-store.js';
|
|
17
|
+
import { discoverBaseagentPlugins, loadExternalBaseagentPlugins } from './agents/baseagent-plugin-loader.js';
|
|
18
|
+
import { getCcAgentAid } from './agents/claude-gateway/agent-registration.js';
|
|
18
19
|
import { RoleQuotaQuestions } from './config/role-command-service.js';
|
|
19
20
|
import { inspectClaudeSandboxDependencies, formatClaudeSandboxDependencies } from './core/permission/sandbox-runtime.js';
|
|
20
21
|
import { migrateRelationSharedDirectories } from './core/relation/shared-data.js';
|
|
21
22
|
import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode } from './config/daemon-services.js';
|
|
22
|
-
import { ConfigTarget,
|
|
23
|
+
import { ConfigTarget, onConfigWrite, } from './config/config-manager.js';
|
|
23
24
|
import { createSessionIdentityResolver } from './config/peer-role-resolver.js';
|
|
24
25
|
import { initializeStartupConfig, prepareStartupConfig, recordStartupConfig } from './config/boot-log.js';
|
|
25
26
|
import { CONFIG_SCHEMA_VERSION } from './types.js';
|
|
@@ -27,7 +28,6 @@ import { SessionManager } from './core/session/session-manager.js';
|
|
|
27
28
|
import { SessionIdleMonitor, readSessionLoopIdleSeconds } from './core/session/session-idle-monitor.js';
|
|
28
29
|
import { ClaudeAgentPlugin } from './agents/claude-runner.js';
|
|
29
30
|
import { CodexAgentPlugin } from './agents/codex-runner.js';
|
|
30
|
-
import { GeminiAgentPlugin } from './agents/gemini-runner.js';
|
|
31
31
|
// 不要静态导入 ecagent-runner:它连带整个 ecagent 运行时(typebox 占了模块图
|
|
32
32
|
// 三分之一的 resolve),而绝大多数部署并不使用 ecagent。这里用懒加载外壳。
|
|
33
33
|
import { EcagentAgentPluginLazy } from './agents/ecagent-plugin-lazy.js';
|
|
@@ -44,6 +44,7 @@ import { readFastaunVersion, readInstalledEvolcoreVersion, createEvolcoreStartup
|
|
|
44
44
|
import { recoverAllRoleMutationsSync } from './core/command/role-menu.js';
|
|
45
45
|
import { HandoffRuntime } from './core/handoff/runtime.js';
|
|
46
46
|
import { startDaemonControlAid } from './core/daemon-control.js';
|
|
47
|
+
import { completeSystemdRestart } from './utils/systemd-lifecycle.js';
|
|
47
48
|
import { createDelegationAuthorizer } from './core/auth/delegation-authorization.js';
|
|
48
49
|
import { registerProxyIpcExecutor } from './proxy/ipc-service.js';
|
|
49
50
|
import { readServiceProxySnapshot } from './proxy/manager.js';
|
|
@@ -79,7 +80,7 @@ import { PluginHandle } from './core/plugin-lifecycle.js';
|
|
|
79
80
|
import { EvolAgentRegistry } from './core/evolagent-registry.js';
|
|
80
81
|
import { createAgentInitializationRuntime, createOnDemandAgentRunners, createAgentReloadRuntime, createAgentRuntimeOperations, createStartupAgentRunners, completeStartupAgentRuntime, bindAgentCreationOwner, loadStartupAgentRegistry, recoverIncompleteAgentInitializations, } from './core/agent-runtime.js';
|
|
81
82
|
import { IpcServer } from './ipc.js';
|
|
82
|
-
import { installChannelSdkConsoleFilter, logger,
|
|
83
|
+
import { installChannelSdkConsoleFilter, logger, setChannelLogsEnabled, setLogLevel } from './utils/logger.js';
|
|
83
84
|
import { StartupTracer, startRequestedStartupCpuProfile } from './utils/startup-trace.js';
|
|
84
85
|
import { DiagService } from './core/command/diag-service.js';
|
|
85
86
|
import { createEcwebSupervisor } from './ecweb/runtime/supervisor.js';
|
|
@@ -93,6 +94,7 @@ import { TargetSessionLockRegistry } from './trigger/session-lock.js';
|
|
|
93
94
|
import { buildTriggerScheduler, createTriggerChannelResolver, TriggerSchedulerRegistry } from './trigger/application-service.js';
|
|
94
95
|
import { createDaemonEventCenter } from './event-center/daemon.js';
|
|
95
96
|
import { setOutputChangePublisher } from './outputs/service.js';
|
|
97
|
+
import { setOutputCardsNotificationsAvailable } from './outputs/cards.js';
|
|
96
98
|
import { setWorkbenchChangePublisher, setWorkbenchRuntimeProvider, notifyWorkbenchRuntimeChanged } from './workbench/service.js';
|
|
97
99
|
import { DaemonChannel } from './channels/daemon.js';
|
|
98
100
|
import { DAEMON_RUNTIME_EPOCH_ENV, ensureProcessManagedTempDir } from './cli/task-context.js';
|
|
@@ -111,6 +113,11 @@ export function readEvolcoreVersion() {
|
|
|
111
113
|
return readInstalledEvolcoreVersion();
|
|
112
114
|
}
|
|
113
115
|
let startupCpuProfile;
|
|
116
|
+
/**
|
|
117
|
+
* 单个 agent 的渠道实例创建超过这个时长就记一条 WARN。正常情况下这一步是毫秒级,
|
|
118
|
+
* 一旦某次读盘/解密被拖慢会到 10 秒以上——固定阈值比事后翻甘特更容易发现回归。
|
|
119
|
+
*/
|
|
120
|
+
const CHANNEL_CREATE_SLOW_MS = 1000;
|
|
114
121
|
async function main() {
|
|
115
122
|
// 启动甘特图埋点。firstPhase 之前的时间(node 启动 + 模块加载 + tsx/dist 编译)
|
|
116
123
|
// 全部记进 daemon.bootstrap;计时器消费 `ec start` 传入的一次性 traceId,
|
|
@@ -167,6 +174,8 @@ async function main() {
|
|
|
167
174
|
process.exit(1);
|
|
168
175
|
}
|
|
169
176
|
}
|
|
177
|
+
// Plugin identities and configuration validators must exist before Agent admission.
|
|
178
|
+
const externalPluginDescriptors = await discoverBaseagentPlugins();
|
|
170
179
|
// 在登记 daemon 实例前自动备份并迁移旧配置;失败才阻止启动。
|
|
171
180
|
trace.mark('daemon.startupConfigMigrate');
|
|
172
181
|
try {
|
|
@@ -248,13 +257,8 @@ async function main() {
|
|
|
248
257
|
if (sandboxDependencies.status === 'missing') {
|
|
249
258
|
logger.warn(`[ClaudeSandbox] ${formatClaudeSandboxDependencies(sandboxDependencies)}`);
|
|
250
259
|
}
|
|
251
|
-
if (daemonCfg.aid)
|
|
260
|
+
if (daemonCfg.aid)
|
|
252
261
|
ownerResolver.setDaemonAid(daemonCfg.aid);
|
|
253
|
-
ownerResolver.setConfiguredOwners(daemonCfg.aid, [
|
|
254
|
-
daemonCfg.owner,
|
|
255
|
-
...(daemonCfg.owners ?? []),
|
|
256
|
-
].filter((owner) => typeof owner === 'string'));
|
|
257
|
-
}
|
|
258
262
|
const processLevelOwners = getDaemonOwners;
|
|
259
263
|
const bindBootstrapMode = process.env.EVOLCORE_BIND_BOOTSTRAP === '1';
|
|
260
264
|
const paths = resolvePaths();
|
|
@@ -337,11 +341,25 @@ async function main() {
|
|
|
337
341
|
normalStartupGate.settle('ready');
|
|
338
342
|
return;
|
|
339
343
|
}
|
|
344
|
+
// ccagent:仅在 daemon 配置显式启用后初始化,在扫描 Agent 前完成身份准备。
|
|
345
|
+
// 注册或 Owner 绑定失败会保留待处理状态,不阻断其余 Agent 启动。
|
|
346
|
+
if (loadDaemonConfig().ccAgent?.enabled === true)
|
|
347
|
+
await trace.track('daemon.ccAgent', async () => {
|
|
348
|
+
if (startupCancelled)
|
|
349
|
+
return false;
|
|
350
|
+
const { ensureCcAgent } = await import('./agents/claude-gateway/agent-registration.js');
|
|
351
|
+
const aid = await ensureCcAgent();
|
|
352
|
+
if (aid)
|
|
353
|
+
logger.info(`[ccagent] 就绪:${aid}`);
|
|
354
|
+
return true;
|
|
355
|
+
}, undefined, { initialPhase: 'running' }).catch((error) => {
|
|
356
|
+
logger.warn(`ccagent 启动失败(不影响 daemon 主流程): ${error?.message || error}`);
|
|
357
|
+
});
|
|
340
358
|
// ── EvolAgent Registry:加载 agents/<aid>/config.json ──
|
|
341
359
|
const templateStartupRecovery = await restoreTemplatesBeforeStartup(paths.root);
|
|
342
360
|
trace.mark('daemon.agentRegistry');
|
|
343
361
|
const agentRegistry = new EvolAgentRegistry(paths.agentsDir);
|
|
344
|
-
const { runtimeStatus } = loadStartupAgentRegistry(agentRegistry);
|
|
362
|
+
const { runtimeStatus, primaryAgent } = loadStartupAgentRegistry(agentRegistry);
|
|
345
363
|
for (const aid of new Set([...templateStartupRecovery.blocked, ...templateStartupRecovery.pending])) {
|
|
346
364
|
const agent = agentRegistry.get(aid);
|
|
347
365
|
if (agent) {
|
|
@@ -349,7 +367,6 @@ async function main() {
|
|
|
349
367
|
agent.error = 'Template installation requires recovery';
|
|
350
368
|
}
|
|
351
369
|
}
|
|
352
|
-
const primaryAgent = agentRegistry.runnableAgents()[0];
|
|
353
370
|
const teamWorkspaceManagementService = new TeamWorkspaceManagementService(new TeamWorkspaceBootstrapService());
|
|
354
371
|
let agentRuntimeState = runtimeStatus.state;
|
|
355
372
|
let agentRuntimeError = runtimeStatus.error;
|
|
@@ -395,7 +412,6 @@ async function main() {
|
|
|
395
412
|
// 注册会话文件适配器(Claude / Codex 各自的会话文件操作)
|
|
396
413
|
sessionManager.registerFileAdapter(new ClaudeSessionFileAdapter());
|
|
397
414
|
sessionManager.registerFileAdapter(new CodexSessionFileAdapter());
|
|
398
|
-
sessionManager.registerFileAdapter(new GeminiSessionFileAdapter());
|
|
399
415
|
sessionManager.registerFileAdapter(new EcagentSessionFileAdapter());
|
|
400
416
|
let capturedStartupQueue;
|
|
401
417
|
let startupQueueSnapshot;
|
|
@@ -459,8 +475,8 @@ async function main() {
|
|
|
459
475
|
const agentLoader = new AgentLoader();
|
|
460
476
|
agentLoader.register(new ClaudeAgentPlugin());
|
|
461
477
|
agentLoader.register(new CodexAgentPlugin());
|
|
462
|
-
agentLoader.register(new GeminiAgentPlugin());
|
|
463
478
|
agentLoader.register(new EcagentAgentPluginLazy());
|
|
479
|
+
await loadExternalBaseagentPlugins(agentLoader, sessionManager, externalPluginDescriptors);
|
|
464
480
|
// 权限审批网关
|
|
465
481
|
const permissionGateway = new PermissionGateway();
|
|
466
482
|
permissionGateway.setEventBus(eventBus);
|
|
@@ -538,6 +554,8 @@ async function main() {
|
|
|
538
554
|
agentMap,
|
|
539
555
|
isCancelled: () => startupCancelled,
|
|
540
556
|
waitForClassification: async (aid) => {
|
|
557
|
+
if (aid === getCcAgentAid())
|
|
558
|
+
return false;
|
|
541
559
|
const priority = await agentWorkReady.get(aid);
|
|
542
560
|
if (priority === undefined && !startupCancelled)
|
|
543
561
|
throw new Error(`Work classification unavailable for ${aid}`);
|
|
@@ -622,10 +640,6 @@ async function main() {
|
|
|
622
640
|
// 交互路由器
|
|
623
641
|
const interactionRouter = new InteractionRouter();
|
|
624
642
|
const groupInviteReviewService = new GroupInviteReviewService(interactionRouter);
|
|
625
|
-
const removeGroupInviteConfigListener = onConfigWrite(({ target, selector }) => {
|
|
626
|
-
if (target === ConfigTarget.Agent && selector.self)
|
|
627
|
-
groupInviteReviewService.configurationChanged(selector.self);
|
|
628
|
-
});
|
|
629
643
|
// 创建消息缓存
|
|
630
644
|
trace.mark('daemon.messageCache');
|
|
631
645
|
const messageCache = new MessageCache();
|
|
@@ -643,17 +657,25 @@ async function main() {
|
|
|
643
657
|
const connectionBudget = startupConnectionBudget();
|
|
644
658
|
trace.setMeta('connectionAdmission', JSON.stringify({ ...connectionBudget, intervalMs: 50 }));
|
|
645
659
|
logger.info(`[startup] Channel connection admission: cpuParallelism=${connectionBudget.cpuParallelism} concurrency=${connectionBudget.concurrency} intervalMs=50`);
|
|
660
|
+
// Pace connection setup bursts; short Trigger initialization needs no fixed spacing.
|
|
646
661
|
const connectionQueue = new StartupTaskQueue(connectionBudget.concurrency, 50);
|
|
647
|
-
const schedulerQueue = new StartupTaskQueue(2,
|
|
662
|
+
const schedulerQueue = new StartupTaskQueue(2, 0);
|
|
648
663
|
channelLoader.setConnectionAdmission(instance => connectionQueue.run(() => instance.connect(), () => !startupCancelled && !instance.lifecycle?.signal.aborted));
|
|
649
664
|
daemonPluginLifecycle.defer(() => { connectionQueue.stop(); schedulerQueue.stop(); }, 'startup admission');
|
|
650
665
|
// Create channel instances: 每个 self-agent 各自的 channels
|
|
651
666
|
const evolagentInstances = [];
|
|
667
|
+
let slowestAgent = null;
|
|
652
668
|
for (const agent of startupAgents) {
|
|
669
|
+
// 逐 agent 计时:这一步曾在 50 个 agent 的规模下出现十几秒的空档,
|
|
670
|
+
// 而整段只有一个汇总耗时,定位不到是谁卡住。单实例超过阈值时直接告警,
|
|
671
|
+
// 同时每个 agent 都进启动甘特(daemon.channelCreate.<aid>)便于回看分布。
|
|
672
|
+
const agentStartedAt = Date.now();
|
|
653
673
|
try {
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
674
|
+
const instances = await trace.track(`daemon.channelCreate.${agent.aid}`, async () => {
|
|
675
|
+
const aun = await channelLoader.createAunForAgent(agent);
|
|
676
|
+
const external = await channelLoader.createExternalForAgent(agent);
|
|
677
|
+
return [...aun, ...external];
|
|
678
|
+
});
|
|
657
679
|
channelInstancesByAgent.set(agent.aid, instances);
|
|
658
680
|
evolagentInstances.push(...instances);
|
|
659
681
|
bindStartupAgentChannels(agent, startupRunnerInstances.get(agent.aid) ?? []);
|
|
@@ -663,10 +685,19 @@ async function main() {
|
|
|
663
685
|
agent.status = 'error';
|
|
664
686
|
agent.error = `Channel creation failed: ${e}`;
|
|
665
687
|
}
|
|
688
|
+
const elapsed = Date.now() - agentStartedAt;
|
|
689
|
+
if (elapsed >= CHANNEL_CREATE_SLOW_MS) {
|
|
690
|
+
logger.warn(`[startup] 渠道实例创建偏慢: aid=${agent.aid} elapsed=${elapsed}ms`);
|
|
691
|
+
}
|
|
692
|
+
if (!slowestAgent || elapsed > slowestAgent.ms)
|
|
693
|
+
slowestAgent = { aid: agent.aid, ms: elapsed };
|
|
666
694
|
}
|
|
667
695
|
const channelInstances = evolagentInstances;
|
|
668
696
|
trace.mark('daemon.channelInstances', `${channelInstances.length} 个渠道实例`);
|
|
669
697
|
logger.info(`✓ Created ${channelInstances.length} channel instance(s)`);
|
|
698
|
+
if (slowestAgent && slowestAgent.ms >= CHANNEL_CREATE_SLOW_MS) {
|
|
699
|
+
logger.warn(`[startup] 最慢的一个: aid=${slowestAgent.aid} elapsed=${slowestAgent.ms}ms`);
|
|
700
|
+
}
|
|
670
701
|
let bootstrapService;
|
|
671
702
|
const bindService = daemonCfg.aid
|
|
672
703
|
? new BindService({
|
|
@@ -689,16 +720,6 @@ async function main() {
|
|
|
689
720
|
return;
|
|
690
721
|
initializationServiceForOwnerRecovery?.resumeForOwner(subjectAid, ownerAid);
|
|
691
722
|
onProtocolOwnerBound(subjectAid, ownerAid);
|
|
692
|
-
if (agentRegistry.get(subjectAid)) {
|
|
693
|
-
try {
|
|
694
|
-
if (clearConfiguredOwnerAfterConsensus(subjectAid, ownerAid)) {
|
|
695
|
-
logOwnershipEvent('compatibility.cleared', { subjectAid, ownerAid });
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
catch (error) {
|
|
699
|
-
logOwnershipEvent('compatibility.cleanup_failed', { subjectAid, ownerAid, errorCode: ownershipErrorCode(error) }, true);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
723
|
});
|
|
703
724
|
// ownerResolver.stop() 交给 daemon shutdown 在发出下线通知之后执行:信号回调
|
|
704
725
|
// 比 shutdown 先注册,在这里清空共识会让下线通知过不了出站准入。
|
|
@@ -856,6 +877,7 @@ async function main() {
|
|
|
856
877
|
setOutputChangePublisher((aid, data) => {
|
|
857
878
|
void eventCenter.publishAgentEvent(aid, 'team.outputs.changed', data).catch(() => { });
|
|
858
879
|
}, aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
880
|
+
setOutputCardsNotificationsAvailable(aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
859
881
|
setWorkbenchChangePublisher((aid, data) => {
|
|
860
882
|
void eventCenter.publishAgentEvent(aid, 'team.workbench.changed', data).catch(() => { });
|
|
861
883
|
}, aid => eventCenter.get(aid)?.runtime.nativeOutputAvailable === true);
|
|
@@ -874,6 +896,7 @@ async function main() {
|
|
|
874
896
|
setWorkbenchRuntimeProvider();
|
|
875
897
|
setWorkbenchChangePublisher();
|
|
876
898
|
setOutputChangePublisher(undefined);
|
|
899
|
+
setOutputCardsNotificationsAvailable();
|
|
877
900
|
for (const type of ['agent:started', 'agent:stopped', 'agent:enabled', 'agent:disabled', 'agent:error']) {
|
|
878
901
|
eventBus.unsubscribe(type, workbenchLifecycle);
|
|
879
902
|
}
|
|
@@ -1016,7 +1039,7 @@ async function main() {
|
|
|
1016
1039
|
permissionGateway,
|
|
1017
1040
|
finalize: finishConsolidationSession,
|
|
1018
1041
|
});
|
|
1019
|
-
const startTriggerScheduler = async (owner, opts = {}) => {
|
|
1042
|
+
const startTriggerScheduler = async (owner, opts = {}, admit) => {
|
|
1020
1043
|
await triggerSchedulers.replace(owner.aid, () => buildTriggerScheduler(owner, {
|
|
1021
1044
|
channelInstances,
|
|
1022
1045
|
daemonChannel,
|
|
@@ -1034,17 +1057,23 @@ async function main() {
|
|
|
1034
1057
|
triggerAudit,
|
|
1035
1058
|
triggerScriptExecutor,
|
|
1036
1059
|
authorizeExecution: authorizeTriggerExecution,
|
|
1037
|
-
}, opts));
|
|
1060
|
+
}, opts), admit);
|
|
1061
|
+
};
|
|
1062
|
+
const admitStartupTrigger = (phase, valid = () => true) => initialize => {
|
|
1063
|
+
phase?.('queued', 'scheduler admission');
|
|
1064
|
+
return schedulerQueue.run(() => { phase?.('running'); return initialize(); }, () => !startupCancelled && valid());
|
|
1038
1065
|
};
|
|
1039
1066
|
cmdHandler.setTriggerSchedulerResolver((agentAid) => triggerSchedulers.get(agentAid));
|
|
1040
1067
|
const ensureTriggerSchedulerStarted = async (agent, phase) => {
|
|
1068
|
+
if (agent.aid === getCcAgentAid())
|
|
1069
|
+
return;
|
|
1041
1070
|
phase?.('waiting', 'Agent startup admission');
|
|
1042
1071
|
await startupRunnerReady.get(agent.aid);
|
|
1043
1072
|
if (startupCancelled || agent.status === 'error' || agent.status === 'disabled')
|
|
1044
1073
|
return;
|
|
1045
|
-
phase?.('
|
|
1074
|
+
phase?.('running', 'Trigger history import');
|
|
1046
1075
|
await triggerSchedulers.ensureStarted(agent.aid, async () => {
|
|
1047
|
-
await
|
|
1076
|
+
await startTriggerScheduler(agent, {}, admitStartupTrigger(phase, () => agent.status !== 'disabled' && agent.status !== 'error'));
|
|
1048
1077
|
});
|
|
1049
1078
|
};
|
|
1050
1079
|
const ensureDaemonTriggerSchedulerStarted = async (phase) => {
|
|
@@ -1055,9 +1084,9 @@ async function main() {
|
|
|
1055
1084
|
return;
|
|
1056
1085
|
if (primaryAgent && (primaryAgent.status === 'error' || primaryAgent.status === 'disabled'))
|
|
1057
1086
|
return;
|
|
1058
|
-
phase?.('
|
|
1087
|
+
phase?.('running', 'Trigger history import');
|
|
1059
1088
|
await triggerSchedulers.ensureStarted(daemonTriggerOwner.aid, async () => {
|
|
1060
|
-
await
|
|
1089
|
+
await startTriggerScheduler(daemonTriggerOwner, { seedUpgradeCheck: true }, admitStartupTrigger(phase));
|
|
1061
1090
|
});
|
|
1062
1091
|
};
|
|
1063
1092
|
const startupTriggerReady = new Set();
|
|
@@ -1396,6 +1425,46 @@ async function main() {
|
|
|
1396
1425
|
return await resync();
|
|
1397
1426
|
};
|
|
1398
1427
|
const agentApplicationService = new AgentApplicationService({
|
|
1428
|
+
authorizeProjectAgent: async (aid, actor) => {
|
|
1429
|
+
const owner = await ownerResolver.refreshForAuthorization(aid);
|
|
1430
|
+
return !owner.refreshFailure && owner.consensusStatus === 'consensus' && owner.ownerAid === actor;
|
|
1431
|
+
},
|
|
1432
|
+
projectGate: async (aid, token) => {
|
|
1433
|
+
const releaseGate = await reloadCoordinator.acquireForMutation(aid, token);
|
|
1434
|
+
let releaseScheduler;
|
|
1435
|
+
let releaseHandoff;
|
|
1436
|
+
let releaseEvents;
|
|
1437
|
+
let releaseServices;
|
|
1438
|
+
try {
|
|
1439
|
+
releaseServices = peekServiceRouter(aid)?.pauseForMutation(token);
|
|
1440
|
+
releaseHandoff = handoffRuntime.holdAgent(aid, token);
|
|
1441
|
+
releaseEvents = eventCenter.pauseForMutation(aid, token);
|
|
1442
|
+
releaseScheduler = await triggerSchedulers.get(aid)?.pauseForMutation(token);
|
|
1443
|
+
}
|
|
1444
|
+
catch (error) {
|
|
1445
|
+
releaseEvents?.();
|
|
1446
|
+
releaseHandoff?.();
|
|
1447
|
+
releaseServices?.();
|
|
1448
|
+
await releaseGate();
|
|
1449
|
+
throw error;
|
|
1450
|
+
}
|
|
1451
|
+
return async () => {
|
|
1452
|
+
try {
|
|
1453
|
+
await releaseScheduler?.();
|
|
1454
|
+
}
|
|
1455
|
+
finally {
|
|
1456
|
+
releaseEvents?.();
|
|
1457
|
+
releaseHandoff?.();
|
|
1458
|
+
releaseServices?.();
|
|
1459
|
+
await releaseGate();
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
},
|
|
1463
|
+
interruptProjectAgent: aid => {
|
|
1464
|
+
const agent = agentRegistry.get(aid);
|
|
1465
|
+
if (agent)
|
|
1466
|
+
messageQueue.interruptByAgent(agent.name);
|
|
1467
|
+
},
|
|
1399
1468
|
registry: agentRegistry,
|
|
1400
1469
|
reload: (aid, options) => reloadCoordinator.reload(aid, options),
|
|
1401
1470
|
hooks: reloadHooks,
|
|
@@ -1437,7 +1506,7 @@ async function main() {
|
|
|
1437
1506
|
agentApplicationService.setInitializationService(agentInitializationService);
|
|
1438
1507
|
cmdHandler.setAgentApplicationService(agentApplicationService);
|
|
1439
1508
|
const templateRecoveryMutes = new Set();
|
|
1440
|
-
|
|
1509
|
+
const agentTemplateRuntime = createAgentTemplateRuntime({
|
|
1441
1510
|
holdHandoff: (aid, token) => handoffRuntime.holdAgent(aid, token),
|
|
1442
1511
|
initialization: agentInitializationService, application: agentApplicationService,
|
|
1443
1512
|
usable: aid => {
|
|
@@ -1459,6 +1528,7 @@ async function main() {
|
|
|
1459
1528
|
}
|
|
1460
1529
|
},
|
|
1461
1530
|
getScheduler: aid => triggerSchedulers.get(aid),
|
|
1531
|
+
pauseEvents: (aid, token) => eventCenter.pauseForMutation(aid, token),
|
|
1462
1532
|
recoveryComplete: (aid, succeeded) => {
|
|
1463
1533
|
if (succeeded && (templateStartupRecovery.pending.has(aid) || templateRecoveryMutes.has(aid))) {
|
|
1464
1534
|
const agent = agentRegistry.get(aid);
|
|
@@ -1490,7 +1560,9 @@ async function main() {
|
|
|
1490
1560
|
if (failures.length)
|
|
1491
1561
|
throw new AggregateError(failures.map(result => result.reason), 'Template runtime cleanup incomplete');
|
|
1492
1562
|
},
|
|
1493
|
-
})
|
|
1563
|
+
});
|
|
1564
|
+
setAgentTemplateService(agentTemplateRuntime);
|
|
1565
|
+
daemonPluginLifecycle.defer(() => agentTemplateRuntime.dispose(), 'template update checks and jobs');
|
|
1494
1566
|
for (const aid of templateStartupRecovery.pending) {
|
|
1495
1567
|
const agent = agentRegistry.get(aid);
|
|
1496
1568
|
if (agent)
|
|
@@ -1699,6 +1771,8 @@ async function main() {
|
|
|
1699
1771
|
// Partition outside connectAll's workers so a deferred channel cannot hold
|
|
1700
1772
|
// a slot required by a recovering Agent. All groups share actual admission.
|
|
1701
1773
|
const connectAfter = async (instances, gate) => {
|
|
1774
|
+
if (!instances.length)
|
|
1775
|
+
return [];
|
|
1702
1776
|
try {
|
|
1703
1777
|
if (gate) {
|
|
1704
1778
|
for (const instance of instances)
|
|
@@ -2038,6 +2112,12 @@ async function main() {
|
|
|
2038
2112
|
const readySignalPath = resolvePaths().readySignal;
|
|
2039
2113
|
fs.writeFileSync(readySignalPath, String(Date.now()));
|
|
2040
2114
|
logger.info(`✓ Ready signal written: ${readySignalPath}`);
|
|
2115
|
+
void completeSystemdRestart(pendingFile).then(confirmed => {
|
|
2116
|
+
if (confirmed)
|
|
2117
|
+
return trySendPendingRestartNotice();
|
|
2118
|
+
}).catch(error => {
|
|
2119
|
+
logger.warn(`[Restart] Systemd ready confirmation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
2120
|
+
});
|
|
2041
2121
|
trace.setMeta('channelInstances', String(channelInstances.length));
|
|
2042
2122
|
trace.setMeta('agents', String(agentRegistry.allAgents().length));
|
|
2043
2123
|
trace.ready();
|
|
@@ -2067,7 +2147,6 @@ async function main() {
|
|
|
2067
2147
|
triggerSchedulers,
|
|
2068
2148
|
agentMap,
|
|
2069
2149
|
eventBus,
|
|
2070
|
-
removeGroupInviteConfigListener,
|
|
2071
2150
|
groupInviteReviewService,
|
|
2072
2151
|
channelLoader,
|
|
2073
2152
|
channelInstances,
|