@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.4
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/dist/assetHealth.d.ts +6 -0
- package/dist/assetHealth.js +105 -0
- package/dist/assetSidecarRecovery.d.ts +14 -0
- package/dist/assetSidecarRecovery.js +171 -0
- package/dist/assetTrust.d.ts +24 -0
- package/dist/assetTrust.js +218 -0
- package/dist/autoexec.d.ts +9 -2
- package/dist/autoexec.js +48 -8
- package/dist/cycleConsumer.d.ts +4 -2
- package/dist/cycleConsumer.js +194 -36
- package/dist/dashboard.d.ts +3 -1
- package/dist/dashboard.js +22 -4
- package/dist/dispatch.d.ts +9 -1
- package/dist/dispatch.js +9 -0
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -7
- package/dist/lifecycle.d.ts +19 -1
- package/dist/lifecycle.js +220 -27
- package/dist/localMemoryGraph.d.ts +97 -0
- package/dist/localMemoryGraph.js +889 -0
- package/dist/migrate/v1Import.d.ts +7 -1
- package/dist/migrate/v1Import.js +132 -11
- package/dist/runtimeCapabilities.d.ts +18 -0
- package/dist/runtimeCapabilities.js +81 -0
- package/package.json +11 -7
package/dist/autoexec.js
CHANGED
|
@@ -18,6 +18,7 @@ import { resolveAutoDistillLlm } from './autoDistillLlm.js';
|
|
|
18
18
|
import { resolveAutoDistillAntiGene as resolveAntiGeneDistill } from './autoDistillAntiGene.js';
|
|
19
19
|
import { runTranscriptDistillTick, transcriptDistillMode } from './autoDistillTranscript.js';
|
|
20
20
|
import { runSessionIngestTick, scanSessionDirs } from './index.js';
|
|
21
|
+
import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
|
|
21
22
|
import { resolveAtpAutoDeliver } from './atpAutoDeliver.js';
|
|
22
23
|
import { resolveAtpHome, resolveAtpSenderId } from './atp.js';
|
|
23
24
|
import { runAutobuyPrompt } from './atpAutobuyPrompt.js';
|
|
@@ -40,8 +41,10 @@ export function readAutoExecConfig(base) {
|
|
|
40
41
|
try {
|
|
41
42
|
const c = JSON.parse(readFileSync(p, 'utf8'));
|
|
42
43
|
// Coerce runner to the known set — an unknown value falls back to claude rather than reaching the registry.
|
|
43
|
-
//
|
|
44
|
-
const runner = c.runner === 'codex'
|
|
44
|
+
// Cursor and Gemini remain experimental; both are selectable only through their bounded registry defaults.
|
|
45
|
+
const runner = c.runner === 'codex' || c.runner === 'cursor' || c.runner === 'gemini'
|
|
46
|
+
? c.runner
|
|
47
|
+
: 'claude';
|
|
45
48
|
return { ...def, ...c, allowedRoots: Array.isArray(c.allowedRoots) ? c.allowedRoots : [], runner };
|
|
46
49
|
}
|
|
47
50
|
catch {
|
|
@@ -326,6 +329,40 @@ export function makeHubQuestionLink(cap, options = {}) {
|
|
|
326
329
|
export function shouldSubmitProactiveQuestionsForTask(task) {
|
|
327
330
|
return typeof task.publicQuestionContext === 'string' && task.publicQuestionContext.trim().length > 0;
|
|
328
331
|
}
|
|
332
|
+
export function autoexecLockFailureMessage(error) {
|
|
333
|
+
if (error instanceof util.UnsafeLockPathError) {
|
|
334
|
+
return `evolver autoexec: unsafe single-instance lock (${error.reason}) - inspect the Evolver state directory before retrying\n`;
|
|
335
|
+
}
|
|
336
|
+
if (error instanceof util.LockTimeoutError) {
|
|
337
|
+
return 'evolver autoexec: another daemon holds the single-instance lock - refusing to start a second instance\n';
|
|
338
|
+
}
|
|
339
|
+
return 'evolver autoexec: failed to acquire the single-instance lock - refusing to start\n';
|
|
340
|
+
}
|
|
341
|
+
export function autoexecLockReleaseFailureMessage(error) {
|
|
342
|
+
const reason = error instanceof util.UnsafeLockPathError
|
|
343
|
+
? error.reason
|
|
344
|
+
: typeof error === 'object' && error !== null && typeof error.reason === 'string'
|
|
345
|
+
? error.reason
|
|
346
|
+
: null;
|
|
347
|
+
if (reason) {
|
|
348
|
+
return `evolver autoexec: could not safely release the single-instance lock (${reason}); inspect the Evolver state directory if the next start is blocked\n`;
|
|
349
|
+
}
|
|
350
|
+
return 'evolver autoexec: could not release the single-instance lock; inspect the Evolver state directory if the next start is blocked\n';
|
|
351
|
+
}
|
|
352
|
+
export function releaseAutoexecLock(lockPath, deps = {}) {
|
|
353
|
+
try {
|
|
354
|
+
const result = (deps.releaseLock ?? util.releaseLock)(lockPath);
|
|
355
|
+
if (result && !result.released) {
|
|
356
|
+
(deps.stderr ?? ((text) => { process.stderr.write(text); }))(autoexecLockReleaseFailureMessage(result));
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
(deps.stderr ?? ((text) => { process.stderr.write(text); }))(autoexecLockReleaseFailureMessage(error));
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
329
366
|
export function urgentQuestionRuntimeWiringStatus() {
|
|
330
367
|
return hubNs.URGENT_QUESTION_RUNTIME_WIRING_STATUS;
|
|
331
368
|
}
|
|
@@ -801,6 +838,9 @@ export async function runAutoExec(argv) {
|
|
|
801
838
|
process.stdout.write(line + '\n');
|
|
802
839
|
}
|
|
803
840
|
const store = new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
841
|
+
const memoryGraphDir = join(events.evomapHome(), 'evolution');
|
|
842
|
+
const memoryUser = resolveLocalMemoryUserIdentity(memoryGraphDir);
|
|
843
|
+
const memoryGraph = new LocalMemoryGraph({ dir: memoryGraphDir, ...memoryUser });
|
|
804
844
|
// Observer bus (#113): the event total-bus, finally given its FIRST built-in observer. The value-digest
|
|
805
845
|
// observer is hung off the bus and the bus is wired as the Ingestor's sink, so every emitted event fans out to
|
|
806
846
|
// it; its weekly cadence + measured-value gate keep it quiet. Off via EVOLVER_VALUE_DIGEST=0. Fault-isolated:
|
|
@@ -847,7 +887,7 @@ export async function runAutoExec(argv) {
|
|
|
847
887
|
let warnedNoIsolation = false;
|
|
848
888
|
const probationOn = geneProbationEnabled();
|
|
849
889
|
const deps = {
|
|
850
|
-
engine, store, provenance, review, personality: personalityStore,
|
|
890
|
+
engine, store, provenance, review, personality: personalityStore, memoryGraph,
|
|
851
891
|
// Probation (#306, gated, default OFF via EVOLVER_GENE_PROBATION): try unproven auto-distilled genes (with their
|
|
852
892
|
// strategy embedded) so the cross-AI loop self-closes — contained by the proven exec gates + worktree isolation.
|
|
853
893
|
...(probationOn ? { includeProbation: true } : {}),
|
|
@@ -916,8 +956,8 @@ export async function runAutoExec(argv) {
|
|
|
916
956
|
try {
|
|
917
957
|
util.acquireLock(lockPath, { maxTries: 5 });
|
|
918
958
|
}
|
|
919
|
-
catch {
|
|
920
|
-
process.stderr.write(
|
|
959
|
+
catch (error) {
|
|
960
|
+
process.stderr.write(autoexecLockFailureMessage(error));
|
|
921
961
|
return 1;
|
|
922
962
|
}
|
|
923
963
|
// First-run auto-buyer opt-in (PORT v1 #10): introduce the autonomous spend path to interactive operators once,
|
|
@@ -932,7 +972,7 @@ export async function runAutoExec(argv) {
|
|
|
932
972
|
process.stderr.write(`[ATP-AutoBuyer] first-run prompt failed: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
933
973
|
}
|
|
934
974
|
const uninstallUnhandledRejectionGuard = daemonNs.installUnhandledRejectionWindow({
|
|
935
|
-
beforeExit: () => {
|
|
975
|
+
beforeExit: () => { releaseAutoexecLock(lockPath); },
|
|
936
976
|
});
|
|
937
977
|
// SINGLE-FLIGHT the producer tick (same as autoExecPass): a session scan that outlasts pollMs must not let two
|
|
938
978
|
// ticks interleave in recordSessionMaterial (which would re-emit material.batch_ready before watermarks settle).
|
|
@@ -1016,7 +1056,7 @@ export async function runAutoExec(argv) {
|
|
|
1016
1056
|
process.stderr.write(`[Solo] 连续失败 ${soloState.consecutiveFailures} 次达阈值,熔断停机(非盲重生)。\n`);
|
|
1017
1057
|
// Stop scheduling, release the lock, and exit non-zero. Detached so we
|
|
1018
1058
|
// don't await our own loop.stop() from inside a tick.
|
|
1019
|
-
void loop.stop().then(() => { uninstallUnhandledRejectionGuard();
|
|
1059
|
+
void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); releaseAutoexecLock(lockPath); process.exit(1); });
|
|
1020
1060
|
}
|
|
1021
1061
|
};
|
|
1022
1062
|
// Heartbeat (#106): record liveness + pacing on the AE spine for the WebUI console, THROTTLED so a fast poll does
|
|
@@ -1051,7 +1091,7 @@ export async function runAutoExec(argv) {
|
|
|
1051
1091
|
return;
|
|
1052
1092
|
stopping = true;
|
|
1053
1093
|
process.stdout.write(`\nevolver autoexec: ${sig} → graceful stop (finishing in-flight, releasing lock)\n`);
|
|
1054
|
-
void loop.stop().then(() => { uninstallUnhandledRejectionGuard();
|
|
1094
|
+
void loop.stop().then(() => { uninstallUnhandledRejectionGuard(); releaseAutoexecLock(lockPath); resolve(0); });
|
|
1055
1095
|
};
|
|
1056
1096
|
process.once('SIGINT', () => shutdown('SIGINT'));
|
|
1057
1097
|
process.once('SIGTERM', () => shutdown('SIGTERM'));
|
package/dist/cycleConsumer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assetstore, algo, events, exec, material as materialNs, personality, verify } from '@evomap/evolver-core';
|
|
2
2
|
type RunnerName = NonNullable<exec.AutonomousSafety['runner']>;
|
|
3
|
-
type SleepFn = (ms: number) => Promise<void>;
|
|
3
|
+
type SleepFn = (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
4
4
|
type SandboxedValidationRunner = typeof verify.runSandboxedValidation;
|
|
5
5
|
type MaterialCycleAction = 'cycle' | 'observe' | 'skip' | 'fail';
|
|
6
6
|
type MaterialCycleStatus = exec.AutoExecVerdict['status'] | 'observed' | 'already_consumed' | 'already_terminal' | 'already_running' | 'no_signals' | 'parse_failed' | 'pending';
|
|
@@ -36,7 +36,7 @@ export interface MaterialCycleWatchResult {
|
|
|
36
36
|
idleIterations: number;
|
|
37
37
|
failedItems: number;
|
|
38
38
|
cursor: number;
|
|
39
|
-
stopped: 'max_iterations' | 'max_idle';
|
|
39
|
+
stopped: 'max_iterations' | 'max_idle' | 'cancelled';
|
|
40
40
|
}
|
|
41
41
|
export interface MaterialCycleWatchState {
|
|
42
42
|
ok: true;
|
|
@@ -61,6 +61,7 @@ export interface MaterialCycleOptions {
|
|
|
61
61
|
validate?: exec.AutoExecDeps['validate'];
|
|
62
62
|
runner?: RunnerName;
|
|
63
63
|
timeoutMs?: number;
|
|
64
|
+
signal?: AbortSignal;
|
|
64
65
|
safety?: Partial<exec.AutonomousSafety>;
|
|
65
66
|
agent?: exec.AgentRunner;
|
|
66
67
|
git?: exec.GitRunner;
|
|
@@ -81,6 +82,7 @@ export interface MaterialCycleDeps {
|
|
|
81
82
|
ingestor?: events.Ingestor;
|
|
82
83
|
engine?: algo.CycleEngine;
|
|
83
84
|
personality?: personality.PersonalityStore;
|
|
85
|
+
memoryGraph?: algo.MemoryGraphProvider;
|
|
84
86
|
validate?: exec.AutoExecDeps['validate'];
|
|
85
87
|
/** Test/composition seam for the external validator; production defaults to the hardened core runner. */
|
|
86
88
|
runSandboxedValidation?: SandboxedValidationRunner;
|
package/dist/cycleConsumer.js
CHANGED
|
@@ -4,13 +4,15 @@ import { assetstore, algo, events, exec, material as materialNs, personality, sc
|
|
|
4
4
|
import { materialHasRuntimeSessionSnapshot, materialSourceAvailable, runtimeSessionSourcesForMaterial } from './materialSnapshot.js';
|
|
5
5
|
import { signalTokens } from './distillPrimitives.js';
|
|
6
6
|
import { readEvents, showCycle } from './commands.js';
|
|
7
|
+
import { RUNTIME_CAPABILITY_MATRIX, runtimeCapabilities } from './runtimeCapabilities.js';
|
|
8
|
+
import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
|
|
7
9
|
const CYCLE_GROUP = 'cycle';
|
|
8
10
|
const DEFAULT_LIMIT = 5;
|
|
9
11
|
const DEFAULT_WATCH_IDLE_MS = 1000;
|
|
10
12
|
const DEFAULT_WATCH_MAX_IDLE_MS = 30_000;
|
|
11
13
|
const DEFAULT_WATCH_BACKOFF = 2;
|
|
12
|
-
const CYCLE_USAGE = 'usage: evolver cycle show <id> | evolver cycle status [--json] | evolver cycle recover [--limit N] [--json] | evolver cycle watch --repo <path> [--idle-ms N] [--max-idle N] [--state-file <path>] [--validation-cmd <cmd>] [--timeout-ms N] [--json] | evolver cycle --repo <path> [--limit N] [--target <path>] [--expected-effect <text>] [--runner claude|codex|cursor] [--validation-cmd <cmd>] [--timeout-ms N]\n';
|
|
13
|
-
const WATCH_USAGE = 'usage: evolver cycle watch --repo <path> [--limit N] [--idle-ms N] [--max-idle-ms N] [--max-idle N] [--max-iterations N] [--state-file <path>] [--target <path>] [--expected-effect <text>] [--runner claude|codex|cursor] [--validation-cmd <cmd>] [--timeout-ms N] [--json]\n';
|
|
14
|
+
const CYCLE_USAGE = 'usage: evolver cycle capabilities [--json] | evolver cycle show <id> | evolver cycle status [--json] | evolver cycle recover [--limit N] [--json] | evolver cycle watch --repo <path> [--idle-ms N] [--max-idle N] [--state-file <path>] [--validation-cmd <cmd>] [--timeout-ms N] [--json] | evolver cycle --repo <path> [--limit N] [--target <path>] [--expected-effect <text>] [--runner claude|codex|cursor|gemini] [--validation-cmd <cmd>] [--timeout-ms N]\n';
|
|
15
|
+
const WATCH_USAGE = 'usage: evolver cycle watch --repo <path> [--limit N] [--idle-ms N] [--max-idle-ms N] [--max-idle N] [--max-iterations N] [--state-file <path>] [--target <path>] [--expected-effect <text>] [--runner claude|codex|cursor|gemini] [--validation-cmd <cmd>] [--timeout-ms N] [--json]\n';
|
|
14
16
|
class CycleWatchStateWriteError extends Error {
|
|
15
17
|
constructor() {
|
|
16
18
|
super('cycle watch state file write failed');
|
|
@@ -92,7 +94,60 @@ function parseRequiredPositiveIntFlag(flags, name) {
|
|
|
92
94
|
return Number.isInteger(n) && n > 0 ? n : null;
|
|
93
95
|
}
|
|
94
96
|
function parseRunner(value) {
|
|
95
|
-
|
|
97
|
+
if (value === undefined || value === 'claude')
|
|
98
|
+
return { ok: true, runner: 'claude' };
|
|
99
|
+
if (value.trim() === '')
|
|
100
|
+
return { ok: false, error: 'runner value is required (supported: claude, codex, cursor, gemini)' };
|
|
101
|
+
if (value === 'codex' || value === 'cursor' || value === 'gemini')
|
|
102
|
+
return { ok: true, runner: value };
|
|
103
|
+
if (value === 'antigravity' || value === 'kimi' || value === 'kiro' || value === 'opencode') {
|
|
104
|
+
const capability = RUNTIME_CAPABILITY_MATRIX[value].execute;
|
|
105
|
+
return { ok: false, error: `runner '${value}' execute capability is ${capability.status}: ${capability.evidence}` };
|
|
106
|
+
}
|
|
107
|
+
return { ok: false, error: `unknown runner '${value}' (supported: claude, codex, cursor, gemini)` };
|
|
108
|
+
}
|
|
109
|
+
function resolveMaterialRunner(material, requestedRunner) {
|
|
110
|
+
const sourceAgent = material.sourceAgent;
|
|
111
|
+
let runner;
|
|
112
|
+
switch (sourceAgent) {
|
|
113
|
+
case 'claude-code':
|
|
114
|
+
runner = 'claude';
|
|
115
|
+
break;
|
|
116
|
+
case 'codex':
|
|
117
|
+
case 'cursor':
|
|
118
|
+
case 'gemini':
|
|
119
|
+
runner = sourceAgent;
|
|
120
|
+
break;
|
|
121
|
+
case 'antigravity':
|
|
122
|
+
case 'kimi': {
|
|
123
|
+
const capability = RUNTIME_CAPABILITY_MATRIX[sourceAgent].execute;
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
error: `sourceAgent '${sourceAgent}' execute capability is ${capability.status}: ${capability.evidence}`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
case 'kiro':
|
|
130
|
+
case 'opencode':
|
|
131
|
+
case 'generic-chat':
|
|
132
|
+
return { ok: false, error: `sourceAgent '${sourceAgent}' has no supported cycle runner` };
|
|
133
|
+
default:
|
|
134
|
+
return { ok: false, error: 'runtime_session material has no supported sourceAgent' };
|
|
135
|
+
}
|
|
136
|
+
if (requestedRunner !== undefined && requestedRunner !== runner) {
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
error: `explicit runner '${requestedRunner}' does not match sourceAgent '${sourceAgent}' runner '${runner}'`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return { ok: true, runner };
|
|
143
|
+
}
|
|
144
|
+
function printRuntimeCapabilities() {
|
|
145
|
+
for (const entry of runtimeCapabilities()) {
|
|
146
|
+
const values = ['ingest', 'inject', 'execute', 'verify', 'resume']
|
|
147
|
+
.map((capability) => `${capability}=${entry[capability].status}`)
|
|
148
|
+
.join(' ');
|
|
149
|
+
process.stdout.write(`${entry.runtime}: ${values}\n`);
|
|
150
|
+
}
|
|
96
151
|
}
|
|
97
152
|
function resolveMaterialCycleDeps(deps = {}) {
|
|
98
153
|
const materialStore = deps.materialStore ?? new materialNs.MaterialStore({ path: events.materialStorePath() });
|
|
@@ -106,6 +161,11 @@ function resolveMaterialCycleDeps(deps = {}) {
|
|
|
106
161
|
const review = deps.review ?? new assetstore.ReviewLedger(assetDir);
|
|
107
162
|
const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
|
|
108
163
|
const personalityStore = deps.personality ?? new personality.PersonalityStore();
|
|
164
|
+
const memoryGraphDir = join(events.evomapHome(), 'evolution');
|
|
165
|
+
const memoryGraph = deps.memoryGraph ?? new LocalMemoryGraph({
|
|
166
|
+
dir: memoryGraphDir,
|
|
167
|
+
...resolveLocalMemoryUserIdentity(memoryGraphDir),
|
|
168
|
+
});
|
|
109
169
|
const engine = deps.engine ?? new algo.CycleEngine({
|
|
110
170
|
ingestor,
|
|
111
171
|
selection: algo.makeGeneSelectionPoint(),
|
|
@@ -113,7 +173,7 @@ function resolveMaterialCycleDeps(deps = {}) {
|
|
|
113
173
|
now: () => Date.now(),
|
|
114
174
|
personality: personalityStore,
|
|
115
175
|
});
|
|
116
|
-
return { materialStore, consumer, store, provenance, review, ingestor, engine, personality: personalityStore };
|
|
176
|
+
return { materialStore, consumer, store, provenance, review, ingestor, engine, personality: personalityStore, memoryGraph };
|
|
117
177
|
}
|
|
118
178
|
export function cycleIdForMaterial(materialId) {
|
|
119
179
|
return `autoexec-material-${materialId}`;
|
|
@@ -288,6 +348,19 @@ async function processMaterial(material, opts, deps) {
|
|
|
288
348
|
ackOne(deps.consumer, material);
|
|
289
349
|
return item;
|
|
290
350
|
}
|
|
351
|
+
const runner = resolveMaterialRunner(material, opts.runner);
|
|
352
|
+
if (!runner.ok) {
|
|
353
|
+
const item = {
|
|
354
|
+
materialId: material.materialId,
|
|
355
|
+
action: 'fail',
|
|
356
|
+
status: 'refused',
|
|
357
|
+
cycleId,
|
|
358
|
+
reason: runner.error,
|
|
359
|
+
};
|
|
360
|
+
await emitConsumed(deps.ingestor, material, item);
|
|
361
|
+
ackOne(deps.consumer, material);
|
|
362
|
+
return item;
|
|
363
|
+
}
|
|
291
364
|
let extracted;
|
|
292
365
|
try {
|
|
293
366
|
extracted = materialSignals(material);
|
|
@@ -317,9 +390,10 @@ async function processMaterial(material, opts, deps) {
|
|
|
317
390
|
};
|
|
318
391
|
const safety = {
|
|
319
392
|
allowedRoots: [repo],
|
|
320
|
-
runner: opts.runner ?? 'claude',
|
|
321
393
|
...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
|
|
322
394
|
...opts.safety,
|
|
395
|
+
runner: runner.runner,
|
|
396
|
+
...(opts.signal ? { signal: opts.signal } : {}),
|
|
323
397
|
};
|
|
324
398
|
const verdict = await exec.runAutoExecTask({
|
|
325
399
|
engine: deps.engine,
|
|
@@ -327,6 +401,7 @@ async function processMaterial(material, opts, deps) {
|
|
|
327
401
|
provenance: deps.provenance,
|
|
328
402
|
review: deps.review,
|
|
329
403
|
personality: deps.personality,
|
|
404
|
+
memoryGraph: deps.memoryGraph,
|
|
330
405
|
...(opts.validate ? { validate: opts.validate } : {}),
|
|
331
406
|
...(opts.agent ? { agent: opts.agent } : {}),
|
|
332
407
|
...(opts.git ? { git: opts.git } : {}),
|
|
@@ -342,6 +417,7 @@ async function processMaterial(material, opts, deps) {
|
|
|
342
417
|
finalStage: verdict.finalStage,
|
|
343
418
|
signalCount: extracted.signals.length,
|
|
344
419
|
signals: extracted.signals,
|
|
420
|
+
runner: runner.runner,
|
|
345
421
|
});
|
|
346
422
|
ackOne(deps.consumer, material);
|
|
347
423
|
return item;
|
|
@@ -356,12 +432,35 @@ export async function runMaterialCycleConsumer(opts, injectedDeps = {}) {
|
|
|
356
432
|
const claimed = deps.consumer.claim(CYCLE_GROUP, limit);
|
|
357
433
|
const items = [];
|
|
358
434
|
for (const material of claimed) {
|
|
435
|
+
if (opts.signal?.aborted)
|
|
436
|
+
break;
|
|
359
437
|
items.push(await processMaterial(material, opts, deps));
|
|
360
438
|
}
|
|
361
439
|
return { claimed: claimed.length, processed: items.length, items };
|
|
362
440
|
}
|
|
363
|
-
function defaultSleep(ms) {
|
|
364
|
-
return new Promise((resolveSleep) =>
|
|
441
|
+
function defaultSleep(ms, signal) {
|
|
442
|
+
return new Promise((resolveSleep) => {
|
|
443
|
+
if (signal?.aborted) {
|
|
444
|
+
resolveSleep();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const timer = setTimeout(finish, ms);
|
|
448
|
+
function finish() {
|
|
449
|
+
clearTimeout(timer);
|
|
450
|
+
signal?.removeEventListener('abort', finish);
|
|
451
|
+
resolveSleep();
|
|
452
|
+
}
|
|
453
|
+
signal?.addEventListener('abort', finish, { once: true });
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function watchResult(deps, stopped, counters) {
|
|
457
|
+
return {
|
|
458
|
+
ok: true,
|
|
459
|
+
group: 'cycle.watch',
|
|
460
|
+
...counters,
|
|
461
|
+
cursor: deps.consumer.position(CYCLE_GROUP),
|
|
462
|
+
stopped,
|
|
463
|
+
};
|
|
365
464
|
}
|
|
366
465
|
function positiveNumber(value, fallback) {
|
|
367
466
|
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
@@ -392,6 +491,15 @@ export async function runMaterialCycleWatch(opts, injectedDeps = {}, hooks = {})
|
|
|
392
491
|
let totalProcessed = 0;
|
|
393
492
|
let totalFailedItems = 0;
|
|
394
493
|
for (;;) {
|
|
494
|
+
if (opts.signal?.aborted) {
|
|
495
|
+
return watchResult(deps, 'cancelled', {
|
|
496
|
+
iterations,
|
|
497
|
+
claimed: totalClaimed,
|
|
498
|
+
processed: totalProcessed,
|
|
499
|
+
idleIterations,
|
|
500
|
+
failedItems: totalFailedItems,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
395
503
|
iterations += 1;
|
|
396
504
|
const cursorBefore = deps.consumer.position(CYCLE_GROUP);
|
|
397
505
|
const result = await runMaterialCycleConsumer(opts, deps);
|
|
@@ -419,30 +527,47 @@ export async function runMaterialCycleWatch(opts, injectedDeps = {}, hooks = {})
|
|
|
419
527
|
idleIterations = 0;
|
|
420
528
|
nextDelayMs = idleBase;
|
|
421
529
|
}
|
|
422
|
-
const stopped =
|
|
423
|
-
? '
|
|
424
|
-
:
|
|
425
|
-
? '
|
|
426
|
-
:
|
|
530
|
+
const stopped = opts.signal?.aborted
|
|
531
|
+
? 'cancelled'
|
|
532
|
+
: maxIterations !== undefined && iterations >= maxIterations
|
|
533
|
+
? 'max_iterations'
|
|
534
|
+
: maxIdle !== undefined && idleIterations >= maxIdle
|
|
535
|
+
? 'max_idle'
|
|
536
|
+
: null;
|
|
427
537
|
if (stopped) {
|
|
428
|
-
return {
|
|
429
|
-
ok: true,
|
|
430
|
-
group: 'cycle.watch',
|
|
538
|
+
return watchResult(deps, stopped, {
|
|
431
539
|
iterations,
|
|
432
540
|
claimed: totalClaimed,
|
|
433
541
|
processed: totalProcessed,
|
|
434
542
|
idleIterations,
|
|
435
543
|
failedItems: totalFailedItems,
|
|
436
|
-
|
|
437
|
-
stopped,
|
|
438
|
-
};
|
|
544
|
+
});
|
|
439
545
|
}
|
|
440
546
|
if (idle) {
|
|
441
|
-
await sleep(nextDelayMs);
|
|
547
|
+
await sleep(nextDelayMs, opts.signal);
|
|
442
548
|
nextDelayMs = Math.min(idleMax, Math.max(idleBase, Math.ceil(nextDelayMs * backoff)));
|
|
443
549
|
}
|
|
444
550
|
}
|
|
445
551
|
}
|
|
552
|
+
function createProcessCancellation() {
|
|
553
|
+
const controller = new AbortController();
|
|
554
|
+
let code = 1;
|
|
555
|
+
const interrupt = () => { code = 130; controller.abort(); };
|
|
556
|
+
const terminate = () => { code = 143; controller.abort(); };
|
|
557
|
+
process.once('SIGINT', interrupt);
|
|
558
|
+
process.once('SIGTERM', terminate);
|
|
559
|
+
return {
|
|
560
|
+
signal: controller.signal,
|
|
561
|
+
exitCode: () => code,
|
|
562
|
+
dispose: () => {
|
|
563
|
+
process.removeListener('SIGINT', interrupt);
|
|
564
|
+
process.removeListener('SIGTERM', terminate);
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function combineSignals(primary, secondary) {
|
|
569
|
+
return secondary ? AbortSignal.any([primary, secondary]) : primary;
|
|
570
|
+
}
|
|
446
571
|
async function recoverMaterialCycleAudit(material, deps) {
|
|
447
572
|
const cycleId = cycleIdForMaterial(material.materialId);
|
|
448
573
|
const lockPath = cycleLockPathForMaterial(deps.materialStore.path, material.materialId);
|
|
@@ -701,6 +826,14 @@ function materialCycleExitCode(result) {
|
|
|
701
826
|
return result.items.some(hasFailedItem) ? 1 : 0;
|
|
702
827
|
}
|
|
703
828
|
export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
829
|
+
if (argv[0] === 'capabilities') {
|
|
830
|
+
const flags = parseFlags(argv.slice(1));
|
|
831
|
+
if ('json' in flags)
|
|
832
|
+
process.stdout.write(`${JSON.stringify(runtimeCapabilities())}\n`);
|
|
833
|
+
else
|
|
834
|
+
printRuntimeCapabilities();
|
|
835
|
+
return 0;
|
|
836
|
+
}
|
|
704
837
|
if (argv[0] === 'show') {
|
|
705
838
|
if (!argv[1]) {
|
|
706
839
|
process.stderr.write('usage: evolver cycle show <id>\n');
|
|
@@ -732,6 +865,11 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
732
865
|
}
|
|
733
866
|
if (argv[0] === 'watch') {
|
|
734
867
|
const flags = parseFlags(argv.slice(1));
|
|
868
|
+
const runner = parseRunner(flags['runner']);
|
|
869
|
+
if (!runner.ok) {
|
|
870
|
+
process.stderr.write(`${runner.error}\n`);
|
|
871
|
+
return 1;
|
|
872
|
+
}
|
|
735
873
|
const validationCmds = parseRepeatedFlag(argv.slice(1), 'validation-cmd');
|
|
736
874
|
const repo = flags['repo'];
|
|
737
875
|
if (!repo) {
|
|
@@ -762,6 +900,8 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
762
900
|
let stateFailedItems = 0;
|
|
763
901
|
let lastIteration;
|
|
764
902
|
const writeState = injectedDeps.watchStateWriter ?? writeWatchStateFile;
|
|
903
|
+
const cancellation = createProcessCancellation();
|
|
904
|
+
const signal = combineSignals(cancellation.signal, injectedDeps.safety?.signal);
|
|
765
905
|
let result;
|
|
766
906
|
try {
|
|
767
907
|
result = await runMaterialCycleWatch({
|
|
@@ -769,11 +909,12 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
769
909
|
limit: parsePositiveInt(flags['limit'], DEFAULT_LIMIT),
|
|
770
910
|
target: flags['target'] || '.',
|
|
771
911
|
expectedEffect: flags['expected-effect'] || 'evolve from consumed session material',
|
|
772
|
-
runner
|
|
912
|
+
...('runner' in flags ? { runner: runner.runner } : {}),
|
|
913
|
+
signal,
|
|
773
914
|
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
774
915
|
...(validationCmds.length > 0 ? { validationCmds } : {}),
|
|
775
916
|
...(validate ? { validate } : {}),
|
|
776
|
-
|
|
917
|
+
safety: { ...injectedDeps.safety, signal },
|
|
777
918
|
...(injectedDeps.agent ? { agent: injectedDeps.agent } : {}),
|
|
778
919
|
...(injectedDeps.git ? { git: injectedDeps.git } : {}),
|
|
779
920
|
idleMs: parsePositiveInt(flags['idle-ms'], DEFAULT_WATCH_IDLE_MS),
|
|
@@ -832,6 +973,9 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
832
973
|
process.stderr.write('cycle watch failed: state_write_failed\n');
|
|
833
974
|
return 1;
|
|
834
975
|
}
|
|
976
|
+
finally {
|
|
977
|
+
cancellation.dispose();
|
|
978
|
+
}
|
|
835
979
|
const finalState = {
|
|
836
980
|
ok: true,
|
|
837
981
|
group: 'cycle.watch.state',
|
|
@@ -859,9 +1003,14 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
859
1003
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
860
1004
|
else
|
|
861
1005
|
printWatchResult(result);
|
|
862
|
-
return 0;
|
|
1006
|
+
return result.stopped === 'cancelled' ? cancellation.exitCode() : 0;
|
|
863
1007
|
}
|
|
864
1008
|
const flags = parseFlags(argv);
|
|
1009
|
+
const runner = parseRunner(flags['runner']);
|
|
1010
|
+
if (!runner.ok) {
|
|
1011
|
+
process.stderr.write(`${runner.error}\n`);
|
|
1012
|
+
return 1;
|
|
1013
|
+
}
|
|
865
1014
|
const validationCmds = parseRepeatedFlag(argv, 'validation-cmd');
|
|
866
1015
|
const repo = flags['repo'];
|
|
867
1016
|
if (!repo) {
|
|
@@ -878,19 +1027,28 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
|
|
|
878
1027
|
return 1;
|
|
879
1028
|
}
|
|
880
1029
|
const validate = makeCycleValidationHook(validationCmds, injectedDeps.validate, injectedDeps.runSandboxedValidation);
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1030
|
+
const cancellation = createProcessCancellation();
|
|
1031
|
+
const signal = combineSignals(cancellation.signal, injectedDeps.safety?.signal);
|
|
1032
|
+
let result;
|
|
1033
|
+
try {
|
|
1034
|
+
result = await runMaterialCycleConsumer({
|
|
1035
|
+
repo,
|
|
1036
|
+
limit: parsePositiveInt(flags['limit'], DEFAULT_LIMIT),
|
|
1037
|
+
target: flags['target'] || '.',
|
|
1038
|
+
expectedEffect: flags['expected-effect'] || 'evolve from consumed session material',
|
|
1039
|
+
...('runner' in flags ? { runner: runner.runner } : {}),
|
|
1040
|
+
signal,
|
|
1041
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
1042
|
+
...(validationCmds.length > 0 ? { validationCmds } : {}),
|
|
1043
|
+
...(validate ? { validate } : {}),
|
|
1044
|
+
safety: { ...injectedDeps.safety, signal },
|
|
1045
|
+
...(injectedDeps.agent ? { agent: injectedDeps.agent } : {}),
|
|
1046
|
+
...(injectedDeps.git ? { git: injectedDeps.git } : {}),
|
|
1047
|
+
}, injectedDeps);
|
|
1048
|
+
}
|
|
1049
|
+
finally {
|
|
1050
|
+
cancellation.dispose();
|
|
1051
|
+
}
|
|
894
1052
|
printResult(result);
|
|
895
|
-
return materialCycleExitCode(result);
|
|
1053
|
+
return signal.aborted ? cancellation.exitCode() : materialCycleExitCode(result);
|
|
896
1054
|
}
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MemoryGraphOperatorStatus } from './localMemoryGraph.js';
|
|
1
2
|
export interface DashboardServer {
|
|
2
3
|
readonly token: string;
|
|
3
4
|
readonly launchTicket: string;
|
|
@@ -5,11 +6,12 @@ export interface DashboardServer {
|
|
|
5
6
|
close(): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
export interface DashboardDeps {
|
|
8
|
-
createServer?: () => DashboardServer;
|
|
9
|
+
createServer?: (memoryGraphStatus: () => MemoryGraphOperatorStatus) => DashboardServer;
|
|
9
10
|
openUrl?: (url: string) => Promise<boolean>;
|
|
10
11
|
waitForShutdown?: () => Promise<void>;
|
|
11
12
|
stdout?: (text: string) => void;
|
|
12
13
|
stderr?: (text: string) => void;
|
|
14
|
+
memoryGraphStatus?: () => MemoryGraphOperatorStatus;
|
|
13
15
|
}
|
|
14
16
|
export interface DashboardCommandOptions {
|
|
15
17
|
eaddrinusePortAttempts?: number;
|
package/dist/dashboard.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { assetstore, events, ops } from '@evomap/evolver-core';
|
|
2
|
+
import { assetstore, events, ops, personality } from '@evomap/evolver-core';
|
|
3
3
|
import { loadPriceTable } from '@evomap/evolver-adapter-public';
|
|
4
|
-
import { WebUIServer } from '@evomap/evolver-webui';
|
|
4
|
+
import { createGithubPrDiagnosticsProvider, readLogDiagnostics, readPersonalityDiagnostics, WebUIServer, } from '@evomap/evolver-webui';
|
|
5
|
+
import { lifecyclePaths } from './lifecycle.js';
|
|
6
|
+
import { formatMemoryGraphOperatorStatus, loadMemoryGraphOperatorStatus } from './localMemoryGraph.js';
|
|
5
7
|
const USAGE = 'usage: evolver dashboard [--port N] [--no-open]\n';
|
|
6
8
|
function parsePort(raw) {
|
|
7
9
|
if (!/^\d+$/.test(raw))
|
|
@@ -43,11 +45,14 @@ function parseDashboardOptions(argv) {
|
|
|
43
45
|
}
|
|
44
46
|
return { ok: true, options };
|
|
45
47
|
}
|
|
46
|
-
function createDashboardServer() {
|
|
48
|
+
function createDashboardServer(memoryGraphStatus) {
|
|
47
49
|
const eventsPath = events.rootEventsPath();
|
|
48
50
|
const tracesDir = events.tracesDir();
|
|
49
51
|
const store = new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
50
52
|
const prices = loadPriceTable();
|
|
53
|
+
const personalityStore = new personality.PersonalityStore();
|
|
54
|
+
const logFile = lifecyclePaths().logFile;
|
|
55
|
+
const githubPrDiagnostics = createGithubPrDiagnosticsProvider({ cwd: process.cwd() });
|
|
51
56
|
return new WebUIServer({
|
|
52
57
|
eventsPath,
|
|
53
58
|
store,
|
|
@@ -57,6 +62,10 @@ function createDashboardServer() {
|
|
|
57
62
|
prices,
|
|
58
63
|
}, window),
|
|
59
64
|
retentionReport: () => events.buildRetentionReport(),
|
|
65
|
+
personalityDiagnostics: () => readPersonalityDiagnostics(() => personalityStore.load()),
|
|
66
|
+
logDiagnostics: () => readLogDiagnostics(logFile),
|
|
67
|
+
githubPrDiagnostics: () => githubPrDiagnostics.read(),
|
|
68
|
+
memoryGraphStatus,
|
|
60
69
|
});
|
|
61
70
|
}
|
|
62
71
|
export function dashboardOpenCommand(url, platform = process.platform) {
|
|
@@ -127,11 +136,12 @@ export async function runDashboardCommand(argv, deps = {}, options = {}) {
|
|
|
127
136
|
return 0;
|
|
128
137
|
}
|
|
129
138
|
const createServer = deps.createServer ?? createDashboardServer;
|
|
139
|
+
const memoryGraphStatus = deps.memoryGraphStatus ?? loadMemoryGraphOperatorStatus;
|
|
130
140
|
const openUrl = deps.openUrl ?? openDashboardUrl;
|
|
131
141
|
const waitForShutdown = deps.waitForShutdown ?? waitForShutdownSignal;
|
|
132
142
|
let server;
|
|
133
143
|
try {
|
|
134
|
-
server = createServer();
|
|
144
|
+
server = createServer(memoryGraphStatus);
|
|
135
145
|
}
|
|
136
146
|
catch {
|
|
137
147
|
stderr('dashboard: dashboard_start_failed\n');
|
|
@@ -141,6 +151,14 @@ export async function runDashboardCommand(argv, deps = {}, options = {}) {
|
|
|
141
151
|
try {
|
|
142
152
|
const port = await listenWithPortFallback(server, parsed.options.port, options.eaddrinusePortAttempts ?? 1);
|
|
143
153
|
listening = true;
|
|
154
|
+
let graphStatus;
|
|
155
|
+
try {
|
|
156
|
+
graphStatus = memoryGraphStatus();
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
graphStatus = { recovery: 'degraded', compactedRecords: 0, activeRecords: 0, corruptLines: 1, oversizedLines: 0, oversizedFiles: 0, archives: 0 };
|
|
160
|
+
}
|
|
161
|
+
stdout(`dashboard: memory-graph ${formatMemoryGraphOperatorStatus(graphStatus)}\n`);
|
|
144
162
|
const baseUrl = `http://127.0.0.1:${port}/`;
|
|
145
163
|
const launchUrl = `${baseUrl}launch?ticket=${encodeURIComponent(server.launchTicket)}`;
|
|
146
164
|
if (parsed.options.noOpen) {
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
interface ProxyCliModule {
|
|
2
|
+
runProxyCli(options: {
|
|
3
|
+
argv: readonly string[];
|
|
4
|
+
}): Promise<number>;
|
|
5
|
+
}
|
|
6
|
+
type ProxyCliImporter = () => Promise<ProxyCliModule>;
|
|
7
|
+
export declare function runProxyCommand(argv: string[], importer?: ProxyCliImporter): Promise<number>;
|
|
1
8
|
export type CommandHandler = (argv: string[]) => Promise<number>;
|
|
2
9
|
/** Verbs dispatched asynchronously ahead of the synchronous runCli core. cli.ts drives its dispatch from this. */
|
|
3
10
|
export declare const ASYNC_COMMANDS: Readonly<Record<string, CommandHandler>>;
|
|
@@ -8,4 +15,5 @@ export declare const SYNC_COMMANDS: readonly ["status", "cycles", "trigger", "va
|
|
|
8
15
|
export declare const ALL_COMMANDS: ReadonlySet<string>;
|
|
9
16
|
export declare function v1TopLevelRunArgs(argv: readonly string[]): readonly string[] | undefined;
|
|
10
17
|
/** Run a top-level argv against the registry: async handler if present, else the synchronous runCli core. */
|
|
11
|
-
export declare function dispatch(argv: readonly string[]): Promise<number> | number;
|
|
18
|
+
export declare function dispatch(argv: readonly string[]): Promise<number> | number;
|
|
19
|
+
export {};
|
package/dist/dispatch.js
CHANGED
|
@@ -28,7 +28,13 @@ import { runCycleCommand } from './cycleConsumer.js';
|
|
|
28
28
|
import { runProxyToken } from './proxyToken.js';
|
|
29
29
|
import { runMaterialCommand } from './materialPackage.js';
|
|
30
30
|
import { runDashboardCommand } from './dashboard.js';
|
|
31
|
+
import { runAssetTrustCommand } from './assetTrust.js';
|
|
32
|
+
import { runAssetHealthCommand } from './assetHealth.js';
|
|
31
33
|
import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat } from './v1Compat.js';
|
|
34
|
+
export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
|
|
35
|
+
const { runProxyCli } = await importer();
|
|
36
|
+
return runProxyCli({ argv: ['proxy', ...argv] });
|
|
37
|
+
}
|
|
32
38
|
/** Verbs dispatched asynchronously ahead of the synchronous runCli core. cli.ts drives its dispatch from this. */
|
|
33
39
|
export const ASYNC_COMMANDS = {
|
|
34
40
|
migrate: runMigrate,
|
|
@@ -65,6 +71,9 @@ export const ASYNC_COMMANDS = {
|
|
|
65
71
|
'anti-gene-benchmark': runAntiGeneBenchmarkCommand,
|
|
66
72
|
'anti-gene-rollout': runAntiGeneRolloutCommand,
|
|
67
73
|
dashboard: runDashboardCommand,
|
|
74
|
+
'asset-trust': runAssetTrustCommand,
|
|
75
|
+
'asset-health': runAssetHealthCommand,
|
|
76
|
+
proxy: runProxyCommand,
|
|
68
77
|
run: runV1RunCompat,
|
|
69
78
|
solidify: runV1SolidifyCompat,
|
|
70
79
|
fetch: runV1FetchCompat,
|