@ai-hero/sandcastle 0.6.5 → 0.6.6
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/README.md +123 -54
- package/dist/{MountConfig.d.ts → MountConfig-CmXclHA5.d.ts} +3 -2
- package/dist/{SandboxProvider.d.ts → SandboxProvider-EkSMuBp8.d.ts} +25 -39
- package/dist/chunk-72UVAC7B.js +99 -0
- package/dist/chunk-72UVAC7B.js.map +1 -0
- package/dist/chunk-BIWNFKGV.js +22 -0
- package/dist/chunk-BIWNFKGV.js.map +1 -0
- package/dist/chunk-NGBM7T3E.js +76 -0
- package/dist/chunk-NGBM7T3E.js.map +1 -0
- package/dist/chunk-Q5W3WQVU.js +25569 -0
- package/dist/chunk-Q5W3WQVU.js.map +1 -0
- package/dist/chunk-UPDEQ2U7.js +362 -0
- package/dist/chunk-UPDEQ2U7.js.map +1 -0
- package/dist/chunk-Z7O2WNRU.js +26934 -0
- package/dist/chunk-Z7O2WNRU.js.map +1 -0
- package/dist/index.d.ts +920 -22
- package/dist/index.js +3212 -9
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.js +19256 -13
- package/dist/main.js.map +1 -1
- package/dist/mountUtils-CCA-bbpK.d.ts +25 -0
- package/dist/sandboxes/daytona.d.ts +8 -5
- package/dist/sandboxes/daytona.js +118 -124
- package/dist/sandboxes/daytona.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +10 -8
- package/dist/sandboxes/docker.js +8 -255
- package/dist/sandboxes/docker.js.map +1 -1
- package/dist/sandboxes/no-sandbox.d.ts +7 -4
- package/dist/sandboxes/no-sandbox.js +6 -114
- package/dist/sandboxes/no-sandbox.js.map +1 -1
- package/dist/sandboxes/podman.d.ts +10 -8
- package/dist/sandboxes/podman.js +287 -297
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/vercel.d.ts +7 -4
- package/dist/sandboxes/vercel.js +144 -165
- package/dist/sandboxes/vercel.js.map +1 -1
- package/package.json +15 -14
- package/dist/AgentProvider.d.ts +0 -134
- package/dist/AgentProvider.d.ts.map +0 -1
- package/dist/AgentProvider.js +0 -647
- package/dist/AgentProvider.js.map +0 -1
- package/dist/AgentStreamEmitter.d.ts +0 -36
- package/dist/AgentStreamEmitter.d.ts.map +0 -1
- package/dist/AgentStreamEmitter.js +0 -21
- package/dist/AgentStreamEmitter.js.map +0 -1
- package/dist/CopyToWorktree.d.ts +0 -15
- package/dist/CopyToWorktree.d.ts.map +0 -1
- package/dist/CopyToWorktree.js +0 -60
- package/dist/CopyToWorktree.js.map +0 -1
- package/dist/Display.d.ts +0 -58
- package/dist/Display.d.ts.map +0 -1
- package/dist/Display.js +0 -142
- package/dist/Display.js.map +0 -1
- package/dist/DockerLifecycle.d.ts +0 -54
- package/dist/DockerLifecycle.d.ts.map +0 -1
- package/dist/DockerLifecycle.js +0 -123
- package/dist/DockerLifecycle.js.map +0 -1
- package/dist/EnvResolver.d.ts +0 -11
- package/dist/EnvResolver.d.ts.map +0 -1
- package/dist/EnvResolver.js +0 -63
- package/dist/EnvResolver.js.map +0 -1
- package/dist/ErrorHandler.d.ts +0 -15
- package/dist/ErrorHandler.d.ts.map +0 -1
- package/dist/ErrorHandler.js +0 -85
- package/dist/ErrorHandler.js.map +0 -1
- package/dist/InitService.d.ts +0 -92
- package/dist/InitService.d.ts.map +0 -1
- package/dist/InitService.js +0 -836
- package/dist/InitService.js.map +0 -1
- package/dist/MountConfig.d.ts.map +0 -1
- package/dist/MountConfig.js +0 -7
- package/dist/MountConfig.js.map +0 -1
- package/dist/Orchestrator.d.ts +0 -56
- package/dist/Orchestrator.d.ts.map +0 -1
- package/dist/Orchestrator.js +0 -293
- package/dist/Orchestrator.js.map +0 -1
- package/dist/Output.d.ts +0 -107
- package/dist/Output.d.ts.map +0 -1
- package/dist/Output.js +0 -95
- package/dist/Output.js.map +0 -1
- package/dist/PodmanLifecycle.d.ts +0 -17
- package/dist/PodmanLifecycle.d.ts.map +0 -1
- package/dist/PodmanLifecycle.js +0 -45
- package/dist/PodmanLifecycle.js.map +0 -1
- package/dist/PromptArgumentSubstitution.d.ts +0 -32
- package/dist/PromptArgumentSubstitution.d.ts.map +0 -1
- package/dist/PromptArgumentSubstitution.js +0 -104
- package/dist/PromptArgumentSubstitution.js.map +0 -1
- package/dist/PromptPreprocessor.d.ts +0 -15
- package/dist/PromptPreprocessor.d.ts.map +0 -1
- package/dist/PromptPreprocessor.js +0 -55
- package/dist/PromptPreprocessor.js.map +0 -1
- package/dist/PromptResolver.d.ts +0 -21
- package/dist/PromptResolver.d.ts.map +0 -1
- package/dist/PromptResolver.js +0 -27
- package/dist/PromptResolver.js.map +0 -1
- package/dist/RecoveryMessage.d.ts +0 -15
- package/dist/RecoveryMessage.d.ts.map +0 -1
- package/dist/RecoveryMessage.js +0 -81
- package/dist/RecoveryMessage.js.map +0 -1
- package/dist/SandboxFactory.d.ts +0 -90
- package/dist/SandboxFactory.d.ts.map +0 -1
- package/dist/SandboxFactory.js +0 -324
- package/dist/SandboxFactory.js.map +0 -1
- package/dist/SandboxLifecycle.d.ts +0 -65
- package/dist/SandboxLifecycle.d.ts.map +0 -1
- package/dist/SandboxLifecycle.js +0 -296
- package/dist/SandboxLifecycle.js.map +0 -1
- package/dist/SandboxProvider.d.ts.map +0 -1
- package/dist/SandboxProvider.js +0 -28
- package/dist/SandboxProvider.js.map +0 -1
- package/dist/SessionStore.d.ts +0 -110
- package/dist/SessionStore.d.ts.map +0 -1
- package/dist/SessionStore.js +0 -330
- package/dist/SessionStore.js.map +0 -1
- package/dist/TextDeltaBuffer.d.ts +0 -24
- package/dist/TextDeltaBuffer.d.ts.map +0 -1
- package/dist/TextDeltaBuffer.js +0 -68
- package/dist/TextDeltaBuffer.js.map +0 -1
- package/dist/WorktreeManager.d.ts +0 -79
- package/dist/WorktreeManager.d.ts.map +0 -1
- package/dist/WorktreeManager.js +0 -283
- package/dist/WorktreeManager.js.map +0 -1
- package/dist/boundedTail.d.ts +0 -48
- package/dist/boundedTail.d.ts.map +0 -1
- package/dist/boundedTail.js +0 -64
- package/dist/boundedTail.js.map +0 -1
- package/dist/cli.d.ts +0 -30
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -340
- package/dist/cli.js.map +0 -1
- package/dist/createSandbox.d.ts +0 -154
- package/dist/createSandbox.d.ts.map +0 -1
- package/dist/createSandbox.js +0 -476
- package/dist/createSandbox.js.map +0 -1
- package/dist/createWorktree.d.ts +0 -154
- package/dist/createWorktree.d.ts.map +0 -1
- package/dist/createWorktree.js +0 -391
- package/dist/createWorktree.js.map +0 -1
- package/dist/errors.d.ts +0 -227
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -81
- package/dist/errors.js.map +0 -1
- package/dist/extractStructuredOutput.d.ts +0 -23
- package/dist/extractStructuredOutput.d.ts.map +0 -1
- package/dist/extractStructuredOutput.js +0 -102
- package/dist/extractStructuredOutput.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interactive.d.ts +0 -74
- package/dist/interactive.d.ts.map +0 -1
- package/dist/interactive.js +0 -279
- package/dist/interactive.js.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/mergeProviderEnv.d.ts +0 -13
- package/dist/mergeProviderEnv.d.ts.map +0 -1
- package/dist/mergeProviderEnv.js +0 -23
- package/dist/mergeProviderEnv.js.map +0 -1
- package/dist/mountUtils.d.ts +0 -146
- package/dist/mountUtils.d.ts.map +0 -1
- package/dist/mountUtils.js +0 -301
- package/dist/mountUtils.js.map +0 -1
- package/dist/raceAbortSignal.d.ts +0 -18
- package/dist/raceAbortSignal.d.ts.map +0 -1
- package/dist/raceAbortSignal.js +0 -32
- package/dist/raceAbortSignal.js.map +0 -1
- package/dist/resolveCwd.d.ts +0 -24
- package/dist/resolveCwd.d.ts.map +0 -1
- package/dist/resolveCwd.js +0 -32
- package/dist/resolveCwd.js.map +0 -1
- package/dist/resumePrecheck.d.ts +0 -26
- package/dist/resumePrecheck.d.ts.map +0 -1
- package/dist/resumePrecheck.js +0 -40
- package/dist/resumePrecheck.js.map +0 -1
- package/dist/run.d.ts +0 -216
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -313
- package/dist/run.js.map +0 -1
- package/dist/sandboxExec.d.ts +0 -12
- package/dist/sandboxExec.d.ts.map +0 -1
- package/dist/sandboxExec.js +0 -26
- package/dist/sandboxExec.js.map +0 -1
- package/dist/sandboxes/daytona.d.ts.map +0 -1
- package/dist/sandboxes/docker.d.ts.map +0 -1
- package/dist/sandboxes/no-sandbox.d.ts.map +0 -1
- package/dist/sandboxes/podman.d.ts.map +0 -1
- package/dist/sandboxes/test-bind-mount.d.ts +0 -17
- package/dist/sandboxes/test-bind-mount.d.ts.map +0 -1
- package/dist/sandboxes/test-bind-mount.js +0 -92
- package/dist/sandboxes/test-bind-mount.js.map +0 -1
- package/dist/sandboxes/test-isolated.d.ts +0 -17
- package/dist/sandboxes/test-isolated.d.ts.map +0 -1
- package/dist/sandboxes/test-isolated.js +0 -98
- package/dist/sandboxes/test-isolated.js.map +0 -1
- package/dist/sandboxes/vercel.d.ts.map +0 -1
- package/dist/shutdownRegistry.d.ts +0 -30
- package/dist/shutdownRegistry.d.ts.map +0 -1
- package/dist/shutdownRegistry.js +0 -73
- package/dist/shutdownRegistry.js.map +0 -1
- package/dist/startSandbox.d.ts +0 -50
- package/dist/startSandbox.d.ts.map +0 -1
- package/dist/startSandbox.js +0 -117
- package/dist/startSandbox.js.map +0 -1
- package/dist/syncIn.d.ts +0 -24
- package/dist/syncIn.d.ts.map +0 -1
- package/dist/syncIn.js +0 -107
- package/dist/syncIn.js.map +0 -1
- package/dist/syncOut.d.ts +0 -27
- package/dist/syncOut.d.ts.map +0 -1
- package/dist/syncOut.js +0 -271
- package/dist/syncOut.js.map +0 -1
- package/dist/templates.d.ts +0 -2
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -26
- package/dist/templates.js.map +0 -1
- package/dist/terminalCleanup.d.ts +0 -30
- package/dist/terminalCleanup.d.ts.map +0 -1
- package/dist/terminalCleanup.js +0 -37
- package/dist/terminalCleanup.js.map +0 -1
- package/dist/testSandbox.d.ts +0 -8
- package/dist/testSandbox.d.ts.map +0 -1
- package/dist/testSandbox.js +0 -109
- package/dist/testSandbox.js.map +0 -1
- package/dist/testSetup.d.ts +0 -2
- package/dist/testSetup.d.ts.map +0 -1
- package/dist/testSetup.js +0 -29
- package/dist/testSetup.js.map +0 -1
package/dist/SessionStore.js
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SessionStore — keyed collection of agent session JSONLs.
|
|
3
|
-
*
|
|
4
|
-
* Provides read/write access to agent session files, with host-backed
|
|
5
|
-
* (filesystem) and sandbox-backed (via bind-mount handle file-transfer
|
|
6
|
-
* primitives) implementations. Per ADR 0012, the per-provider `transfer`
|
|
7
|
-
* op (e.g. `transferClaudeSession`, `transferCodexSession`) copies a session
|
|
8
|
-
* between stores and applies any format-specific content rewriting — for
|
|
9
|
-
* JSONL agents, rewriting `cwd` fields from source cwd to target cwd via the
|
|
10
|
-
* shared `rewriteSessionCwd` primitive.
|
|
11
|
-
*/
|
|
12
|
-
import { access, mkdir, readdir, readFile, rm, writeFile, } from "node:fs/promises";
|
|
13
|
-
import { tmpdir } from "node:os";
|
|
14
|
-
import { dirname, join, posix, relative } from "node:path";
|
|
15
|
-
const pathExists = async (path) => {
|
|
16
|
-
try {
|
|
17
|
-
await access(path);
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Path encoding
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
/**
|
|
28
|
-
* Encode a cwd into the Claude Code `~/.claude/projects/<encoded>/` layout.
|
|
29
|
-
* Replaces path separators with hyphens, matching Claude Code's convention.
|
|
30
|
-
*/
|
|
31
|
-
export const encodeProjectPath = (cwd) => {
|
|
32
|
-
const isRoot = cwd === "/" || /^[A-Za-z]:[\\/]?$/.test(cwd);
|
|
33
|
-
const normalized = isRoot ? cwd : cwd.replace(/[\\/]+$/, "");
|
|
34
|
-
return normalized.replace(/^([A-Za-z]):/, "$1").replace(/[\\/]/g, "-");
|
|
35
|
-
};
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Host-backed SessionStore
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
/**
|
|
40
|
-
* Create a host-backed SessionStore that reads/writes session JSONLs on the
|
|
41
|
-
* host filesystem using Claude Code's `~/.claude/projects/<encoded>/` layout.
|
|
42
|
-
*
|
|
43
|
-
* @param cwd - The host repo directory this store is associated with.
|
|
44
|
-
* @param projectsDir - Override for the projects directory (default: `~/.claude/projects`).
|
|
45
|
-
*/
|
|
46
|
-
export const hostSessionStore = (cwd, projectsDir) => {
|
|
47
|
-
const baseDir = projectsDir ?? join(process.env.HOME ?? "~", ".claude", "projects");
|
|
48
|
-
const encoded = encodeProjectPath(cwd);
|
|
49
|
-
const projectDir = join(baseDir, encoded);
|
|
50
|
-
return {
|
|
51
|
-
cwd,
|
|
52
|
-
sessionFilePath: (id) => join(projectDir, `${id}.jsonl`),
|
|
53
|
-
exists: async (id) => pathExists(join(projectDir, `${id}.jsonl`)),
|
|
54
|
-
readSession: async (id) => {
|
|
55
|
-
return await readFile(join(projectDir, `${id}.jsonl`), "utf-8");
|
|
56
|
-
},
|
|
57
|
-
writeSession: async (id, content) => {
|
|
58
|
-
await mkdir(projectDir, { recursive: true });
|
|
59
|
-
await writeFile(join(projectDir, `${id}.jsonl`), content);
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Locate a Claude Code session JSONL on the host by its unique id, scanning each
|
|
65
|
-
* `~/.claude/projects/<encoded-cwd>/` directory rather than reconstructing the
|
|
66
|
-
* cwd encoding. The session id is globally unique, so the first match wins. Used
|
|
67
|
-
* by the no-sandbox resume precheck, where the agent wrote the file in place
|
|
68
|
-
* under a cwd-derived directory Sandcastle cannot reliably reconstruct.
|
|
69
|
-
*
|
|
70
|
-
* @param id - The session id (file basename without `.jsonl`).
|
|
71
|
-
* @param projectsDir - Override for the projects directory (default: `~/.claude/projects`).
|
|
72
|
-
*/
|
|
73
|
-
export const findClaudeSessionOnHost = async (id, projectsDir) => {
|
|
74
|
-
const root = projectsDir ?? join(process.env.HOME ?? "~", ".claude", "projects");
|
|
75
|
-
let entries;
|
|
76
|
-
try {
|
|
77
|
-
entries = await readdir(root, { withFileTypes: true });
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return { path: undefined, searchedRoot: root };
|
|
81
|
-
}
|
|
82
|
-
for (const entry of entries) {
|
|
83
|
-
if (!entry.isDirectory())
|
|
84
|
-
continue;
|
|
85
|
-
const candidate = join(root, entry.name, `${id}.jsonl`);
|
|
86
|
-
if (await pathExists(candidate)) {
|
|
87
|
-
return { path: candidate, searchedRoot: root };
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return { path: undefined, searchedRoot: root };
|
|
91
|
-
};
|
|
92
|
-
// ---------------------------------------------------------------------------
|
|
93
|
-
// Sandbox-backed SessionStore
|
|
94
|
-
// ---------------------------------------------------------------------------
|
|
95
|
-
/**
|
|
96
|
-
* Create a sandbox-backed SessionStore that uses a bind-mount handle's
|
|
97
|
-
* `copyFileIn`/`copyFileOut` to transfer session files.
|
|
98
|
-
*
|
|
99
|
-
* @param cwd - The sandbox-side working directory.
|
|
100
|
-
* @param handle - The bind-mount sandbox handle for file transfer.
|
|
101
|
-
* @param projectsDir - The sandbox-side path to `~/.claude/projects`.
|
|
102
|
-
*/
|
|
103
|
-
export const sandboxSessionStore = (cwd, handle, projectsDir) => {
|
|
104
|
-
const encoded = encodeProjectPath(cwd);
|
|
105
|
-
// Sandbox-side paths target a Linux container, so they must use POSIX
|
|
106
|
-
// separators regardless of host platform — platform-aware `join` produces
|
|
107
|
-
// backslashes on Windows hosts, which the container daemon rejects.
|
|
108
|
-
const projectDir = posix.join(projectsDir, encoded);
|
|
109
|
-
return {
|
|
110
|
-
cwd,
|
|
111
|
-
sessionFilePath: (id) => posix.join(projectDir, `${id}.jsonl`),
|
|
112
|
-
exists: async (id) => {
|
|
113
|
-
const result = await handle.exec(`test -f ${JSON.stringify(posix.join(projectDir, `${id}.jsonl`))}`);
|
|
114
|
-
return result.exitCode === 0;
|
|
115
|
-
},
|
|
116
|
-
readSession: async (id) => {
|
|
117
|
-
const sandboxPath = posix.join(projectDir, `${id}.jsonl`);
|
|
118
|
-
const tmpPath = join(tmpdir(), `sandcastle-session-${id}-${Date.now()}.jsonl`);
|
|
119
|
-
await handle.copyFileOut(sandboxPath, tmpPath);
|
|
120
|
-
try {
|
|
121
|
-
return await readFile(tmpPath, "utf-8");
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
await rm(tmpPath, { force: true }).catch(() => { });
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
writeSession: async (id, content) => {
|
|
128
|
-
const sandboxPath = posix.join(projectDir, `${id}.jsonl`);
|
|
129
|
-
const tmpPath = join(tmpdir(), `sandcastle-session-${id}-${Date.now()}.jsonl`);
|
|
130
|
-
await writeFile(tmpPath, content);
|
|
131
|
-
try {
|
|
132
|
-
// Ensure the sandbox-side project directory exists — `docker cp` /
|
|
133
|
-
// `podman cp` require the destination's parent directory to exist.
|
|
134
|
-
await handle.exec(`mkdir -p ${JSON.stringify(projectDir)}`);
|
|
135
|
-
await handle.copyFileIn(tmpPath, sandboxPath);
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
await rm(tmpPath, { force: true }).catch(() => { });
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* claudeCode's `sessionStorage.transfer` (ADR 0012). Copies a Claude Code
|
|
145
|
-
* session between stores, rewriting `cwd` fields in the JSONL entries from the
|
|
146
|
-
* source store's cwd to the target store's cwd. The rewrite is specific to
|
|
147
|
-
* Claude Code's JSONL format, so it lives with the provider rather than in
|
|
148
|
-
* central code.
|
|
149
|
-
*/
|
|
150
|
-
export const transferClaudeSession = async (from, to, id) => {
|
|
151
|
-
const content = await from.readSession(id);
|
|
152
|
-
if (content === "") {
|
|
153
|
-
await to.writeSession(id, "");
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const rewritten = rewriteSessionCwd(content, from.cwd, to.cwd);
|
|
157
|
-
await to.writeSession(id, rewritten);
|
|
158
|
-
};
|
|
159
|
-
const isCodexSessionFilename = (filename, id) => filename.startsWith("rollout-") && filename.endsWith(`-${id}.jsonl`);
|
|
160
|
-
const codexIdFromFilename = (filename) => {
|
|
161
|
-
const match = /([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\.jsonl$/.exec(filename);
|
|
162
|
-
return match?.[1];
|
|
163
|
-
};
|
|
164
|
-
const findCodexSessionPath = async (rootDir, id) => {
|
|
165
|
-
const visit = async (dir) => {
|
|
166
|
-
let entries;
|
|
167
|
-
try {
|
|
168
|
-
entries = await readdir(dir, { withFileTypes: true });
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
return undefined;
|
|
172
|
-
}
|
|
173
|
-
for (const entry of entries) {
|
|
174
|
-
const child = join(dir, entry.name);
|
|
175
|
-
if (entry.isFile() && isCodexSessionFilename(entry.name, id)) {
|
|
176
|
-
return child;
|
|
177
|
-
}
|
|
178
|
-
if (entry.isDirectory()) {
|
|
179
|
-
const found = await visit(child);
|
|
180
|
-
if (found)
|
|
181
|
-
return found;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return undefined;
|
|
185
|
-
};
|
|
186
|
-
return visit(rootDir);
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Locate a Codex session rollout file on the host by its id, reusing the
|
|
190
|
-
* date-nested scan. Used by the no-sandbox resume precheck.
|
|
191
|
-
*
|
|
192
|
-
* @param id - The session id.
|
|
193
|
-
* @param sessionsDir - Override for the sessions directory (default: `~/.codex/sessions`).
|
|
194
|
-
*/
|
|
195
|
-
export const findCodexSessionOnHost = async (id, sessionsDir) => {
|
|
196
|
-
const root = sessionsDir ?? join(process.env.HOME ?? "~", ".codex", "sessions");
|
|
197
|
-
const path = await findCodexSessionPath(root, id);
|
|
198
|
-
return { path, searchedRoot: root };
|
|
199
|
-
};
|
|
200
|
-
export const codexHostSessionStore = (cwd, sessionsDir) => {
|
|
201
|
-
const rootDir = sessionsDir ?? join(process.env.HOME ?? "~", ".codex", "sessions");
|
|
202
|
-
const locatedPaths = new Map();
|
|
203
|
-
const locateSession = async (id) => {
|
|
204
|
-
const path = await findCodexSessionPath(rootDir, id);
|
|
205
|
-
if (!path) {
|
|
206
|
-
throw new Error(`session ${id} not found in ${rootDir}`);
|
|
207
|
-
}
|
|
208
|
-
locatedPaths.set(id, path);
|
|
209
|
-
return { path, relativePath: relative(rootDir, path) };
|
|
210
|
-
};
|
|
211
|
-
return {
|
|
212
|
-
cwd,
|
|
213
|
-
locateSession,
|
|
214
|
-
sessionFilePath: (id) => locatedPaths.get(id),
|
|
215
|
-
exists: async (id) => {
|
|
216
|
-
return (await findCodexSessionPath(rootDir, id)) !== undefined;
|
|
217
|
-
},
|
|
218
|
-
readSession: async (id) => {
|
|
219
|
-
const located = await locateSession(id);
|
|
220
|
-
return readFile(located.path, "utf-8");
|
|
221
|
-
},
|
|
222
|
-
writeSession: async (id, content) => {
|
|
223
|
-
const existing = await findCodexSessionPath(rootDir, id);
|
|
224
|
-
const target = existing ??
|
|
225
|
-
join(rootDir, "unknown-date", `rollout-${Date.now()}-${id}.jsonl`);
|
|
226
|
-
await mkdir(dirname(target), { recursive: true });
|
|
227
|
-
await writeFile(target, content);
|
|
228
|
-
locatedPaths.set(id, target);
|
|
229
|
-
},
|
|
230
|
-
writeSessionAt: async (relativePath, content) => {
|
|
231
|
-
const target = join(rootDir, relativePath);
|
|
232
|
-
await mkdir(dirname(target), { recursive: true });
|
|
233
|
-
await writeFile(target, content);
|
|
234
|
-
const id = codexIdFromFilename(posix.basename(relativePath));
|
|
235
|
-
if (id)
|
|
236
|
-
locatedPaths.set(id, target);
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
export const codexSandboxSessionStore = (cwd, handle, sessionsDir = posix.join("/home/agent", ".codex", "sessions")) => {
|
|
241
|
-
const locatedPaths = new Map();
|
|
242
|
-
const writeSessionAt = async (relativePath, content) => {
|
|
243
|
-
const sandboxPath = posix.join(sessionsDir, relativePath);
|
|
244
|
-
const tmpPath = join(tmpdir(), `sandcastle-codex-session-${Date.now()}.jsonl`);
|
|
245
|
-
await writeFile(tmpPath, content);
|
|
246
|
-
try {
|
|
247
|
-
await handle.exec(`mkdir -p ${JSON.stringify(posix.dirname(sandboxPath))}`);
|
|
248
|
-
await handle.copyFileIn(tmpPath, sandboxPath);
|
|
249
|
-
const id = codexIdFromFilename(posix.basename(relativePath));
|
|
250
|
-
if (id)
|
|
251
|
-
locatedPaths.set(id, sandboxPath);
|
|
252
|
-
}
|
|
253
|
-
finally {
|
|
254
|
-
await rm(tmpPath, { force: true }).catch(() => { });
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
const locateSession = async (id) => {
|
|
258
|
-
const result = await handle.exec(`find ${JSON.stringify(sessionsDir)} -type f -name ${JSON.stringify(`rollout-*-${id}.jsonl`)} -print -quit`);
|
|
259
|
-
const path = result.stdout.trim().split("\n")[0];
|
|
260
|
-
if (result.exitCode !== 0 || !path) {
|
|
261
|
-
throw new Error(`session ${id} not found in ${sessionsDir}`);
|
|
262
|
-
}
|
|
263
|
-
locatedPaths.set(id, path);
|
|
264
|
-
return { path, relativePath: posix.relative(sessionsDir, path) };
|
|
265
|
-
};
|
|
266
|
-
return {
|
|
267
|
-
cwd,
|
|
268
|
-
locateSession,
|
|
269
|
-
sessionFilePath: (id) => locatedPaths.get(id),
|
|
270
|
-
exists: async (id) => {
|
|
271
|
-
const result = await handle.exec(`find ${JSON.stringify(sessionsDir)} -type f -name ${JSON.stringify(`rollout-*-${id}.jsonl`)} -print -quit`);
|
|
272
|
-
return result.exitCode === 0 && result.stdout.trim().length > 0;
|
|
273
|
-
},
|
|
274
|
-
readSession: async (id) => {
|
|
275
|
-
const located = await locateSession(id);
|
|
276
|
-
const tmpPath = join(tmpdir(), `sandcastle-codex-session-${id}-${Date.now()}.jsonl`);
|
|
277
|
-
await handle.copyFileOut(located.path, tmpPath);
|
|
278
|
-
try {
|
|
279
|
-
return await readFile(tmpPath, "utf-8");
|
|
280
|
-
}
|
|
281
|
-
finally {
|
|
282
|
-
await rm(tmpPath, { force: true }).catch(() => { });
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
writeSession: async (id, content) => {
|
|
286
|
-
const existing = await locateSession(id).catch(() => undefined);
|
|
287
|
-
const relativePath = existing?.relativePath ??
|
|
288
|
-
posix.join("unknown-date", `rollout-${Date.now()}-${id}.jsonl`);
|
|
289
|
-
await writeSessionAt(relativePath, content);
|
|
290
|
-
},
|
|
291
|
-
writeSessionAt,
|
|
292
|
-
};
|
|
293
|
-
};
|
|
294
|
-
const rewriteSessionCwd = (content, fromCwd, toCwd) => {
|
|
295
|
-
if (content === "")
|
|
296
|
-
return "";
|
|
297
|
-
return content
|
|
298
|
-
.split("\n")
|
|
299
|
-
.map((line) => {
|
|
300
|
-
if (line === "")
|
|
301
|
-
return line;
|
|
302
|
-
const entry = JSON.parse(line);
|
|
303
|
-
if (typeof entry.cwd === "string" && entry.cwd === fromCwd) {
|
|
304
|
-
entry.cwd = toCwd;
|
|
305
|
-
}
|
|
306
|
-
if (entry.type === "session_meta" &&
|
|
307
|
-
typeof entry.payload === "object" &&
|
|
308
|
-
entry.payload !== null &&
|
|
309
|
-
typeof entry.payload.cwd === "string" &&
|
|
310
|
-
entry.payload.cwd === fromCwd) {
|
|
311
|
-
entry.payload.cwd = toCwd;
|
|
312
|
-
}
|
|
313
|
-
return JSON.stringify(entry);
|
|
314
|
-
})
|
|
315
|
-
.join("\n");
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* codex's `sessionStorage.transfer` (ADR 0012). Copies a Codex session between
|
|
319
|
-
* locatable stores, rewriting the `cwd` in the `session_meta` line and
|
|
320
|
-
* preserving the source's relative date-path on the target so Codex's id-scan
|
|
321
|
-
* rediscovers the file.
|
|
322
|
-
*/
|
|
323
|
-
export const transferCodexSession = async (from, to, id) => {
|
|
324
|
-
const located = await from.locateSession(id);
|
|
325
|
-
const content = await from.readSession(id);
|
|
326
|
-
const rewritten = rewriteSessionCwd(content, from.cwd, to.cwd);
|
|
327
|
-
await to.writeSessionAt(located.relativePath, rewritten);
|
|
328
|
-
await to.locateSession(id).catch(() => undefined);
|
|
329
|
-
};
|
|
330
|
-
//# sourceMappingURL=SessionStore.js.map
|
package/dist/SessionStore.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionStore.js","sourceRoot":"","sources":["../src/SessionStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,EACR,EAAE,EACF,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAkC3D,MAAM,UAAU,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC1D,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC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|
|
4
|
-
* Flush triggers:
|
|
5
|
-
* - Newline character in the accumulated buffer
|
|
6
|
-
* - Sentence boundary (`. `, `! `, `? ` at end of buffer)
|
|
7
|
-
* - Buffer exceeds ~80 characters
|
|
8
|
-
* - Debounce timer (~50ms of no new writes)
|
|
9
|
-
*/
|
|
10
|
-
export declare class TextDeltaBuffer {
|
|
11
|
-
private buffer;
|
|
12
|
-
private timer;
|
|
13
|
-
private readonly onFlush;
|
|
14
|
-
constructor(onFlush: (text: string) => void);
|
|
15
|
-
write(text: string): void;
|
|
16
|
-
/** Force-flush any buffered text. */
|
|
17
|
-
flush(): void;
|
|
18
|
-
/** Flush remaining buffer and clean up. */
|
|
19
|
-
dispose(): void;
|
|
20
|
-
private shouldFlush;
|
|
21
|
-
private doFlush;
|
|
22
|
-
private clearTimer;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=TextDeltaBuffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextDeltaBuffer.d.ts","sourceRoot":"","sources":["../src/TextDeltaBuffer.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD,YAAY,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAE1C;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAaxB;IAED,qCAAqC;IACrC,KAAK,IAAI,IAAI,CAGZ;IAED,2CAA2C;IAC3C,OAAO,IAAI,IAAI,CAEd;IAED,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,UAAU;CAMnB"}
|
package/dist/TextDeltaBuffer.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const LENGTH_THRESHOLD = 80;
|
|
2
|
-
const DEBOUNCE_MS = 50;
|
|
3
|
-
/**
|
|
4
|
-
* Sentence-boundary pattern: period, exclamation, or question mark followed by a space.
|
|
5
|
-
*/
|
|
6
|
-
const SENTENCE_BOUNDARY_RE = /[.!?] $/;
|
|
7
|
-
/**
|
|
8
|
-
* Buffers streaming text deltas and flushes them as readable multi-word chunks.
|
|
9
|
-
*
|
|
10
|
-
* Flush triggers:
|
|
11
|
-
* - Newline character in the accumulated buffer
|
|
12
|
-
* - Sentence boundary (`. `, `! `, `? ` at end of buffer)
|
|
13
|
-
* - Buffer exceeds ~80 characters
|
|
14
|
-
* - Debounce timer (~50ms of no new writes)
|
|
15
|
-
*/
|
|
16
|
-
export class TextDeltaBuffer {
|
|
17
|
-
buffer = "";
|
|
18
|
-
timer = null;
|
|
19
|
-
onFlush;
|
|
20
|
-
constructor(onFlush) {
|
|
21
|
-
this.onFlush = onFlush;
|
|
22
|
-
}
|
|
23
|
-
write(text) {
|
|
24
|
-
if (text.length === 0)
|
|
25
|
-
return;
|
|
26
|
-
this.buffer += text;
|
|
27
|
-
this.clearTimer();
|
|
28
|
-
if (this.shouldFlush()) {
|
|
29
|
-
this.doFlush();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
this.timer = setTimeout(() => {
|
|
33
|
-
this.doFlush();
|
|
34
|
-
}, DEBOUNCE_MS);
|
|
35
|
-
}
|
|
36
|
-
/** Force-flush any buffered text. */
|
|
37
|
-
flush() {
|
|
38
|
-
this.clearTimer();
|
|
39
|
-
this.doFlush();
|
|
40
|
-
}
|
|
41
|
-
/** Flush remaining buffer and clean up. */
|
|
42
|
-
dispose() {
|
|
43
|
-
this.flush();
|
|
44
|
-
}
|
|
45
|
-
shouldFlush() {
|
|
46
|
-
if (this.buffer.includes("\n"))
|
|
47
|
-
return true;
|
|
48
|
-
if (SENTENCE_BOUNDARY_RE.test(this.buffer))
|
|
49
|
-
return true;
|
|
50
|
-
if (this.buffer.length >= LENGTH_THRESHOLD)
|
|
51
|
-
return true;
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
doFlush() {
|
|
55
|
-
if (this.buffer.length === 0)
|
|
56
|
-
return;
|
|
57
|
-
const text = this.buffer;
|
|
58
|
-
this.buffer = "";
|
|
59
|
-
this.onFlush(text);
|
|
60
|
-
}
|
|
61
|
-
clearTimer() {
|
|
62
|
-
if (this.timer !== null) {
|
|
63
|
-
clearTimeout(this.timer);
|
|
64
|
-
this.timer = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=TextDeltaBuffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextDeltaBuffer.js","sourceRoot":"","sources":["../src/TextDeltaBuffer.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;GAEG;AACH,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAClB,MAAM,GAAG,EAAE,CAAC;IACZ,KAAK,GAAyC,IAAI,CAAC;IAC1C,OAAO,CAAyB;IAEjD,YAAY,OAA+B;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC9B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC,EAAE,WAAW,CAAC,CAAC;IAClB,CAAC;IAED,qCAAqC;IACrC,KAAK;QACH,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,2CAA2C;IAC3C,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QACxD,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,gBAAgB;YAAE,OAAO,IAAI,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,OAAO;QACb,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAEO,UAAU;QAChB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACxB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { FileSystem } from "@effect/platform";
|
|
3
|
-
import { WorktreeError, WorktreeTimeoutError } from "./errors.js";
|
|
4
|
-
/** Sanitize a name for use in branch names and directory names. */
|
|
5
|
-
export declare const sanitizeName: (name: string) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Generates a temporary branch name.
|
|
8
|
-
* When name is provided: `sandcastle/<sanitized-name>/<YYYYMMDD-HHMMSS>`.
|
|
9
|
-
* Otherwise: `sandcastle/<YYYYMMDD-HHMMSS>`.
|
|
10
|
-
*/
|
|
11
|
-
export declare const generateTempBranchName: (name?: string | undefined) => string;
|
|
12
|
-
/** Returns the name of the currently checked-out branch in the given repo directory. */
|
|
13
|
-
export declare const getCurrentBranch: (repoDir: string) => Effect.Effect<string, WorktreeError, never>;
|
|
14
|
-
export interface WorktreeInfo {
|
|
15
|
-
path: string;
|
|
16
|
-
branch: string;
|
|
17
|
-
}
|
|
18
|
-
/** A single entry parsed from `git worktree list --porcelain`. */
|
|
19
|
-
export interface WorktreeEntry {
|
|
20
|
-
path: string;
|
|
21
|
-
/** `null` for a detached HEAD (e.g. mid-rebase). */
|
|
22
|
-
branch: string | null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Finds an existing worktree that collides with `branch` or `worktreePath`.
|
|
26
|
-
*
|
|
27
|
-
* Matches by branch first, then falls back to a path match — covering the
|
|
28
|
-
* mid-rebase detached-HEAD case where git reports a `null` branch. The path
|
|
29
|
-
* fallback normalizes separators so it works on Windows.
|
|
30
|
-
*/
|
|
31
|
-
export declare const findCollidingWorktree: (existing: readonly WorktreeEntry[], branch: string, worktreePath: string) => WorktreeEntry | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Whether `worktreePath` lives under `worktreesDir` (i.e. is a worktree managed
|
|
34
|
-
* by sandcastle rather than the main working tree or an external worktree).
|
|
35
|
-
* Separators are normalized so the check holds on Windows.
|
|
36
|
-
*/
|
|
37
|
-
export declare const isManagedWorktreePath: (worktreePath: string, worktreesDir: string) => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Whether a directory entry under `.sandcastle/worktrees/` is orphaned — not
|
|
40
|
-
* present in the set of active worktree paths reported by git. Both sides are
|
|
41
|
-
* normalized so paths from `join` (backslashes on Windows) match git's
|
|
42
|
-
* forward-slash output.
|
|
43
|
-
*/
|
|
44
|
-
export declare const isOrphanedWorktreePath: (entryPath: string, activeWorktreePaths: Iterable<string>) => boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a git worktree at `.sandcastle/worktrees/<name>/`.
|
|
47
|
-
*
|
|
48
|
-
* - If `branch` is specified, checks out that branch.
|
|
49
|
-
* - If not, creates a temporary `sandcastle/<timestamp>` branch.
|
|
50
|
-
*
|
|
51
|
-
* When `branch` collides with an existing managed worktree:
|
|
52
|
-
* - Clean → reuses the existing worktree.
|
|
53
|
-
* - Dirty (uncommitted changes) → reuses with a console warning (ADR 0003).
|
|
54
|
-
*
|
|
55
|
-
* Collisions with the main working tree or external worktrees always throw.
|
|
56
|
-
*/
|
|
57
|
-
export declare const create: (repoDir: string, opts?: {
|
|
58
|
-
branch?: string | undefined;
|
|
59
|
-
baseBranch?: string | undefined;
|
|
60
|
-
name?: string | undefined;
|
|
61
|
-
} | undefined) => Effect.Effect<WorktreeInfo, WorktreeError | WorktreeTimeoutError, FileSystem.FileSystem>;
|
|
62
|
-
/**
|
|
63
|
-
* Returns true if the worktree at `worktreePath` has any uncommitted changes:
|
|
64
|
-
* unstaged modifications, staged changes, or untracked files.
|
|
65
|
-
*/
|
|
66
|
-
export declare const hasUncommittedChanges: (worktreePath: string) => Effect.Effect<boolean, WorktreeError, never>;
|
|
67
|
-
/**
|
|
68
|
-
* Removes a worktree and its git metadata.
|
|
69
|
-
*
|
|
70
|
-
* The `worktreePath` must be a path inside `.sandcastle/worktrees/` so that
|
|
71
|
-
* the main repository directory can be derived from it.
|
|
72
|
-
*/
|
|
73
|
-
export declare const remove: (worktreePath: string) => Effect.Effect<void, WorktreeError, never>;
|
|
74
|
-
/**
|
|
75
|
-
* Prunes stale git worktree metadata and removes orphaned directories under
|
|
76
|
-
* `.sandcastle/worktrees/`.
|
|
77
|
-
*/
|
|
78
|
-
export declare const pruneStale: (repoDir: string) => Effect.Effect<void, WorktreeError | WorktreeTimeoutError, FileSystem.FileSystem>;
|
|
79
|
-
//# sourceMappingURL=WorktreeManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorktreeManager.d.ts","sourceRoot":"","sources":["../src/WorktreeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAe,MAAM,aAAa,CAAC;AA0B/E,mEAAmE;AACnE,eAAO,MAAM,YAAY,0BACsB,CAAC;AA+BhD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,uCAMlC,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,kEAK1B,CAAC;AAEJ,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAYD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,yGAM6C,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,yDAImC,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,uEASlC,CAAC;AAiCF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM;;;;0GAwIhB,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,qBAAqB,wEAK/B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,MAAM,qEAQlB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,uGA6EpB,CAAC"}
|