@evomap/evolver-cli 2.0.0-beta.6 → 2.0.0-beta.8
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/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 +2 -0
- package/dist/distillPrimitives.d.ts +5 -1
- package/dist/distillPrimitives.js +1 -1
- package/dist/doctor.js +1 -1
- package/dist/index.js +21 -2
- package/dist/reuse.d.ts +3 -6
- package/dist/reuse.js +31 -6
- 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/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
|
@@ -32,6 +32,7 @@ import { runIssueReportCommand } from './issueReport.js';
|
|
|
32
32
|
import { runAssetTrustCommand } from './assetTrust.js';
|
|
33
33
|
import { runAssetHealthCommand } from './assetHealth.js';
|
|
34
34
|
import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat } from './v1Compat.js';
|
|
35
|
+
import { runWorkflowCommand } from './workflow.js';
|
|
35
36
|
export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
|
|
36
37
|
const { runProxyCli } = await importer();
|
|
37
38
|
return runProxyCli({ argv: ['proxy', ...argv] });
|
|
@@ -80,6 +81,7 @@ export const ASYNC_COMMANDS = {
|
|
|
80
81
|
solidify: runV1SolidifyCompat,
|
|
81
82
|
fetch: runV1FetchCompat,
|
|
82
83
|
webui: runV1WebuiCompat,
|
|
84
|
+
workflow: runWorkflowCommand,
|
|
83
85
|
};
|
|
84
86
|
/** Verbs handled by the synchronous runCli core (read-only views + local ops). Kept in sync with runCli's switch
|
|
85
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
|
@@ -930,7 +930,7 @@ export async function runDoctor(argv, deps = {}) {
|
|
|
930
930
|
if (input) {
|
|
931
931
|
issueReporter.createIssueDraft(input, {
|
|
932
932
|
rootDir: join(events.evomapHome(deps.env ?? process.env), 'evolution', 'issue-reporter'),
|
|
933
|
-
workspaceScope:
|
|
933
|
+
workspaceScope: process.cwd(),
|
|
934
934
|
env: deps.env ?? process.env,
|
|
935
935
|
});
|
|
936
936
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
|
7
7
|
import { makeInjectEmitter } from './autoexec.js';
|
|
8
8
|
import { listApprovedGenes, provenanceStoreForStore, reviewLedgerForStore } from './reviewFilter.js';
|
|
9
9
|
import { ADAPTERS, parseJsonlLines } from '@evomap/evolver-runtime-adapters';
|
|
10
|
-
import { draftGeneCandidate } from './distillPrimitives.js';
|
|
10
|
+
import { assessDraftAdmission, draftGeneCandidate } from './distillPrimitives.js';
|
|
11
11
|
import { emitSessionRecall } from './autoRecall.js';
|
|
12
12
|
import { isRuntimeSessionSourcePath, parseRuntimeSessionSourcesWithDiagnostics } from './runtimeSessionSource.js';
|
|
13
13
|
import { existsSync, readFileSync, readdirSync, statSync, unlinkSync } from 'node:fs';
|
|
@@ -79,7 +79,7 @@ export function cliUsage() {
|
|
|
79
79
|
' Memory: ingest, inject, recall, reuse, reuse-report, narrative, gene-value',
|
|
80
80
|
' Assets: asset-log, asset-trust, asset-health, material, recipe, skill',
|
|
81
81
|
' Hub: login, logout, phub, sync, publish, fetch, buy, orders, atp',
|
|
82
|
-
' Operations: status, cycles, trigger, value, retention, replay, rebuild-views',
|
|
82
|
+
' Operations: status, workflow status, cycles, trigger, value, retention, replay, rebuild-views',
|
|
83
83
|
' issue-report',
|
|
84
84
|
' Tools: dashboard, webui, trajectory-export, migrate, verify',
|
|
85
85
|
' Advanced: anti-gene-benchmark, anti-gene-rollout, reset-local-secret',
|
|
@@ -710,10 +710,24 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
710
710
|
id: typeof g['id'] === 'string' ? String(g['id']) : undefined,
|
|
711
711
|
signals_match: Array.isArray(g['signals_match']) ? g['signals_match'] : [],
|
|
712
712
|
}));
|
|
713
|
+
let candidateCount = 0;
|
|
714
|
+
let admissionSkipped = 0;
|
|
715
|
+
let lastAdmissionSkipReason = '';
|
|
713
716
|
for (const { source, sigs } of sourceSignalPairs) {
|
|
714
717
|
const candidate = draftGeneCandidate(source.turns, sigs, source.agent);
|
|
715
718
|
if (!candidate)
|
|
716
719
|
continue;
|
|
720
|
+
candidateCount += 1;
|
|
721
|
+
// Same value/novelty gate as the live distillObserver (#562): without it, a bulk ingest over session
|
|
722
|
+
// history floods the human review queue with thin / near-duplicate drafts (118 in one run). A non-admit
|
|
723
|
+
// is a deliberate skip — the rest of the batch still distills; intake below stays the structural gate.
|
|
724
|
+
const admission = assessDraftAdmission(candidate, existing);
|
|
725
|
+
if (!admission.admit) {
|
|
726
|
+
admissionSkipped += 1;
|
|
727
|
+
lastAdmissionSkipReason = admission.reason ?? '';
|
|
728
|
+
process.stdout.write(`\ningest --distill skipped [${source.label}]: ${admission.reason}\n`);
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
717
731
|
const r = algo.intakeGene(candidate, existing);
|
|
718
732
|
if (!r.ok || !r.gene) {
|
|
719
733
|
process.stderr.write(`\ningest --distill rejected: ${r.errors.join('; ')}\n`);
|
|
@@ -723,6 +737,11 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
723
737
|
existing = [...existing, { id: r.gene.id, signals_match: r.gene.signals_match }];
|
|
724
738
|
}
|
|
725
739
|
if (accepted.length === 0) {
|
|
740
|
+
if (candidateCount > 0 && admissionSkipped === candidateCount) {
|
|
741
|
+
const reason = lastAdmissionSkipReason ? ` Last skip reason: ${lastAdmissionSkipReason}.` : '';
|
|
742
|
+
process.stdout.write(`\ningest: all ${candidateCount} draft candidate(s) skipped by admission gate.${reason} Nothing stored.\n`);
|
|
743
|
+
return 0;
|
|
744
|
+
}
|
|
726
745
|
process.stdout.write('\ningest: not enough to distill — need ≥1 strong signal and ≥1 substantive assistant step. Nothing stored.\n');
|
|
727
746
|
return 0;
|
|
728
747
|
}
|
package/dist/reuse.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assetstore, hub as hubNs } from '@evomap/evolver-core';
|
|
2
|
-
import type { ConnectPublicOptions, PublicHubCapability } from '@evomap/evolver-adapter-public';
|
|
2
|
+
import type { ConnectPublicOptions, PublicHelloOptions, PublicHubCapability } from '@evomap/evolver-adapter-public';
|
|
3
3
|
declare const REUSE_CONTRACT = "reuse.v1";
|
|
4
|
-
export type ReuseStatus = 'ok' | 'dry_run' | 'invalid_arg' | 'missing_id' | 'unsupported' | 'not_found' | 'unauthorized' | 'unavailable' | 'network' | 'rate_limited' | 'internal_error';
|
|
4
|
+
export type ReuseStatus = 'ok' | 'dry_run' | 'invalid_arg' | 'missing_id' | 'unsupported' | 'not_found' | 'unauthorized' | 'unavailable' | 'network' | 'rate_limited' | 'integrity_failed' | 'internal_error';
|
|
5
5
|
/** The stable reuse.v1 machine contract printed to stdout on success AND failure. Field set is locked by the
|
|
6
6
|
* consumer (evox-desktop `evolverReuseEnvelope`, #1008): { ok, contract, status, reason, message }. */
|
|
7
7
|
export interface ReuseEnvelope {
|
|
@@ -15,10 +15,7 @@ export interface ReuseEnvelope {
|
|
|
15
15
|
* (PublicHubCapability satisfies both; a bare fetcher in tests may omit hello). */
|
|
16
16
|
type AssetByIdFetcher = {
|
|
17
17
|
fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
|
|
18
|
-
hello?(opts:
|
|
19
|
-
rotate: boolean;
|
|
20
|
-
evolverVersion?: string;
|
|
21
|
-
}): Promise<unknown>;
|
|
18
|
+
hello?(opts: PublicHelloOptions): Promise<unknown>;
|
|
22
19
|
};
|
|
23
20
|
export interface ReuseCliDeps {
|
|
24
21
|
store?: assetstore.AssetStoreProvider;
|