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
package/dist/cli/code-stats.js
CHANGED
|
@@ -204,11 +204,11 @@ function listUntrackedFiles(pkgRoot, pathspecs) {
|
|
|
204
204
|
return [];
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
function countFileSet(files) {
|
|
207
|
+
function countFileSet(files, countedLines) {
|
|
208
208
|
let lines = 0;
|
|
209
209
|
for (const file of files) {
|
|
210
210
|
try {
|
|
211
|
-
lines += countFileLines(file);
|
|
211
|
+
lines += countedLines?.get(file) ?? countFileLines(file);
|
|
212
212
|
}
|
|
213
213
|
catch {
|
|
214
214
|
/* 读不到的文件跳过 */
|
|
@@ -217,18 +217,21 @@ function countFileSet(files) {
|
|
|
217
217
|
return { lines, files: files.length };
|
|
218
218
|
}
|
|
219
219
|
export function collectTrackedComparison(pkgRoot) {
|
|
220
|
+
return collectTrackedComparisonFromFiles(pkgRoot, listTrackedFiles(pkgRoot));
|
|
221
|
+
}
|
|
222
|
+
function collectTrackedComparisonFromFiles(pkgRoot, trackedFiles, countedLines) {
|
|
220
223
|
const codeExt = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i;
|
|
221
|
-
const tracked =
|
|
224
|
+
const tracked = trackedFiles.map(file => path.relative(pkgRoot, file));
|
|
222
225
|
const pick = (list, match) => list.filter(match);
|
|
223
226
|
const untrackedMarkdown = listUntrackedFiles(pkgRoot, ['*.md', '*.mdx']);
|
|
224
227
|
const untrackedTests = listUntrackedFiles(pkgRoot, ['tests']).filter(file => codeExt.test(file));
|
|
225
228
|
return {
|
|
226
229
|
markdown: {
|
|
227
|
-
tracked: countFileSet(pick(tracked, item => /\.(md|mdx)$/i.test(item)).map(item => path.join(pkgRoot, item))),
|
|
230
|
+
tracked: countFileSet(pick(tracked, item => /\.(md|mdx)$/i.test(item)).map(item => path.join(pkgRoot, item)), countedLines),
|
|
228
231
|
untracked: countFileSet(untrackedMarkdown),
|
|
229
232
|
},
|
|
230
233
|
tests: {
|
|
231
|
-
tracked: countFileSet(pick(tracked, item => item.split(path.sep)[0] === 'tests' && codeExt.test(item)).map(item => path.join(pkgRoot, item))),
|
|
234
|
+
tracked: countFileSet(pick(tracked, item => item.split(path.sep)[0] === 'tests' && codeExt.test(item)).map(item => path.join(pkgRoot, item)), countedLines),
|
|
232
235
|
untracked: countFileSet(untrackedTests),
|
|
233
236
|
},
|
|
234
237
|
};
|
|
@@ -238,6 +241,9 @@ export function collectTrackedComparison(pkgRoot) {
|
|
|
238
241
|
* 先发现全部文件再归类,新目录/新扩展名不会被漏掉。
|
|
239
242
|
*/
|
|
240
243
|
export function collectCodeStats(pkgRoot, cacheFile) {
|
|
244
|
+
return collectCodeStatsFromFiles(pkgRoot, listTrackedFiles(pkgRoot), cacheFile);
|
|
245
|
+
}
|
|
246
|
+
function collectCodeStatsFromFiles(pkgRoot, trackedFiles, cacheFile, countedLines) {
|
|
241
247
|
const cache = cacheFile ? loadCache(cacheFile) : {};
|
|
242
248
|
const nextCache = {};
|
|
243
249
|
const sections = new Map(SECTIONS.map(def => [def.key, { ...def, lines: 0, files: 0 }]));
|
|
@@ -245,7 +251,7 @@ export function collectCodeStats(pkgRoot, cacheFile) {
|
|
|
245
251
|
const otherDirectories = new Set();
|
|
246
252
|
let cacheHits = 0;
|
|
247
253
|
let cacheMisses = 0;
|
|
248
|
-
for (const filePath of
|
|
254
|
+
for (const filePath of trackedFiles) {
|
|
249
255
|
const fileName = path.basename(filePath);
|
|
250
256
|
// 锁文件动辄几万行,且是生成物 —— 即便入库也不计入。
|
|
251
257
|
if (EXCLUDE_FILE_NAMES.has(fileName))
|
|
@@ -279,6 +285,7 @@ export function collectCodeStats(pkgRoot, cacheFile) {
|
|
|
279
285
|
cacheMisses++;
|
|
280
286
|
}
|
|
281
287
|
nextCache[relative] = { mtime, lines };
|
|
288
|
+
countedLines?.set(filePath, lines);
|
|
282
289
|
const language = languages.get(languageKey);
|
|
283
290
|
language.lines += lines;
|
|
284
291
|
language.files++;
|
|
@@ -525,11 +532,15 @@ export function printCodeStats(pkgRoot, logDir, options = {}) {
|
|
|
525
532
|
const cacheFile = options.cacheFile ?? path.join(logDir, 'code-stats-cache.json');
|
|
526
533
|
const dailyLimit = options.dailyLimit ?? 10;
|
|
527
534
|
console.log('\n[launcher] 正在统计代码行数...');
|
|
528
|
-
|
|
535
|
+
// Both tables describe this invocation's tracked files. Reuse its inventory
|
|
536
|
+
// and line counts instead of enumerating and reading them a second time.
|
|
537
|
+
const trackedFiles = listTrackedFiles(pkgRoot);
|
|
538
|
+
const countedLines = new Map();
|
|
539
|
+
const stats = collectCodeStatsFromFiles(pkgRoot, trackedFiles, cacheFile, countedLines);
|
|
529
540
|
console.log(`[launcher] 统计耗时: ${((Date.now() - startedAt) / 1000).toFixed(2)}秒\n`);
|
|
530
541
|
printLanguageTable(stats);
|
|
531
542
|
printSectionTable(stats);
|
|
532
|
-
printTrackedComparison(
|
|
543
|
+
printTrackedComparison(collectTrackedComparisonFromFiles(pkgRoot, trackedFiles, countedLines));
|
|
533
544
|
const records = readJsonArrayFile(historyFile);
|
|
534
545
|
const record = buildRecord(stats);
|
|
535
546
|
const previous = records.at(-1);
|
package/dist/cli/command-log.js
CHANGED
|
@@ -92,7 +92,7 @@ function loggableArgs(args) {
|
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
94
|
const flag = arg.replace(/^--?/, '').replace(/=.*$/, '').toLowerCase();
|
|
95
|
-
if (/^(?:remote-token|ecweb-token|menu-token|token|password|secret|workspace)$/.test(flag)) {
|
|
95
|
+
if (/^(?:api-key|remote-token|ecweb-token|menu-token|token|password|secret|workspace)$/.test(flag)) {
|
|
96
96
|
output.push(arg.includes('=') ? `${arg.slice(0, arg.indexOf('=') + 1)}[REDACTED]` : arg);
|
|
97
97
|
redactNext = !arg.includes('=');
|
|
98
98
|
continue;
|
|
@@ -16,7 +16,8 @@ import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
|
16
16
|
import { ensureFreshPackageVersionInfo } from '../utils/package-version-info.js';
|
|
17
17
|
import { ecwebVersionRequirementError, resolveEcwebLaunchCommand } from '../ecweb/runtime/launch.js';
|
|
18
18
|
import { stopEcwebForRestart } from '../ecweb/runtime/lifecycle.js';
|
|
19
|
-
import {
|
|
19
|
+
import { fetchRemotePairingCode, buildEcwebPairingUrl } from '../ecweb/pairing.js';
|
|
20
|
+
import { readEcwebProxyAccess } from '../ecweb/runtime/proxy-access.js';
|
|
20
21
|
import { isHostChinese } from '../utils/locale.js';
|
|
21
22
|
import { scanInstances, hasLiveMain, hasLiveRestartMonitor, cleanupInstances, findOrphanProcesses } from '../utils/instance-registry.js';
|
|
22
23
|
import { filterLogFiles, deriveLogTypes, computePreChecked, validateLogTypes, shortLogName as shortLogNameLocal, isWatchLogFile } from './watch-logs.js';
|
|
@@ -649,23 +650,12 @@ export async function cmdStart(opts = {}) {
|
|
|
649
650
|
const { autoMigrateIfNeeded } = await import('../config-store.js');
|
|
650
651
|
autoMigrateIfNeeded();
|
|
651
652
|
trace.mark('cli.initCheck');
|
|
652
|
-
const defaults = loadDefaults();
|
|
653
|
-
const hasAnyAgent = loadAllAgents().agents.length > 0;
|
|
654
|
-
if (!defaults && !hasAnyAgent && !opts.bindBootstrap) {
|
|
655
|
-
trace.finish(false);
|
|
656
|
-
process.exitCode = 1;
|
|
657
|
-
console.error('⚠ 未检测到初始化配置,请先运行 ec init;未启动 EvolCore。');
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
653
|
trace.mark('cli.controlAidCheck');
|
|
661
654
|
const daemonCfgStart = loadDaemonConfig();
|
|
662
655
|
if (!daemonCfgStart.aid) {
|
|
663
|
-
|
|
664
|
-
process.exitCode = 1;
|
|
665
|
-
console.error('⚠ 控制 AID 未配置,请先运行 ec init;未启动 EvolCore。');
|
|
666
|
-
return;
|
|
656
|
+
console.log('ℹ 主机身份待准备:先启动本地 ECWeb,运行 ec init --web 准备控制 AID。');
|
|
667
657
|
}
|
|
668
|
-
if (opts.webInit) {
|
|
658
|
+
if (opts.webInit && daemonCfgStart.aid) {
|
|
669
659
|
const { hasLocalControlIdentity, missingControlIdentityMessage } = await import('../aun/aid/control-aid.js');
|
|
670
660
|
if (!hasLocalControlIdentity(daemonCfgStart.aid)) {
|
|
671
661
|
trace.finish(false);
|
|
@@ -677,7 +667,7 @@ export async function cmdStart(opts = {}) {
|
|
|
677
667
|
trace.finish(false);
|
|
678
668
|
return;
|
|
679
669
|
}
|
|
680
|
-
if (!opts.webInit && process.stdin.isTTY) {
|
|
670
|
+
if (daemonCfgStart.aid && !opts.webInit && process.stdin.isTTY) {
|
|
681
671
|
// 证书缺失时在 CLI 侧提示,daemon 是后台进程无终端不做交互
|
|
682
672
|
const certKey = path.join(resolvePaths().root, 'AIDs', daemonCfgStart.aid, 'private', 'key.json');
|
|
683
673
|
if (!fs.existsSync(certKey)) {
|
|
@@ -1209,7 +1199,7 @@ export async function cmdRestart(opts = {}) {
|
|
|
1209
1199
|
writeAsModeOverride(undefined);
|
|
1210
1200
|
console.log(` ${describeRunMode()}`);
|
|
1211
1201
|
if (!await ensureCodexHookBeforeLifecycle())
|
|
1212
|
-
return;
|
|
1202
|
+
return false;
|
|
1213
1203
|
const socketPath = resolvePaths().socket;
|
|
1214
1204
|
const ping = await probeDaemon(socketPath);
|
|
1215
1205
|
if (ping && !await hasLiveMain(ping.pid)) {
|
|
@@ -1219,9 +1209,9 @@ export async function cmdRestart(opts = {}) {
|
|
|
1219
1209
|
if (!hasVisibleDaemonPid(initialStatus, ping)) {
|
|
1220
1210
|
const initialRuntimeOrphans = findOrphanProcesses(initialStatus).filter(orphan => isRuntimeOrphan(orphan));
|
|
1221
1211
|
if (await tryDelegatedDaemonRestart(socketPath))
|
|
1222
|
-
return;
|
|
1212
|
+
return true;
|
|
1223
1213
|
if (initialRuntimeOrphans.length === 0 && rejectPidIsolatedLifecycle('restart', initialStatus, ping))
|
|
1224
|
-
return;
|
|
1214
|
+
return false;
|
|
1225
1215
|
}
|
|
1226
1216
|
}
|
|
1227
1217
|
// The shared launchPackageLifecycle path delegates to launchMonitorAndConfirm;
|
|
@@ -1234,18 +1224,19 @@ export async function cmdRestart(opts = {}) {
|
|
|
1234
1224
|
if (!readRestartRequest(pendingFile, requestId)) {
|
|
1235
1225
|
console.error('❌ 重启请求已被替换或过期,服务未停止;请重新发起重启。');
|
|
1236
1226
|
process.exitCode = 1;
|
|
1237
|
-
return;
|
|
1227
|
+
return false;
|
|
1238
1228
|
}
|
|
1239
1229
|
}
|
|
1240
|
-
const launched = await launchPackageLifecycle('restart', console.log, { clear: opts.clear, requestId });
|
|
1230
|
+
const launched = await launchPackageLifecycle('restart', console.log, { clear: opts.clear, requestId, applyPackageUpgrades: opts.applyPackageUpgrades });
|
|
1241
1231
|
if (!launched.ok) {
|
|
1242
1232
|
console.error(launched.pending
|
|
1243
1233
|
? `⚠ 重启状态暂不可确认(PID ${launched.pid ?? 'unknown'}):restart-monitor 仍在运行,可能继续执行;请勿立即重复发起。`
|
|
1244
1234
|
: `❌ 重启中止:restart-monitor 未能启动(${launched.reason});当前服务未主动停止`);
|
|
1245
1235
|
process.exitCode = 1;
|
|
1246
|
-
return;
|
|
1236
|
+
return false;
|
|
1247
1237
|
}
|
|
1248
1238
|
console.log(`🔄 Restart monitor started (${((Date.now() - cmdStartedAt) / 1000).toFixed(1)}s); service is restarting...`);
|
|
1239
|
+
return true;
|
|
1249
1240
|
}
|
|
1250
1241
|
function normalizeRuntimePath(value) {
|
|
1251
1242
|
return value.replace(/[\\/]+/g, '/').toLowerCase();
|
|
@@ -1573,18 +1564,25 @@ function renderStatusOverview(snapshot) {
|
|
|
1573
1564
|
]], [0, 1, 2], [12, 12, 12]);
|
|
1574
1565
|
}
|
|
1575
1566
|
}
|
|
1576
|
-
function renderStatusServiceProxy(serviceProxy) {
|
|
1567
|
+
function renderStatusServiceProxy(serviceProxy, ecwebAccess) {
|
|
1577
1568
|
console.log('\n服务代理(配置)');
|
|
1578
1569
|
if (serviceProxy?.source !== 'unavailable' && Array.isArray(serviceProxy?.items)) {
|
|
1579
1570
|
const configured = serviceProxy.items;
|
|
1580
1571
|
if (configured.length > 0) {
|
|
1581
|
-
|
|
1572
|
+
const transport = serviceProxy.transport;
|
|
1573
|
+
renderStatusTable(['服务', '配置', '状态', '来源', '协议', '可见性'], configured.map((item) => [
|
|
1582
1574
|
item.name,
|
|
1583
1575
|
!item.serviceEnabled ? '服务已禁用' : item.proxyEnabled ? '已启用' : '代理已禁用',
|
|
1576
|
+
!item.serviceEnabled || !item.proxyEnabled ? '未发布'
|
|
1577
|
+
: item.name === 'ecweb' && ecwebAccess ? ecwebAccess.message
|
|
1578
|
+
: !transport ? '未知'
|
|
1579
|
+
: transport.gatewayRegistered && transport.registeredServices?.includes(item.name) ? '已登记'
|
|
1580
|
+
: transport.state === 'degraded' ? '登记未完成'
|
|
1581
|
+
: '等待登记',
|
|
1584
1582
|
item.source ?? '—',
|
|
1585
1583
|
item.serviceType ?? '—',
|
|
1586
1584
|
item.visibility ?? '—',
|
|
1587
|
-
]), [], [12, 10, 10, 6, 10]);
|
|
1585
|
+
]), [], [12, 10, 12, 10, 6, 10]);
|
|
1588
1586
|
}
|
|
1589
1587
|
}
|
|
1590
1588
|
else {
|
|
@@ -1853,7 +1851,7 @@ function renderStatusSnapshot(snapshot) {
|
|
|
1853
1851
|
if (hasStatus) {
|
|
1854
1852
|
renderStatusOverview(snapshot);
|
|
1855
1853
|
renderStatusAgents(snapshot.agents.items, snapshot.aun.items, snapshot.daemon.queue, snapshot.controlAid, snapshot.agents.registered);
|
|
1856
|
-
renderStatusServiceProxy(snapshot.proxy);
|
|
1854
|
+
renderStatusServiceProxy(snapshot.proxy, snapshot.ecweb.proxyAccess);
|
|
1857
1855
|
}
|
|
1858
1856
|
renderEcwebStatus(snapshot.ecweb);
|
|
1859
1857
|
}
|
|
@@ -3216,19 +3214,21 @@ async function waitForExistingEcweb(p, timeoutMs = 3_000) {
|
|
|
3216
3214
|
*/
|
|
3217
3215
|
async function collectEcwebStatus(p) {
|
|
3218
3216
|
let externalUrl = null;
|
|
3217
|
+
let proxyAccess;
|
|
3219
3218
|
let enabled = true;
|
|
3220
3219
|
let configuredPort = DEFAULT_ECWEB_PORT;
|
|
3221
3220
|
try {
|
|
3222
3221
|
const cfg = loadDaemonConfig();
|
|
3223
3222
|
enabled = ecwebService(cfg.services)?.enabled !== false;
|
|
3224
3223
|
configuredPort = ecwebService(cfg.services)?.port ?? DEFAULT_ECWEB_PORT;
|
|
3225
|
-
|
|
3224
|
+
proxyAccess = await readEcwebProxyAccess(cfg);
|
|
3225
|
+
externalUrl = proxyAccess.url;
|
|
3226
3226
|
}
|
|
3227
3227
|
catch {
|
|
3228
3228
|
// Runtime and HTTP checks remain useful when config access is restricted.
|
|
3229
3229
|
}
|
|
3230
3230
|
if (!enabled)
|
|
3231
|
-
return { source: 'config', status: 'disabled', port: null, url: null, externalUrl };
|
|
3231
|
+
return { source: 'config', status: 'disabled', port: null, url: null, externalUrl, proxyAccess };
|
|
3232
3232
|
const entries = readEcwebInstanceEntries(p);
|
|
3233
3233
|
// Probe before consulting PID visibility. The daemon and CLI can be in
|
|
3234
3234
|
// different PID namespaces while sharing the host network namespace.
|
|
@@ -3271,6 +3271,7 @@ async function collectEcwebStatus(p) {
|
|
|
3271
3271
|
port: liveEntry.record.port,
|
|
3272
3272
|
url: `http://localhost:${liveEntry.record.port}`,
|
|
3273
3273
|
externalUrl,
|
|
3274
|
+
proxyAccess,
|
|
3274
3275
|
};
|
|
3275
3276
|
}
|
|
3276
3277
|
const occupiedPids = new Set();
|
|
@@ -3283,13 +3284,13 @@ async function collectEcwebStatus(p) {
|
|
|
3283
3284
|
}
|
|
3284
3285
|
}
|
|
3285
3286
|
if (aliveEntries.length > 0) {
|
|
3286
|
-
return { source: 'instance+process', status: 'process-not-ready', pid: aliveEntries[0].record.pid, port: aliveEntries[0].record.port, url: null, externalUrl };
|
|
3287
|
+
return { source: 'instance+process', status: 'process-not-ready', pid: aliveEntries[0].record.pid, port: aliveEntries[0].record.port, url: null, externalUrl, proxyAccess };
|
|
3287
3288
|
}
|
|
3288
3289
|
if (occupiedPids.size > 0) {
|
|
3289
|
-
return { source: 'port-scan', status: 'port-occupied', pids: [...occupiedPids], port: occupiedPort, url: null, externalUrl };
|
|
3290
|
+
return { source: 'port-scan', status: 'port-occupied', pids: [...occupiedPids], port: occupiedPort, url: null, externalUrl, proxyAccess };
|
|
3290
3291
|
}
|
|
3291
3292
|
if (entries.length > 0) {
|
|
3292
|
-
return { source: 'instance-record', status: 'recorded-unavailable', port: entries[0].record.port, url: null, externalUrl };
|
|
3293
|
+
return { source: 'instance-record', status: 'recorded-unavailable', port: entries[0].record.port, url: null, externalUrl, proxyAccess };
|
|
3293
3294
|
}
|
|
3294
3295
|
return {
|
|
3295
3296
|
source: 'daemon-config',
|
|
@@ -3297,6 +3298,7 @@ async function collectEcwebStatus(p) {
|
|
|
3297
3298
|
port: configuredPort,
|
|
3298
3299
|
url: null,
|
|
3299
3300
|
externalUrl,
|
|
3301
|
+
proxyAccess,
|
|
3300
3302
|
};
|
|
3301
3303
|
}
|
|
3302
3304
|
function renderEcwebStatus(status) {
|
|
@@ -3439,7 +3441,6 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3439
3441
|
const service = ecwebService(cfg.services);
|
|
3440
3442
|
if (!service?.enabled)
|
|
3441
3443
|
return false;
|
|
3442
|
-
const externalUrl = resolveEcwebExternalUrl(cfg);
|
|
3443
3444
|
// The daemon is the lifecycle owner. CLI callers normally only need to
|
|
3444
3445
|
// ensure ECWeb is available, so adopt a healthy process instead of killing
|
|
3445
3446
|
// it. `ec watch web` passes forceRestart explicitly for an intentional
|
|
@@ -3447,14 +3448,12 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3447
3448
|
if (!options.forceRestart) {
|
|
3448
3449
|
const existing = await waitForExistingEcweb(p);
|
|
3449
3450
|
if (existing) {
|
|
3450
|
-
console.log(`✓ ECWeb 已在运行 (PID: ${existing.pid}) http://localhost:${existing.port}`);
|
|
3451
|
+
console.log(`✓ ECWeb 已在运行 (PID: ${existing.pid})${options.initialization ? '' : ` http://localhost:${existing.port}`}`);
|
|
3451
3452
|
const readiness = await probeEcwebReadiness(existing.port);
|
|
3452
3453
|
if (!readiness.ready)
|
|
3453
3454
|
console.log(`⚠ ECWeb 进程存活但 daemon 未就绪: ${readiness.error || 'unknown'}`);
|
|
3454
|
-
if (
|
|
3455
|
-
|
|
3456
|
-
if (readiness.ready)
|
|
3457
|
-
await printEcwebPairingInfo(cfg);
|
|
3455
|
+
if (!options.initialization)
|
|
3456
|
+
await printEcwebAccessInfo(cfg, readiness.ready);
|
|
3458
3457
|
return true;
|
|
3459
3458
|
}
|
|
3460
3459
|
}
|
|
@@ -3528,15 +3527,12 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3528
3527
|
}
|
|
3529
3528
|
if (processAlive) {
|
|
3530
3529
|
const actionLabel = wasRunning ? '已重启' : '启动成功';
|
|
3531
|
-
console.log(`✓ ECWeb ${actionLabel} (PID: ${pid}) http://localhost:${port}`);
|
|
3532
|
-
if (externalUrl)
|
|
3533
|
-
console.log(` 外网访问: ${externalUrl}`);
|
|
3530
|
+
console.log(`✓ ECWeb ${actionLabel} (PID: ${pid})${options.initialization ? '' : ` http://localhost:${port}`}`);
|
|
3534
3531
|
if (!readiness?.ready) {
|
|
3535
3532
|
console.log(`⚠ ECWeb 进程存活但 daemon 未就绪: ${readiness?.error || 'unknown'}`);
|
|
3536
3533
|
}
|
|
3537
|
-
|
|
3538
|
-
await
|
|
3539
|
-
}
|
|
3534
|
+
if (!options.initialization)
|
|
3535
|
+
await printEcwebAccessInfo(cfg, readiness?.ready === true);
|
|
3540
3536
|
return true;
|
|
3541
3537
|
}
|
|
3542
3538
|
console.log(`❌ ECWeb 启动失败:端口 ${port} 未就绪(进程 PID ${pid} 可能已退出,查看 logs/watch-web.log)`);
|
|
@@ -3561,7 +3557,12 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3561
3557
|
}
|
|
3562
3558
|
}
|
|
3563
3559
|
/** 新启动和复用已有 ECWeb 时,统一显示 daemon 提供的配对信息。 */
|
|
3564
|
-
async function
|
|
3560
|
+
async function printEcwebAccessInfo(config, ready) {
|
|
3561
|
+
const access = await readEcwebProxyAccess(config);
|
|
3562
|
+
console.log(` 外网代理: ${access.message}`);
|
|
3563
|
+
if (!ready || access.state !== 'ready' || !access.url)
|
|
3564
|
+
return;
|
|
3565
|
+
console.log(` 外网访问: ${access.url}`);
|
|
3565
3566
|
const pair = await fetchRemotePairingCode();
|
|
3566
3567
|
if (pair) {
|
|
3567
3568
|
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
package/dist/cli/directory.js
CHANGED
|
@@ -3,7 +3,7 @@ import { daemonUnavailableMessage, getArgValue, isHelpFlag, queryDaemon, wantsHe
|
|
|
3
3
|
import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
4
4
|
import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQueryCommand, } from '../directory/owner-directory-query-operation.js';
|
|
5
5
|
import { executeDirectoryRequestCommand, resolveDirectoryRequestCommand, } from '../directory/owner-directory-request-operation.js';
|
|
6
|
-
const QUERY_ACTIONS = new Set(['list', 'info', 'refresh', 'blocked']);
|
|
6
|
+
const QUERY_ACTIONS = new Set(['list', 'info', 'refresh', 'blocked', 'block', 'unblock']);
|
|
7
7
|
/**
|
|
8
8
|
* `ec directory ...`
|
|
9
9
|
*
|
|
@@ -119,6 +119,10 @@ function output(result, json) {
|
|
|
119
119
|
: '没有可用连接,未拉取;本地名录已按当前备注重算');
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
+
case 'block':
|
|
123
|
+
case 'unblock':
|
|
124
|
+
console.log(result.changed ? '✓ 本 Agent 的黑名单已更新' : '无需变更');
|
|
125
|
+
return;
|
|
122
126
|
case 'blocked': {
|
|
123
127
|
if (result.entries.length === 0)
|
|
124
128
|
console.log('(没有被拉黑的主体)');
|
|
@@ -185,6 +189,8 @@ function printHelp() {
|
|
|
185
189
|
ec directory info <contact-aid|名字> [--limit <n>]
|
|
186
190
|
ec directory refresh
|
|
187
191
|
ec directory blocked
|
|
192
|
+
ec directory block <target-aid>
|
|
193
|
+
ec directory unblock <target-aid>
|
|
188
194
|
ec directory request <target-aid> [--note <申请介绍>]
|
|
189
195
|
|
|
190
196
|
request:向目标发送 app-v1 friend.invite.v1 加好友申请;介绍默认为“你好,我想添加你为联系人。”。
|
|
@@ -152,8 +152,11 @@ export function buildDownstreamArgv(route, text, passthrough) {
|
|
|
152
152
|
// 所以按普通私聊发出,会话随这条消息建立,也就不建复查。
|
|
153
153
|
if (route.crossTopic && route.threadId && !route.firstContact) {
|
|
154
154
|
argv.push('--thread', route.threadId);
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
// 进入本分支后 `checkEveryMs === undefined` 只可能是显式 `--check-every none`:
|
|
156
|
+
// 未指定时 resolveSendRoute 已补默认周期,firstContact 又进不了本分支。
|
|
157
|
+
// 必须把 `none` 透传下去——漏传会让下游 `resolveManagedSendArgv` 看到
|
|
158
|
+
// 「有 --thread 没 --check-every」,直接报 Cross-thread sends require …。
|
|
159
|
+
argv.push('--check-every', route.checkEveryMs ? formatDuration(route.checkEveryMs) : 'none');
|
|
157
160
|
}
|
|
158
161
|
argv.push(route.encryptResolved ? '--encrypt' : '--no-encrypt');
|
|
159
162
|
// 保留网关正文的字面量语义,包括经 `--` 传入的 --encrypt 等文本。
|
package/dist/cli/index.js
CHANGED
|
@@ -62,9 +62,8 @@ AUN:
|
|
|
62
62
|
rpc 调用底层 AUN RPC
|
|
63
63
|
menu-client 向远程 daemon 发送标准 Menu 请求
|
|
64
64
|
diag 邀请远程诊断 Agent,或 stop 撤销诊断授权
|
|
65
|
-
peer 联系人黑名单与已登记对端查询
|
|
66
65
|
directory 名录查询与发起加好友申请
|
|
67
|
-
role
|
|
66
|
+
role 角色配额/限额设置、关系角色提升申请与审批
|
|
68
67
|
net AUN 网络链路诊断
|
|
69
68
|
|
|
70
69
|
配置与诊断:
|
|
@@ -241,7 +240,7 @@ export async function main(args) {
|
|
|
241
240
|
--owner <aid> 必填。控制 AID 创建后的 Owner 邀约目标,不等待审批
|
|
242
241
|
--baseagent <claude|codex|gemini|ecagent> 可选。默认从 PATH 检测,ecagent 需显式选择
|
|
243
242
|
--projectpath <abs-path> 可选。默认项目目录(必须绝对路径,自动创建)
|
|
244
|
-
--ecweb
|
|
243
|
+
--ecweb 兼容选项。检查 EC Web 安装;默认随 ec start 启动
|
|
245
244
|
--auto-start Windows/macOS 上启用 EvolCore 登录自启动
|
|
246
245
|
--no-auto-start Windows/macOS 上禁用 EvolCore 登录自启动
|
|
247
246
|
--format json 可选但推荐。stdout 输出 init.result JSON
|
|
@@ -677,11 +676,6 @@ export async function main(args) {
|
|
|
677
676
|
await cmdConfig(strippedArgs.slice(1));
|
|
678
677
|
break;
|
|
679
678
|
}
|
|
680
|
-
case 'peer': {
|
|
681
|
-
const { cmdPeer } = await import('./peer.js');
|
|
682
|
-
await cmdPeer(strippedArgs.slice(1));
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
679
|
case 'directory': {
|
|
686
680
|
const { cmdDirectory } = await import('./directory.js');
|
|
687
681
|
await cmdDirectory(strippedArgs.slice(1));
|
package/dist/cli/init-channel.js
CHANGED
|
@@ -19,7 +19,7 @@ import { ipcQuery } from '../ipc.js';
|
|
|
19
19
|
import { cmdStart } from './daemon-commands.js';
|
|
20
20
|
import * as platform from '../utils/cross-platform.js';
|
|
21
21
|
import { cleanupInstances } from '../utils/instance-registry.js';
|
|
22
|
-
import { bindPeerAlias,
|
|
22
|
+
import { bindPeerAlias, isPeerBindingEligible } from '../config/peer-book.js';
|
|
23
23
|
import { listStaticAgentAdmins } from '../config/peer-role-resolver.js';
|
|
24
24
|
import { askInit, InitCancelledError, isInitCancelledError, setupInitRawKeyListener, waitForInitDelay, } from './init-cancel.js';
|
|
25
25
|
function ask(rl, question) {
|
|
@@ -1408,7 +1408,6 @@ async function confirmOverwriteChannel(rl, displayName, channelName) {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
1410
1410
|
const candidates = preferredContactBindingCandidates(agentConfig);
|
|
1411
|
-
const contacts = getPeerSnapshot(agentConfig.aid).contacts;
|
|
1412
1411
|
console.log(`\n请选择 ${channelType} 账号要绑定到的联系人 AID:`);
|
|
1413
1412
|
candidates.forEach((candidate, index) => {
|
|
1414
1413
|
console.log(` ${index + 1}. ${candidate.primaryId} (${candidate.label})`);
|
|
@@ -1425,7 +1424,7 @@ async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
|
1425
1424
|
}
|
|
1426
1425
|
if (selected === manualChoice) {
|
|
1427
1426
|
const primaryId = (await ask(rl, '请输入要绑定的联系人 AID: ')).trim();
|
|
1428
|
-
if (isValidAid(primaryId) &&
|
|
1427
|
+
if (isValidAid(primaryId) && isPeerBindingEligible(agentConfig.aid, primaryId))
|
|
1429
1428
|
return { primaryId, label: 'contact' };
|
|
1430
1429
|
if (isValidAid(primaryId)) {
|
|
1431
1430
|
console.log('该 AID 不是当前 Agent 的联系人,请先添加联系人或将其设为 Owner。');
|
|
@@ -1438,11 +1437,10 @@ async function pickContactForChannelBinding(rl, agentConfig, channelType) {
|
|
|
1438
1437
|
}
|
|
1439
1438
|
}
|
|
1440
1439
|
function preferredContactBindingCandidates(agentConfig) {
|
|
1441
|
-
const contacts = getPeerSnapshot(agentConfig.aid).contacts;
|
|
1442
1440
|
const labels = new Map();
|
|
1443
1441
|
const add = (value, label) => {
|
|
1444
1442
|
const aid = String(value || '').trim();
|
|
1445
|
-
if (!isValidAid(aid) || !
|
|
1443
|
+
if (!isValidAid(aid) || !isPeerBindingEligible(agentConfig.aid, aid))
|
|
1446
1444
|
return;
|
|
1447
1445
|
let set = labels.get(aid);
|
|
1448
1446
|
if (!set) {
|
|
@@ -1465,7 +1463,7 @@ function bindQrActorToContact(aid, binding, channelType, actorId, channelKey) {
|
|
|
1465
1463
|
return;
|
|
1466
1464
|
const normalizedActor = firstNonEmpty(actorId);
|
|
1467
1465
|
if (!normalizedActor) {
|
|
1468
|
-
console.log(` ⚠ ${channelType} 扫码流程未返回可绑定的用户 ID,未写入
|
|
1466
|
+
console.log(` ⚠ ${channelType} 扫码流程未返回可绑定的用户 ID,未写入 peers.json`);
|
|
1469
1467
|
return;
|
|
1470
1468
|
}
|
|
1471
1469
|
try {
|