@evomap/evolver-cli 2.0.38 → 2.0.39
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/cliContracts.js +12 -6
- package/dist/recipe.d.ts +4 -1
- package/dist/recipe.js +64 -14
- package/dist/recipeConsent.d.ts +4 -0
- package/dist/recipeConsent.js +19 -0
- package/package.json +7 -7
package/dist/cliContracts.js
CHANGED
|
@@ -623,13 +623,20 @@ export async function assessPublishRecords(original, deps) {
|
|
|
623
623
|
return { ok: false, reason: 'schema_invalid', message, gates: { schema: 'fail', quality: 'fail' } };
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
+
const sourceIntegrity = original.map(hub.checkEmbeddedSourceIntegrity).find((result) => !result.ok);
|
|
627
|
+
if (sourceIntegrity && !sourceIntegrity.ok) {
|
|
628
|
+
return { ok: false, reason: 'schema_invalid', message: sourceIntegrity.reason, gates: { schema: 'fail' } };
|
|
629
|
+
}
|
|
626
630
|
let sanitized;
|
|
627
631
|
try {
|
|
628
|
-
sanitized = referenceOnly ? structuredClone(original) : sanitizePublishBundle(original);
|
|
632
|
+
sanitized = referenceOnly ? structuredClone(original) : sanitizePublishBundle(original, deps.env ?? process.env);
|
|
629
633
|
}
|
|
630
634
|
catch {
|
|
631
635
|
return { ok: false, reason: 'redaction_unavailable', message: 'redaction unavailable', gates: { redaction: 'unavailable' } };
|
|
632
636
|
}
|
|
637
|
+
if (sanitized.some((asset) => !hub.checkEmbeddedSourceIntegrity(asset).ok)) {
|
|
638
|
+
return { ok: false, reason: 'schema_invalid', message: 'embedded_source_sanitization_changed', gates: { schema: 'fail', redaction: 'fail' } };
|
|
639
|
+
}
|
|
633
640
|
const finalBundleCheck = checkBundle(sanitized);
|
|
634
641
|
if (!finalBundleCheck.ok) {
|
|
635
642
|
return { ok: false, reason: 'bundle_required', message: finalBundleCheck.message, gates: { redaction: 'pass', schema: 'pass', bundle: 'fail' } };
|
|
@@ -797,8 +804,8 @@ function checkValidationCommands(original) {
|
|
|
797
804
|
message: `validation command rejected: ${[...reasons].join(', ')}`,
|
|
798
805
|
};
|
|
799
806
|
}
|
|
800
|
-
function sanitizePublishBundle(original) {
|
|
801
|
-
const sanitized = original.map((asset) => hub.sanitizeAsset(stripPublishMetadata(asset)));
|
|
807
|
+
function sanitizePublishBundle(original, env) {
|
|
808
|
+
const sanitized = original.map((asset) => hub.sanitizeAsset(stripPublishMetadata(asset), { env }));
|
|
802
809
|
// 已绑定记录的 business-id 引用同样属于完整内容,不能在验证后改成另一种引用并重算资产。
|
|
803
810
|
// 脱敏若真正改变内容,后续 host ledger 会要求重新验证;人工无声明路径保留旧引用规范化。
|
|
804
811
|
if (hub.requiresPublishBinding(original))
|
|
@@ -1029,9 +1036,8 @@ function checkBundle(bundle) {
|
|
|
1029
1036
|
return { ok: true };
|
|
1030
1037
|
}
|
|
1031
1038
|
function finalPayloadLeakCheck(bundle, env) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
return { blocked: hardLeaks.length > 0 };
|
|
1039
|
+
// The shared scan includes assembled source files; serialized fragments can hide scan-only matches.
|
|
1040
|
+
return { blocked: hub.sanitizeBundle(bundle, { env, mode: 'strict' }).blocked };
|
|
1035
1041
|
}
|
|
1036
1042
|
async function assertNoLocalReuseIdConflict(asset, store) {
|
|
1037
1043
|
if (asset.type !== 'Gene' && asset.type !== 'Capsule')
|
package/dist/recipe.d.ts
CHANGED
|
@@ -48,7 +48,10 @@ export interface RecipeBuildOptions {
|
|
|
48
48
|
export interface RecipeReuseOptions {
|
|
49
49
|
sub: 'reuse';
|
|
50
50
|
recipeId: string;
|
|
51
|
-
inputPayload:
|
|
51
|
+
inputPayload: hubNs.RecipeJson;
|
|
52
|
+
requestKey: string;
|
|
53
|
+
maxCredits: number;
|
|
54
|
+
executionMode: 'caller' | 'provider';
|
|
52
55
|
jsonOut: boolean;
|
|
53
56
|
}
|
|
54
57
|
export interface RecipeFromSkillsOptions {
|
package/dist/recipe.js
CHANGED
|
@@ -2,9 +2,10 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, unlinkSync
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
-
import { assetstore, events, mailbox, verify, hub as hubNs } from '@evomap/evolver-core';
|
|
5
|
+
import { assetstore, events, mailbox, verify, hub as recipeExecution, hub as hubNs } from '@evomap/evolver-core';
|
|
6
|
+
import { runRecipeConsentCommand } from './recipeConsent.js';
|
|
6
7
|
import { AuthError, HubClientError, HubUnreachableError, connectPublicHub, isHubDryRunEnabled, isNodeSecret, parseNodeSecretVersion, resolveHubUrl } from '@evomap/evolver-adapter-public';
|
|
7
|
-
import { loadEnvFileFromEnv, safeReverificationRecovery } from '@evomap/evolver-mcp';
|
|
8
|
+
import { loadEnvFileFromEnv, loadEnvFileFromEnvOrThrow, safeReverificationRecovery } from '@evomap/evolver-mcp';
|
|
8
9
|
import { resolveExplicitNodeCredentials } from './identityHome.js';
|
|
9
10
|
import { getCliVersion } from './version.js';
|
|
10
11
|
import { parseSkillMd, reverseDistill, synthesizeGene } from './skill2gep.js';
|
|
@@ -40,13 +41,25 @@ export async function runRecipeCommand(argv, deps = {}) {
|
|
|
40
41
|
const parsed = parseRecipeArgs(argv);
|
|
41
42
|
const err = deps.err ?? ((line) => { process.stderr.write(`${line}\n`); });
|
|
42
43
|
const log = deps.log ?? ((line) => { process.stdout.write(`${line}\n`); });
|
|
44
|
+
if (argv[0] === 'consent') {
|
|
45
|
+
try {
|
|
46
|
+
return runRecipeConsentCommand(argv.slice(1), deps.env ?? process.env, { log });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
err(recipeErrorMessage(error));
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
43
53
|
if (!parsed.ok) {
|
|
44
54
|
err(`${parsed.error}\n${recipeUsage()}`);
|
|
45
55
|
return 1;
|
|
46
56
|
}
|
|
47
57
|
try {
|
|
48
58
|
const env = deps.env ?? process.env;
|
|
49
|
-
|
|
59
|
+
if (parsed.value.sub === 'reuse')
|
|
60
|
+
loadEnvFileFromEnvOrThrow(env);
|
|
61
|
+
else
|
|
62
|
+
loadEnvFileFromEnv(env);
|
|
50
63
|
if (isHubDryRunEnabled(env)) {
|
|
51
64
|
if (parsed.value.sub === 'build')
|
|
52
65
|
return await runRecipeBuildDryRun(parsed.value, deps.store, { log, err });
|
|
@@ -56,6 +69,9 @@ export async function runRecipeCommand(argv, deps = {}) {
|
|
|
56
69
|
return runRecipeSearchDryRun(parsed.value, { log });
|
|
57
70
|
return runRecipeReuseDryRun(parsed.value, { log });
|
|
58
71
|
}
|
|
72
|
+
const governance = new recipeExecution.RecipeExecutionGovernance(recipeExecution.recipeStateDirectory(env));
|
|
73
|
+
if (parsed.value.sub === 'reuse')
|
|
74
|
+
governance.assertSpendAllowed(parsed.value.maxCredits);
|
|
59
75
|
const hub = deps.hub ?? createRecipeHubFromEnv(env, deps.connectHub ?? connectPublicHub);
|
|
60
76
|
await recipeIdentityBootstraps.get(hub)?.();
|
|
61
77
|
if (!hub.recipes) {
|
|
@@ -68,7 +84,7 @@ export async function runRecipeCommand(argv, deps = {}) {
|
|
|
68
84
|
return await runRecipeFromSkills(parsed.value, hub, deps, { log, err }, false);
|
|
69
85
|
if (parsed.value.sub === 'search')
|
|
70
86
|
return await runRecipeSearch(parsed.value, hub, { log, err });
|
|
71
|
-
return await runRecipeReuse(parsed.value, hub, { log, err });
|
|
87
|
+
return await runRecipeReuse(parsed.value, hub, { log, err }, governance);
|
|
72
88
|
}
|
|
73
89
|
catch (e) {
|
|
74
90
|
err(recipeErrorMessage(e));
|
|
@@ -488,12 +504,12 @@ async function runRecipeFromSkills(opts, hub, deps, io, dryRun) {
|
|
|
488
504
|
}
|
|
489
505
|
return 0;
|
|
490
506
|
}
|
|
491
|
-
async function runRecipeReuse(opts, hub, io) {
|
|
492
|
-
|
|
493
|
-
const receipt = await
|
|
494
|
-
io.log(`[recipe reuse]
|
|
507
|
+
async function runRecipeReuse(opts, hub, io, governance) {
|
|
508
|
+
const { sub: _sub, jsonOut: _jsonOut, ...input } = opts;
|
|
509
|
+
const receipt = await governance.invoke(hub.recipes?.execution, 'express', input);
|
|
510
|
+
io.log(`[recipe reuse] Accepted run ${terminalSafeText(receipt.organism.id)}; not completed. Preserve request key ${terminalSafeText(opts.requestKey)} for retries. Use private lifecycle tools for authorized host execution.`);
|
|
495
511
|
if (opts.jsonOut)
|
|
496
|
-
io.log(terminalSafeJson(receipt
|
|
512
|
+
io.log(terminalSafeJson(receipt, 2));
|
|
497
513
|
return 0;
|
|
498
514
|
}
|
|
499
515
|
async function recipeStepsFromLocalAssets(assetIds, store) {
|
|
@@ -1050,7 +1066,32 @@ function parseSearchArgs(args) {
|
|
|
1050
1066
|
};
|
|
1051
1067
|
}
|
|
1052
1068
|
function parseReuseArgs(args) {
|
|
1053
|
-
const
|
|
1069
|
+
const allowed = new Set(['--id', '--input', '--request-key', '--max-credits', '--execution-mode', '--json']);
|
|
1070
|
+
const seen = new Set();
|
|
1071
|
+
const positional = [];
|
|
1072
|
+
for (let index = 0; index < args.length; index++) {
|
|
1073
|
+
const token = args[index];
|
|
1074
|
+
if (!token.startsWith('--')) {
|
|
1075
|
+
positional.push(token);
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
const name = token.split('=')[0];
|
|
1079
|
+
if (!allowed.has(name) || seen.has(name))
|
|
1080
|
+
return { ok: false, error: `unknown or duplicate recipe reuse option: ${name}` };
|
|
1081
|
+
seen.add(name);
|
|
1082
|
+
if (name === '--json') {
|
|
1083
|
+
if (token.includes('='))
|
|
1084
|
+
return { ok: false, error: '--json does not accept a value' };
|
|
1085
|
+
}
|
|
1086
|
+
else if (!token.includes('=')) {
|
|
1087
|
+
if (!args[index + 1] || args[index + 1].startsWith('--'))
|
|
1088
|
+
return { ok: false, error: `${name} requires a value` };
|
|
1089
|
+
index++;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
if (positional.length > 1 || (positional.length && seen.has('--id')))
|
|
1093
|
+
return { ok: false, error: 'recipe reuse accepts exactly one recipe id' };
|
|
1094
|
+
const recipeId = flagValue(args, '--id') ?? positional[0];
|
|
1054
1095
|
if (!recipeId)
|
|
1055
1096
|
return { ok: false, error: 'recipe reuse requires --id <recipe_id>' };
|
|
1056
1097
|
if (recipeId.length > MAX_ID_LENGTH)
|
|
@@ -1059,7 +1100,19 @@ function parseReuseArgs(args) {
|
|
|
1059
1100
|
const input = inputRaw === null ? { ok: true, value: {} } : parseJsonObject(inputRaw);
|
|
1060
1101
|
if (!input.ok)
|
|
1061
1102
|
return input;
|
|
1062
|
-
|
|
1103
|
+
const maxCredits = flagValue(args, '--max-credits');
|
|
1104
|
+
try {
|
|
1105
|
+
const execution = recipeExecution.parseRecipeExecutionInput('express', {
|
|
1106
|
+
recipeId, inputPayload: input.value,
|
|
1107
|
+
requestKey: flagValue(args, '--request-key') ?? undefined,
|
|
1108
|
+
maxCredits: maxCredits === null || !maxCredits.trim() ? undefined : Number(maxCredits),
|
|
1109
|
+
executionMode: flagValue(args, '--execution-mode') ?? undefined,
|
|
1110
|
+
});
|
|
1111
|
+
return { ok: true, value: { sub: 'reuse', ...execution, inputPayload: execution.inputPayload ?? {}, jsonOut: args.includes('--json') } };
|
|
1112
|
+
}
|
|
1113
|
+
catch (error) {
|
|
1114
|
+
return { ok: false, error: `${recipeErrorMessage(error)}; reuse requires --request-key <stable-intent-key> --max-credits <ceiling> --execution-mode caller|provider` };
|
|
1115
|
+
}
|
|
1063
1116
|
}
|
|
1064
1117
|
function splitIds(raw) {
|
|
1065
1118
|
return raw.split(',').map((s) => s.trim()).filter(Boolean).filter((s) => s.length <= MAX_ID_LENGTH);
|
|
@@ -1078,9 +1131,6 @@ function flagValue(args, flag) {
|
|
|
1078
1131
|
}
|
|
1079
1132
|
return null;
|
|
1080
1133
|
}
|
|
1081
|
-
function firstPositional(args) {
|
|
1082
|
-
return args.find((a) => typeof a === 'string' && !a.startsWith('--')) ?? null;
|
|
1083
|
-
}
|
|
1084
1134
|
function firstSearchPositional(args) {
|
|
1085
1135
|
for (let i = 0; i < args.length; i += 1) {
|
|
1086
1136
|
const token = args[i];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { hub } from '@evomap/evolver-core';
|
|
2
|
+
import { loadEnvFileFromEnvOrThrow } from '@evomap/evolver-mcp';
|
|
3
|
+
export function runRecipeConsentCommand(args, env, io) {
|
|
4
|
+
loadEnvFileFromEnvOrThrow(env);
|
|
5
|
+
const directory = hub.recipeStateDirectory(env);
|
|
6
|
+
if (args.length === 0 || (args.length === 1 && args[0] === '--status')) {
|
|
7
|
+
io.log(JSON.stringify(hub.readRecipeSpendConsent(directory) ?? { version: 1, enabled: false, maxCredits: 0 }));
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
if (args.length === 1 && args[0] === '--disable') {
|
|
11
|
+
io.log(JSON.stringify(hub.setRecipeSpendConsent(false, 0, directory)));
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
if (args.length !== 4 || args[0] !== '--enable' || args[1] !== '--max-credits' || args[3] !== '--acknowledge-paid-recipe-charges' || !args[2]?.trim()) {
|
|
15
|
+
throw new Error('recipe consent: --status | --disable | --enable --max-credits <ceiling> --acknowledge-paid-recipe-charges. Only the user may opt in; ATP consent is separate.');
|
|
16
|
+
}
|
|
17
|
+
io.log(JSON.stringify(hub.setRecipeSpendConsent(true, Number(args[2]), directory)));
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evomap/evolver-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.39",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@evomap/evolver-core": "2.0.
|
|
27
|
-
"@evomap/evolver-adapter-public": "2.0.
|
|
28
|
-
"@evomap/evolver-mcp": "2.0.
|
|
29
|
-
"@evomap/evolver-proxy": "2.0.
|
|
30
|
-
"@evomap/evolver-runtime-adapters": "2.0.
|
|
31
|
-
"@evomap/evolver-webui": "2.0.
|
|
26
|
+
"@evomap/evolver-core": "2.0.39",
|
|
27
|
+
"@evomap/evolver-adapter-public": "2.0.39",
|
|
28
|
+
"@evomap/evolver-mcp": "2.0.39",
|
|
29
|
+
"@evomap/evolver-proxy": "2.0.39",
|
|
30
|
+
"@evomap/evolver-runtime-adapters": "2.0.39",
|
|
31
|
+
"@evomap/evolver-webui": "2.0.39"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|