@tangle-network/agent-runtime 0.94.9 → 0.94.11
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/agent.js +2 -2
- package/dist/{agentic-generator-1g7GDba7.d.ts → agentic-generator-JT47GnAp.d.ts} +44 -4
- package/dist/{chunk-MSUWXCHD.js → chunk-33OG2NN3.js} +2 -2
- package/dist/{chunk-7NCP74SL.js → chunk-5LIOH5DR.js} +2 -2
- package/dist/{chunk-FRXDOBFP.js → chunk-C3UKLQ54.js} +221 -21
- package/dist/chunk-C3UKLQ54.js.map +1 -0
- package/dist/{chunk-TNUBPPZA.js → chunk-HGRW27YY.js} +2 -2
- package/dist/{chunk-KYPVUEJ4.js → chunk-MXBQNVFE.js} +3 -3
- package/dist/{chunk-GHXW56PO.js → chunk-OLZ6ZZQ2.js} +126 -29
- package/dist/chunk-OLZ6ZZQ2.js.map +1 -0
- package/dist/{chunk-7HH22XN4.js → chunk-YP6B7RZ2.js} +2 -2
- package/dist/chunk-YP6B7RZ2.js.map +1 -0
- package/dist/{completion-gate-tzwyyD-E.d.ts → completion-gate-Bn4AZ_Kw.d.ts} +46 -12
- package/dist/{coordination-o0TzS7Ms.d.ts → coordination-DzwagV_s.d.ts} +2 -2
- package/dist/{improve-DZeatcs7.d.ts → improve-BucbjddC.d.ts} +2 -2
- package/dist/index.d.ts +11 -10
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +2 -2
- package/dist/knowledge.d.ts +5 -4
- package/dist/knowledge.js +2 -2
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +1 -1
- package/dist/{local-harness-ZLMkKdZc.d.ts → local-harness-ZqCx51u7.d.ts} +1 -1
- package/dist/{loop-runner-bin-iTSxSmpv.d.ts → loop-runner-bin-D6K_C6op.d.ts} +1 -1
- package/dist/loop-runner-bin.d.ts +5 -4
- package/dist/loop-runner-bin.js +3 -3
- package/dist/loops.d.ts +10 -9
- package/dist/loops.js +2 -2
- package/dist/mcp/bin.js +1 -1
- package/dist/mcp/index.d.ts +7 -6
- package/dist/mcp/index.js +3 -3
- package/dist/{mcp-serve-verifier-BO4MEsR3.d.ts → mcp-serve-verifier-i6nTNSnu.d.ts} +1 -1
- package/dist/{supervise-CRwaJIkd.d.ts → supervise-CzyytS-o.d.ts} +2 -2
- package/dist/{worktree-fanout-BJy24LYe.d.ts → worktree-fanout-Bn7w_1bM.d.ts} +12 -6
- package/package.json +1 -1
- package/dist/chunk-7HH22XN4.js.map +0 -1
- package/dist/chunk-FRXDOBFP.js.map +0 -1
- package/dist/chunk-GHXW56PO.js.map +0 -1
- /package/dist/{chunk-MSUWXCHD.js.map → chunk-33OG2NN3.js.map} +0 -0
- /package/dist/{chunk-7NCP74SL.js.map → chunk-5LIOH5DR.js.map} +0 -0
- /package/dist/{chunk-TNUBPPZA.js.map → chunk-HGRW27YY.js.map} +0 -0
- /package/dist/{chunk-KYPVUEJ4.js.map → chunk-MXBQNVFE.js.map} +0 -0
package/dist/agent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalystFinding, CostLedger, MaximumCharge } from '@tangle-network/agent-eval';
|
|
2
2
|
import { AgentProfile, ReasoningEffort } from '@tangle-network/agent-interface';
|
|
3
|
-
import { L as LocalHarness, C as CodexTokenUsage, a as CodexExecutionEvidence, r as runLocalHarness } from './local-harness-
|
|
3
|
+
import { L as LocalHarness, C as CodexTokenUsage, a as CodexExecutionEvidence, b as LocalHarnessResult, r as runLocalHarness } from './local-harness-ZqCx51u7.js';
|
|
4
4
|
import { LabeledScenarioStore, WorktreeAdapter, SurfaceProposer } from '@tangle-network/agent-eval/campaign';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -166,6 +166,41 @@ interface AgenticGeneratorShotReceipt {
|
|
|
166
166
|
readonly message: string;
|
|
167
167
|
} | null;
|
|
168
168
|
}
|
|
169
|
+
/** Frozen exact harness result for an author shot: full streams, process state,
|
|
170
|
+
* token usage, and execution-policy evidence.
|
|
171
|
+
* The `onShotCompleted` callback receives `null` when execution failed before
|
|
172
|
+
* the harness returned. */
|
|
173
|
+
type AgenticGeneratorShotExecution = Readonly<Omit<LocalHarnessResult, 'usage' | 'evidence'> & {
|
|
174
|
+
readonly usage?: Readonly<CodexTokenUsage>;
|
|
175
|
+
readonly evidence?: Readonly<Omit<CodexExecutionEvidence, 'readDeniedPaths' | 'policy'>> & {
|
|
176
|
+
readonly readDeniedPaths: ReadonlyArray<string>;
|
|
177
|
+
readonly policy: Readonly<CodexExecutionEvidence['policy']>;
|
|
178
|
+
};
|
|
179
|
+
}>;
|
|
180
|
+
/** Worktree decision emitted before a completed shot is retried, accepted, or
|
|
181
|
+
* discarded. The callback runs while `worktreePath` is still available, so
|
|
182
|
+
* callers can persist the exact diff. */
|
|
183
|
+
type AgenticGeneratorShotDisposition = {
|
|
184
|
+
readonly kind: 'clean';
|
|
185
|
+
readonly worktreePath: string;
|
|
186
|
+
} | {
|
|
187
|
+
readonly kind: 'rejected';
|
|
188
|
+
readonly worktreePath: string;
|
|
189
|
+
readonly stage: 'raw-trace-evidence' | 'verification';
|
|
190
|
+
readonly feedback: string | null;
|
|
191
|
+
} | {
|
|
192
|
+
readonly kind: 'accepted';
|
|
193
|
+
readonly worktreePath: string;
|
|
194
|
+
readonly verified: boolean;
|
|
195
|
+
} | {
|
|
196
|
+
readonly kind: 'setup-error';
|
|
197
|
+
readonly worktreePath: string;
|
|
198
|
+
readonly stage: 'worktree-inspection' | 'raw-trace-evidence' | 'verification';
|
|
199
|
+
readonly error: {
|
|
200
|
+
readonly name: string;
|
|
201
|
+
readonly message: string;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
169
204
|
interface AgenticGeneratorOptions {
|
|
170
205
|
/** Local coding harness to run in the worktree. Default `claude`. */
|
|
171
206
|
harness?: LocalHarness;
|
|
@@ -179,8 +214,13 @@ interface AgenticGeneratorOptions {
|
|
|
179
214
|
* candidate-specific paths after the driver creates its worktree. */
|
|
180
215
|
codexReadDeniedPaths?: ReadonlyArray<string> | ((worktreePath: string) => ReadonlyArray<string>);
|
|
181
216
|
/** Awaited once for every attempted author shot, including process failures.
|
|
182
|
-
*
|
|
183
|
-
|
|
217
|
+
* The second argument preserves the exact harness result, including stdout
|
|
218
|
+
* and stderr, before worktree inspection or verification can reject the
|
|
219
|
+
* shot. Throwing aborts the candidate so evidence persistence fails closed. */
|
|
220
|
+
onShotCompleted?: (receipt: AgenticGeneratorShotReceipt, execution: AgenticGeneratorShotExecution | null) => void | Promise<void>;
|
|
221
|
+
/** Awaited after worktree inspection and before the shot is accepted,
|
|
222
|
+
* retried, or discarded. Throwing aborts the candidate. */
|
|
223
|
+
onShotDisposition?: (receipt: AgenticGeneratorShotReceipt, disposition: AgenticGeneratorShotDisposition) => void | Promise<void>;
|
|
184
224
|
/** Optional hard upper bound passed to the run-wide CostLedger before each
|
|
185
225
|
* author shot. This MUST be enforced by the provider or executor; a planning
|
|
186
226
|
* estimate is not an admissible bound. Omit for an uncapped ledger. A capped
|
|
@@ -215,4 +255,4 @@ declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGene
|
|
|
215
255
|
* silent fallback). */
|
|
216
256
|
declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
|
|
217
257
|
|
|
218
|
-
export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type CandidateGenerator as C, type ImprovementDriverOptions as I, type ManagedImprovementDriver as M, type Verifier as V, type AgenticGeneratorOptions as a, type
|
|
258
|
+
export { AGENTIC_PROFILE_RESOURCE_ROOT as A, type CandidateGenerator as C, type ImprovementDriverOptions as I, type ManagedImprovementDriver as M, type Verifier as V, type AgenticGeneratorOptions as a, type AgenticGeneratorShotDisposition as b, type AgenticGeneratorShotExecution as c, type AgenticGeneratorShotReceipt as d, type VerifyResult as e, agenticGenerator as f, commandVerifier as g, improvementDriver as i };
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
DELEGATION_STATUS_DESCRIPTION,
|
|
9
9
|
DELEGATION_STATUS_INPUT_SCHEMA,
|
|
10
10
|
DELEGATION_STATUS_TOOL_NAME
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-C3UKLQ54.js";
|
|
12
12
|
|
|
13
13
|
// src/mcp/openai-tools.ts
|
|
14
14
|
function buildTool(name, description, parameters) {
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
mcpToolsForRuntimeMcp,
|
|
46
46
|
mcpToolsForRuntimeMcpSubset
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-33OG2NN3.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
agenticGenerator
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OLZ6ZZQ2.js";
|
|
4
4
|
import {
|
|
5
5
|
assertModelAllowed
|
|
6
6
|
} from "./chunk-ISTDY47H.js";
|
|
@@ -658,4 +658,4 @@ export {
|
|
|
658
658
|
applyImprovementWinnerToProfile,
|
|
659
659
|
improve
|
|
660
660
|
};
|
|
661
|
-
//# sourceMappingURL=chunk-
|
|
661
|
+
//# sourceMappingURL=chunk-5LIOH5DR.js.map
|
|
@@ -657,6 +657,7 @@ function errMessage(err) {
|
|
|
657
657
|
|
|
658
658
|
// src/mcp/worktree.ts
|
|
659
659
|
import { spawn } from "child_process";
|
|
660
|
+
import { isAbsolute, win32 } from "path";
|
|
660
661
|
async function runGitAsync(args, cwd, runner) {
|
|
661
662
|
if (runner) return runner(args, { cwd });
|
|
662
663
|
return new Promise((resolve, reject) => {
|
|
@@ -675,11 +676,14 @@ async function runGitAsync(args, cwd, runner) {
|
|
|
675
676
|
}
|
|
676
677
|
function ensureGitOk(step, result) {
|
|
677
678
|
if (result.exitCode !== 0) {
|
|
678
|
-
throw
|
|
679
|
-
`worktree: git ${step} failed (exit ${result.exitCode}): ${result.stderr.slice(0, 400)}`
|
|
680
|
-
);
|
|
679
|
+
throw gitFailure(step, result);
|
|
681
680
|
}
|
|
682
681
|
}
|
|
682
|
+
function gitFailure(step, result) {
|
|
683
|
+
return new Error(
|
|
684
|
+
`worktree: git ${step} failed (exit ${result.exitCode}): ${result.stderr.slice(0, 400)}`
|
|
685
|
+
);
|
|
686
|
+
}
|
|
683
687
|
async function createWorktree(options) {
|
|
684
688
|
const variants = options.variantsDir ?? ".agent-worktrees";
|
|
685
689
|
const baseRef = options.baseRef ?? "HEAD";
|
|
@@ -697,20 +701,59 @@ async function createWorktree(options) {
|
|
|
697
701
|
}
|
|
698
702
|
async function captureWorktreeDiff(options) {
|
|
699
703
|
const baseRef = options.baseRef ?? options.worktree.baseSha;
|
|
700
|
-
|
|
704
|
+
const pathspecs = worktreeDiffPathspecs(options.excludePaths ?? []);
|
|
705
|
+
const staged = await runGitAsync(
|
|
706
|
+
["add", "-A", ...pathspecs.length > 0 ? ["--", ".", ...pathspecs] : []],
|
|
707
|
+
options.worktree.path,
|
|
708
|
+
options.runGit
|
|
709
|
+
);
|
|
710
|
+
ensureGitOk("add -A", staged);
|
|
701
711
|
const patch = await runGitAsync(
|
|
702
|
-
["diff", "--cached", baseRef],
|
|
712
|
+
["diff", "--cached", baseRef, ...pathspecs.length > 0 ? ["--", ".", ...pathspecs] : []],
|
|
703
713
|
options.worktree.path,
|
|
704
714
|
options.runGit
|
|
705
715
|
);
|
|
716
|
+
ensureGitOk(`diff --cached ${baseRef}`, patch);
|
|
706
717
|
const shortstat = await runGitAsync(
|
|
707
|
-
[
|
|
718
|
+
[
|
|
719
|
+
"diff",
|
|
720
|
+
"--cached",
|
|
721
|
+
"--shortstat",
|
|
722
|
+
baseRef,
|
|
723
|
+
...pathspecs.length > 0 ? ["--", ".", ...pathspecs] : []
|
|
724
|
+
],
|
|
708
725
|
options.worktree.path,
|
|
709
726
|
options.runGit
|
|
710
727
|
);
|
|
728
|
+
ensureGitOk(`diff --cached --shortstat ${baseRef}`, shortstat);
|
|
711
729
|
const stats = parseShortstat(shortstat.stdout);
|
|
712
730
|
return { patch: patch.stdout, stats };
|
|
713
731
|
}
|
|
732
|
+
function worktreeDiffPathspecs(paths) {
|
|
733
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
734
|
+
for (const path2 of paths) {
|
|
735
|
+
if (typeof path2 !== "string" || path2.length === 0 || path2.includes("\\") || hasControlCharacter(path2) || isAbsolute(path2) || win32.isAbsolute(path2)) {
|
|
736
|
+
throw new Error(
|
|
737
|
+
`worktree: excluded path must be a canonical repository-relative path: ${path2}`
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
const segments = path2.split("/");
|
|
741
|
+
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
742
|
+
throw new Error(
|
|
743
|
+
`worktree: excluded path must be a canonical repository-relative path: ${path2}`
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
normalized.add(path2);
|
|
747
|
+
}
|
|
748
|
+
return [...normalized].sort((left, right) => left.localeCompare(right)).map((path2) => `:(top,exclude,literal)${path2}`);
|
|
749
|
+
}
|
|
750
|
+
function hasControlCharacter(value) {
|
|
751
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
752
|
+
const code = value.charCodeAt(index);
|
|
753
|
+
if (code < 32 || code === 127) return true;
|
|
754
|
+
}
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
714
757
|
function parseShortstat(text) {
|
|
715
758
|
const out = { filesChanged: 0, insertions: 0, deletions: 0 };
|
|
716
759
|
const filesMatch = text.match(/(\d+)\s+files?\s+changed/);
|
|
@@ -726,19 +769,22 @@ async function removeWorktree(options) {
|
|
|
726
769
|
const args = ["worktree", "remove"];
|
|
727
770
|
if (force) args.push("--force");
|
|
728
771
|
args.push(options.worktree.path);
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
["branch", "-D", options.worktree.branch],
|
|
733
|
-
options.repoRoot,
|
|
734
|
-
options.runGit
|
|
735
|
-
).catch(() => void 0);
|
|
736
|
-
}
|
|
737
|
-
await runGitAsync(
|
|
772
|
+
const removal = await runGitAsync(args, options.repoRoot, options.runGit);
|
|
773
|
+
const removalError = removal.exitCode !== 0 && !/not a working tree/iu.test(removal.stderr) ? gitFailure(`worktree remove ${options.worktree.path}`, removal) : void 0;
|
|
774
|
+
const branchRemoval = await runGitAsync(
|
|
738
775
|
["branch", "-D", options.worktree.branch],
|
|
739
776
|
options.repoRoot,
|
|
740
777
|
options.runGit
|
|
741
|
-
)
|
|
778
|
+
);
|
|
779
|
+
const branchError = branchRemoval.exitCode !== 0 && !/branch .+ not found/iu.test(branchRemoval.stderr) ? gitFailure(`branch -D ${options.worktree.branch}`, branchRemoval) : void 0;
|
|
780
|
+
if (removalError && branchError) {
|
|
781
|
+
throw new AggregateError(
|
|
782
|
+
[removalError, branchError],
|
|
783
|
+
"worktree: failed to remove worktree and branch"
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
if (removalError) throw removalError;
|
|
787
|
+
if (branchError) throw branchError;
|
|
742
788
|
}
|
|
743
789
|
|
|
744
790
|
// src/runtime/router-client.ts
|
|
@@ -1960,6 +2006,11 @@ import { randomUUID } from "crypto";
|
|
|
1960
2006
|
|
|
1961
2007
|
// src/mcp/worktree-harness.ts
|
|
1962
2008
|
import { spawn as spawn2 } from "child_process";
|
|
2009
|
+
import { createHash } from "crypto";
|
|
2010
|
+
import {
|
|
2011
|
+
applyWorkspacePlan,
|
|
2012
|
+
materializeProfile
|
|
2013
|
+
} from "@tangle-network/agent-profile-materialize";
|
|
1963
2014
|
var defaultCheckOutputCap = 16e3;
|
|
1964
2015
|
async function runWorktreeHarness(opts) {
|
|
1965
2016
|
const runHarness = opts.runHarness ?? runLocalHarness;
|
|
@@ -1976,9 +2027,24 @@ async function runWorktreeHarness(opts) {
|
|
|
1976
2027
|
worktree,
|
|
1977
2028
|
repoRoot: opts.repoRoot,
|
|
1978
2029
|
...opts.runGit ? { runGit: opts.runGit } : {}
|
|
1979
|
-
})
|
|
2030
|
+
});
|
|
1980
2031
|
try {
|
|
1981
|
-
|
|
2032
|
+
assertSupportedWorktreeProfile(opts.profile, opts.harness);
|
|
2033
|
+
const resourceInstructions = resolveResourceInstructions(opts.profile);
|
|
2034
|
+
const workspaceProfile = materializationOnlyProfile(opts.profile);
|
|
2035
|
+
const plan = materializeProfile(workspaceProfile, opts.harness);
|
|
2036
|
+
if (plan.unsupported.length > 0) {
|
|
2037
|
+
throw new Error(
|
|
2038
|
+
`runWorktreeHarness: profile cannot be materialized for ${opts.harness}: ${plan.unsupported.map(({ dimension, reason }) => `${dimension}: ${reason}`).join("; ")}`
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
assertSafeMaterializedPaths(plan);
|
|
2042
|
+
const applied = applyWorkspacePlan(plan, worktree.path);
|
|
2043
|
+
if (applied.unsupported.length > 0) {
|
|
2044
|
+
throw new Error("runWorktreeHarness: applied profile unexpectedly retained unsupported rows");
|
|
2045
|
+
}
|
|
2046
|
+
const invocationProfile = profileWithResourceInstructions(opts.profile, resourceInstructions);
|
|
2047
|
+
const { command, args } = harnessInvocation(opts.harness, invocationProfile, opts.taskPrompt, {
|
|
1982
2048
|
// This helper created the candidate worktree above; autonomous Claude
|
|
1983
2049
|
// edits are permitted only inside that isolated checkout.
|
|
1984
2050
|
dangerouslySkipPermissions: opts.harness === "claude",
|
|
@@ -1988,7 +2054,8 @@ async function runWorktreeHarness(opts) {
|
|
|
1988
2054
|
harness: opts.harness,
|
|
1989
2055
|
cwd: worktree.path,
|
|
1990
2056
|
taskPrompt: opts.taskPrompt,
|
|
1991
|
-
invocation: { command, args },
|
|
2057
|
+
invocation: { command, args: [...args, ...applied.flags] },
|
|
2058
|
+
env: { ...process.env, ...applied.env },
|
|
1992
2059
|
...opts.codexReproducible ? { codexReproducible: true } : {},
|
|
1993
2060
|
...opts.codexReadDeniedPaths ? { codexReadDeniedPaths: opts.codexReadDeniedPaths } : {},
|
|
1994
2061
|
...opts.harnessTimeoutMs !== void 0 ? { timeoutMs: opts.harnessTimeoutMs } : {},
|
|
@@ -1996,6 +2063,7 @@ async function runWorktreeHarness(opts) {
|
|
|
1996
2063
|
});
|
|
1997
2064
|
const diff = await captureWorktreeDiff({
|
|
1998
2065
|
worktree,
|
|
2066
|
+
excludePaths: applied.written,
|
|
1999
2067
|
...opts.runGit ? { runGit: opts.runGit } : {}
|
|
2000
2068
|
});
|
|
2001
2069
|
const checks = await runWorktreeChecks({
|
|
@@ -2011,6 +2079,7 @@ async function runWorktreeHarness(opts) {
|
|
|
2011
2079
|
branch: worktree.branch,
|
|
2012
2080
|
patch: diff.patch,
|
|
2013
2081
|
stats: diff.stats,
|
|
2082
|
+
profileMaterialization: profileMaterializationReceipt(applied, resourceInstructions),
|
|
2014
2083
|
harness: {
|
|
2015
2084
|
name: opts.harness,
|
|
2016
2085
|
exitCode: harnessResult.exitCode,
|
|
@@ -2037,10 +2106,141 @@ async function runWorktreeHarness(opts) {
|
|
|
2037
2106
|
};
|
|
2038
2107
|
return { worktree, result, cleanup };
|
|
2039
2108
|
} catch (err) {
|
|
2040
|
-
|
|
2109
|
+
try {
|
|
2110
|
+
await cleanup();
|
|
2111
|
+
} catch (cleanupError) {
|
|
2112
|
+
throw new AggregateError(
|
|
2113
|
+
[err, cleanupError],
|
|
2114
|
+
"runWorktreeHarness: run failed and worktree cleanup also failed"
|
|
2115
|
+
);
|
|
2116
|
+
}
|
|
2041
2117
|
throw err;
|
|
2042
2118
|
}
|
|
2043
2119
|
}
|
|
2120
|
+
function resolveResourceInstructions(profile) {
|
|
2121
|
+
const instructions = profile.resources?.instructions;
|
|
2122
|
+
if (instructions === void 0) return void 0;
|
|
2123
|
+
if (typeof instructions === "string")
|
|
2124
|
+
return instructions.trim().length > 0 ? instructions : void 0;
|
|
2125
|
+
if (instructions.kind === "inline" && typeof instructions.content === "string") {
|
|
2126
|
+
return instructions.content.trim().length > 0 ? instructions.content : void 0;
|
|
2127
|
+
}
|
|
2128
|
+
throw new Error(
|
|
2129
|
+
"runWorktreeHarness: resources.instructions must be a string or inline resource; remote refs require pre-resolution"
|
|
2130
|
+
);
|
|
2131
|
+
}
|
|
2132
|
+
function profileWithResourceInstructions(profile, resourceInstructions) {
|
|
2133
|
+
let resources;
|
|
2134
|
+
if (profile.resources) {
|
|
2135
|
+
const { instructions: _instructions, ...structuralResources } = profile.resources;
|
|
2136
|
+
resources = structuralResources;
|
|
2137
|
+
}
|
|
2138
|
+
return {
|
|
2139
|
+
...profile,
|
|
2140
|
+
...resources ? { resources } : {},
|
|
2141
|
+
...resourceInstructions === void 0 ? {} : {
|
|
2142
|
+
prompt: {
|
|
2143
|
+
...profile.prompt,
|
|
2144
|
+
instructions: [...profile.prompt?.instructions ?? [], resourceInstructions]
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
function materializationOnlyProfile(profile) {
|
|
2150
|
+
const {
|
|
2151
|
+
prompt: _prompt,
|
|
2152
|
+
model: _model,
|
|
2153
|
+
resources: profileResources,
|
|
2154
|
+
...structuralProfile
|
|
2155
|
+
} = profile;
|
|
2156
|
+
let resources;
|
|
2157
|
+
if (profileResources) {
|
|
2158
|
+
const { instructions: _instructions, ...fileBackedResources } = profileResources;
|
|
2159
|
+
resources = fileBackedResources;
|
|
2160
|
+
}
|
|
2161
|
+
return {
|
|
2162
|
+
...structuralProfile,
|
|
2163
|
+
...resources ? { resources } : {}
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
function assertSupportedWorktreeProfile(profile, harness) {
|
|
2167
|
+
const unsupportedAxes = [
|
|
2168
|
+
hasEntries(profile.tools) ? "tools" : null,
|
|
2169
|
+
hasEntries(profile.permissions) ? "permissions" : null,
|
|
2170
|
+
profile.connections && profile.connections.length > 0 ? "connections" : null,
|
|
2171
|
+
hasEntries(profile.confidential) ? "confidential" : null,
|
|
2172
|
+
hasEntries(profile.modes) ? "modes" : null,
|
|
2173
|
+
hasEntries(profile.extensions) ? "extensions" : null
|
|
2174
|
+
].filter((axis) => axis !== null);
|
|
2175
|
+
if (profile.model?.reasoningEffort !== void 0 && harness !== "codex") {
|
|
2176
|
+
unsupportedAxes.push("model.reasoningEffort");
|
|
2177
|
+
}
|
|
2178
|
+
for (const [name, server] of Object.entries(profile.mcp ?? {})) {
|
|
2179
|
+
const path2 = `mcp[${JSON.stringify(name)}]`;
|
|
2180
|
+
if (server.enabled === false && harness !== "opencode") {
|
|
2181
|
+
unsupportedAxes.push(`${path2}.enabled`);
|
|
2182
|
+
}
|
|
2183
|
+
if (hasEntries(server.headers) && harness === "codex") {
|
|
2184
|
+
unsupportedAxes.push(`${path2}.headers`);
|
|
2185
|
+
}
|
|
2186
|
+
if (server.cwd !== void 0 && harness === "opencode") {
|
|
2187
|
+
unsupportedAxes.push(`${path2}.cwd`);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
if (harness === "claude") {
|
|
2191
|
+
for (const [event, commands] of Object.entries(profile.hooks ?? {})) {
|
|
2192
|
+
for (const [index, command] of commands.entries()) {
|
|
2193
|
+
const path2 = `hooks[${JSON.stringify(event)}][${index}]`;
|
|
2194
|
+
if (hasEntries(command.env)) unsupportedAxes.push(`${path2}.env`);
|
|
2195
|
+
if (command.blocking !== void 0) unsupportedAxes.push(`${path2}.blocking`);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
for (const [name, subagent] of Object.entries(profile.subagents ?? {})) {
|
|
2200
|
+
const path2 = `subagents[${JSON.stringify(name)}]`;
|
|
2201
|
+
if (hasEntries(subagent.permissions)) unsupportedAxes.push(`${path2}.permissions`);
|
|
2202
|
+
if (subagent.maxSteps !== void 0) unsupportedAxes.push(`${path2}.maxSteps`);
|
|
2203
|
+
if (hasEntries(subagent.tools) && harness !== "claude") {
|
|
2204
|
+
unsupportedAxes.push(`${path2}.tools`);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (unsupportedAxes.length > 0) {
|
|
2208
|
+
throw new Error(
|
|
2209
|
+
`runWorktreeHarness: profile requests unsupported worktree behavior: ${unsupportedAxes.join(", ")}`
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
function hasEntries(value) {
|
|
2214
|
+
return value !== void 0 && Object.keys(value).length > 0;
|
|
2215
|
+
}
|
|
2216
|
+
function assertSafeMaterializedPaths(plan) {
|
|
2217
|
+
for (const file of plan.files) {
|
|
2218
|
+
if (file.relPath.split("/").some(isGitMetadataSegment)) {
|
|
2219
|
+
throw new Error(
|
|
2220
|
+
`runWorktreeHarness: profile file cannot target reserved Git metadata: ${file.relPath}`
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
function isGitMetadataSegment(segment) {
|
|
2226
|
+
const windowsCanonical = segment.replace(/[ .]+$/u, "").toLowerCase();
|
|
2227
|
+
return windowsCanonical === ".git" || windowsCanonical.startsWith(".git:");
|
|
2228
|
+
}
|
|
2229
|
+
function profileMaterializationReceipt(applied, resourceInstructions) {
|
|
2230
|
+
const instructionBytes = resourceInstructions === void 0 ? null : Buffer.from(resourceInstructions, "utf8");
|
|
2231
|
+
return {
|
|
2232
|
+
workspacePlanDigest: applied.workspacePlanDigest,
|
|
2233
|
+
writtenPaths: [...applied.written],
|
|
2234
|
+
unsupported: [...applied.unsupported],
|
|
2235
|
+
environmentNames: Object.keys(applied.env).sort(),
|
|
2236
|
+
flags: [...applied.flags],
|
|
2237
|
+
resourceInstructions: instructionBytes ? {
|
|
2238
|
+
delivery: "invocation-prompt",
|
|
2239
|
+
sha256: `sha256:${createHash("sha256").update(instructionBytes).digest("hex")}`,
|
|
2240
|
+
byteLength: instructionBytes.byteLength
|
|
2241
|
+
} : { delivery: "none", sha256: null, byteLength: 0 }
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2044
2244
|
async function runWorktreeChecks(opts) {
|
|
2045
2245
|
if (opts.testCmd === void 0 && opts.typecheckCmd === void 0) return void 0;
|
|
2046
2246
|
const runCommand = opts.runCommand ?? defaultRunCommand;
|
|
@@ -6626,4 +6826,4 @@ export {
|
|
|
6626
6826
|
workerFromBackend,
|
|
6627
6827
|
supervise
|
|
6628
6828
|
};
|
|
6629
|
-
//# sourceMappingURL=chunk-
|
|
6829
|
+
//# sourceMappingURL=chunk-C3UKLQ54.js.map
|