@evomap/evolver-cli 2.0.0-beta.0 → 2.0.0-beta.10
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 +105 -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 +19 -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 +74 -6
- 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/version.js +2 -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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { assetstore, events, hub } from '@evomap/evolver-core';
|
|
2
|
+
import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
3
|
+
const GROUP = 'asset-trust';
|
|
4
|
+
const DEFAULT_LIMIT = 50;
|
|
5
|
+
const MAX_LIMIT = 200;
|
|
6
|
+
const MAX_REASON_INPUT = 1_000;
|
|
7
|
+
const MAX_REASON = 240;
|
|
8
|
+
const ASSET_ID_RE = /^sha256:[a-f0-9]{64}$/;
|
|
9
|
+
const ACTOR_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_.@:-]{0,79}$/;
|
|
10
|
+
const USAGE = [
|
|
11
|
+
'Usage:',
|
|
12
|
+
' evolver asset-trust list [--limit N] [--json]',
|
|
13
|
+
' evolver asset-trust show <asset_id> [--json]',
|
|
14
|
+
' evolver asset-trust promote <asset_id> --reason <text> [--json]',
|
|
15
|
+
' evolver asset-trust revoke <asset_id> --reason <text> [--json]',
|
|
16
|
+
'',
|
|
17
|
+
].join('\n');
|
|
18
|
+
function parseArgs(argv) {
|
|
19
|
+
const action = argv[0];
|
|
20
|
+
if (action !== 'list' && action !== 'show' && action !== 'promote' && action !== 'revoke')
|
|
21
|
+
return 'invalid_action';
|
|
22
|
+
let assetId;
|
|
23
|
+
let reason;
|
|
24
|
+
let limit = DEFAULT_LIMIT;
|
|
25
|
+
let json = false;
|
|
26
|
+
let index = 1;
|
|
27
|
+
if (action !== 'list') {
|
|
28
|
+
assetId = argv[index];
|
|
29
|
+
index += 1;
|
|
30
|
+
if (!assetId || !ASSET_ID_RE.test(assetId))
|
|
31
|
+
return 'invalid_asset_id';
|
|
32
|
+
}
|
|
33
|
+
while (index < argv.length) {
|
|
34
|
+
const arg = argv[index];
|
|
35
|
+
if (arg === '--json') {
|
|
36
|
+
json = true;
|
|
37
|
+
index += 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (arg === '--reason' && (action === 'promote' || action === 'revoke')) {
|
|
41
|
+
const value = argv[index + 1];
|
|
42
|
+
if (!value || value.startsWith('--'))
|
|
43
|
+
return 'reason_required';
|
|
44
|
+
reason = value;
|
|
45
|
+
index += 2;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (arg === '--limit' && action === 'list') {
|
|
49
|
+
const value = argv[index + 1];
|
|
50
|
+
if (!value || !/^\d+$/.test(value))
|
|
51
|
+
return 'invalid_limit';
|
|
52
|
+
limit = Math.min(MAX_LIMIT, Math.max(1, Number(value)));
|
|
53
|
+
index += 2;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
return 'unknown_argument';
|
|
57
|
+
}
|
|
58
|
+
if ((action === 'promote' || action === 'revoke') && !reason)
|
|
59
|
+
return 'reason_required';
|
|
60
|
+
return { action, ...(assetId ? { assetId } : {}), ...(reason ? { reason } : {}), limit, json };
|
|
61
|
+
}
|
|
62
|
+
function safeActorId(env) {
|
|
63
|
+
const raw = env['EVOLVER_ACTOR_ID'] ?? env['USER'] ?? env['LOGNAME'] ?? env['USERNAME'] ?? 'cli';
|
|
64
|
+
const trimmed = raw.trim();
|
|
65
|
+
return ACTOR_ID_RE.test(trimmed) && hub.redactString(trimmed) === trimmed ? trimmed : 'cli';
|
|
66
|
+
}
|
|
67
|
+
function safeReason(raw, env) {
|
|
68
|
+
if (raw.length > MAX_REASON_INPUT)
|
|
69
|
+
return null;
|
|
70
|
+
const redacted = hub.redactString(raw).replace(/\s+/g, ' ').trim().slice(0, MAX_REASON);
|
|
71
|
+
if (!redacted || hub.fullLeakCheck(redacted, env).found)
|
|
72
|
+
return null;
|
|
73
|
+
return redacted;
|
|
74
|
+
}
|
|
75
|
+
function safeOutputText(value, env, max = MAX_REASON) {
|
|
76
|
+
if (!value)
|
|
77
|
+
return undefined;
|
|
78
|
+
const redacted = hub.redactString(value).replace(/\s+/g, ' ').trim().slice(0, max);
|
|
79
|
+
return redacted && !hub.fullLeakCheck(redacted, env).found ? redacted : '[redacted]';
|
|
80
|
+
}
|
|
81
|
+
function safeActorOutput(value) {
|
|
82
|
+
if (!value)
|
|
83
|
+
return undefined;
|
|
84
|
+
const trimmed = value.trim();
|
|
85
|
+
return ACTOR_ID_RE.test(trimmed) && hub.redactString(trimmed) === trimmed ? trimmed : '[redacted]';
|
|
86
|
+
}
|
|
87
|
+
function viewFor(asset, record, env) {
|
|
88
|
+
const logicalId = typeof asset['id'] === 'string' && asset['id'].trim() ? asset['id'].trim() : undefined;
|
|
89
|
+
const decidedBy = safeActorOutput(record?.decidedBy ?? record?.promotedBy);
|
|
90
|
+
const reason = safeOutputText(record?.reason, env);
|
|
91
|
+
return {
|
|
92
|
+
assetId: asset.asset_id,
|
|
93
|
+
type: asset.type,
|
|
94
|
+
...(logicalId ? { logicalId: safeOutputText(logicalId, env, 120) } : {}),
|
|
95
|
+
source: record?.source ?? 'local_default',
|
|
96
|
+
trusted: record?.trusted ?? true,
|
|
97
|
+
...(record?.at ? { at: record.at } : {}),
|
|
98
|
+
...(record?.decision ? { decision: record.decision } : {}),
|
|
99
|
+
...(decidedBy ? { decidedBy } : {}),
|
|
100
|
+
...(reason ? { reason } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function storeBaseDir(store, deps) {
|
|
104
|
+
if (deps.assetsDir)
|
|
105
|
+
return deps.assetsDir;
|
|
106
|
+
return store instanceof assetstore.LocalJsonlProvider ? store.baseDir : events.assetsDir();
|
|
107
|
+
}
|
|
108
|
+
function writeJson(write, value) {
|
|
109
|
+
write(`${JSON.stringify(value)}\n`);
|
|
110
|
+
}
|
|
111
|
+
function parseFailure(reason, json, stdout, stderr) {
|
|
112
|
+
if (json)
|
|
113
|
+
writeJson(stdout, { ok: false, group: GROUP, reason });
|
|
114
|
+
else
|
|
115
|
+
stderr(`[asset-trust] ${reason}\n${USAGE}`);
|
|
116
|
+
return 2;
|
|
117
|
+
}
|
|
118
|
+
function renderView(view) {
|
|
119
|
+
return `${view.type} ${view.assetId} source=${view.source} trusted=${view.trusted}${view.logicalId ? ` id=${view.logicalId}` : ''}`;
|
|
120
|
+
}
|
|
121
|
+
async function recordTrustEvent(ingestor, action, view, reason, actorId) {
|
|
122
|
+
try {
|
|
123
|
+
await ingestor.ingest({
|
|
124
|
+
type: action === 'promote' ? 'actor.human.trust.promote' : 'actor.human.trust.revoke',
|
|
125
|
+
payload: { assetId: view.assetId, assetType: view.type, source: view.source, reason },
|
|
126
|
+
human: { title: `${action} ${view.type} ${view.assetId.slice(0, 19)}`, severity: 'notice' },
|
|
127
|
+
actor: { kind: 'human', id: actorId },
|
|
128
|
+
});
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export async function runAssetTrustCommand(argv, deps = {}) {
|
|
136
|
+
const stdout = deps.stdout ?? ((text) => { process.stdout.write(text); });
|
|
137
|
+
const stderr = deps.stderr ?? ((text) => { process.stderr.write(text); });
|
|
138
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
139
|
+
stdout(USAGE);
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
const json = argv.includes('--json');
|
|
143
|
+
const parsed = parseArgs(argv);
|
|
144
|
+
if (typeof parsed === 'string')
|
|
145
|
+
return parseFailure(parsed, json, stdout, stderr);
|
|
146
|
+
const env = deps.env ?? process.env;
|
|
147
|
+
const envFile = loadEnvFileFromEnv(env);
|
|
148
|
+
if (envFile.error)
|
|
149
|
+
return parseFailure('env_file_unavailable', parsed.json, stdout, stderr);
|
|
150
|
+
const store = deps.store ?? new assetstore.LocalJsonlProvider(deps.assetsDir ?? events.assetsDir());
|
|
151
|
+
const provenance = deps.provenance ?? new assetstore.ProvenanceStore(storeBaseDir(store, deps));
|
|
152
|
+
if (parsed.action === 'list') {
|
|
153
|
+
const snapshot = provenance.snapshot();
|
|
154
|
+
const allAssets = (await store.list(undefined, Number.MAX_SAFE_INTEGER))
|
|
155
|
+
.map((asset) => viewFor(asset, snapshot.get(asset.asset_id) ?? null, env))
|
|
156
|
+
.sort((left, right) => Number(left.trusted) - Number(right.trusted)
|
|
157
|
+
|| left.assetId.localeCompare(right.assetId));
|
|
158
|
+
const assets = allAssets.slice(0, parsed.limit);
|
|
159
|
+
const counts = {
|
|
160
|
+
total: allAssets.length,
|
|
161
|
+
trusted: allAssets.filter((asset) => asset.trusted).length,
|
|
162
|
+
untrusted: allAssets.filter((asset) => !asset.trusted).length,
|
|
163
|
+
returned: assets.length,
|
|
164
|
+
};
|
|
165
|
+
const truncated = assets.length < allAssets.length;
|
|
166
|
+
const result = { ok: true, group: GROUP, mode: 'list', counts, truncated, assets };
|
|
167
|
+
if (parsed.json)
|
|
168
|
+
writeJson(stdout, result);
|
|
169
|
+
else {
|
|
170
|
+
stdout(`asset trust: total=${counts.total} trusted=${counts.trusted} untrusted=${counts.untrusted} returned=${counts.returned} truncated=${truncated}\n`);
|
|
171
|
+
for (const asset of assets)
|
|
172
|
+
stdout(`${renderView(asset)}\n`);
|
|
173
|
+
}
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
const asset = await store.get(parsed.assetId);
|
|
177
|
+
if (!asset) {
|
|
178
|
+
if (parsed.json)
|
|
179
|
+
writeJson(stdout, { ok: false, group: GROUP, reason: 'asset_not_found' });
|
|
180
|
+
else
|
|
181
|
+
stderr('[asset-trust] asset_not_found\n');
|
|
182
|
+
return 1;
|
|
183
|
+
}
|
|
184
|
+
if (parsed.action === 'show') {
|
|
185
|
+
const result = { ok: true, group: GROUP, mode: 'show', asset: viewFor(asset, provenance.get(asset.asset_id), env) };
|
|
186
|
+
if (parsed.json)
|
|
187
|
+
writeJson(stdout, result);
|
|
188
|
+
else
|
|
189
|
+
stdout(`${renderView(result.asset)}\n`);
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
const reason = safeReason(parsed.reason, env);
|
|
193
|
+
if (!reason)
|
|
194
|
+
return parseFailure('unsafe_reason', parsed.json, stdout, stderr);
|
|
195
|
+
const actorId = safeActorId(env);
|
|
196
|
+
const desiredTrust = parsed.action === 'promote';
|
|
197
|
+
const change = provenance.changeTrust(asset.asset_id, desiredTrust, actorId, reason);
|
|
198
|
+
const view = viewFor(asset, change.record, env);
|
|
199
|
+
const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
|
|
200
|
+
const auditEventRecorded = change.changed
|
|
201
|
+
? await recordTrustEvent(ingestor, parsed.action, view, reason, actorId)
|
|
202
|
+
: false;
|
|
203
|
+
if (change.changed && !auditEventRecorded)
|
|
204
|
+
stderr('[asset-trust] trust decision saved; root event unavailable\n');
|
|
205
|
+
const result = {
|
|
206
|
+
ok: true,
|
|
207
|
+
group: GROUP,
|
|
208
|
+
mode: parsed.action,
|
|
209
|
+
changed: change.changed,
|
|
210
|
+
auditEventRecorded,
|
|
211
|
+
asset: view,
|
|
212
|
+
};
|
|
213
|
+
if (parsed.json)
|
|
214
|
+
writeJson(stdout, result);
|
|
215
|
+
else
|
|
216
|
+
stdout(`${change.changed ? 'updated' : 'unchanged'} ${renderView(view)}\n`);
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
package/dist/atp.js
CHANGED
|
@@ -2,7 +2,8 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from '
|
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { events, mailbox } from '@evomap/evolver-core';
|
|
5
|
-
import {
|
|
5
|
+
import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
6
|
+
import { AtpHubClient, ATP_PROOF_STATUSES, ATP_ROLES, ATP_ROUTING_MODES, ATP_VERIFY_ACTIONS, ATP_VERIFY_MODES, connectPublicHub, globalFetchLike, resolveHubUrl, } from '@evomap/evolver-adapter-public';
|
|
6
7
|
export function parseBuyArgs(args) {
|
|
7
8
|
if (args.length === 0)
|
|
8
9
|
return { ok: false, error: 'buy requires <capabilities>: comma-separated list (e.g. code_review,bug_fix)' };
|
|
@@ -226,7 +227,8 @@ export async function runAtpCommand(argv) {
|
|
|
226
227
|
return (await runAtp(parsed.opts)).exitCode;
|
|
227
228
|
}
|
|
228
229
|
export function createAtpClientFromEnv(env = process.env) {
|
|
229
|
-
|
|
230
|
+
loadEnvFileFromEnv(env);
|
|
231
|
+
const hubUrl = resolveHubUrl(env);
|
|
230
232
|
const evomapDir = resolveAtpHome(env);
|
|
231
233
|
const resolvedSenderId = resolveAtpSenderId(env);
|
|
232
234
|
const senderId = () => resolvedSenderId;
|
package/dist/autoDistillLlm.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface LlmDistillRunnerResult {
|
|
|
30
30
|
exitCode: number | null;
|
|
31
31
|
stdout: string;
|
|
32
32
|
stderr?: string;
|
|
33
|
+
stdoutTruncated?: boolean;
|
|
33
34
|
}
|
|
34
35
|
export type LlmDistillRunner = (prompt: string, ctx: {
|
|
35
36
|
cwd: string;
|
|
@@ -80,6 +81,11 @@ export declare function runClaudeDistill(prompt: string, ctx: {
|
|
|
80
81
|
* `--output-last-message <file>`: capture ONLY the final assistant message (the gene JSON), avoiding codex's stdout
|
|
81
82
|
* preamble/token-count noise. Prompt arrives via stdin (the trailing `-`). Verified live against codex-cli 0.137.0. */
|
|
82
83
|
export declare function codexDistillArgs(cwd: string, lastMessageFile: string, model?: string): string[];
|
|
84
|
+
/** Read Codex's final-message file without allowing that subprocess-owned file to bypass output bounds. */
|
|
85
|
+
export declare function readBoundedDistillOutputFile(path: string, maxBytes?: number): {
|
|
86
|
+
text: string;
|
|
87
|
+
truncated: boolean;
|
|
88
|
+
};
|
|
83
89
|
/** Distill a prompt with `codex exec` (read-only). Reads the clean final message from --output-last-message so
|
|
84
90
|
* parseDistillOutput sees a bare gene JSON; falls back to raw stdout (pickGeneObject scans it) if the file is absent.
|
|
85
91
|
* Windows: codex is a `.cmd` npm shim, so route through resolveSpawnCommand (shell-free). */
|
package/dist/autoDistillLlm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
5
|
import { algo, assetstore, events, exec, hub, verify } from '@evomap/evolver-core';
|
|
@@ -259,7 +259,7 @@ export function asGeneCandidate(value) {
|
|
|
259
259
|
...(isRecord(value['constraints']) ? {
|
|
260
260
|
constraints: {
|
|
261
261
|
...(typeof value['constraints']['max_files'] === 'number' ? { max_files: value['constraints']['max_files'] } : {}),
|
|
262
|
-
// Only carry a NON-EMPTY
|
|
262
|
+
// Only carry a NON-EMPTY forbiddenPaths through. intakeGene defaults the field with `?? DEFAULT`,
|
|
263
263
|
// and nullish-coalescing does NOT replace an empty array — so an LLM-supplied `[]` would drop the
|
|
264
264
|
// default `.git`/`node_modules` guard on an autonomously-stored gene. Omit it so the default kicks in. (V1 parity.)
|
|
265
265
|
...(Array.isArray(value['constraints']['forbidden_paths']) && value['constraints']['forbidden_paths'].length > 0
|
|
@@ -267,6 +267,9 @@ export function asGeneCandidate(value) {
|
|
|
267
267
|
},
|
|
268
268
|
} : {}),
|
|
269
269
|
...(Array.isArray(value['validation']) ? { validation: value['validation'].map(String) } : {}),
|
|
270
|
+
// An LLM-distilled gene is distilled from prior capsule/session evidence (not a verified fail→pass trajectory,
|
|
271
|
+
// not a human-taught gene) → `distilled` per V1 #302 classifyProvenance. intakeGene normalizes + validates it.
|
|
272
|
+
generation_meta: { source: 'distilled' },
|
|
270
273
|
};
|
|
271
274
|
}
|
|
272
275
|
export function jaccardDuplicate(candidate, existing, threshold = DEFAULT_DUP_JACCARD) {
|
|
@@ -335,7 +338,7 @@ export async function runClaudeDistill(prompt, ctx) {
|
|
|
335
338
|
const env = exec.scrubAgentEnv(ctx.env, { allowPrefixes: exec.getRunnerSpec('claude').envAllow.prefixes });
|
|
336
339
|
try {
|
|
337
340
|
const r = await exec.spawnCapture('claude', args, { cwd: ctx.cwd, timeoutMs: ctx.timeoutMs, input: prompt, env });
|
|
338
|
-
return { exitCode: r.code, stdout: r.stdout, stderr: r.stderr };
|
|
341
|
+
return { exitCode: r.code, stdout: r.stdout, stderr: r.stderr, stdoutTruncated: r.stdoutTruncated };
|
|
339
342
|
}
|
|
340
343
|
catch (e) {
|
|
341
344
|
return { exitCode: null, stdout: '', stderr: e instanceof Error ? e.message : String(e) };
|
|
@@ -353,6 +356,30 @@ export function codexDistillArgs(cwd, lastMessageFile, model) {
|
|
|
353
356
|
args.push('-');
|
|
354
357
|
return args;
|
|
355
358
|
}
|
|
359
|
+
/** Read Codex's final-message file without allowing that subprocess-owned file to bypass output bounds. */
|
|
360
|
+
export function readBoundedDistillOutputFile(path, maxBytes = exec.DEFAULT_MAX_CAPTURE_BYTES) {
|
|
361
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 256)
|
|
362
|
+
throw new RangeError('maxBytes must be an integer >= 256');
|
|
363
|
+
const fd = openSync(path, 'r');
|
|
364
|
+
try {
|
|
365
|
+
const buffer = Buffer.allocUnsafe(maxBytes + 1);
|
|
366
|
+
let offset = 0;
|
|
367
|
+
while (offset < buffer.length) {
|
|
368
|
+
const read = readSync(fd, buffer, offset, buffer.length - offset, null);
|
|
369
|
+
if (read === 0)
|
|
370
|
+
break;
|
|
371
|
+
offset += read;
|
|
372
|
+
}
|
|
373
|
+
const truncated = offset > maxBytes;
|
|
374
|
+
return {
|
|
375
|
+
text: truncated ? '' : buffer.subarray(0, offset).toString('utf8').trim(),
|
|
376
|
+
truncated,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
closeSync(fd);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
356
383
|
/** Distill a prompt with `codex exec` (read-only). Reads the clean final message from --output-last-message so
|
|
357
384
|
* parseDistillOutput sees a bare gene JSON; falls back to raw stdout (pickGeneObject scans it) if the file is absent.
|
|
358
385
|
* Windows: codex is a `.cmd` npm shim, so route through resolveSpawnCommand (shell-free). */
|
|
@@ -364,13 +391,20 @@ export async function runCodexDistill(prompt, ctx) {
|
|
|
364
391
|
try {
|
|
365
392
|
const r = await exec.spawnCapture(resolved.cmd, resolved.args, { cwd: ctx.cwd, timeoutMs: ctx.timeoutMs, input: prompt, env });
|
|
366
393
|
let stdout = r.stdout;
|
|
394
|
+
let stdoutTruncated = r.stdoutTruncated;
|
|
367
395
|
try {
|
|
368
|
-
const last =
|
|
369
|
-
if (last)
|
|
370
|
-
stdout =
|
|
396
|
+
const last = readBoundedDistillOutputFile(lastMessageFile);
|
|
397
|
+
if (last.truncated) {
|
|
398
|
+
stdout = '';
|
|
399
|
+
stdoutTruncated = true;
|
|
400
|
+
}
|
|
401
|
+
else if (last.text) {
|
|
402
|
+
stdout = last.text;
|
|
403
|
+
stdoutTruncated = false;
|
|
404
|
+
}
|
|
371
405
|
}
|
|
372
406
|
catch { /* file absent (codex failed early) → keep raw stdout for pickGeneObject */ }
|
|
373
|
-
return { exitCode: r.code, stdout, stderr: r.stderr };
|
|
407
|
+
return { exitCode: r.code, stdout, stderr: r.stderr, stdoutTruncated };
|
|
374
408
|
}
|
|
375
409
|
catch (e) {
|
|
376
410
|
return { exitCode: null, stdout: '', stderr: e instanceof Error ? e.message : String(e) };
|
|
@@ -464,6 +498,9 @@ export async function autoDistillLlm(options) {
|
|
|
464
498
|
// permanently exhaust this data hash after MAX_ATTEMPTS — the exact silent stall this exemption prevents.
|
|
465
499
|
return { ok: false, mode, reason: llm.exitCode === null ? 'claude_spawn_error' : 'claude_nonzero_exit', dataHash: input.dataHash };
|
|
466
500
|
}
|
|
501
|
+
if (llm.stdoutTruncated) {
|
|
502
|
+
return { ok: false, mode, reason: 'llm_output_truncated', dataHash: input.dataHash };
|
|
503
|
+
}
|
|
467
504
|
const raw = parseDistillOutput(llm.stdout);
|
|
468
505
|
const candidate0 = asGeneCandidate(raw);
|
|
469
506
|
if (!candidate0) {
|
package/dist/autoexec.d.ts
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import { events, assetstore, algo, exec, hooks, material as materialNs, verify, hub as hubNs } from '@evomap/evolver-core';
|
|
1
|
+
import { events, assetstore, algo, exec, hooks, material as materialNs, util, verify, hub as hubNs } from '@evomap/evolver-core';
|
|
2
2
|
import { type Beat } from './daemonLoop.js';
|
|
3
3
|
import { connectPublicHub, ReuseCache } from '@evomap/evolver-adapter-public';
|
|
4
|
-
import type { FetchLike, OfflinePermitStore, OutcomeReport, OutcomeReceipt } from '@evomap/evolver-adapter-public';
|
|
4
|
+
import type { FetchLike, MemoryGraphEventReceipt, MemoryGraphEventReport, OfflinePermitStore, OutcomeReport, OutcomeReceipt } from '@evomap/evolver-adapter-public';
|
|
5
5
|
import { type EvolverProxyClient } from '@evomap/evolver-mcp';
|
|
6
|
+
import { type MemoryEventMirrorWiring } from './memoryEventMirror.js';
|
|
6
7
|
import { resolveDistillObserver } from './distillObserver.js';
|
|
7
8
|
import { type AutoDistillLlmResult, type LlmDistillRunner } from './autoDistillLlm.js';
|
|
8
9
|
import { type AutoDistillAntiGeneMode, type AutoDistillAntiGeneResult } from './autoDistillAntiGene.js';
|
|
9
10
|
import { type AutoDistillTranscriptMode, type TranscriptDistillTickResult } from './autoDistillTranscript.js';
|
|
10
11
|
import { type SessionIngestTickResult } from './index.js';
|
|
12
|
+
export { readAutoExecConfig, type AutoExecConfig } from './autoexecConfig.js';
|
|
11
13
|
export interface AutoExecDirs {
|
|
12
14
|
base: string;
|
|
13
15
|
tasks: string;
|
|
14
16
|
done: string;
|
|
15
17
|
refused: string;
|
|
16
18
|
}
|
|
17
|
-
export interface AutoExecConfig {
|
|
18
|
-
allowedRoots: string[];
|
|
19
|
-
pollMs: number;
|
|
20
|
-
timeoutMs: number;
|
|
21
|
-
runner: 'claude' | 'codex' | 'cursor';
|
|
22
|
-
}
|
|
23
19
|
/** Create the queue layout under <home>/autoexec/{tasks,done,refused}. */
|
|
24
20
|
export declare function ensureAutoExecDirs(base: string): AutoExecDirs;
|
|
25
|
-
/** Read <base>/config.json; deny-by-default (empty allowedRoots) when absent. Default runner 'claude' (#66). */
|
|
26
|
-
export declare function readAutoExecConfig(base: string): AutoExecConfig;
|
|
27
21
|
export declare function summarizeSandboxedValidation(result: verify.SandboxedValidationResult): string | null;
|
|
28
22
|
/**
|
|
29
23
|
* One queue pass: drain every tasks/*.json through `runOne`, route the verdict to done/ (success or failure)
|
|
@@ -62,6 +56,7 @@ export declare function makeInjectEmitter(ingestor?: events.Ingestor): {
|
|
|
62
56
|
/** A hub the link can report outcomes to. Structural (not the concrete class) so tests can fake it. */
|
|
63
57
|
export type OutcomeReportingHub = hubNs.HubCapability & {
|
|
64
58
|
recordOutcome(report: OutcomeReport): Promise<OutcomeReceipt>;
|
|
59
|
+
recordMemoryEvent?(report: MemoryGraphEventReport): Promise<MemoryGraphEventReceipt>;
|
|
65
60
|
recordReuseResult?(report: hubNs.ReuseResultReport): Promise<hubNs.ReuseResultReceipt>;
|
|
66
61
|
};
|
|
67
62
|
/** The composed hub wiring: the reuse seam plus the matching outcome reporter that closes the loop. */
|
|
@@ -111,6 +106,13 @@ export declare function verdictToOutcomeStatus(status: exec.AutoExecVerdict['sta
|
|
|
111
106
|
export declare function questionGeneratorStatePath(home?: string): string;
|
|
112
107
|
export declare function makeHubQuestionLink(cap: hubNs.HubCapability, options?: HubQuestionLinkOptions): HubQuestionLink;
|
|
113
108
|
export declare function shouldSubmitProactiveQuestionsForTask(task: exec.AutoExecTask): boolean;
|
|
109
|
+
export declare function autoexecLockFailureMessage(error: unknown): string;
|
|
110
|
+
export declare function autoexecLockReleaseFailureMessage(error: unknown): string;
|
|
111
|
+
export interface AutoexecLockReleaseDeps {
|
|
112
|
+
releaseLock?: (path: string) => util.ReleaseLockResult | void;
|
|
113
|
+
stderr?: (text: string) => void;
|
|
114
|
+
}
|
|
115
|
+
export declare function releaseAutoexecLock(lockPath: string, deps?: AutoexecLockReleaseDeps): boolean;
|
|
114
116
|
export declare function urgentQuestionRuntimeWiringStatus(): typeof hubNs.URGENT_QUESTION_RUNTIME_WIRING_STATUS;
|
|
115
117
|
export declare function submitDistillTickExplorationQuestion(questions: HubQuestionLink | undefined, source: DistillTickQuestionSource | undefined): Promise<HubQuestionSubmitResult>;
|
|
116
118
|
export declare function scheduleAutoExecHubSideEffects(task: exec.AutoExecTask, verdict: exec.AutoExecVerdict, links: {
|
|
@@ -133,6 +135,7 @@ export declare function makeHubLink(cap: OutcomeReportingHub, ingestor?: events.
|
|
|
133
135
|
*/
|
|
134
136
|
export declare function resolveHubLink(env?: NodeJS.ProcessEnv, ingestor?: events.Ingestor, connectHub?: PublicHubConnector): HubLink | undefined;
|
|
135
137
|
export declare function resolveHubQuestionLink(env?: NodeJS.ProcessEnv, connectHub?: PublicHubConnector): HubQuestionLink | undefined;
|
|
138
|
+
export declare function resolveMemoryEventMirror(env?: NodeJS.ProcessEnv, connectHub?: PublicHubConnector): MemoryEventMirrorWiring;
|
|
136
139
|
export declare function offlinePermitDir(env?: NodeJS.ProcessEnv): string;
|
|
137
140
|
export declare function makeOfflineSolidifyPermitGate(permits: Pick<OfflinePermitStore, 'consumeOfflinePermit'>): algo.SolidifyPermitGate;
|
|
138
141
|
export declare function resolveSolidifyPermitGate(env?: NodeJS.ProcessEnv, connectHub?: PublicHubPermitConnector, opts?: SolidifyPermitResolverOptions): algo.SolidifyPermitGate | undefined;
|
|
@@ -233,5 +236,4 @@ export declare function runIdleTranscriptDistillForBeat(beat: Pick<Beat, 'intens
|
|
|
233
236
|
* autoExecPass on an interval. Real agent execution only happens for repos the operator has allowlisted in
|
|
234
237
|
* <home>/autoexec/config.json (allowedRoots) — empty by default = nothing runs.
|
|
235
238
|
*/
|
|
236
|
-
export declare function runAutoExec(argv: readonly string[]): Promise<number>;
|
|
237
|
-
export {};
|
|
239
|
+
export declare function runAutoExec(argv: readonly string[]): Promise<number>;
|