@computesdk/sandbox0 1.0.12 → 1.0.14
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -22474,7 +22474,7 @@ var SandboxRuntimeMetricName2 = models.SandboxRuntimeMetricName;
|
|
|
22474
22474
|
var SandboxRuntimeMetricStatistic2 = models.SandboxRuntimeMetricStatistic;
|
|
22475
22475
|
|
|
22476
22476
|
// src/index.ts
|
|
22477
|
-
import { defineProvider } from "@computesdk/provider";
|
|
22477
|
+
import { defineProvider, resolveVolumeRef, withVolumeSettle } from "@computesdk/provider";
|
|
22478
22478
|
var observations = /* @__PURE__ */ new WeakMap();
|
|
22479
22479
|
function env(name) {
|
|
22480
22480
|
return typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
@@ -22541,6 +22541,17 @@ function buildClaimOptions(config, options) {
|
|
|
22541
22541
|
const claimOptions = {
|
|
22542
22542
|
...Object.keys(sandboxConfig).length > 0 ? { config: sandboxConfig } : {},
|
|
22543
22543
|
...options?.snapshotId ? { snapshotId: options.snapshotId } : {},
|
|
22544
|
+
// Unified mounts → claim's [{sandboxvolumeId, mountPoint}] wire shape.
|
|
22545
|
+
...Array.isArray(options?.volumes) && options.volumes.length > 0 ? {
|
|
22546
|
+
mounts: options.volumes.map((m) => {
|
|
22547
|
+
const ref = resolveVolumeRef(m.volume);
|
|
22548
|
+
const sandboxvolumeId = ref.id ?? ref.name;
|
|
22549
|
+
if (!sandboxvolumeId) {
|
|
22550
|
+
throw new Error("sandbox0 volume mount requires a volume id");
|
|
22551
|
+
}
|
|
22552
|
+
return { sandboxvolumeId, mountPoint: m.mountPath };
|
|
22553
|
+
})
|
|
22554
|
+
} : {},
|
|
22544
22555
|
...providerOptions?.memory !== void 0 || config.memory !== void 0 ? { memory: normalizeMemory(providerOptions?.memory ?? config.memory) } : {}
|
|
22545
22556
|
};
|
|
22546
22557
|
return Object.keys(claimOptions).length > 0 ? claimOptions : void 0;
|
|
@@ -22875,6 +22886,31 @@ var _provider = defineProvider({
|
|
|
22875
22886
|
}
|
|
22876
22887
|
},
|
|
22877
22888
|
getInstance: (sandbox) => sandbox
|
|
22889
|
+
},
|
|
22890
|
+
volume: {
|
|
22891
|
+
create: async (config, options) => {
|
|
22892
|
+
const client = createClient(config);
|
|
22893
|
+
const volume = await client.volumes.create({ backend: "s0fs", accessMode: "RWO" });
|
|
22894
|
+
return { id: volume.id, native: volume };
|
|
22895
|
+
},
|
|
22896
|
+
get: async (config, id) => {
|
|
22897
|
+
const client = createClient(config);
|
|
22898
|
+
try {
|
|
22899
|
+
const volume = await client.volumes.get(id);
|
|
22900
|
+
return { id: volume.id, native: volume };
|
|
22901
|
+
} catch {
|
|
22902
|
+
return null;
|
|
22903
|
+
}
|
|
22904
|
+
},
|
|
22905
|
+
list: async (config) => {
|
|
22906
|
+
const client = createClient(config);
|
|
22907
|
+
const volumes = await client.volumes.list();
|
|
22908
|
+
return (volumes ?? []).map((v) => ({ id: v.id, native: v }));
|
|
22909
|
+
},
|
|
22910
|
+
delete: async (config, id) => {
|
|
22911
|
+
const client = createClient(config);
|
|
22912
|
+
await withVolumeSettle(() => client.volumes.delete(id, { force: true }));
|
|
22913
|
+
}
|
|
22878
22914
|
}
|
|
22879
22915
|
}
|
|
22880
22916
|
});
|