evolcore 0.0.47 → 0.0.48
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 +56 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +139 -39
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +31 -16
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +81 -24
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +7 -1
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +2 -8
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/role.js +61 -17
- package/dist/cli/stats.js +3 -3
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-manager.js +2 -6
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +59 -8
- package/dist/config/providers-management.js +467 -49
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +3 -0
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +28 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/command-handler.js +81 -85
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +61 -149
- package/dist/core/command/menu-protocol.js +7 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +7 -7
- package/dist/core/evolagent-registry.js +14 -1
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +2 -1
- package/dist/core/message/aun-ipc-sender.js +165 -55
- package/dist/core/message/im-renderer.js +1 -1
- package/dist/core/message/message-bridge.js +51 -334
- package/dist/core/message/message-log.js +5 -0
- package/dist/core/message/message-queue.js +22 -0
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +429 -116
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/relation/peer-identity.js +23 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +12 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/directory/owner-directory-admission.js +1 -1
- package/dist/directory/owner-directory-cache.js +45 -28
- package/dist/directory/owner-directory-markdown.js +13 -1
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/eck/message-renderer.js +84 -24
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +4 -2
- package/dist/event-center/registry.js +13 -2
- package/dist/event-center/runtime.js +103 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +92 -59
- package/dist/ipc.js +13 -2
- package/dist/outputs/events.js +62 -0
- package/dist/outputs/protocol.js +102 -0
- package/dist/outputs/service.js +279 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +89 -4
- package/dist/services/ipc-operation.js +4 -15
- package/dist/services/pack-manager.js +12 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +9 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -2
- package/kits/docs/evolcore/config.md +12 -0
- package/kits/docs/evolcore/directory.md +22 -3
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +123 -3
- package/kits/docs/evolcore/role.md +80 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +10 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +221 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +3 -3
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +6 -5
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +4 -1
- package/scripts/agent-template/shared/common.mjs +2 -3
- package/scripts/agent-template/shared/template-contract.mjs +2 -1
- package/scripts/agent-template/shared/template-package.mjs +9 -2
- package/scripts/agent-template/shared/template-runtime.mjs +20 -5
- package/scripts/agent-template/team-pack.mjs +6 -3
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -302,43 +302,26 @@ function getAgentBusyCount(handler, aid, excludeSessionKey) {
|
|
|
302
302
|
}
|
|
303
303
|
async function getGitWorkingDirInfo(projectPath) {
|
|
304
304
|
try {
|
|
305
|
-
const {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
})
|
|
305
|
+
const { execFile } = await import('child_process');
|
|
306
|
+
const git = (args) => new Promise((resolve, reject) => {
|
|
307
|
+
const child = execFile('git', args, {
|
|
308
|
+
cwd: projectPath, encoding: 'utf8', timeout: 1000,
|
|
309
|
+
windowsHide: process.platform === 'win32',
|
|
310
|
+
}, (error, stdout) => error ? reject(error) : resolve(stdout));
|
|
311
|
+
child.stdin?.end();
|
|
312
|
+
});
|
|
313
|
+
const isInsideWorkTree = (await git(['rev-parse', '--is-inside-work-tree'])).trim();
|
|
313
314
|
if (isInsideWorkTree !== 'true')
|
|
314
315
|
return null;
|
|
315
316
|
// 获取分支名
|
|
316
|
-
let branch =
|
|
317
|
-
cwd: projectPath,
|
|
318
|
-
encoding: 'utf8',
|
|
319
|
-
timeout: 1000,
|
|
320
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
321
|
-
windowsHide: process.platform === 'win32',
|
|
322
|
-
}).trim();
|
|
317
|
+
let branch = (await git(['branch', '--show-current'])).trim();
|
|
323
318
|
if (!branch) {
|
|
324
|
-
branch =
|
|
325
|
-
cwd: projectPath,
|
|
326
|
-
encoding: 'utf8',
|
|
327
|
-
timeout: 1000,
|
|
328
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
329
|
-
windowsHide: process.platform === 'win32',
|
|
330
|
-
}).trim();
|
|
319
|
+
branch = (await git(['rev-parse', '--abbrev-ref', 'HEAD'])).trim();
|
|
331
320
|
}
|
|
332
321
|
if (!branch)
|
|
333
322
|
return null;
|
|
334
323
|
// 检查文件状态
|
|
335
|
-
const statusOutput =
|
|
336
|
-
cwd: projectPath,
|
|
337
|
-
encoding: 'utf8',
|
|
338
|
-
timeout: 1000,
|
|
339
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
340
|
-
windowsHide: process.platform === 'win32',
|
|
341
|
-
});
|
|
324
|
+
const statusOutput = await git(['--no-optional-locks', 'status', '--porcelain']);
|
|
342
325
|
// 解析文件状态统计
|
|
343
326
|
const stats = { modified: 0, added: 0, deleted: 0, untracked: 0 };
|
|
344
327
|
const lines = statusOutput.trim().split('\n').filter(Boolean);
|
|
@@ -380,13 +363,7 @@ async function getGitWorkingDirInfo(projectPath) {
|
|
|
380
363
|
}
|
|
381
364
|
// 获取 ahead/behind 信息
|
|
382
365
|
try {
|
|
383
|
-
const revOutput =
|
|
384
|
-
cwd: projectPath,
|
|
385
|
-
timeout: 1000,
|
|
386
|
-
encoding: 'utf8',
|
|
387
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
388
|
-
windowsHide: process.platform === 'win32',
|
|
389
|
-
});
|
|
366
|
+
const revOutput = await git(['rev-list', '--left-right', '--count', '@{upstream}...HEAD']);
|
|
390
367
|
const revParts = revOutput.trim().split(/\s+/);
|
|
391
368
|
if (revParts.length === 2) {
|
|
392
369
|
const behind = parseInt(revParts[0], 10) || 0;
|
|
@@ -2609,7 +2586,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2609
2586
|
return { kind: 'command.error', text: `❌ 当前 Agent (${currentSessionAgent.name}) 不支持 /compact` };
|
|
2610
2587
|
}
|
|
2611
2588
|
if (sendMessage) {
|
|
2612
|
-
const text = '
|
|
2589
|
+
const text = '正在压缩会话上下文...';
|
|
2613
2590
|
await sendMessage(channelId, text, this.getReplyContext(session), {
|
|
2614
2591
|
kind: 'system.notice',
|
|
2615
2592
|
text,
|
|
@@ -2681,7 +2658,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2681
2658
|
if (compactResult === true || compactResult?.ok === true) {
|
|
2682
2659
|
return {
|
|
2683
2660
|
kind: 'system.notice',
|
|
2684
|
-
text: '
|
|
2661
|
+
text: '会话压缩完成',
|
|
2685
2662
|
subtype: 'session.compacted',
|
|
2686
2663
|
};
|
|
2687
2664
|
}
|
|
@@ -3822,10 +3799,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3822
3799
|
if (!targetSession) {
|
|
3823
3800
|
return { kind: 'command.error', text: `❌ 会话不存在: ${sessionName}\n使用 /s 查看可用会话` };
|
|
3824
3801
|
}
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3802
|
+
// Context is presentation only: finish the switch before asynchronous I/O
|
|
3803
|
+
// so it cannot widen the idle-check-to-session-replacement window.
|
|
3804
|
+
const readLastInput = async () => {
|
|
3805
|
+
const lastInput = targetSession.agentSessionId
|
|
3806
|
+
? await this.sessionManager.readSessionLastUserMessage(targetSession.projectPath, targetSession.agentSessionId, targetSession.baseagent, targetSession.selfAID)
|
|
3807
|
+
: null;
|
|
3808
|
+
return { lastInput, lastInputLine: lastInput ? `\n 最后输入: "${lastInput}"` : '' };
|
|
3809
|
+
};
|
|
3829
3810
|
if (!session) {
|
|
3830
3811
|
const switched = await this.sessionManager.switchToSession(channel, channelId, targetSession.id);
|
|
3831
3812
|
if (!switched) {
|
|
@@ -3833,6 +3814,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3833
3814
|
}
|
|
3834
3815
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3835
3816
|
return null;
|
|
3817
|
+
const { lastInputLine } = await readLastInput();
|
|
3836
3818
|
return { kind: 'command.result', text: `✓ 已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}\n 项目: ${path.basename(targetSession.projectPath)}${lastInputLine}` };
|
|
3837
3819
|
}
|
|
3838
3820
|
if (targetSession.id === session.id) {
|
|
@@ -3850,9 +3832,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3850
3832
|
return { kind: 'command.error', text: `❌ 切换会话失败` };
|
|
3851
3833
|
}
|
|
3852
3834
|
this.eventBus.publish({ type: 'session:switched', sessionId: targetSession.id, fromSessionId: session.id, toSessionId: targetSession.id });
|
|
3853
|
-
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3854
3835
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3855
3836
|
return null;
|
|
3837
|
+
const { lastInput, lastInputLine } = await readLastInput();
|
|
3838
|
+
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3856
3839
|
return { kind: 'command.result', text: `✓ 已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}${continueHint}${lastInputLine}` };
|
|
3857
3840
|
}
|
|
3858
3841
|
// /rename 或 /name 命令:重命名当前会话
|
|
@@ -105,9 +105,18 @@ async function preview(realPath, size) {
|
|
|
105
105
|
/** Derived private cache. No Skill files, workspace content or directory layouts are modified. */
|
|
106
106
|
export class TeamWorkspaceItemsIndex {
|
|
107
107
|
store;
|
|
108
|
+
cacheNamespace;
|
|
109
|
+
idleMs;
|
|
108
110
|
indexes = new Map();
|
|
109
|
-
|
|
111
|
+
listeners = new Set();
|
|
112
|
+
constructor(store = teamWorkspaceStore, cacheNamespace = 'team-workspace-items-v1', idleMs = IDLE_MS) {
|
|
110
113
|
this.store = store;
|
|
114
|
+
this.cacheNamespace = cacheNamespace;
|
|
115
|
+
this.idleMs = idleMs;
|
|
116
|
+
}
|
|
117
|
+
onCommitted(listener) {
|
|
118
|
+
this.listeners.add(listener);
|
|
119
|
+
return () => { this.listeners.delete(listener); };
|
|
111
120
|
}
|
|
112
121
|
warm(agentAid, state) {
|
|
113
122
|
// Navigation must not wait for cache JSON parsing or filesystem discovery.
|
|
@@ -134,6 +143,11 @@ export class TeamWorkspaceItemsIndex {
|
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
async query(agentAid, state, args) {
|
|
146
|
+
const { indexState: _indexState, watcherHealthy: _watcherHealthy, ...response } = await this.queryFiltered(agentAid, state, args);
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
/** Fixed-output queries share the bounded scanner, preview queue and path checks. */
|
|
150
|
+
async queryFiltered(agentAid, state, args, predicate = () => true, nonBlocking = false) {
|
|
137
151
|
validateTeamWorkspaceItemsArgs(args);
|
|
138
152
|
this.assertCurrent(agentAid, state);
|
|
139
153
|
const requestedPath = args.path;
|
|
@@ -141,13 +155,31 @@ export class TeamWorkspaceItemsIndex {
|
|
|
141
155
|
throw new DataRootError('FORBIDDEN', 'Path is not published in Team navigation');
|
|
142
156
|
this.store.resolvePath(state, requestedPath);
|
|
143
157
|
const index = this.get(agentAid, state);
|
|
158
|
+
if (index.watchDegraded) {
|
|
159
|
+
// A failed watcher is retried only on a legal read, never by a scan timer.
|
|
160
|
+
index.watchRestart ??= Promise.all((index.watchers ?? []).map(w => w.close())).then(() => {
|
|
161
|
+
if (index.closed)
|
|
162
|
+
return;
|
|
163
|
+
index.watchDegraded = false;
|
|
164
|
+
this.observe(index);
|
|
165
|
+
}).finally(() => { index.watchRestart = undefined; });
|
|
166
|
+
await index.watchRestart;
|
|
167
|
+
}
|
|
168
|
+
if (nonBlocking && index.scannedAt === 0) {
|
|
169
|
+
void this.refresh(index).catch(() => { index.rescan = true; });
|
|
170
|
+
return {
|
|
171
|
+
indexRevision: index.revision, items: [], total: 0,
|
|
172
|
+
nextOffset: null, hasMore: false, truncated: false, indexState: 'building',
|
|
173
|
+
watcherHealthy: index.watchReady === true && !index.watchDegraded,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
144
176
|
await this.refresh(index);
|
|
145
177
|
this.assertCurrent(agentAid, state);
|
|
146
178
|
if (args.indexRevision !== undefined && args.indexRevision !== index.revision) {
|
|
147
179
|
throw new DataRootError('INDEX_CHANGED', 'Team workspace items changed; restart pagination');
|
|
148
180
|
}
|
|
149
181
|
const snapshotRevision = index.revision;
|
|
150
|
-
const matching = index.sorted.filter(item => within(requestedPath, item.path));
|
|
182
|
+
const matching = index.sorted.filter(item => within(requestedPath, item.path) && predicate(item));
|
|
151
183
|
const offset = Number(args.offset ?? 0);
|
|
152
184
|
const limit = Number(args.limit ?? 20);
|
|
153
185
|
const window = matching.slice(offset, offset + limit);
|
|
@@ -181,6 +213,8 @@ export class TeamWorkspaceItemsIndex {
|
|
|
181
213
|
indexRevision: index.revision, path: requestedPath, offset,
|
|
182
214
|
total: matching.length, nextOffset: next < matching.length ? next : null,
|
|
183
215
|
hasMore: next < matching.length, truncated: index.truncated,
|
|
216
|
+
indexState: 'ready',
|
|
217
|
+
watcherHealthy: index.watchReady === true && !index.watchDegraded,
|
|
184
218
|
items: window.map(({ signature: _signature, realPath: _realPath, previewLoaded: _loaded, ...item }) => item),
|
|
185
219
|
};
|
|
186
220
|
// JSON escaping and long logical paths also consume transport space. A page
|
|
@@ -229,12 +263,14 @@ export class TeamWorkspaceItemsIndex {
|
|
|
229
263
|
this.observe(index);
|
|
230
264
|
}
|
|
231
265
|
clearTimeout(index.idle);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
this.indexes.
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
if (this.idleMs > 0) {
|
|
267
|
+
index.idle = setTimeout(() => {
|
|
268
|
+
this.release(index);
|
|
269
|
+
if (this.indexes.get(agentAid) === index)
|
|
270
|
+
this.indexes.delete(agentAid);
|
|
271
|
+
}, this.idleMs);
|
|
272
|
+
index.idle.unref();
|
|
273
|
+
}
|
|
238
274
|
// Bound watcher count even on a host with many PAs.
|
|
239
275
|
if (this.indexes.size > 16) {
|
|
240
276
|
const oldest = [...this.indexes.values()].find(candidate => candidate !== index && !candidate.pending);
|
|
@@ -245,7 +281,10 @@ export class TeamWorkspaceItemsIndex {
|
|
|
245
281
|
}
|
|
246
282
|
return index;
|
|
247
283
|
}
|
|
248
|
-
cachePath(index) {
|
|
284
|
+
cachePath(index) {
|
|
285
|
+
const safeNamespace = this.cacheNamespace.replace(/[^A-Za-z0-9._-]/g, '-');
|
|
286
|
+
return path.join(agentDataDir(index.agentAid), `${safeNamespace}.json`);
|
|
287
|
+
}
|
|
249
288
|
persist(index) {
|
|
250
289
|
if (index.closed || this.indexes.get(index.agentAid) !== index)
|
|
251
290
|
return;
|
|
@@ -311,6 +350,9 @@ export class TeamWorkspaceItemsIndex {
|
|
|
311
350
|
{ root: workspaceRoot, output: false },
|
|
312
351
|
...(outputRoot && outputRoot !== workspaceRoot ? [{ root: outputRoot, output: true }] : []),
|
|
313
352
|
];
|
|
353
|
+
index.watchReady = false;
|
|
354
|
+
const generation = index.watchGeneration = (index.watchGeneration ?? 0) + 1;
|
|
355
|
+
let pendingReady = roots.length;
|
|
314
356
|
index.watchers = roots.map(({ root, output }) => {
|
|
315
357
|
const allowed = index.state.entries.filter(entry => entry.availability !== 'unavailable'
|
|
316
358
|
&& (output ? entry.path === 'output' || entry.path.startsWith('output/') : !outputRoot || entry.path !== 'output' && !entry.path.startsWith('output/')));
|
|
@@ -326,7 +368,7 @@ export class TeamWorkspaceItemsIndex {
|
|
|
326
368
|
},
|
|
327
369
|
});
|
|
328
370
|
watcher.on('all', (event, absolute) => {
|
|
329
|
-
if (index.closed)
|
|
371
|
+
if (index.closed || index.watchGeneration !== generation)
|
|
330
372
|
return;
|
|
331
373
|
const relative = path.relative(root, absolute).split(path.sep).join('/');
|
|
332
374
|
const logical = logicalPath(relative);
|
|
@@ -338,8 +380,27 @@ export class TeamWorkspaceItemsIndex {
|
|
|
338
380
|
index.timer = setTimeout(() => { void this.refresh(index).catch(() => { index.rescan = true; }); }, 75);
|
|
339
381
|
index.timer.unref();
|
|
340
382
|
});
|
|
341
|
-
watcher.on('ready', () => {
|
|
342
|
-
|
|
383
|
+
watcher.on('ready', () => {
|
|
384
|
+
if (index.closed || index.watchDegraded || index.watchGeneration !== generation)
|
|
385
|
+
return;
|
|
386
|
+
if (--pendingReady === 0)
|
|
387
|
+
index.watchReady = true;
|
|
388
|
+
index.rescan = true;
|
|
389
|
+
void this.refresh(index).catch(() => { index.rescan = true; });
|
|
390
|
+
});
|
|
391
|
+
watcher.on('error', () => {
|
|
392
|
+
if (index.closed || index.watchDegraded || index.watchGeneration !== generation)
|
|
393
|
+
return;
|
|
394
|
+
index.watchDegraded = true;
|
|
395
|
+
index.watchReady = false;
|
|
396
|
+
index.rescan = true;
|
|
397
|
+
for (const listener of this.listeners) {
|
|
398
|
+
try {
|
|
399
|
+
listener(index.agentAid, index.revision, index.sorted, index.truncated, false);
|
|
400
|
+
}
|
|
401
|
+
catch { /* observers never block reads */ }
|
|
402
|
+
}
|
|
403
|
+
});
|
|
343
404
|
return watcher;
|
|
344
405
|
});
|
|
345
406
|
}
|
|
@@ -480,6 +541,14 @@ export class TeamWorkspaceItemsIndex {
|
|
|
480
541
|
index.revision = crypto.randomBytes(12).toString('hex');
|
|
481
542
|
if (changed || full)
|
|
482
543
|
this.persist(index);
|
|
544
|
+
if (changed || full && index.scannedAt !== 0) {
|
|
545
|
+
for (const listener of this.listeners) {
|
|
546
|
+
try {
|
|
547
|
+
listener(index.agentAid, index.revision, index.sorted, index.truncated, index.watchReady === true && !index.watchDegraded);
|
|
548
|
+
}
|
|
549
|
+
catch { /* observers never block reads */ }
|
|
550
|
+
}
|
|
551
|
+
}
|
|
483
552
|
}
|
|
484
553
|
release(index) {
|
|
485
554
|
index.closed = true;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
3
3
|
import { ConfigTarget, mutateConfig, read } from '../../config/config-manager.js';
|
|
4
|
-
import { getPeerSnapshot, isAcceptedPeer } from '../../config/peer-book.js';
|
|
5
4
|
import { readOwnerDirectoryMembership, refreshDirectoryMarkdown } from '../../directory/owner-directory-admission.js';
|
|
6
5
|
import { MY_AGENT_TEAM_LIMIT } from '../../directory/owner-directory-markdown.js';
|
|
7
6
|
import { entryOwnerAid } from '../../directory/owner-directory-scope.js';
|
|
8
|
-
import { readAunPeerKind } from '../relation/peer-identity.js';
|
|
9
7
|
export class TeamWorkspaceTeamError extends Error {
|
|
10
8
|
code;
|
|
11
9
|
data;
|
|
@@ -36,30 +34,12 @@ export function normalizeTeamMemberAids(value, selfAid) {
|
|
|
36
34
|
throw new TeamWorkspaceTeamError('INVALID_ARGUMENT', 'team cannot contain its own Agent AID');
|
|
37
35
|
return members;
|
|
38
36
|
}
|
|
39
|
-
function contactSnapshot(selfAid) {
|
|
40
|
-
try {
|
|
41
|
-
return getPeerSnapshot(selfAid);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
throw new TeamWorkspaceTeamError('CONTACT_BOOK_INVALID', 'The current Agent contact book is unavailable');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function assertPeerContacts(selfAid, members) {
|
|
48
|
-
const snapshot = contactSnapshot(selfAid);
|
|
49
|
-
for (const aid of members) {
|
|
50
|
-
if (readAunPeerKind(selfAid, aid).kind !== 'private' || !snapshot.contacts.has(aid) || !isAcceptedPeer(selfAid, aid)) {
|
|
51
|
-
throw new TeamWorkspaceTeamError('TEAM_MEMBER_NOT_CONTACT', `Team member must be an active private Agent contact: ${aid}`, { memberAid: aid });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
37
|
function assertActiveContacts(selfAid, members) {
|
|
56
38
|
for (const aid of members) {
|
|
57
39
|
const membership = readOwnerDirectoryMembership(selfAid, aid);
|
|
58
|
-
//
|
|
59
|
-
// Keep the established peer-book admission path usable in that case.
|
|
40
|
+
// Team eligibility requires the Owner directory; peer state is not a fallback.
|
|
60
41
|
if (membership === undefined) {
|
|
61
|
-
|
|
62
|
-
return;
|
|
42
|
+
throw new TeamWorkspaceTeamError('CONTACT_DIRECTORY_UNAVAILABLE', 'Owner directory is not configured');
|
|
63
43
|
}
|
|
64
44
|
// Directory unavailable
|
|
65
45
|
if (membership.category === 'unavailable') {
|
|
@@ -103,61 +83,19 @@ export function readTeamMembersState(selfAid) {
|
|
|
103
83
|
}
|
|
104
84
|
/** Keep stale contacts visible to the Owner so they can be removed. */
|
|
105
85
|
export function readTeamMemberDetails(selfAid, members) {
|
|
106
|
-
// Keep the legacy/local contact-book view when no Owner directory is configured.
|
|
107
|
-
if (members.some(aid => readOwnerDirectoryMembership(selfAid, aid) === undefined)) {
|
|
108
|
-
const snapshot = contactSnapshot(selfAid);
|
|
109
|
-
return members.map(aid => {
|
|
110
|
-
const contact = snapshot.contacts.get(aid);
|
|
111
|
-
const contactStatus = contact ? contact.status ?? 'active' : 'missing';
|
|
112
|
-
const reason = !contact ? 'NOT_A_CONTACT'
|
|
113
|
-
: contactStatus !== 'active' ? 'CONTACT_NOT_ACTIVE'
|
|
114
|
-
: readAunPeerKind(selfAid, aid).kind !== 'private' ? 'NOT_PRIVATE_CONTACT' : undefined;
|
|
115
|
-
return {
|
|
116
|
-
aid,
|
|
117
|
-
...(contact?.displayName ? { displayName: contact.displayName } : {}),
|
|
118
|
-
contactStatus,
|
|
119
|
-
availability: reason ? 'unavailable' : 'available',
|
|
120
|
-
...(reason ? { reason } : {}),
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
86
|
return members.map(aid => {
|
|
125
87
|
const membership = readOwnerDirectoryMembership(selfAid, aid);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
aid,
|
|
130
|
-
contactStatus: 'unavailable',
|
|
131
|
-
availability: 'unavailable',
|
|
132
|
-
reason: 'OWNER_DIRECTORY_UNAVAILABLE',
|
|
133
|
-
};
|
|
88
|
+
if (!membership || membership.category === 'unavailable') {
|
|
89
|
+
return { aid, contactStatus: 'unavailable', availability: 'unavailable', reason: 'OWNER_DIRECTORY_UNAVAILABLE' };
|
|
134
90
|
}
|
|
135
|
-
// Not found in directory
|
|
136
91
|
if (membership.category === 'not_found') {
|
|
137
|
-
return {
|
|
138
|
-
aid,
|
|
139
|
-
contactStatus: 'missing',
|
|
140
|
-
availability: 'unavailable',
|
|
141
|
-
reason: 'NOT_IN_OWNER_DIRECTORY',
|
|
142
|
-
};
|
|
92
|
+
return { aid, contactStatus: 'missing', availability: 'unavailable', reason: 'NOT_IN_OWNER_DIRECTORY' };
|
|
143
93
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
aid,
|
|
148
|
-
displayName: membership.entry?.name,
|
|
149
|
-
contactStatus: membership.blocked ? 'missing' : 'unavailable',
|
|
150
|
-
availability: 'unavailable',
|
|
151
|
-
reason: membership.blocked ? 'NOT_IN_OWNER_DIRECTORY' : 'NOT_AGENT_TYPE',
|
|
152
|
-
};
|
|
94
|
+
if (membership.blocked || !['agent', 'human', 'assistant'].includes(membership.category)) {
|
|
95
|
+
return { aid, contactStatus: 'unavailable', availability: 'unavailable',
|
|
96
|
+
reason: membership.blocked ? 'NOT_IN_OWNER_DIRECTORY' : 'NOT_AGENT_TYPE' };
|
|
153
97
|
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
aid,
|
|
157
|
-
displayName: membership.entry?.name,
|
|
158
|
-
contactStatus: 'active',
|
|
159
|
-
availability: 'available',
|
|
160
|
-
};
|
|
98
|
+
return { aid, displayName: membership.entry?.name, contactStatus: 'active', availability: 'available' };
|
|
161
99
|
});
|
|
162
100
|
}
|
|
163
101
|
export function readTeamMembers(selfAid) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 权限(沿用 /memory 的两级模型):
|
|
5
5
|
* - 只读(list / show / history / summary show / summary log / peers):
|
|
6
6
|
* 私聊所有角色可看;群聊仅 admin+ 可看
|
|
7
|
-
* - 写(create / rename /
|
|
7
|
+
* - 写(create / rename / status / delete / summary set / summary clear):
|
|
8
8
|
* 仅 admin+(群聊同样要求 admin,且只能操作本群关系)
|
|
9
9
|
* - rebuild-index:仅 admin+,且默认只报告不写盘(--write 才落盘)
|
|
10
10
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { ThreadService, ThreadServiceError } from '../thread/thread-service.js';
|
|
16
16
|
import { isTopicThreadId } from '../thread/topic-id.js';
|
|
17
17
|
import { parseTimeArg, TIME_ARG_FORMATS } from '../../cli/cli-argv.js';
|
|
18
|
-
const TOPIC_STATUSES = ['
|
|
18
|
+
const TOPIC_STATUSES = ['active', 'closed', 'archived'];
|
|
19
19
|
const USAGE = [
|
|
20
20
|
'用法(更名与总结默认作用于当前话题,无需手写 ref):',
|
|
21
21
|
' /thread rename <新名称> 重命名当前话题',
|
|
@@ -26,15 +26,14 @@ const USAGE = [
|
|
|
26
26
|
'',
|
|
27
27
|
' /thread 当前对端的话题列表(等价 /thread list)',
|
|
28
28
|
' /thread list all 本节点所有对端的话题列表',
|
|
29
|
-
' /thread list [ref] [--status <s>] [--
|
|
29
|
+
' /thread list [ref] [--status <s>] [--page <n>]',
|
|
30
30
|
' /thread peers 列出有话题记录的所有对端',
|
|
31
31
|
' /thread show [ref] 查看话题元数据',
|
|
32
32
|
' /thread history [ref] [--limit <n>] [--after <ts>] [--before <ts>]',
|
|
33
33
|
' 读取话题历史消息(--after 上次 summary 的 coveredThroughTs 读增量)',
|
|
34
34
|
'',
|
|
35
|
-
' /thread create <名称> [--
|
|
36
|
-
' /thread
|
|
37
|
-
' /thread status [ref] <状态> 更新话题业务状态',
|
|
35
|
+
' /thread create <名称> [--status <s>] 新建话题',
|
|
36
|
+
' /thread status [ref] <状态> 更新话题状态(active|closed|archived)',
|
|
38
37
|
' /thread delete [ref] 删除话题(session 文件移入 _trash)',
|
|
39
38
|
' /thread rebuild-index [--write] 检查/重建话题索引',
|
|
40
39
|
'',
|
|
@@ -80,7 +79,7 @@ export function topicHelpEntries(ctx) {
|
|
|
80
79
|
out.push({ command: '/thread', aliases: ['/thread list'], description: '当前对端的话题列表', category, roles }, { command: '/thread list all', description: '本节点所有对端的话题列表', category, roles }, { command: '/thread peers', description: '有话题记录的所有对端', category, roles }, { command: '/thread show', description: '查看话题元数据', args: '[ref]', category, roles }, { command: '/thread history', description: '读取话题历史消息', args: '[ref] [--limit <n>]', category, roles });
|
|
81
80
|
// 第三档:其余写操作与索引维护
|
|
82
81
|
if (write) {
|
|
83
|
-
out.push({ command: '/thread create', description: '新建话题', args: '<名称> [--
|
|
82
|
+
out.push({ command: '/thread create', description: '新建话题', args: '<名称> [--status <s>]', category, roles }, { command: '/thread status', description: '更新话题状态', args: '[ref] <状态>', category, roles }, { command: '/thread delete', description: '删除话题', args: '[ref]', category, roles }, { command: '/thread rebuild-index', description: '检查话题索引健康状态', category, roles });
|
|
84
83
|
}
|
|
85
84
|
out.push({ command: '/thread help', description: '全部子命令说明', category, roles });
|
|
86
85
|
return out;
|
|
@@ -133,11 +132,10 @@ function truncate(s, n) {
|
|
|
133
132
|
}
|
|
134
133
|
function formatThreadLine(t, currentThreadId) {
|
|
135
134
|
const mark = currentThreadId && t.threadId === currentThreadId ? ' ←当前' : '';
|
|
136
|
-
//
|
|
135
|
+
// 标题只放标题本身;状态单独成字段,不与标题拼接
|
|
137
136
|
const bits = [
|
|
138
137
|
t.name,
|
|
139
|
-
t.
|
|
140
|
-
t.topicStatus ? `状态:${t.topicStatus}` : '',
|
|
138
|
+
t.topicStatus && t.topicStatus !== 'active' ? `状态:${t.topicStatus}` : '',
|
|
141
139
|
formatTime(t.lastActiveAt),
|
|
142
140
|
t.lastMsgSnippet ? truncate(t.lastMsgSnippet, 30) : '',
|
|
143
141
|
].filter(Boolean);
|
|
@@ -256,7 +254,6 @@ export async function handleTopicSlash(ctx) {
|
|
|
256
254
|
`session: ${t.sessionId}`,
|
|
257
255
|
`对端: ${t.peer}(${t.peerKind === 'group' ? '群' : '私聊'})`,
|
|
258
256
|
`状态: ${t.topicStatus}`,
|
|
259
|
-
`标签: ${t.label ?? '(无)'}`,
|
|
260
257
|
`创建: ${formatTime(t.createdAt)} 最近活跃: ${formatTime(t.lastActiveAt)}`,
|
|
261
258
|
`消息: ${t.msgTotal ?? 0} 条(24h 内 ${t.msg24h ?? 0} 条)`,
|
|
262
259
|
];
|
|
@@ -302,7 +299,7 @@ export async function handleTopicSlash(ctx) {
|
|
|
302
299
|
if (sub === 'create') {
|
|
303
300
|
const name = positional[0];
|
|
304
301
|
if (!name)
|
|
305
|
-
return error('用法: /thread create <名称> [--
|
|
302
|
+
return error('用法: /thread create <名称> [--status <状态>]');
|
|
306
303
|
if (!ctx.peerKey)
|
|
307
304
|
return error('当前会话没有关系上下文,无法新建话题');
|
|
308
305
|
const status = flags.status !== undefined ? needStatus(flags.status) : undefined;
|
|
@@ -315,7 +312,6 @@ export async function handleTopicSlash(ctx) {
|
|
|
315
312
|
peer: ctx.peerKey,
|
|
316
313
|
peerKind: ctx.chatType === 'group' ? 'group' : 'private',
|
|
317
314
|
name,
|
|
318
|
-
...(typeof flags.label === 'string' ? { label: flags.label } : {}),
|
|
319
315
|
...(status ? { topicStatus: status } : {}),
|
|
320
316
|
});
|
|
321
317
|
return result(`✅ 已创建话题: ${created.name}\nref: ${created.threadId}`);
|
|
@@ -333,21 +329,6 @@ export async function handleTopicSlash(ctx) {
|
|
|
333
329
|
const r = await service.renameThread({ selfAid: ctx.selfAid, peer: target.peer, threadId: target.threadId, name });
|
|
334
330
|
return result(r.changed ? `✅ 已重命名为 ${r.name}` : `话题名称已是 ${r.name}`);
|
|
335
331
|
}
|
|
336
|
-
if (sub === 'label') {
|
|
337
|
-
const ref = refSource(positional, flags);
|
|
338
|
-
const target = resolveRef(ref, ctx, service);
|
|
339
|
-
if (isPayload(target))
|
|
340
|
-
return target;
|
|
341
|
-
if (!target.threadId)
|
|
342
|
-
return error('不能标记主会话;请指定 <peer>/<threadId>');
|
|
343
|
-
const clear = flags.clear === true;
|
|
344
|
-
const labelArg = stripRefArg(positional, ref).join(' ').trim();
|
|
345
|
-
if (!clear && !labelArg)
|
|
346
|
-
return error('用法: /thread label <标签> 或 /thread label --clear');
|
|
347
|
-
const label = clear ? null : labelArg;
|
|
348
|
-
await service.labelThread({ selfAid: ctx.selfAid, peer: target.peer, threadId: target.threadId, label });
|
|
349
|
-
return result(clear ? '✅ 已清除标签' : `✅ 已设置标签: ${label}`);
|
|
350
|
-
}
|
|
351
332
|
if (sub === 'status') {
|
|
352
333
|
const ref = refSource(positional, flags);
|
|
353
334
|
const target = resolveRef(ref, ctx, service);
|
|
@@ -416,8 +397,6 @@ async function listThreads(ctx, service, positional, flags) {
|
|
|
416
397
|
selfAid: ctx.selfAid,
|
|
417
398
|
...(peer ? { peer } : {}),
|
|
418
399
|
...(status ? { status } : {}),
|
|
419
|
-
...(typeof flags.label === 'string' ? { label: flags.label } : {}),
|
|
420
|
-
...(flags.unlabeled === true ? { unlabeled: true } : {}),
|
|
421
400
|
...(flags.sort === 'created' ? { sort: 'created' } : {}),
|
|
422
401
|
page: Number.isFinite(page) && page > 0 ? page : 1,
|
|
423
402
|
limit: Number.isFinite(limit) && limit > 0 ? limit : 10,
|
|
@@ -14,13 +14,15 @@ import { TriggerDefinitionManager } from '../trigger/manager.js';
|
|
|
14
14
|
import { seedUpgradeCheckTrigger } from '../trigger/system-definitions.js';
|
|
15
15
|
import { ownerResolver } from './ownership/owner-resolver.js';
|
|
16
16
|
import { ecwebInitializationService } from './initialization/service.js';
|
|
17
|
+
import { readServiceProxySnapshot, ServiceProxyManager } from '../proxy/manager.js';
|
|
17
18
|
export function detectAvailableBaseagents() {
|
|
18
19
|
// 与 init/ECWeb 的探测保持同一判据;claude 在这里也走内置二进制,
|
|
19
20
|
// 不再只看 PATH——否则 daemon 会对外声明一个实际跑不起来的 baseagent。
|
|
20
21
|
return detectBaseagentDetails().filter(item => item.detected).map(item => item.id);
|
|
21
22
|
}
|
|
22
|
-
export async function runBindBootstrapDaemon(daemonCfg) {
|
|
23
|
+
export async function runBindBootstrapDaemon(daemonCfg, ecwebSupervisor) {
|
|
23
24
|
logger.warn('[daemon-bootstrap] starting control AID + IPC only');
|
|
25
|
+
ecwebInitializationService.setRuntimeControlAid(daemonCfg.aid);
|
|
24
26
|
const bootstrapControlAid = daemonCfg.aid || '__daemon__';
|
|
25
27
|
try {
|
|
26
28
|
seedUpgradeCheckTrigger(new TriggerDefinitionManager(bootstrapControlAid), {
|
|
@@ -57,6 +59,8 @@ export async function runBindBootstrapDaemon(daemonCfg) {
|
|
|
57
59
|
aunTrace: daemonCfg.debug?.aunTrace,
|
|
58
60
|
aunSdkLog: daemonCfg.debug?.aunSdkLog,
|
|
59
61
|
});
|
|
62
|
+
const serviceManager = new ServiceProxyManager({ providerAid: daemonCfg.aid, controlChannel, ecwebSupervisor });
|
|
63
|
+
await serviceManager.start();
|
|
60
64
|
controlChannel.onMessage(async (opts) => {
|
|
61
65
|
const text = (opts.content || '').trim();
|
|
62
66
|
let parsed = null;
|
|
@@ -91,6 +95,7 @@ export async function runBindBootstrapDaemon(daemonCfg) {
|
|
|
91
95
|
channels: {},
|
|
92
96
|
channelsByType: {},
|
|
93
97
|
queue: { pending: 0, processing: 0 },
|
|
98
|
+
serviceProxy: readServiceProxySnapshot(serviceManager.transportSnapshot()),
|
|
94
99
|
controlAid: (() => {
|
|
95
100
|
const aidState = controlChannel?.getAidState();
|
|
96
101
|
return {
|
|
@@ -137,6 +142,8 @@ export async function runBindBootstrapDaemon(daemonCfg) {
|
|
|
137
142
|
}
|
|
138
143
|
catch { }
|
|
139
144
|
bindService.stopCleanup();
|
|
145
|
+
await serviceManager.stop();
|
|
146
|
+
await ecwebSupervisor?.stop();
|
|
140
147
|
if (controlChannel) {
|
|
141
148
|
try {
|
|
142
149
|
await controlChannel.disconnect();
|
|
@@ -17,14 +17,12 @@ import { subscribeUpgradeJob } from '../utils/upgrade-jobs.js';
|
|
|
17
17
|
import { subscribeTemplateJob } from '../agent-template/service.js';
|
|
18
18
|
const controlMenuDeduper = new MenuRequestDeduper();
|
|
19
19
|
export function startDaemonControlAid({ daemonCfg, cmdHandler, bindService, diagService, getProcessOwners, ecwebSupervisor, onServiceProxyManager, connectChannel, startupTrace, waitForServices, }) {
|
|
20
|
-
if (!daemonCfg.aid)
|
|
21
|
-
return undefined;
|
|
22
20
|
const aunPath = resolvePaths().root;
|
|
23
|
-
const certKey = path.join(aunPath, 'AIDs', daemonCfg.aid, 'private', 'key.json');
|
|
24
|
-
if (!fs.existsSync(certKey)) {
|
|
21
|
+
const certKey = daemonCfg.aid ? path.join(aunPath, 'AIDs', daemonCfg.aid, 'private', 'key.json') : undefined;
|
|
22
|
+
if (certKey && !fs.existsSync(certKey)) {
|
|
25
23
|
logger.warn(`控制 AID 证书缺失:${daemonCfg.aid}(AUN 控制通道后台重连;如需重建运行 ec init)`);
|
|
26
24
|
}
|
|
27
|
-
const controlChannel = new AUNChannel({
|
|
25
|
+
const controlChannel = daemonCfg.aid ? new AUNChannel({
|
|
28
26
|
aid: daemonCfg.aid,
|
|
29
27
|
agentName: daemonCfg.aid,
|
|
30
28
|
channelName: 'control',
|
|
@@ -32,8 +30,8 @@ export function startDaemonControlAid({ daemonCfg, cmdHandler, bindService, diag
|
|
|
32
30
|
defaultEncrypt: daemonCfg.aun?.defaultEncrypt,
|
|
33
31
|
aunTrace: daemonCfg.debug?.aunTrace,
|
|
34
32
|
aunSdkLog: daemonCfg.debug?.aunSdkLog,
|
|
35
|
-
});
|
|
36
|
-
const serviceProxyManager = new ServiceProxyManager({ providerAid: daemonCfg.aid, controlChannel, ecwebSupervisor: ecwebSupervisor ?? undefined, startupTrace });
|
|
33
|
+
}) : undefined;
|
|
34
|
+
const serviceProxyManager = new ServiceProxyManager({ providerAid: daemonCfg.aid ?? '', controlChannel, ecwebSupervisor: ecwebSupervisor ?? undefined, startupTrace });
|
|
37
35
|
onServiceProxyManager?.(serviceProxyManager);
|
|
38
36
|
let stopping = false;
|
|
39
37
|
onShutdown(() => { stopping = true; return serviceProxyManager.stop(); });
|
|
@@ -52,6 +50,8 @@ export function startDaemonControlAid({ daemonCfg, cmdHandler, bindService, diag
|
|
|
52
50
|
void proxyStartup.catch((error) => {
|
|
53
51
|
logger.warn(`ServiceProxy manager 启动失败(不影响 daemon 主流程): ${error?.message || error}`);
|
|
54
52
|
});
|
|
53
|
+
if (!controlChannel)
|
|
54
|
+
return undefined;
|
|
55
55
|
controlChannel.onMessage(async (opts) => {
|
|
56
56
|
const text = (opts.content || '').trim();
|
|
57
57
|
let activeMenuRequest;
|