@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
@@ -0,0 +1,244 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { events, mailbox } from '@evomap/evolver-core';
4
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
5
+ const SUCCESS_THRESHOLD = 0.95;
6
+ const KNOWN_OUTCOMES = new Set(['ok', 'missing', 'mismatch', 'error', 'skipped']);
7
+ function parseSince(value, now) {
8
+ const relative = /^(\d+)\s*(s|m|h|d)$/i.exec(value);
9
+ if (relative) {
10
+ const amount = Number(relative[1]);
11
+ const unit = relative[2].toLowerCase();
12
+ const factor = unit === 's' ? 1_000 : unit === 'm' ? 60_000 : unit === 'h' ? 3_600_000 : 86_400_000;
13
+ return now - amount * factor;
14
+ }
15
+ if (!/[-T]/.test(value))
16
+ return undefined;
17
+ const parsed = Date.parse(value);
18
+ return Number.isFinite(parsed) ? parsed : undefined;
19
+ }
20
+ function parseArgs(argv, now) {
21
+ let json = false;
22
+ let help = false;
23
+ let sinceMs = null;
24
+ let namespace = 'default';
25
+ for (let index = 0; index < argv.length; index += 1) {
26
+ const arg = argv[index];
27
+ if (arg === '--json') {
28
+ json = true;
29
+ continue;
30
+ }
31
+ if (arg === '--help' || arg === '-h') {
32
+ help = true;
33
+ continue;
34
+ }
35
+ const readValue = (flag) => {
36
+ if (arg?.startsWith(`${flag}=`))
37
+ return arg.slice(flag.length + 1);
38
+ if (arg === flag) {
39
+ index += 1;
40
+ return argv[index];
41
+ }
42
+ return undefined;
43
+ };
44
+ const since = readValue('--since');
45
+ if (since !== undefined) {
46
+ const parsed = parseSince(since, now);
47
+ if (parsed === undefined)
48
+ return 'invalid --since (expected ISO-8601 or a duration such as 1h, 30m, or 2d)';
49
+ sinceMs = parsed;
50
+ continue;
51
+ }
52
+ const requestedNamespace = readValue('--namespace');
53
+ if (requestedNamespace !== undefined) {
54
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(requestedNamespace))
55
+ return 'invalid --namespace';
56
+ namespace = requestedNamespace;
57
+ continue;
58
+ }
59
+ return `unknown argument: ${arg ?? '(missing)'}`;
60
+ }
61
+ return { json, help, sinceMs, namespace };
62
+ }
63
+ function percentile(values, fraction) {
64
+ if (values.length === 0)
65
+ return 0;
66
+ const sorted = [...values].sort((left, right) => left - right);
67
+ return sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * fraction))] ?? 0;
68
+ }
69
+ function emptyRow(assetType) {
70
+ return {
71
+ assetType,
72
+ total: 0,
73
+ ok: 0,
74
+ missing: 0,
75
+ mismatch: 0,
76
+ error: 0,
77
+ skipped: 0,
78
+ successRate: 0,
79
+ p50LatencyMs: 0,
80
+ p95LatencyMs: 0,
81
+ p99LatencyMs: 0,
82
+ p50AgeMs: 0,
83
+ p95AgeMs: 0,
84
+ p99AgeMs: 0,
85
+ };
86
+ }
87
+ export function aggregateRecallVerifyState(state, sinceMs) {
88
+ const outcomes = (state?.outcomes ?? []).filter((outcome) => sinceMs === null || outcome.at >= sinceMs);
89
+ const buckets = new Map();
90
+ for (const outcome of outcomes) {
91
+ const assetType = outcome.assetType ?? 'Unknown';
92
+ const bucket = buckets.get(assetType) ?? { row: emptyRow(assetType), latencies: [], ages: [], blockingSkips: 0 };
93
+ bucket.row.total += 1;
94
+ bucket.row[outcome.outcome] += 1;
95
+ // V1 state can contain terminal verifier failures as `skipped`. Only intentional sampling is non-blocking.
96
+ if (outcome.outcome === 'skipped' && outcome.reason !== 'sampled_out')
97
+ bucket.blockingSkips += 1;
98
+ if (Number.isFinite(outcome.latencyMs) && outcome.latencyMs >= 0)
99
+ bucket.latencies.push(outcome.latencyMs);
100
+ if (Number.isFinite(outcome.ageMs) && outcome.ageMs >= 0)
101
+ bucket.ages.push(outcome.ageMs);
102
+ buckets.set(assetType, bucket);
103
+ }
104
+ const rows = [...buckets.values()].map(({ row, latencies, ages, blockingSkips }) => {
105
+ const denominator = row.ok + row.missing + row.mismatch + row.error + blockingSkips;
106
+ return {
107
+ ...row,
108
+ successRate: denominator > 0 ? row.ok / denominator : 0,
109
+ p50LatencyMs: percentile(latencies, 0.5),
110
+ p95LatencyMs: percentile(latencies, 0.95),
111
+ p99LatencyMs: percentile(latencies, 0.99),
112
+ p50AgeMs: percentile(ages, 0.5),
113
+ p95AgeMs: percentile(ages, 0.95),
114
+ p99AgeMs: percentile(ages, 0.99),
115
+ };
116
+ }).sort((left, right) => left.assetType.localeCompare(right.assetType));
117
+ const totals = rows.reduce((total, row) => ({
118
+ ...total,
119
+ total: total.total + row.total,
120
+ ok: total.ok + row.ok,
121
+ missing: total.missing + row.missing,
122
+ mismatch: total.mismatch + row.mismatch,
123
+ error: total.error + row.error,
124
+ skipped: total.skipped + row.skipped,
125
+ }), emptyRow('TOTAL'));
126
+ const blockingSkips = [...buckets.values()].reduce((total, bucket) => total + bucket.blockingSkips, 0);
127
+ const denominator = totals.ok + totals.missing + totals.mismatch + totals.error + blockingSkips;
128
+ totals.successRate = denominator > 0 ? totals.ok / denominator : 0;
129
+ const totalLatencies = outcomes
130
+ .map((outcome) => outcome.latencyMs)
131
+ .filter((latency) => Number.isFinite(latency) && latency >= 0);
132
+ totals.p50LatencyMs = percentile(totalLatencies, 0.5);
133
+ totals.p95LatencyMs = percentile(totalLatencies, 0.95);
134
+ totals.p99LatencyMs = percentile(totalLatencies, 0.99);
135
+ const totalAges = outcomes
136
+ .map((outcome) => outcome.ageMs)
137
+ .filter((age) => age !== undefined && Number.isFinite(age) && age >= 0);
138
+ totals.p50AgeMs = percentile(totalAges, 0.5);
139
+ totals.p95AgeMs = percentile(totalAges, 0.95);
140
+ totals.p99AgeMs = percentile(totalAges, 0.99);
141
+ let gate = rows.length === 0 ? 'RED' : 'GREEN';
142
+ for (const row of rows) {
143
+ if (row.mismatch > 0 || row.successRate < 0.85) {
144
+ gate = 'RED';
145
+ break;
146
+ }
147
+ if (row.successRate < SUCCESS_THRESHOLD)
148
+ gate = 'YELLOW';
149
+ }
150
+ return {
151
+ since: sinceMs === null ? null : new Date(sinceMs).toISOString(),
152
+ retainedOutcomes: state?.outcomes.length ?? 0,
153
+ queued: state?.queue.length ?? 0,
154
+ rows,
155
+ totals,
156
+ gate,
157
+ retentionNotice: 'This gate covers only outcomes retained in the bounded proxy state; it is not an all-time history.',
158
+ };
159
+ }
160
+ function parseState(raw) {
161
+ if (raw === undefined)
162
+ return undefined;
163
+ const parsed = JSON.parse(raw);
164
+ if (parsed.version !== 1 || !Array.isArray(parsed.queue) || !Array.isArray(parsed.outcomes)) {
165
+ throw new Error('invalid_recall_verify_state');
166
+ }
167
+ const outcomes = parsed.outcomes.filter((outcome) => (outcome !== null
168
+ && typeof outcome === 'object'
169
+ && typeof outcome.assetId === 'string'
170
+ && KNOWN_OUTCOMES.has(outcome.outcome)
171
+ && Number.isFinite(outcome.at)
172
+ && Number.isFinite(outcome.latencyMs)
173
+ && (outcome.ageMs === undefined || (Number.isFinite(outcome.ageMs) && outcome.ageMs >= 0))));
174
+ if (outcomes.length !== parsed.outcomes.length)
175
+ throw new Error('invalid_recall_verify_state');
176
+ return { version: 1, queue: parsed.queue, outcomes, counts: parsed.counts };
177
+ }
178
+ function formatPercent(value) {
179
+ return `${(value * 100).toFixed(1)}%`;
180
+ }
181
+ function printReport(report, log) {
182
+ log(`# Publish Recall Report (since ${report.since ?? 'retained window'})`);
183
+ log('');
184
+ log(report.retentionNotice);
185
+ log(`Retained outcomes: ${report.retainedOutcomes}; queued: ${report.queued}`);
186
+ log('');
187
+ if (report.rows.length === 0) {
188
+ log('_No publish recall outcomes found._');
189
+ }
190
+ else {
191
+ log('| asset_type | total | ok | missing | mismatch | error | skipped | success_rate | p50_latency_ms | p95_latency_ms | p99_latency_ms | p50_age_ms | p95_age_ms | p99_age_ms |');
192
+ log('|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|');
193
+ for (const row of [...report.rows, report.totals]) {
194
+ log(`| ${row.assetType} | ${row.total} | ${row.ok} | ${row.missing} | ${row.mismatch} | ${row.error} | ${row.skipped} | ${formatPercent(row.successRate)} | ${row.p50LatencyMs} | ${row.p95LatencyMs} | ${row.p99LatencyMs} | ${row.p50AgeMs} | ${row.p95AgeMs} | ${row.p99AgeMs} |`);
195
+ }
196
+ }
197
+ log('');
198
+ log(`Ship gate: **${report.gate}** (${report.gate === 'GREEN' ? 'exit 0' : 'exit 2'})`);
199
+ }
200
+ export async function runRecallVerifyReport(argv, deps = {}) {
201
+ const log = deps.log ?? ((line) => process.stdout.write(`${line}\n`));
202
+ const err = deps.err ?? ((line) => process.stderr.write(`${line}\n`));
203
+ const env = deps.env ?? process.env;
204
+ const parsed = parseArgs(argv, (deps.now ?? Date.now)());
205
+ if (typeof parsed === 'string') {
206
+ err(`recall-verify-report: ${parsed}`);
207
+ return 1;
208
+ }
209
+ if (parsed.help) {
210
+ log('Usage: evolver recall-verify-report [--since <Nh|Nm|Nd|ISO>] [--namespace <name>] [--json]');
211
+ return 0;
212
+ }
213
+ const envFile = loadEnvFileFromEnv(env);
214
+ if (envFile.error) {
215
+ err('recall-verify-report: env_file_unavailable');
216
+ return 1;
217
+ }
218
+ const storePath = deps.storePath ?? env['EVOLVER_PROXY_STORE']?.trim() ?? join(events.evomapHome(env), 'proxy', 'mailbox.db');
219
+ let store;
220
+ try {
221
+ const key = `publish_recall_verifier:${parsed.namespace}:v1`;
222
+ let raw;
223
+ if (deps.readState)
224
+ raw = deps.readState(key);
225
+ else if (existsSync(storePath)) {
226
+ store = new mailbox.MailboxStore({ path: storePath });
227
+ raw = store.getState(key);
228
+ }
229
+ const report = aggregateRecallVerifyState(parseState(raw), parsed.sinceMs);
230
+ if (parsed.json)
231
+ log(JSON.stringify(report, null, 2));
232
+ else
233
+ printReport(report, log);
234
+ return report.gate === 'GREEN' ? 0 : 2;
235
+ }
236
+ catch {
237
+ err('recall-verify-report: invalid_or_unavailable_state');
238
+ return 1;
239
+ }
240
+ finally {
241
+ store?.close();
242
+ }
243
+ }
244
+ export const runRecallVerifyReportCommand = (argv) => runRecallVerifyReport(argv);
package/dist/recipe.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { assetstore, events, type hub as hubNs } from '@evomap/evolver-core';
1
+ import { assetstore, events, verify, type hub as hubNs } from '@evomap/evolver-core';
2
2
  import type { ConnectPublicOptions, PublicHubCapability } from '@evomap/evolver-adapter-public';
3
3
  export interface RecipeCliDeps {
4
4
  hub?: RecipeHub;
@@ -8,6 +8,7 @@ export interface RecipeCliDeps {
8
8
  err?: (line: string) => void;
9
9
  ingestor?: events.Ingestor;
10
10
  review?: assetstore.ReviewLedger;
11
+ runValidation?: typeof verify.runSandboxedValidation;
11
12
  connectHub?: (opts: ConnectPublicOptions) => {
12
13
  hub: PublicHubCapability;
13
14
  auth: hubNs.AuthProvider;
@@ -15,12 +16,15 @@ export interface RecipeCliDeps {
15
16
  }
16
17
  export interface RecipeHub {
17
18
  recipes?: hubNs.RecipeCapability;
19
+ publish(bundle: assetstore.AssetRecord[]): Promise<hubNs.PublishReceipt>;
18
20
  hello?(opts: {
19
21
  rotate: boolean;
20
22
  evolverVersion?: string;
23
+ preserveCredentials?: boolean;
21
24
  }): Promise<{
22
25
  ok: boolean;
23
26
  error?: string;
27
+ nodeId?: string;
24
28
  }>;
25
29
  }
26
30
  type ParseResult<T> = {
@@ -50,12 +54,20 @@ export interface RecipeFromSkillsOptions {
50
54
  publish: boolean;
51
55
  jsonOut: boolean;
52
56
  }
53
- export type RecipeOptions = RecipeBuildOptions | RecipeReuseOptions | RecipeFromSkillsOptions;
57
+ export interface RecipeSearchOptions {
58
+ sub: 'search';
59
+ q?: string;
60
+ limit?: number;
61
+ jsonOut: boolean;
62
+ }
63
+ export type RecipeOptions = RecipeBuildOptions | RecipeReuseOptions | RecipeFromSkillsOptions | RecipeSearchOptions;
54
64
  export declare function runRecipeCommand(argv: readonly string[], deps?: RecipeCliDeps): Promise<number>;
55
65
  export declare function createRecipeHubFromEnv(env?: NodeJS.ProcessEnv, connectHub?: (opts: ConnectPublicOptions) => {
56
66
  hub: PublicHubCapability;
57
67
  auth: hubNs.AuthProvider;
58
68
  }): PublicHubCapability;
69
+ /** Opaque identity for resume isolation; raw credentials, account ids, and local paths never leave this helper. */
70
+ export declare function resolveRecipeHubResumeIdentityFingerprint(env: NodeJS.ProcessEnv): string;
59
71
  export declare function parseRecipeArgs(argv: readonly string[]): ParseResult<RecipeOptions>;
60
72
  /**
61
73
  * The EXPLICIT home overrides (EVOMAP_DIR / EVOLVER_HOME / EVOMAP_HOME) the recipe credential layer honors,