|
1 | 1 | import type { WorktreeExecFn } from "@loopover/engine"; |
2 | 2 | import type { RunGitFn } from "./repo-clone.js"; |
3 | | - |
4 | | -export function createRealWorktreeExec(timeoutMs?: number): WorktreeExecFn; |
5 | | - |
| 3 | +/** |
| 4 | + * Real child_process-backed implementation of the engine's WorktreeExecFn contract. Resolves (never |
| 5 | + * rejects) on error/timeout, mirroring coding-agent-construction.js's createRealCliSubprocessSpawn -- a |
| 6 | + * failed `git worktree add`'s stderr is the diagnosable signal, not something to lose to an unhandled |
| 7 | + * rejection. |
| 8 | + */ |
| 9 | +export declare function createRealWorktreeExec(timeoutMs?: number): WorktreeExecFn; |
6 | 10 | export type PrepareAttemptWorktreeOptions = { |
7 | | - baseBranch?: string; |
8 | | - cloneBaseDir?: string; |
9 | | - env?: Record<string, string | undefined>; |
10 | | - exec?: WorktreeExecFn; |
11 | | - timeoutMs?: number; |
12 | | - remoteUrl?: string; |
13 | | - runGit?: RunGitFn; |
| 11 | + baseBranch?: string; |
| 12 | + cloneBaseDir?: string; |
| 13 | + env?: Record<string, string | undefined>; |
| 14 | + exec?: WorktreeExecFn; |
| 15 | + timeoutMs?: number; |
| 16 | + remoteUrl?: string; |
| 17 | + runGit?: RunGitFn; |
14 | 18 | }; |
15 | | - |
16 | | -export type PrepareAttemptWorktreeResult = |
17 | | - | { ok: true; worktreePath: string; branchName: string; repoPath: string } |
18 | | - | { ok: false; repoPath?: string; error: string }; |
19 | | - |
20 | | -export function prepareAttemptWorktree( |
21 | | - repoFullName: string, |
22 | | - attemptId: string, |
23 | | - options?: PrepareAttemptWorktreeOptions, |
24 | | -): Promise<PrepareAttemptWorktreeResult>; |
25 | | - |
26 | | -export function cleanupAttemptWorktree( |
27 | | - repoPath: string, |
28 | | - worktreePath: string, |
29 | | - attemptOk: boolean, |
30 | | - options?: { exec?: WorktreeExecFn; timeoutMs?: number }, |
31 | | -): Promise<{ ok: boolean; removed: boolean; error?: string }>; |
| 19 | +export type PrepareAttemptWorktreeResult = { |
| 20 | + ok: true; |
| 21 | + worktreePath: string; |
| 22 | + branchName: string; |
| 23 | + repoPath: string; |
| 24 | +} | { |
| 25 | + ok: false; |
| 26 | + repoPath?: string; |
| 27 | + error: string; |
| 28 | +}; |
| 29 | +/** |
| 30 | + * Prepare a real, isolated git worktree for one attempt: ensure the target repo's base clone exists and is |
| 31 | + * current, then create a fresh `git worktree` off it on a deterministically-named branch. Fails closed |
| 32 | + * (`ok: false`) on any step's failure rather than handing back a half-prepared directory. |
| 33 | + */ |
| 34 | +export declare function prepareAttemptWorktree(repoFullName: string, attemptId: string, options?: PrepareAttemptWorktreeOptions): Promise<PrepareAttemptWorktreeResult>; |
| 35 | +/** |
| 36 | + * Tear down an attempt's worktree once the attempt concludes, per the engine's own retention policy: a |
| 37 | + * failed attempt's worktree is RETAINED for post-mortem inspection, a succeeded one is removed. |
| 38 | + */ |
| 39 | +export declare function cleanupAttemptWorktree(repoPath: string, worktreePath: string, attemptOk: boolean, options?: { |
| 40 | + exec?: WorktreeExecFn; |
| 41 | + timeoutMs?: number; |
| 42 | +}): Promise<{ |
| 43 | + ok: boolean; |
| 44 | + removed: boolean; |
| 45 | + error?: string; |
| 46 | +}>; |
0 commit comments