@evomap/evolver-cli 2.0.0-beta.1 → 2.0.0-beta.12
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/antiGeneBenchmark.js +12 -0
- package/dist/antiGeneEvidence.d.ts +15 -0
- package/dist/antiGeneEvidence.js +49 -0
- package/dist/antiGeneRollout.d.ts +3 -1
- package/dist/antiGeneRollout.js +16 -2
- package/dist/assetHealth.d.ts +6 -0
- package/dist/assetHealth.js +107 -0
- package/dist/assetSidecarRecovery.d.ts +14 -0
- package/dist/assetSidecarRecovery.js +171 -0
- package/dist/assetTrust.d.ts +24 -0
- package/dist/assetTrust.js +218 -0
- package/dist/atp.js +4 -2
- package/dist/autoDistillLlm.d.ts +6 -0
- package/dist/autoDistillLlm.js +44 -7
- package/dist/autoexec.d.ts +14 -12
- package/dist/autoexec.js +84 -34
- package/dist/autoexecConfig.d.ts +10 -0
- package/dist/autoexecConfig.js +68 -0
- package/dist/cli.js +12 -5
- package/dist/cliContracts.js +30 -3
- package/dist/cliLifecycle.d.ts +7 -0
- package/dist/cliLifecycle.js +9 -0
- package/dist/cycleConsumer.d.ts +61 -1
- package/dist/cycleConsumer.js +551 -16
- package/dist/dashboard.d.ts +33 -0
- package/dist/dashboard.js +352 -0
- package/dist/dispatch.d.ts +10 -1
- package/dist/dispatch.js +40 -2
- package/dist/distillAdmission.d.ts +13 -0
- package/dist/distillAdmission.js +35 -0
- package/dist/distillObserver.js +6 -8
- package/dist/distillPrimitives.d.ts +9 -7
- package/dist/distillPrimitives.js +65 -12
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +49 -3
- package/dist/index.d.ts +8 -2
- package/dist/index.js +350 -42
- package/dist/issueReport.d.ts +7 -0
- package/dist/issueReport.js +291 -0
- package/dist/lifecycle.d.ts +22 -1
- package/dist/lifecycle.js +226 -29
- package/dist/localMemoryGraph.d.ts +97 -0
- package/dist/localMemoryGraph.js +889 -0
- package/dist/login.d.ts +20 -4
- package/dist/login.js +58 -8
- package/dist/materialPackage.d.ts +52 -0
- package/dist/materialPackage.js +401 -0
- package/dist/materialSnapshot.d.ts +54 -0
- package/dist/materialSnapshot.js +370 -0
- package/dist/memoryEventMirror.d.ts +23 -0
- package/dist/memoryEventMirror.js +140 -0
- package/dist/migrate/fieldMap.js +25 -0
- package/dist/migrate/v1Import.d.ts +7 -1
- package/dist/migrate/v1Import.js +132 -11
- package/dist/nonGitWorkspaceNotice.d.ts +24 -0
- package/dist/nonGitWorkspaceNotice.js +122 -0
- package/dist/proxyToken.d.ts +10 -0
- package/dist/proxyToken.js +80 -0
- package/dist/recipe.d.ts +12 -2
- package/dist/recipe.js +381 -8
- package/dist/reuse.d.ts +5 -3
- package/dist/reuse.js +126 -15
- package/dist/reuseReport.js +16 -16
- package/dist/runtimeCapabilities.d.ts +18 -0
- package/dist/runtimeCapabilities.js +81 -0
- package/dist/runtimeSessionSource.d.ts +10 -0
- package/dist/runtimeSessionSource.js +32 -5
- package/dist/setupHooks.d.ts +11 -1
- package/dist/setupHooks.js +235 -16
- package/dist/skill2gep.d.ts +38 -9
- package/dist/skill2gep.js +147 -14
- package/dist/skillDistill.d.ts +1 -0
- package/dist/skillDistill.js +4 -4
- package/dist/skillFetch.d.ts +18 -0
- package/dist/skillFetch.js +391 -0
- package/dist/solo/mode.js +5 -0
- package/dist/sync.d.ts +38 -0
- package/dist/sync.js +1981 -0
- package/dist/trajectoryExport.js +23 -12
- package/dist/v1Compat.d.ts +24 -0
- package/dist/v1Compat.js +249 -0
- 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 +12 -6
package/dist/recipe.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
5
|
import { assetstore, events, mailbox } from '@evomap/evolver-core';
|
|
5
|
-
import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled, isNodeSecret, parseNodeSecretVersion } from '@evomap/evolver-adapter-public';
|
|
6
|
+
import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled, isNodeSecret, parseNodeSecretVersion, resolveHubUrl } from '@evomap/evolver-adapter-public';
|
|
7
|
+
import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
6
8
|
import { resolveAtpSenderId } from './atp.js';
|
|
9
|
+
import { parseSkillMd, reverseDistill } from './skill2gep.js';
|
|
10
|
+
import { recordSkillDistillation } from './skillDistill.js';
|
|
7
11
|
const MAX_RECIPE_STEPS = 20;
|
|
8
12
|
const MAX_ID_LENGTH = 200;
|
|
9
|
-
const DEFAULT_PUBLIC_HUB_URL = 'https://evomap.ai';
|
|
10
13
|
const SENSITIVE_ERROR_KEYS = new Set(['authorization', 'node_secret', 'nodesecret', 'token', 'access_token', 'refresh_token', 'secret']);
|
|
11
14
|
const STALE_NODE_SECRET_ERRORS = new Set(['node_secret_invalid', 'node_secret_not_set']);
|
|
12
15
|
export async function runRecipeCommand(argv, deps = {}) {
|
|
@@ -22,6 +25,8 @@ export async function runRecipeCommand(argv, deps = {}) {
|
|
|
22
25
|
if (isHubDryRunEnabled(env)) {
|
|
23
26
|
if (parsed.value.sub === 'build')
|
|
24
27
|
return await runRecipeBuildDryRun(parsed.value, deps.store, { log, err });
|
|
28
|
+
if (parsed.value.sub === 'from-skills')
|
|
29
|
+
return await runRecipeFromSkills(parsed.value, undefined, deps, { log, err }, true);
|
|
25
30
|
return runRecipeReuseDryRun(parsed.value, { log });
|
|
26
31
|
}
|
|
27
32
|
const hub = deps.hub ?? createRecipeHubFromEnv(env, deps.connectHub ?? connectPublicHub);
|
|
@@ -31,6 +36,8 @@ export async function runRecipeCommand(argv, deps = {}) {
|
|
|
31
36
|
}
|
|
32
37
|
if (parsed.value.sub === 'build')
|
|
33
38
|
return await runRecipeBuild(parsed.value, hub, deps.store, { log, err });
|
|
39
|
+
if (parsed.value.sub === 'from-skills')
|
|
40
|
+
return await runRecipeFromSkills(parsed.value, hub, deps, { log, err }, false);
|
|
34
41
|
return await runRecipeReuse(parsed.value, hub, { log, err });
|
|
35
42
|
}
|
|
36
43
|
catch (e) {
|
|
@@ -67,6 +74,7 @@ function runRecipeReuseDryRun(opts, io) {
|
|
|
67
74
|
return 0;
|
|
68
75
|
}
|
|
69
76
|
export function createRecipeHubFromEnv(env = process.env, connectHub = connectPublicHub) {
|
|
77
|
+
loadEnvFileFromEnv(env);
|
|
70
78
|
const hubUrl = resolveRecipeHubUrl(env);
|
|
71
79
|
const credentials = resolveRecipeHubCredentials(env);
|
|
72
80
|
if (!credentials.nodeSecret && !existsSync(join(credentials.evomapDir, 'token.json'))) {
|
|
@@ -89,17 +97,42 @@ export function createRecipeHubFromEnv(env = process.env, connectHub = connectPu
|
|
|
89
97
|
: connectHub({ hubUrl, authMode: 'oauth', evomapDir: credentials.evomapDir, senderId: () => credentials.senderId });
|
|
90
98
|
return connected.hub;
|
|
91
99
|
}
|
|
100
|
+
/** Opaque identity for resume isolation; raw credentials, account ids, and local paths never leave this helper. */
|
|
101
|
+
export function resolveRecipeHubResumeIdentityFingerprint(env) {
|
|
102
|
+
loadEnvFileFromEnv(env);
|
|
103
|
+
const credentials = resolveRecipeHubCredentials(env);
|
|
104
|
+
let credential;
|
|
105
|
+
if (credentials.nodeSecret) {
|
|
106
|
+
credential = credentials.nodeSecret;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
try {
|
|
110
|
+
credential = createHash('sha256')
|
|
111
|
+
.update(readFileSync(join(credentials.evomapDir, 'token.json'), 'utf8'))
|
|
112
|
+
.digest('hex');
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
throw new Error('Hub resume identity credentials are unavailable');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return createHash('sha256').update(JSON.stringify({
|
|
119
|
+
authMode: credentials.nodeSecret ? 'legacy' : 'oauth',
|
|
120
|
+
senderId: credentials.senderId ?? '',
|
|
121
|
+
credential,
|
|
122
|
+
})).digest('hex');
|
|
123
|
+
}
|
|
92
124
|
function resolveRecipeHubUrl(env) {
|
|
93
|
-
|
|
94
|
-
return hubUrl;
|
|
125
|
+
return resolveHubUrl(env);
|
|
95
126
|
}
|
|
96
127
|
export function parseRecipeArgs(argv) {
|
|
97
128
|
const sub = argv[0];
|
|
98
|
-
if (sub !== 'build' && sub !== 'reuse')
|
|
99
|
-
return { ok: false, error: 'recipe subcommand must be build|reuse' };
|
|
129
|
+
if (sub !== 'build' && sub !== 'reuse' && sub !== 'from-skills')
|
|
130
|
+
return { ok: false, error: 'recipe subcommand must be build|reuse|from-skills' };
|
|
100
131
|
const args = argv.slice(1);
|
|
101
132
|
if (sub === 'build')
|
|
102
133
|
return parseBuildArgs(args);
|
|
134
|
+
if (sub === 'from-skills')
|
|
135
|
+
return parseFromSkillsArgs(args);
|
|
103
136
|
return parseReuseArgs(args);
|
|
104
137
|
}
|
|
105
138
|
async function runRecipeBuild(opts, hub, store, io) {
|
|
@@ -129,6 +162,132 @@ async function runRecipeBuild(opts, hub, store, io) {
|
|
|
129
162
|
}
|
|
130
163
|
return 0;
|
|
131
164
|
}
|
|
165
|
+
async function runRecipeFromSkills(opts, hub, deps, io, dryRun) {
|
|
166
|
+
const loaded = loadRecipeFromSkillsManifest(opts.manifestPath);
|
|
167
|
+
if (!loaded.ok) {
|
|
168
|
+
io.err(loaded.error);
|
|
169
|
+
return 1;
|
|
170
|
+
}
|
|
171
|
+
const preflight = preflightRecipeFromSkillsSteps(loaded.value.steps);
|
|
172
|
+
if (!preflight.ok) {
|
|
173
|
+
io.err(preflight.error);
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
const store = deps.store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
177
|
+
const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
|
|
178
|
+
const steps = [];
|
|
179
|
+
const distilled = [];
|
|
180
|
+
for (const prepared of preflight.value) {
|
|
181
|
+
const existing = await findReusableRecipeStep(store, prepared);
|
|
182
|
+
if (existing) {
|
|
183
|
+
addRecipeFromSkillsStep(steps, distilled, existing);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const step = prepared.step;
|
|
187
|
+
const res = await recordSkillDistillation(step.skill, step.execution, {
|
|
188
|
+
store,
|
|
189
|
+
...(deps.review ? { review: deps.review } : {}),
|
|
190
|
+
ingestor,
|
|
191
|
+
}, step.scenario ? { scenario: step.scenario } : {});
|
|
192
|
+
if (!res.geneId || !res.geneAssetId) {
|
|
193
|
+
const recovered = await findReusableRecipeStep(store, prepared);
|
|
194
|
+
if (recovered) {
|
|
195
|
+
addRecipeFromSkillsStep(steps, distilled, recovered);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
io.err(`recipe from-skills step ${prepared.position + 1} did not produce a Gene: ${res.errors.join('; ') || 'refused'}`);
|
|
199
|
+
return 1;
|
|
200
|
+
}
|
|
201
|
+
if (!res.capsuleId) {
|
|
202
|
+
io.err(`recipe from-skills step ${prepared.position + 1} missing Capsule evidence: ${res.capsuleDiagnostic ?? 'missing_capsule_evidence'}`);
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
if (!(await hasCapsuleEvidence(store, res.capsuleId, res.geneId))) {
|
|
206
|
+
io.err(`recipe from-skills step ${prepared.position + 1} missing persisted Capsule evidence`);
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
addRecipeFromSkillsStep(steps, distilled, {
|
|
210
|
+
position: prepared.position,
|
|
211
|
+
geneId: res.geneId,
|
|
212
|
+
geneAssetId: res.geneAssetId,
|
|
213
|
+
capsuleId: res.capsuleId,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (dryRun) {
|
|
217
|
+
const payload = recipeFromSkillsPayload({
|
|
218
|
+
mode: 'dry_run',
|
|
219
|
+
title: loaded.value.title,
|
|
220
|
+
publish: opts.publish,
|
|
221
|
+
steps: distilled,
|
|
222
|
+
});
|
|
223
|
+
if (opts.jsonOut)
|
|
224
|
+
io.log(JSON.stringify(payload, null, 2));
|
|
225
|
+
else {
|
|
226
|
+
io.log(`[recipe from-skills] dry-run: would create DRAFT recipe ("${loaded.value.title}", ${steps.length} step${steps.length === 1 ? '' : 's'}).`);
|
|
227
|
+
if (opts.publish)
|
|
228
|
+
io.log('[recipe from-skills] dry-run: would publish the recipe after creation.');
|
|
229
|
+
else
|
|
230
|
+
io.log('[recipe from-skills] dry-run: would leave the recipe as draft.');
|
|
231
|
+
}
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
if (!hub?.recipes) {
|
|
235
|
+
io.err('recipe capability is not available for the configured Hub adapter');
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
238
|
+
const createReceipt = await callRecipeWithAuthRetry(hub, 'recipe from-skills', () => hub.recipes.create({
|
|
239
|
+
title: loaded.value.title,
|
|
240
|
+
steps,
|
|
241
|
+
...(loaded.value.description ? { description: loaded.value.description } : {}),
|
|
242
|
+
...(loaded.value.pricePerExecution !== undefined ? { pricePerExecution: loaded.value.pricePerExecution } : {}),
|
|
243
|
+
}), io);
|
|
244
|
+
const recipeId = createReceipt.recipeId;
|
|
245
|
+
if (!opts.jsonOut) {
|
|
246
|
+
io.log(`[recipe from-skills] Created DRAFT recipe ${recipeId ?? '(id pending)'} ("${loaded.value.title}", ${steps.length} step${steps.length === 1 ? '' : 's'}).`);
|
|
247
|
+
}
|
|
248
|
+
if (opts.publish) {
|
|
249
|
+
if (!recipeId) {
|
|
250
|
+
io.err('[recipe from-skills] Hub did not return a recipe id; cannot publish.');
|
|
251
|
+
return 1;
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
await callRecipeWithAuthRetry(hub, 'recipe from-skills', () => hub.recipes.publish(recipeId), io);
|
|
255
|
+
}
|
|
256
|
+
catch (e) {
|
|
257
|
+
if (opts.jsonOut) {
|
|
258
|
+
io.log(JSON.stringify(recipeFromSkillsPayload({
|
|
259
|
+
ok: false,
|
|
260
|
+
mode: 'draft',
|
|
261
|
+
title: loaded.value.title,
|
|
262
|
+
publish: opts.publish,
|
|
263
|
+
steps: distilled,
|
|
264
|
+
recipeId,
|
|
265
|
+
error: 'publish_failed',
|
|
266
|
+
}), null, 2));
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
io.err(`[recipe from-skills] Created DRAFT recipe ${recipeId}; publish failed before it was made live.`);
|
|
270
|
+
}
|
|
271
|
+
throw e;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const payload = recipeFromSkillsPayload({
|
|
275
|
+
mode: opts.publish ? 'published' : 'draft',
|
|
276
|
+
title: loaded.value.title,
|
|
277
|
+
publish: opts.publish,
|
|
278
|
+
steps: distilled,
|
|
279
|
+
recipeId,
|
|
280
|
+
});
|
|
281
|
+
if (opts.jsonOut)
|
|
282
|
+
io.log(JSON.stringify(payload, null, 2));
|
|
283
|
+
else {
|
|
284
|
+
if (opts.publish)
|
|
285
|
+
io.log(`[recipe from-skills] Published recipe ${recipeId}.`);
|
|
286
|
+
else
|
|
287
|
+
io.log('[recipe from-skills] Left as draft. Re-run with --publish to make it live.');
|
|
288
|
+
}
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
132
291
|
async function runRecipeReuse(opts, hub, io) {
|
|
133
292
|
await callRecipeWithAuthRetry(hub, 'recipe reuse', () => hub.recipes.get(opts.recipeId), io);
|
|
134
293
|
const receipt = await callRecipeWithAuthRetry(hub, 'recipe reuse', () => hub.recipes.express(opts.recipeId, { inputPayload: opts.inputPayload }), io);
|
|
@@ -150,6 +309,198 @@ async function recipeStepsFromLocalAssets(assetIds, store) {
|
|
|
150
309
|
return { assetId, assetType, position: index };
|
|
151
310
|
});
|
|
152
311
|
}
|
|
312
|
+
function preflightRecipeFromSkillsSteps(steps) {
|
|
313
|
+
const prepared = [];
|
|
314
|
+
for (let i = 0; i < steps.length; i += 1) {
|
|
315
|
+
const step = steps[i];
|
|
316
|
+
const parsed = parseSkillMd(step.skill);
|
|
317
|
+
const preview = reverseDistill(parsed, step.execution, step.scenario ? { scenario: step.scenario } : {});
|
|
318
|
+
if (!preview.gene) {
|
|
319
|
+
return {
|
|
320
|
+
ok: false,
|
|
321
|
+
error: `recipe from-skills step ${i + 1} did not produce a Gene: ${preview.errors.join('; ') || 'refused'}`,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (!preview.capsule) {
|
|
325
|
+
const diag = preview.capsuleDiagnostic
|
|
326
|
+
? (preview.capsuleDiagnostic.detail ?? preview.capsuleDiagnostic.reason)
|
|
327
|
+
: 'missing_capsule_evidence';
|
|
328
|
+
return {
|
|
329
|
+
ok: false,
|
|
330
|
+
error: `recipe from-skills step ${i + 1} missing Capsule evidence: ${diag}`,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
prepared.push({
|
|
334
|
+
position: i,
|
|
335
|
+
step,
|
|
336
|
+
candidateSignals: normalizedSignalList(preview.gene.signals_match),
|
|
337
|
+
candidateCapsuleId: preview.capsule.id,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return { ok: true, value: prepared };
|
|
341
|
+
}
|
|
342
|
+
async function findReusableRecipeStep(store, prepared) {
|
|
343
|
+
const candidateSignals = prepared.candidateSignals;
|
|
344
|
+
if (candidateSignals.length === 0)
|
|
345
|
+
return null;
|
|
346
|
+
const genes = await store.list('Gene', 10_000);
|
|
347
|
+
const capsules = await store.list('Capsule', 10_000);
|
|
348
|
+
for (const gene of genes) {
|
|
349
|
+
const signals = new Set(normalizedSignalList(gene['signals_match']));
|
|
350
|
+
if (!candidateSignals.every((signal) => signals.has(signal)))
|
|
351
|
+
continue;
|
|
352
|
+
const geneId = typeof gene['id'] === 'string' && gene['id'].trim()
|
|
353
|
+
? gene['id'].trim()
|
|
354
|
+
: String(gene['asset_id'] ?? '');
|
|
355
|
+
const geneAssetId = typeof gene['asset_id'] === 'string' ? gene['asset_id'] : '';
|
|
356
|
+
if (!geneId || !geneAssetId)
|
|
357
|
+
continue;
|
|
358
|
+
const capsule = capsules.find((record) => String(record['id']) === prepared.candidateCapsuleId &&
|
|
359
|
+
String(record['gene']) === geneId);
|
|
360
|
+
if (!capsule)
|
|
361
|
+
continue;
|
|
362
|
+
return {
|
|
363
|
+
position: prepared.position,
|
|
364
|
+
geneId,
|
|
365
|
+
geneAssetId,
|
|
366
|
+
capsuleId: String(capsule['id']),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
function addRecipeFromSkillsStep(steps, distilled, result) {
|
|
372
|
+
steps.push({ assetId: result.geneAssetId, assetType: 'Gene', position: result.position });
|
|
373
|
+
distilled.push(result);
|
|
374
|
+
}
|
|
375
|
+
async function hasCapsuleEvidence(store, capsuleId, geneId) {
|
|
376
|
+
const capsules = await store.list('Capsule', 10_000);
|
|
377
|
+
return capsules.some((capsule) => String(capsule['id']) === capsuleId &&
|
|
378
|
+
String(capsule['gene']) === geneId);
|
|
379
|
+
}
|
|
380
|
+
function normalizedSignalList(value) {
|
|
381
|
+
return Array.isArray(value)
|
|
382
|
+
? value.map((item) => String(item).trim().toLowerCase()).filter(Boolean)
|
|
383
|
+
: [];
|
|
384
|
+
}
|
|
385
|
+
function loadRecipeFromSkillsManifest(path) {
|
|
386
|
+
let raw;
|
|
387
|
+
const manifestPath = resolve(path);
|
|
388
|
+
try {
|
|
389
|
+
raw = readFileSync(manifestPath, 'utf8');
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
return { ok: false, error: 'recipe from-skills cannot read --manifest file' };
|
|
393
|
+
}
|
|
394
|
+
let parsed;
|
|
395
|
+
try {
|
|
396
|
+
parsed = JSON.parse(raw);
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
return { ok: false, error: 'recipe from-skills --manifest must be valid JSON' };
|
|
400
|
+
}
|
|
401
|
+
if (!isPlainRecord(parsed))
|
|
402
|
+
return { ok: false, error: 'recipe from-skills --manifest must be a JSON object' };
|
|
403
|
+
const title = typeof parsed['title'] === 'string' ? parsed['title'].trim() : '';
|
|
404
|
+
if (!title)
|
|
405
|
+
return { ok: false, error: 'recipe from-skills manifest requires title' };
|
|
406
|
+
const rawSteps = parsed['steps'];
|
|
407
|
+
if (!Array.isArray(rawSteps) || rawSteps.length === 0)
|
|
408
|
+
return { ok: false, error: 'recipe from-skills manifest requires non-empty steps[]' };
|
|
409
|
+
if (rawSteps.length > MAX_RECIPE_STEPS)
|
|
410
|
+
return { ok: false, error: `recipe from-skills supports at most ${MAX_RECIPE_STEPS} steps` };
|
|
411
|
+
const priceRaw = parsed['pricePerExecution'];
|
|
412
|
+
if (priceRaw === null)
|
|
413
|
+
return { ok: false, error: 'recipe from-skills pricePerExecution must be a non-negative number' };
|
|
414
|
+
const price = priceRaw === undefined ? undefined : Number(priceRaw);
|
|
415
|
+
if (price !== undefined && (!Number.isFinite(price) || price < 0))
|
|
416
|
+
return { ok: false, error: 'recipe from-skills pricePerExecution must be a non-negative number' };
|
|
417
|
+
const baseDir = dirname(manifestPath);
|
|
418
|
+
const steps = [];
|
|
419
|
+
for (let i = 0; i < rawSteps.length; i += 1) {
|
|
420
|
+
const rawStep = rawSteps[i];
|
|
421
|
+
if (!isPlainRecord(rawStep))
|
|
422
|
+
return { ok: false, error: `recipe from-skills step ${i + 1} must be a JSON object` };
|
|
423
|
+
const skillRef = typeof rawStep['skill'] === 'string' ? rawStep['skill'].trim() : '';
|
|
424
|
+
if (!skillRef)
|
|
425
|
+
return { ok: false, error: `recipe from-skills step ${i + 1} requires skill` };
|
|
426
|
+
let skill;
|
|
427
|
+
try {
|
|
428
|
+
skill = readFileSync(resolveManifestRef(baseDir, skillRef), 'utf8');
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
return { ok: false, error: `recipe from-skills step ${i + 1} cannot read skill` };
|
|
432
|
+
}
|
|
433
|
+
const execution = loadSkillExecution(rawStep['execution'], baseDir, i + 1);
|
|
434
|
+
if (!execution.ok)
|
|
435
|
+
return execution;
|
|
436
|
+
const scenario = typeof rawStep['scenario'] === 'string' && rawStep['scenario'].trim()
|
|
437
|
+
? rawStep['scenario'].trim()
|
|
438
|
+
: undefined;
|
|
439
|
+
steps.push({
|
|
440
|
+
skill,
|
|
441
|
+
execution: execution.value,
|
|
442
|
+
...(scenario ? { scenario } : {}),
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
const description = typeof parsed['description'] === 'string' && parsed['description'].trim()
|
|
446
|
+
? parsed['description'].trim()
|
|
447
|
+
: undefined;
|
|
448
|
+
return {
|
|
449
|
+
ok: true,
|
|
450
|
+
value: {
|
|
451
|
+
title,
|
|
452
|
+
...(description ? { description } : {}),
|
|
453
|
+
...(price !== undefined ? { pricePerExecution: price } : {}),
|
|
454
|
+
steps,
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
function loadSkillExecution(raw, baseDir, stepNumber) {
|
|
459
|
+
if (typeof raw === 'string' && raw.trim()) {
|
|
460
|
+
let text;
|
|
461
|
+
try {
|
|
462
|
+
text = readFileSync(resolveManifestRef(baseDir, raw.trim()), 'utf8');
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
return { ok: false, error: `recipe from-skills step ${stepNumber} cannot read execution` };
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
const parsed = JSON.parse(text);
|
|
469
|
+
if (isPlainRecord(parsed))
|
|
470
|
+
return { ok: true, value: parsed };
|
|
471
|
+
return { ok: false, error: `recipe from-skills step ${stepNumber} execution must be a JSON object` };
|
|
472
|
+
}
|
|
473
|
+
catch {
|
|
474
|
+
return { ok: false, error: `recipe from-skills step ${stepNumber} execution must be valid JSON` };
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (isPlainRecord(raw))
|
|
478
|
+
return { ok: true, value: raw };
|
|
479
|
+
return { ok: false, error: `recipe from-skills step ${stepNumber} requires execution evidence` };
|
|
480
|
+
}
|
|
481
|
+
function resolveManifestRef(baseDir, ref) {
|
|
482
|
+
return isAbsolute(ref) ? ref : resolve(baseDir, ref);
|
|
483
|
+
}
|
|
484
|
+
function isPlainRecord(value) {
|
|
485
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
486
|
+
}
|
|
487
|
+
function recipeFromSkillsPayload(opts) {
|
|
488
|
+
return {
|
|
489
|
+
ok: opts.ok ?? true,
|
|
490
|
+
group: 'recipe.from_skills',
|
|
491
|
+
mode: opts.mode,
|
|
492
|
+
title: opts.title,
|
|
493
|
+
...(opts.recipeId ? { recipeId: opts.recipeId } : {}),
|
|
494
|
+
...(opts.error ? { error: opts.error } : {}),
|
|
495
|
+
publish: opts.publish,
|
|
496
|
+
steps: opts.steps.map((step) => ({
|
|
497
|
+
position: step.position,
|
|
498
|
+
geneId: step.geneId,
|
|
499
|
+
geneAssetId: step.geneAssetId,
|
|
500
|
+
capsuleId: step.capsuleId,
|
|
501
|
+
})),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
153
504
|
async function callRecipeWithAuthRetry(hub, tag, fn, io) {
|
|
154
505
|
try {
|
|
155
506
|
return await fn();
|
|
@@ -198,6 +549,20 @@ function parseBuildArgs(args) {
|
|
|
198
549
|
},
|
|
199
550
|
};
|
|
200
551
|
}
|
|
552
|
+
function parseFromSkillsArgs(args) {
|
|
553
|
+
const manifestPath = flagValue(args, '--manifest');
|
|
554
|
+
if (!manifestPath)
|
|
555
|
+
return { ok: false, error: 'recipe from-skills requires --manifest <file>' };
|
|
556
|
+
return {
|
|
557
|
+
ok: true,
|
|
558
|
+
value: {
|
|
559
|
+
sub: 'from-skills',
|
|
560
|
+
manifestPath,
|
|
561
|
+
publish: args.includes('--publish'),
|
|
562
|
+
jsonOut: args.includes('--json'),
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
}
|
|
201
566
|
function parseReuseArgs(args) {
|
|
202
567
|
const recipeId = flagValue(args, '--id') ?? firstPositional(args);
|
|
203
568
|
if (!recipeId)
|
|
@@ -361,10 +726,16 @@ function resolveRecipeHubCredentials(env) {
|
|
|
361
726
|
* the next recipe run (H3). Kept env-pure (no events.evomapHome()) so reset stays hermetic under an injected env.
|
|
362
727
|
*/
|
|
363
728
|
export function explicitRecipeHomes(env) {
|
|
729
|
+
// Identity-first order (#555 T2): EVOMAP_HOME is THE identity home and outranks the state root
|
|
730
|
+
// (EVOLVER_HOME). This order decides BOTH the read fall-through AND rotatePersistDir (= homes[0]),
|
|
731
|
+
// so under the evox agentDir split (EVOMAP_HOME=<agentDir>/evomap, EVOLVER_HOME=<agentDir>/evolver)
|
|
732
|
+
// a hub-rotated secret persists into the evomap dir the desktop actually reads — the old
|
|
733
|
+
// EVOLVER_HOME-first order would strand it in the state root and split-brain the node on rotation.
|
|
734
|
+
// Read-your-writes holds because read and persist share this one order; single-home setups are unchanged.
|
|
364
735
|
const explicit = [
|
|
736
|
+
env['EVOMAP_HOME'],
|
|
365
737
|
env['EVOMAP_DIR'],
|
|
366
738
|
env['EVOLVER_HOME'],
|
|
367
|
-
env['EVOMAP_HOME'],
|
|
368
739
|
];
|
|
369
740
|
return uniqueStrings(explicit.map((value) => value?.trim()).filter((value) => Boolean(value)));
|
|
370
741
|
}
|
|
@@ -559,6 +930,8 @@ function recipeUsage() {
|
|
|
559
930
|
'Recipe subcommands:',
|
|
560
931
|
' evolver recipe build --title <title> --genes <asset_id,...> [--description <text>] [--price <n>] [--publish]',
|
|
561
932
|
' Creates a draft recipe by default. --publish is explicit.',
|
|
933
|
+
' evolver recipe from-skills --manifest <file> [--publish] [--json]',
|
|
934
|
+
' Distills ordered SKILL.md steps with execution evidence, then creates a recipe.',
|
|
562
935
|
' evolver recipe reuse --id <recipe_id> [--input <json-object>] [--json]',
|
|
563
936
|
].join('\n');
|
|
564
937
|
}
|
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' | '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 {
|
|
@@ -11,9 +11,11 @@ export interface ReuseEnvelope {
|
|
|
11
11
|
reason: string;
|
|
12
12
|
message: string;
|
|
13
13
|
}
|
|
14
|
-
/** Minimal hub surface this command needs:
|
|
14
|
+
/** Minimal hub surface this command needs: a single fetch-by-id, plus an optional trust-establishing hello
|
|
15
|
+
* (PublicHubCapability satisfies both; a bare fetcher in tests may omit hello). */
|
|
15
16
|
type AssetByIdFetcher = {
|
|
16
17
|
fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
|
|
18
|
+
hello?(opts: PublicHelloOptions): Promise<unknown>;
|
|
17
19
|
};
|
|
18
20
|
export interface ReuseCliDeps {
|
|
19
21
|
store?: assetstore.AssetStoreProvider;
|