@veris-ai/daytona 0.3.0 → 0.4.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/README.md +36 -151
- package/dist/gateway.d.ts +6 -0
- package/dist/index.cjs +54 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +49 -42
- package/dist/index.js.map +1 -1
- package/dist/trust.d.ts +38 -0
- package/package.json +1 -4
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2099
- package/dist/cli.js.map +0 -1
- package/dist/exec.d.ts +0 -15
- package/dist/provision.d.ts +0 -100
- package/dist/push.d.ts +0 -11
- package/dist/run.d.ts +0 -87
- package/dist/teardown.d.ts +0 -52
package/dist/index.d.ts
CHANGED
|
@@ -8,14 +8,12 @@ export type { EgressMode, NetworkParams, NetworkPlan } from './network';
|
|
|
8
8
|
export { buildNetwork, vendorHosts, twinHosts, directTwinHosts, dataPlaneHosts } from './network';
|
|
9
9
|
export type { ServiceInfo as VerisServiceInfo, RouteEntry, TwinSandbox } from './control-plane';
|
|
10
10
|
export { ControlPlane } from './control-plane';
|
|
11
|
-
export { CA_CERT_PATH, SYSTEM_BUNDLE, VERIS_BUNDLE, VERIS_CA_FILE, NODE_TRUST_FLAG, BUNDLED_CA_FILES, BUNDLED_CA_PATCH_SCRIPT, nodeOptionsWithTrust, vendoredTrustEnv, trustPrelude, } from './trust';
|
|
11
|
+
export { CA_CERT_PATH, SYSTEM_BUNDLE, VERIS_BUNDLE, VERIS_CA_FILE, NODE_TRUST_FLAG, NODE_PROXY_PRELOAD, NODE_PROXY_FLAG, BUNDLED_CA_FILES, BUNDLED_CA_PATCH_SCRIPT, nodeOptionsWithTrust, nodeOptionsWithProxy, verisNodeOptions, nodeProxyPreloadScript, vendoredTrustEnv, trustPrelude, } from './trust';
|
|
12
12
|
export { gatewayIps, gatewayProxyUrl, patchBundledCas } from './gateway';
|
|
13
13
|
export { DEFAULT_API_BASE, profilePath, resolveVerisCredentials, requireVerisCredentials, missingKeyMessage, } from './profile';
|
|
14
14
|
export type { VerisCredentials, ResolveOpts, ProfileFile } from './profile';
|
|
15
15
|
export { DAYTONA_API_URL, DELETE_SANDBOXES, daytonaApiUrl, fetchDaytonaKey, canDeleteSandboxes, cannotTeardownWarning, } from './daytona-key';
|
|
16
16
|
export type { DaytonaKeyInfo } from './daytona-key';
|
|
17
|
-
export { isPermissionDenied, sandboxBrakes, teardownRefusedMessage } from './teardown';
|
|
18
|
-
export type { RefusedTeardown } from './teardown';
|
|
19
17
|
export { fetchManual, assertHttpControlPlane } from './state';
|
|
20
18
|
export { VerisError, MissingCredentialsError, VerisGatewayUnreachableError, VerisGatewayNotOfferedError, ReceiptIntegrityError, VerisUntouchedError, TwinExpiredError, SnapshotUnsupportedError, UnsupportedOperationError, } from './errors';
|
|
21
19
|
export type { VerisErrorPhase } from './errors';
|
package/dist/index.js
CHANGED
|
@@ -524,9 +524,38 @@ function bundledCaPatchScript() {
|
|
|
524
524
|
}
|
|
525
525
|
var NODE_TRUST_FLAG = "--use-openssl-ca";
|
|
526
526
|
function nodeOptionsWithTrust(existing) {
|
|
527
|
+
return appendFlag(existing, NODE_TRUST_FLAG);
|
|
528
|
+
}
|
|
529
|
+
var NODE_PROXY_PRELOAD = "/tmp/veris-node-proxy.cjs";
|
|
530
|
+
var NODE_PROXY_FLAG = `--require ${NODE_PROXY_PRELOAD}`;
|
|
531
|
+
function nodeProxyPreloadScript() {
|
|
532
|
+
return [
|
|
533
|
+
`// Preloaded by @veris-ai/daytona through NODE_OPTIONS=--require.`,
|
|
534
|
+
`// Gives every http(s).Agent the proxy environment, which Node applies only`,
|
|
535
|
+
`// to its global agents under NODE_USE_ENV_PROXY=1. An SDK that builds its own`,
|
|
536
|
+
`// Agent would otherwise dial the vendor directly, which this sandbox cannot.`,
|
|
537
|
+
`for (const mod of [require("http"), require("https")]) {`,
|
|
538
|
+
` const Base = mod.Agent`,
|
|
539
|
+
` mod.Agent = class Agent extends Base {`,
|
|
540
|
+
` constructor(options) {`,
|
|
541
|
+
` super({ proxyEnv: process.env, ...(options || {}) })`,
|
|
542
|
+
` }`,
|
|
543
|
+
` }`,
|
|
544
|
+
`}`,
|
|
545
|
+
``
|
|
546
|
+
].join("\n");
|
|
547
|
+
}
|
|
548
|
+
function nodeOptionsWithProxy(existing) {
|
|
549
|
+
return appendFlag(existing, NODE_PROXY_FLAG);
|
|
550
|
+
}
|
|
551
|
+
function verisNodeOptions(existing, opts = {}) {
|
|
552
|
+
const withProxy = nodeOptionsWithProxy(existing);
|
|
553
|
+
return opts.trust === false ? withProxy : nodeOptionsWithTrust(withProxy);
|
|
554
|
+
}
|
|
555
|
+
function appendFlag(existing, flag) {
|
|
527
556
|
const base = (existing ?? "").trim();
|
|
528
|
-
if (base.
|
|
529
|
-
return base ? `${base} ${
|
|
557
|
+
if (base === flag || base.startsWith(`${flag} `) || base.endsWith(` ${flag}`) || base.includes(` ${flag} `)) return base;
|
|
558
|
+
return base ? `${base} ${flag}` : flag;
|
|
530
559
|
}
|
|
531
560
|
var CA_INSTALL_CMD = [
|
|
532
561
|
"update-ca-certificates",
|
|
@@ -599,6 +628,7 @@ function assertProxyUrl(raw) {
|
|
|
599
628
|
async function installCa(sandbox, caPem) {
|
|
600
629
|
await sandbox.fs.uploadFile(Buffer.from(caPem, "utf8"), VERIS_CA_FILE);
|
|
601
630
|
await sandbox.fs.uploadFile(Buffer.from(bundledCaPatchScript(), "utf8"), BUNDLED_CA_PATCH_SCRIPT);
|
|
631
|
+
await installNodeProxyPreload(sandbox);
|
|
602
632
|
const script = [
|
|
603
633
|
`chmod 0644 ${VERIS_CA_FILE}`,
|
|
604
634
|
// Public roots first so they keep working; ours appended. `cat` of a
|
|
@@ -624,6 +654,9 @@ async function installCa(sandbox, caPem) {
|
|
|
624
654
|
);
|
|
625
655
|
}
|
|
626
656
|
}
|
|
657
|
+
async function installNodeProxyPreload(sandbox) {
|
|
658
|
+
await sandbox.fs.uploadFile(Buffer.from(nodeProxyPreloadScript(), "utf8"), NODE_PROXY_PRELOAD);
|
|
659
|
+
}
|
|
627
660
|
async function patchBundledCas(sandbox) {
|
|
628
661
|
const r = await sh(sandbox, `sh ${BUNDLED_CA_PATCH_SCRIPT}`, 180).catch((e) => ({ exitCode: 1, result: String(e) }));
|
|
629
662
|
return (r.result ?? "").split("\n").filter((line) => line.startsWith(BUNDLED_CA_PATCHED_MARKER)).map((line) => line.slice(BUNDLED_CA_PATCHED_MARKER.length).trim()).filter(Boolean);
|
|
@@ -916,7 +949,7 @@ function requireVerisCredentials(opts = {}) {
|
|
|
916
949
|
}
|
|
917
950
|
|
|
918
951
|
// src/version.ts
|
|
919
|
-
var SDK_VERSION = true ? "0.
|
|
952
|
+
var SDK_VERSION = true ? "0.4.0" : "0.0.0-dev";
|
|
920
953
|
|
|
921
954
|
// src/daytona.ts
|
|
922
955
|
var LABEL = {
|
|
@@ -994,9 +1027,12 @@ var Daytona = class extends BaseDaytona {
|
|
|
994
1027
|
const verisManaged = {
|
|
995
1028
|
...v.installCa !== false ? sanitizeTrustEnv(void 0) : {},
|
|
996
1029
|
// Node reads none of the variables above once Daytona has overwritten
|
|
997
|
-
// them; the flag makes it read OpenSSL's store, which the CA
|
|
998
|
-
// fills.
|
|
999
|
-
|
|
1030
|
+
// them; the trust flag makes it read OpenSSL's store, which the CA
|
|
1031
|
+
// install fills. The preload gives every http(s).Agent the proxy
|
|
1032
|
+
// environment, which NODE_USE_ENV_PROXY below reaches only for the
|
|
1033
|
+
// global ones. Appended, not replaced: a caller's own NODE_OPTIONS keep
|
|
1034
|
+
// working.
|
|
1035
|
+
NODE_OPTIONS: verisNodeOptions(rest.envVars?.NODE_OPTIONS, { trust: v.installCa !== false }),
|
|
1000
1036
|
// Node ignores HTTPS_PROXY unless told to, and Daytona blocks anything
|
|
1001
1037
|
// that dials out directly — so without this every plain `https.get`
|
|
1002
1038
|
// and `fetch` in Node 24+ dies with ECONNRESET instead of reaching
|
|
@@ -1039,7 +1075,8 @@ var Daytona = class extends BaseDaytona {
|
|
|
1039
1075
|
});
|
|
1040
1076
|
}
|
|
1041
1077
|
try {
|
|
1042
|
-
await installCa(sandbox, credential.ca_pem);
|
|
1078
|
+
if (v.installCa !== false) await installCa(sandbox, credential.ca_pem);
|
|
1079
|
+
else await installNodeProxyPreload(sandbox);
|
|
1043
1080
|
await probeCanary(sandbox, credential.canary_host, twin.id);
|
|
1044
1081
|
} catch (err) {
|
|
1045
1082
|
await sandbox.delete().catch(() => {
|
|
@@ -1258,38 +1295,6 @@ var DELETE_PERMISSION_FIX = 'create a key with the "delete sandboxes" permission
|
|
|
1258
1295
|
function cannotTeardownWarning(key, autoStopMinutes, autoDeleteMinutes) {
|
|
1259
1296
|
return `DAYTONA_API_KEY ${describeKey(key)} lacks \`${DELETE_SANDBOXES}\`, so \`veris-daytona teardown\` will be refused for the sandbox about to be created, and \`run\` cannot delete its own. The box still stops after ${autoStopMinutes} idle minutes and is deleted ${autoDeleteMinutes} minutes after it stops. For a teardown that works, ${DELETE_PERMISSION_FIX} and use it instead.`;
|
|
1260
1297
|
}
|
|
1261
|
-
|
|
1262
|
-
// src/teardown.ts
|
|
1263
|
-
var TEARDOWN_USAGE = `usage: veris-daytona teardown <daytona-sandbox-id>
|
|
1264
|
-
|
|
1265
|
-
Deletes the Daytona sandbox. The id is the one \`veris-daytona provision\`
|
|
1266
|
-
printed as daytonaSandboxId \u2014 not the Veris twin's id.
|
|
1267
|
-
|
|
1268
|
-
The twin follows the rule it was created under: one this package created is
|
|
1269
|
-
deleted with the sandbox, one it attached to (\`provision\`, or \`run --sandbox\`)
|
|
1270
|
-
is yours and is left running. Which of the two happened is printed.
|
|
1271
|
-
|
|
1272
|
-
needs: DAYTONA_API_KEY with the ${DELETE_SANDBOXES} permission \u2014 a key made with
|
|
1273
|
-
"write sandboxes" alone is refused, and the refusal says when Daytona will stop
|
|
1274
|
-
and delete the box on its own. To reach a twin that must be deleted, a Veris
|
|
1275
|
-
key too: VERIS_API_KEY, or the profile \`veris login\` saved.
|
|
1276
|
-
|
|
1277
|
-
exit code: 0 when the sandbox is deleted; 1 when there is no such sandbox, or
|
|
1278
|
-
the key may not delete one.`;
|
|
1279
|
-
function isPermissionDenied(e) {
|
|
1280
|
-
return typeof e === "object" && e !== null && e.statusCode === 403;
|
|
1281
|
-
}
|
|
1282
|
-
function sandboxBrakes(r) {
|
|
1283
|
-
const stop = r.autoStopMinutes && r.autoStopMinutes > 0 ? `stops after ${r.autoStopMinutes} idle minutes` : "never stops on its own";
|
|
1284
|
-
const del = r.autoDeleteMinutes === void 0 || r.autoDeleteMinutes < 0 ? "is never auto-deleted" : r.autoDeleteMinutes === 0 ? "is deleted as soon as it stops" : `is deleted ${r.autoDeleteMinutes} minutes after it stops`;
|
|
1285
|
-
const destroy = r.expiresAt ? `, and is destroyed at ${r.expiresAt} whatever state it is in` : "";
|
|
1286
|
-
return `${stop} and ${del}${destroy}`;
|
|
1287
|
-
}
|
|
1288
|
-
function teardownRefusedMessage(r) {
|
|
1289
|
-
const key = r.key ? `this DAYTONA_API_KEY ${describeKey(r.key)} lacks the \`${DELETE_SANDBOXES}\` permission` : `Daytona answered 403 (Access denied), which is what a DAYTONA_API_KEY without the \`${DELETE_SANDBOXES}\` permission gets \u2014 the key's own record could not be read to confirm it`;
|
|
1290
|
-
const twin = r.twinId === void 0 ? "" : r.ownsTwin ? ` Its twin ${r.twinId} was deleted before Daytona refused, so nothing is left on the Veris side.` : ` Twin ${r.twinId} is yours and was not touched.`;
|
|
1291
|
-
return `Daytona refused to delete sandbox ${r.sandboxId}: ${key}. The sandbox is still there: it ${sandboxBrakes(r)}.${twin} To delete it sooner, ${DELETE_PERMISSION_FIX}, then run \`veris-daytona teardown ${r.sandboxId}\` with it \u2014 or delete the sandbox in the Daytona dashboard.`;
|
|
1292
|
-
}
|
|
1293
1298
|
export {
|
|
1294
1299
|
BUNDLED_CA_FILES,
|
|
1295
1300
|
BUNDLED_CA_PATCH_SCRIPT,
|
|
@@ -1300,6 +1305,8 @@ export {
|
|
|
1300
1305
|
DELETE_SANDBOXES,
|
|
1301
1306
|
Daytona,
|
|
1302
1307
|
MissingCredentialsError,
|
|
1308
|
+
NODE_PROXY_FLAG,
|
|
1309
|
+
NODE_PROXY_PRELOAD,
|
|
1303
1310
|
NODE_TRUST_FLAG,
|
|
1304
1311
|
ReceiptIntegrityError,
|
|
1305
1312
|
SDK_VERSION,
|
|
@@ -1325,20 +1332,20 @@ export {
|
|
|
1325
1332
|
fetchManual,
|
|
1326
1333
|
gatewayIps,
|
|
1327
1334
|
gatewayProxyUrl,
|
|
1328
|
-
isPermissionDenied,
|
|
1329
1335
|
isVerisSandbox,
|
|
1330
1336
|
missingKeyMessage,
|
|
1337
|
+
nodeOptionsWithProxy,
|
|
1331
1338
|
nodeOptionsWithTrust,
|
|
1339
|
+
nodeProxyPreloadScript,
|
|
1332
1340
|
patchBundledCas,
|
|
1333
1341
|
profilePath,
|
|
1334
1342
|
requireVerisCredentials,
|
|
1335
1343
|
resolveVerisCredentials,
|
|
1336
|
-
sandboxBrakes,
|
|
1337
|
-
teardownRefusedMessage,
|
|
1338
1344
|
trustPrelude,
|
|
1339
1345
|
twinHosts,
|
|
1340
1346
|
vendorHosts,
|
|
1341
1347
|
vendoredTrustEnv,
|
|
1348
|
+
verisNodeOptions,
|
|
1342
1349
|
verisOwnsTwin,
|
|
1343
1350
|
verisTwinId
|
|
1344
1351
|
};
|