evolcore 0.0.43-test.5 → 0.0.43-test.6
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 +47 -0
- package/bin/ecmsg.js +126 -43
- package/dist/agents/baseagent-availability.js +19 -4
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +14 -3
- package/dist/agents/codex-runner.js +6 -6
- package/dist/aun/group/invite-service.js +3 -2
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +73 -10
- package/dist/cli/agent-create.js +16 -6
- package/dist/cli/aun-commands.js +9 -1
- package/dist/cli/daemon-commands.js +30 -1
- package/dist/cli/ecmsg-gateway.js +3 -1
- package/dist/cli/init.js +75 -0
- package/dist/cli/provider-command.js +1 -1
- package/dist/cli/restart-monitor.js +24 -5
- package/dist/cli/task-context.js +38 -1
- package/dist/cli/watch-logs.js +6 -4
- package/dist/config/boot-log.js +6 -4
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-manager.js +1 -1
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/provider-identity-migration.js +92 -17
- package/dist/config/provider-local-sync.js +2 -0
- package/dist/config/providers-config.js +13 -0
- package/dist/config/providers-management.js +100 -10
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +80 -87
- package/dist/config/snapshot.js +70 -41
- package/dist/core/agent-runtime.js +44 -7
- package/dist/core/baseagent-loader.js +114 -11
- package/dist/core/channel-loader.js +36 -13
- package/dist/core/channel-runtime.js +112 -42
- package/dist/core/command/command-handler.js +5 -5
- package/dist/core/command/menu-handler.js +8 -3
- package/dist/core/command/menu-protocol.js +82 -11
- package/dist/core/command/role-menu.js +27 -15
- package/dist/core/daemon-control.js +42 -15
- package/dist/core/daemon-lifecycle.js +411 -67
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +130 -42
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +4 -4
- package/dist/core/ipc-registration.js +5 -4
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/message/aun-ipc-sender.js +2 -2
- package/dist/core/message/message-bridge.js +53 -4
- package/dist/core/message/message-queue.js +46 -4
- package/dist/core/message/pending-hints.js +4 -10
- package/dist/core/message/response-engine.js +10 -2
- package/dist/core/message/send-routing.js +12 -2
- package/dist/core/ownership/owner-resolver.js +1 -0
- package/dist/core/permission/ec-command-parser.js +11 -1
- package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-fs-store.js +164 -3
- package/dist/core/session/session-idle-monitor.js +9 -1
- package/dist/core/session/session-manager.js +36 -2
- package/dist/directory/owner-directory-admission.js +26 -1
- package/dist/directory/owner-directory-cache.js +57 -16
- package/dist/directory/owner-directory-query-operation.js +4 -1
- package/dist/ecweb/runtime/lifecycle.js +9 -7
- package/dist/ecweb/runtime/supervisor.js +44 -27
- package/dist/index.js +548 -251
- package/dist/proxy/manager.js +38 -17
- package/dist/proxy/service-supervisor.js +65 -31
- package/dist/trigger/application-service.js +3 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +78 -5
- package/dist/utils/cross-platform.js +152 -4
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +64 -1
- package/dist/utils/startup-trace.js +160 -19
- package/kits/docs/aun/ABILITY_CALLING.md +3 -3
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/ctl.md +2 -1
- package/kits/docs/evolcore/group.md +2 -2
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/msg.md +13 -6
- package/kits/docs/evolcore/provider.md +21 -3
- package/kits/docs/evolcore/response.md +1 -1
- package/kits/eck_manifest.json +19 -7
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/06-channel.md +5 -6
- package/kits/schemas/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- package/kits/skills/aid-ability/SKILL.md +7 -7
- package/kits/skills/ec-group/SKILL.md +8 -5
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/system-fragments/commands.md +5 -5
- package/kits/templates/system-fragments/reply.md +2 -1
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +1 -1
- package/package.json +4 -3
|
@@ -4,10 +4,10 @@ import { spawn } from 'child_process';
|
|
|
4
4
|
import { isDevMode, resolvePaths } from '../../paths.js';
|
|
5
5
|
import { SERVICE_HEALTH_INTERVALS, SERVICE_RESTART_BACKOFF_MS, SERVICE_RESTART_MAX_ATTEMPTS, SERVICE_RESTART_WINDOW_MS, SERVICE_STARTUP_TIMEOUT_MS, } from '../../config/daemon-services.js';
|
|
6
6
|
import { WEB_PACKAGE_NAME } from '../../product.js';
|
|
7
|
-
import {
|
|
7
|
+
import { resolveGlobalPkgAsync } from '../../utils/npm-ops.js';
|
|
8
8
|
import { ecwebVersionRequirementError, resolveEcwebLaunchCommand } from './launch.js';
|
|
9
9
|
import * as platform from '../../utils/cross-platform.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getProcessStartTimeAsync } from '../../utils/process-introspect.js';
|
|
11
11
|
import { matchesEcwebInstanceHealth, parseEcwebInstanceRecord } from '../../contracts/ecweb-instance.js';
|
|
12
12
|
import { sanitizeMenuLogValue } from '../../core/command/menu-protocol.js';
|
|
13
13
|
import { stopEcwebProcess } from './lifecycle.js';
|
|
@@ -52,7 +52,7 @@ function readExitDiagnostics(filePath, startOffset) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function isAlive(record) {
|
|
55
|
+
async function isAlive(record) {
|
|
56
56
|
if (!Number.isInteger(record.pid) || record.pid <= 0)
|
|
57
57
|
return false;
|
|
58
58
|
// ECWeb versions before the supervisor used a different Linux boot-time
|
|
@@ -61,7 +61,7 @@ function isAlive(record) {
|
|
|
61
61
|
// scoped to this EVOLCORE_HOME; use liveness here and let the HTTP probe be
|
|
62
62
|
// the ownership/health check. PID/start-time validation remains in the
|
|
63
63
|
// explicit kill path below.
|
|
64
|
-
return platform.
|
|
64
|
+
return platform.isProcessRunningAsync(record.pid);
|
|
65
65
|
}
|
|
66
66
|
function readEntries() {
|
|
67
67
|
const dir = resolvePaths().instanceDir;
|
|
@@ -125,6 +125,7 @@ async function probe(record, timeoutMs) {
|
|
|
125
125
|
* ECWeb's own stale-instance cleanup, and daemon startup.
|
|
126
126
|
*/
|
|
127
127
|
export function createEcwebSupervisor(options) {
|
|
128
|
+
const settleInitialHealth = options.startupTrace?.startTask('daemon.ecwebHealthReady');
|
|
128
129
|
let healthConfig = options.health;
|
|
129
130
|
let failureThreshold = Math.max(1, healthConfig?.failureThreshold ?? options.failureThreshold ?? 3);
|
|
130
131
|
let desiredPort = options.port;
|
|
@@ -166,13 +167,13 @@ export function createEcwebSupervisor(options) {
|
|
|
166
167
|
catch { }
|
|
167
168
|
}
|
|
168
169
|
};
|
|
169
|
-
const setActiveFromEntry = (entry, owned) => {
|
|
170
|
+
const setActiveFromEntry = async (entry, owned) => {
|
|
170
171
|
active = {
|
|
171
172
|
pid: entry.record.pid,
|
|
172
173
|
port: entry.record.port,
|
|
173
174
|
// Capture the current PID start time rather than trusting the record.
|
|
174
175
|
// Older ECWeb builds could write a clock-skewed `startedAt` value.
|
|
175
|
-
startedAt:
|
|
176
|
+
startedAt: await getProcessStartTimeAsync(entry.record.pid)
|
|
176
177
|
?? (typeof entry.record.startedAt === 'number' ? entry.record.startedAt : null),
|
|
177
178
|
owned,
|
|
178
179
|
};
|
|
@@ -180,12 +181,12 @@ export function createEcwebSupervisor(options) {
|
|
|
180
181
|
const findHealthyInstance = async () => {
|
|
181
182
|
lastHealthFailure = '未发现有效的 ECWeb 实例注册';
|
|
182
183
|
for (const entry of readEntries()) {
|
|
183
|
-
if (!isAlive(entry.record)) {
|
|
184
|
+
if (!await isAlive(entry.record)) {
|
|
184
185
|
lastHealthFailure = '实例进程不存在';
|
|
185
186
|
removeEntry(entry);
|
|
186
187
|
continue;
|
|
187
188
|
}
|
|
188
|
-
const actual =
|
|
189
|
+
const actual = await getProcessStartTimeAsync(entry.record.pid);
|
|
189
190
|
if (actual !== null && entry.record.startedAt !== undefined
|
|
190
191
|
&& (entry.record.schemaVersion === 1 ? Math.abs(actual - entry.record.startedAt) >= 2000 : actual - entry.record.startedAt > 2000)) {
|
|
191
192
|
lastHealthFailure = '实例 PID 启动时间不匹配';
|
|
@@ -253,7 +254,7 @@ export function createEcwebSupervisor(options) {
|
|
|
253
254
|
// instance record there is no `active` entry yet, but the daemon still
|
|
254
255
|
// owns the child and must not leave it behind on shutdown.
|
|
255
256
|
const pendingPid = child?.pid;
|
|
256
|
-
if (pendingPid && platform.
|
|
257
|
+
if (pendingPid && (await platform.isProcessRunningAsync(pendingPid))) {
|
|
257
258
|
await stopTrackedProcess({ pid: pendingPid, startedAt: childIdentityStartedAt }, onTiming);
|
|
258
259
|
}
|
|
259
260
|
child = null;
|
|
@@ -276,7 +277,9 @@ export function createEcwebSupervisor(options) {
|
|
|
276
277
|
failureCount = 0;
|
|
277
278
|
const root = resolvePaths().root;
|
|
278
279
|
const localEntry = path.join(root, 'ecweb', 'dist', 'index.js');
|
|
279
|
-
const globalPkg =
|
|
280
|
+
const globalPkg = await resolveGlobalPkgAsync(WEB_PACKAGE_NAME);
|
|
281
|
+
if (stopping || !desiredEnabled || runtimeMode !== 'managed')
|
|
282
|
+
return;
|
|
280
283
|
let launch = resolveEcwebLaunchCommand(['--home', root, '--port', String(desiredPort)], {
|
|
281
284
|
installedPkg: globalPkg,
|
|
282
285
|
});
|
|
@@ -311,7 +314,9 @@ export function createEcwebSupervisor(options) {
|
|
|
311
314
|
scheduleRecovery();
|
|
312
315
|
return;
|
|
313
316
|
}
|
|
314
|
-
const occupiedPids = platform.
|
|
317
|
+
const occupiedPids = await platform.findProcessByPortAsync(desiredPort);
|
|
318
|
+
if (stopping || !desiredEnabled || runtimeMode !== 'managed')
|
|
319
|
+
return;
|
|
315
320
|
if (occupiedPids.length > 0) {
|
|
316
321
|
options.logger.error(`ECWeb 启动已停止:端口 ${desiredPort} 被占用 (PID: ${occupiedPids.join(', ')})`);
|
|
317
322
|
failureCount = failureThreshold;
|
|
@@ -350,7 +355,6 @@ export function createEcwebSupervisor(options) {
|
|
|
350
355
|
closeLogStream();
|
|
351
356
|
child = spawned;
|
|
352
357
|
childStartedAt = Date.now();
|
|
353
|
-
childIdentityStartedAt = spawned.pid ? getProcessStartTime(spawned.pid) : null;
|
|
354
358
|
spawned.once('error', (error) => {
|
|
355
359
|
options.logger.error(`ECWeb 子进程创建失败: ${error.message}`);
|
|
356
360
|
if (child !== spawned || intentionalStop || stopping)
|
|
@@ -377,14 +381,7 @@ export function createEcwebSupervisor(options) {
|
|
|
377
381
|
if (active?.pid === spawned.pid)
|
|
378
382
|
active = null;
|
|
379
383
|
failureCount = failureThreshold;
|
|
380
|
-
|
|
381
|
-
if (occupiedPids.length > 0) {
|
|
382
|
-
recoveryExhausted = true;
|
|
383
|
-
options.logger.error(`ECWeb 自动恢复已停止:端口 ${desiredPort} 被占用 (PID: ${occupiedPids.join(', ')})`);
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
scheduleRecovery();
|
|
387
|
-
}
|
|
384
|
+
scheduleRecovery();
|
|
388
385
|
}
|
|
389
386
|
}
|
|
390
387
|
closeLogStream();
|
|
@@ -396,6 +393,10 @@ export function createEcwebSupervisor(options) {
|
|
|
396
393
|
options.logger.warn('ECWeb 启动失败:未取得子进程 PID');
|
|
397
394
|
return;
|
|
398
395
|
}
|
|
396
|
+
const startedAt = await getProcessStartTimeAsync(spawned.pid);
|
|
397
|
+
if (child !== spawned)
|
|
398
|
+
return;
|
|
399
|
+
childIdentityStartedAt = startedAt;
|
|
399
400
|
options.logger.info(`✓ ECWeb supervisor 已启动 (PID: ${spawned.pid}),日志: ${logFile}`);
|
|
400
401
|
// ECWeb writes its own instance record after binding. Do not fabricate a
|
|
401
402
|
// record here; the watchdog will adopt the real record on its next tick.
|
|
@@ -411,7 +412,7 @@ export function createEcwebSupervisor(options) {
|
|
|
411
412
|
if (stopping) {
|
|
412
413
|
// 保留已核验的实例身份供 stop 清理,但不再接管运行状态或进入恢复分支。
|
|
413
414
|
if (instance)
|
|
414
|
-
setActiveFromEntry(instance, active?.pid === instance.record.pid ? active.owned : false);
|
|
415
|
+
await setActiveFromEntry(instance, active?.pid === instance.record.pid ? active.owned : false);
|
|
415
416
|
return;
|
|
416
417
|
}
|
|
417
418
|
if (!desiredEnabled || runtimeMode !== 'managed')
|
|
@@ -421,16 +422,21 @@ export function createEcwebSupervisor(options) {
|
|
|
421
422
|
launchRequested = false;
|
|
422
423
|
cancelRecovery();
|
|
423
424
|
const changed = !active || active.pid !== instance.record.pid || active.port !== instance.record.port;
|
|
424
|
-
setActiveFromEntry(instance, active?.pid === instance.record.pid ? active.owned : false);
|
|
425
|
+
await setActiveFromEntry(instance, active?.pid === instance.record.pid ? active.owned : false);
|
|
426
|
+
if (stopping || !desiredEnabled || runtimeMode !== 'managed')
|
|
427
|
+
return;
|
|
425
428
|
failureCount = 0;
|
|
426
429
|
hasBeenReady = true;
|
|
430
|
+
settleInitialHealth?.('ok');
|
|
427
431
|
if (changed)
|
|
428
432
|
options.logger.info(`✓ ECWeb supervisor 接管现有实例 (PID: ${instance.record.pid}, 端口: ${instance.record.port})`);
|
|
429
433
|
return;
|
|
430
434
|
}
|
|
431
|
-
if (!launchRequested && !hasBeenReady && child?.pid && platform.
|
|
435
|
+
if (!launchRequested && !hasBeenReady && child?.pid && (await platform.isProcessRunningAsync(child.pid))
|
|
432
436
|
&& Date.now() - childStartedAt < (healthConfig?.startupTimeoutMs ?? SERVICE_STARTUP_TIMEOUT_MS))
|
|
433
437
|
return;
|
|
438
|
+
if (stopping || !desiredEnabled || runtimeMode !== 'managed')
|
|
439
|
+
return;
|
|
434
440
|
if (launchRequested) {
|
|
435
441
|
// A successful probe above cancels recovery without spending a retry.
|
|
436
442
|
// Charge the allowance only when an automatic restart actually begins.
|
|
@@ -465,6 +471,8 @@ export function createEcwebSupervisor(options) {
|
|
|
465
471
|
recoveryTimer = null;
|
|
466
472
|
};
|
|
467
473
|
const scheduleRecovery = () => {
|
|
474
|
+
if (!healthy && desiredEnabled && !stopping)
|
|
475
|
+
settleInitialHealth?.('failed');
|
|
468
476
|
if (stopping || intentionalStop || !desiredEnabled || runtimeMode !== 'managed'
|
|
469
477
|
|| restartConfig?.enabled === false || recoveryTimer || launchRequested || recoveryExhausted)
|
|
470
478
|
return;
|
|
@@ -526,6 +534,7 @@ export function createEcwebSupervisor(options) {
|
|
|
526
534
|
if (stopping)
|
|
527
535
|
return;
|
|
528
536
|
if (!desiredEnabled || runtimeMode !== 'managed') {
|
|
537
|
+
settleInitialHealth?.('skipped');
|
|
529
538
|
scheduleCheck();
|
|
530
539
|
return;
|
|
531
540
|
}
|
|
@@ -533,14 +542,15 @@ export function createEcwebSupervisor(options) {
|
|
|
533
542
|
const existing = await waitForHealthyInstance(1_500);
|
|
534
543
|
if (stopping) {
|
|
535
544
|
if (existing)
|
|
536
|
-
setActiveFromEntry(existing, false);
|
|
545
|
+
await setActiveFromEntry(existing, false);
|
|
537
546
|
return;
|
|
538
547
|
}
|
|
539
548
|
if (existing) {
|
|
540
549
|
healthy = true;
|
|
541
550
|
hasBeenReady = true;
|
|
542
|
-
setActiveFromEntry(existing, false);
|
|
551
|
+
await setActiveFromEntry(existing, false);
|
|
543
552
|
options.logger.info(`✓ ECWeb supervisor 接管现有实例 (PID: ${existing.record.pid}, 端口: ${existing.record.port})`);
|
|
553
|
+
settleInitialHealth?.('ok');
|
|
544
554
|
}
|
|
545
555
|
else {
|
|
546
556
|
failureCount = failureThreshold;
|
|
@@ -563,6 +573,8 @@ export function createEcwebSupervisor(options) {
|
|
|
563
573
|
desiredEnabled = config.enabled;
|
|
564
574
|
desiredPort = config.port;
|
|
565
575
|
runtimeMode = nextMode;
|
|
576
|
+
if (!desiredEnabled || runtimeMode !== 'managed')
|
|
577
|
+
settleInitialHealth?.('skipped');
|
|
566
578
|
restartConfig = config.restart;
|
|
567
579
|
healthConfig = config.health;
|
|
568
580
|
failureThreshold = Math.max(1, healthConfig?.failureThreshold ?? options.failureThreshold ?? 3);
|
|
@@ -604,7 +616,10 @@ export function createEcwebSupervisor(options) {
|
|
|
604
616
|
return {
|
|
605
617
|
start() {
|
|
606
618
|
if (!startup)
|
|
607
|
-
startup = start()
|
|
619
|
+
startup = start().catch(error => {
|
|
620
|
+
settleInitialHealth?.('failed');
|
|
621
|
+
throw error;
|
|
622
|
+
});
|
|
608
623
|
return startup;
|
|
609
624
|
},
|
|
610
625
|
configure(config) {
|
|
@@ -619,7 +634,8 @@ export function createEcwebSupervisor(options) {
|
|
|
619
634
|
await restart();
|
|
620
635
|
},
|
|
621
636
|
status() {
|
|
622
|
-
|
|
637
|
+
// Report the latest supervised state; status reads must not run tasklist.
|
|
638
|
+
const running = active !== null;
|
|
623
639
|
const ready = running && healthy && active.port === desiredPort;
|
|
624
640
|
return {
|
|
625
641
|
enabled: desiredEnabled,
|
|
@@ -629,6 +645,7 @@ export function createEcwebSupervisor(options) {
|
|
|
629
645
|
};
|
|
630
646
|
},
|
|
631
647
|
stop(onTiming) {
|
|
648
|
+
settleInitialHealth?.('cancelled');
|
|
632
649
|
if (onTiming) {
|
|
633
650
|
stopTimingListeners.add(onTiming);
|
|
634
651
|
for (const timing of completedStopTimings) {
|