@boxes-dev/dvb-runtime 1.0.180 → 1.0.182
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/bin/dvb.cjs +284 -150
- package/dist/bin/dvb.cjs.map +1 -1
- package/dist/bin/dvbd.cjs +6 -6
- package/dist/devbox/commands/init/codex/execConfig.d.ts +1 -1
- package/dist/devbox/commands/init/codex/execConfig.d.ts.map +1 -1
- package/dist/devbox/commands/init/codex/execConfig.js +1 -1
- package/dist/devbox/commands/init/codex/execConfig.js.map +1 -1
- package/dist/devbox/commands/provider/modalRuntime.d.ts +1 -5
- package/dist/devbox/commands/provider/modalRuntime.d.ts.map +1 -1
- package/dist/devbox/commands/provider/modalRuntime.js +209 -99
- package/dist/devbox/commands/provider/modalRuntime.js.map +1 -1
- package/dist/devbox/daemonClient.d.ts +1 -0
- package/dist/devbox/daemonClient.d.ts.map +1 -1
- package/dist/devbox/daemonClient.js +7 -2
- package/dist/devbox/daemonClient.js.map +1 -1
- package/package.json +2 -2
package/dist/bin/dvb.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76631a09-23cb-5d66-b6e8-c3a9d5351d3b")}catch(e){}}();
|
|
4
4
|
|
|
5
5
|
var __create = Object.create;
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
@@ -88688,8 +88688,8 @@ var init_otel = __esm({
|
|
|
88688
88688
|
return trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
88689
88689
|
};
|
|
88690
88690
|
readBuildMetadata = () => {
|
|
88691
|
-
const rawPackageVersion = "1.0.
|
|
88692
|
-
const rawGitSha = "
|
|
88691
|
+
const rawPackageVersion = "1.0.182";
|
|
88692
|
+
const rawGitSha = "1d4fcc54f69a7ebd0d25b7c66bc48ea9a3719434";
|
|
88693
88693
|
const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
|
|
88694
88694
|
const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
|
|
88695
88695
|
return { packageVersion, gitSha };
|
|
@@ -120881,9 +120881,9 @@ var init_sentry = __esm({
|
|
|
120881
120881
|
sentryEnabled = false;
|
|
120882
120882
|
uncaughtExceptionMonitorInstalled = false;
|
|
120883
120883
|
readBuildMetadata2 = () => {
|
|
120884
|
-
const rawPackageVersion = "1.0.
|
|
120885
|
-
const rawGitSha = "
|
|
120886
|
-
const rawSentryRelease = "boxes-dev-dvb@1.0.
|
|
120884
|
+
const rawPackageVersion = "1.0.182";
|
|
120885
|
+
const rawGitSha = "1d4fcc54f69a7ebd0d25b7c66bc48ea9a3719434";
|
|
120886
|
+
const rawSentryRelease = "boxes-dev-dvb@1.0.182+1d4fcc54f69a7ebd0d25b7c66bc48ea9a3719434";
|
|
120887
120887
|
const packageVersion = typeof rawPackageVersion === "string" ? rawPackageVersion : void 0;
|
|
120888
120888
|
const gitSha = typeof rawGitSha === "string" ? rawGitSha : void 0;
|
|
120889
120889
|
const sentryRelease = typeof rawSentryRelease === "string" ? rawSentryRelease : void 0;
|
|
@@ -123416,7 +123416,7 @@ var require_websocket = __commonJS({
|
|
|
123416
123416
|
var http6 = require("http");
|
|
123417
123417
|
var net7 = require("net");
|
|
123418
123418
|
var tls2 = require("tls");
|
|
123419
|
-
var { randomBytes, createHash:
|
|
123419
|
+
var { randomBytes, createHash: createHash7 } = require("crypto");
|
|
123420
123420
|
var { Duplex, Readable: Readable3 } = require("stream");
|
|
123421
123421
|
var { URL: URL2 } = require("url");
|
|
123422
123422
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -124076,7 +124076,7 @@ var require_websocket = __commonJS({
|
|
|
124076
124076
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
124077
124077
|
return;
|
|
124078
124078
|
}
|
|
124079
|
-
const digest =
|
|
124079
|
+
const digest = createHash7("sha1").update(key + GUID).digest("base64");
|
|
124080
124080
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
124081
124081
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
124082
124082
|
return;
|
|
@@ -124443,7 +124443,7 @@ var require_websocket_server = __commonJS({
|
|
|
124443
124443
|
var EventEmitter = require("events");
|
|
124444
124444
|
var http6 = require("http");
|
|
124445
124445
|
var { Duplex } = require("stream");
|
|
124446
|
-
var { createHash:
|
|
124446
|
+
var { createHash: createHash7 } = require("crypto");
|
|
124447
124447
|
var extension = require_extension();
|
|
124448
124448
|
var PerMessageDeflate = require_permessage_deflate();
|
|
124449
124449
|
var subprotocol = require_subprotocol();
|
|
@@ -124744,7 +124744,7 @@ var require_websocket_server = __commonJS({
|
|
|
124744
124744
|
);
|
|
124745
124745
|
}
|
|
124746
124746
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
124747
|
-
const digest =
|
|
124747
|
+
const digest = createHash7("sha1").update(key + GUID).digest("base64");
|
|
124748
124748
|
const headers = [
|
|
124749
124749
|
"HTTP/1.1 101 Switching Protocols",
|
|
124750
124750
|
"Upgrade: websocket",
|
|
@@ -124880,7 +124880,7 @@ var init_packageVersion = __esm({
|
|
|
124880
124880
|
return import_node_path8.default.join(process.cwd(), "dvb");
|
|
124881
124881
|
};
|
|
124882
124882
|
readEmbeddedPackageVersion = () => {
|
|
124883
|
-
const raw = "1.0.
|
|
124883
|
+
const raw = "1.0.182";
|
|
124884
124884
|
return trimVersion(raw);
|
|
124885
124885
|
};
|
|
124886
124886
|
readNearestPackageMetadata = (basePath) => {
|
|
@@ -134744,7 +134744,7 @@ var init_simple_client_node = __esm({
|
|
|
134744
134744
|
var http6 = __require("http");
|
|
134745
134745
|
var net7 = __require("net");
|
|
134746
134746
|
var tls2 = __require("tls");
|
|
134747
|
-
var { randomBytes, createHash:
|
|
134747
|
+
var { randomBytes, createHash: createHash7 } = __require("crypto");
|
|
134748
134748
|
var { Duplex, Readable: Readable3 } = __require("stream");
|
|
134749
134749
|
var { URL: URL2 } = __require("url");
|
|
134750
134750
|
var PerMessageDeflate = require_permessage_deflate2();
|
|
@@ -135401,7 +135401,7 @@ var init_simple_client_node = __esm({
|
|
|
135401
135401
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
135402
135402
|
return;
|
|
135403
135403
|
}
|
|
135404
|
-
const digest =
|
|
135404
|
+
const digest = createHash7("sha1").update(key + GUID).digest("base64");
|
|
135405
135405
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
135406
135406
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
135407
135407
|
return;
|
|
@@ -135666,7 +135666,7 @@ var init_simple_client_node = __esm({
|
|
|
135666
135666
|
var EventEmitter = __require("events");
|
|
135667
135667
|
var http6 = __require("http");
|
|
135668
135668
|
var { Duplex } = __require("stream");
|
|
135669
|
-
var { createHash:
|
|
135669
|
+
var { createHash: createHash7 } = __require("crypto");
|
|
135670
135670
|
var extension = require_extension2();
|
|
135671
135671
|
var PerMessageDeflate = require_permessage_deflate2();
|
|
135672
135672
|
var subprotocol = require_subprotocol2();
|
|
@@ -135961,7 +135961,7 @@ var init_simple_client_node = __esm({
|
|
|
135961
135961
|
);
|
|
135962
135962
|
}
|
|
135963
135963
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
135964
|
-
const digest =
|
|
135964
|
+
const digest = createHash7("sha1").update(key + GUID).digest("base64");
|
|
135965
135965
|
const headers = [
|
|
135966
135966
|
"HTTP/1.1 101 Switching Protocols",
|
|
135967
135967
|
"Upgrade: websocket",
|
|
@@ -142352,7 +142352,7 @@ var init_controlPlane = __esm({
|
|
|
142352
142352
|
});
|
|
142353
142353
|
|
|
142354
142354
|
// src/devbox/daemonClient.ts
|
|
142355
|
-
var import_node_http3, import_node_path11, import_node_child_process3, import_node_crypto7, import_node_fs6, import_promises6, DAEMON_TIMEOUT_MS, AUTH_RELOGIN_HINT, readNonEmptyString2, extractDaemonErrorPayload, shouldAttachReloginHint, formatDaemonResponseError, throwDaemonResponseError, DaemonConnectionError, isConnectionError, unixSocketPathLimit, isSocketPathTooLong, expectedDaemonVersionCache, daemonFeaturesCache, ensureDaemonRunningInFlight, readExpectedDaemonVersion, normalizeVersion, requestJson3, requireDaemonFeatures, resolveDaemonCommand, spawnDaemon, waitForHealth, listAlternateSocketPaths, pruneDuplicateDaemons, listDaemonPidsForSocket, pruneSameSocketDaemons, maybeRestartDaemonForVersionMismatch, readHealthyDaemon, ensureDaemonRunning, ensureDaemonUpToDateIfRunning, waitForSocketGone, stopDaemon;
|
|
142355
|
+
var import_node_http3, import_node_path11, import_node_child_process3, import_node_crypto7, import_node_fs6, import_promises6, DAEMON_TIMEOUT_MS, AUTH_RELOGIN_HINT, readNonEmptyString2, extractDaemonErrorPayload, shouldAttachReloginHint, formatDaemonResponseError, throwDaemonResponseError, DaemonConnectionError, isConnectionError, isDaemonConnectionError, unixSocketPathLimit, isSocketPathTooLong, expectedDaemonVersionCache, daemonFeaturesCache, ensureDaemonRunningInFlight, ACTIVE_DAEMON_RECOVERY_TIMEOUT_MS, readExpectedDaemonVersion, normalizeVersion, requestJson3, requireDaemonFeatures, resolveDaemonCommand, spawnDaemon, waitForHealth, listAlternateSocketPaths, pruneDuplicateDaemons, listDaemonPidsForSocket, pruneSameSocketDaemons, maybeRestartDaemonForVersionMismatch, readHealthyDaemon, ensureDaemonRunning, ensureDaemonUpToDateIfRunning, waitForSocketGone, stopDaemon;
|
|
142356
142356
|
var init_daemonClient = __esm({
|
|
142357
142357
|
"src/devbox/daemonClient.ts"() {
|
|
142358
142358
|
"use strict";
|
|
@@ -142435,6 +142435,7 @@ var init_daemonClient = __esm({
|
|
|
142435
142435
|
const code2 = error2.code;
|
|
142436
142436
|
return code2 === "ENOENT" || code2 === "ECONNREFUSED" || code2 === "EPIPE" || code2 === "ENOTFOUND" || code2 === "EINVAL" || code2 === "ENAMETOOLONG";
|
|
142437
142437
|
};
|
|
142438
|
+
isDaemonConnectionError = isConnectionError;
|
|
142438
142439
|
unixSocketPathLimit = () => {
|
|
142439
142440
|
return process.platform === "linux" ? 107 : 103;
|
|
142440
142441
|
};
|
|
@@ -142444,6 +142445,7 @@ var init_daemonClient = __esm({
|
|
|
142444
142445
|
expectedDaemonVersionCache = null;
|
|
142445
142446
|
daemonFeaturesCache = /* @__PURE__ */ new Map();
|
|
142446
142447
|
ensureDaemonRunningInFlight = /* @__PURE__ */ new Map();
|
|
142448
|
+
ACTIVE_DAEMON_RECOVERY_TIMEOUT_MS = 2e4;
|
|
142447
142449
|
readExpectedDaemonVersion = () => {
|
|
142448
142450
|
if (expectedDaemonVersionCache) return expectedDaemonVersionCache;
|
|
142449
142451
|
expectedDaemonVersionCache = readCurrentPackageVersion() ?? "unknown";
|
|
@@ -142797,8 +142799,10 @@ var init_daemonClient = __esm({
|
|
|
142797
142799
|
return health2;
|
|
142798
142800
|
}
|
|
142799
142801
|
await pruneDuplicateDaemons(socketPath);
|
|
142802
|
+
const existingDaemonPids = listDaemonPidsForSocket(socketPath);
|
|
142803
|
+
const recoverTimeoutMs = existingDaemonPids.length > 0 ? ACTIVE_DAEMON_RECOVERY_TIMEOUT_MS : 1200;
|
|
142800
142804
|
try {
|
|
142801
|
-
const recovered = await waitForHealth(socketPath,
|
|
142805
|
+
const recovered = await waitForHealth(socketPath, recoverTimeoutMs);
|
|
142802
142806
|
const health2 = await maybeRestartDaemonForVersionMismatch(
|
|
142803
142807
|
socketPath,
|
|
142804
142808
|
recovered
|
|
@@ -206080,7 +206084,7 @@ var init_modalLifecycle = __esm({
|
|
|
206080
206084
|
});
|
|
206081
206085
|
|
|
206082
206086
|
// src/devbox/commands/provider/modalRuntime.ts
|
|
206083
|
-
var import_node_crypto10, import_node_path16, import_node_net3, SERVICE_NAME_PATTERN, CORE_SERVICE_NAMES2, MODAL_DAEMON_REQUEST_TIMEOUT_MS, MODAL_DAEMON_REQUEST_TIMEOUT_MAX_MS, MODAL_DAEMON_TTY_HANDSHAKE_TIMEOUT_MS, MODAL_SANDBOX_RESOLVE_TIMEOUT_MS, MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_MS, MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_PADDING_MS,
|
|
206087
|
+
var import_node_crypto10, import_node_path16, import_node_net3, SERVICE_NAME_PATTERN, CORE_SERVICE_NAMES2, MODAL_DAEMON_REQUEST_TIMEOUT_MS, MODAL_DAEMON_REQUEST_TIMEOUT_MAX_MS, MODAL_DAEMON_TTY_HANDSHAKE_TIMEOUT_MS, MODAL_SANDBOX_RESOLVE_TIMEOUT_MS, MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_MS, MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_PADDING_MS, MODAL_DAEMON_TTY_WS_PATH, MODAL_DAEMON_INLINE_WRITE_MAX_BYTES, MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES, MODAL_DAEMON_MULTIPART_WRITE_CONCURRENCY, MODAL_DAEMON_WRITE_TIMEOUT_BASE_MS, MODAL_DAEMON_WRITE_TIMEOUT_PER_MIB_MS, MODAL_DAEMON_MULTIPART_ASSEMBLE_MIN_TIMEOUT_MS, logger9, validateServiceName, isSandboxNotFoundError, shellQuote3, clampModalControlTimeoutMs, sha256Hex, estimateModalWriteTimeoutMs, normalizeConcurrency, resolveBoundedConcurrency, estimateModalMultipartPartTimeoutMs, estimateModalMultipartAssembleTimeoutMs, buildModalMultipartWritePlan, buildModalMultipartAssembleScript, buildModalMultipartCleanupScript, buildModalControlTraceAttributes, runWithConcurrency, resolveReadPath, parseJsonRecord2, withTimeout3, parseControlError, mapControlSessionRecord, normalizeServiceScope, normalizeServiceRestartPolicy, normalizeServiceStatus2, ModalDaemonExecSocket, createModalRuntimeClient;
|
|
206084
206088
|
var init_modalRuntime = __esm({
|
|
206085
206089
|
"src/devbox/commands/provider/modalRuntime.ts"() {
|
|
206086
206090
|
"use strict";
|
|
@@ -206100,9 +206104,13 @@ var init_modalRuntime = __esm({
|
|
|
206100
206104
|
MODAL_SANDBOX_RESOLVE_TIMEOUT_MS = 3e4;
|
|
206101
206105
|
MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_MS = 25e3;
|
|
206102
206106
|
MODAL_DAEMON_CONTROL_HTTP_TIMEOUT_PADDING_MS = 1e4;
|
|
206103
|
-
MODAL_FS_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
206104
|
-
MODAL_FS_WRITE_TIMEOUT_PER_MIB_MS = 4e3;
|
|
206105
206107
|
MODAL_DAEMON_TTY_WS_PATH = "/modal/tty";
|
|
206108
|
+
MODAL_DAEMON_INLINE_WRITE_MAX_BYTES = 8 * 1024 * 1024;
|
|
206109
|
+
MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES = 8 * 1024 * 1024;
|
|
206110
|
+
MODAL_DAEMON_MULTIPART_WRITE_CONCURRENCY = 3;
|
|
206111
|
+
MODAL_DAEMON_WRITE_TIMEOUT_BASE_MS = 5e3;
|
|
206112
|
+
MODAL_DAEMON_WRITE_TIMEOUT_PER_MIB_MS = 2e3;
|
|
206113
|
+
MODAL_DAEMON_MULTIPART_ASSEMBLE_MIN_TIMEOUT_MS = 3e4;
|
|
206106
206114
|
logger9 = createLogger("modal_runtime");
|
|
206107
206115
|
validateServiceName = (service) => {
|
|
206108
206116
|
if (!SERVICE_NAME_PATTERN.test(service)) {
|
|
@@ -206122,36 +206130,111 @@ var init_modalRuntime = __esm({
|
|
|
206122
206130
|
MODAL_DAEMON_REQUEST_TIMEOUT_MAX_MS
|
|
206123
206131
|
);
|
|
206124
206132
|
};
|
|
206125
|
-
|
|
206126
|
-
|
|
206127
|
-
const
|
|
206133
|
+
sha256Hex = (data) => (0, import_node_crypto10.createHash)("sha256").update(data).digest("hex");
|
|
206134
|
+
estimateModalWriteTimeoutMs = (bytes) => {
|
|
206135
|
+
const wholeMiB = Math.max(1, Math.ceil(bytes / (1024 * 1024)));
|
|
206128
206136
|
return clampModalControlTimeoutMs(
|
|
206129
|
-
|
|
206137
|
+
MODAL_DAEMON_WRITE_TIMEOUT_BASE_MS + wholeMiB * MODAL_DAEMON_WRITE_TIMEOUT_PER_MIB_MS
|
|
206130
206138
|
);
|
|
206131
206139
|
};
|
|
206132
|
-
|
|
206133
|
-
|
|
206134
|
-
|
|
206135
|
-
|
|
206136
|
-
|
|
206137
|
-
|
|
206138
|
-
|
|
206139
|
-
|
|
206140
|
-
|
|
206141
|
-
|
|
206142
|
-
|
|
206143
|
-
|
|
206144
|
-
|
|
206145
|
-
|
|
206146
|
-
|
|
206147
|
-
|
|
206148
|
-
|
|
206149
|
-
|
|
206150
|
-
|
|
206151
|
-
|
|
206152
|
-
|
|
206153
|
-
|
|
206140
|
+
normalizeConcurrency = (concurrency) => Math.max(1, Math.floor(concurrency));
|
|
206141
|
+
resolveBoundedConcurrency = (itemCount, concurrency) => Math.max(1, Math.min(itemCount, normalizeConcurrency(concurrency)));
|
|
206142
|
+
estimateModalMultipartPartTimeoutMs = (bytes, concurrency) => estimateModalWriteTimeoutMs(bytes * normalizeConcurrency(concurrency));
|
|
206143
|
+
estimateModalMultipartAssembleTimeoutMs = (bytes) => clampModalControlTimeoutMs(
|
|
206144
|
+
Math.max(
|
|
206145
|
+
MODAL_DAEMON_MULTIPART_ASSEMBLE_MIN_TIMEOUT_MS,
|
|
206146
|
+
estimateModalWriteTimeoutMs(bytes) * 2
|
|
206147
|
+
)
|
|
206148
|
+
);
|
|
206149
|
+
buildModalMultipartWritePlan = (remotePath, data) => {
|
|
206150
|
+
const normalizedRemotePath = import_node_path16.default.posix.normalize(remotePath);
|
|
206151
|
+
const remoteDir = import_node_path16.default.posix.dirname(normalizedRemotePath);
|
|
206152
|
+
const remoteBaseName = import_node_path16.default.posix.basename(normalizedRemotePath);
|
|
206153
|
+
const uploadId = (0, import_node_crypto10.randomUUID)();
|
|
206154
|
+
const partDir = import_node_path16.default.posix.join(
|
|
206155
|
+
remoteDir,
|
|
206156
|
+
`.${remoteBaseName}.tmp-upload-${uploadId}`
|
|
206157
|
+
);
|
|
206158
|
+
const assembledTmpPath = import_node_path16.default.posix.join(
|
|
206159
|
+
remoteDir,
|
|
206160
|
+
`.${remoteBaseName}.tmp-assemble-${uploadId}`
|
|
206161
|
+
);
|
|
206162
|
+
const parts = [];
|
|
206163
|
+
for (let offset = 0, index = 0; offset < data.length; offset += MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES, index += 1) {
|
|
206164
|
+
const partData = data.subarray(
|
|
206165
|
+
offset,
|
|
206166
|
+
Math.min(
|
|
206167
|
+
offset + MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES,
|
|
206168
|
+
data.length
|
|
206169
|
+
)
|
|
206170
|
+
);
|
|
206171
|
+
parts.push({
|
|
206172
|
+
index,
|
|
206173
|
+
remotePath: import_node_path16.default.posix.join(
|
|
206174
|
+
partDir,
|
|
206175
|
+
`part-${String(index).padStart(5, "0")}`
|
|
206176
|
+
),
|
|
206177
|
+
data: partData,
|
|
206178
|
+
sizeBytes: partData.length,
|
|
206179
|
+
sha256: sha256Hex(partData)
|
|
206180
|
+
});
|
|
206181
|
+
}
|
|
206182
|
+
return {
|
|
206183
|
+
partDir,
|
|
206184
|
+
assembledTmpPath,
|
|
206185
|
+
expectedSizeBytes: data.length,
|
|
206186
|
+
expectedSha256: sha256Hex(data),
|
|
206187
|
+
parts
|
|
206188
|
+
};
|
|
206154
206189
|
};
|
|
206190
|
+
buildModalMultipartAssembleScript = (remotePath, plan) => [
|
|
206191
|
+
"set -euo pipefail",
|
|
206192
|
+
`target=${shellQuote3(import_node_path16.default.posix.normalize(remotePath))}`,
|
|
206193
|
+
`part_dir=${shellQuote3(plan.partDir)}`,
|
|
206194
|
+
`assembled_tmp=${shellQuote3(plan.assembledTmpPath)}`,
|
|
206195
|
+
`expected_size=${plan.expectedSizeBytes}`,
|
|
206196
|
+
`expected_sha=${shellQuote3(plan.expectedSha256)}`,
|
|
206197
|
+
"hash_file() {",
|
|
206198
|
+
" if command -v sha256sum >/dev/null 2>&1; then",
|
|
206199
|
+
` sha256sum "$1" | awk '{print $1}'`,
|
|
206200
|
+
" return 0",
|
|
206201
|
+
" fi",
|
|
206202
|
+
" if command -v shasum >/dev/null 2>&1; then",
|
|
206203
|
+
` shasum -a 256 "$1" | awk '{print $1}'`,
|
|
206204
|
+
" return 0",
|
|
206205
|
+
" fi",
|
|
206206
|
+
' echo "No SHA256 tool available (sha256sum/shasum)." >&2',
|
|
206207
|
+
" return 1",
|
|
206208
|
+
"}",
|
|
206209
|
+
'cleanup() { rm -f "$assembled_tmp"; }',
|
|
206210
|
+
"trap cleanup EXIT",
|
|
206211
|
+
'mkdir -p "$(dirname "$target")"',
|
|
206212
|
+
'[ -d "$part_dir" ] || { echo "Missing multipart upload directory: $part_dir" >&2; exit 1; }',
|
|
206213
|
+
': > "$assembled_tmp"',
|
|
206214
|
+
...plan.parts.flatMap((part) => [
|
|
206215
|
+
`part_path=${shellQuote3(part.remotePath)}`,
|
|
206216
|
+
`part_expected_size=${part.sizeBytes}`,
|
|
206217
|
+
`part_expected_sha=${shellQuote3(part.sha256)}`,
|
|
206218
|
+
'[ -f "$part_path" ] || { echo "Missing upload part: $part_path" >&2; exit 1; }',
|
|
206219
|
+
`part_size="$(wc -c < "$part_path" | tr -d '[:space:]')"`,
|
|
206220
|
+
'if [ "$part_size" != "$part_expected_size" ]; then echo "Part size mismatch for $part_path: expected $part_expected_size got $part_size" >&2; exit 1; fi',
|
|
206221
|
+
'part_sha="$(hash_file "$part_path")"',
|
|
206222
|
+
'if [ "$part_sha" != "$part_expected_sha" ]; then echo "Part checksum mismatch for $part_path" >&2; exit 1; fi',
|
|
206223
|
+
'cat "$part_path" >> "$assembled_tmp"'
|
|
206224
|
+
]),
|
|
206225
|
+
`assembled_size="$(wc -c < "$assembled_tmp" | tr -d '[:space:]')"`,
|
|
206226
|
+
'if [ "$assembled_size" != "$expected_size" ]; then echo "Assembled file size mismatch: expected $expected_size got $assembled_size" >&2; exit 1; fi',
|
|
206227
|
+
'assembled_sha="$(hash_file "$assembled_tmp")"',
|
|
206228
|
+
'if [ "$assembled_sha" != "$expected_sha" ]; then echo "Assembled file checksum mismatch" >&2; exit 1; fi',
|
|
206229
|
+
'mv "$assembled_tmp" "$target"',
|
|
206230
|
+
'rm -rf "$part_dir"',
|
|
206231
|
+
"trap - EXIT"
|
|
206232
|
+
].join("\n");
|
|
206233
|
+
buildModalMultipartCleanupScript = (plan) => [
|
|
206234
|
+
"set -euo pipefail",
|
|
206235
|
+
`rm -rf ${shellQuote3(plan.partDir)}`,
|
|
206236
|
+
`rm -f ${shellQuote3(plan.assembledTmpPath)}`
|
|
206237
|
+
].join("\n");
|
|
206155
206238
|
buildModalControlTraceAttributes = (alias, requestPayload, expectedType, responseTimeoutMs) => {
|
|
206156
206239
|
const requestType = typeof requestPayload.type === "string" ? requestPayload.type : "unknown";
|
|
206157
206240
|
return {
|
|
@@ -206169,6 +206252,45 @@ var init_modalRuntime = __esm({
|
|
|
206169
206252
|
} : {}
|
|
206170
206253
|
};
|
|
206171
206254
|
};
|
|
206255
|
+
runWithConcurrency = async (items, concurrency, worker) => {
|
|
206256
|
+
if (items.length === 0) {
|
|
206257
|
+
return;
|
|
206258
|
+
}
|
|
206259
|
+
const boundedConcurrency = resolveBoundedConcurrency(
|
|
206260
|
+
items.length,
|
|
206261
|
+
concurrency
|
|
206262
|
+
);
|
|
206263
|
+
let nextIndex = 0;
|
|
206264
|
+
let firstError = null;
|
|
206265
|
+
const workers = Array.from({ length: boundedConcurrency }, async () => {
|
|
206266
|
+
while (true) {
|
|
206267
|
+
if (firstError) {
|
|
206268
|
+
return;
|
|
206269
|
+
}
|
|
206270
|
+
const currentIndex = nextIndex;
|
|
206271
|
+
nextIndex += 1;
|
|
206272
|
+
if (currentIndex >= items.length) {
|
|
206273
|
+
return;
|
|
206274
|
+
}
|
|
206275
|
+
const item = items.at(currentIndex);
|
|
206276
|
+
if (item === void 0) {
|
|
206277
|
+
return;
|
|
206278
|
+
}
|
|
206279
|
+
try {
|
|
206280
|
+
await worker(item);
|
|
206281
|
+
} catch (error2) {
|
|
206282
|
+
if (!firstError) {
|
|
206283
|
+
firstError = error2;
|
|
206284
|
+
}
|
|
206285
|
+
return;
|
|
206286
|
+
}
|
|
206287
|
+
}
|
|
206288
|
+
});
|
|
206289
|
+
await Promise.all(workers);
|
|
206290
|
+
if (firstError) {
|
|
206291
|
+
throw firstError;
|
|
206292
|
+
}
|
|
206293
|
+
};
|
|
206172
206294
|
resolveReadPath = (readPath, workingDir) => {
|
|
206173
206295
|
if (import_node_path16.default.posix.isAbsolute(readPath)) return import_node_path16.default.posix.normalize(readPath);
|
|
206174
206296
|
if (workingDir && workingDir.trim().length > 0) {
|
|
@@ -206571,6 +206693,7 @@ var init_modalRuntime = __esm({
|
|
|
206571
206693
|
}) => {
|
|
206572
206694
|
let modal = null;
|
|
206573
206695
|
let modalSandboxName = alias;
|
|
206696
|
+
const socketPath = resolveSocketInfo().socketPath;
|
|
206574
206697
|
try {
|
|
206575
206698
|
const modalCredentials = resolveModalClientCredentials({
|
|
206576
206699
|
...credentialMode ? { credentialMode } : {},
|
|
@@ -206671,6 +206794,26 @@ var init_modalRuntime = __esm({
|
|
|
206671
206794
|
const stderr = typeof response.stderr === "string" ? response.stderr : "";
|
|
206672
206795
|
return { exitCode, stdout, stderr };
|
|
206673
206796
|
};
|
|
206797
|
+
const execShellScript = async (script, timeoutMs, failureMessage) => {
|
|
206798
|
+
const result = await exec(
|
|
206799
|
+
alias,
|
|
206800
|
+
[
|
|
206801
|
+
"/bin/bash",
|
|
206802
|
+
"--noprofile",
|
|
206803
|
+
"--norc",
|
|
206804
|
+
"-e",
|
|
206805
|
+
"-u",
|
|
206806
|
+
"-o",
|
|
206807
|
+
"pipefail",
|
|
206808
|
+
"-c",
|
|
206809
|
+
script
|
|
206810
|
+
],
|
|
206811
|
+
{ timeoutMs }
|
|
206812
|
+
);
|
|
206813
|
+
if (result.exitCode !== 0) {
|
|
206814
|
+
throw new Error(result.stderr || result.stdout || failureMessage);
|
|
206815
|
+
}
|
|
206816
|
+
};
|
|
206674
206817
|
const readFile3 = async (name, options) => {
|
|
206675
206818
|
requireAlias(name);
|
|
206676
206819
|
const resolvedPath = resolveReadPath(options.path, options.workingDir);
|
|
@@ -206701,10 +206844,13 @@ var init_modalRuntime = __esm({
|
|
|
206701
206844
|
requireAlias(name);
|
|
206702
206845
|
const total = data.length;
|
|
206703
206846
|
options?.onProgress?.(0, total);
|
|
206704
|
-
const chunked =
|
|
206705
|
-
const
|
|
206706
|
-
|
|
206707
|
-
const
|
|
206847
|
+
const chunked = total > MODAL_DAEMON_INLINE_WRITE_MAX_BYTES;
|
|
206848
|
+
const chunkCount = chunked ? Math.ceil(total / MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES) : 0;
|
|
206849
|
+
const plan = chunked ? buildModalMultipartWritePlan(remotePath, data) : null;
|
|
206850
|
+
const multipartConcurrency = plan ? resolveBoundedConcurrency(
|
|
206851
|
+
plan.parts.length,
|
|
206852
|
+
MODAL_DAEMON_MULTIPART_WRITE_CONCURRENCY
|
|
206853
|
+
) : 1;
|
|
206708
206854
|
await withDevboxSpan(
|
|
206709
206855
|
"modal.write_file",
|
|
206710
206856
|
{
|
|
@@ -206721,8 +206867,9 @@ var init_modalRuntime = __esm({
|
|
|
206721
206867
|
sizeBytes: total,
|
|
206722
206868
|
chunked,
|
|
206723
206869
|
...chunked ? {
|
|
206724
|
-
chunkBytes:
|
|
206725
|
-
chunkCount
|
|
206870
|
+
chunkBytes: MODAL_DAEMON_MULTIPART_WRITE_PART_SIZE_BYTES,
|
|
206871
|
+
chunkCount,
|
|
206872
|
+
multipartConcurrency
|
|
206726
206873
|
} : {}
|
|
206727
206874
|
});
|
|
206728
206875
|
try {
|
|
@@ -206736,7 +206883,7 @@ var init_modalRuntime = __esm({
|
|
|
206736
206883
|
},
|
|
206737
206884
|
"fs_write_result",
|
|
206738
206885
|
{
|
|
206739
|
-
responseTimeoutMs:
|
|
206886
|
+
responseTimeoutMs: estimateModalWriteTimeoutMs(total)
|
|
206740
206887
|
}
|
|
206741
206888
|
);
|
|
206742
206889
|
if (response.status !== "ok") {
|
|
@@ -206752,118 +206899,71 @@ var init_modalRuntime = __esm({
|
|
|
206752
206899
|
});
|
|
206753
206900
|
return;
|
|
206754
206901
|
}
|
|
206755
|
-
|
|
206756
|
-
|
|
206902
|
+
if (!plan) {
|
|
206903
|
+
throw new Error("Missing multipart upload plan.");
|
|
206904
|
+
}
|
|
206757
206905
|
let uploadedBytes = 0;
|
|
206758
|
-
|
|
206759
|
-
|
|
206760
|
-
|
|
206761
|
-
|
|
206762
|
-
|
|
206763
|
-
|
|
206764
|
-
|
|
206765
|
-
|
|
206766
|
-
|
|
206767
|
-
|
|
206768
|
-
|
|
206769
|
-
|
|
206770
|
-
|
|
206771
|
-
|
|
206772
|
-
|
|
206773
|
-
|
|
206774
|
-
|
|
206775
|
-
|
|
206776
|
-
|
|
206777
|
-
{
|
|
206778
|
-
|
|
206779
|
-
|
|
206780
|
-
)
|
|
206906
|
+
await runWithConcurrency(
|
|
206907
|
+
plan.parts,
|
|
206908
|
+
multipartConcurrency,
|
|
206909
|
+
async (part) => {
|
|
206910
|
+
const response = await runControlRequest(
|
|
206911
|
+
{
|
|
206912
|
+
type: "fs_write",
|
|
206913
|
+
path: part.remotePath,
|
|
206914
|
+
mkdir: true,
|
|
206915
|
+
data: Buffer.from(part.data).toString("base64")
|
|
206916
|
+
},
|
|
206917
|
+
"fs_write_result",
|
|
206918
|
+
{
|
|
206919
|
+
responseTimeoutMs: estimateModalMultipartPartTimeoutMs(
|
|
206920
|
+
part.sizeBytes,
|
|
206921
|
+
multipartConcurrency
|
|
206922
|
+
)
|
|
206923
|
+
}
|
|
206924
|
+
);
|
|
206925
|
+
if (response.status !== "ok") {
|
|
206926
|
+
const { text } = parseControlError(response);
|
|
206927
|
+
throw new Error(text);
|
|
206781
206928
|
}
|
|
206782
|
-
|
|
206783
|
-
|
|
206784
|
-
|
|
206785
|
-
throw new Error(text);
|
|
206786
|
-
}
|
|
206787
|
-
uploadedBytes += chunk.length;
|
|
206788
|
-
logger9.info("modal_fs_write_chunk_complete", {
|
|
206789
|
-
alias,
|
|
206790
|
-
remotePath,
|
|
206791
|
-
chunkIndex,
|
|
206792
|
-
chunkCount,
|
|
206793
|
-
chunkSizeBytes: chunk.length,
|
|
206794
|
-
uploadedBytes,
|
|
206795
|
-
totalBytes: total
|
|
206796
|
-
});
|
|
206797
|
-
chunkIndex += 1;
|
|
206798
|
-
options?.onProgress?.(uploadedBytes, total);
|
|
206799
|
-
}
|
|
206800
|
-
const assembleResult = await exec(
|
|
206801
|
-
name,
|
|
206802
|
-
[
|
|
206803
|
-
"/bin/bash",
|
|
206804
|
-
"--noprofile",
|
|
206805
|
-
"--norc",
|
|
206806
|
-
"-e",
|
|
206807
|
-
"-u",
|
|
206808
|
-
"-o",
|
|
206809
|
-
"pipefail",
|
|
206810
|
-
"-c",
|
|
206811
|
-
buildModalFsWriteAssembleScript(
|
|
206929
|
+
uploadedBytes += part.sizeBytes;
|
|
206930
|
+
logger9.info("modal_fs_write_chunk_complete", {
|
|
206931
|
+
alias,
|
|
206812
206932
|
remotePath,
|
|
206813
|
-
|
|
206814
|
-
|
|
206815
|
-
|
|
206816
|
-
|
|
206817
|
-
|
|
206818
|
-
|
|
206933
|
+
chunkIndex: part.index,
|
|
206934
|
+
chunkCount: plan.parts.length,
|
|
206935
|
+
chunkSizeBytes: part.sizeBytes,
|
|
206936
|
+
uploadedBytes,
|
|
206937
|
+
totalBytes: total
|
|
206938
|
+
});
|
|
206939
|
+
options?.onProgress?.(uploadedBytes, total);
|
|
206819
206940
|
}
|
|
206820
206941
|
);
|
|
206821
|
-
|
|
206822
|
-
|
|
206823
|
-
|
|
206824
|
-
|
|
206825
|
-
|
|
206942
|
+
await execShellScript(
|
|
206943
|
+
buildModalMultipartAssembleScript(remotePath, plan),
|
|
206944
|
+
estimateModalMultipartAssembleTimeoutMs(total),
|
|
206945
|
+
"Failed to assemble multipart Modal upload."
|
|
206946
|
+
);
|
|
206826
206947
|
options?.onProgress?.(total, total);
|
|
206827
206948
|
logger9.info("modal_fs_write_complete", {
|
|
206828
206949
|
alias,
|
|
206829
206950
|
remotePath,
|
|
206830
206951
|
sizeBytes: total,
|
|
206831
206952
|
chunked: true,
|
|
206832
|
-
chunkCount:
|
|
206953
|
+
chunkCount: plan.parts.length
|
|
206833
206954
|
});
|
|
206834
206955
|
} catch (error2) {
|
|
206835
|
-
|
|
206836
|
-
if (cleanupPaths.length > 0) {
|
|
206956
|
+
if (plan) {
|
|
206837
206957
|
try {
|
|
206838
|
-
|
|
206839
|
-
|
|
206840
|
-
|
|
206841
|
-
|
|
206842
|
-
"--noprofile",
|
|
206843
|
-
"--norc",
|
|
206844
|
-
"-e",
|
|
206845
|
-
"-u",
|
|
206846
|
-
"-o",
|
|
206847
|
-
"pipefail",
|
|
206848
|
-
"-c",
|
|
206849
|
-
buildModalFsWriteCleanupScript(cleanupPaths)
|
|
206850
|
-
],
|
|
206851
|
-
{ timeoutMs: MODAL_DAEMON_REQUEST_TIMEOUT_MS }
|
|
206958
|
+
await execShellScript(
|
|
206959
|
+
buildModalMultipartCleanupScript(plan),
|
|
206960
|
+
MODAL_DAEMON_REQUEST_TIMEOUT_MS,
|
|
206961
|
+
"Failed to clean up multipart Modal upload."
|
|
206852
206962
|
);
|
|
206853
|
-
if (cleanupResult.exitCode !== 0) {
|
|
206854
|
-
logger9.warn("modal_fs_write_cleanup_failed", {
|
|
206855
|
-
alias,
|
|
206856
|
-
remotePath,
|
|
206857
|
-
cleanupTargetCount: cleanupPaths.length,
|
|
206858
|
-
stderr: cleanupResult.stderr || void 0,
|
|
206859
|
-
stdout: cleanupResult.stdout || void 0
|
|
206860
|
-
});
|
|
206861
|
-
}
|
|
206862
206963
|
} catch (cleanupError) {
|
|
206863
206964
|
logger9.warn("modal_fs_write_cleanup_failed", {
|
|
206864
206965
|
alias,
|
|
206865
206966
|
remotePath,
|
|
206866
|
-
cleanupTargetCount: cleanupPaths.length,
|
|
206867
206967
|
error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
|
|
206868
206968
|
});
|
|
206869
206969
|
}
|
|
@@ -206873,7 +206973,6 @@ var init_modalRuntime = __esm({
|
|
|
206873
206973
|
remotePath,
|
|
206874
206974
|
sizeBytes: total,
|
|
206875
206975
|
chunked,
|
|
206876
|
-
cleanupAttempted: cleanupPaths.length > 0,
|
|
206877
206976
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
206878
206977
|
});
|
|
206879
206978
|
throw error2;
|
|
@@ -207162,7 +207261,27 @@ var init_modalRuntime = __esm({
|
|
|
207162
207261
|
if (unit === "m") return amount * 6e4;
|
|
207163
207262
|
return void 0;
|
|
207164
207263
|
};
|
|
207165
|
-
|
|
207264
|
+
let modalControlReadyPromise = null;
|
|
207265
|
+
const ensureModalControlReady = async (force = false) => {
|
|
207266
|
+
if (!force && modalControlReadyPromise) {
|
|
207267
|
+
await modalControlReadyPromise;
|
|
207268
|
+
return;
|
|
207269
|
+
}
|
|
207270
|
+
const ready = (async () => {
|
|
207271
|
+
await ensureDaemonRunning(socketPath);
|
|
207272
|
+
await requireDaemonFeatures(socketPath, ["modal.control"]);
|
|
207273
|
+
})();
|
|
207274
|
+
modalControlReadyPromise = ready;
|
|
207275
|
+
try {
|
|
207276
|
+
await ready;
|
|
207277
|
+
} catch (error2) {
|
|
207278
|
+
if (modalControlReadyPromise === ready) {
|
|
207279
|
+
modalControlReadyPromise = null;
|
|
207280
|
+
}
|
|
207281
|
+
throw error2;
|
|
207282
|
+
}
|
|
207283
|
+
};
|
|
207284
|
+
const postControlRequest = async (requestPayload, expectedType, options) => {
|
|
207166
207285
|
const socketInfo = resolveSocketInfo();
|
|
207167
207286
|
await ensureDaemonRunning(socketInfo.socketPath);
|
|
207168
207287
|
await requireDaemonFeatures(socketInfo.socketPath, ["modal.control"]);
|
|
@@ -207225,6 +207344,21 @@ var init_modalRuntime = __esm({
|
|
|
207225
207344
|
}
|
|
207226
207345
|
);
|
|
207227
207346
|
};
|
|
207347
|
+
const runControlRequest = async (requestPayload, expectedType, options) => {
|
|
207348
|
+
await ensureModalControlReady();
|
|
207349
|
+
let response;
|
|
207350
|
+
try {
|
|
207351
|
+
response = await postControlRequest(requestPayload, expectedType, options);
|
|
207352
|
+
} catch (error2) {
|
|
207353
|
+
if (!isDaemonConnectionError(error2)) {
|
|
207354
|
+
throw error2;
|
|
207355
|
+
}
|
|
207356
|
+
modalControlReadyPromise = null;
|
|
207357
|
+
await ensureModalControlReady(true);
|
|
207358
|
+
response = await postControlRequest(requestPayload, expectedType, options);
|
|
207359
|
+
}
|
|
207360
|
+
return response;
|
|
207361
|
+
};
|
|
207228
207362
|
const listExecSessions2 = async (name) => {
|
|
207229
207363
|
requireAlias(name);
|
|
207230
207364
|
const response = await runControlRequest(
|
|
@@ -215737,7 +215871,7 @@ var CODEX_INIT_EXEC_MODEL, CODEX_INIT_EXEC_REASONING_EFFORT, buildCodexInitExecA
|
|
|
215737
215871
|
var init_execConfig = __esm({
|
|
215738
215872
|
"src/devbox/commands/init/codex/execConfig.ts"() {
|
|
215739
215873
|
"use strict";
|
|
215740
|
-
CODEX_INIT_EXEC_MODEL = "gpt-5.
|
|
215874
|
+
CODEX_INIT_EXEC_MODEL = "gpt-5.4";
|
|
215741
215875
|
CODEX_INIT_EXEC_REASONING_EFFORT = "high";
|
|
215742
215876
|
buildCodexInitExecArgs = () => [
|
|
215743
215877
|
"--model",
|
|
@@ -229397,4 +229531,4 @@ smol-toml/dist/index.js:
|
|
|
229397
229531
|
*/
|
|
229398
229532
|
//# sourceMappingURL=dvb.cjs.map
|
|
229399
229533
|
|
|
229400
|
-
//# debugId=
|
|
229534
|
+
//# debugId=76631a09-23cb-5d66-b6e8-c3a9d5351d3b
|