evolcore 0.0.42 → 0.0.43-test.1
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 +35 -0
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/agent-runtime.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +5 -3
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -9,8 +9,10 @@ import { RESTART_REQUEST_ID_ENV } from '../../product.js';
|
|
|
9
9
|
import crypto from 'crypto';
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import fs from 'fs';
|
|
12
|
-
import { ensureFreshPackageVersionInfo
|
|
12
|
+
import { ensureFreshPackageVersionInfo } from '../../utils/package-version-info.js';
|
|
13
|
+
import { executeUpgradeAction, formatUpgradeResult, subscribeUpgradeJob } from '../../utils/upgrade-jobs.js';
|
|
13
14
|
import { loadDaemonConfig } from '../../config-store.js';
|
|
15
|
+
import { formatPairingCodeMessage } from '../../ecweb/pairing.js';
|
|
14
16
|
import { remoteAccessService } from '../auth/remote-access-store.js';
|
|
15
17
|
import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, } from '../../config/config-manager.js';
|
|
16
18
|
import { execAgentAction } from './agent-control.js';
|
|
@@ -40,6 +42,19 @@ import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
|
40
42
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
41
43
|
const allEfforts = CONFIGURABLE_EFFORTS;
|
|
42
44
|
const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
|
|
45
|
+
function formatUpgradeEvent(event) {
|
|
46
|
+
if (event.event === 'upgrade.progress')
|
|
47
|
+
return `⏳ ${event.message}`;
|
|
48
|
+
if (event.status === 'no-update')
|
|
49
|
+
return '✓ 当前 EvolCore 已是最新版本';
|
|
50
|
+
if (event.status === 'restart-started')
|
|
51
|
+
return '✅ 升级包已准备完成,服务正在重启';
|
|
52
|
+
if (event.status === 'timeout')
|
|
53
|
+
return `❌ 升级超时:${event.reason ?? event.message}`;
|
|
54
|
+
if (event.status === 'failed')
|
|
55
|
+
return `❌ 升级失败:${event.reason ?? event.message}`;
|
|
56
|
+
return event.success === false ? `❌ ${event.reason ?? event.message}` : event.message;
|
|
57
|
+
}
|
|
43
58
|
function defaultSlashChatmode(field) {
|
|
44
59
|
return field === 'private' ? 'interactive' : 'proactive';
|
|
45
60
|
}
|
|
@@ -198,6 +213,11 @@ async function authorizeSlashIntent(params) {
|
|
|
198
213
|
if (intent.scope === 'relation') {
|
|
199
214
|
intent.args = buildSlashRelationIntentArgs({ args: intent.args, selfAid: subject.selfAid, peerKey: subject.peerKey ?? peerKey });
|
|
200
215
|
}
|
|
216
|
+
if (intent.scope === 'agent' || intent.scope === 'relation') {
|
|
217
|
+
const selectedAid = typeof intent.args.aid === 'string' ? intent.args.aid
|
|
218
|
+
: typeof intent.args.self === 'string' ? intent.args.self : subject.selfAid;
|
|
219
|
+
intent.args = { ...intent.args, targetAgentAid: selectedAid };
|
|
220
|
+
}
|
|
201
221
|
const decision = await authorizeFreshOperation({ source: 'slash', intent, subject });
|
|
202
222
|
if (!decision.allow) {
|
|
203
223
|
const reasonCode = decision.command?.reasonCode;
|
|
@@ -236,6 +256,8 @@ function buildSlashRelationIntentArgs(params) {
|
|
|
236
256
|
const out = { ...(params.args ?? {}) };
|
|
237
257
|
if (params.selfAid && out.self === undefined)
|
|
238
258
|
out.self = params.selfAid;
|
|
259
|
+
if (params.selfAid && out.targetAgentAid === undefined)
|
|
260
|
+
out.targetAgentAid = params.selfAid;
|
|
239
261
|
if (params.peerKey && out.peer === undefined && out.peerKey === undefined)
|
|
240
262
|
out.peer = params.peerKey;
|
|
241
263
|
return out;
|
|
@@ -404,7 +426,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
404
426
|
await refreshOwnershipForAuthorization(selfAID ?? this.agentRegistry?.resolveByChannel(channel)?.aid ?? this.resolveSelfAID(channel), {
|
|
405
427
|
maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS,
|
|
406
428
|
allowTransient: true,
|
|
407
|
-
includeDaemon: /^\/(?:restart|upgrade|reload|pair|fa|fullaccess|diag)(?:\s|$)/i.test(normalizedContent),
|
|
429
|
+
includeDaemon: /^\/(?:restart|upgrade|update|reload|pair|fa|fullaccess|diag)(?:\s|$)/i.test(normalizedContent),
|
|
408
430
|
});
|
|
409
431
|
const identityConversationId = narrowedChatType === 'group' ? channelId : userId;
|
|
410
432
|
const resolvedIdentity = overrideIdentity ?? this.sessionManager.resolveIdentity(channel, userId, narrowedChatType, identityConversationId);
|
|
@@ -513,6 +535,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
513
535
|
const args = scope === 'relation'
|
|
514
536
|
? buildSlashRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
|
|
515
537
|
: scope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
|
|
538
|
+
if (authSubject.selfAid)
|
|
539
|
+
args.targetAgentAid = authSubject.selfAid;
|
|
516
540
|
return authorizeOperation({
|
|
517
541
|
source: 'slash',
|
|
518
542
|
intent: { operation, scope, source: 'slash', args },
|
|
@@ -520,10 +544,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
520
544
|
audit: false,
|
|
521
545
|
}).allow;
|
|
522
546
|
};
|
|
523
|
-
// roleGuard 仅对进程级命令(/restart /upgrade /reload)放行 daemon owner 绕过,
|
|
547
|
+
// roleGuard 仅对进程级命令(/restart /upgrade /update /reload)放行 daemon owner 绕过,
|
|
524
548
|
// 其余命令严格按 agent-channel 的 isAdmin 判定,不越权。
|
|
525
549
|
const isProcessLevelSlash = normalizedContent === '/restart'
|
|
526
550
|
|| normalizedContent === '/upgrade'
|
|
551
|
+
|| /^\/update(?:\s|$)/.test(normalizedContent)
|
|
527
552
|
|| normalizedContent === '/reload'
|
|
528
553
|
|| normalizedContent.startsWith('/reload ')
|
|
529
554
|
|| normalizedContent === '/pair'
|
|
@@ -855,7 +880,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
855
880
|
const appendProcessCommands = (lines) => {
|
|
856
881
|
if (!isDaemonOwner)
|
|
857
882
|
return;
|
|
858
|
-
lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
|
|
883
|
+
lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /update [status] - 执行版本升级或查询当前升级状态', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
|
|
859
884
|
};
|
|
860
885
|
if (!isAdmin && activeChatType === 'group') {
|
|
861
886
|
const lines = [
|
|
@@ -1023,10 +1048,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1023
1048
|
};
|
|
1024
1049
|
}
|
|
1025
1050
|
const pair = remoteAccessService.getPairingCode(userId, Date.now(), 'pair');
|
|
1026
|
-
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
|
1027
1051
|
return {
|
|
1028
1052
|
kind: 'command.result',
|
|
1029
|
-
text:
|
|
1053
|
+
text: `${formatPairingCodeMessage(pair, loadDaemonConfig())}\n可用于 ECWeb 登录或远程 Menu 客户端授权`,
|
|
1030
1054
|
};
|
|
1031
1055
|
}
|
|
1032
1056
|
// /evolhelp 命令:返回 JSON 格式的命令列表(供程序解析)
|
|
@@ -1150,6 +1174,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1150
1174
|
cmds.push({ command: '/fa', aliases: ['/fullaccess'], args: '[on|off|<任务信息>]', description: '查看/切换当前 EC 会话 fullaccess,或单次执行 fullaccess 任务', category: '权限管理', roles: ['daemon-owner'] });
|
|
1151
1175
|
cmds.push({ command: '/restart', description: '重启服务', category: '运维', roles: ['daemon-owner'] });
|
|
1152
1176
|
cmds.push({ command: '/upgrade', description: '检查版本更新', category: '运维', roles: ['daemon-owner'] });
|
|
1177
|
+
cmds.push({ command: '/update', args: '[status]', description: '执行版本升级或查询当前升级状态', category: '运维', roles: ['daemon-owner'] });
|
|
1153
1178
|
cmds.push({ command: '/reload', args: '[aid]', description: '热重载 Agent 配置', category: '运维', roles: ['daemon-owner'] });
|
|
1154
1179
|
cmds.push({ command: '/pair', description: '获取远程控制配对码', category: '运维', roles: ['daemon-owner'] });
|
|
1155
1180
|
cmds.push({ command: '/diag', args: '<问题描述>|stop', description: '邀请/追加远程诊断或撤销授权', category: '运维', roles: ['daemon-owner'] });
|
|
@@ -3281,14 +3306,19 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3281
3306
|
// executeRestart 内部已经发送了反馈消息,这里返回 null 避免重复发送
|
|
3282
3307
|
return null;
|
|
3283
3308
|
}
|
|
3284
|
-
//
|
|
3285
|
-
if (normalizedContent === '/upgrade') {
|
|
3309
|
+
// Slash only adapts presentation; all upgrade work uses the shared service.
|
|
3310
|
+
if (normalizedContent === '/upgrade' || /^\/update(?:\s|$)/.test(normalizedContent)) {
|
|
3311
|
+
const mode = normalizedContent === '/upgrade' ? 'check'
|
|
3312
|
+
: normalizedContent === '/update' ? 'update'
|
|
3313
|
+
: /^\/update\s+status$/.test(normalizedContent) ? 'status' : undefined;
|
|
3314
|
+
if (!mode)
|
|
3315
|
+
return { kind: 'command.error', text: '用法:/update [status]', reason: 'INVALID_ARGUMENT' };
|
|
3286
3316
|
const upgradeAuthDenied = await authorizeIntent({
|
|
3287
3317
|
intent: {
|
|
3288
|
-
operation: 'system.upgrade',
|
|
3318
|
+
operation: mode === 'check' ? 'system.upgrade.check' : mode === 'update' ? 'system.update' : 'system.update.status',
|
|
3289
3319
|
scope: 'process',
|
|
3290
3320
|
source: 'slash',
|
|
3291
|
-
args: {},
|
|
3321
|
+
args: { mode },
|
|
3292
3322
|
dangerous: true,
|
|
3293
3323
|
},
|
|
3294
3324
|
identity,
|
|
@@ -3301,21 +3331,33 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3301
3331
|
});
|
|
3302
3332
|
if (upgradeAuthDenied)
|
|
3303
3333
|
return upgradeAuthDenied;
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3334
|
+
try {
|
|
3335
|
+
const data = await executeUpgradeAction(mode, messageId || crypto.randomUUID(), 'system-upgrade-singleton');
|
|
3336
|
+
if (mode === 'update' && 'jobId' in data && sendMessage) {
|
|
3337
|
+
subscribeUpgradeJob(data.jobId, async (event) => {
|
|
3338
|
+
const denied = await authorizeIntent({
|
|
3339
|
+
intent: { operation: 'system.update.status', scope: 'process', source: 'slash', args: { mode: 'status' } },
|
|
3340
|
+
identity, session: activeSession, channel, channelId, userId,
|
|
3341
|
+
selfAid: authSubject.selfAid, isDaemonOwner,
|
|
3342
|
+
});
|
|
3343
|
+
if (denied)
|
|
3344
|
+
throw new Error('Upgrade event authorization expired');
|
|
3345
|
+
const text = formatUpgradeEvent(event);
|
|
3346
|
+
await sendMessage(channelId, text, replyContext, { kind: 'command.result', text });
|
|
3347
|
+
}, ['slash', channel, channelId, userId || '', threadId || '', data.jobId].join('\u001f'));
|
|
3348
|
+
}
|
|
3349
|
+
return {
|
|
3350
|
+
kind: 'command.result',
|
|
3351
|
+
text: formatUpgradeResult(data).replace('请执行 update', '请执行 /update'),
|
|
3352
|
+
};
|
|
3353
|
+
}
|
|
3354
|
+
catch (error) {
|
|
3355
|
+
return {
|
|
3356
|
+
kind: 'command.error',
|
|
3357
|
+
text: `❌ ${error instanceof Error ? error.message : String(error)}`,
|
|
3358
|
+
reason: error.code ?? 'UPGRADE_FAILED',
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3319
3361
|
}
|
|
3320
3362
|
// /pwd 命令:显示当前项目路径
|
|
3321
3363
|
if (normalizedContent === '/pwd') {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class ContactBindRegistry {
|
|
2
|
+
providers = new Map();
|
|
3
|
+
register(channelType, provider) {
|
|
4
|
+
const normalizedType = channelType.trim().toLowerCase();
|
|
5
|
+
if (!normalizedType)
|
|
6
|
+
throw new Error('Contact-bind channel type must not be empty');
|
|
7
|
+
if (this.providers.has(normalizedType)) {
|
|
8
|
+
throw new Error(`Contact-bind provider '${normalizedType}' already registered`);
|
|
9
|
+
}
|
|
10
|
+
this.providers.set(normalizedType, provider);
|
|
11
|
+
}
|
|
12
|
+
get(channelType) {
|
|
13
|
+
return this.providers.get(channelType.trim().toLowerCase());
|
|
14
|
+
}
|
|
15
|
+
channelTypes() {
|
|
16
|
+
return [...this.providers.keys()];
|
|
17
|
+
}
|
|
18
|
+
handle(channelType, context) {
|
|
19
|
+
return this.get(channelType)?.handle(context) ?? { handled: false };
|
|
20
|
+
}
|
|
21
|
+
registerPending(channelType, request) {
|
|
22
|
+
const provider = this.get(channelType);
|
|
23
|
+
return provider
|
|
24
|
+
? provider.register(request)
|
|
25
|
+
: { ok: false, error: `contact bind provider not configured for channel '${channelType}'` };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { AUNChannel } from '../channels/aun.js';
|
|
4
4
|
import { ServiceProxyManager } from '../proxy/manager.js';
|
|
5
|
+
import { formatPairingCodeMessage } from '../ecweb/pairing.js';
|
|
5
6
|
import { remoteAccessService } from './auth/remote-access-store.js';
|
|
6
7
|
import { authorizationDenialData, formatAuthorizationDenial } from './auth/authorization-denial.js';
|
|
7
8
|
import { controlReplyContext } from './message/outbound.js';
|
|
@@ -161,8 +162,7 @@ export function startDaemonControlAid({ daemonCfg, cmdHandler, bindService, diag
|
|
|
161
162
|
}
|
|
162
163
|
if (text.toLowerCase() === '/pair') {
|
|
163
164
|
const pair = remoteAccessService.getPairingCode(opts.peerId, Date.now(), 'pair');
|
|
164
|
-
const
|
|
165
|
-
const reply = `远程控制配对码:${pair.code}(约 ${mins} 分钟内有效,仅可配对一次)`;
|
|
165
|
+
const reply = formatPairingCodeMessage(pair, daemonCfg);
|
|
166
166
|
await controlChannel.sendMessage(opts.channelId, reply, controlReplyContext(opts));
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
@@ -194,7 +194,7 @@ export function startDaemonControlAid({ daemonCfg, cmdHandler, bindService, diag
|
|
|
194
194
|
if (parsed?.type === 'menu.action' && parsed.action === 'upgrade' && (parsed.name === 'system' || parsed.cmd === '/system') && upgradeData?.jobId) {
|
|
195
195
|
const jobId = upgradeData.jobId;
|
|
196
196
|
subscribeUpgradeJob(jobId, async (event) => {
|
|
197
|
-
const permission = await cmdHandler.execMenuForControl({ type: 'menu.action', id: parsed.id, name: 'system', action: 'upgrade', args: { mode: 'status'
|
|
197
|
+
const permission = await cmdHandler.execMenuForControl({ type: 'menu.action', id: parsed.id, name: 'system', action: 'upgrade', args: { mode: 'status' } }, opts.peerId, {
|
|
198
198
|
encrypted: opts.encrypted, protectedHeaders: opts.protectedHeaders,
|
|
199
199
|
});
|
|
200
200
|
if (permission.error)
|
|
@@ -166,7 +166,7 @@ export function resumePendingSessions({ sessionManager, messageQueue, droppedTri
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
export function createDaemonShutdown({ ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, controlChannel, sessionManager, removeAll, exit, }) {
|
|
169
|
+
export function createDaemonShutdown({ disposePluginResources, ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, controlChannel, sessionManager, removeAll, exit, }) {
|
|
170
170
|
let shutdownSignal = 'unknown';
|
|
171
171
|
let shutdownInProgress = false;
|
|
172
172
|
return async (signal, traceId) => {
|
|
@@ -271,6 +271,7 @@ export function createDaemonShutdown({ ipcServer, readySignalPath, bindService,
|
|
|
271
271
|
logger.error(`[Shutdown] Unexpected shutdown failure: ${error instanceof Error ? error.stack || error.message : String(error)}`);
|
|
272
272
|
}
|
|
273
273
|
finally {
|
|
274
|
+
await shutdownStep('daemon.pluginResources', 'dispose plugin resources', async () => { await disposePluginResources?.(); });
|
|
274
275
|
await shutdownStep('daemon.finalizers', 'remove permission config listener', () => removePermissionConfigListener?.());
|
|
275
276
|
await shutdownStep('daemon.statsPersistence', 'stop stats persistence', () => stopStatsPersistence?.());
|
|
276
277
|
await shutdownStep('daemon.sessionManager', 'close session manager', () => { sessionManager.close(); });
|
package/dist/core/event-bus.js
CHANGED
|
@@ -16,12 +16,19 @@ export class EventBus extends EventEmitter {
|
|
|
16
16
|
}
|
|
17
17
|
subscribe(eventType, handler) {
|
|
18
18
|
this.on(eventType, handler);
|
|
19
|
+
let subscribed = true;
|
|
20
|
+
return () => {
|
|
21
|
+
if (!subscribed)
|
|
22
|
+
return;
|
|
23
|
+
subscribed = false;
|
|
24
|
+
this.off(eventType, handler);
|
|
25
|
+
};
|
|
19
26
|
}
|
|
20
27
|
subscribeAll(handler) {
|
|
21
|
-
this.
|
|
28
|
+
return this.subscribe('*', handler);
|
|
22
29
|
}
|
|
23
30
|
subscribePrefix(prefix, handler) {
|
|
24
|
-
this.
|
|
31
|
+
return this.subscribe('*', (event) => {
|
|
25
32
|
if (event.type.startsWith(prefix))
|
|
26
33
|
handler(event);
|
|
27
34
|
});
|
|
@@ -10,8 +10,7 @@ import fs from 'node:fs';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { parseDocument } from 'yaml';
|
|
12
12
|
import { resolvePaths, agentMdPath } from '../paths.js';
|
|
13
|
-
import { readHostInfo, probeVirtualization, probeRuntimes } from '../utils/host-info.js';
|
|
14
|
-
import { readVersionInfo, readRuntimeInfo } from '../utils/machine-info.js';
|
|
13
|
+
import { readHostInfo, probeVirtualization, probeRuntimes, readVersionInfo, readRuntimeInfo } from '../utils/host-info.js';
|
|
15
14
|
import { loadDaemonConfig } from '../config-store.js';
|
|
16
15
|
const EMPTY_RUNTIMES = { python: null, go: null, claudeCode: null, claudeCodeBundled: null, codex: null, ecagent: null };
|
|
17
16
|
function staticCachePath() {
|
|
@@ -157,9 +157,9 @@ export class EcwebInitializationService {
|
|
|
157
157
|
const firstProvider = (id) => providerServiceTypesForBaseagent(id)
|
|
158
158
|
.map(type => Object.entries(providers.providers).find(([, provider]) => Object.hasOwn(provider.services ?? {}, type))?.[0])
|
|
159
159
|
.find(providerId => providerId !== undefined);
|
|
160
|
-
const ecagentProvider =
|
|
161
|
-
if (
|
|
162
|
-
fail('PROVIDER_REQUIRED', '
|
|
160
|
+
const ecagentProvider = firstProvider('ecagent');
|
|
161
|
+
if (baseagent === 'ecagent' && !ecagentProvider)
|
|
162
|
+
fail('PROVIDER_REQUIRED', '当前默认 Base Agent 是 ecagent,但尚无可用服务商配置。请先导入服务商配置,或返回选择其他 Base Agent。', 409);
|
|
163
163
|
const ecagentModel = ecagentProvider ? await resolveEcagentDefaultModel(ecagentProvider) : undefined;
|
|
164
164
|
try {
|
|
165
165
|
mutateConfig(ConfigTarget.Defaults, undefined, config => {
|
|
@@ -175,11 +175,11 @@ export class EcwebInitializationService {
|
|
|
175
175
|
: state.providerIds?.[id]
|
|
176
176
|
|| (providerSupportsBaseagent(providers.providers[previousProvider], id) ? previousProvider : undefined)
|
|
177
177
|
|| firstProvider(id);
|
|
178
|
-
if (
|
|
178
|
+
if (provider && providerSupportsBaseagent(providers.providers[provider], id))
|
|
179
|
+
config.baseagents[id] = { ...previous, provider };
|
|
180
|
+
else if (id === baseagent)
|
|
179
181
|
fail('PROVIDER_REQUIRED', `未找到可用于 ${id} 的服务商,请先导入对应配置后重试`, 409);
|
|
180
|
-
|
|
181
|
-
config.baseagents[id] = { ...previous, provider };
|
|
182
|
-
if (id === 'ecagent') {
|
|
182
|
+
if (id === 'ecagent' && config.baseagents[id] && ecagentModel) {
|
|
183
183
|
config.baseagents[id].model = ecagentModel;
|
|
184
184
|
delete config.baseagents[id].effort;
|
|
185
185
|
}
|
|
@@ -195,10 +195,15 @@ export class EcwebInitializationService {
|
|
|
195
195
|
requireDefaults(state, inventory) {
|
|
196
196
|
const defaults = baseagentDefaults();
|
|
197
197
|
const providers = readProvidersSnapshot();
|
|
198
|
+
const configured = inventory.baseagents.filter(item => item.detected);
|
|
199
|
+
const defaultsComplete = configured.every(item => {
|
|
200
|
+
const selected = defaults[item.id];
|
|
201
|
+
return !!selected?.provider
|
|
202
|
+
&& providerSupportsBaseagent(providers.providers[selected.provider], item.id)
|
|
203
|
+
&& (item.id !== 'ecagent' || !!selected.model?.trim());
|
|
204
|
+
});
|
|
198
205
|
const active = inventory.baseagents.find(item => item.id === inventory.active && item.detected);
|
|
199
|
-
if (!state.baseagent || !active ||
|
|
200
|
-
&& !defaults.ecagent?.model?.trim()) || inventory.baseagents.some(item => item.detected
|
|
201
|
-
&& !providerSupportsBaseagent(providers.providers[defaults[item.id]?.provider ?? ''], item.id))) {
|
|
206
|
+
if (!state.baseagent || !active || !defaultsComplete) {
|
|
202
207
|
fail('DEFAULTS_REQUIRED', '默认 Base Agent 或服务商配置未保存完整,请返回配置步骤重新保存', 409);
|
|
203
208
|
}
|
|
204
209
|
return defaults;
|
|
@@ -485,7 +490,19 @@ export class EcwebInitializationService {
|
|
|
485
490
|
else
|
|
486
491
|
return fail('INVALID_SOURCE', 'Provider 来源无效');
|
|
487
492
|
try {
|
|
488
|
-
|
|
493
|
+
if (body.resolution !== undefined && !['create', 'merge', 'cancel'].includes(String(body.resolution)))
|
|
494
|
+
fail('INVALID_REQUEST', '服务商导入决策无效');
|
|
495
|
+
if (body.name !== undefined && typeof body.name !== 'string')
|
|
496
|
+
fail('INVALID_REQUEST', '服务商名称无效');
|
|
497
|
+
if (body.serviceDecisions !== undefined && !record(body.serviceDecisions))
|
|
498
|
+
fail('INVALID_REQUEST', '服务类型冲突决策无效');
|
|
499
|
+
const data = await importOrMergeBaseagentProvider({
|
|
500
|
+
revision: body.revision, value: provider,
|
|
501
|
+
resolution: body.resolution,
|
|
502
|
+
name: body.name,
|
|
503
|
+
serviceDecisions: body.serviceDecisions,
|
|
504
|
+
requireResolution: true,
|
|
505
|
+
});
|
|
489
506
|
if (!state.providerIds)
|
|
490
507
|
state.providerIds = {};
|
|
491
508
|
state.providerIds[body.id] = data.providerId;
|
|
@@ -500,6 +517,10 @@ export class EcwebInitializationService {
|
|
|
500
517
|
catch (error) {
|
|
501
518
|
if (error.code === 'INIT_STATE_SAVE_FAILED')
|
|
502
519
|
throw error;
|
|
520
|
+
if (error.code === 'PROVIDER_CONFLICT') {
|
|
521
|
+
const details = error;
|
|
522
|
+
return { status: 409, body: { success: false, code: 'PROVIDER_CONFLICT', error: details.message || 'Provider conflict requires a decision', data: details.data } };
|
|
523
|
+
}
|
|
503
524
|
if (error.statusCode === 409)
|
|
504
525
|
fail('REVISION_CONFLICT', '配置已变更,请刷新预览后重新确认', 409);
|
|
505
526
|
return fail('PROVIDER_IMPORT_FAILED', 'Provider 导入失败,未返回凭据详情');
|
|
@@ -16,7 +16,6 @@ import { buildDebugTaskContext } from './auth/debug-context.js';
|
|
|
16
16
|
import { loadAgent } from '../config-store.js';
|
|
17
17
|
import { executeLocalInitializationCommand, hasSuppliedInitialization } from '../cli/agent-create.js';
|
|
18
18
|
import { remoteAccessService } from './auth/remote-access-store.js';
|
|
19
|
-
import { createDelegationAuthorizer } from './auth/delegation-authorization.js';
|
|
20
19
|
import { executeDiagIpc } from './command/diag-service.js';
|
|
21
20
|
import { registerAgentOperationExecutor } from './agent-ipc-registration.js';
|
|
22
21
|
import { registerHandoffIpc } from './handoff/ipc-registration.js';
|
|
@@ -27,14 +26,26 @@ import { createThreadOperationExecutor } from './thread/ipc-operation.js';
|
|
|
27
26
|
import { isLinkedInstall } from '../utils/npm-ops.js';
|
|
28
27
|
import { buildSystemSessionContext, getSystemSessionModule } from './system-session/registry.js';
|
|
29
28
|
import { parseManagedDaemonLogArgv, queryDiagnosticLogs } from './command/daemon-diagnostics.js';
|
|
30
|
-
|
|
29
|
+
import { createDelegationAuthorizer, createDelegatedProviderOperationExecutor, createDelegatedUpgradeOperationExecutor } from './auth/delegation-authorization.js';
|
|
30
|
+
export function registerDaemonIpc({ lifecycle, ipcServer, agentRegistry, agentDelegationRegistry, sessionManager, statsCollector, aidStatsCollector, responseEngine, messageQueue, agentMap, commandHandler, channelInstances, eventBus, handoffRuntime, reloadCoordinator, agentApplicationService, agentInitializationService, enqueueConsolidation, getRelationRoute, isConsolidationPending, completeAgentBootstrap, contactBinds, bindService, diagService, getProcessOwners, getControlAidState, daemonAid, triggerControlToken, triggerSchedulers, daemonTriggerOwner, primaryAgent, triggerAuthorization, }) {
|
|
31
31
|
ecwebInitializationService.setAgentInitializer(agentInitializationService);
|
|
32
32
|
const authorizeManagedAgentOperation = createDelegationAuthorizer({
|
|
33
33
|
agentDelegationRegistry,
|
|
34
34
|
sessionManager,
|
|
35
35
|
getProcessOwners,
|
|
36
36
|
});
|
|
37
|
+
ipcServer.setProviderExecutor(createDelegatedProviderOperationExecutor({
|
|
38
|
+
agentDelegationRegistry,
|
|
39
|
+
sessionManager,
|
|
40
|
+
getProcessOwners,
|
|
41
|
+
}));
|
|
42
|
+
ipcServer.setUpgradeExecutor(createDelegatedUpgradeOperationExecutor({
|
|
43
|
+
agentDelegationRegistry,
|
|
44
|
+
sessionManager,
|
|
45
|
+
getProcessOwners,
|
|
46
|
+
}));
|
|
37
47
|
registerCommandIpcProviders({
|
|
48
|
+
lifecycle,
|
|
38
49
|
ipcServer,
|
|
39
50
|
agentRegistry,
|
|
40
51
|
triggerControlToken,
|
|
@@ -62,7 +73,7 @@ export function registerDaemonIpc({ ipcServer, agentRegistry, agentDelegationReg
|
|
|
62
73
|
agentMap,
|
|
63
74
|
isLinkedInstall: isLinkedInstall(),
|
|
64
75
|
});
|
|
65
|
-
ipcServer.setEcwebMessageContextProvider(createEcwebMessageContextProvider(sessionManager, session => {
|
|
76
|
+
const unregisterMessageContext = ipcServer.setEcwebMessageContextProvider(createEcwebMessageContextProvider(sessionManager, session => {
|
|
66
77
|
const queued = messageQueue.isProcessing(session.id) || messageQueue.getQueueLength(session.id) > 0;
|
|
67
78
|
try {
|
|
68
79
|
const runner = responseEngine.getAgent(session.metadata?.channelKey || session.channel, session.baseagent, session.selfAID);
|
|
@@ -78,6 +89,7 @@ export function registerDaemonIpc({ ipcServer, agentRegistry, agentDelegationReg
|
|
|
78
89
|
return queued ? 'processing' : undefined;
|
|
79
90
|
}
|
|
80
91
|
}));
|
|
92
|
+
lifecycle?.defer(unregisterMessageContext, 'ipc:ecweb.message.context');
|
|
81
93
|
if (process.env.EVOLCORE_DEBUG_MODE === '1') {
|
|
82
94
|
ipcServer.setDebugIssueTokenExecutor(async ({ sessionId }) => {
|
|
83
95
|
try {
|
|
@@ -550,7 +562,7 @@ export function registerQueueIpcProviders({ ipcServer, statsCollector, agentRegi
|
|
|
550
562
|
}
|
|
551
563
|
});
|
|
552
564
|
}
|
|
553
|
-
export function registerCommandIpcProviders({ ipcServer, agentRegistry, triggerControlToken, remoteAccessService, authorizeManagedAgentOperation, hasSuppliedInitialization, loadAgent, completeAgentBootstrap, contactBinds, cmdHandler, executeDiag, channelInstances, getControlAidState, daemonAid, bindService, }) {
|
|
565
|
+
export function registerCommandIpcProviders({ lifecycle, ipcServer, agentRegistry, triggerControlToken, remoteAccessService, authorizeManagedAgentOperation, hasSuppliedInitialization, loadAgent, completeAgentBootstrap, contactBinds, cmdHandler, executeDiag, channelInstances, getControlAidState, daemonAid, bindService, }) {
|
|
554
566
|
ipcServer.setAgentRegistry(agentRegistry);
|
|
555
567
|
ipcServer.setControlToken(triggerControlToken);
|
|
556
568
|
ipcServer.setRemoteAccessService(remoteAccessService);
|
|
@@ -584,7 +596,8 @@ export function registerCommandIpcProviders({ ipcServer, agentRegistry, triggerC
|
|
|
584
596
|
ipcServer.setQQBotContactBindExecutor(contactBinds.qqbot);
|
|
585
597
|
ipcServer.setWecomContactBindExecutor(contactBinds.wecom);
|
|
586
598
|
ipcServer.setWechatContactBindExecutor(contactBinds.wechat);
|
|
587
|
-
ipcServer.setMenuExecutor((payload, auth) => cmdHandler.execMenuForEcweb(payload, auth));
|
|
599
|
+
const unregisterMenu = ipcServer.setMenuExecutor((payload, auth) => cmdHandler.execMenuForEcweb(payload, auth));
|
|
600
|
+
lifecycle?.defer(unregisterMenu, 'ipc:menu.exec');
|
|
588
601
|
ipcServer.setConfigOperationExecutor((argv, sessionId, delegationToken, delegationCommandHash, requestId) => cmdHandler.handleConfigOperation(argv, sessionId, delegationToken, delegationCommandHash, requestId));
|
|
589
602
|
ipcServer.setPeerOperationExecutor((argv, sessionId, delegationToken, delegationCommandHash) => cmdHandler.handleContactOperation(argv, sessionId, delegationToken, delegationCommandHash));
|
|
590
603
|
ipcServer.setRoleOperationExecutor((argv, sessionId, delegationToken, delegationCommandHash) => cmdHandler.handleRoleOperation(argv, sessionId, delegationToken, delegationCommandHash));
|
|
@@ -637,11 +637,11 @@ export function serializeConsolidationContext(input) {
|
|
|
637
637
|
}
|
|
638
638
|
lines.push('请按照本次会话注入的模式手册完成整理。');
|
|
639
639
|
lines.push('');
|
|
640
|
-
lines.push('
|
|
640
|
+
lines.push('正式记忆只能用单条 `ec memory create|update|archive` 命令写入;整理结束后,再把整体反馈写入以下**反馈文件路径**。反馈文件是唯一的文件写入例外:优先用 Write / Edit;没有文件写入工具时,可用系统会话明确允许的、仅修改该反馈文件的 `apply_patch`:');
|
|
641
641
|
lines.push('');
|
|
642
642
|
lines.push(`\`${feedbackFilePath(batchDir)}\``);
|
|
643
643
|
lines.push('');
|
|
644
|
-
lines.push('
|
|
644
|
+
lines.push('这是本次会话唯一可以直接写入的文件(文件已建好,直接写即可);写别的路径会被拒绝。不要用 shell 重定向、`tee` 或其它写入命令。');
|
|
645
645
|
lines.push('未写入则收尾时回退到默认统计模板(模式、触发方式、耗时、新建/更新/归档条数等)。');
|
|
646
646
|
const text = lines.join('\n');
|
|
647
647
|
// ── 写批次目录(任务书唯一落点)────────────────────────────────────────────
|