@madarco/agentbox 0.20.0 → 0.21.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/CHANGELOG.md +94 -0
- package/dist/{_cloud-attach-THTN4CFZ.js → _cloud-attach-U3QJO7IF.js} +4 -4
- package/dist/{chunk-52LKNUY7.js → chunk-6JJIKCMY.js} +2 -2
- package/dist/{chunk-P6UT5XGE.js → chunk-DBMLOY3T.js} +11 -3
- package/dist/{chunk-P6UT5XGE.js.map → chunk-DBMLOY3T.js.map} +1 -1
- package/dist/{chunk-NXX3KQZ6.js → chunk-IXQTUXWV.js} +2 -2
- package/dist/{chunk-MODNW54N.js → chunk-KTEDFUKM.js} +2 -2
- package/dist/{chunk-7RWFYLF3.js → chunk-PX7G4PSI.js} +78 -23
- package/dist/chunk-PX7G4PSI.js.map +1 -0
- package/dist/{chunk-ZX6DTA4X.js → chunk-QKL7PCXQ.js} +220 -16
- package/dist/chunk-QKL7PCXQ.js.map +1 -0
- package/dist/{chunk-7K2A3NLE.js → chunk-X2DWS4KS.js} +14 -6
- package/dist/chunk-X2DWS4KS.js.map +1 -0
- package/dist/{chunk-3VFY3N4A.js → chunk-YZVFGFYQ.js} +320 -956
- package/dist/chunk-YZVFGFYQ.js.map +1 -0
- package/dist/{dist-7ELDXBAG.js → dist-FMA5Y25B.js} +9 -6
- package/dist/{dist-7ELDXBAG.js.map → dist-FMA5Y25B.js.map} +1 -1
- package/dist/{dist-C3YRC3PP.js → dist-NWKOEWUJ.js} +120 -26
- package/dist/dist-NWKOEWUJ.js.map +1 -0
- package/dist/{dist-3PLT2EK2.js → dist-SAS4PIHA.js} +15 -3
- package/dist/{dist-3WFNXXPE.js → dist-U76JL6HI.js} +7 -6
- package/dist/{dist-3WFNXXPE.js.map → dist-U76JL6HI.js.map} +1 -1
- package/dist/{dist-CZ6CRADC.js → dist-UVQJ2BZJ.js} +5 -5
- package/dist/dist-UVQJ2BZJ.js.map +1 -0
- package/dist/index.js +1236 -561
- package/dist/index.js.map +1 -1
- package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js → prepared-state-MQHD3M5F-YYVVMTNJ.js} +2 -2
- package/package.json +4 -3
- package/runtime/daytona/custom-system-CLAUDE.md +13 -3
- package/runtime/docker/Dockerfile.box +57 -10
- package/runtime/docker/apps/cli/share/agentbox-setup/SKILL.md +6 -5
- package/runtime/docker/packages/ctl/dist/bin.cjs +324 -109
- package/runtime/docker/packages/sandbox-docker/scripts/agentbox-portless-trust +82 -0
- package/runtime/docker/packages/sandbox-docker/scripts/custom-system-CLAUDE.md +12 -3
- package/runtime/e2b/agentbox-setup-skill.md +6 -5
- package/runtime/e2b/attach-helper.cjs +4 -1
- package/runtime/e2b/ctl.cjs +324 -109
- package/runtime/e2b/custom-system-CLAUDE.md +12 -3
- package/runtime/e2b/scripts/build-template.sh +54 -2
- package/runtime/hetzner/agentbox-portless-trust +82 -0
- package/runtime/hetzner/agentbox-setup-skill.md +6 -5
- package/runtime/hetzner/ctl.cjs +324 -109
- package/runtime/hetzner/custom-system-CLAUDE.md +12 -3
- package/runtime/hetzner/scripts/install-box.sh +60 -7
- package/runtime/relay/bin.cjs +187 -43
- package/runtime/vercel/agentbox-setup-skill.md +6 -5
- package/runtime/vercel/ctl.cjs +324 -109
- package/runtime/vercel/custom-system-CLAUDE.md +12 -3
- package/runtime/vercel/scripts/provision.sh +64 -2
- package/share/agentbox-setup/SKILL.md +6 -5
- package/share/host-skills/agentbox/SKILL.md +14 -0
- package/share/host-skills/agentbox-info/SKILL.md +30 -1
- package/dist/chunk-3VFY3N4A.js.map +0 -1
- package/dist/chunk-7K2A3NLE.js.map +0 -1
- package/dist/chunk-7RWFYLF3.js.map +0 -1
- package/dist/chunk-ZX6DTA4X.js.map +0 -1
- package/dist/dist-C3YRC3PP.js.map +0 -1
- package/dist/dist-CZ6CRADC.js.map +0 -1
- /package/dist/{_cloud-attach-THTN4CFZ.js.map → _cloud-attach-U3QJO7IF.js.map} +0 -0
- /package/dist/{chunk-52LKNUY7.js.map → chunk-6JJIKCMY.js.map} +0 -0
- /package/dist/{chunk-NXX3KQZ6.js.map → chunk-IXQTUXWV.js.map} +0 -0
- /package/dist/{chunk-MODNW54N.js.map → chunk-KTEDFUKM.js.map} +0 -0
- /package/dist/{dist-3PLT2EK2.js.map → dist-SAS4PIHA.js.map} +0 -0
- /package/dist/{prepared-state-MQHD3M5F-5ZMCNY43.js.map → prepared-state-MQHD3M5F-YYVVMTNJ.js.map} +0 -0
|
@@ -6,12 +6,15 @@ import {
|
|
|
6
6
|
CLAUDE_FORWARDED_ENV_KEYS,
|
|
7
7
|
CODEX_CREDENTIALS_BACKUP_FILE,
|
|
8
8
|
CODEX_FORWARDED_ENV_KEYS,
|
|
9
|
+
CODEX_OVERRIDE_WROTE_MARKER,
|
|
9
10
|
CREDENTIALS_BACKUP_FILE,
|
|
10
11
|
OPENCODE_CREDENTIALS_BACKUP_FILE,
|
|
11
12
|
OPENCODE_FORWARDED_ENV_KEYS,
|
|
12
13
|
SHARED_CLAUDE_VOLUME,
|
|
13
14
|
SHARED_CODEX_VOLUME,
|
|
14
15
|
SHARED_OPENCODE_VOLUME,
|
|
16
|
+
TERM_FALLBACK_SNIPPET,
|
|
17
|
+
buildCodexAgentsOverrideScript,
|
|
15
18
|
buildHostEnvFindArgs,
|
|
16
19
|
buildHostSyncManifest,
|
|
17
20
|
buildTmuxConfigShellSnippet,
|
|
@@ -42,7 +45,7 @@ import {
|
|
|
42
45
|
stageOpencodeStateForUpload,
|
|
43
46
|
stageOpencodeStaticForUpload,
|
|
44
47
|
syncClaudeCredentials
|
|
45
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-YZVFGFYQ.js";
|
|
46
49
|
import {
|
|
47
50
|
DEFAULT_BOX_IMAGE,
|
|
48
51
|
allocateProjectIndex,
|
|
@@ -54,7 +57,7 @@ import {
|
|
|
54
57
|
recordBox,
|
|
55
58
|
removeBoxRecord,
|
|
56
59
|
renderCarryEntries
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-X2DWS4KS.js";
|
|
58
61
|
|
|
59
62
|
// ../../packages/sandbox-cloud/dist/index.js
|
|
60
63
|
import { basename as basename2, resolve } from "path";
|
|
@@ -90,9 +93,9 @@ import {
|
|
|
90
93
|
} from "path";
|
|
91
94
|
import { posix } from "path";
|
|
92
95
|
import { execa as execa5 } from "execa";
|
|
93
|
-
import { mkdtemp as mkdtemp5, rm as rm6, stat } from "fs/promises";
|
|
96
|
+
import { copyFile, mkdir as mkdir3, mkdtemp as mkdtemp5, rm as rm6, stat } from "fs/promises";
|
|
94
97
|
import { tmpdir as tmpdir5 } from "os";
|
|
95
|
-
import { join as join6 } from "path";
|
|
98
|
+
import { dirname as dirname3, join as join6 } from "path";
|
|
96
99
|
var CREDENTIALS_VOLUME = "agentbox-credentials";
|
|
97
100
|
var AGENT_SPECS = [
|
|
98
101
|
{
|
|
@@ -178,6 +181,21 @@ async function seedAgentVolumesIfFresh(backend, handle, opts = {}) {
|
|
|
178
181
|
)
|
|
179
182
|
);
|
|
180
183
|
}
|
|
184
|
+
async function ensureAgentHomeDirsOwned(backend, handle, opts = {}) {
|
|
185
|
+
const log = opts.onLog ?? (() => {
|
|
186
|
+
});
|
|
187
|
+
const paths = AGENT_SPECS.map((s) => s.staticMountPath).join(" ");
|
|
188
|
+
try {
|
|
189
|
+
await backend.exec(
|
|
190
|
+
handle,
|
|
191
|
+
`sudo -n chown -R vscode:vscode ${paths} 2>/dev/null || true`
|
|
192
|
+
);
|
|
193
|
+
} catch (err) {
|
|
194
|
+
log(
|
|
195
|
+
`agent home-dir ownership normalize failed (continuing): ${err instanceof Error ? err.message : String(err)}`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
181
199
|
async function refreshAgentCredentialsBackup(opts = {}) {
|
|
182
200
|
const log = opts.onLog ?? (() => {
|
|
183
201
|
});
|
|
@@ -414,6 +432,28 @@ async function seedDynamicConfig(backend, handle, opts) {
|
|
|
414
432
|
);
|
|
415
433
|
}
|
|
416
434
|
}
|
|
435
|
+
var BOX_CODEX_HOME = "/home/vscode/.codex";
|
|
436
|
+
async function ensureCodexAgentsOverride(backend, handle, opts = {}) {
|
|
437
|
+
const log = opts.onLog ?? (() => {
|
|
438
|
+
});
|
|
439
|
+
const script = buildCodexAgentsOverrideScript(BOX_CODEX_HOME) + `
|
|
440
|
+
chown vscode:vscode "$OVR" 2>/dev/null || true
|
|
441
|
+
chmod 0644 "$OVR" 2>/dev/null || true`;
|
|
442
|
+
try {
|
|
443
|
+
const res = await backend.exec(handle, script);
|
|
444
|
+
if (res.exitCode !== 0)
|
|
445
|
+
log(
|
|
446
|
+
`codex AGENTS.override seed failed (continuing): exit ${res.exitCode}${res.stderr.trim() ? `: ${res.stderr.trim()}` : ""}`
|
|
447
|
+
);
|
|
448
|
+
else if (res.stdout.includes(CODEX_OVERRIDE_WROTE_MARKER))
|
|
449
|
+
log("seeded Codex AGENTS.override.md");
|
|
450
|
+
else log("codex AGENTS.override skipped: box-facts file absent");
|
|
451
|
+
} catch (err) {
|
|
452
|
+
log(
|
|
453
|
+
`codex AGENTS.override seed failed (continuing): ${err instanceof Error ? err.message : String(err)}`
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
417
457
|
var REMOTE_TAR2 = "/tmp/agentbox-claude-json.tar.gz";
|
|
418
458
|
var BOX_CLAUDE_DIR = "/home/vscode/.claude";
|
|
419
459
|
async function seedClaudeJsonAtCreate(backend, handle, opts = {}) {
|
|
@@ -773,7 +813,8 @@ function isPlainObject(v) {
|
|
|
773
813
|
}
|
|
774
814
|
var REMOTE_UP_TAR = "/tmp/agentbox-cp-up.tar.gz";
|
|
775
815
|
var REMOTE_DOWN_TAR = "/tmp/agentbox-cp-down.tar.gz";
|
|
776
|
-
|
|
816
|
+
var BOX_HOME2 = "/home/vscode";
|
|
817
|
+
async function uploadOneToCloudBox(backend, handle, hostSrc, boxDst, exclude) {
|
|
777
818
|
const srcAbs = hostResolve(hostSrc);
|
|
778
819
|
if (!existsSync(srcAbs)) throw new Error(`source not found: ${hostSrc}`);
|
|
779
820
|
const srcBasename = hostBasename(srcAbs);
|
|
@@ -798,6 +839,8 @@ async function uploadToCloudBox(backend, handle, hostSrc, boxDst, exclude) {
|
|
|
798
839
|
await backend.uploadFile(handle, localTar, REMOTE_UP_TAR);
|
|
799
840
|
const initialPath = boxParent === "/" ? `/${srcBasename}` : `${boxParent}/${srcBasename}`;
|
|
800
841
|
const renameStep = finalName !== srcBasename ? `$SUDO cp -f ${quoteShellArg(initialPath)} ${quoteShellArg(finalPath)} && $SUDO rm -f ${quoteShellArg(initialPath)}` : ": # no rename";
|
|
842
|
+
const underHome = finalPath.startsWith(BOX_HOME2 + "/");
|
|
843
|
+
const parentWalk = underHome ? `parent=$(dirname ${quoteShellArg(finalPath)}); while [ "$parent" != ${quoteShellArg(BOX_HOME2)} ] && [ "$parent" != "/" ]; do $SUDO chown "$(id -un):$(id -gn)" "$parent" || true; parent=$(dirname "$parent"); done` : `: # dest outside ${BOX_HOME2}; leave parent ownership untouched`;
|
|
801
844
|
const script = [
|
|
802
845
|
`set -euo pipefail`,
|
|
803
846
|
`if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`,
|
|
@@ -808,9 +851,10 @@ async function uploadToCloudBox(backend, handle, hostSrc, boxDst, exclude) {
|
|
|
808
851
|
// sandbox's regular disk. Same flags as the credential-seed extract.
|
|
809
852
|
`$SUDO tar -xzf ${quoteShellArg(REMOTE_UP_TAR)} -C ${quoteShellArg(boxParent)} --no-same-permissions --no-same-owner -m`,
|
|
810
853
|
renameStep,
|
|
811
|
-
// chown
|
|
812
|
-
//
|
|
854
|
+
// chown the landed subtree, then the parent chain back up to $HOME.
|
|
855
|
+
// Tolerate failure (chown bad on read-only / FUSE mounts).
|
|
813
856
|
`$SUDO chown -R "$(id -un):$(id -gn)" ${quoteShellArg(finalPath)} || true`,
|
|
857
|
+
parentWalk,
|
|
814
858
|
`rm -f ${quoteShellArg(REMOTE_UP_TAR)}`
|
|
815
859
|
].join("\n");
|
|
816
860
|
const r = await backend.exec(handle, bashScript(script));
|
|
@@ -846,7 +890,7 @@ async function pullCloudDirContents(backend, handle, boxSrcDir, hostDstDir) {
|
|
|
846
890
|
}
|
|
847
891
|
return { finalPath: dstAbs };
|
|
848
892
|
}
|
|
849
|
-
async function
|
|
893
|
+
async function downloadOneFromCloudBox(backend, handle, boxSrc, hostDst, exclude) {
|
|
850
894
|
const srcBasename = posix.basename(boxSrc);
|
|
851
895
|
const srcParent = posix.dirname(boxSrc);
|
|
852
896
|
const dstAbs = hostResolve(hostDst);
|
|
@@ -887,6 +931,37 @@ async function downloadFromCloudBox(backend, handle, boxSrc, hostDst, exclude) {
|
|
|
887
931
|
}
|
|
888
932
|
return { finalPath };
|
|
889
933
|
}
|
|
934
|
+
async function uploadToCloudBox(backend, handle, hostSrcs, boxDst, exclude) {
|
|
935
|
+
if (hostSrcs.length === 1) {
|
|
936
|
+
return uploadOneToCloudBox(backend, handle, hostSrcs[0], boxDst, exclude);
|
|
937
|
+
}
|
|
938
|
+
if (!boxDst.endsWith("/")) {
|
|
939
|
+
throw new Error(
|
|
940
|
+
`cannot copy multiple sources to '${boxDst}': destination is not a directory (add a trailing slash, e.g. ${boxDst}/)`
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
for (const src of hostSrcs) {
|
|
944
|
+
await uploadOneToCloudBox(backend, handle, src, boxDst, exclude);
|
|
945
|
+
}
|
|
946
|
+
return { finalPath: boxDst };
|
|
947
|
+
}
|
|
948
|
+
async function downloadFromCloudBox(backend, handle, boxSrcs, hostDst, exclude) {
|
|
949
|
+
if (boxSrcs.length === 1) {
|
|
950
|
+
return downloadOneFromCloudBox(backend, handle, boxSrcs[0], hostDst, exclude);
|
|
951
|
+
}
|
|
952
|
+
const dstAbs = hostResolve(hostDst);
|
|
953
|
+
const dstExists = existsSync(dstAbs);
|
|
954
|
+
if (!hostDst.endsWith("/") && !(dstExists && statSync(dstAbs).isDirectory())) {
|
|
955
|
+
throw new Error(
|
|
956
|
+
`cannot copy multiple sources to '${hostDst}': destination is not a directory (add a trailing slash, e.g. ${hostDst}/)`
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
mkdirSync(dstAbs, { recursive: true });
|
|
960
|
+
for (const src of boxSrcs) {
|
|
961
|
+
await downloadOneFromCloudBox(backend, handle, src, dstAbs, exclude);
|
|
962
|
+
}
|
|
963
|
+
return { finalPath: dstAbs };
|
|
964
|
+
}
|
|
890
965
|
async function launchCloudCtlDaemon(args) {
|
|
891
966
|
const env = [
|
|
892
967
|
`AGENTBOX_BOX_ID=${quoteShellArgv([args.boxId])}`,
|
|
@@ -907,8 +982,29 @@ async function launchCloudCtlDaemon(args) {
|
|
|
907
982
|
if (args.webProxyPort !== void 0)
|
|
908
983
|
boxEnvFile.push(`AGENTBOX_WEB_PROXY_PORT=${quoteShellArgv([String(args.webProxyPort)])}`);
|
|
909
984
|
if (args.boxHost) boxEnvFile.push(`AGENTBOX_BOX_HOST=${quoteShellArgv([args.boxHost])}`);
|
|
985
|
+
const boxRelayPort = (() => {
|
|
986
|
+
if (args.relayUrl) {
|
|
987
|
+
try {
|
|
988
|
+
const p = new URL(args.relayUrl).port;
|
|
989
|
+
if (p) return Number.parseInt(p, 10);
|
|
990
|
+
} catch {
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
return 8788;
|
|
994
|
+
})();
|
|
910
995
|
const script = [
|
|
911
996
|
`set -e`,
|
|
997
|
+
// Idempotent: if a healthy ctl daemon is already serving the box relay,
|
|
998
|
+
// leave it — it already has the right env (relayUrl/token are stable across
|
|
999
|
+
// a host-only reconnect), and a fresh spawn would just fail to bind :PORT
|
|
1000
|
+
// and linger as an orphan. Only a real sandbox restart kills the daemon, in
|
|
1001
|
+
// which case the probe fails and we (re)launch. Without this, every
|
|
1002
|
+
// start/resume/recover leaked another idle daemon. node is guaranteed
|
|
1003
|
+
// present (it runs agentbox-ctl); curl may not be.
|
|
1004
|
+
`if node -e 'require("http").get("http://127.0.0.1:${String(boxRelayPort)}/healthz",r=>process.exit(r.statusCode===200?0:1)).on("error",()=>process.exit(1))' 2>/dev/null; then`,
|
|
1005
|
+
` echo "agentbox-ctl daemon already healthy on :${String(boxRelayPort)}; skipping launch"`,
|
|
1006
|
+
` exit 0`,
|
|
1007
|
+
`fi`,
|
|
912
1008
|
`if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`,
|
|
913
1009
|
`$SUDO mkdir -p /run/agentbox /var/log/agentbox /etc/agentbox`,
|
|
914
1010
|
`$SUDO chown "$(id -un):$(id -gn)" /run/agentbox /var/log/agentbox`,
|
|
@@ -1117,7 +1213,9 @@ async function seedFromGitClone(args) {
|
|
|
1117
1213
|
adaptive ? `clone: depth=${String(DEFAULT_BUNDLE_DEPTH)} (default, adaptive)` : initialDepth === null ? "clone: depth=full (configured)" : `clone: depth=${String(initialDepth)} (configured)`
|
|
1118
1214
|
);
|
|
1119
1215
|
const cloneBranch = args.useBranch ?? args.fromBranch;
|
|
1216
|
+
const lfsRef = cloneBranch ?? "HEAD";
|
|
1120
1217
|
await runShallowClone(args.hostRepo, cloneDir, initialDepth, stashRefCreated, cloneBranch);
|
|
1218
|
+
await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
|
|
1121
1219
|
await tarCloneDir(cloneDir, tarPath);
|
|
1122
1220
|
if (adaptive && initialDepth !== null) {
|
|
1123
1221
|
const size = await safeFileSize(tarPath);
|
|
@@ -1129,6 +1227,7 @@ async function seedFromGitClone(args) {
|
|
|
1129
1227
|
await rm6(cloneDir, { recursive: true, force: true });
|
|
1130
1228
|
await rm6(tarPath, { force: true });
|
|
1131
1229
|
await runShallowClone(args.hostRepo, cloneDir, LARGE_BUNDLE_DEPTH, stashRefCreated, cloneBranch);
|
|
1230
|
+
await seedCloneLfsObjects(args.hostRepo, cloneDir, lfsRef, log);
|
|
1132
1231
|
await tarCloneDir(cloneDir, tarPath);
|
|
1133
1232
|
}
|
|
1134
1233
|
}
|
|
@@ -1200,6 +1299,7 @@ async function seedFromGitClone(args) {
|
|
|
1200
1299
|
}
|
|
1201
1300
|
var DELTA_TARGET_REF = "refs/agentbox-delta/target";
|
|
1202
1301
|
var REMOTE_DELTA_BUNDLE = "/tmp/agentbox-delta.bundle";
|
|
1302
|
+
var REMOTE_DELTA_LFS = "/tmp/agentbox-delta-lfs.tar.gz";
|
|
1203
1303
|
var SHA_RE = /^[0-9a-f]{40}$/;
|
|
1204
1304
|
async function tryReseedRepoDelta(args) {
|
|
1205
1305
|
const log = args.onLog ?? (() => {
|
|
@@ -1232,6 +1332,7 @@ async function tryReseedRepoDelta(args) {
|
|
|
1232
1332
|
const stage = await mkdtemp5(join6(tmpdir5(), "agentbox-delta-"));
|
|
1233
1333
|
const bundlePath = join6(stage, "delta.bundle");
|
|
1234
1334
|
const untrackedTarPath = join6(stage, "untracked.tar.gz");
|
|
1335
|
+
const deltaLfsTarPath = join6(stage, "delta-lfs.tar.gz");
|
|
1235
1336
|
const stashSha = args.useBranch || args.skipCarryOver ? null : await safeStashCreate(args.hostRepo);
|
|
1236
1337
|
const untrackedSize = args.useBranch || args.skipCarryOver ? 0 : await maybeBuildUntrackedTar(args.hostRepo, untrackedTarPath);
|
|
1237
1338
|
let stashRefCreated = false;
|
|
@@ -1267,6 +1368,18 @@ async function tryReseedRepoDelta(args) {
|
|
|
1267
1368
|
if (untrackedSize > 0) {
|
|
1268
1369
|
await args.backend.uploadFile(args.handle, untrackedTarPath, REMOTE_UNTRACKED_TAR);
|
|
1269
1370
|
}
|
|
1371
|
+
const deltaLfsSize = await maybeBuildDeltaLfsTar(
|
|
1372
|
+
args.hostRepo,
|
|
1373
|
+
target,
|
|
1374
|
+
checkpointTip,
|
|
1375
|
+
deltaLfsTarPath
|
|
1376
|
+
);
|
|
1377
|
+
if (deltaLfsSize > 0) {
|
|
1378
|
+
await args.backend.uploadFile(args.handle, deltaLfsTarPath, REMOTE_DELTA_LFS);
|
|
1379
|
+
log(
|
|
1380
|
+
`checkpoint restore: ${args.workspaceDir}: ${String(deltaLfsSize)} B of new git-lfs objects`
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1270
1383
|
log(
|
|
1271
1384
|
needTarget ? `checkpoint restore: ${args.workspaceDir}: delta bundle (${checkpointTip.slice(0, 8)}..${target.slice(0, 8)})` : `checkpoint restore: ${args.workspaceDir}: no new host commits; re-branch + carry-over only`
|
|
1272
1385
|
);
|
|
@@ -1284,18 +1397,20 @@ async function tryReseedRepoDelta(args) {
|
|
|
1284
1397
|
hasUntracked: untrackedSize > 0,
|
|
1285
1398
|
detectConflicts: true
|
|
1286
1399
|
});
|
|
1400
|
+
const lfsStep = deltaLfsSize > 0 ? `tar -C ${quoteShellArgv([`${args.workspaceDir}/.git`])} -xzf ${quoteShellArgv([REMOTE_DELTA_LFS])}` : ": # no delta lfs objects";
|
|
1287
1401
|
const SUDO = `if command -v sudo >/dev/null 2>&1; then SUDO='sudo -n'; else SUDO=''; fi`;
|
|
1288
1402
|
const script = [
|
|
1289
1403
|
`set -euo pipefail`,
|
|
1290
1404
|
`cd /tmp`,
|
|
1291
1405
|
SUDO,
|
|
1292
1406
|
fetchStep,
|
|
1407
|
+
lfsStep,
|
|
1293
1408
|
checkoutStep,
|
|
1294
1409
|
`git -C ${wd} reset --hard ${quoteShellArgv([target])}`,
|
|
1295
1410
|
setOrigin,
|
|
1296
1411
|
...carryOverSteps,
|
|
1297
1412
|
`git -C ${wd} update-ref -d ${quoteShellArgv([DELTA_TARGET_REF])} || true`,
|
|
1298
|
-
`rm -f ${quoteShellArgv([REMOTE_DELTA_BUNDLE])}`
|
|
1413
|
+
`rm -f ${quoteShellArgv([REMOTE_DELTA_BUNDLE])} ${quoteShellArgv([REMOTE_DELTA_LFS])}`
|
|
1299
1414
|
].join("\n");
|
|
1300
1415
|
const r = await args.backend.exec(args.handle, bashScript(script));
|
|
1301
1416
|
if (r.exitCode !== 0) {
|
|
@@ -1336,6 +1451,69 @@ async function tarCloneDir(cloneDir, outPath) {
|
|
|
1336
1451
|
env: { ...process.env, COPYFILE_DISABLE: "1" }
|
|
1337
1452
|
});
|
|
1338
1453
|
}
|
|
1454
|
+
var LFS_OID_RE = /^[0-9a-f]{64}$/;
|
|
1455
|
+
function lfsObjectRelPath(oid) {
|
|
1456
|
+
return join6("lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid);
|
|
1457
|
+
}
|
|
1458
|
+
async function lfsOidsForRef(hostRepo, ref) {
|
|
1459
|
+
const listed = await execa5("git", ["-C", hostRepo, "lfs", "ls-files", "--long", ref], {
|
|
1460
|
+
reject: false
|
|
1461
|
+
});
|
|
1462
|
+
if (listed.exitCode !== 0) return [];
|
|
1463
|
+
const oids = listed.stdout.split("\n").map((l) => l.trim().split(/\s+/)[0] ?? "").filter((o) => LFS_OID_RE.test(o));
|
|
1464
|
+
return [...new Set(oids)];
|
|
1465
|
+
}
|
|
1466
|
+
async function seedCloneLfsObjects(hostRepo, cloneDir, ref, log) {
|
|
1467
|
+
const tracked = await execa5("git", ["-C", hostRepo, "lfs", "ls-files", "-n", ref], {
|
|
1468
|
+
reject: false
|
|
1469
|
+
});
|
|
1470
|
+
if (tracked.exitCode !== 0 || tracked.stdout.trim().length === 0) return;
|
|
1471
|
+
const fetched = await execa5("git", ["-C", hostRepo, "lfs", "fetch", "origin", ref], {
|
|
1472
|
+
reject: false
|
|
1473
|
+
});
|
|
1474
|
+
if (fetched.exitCode !== 0) {
|
|
1475
|
+
const msg = (fetched.stderr || fetched.stdout || `exit ${String(fetched.exitCode ?? "?")}`).trim().split("\n")[0];
|
|
1476
|
+
log(`git-lfs prefetch for ${ref} skipped (best-effort, continuing): ${msg}`);
|
|
1477
|
+
}
|
|
1478
|
+
const oids = await lfsOidsForRef(hostRepo, ref);
|
|
1479
|
+
let copied = 0;
|
|
1480
|
+
for (const oid of oids) {
|
|
1481
|
+
const rel = lfsObjectRelPath(oid);
|
|
1482
|
+
const dst = join6(cloneDir, ".git", rel);
|
|
1483
|
+
try {
|
|
1484
|
+
await mkdir3(dirname3(dst), { recursive: true });
|
|
1485
|
+
await copyFile(join6(hostRepo, ".git", rel), dst);
|
|
1486
|
+
copied++;
|
|
1487
|
+
} catch {
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
if (copied > 0) log(`seeded ${String(copied)} git-lfs object(s) for ${ref} into clone`);
|
|
1491
|
+
}
|
|
1492
|
+
async function maybeBuildDeltaLfsTar(hostRepo, target, checkpointTip, outPath) {
|
|
1493
|
+
const targetOids = await lfsOidsForRef(hostRepo, target);
|
|
1494
|
+
if (targetOids.length === 0) return 0;
|
|
1495
|
+
const have = new Set(await lfsOidsForRef(hostRepo, checkpointTip));
|
|
1496
|
+
const deltaOids = targetOids.filter((o) => !have.has(o));
|
|
1497
|
+
if (deltaOids.length === 0) return 0;
|
|
1498
|
+
await execa5("git", ["-C", hostRepo, "lfs", "fetch", "origin", target], { reject: false });
|
|
1499
|
+
const gitDir = join6(hostRepo, ".git");
|
|
1500
|
+
const relPaths = [];
|
|
1501
|
+
for (const oid of deltaOids) {
|
|
1502
|
+
const rel = lfsObjectRelPath(oid);
|
|
1503
|
+
try {
|
|
1504
|
+
await stat(join6(gitDir, rel));
|
|
1505
|
+
relPaths.push(rel);
|
|
1506
|
+
} catch {
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (relPaths.length === 0) return 0;
|
|
1510
|
+
const tar = await execa5("tar", ["-C", gitDir, "-czf", outPath, ...relPaths], {
|
|
1511
|
+
env: { ...process.env, COPYFILE_DISABLE: "1" },
|
|
1512
|
+
reject: false
|
|
1513
|
+
});
|
|
1514
|
+
if (tar.exitCode !== 0) return 0;
|
|
1515
|
+
return safeFileSize(outPath);
|
|
1516
|
+
}
|
|
1339
1517
|
async function safeFileSize(path) {
|
|
1340
1518
|
try {
|
|
1341
1519
|
return (await stat(path)).size;
|
|
@@ -1779,6 +1957,8 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
1779
1957
|
onLog: log
|
|
1780
1958
|
});
|
|
1781
1959
|
}
|
|
1960
|
+
await ensureAgentHomeDirsOwned(backend, handle, { onLog: log });
|
|
1961
|
+
await ensureCodexAgentsOverride(backend, handle, { onLog: log });
|
|
1782
1962
|
await seedOpencodeModelState(backend, handle, { onLog: log });
|
|
1783
1963
|
await seedClaudeJsonAtCreate(backend, handle, {
|
|
1784
1964
|
hostWorkspace: req.workspacePath,
|
|
@@ -2011,6 +2191,25 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2011
2191
|
await backend.start(h);
|
|
2012
2192
|
return reEnsureCloudBox(box, h);
|
|
2013
2193
|
},
|
|
2194
|
+
async reconnect(box) {
|
|
2195
|
+
const h = handleFor(box);
|
|
2196
|
+
const state = await probe(box);
|
|
2197
|
+
if (state === "running") return reEnsureCloudBox(box, h);
|
|
2198
|
+
if (state === "paused") {
|
|
2199
|
+
await backend.resume(h);
|
|
2200
|
+
return reEnsureCloudBox(box, h);
|
|
2201
|
+
}
|
|
2202
|
+
if (state === "stopped") {
|
|
2203
|
+
await backend.start(h);
|
|
2204
|
+
return reEnsureCloudBox(box, h);
|
|
2205
|
+
}
|
|
2206
|
+
throw new Error(
|
|
2207
|
+
`cannot recover ${box.name}: sandbox ${box.cloud?.sandboxId ?? box.id} is ${state}`
|
|
2208
|
+
);
|
|
2209
|
+
},
|
|
2210
|
+
async repairReachability(box) {
|
|
2211
|
+
return await backend.repairReachability?.(handleFor(box)) ?? { changed: false };
|
|
2212
|
+
},
|
|
2014
2213
|
async pause(box) {
|
|
2015
2214
|
await backend.pause(handleFor(box));
|
|
2016
2215
|
await persistLastState(box, "paused");
|
|
@@ -2114,11 +2313,11 @@ function createCloudProvider(backend, opts = {}) {
|
|
|
2114
2313
|
} : void 0;
|
|
2115
2314
|
return { argv: fullArgv, cleanup };
|
|
2116
2315
|
},
|
|
2117
|
-
async uploadPath(box,
|
|
2118
|
-
return uploadToCloudBox(backend, handleFor(box),
|
|
2316
|
+
async uploadPath(box, hostSrcs, boxDst, exclude) {
|
|
2317
|
+
return uploadToCloudBox(backend, handleFor(box), hostSrcs, boxDst, exclude);
|
|
2119
2318
|
},
|
|
2120
|
-
async downloadPath(box,
|
|
2121
|
-
return downloadFromCloudBox(backend, handleFor(box),
|
|
2319
|
+
async downloadPath(box, boxSrcs, hostDst, exclude) {
|
|
2320
|
+
return downloadFromCloudBox(backend, handleFor(box), boxSrcs, hostDst, exclude);
|
|
2122
2321
|
},
|
|
2123
2322
|
async downloadDirContents(box, boxSrc, hostDst) {
|
|
2124
2323
|
return pullCloudDirContents(backend, handleFor(box), boxSrc, hostDst);
|
|
@@ -2231,6 +2430,10 @@ function makeCloudCheckpoint(backend) {
|
|
|
2231
2430
|
}
|
|
2232
2431
|
};
|
|
2233
2432
|
}
|
|
2433
|
+
function hostTermForCloud() {
|
|
2434
|
+
const t = process.env["TERM"];
|
|
2435
|
+
return t && /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(t) ? t : "xterm-256color";
|
|
2436
|
+
}
|
|
2234
2437
|
function renderInnerCommand(kind, opts) {
|
|
2235
2438
|
const sessionName = opts?.sessionName ?? defaultSessionName(kind);
|
|
2236
2439
|
const fallback = opts?.command ?? defaultCommand(kind, opts);
|
|
@@ -2249,8 +2452,8 @@ function renderInnerCommand(kind, opts) {
|
|
|
2249
2452
|
`tmux has-session -t ${sessionQ} 2>/dev/null || tmux new-session -d -c ${cwdQ} -s ${sessionQ} ${fallbackQ}`,
|
|
2250
2453
|
configSnippet
|
|
2251
2454
|
];
|
|
2252
|
-
if (opts?.detached) return lines.join("; ");
|
|
2253
|
-
return [...lines, `exec tmux attach -t ${sessionQ}`].join("; ");
|
|
2455
|
+
if (opts?.detached) return TERM_FALLBACK_SNIPPET + lines.join("; ");
|
|
2456
|
+
return TERM_FALLBACK_SNIPPET + [...lines, `exec tmux attach -t ${sessionQ}`].join("; ");
|
|
2254
2457
|
}
|
|
2255
2458
|
function defaultSessionName(kind) {
|
|
2256
2459
|
switch (kind) {
|
|
@@ -2295,6 +2498,7 @@ export {
|
|
|
2295
2498
|
removeCloudCheckpointDir,
|
|
2296
2499
|
probeCloudCheckpoint,
|
|
2297
2500
|
createCloudProvider,
|
|
2501
|
+
hostTermForCloud,
|
|
2298
2502
|
renderInnerCommand
|
|
2299
2503
|
};
|
|
2300
|
-
//# sourceMappingURL=chunk-
|
|
2504
|
+
//# sourceMappingURL=chunk-QKL7PCXQ.js.map
|