@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.22

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.
Files changed (124) hide show
  1. package/dist/antiGeneBenchmark.js +2 -0
  2. package/dist/antiGeneRollout.js +9 -3
  3. package/dist/assetHealth.d.ts +6 -0
  4. package/dist/assetHealth.js +107 -0
  5. package/dist/assetRepair.d.ts +24 -0
  6. package/dist/assetRepair.js +172 -0
  7. package/dist/assetSidecarRecovery.d.ts +14 -0
  8. package/dist/assetSidecarRecovery.js +171 -0
  9. package/dist/assetTrust.d.ts +24 -0
  10. package/dist/assetTrust.js +231 -0
  11. package/dist/atp.d.ts +10 -5
  12. package/dist/atp.js +119 -26
  13. package/dist/atpAutoBuyer.d.ts +120 -0
  14. package/dist/atpAutoBuyer.js +814 -0
  15. package/dist/atpAutoDeliver.js +2 -2
  16. package/dist/autoDistillAntiGene.js +7 -5
  17. package/dist/autoDistillLlm.d.ts +26 -0
  18. package/dist/autoDistillLlm.js +119 -22
  19. package/dist/autoDistillTranscript.js +3 -2
  20. package/dist/autoexec.d.ts +111 -24
  21. package/dist/autoexec.js +887 -120
  22. package/dist/autoexecConfig.d.ts +10 -0
  23. package/dist/autoexecConfig.js +69 -0
  24. package/dist/cli.js +13 -0
  25. package/dist/cliContracts.d.ts +33 -2
  26. package/dist/cliContracts.js +818 -78
  27. package/dist/commandCatalog.d.ts +72 -0
  28. package/dist/commandCatalog.js +120 -0
  29. package/dist/commands.d.ts +1 -0
  30. package/dist/commands.js +1 -0
  31. package/dist/curriculumCapabilityGaps.d.ts +6 -0
  32. package/dist/curriculumCapabilityGaps.js +24 -0
  33. package/dist/cycleConsumer.d.ts +17 -2
  34. package/dist/cycleConsumer.js +374 -50
  35. package/dist/dashboard.d.ts +13 -1
  36. package/dist/dashboard.js +235 -18
  37. package/dist/dispatch.d.ts +9 -2
  38. package/dist/dispatch.js +29 -6
  39. package/dist/distillAdmission.d.ts +13 -0
  40. package/dist/distillAdmission.js +35 -0
  41. package/dist/distillObserver.js +27 -12
  42. package/dist/distillPrimitives.d.ts +11 -8
  43. package/dist/distillPrimitives.js +116 -22
  44. package/dist/doctor.d.ts +13 -0
  45. package/dist/doctor.js +177 -10
  46. package/dist/identityHome.d.ts +9 -0
  47. package/dist/identityHome.js +47 -0
  48. package/dist/index.d.ts +73 -40
  49. package/dist/index.js +745 -207
  50. package/dist/issueReport.d.ts +7 -0
  51. package/dist/issueReport.js +291 -0
  52. package/dist/learningTrace.d.ts +15 -0
  53. package/dist/learningTrace.js +73 -0
  54. package/dist/lifecycle.d.ts +199 -2
  55. package/dist/lifecycle.js +4999 -152
  56. package/dist/lifecycleBootstrapTransaction.d.ts +235 -0
  57. package/dist/lifecycleBootstrapTransaction.js +2182 -0
  58. package/dist/localMemoryGraph.d.ts +184 -0
  59. package/dist/localMemoryGraph.js +2689 -0
  60. package/dist/login.d.ts +1 -1
  61. package/dist/login.js +3 -3
  62. package/dist/materialPackage.js +3 -6
  63. package/dist/materialSnapshot.d.ts +35 -1
  64. package/dist/materialSnapshot.js +265 -18
  65. package/dist/memoryGraphOps.d.ts +8 -0
  66. package/dist/memoryGraphOps.js +140 -0
  67. package/dist/migrate/assetFormatMap.d.ts +61 -0
  68. package/dist/migrate/assetFormatMap.js +53 -0
  69. package/dist/migrate/envTranslate.d.ts +26 -0
  70. package/dist/migrate/envTranslate.js +147 -0
  71. package/dist/migrate/fieldMap.d.ts +7 -5
  72. package/dist/migrate/fieldMap.js +20 -14
  73. package/dist/migrate/oauthImport.d.ts +66 -0
  74. package/dist/migrate/oauthImport.js +667 -0
  75. package/dist/migrate/v1Import.d.ts +98 -1
  76. package/dist/migrate/v1Import.js +1532 -71
  77. package/dist/modelCompatibility.d.ts +10 -0
  78. package/dist/modelCompatibility.js +296 -0
  79. package/dist/promptRecallHook.d.ts +24 -0
  80. package/dist/promptRecallHook.js +425 -0
  81. package/dist/recallVerifyReport.d.ts +37 -0
  82. package/dist/recallVerifyReport.js +244 -0
  83. package/dist/recipe.d.ts +14 -2
  84. package/dist/recipe.js +543 -65
  85. package/dist/repairedAssetStore.d.ts +2 -0
  86. package/dist/repairedAssetStore.js +12 -0
  87. package/dist/requiredSandboxValidation.d.ts +5 -0
  88. package/dist/requiredSandboxValidation.js +4 -0
  89. package/dist/reuse.d.ts +18 -4
  90. package/dist/reuse.js +375 -107
  91. package/dist/reviewFilter.d.ts +3 -1
  92. package/dist/reviewFilter.js +3 -1
  93. package/dist/runtimeCapabilities.d.ts +18 -0
  94. package/dist/runtimeCapabilities.js +81 -0
  95. package/dist/runtimeSessionSource.d.ts +8 -2
  96. package/dist/runtimeSessionSource.js +63 -11
  97. package/dist/selectionPolicyConfig.d.ts +8 -0
  98. package/dist/selectionPolicyConfig.js +18 -0
  99. package/dist/semanticIdfConfig.d.ts +2 -0
  100. package/dist/semanticIdfConfig.js +4 -0
  101. package/dist/sessionIngest.d.ts +43 -0
  102. package/dist/sessionIngest.js +180 -0
  103. package/dist/setupHooks.d.ts +5 -0
  104. package/dist/setupHooks.js +330 -14
  105. package/dist/skill2gep.d.ts +13 -9
  106. package/dist/skill2gep.js +99 -36
  107. package/dist/skillDistill.d.ts +8 -4
  108. package/dist/skillDistill.js +39 -9
  109. package/dist/solo/mode.js +1 -0
  110. package/dist/sync.d.ts +13 -1
  111. package/dist/sync.js +1947 -265
  112. package/dist/thesis.d.ts +1 -1
  113. package/dist/thesis.js +20 -3
  114. package/dist/trajectoryExport.js +21 -3
  115. package/dist/v1Compat.d.ts +1 -0
  116. package/dist/v1Compat.js +9 -0
  117. package/dist/valueDigest.js +8 -1
  118. package/dist/windowsLegacyTaskCleanup.d.ts +228 -0
  119. package/dist/windowsLegacyTaskCleanup.js +1475 -0
  120. package/dist/workflow.d.ts +39 -0
  121. package/dist/workflow.js +386 -0
  122. package/dist/workflowRuntime.d.ts +66 -0
  123. package/dist/workflowRuntime.js +638 -0
  124. package/package.json +14 -7
@@ -1,16 +1,24 @@
1
1
  import { accessSync, constants, lstatSync, mkdirSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
2
3
  import { basename, dirname, join, resolve } from 'node:path';
3
4
  import { assetstore, algo, events, exec, material as materialNs, personality, schema, signals, util, verify } from '@evomap/evolver-core';
4
- import { materialHasRuntimeSessionSnapshot, materialSourceAvailable, runtimeSessionSourcesForMaterial } from './materialSnapshot.js';
5
+ import { MATERIAL_RUNTIME_SESSION_SNAPSHOT_SCHEMA, materialHasRuntimeSessionSnapshot, materialSourceAvailable, runtimeSessionEvidenceSummariesFromMaterialPayload, runtimeSessionSourcesForMaterial, runtimeSessionSourcesForMaterialDetails, } from './materialSnapshot.js';
6
+ import { runRequiredSandboxedValidation } from './requiredSandboxValidation.js';
5
7
  import { signalTokens } from './distillPrimitives.js';
6
8
  import { readEvents, showCycle } from './commands.js';
9
+ import { RUNTIME_CAPABILITY_MATRIX, runtimeCapabilities } from './runtimeCapabilities.js';
10
+ import { parseRuntimeSessionSources } from './runtimeSessionSource.js';
11
+ import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
12
+ import { makeCurriculumCapabilityGapsProvider } from './curriculumCapabilityGaps.js';
13
+ import { semanticIdfEnabled } from './semanticIdfConfig.js';
14
+ import { selectionFloorFromEnv, selectionGuardFromEnv, selectionPolicyFromEnv, } from './selectionPolicyConfig.js';
7
15
  const CYCLE_GROUP = 'cycle';
8
16
  const DEFAULT_LIMIT = 5;
9
17
  const DEFAULT_WATCH_IDLE_MS = 1000;
10
18
  const DEFAULT_WATCH_MAX_IDLE_MS = 30_000;
11
19
  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';
20
+ 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> [--resume] [--idle-ms N] [--max-idle N] [--state-file <path>] [--validation-cmd <cmd>] [--timeout-ms N] [--json] | evolver cycle --repo <path> [--resume] [--limit N] [--target <path>] [--expected-effect <text>] [--runner claude|codex|gemini] [--validation-cmd <cmd>] [--timeout-ms N]\n';
21
+ const WATCH_USAGE = 'usage: evolver cycle watch --repo <path> [--resume] [--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|gemini] [--validation-cmd <cmd>] [--timeout-ms N] [--json]\n';
14
22
  class CycleWatchStateWriteError extends Error {
15
23
  constructor() {
16
24
  super('cycle watch state file write failed');
@@ -34,6 +42,22 @@ function parseFlags(argv) {
34
42
  }
35
43
  return out;
36
44
  }
45
+ function parseSwitchFlag(argv, name) {
46
+ const flag = `--${name}`;
47
+ let present = false;
48
+ for (let i = 0; i < argv.length; i++) {
49
+ const arg = argv[i];
50
+ if (arg?.startsWith(`${flag}=`))
51
+ return null;
52
+ if (arg !== flag)
53
+ continue;
54
+ const next = argv[i + 1];
55
+ if (next !== undefined && !next.startsWith('--'))
56
+ return null;
57
+ present = true;
58
+ }
59
+ return present;
60
+ }
37
61
  function parseRepeatedFlag(argv, name) {
38
62
  const values = [];
39
63
  const flag = `--${name}`;
@@ -60,18 +84,13 @@ function parseRepeatedFlag(argv, name) {
60
84
  function makeCycleValidationHook(validationCmds, fallback, runSandboxedValidation = verify.runSandboxedValidation) {
61
85
  if (validationCmds.length === 0)
62
86
  return fallback;
63
- let warnedNoIsolation = false;
64
87
  return (task) => {
65
88
  const fallbackHook = fallback?.(task);
66
- return async (mutation, decision, cwd) => {
67
- const fallbackResult = fallbackHook ? await fallbackHook(mutation, decision, cwd) : null;
89
+ return async (mutation, decision, cwd, signal) => {
90
+ const fallbackResult = fallbackHook ? await fallbackHook(mutation, decision, cwd, signal) : null;
68
91
  if (fallbackResult && !fallbackResult.passed)
69
92
  return fallbackResult;
70
- const result = await runSandboxedValidation(task.validationCmds ?? validationCmds, cwd);
71
- if (!result.isolated && !warnedNoIsolation) {
72
- warnedNoIsolation = true;
73
- process.stdout.write(' warning: validation runs WITHOUT network/FS isolation on this platform; non-namespace hardening still applies.\n');
74
- }
93
+ const result = await runRequiredSandboxedValidation(task.validationCmds ?? validationCmds, cwd, { signal }, runSandboxedValidation);
75
94
  return { passed: result.passed, score: result.score };
76
95
  };
77
96
  };
@@ -92,7 +111,60 @@ function parseRequiredPositiveIntFlag(flags, name) {
92
111
  return Number.isInteger(n) && n > 0 ? n : null;
93
112
  }
94
113
  function parseRunner(value) {
95
- return value === 'codex' || value === 'cursor' ? value : 'claude';
114
+ if (value === undefined || value === 'claude')
115
+ return { ok: true, runner: 'claude' };
116
+ if (value.trim() === '')
117
+ return { ok: false, error: 'runner value is required (supported: claude, codex, gemini)' };
118
+ if (value === 'codex' || value === 'gemini')
119
+ return { ok: true, runner: value };
120
+ if (value === 'cursor' || value === 'antigravity' || value === 'kimi' || value === 'kiro' || value === 'opencode') {
121
+ const capability = RUNTIME_CAPABILITY_MATRIX[value].execute;
122
+ return { ok: false, error: `runner '${value}' execute capability is ${capability.status}: ${capability.evidence}` };
123
+ }
124
+ return { ok: false, error: `unknown runner '${value}' (supported: claude, codex, gemini)` };
125
+ }
126
+ function resolveMaterialRunner(material, requestedRunner) {
127
+ const sourceAgent = material.sourceAgent;
128
+ let runner;
129
+ switch (sourceAgent) {
130
+ case 'claude-code':
131
+ runner = 'claude';
132
+ break;
133
+ case 'codex':
134
+ case 'gemini':
135
+ runner = sourceAgent;
136
+ break;
137
+ case 'cursor':
138
+ case 'antigravity':
139
+ case 'kimi': {
140
+ const capability = RUNTIME_CAPABILITY_MATRIX[sourceAgent].execute;
141
+ return {
142
+ ok: false,
143
+ error: `sourceAgent '${sourceAgent}' execute capability is ${capability.status}: ${capability.evidence}`,
144
+ };
145
+ }
146
+ case 'kiro':
147
+ case 'opencode':
148
+ case 'generic-chat':
149
+ return { ok: false, error: `sourceAgent '${sourceAgent}' has no supported cycle runner` };
150
+ default:
151
+ return { ok: false, error: 'runtime_session material has no supported sourceAgent' };
152
+ }
153
+ if (requestedRunner !== undefined && requestedRunner !== runner) {
154
+ return {
155
+ ok: false,
156
+ error: `explicit runner '${requestedRunner}' does not match sourceAgent '${sourceAgent}' runner '${runner}'`,
157
+ };
158
+ }
159
+ return { ok: true, runner };
160
+ }
161
+ function printRuntimeCapabilities() {
162
+ for (const entry of runtimeCapabilities()) {
163
+ const values = ['ingest', 'inject', 'execute', 'verify', 'resume']
164
+ .map((capability) => `${capability}=${entry[capability].status}`)
165
+ .join(' ');
166
+ process.stdout.write(`${entry.runtime}: ${values}\n`);
167
+ }
96
168
  }
97
169
  function resolveMaterialCycleDeps(deps = {}) {
98
170
  const materialStore = deps.materialStore ?? new materialNs.MaterialStore({ path: events.materialStorePath() });
@@ -106,14 +178,36 @@ function resolveMaterialCycleDeps(deps = {}) {
106
178
  const review = deps.review ?? new assetstore.ReviewLedger(assetDir);
107
179
  const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
108
180
  const personalityStore = deps.personality ?? new personality.PersonalityStore();
181
+ const memoryGraphDir = join(events.evomapHome(), 'evolution');
182
+ const memoryGraph = deps.memoryGraph ?? new LocalMemoryGraph({
183
+ dir: memoryGraphDir,
184
+ ...resolveLocalMemoryUserIdentity(memoryGraphDir),
185
+ });
109
186
  const engine = deps.engine ?? new algo.CycleEngine({
110
187
  ingestor,
111
188
  selection: algo.makeGeneSelectionPoint(),
112
189
  store,
113
190
  now: () => Date.now(),
114
191
  personality: personalityStore,
192
+ capabilityGaps: makeCurriculumCapabilityGapsProvider(),
115
193
  });
116
- return { materialStore, consumer, store, provenance, review, ingestor, engine, personality: personalityStore };
194
+ const selectionFloor = deps.selectionFloor ?? selectionFloorFromEnv();
195
+ return {
196
+ materialStore,
197
+ consumer,
198
+ store,
199
+ provenance,
200
+ review,
201
+ ingestor,
202
+ engine,
203
+ personality: personalityStore,
204
+ memoryGraph,
205
+ nativeSessionHome: deps.nativeSessionHome ?? homedir(),
206
+ disableSemanticIdf: deps.disableSemanticIdf ?? !semanticIdfEnabled(),
207
+ selectionPolicy: deps.selectionPolicy ?? selectionPolicyFromEnv(),
208
+ selectionGuard: deps.selectionGuard ?? selectionGuardFromEnv(),
209
+ ...(selectionFloor !== undefined ? { selectionFloor } : {}),
210
+ };
117
211
  }
118
212
  export function cycleIdForMaterial(materialId) {
119
213
  return `autoexec-material-${materialId}`;
@@ -213,8 +307,7 @@ function fallbackSignalTokens(sigs) {
213
307
  }
214
308
  return [...out];
215
309
  }
216
- function materialSignals(material) {
217
- const sources = runtimeSessionSourcesForMaterial(material);
310
+ function materialSignals(sources) {
218
311
  const sigs = sources.flatMap((source) => signals.extractSignals(source.turns));
219
312
  const tokens = signalTokens(sigs);
220
313
  return {
@@ -222,6 +315,82 @@ function materialSignals(material) {
222
315
  sourceCount: sources.length,
223
316
  };
224
317
  }
318
+ function resolveMaterialResume(material, runner, sources, liveSources) {
319
+ if (material.sourceAgent !== 'claude-code' && material.sourceAgent !== 'cursor') {
320
+ const capability = material.sourceAgent
321
+ ? RUNTIME_CAPABILITY_MATRIX[material.sourceAgent].resume
322
+ : undefined;
323
+ return {
324
+ ok: false,
325
+ error: capability
326
+ ? `sourceAgent '${material.sourceAgent}' resume capability is ${capability.status}: ${capability.evidence}`
327
+ : 'runtime_session material has no resumable sourceAgent',
328
+ };
329
+ }
330
+ const expectedRunner = material.sourceAgent === 'cursor' ? 'cursor' : 'claude';
331
+ if (runner !== expectedRunner) {
332
+ return { ok: false, error: `resume identity harness does not match runner '${runner}'` };
333
+ }
334
+ if (material.sourceAgent === 'cursor' && basename(material.sourcePath).toLowerCase() === 'state.vscdb') {
335
+ return { ok: false, error: 'Cursor state.vscdb composer identity is ingest-only and cannot be resumed' };
336
+ }
337
+ const hasSnapshotSchema = typeof material.payload === 'object'
338
+ && material.payload !== null
339
+ && material.payload['schema'] === MATERIAL_RUNTIME_SESSION_SNAPSHOT_SCHEMA;
340
+ const snapshot = runtimeSessionEvidenceSummariesFromMaterialPayload(material.payload);
341
+ if (hasSnapshotSchema && !snapshot) {
342
+ return { ok: false, error: 'resume identity snapshot metadata is invalid' };
343
+ }
344
+ if (snapshot && (snapshot.sourceCount !== 1 || snapshot.omittedSourceCount !== 0)) {
345
+ return {
346
+ ok: false,
347
+ error: `resume identity is ambiguous for sourceAgent '${material.sourceAgent}': snapshot reports ${snapshot.sourceCount} sessions (${snapshot.omittedSourceCount} omitted)`,
348
+ };
349
+ }
350
+ const snapshotSource = snapshot?.summaries[0];
351
+ if (snapshot && snapshotSource?.agent !== material.sourceAgent) {
352
+ return { ok: false, error: `resume identity harness does not match sourceAgent '${material.sourceAgent}' in snapshot` };
353
+ }
354
+ const snapshotSessionId = snapshotSource?.sessionId?.trim();
355
+ if (snapshot && !snapshotSessionId) {
356
+ return { ok: false, error: `resume identity missing from snapshot for sourceAgent '${material.sourceAgent}'` };
357
+ }
358
+ if (!liveSources && snapshotSource?.resumeIdentityProvenance !== 'canonical_native_transcript') {
359
+ return {
360
+ ok: false,
361
+ error: `resume identity snapshot lacks verified native transcript provenance for sourceAgent '${material.sourceAgent}'`,
362
+ };
363
+ }
364
+ // Signals may safely fall back to the durable snapshot, but resume identity must retain live provenance.
365
+ // Otherwise an existing transcript with a new path-bound identity and no parseable turns can be filtered out,
366
+ // making the stale snapshot identity appear to match itself and resuming the wrong native session.
367
+ const identitySources = liveSources ?? sources;
368
+ if (identitySources.length === 0) {
369
+ return { ok: false, error: `resume identity missing for sourceAgent '${material.sourceAgent}'` };
370
+ }
371
+ if (identitySources.some((source) => source.agent !== material.sourceAgent)) {
372
+ return { ok: false, error: `resume identity harness does not match sourceAgent '${material.sourceAgent}'` };
373
+ }
374
+ if (identitySources.length !== 1) {
375
+ return { ok: false, error: `resume identity is ambiguous for sourceAgent '${material.sourceAgent}': expected one session, found ${identitySources.length}` };
376
+ }
377
+ const sessionId = identitySources[0].sessionId?.trim();
378
+ if (!sessionId) {
379
+ return { ok: false, error: `resume identity missing for sourceAgent '${material.sourceAgent}'` };
380
+ }
381
+ if (snapshotSessionId && sessionId !== snapshotSessionId) {
382
+ return { ok: false, error: `resume identity does not match snapshot for sourceAgent '${material.sourceAgent}'` };
383
+ }
384
+ const resume = { runner, sessionId };
385
+ try {
386
+ exec.validateAgentSessionResume(resume, runner);
387
+ }
388
+ catch (error) {
389
+ const code = error instanceof exec.AgentSessionResumeError ? error.code : 'invalid_session_id';
390
+ return { ok: false, error: `resume identity is invalid for sourceAgent '${material.sourceAgent}' (${code})` };
391
+ }
392
+ return { ok: true, resume };
393
+ }
225
394
  async function emitConsumed(ingestor, material, item, extra = {}) {
226
395
  await ingestor.ingest({
227
396
  type: 'cycle.consumed',
@@ -288,9 +457,31 @@ async function processMaterial(material, opts, deps) {
288
457
  ackOne(deps.consumer, material);
289
458
  return item;
290
459
  }
291
- let extracted;
460
+ const runner = resolveMaterialRunner(material, opts.runner);
461
+ if (!runner.ok) {
462
+ const item = {
463
+ materialId: material.materialId,
464
+ action: 'fail',
465
+ status: 'refused',
466
+ cycleId,
467
+ reason: runner.error,
468
+ };
469
+ await emitConsumed(deps.ingestor, material, item);
470
+ ackOne(deps.consumer, material);
471
+ return item;
472
+ }
473
+ let sources;
474
+ let liveResumeSources;
292
475
  try {
293
- extracted = materialSignals(material);
476
+ const resolvedSources = runtimeSessionSourcesForMaterialDetails(material, undefined, deps.nativeSessionHome);
477
+ const sourceAvailable = materialSourceAvailable(material);
478
+ if (opts.resume && sourceAvailable && resolvedSources.sourceError) {
479
+ throw resolvedSources.sourceError;
480
+ }
481
+ sources = resolvedSources.sources;
482
+ // A successful read is authoritative even if the source disappears before the availability check.
483
+ // Discarding captured provenance here could resume a stale snapshot identity.
484
+ liveResumeSources = opts.resume ? resolvedSources.liveSources : undefined;
294
485
  }
295
486
  catch (error) {
296
487
  const reason = error instanceof Error ? error.message : String(error);
@@ -299,6 +490,22 @@ async function processMaterial(material, opts, deps) {
299
490
  ackOne(deps.consumer, material);
300
491
  return item;
301
492
  }
493
+ const resume = opts.resume
494
+ ? resolveMaterialResume(material, runner.runner, sources, liveResumeSources)
495
+ : undefined;
496
+ if (resume && !resume.ok) {
497
+ const item = {
498
+ materialId: material.materialId,
499
+ action: 'fail',
500
+ status: 'refused',
501
+ cycleId,
502
+ reason: resume.error,
503
+ };
504
+ await emitConsumed(deps.ingestor, material, item);
505
+ ackOne(deps.consumer, material);
506
+ return item;
507
+ }
508
+ const extracted = materialSignals(sources);
302
509
  if (extracted.sourceCount === 0 || extracted.signals.length === 0) {
303
510
  const reason = extracted.sourceCount === 0 ? 'no parseable runtime session source' : 'no cycle-worthy session signals';
304
511
  const item = { materialId: material.materialId, action: 'fail', status: 'no_signals', cycleId, reason };
@@ -306,6 +513,19 @@ async function processMaterial(material, opts, deps) {
306
513
  ackOne(deps.consumer, material);
307
514
  return item;
308
515
  }
516
+ if ((runner.runner === 'claude' || runner.runner === 'codex') && !opts.agent) {
517
+ const runnerName = runner.runner === 'claude' ? 'Claude' : 'Codex';
518
+ const item = {
519
+ materialId: material.materialId,
520
+ action: 'fail',
521
+ status: 'refused',
522
+ cycleId,
523
+ reason: `execute capability is unsupported: built-in ${runnerName} requires a verified host filesystem sandbox`,
524
+ };
525
+ await emitConsumed(deps.ingestor, material, item);
526
+ ackOne(deps.consumer, material);
527
+ return item;
528
+ }
309
529
  const repo = resolve(opts.repo);
310
530
  const task = {
311
531
  id: `material-${material.materialId}`,
@@ -317,9 +537,11 @@ async function processMaterial(material, opts, deps) {
317
537
  };
318
538
  const safety = {
319
539
  allowedRoots: [repo],
320
- runner: opts.runner ?? 'claude',
321
540
  ...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
322
541
  ...opts.safety,
542
+ runner: runner.runner,
543
+ ...(resume?.ok ? { resume: resume.resume } : {}),
544
+ ...(opts.signal ? { signal: opts.signal } : {}),
323
545
  };
324
546
  const verdict = await exec.runAutoExecTask({
325
547
  engine: deps.engine,
@@ -327,6 +549,11 @@ async function processMaterial(material, opts, deps) {
327
549
  provenance: deps.provenance,
328
550
  review: deps.review,
329
551
  personality: deps.personality,
552
+ memoryGraph: deps.memoryGraph,
553
+ ...(deps.disableSemanticIdf ? { disableSemanticIdf: true } : {}),
554
+ ...(deps.selectionPolicy !== 'engine-health' ? { selectionPolicy: deps.selectionPolicy } : {}),
555
+ selectionGuard: deps.selectionGuard,
556
+ ...(deps.selectionFloor !== undefined ? { selectionFloor: deps.selectionFloor } : {}),
330
557
  ...(opts.validate ? { validate: opts.validate } : {}),
331
558
  ...(opts.agent ? { agent: opts.agent } : {}),
332
559
  ...(opts.git ? { git: opts.git } : {}),
@@ -342,6 +569,8 @@ async function processMaterial(material, opts, deps) {
342
569
  finalStage: verdict.finalStage,
343
570
  signalCount: extracted.signals.length,
344
571
  signals: extracted.signals,
572
+ runner: runner.runner,
573
+ ...(resume?.ok && verdict.status === 'solidified' ? { resumedSession: true } : {}),
345
574
  });
346
575
  ackOne(deps.consumer, material);
347
576
  return item;
@@ -356,12 +585,35 @@ export async function runMaterialCycleConsumer(opts, injectedDeps = {}) {
356
585
  const claimed = deps.consumer.claim(CYCLE_GROUP, limit);
357
586
  const items = [];
358
587
  for (const material of claimed) {
588
+ if (opts.signal?.aborted)
589
+ break;
359
590
  items.push(await processMaterial(material, opts, deps));
360
591
  }
361
592
  return { claimed: claimed.length, processed: items.length, items };
362
593
  }
363
- function defaultSleep(ms) {
364
- return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
594
+ function defaultSleep(ms, signal) {
595
+ return new Promise((resolveSleep) => {
596
+ if (signal?.aborted) {
597
+ resolveSleep();
598
+ return;
599
+ }
600
+ const timer = setTimeout(finish, ms);
601
+ function finish() {
602
+ clearTimeout(timer);
603
+ signal?.removeEventListener('abort', finish);
604
+ resolveSleep();
605
+ }
606
+ signal?.addEventListener('abort', finish, { once: true });
607
+ });
608
+ }
609
+ function watchResult(deps, stopped, counters) {
610
+ return {
611
+ ok: true,
612
+ group: 'cycle.watch',
613
+ ...counters,
614
+ cursor: deps.consumer.position(CYCLE_GROUP),
615
+ stopped,
616
+ };
365
617
  }
366
618
  function positiveNumber(value, fallback) {
367
619
  return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
@@ -392,6 +644,15 @@ export async function runMaterialCycleWatch(opts, injectedDeps = {}, hooks = {})
392
644
  let totalProcessed = 0;
393
645
  let totalFailedItems = 0;
394
646
  for (;;) {
647
+ if (opts.signal?.aborted) {
648
+ return watchResult(deps, 'cancelled', {
649
+ iterations,
650
+ claimed: totalClaimed,
651
+ processed: totalProcessed,
652
+ idleIterations,
653
+ failedItems: totalFailedItems,
654
+ });
655
+ }
395
656
  iterations += 1;
396
657
  const cursorBefore = deps.consumer.position(CYCLE_GROUP);
397
658
  const result = await runMaterialCycleConsumer(opts, deps);
@@ -419,30 +680,47 @@ export async function runMaterialCycleWatch(opts, injectedDeps = {}, hooks = {})
419
680
  idleIterations = 0;
420
681
  nextDelayMs = idleBase;
421
682
  }
422
- const stopped = maxIterations !== undefined && iterations >= maxIterations
423
- ? 'max_iterations'
424
- : maxIdle !== undefined && idleIterations >= maxIdle
425
- ? 'max_idle'
426
- : null;
683
+ const stopped = opts.signal?.aborted
684
+ ? 'cancelled'
685
+ : maxIterations !== undefined && iterations >= maxIterations
686
+ ? 'max_iterations'
687
+ : maxIdle !== undefined && idleIterations >= maxIdle
688
+ ? 'max_idle'
689
+ : null;
427
690
  if (stopped) {
428
- return {
429
- ok: true,
430
- group: 'cycle.watch',
691
+ return watchResult(deps, stopped, {
431
692
  iterations,
432
693
  claimed: totalClaimed,
433
694
  processed: totalProcessed,
434
695
  idleIterations,
435
696
  failedItems: totalFailedItems,
436
- cursor: deps.consumer.position(CYCLE_GROUP),
437
- stopped,
438
- };
697
+ });
439
698
  }
440
699
  if (idle) {
441
- await sleep(nextDelayMs);
700
+ await sleep(nextDelayMs, opts.signal);
442
701
  nextDelayMs = Math.min(idleMax, Math.max(idleBase, Math.ceil(nextDelayMs * backoff)));
443
702
  }
444
703
  }
445
704
  }
705
+ function createProcessCancellation() {
706
+ const controller = new AbortController();
707
+ let code = 1;
708
+ const interrupt = () => { code = 130; controller.abort(); };
709
+ const terminate = () => { code = 143; controller.abort(); };
710
+ process.once('SIGINT', interrupt);
711
+ process.once('SIGTERM', terminate);
712
+ return {
713
+ signal: controller.signal,
714
+ exitCode: () => code,
715
+ dispose: () => {
716
+ process.removeListener('SIGINT', interrupt);
717
+ process.removeListener('SIGTERM', terminate);
718
+ },
719
+ };
720
+ }
721
+ function combineSignals(primary, secondary) {
722
+ return secondary ? AbortSignal.any([primary, secondary]) : primary;
723
+ }
446
724
  async function recoverMaterialCycleAudit(material, deps) {
447
725
  const cycleId = cycleIdForMaterial(material.materialId);
448
726
  const lockPath = cycleLockPathForMaterial(deps.materialStore.path, material.materialId);
@@ -701,6 +979,14 @@ function materialCycleExitCode(result) {
701
979
  return result.items.some(hasFailedItem) ? 1 : 0;
702
980
  }
703
981
  export async function runCycleCommand(argv, injectedDeps = {}) {
982
+ if (argv[0] === 'capabilities') {
983
+ const flags = parseFlags(argv.slice(1));
984
+ if ('json' in flags)
985
+ process.stdout.write(`${JSON.stringify(runtimeCapabilities())}\n`);
986
+ else
987
+ printRuntimeCapabilities();
988
+ return 0;
989
+ }
704
990
  if (argv[0] === 'show') {
705
991
  if (!argv[1]) {
706
992
  process.stderr.write('usage: evolver cycle show <id>\n');
@@ -731,7 +1017,18 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
731
1017
  return 0;
732
1018
  }
733
1019
  if (argv[0] === 'watch') {
734
- const flags = parseFlags(argv.slice(1));
1020
+ const watchArgv = argv.slice(1);
1021
+ const flags = parseFlags(watchArgv);
1022
+ const resume = parseSwitchFlag(watchArgv, 'resume');
1023
+ if (resume === null) {
1024
+ process.stderr.write(WATCH_USAGE);
1025
+ return 1;
1026
+ }
1027
+ const runner = parseRunner(flags['runner']);
1028
+ if (!runner.ok) {
1029
+ process.stderr.write(`${runner.error}\n`);
1030
+ return 1;
1031
+ }
735
1032
  const validationCmds = parseRepeatedFlag(argv.slice(1), 'validation-cmd');
736
1033
  const repo = flags['repo'];
737
1034
  if (!repo) {
@@ -762,18 +1059,22 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
762
1059
  let stateFailedItems = 0;
763
1060
  let lastIteration;
764
1061
  const writeState = injectedDeps.watchStateWriter ?? writeWatchStateFile;
1062
+ const cancellation = createProcessCancellation();
1063
+ const signal = combineSignals(cancellation.signal, injectedDeps.safety?.signal);
765
1064
  let result;
766
1065
  try {
767
1066
  result = await runMaterialCycleWatch({
768
1067
  repo,
1068
+ ...(resume ? { resume: true } : {}),
769
1069
  limit: parsePositiveInt(flags['limit'], DEFAULT_LIMIT),
770
1070
  target: flags['target'] || '.',
771
1071
  expectedEffect: flags['expected-effect'] || 'evolve from consumed session material',
772
- runner: parseRunner(flags['runner']),
1072
+ ...('runner' in flags ? { runner: runner.runner } : {}),
1073
+ signal,
773
1074
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
774
1075
  ...(validationCmds.length > 0 ? { validationCmds } : {}),
775
1076
  ...(validate ? { validate } : {}),
776
- ...(injectedDeps.safety ? { safety: injectedDeps.safety } : {}),
1077
+ safety: { ...injectedDeps.safety, signal },
777
1078
  ...(injectedDeps.agent ? { agent: injectedDeps.agent } : {}),
778
1079
  ...(injectedDeps.git ? { git: injectedDeps.git } : {}),
779
1080
  idleMs: parsePositiveInt(flags['idle-ms'], DEFAULT_WATCH_IDLE_MS),
@@ -832,6 +1133,9 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
832
1133
  process.stderr.write('cycle watch failed: state_write_failed\n');
833
1134
  return 1;
834
1135
  }
1136
+ finally {
1137
+ cancellation.dispose();
1138
+ }
835
1139
  const finalState = {
836
1140
  ok: true,
837
1141
  group: 'cycle.watch.state',
@@ -859,9 +1163,19 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
859
1163
  process.stdout.write(`${JSON.stringify(result)}\n`);
860
1164
  else
861
1165
  printWatchResult(result);
862
- return 0;
1166
+ return result.stopped === 'cancelled' ? cancellation.exitCode() : 0;
863
1167
  }
864
1168
  const flags = parseFlags(argv);
1169
+ const resume = parseSwitchFlag(argv, 'resume');
1170
+ if (resume === null) {
1171
+ process.stderr.write(CYCLE_USAGE);
1172
+ return 1;
1173
+ }
1174
+ const runner = parseRunner(flags['runner']);
1175
+ if (!runner.ok) {
1176
+ process.stderr.write(`${runner.error}\n`);
1177
+ return 1;
1178
+ }
865
1179
  const validationCmds = parseRepeatedFlag(argv, 'validation-cmd');
866
1180
  const repo = flags['repo'];
867
1181
  if (!repo) {
@@ -878,19 +1192,29 @@ export async function runCycleCommand(argv, injectedDeps = {}) {
878
1192
  return 1;
879
1193
  }
880
1194
  const validate = makeCycleValidationHook(validationCmds, injectedDeps.validate, injectedDeps.runSandboxedValidation);
881
- const result = await runMaterialCycleConsumer({
882
- repo,
883
- limit: parsePositiveInt(flags['limit'], DEFAULT_LIMIT),
884
- target: flags['target'] || '.',
885
- expectedEffect: flags['expected-effect'] || 'evolve from consumed session material',
886
- runner: parseRunner(flags['runner']),
887
- ...(timeoutMs !== undefined ? { timeoutMs } : {}),
888
- ...(validationCmds.length > 0 ? { validationCmds } : {}),
889
- ...(validate ? { validate } : {}),
890
- ...(injectedDeps.safety ? { safety: injectedDeps.safety } : {}),
891
- ...(injectedDeps.agent ? { agent: injectedDeps.agent } : {}),
892
- ...(injectedDeps.git ? { git: injectedDeps.git } : {}),
893
- }, injectedDeps);
1195
+ const cancellation = createProcessCancellation();
1196
+ const signal = combineSignals(cancellation.signal, injectedDeps.safety?.signal);
1197
+ let result;
1198
+ try {
1199
+ result = await runMaterialCycleConsumer({
1200
+ repo,
1201
+ ...(resume ? { resume: true } : {}),
1202
+ limit: parsePositiveInt(flags['limit'], DEFAULT_LIMIT),
1203
+ target: flags['target'] || '.',
1204
+ expectedEffect: flags['expected-effect'] || 'evolve from consumed session material',
1205
+ ...('runner' in flags ? { runner: runner.runner } : {}),
1206
+ signal,
1207
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
1208
+ ...(validationCmds.length > 0 ? { validationCmds } : {}),
1209
+ ...(validate ? { validate } : {}),
1210
+ safety: { ...injectedDeps.safety, signal },
1211
+ ...(injectedDeps.agent ? { agent: injectedDeps.agent } : {}),
1212
+ ...(injectedDeps.git ? { git: injectedDeps.git } : {}),
1213
+ }, injectedDeps);
1214
+ }
1215
+ finally {
1216
+ cancellation.dispose();
1217
+ }
894
1218
  printResult(result);
895
- return materialCycleExitCode(result);
1219
+ return signal.aborted ? cancellation.exitCode() : materialCycleExitCode(result);
896
1220
  }
@@ -1,19 +1,31 @@
1
+ import { type WorkflowProvider } from '@evomap/evolver-webui';
2
+ import { type MemoryGraphOperatorStatus } from './localMemoryGraph.js';
1
3
  export interface DashboardServer {
2
4
  readonly token: string;
3
5
  readonly launchTicket: string;
4
6
  listen(port?: number): Promise<number>;
5
7
  close(): Promise<void>;
6
8
  }
9
+ export type DashboardEnv = Readonly<Record<string, string | undefined>>;
7
10
  export interface DashboardDeps {
8
- createServer?: () => DashboardServer;
11
+ createServer?: (memoryGraphStatus: () => MemoryGraphOperatorStatus, env: DashboardEnv) => DashboardServer;
12
+ env?: DashboardEnv;
9
13
  openUrl?: (url: string) => Promise<boolean>;
10
14
  waitForShutdown?: () => Promise<void>;
11
15
  stdout?: (text: string) => void;
12
16
  stderr?: (text: string) => void;
17
+ memoryGraphStatus?: () => MemoryGraphOperatorStatus;
13
18
  }
14
19
  export interface DashboardCommandOptions {
15
20
  eaddrinusePortAttempts?: number;
16
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;
17
29
  export declare function dashboardOpenCommand(url: string, platform?: NodeJS.Platform): {
18
30
  command: string;
19
31
  args: string[];