evolcore 0.0.49 → 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 +64 -1
- 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 +280 -6
- 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 +4 -1
- 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 +29 -1
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +537 -189
- 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/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +23 -4
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +1 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/services-command.js +11 -9
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +17 -8
- package/dist/config/config-manager.js +86 -46
- 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 +99 -16
- package/dist/config/providers-management.js +35 -19
- package/dist/config/resolved-config-op.js +1 -42
- 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/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +50 -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 +15 -0
- 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 +91 -72
- package/dist/core/command/menu-protocol.js +5 -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/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 +2 -1
- package/dist/core/daemon-lifecycle.js +13 -5
- package/dist/core/evolagent-registry.js +12 -7
- 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 +4 -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 +98 -21
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/message-bridge.js +105 -6
- package/dist/core/message/message-log.js +8 -0
- package/dist/core/message/message-queue.js +5 -3
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +23 -8
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +4 -0
- package/dist/core/permission/ec-command-parser.js +182 -58
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +9 -2
- package/dist/core/permission/tool-policy.js +21 -9
- 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/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 +52 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/eck/kit-renderer.js +2 -1
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/index.js +116 -41
- package/dist/ipc.js +58 -2
- 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 +176 -18
- package/dist/services/ipc-operation.js +204 -44
- package/dist/services/script-runner.js +515 -83
- package/dist/services/validation.js +109 -4
- 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 -20
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +73 -0
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- 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/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 +7 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +20 -3
- package/kits/docs/evolcore/config.md +1 -1
- 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 +68 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +21 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -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.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 +13 -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 +12 -5
- 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 +1 -1
- 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/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +4 -3
- 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 -129
- package/kits/templates/system-fragments/venue.md +16 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +37 -23
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +16 -4
- package/scripts/agent-template/shared/team-schema.json +20 -4
- package/scripts/agent-template/shared/template-contract.mjs +53 -13
- package/scripts/agent-template/shared/template-package.mjs +90 -26
- package/scripts/agent-template/shared/template-runtime.mjs +111 -1
- package/scripts/agent-template/shared/template.mjs +65 -7
- package/scripts/agent-template/team-pack.mjs +89 -33
- 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
|
@@ -16,6 +16,27 @@
|
|
|
16
16
|
* 对端凭空建出一个叫 `main:…` 的话题。它只用于本端寻址、持久化与展示。
|
|
17
17
|
*/
|
|
18
18
|
export const MAIN_TOPIC_PREFIX = 'main:';
|
|
19
|
+
/** Decode relation/session selectors while retaining native channel ID case. */
|
|
20
|
+
export function normalizeThreadPeer(input) {
|
|
21
|
+
const raw = String(input ?? '').trim();
|
|
22
|
+
if (!raw)
|
|
23
|
+
return undefined;
|
|
24
|
+
const value = raw.includes('#') ? raw.split('#').at(-1) : raw;
|
|
25
|
+
try {
|
|
26
|
+
return decodeURIComponent(value).trim() || undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return value || undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function sameThreadPeer(a, b, channelType = 'aun') {
|
|
33
|
+
const left = normalizeThreadPeer(a);
|
|
34
|
+
const right = normalizeThreadPeer(b);
|
|
35
|
+
return !!left && !!right && (channelType === 'aun' ? left.toLowerCase() === right.toLowerCase() : left === right);
|
|
36
|
+
}
|
|
37
|
+
export function isInternalThreadPeer(peer) {
|
|
38
|
+
return /^(bg:|trigger:|daemon:|memory:)/.test(peer);
|
|
39
|
+
}
|
|
19
40
|
// CLI 创建时间戳形式,客户端可创建 UUID 形式;原值参与索引与双端寻址,不改写大小写。
|
|
20
41
|
const TIMESTAMP_TOPIC_ID_RE = /^thread-[0-9]+-[0-9a-f]{4}-[0-9a-f]{4}$/;
|
|
21
42
|
const UUID_TOPIC_ID_RE = /^thread-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -36,10 +57,39 @@ function isTopicAidSegment(value) {
|
|
|
36
57
|
return false;
|
|
37
58
|
return labels.every(label => /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(label));
|
|
38
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* 建话题时对端形态的**初步筛查**。
|
|
62
|
+
*
|
|
63
|
+
* 门槛刻意低于 `isValidAid`(三级以上):群 AID(`g-xxx.agentid.cn`)只有两级,
|
|
64
|
+
* 卡死会把合法的群话题挡掉。这里只排除结构上不可能是 AID 的输入——
|
|
65
|
+
* 空值、单级标签、带下划线/冒号/空格的段、以 `-` 起止的标签。
|
|
66
|
+
*
|
|
67
|
+
* 真正的身份确认交给名片缓存(`createThread` 里的 peerUnverified 标记),
|
|
68
|
+
* 不做网络校验:建话题本身不发送任何东西,离线场景必须能建。
|
|
69
|
+
*/
|
|
70
|
+
export function isTopicPeerAid(value) {
|
|
71
|
+
return typeof value === 'string' && isTopicAidSegment(normalizeTopicAid(value));
|
|
72
|
+
}
|
|
39
73
|
/** 统一输入形态:去空白与 `@` 前缀。不做域名展开、不改大小写。 */
|
|
40
74
|
export function normalizeTopicAid(value) {
|
|
41
75
|
return String(value ?? '').trim().replace(/^@/, '');
|
|
42
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* 话题对端是否就是本端自己。
|
|
79
|
+
*
|
|
80
|
+
* 话题是「本端 ↔ 对端」的两端结构,对端写成自己会得到残缺结构:会话元数据、
|
|
81
|
+
* 回复目标和角色解析全部指向本端,消息发得进去却没有人真正接收。
|
|
82
|
+
*
|
|
83
|
+
* 放在这里而不是 `thread-service`:创建侧与发送路由侧都要用,而发送路由是
|
|
84
|
+
* 不依赖 IO 的纯函数模块。比较按 AUN 的 AID 口径,大小写不敏感。
|
|
85
|
+
*/
|
|
86
|
+
export function isSelfTopicPeer(peer, selfAid) {
|
|
87
|
+
const normalizedPeer = normalizeTopicAid(typeof peer === 'string' ? peer : '');
|
|
88
|
+
const normalizedSelf = normalizeTopicAid(typeof selfAid === 'string' ? selfAid : '');
|
|
89
|
+
if (!normalizedPeer || !normalizedSelf)
|
|
90
|
+
return false;
|
|
91
|
+
return normalizedPeer.toLowerCase() === normalizedSelf.toLowerCase();
|
|
92
|
+
}
|
|
43
93
|
/**
|
|
44
94
|
* 由关系两端生成规范主话题 id。
|
|
45
95
|
*
|
|
@@ -79,9 +129,9 @@ export function mainTopicPeer(topicId, selfAid) {
|
|
|
79
129
|
if (!parsed)
|
|
80
130
|
return undefined;
|
|
81
131
|
const self = normalizeTopicAid(selfAid);
|
|
82
|
-
if (parsed.aidA
|
|
132
|
+
if (sameThreadPeer(parsed.aidA, self))
|
|
83
133
|
return parsed.aidB;
|
|
84
|
-
if (parsed.aidB
|
|
134
|
+
if (sameThreadPeer(parsed.aidB, self))
|
|
85
135
|
return parsed.aidA;
|
|
86
136
|
return undefined;
|
|
87
137
|
}
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { readTopicStatusLenient } from '../session/session-mapper.js';
|
|
2
|
+
import { isInternalThreadPeer, isTopicPeerAid, isTopicThreadId, normalizeThreadPeer } from './topic-id.js';
|
|
3
|
+
/** Shared index gate for both explicit topic operations and passive session creation. */
|
|
4
|
+
export function sanitizeIndexEntry(entry) {
|
|
5
|
+
const peer = normalizeThreadPeer(entry.peer);
|
|
6
|
+
const channelType = entry.channelType || 'aun';
|
|
7
|
+
if (!peer || isInternalThreadPeer(peer) || channelType === 'daemon')
|
|
8
|
+
return { ok: false, reason: 'internal or empty peer' };
|
|
9
|
+
if ((channelType === 'aun' && !isTopicPeerAid(peer)) || /[\x00-\x1f\x7f]/.test(peer)) {
|
|
10
|
+
return { ok: false, reason: `invalid ${channelType} peer ${peer}` };
|
|
11
|
+
}
|
|
12
|
+
if (!isTopicThreadId(entry.threadId))
|
|
13
|
+
return { ok: false, reason: `invalid threadId ${entry.threadId}` };
|
|
14
|
+
return { ok: true, entry: { ...entry, peer, channelType, topicStatus: readTopicStatusLenient(entry.topicStatus) } };
|
|
15
|
+
}
|
package/dist/eck/kit-renderer.js
CHANGED
|
@@ -232,7 +232,7 @@ const PARAM_DESCRIPTIONS = {
|
|
|
232
232
|
CURRENT_PROJECT: '当前项目完整路径',
|
|
233
233
|
AGENT_DIR: '当前 agent 数据根目录',
|
|
234
234
|
PERSONAL_DIR: '当前 agent 个人数据目录',
|
|
235
|
-
RELATIONS_DIR: '当前 agent
|
|
235
|
+
RELATIONS_DIR: '当前 agent 关系数据目录(历史消息里的 $RELATIONS_DIR/... 前缀即此绝对路径)',
|
|
236
236
|
VENUES_DIR: '当前 agent 环境数据目录',
|
|
237
237
|
selfAid: '当前 agent 的 AID',
|
|
238
238
|
selfName: '当前 agent 的显示名',
|
|
@@ -265,6 +265,7 @@ const PARAM_DESCRIPTIONS = {
|
|
|
265
265
|
channel: '渠道类型(aun/feishu/wechat/dingtalk/qqbot/wecom)',
|
|
266
266
|
venueUid: '场所唯一标识(预留)',
|
|
267
267
|
mentionMode: '群 @ 处理模式(mention-only=被@才响应 / disabled=所有消息都响应 / auto=按上下文判断)',
|
|
268
|
+
privateMentionMode: '私聊 @ 处理策略(mention-only=被@才响应 / disabled=所有消息都响应);Agent 级、Owner 专属',
|
|
268
269
|
groupHistoryAvailable: '本地群历史读取能力是否可用',
|
|
269
270
|
clientType: '客户端类型(desktop/web/mobile)',
|
|
270
271
|
permissionMode: '权限模式(readonly/auto/request/bypass;旧值会安全迁移)',
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { isSupportedBaseagent } from '../agents/baseagent.js';
|
|
1
2
|
import crypto from 'node:crypto';
|
|
2
3
|
import { assertProjectPathConfig } from '../utils/project-path.js';
|
|
3
4
|
import { ConfigTarget, mutateConfig, read, validateConfig, } from '../config/config-manager.js';
|
|
4
5
|
import { getLogStreamStates, LOG_LEVELS } from '../utils/logger.js';
|
|
5
6
|
import { resolveDaemonServices } from '../config/daemon-services.js';
|
|
6
|
-
const BASEAGENTS = ['claude', 'codex', 'gemini', 'ecagent'];
|
|
7
|
-
const BASEAGENT_SET = new Set(BASEAGENTS);
|
|
8
7
|
const EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
9
8
|
const PROHIBITED_PATH_SEGMENTS = new Set(['__proto__', 'prototype', 'constructor']);
|
|
10
9
|
const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
|
|
@@ -200,10 +199,7 @@ export function readBasicSettings() {
|
|
|
200
199
|
const rawDefaults = readSettingsFile('defaults');
|
|
201
200
|
const daemon = rawDaemon ? clone(rawDaemon) : {};
|
|
202
201
|
daemon.services = resolveDaemonServices(daemon.services);
|
|
203
|
-
|
|
204
|
-
delete daemon.owner;
|
|
205
|
-
delete daemon.owners;
|
|
206
|
-
}
|
|
202
|
+
// The daemon config no longer carries an Owner field; nothing to redact here.
|
|
207
203
|
return {
|
|
208
204
|
ok: true,
|
|
209
205
|
daemon,
|
|
@@ -245,9 +241,9 @@ function isAllowedPath(file, fieldPath) {
|
|
|
245
241
|
return true;
|
|
246
242
|
const block = baseagentBlockPath(fieldPath);
|
|
247
243
|
if (block)
|
|
248
|
-
return
|
|
244
|
+
return isSupportedBaseagent(block);
|
|
249
245
|
const parsed = baseagentPath(fieldPath);
|
|
250
|
-
return !!parsed &&
|
|
246
|
+
return !!parsed && isSupportedBaseagent(parsed.baseagent) && (BASEAGENT_FIELDS[parsed.baseagent] ?? new Set(['model', 'provider', 'effort', 'fallback'])).has(parsed.field);
|
|
251
247
|
}
|
|
252
248
|
function assertString(value, fieldPath, options = {}) {
|
|
253
249
|
if (typeof value !== 'string')
|
|
@@ -495,7 +491,7 @@ function validateDefaultsValue(fieldPath, value) {
|
|
|
495
491
|
return;
|
|
496
492
|
}
|
|
497
493
|
if (fieldPath === 'active_baseagent') {
|
|
498
|
-
if (!
|
|
494
|
+
if (!isSupportedBaseagent(String(value)))
|
|
499
495
|
throw makeError(`${fieldPath} is invalid`, 'INVALID_SETTINGS_VALUE');
|
|
500
496
|
return;
|
|
501
497
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isProviderModelPattern, providerModelLiteralId, providerModelEnabled, readProvidersFile, resolveProviderService } from '../config/providers.js';
|
|
2
|
-
import { resolveProviderId } from '../config/providers-config.js';
|
|
2
|
+
import { providerApiKeyEntries, resolveProviderId } from '../config/providers-config.js';
|
|
3
3
|
import { createProvider, importOrMergeBaseagentProvider, parseProviderImport, previewProviderImport, previewProviderValue, readProviderForExport, readProvidersSnapshot, resolveProviderDraftService, saveProviderChanges, updateProvider, prepareProviderTemplate, previewProviderTemplate, } from '../config/providers-management.js';
|
|
4
4
|
import { readProviderTemplates, providerTemplateDetail } from '../config/provider-templates.js';
|
|
5
5
|
import { listBaseagentImportSources, providerFromBaseagent } from '../config/providers-import.js';
|
|
@@ -176,7 +176,9 @@ export async function handleProvidersService(input) {
|
|
|
176
176
|
const provider = registry.providers[resolveProviderId(providerId, registry)];
|
|
177
177
|
if (!provider)
|
|
178
178
|
return response(404, { success: false, error: 'Provider not found' });
|
|
179
|
-
|
|
179
|
+
// apiKey stays the primary for existing clients; apiKeys exposes the whole pool.
|
|
180
|
+
const apiKeys = providerApiKeyEntries(provider.common.apiKey);
|
|
181
|
+
return response(200, { success: true, data: { apiKey: apiKeys[0] || '', apiKeys } });
|
|
180
182
|
}
|
|
181
183
|
if (input.method === 'GET' && parts[1] === 'models' && parts.length === 2) {
|
|
182
184
|
const serviceType = query.serviceType || '';
|
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';
|
|
@@ -112,6 +113,11 @@ export function readEvolcoreVersion() {
|
|
|
112
113
|
return readInstalledEvolcoreVersion();
|
|
113
114
|
}
|
|
114
115
|
let startupCpuProfile;
|
|
116
|
+
/**
|
|
117
|
+
* 单个 agent 的渠道实例创建超过这个时长就记一条 WARN。正常情况下这一步是毫秒级,
|
|
118
|
+
* 一旦某次读盘/解密被拖慢会到 10 秒以上——固定阈值比事后翻甘特更容易发现回归。
|
|
119
|
+
*/
|
|
120
|
+
const CHANNEL_CREATE_SLOW_MS = 1000;
|
|
115
121
|
async function main() {
|
|
116
122
|
// 启动甘特图埋点。firstPhase 之前的时间(node 启动 + 模块加载 + tsx/dist 编译)
|
|
117
123
|
// 全部记进 daemon.bootstrap;计时器消费 `ec start` 传入的一次性 traceId,
|
|
@@ -168,6 +174,8 @@ async function main() {
|
|
|
168
174
|
process.exit(1);
|
|
169
175
|
}
|
|
170
176
|
}
|
|
177
|
+
// Plugin identities and configuration validators must exist before Agent admission.
|
|
178
|
+
const externalPluginDescriptors = await discoverBaseagentPlugins();
|
|
171
179
|
// 在登记 daemon 实例前自动备份并迁移旧配置;失败才阻止启动。
|
|
172
180
|
trace.mark('daemon.startupConfigMigrate');
|
|
173
181
|
try {
|
|
@@ -249,13 +257,8 @@ async function main() {
|
|
|
249
257
|
if (sandboxDependencies.status === 'missing') {
|
|
250
258
|
logger.warn(`[ClaudeSandbox] ${formatClaudeSandboxDependencies(sandboxDependencies)}`);
|
|
251
259
|
}
|
|
252
|
-
if (daemonCfg.aid)
|
|
260
|
+
if (daemonCfg.aid)
|
|
253
261
|
ownerResolver.setDaemonAid(daemonCfg.aid);
|
|
254
|
-
ownerResolver.setConfiguredOwners(daemonCfg.aid, [
|
|
255
|
-
daemonCfg.owner,
|
|
256
|
-
...(daemonCfg.owners ?? []),
|
|
257
|
-
].filter((owner) => typeof owner === 'string'));
|
|
258
|
-
}
|
|
259
262
|
const processLevelOwners = getDaemonOwners;
|
|
260
263
|
const bindBootstrapMode = process.env.EVOLCORE_BIND_BOOTSTRAP === '1';
|
|
261
264
|
const paths = resolvePaths();
|
|
@@ -338,11 +341,25 @@ async function main() {
|
|
|
338
341
|
normalStartupGate.settle('ready');
|
|
339
342
|
return;
|
|
340
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
|
+
});
|
|
341
358
|
// ── EvolAgent Registry:加载 agents/<aid>/config.json ──
|
|
342
359
|
const templateStartupRecovery = await restoreTemplatesBeforeStartup(paths.root);
|
|
343
360
|
trace.mark('daemon.agentRegistry');
|
|
344
361
|
const agentRegistry = new EvolAgentRegistry(paths.agentsDir);
|
|
345
|
-
const { runtimeStatus } = loadStartupAgentRegistry(agentRegistry);
|
|
362
|
+
const { runtimeStatus, primaryAgent } = loadStartupAgentRegistry(agentRegistry);
|
|
346
363
|
for (const aid of new Set([...templateStartupRecovery.blocked, ...templateStartupRecovery.pending])) {
|
|
347
364
|
const agent = agentRegistry.get(aid);
|
|
348
365
|
if (agent) {
|
|
@@ -350,7 +367,6 @@ async function main() {
|
|
|
350
367
|
agent.error = 'Template installation requires recovery';
|
|
351
368
|
}
|
|
352
369
|
}
|
|
353
|
-
const primaryAgent = agentRegistry.runnableAgents()[0];
|
|
354
370
|
const teamWorkspaceManagementService = new TeamWorkspaceManagementService(new TeamWorkspaceBootstrapService());
|
|
355
371
|
let agentRuntimeState = runtimeStatus.state;
|
|
356
372
|
let agentRuntimeError = runtimeStatus.error;
|
|
@@ -396,7 +412,6 @@ async function main() {
|
|
|
396
412
|
// 注册会话文件适配器(Claude / Codex 各自的会话文件操作)
|
|
397
413
|
sessionManager.registerFileAdapter(new ClaudeSessionFileAdapter());
|
|
398
414
|
sessionManager.registerFileAdapter(new CodexSessionFileAdapter());
|
|
399
|
-
sessionManager.registerFileAdapter(new GeminiSessionFileAdapter());
|
|
400
415
|
sessionManager.registerFileAdapter(new EcagentSessionFileAdapter());
|
|
401
416
|
let capturedStartupQueue;
|
|
402
417
|
let startupQueueSnapshot;
|
|
@@ -460,8 +475,8 @@ async function main() {
|
|
|
460
475
|
const agentLoader = new AgentLoader();
|
|
461
476
|
agentLoader.register(new ClaudeAgentPlugin());
|
|
462
477
|
agentLoader.register(new CodexAgentPlugin());
|
|
463
|
-
agentLoader.register(new GeminiAgentPlugin());
|
|
464
478
|
agentLoader.register(new EcagentAgentPluginLazy());
|
|
479
|
+
await loadExternalBaseagentPlugins(agentLoader, sessionManager, externalPluginDescriptors);
|
|
465
480
|
// 权限审批网关
|
|
466
481
|
const permissionGateway = new PermissionGateway();
|
|
467
482
|
permissionGateway.setEventBus(eventBus);
|
|
@@ -539,6 +554,8 @@ async function main() {
|
|
|
539
554
|
agentMap,
|
|
540
555
|
isCancelled: () => startupCancelled,
|
|
541
556
|
waitForClassification: async (aid) => {
|
|
557
|
+
if (aid === getCcAgentAid())
|
|
558
|
+
return false;
|
|
542
559
|
const priority = await agentWorkReady.get(aid);
|
|
543
560
|
if (priority === undefined && !startupCancelled)
|
|
544
561
|
throw new Error(`Work classification unavailable for ${aid}`);
|
|
@@ -623,10 +640,6 @@ async function main() {
|
|
|
623
640
|
// 交互路由器
|
|
624
641
|
const interactionRouter = new InteractionRouter();
|
|
625
642
|
const groupInviteReviewService = new GroupInviteReviewService(interactionRouter);
|
|
626
|
-
const removeGroupInviteConfigListener = onConfigWrite(({ target, selector }) => {
|
|
627
|
-
if (target === ConfigTarget.Agent && selector.self)
|
|
628
|
-
groupInviteReviewService.configurationChanged(selector.self);
|
|
629
|
-
});
|
|
630
643
|
// 创建消息缓存
|
|
631
644
|
trace.mark('daemon.messageCache');
|
|
632
645
|
const messageCache = new MessageCache();
|
|
@@ -644,17 +657,25 @@ async function main() {
|
|
|
644
657
|
const connectionBudget = startupConnectionBudget();
|
|
645
658
|
trace.setMeta('connectionAdmission', JSON.stringify({ ...connectionBudget, intervalMs: 50 }));
|
|
646
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.
|
|
647
661
|
const connectionQueue = new StartupTaskQueue(connectionBudget.concurrency, 50);
|
|
648
|
-
const schedulerQueue = new StartupTaskQueue(2,
|
|
662
|
+
const schedulerQueue = new StartupTaskQueue(2, 0);
|
|
649
663
|
channelLoader.setConnectionAdmission(instance => connectionQueue.run(() => instance.connect(), () => !startupCancelled && !instance.lifecycle?.signal.aborted));
|
|
650
664
|
daemonPluginLifecycle.defer(() => { connectionQueue.stop(); schedulerQueue.stop(); }, 'startup admission');
|
|
651
665
|
// Create channel instances: 每个 self-agent 各自的 channels
|
|
652
666
|
const evolagentInstances = [];
|
|
667
|
+
let slowestAgent = null;
|
|
653
668
|
for (const agent of startupAgents) {
|
|
669
|
+
// 逐 agent 计时:这一步曾在 50 个 agent 的规模下出现十几秒的空档,
|
|
670
|
+
// 而整段只有一个汇总耗时,定位不到是谁卡住。单实例超过阈值时直接告警,
|
|
671
|
+
// 同时每个 agent 都进启动甘特(daemon.channelCreate.<aid>)便于回看分布。
|
|
672
|
+
const agentStartedAt = Date.now();
|
|
654
673
|
try {
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
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
|
+
});
|
|
658
679
|
channelInstancesByAgent.set(agent.aid, instances);
|
|
659
680
|
evolagentInstances.push(...instances);
|
|
660
681
|
bindStartupAgentChannels(agent, startupRunnerInstances.get(agent.aid) ?? []);
|
|
@@ -664,10 +685,19 @@ async function main() {
|
|
|
664
685
|
agent.status = 'error';
|
|
665
686
|
agent.error = `Channel creation failed: ${e}`;
|
|
666
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 };
|
|
667
694
|
}
|
|
668
695
|
const channelInstances = evolagentInstances;
|
|
669
696
|
trace.mark('daemon.channelInstances', `${channelInstances.length} 个渠道实例`);
|
|
670
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
|
+
}
|
|
671
701
|
let bootstrapService;
|
|
672
702
|
const bindService = daemonCfg.aid
|
|
673
703
|
? new BindService({
|
|
@@ -690,16 +720,6 @@ async function main() {
|
|
|
690
720
|
return;
|
|
691
721
|
initializationServiceForOwnerRecovery?.resumeForOwner(subjectAid, ownerAid);
|
|
692
722
|
onProtocolOwnerBound(subjectAid, ownerAid);
|
|
693
|
-
if (agentRegistry.get(subjectAid)) {
|
|
694
|
-
try {
|
|
695
|
-
if (clearConfiguredOwnerAfterConsensus(subjectAid, ownerAid)) {
|
|
696
|
-
logOwnershipEvent('compatibility.cleared', { subjectAid, ownerAid });
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
catch (error) {
|
|
700
|
-
logOwnershipEvent('compatibility.cleanup_failed', { subjectAid, ownerAid, errorCode: ownershipErrorCode(error) }, true);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
723
|
});
|
|
704
724
|
// ownerResolver.stop() 交给 daemon shutdown 在发出下线通知之后执行:信号回调
|
|
705
725
|
// 比 shutdown 先注册,在这里清空共识会让下线通知过不了出站准入。
|
|
@@ -1019,7 +1039,7 @@ async function main() {
|
|
|
1019
1039
|
permissionGateway,
|
|
1020
1040
|
finalize: finishConsolidationSession,
|
|
1021
1041
|
});
|
|
1022
|
-
const startTriggerScheduler = async (owner, opts = {}) => {
|
|
1042
|
+
const startTriggerScheduler = async (owner, opts = {}, admit) => {
|
|
1023
1043
|
await triggerSchedulers.replace(owner.aid, () => buildTriggerScheduler(owner, {
|
|
1024
1044
|
channelInstances,
|
|
1025
1045
|
daemonChannel,
|
|
@@ -1037,17 +1057,23 @@ async function main() {
|
|
|
1037
1057
|
triggerAudit,
|
|
1038
1058
|
triggerScriptExecutor,
|
|
1039
1059
|
authorizeExecution: authorizeTriggerExecution,
|
|
1040
|
-
}, 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());
|
|
1041
1065
|
};
|
|
1042
1066
|
cmdHandler.setTriggerSchedulerResolver((agentAid) => triggerSchedulers.get(agentAid));
|
|
1043
1067
|
const ensureTriggerSchedulerStarted = async (agent, phase) => {
|
|
1068
|
+
if (agent.aid === getCcAgentAid())
|
|
1069
|
+
return;
|
|
1044
1070
|
phase?.('waiting', 'Agent startup admission');
|
|
1045
1071
|
await startupRunnerReady.get(agent.aid);
|
|
1046
1072
|
if (startupCancelled || agent.status === 'error' || agent.status === 'disabled')
|
|
1047
1073
|
return;
|
|
1048
|
-
phase?.('
|
|
1074
|
+
phase?.('running', 'Trigger history import');
|
|
1049
1075
|
await triggerSchedulers.ensureStarted(agent.aid, async () => {
|
|
1050
|
-
await
|
|
1076
|
+
await startTriggerScheduler(agent, {}, admitStartupTrigger(phase, () => agent.status !== 'disabled' && agent.status !== 'error'));
|
|
1051
1077
|
});
|
|
1052
1078
|
};
|
|
1053
1079
|
const ensureDaemonTriggerSchedulerStarted = async (phase) => {
|
|
@@ -1058,9 +1084,9 @@ async function main() {
|
|
|
1058
1084
|
return;
|
|
1059
1085
|
if (primaryAgent && (primaryAgent.status === 'error' || primaryAgent.status === 'disabled'))
|
|
1060
1086
|
return;
|
|
1061
|
-
phase?.('
|
|
1087
|
+
phase?.('running', 'Trigger history import');
|
|
1062
1088
|
await triggerSchedulers.ensureStarted(daemonTriggerOwner.aid, async () => {
|
|
1063
|
-
await
|
|
1089
|
+
await startTriggerScheduler(daemonTriggerOwner, { seedUpgradeCheck: true }, admitStartupTrigger(phase));
|
|
1064
1090
|
});
|
|
1065
1091
|
};
|
|
1066
1092
|
const startupTriggerReady = new Set();
|
|
@@ -1399,6 +1425,46 @@ async function main() {
|
|
|
1399
1425
|
return await resync();
|
|
1400
1426
|
};
|
|
1401
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
|
+
},
|
|
1402
1468
|
registry: agentRegistry,
|
|
1403
1469
|
reload: (aid, options) => reloadCoordinator.reload(aid, options),
|
|
1404
1470
|
hooks: reloadHooks,
|
|
@@ -1440,7 +1506,7 @@ async function main() {
|
|
|
1440
1506
|
agentApplicationService.setInitializationService(agentInitializationService);
|
|
1441
1507
|
cmdHandler.setAgentApplicationService(agentApplicationService);
|
|
1442
1508
|
const templateRecoveryMutes = new Set();
|
|
1443
|
-
|
|
1509
|
+
const agentTemplateRuntime = createAgentTemplateRuntime({
|
|
1444
1510
|
holdHandoff: (aid, token) => handoffRuntime.holdAgent(aid, token),
|
|
1445
1511
|
initialization: agentInitializationService, application: agentApplicationService,
|
|
1446
1512
|
usable: aid => {
|
|
@@ -1494,7 +1560,9 @@ async function main() {
|
|
|
1494
1560
|
if (failures.length)
|
|
1495
1561
|
throw new AggregateError(failures.map(result => result.reason), 'Template runtime cleanup incomplete');
|
|
1496
1562
|
},
|
|
1497
|
-
})
|
|
1563
|
+
});
|
|
1564
|
+
setAgentTemplateService(agentTemplateRuntime);
|
|
1565
|
+
daemonPluginLifecycle.defer(() => agentTemplateRuntime.dispose(), 'template update checks and jobs');
|
|
1498
1566
|
for (const aid of templateStartupRecovery.pending) {
|
|
1499
1567
|
const agent = agentRegistry.get(aid);
|
|
1500
1568
|
if (agent)
|
|
@@ -1703,6 +1771,8 @@ async function main() {
|
|
|
1703
1771
|
// Partition outside connectAll's workers so a deferred channel cannot hold
|
|
1704
1772
|
// a slot required by a recovering Agent. All groups share actual admission.
|
|
1705
1773
|
const connectAfter = async (instances, gate) => {
|
|
1774
|
+
if (!instances.length)
|
|
1775
|
+
return [];
|
|
1706
1776
|
try {
|
|
1707
1777
|
if (gate) {
|
|
1708
1778
|
for (const instance of instances)
|
|
@@ -2042,6 +2112,12 @@ async function main() {
|
|
|
2042
2112
|
const readySignalPath = resolvePaths().readySignal;
|
|
2043
2113
|
fs.writeFileSync(readySignalPath, String(Date.now()));
|
|
2044
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
|
+
});
|
|
2045
2121
|
trace.setMeta('channelInstances', String(channelInstances.length));
|
|
2046
2122
|
trace.setMeta('agents', String(agentRegistry.allAgents().length));
|
|
2047
2123
|
trace.ready();
|
|
@@ -2071,7 +2147,6 @@ async function main() {
|
|
|
2071
2147
|
triggerSchedulers,
|
|
2072
2148
|
agentMap,
|
|
2073
2149
|
eventBus,
|
|
2074
|
-
removeGroupInviteConfigListener,
|
|
2075
2150
|
groupInviteReviewService,
|
|
2076
2151
|
channelLoader,
|
|
2077
2152
|
channelInstances,
|