@claudexor/workspace 5.0.2 → 5.1.0
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/cleanup-fault.d.ts +9 -0
- package/dist/cleanup-fault.d.ts.map +1 -1
- package/dist/cleanup-fault.js +21 -0
- package/dist/cleanup-fault.js.map +1 -1
- package/dist/continuation-evidence.d.ts +66 -8
- package/dist/continuation-evidence.d.ts.map +1 -1
- package/dist/continuation-evidence.js +32 -14
- package/dist/continuation-evidence.js.map +1 -1
- package/dist/continuation-sources.d.ts +1 -1
- package/dist/envelope-recovery.d.ts +25 -0
- package/dist/envelope-recovery.d.ts.map +1 -1
- package/dist/envelope-recovery.js +61 -1
- package/dist/envelope-recovery.js.map +1 -1
- package/dist/git.d.ts +10 -3
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +39 -10
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/isolated-clone-content.d.ts +29 -0
- package/dist/isolated-clone-content.d.ts.map +1 -0
- package/dist/isolated-clone-content.js +103 -0
- package/dist/isolated-clone-content.js.map +1 -0
- package/dist/lanes.d.ts +4 -4
- package/dist/lanes.d.ts.map +1 -1
- package/dist/lanes.js +7 -7
- package/dist/lanes.js.map +1 -1
- package/dist/manager.d.ts +5 -11
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +21 -33
- package/dist/manager.js.map +1 -1
- package/dist/object-store-retire.d.ts +17 -0
- package/dist/object-store-retire.d.ts.map +1 -0
- package/dist/object-store-retire.js +74 -0
- package/dist/object-store-retire.js.map +1 -0
- package/dist/object-store.d.ts +4 -0
- package/dist/object-store.d.ts.map +1 -1
- package/dist/object-store.js +13 -2
- package/dist/object-store.js.map +1 -1
- package/dist/raw-patch.d.ts +19 -1
- package/dist/raw-patch.d.ts.map +1 -1
- package/dist/raw-patch.js +47 -24
- package/dist/raw-patch.js.map +1 -1
- package/dist/retained-envelopes.d.ts.map +1 -1
- package/dist/retained-envelopes.js +6 -2
- package/dist/retained-envelopes.js.map +1 -1
- package/package.json +5 -5
package/dist/cleanup-fault.d.ts
CHANGED
|
@@ -15,4 +15,13 @@ export interface HeldScratch {
|
|
|
15
15
|
* threw: its fault is noted beside that outcome ({@link noteCleanupFault}).
|
|
16
16
|
*/
|
|
17
17
|
export declare function withDisposableScratch<T>(body: (held: HeldScratch) => Promise<T>): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* An envelope whose creation failed before it was returned never started: no harness
|
|
20
|
+
* ran in it, and no caller holds it to dispose of. Its creator, which made `base` in
|
|
21
|
+
* this same call, removes it whole (#501); the orphan sweeper keeps a directory whose
|
|
22
|
+
* creating process is alive, so nothing else would. A removal that fails leaves it,
|
|
23
|
+
* keeps `refusal` as the outcome and says so: the fault is noted beside it and named
|
|
24
|
+
* after its message. Returns what to throw.
|
|
25
|
+
*/
|
|
26
|
+
export declare function discardUnstartedEnvelope(base: string, refusal: unknown): unknown;
|
|
18
27
|
//# sourceMappingURL=cleanup-fault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup-fault.d.ts","sourceRoot":"","sources":["../src/cleanup-fault.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAQvE;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACtC,OAAO,CAAC,CAAC,CAAC,CAeZ"}
|
|
1
|
+
{"version":3,"file":"cleanup-fault.d.ts","sourceRoot":"","sources":["../src/cleanup-fault.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAQvE;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACtC,OAAO,CAAC,CAAC,CAAC,CAeZ;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAWhF"}
|
package/dist/cleanup-fault.js
CHANGED
|
@@ -42,4 +42,25 @@ export async function withDisposableScratch(body) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* An envelope whose creation failed before it was returned never started: no harness
|
|
47
|
+
* ran in it, and no caller holds it to dispose of. Its creator, which made `base` in
|
|
48
|
+
* this same call, removes it whole (#501); the orphan sweeper keeps a directory whose
|
|
49
|
+
* creating process is alive, so nothing else would. A removal that fails leaves it,
|
|
50
|
+
* keeps `refusal` as the outcome and says so: the fault is noted beside it and named
|
|
51
|
+
* after its message. Returns what to throw.
|
|
52
|
+
*/
|
|
53
|
+
export function discardUnstartedEnvelope(base, refusal) {
|
|
54
|
+
try {
|
|
55
|
+
rmSync(base, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
catch (fault) {
|
|
58
|
+
noteCleanupFault(refusal, fault);
|
|
59
|
+
if (refusal instanceof Error) {
|
|
60
|
+
const why = fault instanceof Error ? fault.message : String(fault);
|
|
61
|
+
refusal.message = `${refusal.message}; its never-started envelope ${base} could not be removed: ${why}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return refusal;
|
|
65
|
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AM,UAAU,wBAAwB,CAAC,IAAY,EAAE,OAAgB;IACrE,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,OAAO,CAAC,OAAO,GAAG,GAAG,OAAO,CAAC,OAAO,gCAAgC,IAAI,0BAA0B,GAAG,EAAE,CAAC;QAC1G,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -10,14 +10,18 @@ interface HeldSession {
|
|
|
10
10
|
* Recorded assistant output that what a run carries forward does not
|
|
11
11
|
* represent, each block once under its attempt and native try (its process
|
|
12
12
|
* session). The represented try is the last accepted try of
|
|
13
|
-
* `representedAttempt`, whose answer or report is carried: its last typed
|
|
14
|
-
* final (AnswerAssembly's answer)
|
|
15
|
-
* its other narration and earlier
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* `representedAttempt`, whose answer or report is carried: only its last typed
|
|
14
|
+
* final (AnswerAssembly's answer) is left out, as one block with its own keyed
|
|
15
|
+
* and exact adjacent streamed forms; its other narration and earlier
|
|
16
|
+
* native-turn finals stay (with no typed final its joined narration is the
|
|
17
|
+
* carried answer, so the whole try is left out). Identity decides, never text:
|
|
18
|
+
* equal or contained words elsewhere stay, and without a represented try
|
|
19
|
+
* nothing is left out. Read from events the caller already holds.
|
|
20
|
+
*
|
|
21
|
+
* `_carried`, the carried text earlier callers pass, is accepted so they still
|
|
22
|
+
* compile and is ignored: that prose identifies no recorded event (#568).
|
|
19
23
|
*/
|
|
20
|
-
export declare function unrepresentedOutput(events: readonly RunEvent[], facts: RunExecutionFacts, representedAttempt: string | null,
|
|
24
|
+
export declare function unrepresentedOutput(events: readonly RunEvent[], facts: RunExecutionFacts, representedAttempt: string | null, _carried?: string): string | null;
|
|
21
25
|
/**
|
|
22
26
|
* Whether a run is its own continuation source: it declared a terminal block,
|
|
23
27
|
* holds a carrying session or recorded its own work. The successor's planner
|
|
@@ -29,6 +33,21 @@ export declare function ownsContinuationSource(evidence: {
|
|
|
29
33
|
held: HeldSession | null;
|
|
30
34
|
hasEvidence: boolean;
|
|
31
35
|
}): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A run's recorded assistant output, by one rule for every reader that carries
|
|
38
|
+
* it forward (a `continueFrom` successor, a thread's next lane): its
|
|
39
|
+
* `final/retained-output.md` exactly as stored, else the same projection of its
|
|
40
|
+
* event log, for a run whose terminal never wrote that file (an engine restart
|
|
41
|
+
* interrupted it, or the write failed). `source` is the file the text is read
|
|
42
|
+
* or rendered from; null when neither holds any output.
|
|
43
|
+
*/
|
|
44
|
+
export declare function recordedOutput(runDir: string, log?: () => {
|
|
45
|
+
events: RunEvent[];
|
|
46
|
+
malformed: number;
|
|
47
|
+
}): {
|
|
48
|
+
text: string;
|
|
49
|
+
source: string;
|
|
50
|
+
} | null;
|
|
32
51
|
/**
|
|
33
52
|
* The source a status projection names, by the planner's own rule: the
|
|
34
53
|
* carrying session and whether the run is its own source. A declared terminal
|
|
@@ -42,7 +61,7 @@ export declare function continuationSource(runDir: string, facts?: () => RunExec
|
|
|
42
61
|
};
|
|
43
62
|
export declare function readContinuationEvidence(runDir: string): {
|
|
44
63
|
resumable: {
|
|
45
|
-
cause: "cancelled" | "context_exhausted" | "host_restart" | "input_required" | "other" | "permission_denied" | "pinned_limit" | "pool_exhausted" | "transport" | "vendor_limit" | "wall_clock";
|
|
64
|
+
cause: "cancelled" | "context_exhausted" | "host_restart" | "input_required" | "other" | "permission_denied" | "pinned_limit" | "pool_exhausted" | "transport" | "turn_limit" | "vendor_limit" | "wall_clock";
|
|
46
65
|
resetsAt: string | null;
|
|
47
66
|
limitWindow: string | null;
|
|
48
67
|
limitEvidence: "unspecified" | "window" | null;
|
|
@@ -90,6 +109,10 @@ export declare function readContinuationEvidence(runDir: string): {
|
|
|
90
109
|
native_code: "grok_credential_source_unconfirmed";
|
|
91
110
|
source: "grok_init";
|
|
92
111
|
reported_source: string;
|
|
112
|
+
} | {
|
|
113
|
+
kind: "vendor_not_retryable";
|
|
114
|
+
source: "agy_stderr";
|
|
115
|
+
error_id: string | null;
|
|
93
116
|
} | undefined;
|
|
94
117
|
effort_resolution?: {
|
|
95
118
|
requested: string | null;
|
|
@@ -170,10 +193,23 @@ export declare function readContinuationEvidence(runDir: string): {
|
|
|
170
193
|
satisfied: boolean;
|
|
171
194
|
status: "attempted" | "failed" | "none" | "satisfied" | "unverified";
|
|
172
195
|
verification: "dispatched" | "none" | "verified";
|
|
196
|
+
verified_content: "page" | "search_results" | null;
|
|
173
197
|
tool: string | null;
|
|
174
198
|
target: string | null;
|
|
175
199
|
error_summary: string | null;
|
|
200
|
+
observation: {
|
|
201
|
+
evidence: "tool_calls";
|
|
202
|
+
network: "not_measured";
|
|
203
|
+
};
|
|
176
204
|
};
|
|
205
|
+
route_controls?: {
|
|
206
|
+
web_mechanism: "native" | "none" | "tools" | "uncontrolled";
|
|
207
|
+
access: "full" | "inherit_native" | "readonly" | "workspace_write";
|
|
208
|
+
native_access: string | null;
|
|
209
|
+
access_mechanism: "fs_sandbox" | "native_settings" | "none" | "permission_deny" | "tool_allowlist" | "tool_policy";
|
|
210
|
+
} | undefined;
|
|
211
|
+
native_session_started?: boolean | undefined;
|
|
212
|
+
harness_home_isolated?: boolean | undefined;
|
|
177
213
|
tool_errors: {
|
|
178
214
|
tool: string;
|
|
179
215
|
kind: "command" | "file" | "mcp" | "other" | "search" | "web";
|
|
@@ -184,6 +220,23 @@ export declare function readContinuationEvidence(runDir: string): {
|
|
|
184
220
|
}[];
|
|
185
221
|
tool_errors_total: number;
|
|
186
222
|
unrecovered_tool_errors: number;
|
|
223
|
+
reported_command_outcomes?: {
|
|
224
|
+
total: number;
|
|
225
|
+
recent: {
|
|
226
|
+
tool: string;
|
|
227
|
+
target: string | null;
|
|
228
|
+
tool_use_id: string;
|
|
229
|
+
command_outcome: {
|
|
230
|
+
state: "backgrounded" | "completion_reported" | "exited" | "timed_out" | "unknown";
|
|
231
|
+
signal?: string | undefined;
|
|
232
|
+
timeout_ms?: number | undefined;
|
|
233
|
+
background_reason?: "requested" | "timeout" | undefined;
|
|
234
|
+
shell_id?: string | undefined;
|
|
235
|
+
pid?: number | undefined;
|
|
236
|
+
completion_status?: "aborted" | "error" | "success" | undefined;
|
|
237
|
+
};
|
|
238
|
+
}[];
|
|
239
|
+
} | undefined;
|
|
187
240
|
statusless_tool_results: number;
|
|
188
241
|
dropped_events: number;
|
|
189
242
|
transient_failures: {
|
|
@@ -228,6 +281,11 @@ export declare function readContinuationEvidence(runDir: string): {
|
|
|
228
281
|
satisfied: boolean;
|
|
229
282
|
failed: boolean;
|
|
230
283
|
unused: boolean;
|
|
284
|
+
startup?: {
|
|
285
|
+
status: "cancelled" | "failed" | "not_observed" | "ready" | "starting";
|
|
286
|
+
waited_ms: number;
|
|
287
|
+
error: string | null;
|
|
288
|
+
} | undefined;
|
|
231
289
|
} | undefined;
|
|
232
290
|
usage: {
|
|
233
291
|
input_tokens: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continuation-evidence.d.ts","sourceRoot":"","sources":["../src/continuation-evidence.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAgB,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG9F,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAg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CAAA;CAAE,GAAG,IAAI,CAOzC;AAwBD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,iBAAiB,GAC9B;IAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAgB7C;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CtD"}
|
|
@@ -3,7 +3,7 @@ import { existsSync, readdirSync } from "node:fs";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { parse as yamlParse } from "yaml";
|
|
5
5
|
import { RunResumable, RunTelemetry, SessionCapsule } from "@claudexor/schema";
|
|
6
|
-
import { readRunEvents, retainedOutput } from "@claudexor/event-log";
|
|
6
|
+
import { RETAINED_OUTPUT_PATH, readRunEvents, retainedOutput } from "@claudexor/event-log";
|
|
7
7
|
import { readTextSafe } from "@claudexor/util";
|
|
8
8
|
import { carryingAttempt, recordedSessionMemory, runExecutionFacts, uncoveredAttempts, } from "./continuation-facts.js";
|
|
9
9
|
import { readContinuationSources } from "./continuation-sources.js";
|
|
@@ -77,23 +77,24 @@ function terminalRecords(runDir) {
|
|
|
77
77
|
* Recorded assistant output that what a run carries forward does not
|
|
78
78
|
* represent, each block once under its attempt and native try (its process
|
|
79
79
|
* session). The represented try is the last accepted try of
|
|
80
|
-
* `representedAttempt`, whose answer or report is carried: its last typed
|
|
81
|
-
* final (AnswerAssembly's answer)
|
|
82
|
-
* its other narration and earlier
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
80
|
+
* `representedAttempt`, whose answer or report is carried: only its last typed
|
|
81
|
+
* final (AnswerAssembly's answer) is left out, as one block with its own keyed
|
|
82
|
+
* and exact adjacent streamed forms; its other narration and earlier
|
|
83
|
+
* native-turn finals stay (with no typed final its joined narration is the
|
|
84
|
+
* carried answer, so the whole try is left out). Identity decides, never text:
|
|
85
|
+
* equal or contained words elsewhere stay, and without a represented try
|
|
86
|
+
* nothing is left out. Read from events the caller already holds.
|
|
87
|
+
*
|
|
88
|
+
* `_carried`, the carried text earlier callers pass, is accepted so they still
|
|
89
|
+
* compile and is ignored: that prose identifies no recorded event (#568).
|
|
86
90
|
*/
|
|
87
|
-
export function unrepresentedOutput(events, facts, representedAttempt,
|
|
91
|
+
export function unrepresentedOutput(events, facts, representedAttempt, _carried) {
|
|
88
92
|
const session = facts.accepted
|
|
89
93
|
.filter((start) => start.attemptId === representedAttempt)
|
|
90
94
|
.at(-1)?.sessionId;
|
|
91
95
|
const represented = representedAttempt !== null && session ? { attempt: representedAttempt, session } : undefined;
|
|
92
96
|
const harness = events.filter((event) => event.type === "harness.event");
|
|
93
|
-
return
|
|
94
|
-
text: carried,
|
|
95
|
-
...(represented ? { represented } : {}),
|
|
96
|
-
})?.trim() || null);
|
|
97
|
+
return retainedOutput(harness, 0, false, represented ? { represented } : {})?.trim() || null;
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
99
100
|
* Whether a run is its own continuation source: it declared a terminal block,
|
|
@@ -104,6 +105,23 @@ export function unrepresentedOutput(events, facts, representedAttempt, carried)
|
|
|
104
105
|
export function ownsContinuationSource(evidence) {
|
|
105
106
|
return evidence.resumable !== undefined || evidence.held !== null || evidence.hasEvidence;
|
|
106
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* A run's recorded assistant output, by one rule for every reader that carries
|
|
110
|
+
* it forward (a `continueFrom` successor, a thread's next lane): its
|
|
111
|
+
* `final/retained-output.md` exactly as stored, else the same projection of its
|
|
112
|
+
* event log, for a run whose terminal never wrote that file (an engine restart
|
|
113
|
+
* interrupted it, or the write failed). `source` is the file the text is read
|
|
114
|
+
* or rendered from; null when neither holds any output.
|
|
115
|
+
*/
|
|
116
|
+
export function recordedOutput(runDir, log = () => readRunEvents(join(runDir, "events.jsonl"))) {
|
|
117
|
+
const stored = join(runDir, RETAINED_OUTPUT_PATH);
|
|
118
|
+
const text = readTextSafe(stored);
|
|
119
|
+
if (text?.trim())
|
|
120
|
+
return { text, source: stored };
|
|
121
|
+
const { events, malformed } = log();
|
|
122
|
+
const rendered = retainedOutput(events, malformed);
|
|
123
|
+
return rendered ? { text: rendered, source: join(runDir, "events.jsonl") } : null;
|
|
124
|
+
}
|
|
107
125
|
/** A run's own work outside its events: the source attempt's patch, its final answer and retained output. */
|
|
108
126
|
function sourceFiles(runDir, attemptId) {
|
|
109
127
|
const finalDir = join(runDir, "final");
|
|
@@ -161,12 +179,12 @@ export function readContinuationEvidence(runDir) {
|
|
|
161
179
|
// winning try's other narration and earlier native-turn finals) stays beside
|
|
162
180
|
// it as evidence, once under its attempt and try.
|
|
163
181
|
const winner = telemetry?.final_attempt_id ?? null;
|
|
164
|
-
const unrepresented = answer ? unrepresentedOutput(events.events, facts, winner
|
|
182
|
+
const unrepresented = answer ? unrepresentedOutput(events.events, facts, winner) : null;
|
|
165
183
|
const output = answer
|
|
166
184
|
? unrepresented
|
|
167
185
|
? `Final answer (final/answer.md${winner ? `, attempt ${winner}` : ""}):\n\n${answer}\n\n${unrepresented}`
|
|
168
186
|
: answer
|
|
169
|
-
: retained ||
|
|
187
|
+
: retained || recordedOutput(runDir, () => events)?.text || "";
|
|
170
188
|
return {
|
|
171
189
|
resumable,
|
|
172
190
|
held,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"continuation-evidence.js","sourceRoot":"","sources":["../src/continuation-evidence.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO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AAM,MAAM,GAAG,SAAS,EAAE,gBAAgB,IAAI,IAAI,CAAC;IACnD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxF,MAAM,MAAM,GAAG,MAAM;QACnB,CAAC,CAAC,aAAa;YACb,CAAC,CAAC,gCAAgC,MAAM,CAAC,CAAC,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,MAAM,OAAO,aAAa,EAAE;YAC1G,CAAC,CAAC,MAAM;QACV,CAAC,CAAC,QAAQ,IAAI,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;IACjE,OAAO;QACL,SAAS;QACT,IAAI;QACJ,aAAa;QACb,SAAS;QACT,wEAAwE;QACxE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAClE,2DAA2D;QAC3D,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;QAC/D,OAAO;QACP,KAAK;QACL,MAAM;QACN,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -26,7 +26,7 @@ export declare function retainedEnvelopeInChain(sources: ContinuationSources): {
|
|
|
26
26
|
dirty_policy: "refuse" | "snapshot";
|
|
27
27
|
created_at: string;
|
|
28
28
|
};
|
|
29
|
-
cause: "cancelled" | "context_exhausted" | "host_restart" | "input_required" | "other" | "permission_denied" | "pinned_limit" | "pool_exhausted" | "transport" | "vendor_limit" | "wall_clock" | null;
|
|
29
|
+
cause: "cancelled" | "context_exhausted" | "host_restart" | "input_required" | "other" | "permission_denied" | "pinned_limit" | "pool_exhausted" | "transport" | "turn_limit" | "vendor_limit" | "wall_clock" | null;
|
|
30
30
|
retained_at: string | null;
|
|
31
31
|
bytes: number | null;
|
|
32
32
|
} | null;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { WorkspaceEnvelope } from "@claudexor/schema";
|
|
1
2
|
export interface EnvelopeRecoveryRecord {
|
|
2
3
|
envelopeId: string;
|
|
3
4
|
workspaceMode: "in_place" | "isolated";
|
|
4
5
|
workspaceKind?: "git" | "directory";
|
|
6
|
+
/** The tree Git ran in, recorded at creation (#503); absent in legacy records. */
|
|
7
|
+
executionRoot?: string;
|
|
5
8
|
}
|
|
6
9
|
/** Read only the identity needed to dispose a crashed envelope. The caller
|
|
7
10
|
* decides whether missing legacy data is safe to fall back from. */
|
|
@@ -10,4 +13,26 @@ export declare function readEnvelopeRecoveryRecord(base: string): EnvelopeRecove
|
|
|
10
13
|
* equality is the recycling-proof liveness identity for envelope owners
|
|
11
14
|
* (command names/titles mutate; the kernel start time never does). */
|
|
12
15
|
export declare function processStartTime(pid: number): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The engine-owned runtime namespace an envelope base lives in, from its own
|
|
18
|
+
* recorded path (`<runtime>/workspaces/<task>/<attempt>`): a project namespace
|
|
19
|
+
* `projects/<sha256>` or the one-shot namespace (#503). Null for any other
|
|
20
|
+
* path, so a caller falls back to the legacy execution-root namespace and
|
|
21
|
+
* never removes anything outside an engine-owned workspaces directory.
|
|
22
|
+
*/
|
|
23
|
+
export declare function envelopeRuntimeRoot(base: string): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The scoped envelope base for a task/attempt under `workspacesDir`: the sole
|
|
26
|
+
* on-disk root dispose deletes, so the ids MUST be path-safe segments and the
|
|
27
|
+
* resolved base MUST stay inside the workspaces dir (a crafted `../` id could
|
|
28
|
+
* otherwise turn dispose() into an arbitrary recursive delete).
|
|
29
|
+
*/
|
|
30
|
+
export declare function envelopeBaseIn(workspacesDir: string, taskId: string, attemptId: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Where an envelope physically is: the base its own scoped HOME records, when
|
|
33
|
+
* that is an engine-owned `<runtime>/workspaces/<task>/<attempt>` of exactly
|
|
34
|
+
* these ids (an adopted envelope keeps its path whichever run holds it, #503);
|
|
35
|
+
* else the manager's own namespace (legacy records, foreign paths).
|
|
36
|
+
*/
|
|
37
|
+
export declare function physicalEnvelopeBase(env: Pick<WorkspaceEnvelope, "home_dir" | "task_id" | "attempt_id">, fallbackWorkspacesDir: string): string;
|
|
13
38
|
//# sourceMappingURL=envelope-recovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope-recovery.d.ts","sourceRoot":"","sources":["../src/envelope-recovery.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,aAAa,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope-recovery.d.ts","sourceRoot":"","sources":["../src/envelope-recovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,aAAa,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC;IACpC,kFAAkF;IAClF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;oEACoE;AACpE,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAyBtF;AAED;;sEAEsE;AACtE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS3D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO/D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAe/F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC,EACnE,qBAAqB,EAAE,MAAM,GAC5B,MAAM,CAQR"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, sep } from "node:path";
|
|
4
|
+
import { WorkspaceError } from "@claudexor/core";
|
|
5
|
+
import { oneShotRuntimeDir, userConfigDir } from "@claudexor/util";
|
|
4
6
|
/** Read only the identity needed to dispose a crashed envelope. The caller
|
|
5
7
|
* decides whether missing legacy data is safe to fall back from. */
|
|
6
8
|
export function readEnvelopeRecoveryRecord(base) {
|
|
@@ -14,6 +16,9 @@ export function readEnvelopeRecoveryRecord(base) {
|
|
|
14
16
|
envelopeId: parsed.envelope_id,
|
|
15
17
|
workspaceMode: parsed.workspace_mode,
|
|
16
18
|
...(parsed.workspace_kind === "directory" ? { workspaceKind: "directory" } : {}),
|
|
19
|
+
...(typeof parsed.execution_root === "string" && isAbsolute(parsed.execution_root)
|
|
20
|
+
? { executionRoot: parsed.execution_root }
|
|
21
|
+
: {}),
|
|
17
22
|
};
|
|
18
23
|
}
|
|
19
24
|
catch {
|
|
@@ -34,4 +39,59 @@ export function processStartTime(pid) {
|
|
|
34
39
|
return null;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The engine-owned runtime namespace an envelope base lives in, from its own
|
|
44
|
+
* recorded path (`<runtime>/workspaces/<task>/<attempt>`): a project namespace
|
|
45
|
+
* `projects/<sha256>` or the one-shot namespace (#503). Null for any other
|
|
46
|
+
* path, so a caller falls back to the legacy execution-root namespace and
|
|
47
|
+
* never removes anything outside an engine-owned workspaces directory.
|
|
48
|
+
*/
|
|
49
|
+
export function envelopeRuntimeRoot(base) {
|
|
50
|
+
const workspaces = dirname(dirname(base));
|
|
51
|
+
if (basename(workspaces) !== "workspaces")
|
|
52
|
+
return null;
|
|
53
|
+
const runtime = dirname(workspaces);
|
|
54
|
+
const projects = join(userConfigDir(), "projects");
|
|
55
|
+
if (runtime === oneShotRuntimeDir())
|
|
56
|
+
return runtime;
|
|
57
|
+
return dirname(runtime) === projects && /^[0-9a-f]{64}$/.test(basename(runtime)) ? runtime : null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The scoped envelope base for a task/attempt under `workspacesDir`: the sole
|
|
61
|
+
* on-disk root dispose deletes, so the ids MUST be path-safe segments and the
|
|
62
|
+
* resolved base MUST stay inside the workspaces dir (a crafted `../` id could
|
|
63
|
+
* otherwise turn dispose() into an arbitrary recursive delete).
|
|
64
|
+
*/
|
|
65
|
+
export function envelopeBaseIn(workspacesDir, taskId, attemptId) {
|
|
66
|
+
const idPattern = /^[A-Za-z0-9._-]+$/;
|
|
67
|
+
for (const [label, id] of [
|
|
68
|
+
["taskId", taskId],
|
|
69
|
+
["attemptId", attemptId],
|
|
70
|
+
]) {
|
|
71
|
+
if (!idPattern.test(id) || id === "." || id === "..") {
|
|
72
|
+
throw new WorkspaceError(`${label} '${id}' is not a safe path segment`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const base = join(workspacesDir, taskId, attemptId);
|
|
76
|
+
if (!base.startsWith(workspacesDir + sep)) {
|
|
77
|
+
throw new WorkspaceError(`envelope base escapes the workspaces dir: ${base}`);
|
|
78
|
+
}
|
|
79
|
+
return base;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Where an envelope physically is: the base its own scoped HOME records, when
|
|
83
|
+
* that is an engine-owned `<runtime>/workspaces/<task>/<attempt>` of exactly
|
|
84
|
+
* these ids (an adopted envelope keeps its path whichever run holds it, #503);
|
|
85
|
+
* else the manager's own namespace (legacy records, foreign paths).
|
|
86
|
+
*/
|
|
87
|
+
export function physicalEnvelopeBase(env, fallbackWorkspacesDir) {
|
|
88
|
+
const recorded = dirname(env.home_dir);
|
|
89
|
+
const runtime = envelopeRuntimeRoot(recorded);
|
|
90
|
+
if (runtime) {
|
|
91
|
+
const base = envelopeBaseIn(join(runtime, "workspaces"), env.task_id, env.attempt_id);
|
|
92
|
+
if (base === recorded)
|
|
93
|
+
return base;
|
|
94
|
+
}
|
|
95
|
+
return envelopeBaseIn(fallbackWorkspacesDir, env.task_id, env.attempt_id);
|
|
96
|
+
}
|
|
37
97
|
//# sourceMappingURL=envelope-recovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope-recovery.js","sourceRoot":"","sources":["../src/envelope-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope-recovery.js","sourceRoot":"","sources":["../src/envelope-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUnE;oEACoE;AACpE,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,IAAI,C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AAI,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAmE,EACnE,qBAA6B;IAE7B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QACtF,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;IACrC,CAAC;IACD,OAAO,cAAc,CAAC,qBAAqB,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/git.d.ts
CHANGED
|
@@ -33,9 +33,16 @@ export declare function materializePatchTree(repo: string, baseSha: string, diff
|
|
|
33
33
|
export declare function worktreeAdd(repo: string, path: string, branch: string, baseSha: string): Promise<void>;
|
|
34
34
|
/** Disposable candidate checkout with private refs/index/objects. The source
|
|
35
35
|
* repository is only an object alternate, so harness `git add`/`commit` cannot
|
|
36
|
-
* write candidate blobs or refs into the user's repository.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* write candidate blobs or refs into the user's repository. That alternate is
|
|
37
|
+
* the FIRST one whatever the source's depth: `--shared` writes it only when Git
|
|
38
|
+
* clones the path locally, and a shallow source Git silently clones through its
|
|
39
|
+
* transport instead (#501), so it is written here, keeping what only the source
|
|
40
|
+
* holds (a dirty snapshot, a delivery's composed tree) readable in the clone.
|
|
41
|
+
* A shallow source Git copies locally keeps its history boundary (see
|
|
42
|
+
* keepShallowBoundary), and a copy or checkout that cannot be complete is refused
|
|
43
|
+
* naming what the source lacks (isolated-clone-content.ts); nothing is fetched.
|
|
44
|
+
* Claudexor's own clone lists the project object store as a SECOND alternate
|
|
45
|
+
* (#535 D2): a dirty base resolves after the user's prune; the user repo never gets it. */
|
|
39
46
|
export declare function isolatedCloneAdd(repo: string, path: string, branch: string, baseSha: string, storeObjects?: string): Promise<void>;
|
|
40
47
|
/** Recreate a worktree for an EXISTING branch (recovery: dir lost, branch survived). */
|
|
41
48
|
export declare function worktreeAddExisting(repo: string, path: string, branch: string): Promise<void>;
|
package/dist/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,GAC/B,MAAM,yBAAyB,CAAC;AAEjC,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,yBAAyB,CAAC,CAOpC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnE;AAED,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;6EAE6E;AAC7E,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAA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AAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM/D;AA6CD;;;;GAIG;AAEH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,8EAA8E;IAC9E,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA+CD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAiBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM/D;AAED,kFAAkF;AAClF,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9E;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,MAAM,OAAO,CAAC,IAAI,CAAkB,GACjD,OAAO,CAAC,IAAI,CAAC,CASf"}
|
package/dist/git.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendFileSync, existsSync, lstatSync, mkdtempSync, readFileSync, rmSync, statSync, } from "node:fs";
|
|
1
|
+
import { appendFileSync, copyFileSync, existsSync, lstatSync, mkdtempSync, readFileSync, rmSync, statSync, } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
4
4
|
import { assertCaptureComplete, runCaptureRaw, WorkspaceError } from "@claudexor/core";
|
|
@@ -6,6 +6,8 @@ import { isClaudexorOwnedRuntimePath } from "@claudexor/util";
|
|
|
6
6
|
import { initializeGitRepository, } from "./git-initialization.js";
|
|
7
7
|
import { assertNoBinaryStubs, git, gitEnv, SCRATCH_INDEX_CONFIG } from "./git-run.js";
|
|
8
8
|
import { diskProgress, gitObserved } from "./git-observed.js";
|
|
9
|
+
import { absentAfterCheckout, cloneFailureMessage, incompleteCloneMessage, } from "./isolated-clone-content.js";
|
|
10
|
+
import { repositoryEndpoint } from "./object-store.js";
|
|
9
11
|
export { git, revParse } from "./git-run.js";
|
|
10
12
|
export { captureWorkingTreeTransient, diffWorkingTreeTransient } from "./git-transient-capture.js";
|
|
11
13
|
export { GitBoundaryRootRefusedError, GitInitializationError, } from "./git-initialization.js";
|
|
@@ -91,19 +93,28 @@ export async function worktreeAdd(repo, path, branch, baseSha) {
|
|
|
91
93
|
}
|
|
92
94
|
/** Disposable candidate checkout with private refs/index/objects. The source
|
|
93
95
|
* repository is only an object alternate, so harness `git add`/`commit` cannot
|
|
94
|
-
* write candidate blobs or refs into the user's repository.
|
|
95
|
-
*
|
|
96
|
-
*
|
|
96
|
+
* write candidate blobs or refs into the user's repository. That alternate is
|
|
97
|
+
* the FIRST one whatever the source's depth: `--shared` writes it only when Git
|
|
98
|
+
* clones the path locally, and a shallow source Git silently clones through its
|
|
99
|
+
* transport instead (#501), so it is written here, keeping what only the source
|
|
100
|
+
* holds (a dirty snapshot, a delivery's composed tree) readable in the clone.
|
|
101
|
+
* A shallow source Git copies locally keeps its history boundary (see
|
|
102
|
+
* keepShallowBoundary), and a copy or checkout that cannot be complete is refused
|
|
103
|
+
* naming what the source lacks (isolated-clone-content.ts); nothing is fetched.
|
|
104
|
+
* Claudexor's own clone lists the project object store as a SECOND alternate
|
|
105
|
+
* (#535 D2): a dirty base resolves after the user's prune; the user repo never gets it. */
|
|
97
106
|
export async function isolatedCloneAdd(repo, path, branch, baseSha, storeObjects) {
|
|
98
107
|
const cloned = await runCaptureRaw("git", ["clone", "--shared", "--no-checkout", "--", repo, path], { timeoutMs: 120_000, windowsConsole: "none" });
|
|
99
108
|
assertCaptureComplete(cloned);
|
|
100
|
-
if (cloned.code !== 0)
|
|
101
|
-
throw new WorkspaceError(
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
109
|
+
if (cloned.code !== 0)
|
|
110
|
+
throw new WorkspaceError(await cloneFailureMessage(repo, baseSha, cloned.stderr));
|
|
111
|
+
const alternates = join(path, ".git", "objects", "info", "alternates");
|
|
112
|
+
if (!existsSync(alternates))
|
|
113
|
+
appendFileSync(alternates, `${(await repositoryEndpoint(repo)).objectsDir}\n`);
|
|
114
|
+
else
|
|
115
|
+
await keepShallowBoundary(repo, path);
|
|
116
|
+
if (storeObjects && existsSync(storeObjects))
|
|
105
117
|
appendFileSync(alternates, `${storeObjects}\n`);
|
|
106
|
-
}
|
|
107
118
|
// A large checkout may take long: only a stall (no disk progress) stops it.
|
|
108
119
|
const checkout = await gitObserved(path, ["checkout", "-q", "-b", branch, baseSha], {
|
|
109
120
|
label: "checkout (isolated clone)",
|
|
@@ -113,11 +124,29 @@ export async function isolatedCloneAdd(repo, path, branch, baseSha, storeObjects
|
|
|
113
124
|
if (checkout.code !== 0) {
|
|
114
125
|
throw new WorkspaceError(`isolated clone checkout failed: ${checkout.stderr.trim()}`);
|
|
115
126
|
}
|
|
127
|
+
// Git checks out a commit whose content no object directory here holds (what a
|
|
128
|
+
// partial clone never fetched or a sparse checkout left out) by reporting each
|
|
129
|
+
// such file and succeeding (#501). That tree is refused, and nothing is fetched.
|
|
130
|
+
const absent = await absentAfterCheckout(path);
|
|
131
|
+
if (absent.length > 0)
|
|
132
|
+
throw new WorkspaceError(incompleteCloneMessage(repo, baseSha, absent, checkout.stderr));
|
|
116
133
|
const detachedRemote = await git(path, ["remote", "remove", "origin"]);
|
|
117
134
|
if (detachedRemote.code !== 0) {
|
|
118
135
|
throw new WorkspaceError(`isolated clone remote removal failed: ${detachedRemote.stderr.trim()}`);
|
|
119
136
|
}
|
|
120
137
|
}
|
|
138
|
+
/** Git copies a shallow source locally when it is a linked worktree of a shallow
|
|
139
|
+
* repository: refs and the alternate come, the `shallow` file does not, so the clone's
|
|
140
|
+
* history ends at parents it does not hold instead of at the boundary, and a log, a
|
|
141
|
+
* blame or `fsck` there fails (#501). The source's own boundary, wherever Git keeps it,
|
|
142
|
+
* goes into the clone; a full source has none. */
|
|
143
|
+
async function keepShallowBoundary(repo, clone) {
|
|
144
|
+
const located = await gitObserved(repo, ["rev-parse", "--path-format=absolute", "--git-path", "shallow"], { label: "rev-parse --git-path shallow" });
|
|
145
|
+
const boundary = located.stdout.trim();
|
|
146
|
+
const own = join(clone, ".git", "shallow");
|
|
147
|
+
if (boundary && existsSync(boundary) && !existsSync(own))
|
|
148
|
+
copyFileSync(boundary, own);
|
|
149
|
+
}
|
|
121
150
|
/** Recreate a worktree for an EXISTING branch (recovery: dir lost, branch survived). */
|
|
122
151
|
export async function worktreeAddExisting(repo, path, branch) {
|
|
123
152
|
// A stale registration for the lost directory would fail the add, so it has
|