@evomap/evolver-cli 2.0.0-beta.5 → 2.0.0-beta.7
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/autoDistillLlm.d.ts +6 -0
- package/dist/autoDistillLlm.js +40 -6
- package/dist/autoexec.d.ts +2 -10
- package/dist/autoexec.js +17 -25
- package/dist/autoexecConfig.d.ts +10 -0
- package/dist/autoexecConfig.js +68 -0
- package/dist/cliContracts.js +22 -1
- package/dist/dashboard.d.ts +11 -1
- package/dist/dashboard.js +173 -12
- package/dist/dispatch.js +4 -0
- package/dist/distillPrimitives.d.ts +5 -1
- package/dist/distillPrimitives.js +1 -1
- package/dist/doctor.js +16 -0
- package/dist/index.js +27 -6
- package/dist/issueReport.d.ts +7 -0
- package/dist/issueReport.js +291 -0
- package/dist/materialSnapshot.d.ts +24 -0
- package/dist/materialSnapshot.js +234 -12
- package/dist/recipe.js +7 -1
- package/dist/reuse.d.ts +5 -3
- package/dist/reuse.js +50 -3
- package/dist/setupHooks.d.ts +5 -0
- package/dist/setupHooks.js +230 -14
- package/dist/workflow.d.ts +39 -0
- package/dist/workflow.js +386 -0
- package/dist/workflowRuntime.d.ts +66 -0
- package/dist/workflowRuntime.js +631 -0
- package/package.json +7 -7
package/dist/autoDistillLlm.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface LlmDistillRunnerResult {
|
|
|
30
30
|
exitCode: number | null;
|
|
31
31
|
stdout: string;
|
|
32
32
|
stderr?: string;
|
|
33
|
+
stdoutTruncated?: boolean;
|
|
33
34
|
}
|
|
34
35
|
export type LlmDistillRunner = (prompt: string, ctx: {
|
|
35
36
|
cwd: string;
|
|
@@ -80,6 +81,11 @@ export declare function runClaudeDistill(prompt: string, ctx: {
|
|
|
80
81
|
* `--output-last-message <file>`: capture ONLY the final assistant message (the gene JSON), avoiding codex's stdout
|
|
81
82
|
* preamble/token-count noise. Prompt arrives via stdin (the trailing `-`). Verified live against codex-cli 0.137.0. */
|
|
82
83
|
export declare function codexDistillArgs(cwd: string, lastMessageFile: string, model?: string): string[];
|
|
84
|
+
/** Read Codex's final-message file without allowing that subprocess-owned file to bypass output bounds. */
|
|
85
|
+
export declare function readBoundedDistillOutputFile(path: string, maxBytes?: number): {
|
|
86
|
+
text: string;
|
|
87
|
+
truncated: boolean;
|
|
88
|
+
};
|
|
83
89
|
/** Distill a prompt with `codex exec` (read-only). Reads the clean final message from --output-last-message so
|
|
84
90
|
* parseDistillOutput sees a bare gene JSON; falls back to raw stdout (pickGeneObject scans it) if the file is absent.
|
|
85
91
|
* Windows: codex is a `.cmd` npm shim, so route through resolveSpawnCommand (shell-free). */
|
package/dist/autoDistillLlm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
5
|
import { algo, assetstore, events, exec, hub, verify } from '@evomap/evolver-core';
|
|
@@ -338,7 +338,7 @@ export async function runClaudeDistill(prompt, ctx) {
|
|
|
338
338
|
const env = exec.scrubAgentEnv(ctx.env, { allowPrefixes: exec.getRunnerSpec('claude').envAllow.prefixes });
|
|
339
339
|
try {
|
|
340
340
|
const r = await exec.spawnCapture('claude', args, { cwd: ctx.cwd, timeoutMs: ctx.timeoutMs, input: prompt, env });
|
|
341
|
-
return { exitCode: r.code, stdout: r.stdout, stderr: r.stderr };
|
|
341
|
+
return { exitCode: r.code, stdout: r.stdout, stderr: r.stderr, stdoutTruncated: r.stdoutTruncated };
|
|
342
342
|
}
|
|
343
343
|
catch (e) {
|
|
344
344
|
return { exitCode: null, stdout: '', stderr: e instanceof Error ? e.message : String(e) };
|
|
@@ -356,6 +356,30 @@ export function codexDistillArgs(cwd, lastMessageFile, model) {
|
|
|
356
356
|
args.push('-');
|
|
357
357
|
return args;
|
|
358
358
|
}
|
|
359
|
+
/** Read Codex's final-message file without allowing that subprocess-owned file to bypass output bounds. */
|
|
360
|
+
export function readBoundedDistillOutputFile(path, maxBytes = exec.DEFAULT_MAX_CAPTURE_BYTES) {
|
|
361
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 256)
|
|
362
|
+
throw new RangeError('maxBytes must be an integer >= 256');
|
|
363
|
+
const fd = openSync(path, 'r');
|
|
364
|
+
try {
|
|
365
|
+
const buffer = Buffer.allocUnsafe(maxBytes + 1);
|
|
366
|
+
let offset = 0;
|
|
367
|
+
while (offset < buffer.length) {
|
|
368
|
+
const read = readSync(fd, buffer, offset, buffer.length - offset, null);
|
|
369
|
+
if (read === 0)
|
|
370
|
+
break;
|
|
371
|
+
offset += read;
|
|
372
|
+
}
|
|
373
|
+
const truncated = offset > maxBytes;
|
|
374
|
+
return {
|
|
375
|
+
text: truncated ? '' : buffer.subarray(0, offset).toString('utf8').trim(),
|
|
376
|
+
truncated,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
closeSync(fd);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
359
383
|
/** Distill a prompt with `codex exec` (read-only). Reads the clean final message from --output-last-message so
|
|
360
384
|
* parseDistillOutput sees a bare gene JSON; falls back to raw stdout (pickGeneObject scans it) if the file is absent.
|
|
361
385
|
* Windows: codex is a `.cmd` npm shim, so route through resolveSpawnCommand (shell-free). */
|
|
@@ -367,13 +391,20 @@ export async function runCodexDistill(prompt, ctx) {
|
|
|
367
391
|
try {
|
|
368
392
|
const r = await exec.spawnCapture(resolved.cmd, resolved.args, { cwd: ctx.cwd, timeoutMs: ctx.timeoutMs, input: prompt, env });
|
|
369
393
|
let stdout = r.stdout;
|
|
394
|
+
let stdoutTruncated = r.stdoutTruncated;
|
|
370
395
|
try {
|
|
371
|
-
const last =
|
|
372
|
-
if (last)
|
|
373
|
-
stdout =
|
|
396
|
+
const last = readBoundedDistillOutputFile(lastMessageFile);
|
|
397
|
+
if (last.truncated) {
|
|
398
|
+
stdout = '';
|
|
399
|
+
stdoutTruncated = true;
|
|
400
|
+
}
|
|
401
|
+
else if (last.text) {
|
|
402
|
+
stdout = last.text;
|
|
403
|
+
stdoutTruncated = false;
|
|
404
|
+
}
|
|
374
405
|
}
|
|
375
406
|
catch { /* file absent (codex failed early) → keep raw stdout for pickGeneObject */ }
|
|
376
|
-
return { exitCode: r.code, stdout, stderr: r.stderr };
|
|
407
|
+
return { exitCode: r.code, stdout, stderr: r.stderr, stdoutTruncated };
|
|
377
408
|
}
|
|
378
409
|
catch (e) {
|
|
379
410
|
return { exitCode: null, stdout: '', stderr: e instanceof Error ? e.message : String(e) };
|
|
@@ -467,6 +498,9 @@ export async function autoDistillLlm(options) {
|
|
|
467
498
|
// permanently exhaust this data hash after MAX_ATTEMPTS — the exact silent stall this exemption prevents.
|
|
468
499
|
return { ok: false, mode, reason: llm.exitCode === null ? 'claude_spawn_error' : 'claude_nonzero_exit', dataHash: input.dataHash };
|
|
469
500
|
}
|
|
501
|
+
if (llm.stdoutTruncated) {
|
|
502
|
+
return { ok: false, mode, reason: 'llm_output_truncated', dataHash: input.dataHash };
|
|
503
|
+
}
|
|
470
504
|
const raw = parseDistillOutput(llm.stdout);
|
|
471
505
|
const candidate0 = asGeneCandidate(raw);
|
|
472
506
|
if (!candidate0) {
|
package/dist/autoexec.d.ts
CHANGED
|
@@ -9,22 +9,15 @@ import { type AutoDistillLlmResult, type LlmDistillRunner } from './autoDistillL
|
|
|
9
9
|
import { type AutoDistillAntiGeneMode, type AutoDistillAntiGeneResult } from './autoDistillAntiGene.js';
|
|
10
10
|
import { type AutoDistillTranscriptMode, type TranscriptDistillTickResult } from './autoDistillTranscript.js';
|
|
11
11
|
import { type SessionIngestTickResult } from './index.js';
|
|
12
|
+
export { readAutoExecConfig, type AutoExecConfig } from './autoexecConfig.js';
|
|
12
13
|
export interface AutoExecDirs {
|
|
13
14
|
base: string;
|
|
14
15
|
tasks: string;
|
|
15
16
|
done: string;
|
|
16
17
|
refused: string;
|
|
17
18
|
}
|
|
18
|
-
export interface AutoExecConfig {
|
|
19
|
-
allowedRoots: string[];
|
|
20
|
-
pollMs: number;
|
|
21
|
-
timeoutMs: number;
|
|
22
|
-
runner: 'claude' | 'codex' | 'cursor' | 'gemini';
|
|
23
|
-
}
|
|
24
19
|
/** Create the queue layout under <home>/autoexec/{tasks,done,refused}. */
|
|
25
20
|
export declare function ensureAutoExecDirs(base: string): AutoExecDirs;
|
|
26
|
-
/** Read <base>/config.json; deny-by-default (empty allowedRoots) when absent. Default runner 'claude' (#66). */
|
|
27
|
-
export declare function readAutoExecConfig(base: string): AutoExecConfig;
|
|
28
21
|
export declare function summarizeSandboxedValidation(result: verify.SandboxedValidationResult): string | null;
|
|
29
22
|
/**
|
|
30
23
|
* One queue pass: drain every tasks/*.json through `runOne`, route the verdict to done/ (success or failure)
|
|
@@ -243,5 +236,4 @@ export declare function runIdleTranscriptDistillForBeat(beat: Pick<Beat, 'intens
|
|
|
243
236
|
* autoExecPass on an interval. Real agent execution only happens for repos the operator has allowlisted in
|
|
244
237
|
* <home>/autoexec/config.json (allowedRoots) — empty by default = nothing runs.
|
|
245
238
|
*/
|
|
246
|
-
export declare function runAutoExec(argv: readonly string[]): Promise<number>;
|
|
247
|
-
export {};
|
|
239
|
+
export declare function runAutoExec(argv: readonly string[]): Promise<number>;
|
package/dist/autoexec.js
CHANGED
|
@@ -25,32 +25,17 @@ import { runAutobuyPrompt } from './atpAutobuyPrompt.js';
|
|
|
25
25
|
import * as solomode from './solo/mode.js';
|
|
26
26
|
import * as gitGuard from './solo/gitGuard.js';
|
|
27
27
|
import * as breaker from './solo/breaker.js';
|
|
28
|
+
import { initializeWorkflowStartupRecovery } from './workflowRuntime.js';
|
|
29
|
+
import { readAutoExecConfig } from './autoexecConfig.js';
|
|
30
|
+
export { readAutoExecConfig } from './autoexecConfig.js';
|
|
31
|
+
const ENV_FILE_UNAVAILABLE_DIAGNOSTIC = '[evolver-autoexec] env_file_unavailable\n';
|
|
28
32
|
/** Create the queue layout under <home>/autoexec/{tasks,done,refused}. */
|
|
29
33
|
export function ensureAutoExecDirs(base) {
|
|
30
34
|
const dirs = { base, tasks: join(base, 'tasks'), done: join(base, 'done'), refused: join(base, 'refused') };
|
|
31
|
-
for (const
|
|
32
|
-
mkdirSync(
|
|
35
|
+
for (const dir of [dirs.tasks, dirs.done, dirs.refused])
|
|
36
|
+
mkdirSync(dir, { recursive: true });
|
|
33
37
|
return dirs;
|
|
34
38
|
}
|
|
35
|
-
/** Read <base>/config.json; deny-by-default (empty allowedRoots) when absent. Default runner 'claude' (#66). */
|
|
36
|
-
export function readAutoExecConfig(base) {
|
|
37
|
-
const p = join(base, 'config.json');
|
|
38
|
-
const def = { allowedRoots: [], pollMs: 60_000, timeoutMs: 600_000, runner: 'claude' };
|
|
39
|
-
if (!existsSync(p))
|
|
40
|
-
return def;
|
|
41
|
-
try {
|
|
42
|
-
const c = JSON.parse(readFileSync(p, 'utf8'));
|
|
43
|
-
// Coerce runner to the known set — an unknown value falls back to claude rather than reaching the registry.
|
|
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';
|
|
48
|
-
return { ...def, ...c, allowedRoots: Array.isArray(c.allowedRoots) ? c.allowedRoots : [], runner };
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return def;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
39
|
function clippedValidationText(value) {
|
|
55
40
|
return value.length <= 160 ? value : `${value.slice(0, 157)}...`;
|
|
56
41
|
}
|
|
@@ -494,8 +479,10 @@ function hubMode(env) {
|
|
|
494
479
|
*/
|
|
495
480
|
export function resolveHubLink(env = process.env, ingestor, connectHub = connectPublicHub) {
|
|
496
481
|
const envFile = loadEnvFileFromEnv(env);
|
|
497
|
-
if (envFile.error)
|
|
498
|
-
process.stderr.write(
|
|
482
|
+
if (envFile.error) {
|
|
483
|
+
process.stderr.write(ENV_FILE_UNAVAILABLE_DIAGNOSTIC);
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
499
486
|
if (env['EVOLVER_REUSE_BEFORE_SOLVE'] !== '1')
|
|
500
487
|
return undefined;
|
|
501
488
|
if (hubMode(env) === 'private') {
|
|
@@ -819,8 +806,10 @@ export async function runAutoExec(argv) {
|
|
|
819
806
|
// loads the file too (idempotent re-read) for its standalone callers/tests, so this is the single authoritative
|
|
820
807
|
// early load, not a replacement. This MUST stay above runAutobuyPrompt() (which now runs after the lock below).
|
|
821
808
|
const envFile = loadEnvFileFromEnv(process.env);
|
|
822
|
-
if (envFile.error)
|
|
823
|
-
process.stderr.write(
|
|
809
|
+
if (envFile.error) {
|
|
810
|
+
process.stderr.write(ENV_FILE_UNAVAILABLE_DIAGNOSTIC);
|
|
811
|
+
return 1;
|
|
812
|
+
}
|
|
824
813
|
const home = argv.find((a) => !a.startsWith('-')) ?? join(events.evomapHome(), 'autoexec');
|
|
825
814
|
const dirs = ensureAutoExecDirs(home);
|
|
826
815
|
const cfg = readAutoExecConfig(home);
|
|
@@ -974,6 +963,9 @@ export async function runAutoExec(argv) {
|
|
|
974
963
|
const uninstallUnhandledRejectionGuard = daemonNs.installUnhandledRejectionWindow({
|
|
975
964
|
beforeExit: () => { releaseAutoexecLock(lockPath); },
|
|
976
965
|
});
|
|
966
|
+
// Durable workflow recovery uses the same policy/review-gated runtime factory as `evolver workflow start/resume`.
|
|
967
|
+
// Pass the already-loaded config so a custom autoexec home uses the same allowlist, runner, and validation profiles.
|
|
968
|
+
initializeWorkflowStartupRecovery({ autoExecHome: home, autoExecConfig: cfg });
|
|
977
969
|
// SINGLE-FLIGHT the producer tick (same as autoExecPass): a session scan that outlasts pollMs must not let two
|
|
978
970
|
// ticks interleave in recordSessionMaterial (which would re-emit material.batch_ready before watermarks settle).
|
|
979
971
|
const guardedDistill = distill.enabled && distill.observer ? exec.singleFlight(() => distill.tick()) : null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type AutoExecRunner = 'claude' | 'codex' | 'cursor' | 'gemini';
|
|
2
|
+
export interface AutoExecConfig {
|
|
3
|
+
allowedRoots: string[];
|
|
4
|
+
pollMs: number;
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
runner: AutoExecRunner;
|
|
7
|
+
workflowValidationProfiles: Record<string, string[]>;
|
|
8
|
+
}
|
|
9
|
+
/** Read <base>/config.json with deny-by-default workflow and autoexec safety settings. */
|
|
10
|
+
export declare function readAutoExecConfig(base: string): AutoExecConfig;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { verify } from '@evomap/evolver-core';
|
|
4
|
+
const DEFAULT_POLL_MS = 60_000;
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
6
|
+
const MAX_VALIDATION_PROFILES = 32;
|
|
7
|
+
const MAX_VALIDATION_COMMANDS = 16;
|
|
8
|
+
const MAX_VALIDATION_COMMAND_LENGTH = 300;
|
|
9
|
+
const PROFILE_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
10
|
+
const SECRET_TEXT_RE = /(?:\bBearer\s+[A-Za-z0-9._~+/=-]{8,}|\b(?:sk|gh[oprsu])_[A-Za-z0-9_-]{8,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*\S+)/i;
|
|
11
|
+
function parseRunner(value) {
|
|
12
|
+
return value === 'codex' || value === 'cursor' || value === 'gemini' ? value : 'claude';
|
|
13
|
+
}
|
|
14
|
+
function isSafeValidationCommand(value) {
|
|
15
|
+
if (typeof value !== 'string')
|
|
16
|
+
return false;
|
|
17
|
+
const command = value.trim();
|
|
18
|
+
if (command.length === 0 || command.length > MAX_VALIDATION_COMMAND_LENGTH)
|
|
19
|
+
return false;
|
|
20
|
+
if (SECRET_TEXT_RE.test(command) || verify.SHELL_METACHARS.test(command))
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
function parseValidationProfiles(value) {
|
|
25
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
26
|
+
return {};
|
|
27
|
+
const profiles = {};
|
|
28
|
+
for (const [name, commands] of Object.entries(value).slice(0, MAX_VALIDATION_PROFILES)) {
|
|
29
|
+
if (!PROFILE_NAME_RE.test(name) || !Array.isArray(commands) || commands.length === 0 || commands.length > MAX_VALIDATION_COMMANDS)
|
|
30
|
+
continue;
|
|
31
|
+
if (!commands.every(isSafeValidationCommand))
|
|
32
|
+
continue;
|
|
33
|
+
profiles[name] = commands.map((command) => command.trim());
|
|
34
|
+
}
|
|
35
|
+
return profiles;
|
|
36
|
+
}
|
|
37
|
+
/** Read <base>/config.json with deny-by-default workflow and autoexec safety settings. */
|
|
38
|
+
export function readAutoExecConfig(base) {
|
|
39
|
+
const path = join(base, 'config.json');
|
|
40
|
+
const defaults = {
|
|
41
|
+
allowedRoots: [],
|
|
42
|
+
pollMs: DEFAULT_POLL_MS,
|
|
43
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
44
|
+
runner: 'claude',
|
|
45
|
+
workflowValidationProfiles: {},
|
|
46
|
+
};
|
|
47
|
+
if (!existsSync(path))
|
|
48
|
+
return defaults;
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
51
|
+
return {
|
|
52
|
+
allowedRoots: Array.isArray(parsed['allowedRoots'])
|
|
53
|
+
? parsed['allowedRoots'].filter((root) => typeof root === 'string' && root.trim().length > 0)
|
|
54
|
+
: [],
|
|
55
|
+
pollMs: typeof parsed['pollMs'] === 'number' && Number.isSafeInteger(parsed['pollMs']) && parsed['pollMs'] > 0
|
|
56
|
+
? parsed['pollMs']
|
|
57
|
+
: DEFAULT_POLL_MS,
|
|
58
|
+
timeoutMs: typeof parsed['timeoutMs'] === 'number' && Number.isSafeInteger(parsed['timeoutMs']) && parsed['timeoutMs'] > 0
|
|
59
|
+
? parsed['timeoutMs']
|
|
60
|
+
: DEFAULT_TIMEOUT_MS,
|
|
61
|
+
runner: parseRunner(parsed['runner']),
|
|
62
|
+
workflowValidationProfiles: parseValidationProfiles(parsed['workflowValidationProfiles']),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return defaults;
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/cliContracts.js
CHANGED
|
@@ -388,11 +388,32 @@ async function findAssetInStore(ref, store) {
|
|
|
388
388
|
}
|
|
389
389
|
function loadLocalAssetsReadOnly(baseDir) {
|
|
390
390
|
return [
|
|
391
|
-
...
|
|
391
|
+
...loadLocalGenesReadOnly(baseDir),
|
|
392
392
|
...readJsonLines(`${baseDir}/capsules.jsonl`, 'Capsule'),
|
|
393
393
|
...readJsonLines(`${baseDir}/events.jsonl`, 'EvolutionEvent'),
|
|
394
394
|
];
|
|
395
395
|
}
|
|
396
|
+
function loadLocalGenesReadOnly(baseDir) {
|
|
397
|
+
const byId = new Map();
|
|
398
|
+
for (const gene of [...readGenesEnvelopeReadOnly(`${baseDir}/genes.json`), ...readJsonLines(`${baseDir}/genes.jsonl`, 'Gene')]) {
|
|
399
|
+
const id = stringField(gene, 'id') ?? gene.asset_id;
|
|
400
|
+
if (id && !byId.has(id))
|
|
401
|
+
byId.set(id, gene);
|
|
402
|
+
}
|
|
403
|
+
return [...byId.values()];
|
|
404
|
+
}
|
|
405
|
+
function readGenesEnvelopeReadOnly(filePath) {
|
|
406
|
+
if (!existsSync(filePath))
|
|
407
|
+
return [];
|
|
408
|
+
try {
|
|
409
|
+
const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
410
|
+
const envelopeGenes = isRecord(parsed) && Array.isArray(parsed['genes']) ? parsed['genes'] : [];
|
|
411
|
+
return envelopeGenes.filter(isRecord).map((gene) => normalizeAsset({ ...gene, type: 'Gene' }));
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
throw new ContractError('schema_invalid', 'asset schema is invalid');
|
|
415
|
+
}
|
|
416
|
+
}
|
|
396
417
|
function readJsonLines(filePath, type) {
|
|
397
418
|
if (!existsSync(filePath))
|
|
398
419
|
return [];
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type WorkflowProvider } from '@evomap/evolver-webui';
|
|
1
2
|
import { type MemoryGraphOperatorStatus } from './localMemoryGraph.js';
|
|
2
3
|
export interface DashboardServer {
|
|
3
4
|
readonly token: string;
|
|
@@ -5,8 +6,10 @@ export interface DashboardServer {
|
|
|
5
6
|
listen(port?: number): Promise<number>;
|
|
6
7
|
close(): Promise<void>;
|
|
7
8
|
}
|
|
9
|
+
export type DashboardEnv = Readonly<Record<string, string | undefined>>;
|
|
8
10
|
export interface DashboardDeps {
|
|
9
|
-
createServer?: (memoryGraphStatus: () => MemoryGraphOperatorStatus) => DashboardServer;
|
|
11
|
+
createServer?: (memoryGraphStatus: () => MemoryGraphOperatorStatus, env: DashboardEnv) => DashboardServer;
|
|
12
|
+
env?: DashboardEnv;
|
|
10
13
|
openUrl?: (url: string) => Promise<boolean>;
|
|
11
14
|
waitForShutdown?: () => Promise<void>;
|
|
12
15
|
stdout?: (text: string) => void;
|
|
@@ -16,6 +19,13 @@ export interface DashboardDeps {
|
|
|
16
19
|
export interface DashboardCommandOptions {
|
|
17
20
|
eaddrinusePortAttempts?: number;
|
|
18
21
|
}
|
|
22
|
+
export interface WorkflowStateReader {
|
|
23
|
+
listRunIds(): string[];
|
|
24
|
+
read(runId: string): unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare function createWorkflowDashboardProvider(store: WorkflowStateReader): WorkflowProvider;
|
|
27
|
+
export declare function createDashboardWorkflowProvider(env?: DashboardEnv, defaultStateDir?: () => string): WorkflowProvider;
|
|
28
|
+
export declare function createDashboardServer(memoryGraphStatus: () => MemoryGraphOperatorStatus, env?: DashboardEnv): DashboardServer;
|
|
19
29
|
export declare function dashboardOpenCommand(url: string, platform?: NodeJS.Platform): {
|
|
20
30
|
command: string;
|
|
21
31
|
args: string[];
|
package/dist/dashboard.js
CHANGED
|
@@ -1,10 +1,155 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { assetstore, events, ops, personality } from '@evomap/evolver-core';
|
|
2
|
+
import { assetstore, events, ops, personality, workflow } from '@evomap/evolver-core';
|
|
3
3
|
import { loadPriceTable } from '@evomap/evolver-adapter-public';
|
|
4
|
+
import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
4
5
|
import { createGithubPrDiagnosticsProvider, readLogDiagnostics, readPersonalityDiagnostics, WebUIServer, } from '@evomap/evolver-webui';
|
|
5
6
|
import { lifecyclePaths } from './lifecycle.js';
|
|
6
7
|
import { formatMemoryGraphOperatorStatus, loadMemoryGraphOperatorStatus } from './localMemoryGraph.js';
|
|
7
8
|
const USAGE = 'usage: evolver dashboard [--port N] [--no-open]\n';
|
|
9
|
+
class DashboardEnvFileUnavailableError extends Error {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('dashboard_env_file_unavailable');
|
|
12
|
+
this.name = 'DashboardEnvFileUnavailableError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function resolveDashboardEnv(env) {
|
|
16
|
+
const resolvedEnv = { ...env };
|
|
17
|
+
const envFile = loadEnvFileFromEnv(resolvedEnv);
|
|
18
|
+
if (envFile.error)
|
|
19
|
+
throw new DashboardEnvFileUnavailableError();
|
|
20
|
+
return resolvedEnv;
|
|
21
|
+
}
|
|
22
|
+
function dashboardStartupError(error) {
|
|
23
|
+
return error instanceof DashboardEnvFileUnavailableError
|
|
24
|
+
? 'dashboard_env_file_unavailable'
|
|
25
|
+
: 'dashboard_start_failed';
|
|
26
|
+
}
|
|
27
|
+
function record(value) {
|
|
28
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
29
|
+
}
|
|
30
|
+
function stringField(value) {
|
|
31
|
+
return typeof value === 'string' ? value : null;
|
|
32
|
+
}
|
|
33
|
+
function runSummary(value) {
|
|
34
|
+
const state = record(value);
|
|
35
|
+
if (!state)
|
|
36
|
+
return null;
|
|
37
|
+
const runId = stringField(state['runId']);
|
|
38
|
+
const workflowId = stringField(state['workflowId']);
|
|
39
|
+
const status = stringField(state['status']);
|
|
40
|
+
const createdAt = stringField(state['createdAt']);
|
|
41
|
+
const updatedAt = stringField(state['updatedAt']);
|
|
42
|
+
if (!runId || !workflowId || !status || !createdAt || !updatedAt)
|
|
43
|
+
return null;
|
|
44
|
+
const currentKey = stringField(state['currentStep']);
|
|
45
|
+
const steps = record(state['steps']);
|
|
46
|
+
const currentState = currentKey && steps ? record(steps[currentKey]) : null;
|
|
47
|
+
const currentStep = currentState && currentState['status'] !== 'succeeded'
|
|
48
|
+
? stringField(currentState['executionId']) ?? stringField(currentState['stepId']) ?? currentKey
|
|
49
|
+
: currentState ? null : currentKey;
|
|
50
|
+
return {
|
|
51
|
+
runId,
|
|
52
|
+
workflowId,
|
|
53
|
+
status,
|
|
54
|
+
currentStep,
|
|
55
|
+
createdAt,
|
|
56
|
+
updatedAt,
|
|
57
|
+
completedAt: stringField(state['completedAt']),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function historyRows(value) {
|
|
61
|
+
if (Array.isArray(value))
|
|
62
|
+
return value;
|
|
63
|
+
const envelope = record(value);
|
|
64
|
+
if (!envelope)
|
|
65
|
+
return [];
|
|
66
|
+
if (Array.isArray(envelope['history']))
|
|
67
|
+
return envelope['history'];
|
|
68
|
+
if (Array.isArray(envelope['entries']))
|
|
69
|
+
return envelope['entries'];
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
function historyEntry(value, index) {
|
|
73
|
+
const entry = record(value);
|
|
74
|
+
if (!entry)
|
|
75
|
+
return null;
|
|
76
|
+
const actor = record(entry['actor']);
|
|
77
|
+
const timestamp = stringField(entry['timestamp'])
|
|
78
|
+
?? stringField(entry['createdAt'])
|
|
79
|
+
?? stringField(entry['at'])
|
|
80
|
+
?? stringField(entry['ts']);
|
|
81
|
+
const type = stringField(entry['type'])
|
|
82
|
+
?? stringField(entry['event'])
|
|
83
|
+
?? stringField(entry['operation'])
|
|
84
|
+
?? stringField(entry['kind']);
|
|
85
|
+
if (!timestamp || !type)
|
|
86
|
+
return null;
|
|
87
|
+
const rawSequence = entry['sequence'] ?? entry['seq'];
|
|
88
|
+
const sequence = typeof rawSequence === 'number' && Number.isSafeInteger(rawSequence) && rawSequence >= 0
|
|
89
|
+
? rawSequence
|
|
90
|
+
: index;
|
|
91
|
+
const status = stringField(entry['status']);
|
|
92
|
+
const stepId = stringField(entry['stepId']);
|
|
93
|
+
const executionId = stringField(entry['executionId']);
|
|
94
|
+
const gateId = stringField(entry['gateId']);
|
|
95
|
+
const attempt = typeof entry['attempt'] === 'number' && Number.isSafeInteger(entry['attempt']) && entry['attempt'] >= 0
|
|
96
|
+
? entry['attempt']
|
|
97
|
+
: null;
|
|
98
|
+
const actorId = stringField(entry['actorId']) ?? stringField(entry['actor']) ?? stringField(actor?.['id']);
|
|
99
|
+
const errorClass = stringField(entry['errorClass']);
|
|
100
|
+
return {
|
|
101
|
+
sequence,
|
|
102
|
+
timestamp,
|
|
103
|
+
type,
|
|
104
|
+
...(status ? { status } : {}),
|
|
105
|
+
...(stepId ? { stepId } : {}),
|
|
106
|
+
...(executionId ? { executionId } : {}),
|
|
107
|
+
...(gateId ? { gateId } : {}),
|
|
108
|
+
...(attempt !== null ? { attempt } : {}),
|
|
109
|
+
...(actorId ? { actorId } : {}),
|
|
110
|
+
...(errorClass ? { errorClass } : {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function readDurableHistory(store, runId, state) {
|
|
114
|
+
const candidate = store;
|
|
115
|
+
const reader = candidate.readHistory ?? candidate.listHistory ?? candidate.history;
|
|
116
|
+
if (reader)
|
|
117
|
+
return historyRows(reader.call(store, runId));
|
|
118
|
+
return historyRows(record(state)?.['history']);
|
|
119
|
+
}
|
|
120
|
+
export function createWorkflowDashboardProvider(store) {
|
|
121
|
+
const read = (runId) => {
|
|
122
|
+
try {
|
|
123
|
+
return store.read(runId);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof workflow.WorkflowStateError && error.code === 'STATE_NOT_FOUND')
|
|
127
|
+
return null;
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
listRuns: () => store.listRunIds()
|
|
133
|
+
.map((runId) => runSummary(read(runId)))
|
|
134
|
+
.filter((run) => run !== null)
|
|
135
|
+
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || a.runId.localeCompare(b.runId)),
|
|
136
|
+
getRun: (runId) => runSummary(read(runId)),
|
|
137
|
+
getHistory: (runId) => {
|
|
138
|
+
const state = read(runId);
|
|
139
|
+
if (state === null)
|
|
140
|
+
return null;
|
|
141
|
+
return readDurableHistory(store, runId, state)
|
|
142
|
+
.map(historyEntry)
|
|
143
|
+
.filter((entry) => entry !== null);
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export function createDashboardWorkflowProvider(env = process.env, defaultStateDir = workflow.defaultWorkflowStateDir) {
|
|
148
|
+
const resolvedEnv = resolveDashboardEnv(env);
|
|
149
|
+
const configuredStateDir = resolvedEnv['EVOLVER_WORKFLOW_STATE_DIR']?.trim();
|
|
150
|
+
const stateDir = configuredStateDir || defaultStateDir();
|
|
151
|
+
return createWorkflowDashboardProvider(new workflow.WorkflowStateStore(stateDir));
|
|
152
|
+
}
|
|
8
153
|
function parsePort(raw) {
|
|
9
154
|
if (!/^\d+$/.test(raw))
|
|
10
155
|
return null;
|
|
@@ -45,13 +190,16 @@ function parseDashboardOptions(argv) {
|
|
|
45
190
|
}
|
|
46
191
|
return { ok: true, options };
|
|
47
192
|
}
|
|
48
|
-
function createDashboardServer(memoryGraphStatus) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
193
|
+
export function createDashboardServer(memoryGraphStatus, env = process.env) {
|
|
194
|
+
const resolvedEnv = resolveDashboardEnv(env);
|
|
195
|
+
const eventsPath = events.rootEventsPath(resolvedEnv);
|
|
196
|
+
const tracesDir = events.tracesDir(resolvedEnv);
|
|
197
|
+
const store = new assetstore.LocalJsonlProvider(events.assetsDir(resolvedEnv));
|
|
52
198
|
const prices = loadPriceTable();
|
|
53
|
-
const personalityStore = new personality.PersonalityStore(
|
|
54
|
-
|
|
199
|
+
const personalityStore = new personality.PersonalityStore({
|
|
200
|
+
path: events.personalityStatePath(resolvedEnv),
|
|
201
|
+
});
|
|
202
|
+
const logFile = lifecyclePaths(resolvedEnv).logFile;
|
|
55
203
|
const githubPrDiagnostics = createGithubPrDiagnosticsProvider({ cwd: process.cwd() });
|
|
56
204
|
return new WebUIServer({
|
|
57
205
|
eventsPath,
|
|
@@ -61,11 +209,16 @@ function createDashboardServer(memoryGraphStatus) {
|
|
|
61
209
|
events: eventSnapshot,
|
|
62
210
|
prices,
|
|
63
211
|
}, window),
|
|
64
|
-
retentionReport: () => events.buildRetentionReport(
|
|
212
|
+
retentionReport: () => events.buildRetentionReport({
|
|
213
|
+
rootEventsPath: eventsPath,
|
|
214
|
+
materialStorePath: events.materialStorePath(resolvedEnv),
|
|
215
|
+
materialCursorPath: events.materialWatermarkPath(resolvedEnv),
|
|
216
|
+
}),
|
|
65
217
|
personalityDiagnostics: () => readPersonalityDiagnostics(() => personalityStore.load()),
|
|
66
218
|
logDiagnostics: () => readLogDiagnostics(logFile),
|
|
67
219
|
githubPrDiagnostics: () => githubPrDiagnostics.read(),
|
|
68
220
|
memoryGraphStatus,
|
|
221
|
+
workflow: createDashboardWorkflowProvider(resolvedEnv),
|
|
69
222
|
});
|
|
70
223
|
}
|
|
71
224
|
export function dashboardOpenCommand(url, platform = process.platform) {
|
|
@@ -136,15 +289,23 @@ export async function runDashboardCommand(argv, deps = {}, options = {}) {
|
|
|
136
289
|
return 0;
|
|
137
290
|
}
|
|
138
291
|
const createServer = deps.createServer ?? createDashboardServer;
|
|
139
|
-
|
|
292
|
+
let env;
|
|
293
|
+
try {
|
|
294
|
+
env = resolveDashboardEnv(deps.env ?? process.env);
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
stderr(`dashboard: ${dashboardStartupError(error)}\n`);
|
|
298
|
+
return 1;
|
|
299
|
+
}
|
|
300
|
+
const memoryGraphStatus = deps.memoryGraphStatus ?? (() => loadMemoryGraphOperatorStatus(env));
|
|
140
301
|
const openUrl = deps.openUrl ?? openDashboardUrl;
|
|
141
302
|
const waitForShutdown = deps.waitForShutdown ?? waitForShutdownSignal;
|
|
142
303
|
let server;
|
|
143
304
|
try {
|
|
144
|
-
server = createServer(memoryGraphStatus);
|
|
305
|
+
server = createServer(memoryGraphStatus, env);
|
|
145
306
|
}
|
|
146
|
-
catch {
|
|
147
|
-
stderr(
|
|
307
|
+
catch (error) {
|
|
308
|
+
stderr(`dashboard: ${dashboardStartupError(error)}\n`);
|
|
148
309
|
return 1;
|
|
149
310
|
}
|
|
150
311
|
let listening = false;
|
package/dist/dispatch.js
CHANGED
|
@@ -28,9 +28,11 @@ 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 { runIssueReportCommand } from './issueReport.js';
|
|
31
32
|
import { runAssetTrustCommand } from './assetTrust.js';
|
|
32
33
|
import { runAssetHealthCommand } from './assetHealth.js';
|
|
33
34
|
import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat } from './v1Compat.js';
|
|
35
|
+
import { runWorkflowCommand } from './workflow.js';
|
|
34
36
|
export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
|
|
35
37
|
const { runProxyCli } = await importer();
|
|
36
38
|
return runProxyCli({ argv: ['proxy', ...argv] });
|
|
@@ -71,6 +73,7 @@ export const ASYNC_COMMANDS = {
|
|
|
71
73
|
'anti-gene-benchmark': runAntiGeneBenchmarkCommand,
|
|
72
74
|
'anti-gene-rollout': runAntiGeneRolloutCommand,
|
|
73
75
|
dashboard: runDashboardCommand,
|
|
76
|
+
'issue-report': runIssueReportCommand,
|
|
74
77
|
'asset-trust': runAssetTrustCommand,
|
|
75
78
|
'asset-health': runAssetHealthCommand,
|
|
76
79
|
proxy: runProxyCommand,
|
|
@@ -78,6 +81,7 @@ export const ASYNC_COMMANDS = {
|
|
|
78
81
|
solidify: runV1SolidifyCompat,
|
|
79
82
|
fetch: runV1FetchCompat,
|
|
80
83
|
webui: runV1WebuiCompat,
|
|
84
|
+
workflow: runWorkflowCommand,
|
|
81
85
|
};
|
|
82
86
|
/** Verbs handled by the synchronous runCli core (read-only views + local ops). Kept in sync with runCli's switch
|
|
83
87
|
* — the source of truth for these stays runCli; this list completes the surface for the registry contract. */
|
|
@@ -30,7 +30,11 @@ export interface DraftAdmissionOptions {
|
|
|
30
30
|
/** Reject a draft with fewer strategy steps than this (default 1, i.e. just non-empty like intakeGene; raise it
|
|
31
31
|
* for a stricter substance floor). A real fix can be one concrete step, so the default does not over-filter. */
|
|
32
32
|
minStrategy?: number;
|
|
33
|
-
/** Reject a draft whose signal-set Jaccard similarity to ANY existing gene is >= this (default 0.
|
|
33
|
+
/** Reject a draft whose signal-set Jaccard similarity to ANY existing gene is >= this (default 0.6).
|
|
34
|
+
* Signal sets are capped at 8 tokens, so two same-size sets differing by ONE token score 7/9 ≈ 0.78 —
|
|
35
|
+
* the old 0.8 default could never fire on the dominant draft shape (#562: 118-draft flood, max pairwise
|
|
36
|
+
* similarity exactly 0.78, zero rejections). 0.6 rejects shared-core near-dupes while genuinely
|
|
37
|
+
* cross-domain drafts (less than half the tokens shared) still pass. */
|
|
34
38
|
maxSimilarity?: number;
|
|
35
39
|
}
|
|
36
40
|
export interface DraftAdmission {
|
|
@@ -147,7 +147,7 @@ export function draftGeneCandidate(turns, sigs, agent) {
|
|
|
147
147
|
export function assessDraftAdmission(candidate, existing = [], opts = {}) {
|
|
148
148
|
const minSignals = opts.minSignals ?? 2;
|
|
149
149
|
const minStrategy = opts.minStrategy ?? 1;
|
|
150
|
-
const maxSimilarity = opts.maxSimilarity ?? 0.
|
|
150
|
+
const maxSimilarity = opts.maxSimilarity ?? 0.6;
|
|
151
151
|
const sigs = [...new Set((candidate.signals_match ?? []).map((s) => String(s).toLowerCase()).filter(Boolean))];
|
|
152
152
|
const strategy = (candidate.strategy ?? []).filter((s) => String(s).trim());
|
|
153
153
|
if (sigs.length < minSignals)
|
package/dist/doctor.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// (heartbeat, proxy path) touch the proxy and are a SEPARATE, gated step — not here.
|
|
5
5
|
import { readFileSync, existsSync, statSync } from 'node:fs';
|
|
6
6
|
import { isAbsolute, join } from 'node:path';
|
|
7
|
+
import { events, issueReporter } from '@evomap/evolver-core';
|
|
7
8
|
import { expandHomePath, parseEnvFile } from '@evomap/evolver-mcp';
|
|
8
9
|
import { formatMemoryGraphOperatorStatus, loadMemoryGraphOperatorStatus } from './localMemoryGraph.js';
|
|
9
10
|
// Secrets that must live ONLY behind the EVOLVER_ENV_FILE pointer — never inlined into a runtime config (#217).
|
|
@@ -923,6 +924,21 @@ export async function runDoctor(argv, deps = {}) {
|
|
|
923
924
|
}
|
|
924
925
|
const checks = runDoctorChecks({ ...deps, profile: f.profile, ...(f.root !== undefined ? { configRoot: f.root } : {}) });
|
|
925
926
|
const failed = checks.some((c) => c.status === 'fail');
|
|
927
|
+
if (failed) {
|
|
928
|
+
try {
|
|
929
|
+
const input = issueReporter.issueReportInputFromDoctor(checks.map(({ name, status }) => ({ name, status })));
|
|
930
|
+
if (input) {
|
|
931
|
+
issueReporter.createIssueDraft(input, {
|
|
932
|
+
rootDir: join(events.evomapHome(deps.env ?? process.env), 'evolution', 'issue-reporter'),
|
|
933
|
+
workspaceScope: process.cwd(),
|
|
934
|
+
env: deps.env ?? process.env,
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
catch {
|
|
939
|
+
// Local draft reporting must never change the doctor command surface.
|
|
940
|
+
}
|
|
941
|
+
}
|
|
926
942
|
if (f.json) {
|
|
927
943
|
process.stdout.write(`${JSON.stringify({ ok: !failed, profile: f.profile, checks })}\n`);
|
|
928
944
|
}
|