@evomap/evolver-core 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.
- package/assets/gep/genes.jsonl +5 -5
- package/dist/algo/bans.d.ts +10 -1
- package/dist/algo/bans.js +56 -6
- package/dist/algo/candidateAssembly.d.ts +25 -2
- package/dist/algo/candidateAssembly.js +171 -26
- package/dist/algo/capabilityCandidates.js +10 -0
- package/dist/algo/conversationSniffer.js +25 -8
- package/dist/algo/cycleEngine.d.ts +63 -5
- package/dist/algo/cycleEngine.js +320 -42
- package/dist/algo/cycleFailureClassifier.d.ts +1 -1
- package/dist/algo/evolutionEvent.d.ts +26 -0
- package/dist/algo/evolutionEvent.js +32 -0
- package/dist/algo/exploration.d.ts +7 -0
- package/dist/algo/exploration.js +16 -3
- package/dist/algo/geneHealth.d.ts +36 -3
- package/dist/algo/geneHealth.js +47 -4
- package/dist/algo/geneIntake.d.ts +46 -1
- package/dist/algo/geneIntake.js +121 -10
- package/dist/algo/geneSelection.d.ts +126 -6
- package/dist/algo/geneSelection.js +479 -36
- package/dist/algo/index.d.ts +6 -1
- package/dist/algo/index.js +6 -1
- package/dist/algo/kautoProjection.d.ts +41 -0
- package/dist/algo/kautoProjection.js +95 -0
- package/dist/algo/kautoValidator.d.ts +68 -0
- package/dist/algo/kautoValidator.js +256 -0
- package/dist/algo/memoryGraph.d.ts +62 -0
- package/dist/algo/memoryGraph.js +86 -0
- package/dist/algo/orchestrator.d.ts +17 -1
- package/dist/algo/orchestrator.js +30 -4
- package/dist/algo/publishEligibility.d.ts +34 -0
- package/dist/algo/publishEligibility.js +52 -0
- package/dist/algo/solidify.d.ts +11 -2
- package/dist/algo/solidify.js +37 -7
- package/dist/algo/ucb1.d.ts +53 -0
- package/dist/algo/ucb1.js +156 -0
- package/dist/assetrepair/hubRejection.d.ts +12 -0
- package/dist/assetrepair/hubRejection.js +109 -0
- package/dist/assetrepair/index.d.ts +2 -0
- package/dist/assetrepair/index.js +2 -0
- package/dist/assetrepair/repair.d.ts +33 -0
- package/dist/assetrepair/repair.js +155 -0
- package/dist/assetstore/assetSidecarRecords.d.ts +28 -0
- package/dist/assetstore/assetSidecarRecords.js +384 -0
- package/dist/assetstore/assetSidecarRecovery.d.ts +48 -0
- package/dist/assetstore/assetSidecarRecovery.js +288 -0
- package/dist/assetstore/assetStoreHealth.d.ts +81 -0
- package/dist/assetstore/assetStoreHealth.js +319 -0
- package/dist/assetstore/assetStoreLayout.d.ts +2 -0
- package/dist/assetstore/assetStoreLayout.js +6 -0
- package/dist/assetstore/assetStoreStorage.d.ts +42 -0
- package/dist/assetstore/assetStoreStorage.js +336 -0
- package/dist/assetstore/assetSyncLedger.d.ts +91 -1
- package/dist/assetstore/assetSyncLedger.js +718 -59
- package/dist/assetstore/foreignJsonlSource.d.ts +48 -0
- package/dist/assetstore/foreignJsonlSource.js +150 -0
- package/dist/assetstore/index.d.ts +5 -0
- package/dist/assetstore/index.js +5 -0
- package/dist/assetstore/learningHistory.js +3 -3
- package/dist/assetstore/localAssetStoreSnapshot.d.ts +51 -0
- package/dist/assetstore/localAssetStoreSnapshot.js +329 -0
- package/dist/assetstore/localJsonl.d.ts +12 -1
- package/dist/assetstore/localJsonl.js +251 -42
- package/dist/assetstore/provenance.d.ts +93 -4
- package/dist/assetstore/provenance.js +368 -84
- package/dist/assetstore/provider.d.ts +63 -0
- package/dist/assetstore/provider.js +97 -6
- package/dist/assetstore/reviewFilter.d.ts +19 -1
- package/dist/assetstore/reviewFilter.js +39 -1
- package/dist/assetstore/reviewLedger.d.ts +8 -2
- package/dist/assetstore/reviewLedger.js +71 -45
- package/dist/assetstore/unionReadStore.d.ts +25 -0
- package/dist/assetstore/unionReadStore.js +119 -0
- package/dist/benchmark/antiGeneBenchmark.d.ts +2 -0
- package/dist/benchmark/antiGeneBenchmark.js +4 -3
- package/dist/benchmark/antiGeneRollout.d.ts +2 -0
- package/dist/benchmark/antiGeneRollout.js +4 -3
- package/dist/benchmark/index.d.ts +3 -1
- package/dist/benchmark/index.js +3 -1
- package/dist/benchmark/selectionFlatAbstention.d.ts +152 -0
- package/dist/benchmark/selectionFlatAbstention.js +481 -0
- package/dist/benchmark/triggerShift.d.ts +62 -0
- package/dist/benchmark/triggerShift.js +106 -0
- package/dist/bootstrap/envFingerprint.d.ts +9 -0
- package/dist/bootstrap/envFingerprint.js +5 -0
- package/dist/bootstrap/index.d.ts +3 -1
- package/dist/bootstrap/index.js +3 -1
- package/dist/bootstrap/lifecycleBootstrap.d.ts +111 -0
- package/dist/bootstrap/lifecycleBootstrap.js +433 -0
- package/dist/bootstrap/v1EnvCompat.d.ts +113 -0
- package/dist/bootstrap/v1EnvCompat.js +303 -0
- package/dist/events/eventArchive.d.ts +2 -0
- package/dist/events/eventArchive.js +13 -3
- package/dist/events/eventSchema.d.ts +7 -7
- package/dist/events/eventStore.d.ts +2 -0
- package/dist/events/eventStore.js +5 -1
- package/dist/events/ingest.d.ts +2 -1
- package/dist/events/ingest.js +15 -0
- package/dist/events/paths.d.ts +12 -10
- package/dist/events/paths.js +24 -20
- package/dist/events/public.d.ts +2 -2
- package/dist/events/public.js +2 -2
- package/dist/events/reports.d.ts +2 -0
- package/dist/events/reports.js +4 -0
- package/dist/exec/autoExec.d.ts +68 -4
- package/dist/exec/autoExec.js +392 -33
- package/dist/exec/autonomousCycle.d.ts +31 -4
- package/dist/exec/autonomousCycle.js +71 -13
- package/dist/exec/claudeBridge.d.ts +80 -15
- package/dist/exec/claudeBridge.js +845 -76
- package/dist/exec/executionBinding.d.ts +414 -0
- package/dist/exec/executionBinding.js +588 -0
- package/dist/exec/index.d.ts +1 -0
- package/dist/exec/index.js +1 -0
- package/dist/exec/openPrRegistry.d.ts +8 -2
- package/dist/exec/openPrRegistry.js +32 -22
- package/dist/exec/prompt.js +14 -1
- package/dist/exec/proofOfWork.d.ts +1 -1
- package/dist/exec/proofOfWork.js +2 -2
- package/dist/exec/runnerRegistry.d.ts +153 -36
- package/dist/exec/runnerRegistry.js +848 -65
- package/dist/exec/selfPr.js +1 -7
- package/dist/feedback/envelope.d.ts +61 -0
- package/dist/feedback/envelope.js +168 -0
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.js +1 -0
- package/dist/hooks/hooks.js +1 -0
- package/dist/hub/assetCallLog.d.ts +35 -1
- package/dist/hub/assetCallLog.js +124 -1
- package/dist/hub/bindings.d.ts +8 -1
- package/dist/hub/bindings.js +29 -8
- package/dist/hub/capability.d.ts +130 -4
- package/dist/hub/conversationDistiller.d.ts +19 -0
- package/dist/hub/conversationDistiller.js +115 -37
- package/dist/hub/fake.d.ts +3 -2
- package/dist/hub/fake.js +2 -1
- package/dist/hub/index.d.ts +1 -0
- package/dist/hub/index.js +1 -0
- package/dist/hub/questionGenerator.d.ts +5 -1
- package/dist/hub/questionGenerator.js +8 -6
- package/dist/hub/recipeCompose.d.ts +27 -0
- package/dist/hub/recipeCompose.js +90 -0
- package/dist/hub/sanitize.js +122 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +7 -1
- package/dist/issueReporter/index.d.ts +156 -0
- package/dist/issueReporter/index.js +1688 -0
- package/dist/mailbox/dispatch.d.ts +1 -1
- package/dist/mailbox/dispatch.js +22 -6
- package/dist/mailbox/envelope.d.ts +7 -1
- package/dist/mailbox/envelope.js +9 -2
- package/dist/mailbox/ipcServer.d.ts +12 -2
- package/dist/mailbox/ipcServer.js +183 -13
- package/dist/mailbox/store.d.ts +89 -3
- package/dist/mailbox/store.js +895 -41
- package/dist/modelCompatibility.d.ts +164 -0
- package/dist/modelCompatibility.js +309 -0
- package/dist/observers/valueDigestObserver.d.ts +9 -0
- package/dist/observers/valueDigestObserver.js +35 -2
- package/dist/ops/cleanup.js +1 -1
- package/dist/ops/evolutionGraphProjection.d.ts +20 -0
- package/dist/ops/evolutionGraphProjection.js +315 -0
- package/dist/ops/index.d.ts +2 -1
- package/dist/ops/index.js +2 -1
- package/dist/ops/savingsCore.js +1 -2
- package/dist/ops/selfUpdate.d.ts +18 -1
- package/dist/ops/selfUpdate.js +88 -23
- package/dist/ops/valueOutreach.d.ts +3 -1
- package/dist/ops/valueOutreach.js +5 -1
- package/dist/personality/schema.d.ts +24 -24
- package/dist/schema/evolutionGraph.d.ts +784 -0
- package/dist/schema/evolutionGraph.js +187 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/proofOfWork.d.ts +125 -6
- package/dist/schema/proofOfWork.js +102 -4
- package/dist/schema/signal.d.ts +3 -3
- package/dist/schema/signal.js +1 -1
- package/dist/shadow/shadowHub.js +1 -0
- package/dist/signals/curriculum.d.ts +55 -0
- package/dist/signals/curriculum.js +202 -0
- package/dist/signals/cycleHistoryFromEvents.js +17 -8
- package/dist/signals/expand.d.ts +15 -1
- package/dist/signals/expand.js +169 -1
- package/dist/signals/extractor.d.ts +2 -2
- package/dist/signals/extractor.js +31 -6
- package/dist/signals/index.d.ts +4 -1
- package/dist/signals/index.js +4 -1
- package/dist/signals/metaSignals.d.ts +4 -0
- package/dist/signals/metaSignals.js +42 -0
- package/dist/signals/scopeVocabulary.d.ts +75 -0
- package/dist/signals/scopeVocabulary.js +91 -0
- package/dist/signals/signalGate.js +1 -1
- package/dist/signals/taskDomain.d.ts +22 -0
- package/dist/signals/taskDomain.js +43 -0
- package/dist/strategy/constraintAblation.d.ts +64 -0
- package/dist/strategy/constraintAblation.js +2820 -0
- package/dist/strategy/constraintAblationPredicates.d.ts +31 -0
- package/dist/strategy/constraintAblationPredicates.js +339 -0
- package/dist/strategy/index.d.ts +2 -1
- package/dist/strategy/index.js +2 -1
- package/dist/trace/index.d.ts +3 -1
- package/dist/trace/index.js +3 -1
- package/dist/trace/learningTrace.d.ts +216 -0
- package/dist/trace/learningTrace.js +298 -0
- package/dist/trace/proxyTurns.d.ts +31 -0
- package/dist/trace/proxyTurns.js +137 -0
- package/dist/trace/trajectory.d.ts +8 -0
- package/dist/trace/trajectory.js +14 -2
- package/dist/util/fetchPort.d.ts +1 -0
- package/dist/util/fetchPort.js +11 -0
- package/dist/util/fileLock.d.ts +113 -7
- package/dist/util/fileLock.js +1035 -80
- package/dist/util/index.d.ts +3 -1
- package/dist/util/index.js +2 -1
- package/dist/verify/index.d.ts +2 -1
- package/dist/verify/index.js +1 -1
- package/dist/verify/sandboxRunner.d.ts +30 -0
- package/dist/verify/sandboxRunner.js +370 -27
- package/dist/verify/sandboxedValidation.d.ts +16 -2
- package/dist/verify/sandboxedValidation.js +200 -22
- package/dist/verify/validation.d.ts +35 -4
- package/dist/verify/validation.js +164 -16
- package/dist/wire/geneHints.d.ts +88 -16
- package/dist/wire/geneHints.js +124 -15
- package/dist/wire/index.d.ts +8 -3
- package/dist/wire/index.js +2 -2
- package/dist/wire/schemaGate.d.ts +21 -0
- package/dist/wire/schemaGate.js +119 -10
- package/dist/workflow/dsl.d.ts +24 -3
- package/dist/workflow/dsl.js +4 -0
- package/dist/workflow/engine.d.ts +5 -1
- package/dist/workflow/engine.js +3 -0
- package/dist/workflow/index.d.ts +3 -1
- package/dist/workflow/index.js +3 -1
- package/dist/workflow/runtime.d.ts +110 -0
- package/dist/workflow/runtime.js +1298 -0
- package/dist/workflow/stateStore.d.ts +172 -0
- package/dist/workflow/stateStore.js +1044 -0
- package/package.json +12 -4
|
@@ -4,8 +4,10 @@ import type { ReviewLedger } from '../assetstore/reviewLedger.js';
|
|
|
4
4
|
import type { Mutation } from '../wire/index.js';
|
|
5
5
|
import type { GeneDecision } from '../algo/geneSelection.js';
|
|
6
6
|
import type { ExecutionResult } from '../algo/cycleEngine.js';
|
|
7
|
-
import { type GeneResolver, type ValidateHook, type AgentRunnerOptions, type RunnerName, type AgentRunner, type GitRunner } from './claudeBridge.js';
|
|
7
|
+
import { type GeneResolver, type ValidateHook, type AgentRunnerOptions, type AgentSessionResume, type RunnerName, type AgentRunner, type GitRunner } from './claudeBridge.js';
|
|
8
8
|
import type { PersonalityStore } from '../personality/store.js';
|
|
9
|
+
import type { AgentRunTraceRecorder } from '../trace/learningTrace.js';
|
|
10
|
+
import type { ExecutionObserver } from './claudeBridge.js';
|
|
9
11
|
/**
|
|
10
12
|
* Resolve a gene's strategy from the store and whether it is safe to EMBED into an autonomous agent's prompt —
|
|
11
13
|
* the exec-side link from #30 (provenance ledger) and the review-state gate to #45 (requireTrustedGene gate). A
|
|
@@ -18,9 +20,11 @@ export declare function makeTrustedGeneResolver(store: AssetStoreProvider, prove
|
|
|
18
20
|
export interface AutonomousSafety {
|
|
19
21
|
/** Deny-by-default repo allowlist (#41). Required — an empty array refuses everything. */
|
|
20
22
|
allowedRoots: readonly string[];
|
|
21
|
-
/** Which built-in runner (#66). Default '
|
|
23
|
+
/** Which built-in runner (#66). Default 'codex'. The same safety controls wrap whichever runner. cursor is a scaffold (unverified). */
|
|
22
24
|
runner?: RunnerName;
|
|
23
|
-
/**
|
|
25
|
+
/** Explicit opt-in to continue a native session owned by the selected runner. */
|
|
26
|
+
resume?: AgentSessionResume;
|
|
27
|
+
/** Agent runner options (#38/#40). Default: no pre-authorized host access. */
|
|
24
28
|
agentOptions?: AgentRunnerOptions;
|
|
25
29
|
/** Strip evolver/hub secrets from the agent env (#42). Default true. */
|
|
26
30
|
scrubEnv?: boolean;
|
|
@@ -29,11 +33,26 @@ export interface AutonomousSafety {
|
|
|
29
33
|
/** Only embed trusted gene strategies (#45). Default true. */
|
|
30
34
|
requireTrustedGene?: boolean;
|
|
31
35
|
timeoutMs?: number;
|
|
36
|
+
/** Cooperative cancellation propagated to the spawned runner process tree. */
|
|
37
|
+
signal?: AbortSignal;
|
|
32
38
|
}
|
|
39
|
+
export declare class UnsupportedCursorAutonomousIsolationError extends Error {
|
|
40
|
+
constructor();
|
|
41
|
+
}
|
|
42
|
+
export declare class UnsupportedAutonomousHostAccessError extends Error {
|
|
43
|
+
constructor();
|
|
44
|
+
}
|
|
45
|
+
export declare class UnsupportedAutonomousClaudeRunnerError extends Error {
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
export declare class UnsupportedAutonomousCodexRunnerError extends Error {
|
|
49
|
+
constructor();
|
|
50
|
+
}
|
|
51
|
+
export declare function resolveAutonomousAgentOptions(runner: RunnerName | undefined, isolation: AutonomousSafety['isolation'], overrides?: AgentRunnerOptions): AgentRunnerOptions;
|
|
33
52
|
/**
|
|
34
53
|
* Build the fully-hardened `execute` for an autonomous run against `repo`. Composes every exec-bridge control
|
|
35
54
|
* with secure defaults so they can't be forgotten piecemeal: deny-by-default allowedRoots (#41) + worktree
|
|
36
|
-
* isolation (#43) + env scrub (#42) +
|
|
55
|
+
* isolation (#43) + env scrub (#42) + non-bypassing agent permissions (#38/#40) + trusted-gene gate fed by
|
|
37
56
|
* provenance (#45/#30). Pass the result as runEvolutionCycle's `execute`.
|
|
38
57
|
*/
|
|
39
58
|
export declare function makeSafeExecute(repo: string, store: AssetStoreProvider, safety: AutonomousSafety, opts?: {
|
|
@@ -45,4 +64,12 @@ export declare function makeSafeExecute(repo: string, store: AssetStoreProvider,
|
|
|
45
64
|
personality?: PersonalityStore;
|
|
46
65
|
agent?: AgentRunner;
|
|
47
66
|
git?: GitRunner;
|
|
67
|
+
/** Optional learning-trace recorder forwarded to the exec bridge (Learning Ops slice 2). */
|
|
68
|
+
traceRecorder?: AgentRunTraceRecorder;
|
|
69
|
+
executionObserver?: ExecutionObserver;
|
|
70
|
+
executionLimits?: {
|
|
71
|
+
maxRuntimeMs: number;
|
|
72
|
+
maxFiles: number;
|
|
73
|
+
maxLines: number;
|
|
74
|
+
};
|
|
48
75
|
}): (mutation: Mutation, decision: GeneDecision) => Promise<ExecutionResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeClaudeExecBridge } from './claudeBridge.js';
|
|
1
|
+
import { CLAUDE_SAFE_AUTONOMOUS_TOOLS, hasBoundedClaudeFileAccess, makeClaudeExecBridge, validateAgentSessionResume } from './claudeBridge.js';
|
|
2
2
|
const asStrings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string') : []);
|
|
3
3
|
/**
|
|
4
4
|
* Resolve a gene's strategy from the store and whether it is safe to EMBED into an autonomous agent's prompt —
|
|
@@ -33,43 +33,101 @@ export function makeTrustedGeneResolver(store, provenance, review, includeProbat
|
|
|
33
33
|
return info;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
// Claude's
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// Keep Claude's project path checks enabled and expose only file/search tools.
|
|
37
|
+
// Bash, web, task, and MCP tools remain unavailable.
|
|
38
|
+
const CLAUDE_DEFAULT_AGENT_OPTIONS = {
|
|
39
|
+
permissionMode: 'acceptEdits',
|
|
40
|
+
tools: CLAUDE_SAFE_AUTONOMOUS_TOOLS,
|
|
41
|
+
};
|
|
42
|
+
// Codex workspace-write prevents host writes but does not contain host reads. It therefore remains explicit.
|
|
40
43
|
const CODEX_DEFAULT_AGENT_OPTIONS = {};
|
|
41
|
-
// Cursor
|
|
42
|
-
// but not yet run-verified end to end (needs an authed cursor-agent). The `-p --force --trust` bypass would
|
|
43
|
-
// auto-approve shell+write, but Cursor has no verified per-run allowlist/sandbox mapping yet, so skipPermissions
|
|
44
|
-
// is refused outright. Use default cursor with worktree isolation until the CLI is run-verified.
|
|
44
|
+
// Cursor has no verified host filesystem/network sandbox. Worktree isolation cannot safely authorize `--trust`.
|
|
45
45
|
const CURSOR_DEFAULT_AGENT_OPTIONS = {};
|
|
46
|
-
|
|
46
|
+
// Gemini's verified safe default is `--approval-mode auto_edit`; shell remains gated and --yolo is refused.
|
|
47
|
+
const GEMINI_DEFAULT_AGENT_OPTIONS = {};
|
|
48
|
+
/** Per-runner safe default agent options. Host permission bypass is never enabled by default. */
|
|
47
49
|
function defaultAgentOptions(runner) {
|
|
48
50
|
if (runner === 'codex')
|
|
49
51
|
return CODEX_DEFAULT_AGENT_OPTIONS;
|
|
50
52
|
if (runner === 'cursor')
|
|
51
53
|
return CURSOR_DEFAULT_AGENT_OPTIONS;
|
|
54
|
+
if (runner === 'gemini')
|
|
55
|
+
return GEMINI_DEFAULT_AGENT_OPTIONS;
|
|
52
56
|
return CLAUDE_DEFAULT_AGENT_OPTIONS;
|
|
53
57
|
}
|
|
58
|
+
export class UnsupportedCursorAutonomousIsolationError extends Error {
|
|
59
|
+
constructor() {
|
|
60
|
+
super('Autonomous Cursor cannot use worktree isolation because --trust grants host filesystem and network access');
|
|
61
|
+
this.name = 'UnsupportedCursorAutonomousIsolationError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class UnsupportedAutonomousHostAccessError extends Error {
|
|
65
|
+
constructor() {
|
|
66
|
+
super('Autonomous Claude requires project-scoped acceptEdits with bounded file/search tools; host access bypass or unsupported tools are forbidden because a worktree is not a security boundary');
|
|
67
|
+
this.name = 'UnsupportedAutonomousHostAccessError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class UnsupportedAutonomousClaudeRunnerError extends Error {
|
|
71
|
+
constructor() {
|
|
72
|
+
super('Autonomous claude is disabled because its headless edit mode has no verified host filesystem sandbox; inject an externally sandboxed agent or explicitly select a runner after reviewing its host-access boundary');
|
|
73
|
+
this.name = 'UnsupportedAutonomousClaudeRunnerError';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class UnsupportedAutonomousCodexRunnerError extends Error {
|
|
77
|
+
constructor() {
|
|
78
|
+
super('Autonomous codex is disabled because workspace-write does not restrict host filesystem reads; inject an externally sandboxed agent');
|
|
79
|
+
this.name = 'UnsupportedAutonomousCodexRunnerError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function resolveAutonomousAgentOptions(runner, isolation, overrides) {
|
|
83
|
+
const options = {
|
|
84
|
+
...defaultAgentOptions(runner),
|
|
85
|
+
...(isolation !== 'none' ? { workspaceTrust: 'isolated-worktree' } : {}),
|
|
86
|
+
...(overrides ?? {}),
|
|
87
|
+
};
|
|
88
|
+
if (runner === 'cursor' && isolation !== 'none') {
|
|
89
|
+
throw new UnsupportedCursorAutonomousIsolationError();
|
|
90
|
+
}
|
|
91
|
+
const effectiveRunner = runner ?? 'claude';
|
|
92
|
+
const unsafeClaudeOptions = effectiveRunner === 'claude' && !hasBoundedClaudeFileAccess(options);
|
|
93
|
+
if (unsafeClaudeOptions) {
|
|
94
|
+
throw new UnsupportedAutonomousHostAccessError();
|
|
95
|
+
}
|
|
96
|
+
return options;
|
|
97
|
+
}
|
|
54
98
|
/**
|
|
55
99
|
* Build the fully-hardened `execute` for an autonomous run against `repo`. Composes every exec-bridge control
|
|
56
100
|
* with secure defaults so they can't be forgotten piecemeal: deny-by-default allowedRoots (#41) + worktree
|
|
57
|
-
* isolation (#43) + env scrub (#42) +
|
|
101
|
+
* isolation (#43) + env scrub (#42) + non-bypassing agent permissions (#38/#40) + trusted-gene gate fed by
|
|
58
102
|
* provenance (#45/#30). Pass the result as runEvolutionCycle's `execute`.
|
|
59
103
|
*/
|
|
60
104
|
export function makeSafeExecute(repo, store, safety, opts = {}) {
|
|
105
|
+
const runner = safety.runner ?? (opts.agent ? undefined : 'claude');
|
|
106
|
+
if (safety.resume && runner)
|
|
107
|
+
validateAgentSessionResume(safety.resume, runner);
|
|
108
|
+
if (!opts.agent && runner === 'claude') {
|
|
109
|
+
throw new UnsupportedAutonomousClaudeRunnerError();
|
|
110
|
+
}
|
|
111
|
+
if (!opts.agent && runner === 'codex') {
|
|
112
|
+
throw new UnsupportedAutonomousCodexRunnerError();
|
|
113
|
+
}
|
|
61
114
|
return makeClaudeExecBridge({
|
|
62
115
|
cwd: repo,
|
|
63
116
|
enabled: true,
|
|
64
117
|
...(opts.agent ? { agent: opts.agent } : {}),
|
|
65
118
|
...(opts.git ? { git: opts.git } : {}),
|
|
119
|
+
...(opts.traceRecorder ? { traceRecorder: opts.traceRecorder } : {}),
|
|
120
|
+
...(opts.executionObserver ? { executionObserver: opts.executionObserver } : {}),
|
|
121
|
+
...(opts.executionLimits ? { executionLimits: opts.executionLimits } : {}),
|
|
66
122
|
allowedRoots: safety.allowedRoots,
|
|
67
|
-
...(
|
|
123
|
+
...(runner ? { runner } : {}),
|
|
124
|
+
...(safety.resume ? { resume: safety.resume } : {}),
|
|
68
125
|
...(safety.isolation === 'none' ? {} : { isolation: 'worktree' }),
|
|
69
126
|
scrubEnv: safety.scrubEnv ?? true,
|
|
70
127
|
requireTrustedGene: safety.requireTrustedGene ?? true,
|
|
71
|
-
agentOptions: safety.
|
|
128
|
+
agentOptions: resolveAutonomousAgentOptions(runner, safety.isolation, safety.agentOptions),
|
|
72
129
|
...(safety.timeoutMs !== undefined ? { timeoutMs: safety.timeoutMs } : {}),
|
|
130
|
+
...(safety.signal ? { signal: safety.signal } : {}),
|
|
73
131
|
resolveGene: makeTrustedGeneResolver(store, opts.provenance, opts.review, opts.includeProbation ?? false),
|
|
74
132
|
...(opts.validate ? { validate: opts.validate } : {}),
|
|
75
133
|
...(opts.validationCmds ? { validationCmds: opts.validationCmds } : {}),
|
|
@@ -3,21 +3,34 @@ import type { GeneDecision } from '../algo/geneSelection.js';
|
|
|
3
3
|
import type { ExecutionResult } from '../algo/cycleEngine.js';
|
|
4
4
|
import { type GeneStrategyInfo } from './prompt.js';
|
|
5
5
|
import type { PersonalityStore } from '../personality/store.js';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import type { AgentRunTraceRecorder } from '../trace/learningTrace.js';
|
|
7
|
+
import type { PolicyDecision, ProofReference, ToolDecision, ValidatorEvidence } from './executionBinding.js';
|
|
8
|
+
import { type AgentRunner, type AgentRunnerOptions, type AgentSessionResume, type RunnerName } from './runnerRegistry.js';
|
|
9
|
+
export { resolveSpawnCommand, spawnCapture, DEFAULT_MAX_CAPTURE_BYTES, MAX_AGENT_SESSION_ID_CHARS, AgentSessionResumeError, validateAgentSessionResume, UnboundedSkipPermissionsError, UnsupportedCodexPermissionOptionsError, UnsupportedCursorAllowedToolsError, UnsupportedCursorSkipPermissionsError, UnsupportedCursorWorkspaceTrustError, UnsupportedGeminiPermissionOptionsError, claudeRunnerArgs, makeClaudeHeadlessRunner, claudeHeadlessRunner, codexRunnerArgs, makeCodexHeadlessRunner, cursorRunnerArgs, makeCursorHeadlessRunner, getRunnerSpec, hasBoundedClaudeFileAccess, CLAUDE_SAFE_AUTONOMOUS_TOOLS, geminiRunnerArgs, makeGeminiHeadlessRunner, classifyGeminiRunnerResult, } from './runnerRegistry.js';
|
|
10
|
+
export type { AgentRunContext, AgentRunResult, AgentRunner, RunnerName, AgentRunnerOptions, ClaudeRunnerOptions, CodexRunnerOptions, AgentRunnerSpec, AgentSessionResume, } from './runnerRegistry.js';
|
|
11
|
+
export interface GitRunnerOptions {
|
|
12
|
+
processSignalMode?: 'cancel' | 'ignore';
|
|
13
|
+
}
|
|
9
14
|
/** Run a git subcommand in cwd and return its stdout. */
|
|
10
|
-
export type GitRunner = (args: readonly string[], cwd: string) => Promise<string>;
|
|
15
|
+
export type GitRunner = (args: readonly string[], cwd: string, signal?: AbortSignal, options?: GitRunnerOptions) => Promise<string>;
|
|
16
|
+
export type GitPatchWriter = (args: readonly string[], cwd: string, destination: string, signal?: AbortSignal,
|
|
17
|
+
/** Call immediately after this writer exclusively creates `destination`. */
|
|
18
|
+
onDestinationOpened?: () => void) => Promise<void>;
|
|
11
19
|
/** Resolve the selected gene's learned strategy (for prompt enrichment). */
|
|
12
20
|
export type GeneResolver = (geneId: string) => Promise<GeneStrategyInfo | null> | GeneStrategyInfo | null;
|
|
13
21
|
/** Decide success from the post-run working tree (e.g. run the gene's validation plan). */
|
|
14
|
-
export
|
|
15
|
-
passed: boolean;
|
|
16
|
-
score?: number;
|
|
17
|
-
}> | {
|
|
22
|
+
export interface ValidateHookResult {
|
|
18
23
|
passed: boolean;
|
|
19
24
|
score?: number;
|
|
20
|
-
|
|
25
|
+
validator?: ValidatorEvidence;
|
|
26
|
+
}
|
|
27
|
+
export type ValidateHook = (mutation: Mutation, decision: GeneDecision, cwd: string, signal: AbortSignal) => Promise<ValidateHookResult> | ValidateHookResult;
|
|
28
|
+
export interface ExecutionObserver {
|
|
29
|
+
onToolDecision?(decision: ToolDecision, signal?: AbortSignal): Promise<void> | void;
|
|
30
|
+
onPolicyDecision?(decision: PolicyDecision, signal?: AbortSignal): Promise<void> | void;
|
|
31
|
+
onValidatorDecision?(decision: ValidatorEvidence, signal?: AbortSignal): Promise<void> | void;
|
|
32
|
+
onProofReference?(reference: ProofReference, signal?: AbortSignal): Promise<void> | void;
|
|
33
|
+
}
|
|
21
34
|
export interface ExecBridgeOptions {
|
|
22
35
|
/** Working directory the agent edits and git is measured in. */
|
|
23
36
|
cwd: string;
|
|
@@ -25,10 +38,18 @@ export interface ExecBridgeOptions {
|
|
|
25
38
|
agent?: AgentRunner;
|
|
26
39
|
/** Which built-in runner to use when `agent` is not injected (#66). Default 'claude' (byte-identical). cursor is a scaffold (unverified runner). */
|
|
27
40
|
runner?: RunnerName;
|
|
41
|
+
/** Explicit native session continuation. Must name the same runner selected above. */
|
|
42
|
+
resume?: AgentSessionResume;
|
|
28
43
|
/** When `agent` is not injected, options for the built-in headless runner (permission bypass / allowed tools / model). */
|
|
29
44
|
agentOptions?: AgentRunnerOptions;
|
|
30
45
|
/** Default: spawns `git`. Inject a fake in tests. */
|
|
31
46
|
git?: GitRunner;
|
|
47
|
+
/** Optional complete-patch sink. The default streams built-in git output directly to disk. */
|
|
48
|
+
gitPatchWriter?: GitPatchWriter;
|
|
49
|
+
/** Test seam for fallback patch persistence; production callers should use the exclusive private writer. */
|
|
50
|
+
writePatchFile?: (path: string, patch: string) => void;
|
|
51
|
+
/** Test seam for temporary patch cleanup; production callers should use the filesystem default. */
|
|
52
|
+
removePatchFile?: (path: string) => void;
|
|
32
53
|
/** Default: EVOLVE_EXEC_BRIDGE === '1'. Set true to force-enable (e.g. integration tests). */
|
|
33
54
|
enabled?: boolean;
|
|
34
55
|
/**
|
|
@@ -45,7 +66,7 @@ export interface ExecBridgeOptions {
|
|
|
45
66
|
/**
|
|
46
67
|
* Run the agent in a throwaway git worktree of `cwd` instead of the repo's real working tree (finding #39.4):
|
|
47
68
|
* the agent's edits land in an isolated checkout, never touching the user's working tree. The diff is measured
|
|
48
|
-
* there, captured as a patch (proof.
|
|
69
|
+
* there, captured as a patch (proof.git_diff.patch_ref), and the worktree is removed. `cwd` must be a git repo.
|
|
49
70
|
*/
|
|
50
71
|
isolation?: 'worktree';
|
|
51
72
|
/**
|
|
@@ -57,12 +78,22 @@ export interface ExecBridgeOptions {
|
|
|
57
78
|
requireTrustedGene?: boolean;
|
|
58
79
|
/** Per-run agent timeout. Default 600_000ms (10 min). */
|
|
59
80
|
timeoutMs?: number;
|
|
81
|
+
/** Cooperative cancellation propagated to the runner process tree. */
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
/** Binding hard limits are intersected with the existing policy/runner controls; never widen local safety. */
|
|
84
|
+
executionLimits?: {
|
|
85
|
+
maxRuntimeMs: number;
|
|
86
|
+
maxFiles: number;
|
|
87
|
+
maxLines: number;
|
|
88
|
+
};
|
|
60
89
|
/** Optional: enrich the prompt with the selected gene's strategy. */
|
|
61
90
|
resolveGene?: GeneResolver;
|
|
62
91
|
/** Optional: validation commands surfaced in the prompt's done-criteria. */
|
|
63
92
|
validationCmds?: readonly string[];
|
|
64
93
|
/** Optional: authoritative success decision after the agent runs. Falls back to "agent ok + produced a diff". */
|
|
65
94
|
validate?: ValidateHook;
|
|
95
|
+
/** Bound execution provenance observer. Failures are authoritative and fail the execution closed. */
|
|
96
|
+
executionObserver?: ExecutionObserver;
|
|
66
97
|
/**
|
|
67
98
|
* Optional evolvable personality (use-case ①): when set, the agent prompt gets a behavioral-style block
|
|
68
99
|
* rendered from the store's CURRENT persisted state. CycleEngine's applySelectForRun has already run and
|
|
@@ -72,6 +103,12 @@ export interface ExecBridgeOptions {
|
|
|
72
103
|
* the store's default state (store.load never throws), it never fails the run.
|
|
73
104
|
*/
|
|
74
105
|
personality?: PersonalityStore;
|
|
106
|
+
/**
|
|
107
|
+
* Optional learning-trace recorder (Learning Ops slice 2): when set, the bridge emits `model.called` around
|
|
108
|
+
* each agent spawn and `tool.failed`/`retry.attempted` metadata on failures. Best-effort observability — a
|
|
109
|
+
* recorder/sink failure must never affect the execution result, so every emission is wrapped defensively.
|
|
110
|
+
*/
|
|
111
|
+
traceRecorder?: AgentRunTraceRecorder;
|
|
75
112
|
}
|
|
76
113
|
export declare class ExecBridgeDisabledError extends Error {
|
|
77
114
|
constructor();
|
|
@@ -84,16 +121,33 @@ export declare class ExecBridgeForbiddenError extends Error {
|
|
|
84
121
|
* Thrown when a FULL-ACCESS (or unverified) agent run is requested without worktree isolation. The throwaway
|
|
85
122
|
* worktree is the containment WE control — allowedRoots gates the cwd but cannot stop an auto-approved or
|
|
86
123
|
* unsandboxed process writing/running outside it. Gated runners:
|
|
87
|
-
* - codex
|
|
88
|
-
* workspace-write, so only the skip path is gated.
|
|
124
|
+
* - codex permission overrides are refused by the runner because it has no enforceable per-tool allowlist.
|
|
89
125
|
* - cursor default → gated UNCONDITIONALLY. cursor-agent base `-p` already documents write+shell access, cursor
|
|
90
126
|
* skipPermissions is rejected by the runner layer, and the scaffold remains unverified (#66/#181) — so default
|
|
91
127
|
* cursor still needs the wrapper worktree rather than risk mutating the real tree.
|
|
92
|
-
*
|
|
128
|
+
* Claude is fail-closed below because a tool-name allowlist does not constrain absolute filesystem paths.
|
|
93
129
|
*/
|
|
94
130
|
export declare class UnsandboxedFullAccessRequiresIsolationError extends Error {
|
|
95
131
|
constructor();
|
|
96
132
|
}
|
|
133
|
+
export declare class WorkspaceTrustRequiresIsolationError extends Error {
|
|
134
|
+
readonly code = "WORKSPACE_TRUST_REQUIRES_ISOLATION";
|
|
135
|
+
constructor();
|
|
136
|
+
}
|
|
137
|
+
export declare class UnsupportedCursorBuiltInRunnerError extends Error {
|
|
138
|
+
constructor();
|
|
139
|
+
}
|
|
140
|
+
export declare class UnsupportedClaudeBuiltInRunnerError extends Error {
|
|
141
|
+
constructor();
|
|
142
|
+
}
|
|
143
|
+
export declare class UnsupportedCodexBuiltInRunnerError extends Error {
|
|
144
|
+
constructor();
|
|
145
|
+
}
|
|
146
|
+
export declare class UnsafeWorktreePathError extends Error {
|
|
147
|
+
constructor(reason: string);
|
|
148
|
+
}
|
|
149
|
+
/** Whether `child` is the same as, or nested under, `root`, including filesystem symlink resolution. */
|
|
150
|
+
export declare function isWithinRoot(child: string, root: string): boolean;
|
|
97
151
|
/**
|
|
98
152
|
* Whitelist-filter `env` for a spawned agent/tool: keep ONLY the minimal runtime env + the caller-declared
|
|
99
153
|
* extras (the runner's own auth via allowPrefixes/allowKeys); drop everything else. Fail-safe by construction —
|
|
@@ -103,10 +157,21 @@ export declare function scrubAgentEnv(env: NodeJS.ProcessEnv, opts?: {
|
|
|
103
157
|
allowKeys?: readonly string[];
|
|
104
158
|
allowPrefixes?: readonly string[];
|
|
105
159
|
}): NodeJS.ProcessEnv;
|
|
106
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* 绑定执行不能接受无法收到权威截止时间取消信号的旧验证器或写入器。
|
|
162
|
+
* AbortSignal 本身是协作式的;先拒绝不暴露该信号的回调,避免旧 hook
|
|
163
|
+
* 被静默地当作无界工作运行。
|
|
164
|
+
*/
|
|
165
|
+
export declare class ExecBridgeCancellationContractError extends Error {
|
|
166
|
+
constructor(hook: 'validate' | 'gitPatchWriter');
|
|
167
|
+
}
|
|
168
|
+
/** Default git runner: every incomplete command result fails closed. */
|
|
107
169
|
export declare const defaultGitRunner: GitRunner;
|
|
170
|
+
export declare const defaultGitPatchWriter: GitPatchWriter;
|
|
108
171
|
/**
|
|
109
172
|
* Build the `execute` function CycleEngine/runEvolutionCycle consume. Default-off: throws
|
|
110
173
|
* ExecBridgeDisabledError on first call unless enabled.
|
|
111
174
|
*/
|
|
112
|
-
export declare function makeClaudeExecBridge(opts: ExecBridgeOptions
|
|
175
|
+
export declare function makeClaudeExecBridge(opts: ExecBridgeOptions, internal?: {
|
|
176
|
+
cursorWorktreeRoot?: string;
|
|
177
|
+
}): (mutation: Mutation, decision: GeneDecision) => Promise<ExecutionResult>;
|