evolcore 0.0.45 → 0.0.47
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 +113 -0
- package/bin/ecmsg.js +33 -23
- package/dist/ability/application-service.js +1 -2
- package/dist/ability/package.js +28 -0
- package/dist/agent-template/jobs.js +158 -36
- package/dist/agent-template/runtime.js +401 -34
- package/dist/agent-template/service.js +764 -369
- package/dist/agent-template/tool-runner.js +35 -17
- package/dist/agent-template/types.js +7 -4
- package/dist/agents/baseagent.js +10 -9
- package/dist/agents/claude-runner.js +22 -6
- package/dist/agents/codex/app-server-client.js +34 -27
- package/dist/agents/codex/diagnostics.js +18 -1
- package/dist/agents/codex-runner.js +3 -1
- package/dist/agents/ecagent-runner.js +3 -1
- package/dist/agents/gemini-runner.js +2 -1
- package/dist/aun/group/fs-download.js +1 -1
- package/dist/aun/menu/client.js +142 -182
- package/dist/aun/rpc/client.js +33 -17
- package/dist/aun/service-proxy.js +6 -23
- package/dist/channels/aun.js +675 -120
- package/dist/channels/daemon.js +1 -1
- package/dist/cli/agent-create.js +37 -10
- package/dist/cli/agent-template.js +105 -84
- package/dist/cli/agent.js +31 -18
- package/dist/cli/daemon-commands.js +42 -56
- package/dist/cli/daemon-lifecycle-client.js +55 -19
- package/dist/cli/directory.js +12 -4
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/events-command.js +2 -1
- package/dist/cli/init-channel.js +2 -2
- package/dist/cli/init.js +57 -21
- package/dist/cli/integrity-command.js +2 -0
- package/dist/cli/managed-command-guard.js +20 -1
- package/dist/cli/menu-client.js +7 -5
- package/dist/cli/restart-monitor.js +135 -46
- package/dist/cli/services-command.js +28 -5
- package/dist/cli/task-context.js +83 -15
- package/dist/cli/upgrade-command.js +4 -2
- package/dist/config/config-field-policy.js +24 -0
- package/dist/config/config-manager.js +49 -19
- package/dist/config/peer-book-store.js +167 -127
- package/dist/config/peer-role-resolver.js +24 -4
- package/dist/config/provider-identity-migration.js +158 -6
- package/dist/config/provider-identity.js +10 -4
- package/dist/config/provider-ipc-service.js +10 -2
- package/dist/config/provider-local-sync.js +2 -2
- package/dist/config/providers-config.js +95 -10
- package/dist/config/providers-import.js +4 -6
- package/dist/config/providers.js +14 -3
- package/dist/config/role-store.js +1 -1
- package/dist/config/schema-migration.js +123 -16
- package/dist/config/schema-registry.js +6 -2
- package/dist/config-store.js +9 -1
- package/dist/core/agent-application-service.js +56 -29
- package/dist/core/agent-create-status.js +3 -1
- package/dist/core/agent-creation-claim.js +1 -0
- package/dist/core/agent-ipc-registration.js +2 -2
- package/dist/core/agent-reload-coordinator.js +38 -1
- package/dist/core/agent-runtime.js +91 -43
- package/dist/core/auth/agent-delegation.js +13 -3
- package/dist/core/auth/delegation-diagnostics.js +56 -15
- package/dist/core/auth/operation-authorizer.js +2 -2
- package/dist/core/auth/operation-catalog.js +3 -3
- package/dist/core/bootstrap-service.js +3 -0
- package/dist/core/capability/capability-manager.js +3 -1
- package/dist/core/channel-loader.js +29 -3
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-control.js +6 -5
- package/dist/core/command/agent-template-menu.js +32 -97
- package/dist/core/command/eventcenter-menu.js +61 -13
- package/dist/core/command/menu-catalog.js +11 -4
- package/dist/core/command/menu-handler.js +39 -12
- package/dist/core/command/menu-protocol.js +8 -16
- package/dist/core/command/skill-slash.js +6 -2
- package/dist/core/command/slash-handler.js +4 -6
- package/dist/core/command/team-workspace-bootstrap.js +1 -2
- package/dist/core/command/team-workspace-management-store.js +83 -0
- package/dist/core/command/team-workspace-management.js +1 -2
- package/dist/core/command/team-workspace-team.js +26 -3
- package/dist/core/daemon-bootstrap.js +11 -9
- package/dist/core/daemon-control.js +4 -7
- package/dist/core/daemon-lifecycle.js +189 -143
- package/dist/core/evolagent-registry.js +50 -2
- package/dist/core/evolagent.js +2 -1
- package/dist/core/file-integrity/read.js +9 -16
- package/dist/core/file-integrity/store.js +94 -34
- package/dist/core/handoff/dispatcher.js +33 -7
- package/dist/core/handoff/runtime.js +8 -0
- package/dist/core/host-snapshot.js +9 -4
- package/dist/core/inference/text-inference.js +12 -2
- package/dist/core/initialization/service.js +22 -4
- package/dist/core/invoke/invoke-service.js +24 -3
- package/dist/core/ipc-registration.js +7 -3
- package/dist/core/memory/consolidation.js +6 -6
- package/dist/core/message/aun-ipc-sender.js +109 -7
- package/dist/core/message/contact-admission.js +6 -2
- package/dist/core/message/message-bridge.js +13 -0
- package/dist/core/message/message-queue.js +131 -30
- package/dist/core/message/pending-hints.js +8 -0
- package/dist/core/message/response-engine.js +48 -2
- package/dist/core/message/send-routing.js +3 -12
- package/dist/core/model/catalog-service.js +13 -0
- package/dist/core/model/model-catalog.js +57 -18
- package/dist/core/ownership/owner-resolver.js +27 -10
- package/dist/core/pack-auth.js +163 -31
- package/dist/core/pack-install.js +42 -1
- package/dist/{services/ledger.js → core/pack-ledger.js} +17 -6
- package/dist/core/permission/ec-command-parser.js +3 -1
- package/dist/core/permission/shell-environment.js +23 -0
- package/dist/core/rate-window.js +6 -1
- package/dist/core/relation/peer-identity.js +5 -1
- package/dist/core/relation/same-owner-proof.js +2 -1
- package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
- package/dist/core/session/session-file-health.js +36 -7
- package/dist/core/session/session-idle-monitor.js +0 -1
- package/dist/core/session/session-manager.js +14 -0
- package/dist/core/session/session-title.js +26 -6
- package/dist/core/skill/index-generator.js +3 -4
- package/dist/core/task/task-image-resources.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/core/thread/topic-id.js +8 -0
- package/dist/directory/owner-directory-admission.js +17 -0
- package/dist/directory/owner-directory-cache.js +3 -1
- package/dist/directory/owner-directory-markdown.js +145 -23
- package/dist/directory/owner-directory-policy.js +23 -0
- package/dist/directory/owner-directory-query-operation.js +20 -6
- package/dist/directory/owner-directory-search.js +47 -0
- package/dist/eck/message-renderer.js +171 -32
- package/dist/ecweb/basic-settings-service.js +7 -3
- package/dist/ecweb/providers-service.js +17 -10
- package/dist/ecweb/runtime/lifecycle.js +65 -16
- package/dist/ecweb/runtime/supervisor.js +79 -50
- package/dist/event-center/admission-materializer.js +1 -1
- package/dist/event-center/bus-gate.js +48 -4
- package/dist/event-center/bus-host.js +3 -3
- package/dist/event-center/center-config.js +57 -28
- package/dist/event-center/dispatcher.js +8 -0
- package/dist/event-center/event-log.js +69 -27
- package/dist/event-center/index-generator.js +6 -1
- package/dist/event-center/ipc-operation.js +66 -25
- package/dist/event-center/pack-loader.js +12 -55
- package/dist/event-center/pack-manager.js +5 -3
- package/dist/event-center/registry.js +48 -52
- package/dist/event-center/runtime.js +219 -81
- package/dist/event-center/script-runner.js +18 -7
- package/dist/event-center/types.js +9 -1
- package/dist/event-center/validation.js +33 -4
- package/dist/index.js +132 -75
- package/dist/ipc.js +35 -8
- package/dist/product.js +1 -0
- package/dist/proxy/manager.js +52 -11
- package/dist/proxy/service-supervisor.js +265 -67
- package/dist/services/dispatcher.js +26 -3
- package/dist/services/idempotency.js +128 -0
- package/dist/services/identity.js +3 -27
- package/dist/services/index-generator.js +5 -1
- package/dist/services/index.js +244 -45
- package/dist/services/ipc-operation.js +164 -20
- package/dist/services/pack-manager.js +37 -9
- package/dist/services/router.js +100 -31
- package/dist/services/script-runner.js +15 -4
- package/dist/services/service-payload.js +50 -2
- package/dist/services/validation.js +107 -3
- package/dist/trigger/scheduler.js +18 -4
- package/dist/trigger/script-sandbox.js +39 -2
- package/dist/trigger/state.js +7 -0
- package/dist/utils/aid-bind.js +155 -18
- package/dist/utils/atomic-write.js +3 -3
- package/dist/utils/cross-platform.js +59 -16
- package/dist/utils/error-utils.js +26 -1
- package/dist/utils/instance-registry.js +94 -35
- package/dist/utils/process-introspect.js +187 -27
- package/dist/utils/project-path.js +47 -3
- package/dist/utils/upgrade-jobs.js +4 -4
- package/dist/utils/windows-shell-trust.js +174 -68
- package/kits/docs/context-assembly.md +3 -3
- package/kits/docs/evolcore/agent.md +28 -10
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +22 -0
- package/kits/docs/evolcore/directory.md +46 -12
- package/kits/docs/evolcore/event-center.md +6 -6
- package/kits/docs/evolcore/group-collaboration.md +1 -1
- package/kits/docs/evolcore/menu-client.md +7 -5
- package/kits/docs/evolcore/menu-protocol.md +5 -3
- package/kits/docs/evolcore/msg.md +10 -3
- package/kits/docs/evolcore/provider.md +17 -5
- package/kits/docs/evolcore/services.md +145 -12
- package/kits/docs/evolcore/thread-chain.md +17 -9
- package/kits/docs/prompt-loading-architecture.md +4 -4
- package/kits/eck_message_manifest.json +46 -3
- package/kits/rules/04-relation.md +10 -2
- package/kits/rules/06-channel.md +2 -1
- package/kits/schemas/providers.schema.2.json +1 -0
- package/kits/skills/ec-group/SKILL.md +4 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +1 -1
- package/kits/skills/ec-skill/scripts/skill.mjs +13 -2
- package/kits/skills/thread-ops/SKILL.md +8 -5
- package/kits/templates/message-fragments/group-batch-item.md +3 -0
- package/kits/templates/message-fragments/group-batch.md +1 -0
- package/kits/templates/message-fragments/item-group.md +4 -0
- package/kits/templates/message-fragments/item-private.md +4 -0
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/system-fragments/commands.md +5 -5
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +11 -7
- package/package.json +3 -2
- package/scripts/agent-template/index.mjs +9 -4
- package/scripts/agent-template/inspect.mjs +16 -9
- package/scripts/agent-template/shared/plan.mjs +3 -33
- package/scripts/agent-template/shared/template-contract.mjs +186 -3
- package/scripts/agent-template/shared/template-package.mjs +119 -10
- package/scripts/agent-template/shared/template-runtime.mjs +49 -6
- package/scripts/agent-template/shared/template.mjs +5 -5
- package/scripts/agent-template/team-pack.mjs +245 -0
- package/scripts/agent-template/team-preview.mjs +111 -0
- package/scripts/aid-batch/identity-batch.mjs +143 -0
- package/dist/ability/versions.js +0 -32
- package/dist/aun/model-headers.js +0 -17
- package/dist/channels/builtin-plugins.js +0 -19
- package/dist/core/command/team-workspace-initializer.js +0 -2
- package/dist/core/command/team-workspace-job-store.js +0 -88
- package/dist/core/command/team-workspace-management-service.js +0 -2
- package/dist/core/contact-bind-registry.js +0 -27
- package/dist/event-center/ledger.js +0 -52
- package/dist/services/reply.js +0 -55
- package/kits/templates/message-fragments/item.md +0 -3
- package/scripts/agent-template/pack.mjs +0 -169
|
@@ -18,7 +18,7 @@ import { ecwebVersionRequirementError, resolveEcwebLaunchCommand } from '../ecwe
|
|
|
18
18
|
import { stopEcwebForRestart } from '../ecweb/runtime/lifecycle.js';
|
|
19
19
|
import { resolveEcwebExternalUrl, fetchRemotePairingCode, buildEcwebPairingUrl } from '../ecweb/pairing.js';
|
|
20
20
|
import { isHostChinese } from '../utils/locale.js';
|
|
21
|
-
import { scanInstances, cleanupInstances, findOrphanProcesses } from '../utils/instance-registry.js';
|
|
21
|
+
import { scanInstances, hasLiveMain, hasLiveRestartMonitor, cleanupInstances, findOrphanProcesses } from '../utils/instance-registry.js';
|
|
22
22
|
import { filterLogFiles, deriveLogTypes, computePreChecked, validateLogTypes, shortLogName as shortLogNameLocal, isWatchLogFile } from './watch-logs.js';
|
|
23
23
|
import { printCodeStats } from './code-stats.js';
|
|
24
24
|
import { StartupTracer, STARTUP_TRACE_ID_ENV, formatMs, formatSlowestSpans, findTraceRecord } from '../utils/startup-trace.js';
|
|
@@ -32,7 +32,7 @@ import { logLevelRank } from '../utils/logger.js';
|
|
|
32
32
|
import { inspectDataMigrationRequirement } from '../core/data-migration.js';
|
|
33
33
|
import { readHostInfo, readVersionInfo } from '../utils/host-info.js';
|
|
34
34
|
import { queryStatusActivity, queryStatusActivityByAgent } from '../stats/query.js';
|
|
35
|
-
import { DAEMON_PROBE_TIMEOUT_MS, DAEMON_SHUTDOWN_TIMEOUT_MS, probeDaemon, requestDaemonShutdown } from './daemon-lifecycle-client.js';
|
|
35
|
+
import { DAEMON_PROBE_TIMEOUT_MS, DAEMON_SHUTDOWN_TIMEOUT_MS, isRecordedProcessGone, probeDaemon, requestDaemonShutdown } from './daemon-lifecycle-client.js';
|
|
36
36
|
export { DAEMON_SHUTDOWN_TIMEOUT_MS, requestDaemonShutdown, stopCodexAppServerOrphans } from './daemon-lifecycle-client.js';
|
|
37
37
|
import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode, setEcwebEnabled } from '../config/daemon-services.js';
|
|
38
38
|
import { checkCodexProjectPath, inspectCodexManagedHook, ensureCodexManagedHook, runCodexHookLaunchDiagnostic, } from '../agents/codex/diagnostics.js';
|
|
@@ -322,14 +322,15 @@ async function launchPackageLifecycle(source, log, options = {}) {
|
|
|
322
322
|
const result = await platform.launchMonitorAndConfirm(args, env, pid => requestId
|
|
323
323
|
? readRestartRequest(path.join(root, 'data', 'daemon', 'control', 'restart-pending.json'), requestId)?.status === 'accepted'
|
|
324
324
|
|| readRestartRequest(path.join(root, 'data', 'daemon', 'control', 'restart-pending.json'), requestId)?.status === 'ready'
|
|
325
|
-
:
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
: hasLiveRestartMonitor({ pid }),
|
|
326
|
+
// Launch confirmation only observes monitors. Probing the still-running
|
|
327
|
+
// daemon here adds process-table queries to each unsuccessful poll.
|
|
328
|
+
pid => hasLiveRestartMonitor({ excludePid: pid, ...(requestId ? { requestId, phase: 'accepted' } : {}) }), {
|
|
328
329
|
requestId,
|
|
329
330
|
logFilePath: requestId ? path.join(root, 'logs', `restart-launch-${requestId}.log`) : undefined,
|
|
330
331
|
onSpawn: pid => { if (requestId)
|
|
331
332
|
updateRestartRequest(path.join(root, 'data', 'daemon', 'control', 'restart-pending.json'), requestId, { launcherPid: pid }); },
|
|
332
|
-
isPendingInRegistry: () =>
|
|
333
|
+
isPendingInRegistry: () => requestId ? hasLiveRestartMonitor({ requestId }) : false,
|
|
333
334
|
});
|
|
334
335
|
if (!result.ok && !result.pending && launch.stageDir)
|
|
335
336
|
platform.cleanupMonitorStage(launch.stageDir);
|
|
@@ -1047,12 +1048,6 @@ export async function cmdStart(opts = {}) {
|
|
|
1047
1048
|
};
|
|
1048
1049
|
setTimeout(checkReady, 200);
|
|
1049
1050
|
}
|
|
1050
|
-
function isPidReused(pid, expectedStartedAt) {
|
|
1051
|
-
if (expectedStartedAt === undefined)
|
|
1052
|
-
return false;
|
|
1053
|
-
const actualStartedAt = getProcessStartTime(pid);
|
|
1054
|
-
return actualStartedAt !== null && !startTimeMatches(expectedStartedAt, actualStartedAt);
|
|
1055
|
-
}
|
|
1056
1051
|
function reportPidReused(pid) {
|
|
1057
1052
|
console.log(`ℹ EvolCore PID ${pid} no longer refers to the recorded process; treating it as stopped`);
|
|
1058
1053
|
}
|
|
@@ -1062,7 +1057,7 @@ async function stopPid(pid, gracefulRequested = false, expectedStartedAt, trace)
|
|
|
1062
1057
|
// A graceful request was accepted by the daemon that answered for this exact
|
|
1063
1058
|
// PID over IPC, so its identity is already proven; the start-time probe (a
|
|
1064
1059
|
// PowerShell launch on Windows) only guards the kill path.
|
|
1065
|
-
if (!gracefulRequested &&
|
|
1060
|
+
if (!gracefulRequested && await isRecordedProcessGone(pid, expectedStartedAt)) {
|
|
1066
1061
|
reportPidReused(pid);
|
|
1067
1062
|
return true;
|
|
1068
1063
|
}
|
|
@@ -1079,14 +1074,10 @@ async function stopPid(pid, gracefulRequested = false, expectedStartedAt, trace)
|
|
|
1079
1074
|
console.log('✓ EvolCore stopped');
|
|
1080
1075
|
return true;
|
|
1081
1076
|
}
|
|
1082
|
-
if (isPidReused(pid, expectedStartedAt)) {
|
|
1083
|
-
reportPidReused(pid);
|
|
1084
|
-
return true;
|
|
1085
|
-
}
|
|
1086
1077
|
const state = platform.getProcessState(pid);
|
|
1087
1078
|
const stateSuffix = state ? ` (state=${state})` : '';
|
|
1088
1079
|
console.log(`⚠ EvolCore PID ${pid} did not exit gracefully${stateSuffix}; forcing termination...`);
|
|
1089
|
-
if (
|
|
1080
|
+
if (await isRecordedProcessGone(pid, expectedStartedAt)) {
|
|
1090
1081
|
reportPidReused(pid);
|
|
1091
1082
|
return true;
|
|
1092
1083
|
}
|
|
@@ -1098,7 +1089,7 @@ async function stopPid(pid, gracefulRequested = false, expectedStartedAt, trace)
|
|
|
1098
1089
|
console.log('✓ EvolCore stopped (forced)');
|
|
1099
1090
|
return true;
|
|
1100
1091
|
}
|
|
1101
|
-
if (
|
|
1092
|
+
if (await isRecordedProcessGone(pid, expectedStartedAt)) {
|
|
1102
1093
|
reportPidReused(pid);
|
|
1103
1094
|
return true;
|
|
1104
1095
|
}
|
|
@@ -1155,6 +1146,10 @@ export async function cmdStop() {
|
|
|
1155
1146
|
}
|
|
1156
1147
|
const pids = new Set([...aliveMains.map(entry => entry.record.pid), ...runtimeOrphans.map(orphan => orphan.pid)]);
|
|
1157
1148
|
const expectedStarts = new Map(aliveMains.map(entry => [entry.record.pid, entry.record.startedAt]));
|
|
1149
|
+
for (const orphan of runtimeOrphans) {
|
|
1150
|
+
if (orphan.startedAt !== undefined && !expectedStarts.has(orphan.pid))
|
|
1151
|
+
expectedStarts.set(orphan.pid, orphan.startedAt);
|
|
1152
|
+
}
|
|
1158
1153
|
if (runtimeOrphans.length > 0) {
|
|
1159
1154
|
console.log(`⚠ 检测到未登记的 EvolCore 进程,将一并停止: ${runtimeOrphans.map(orphan => orphan.pid).join(', ')}`);
|
|
1160
1155
|
}
|
|
@@ -1215,18 +1210,19 @@ export async function cmdRestart(opts = {}) {
|
|
|
1215
1210
|
console.log(` ${describeRunMode()}`);
|
|
1216
1211
|
if (!await ensureCodexHookBeforeLifecycle())
|
|
1217
1212
|
return;
|
|
1218
|
-
const initialStatus = scanInstances();
|
|
1219
1213
|
const socketPath = resolvePaths().socket;
|
|
1220
1214
|
const ping = await probeDaemon(socketPath);
|
|
1221
|
-
if (ping && !
|
|
1222
|
-
//
|
|
1223
|
-
//
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1215
|
+
if (ping && !await hasLiveMain(ping.pid)) {
|
|
1216
|
+
// Keep the full PID-namespace fallback for unregistered/unobservable targets.
|
|
1217
|
+
// Normal restarts only inspect the responding PID, without AID activity logs.
|
|
1218
|
+
const initialStatus = scanInstances({ includeAidActivity: false });
|
|
1219
|
+
if (!hasVisibleDaemonPid(initialStatus, ping)) {
|
|
1220
|
+
const initialRuntimeOrphans = findOrphanProcesses(initialStatus).filter(orphan => isRuntimeOrphan(orphan));
|
|
1221
|
+
if (await tryDelegatedDaemonRestart(socketPath))
|
|
1222
|
+
return;
|
|
1223
|
+
if (initialRuntimeOrphans.length === 0 && rejectPidIsolatedLifecycle('restart', initialStatus, ping))
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1230
1226
|
}
|
|
1231
1227
|
// The shared launchPackageLifecycle path delegates to launchMonitorAndConfirm;
|
|
1232
1228
|
// the monitor retains shutdown, orphan checks, build and rollback ownership.
|
|
@@ -1698,7 +1694,6 @@ function projectStatusAgentItems(evolcoreHome, now, statusAgents, fallbackAgents
|
|
|
1698
1694
|
}
|
|
1699
1695
|
async function collectStatusSnapshot() {
|
|
1700
1696
|
const p = resolvePaths();
|
|
1701
|
-
const started = Date.now();
|
|
1702
1697
|
const instances = scanInstances();
|
|
1703
1698
|
const aliveMains = instances.mains.filter(instance => instance.alive);
|
|
1704
1699
|
const restartMonitors = instances.restartMonitors.filter(instance => instance.alive);
|
|
@@ -1710,15 +1705,20 @@ async function collectStatusSnapshot() {
|
|
|
1710
1705
|
const agentsPromise = process.env.EVOLCORE_SESSION_ID
|
|
1711
1706
|
? Promise.resolve(null)
|
|
1712
1707
|
: ipcQuery(p.socket, { type: 'evolagent.list' }).catch(() => null);
|
|
1708
|
+
// Measure the status request itself, excluding instance scans and ECWeb checks.
|
|
1709
|
+
const statusStartedAt = performance.now();
|
|
1710
|
+
let latencyMs = 0;
|
|
1711
|
+
const statusPromise = ipcQuery(p.socket, { type: 'status' }).catch(() => null).finally(() => {
|
|
1712
|
+
latencyMs = Math.round(performance.now() - statusStartedAt);
|
|
1713
|
+
});
|
|
1713
1714
|
const [ping, statusResponse, aidsResponse, agentsResponse, agentStatsResponse, ecweb] = await Promise.all([
|
|
1714
1715
|
pingPromise,
|
|
1715
|
-
|
|
1716
|
+
statusPromise,
|
|
1716
1717
|
ipcQuery(p.socket, { type: 'aun-aids' }).catch(() => null),
|
|
1717
1718
|
agentsPromise,
|
|
1718
1719
|
ipcQuery(p.socket, { type: 'agent-stats' }).catch(() => null),
|
|
1719
1720
|
collectEcwebStatus(p),
|
|
1720
1721
|
]);
|
|
1721
|
-
const latencyMs = Date.now() - started;
|
|
1722
1722
|
const now = Date.now();
|
|
1723
1723
|
const pid = ping?.pid ?? statusResponse?.pid ?? aliveMains[0]?.record.pid ?? null;
|
|
1724
1724
|
const mainRecord = aliveMains.find(instance => instance.record.pid === pid)?.record;
|
|
@@ -3315,7 +3315,7 @@ function renderEcwebStatus(status) {
|
|
|
3315
3315
|
}
|
|
3316
3316
|
}
|
|
3317
3317
|
else if (status.startupState === 'waiting') {
|
|
3318
|
-
console.log('🔭 ECWeb:
|
|
3318
|
+
console.log('🔭 ECWeb: 等待启动');
|
|
3319
3319
|
}
|
|
3320
3320
|
else if (status.startupState === 'starting' && status.status !== 'process-not-ready') {
|
|
3321
3321
|
console.log('🔭 ECWeb: 正在启动,等待健康检查');
|
|
@@ -3453,6 +3453,8 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3453
3453
|
console.log(`⚠ ECWeb 进程存活但 daemon 未就绪: ${readiness.error || 'unknown'}`);
|
|
3454
3454
|
if (externalUrl)
|
|
3455
3455
|
console.log(` 外网访问: ${externalUrl}`);
|
|
3456
|
+
if (readiness.ready)
|
|
3457
|
+
await printEcwebPairingInfo(cfg);
|
|
3456
3458
|
return true;
|
|
3457
3459
|
}
|
|
3458
3460
|
}
|
|
@@ -3515,14 +3517,11 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3515
3517
|
startedAt = getProcessStartTime(pid);
|
|
3516
3518
|
let processAlive = false;
|
|
3517
3519
|
let readiness = null;
|
|
3518
|
-
let pair = null;
|
|
3519
3520
|
for (let i = 0; i < 40; i++) {
|
|
3520
3521
|
const registered = readEcwebInstanceEntries(p).find(entry => entry.record.pid === pid)?.record;
|
|
3521
3522
|
processAlive = registered ? await probeEcwebLiveness(registered.port, registered) : false;
|
|
3522
3523
|
if (processAlive) {
|
|
3523
3524
|
readiness = await probeEcwebReadiness(port);
|
|
3524
|
-
if (readiness.ready)
|
|
3525
|
-
pair = await fetchRemotePairingCode();
|
|
3526
3525
|
break;
|
|
3527
3526
|
}
|
|
3528
3527
|
await sleep(250);
|
|
@@ -3535,15 +3534,8 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3535
3534
|
if (!readiness?.ready) {
|
|
3536
3535
|
console.log(`⚠ ECWeb 进程存活但 daemon 未就绪: ${readiness?.error || 'unknown'}`);
|
|
3537
3536
|
}
|
|
3538
|
-
else if (pair) {
|
|
3539
|
-
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
|
3540
|
-
console.log(` 配对码: ${pair.code} (约 ${mins} 分钟内有效,仅可配对一次,已配对过的浏览器无需重新配对)`);
|
|
3541
|
-
const pairingUrl = buildEcwebPairingUrl(cfg, pair.code);
|
|
3542
|
-
if (pairingUrl)
|
|
3543
|
-
console.log(` 一键登录: ${pairingUrl}`);
|
|
3544
|
-
}
|
|
3545
3537
|
else {
|
|
3546
|
-
|
|
3538
|
+
await printEcwebPairingInfo(cfg);
|
|
3547
3539
|
}
|
|
3548
3540
|
return true;
|
|
3549
3541
|
}
|
|
@@ -3568,24 +3560,18 @@ export async function startEcwebIfEnabled(p, options = {}) {
|
|
|
3568
3560
|
return false;
|
|
3569
3561
|
}
|
|
3570
3562
|
}
|
|
3571
|
-
/**
|
|
3572
|
-
async function
|
|
3573
|
-
|
|
3574
|
-
let pair = null;
|
|
3575
|
-
for (let i = 0; i < 10 && !pair; i++) {
|
|
3576
|
-
pair = await fetchRemotePairingCode();
|
|
3577
|
-
if (!pair)
|
|
3578
|
-
await sleep(300);
|
|
3579
|
-
}
|
|
3563
|
+
/** 新启动和复用已有 ECWeb 时,统一显示 daemon 提供的配对信息。 */
|
|
3564
|
+
async function printEcwebPairingInfo(config) {
|
|
3565
|
+
const pair = await fetchRemotePairingCode();
|
|
3580
3566
|
if (pair) {
|
|
3581
3567
|
const mins = Math.max(0, Math.round((pair.expiresAt - Date.now()) / 60000));
|
|
3582
3568
|
console.log(` 配对码: ${pair.code} (约 ${mins} 分钟内有效,仅可配对一次,token 缓存 7 天,有访问自动续期)`);
|
|
3583
|
-
const pairingUrl = buildEcwebPairingUrl(
|
|
3569
|
+
const pairingUrl = buildEcwebPairingUrl(config, pair.code);
|
|
3584
3570
|
if (pairingUrl)
|
|
3585
3571
|
console.log(` 一键登录: ${pairingUrl}`);
|
|
3586
3572
|
}
|
|
3587
3573
|
else {
|
|
3588
|
-
console.log(' 配对码:
|
|
3574
|
+
console.log(' 配对码: 暂不可用(稍后重新运行 ec init --web,或在本机 ECWeb 页面获取)');
|
|
3589
3575
|
}
|
|
3590
3576
|
}
|
|
3591
3577
|
async function cmdWatchWeb() {
|
|
@@ -3608,7 +3594,7 @@ async function cmdWatchWeb() {
|
|
|
3608
3594
|
const ok = await startEcwebIfEnabled(p, { forceRestart: true });
|
|
3609
3595
|
if (!ok)
|
|
3610
3596
|
process.exit(1); // 失败原因已由 startEcwebIfEnabled 打印
|
|
3611
|
-
// 启动成功的访问信息已由 startEcwebIfEnabled
|
|
3597
|
+
// 启动成功的访问信息已由 startEcwebIfEnabled 打印。
|
|
3612
3598
|
}
|
|
3613
3599
|
function sleep(ms) {
|
|
3614
3600
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ipcQuery } from '../ipc.js';
|
|
2
2
|
import * as platform from '../utils/cross-platform.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getProcessStartTimeAsync, startTimeMatches } from '../utils/process-introspect.js';
|
|
4
4
|
import { listCodexAppServerProcesses, unregisterCodexAppServerProcess } from '../agents/codex/app-server-registry.js';
|
|
5
5
|
// A busy Windows named pipe may need several seconds to accept a connection.
|
|
6
6
|
export const DAEMON_PROBE_TIMEOUT_MS = platform.isWindows ? 5_000 : 1_000;
|
|
@@ -28,34 +28,70 @@ export async function requestDaemonShutdown(socketPath, timeoutMs = DAEMON_SHUTD
|
|
|
28
28
|
return null;
|
|
29
29
|
return response.pid;
|
|
30
30
|
}
|
|
31
|
+
/** A stale or unavailable observation must never authorize a PID-addressed signal. */
|
|
32
|
+
export async function isRecordedProcessGone(pid, expectedStartedAt) {
|
|
33
|
+
if (!await platform.isProcessRunningAsync(pid))
|
|
34
|
+
return true;
|
|
35
|
+
const actual = await getProcessStartTimeAsync(pid, { fresh: true });
|
|
36
|
+
if (actual === null) {
|
|
37
|
+
if (!await platform.isProcessRunningAsync(pid))
|
|
38
|
+
return true;
|
|
39
|
+
throw new Error(`Cannot verify process identity for PID ${pid}; refusing termination`);
|
|
40
|
+
}
|
|
41
|
+
if (!Number.isFinite(expectedStartedAt) || expectedStartedAt <= 0) {
|
|
42
|
+
throw new Error(`Missing recorded process identity for PID ${pid}; refusing termination`);
|
|
43
|
+
}
|
|
44
|
+
return !startTimeMatches(expectedStartedAt, actual);
|
|
45
|
+
}
|
|
31
46
|
/** Clean up only registered, identity-verified EvolCore Codex app-server children. */
|
|
32
|
-
export function stopCodexAppServerOrphans() {
|
|
47
|
+
export async function stopCodexAppServerOrphans(snapshot) {
|
|
33
48
|
const entries = listCodexAppServerProcesses();
|
|
34
49
|
if (entries.length === 0)
|
|
35
50
|
return 0;
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
// The restart monitor already captured all Windows command lines after the
|
|
52
|
+
// daemon exited. Reuse that enumeration, but never its stale signal authority.
|
|
53
|
+
const reuseSnapshot = platform.isWindows && snapshot?.complete;
|
|
54
|
+
const codexProcs = reuseSnapshot ? undefined : new Set(platform.findProcesses('codex app-server'));
|
|
55
|
+
const exits = [];
|
|
38
56
|
for (const entry of entries) {
|
|
39
57
|
const { pid, startedAt } = entry.record;
|
|
40
|
-
if (!platform.isProcessRunning(pid)) {
|
|
41
|
-
unregisterCodexAppServerProcess(entry.filePath);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
// Discard reused PIDs without signalling; retain unverified commands to retry.
|
|
45
|
-
const actualStartedAt = getProcessStartTime(pid);
|
|
46
|
-
if (!startTimeMatches(startedAt, actualStartedAt)) {
|
|
47
|
-
unregisterCodexAppServerProcess(entry.filePath);
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (!codexProcs.has(pid))
|
|
51
|
-
continue;
|
|
52
58
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
// An unknown identity retains its registration for a later retry.
|
|
60
|
+
if (await isRecordedProcessGone(pid, startedAt)) {
|
|
55
61
|
unregisterCodexAppServerProcess(entry.filePath);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (reuseSnapshot) {
|
|
65
|
+
const command = snapshot.commandLines.get(pid) ?? '';
|
|
66
|
+
const capturedStart = snapshot.startedAt.get(pid);
|
|
67
|
+
if (capturedStart === undefined || !startTimeMatches(startedAt, capturedStart))
|
|
68
|
+
continue;
|
|
69
|
+
// Native executables and npm's cmd wrapper both carry the app-server
|
|
70
|
+
// token. Registration and fresh identity verification scope termination.
|
|
71
|
+
if (!/(?:^|[\\/"'\s])codex(?:\.(?:exe|cmd|bat|js|mjs))?(?=$|["'\s])/i.test(command)
|
|
72
|
+
|| !/(?:^|["'\s^])app-server(?=$|["'\s^])/.test(command))
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
else if (!codexProcs.has(pid))
|
|
76
|
+
continue;
|
|
77
|
+
if (platform.killProcess(pid, true)) {
|
|
78
|
+
// Signal acceptance is not proof of exit. Confirm children concurrently
|
|
79
|
+
// so multiple survivors do not add a separate timeout to the restart.
|
|
80
|
+
exits.push((async () => {
|
|
81
|
+
try {
|
|
82
|
+
if (!await platform.waitForProcessExit(pid, 2_000)
|
|
83
|
+
&& !await isRecordedProcessGone(pid, startedAt))
|
|
84
|
+
return false;
|
|
85
|
+
unregisterCodexAppServerProcess(entry.filePath);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
})());
|
|
56
92
|
}
|
|
57
93
|
}
|
|
58
94
|
catch { }
|
|
59
95
|
}
|
|
60
|
-
return
|
|
96
|
+
return (await Promise.all(exits)).filter(Boolean).length;
|
|
61
97
|
}
|
package/dist/cli/directory.js
CHANGED
|
@@ -151,7 +151,12 @@ function printListRow(entry) {
|
|
|
151
151
|
function printPageFooter(result) {
|
|
152
152
|
const pages = Math.max(1, Math.ceil(result.total / result.limit));
|
|
153
153
|
const next = result.hasMore ? ';加 --page ' + (result.page + 1) + ' 看下一页' : '';
|
|
154
|
-
|
|
154
|
+
// `--scope my-agent-team` 被 50 人上限截断时,注入里只列了前 50 人,
|
|
155
|
+
// 这里必须把被截掉的条数说出来,否则"共 50 条"会被当成名单只有 50 人。
|
|
156
|
+
const dropped = typeof result.myAgentTeamDropped === 'number' && result.myAgentTeamDropped > 0
|
|
157
|
+
? `;另有 ${result.myAgentTeamDropped} 人超过注入上限未列出(名单共 ${result.myAgentTeamTotal} 人)`
|
|
158
|
+
: '';
|
|
159
|
+
console.log(`(第 ${result.page}/${pages} 页,共 ${result.total} 条${next}${dropped})`);
|
|
155
160
|
}
|
|
156
161
|
async function runManaged(argv, json) {
|
|
157
162
|
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
@@ -176,7 +181,7 @@ async function runManaged(argv, json) {
|
|
|
176
181
|
}
|
|
177
182
|
function printHelp() {
|
|
178
183
|
console.log(`用法:
|
|
179
|
-
ec directory list [<关键词>] [--filter '<kw1,kw2>']... [--type <type>] [--scope internal|external|pa-team|all] [--owner <aid|unbound>] [--limit <n>] [--page <n>]
|
|
184
|
+
ec directory list [<关键词>] [--filter '<kw1,kw2>']... [--type <type>] [--scope internal|external|pa-team|my-agent-team|all] [--owner <aid|unbound>] [--limit <n>] [--page <n>]
|
|
180
185
|
ec directory info <contact-aid|名字> [--limit <n>]
|
|
181
186
|
ec directory refresh
|
|
182
187
|
ec directory blocked
|
|
@@ -191,8 +196,11 @@ list:
|
|
|
191
196
|
位置参数按“多个词同时命中”处理。
|
|
192
197
|
默认每页 20 条,--page / --limit 可翻页;输出包含 type、exttype、描述、备注、
|
|
193
198
|
Owner 绑定关系与 Ownership 核验状态。本地备注正文不在 list 展示。
|
|
194
|
-
--scope internal|external|pa-team|all(默认 all):
|
|
195
|
-
|
|
199
|
+
--scope internal|external|pa-team|my-agent-team|all(默认 all):
|
|
200
|
+
pa-team 只列 open_pa_context 里且 ownership_status=owned 的成员。
|
|
201
|
+
my-agent-team 列 config.team(Evol App 里配的「我的 agent 团队」)里的成员,
|
|
202
|
+
以名单为准,**包含名录里已经没有的残留**——这些条目只有 AID、
|
|
203
|
+
ownerAid 为空,用来排查"配了但联系不上"。不受准入开关影响。
|
|
196
204
|
|
|
197
205
|
info:
|
|
198
206
|
接受 AID 或名字。AID 大小写不敏感、可带 @ 前缀;名字先做归一后的精确匹配
|
|
@@ -146,8 +146,8 @@ export function buildDownstreamArgv(route, text, passthrough) {
|
|
|
146
146
|
const targetAsPositional = looksLikeAid(targetId)
|
|
147
147
|
|| (route.peer.peerKind === 'group' && !route.crossTopic);
|
|
148
148
|
const argv = targetAsPositional
|
|
149
|
-
? [scope, 'send', route.self, targetId, ...
|
|
150
|
-
: [scope, 'send', route.self, ...
|
|
149
|
+
? [scope, 'send', route.self, targetId, ...passthrough]
|
|
150
|
+
: [scope, 'send', route.self, ...passthrough];
|
|
151
151
|
// 首次联系:主话题还没被创建,带上 --thread 反而会被下游判成"话题不存在",
|
|
152
152
|
// 所以按普通私聊发出,会话随这条消息建立,也就不建复查。
|
|
153
153
|
if (route.crossTopic && route.threadId && !route.firstContact) {
|
|
@@ -156,6 +156,9 @@ export function buildDownstreamArgv(route, text, passthrough) {
|
|
|
156
156
|
argv.push('--check-every', formatDuration(route.checkEveryMs));
|
|
157
157
|
}
|
|
158
158
|
argv.push(route.encryptResolved ? '--encrypt' : '--no-encrypt');
|
|
159
|
+
// 保留网关正文的字面量语义,包括经 `--` 传入的 --encrypt 等文本。
|
|
160
|
+
if (text.length > 0)
|
|
161
|
+
argv.push('--', ...text);
|
|
159
162
|
return argv;
|
|
160
163
|
}
|
|
161
164
|
/**
|
|
@@ -16,7 +16,7 @@ const HELP = `ec events — 事件中心运维
|
|
|
16
16
|
ec events ledger [<包名>] [--tail N] 台账(不传包名=中心台账)
|
|
17
17
|
ec events tail <包名> [--tail N] 事件日志
|
|
18
18
|
ec events doctor <包名> 诊断
|
|
19
|
-
ec events reload
|
|
19
|
+
ec events reload 重载(重新扫描全部包并重建订阅)
|
|
20
20
|
ec events rules add <事件> --publish <aid> [--subscribe <aid>] [--deny]
|
|
21
21
|
ec events rules remove <事件> --publish <aid> [--subscribe <aid>] [--deny]
|
|
22
22
|
ec events rules show [--event <事件>]
|
|
@@ -25,6 +25,7 @@ const HELP = `ec events — 事件中心运维
|
|
|
25
25
|
安装与卸载(L 类目录只能由 daemon 代写):
|
|
26
26
|
ec events pack add <包名> --from <源目录> [--aid <aid>]
|
|
27
27
|
ec events pack remove <包名> [--aid <aid>] [--purge]
|
|
28
|
+
ec events pack enable / disable <包名> [--aid <aid>]
|
|
28
29
|
ec events pack list [--aid <aid>]
|
|
29
30
|
|
|
30
31
|
add 遇到已安装的包直接报错,先 remove 再装。
|
package/dist/cli/init-channel.js
CHANGED
|
@@ -179,11 +179,11 @@ async function reloadAgentAfterBind(aid) {
|
|
|
179
179
|
console.log(' ✓ agent owner 已热重载');
|
|
180
180
|
}
|
|
181
181
|
else if (result?.error) {
|
|
182
|
-
console.log(` ⚠
|
|
182
|
+
console.log(` ⚠ Agent Owner 协议绑定已确认,热重载失败:${result.error}`);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
catch {
|
|
186
|
-
console.log(' ⚠
|
|
186
|
+
console.log(' ⚠ Agent Owner 协议绑定已确认,daemon 未响应热重载;下次启动恢复');
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
async function printQr(qrData) {
|
package/dist/cli/init.js
CHANGED
|
@@ -6,7 +6,9 @@ import { resolvePaths, ensureDataDirs } from '../paths.js';
|
|
|
6
6
|
import { commandExists } from '../utils/cross-platform.js';
|
|
7
7
|
import { scanInstances } from '../utils/instance-registry.js';
|
|
8
8
|
import { saveDefaultsSafe, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
|
|
9
|
+
import { currentVersion } from '../config/schema-registry.js';
|
|
9
10
|
import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
11
|
+
import { resolveEcwebExternalUrl } from '../ecweb/pairing.js';
|
|
10
12
|
import { ensureControlAgentMd, generateControlAid, hasLocalControlIdentity, missingControlIdentityMessage, resolveControlAidDomain, submitControlAidRegistration, } from '../aun/aid/control-aid.js';
|
|
11
13
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
12
14
|
/**
|
|
@@ -20,7 +22,7 @@ async function probeCodexAvailability() {
|
|
|
20
22
|
return getCodexAppServerAvailability();
|
|
21
23
|
}
|
|
22
24
|
import { resolveCodexCliPath, resolveCodexPowerShellShimPath, } from '../agents/baseagent.js';
|
|
23
|
-
import { defaultProjectsRoot } from '../utils/project-path.js';
|
|
25
|
+
import { assertProjectPathReference, defaultProjectsRoot, hasProjectPathEnvironmentReference } from '../utils/project-path.js';
|
|
24
26
|
import { WEB_CLI_BIN, WEB_PACKAGE_LATEST } from '../product.js';
|
|
25
27
|
import { autostartInstalled, autostartPlatformLabel, configureAutostart } from '../utils/autostart.js';
|
|
26
28
|
import { askInit, printInitCancelHint } from './init-cancel.js';
|
|
@@ -91,7 +93,7 @@ function buildDefaults(chosen, available, projectsDefaultPath) {
|
|
|
91
93
|
// supplies a reduced availability list (for example, a test probe).
|
|
92
94
|
baseagents.ecagent = baseagents.ecagent ?? {};
|
|
93
95
|
return {
|
|
94
|
-
$schema_version:
|
|
96
|
+
$schema_version: currentVersion('defaults'),
|
|
95
97
|
active_baseagent: chosen,
|
|
96
98
|
baseagents,
|
|
97
99
|
...(projectsDefaultPath ? { projects: { defaultPath: projectsDefaultPath } } : {}),
|
|
@@ -101,20 +103,38 @@ function writeDefaults(chosen, available, projectsDefaultPath) {
|
|
|
101
103
|
saveDefaultsSafe(buildDefaults(chosen, available, projectsDefaultPath));
|
|
102
104
|
}
|
|
103
105
|
export async function importProvidersForCliInit(available, options = {}) {
|
|
104
|
-
const { providerFromBaseagent } = await import('../config/providers-import.js');
|
|
106
|
+
const { IMPORTABLE_BASEAGENTS, providerFromBaseagent } = await import('../config/providers-import.js');
|
|
105
107
|
const { importOrMergeBaseagentProvider, readProvidersSnapshot } = await import('../config/providers-management.js');
|
|
106
108
|
const { readProvidersFile } = await import('../config/providers.js');
|
|
107
109
|
const { resolveProviderId, resolveProviderServiceForBaseagent } = await import('../config/providers-config.js');
|
|
108
110
|
const { ConfigTarget, mutateConfig } = await import('../config/config-manager.js');
|
|
111
|
+
const messages = {
|
|
112
|
+
LOCAL_PROVIDER_SOURCE_UNAVAILABLE: '未找到可导入的本机连接或有效凭据',
|
|
113
|
+
PROVIDER_REQUIRED: '最终仍缺少可用 Provider',
|
|
114
|
+
PROVIDER_CONFLICT: 'Provider 域名配置冲突,未覆盖原配置',
|
|
115
|
+
PROVIDER_ID_COLLISION: 'Provider ID 冲突,未覆盖原配置',
|
|
116
|
+
PROVIDER_DOMAIN_REQUIRED: '接入地址使用环境变量时,必须显式填写 Provider 主机名',
|
|
117
|
+
PROVIDER_DOMAIN_INVALID: 'Provider 主机名无效(支持 DNS 域名、IP 和 localhost,不含协议、端口或路径)',
|
|
118
|
+
PROVIDER_DOMAIN_MISMATCH: 'Provider 身份与接入地址的主机名不一致',
|
|
119
|
+
PROVIDER_DOMAIN_IMMUTABLE: '已有 Provider 的主机名不能更改,请新建 Provider',
|
|
120
|
+
CONFLICT: '配置已变更,请重试导入',
|
|
121
|
+
PROVIDER_IMPORT_FAILED: 'Provider 导入失败,原因未归类',
|
|
122
|
+
};
|
|
123
|
+
const warningCode = (error, fallback) => {
|
|
124
|
+
const code = error?.code;
|
|
125
|
+
return typeof code === 'string' && Object.hasOwn(messages, code) ? code : fallback;
|
|
126
|
+
};
|
|
109
127
|
const imported = [];
|
|
110
128
|
const warnings = [];
|
|
111
129
|
for (const baseagent of available) {
|
|
130
|
+
if (!IMPORTABLE_BASEAGENTS.some(importable => importable === baseagent))
|
|
131
|
+
continue;
|
|
112
132
|
let value;
|
|
113
133
|
try {
|
|
114
134
|
value = (options.source ?? providerFromBaseagent)(baseagent);
|
|
115
135
|
}
|
|
116
|
-
catch {
|
|
117
|
-
warnings.push({ baseagent, code: 'LOCAL_PROVIDER_SOURCE_UNAVAILABLE' });
|
|
136
|
+
catch (error) {
|
|
137
|
+
warnings.push({ baseagent, code: warningCode(error, 'LOCAL_PROVIDER_SOURCE_UNAVAILABLE') });
|
|
118
138
|
continue;
|
|
119
139
|
}
|
|
120
140
|
try {
|
|
@@ -122,8 +142,7 @@ export async function importProvidersForCliInit(available, options = {}) {
|
|
|
122
142
|
imported.push({ baseagent, providerId: result.providerId, merged: result.merged });
|
|
123
143
|
}
|
|
124
144
|
catch (error) {
|
|
125
|
-
|
|
126
|
-
warnings.push({ baseagent, code: ['PROVIDER_CONFLICT', 'PROVIDER_ID_COLLISION', 'CONFLICT'].includes(code ?? '') ? code : 'PROVIDER_IMPORT_FAILED' });
|
|
145
|
+
warnings.push({ baseagent, code: warningCode(error, 'PROVIDER_IMPORT_FAILED') });
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
148
|
const snapshot = readProvidersSnapshot();
|
|
@@ -153,16 +172,12 @@ export async function importProvidersForCliInit(available, options = {}) {
|
|
|
153
172
|
if (!options.quiet) {
|
|
154
173
|
for (const item of imported)
|
|
155
174
|
console.log(`✓ Provider ${item.merged ? '已合并' : '已导入'}: ${item.baseagent} → ${item.providerId}`);
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
PROVIDER_IMPORT_FAILED: 'Provider 导入失败,未返回凭据详情',
|
|
163
|
-
};
|
|
164
|
-
for (const item of warnings)
|
|
165
|
-
console.warn(`⚠ ${item.baseagent}: ${messages[item.code]}(${item.code});可使用 ec provider import 或 ECWEB 检查并补齐。`);
|
|
175
|
+
for (const item of warnings) {
|
|
176
|
+
const hint = item.baseagent === 'ecagent'
|
|
177
|
+
? '请在内部配置中为内置 ecagent 选择可用 Provider。'
|
|
178
|
+
: '可使用 ec provider import 或 ECWEB 检查并补齐。';
|
|
179
|
+
console.warn(`⚠ ${item.baseagent}: ${messages[item.code]}(${item.code});${hint}`);
|
|
180
|
+
}
|
|
166
181
|
}
|
|
167
182
|
return { imported, warnings };
|
|
168
183
|
}
|
|
@@ -352,7 +367,12 @@ export async function cmdInitWeb(dependencies = {}) {
|
|
|
352
367
|
}
|
|
353
368
|
const currentConfig = (dependencies.loadConfig ?? loadDaemonConfig)();
|
|
354
369
|
const port = ecwebService(currentConfig.services)?.port ?? DEFAULT_ECWEB_PORT;
|
|
355
|
-
|
|
370
|
+
const externalUrl = resolveEcwebExternalUrl(currentConfig);
|
|
371
|
+
console.log('\nECweb 初始化:');
|
|
372
|
+
console.log(` 本地访问: http://localhost:${port}/init`);
|
|
373
|
+
if (externalUrl)
|
|
374
|
+
console.log(` 外网访问: ${externalUrl}/init`);
|
|
375
|
+
console.log(' 远程首次访问需要配对;已有有效 token 可直接继续。');
|
|
356
376
|
return true;
|
|
357
377
|
}
|
|
358
378
|
// ==================== Main ====================
|
|
@@ -547,6 +567,15 @@ export async function cmdInit(options) {
|
|
|
547
567
|
return undefined;
|
|
548
568
|
}
|
|
549
569
|
const resolved = expandLeadingTildePath(input || defaultDir);
|
|
570
|
+
try {
|
|
571
|
+
assertProjectPathReference(resolved);
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
console.log(` ⚠ ${error.message}`);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
if (hasProjectPathEnvironmentReference(resolved))
|
|
578
|
+
return resolved;
|
|
550
579
|
if (!path.isAbsolute(resolved)) {
|
|
551
580
|
console.log(' ⚠ 请输入绝对路径或回车使用默认值;输入 skip 可跳过');
|
|
552
581
|
continue;
|
|
@@ -880,10 +909,17 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
880
909
|
// ── 4. projectpath 校验 + 创建 ──
|
|
881
910
|
let projectsDefaultPath;
|
|
882
911
|
if (opts.projectpath !== undefined) {
|
|
883
|
-
|
|
884
|
-
|
|
912
|
+
try {
|
|
913
|
+
assertProjectPathReference(opts.projectpath);
|
|
914
|
+
}
|
|
915
|
+
catch (error) {
|
|
916
|
+
fail('INVALID_PROJECT_PATH', error.message, EXIT_USAGE, format);
|
|
917
|
+
}
|
|
918
|
+
const reference = hasProjectPathEnvironmentReference(opts.projectpath);
|
|
919
|
+
if (!reference && !path.isAbsolute(opts.projectpath)) {
|
|
920
|
+
fail('INVALID_PROJECT_PATH', '--projectpath must be absolute or use environment references', EXIT_USAGE, format);
|
|
885
921
|
}
|
|
886
|
-
if (!fs.existsSync(opts.projectpath)) {
|
|
922
|
+
if (!reference && !fs.existsSync(opts.projectpath)) {
|
|
887
923
|
try {
|
|
888
924
|
fs.mkdirSync(opts.projectpath, { recursive: true });
|
|
889
925
|
}
|
|
@@ -92,6 +92,8 @@ function cmdQuery(target) {
|
|
|
92
92
|
console.log(` 登记时间: ${fmtTime(rec.registered_at)}`);
|
|
93
93
|
console.log(` 最后校验: ${fmtTime(rec.last_verified_at)}`);
|
|
94
94
|
console.log(` 登记方: ${rec.registrar_aid ?? '(系统)'}`);
|
|
95
|
+
if (rec.package_version)
|
|
96
|
+
console.log(` 包基线版本: ${rec.package_version}`);
|
|
95
97
|
}
|
|
96
98
|
function cmdList() {
|
|
97
99
|
if (!fs.existsSync(integrityDbPath())) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isHelpFlag, wantsHelp } from './help.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
2
3
|
import { isTrustedFullAccessRuntimeContext, readVerifiedTaskRuntimeContext } from './task-context.js';
|
|
3
4
|
const MANAGED_TASK_COMMANDS = new Set([
|
|
4
5
|
'aid',
|
|
@@ -44,6 +45,12 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
44
45
|
// `events` 事件中心运维(白名单自动维护脚本用它加白名单),通过 events.op IPC
|
|
45
46
|
// 且要求本地 control token,daemon 侧鉴权。
|
|
46
47
|
'events',
|
|
48
|
+
// `services` 服务路由运维,同样通过 services.op IPC 由 daemon 侧
|
|
49
|
+
// `authorizePackTarget` 逐操作判定(只读放行、enable/disable/pack add|remove
|
|
50
|
+
// 要 owner|admin)。本白名单只管"能不能进到脚本"。
|
|
51
|
+
// 不列入时连 `ec services status` 都会被拒:daemon 忙(例如一条 30s 的
|
|
52
|
+
// services call 占着 IPC 队列)时 1s 探测超时,整条命令被误判成 NOT_ALLOWED。
|
|
53
|
+
'services',
|
|
47
54
|
// $EVOLCORE_HOME/skills/ 与 kits/skills/ 下的技能文件,不触碰进程生命周期。
|
|
48
55
|
// 本白名单只负责让它进到脚本;具体某一级的读写权限由 skill.mjs 的
|
|
49
56
|
// assertPermission() 按会话上下文判定(群聊一律拒,Agent 级要 owner,
|
|
@@ -83,7 +90,19 @@ export async function assertManagedTopLevelCommandAllowed(command, args, env = p
|
|
|
83
90
|
return;
|
|
84
91
|
// A trusted fullaccess task may enter any implemented CLI command. The
|
|
85
92
|
// command's own daemon/operation handler still performs its normal checks.
|
|
86
|
-
|
|
93
|
+
//
|
|
94
|
+
// 探测本身给 1s:daemon 正忙(例如一条 30s 的 services call 占着 IPC 队列)时
|
|
95
|
+
// 第一次探测可能超时返回 undefined,随后 `MANAGED_TASK_COMMANDS` 不认识
|
|
96
|
+
// `services`,整条命令被误拒成 NOT_ALLOWED。这不是权限结论,是探测失手——
|
|
97
|
+
// 再试一次再判,并且把两次都失败的原因打出来,便于事后区分"真无权"与"没问上"。
|
|
98
|
+
let verified = await readVerifiedTaskRuntimeContext(env);
|
|
99
|
+
if (!verified) {
|
|
100
|
+
verified = await readVerifiedTaskRuntimeContext(env, 3_000);
|
|
101
|
+
if (!verified) {
|
|
102
|
+
logger.warn(`[ManagedGuard] task runtime context unavailable for "${command}" `
|
|
103
|
+
+ `(session=${env.EVOLCORE_SESSION_ID}); falling back to the static allowlist`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
87
106
|
if (isTrustedFullAccessRuntimeContext(verified)) {
|
|
88
107
|
if (SELF_PROTECTED_LIFECYCLE_COMMANDS.has(command)) {
|
|
89
108
|
throw new ManagedCommandNotAllowedError(command);
|