@computesdk/gravixlayer 1.0.20 → 1.0.21
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 +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +59 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateTemplateOptions, Provider, ProviderTemplateManager } from '@computesdk/provider';
|
|
1
|
+
import { InstanceSizeClass, CreateTemplateOptions, Provider, ProviderTemplateManager, InstanceSizeManager } from '@computesdk/provider';
|
|
2
2
|
import { Runtime } from 'gravixlayer';
|
|
3
3
|
export { Runtime as GravixLayerRuntime } from 'gravixlayer';
|
|
4
4
|
|
|
@@ -19,7 +19,16 @@ interface GravixLayerConfig {
|
|
|
19
19
|
timeout?: number;
|
|
20
20
|
maxRetries?: number;
|
|
21
21
|
http2?: boolean;
|
|
22
|
+
/** Template name to boot per standard `sizeClass`; defaults to {@link GRAVIXLAYER_SIZE_TEMPLATES}. */
|
|
23
|
+
sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* GravixLayer fixes CPU and memory when a template is built, so each standard
|
|
27
|
+
* size boots its own template. The platform ships these `base-*` templates
|
|
28
|
+
* with matching shapes; `scripts/provider-setup.mjs gravixlayer` builds them
|
|
29
|
+
* on deployments where they are absent.
|
|
30
|
+
*/
|
|
31
|
+
declare const GRAVIXLAYER_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>>;
|
|
23
32
|
/** Snapshot returned by this provider's snapshot manager. */
|
|
24
33
|
interface GravixLayerSnapshot {
|
|
25
34
|
id: string;
|
|
@@ -50,10 +59,11 @@ interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {
|
|
|
50
59
|
/** Public provider with GravixLayer-specific template.create options. */
|
|
51
60
|
interface GravixLayerProvider extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {
|
|
52
61
|
template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>;
|
|
62
|
+
readonly sizes: InstanceSizeManager;
|
|
53
63
|
}
|
|
54
64
|
/** Clear the module-level GravixLayer client caches. For tests only. */
|
|
55
65
|
declare function clearGravixLayerClients(): void;
|
|
56
66
|
/** Preserve GravixLayer-specific template.create options on the public provider. */
|
|
57
67
|
declare function gravixlayer(config?: GravixLayerConfig): GravixLayerProvider;
|
|
58
68
|
|
|
59
|
-
export { type GravixLayerConfig, type GravixLayerCreateTemplateOptions, type GravixLayerProvider, type GravixLayerSnapshot, type GravixLayerTemplate, clearGravixLayerClients, gravixlayer };
|
|
69
|
+
export { GRAVIXLAYER_SIZE_TEMPLATES, type GravixLayerConfig, type GravixLayerCreateTemplateOptions, type GravixLayerProvider, type GravixLayerSnapshot, type GravixLayerTemplate, clearGravixLayerClients, gravixlayer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateTemplateOptions, Provider, ProviderTemplateManager } from '@computesdk/provider';
|
|
1
|
+
import { InstanceSizeClass, CreateTemplateOptions, Provider, ProviderTemplateManager, InstanceSizeManager } from '@computesdk/provider';
|
|
2
2
|
import { Runtime } from 'gravixlayer';
|
|
3
3
|
export { Runtime as GravixLayerRuntime } from 'gravixlayer';
|
|
4
4
|
|
|
@@ -19,7 +19,16 @@ interface GravixLayerConfig {
|
|
|
19
19
|
timeout?: number;
|
|
20
20
|
maxRetries?: number;
|
|
21
21
|
http2?: boolean;
|
|
22
|
+
/** Template name to boot per standard `sizeClass`; defaults to {@link GRAVIXLAYER_SIZE_TEMPLATES}. */
|
|
23
|
+
sizeTemplates?: Partial<Record<InstanceSizeClass, string>>;
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* GravixLayer fixes CPU and memory when a template is built, so each standard
|
|
27
|
+
* size boots its own template. The platform ships these `base-*` templates
|
|
28
|
+
* with matching shapes; `scripts/provider-setup.mjs gravixlayer` builds them
|
|
29
|
+
* on deployments where they are absent.
|
|
30
|
+
*/
|
|
31
|
+
declare const GRAVIXLAYER_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>>;
|
|
23
32
|
/** Snapshot returned by this provider's snapshot manager. */
|
|
24
33
|
interface GravixLayerSnapshot {
|
|
25
34
|
id: string;
|
|
@@ -50,10 +59,11 @@ interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {
|
|
|
50
59
|
/** Public provider with GravixLayer-specific template.create options. */
|
|
51
60
|
interface GravixLayerProvider extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {
|
|
52
61
|
template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>;
|
|
62
|
+
readonly sizes: InstanceSizeManager;
|
|
53
63
|
}
|
|
54
64
|
/** Clear the module-level GravixLayer client caches. For tests only. */
|
|
55
65
|
declare function clearGravixLayerClients(): void;
|
|
56
66
|
/** Preserve GravixLayer-specific template.create options on the public provider. */
|
|
57
67
|
declare function gravixlayer(config?: GravixLayerConfig): GravixLayerProvider;
|
|
58
68
|
|
|
59
|
-
export { type GravixLayerConfig, type GravixLayerCreateTemplateOptions, type GravixLayerProvider, type GravixLayerSnapshot, type GravixLayerTemplate, clearGravixLayerClients, gravixlayer };
|
|
69
|
+
export { GRAVIXLAYER_SIZE_TEMPLATES, type GravixLayerConfig, type GravixLayerCreateTemplateOptions, type GravixLayerProvider, type GravixLayerSnapshot, type GravixLayerTemplate, clearGravixLayerClients, gravixlayer };
|
package/dist/index.js
CHANGED
|
@@ -20,12 +20,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
GRAVIXLAYER_SIZE_TEMPLATES: () => GRAVIXLAYER_SIZE_TEMPLATES,
|
|
23
24
|
clearGravixLayerClients: () => clearGravixLayerClients,
|
|
24
25
|
gravixlayer: () => gravixlayer
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
27
28
|
var import_provider = require("@computesdk/provider");
|
|
28
29
|
var import_gravixlayer = require("gravixlayer");
|
|
30
|
+
var GRAVIXLAYER_SIZE_TEMPLATES = Object.freeze({
|
|
31
|
+
xs: "base-xsmall",
|
|
32
|
+
sm: "base-small",
|
|
33
|
+
md: "base-medium",
|
|
34
|
+
lg: "base-large",
|
|
35
|
+
xl: "base-xlarge",
|
|
36
|
+
"2xl": "base-2xlarge"
|
|
37
|
+
});
|
|
38
|
+
function sizeTemplateOf(config, sizeClass) {
|
|
39
|
+
const name = config.sizeTemplates?.[sizeClass] ?? GRAVIXLAYER_SIZE_TEMPLATES[sizeClass];
|
|
40
|
+
return typeof name === "string" && name.trim() ? name : void 0;
|
|
41
|
+
}
|
|
42
|
+
function missingSizeTemplate(config, templateId, error) {
|
|
43
|
+
if (typeof templateId !== "string" || !isNotFound(error)) return void 0;
|
|
44
|
+
const sizeClass = Object.keys(GRAVIXLAYER_SIZE_TEMPLATES).find((c) => sizeTemplateOf(config, c) === templateId);
|
|
45
|
+
if (!sizeClass) return void 0;
|
|
46
|
+
return `GravixLayer size template '${templateId}' (sizeClass ${sizeClass}) is not available on this project; build it with \`template.create\` or point \`sizeTemplates.${sizeClass}\` at an existing template`;
|
|
47
|
+
}
|
|
29
48
|
function snapshotKind(options) {
|
|
30
49
|
const value = options?.kind ?? options?.metadata?.kind ?? "hot";
|
|
31
50
|
if (value !== "hot" && value !== "cold") {
|
|
@@ -165,6 +184,7 @@ function getClient(config) {
|
|
|
165
184
|
return client;
|
|
166
185
|
}
|
|
167
186
|
var CREATE_HTTP_TIMEOUT_MS = 18e4;
|
|
187
|
+
var FILE_WRITE_JSON_MAX_BYTES = 1024 * 1024;
|
|
168
188
|
var publishedUrls = /* @__PURE__ */ new WeakMap();
|
|
169
189
|
function mapStatus(status) {
|
|
170
190
|
return SANDBOX_STATUS.get(status) ?? "stopped";
|
|
@@ -244,16 +264,26 @@ function elapsedMs(started) {
|
|
|
244
264
|
}
|
|
245
265
|
var createGravixLayerProvider = (0, import_provider.defineProvider)({
|
|
246
266
|
name: "gravixlayer",
|
|
267
|
+
sizes: (config, profile, options) => {
|
|
268
|
+
if (options?.templateId !== void 0 || options?.snapshotId !== void 0 || options?.sandboxId !== void 0 || nonempty(options?.image)) {
|
|
269
|
+
return { status: "unsupported", reason: "A GravixLayer template or snapshot fixes CPU and memory; drop templateId/image/snapshotId/sandboxId to boot the standard size template." };
|
|
270
|
+
}
|
|
271
|
+
const templateId = sizeTemplateOf(config, profile.sizeClass);
|
|
272
|
+
if (!templateId) {
|
|
273
|
+
return { status: "unknown", reason: "No GravixLayer size template is set up for this standard shape." };
|
|
274
|
+
}
|
|
275
|
+
return { status: "supported", nativeOptions: { templateId } };
|
|
276
|
+
},
|
|
247
277
|
methods: {
|
|
248
278
|
instances: {
|
|
249
279
|
create: async (config, options = {}) => {
|
|
250
|
-
if (nonempty(options.image)) {
|
|
251
|
-
throw new Error(
|
|
252
|
-
"GravixLayer runtimes start from a template, not an image. Pass `templateId`, or build a template from the image with `template.create({ name, fromImage })`."
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
280
|
const template = nonempty(options.templateId);
|
|
256
|
-
|
|
281
|
+
const image = nonempty(options.image);
|
|
282
|
+
if (template && image && template !== image) {
|
|
283
|
+
throw new Error("`image` and `templateId` name two different templates; pass one");
|
|
284
|
+
}
|
|
285
|
+
const source = template ?? image;
|
|
286
|
+
if (source && options.snapshotId) {
|
|
257
287
|
throw new Error("A runtime starts from a template or a snapshot, not both");
|
|
258
288
|
}
|
|
259
289
|
const envVars = validateEnvironment(options.envs);
|
|
@@ -261,8 +291,8 @@ var createGravixLayerProvider = (0, import_provider.defineProvider)({
|
|
|
261
291
|
const body = {};
|
|
262
292
|
if (options.snapshotId) {
|
|
263
293
|
body.snapshot = options.snapshotId;
|
|
264
|
-
} else if (
|
|
265
|
-
body.template =
|
|
294
|
+
} else if (source) {
|
|
295
|
+
body.template = source;
|
|
266
296
|
}
|
|
267
297
|
if (Object.keys(envVars).length > 0) body.envVars = envVars;
|
|
268
298
|
if (options.timeout !== void 0) {
|
|
@@ -286,7 +316,19 @@ var createGravixLayerProvider = (0, import_provider.defineProvider)({
|
|
|
286
316
|
if (!options.snapshotId && config.timeout === void 0) {
|
|
287
317
|
body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS;
|
|
288
318
|
}
|
|
289
|
-
|
|
319
|
+
let sandbox;
|
|
320
|
+
try {
|
|
321
|
+
sandbox = await client.runtime.create(body);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
const notBuilt = missingSizeTemplate(config, options.templateId, error);
|
|
324
|
+
if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });
|
|
325
|
+
if (image && !template && isNotFound(error)) {
|
|
326
|
+
throw Object.assign(new Error(
|
|
327
|
+
`GravixLayer template '${image}' is not available on this project; build it with \`template.create\` or pass an existing \`templateId\``
|
|
328
|
+
), { status: 404, cause: error });
|
|
329
|
+
}
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
290
332
|
rememberTimeout(
|
|
291
333
|
sandbox,
|
|
292
334
|
body.timeout === void 0 ? void 0 : body.timeout * 1e3
|
|
@@ -390,10 +432,15 @@ var createGravixLayerProvider = (0, import_provider.defineProvider)({
|
|
|
390
432
|
pauseCapabilities: { memory: true },
|
|
391
433
|
filesystem: {
|
|
392
434
|
readFile: async (sandbox, path) => {
|
|
393
|
-
return
|
|
435
|
+
return sandbox.file.downloadText(path);
|
|
394
436
|
},
|
|
395
437
|
writeFile: async (sandbox, path, content) => {
|
|
396
|
-
|
|
438
|
+
const jsonBytes = new TextEncoder().encode(JSON.stringify(content)).byteLength;
|
|
439
|
+
if (jsonBytes > FILE_WRITE_JSON_MAX_BYTES) {
|
|
440
|
+
await sandbox.file.upload(path, new TextEncoder().encode(content));
|
|
441
|
+
} else {
|
|
442
|
+
await sandbox.file.write(path, content);
|
|
443
|
+
}
|
|
397
444
|
},
|
|
398
445
|
mkdir: async (sandbox, path) => {
|
|
399
446
|
await sandbox.file.createDirectory(path);
|
|
@@ -620,6 +667,7 @@ function gravixlayer(config = {}) {
|
|
|
620
667
|
}
|
|
621
668
|
// Annotate the CommonJS export names for ESM import in node:
|
|
622
669
|
0 && (module.exports = {
|
|
670
|
+
GRAVIXLAYER_SIZE_TEMPLATES,
|
|
623
671
|
clearGravixLayerClients,
|
|
624
672
|
gravixlayer
|
|
625
673
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @computesdk/gravixlayer — GravixLayer provider for ComputeSDK.\n *\n * Cloud runtimes with a native filesystem API, live command streaming,\n * port publishing, templates, snapshots, and bucket-mount volumes.\n *\n * @see https://gravixlayer.ai\n */\n\nimport { defineProvider, isUnifiedVolumeMounts, resolveVolumeRef } from '@computesdk/provider'\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n CreateTemplateOptions,\n FileEntry,\n ListSnapshotsOptions,\n ListTemplatesOptions,\n Provider,\n ProviderTemplateManager,\n RunCommandOptions,\n SandboxInfo,\n CreateVolumeOptions,\n ListVolumesOptions,\n} from '@computesdk/provider'\nimport { GravixLayer, Runtime, TemplateBuilder, type RuntimeInfo } from 'gravixlayer'\n\nexport type { Runtime as GravixLayerRuntime }\n\nexport interface GravixLayerConfig {\n apiKey?: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries?: number\n http2?: boolean\n}\n\n/**\n * Snapshots default to `hot` (filesystem and memory), so tmpfs paths such as\n * `/tmp` survive restore. Pass `kind: 'cold'` (or\n * `metadata.kind`) for a filesystem-only snapshot of the persistent disk.\n */\nfunction snapshotKind(options?: CreateSnapshotOptions): 'hot' | 'cold' {\n const value =\n (options as { kind?: unknown } | undefined)?.kind ?? options?.metadata?.kind ?? 'hot'\n if (value !== 'hot' && value !== 'cold') {\n throw new Error(`Invalid GravixLayer snapshot kind: ${String(value)}. Use 'hot' or 'cold'.`)\n }\n return value\n}\n\n/** GravixLayer requires a snapshot name; generate a unique one when none is given. */\nfunction defaultSnapshotName(): string {\n return `computesdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`\n}\n\n/** Snapshot returned by this provider's snapshot manager. */\nexport interface GravixLayerSnapshot {\n id: string\n provider: 'gravixlayer'\n createdAt: Date\n metadata: {\n name: string\n state: string\n kind: string\n }\n}\n\n/** Template returned by this provider's template manager. */\nexport interface GravixLayerTemplate {\n id: string\n provider: 'gravixlayer'\n name: string\n createdAt: Date\n}\n\n/** Extra fields accepted on template.create beyond ComputeSDK's base options. */\nexport interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {\n fromImage?: string\n dockerfile?: string\n run?: string[]\n vcpu?: number\n memoryMb?: number\n diskMb?: number\n}\n\n/** Public provider with GravixLayer-specific template.create options. */\nexport interface GravixLayerProvider\n extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {\n template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>\n}\n\ninterface ResolvedClientOptions {\n apiKey: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries: number\n http2: boolean\n}\n\nconst clients = new Map<string, GravixLayer>()\n\n/**\n * Fast path over `clients`: a provider instance's config object resolves once,\n * and later calls on the same instance skip resolution and the identity string.\n * The entry also snapshots the raw config fields and the env vars resolution\n * consulted, so a mutated config object or a changed env var falls through to a\n * fresh resolve — identical semantics to resolving on every call. `WeakMap`\n * means the entry dies with the config; it cannot leak. Two provider instances\n * with equivalent options still share one client through the `clients` map.\n */\ninterface CachedResolution {\n client: GravixLayer\n config: Pick<\n GravixLayerConfig,\n 'apiKey' | 'baseUrl' | 'cloud' | 'region' | 'timeout' | 'maxRetries' | 'http2'\n >\n env: [string | undefined, string | undefined, string | undefined, string | undefined]\n}\n\nlet clientsByConfig = new WeakMap<GravixLayerConfig, CachedResolution>()\n\n/** Clear the module-level GravixLayer client caches. For tests only. */\nexport function clearGravixLayerClients(): void {\n clients.clear()\n clientsByConfig = new WeakMap()\n}\n\nconst createTimeoutMs = new WeakMap<object, number>()\n\n/**\n * ComputeSDK status for every runtime status the API reports. Only a running\n * runtime accepts commands, so a paused or stopping one reports `stopped`.\n * A `Map`, so no status string can resolve to an `Object.prototype` member.\n */\nconst SANDBOX_STATUS: ReadonlyMap<string, SandboxInfo['status']> = new Map([\n ['creating', 'running'],\n ['running', 'running'],\n ['paused', 'stopped'],\n ['stopping', 'stopped'],\n ['stopped', 'stopped'],\n ['terminated', 'stopped'],\n ['timed_out', 'stopped'],\n ['failed', 'error'],\n])\n\n/** Statuses the API no longer counts as live. `getById` reports these as gone. */\nconst ENDED_STATUSES: ReadonlySet<string> = new Set(['stopped', 'failed', 'terminated', 'timed_out'])\n\n/** Runtime IDs are UUIDs. A string of any other shape cannot name a runtime. */\nconst RUNTIME_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\nfunction isNotFound(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { status?: unknown }).status === 404\n )\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction validateEnvironment(\n environment: Record<string, string> | undefined,\n): Record<string, string> {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(environment ?? {})) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(name)}`)\n }\n result[name] = String(value)\n }\n return result\n}\n\n/** Convert a millisecond timeout to whole seconds. Zero is allowed. */\nfunction toTimeoutSeconds(ms: number, what: string): number {\n if (!Number.isFinite(ms) || ms < 0) {\n throw new Error(`GravixLayer ${what} must be a non-negative finite number of milliseconds`)\n }\n return Math.ceil(ms / 1000)\n}\n\nfunction nonempty(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed === '' ? undefined : trimmed\n}\n\nfunction resolveClientOptions(config: GravixLayerConfig): ResolvedClientOptions {\n const apiKey = (config.apiKey ?? process.env.GRAVIXLAYER_API_KEY)?.trim()\n if (!apiKey) {\n throw new Error(\n 'GravixLayer requires an API key. Pass `apiKey` or set the `GRAVIXLAYER_API_KEY` environment variable. Get a key at https://gravixlayer.ai .',\n )\n }\n\n const maxRetries = config.maxRetries ?? 0\n if (!Number.isInteger(maxRetries) || maxRetries < 0) {\n throw new Error('GravixLayer maxRetries must be a non-negative integer')\n }\n\n const resolved: ResolvedClientOptions = {\n apiKey,\n maxRetries,\n http2: config.http2 ?? true,\n }\n\n const baseUrl = nonempty(config.baseUrl ?? process.env.GRAVIXLAYER_BASE_URL)\n if (baseUrl !== undefined) resolved.baseUrl = baseUrl\n\n const cloud = nonempty(config.cloud ?? process.env.GRAVIXLAYER_CLOUD)\n if (cloud !== undefined) resolved.cloud = cloud\n\n const region = nonempty(config.region ?? process.env.GRAVIXLAYER_REGION)\n if (region !== undefined) resolved.region = region\n\n if (config.timeout !== undefined) {\n if (!Number.isFinite(config.timeout) || config.timeout < 0) {\n throw new Error('GravixLayer timeout must be a non-negative finite number of milliseconds')\n }\n resolved.timeout = config.timeout\n }\n\n return resolved\n}\n\nfunction clientIdentity(options: ResolvedClientOptions): string {\n return JSON.stringify([\n options.apiKey,\n options.baseUrl ?? null,\n options.cloud ?? null,\n options.region ?? null,\n options.timeout ?? null,\n options.maxRetries,\n options.http2,\n ])\n}\n\nfunction getClient(config: GravixLayerConfig): GravixLayer {\n const cached = clientsByConfig.get(config)\n if (\n cached &&\n cached.config.apiKey === config.apiKey &&\n cached.config.baseUrl === config.baseUrl &&\n cached.config.cloud === config.cloud &&\n cached.config.region === config.region &&\n cached.config.timeout === config.timeout &&\n cached.config.maxRetries === config.maxRetries &&\n cached.config.http2 === config.http2 &&\n // env is only consulted when the matching config field is unset\n (config.apiKey !== undefined || process.env.GRAVIXLAYER_API_KEY === cached.env[0]) &&\n (config.baseUrl !== undefined || process.env.GRAVIXLAYER_BASE_URL === cached.env[1]) &&\n (config.cloud !== undefined || process.env.GRAVIXLAYER_CLOUD === cached.env[2]) &&\n (config.region !== undefined || process.env.GRAVIXLAYER_REGION === cached.env[3])\n ) {\n return cached.client\n }\n const options = resolveClientOptions(config)\n const key = clientIdentity(options)\n let client = clients.get(key)\n if (!client) {\n client = new GravixLayer({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n ...(options.cloud !== undefined ? { cloud: options.cloud } : {}),\n ...(options.region !== undefined ? { region: options.region } : {}),\n ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n maxRetries: options.maxRetries,\n http2: options.http2,\n })\n clients.set(key, client)\n }\n clientsByConfig.set(config, {\n client,\n config: {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n cloud: config.cloud,\n region: config.region,\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n http2: config.http2,\n },\n env: [\n process.env.GRAVIXLAYER_API_KEY,\n process.env.GRAVIXLAYER_BASE_URL,\n process.env.GRAVIXLAYER_CLOUD,\n process.env.GRAVIXLAYER_REGION,\n ],\n })\n return client\n}\n\n/**\n * The SDK keeps a small HTTP/2 session pool per origin: a burst spreads over\n * a handful of connections whose handshakes run in parallel, while a quiet\n * caller keeps one session. `maxRetries: 0` keeps a refused create from\n * sleeping inside the caller's timer. `connect()` is intentionally not\n * called: it issues its own request and would compete with create.\n *\n * A boot can outlast the client's 60-second default, so create gets its own\n * HTTP deadline — longer than a slow boot and shorter than the benchmark's\n * 120s create budget. It is sent as `requestTimeoutMs`: `timeout` on create\n * options is the sandbox lifetime in seconds, so putting the budget there\n * would store a multi-day lifetime. An explicit provider `timeout` is kept\n * as the caller's cap. It does not add latency on a fast create; it only\n * releases the HTTP/2 stream if a boot never returns. `0` would hold that\n * stream until the process exits.\n */\nconst CREATE_HTTP_TIMEOUT_MS = 180_000\n\n/** In-flight or completed publish, so concurrent getUrl calls share one request. */\nconst publishedUrls = new WeakMap<Runtime, Map<number, Promise<string>>>()\n\n/** A status this version does not know is reported as stopped, never as running. */\nfunction mapStatus(status: string): SandboxInfo['status'] {\n return SANDBOX_STATUS.get(status) ?? 'stopped'\n}\n\nfunction parseCreatedAt(startedAt: string | undefined): Date {\n if (startedAt) {\n const date = new Date(startedAt)\n if (!Number.isNaN(date.getTime())) return date\n }\n return new Date()\n}\n\nfunction leaseTimeoutMs(startedAt: string | undefined, timeoutAt: string | undefined): number {\n if (!startedAt || !timeoutAt) return 0\n const start = new Date(startedAt).getTime()\n const end = new Date(timeoutAt).getTime()\n if (!Number.isFinite(start) || !Number.isFinite(end)) return 0\n const delta = end - start\n return delta > 0 ? delta : 0\n}\n\nfunction rememberTimeout(sandbox: Runtime, timeoutMs: number | undefined): Runtime {\n if (timeoutMs !== undefined) createTimeoutMs.set(sandbox, timeoutMs)\n return sandbox\n}\n\nfunction bindRuntime(client: GravixLayer, info: RuntimeInfo): Runtime {\n return new Runtime(client.runtime, info)\n}\n\nasync function publishedUrl(sandbox: Runtime, port: number): Promise<string> {\n let ports = publishedUrls.get(sandbox)\n const existing = ports?.get(port)\n if (existing) return existing\n\n const pending = sandbox.service(port).then((handle) => {\n if (!handle.url) {\n throw new Error(`GravixLayer did not return a URL for port ${port}.`)\n }\n return handle.url\n })\n if (!ports) {\n ports = new Map()\n publishedUrls.set(sandbox, ports)\n }\n ports.set(port, pending)\n try {\n return await pending\n } catch (error) {\n ports.delete(port)\n throw error\n }\n}\n\nasync function runCommand(\n sandbox: Runtime,\n command: string,\n options: RunCommandOptions = {},\n): Promise<CommandResult> {\n const started = performance.now()\n\n if (options.background && (options.onStdout || options.onStderr)) {\n throw new Error('runCommand with streaming callbacks does not support background mode.')\n }\n\n const environment = validateEnvironment(options.env)\n const opts: {\n workingDir?: string\n environment?: Record<string, string>\n timeout?: number\n background?: boolean\n onStdout?: (chunk: string) => void\n onStderr?: (chunk: string) => void\n } = {}\n\n if (options.cwd) opts.workingDir = options.cwd\n if (Object.keys(environment).length > 0) opts.environment = environment\n if (options.timeout !== undefined) {\n opts.timeout = toTimeoutSeconds(options.timeout, 'command timeout')\n }\n if (options.onStdout) opts.onStdout = options.onStdout\n if (options.onStderr) opts.onStderr = options.onStderr\n\n if (options.background) {\n await sandbox.runCmd(command, { ...opts, background: true })\n return { stdout: '', stderr: '', exitCode: 0, durationMs: elapsedMs(started) }\n }\n\n const result = await sandbox.runCmd(command, opts)\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs:\n typeof result.durationMs === 'number' && Number.isFinite(result.durationMs)\n ? Math.max(0, result.durationMs)\n : elapsedMs(started),\n }\n}\n\nfunction elapsedMs(started: number): number {\n return Math.max(0, Math.round(performance.now() - started))\n}\n\nconst createGravixLayerProvider = defineProvider<\n Runtime,\n GravixLayerConfig,\n GravixLayerTemplate,\n GravixLayerSnapshot\n>({\n name: 'gravixlayer',\n methods: {\n instances: {\n create: async (config: GravixLayerConfig, options: CreateInstanceOptions = {}) => {\n if (nonempty(options.image)) {\n throw new Error(\n 'GravixLayer runtimes start from a template, not an image. Pass `templateId`, or build a template from the image with `template.create({ name, fromImage })`.',\n )\n }\n const template = nonempty(options.templateId)\n if (template && options.snapshotId) {\n throw new Error('A runtime starts from a template or a snapshot, not both')\n }\n\n const envVars = validateEnvironment(options.envs)\n const client = getClient(config)\n\n const body: {\n template?: string\n snapshot?: string\n envVars?: Record<string, string>\n /** Sandbox lifetime in seconds. */\n timeout?: number\n /** HTTP deadline for this request, in milliseconds. */\n requestTimeoutMs?: number\n metadata?: Record<string, unknown>\n cloud?: string\n region?: string\n mounts?: Array<{ kind: 'bucket'; bucket: string; path: string; mode: 'ro' | 'rw' }>\n signal?: AbortSignal\n } = {}\n\n if (options.snapshotId) {\n body.snapshot = options.snapshotId\n } else if (template) {\n body.template = template\n }\n\n if (Object.keys(envVars).length > 0) body.envVars = envVars\n\n if (options.timeout !== undefined) {\n body.timeout = toTimeoutSeconds(options.timeout, 'sandbox timeout')\n }\n\n if (isPlainObject(options.metadata)) {\n body.metadata = options.metadata\n }\n\n // Unified mounts → gravixlayer's [{kind:'bucket',bucket,path,mode}] wire\n // shape; buckets are created via `provider.volume`/`compute.volume`.\n const volumes = options.volumes\n if (isUnifiedVolumeMounts(volumes) && volumes.length > 0) {\n body.mounts = volumes.map((m) => ({\n kind: 'bucket' as const,\n bucket: resolveVolumeRef(m.volume).id ?? resolveVolumeRef(m.volume).name ?? '',\n path: m.mountPath,\n mode: m.readOnly ? 'ro' : 'rw',\n }))\n }\n\n if (typeof options.cloud === 'string') body.cloud = options.cloud\n if (typeof options.region === 'string') body.region = options.region\n if (options.signal) body.signal = options.signal\n if (!options.snapshotId && config.timeout === undefined) {\n body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS\n }\n\n const sandbox = await client.runtime.create(body)\n // Report the lease the runtime actually got: seconds, rounded up.\n rememberTimeout(\n sandbox,\n body.timeout === undefined ? undefined : body.timeout * 1000,\n )\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n },\n\n getById: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n if (!RUNTIME_ID.test(sandboxId)) return null\n try {\n const sandbox = await client.runtime.get(sandboxId)\n if (ENDED_STATUSES.has(sandbox.status)) return null\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n } catch (error) {\n if (isNotFound(error)) return null\n throw error\n }\n },\n\n list: async (config: GravixLayerConfig) => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const sandboxes: Array<{ instance: Runtime; instanceId: string }> = []\n const seen = new Set<string>()\n\n for (;;) {\n const page = await client.runtime.list({ limit: pageSize, offset })\n const marker = page.runtimes[0]?.runtimeId\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const info of page.runtimes) {\n if (!info.runtimeId) continue\n // The list payload is enough to bind a handle. A follow-up get\n // per row would add one round trip per runtime.\n const sandbox = bindRuntime(client, info)\n sandboxes.push({ instance: sandbox, instanceId: sandbox.runtimeId })\n }\n offset += page.runtimes.length\n if (\n page.runtimes.length < pageSize ||\n !Number.isFinite(page.total) ||\n offset >= page.total\n ) {\n break\n }\n }\n\n return sandboxes\n },\n\n destroy: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n try {\n await client.runtime.kill(sandboxId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n\n runCommand,\n\n streamCommand: runCommand,\n\n getInfo: async (sandbox: Runtime): Promise<SandboxInfo> => {\n await sandbox.refresh()\n const info = sandbox.info\n return {\n id: sandbox.runtimeId,\n provider: 'gravixlayer',\n status: mapStatus(info.status),\n createdAt: parseCreatedAt(info.startedAt),\n timeout:\n createTimeoutMs.get(sandbox) ?? leaseTimeoutMs(info.startedAt, info.timeoutAt),\n ...(info.metadata !== undefined ? { metadata: info.metadata } : {}),\n }\n },\n\n getUrl: async (sandbox: Runtime, options: { port: number; protocol?: string }) => {\n const { port } = options\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`Invalid port: ${port}`)\n }\n const value = await publishedUrl(sandbox, port)\n if (!options.protocol) return value\n const url = new URL(value)\n url.protocol = `${options.protocol.replace(/:$/, '')}:`\n return url.toString()\n },\n\n getInstance: (sandbox: Runtime) => sandbox,\n\n attachVolume: async (instance: Runtime, volume, mountPath: string) => {\n const ref = resolveVolumeRef(volume)\n await instance.mounts.attach({\n kind: 'bucket',\n bucket: ref.id ?? ref.name ?? '',\n path: mountPath,\n mode: 'rw',\n })\n },\n\n detachVolume: async (instance: Runtime, volume, mountPath?: string) => {\n const ref = resolveVolumeRef(volume)\n const id = ref.id ?? ref.name\n const { mounts } = await instance.mounts.list()\n const mount = mounts.find(\n (m: { id?: string; targetId?: string; mountPath?: string }) =>\n id !== undefined\n ? (m.targetId === id || m.id === id) && (mountPath === undefined || m.mountPath === mountPath)\n : m.mountPath === mountPath,\n )\n if (mount?.id) await instance.mounts.detach(mount.id)\n },\n\n pause: async (sandbox: Runtime) => {\n await sandbox.pause()\n },\n\n resume: async (sandbox: Runtime) => {\n await sandbox.resume()\n },\n\n // Pause freezes memory: files and running processes survive resume.\n pauseCapabilities: { memory: true },\n\n filesystem: {\n readFile: async (sandbox: Runtime, path: string): Promise<string> => {\n return (await sandbox.file.read(path)).content\n },\n\n writeFile: async (sandbox: Runtime, path: string, content: string): Promise<void> => {\n await sandbox.file.write(path, content)\n },\n\n mkdir: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.createDirectory(path)\n },\n\n readdir: async (sandbox: Runtime, path: string): Promise<FileEntry[]> => {\n const listing = await sandbox.file.list(path)\n return listing.files.map((entry) => {\n const fileEntry: FileEntry = {\n name: entry.name,\n type: entry.isDir ? 'directory' : 'file',\n size: entry.size,\n }\n const modified = new Date(entry.modifiedAt)\n if (!Number.isNaN(modified.getTime())) {\n fileEntry.modified = modified\n }\n return fileEntry\n })\n },\n\n exists: async (sandbox: Runtime, path: string): Promise<boolean> => {\n return (await sandbox.file.getInfo(path)).exists\n },\n\n remove: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.delete(path)\n },\n },\n },\n\n snapshot: {\n // Hot snapshots (the default) keep the whole rootfs, `/tmp` included,\n // and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n\n create: async (\n config: GravixLayerConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ): Promise<GravixLayerSnapshot> => {\n const name = nonempty(options?.name) ?? defaultSnapshotName()\n const client = getClient(config)\n const description =\n options &&\n 'description' in options &&\n typeof (options as { description?: unknown }).description === 'string'\n ? (options as { description: string }).description\n : undefined\n const kind = snapshotKind(options)\n const snapshot = await client.snapshots.create(sandboxId, name, {\n kind,\n ...(description !== undefined ? { description } : {}),\n })\n return {\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListSnapshotsOptions,\n ): Promise<GravixLayerSnapshot[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const snapshots: GravixLayerSnapshot[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - snapshots.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.snapshots.list({\n limit: take,\n offset,\n ...(options?.sandboxId ? { runtimeId: options.sandboxId } : {}),\n })\n\n const marker = page.snapshots[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n\n for (const snapshot of page.snapshots) {\n snapshots.push({\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n })\n if (limit !== undefined && snapshots.length >= limit) return snapshots\n }\n\n offset += page.snapshots.length\n if (page.snapshots.length === 0 || offset >= page.total) break\n if (page.snapshots.length < take) break\n }\n\n return snapshots\n },\n\n delete: async (config: GravixLayerConfig, snapshotId: string) => {\n const client = getClient(config)\n try {\n await client.snapshots.delete(snapshotId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n template: {\n create: async (\n config: GravixLayerConfig,\n options: GravixLayerCreateTemplateOptions,\n ): Promise<GravixLayerTemplate> => {\n const name = nonempty(options.name)\n if (!name) {\n throw new Error('GravixLayer templates require a name.')\n }\n\n const fromImage = nonempty(options.fromImage)\n const dockerfile = nonempty(options.dockerfile)\n if (!fromImage && !dockerfile) {\n throw new Error(\n 'A GravixLayer template build needs `fromImage` or `dockerfile`. Select an existing template with `templateId` on sandbox create.',\n )\n }\n if (fromImage && dockerfile) {\n throw new Error('Specify either fromImage or dockerfile, not both.')\n }\n\n const builder = new TemplateBuilder(name, options.description ?? '')\n if (fromImage) builder.fromImage(fromImage)\n if (dockerfile) builder.dockerfile(dockerfile)\n\n if (Array.isArray(options.run)) {\n for (const command of options.run) {\n if (typeof command === 'string' && command.trim() !== '') {\n builder.run(command)\n }\n }\n }\n\n if (typeof options.vcpu === 'number' && Number.isFinite(options.vcpu) && options.vcpu > 0) {\n builder.vcpu(options.vcpu)\n }\n if (\n typeof options.memoryMb === 'number' &&\n Number.isFinite(options.memoryMb) &&\n options.memoryMb > 0\n ) {\n builder.memory(options.memoryMb)\n }\n if (\n typeof options.diskMb === 'number' &&\n Number.isFinite(options.diskMb) &&\n options.diskMb > 0\n ) {\n builder.disk(options.diskMb)\n }\n\n if (options.metadata) {\n const tags: Record<string, string> = {}\n for (const [key, value] of Object.entries(options.metadata)) {\n if (typeof value === 'string') tags[key] = value\n }\n if (Object.keys(tags).length > 0) builder.tags(tags)\n }\n\n const client = getClient(config)\n const status = await client.templates.buildAndWait(builder)\n return {\n id: status.templateId,\n provider: 'gravixlayer',\n name,\n createdAt: new Date(),\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListTemplatesOptions,\n ): Promise<GravixLayerTemplate[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const templates: GravixLayerTemplate[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - templates.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.templates.list({ limit: take, offset })\n const marker = page.templates[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const template of page.templates) {\n templates.push({\n id: template.id,\n provider: 'gravixlayer',\n name: template.name,\n createdAt: new Date(template.createdAt),\n })\n if (limit !== undefined && templates.length >= limit) return templates\n }\n\n offset += page.templates.length\n // TemplateListResponse has no total; stop on a short/empty page.\n if (page.templates.length === 0 || page.templates.length < take) break\n }\n\n return templates\n },\n\n delete: async (config: GravixLayerConfig, templateId: string) => {\n const client = getClient(config)\n try {\n await client.templates.delete(templateId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n // GravixLayer \"volumes\" are managed object-storage buckets mounted into a\n // runtime (`mounts: [{kind:'bucket'}]` at create, or runtime.attachVolume).\n volume: {\n create: async (config: GravixLayerConfig, options: CreateVolumeOptions) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.create(options.name)\n return { id: bucket.id, name: bucket.name, native: bucket }\n },\n\n get: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n return bucket ? { id: bucket.id, name: bucket.name, native: bucket } : null\n },\n\n list: async (config: GravixLayerConfig, options?: ListVolumesOptions) => {\n const client = getClient(config)\n const page = await client.storage.buckets.list()\n const buckets = page.buckets ?? []\n const limited = options?.limit === undefined ? buckets : buckets.slice(0, options.limit)\n return limited.map((b: { id?: string; name?: string }) => ({ id: b.id, name: b.name, native: b }))\n },\n\n delete: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n if (!bucket) return\n await client.storage.buckets.delete(bucket.id ?? idOrName)\n },\n },\n },\n})\n\n/** Preserve GravixLayer-specific template.create options on the public provider. */\nexport function gravixlayer(config: GravixLayerConfig = {}): GravixLayerProvider {\n const provider = createGravixLayerProvider(config)\n return { ...provider, template: provider.template! }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,sBAAwE;AAiBxE,yBAAwE;AAmBxE,SAAS,aAAa,SAAiD;AACrE,QAAM,QACH,SAA4C,QAAQ,SAAS,UA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,QAAiB;AAChF,cAAK,KAA6B,WAAW,IAAK,QAAO;AACzD,gBAAM;AAAA,QACR,CAAC;AACD,eAAO,SAAS,EAAE,IAAI,OAAO,IAAI,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI;AAAA,MACzE;AAAA,MAEA,MAAM,OAAO,QAA2B,YAAiC;AACvE,cAAM,SAAS,UAAU,MAAM;AAC/B,cAAM,OAAO,MAAM,OAAO,QAAQ,QAAQ,KAAK;AAC/C,cAAM,UAAU,KAAK,WAAW,CAAC;AACjC,cAAM,UAAU,SAAS,UAAU,SAAY,UAAU,QAAQ,MAAM,GAAG,QAAQ,KAAK;AACvF,eAAO,QAAQ,IAAI,CAAC,OAAuC,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,QAAQ,EAAE,EAAE;AAAA,MACnG;AAAA,MAEA,QAAQ,OAAO,QAA2B,aAAqB;AAC7D,cAAM,SAAS,UAAU,MAAM;AAC/B,cAAM,SAAS,MAAM,OAAO,QAAQ,QAAQ,IAAI,QAAQ,EAAE,MAAM,CAAC,QAAiB;AAChF,cAAK,KAA6B,WAAW,IAAK,QAAO;AACzD,gBAAM;AAAA,QACR,CAAC;AACD,YAAI,CAAC,OAAQ;AACb,cAAM,OAAO,QAAQ,QAAQ,OAAO,OAAO,MAAM,QAAQ;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAGM,SAAS,YAAY,SAA4B,CAAC,GAAwB;AAC/E,QAAM,WAAW,0BAA0B,MAAM;AACjD,SAAO,EAAE,GAAG,UAAU,UAAU,SAAS,SAAU;AACrD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @computesdk/gravixlayer — GravixLayer provider for ComputeSDK.\n *\n * Cloud runtimes with a native filesystem API, live command streaming,\n * port publishing, templates, snapshots, and bucket-mount volumes.\n *\n * @see https://gravixlayer.ai\n */\n\nimport { defineProvider, isUnifiedVolumeMounts, resolveVolumeRef } from '@computesdk/provider'\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n CreateTemplateOptions,\n FileEntry,\n ListSnapshotsOptions,\n ListTemplatesOptions,\n InstanceSizeClass,\n InstanceSizeManager,\n Provider,\n ProviderTemplateManager,\n RunCommandOptions,\n SandboxInfo,\n CreateVolumeOptions,\n ListVolumesOptions,\n} from '@computesdk/provider'\nimport { GravixLayer, Runtime, TemplateBuilder, type RuntimeInfo } from 'gravixlayer'\n\nexport type { Runtime as GravixLayerRuntime }\n\nexport interface GravixLayerConfig {\n apiKey?: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries?: number\n http2?: boolean\n /** Template name to boot per standard `sizeClass`; defaults to {@link GRAVIXLAYER_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>\n}\n\n/**\n * GravixLayer fixes CPU and memory when a template is built, so each standard\n * size boots its own template. The platform ships these `base-*` templates\n * with matching shapes; `scripts/provider-setup.mjs gravixlayer` builds them\n * on deployments where they are absent.\n */\nexport const GRAVIXLAYER_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'base-xsmall',\n sm: 'base-small',\n md: 'base-medium',\n lg: 'base-large',\n xl: 'base-xlarge',\n '2xl': 'base-2xlarge',\n})\n\nfunction sizeTemplateOf(config: GravixLayerConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? GRAVIXLAYER_SIZE_TEMPLATES[sizeClass]\n return typeof name === 'string' && name.trim() ? name : undefined\n}\n\n/** A create that failed because a standard-size template was never built on this project. */\nfunction missingSizeTemplate(config: GravixLayerConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !isNotFound(error)) return undefined\n const sizeClass = (Object.keys(GRAVIXLAYER_SIZE_TEMPLATES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId)\n if (!sizeClass) return undefined\n return `GravixLayer size template '${templateId}' (sizeClass ${sizeClass}) is not available on this project; build it with \\`template.create\\` or point \\`sizeTemplates.${sizeClass}\\` at an existing template`\n}\n\n/**\n * Snapshots default to `hot` (filesystem and memory), so tmpfs paths such as\n * `/tmp` survive restore. Pass `kind: 'cold'` (or\n * `metadata.kind`) for a filesystem-only snapshot of the persistent disk.\n */\nfunction snapshotKind(options?: CreateSnapshotOptions): 'hot' | 'cold' {\n const value =\n (options as { kind?: unknown } | undefined)?.kind ?? options?.metadata?.kind ?? 'hot'\n if (value !== 'hot' && value !== 'cold') {\n throw new Error(`Invalid GravixLayer snapshot kind: ${String(value)}. Use 'hot' or 'cold'.`)\n }\n return value\n}\n\n/** GravixLayer requires a snapshot name; generate a unique one when none is given. */\nfunction defaultSnapshotName(): string {\n return `computesdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`\n}\n\n/** Snapshot returned by this provider's snapshot manager. */\nexport interface GravixLayerSnapshot {\n id: string\n provider: 'gravixlayer'\n createdAt: Date\n metadata: {\n name: string\n state: string\n kind: string\n }\n}\n\n/** Template returned by this provider's template manager. */\nexport interface GravixLayerTemplate {\n id: string\n provider: 'gravixlayer'\n name: string\n createdAt: Date\n}\n\n/** Extra fields accepted on template.create beyond ComputeSDK's base options. */\nexport interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {\n fromImage?: string\n dockerfile?: string\n run?: string[]\n vcpu?: number\n memoryMb?: number\n diskMb?: number\n}\n\n/** Public provider with GravixLayer-specific template.create options. */\nexport interface GravixLayerProvider\n extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {\n template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>\n readonly sizes: InstanceSizeManager\n}\n\ninterface ResolvedClientOptions {\n apiKey: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries: number\n http2: boolean\n}\n\nconst clients = new Map<string, GravixLayer>()\n\n/**\n * Fast path over `clients`: a provider instance's config object resolves once,\n * and later calls on the same instance skip resolution and the identity string.\n * The entry also snapshots the raw config fields and the env vars resolution\n * consulted, so a mutated config object or a changed env var falls through to a\n * fresh resolve — identical semantics to resolving on every call. `WeakMap`\n * means the entry dies with the config; it cannot leak. Two provider instances\n * with equivalent options still share one client through the `clients` map.\n */\ninterface CachedResolution {\n client: GravixLayer\n config: Pick<\n GravixLayerConfig,\n 'apiKey' | 'baseUrl' | 'cloud' | 'region' | 'timeout' | 'maxRetries' | 'http2'\n >\n env: [string | undefined, string | undefined, string | undefined, string | undefined]\n}\n\nlet clientsByConfig = new WeakMap<GravixLayerConfig, CachedResolution>()\n\n/** Clear the module-level GravixLayer client caches. For tests only. */\nexport function clearGravixLayerClients(): void {\n clients.clear()\n clientsByConfig = new WeakMap()\n}\n\nconst createTimeoutMs = new WeakMap<object, number>()\n\n/**\n * ComputeSDK status for every runtime status the API reports. Only a running\n * runtime accepts commands, so a paused or stopping one reports `stopped`.\n * A `Map`, so no status string can resolve to an `Object.prototype` member.\n */\nconst SANDBOX_STATUS: ReadonlyMap<string, SandboxInfo['status']> = new Map([\n ['creating', 'running'],\n ['running', 'running'],\n ['paused', 'stopped'],\n ['stopping', 'stopped'],\n ['stopped', 'stopped'],\n ['terminated', 'stopped'],\n ['timed_out', 'stopped'],\n ['failed', 'error'],\n])\n\n/** Statuses the API no longer counts as live. `getById` reports these as gone. */\nconst ENDED_STATUSES: ReadonlySet<string> = new Set(['stopped', 'failed', 'terminated', 'timed_out'])\n\n/** Runtime IDs are UUIDs. A string of any other shape cannot name a runtime. */\nconst RUNTIME_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\nfunction isNotFound(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { status?: unknown }).status === 404\n )\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction validateEnvironment(\n environment: Record<string, string> | undefined,\n): Record<string, string> {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(environment ?? {})) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(name)}`)\n }\n result[name] = String(value)\n }\n return result\n}\n\n/** Convert a millisecond timeout to whole seconds. Zero is allowed. */\nfunction toTimeoutSeconds(ms: number, what: string): number {\n if (!Number.isFinite(ms) || ms < 0) {\n throw new Error(`GravixLayer ${what} must be a non-negative finite number of milliseconds`)\n }\n return Math.ceil(ms / 1000)\n}\n\nfunction nonempty(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed === '' ? undefined : trimmed\n}\n\nfunction resolveClientOptions(config: GravixLayerConfig): ResolvedClientOptions {\n const apiKey = (config.apiKey ?? process.env.GRAVIXLAYER_API_KEY)?.trim()\n if (!apiKey) {\n throw new Error(\n 'GravixLayer requires an API key. Pass `apiKey` or set the `GRAVIXLAYER_API_KEY` environment variable. Get a key at https://gravixlayer.ai .',\n )\n }\n\n const maxRetries = config.maxRetries ?? 0\n if (!Number.isInteger(maxRetries) || maxRetries < 0) {\n throw new Error('GravixLayer maxRetries must be a non-negative integer')\n }\n\n const resolved: ResolvedClientOptions = {\n apiKey,\n maxRetries,\n http2: config.http2 ?? true,\n }\n\n const baseUrl = nonempty(config.baseUrl ?? process.env.GRAVIXLAYER_BASE_URL)\n if (baseUrl !== undefined) resolved.baseUrl = baseUrl\n\n const cloud = nonempty(config.cloud ?? process.env.GRAVIXLAYER_CLOUD)\n if (cloud !== undefined) resolved.cloud = cloud\n\n const region = nonempty(config.region ?? process.env.GRAVIXLAYER_REGION)\n if (region !== undefined) resolved.region = region\n\n if (config.timeout !== undefined) {\n if (!Number.isFinite(config.timeout) || config.timeout < 0) {\n throw new Error('GravixLayer timeout must be a non-negative finite number of milliseconds')\n }\n resolved.timeout = config.timeout\n }\n\n return resolved\n}\n\nfunction clientIdentity(options: ResolvedClientOptions): string {\n return JSON.stringify([\n options.apiKey,\n options.baseUrl ?? null,\n options.cloud ?? null,\n options.region ?? null,\n options.timeout ?? null,\n options.maxRetries,\n options.http2,\n ])\n}\n\nfunction getClient(config: GravixLayerConfig): GravixLayer {\n const cached = clientsByConfig.get(config)\n if (\n cached &&\n cached.config.apiKey === config.apiKey &&\n cached.config.baseUrl === config.baseUrl &&\n cached.config.cloud === config.cloud &&\n cached.config.region === config.region &&\n cached.config.timeout === config.timeout &&\n cached.config.maxRetries === config.maxRetries &&\n cached.config.http2 === config.http2 &&\n // env is only consulted when the matching config field is unset\n (config.apiKey !== undefined || process.env.GRAVIXLAYER_API_KEY === cached.env[0]) &&\n (config.baseUrl !== undefined || process.env.GRAVIXLAYER_BASE_URL === cached.env[1]) &&\n (config.cloud !== undefined || process.env.GRAVIXLAYER_CLOUD === cached.env[2]) &&\n (config.region !== undefined || process.env.GRAVIXLAYER_REGION === cached.env[3])\n ) {\n return cached.client\n }\n const options = resolveClientOptions(config)\n const key = clientIdentity(options)\n let client = clients.get(key)\n if (!client) {\n client = new GravixLayer({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n ...(options.cloud !== undefined ? { cloud: options.cloud } : {}),\n ...(options.region !== undefined ? { region: options.region } : {}),\n ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n maxRetries: options.maxRetries,\n http2: options.http2,\n })\n clients.set(key, client)\n }\n clientsByConfig.set(config, {\n client,\n config: {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n cloud: config.cloud,\n region: config.region,\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n http2: config.http2,\n },\n env: [\n process.env.GRAVIXLAYER_API_KEY,\n process.env.GRAVIXLAYER_BASE_URL,\n process.env.GRAVIXLAYER_CLOUD,\n process.env.GRAVIXLAYER_REGION,\n ],\n })\n return client\n}\n\n/**\n * The SDK keeps a small HTTP/2 session pool per origin: a burst spreads over\n * a handful of connections whose handshakes run in parallel, while a quiet\n * caller keeps one session. `maxRetries: 0` keeps a refused create from\n * sleeping inside the caller's timer. `connect()` is intentionally not\n * called: it issues its own request and would compete with create.\n *\n * A boot can outlast the client's 60-second default, so create gets its own\n * HTTP deadline — longer than a slow boot and shorter than the benchmark's\n * 120s create budget. It is sent as `requestTimeoutMs`: `timeout` on create\n * options is the sandbox lifetime in seconds, so putting the budget there\n * would store a multi-day lifetime. An explicit provider `timeout` is kept\n * as the caller's cap. It does not add latency on a fast create; it only\n * releases the HTTP/2 stream if a boot never returns. `0` would hold that\n * stream until the process exits.\n */\nconst CREATE_HTTP_TIMEOUT_MS = 180_000\n\n// `files/write` carries content inside a JSON string body, capped server-side\n// at 2 MiB; escapes (`\\\"`, `\\\\`, `\\n`, control chars) inflate it past raw\n// UTF-8 length, so writes switch to the binary `upload` endpoint with\n// headroom under the cap.\nconst FILE_WRITE_JSON_MAX_BYTES = 1024 * 1024\n\n/** In-flight or completed publish, so concurrent getUrl calls share one request. */\nconst publishedUrls = new WeakMap<Runtime, Map<number, Promise<string>>>()\n\n/** A status this version does not know is reported as stopped, never as running. */\nfunction mapStatus(status: string): SandboxInfo['status'] {\n return SANDBOX_STATUS.get(status) ?? 'stopped'\n}\n\nfunction parseCreatedAt(startedAt: string | undefined): Date {\n if (startedAt) {\n const date = new Date(startedAt)\n if (!Number.isNaN(date.getTime())) return date\n }\n return new Date()\n}\n\nfunction leaseTimeoutMs(startedAt: string | undefined, timeoutAt: string | undefined): number {\n if (!startedAt || !timeoutAt) return 0\n const start = new Date(startedAt).getTime()\n const end = new Date(timeoutAt).getTime()\n if (!Number.isFinite(start) || !Number.isFinite(end)) return 0\n const delta = end - start\n return delta > 0 ? delta : 0\n}\n\nfunction rememberTimeout(sandbox: Runtime, timeoutMs: number | undefined): Runtime {\n if (timeoutMs !== undefined) createTimeoutMs.set(sandbox, timeoutMs)\n return sandbox\n}\n\nfunction bindRuntime(client: GravixLayer, info: RuntimeInfo): Runtime {\n return new Runtime(client.runtime, info)\n}\n\nasync function publishedUrl(sandbox: Runtime, port: number): Promise<string> {\n let ports = publishedUrls.get(sandbox)\n const existing = ports?.get(port)\n if (existing) return existing\n\n const pending = sandbox.service(port).then((handle) => {\n if (!handle.url) {\n throw new Error(`GravixLayer did not return a URL for port ${port}.`)\n }\n return handle.url\n })\n if (!ports) {\n ports = new Map()\n publishedUrls.set(sandbox, ports)\n }\n ports.set(port, pending)\n try {\n return await pending\n } catch (error) {\n ports.delete(port)\n throw error\n }\n}\n\nasync function runCommand(\n sandbox: Runtime,\n command: string,\n options: RunCommandOptions = {},\n): Promise<CommandResult> {\n const started = performance.now()\n\n if (options.background && (options.onStdout || options.onStderr)) {\n throw new Error('runCommand with streaming callbacks does not support background mode.')\n }\n\n const environment = validateEnvironment(options.env)\n const opts: {\n workingDir?: string\n environment?: Record<string, string>\n timeout?: number\n background?: boolean\n onStdout?: (chunk: string) => void\n onStderr?: (chunk: string) => void\n } = {}\n\n if (options.cwd) opts.workingDir = options.cwd\n if (Object.keys(environment).length > 0) opts.environment = environment\n if (options.timeout !== undefined) {\n opts.timeout = toTimeoutSeconds(options.timeout, 'command timeout')\n }\n if (options.onStdout) opts.onStdout = options.onStdout\n if (options.onStderr) opts.onStderr = options.onStderr\n\n if (options.background) {\n await sandbox.runCmd(command, { ...opts, background: true })\n return { stdout: '', stderr: '', exitCode: 0, durationMs: elapsedMs(started) }\n }\n\n const result = await sandbox.runCmd(command, opts)\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs:\n typeof result.durationMs === 'number' && Number.isFinite(result.durationMs)\n ? Math.max(0, result.durationMs)\n : elapsedMs(started),\n }\n}\n\nfunction elapsedMs(started: number): number {\n return Math.max(0, Math.round(performance.now() - started))\n}\n\nconst createGravixLayerProvider = defineProvider<\n Runtime,\n GravixLayerConfig,\n GravixLayerTemplate,\n GravixLayerSnapshot\n>({\n name: 'gravixlayer',\n sizes: (config, profile, options) => {\n if (options?.templateId !== undefined || options?.snapshotId !== undefined || options?.sandboxId !== undefined || nonempty(options?.image)) {\n return { status: 'unsupported', reason: 'A GravixLayer template or snapshot fixes CPU and memory; drop templateId/image/snapshotId/sandboxId to boot the standard size template.' }\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass)\n if (!templateId) {\n return { status: 'unknown', reason: 'No GravixLayer size template is set up for this standard shape.' }\n }\n return { status: 'supported', nativeOptions: { templateId } }\n },\n methods: {\n instances: {\n create: async (config: GravixLayerConfig, options: CreateInstanceOptions = {}) => {\n const template = nonempty(options.templateId)\n // `image` is a template name: the template built from that image.\n // Same source as `templateId`, so a differing pair is a conflict.\n const image = nonempty(options.image)\n if (template && image && template !== image) {\n throw new Error('`image` and `templateId` name two different templates; pass one')\n }\n const source = template ?? image\n if (source && options.snapshotId) {\n throw new Error('A runtime starts from a template or a snapshot, not both')\n }\n\n const envVars = validateEnvironment(options.envs)\n const client = getClient(config)\n\n const body: {\n template?: string\n snapshot?: string\n envVars?: Record<string, string>\n /** Sandbox lifetime in seconds. */\n timeout?: number\n /** HTTP deadline for this request, in milliseconds. */\n requestTimeoutMs?: number\n metadata?: Record<string, unknown>\n cloud?: string\n region?: string\n mounts?: Array<{ kind: 'bucket'; bucket: string; path: string; mode: 'ro' | 'rw' }>\n signal?: AbortSignal\n } = {}\n\n if (options.snapshotId) {\n body.snapshot = options.snapshotId\n } else if (source) {\n body.template = source\n }\n\n if (Object.keys(envVars).length > 0) body.envVars = envVars\n\n if (options.timeout !== undefined) {\n body.timeout = toTimeoutSeconds(options.timeout, 'sandbox timeout')\n }\n\n if (isPlainObject(options.metadata)) {\n body.metadata = options.metadata\n }\n\n // Unified mounts → gravixlayer's [{kind:'bucket',bucket,path,mode}] wire\n // shape; buckets are created via `provider.volume`/`compute.volume`.\n const volumes = options.volumes\n if (isUnifiedVolumeMounts(volumes) && volumes.length > 0) {\n body.mounts = volumes.map((m) => ({\n kind: 'bucket' as const,\n bucket: resolveVolumeRef(m.volume).id ?? resolveVolumeRef(m.volume).name ?? '',\n path: m.mountPath,\n mode: m.readOnly ? 'ro' : 'rw',\n }))\n }\n\n if (typeof options.cloud === 'string') body.cloud = options.cloud\n if (typeof options.region === 'string') body.region = options.region\n if (options.signal) body.signal = options.signal\n if (!options.snapshotId && config.timeout === undefined) {\n body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS\n }\n\n let sandbox: Runtime\n try {\n sandbox = await client.runtime.create(body)\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, options.templateId, error)\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error })\n if (image && !template && isNotFound(error)) {\n throw Object.assign(new Error(\n `GravixLayer template '${image}' is not available on this project; build it with \\`template.create\\` or pass an existing \\`templateId\\``,\n ), { status: 404, cause: error })\n }\n throw error\n }\n // Report the lease the runtime actually got: seconds, rounded up.\n rememberTimeout(\n sandbox,\n body.timeout === undefined ? undefined : body.timeout * 1000,\n )\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n },\n\n getById: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n if (!RUNTIME_ID.test(sandboxId)) return null\n try {\n const sandbox = await client.runtime.get(sandboxId)\n if (ENDED_STATUSES.has(sandbox.status)) return null\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n } catch (error) {\n if (isNotFound(error)) return null\n throw error\n }\n },\n\n list: async (config: GravixLayerConfig) => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const sandboxes: Array<{ instance: Runtime; instanceId: string }> = []\n const seen = new Set<string>()\n\n for (;;) {\n const page = await client.runtime.list({ limit: pageSize, offset })\n const marker = page.runtimes[0]?.runtimeId\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const info of page.runtimes) {\n if (!info.runtimeId) continue\n // The list payload is enough to bind a handle. A follow-up get\n // per row would add one round trip per runtime.\n const sandbox = bindRuntime(client, info)\n sandboxes.push({ instance: sandbox, instanceId: sandbox.runtimeId })\n }\n offset += page.runtimes.length\n if (\n page.runtimes.length < pageSize ||\n !Number.isFinite(page.total) ||\n offset >= page.total\n ) {\n break\n }\n }\n\n return sandboxes\n },\n\n destroy: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n try {\n await client.runtime.kill(sandboxId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n\n runCommand,\n\n streamCommand: runCommand,\n\n getInfo: async (sandbox: Runtime): Promise<SandboxInfo> => {\n await sandbox.refresh()\n const info = sandbox.info\n return {\n id: sandbox.runtimeId,\n provider: 'gravixlayer',\n status: mapStatus(info.status),\n createdAt: parseCreatedAt(info.startedAt),\n timeout:\n createTimeoutMs.get(sandbox) ?? leaseTimeoutMs(info.startedAt, info.timeoutAt),\n ...(info.metadata !== undefined ? { metadata: info.metadata } : {}),\n }\n },\n\n getUrl: async (sandbox: Runtime, options: { port: number; protocol?: string }) => {\n const { port } = options\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`Invalid port: ${port}`)\n }\n const value = await publishedUrl(sandbox, port)\n if (!options.protocol) return value\n const url = new URL(value)\n url.protocol = `${options.protocol.replace(/:$/, '')}:`\n return url.toString()\n },\n\n getInstance: (sandbox: Runtime) => sandbox,\n\n attachVolume: async (instance: Runtime, volume, mountPath: string) => {\n const ref = resolveVolumeRef(volume)\n await instance.mounts.attach({\n kind: 'bucket',\n bucket: ref.id ?? ref.name ?? '',\n path: mountPath,\n mode: 'rw',\n })\n },\n\n detachVolume: async (instance: Runtime, volume, mountPath?: string) => {\n const ref = resolveVolumeRef(volume)\n const id = ref.id ?? ref.name\n const { mounts } = await instance.mounts.list()\n const mount = mounts.find(\n (m: { id?: string; targetId?: string; mountPath?: string }) =>\n id !== undefined\n ? (m.targetId === id || m.id === id) && (mountPath === undefined || m.mountPath === mountPath)\n : m.mountPath === mountPath,\n )\n if (mount?.id) await instance.mounts.detach(mount.id)\n },\n\n pause: async (sandbox: Runtime) => {\n await sandbox.pause()\n },\n\n resume: async (sandbox: Runtime) => {\n await sandbox.resume()\n },\n\n // Pause freezes memory: files and running processes survive resume.\n pauseCapabilities: { memory: true },\n\n filesystem: {\n readFile: async (sandbox: Runtime, path: string): Promise<string> => {\n return sandbox.file.downloadText(path)\n },\n\n writeFile: async (sandbox: Runtime, path: string, content: string): Promise<void> => {\n // `files/write` carries content inside a JSON string body capped\n // server-side; escapes inflate it past raw UTF-8 length, so measure\n // the encoded form. Larger payloads stream through binary upload.\n const jsonBytes = new TextEncoder().encode(JSON.stringify(content)).byteLength\n if (jsonBytes > FILE_WRITE_JSON_MAX_BYTES) {\n await sandbox.file.upload(path, new TextEncoder().encode(content))\n } else {\n await sandbox.file.write(path, content)\n }\n },\n\n mkdir: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.createDirectory(path)\n },\n\n readdir: async (sandbox: Runtime, path: string): Promise<FileEntry[]> => {\n const listing = await sandbox.file.list(path)\n return listing.files.map((entry) => {\n const fileEntry: FileEntry = {\n name: entry.name,\n type: entry.isDir ? 'directory' : 'file',\n size: entry.size,\n }\n const modified = new Date(entry.modifiedAt)\n if (!Number.isNaN(modified.getTime())) {\n fileEntry.modified = modified\n }\n return fileEntry\n })\n },\n\n exists: async (sandbox: Runtime, path: string): Promise<boolean> => {\n return (await sandbox.file.getInfo(path)).exists\n },\n\n remove: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.delete(path)\n },\n },\n },\n\n snapshot: {\n // Hot snapshots (the default) keep the whole rootfs, `/tmp` included,\n // and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n\n create: async (\n config: GravixLayerConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ): Promise<GravixLayerSnapshot> => {\n const name = nonempty(options?.name) ?? defaultSnapshotName()\n const client = getClient(config)\n const description =\n options &&\n 'description' in options &&\n typeof (options as { description?: unknown }).description === 'string'\n ? (options as { description: string }).description\n : undefined\n const kind = snapshotKind(options)\n const snapshot = await client.snapshots.create(sandboxId, name, {\n kind,\n ...(description !== undefined ? { description } : {}),\n })\n return {\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListSnapshotsOptions,\n ): Promise<GravixLayerSnapshot[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const snapshots: GravixLayerSnapshot[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - snapshots.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.snapshots.list({\n limit: take,\n offset,\n ...(options?.sandboxId ? { runtimeId: options.sandboxId } : {}),\n })\n\n const marker = page.snapshots[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n\n for (const snapshot of page.snapshots) {\n snapshots.push({\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n })\n if (limit !== undefined && snapshots.length >= limit) return snapshots\n }\n\n offset += page.snapshots.length\n if (page.snapshots.length === 0 || offset >= page.total) break\n if (page.snapshots.length < take) break\n }\n\n return snapshots\n },\n\n delete: async (config: GravixLayerConfig, snapshotId: string) => {\n const client = getClient(config)\n try {\n await client.snapshots.delete(snapshotId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n template: {\n create: async (\n config: GravixLayerConfig,\n options: GravixLayerCreateTemplateOptions,\n ): Promise<GravixLayerTemplate> => {\n const name = nonempty(options.name)\n if (!name) {\n throw new Error('GravixLayer templates require a name.')\n }\n\n const fromImage = nonempty(options.fromImage)\n const dockerfile = nonempty(options.dockerfile)\n if (!fromImage && !dockerfile) {\n throw new Error(\n 'A GravixLayer template build needs `fromImage` or `dockerfile`. Select an existing template with `templateId` on sandbox create.',\n )\n }\n if (fromImage && dockerfile) {\n throw new Error('Specify either fromImage or dockerfile, not both.')\n }\n\n const builder = new TemplateBuilder(name, options.description ?? '')\n if (fromImage) builder.fromImage(fromImage)\n if (dockerfile) builder.dockerfile(dockerfile)\n\n if (Array.isArray(options.run)) {\n for (const command of options.run) {\n if (typeof command === 'string' && command.trim() !== '') {\n builder.run(command)\n }\n }\n }\n\n if (typeof options.vcpu === 'number' && Number.isFinite(options.vcpu) && options.vcpu > 0) {\n builder.vcpu(options.vcpu)\n }\n if (\n typeof options.memoryMb === 'number' &&\n Number.isFinite(options.memoryMb) &&\n options.memoryMb > 0\n ) {\n builder.memory(options.memoryMb)\n }\n if (\n typeof options.diskMb === 'number' &&\n Number.isFinite(options.diskMb) &&\n options.diskMb > 0\n ) {\n builder.disk(options.diskMb)\n }\n\n if (options.metadata) {\n const tags: Record<string, string> = {}\n for (const [key, value] of Object.entries(options.metadata)) {\n if (typeof value === 'string') tags[key] = value\n }\n if (Object.keys(tags).length > 0) builder.tags(tags)\n }\n\n const client = getClient(config)\n const status = await client.templates.buildAndWait(builder)\n return {\n id: status.templateId,\n provider: 'gravixlayer',\n name,\n createdAt: new Date(),\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListTemplatesOptions,\n ): Promise<GravixLayerTemplate[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const templates: GravixLayerTemplate[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - templates.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.templates.list({ limit: take, offset })\n const marker = page.templates[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const template of page.templates) {\n templates.push({\n id: template.id,\n provider: 'gravixlayer',\n name: template.name,\n createdAt: new Date(template.createdAt),\n })\n if (limit !== undefined && templates.length >= limit) return templates\n }\n\n offset += page.templates.length\n // TemplateListResponse has no total; stop on a short/empty page.\n if (page.templates.length === 0 || page.templates.length < take) break\n }\n\n return templates\n },\n\n delete: async (config: GravixLayerConfig, templateId: string) => {\n const client = getClient(config)\n try {\n await client.templates.delete(templateId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n // GravixLayer \"volumes\" are managed object-storage buckets mounted into a\n // runtime (`mounts: [{kind:'bucket'}]` at create, or runtime.attachVolume).\n volume: {\n create: async (config: GravixLayerConfig, options: CreateVolumeOptions) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.create(options.name)\n return { id: bucket.id, name: bucket.name, native: bucket }\n },\n\n get: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n return bucket ? { id: bucket.id, name: bucket.name, native: bucket } : null\n },\n\n list: async (config: GravixLayerConfig, options?: ListVolumesOptions) => {\n const client = getClient(config)\n const page = await client.storage.buckets.list()\n const buckets = page.buckets ?? []\n const limited = options?.limit === undefined ? buckets : buckets.slice(0, options.limit)\n return limited.map((b: { id?: string; name?: string }) => ({ id: b.id, name: b.name, native: b }))\n },\n\n delete: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n if (!bucket) return\n await client.storage.buckets.delete(bucket.id ?? idOrName)\n },\n },\n },\n})\n\n/** Preserve GravixLayer-specific template.create options on the public provider. */\nexport function gravixlayer(config: GravixLayerConfig = {}): GravixLayerProvider {\n const provider = createGravixLayerProvider(config)\n return { ...provider, template: provider.template! }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,sBAAwE;AAmBxE,yBAAwE;AAsBjE,IAAM,6BAAmF,OAAO,OAAO;AAAA,EAC5G,IAAI;AAAA,EACJ,IAAI;AAAA,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F;AAAA,EACF;AACF,CAAC;AAGM,SAAS,YAAY,SAA4B,CAAC,GAAwB;AAC/E,QAAM,WAAW,0BAA0B,MAAM;AACjD,SAAO,EAAE,GAAG,UAAU,UAAU,SAAS,SAAU;AACrD;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { defineProvider, isUnifiedVolumeMounts, resolveVolumeRef } from "@computesdk/provider";
|
|
3
3
|
import { GravixLayer, Runtime, TemplateBuilder } from "gravixlayer";
|
|
4
|
+
var GRAVIXLAYER_SIZE_TEMPLATES = Object.freeze({
|
|
5
|
+
xs: "base-xsmall",
|
|
6
|
+
sm: "base-small",
|
|
7
|
+
md: "base-medium",
|
|
8
|
+
lg: "base-large",
|
|
9
|
+
xl: "base-xlarge",
|
|
10
|
+
"2xl": "base-2xlarge"
|
|
11
|
+
});
|
|
12
|
+
function sizeTemplateOf(config, sizeClass) {
|
|
13
|
+
const name = config.sizeTemplates?.[sizeClass] ?? GRAVIXLAYER_SIZE_TEMPLATES[sizeClass];
|
|
14
|
+
return typeof name === "string" && name.trim() ? name : void 0;
|
|
15
|
+
}
|
|
16
|
+
function missingSizeTemplate(config, templateId, error) {
|
|
17
|
+
if (typeof templateId !== "string" || !isNotFound(error)) return void 0;
|
|
18
|
+
const sizeClass = Object.keys(GRAVIXLAYER_SIZE_TEMPLATES).find((c) => sizeTemplateOf(config, c) === templateId);
|
|
19
|
+
if (!sizeClass) return void 0;
|
|
20
|
+
return `GravixLayer size template '${templateId}' (sizeClass ${sizeClass}) is not available on this project; build it with \`template.create\` or point \`sizeTemplates.${sizeClass}\` at an existing template`;
|
|
21
|
+
}
|
|
4
22
|
function snapshotKind(options) {
|
|
5
23
|
const value = options?.kind ?? options?.metadata?.kind ?? "hot";
|
|
6
24
|
if (value !== "hot" && value !== "cold") {
|
|
@@ -140,6 +158,7 @@ function getClient(config) {
|
|
|
140
158
|
return client;
|
|
141
159
|
}
|
|
142
160
|
var CREATE_HTTP_TIMEOUT_MS = 18e4;
|
|
161
|
+
var FILE_WRITE_JSON_MAX_BYTES = 1024 * 1024;
|
|
143
162
|
var publishedUrls = /* @__PURE__ */ new WeakMap();
|
|
144
163
|
function mapStatus(status) {
|
|
145
164
|
return SANDBOX_STATUS.get(status) ?? "stopped";
|
|
@@ -219,16 +238,26 @@ function elapsedMs(started) {
|
|
|
219
238
|
}
|
|
220
239
|
var createGravixLayerProvider = defineProvider({
|
|
221
240
|
name: "gravixlayer",
|
|
241
|
+
sizes: (config, profile, options) => {
|
|
242
|
+
if (options?.templateId !== void 0 || options?.snapshotId !== void 0 || options?.sandboxId !== void 0 || nonempty(options?.image)) {
|
|
243
|
+
return { status: "unsupported", reason: "A GravixLayer template or snapshot fixes CPU and memory; drop templateId/image/snapshotId/sandboxId to boot the standard size template." };
|
|
244
|
+
}
|
|
245
|
+
const templateId = sizeTemplateOf(config, profile.sizeClass);
|
|
246
|
+
if (!templateId) {
|
|
247
|
+
return { status: "unknown", reason: "No GravixLayer size template is set up for this standard shape." };
|
|
248
|
+
}
|
|
249
|
+
return { status: "supported", nativeOptions: { templateId } };
|
|
250
|
+
},
|
|
222
251
|
methods: {
|
|
223
252
|
instances: {
|
|
224
253
|
create: async (config, options = {}) => {
|
|
225
|
-
if (nonempty(options.image)) {
|
|
226
|
-
throw new Error(
|
|
227
|
-
"GravixLayer runtimes start from a template, not an image. Pass `templateId`, or build a template from the image with `template.create({ name, fromImage })`."
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
254
|
const template = nonempty(options.templateId);
|
|
231
|
-
|
|
255
|
+
const image = nonempty(options.image);
|
|
256
|
+
if (template && image && template !== image) {
|
|
257
|
+
throw new Error("`image` and `templateId` name two different templates; pass one");
|
|
258
|
+
}
|
|
259
|
+
const source = template ?? image;
|
|
260
|
+
if (source && options.snapshotId) {
|
|
232
261
|
throw new Error("A runtime starts from a template or a snapshot, not both");
|
|
233
262
|
}
|
|
234
263
|
const envVars = validateEnvironment(options.envs);
|
|
@@ -236,8 +265,8 @@ var createGravixLayerProvider = defineProvider({
|
|
|
236
265
|
const body = {};
|
|
237
266
|
if (options.snapshotId) {
|
|
238
267
|
body.snapshot = options.snapshotId;
|
|
239
|
-
} else if (
|
|
240
|
-
body.template =
|
|
268
|
+
} else if (source) {
|
|
269
|
+
body.template = source;
|
|
241
270
|
}
|
|
242
271
|
if (Object.keys(envVars).length > 0) body.envVars = envVars;
|
|
243
272
|
if (options.timeout !== void 0) {
|
|
@@ -261,7 +290,19 @@ var createGravixLayerProvider = defineProvider({
|
|
|
261
290
|
if (!options.snapshotId && config.timeout === void 0) {
|
|
262
291
|
body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS;
|
|
263
292
|
}
|
|
264
|
-
|
|
293
|
+
let sandbox;
|
|
294
|
+
try {
|
|
295
|
+
sandbox = await client.runtime.create(body);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
const notBuilt = missingSizeTemplate(config, options.templateId, error);
|
|
298
|
+
if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error });
|
|
299
|
+
if (image && !template && isNotFound(error)) {
|
|
300
|
+
throw Object.assign(new Error(
|
|
301
|
+
`GravixLayer template '${image}' is not available on this project; build it with \`template.create\` or pass an existing \`templateId\``
|
|
302
|
+
), { status: 404, cause: error });
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
265
306
|
rememberTimeout(
|
|
266
307
|
sandbox,
|
|
267
308
|
body.timeout === void 0 ? void 0 : body.timeout * 1e3
|
|
@@ -365,10 +406,15 @@ var createGravixLayerProvider = defineProvider({
|
|
|
365
406
|
pauseCapabilities: { memory: true },
|
|
366
407
|
filesystem: {
|
|
367
408
|
readFile: async (sandbox, path) => {
|
|
368
|
-
return
|
|
409
|
+
return sandbox.file.downloadText(path);
|
|
369
410
|
},
|
|
370
411
|
writeFile: async (sandbox, path, content) => {
|
|
371
|
-
|
|
412
|
+
const jsonBytes = new TextEncoder().encode(JSON.stringify(content)).byteLength;
|
|
413
|
+
if (jsonBytes > FILE_WRITE_JSON_MAX_BYTES) {
|
|
414
|
+
await sandbox.file.upload(path, new TextEncoder().encode(content));
|
|
415
|
+
} else {
|
|
416
|
+
await sandbox.file.write(path, content);
|
|
417
|
+
}
|
|
372
418
|
},
|
|
373
419
|
mkdir: async (sandbox, path) => {
|
|
374
420
|
await sandbox.file.createDirectory(path);
|
|
@@ -594,6 +640,7 @@ function gravixlayer(config = {}) {
|
|
|
594
640
|
return { ...provider, template: provider.template };
|
|
595
641
|
}
|
|
596
642
|
export {
|
|
643
|
+
GRAVIXLAYER_SIZE_TEMPLATES,
|
|
597
644
|
clearGravixLayerClients,
|
|
598
645
|
gravixlayer
|
|
599
646
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @computesdk/gravixlayer — GravixLayer provider for ComputeSDK.\n *\n * Cloud runtimes with a native filesystem API, live command streaming,\n * port publishing, templates, snapshots, and bucket-mount volumes.\n *\n * @see https://gravixlayer.ai\n */\n\nimport { defineProvider, isUnifiedVolumeMounts, resolveVolumeRef } from '@computesdk/provider'\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n CreateTemplateOptions,\n FileEntry,\n ListSnapshotsOptions,\n ListTemplatesOptions,\n Provider,\n ProviderTemplateManager,\n RunCommandOptions,\n SandboxInfo,\n CreateVolumeOptions,\n ListVolumesOptions,\n} from '@computesdk/provider'\nimport { GravixLayer, Runtime, TemplateBuilder, type RuntimeInfo } from 'gravixlayer'\n\nexport type { Runtime as GravixLayerRuntime }\n\nexport interface GravixLayerConfig {\n apiKey?: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries?: number\n http2?: boolean\n}\n\n/**\n * Snapshots default to `hot` (filesystem and memory), so tmpfs paths such as\n * `/tmp` survive restore. Pass `kind: 'cold'` (or\n * `metadata.kind`) for a filesystem-only snapshot of the persistent disk.\n */\nfunction snapshotKind(options?: CreateSnapshotOptions): 'hot' | 'cold' {\n const value =\n (options as { kind?: unknown } | undefined)?.kind ?? options?.metadata?.kind ?? 'hot'\n if (value !== 'hot' && value !== 'cold') {\n throw new Error(`Invalid GravixLayer snapshot kind: ${String(value)}. Use 'hot' or 'cold'.`)\n }\n return value\n}\n\n/** GravixLayer requires a snapshot name; generate a unique one when none is given. */\nfunction defaultSnapshotName(): string {\n return `computesdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`\n}\n\n/** Snapshot returned by this provider's snapshot manager. */\nexport interface GravixLayerSnapshot {\n id: string\n provider: 'gravixlayer'\n createdAt: Date\n metadata: {\n name: string\n state: string\n kind: string\n }\n}\n\n/** Template returned by this provider's template manager. */\nexport interface GravixLayerTemplate {\n id: string\n provider: 'gravixlayer'\n name: string\n createdAt: Date\n}\n\n/** Extra fields accepted on template.create beyond ComputeSDK's base options. */\nexport interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {\n fromImage?: string\n dockerfile?: string\n run?: string[]\n vcpu?: number\n memoryMb?: number\n diskMb?: number\n}\n\n/** Public provider with GravixLayer-specific template.create options. */\nexport interface GravixLayerProvider\n extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {\n template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>\n}\n\ninterface ResolvedClientOptions {\n apiKey: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries: number\n http2: boolean\n}\n\nconst clients = new Map<string, GravixLayer>()\n\n/**\n * Fast path over `clients`: a provider instance's config object resolves once,\n * and later calls on the same instance skip resolution and the identity string.\n * The entry also snapshots the raw config fields and the env vars resolution\n * consulted, so a mutated config object or a changed env var falls through to a\n * fresh resolve — identical semantics to resolving on every call. `WeakMap`\n * means the entry dies with the config; it cannot leak. Two provider instances\n * with equivalent options still share one client through the `clients` map.\n */\ninterface CachedResolution {\n client: GravixLayer\n config: Pick<\n GravixLayerConfig,\n 'apiKey' | 'baseUrl' | 'cloud' | 'region' | 'timeout' | 'maxRetries' | 'http2'\n >\n env: [string | undefined, string | undefined, string | undefined, string | undefined]\n}\n\nlet clientsByConfig = new WeakMap<GravixLayerConfig, CachedResolution>()\n\n/** Clear the module-level GravixLayer client caches. For tests only. */\nexport function clearGravixLayerClients(): void {\n clients.clear()\n clientsByConfig = new WeakMap()\n}\n\nconst createTimeoutMs = new WeakMap<object, number>()\n\n/**\n * ComputeSDK status for every runtime status the API reports. Only a running\n * runtime accepts commands, so a paused or stopping one reports `stopped`.\n * A `Map`, so no status string can resolve to an `Object.prototype` member.\n */\nconst SANDBOX_STATUS: ReadonlyMap<string, SandboxInfo['status']> = new Map([\n ['creating', 'running'],\n ['running', 'running'],\n ['paused', 'stopped'],\n ['stopping', 'stopped'],\n ['stopped', 'stopped'],\n ['terminated', 'stopped'],\n ['timed_out', 'stopped'],\n ['failed', 'error'],\n])\n\n/** Statuses the API no longer counts as live. `getById` reports these as gone. */\nconst ENDED_STATUSES: ReadonlySet<string> = new Set(['stopped', 'failed', 'terminated', 'timed_out'])\n\n/** Runtime IDs are UUIDs. A string of any other shape cannot name a runtime. */\nconst RUNTIME_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\nfunction isNotFound(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { status?: unknown }).status === 404\n )\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction validateEnvironment(\n environment: Record<string, string> | undefined,\n): Record<string, string> {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(environment ?? {})) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(name)}`)\n }\n result[name] = String(value)\n }\n return result\n}\n\n/** Convert a millisecond timeout to whole seconds. Zero is allowed. */\nfunction toTimeoutSeconds(ms: number, what: string): number {\n if (!Number.isFinite(ms) || ms < 0) {\n throw new Error(`GravixLayer ${what} must be a non-negative finite number of milliseconds`)\n }\n return Math.ceil(ms / 1000)\n}\n\nfunction nonempty(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed === '' ? undefined : trimmed\n}\n\nfunction resolveClientOptions(config: GravixLayerConfig): ResolvedClientOptions {\n const apiKey = (config.apiKey ?? process.env.GRAVIXLAYER_API_KEY)?.trim()\n if (!apiKey) {\n throw new Error(\n 'GravixLayer requires an API key. Pass `apiKey` or set the `GRAVIXLAYER_API_KEY` environment variable. Get a key at https://gravixlayer.ai .',\n )\n }\n\n const maxRetries = config.maxRetries ?? 0\n if (!Number.isInteger(maxRetries) || maxRetries < 0) {\n throw new Error('GravixLayer maxRetries must be a non-negative integer')\n }\n\n const resolved: ResolvedClientOptions = {\n apiKey,\n maxRetries,\n http2: config.http2 ?? true,\n }\n\n const baseUrl = nonempty(config.baseUrl ?? process.env.GRAVIXLAYER_BASE_URL)\n if (baseUrl !== undefined) resolved.baseUrl = baseUrl\n\n const cloud = nonempty(config.cloud ?? process.env.GRAVIXLAYER_CLOUD)\n if (cloud !== undefined) resolved.cloud = cloud\n\n const region = nonempty(config.region ?? process.env.GRAVIXLAYER_REGION)\n if (region !== undefined) resolved.region = region\n\n if (config.timeout !== undefined) {\n if (!Number.isFinite(config.timeout) || config.timeout < 0) {\n throw new Error('GravixLayer timeout must be a non-negative finite number of milliseconds')\n }\n resolved.timeout = config.timeout\n }\n\n return resolved\n}\n\nfunction clientIdentity(options: ResolvedClientOptions): string {\n return JSON.stringify([\n options.apiKey,\n options.baseUrl ?? null,\n options.cloud ?? null,\n options.region ?? null,\n options.timeout ?? null,\n options.maxRetries,\n options.http2,\n ])\n}\n\nfunction getClient(config: GravixLayerConfig): GravixLayer {\n const cached = clientsByConfig.get(config)\n if (\n cached &&\n cached.config.apiKey === config.apiKey &&\n cached.config.baseUrl === config.baseUrl &&\n cached.config.cloud === config.cloud &&\n cached.config.region === config.region &&\n cached.config.timeout === config.timeout &&\n cached.config.maxRetries === config.maxRetries &&\n cached.config.http2 === config.http2 &&\n // env is only consulted when the matching config field is unset\n (config.apiKey !== undefined || process.env.GRAVIXLAYER_API_KEY === cached.env[0]) &&\n (config.baseUrl !== undefined || process.env.GRAVIXLAYER_BASE_URL === cached.env[1]) &&\n (config.cloud !== undefined || process.env.GRAVIXLAYER_CLOUD === cached.env[2]) &&\n (config.region !== undefined || process.env.GRAVIXLAYER_REGION === cached.env[3])\n ) {\n return cached.client\n }\n const options = resolveClientOptions(config)\n const key = clientIdentity(options)\n let client = clients.get(key)\n if (!client) {\n client = new GravixLayer({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n ...(options.cloud !== undefined ? { cloud: options.cloud } : {}),\n ...(options.region !== undefined ? { region: options.region } : {}),\n ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n maxRetries: options.maxRetries,\n http2: options.http2,\n })\n clients.set(key, client)\n }\n clientsByConfig.set(config, {\n client,\n config: {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n cloud: config.cloud,\n region: config.region,\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n http2: config.http2,\n },\n env: [\n process.env.GRAVIXLAYER_API_KEY,\n process.env.GRAVIXLAYER_BASE_URL,\n process.env.GRAVIXLAYER_CLOUD,\n process.env.GRAVIXLAYER_REGION,\n ],\n })\n return client\n}\n\n/**\n * The SDK keeps a small HTTP/2 session pool per origin: a burst spreads over\n * a handful of connections whose handshakes run in parallel, while a quiet\n * caller keeps one session. `maxRetries: 0` keeps a refused create from\n * sleeping inside the caller's timer. `connect()` is intentionally not\n * called: it issues its own request and would compete with create.\n *\n * A boot can outlast the client's 60-second default, so create gets its own\n * HTTP deadline — longer than a slow boot and shorter than the benchmark's\n * 120s create budget. It is sent as `requestTimeoutMs`: `timeout` on create\n * options is the sandbox lifetime in seconds, so putting the budget there\n * would store a multi-day lifetime. An explicit provider `timeout` is kept\n * as the caller's cap. It does not add latency on a fast create; it only\n * releases the HTTP/2 stream if a boot never returns. `0` would hold that\n * stream until the process exits.\n */\nconst CREATE_HTTP_TIMEOUT_MS = 180_000\n\n/** In-flight or completed publish, so concurrent getUrl calls share one request. */\nconst publishedUrls = new WeakMap<Runtime, Map<number, Promise<string>>>()\n\n/** A status this version does not know is reported as stopped, never as running. */\nfunction mapStatus(status: string): SandboxInfo['status'] {\n return SANDBOX_STATUS.get(status) ?? 'stopped'\n}\n\nfunction parseCreatedAt(startedAt: string | undefined): Date {\n if (startedAt) {\n const date = new Date(startedAt)\n if (!Number.isNaN(date.getTime())) return date\n }\n return new Date()\n}\n\nfunction leaseTimeoutMs(startedAt: string | undefined, timeoutAt: string | undefined): number {\n if (!startedAt || !timeoutAt) return 0\n const start = new Date(startedAt).getTime()\n const end = new Date(timeoutAt).getTime()\n if (!Number.isFinite(start) || !Number.isFinite(end)) return 0\n const delta = end - start\n return delta > 0 ? delta : 0\n}\n\nfunction rememberTimeout(sandbox: Runtime, timeoutMs: number | undefined): Runtime {\n if (timeoutMs !== undefined) createTimeoutMs.set(sandbox, timeoutMs)\n return sandbox\n}\n\nfunction bindRuntime(client: GravixLayer, info: RuntimeInfo): Runtime {\n return new Runtime(client.runtime, info)\n}\n\nasync function publishedUrl(sandbox: Runtime, port: number): Promise<string> {\n let ports = publishedUrls.get(sandbox)\n const existing = ports?.get(port)\n if (existing) return existing\n\n const pending = sandbox.service(port).then((handle) => {\n if (!handle.url) {\n throw new Error(`GravixLayer did not return a URL for port ${port}.`)\n }\n return handle.url\n })\n if (!ports) {\n ports = new Map()\n publishedUrls.set(sandbox, ports)\n }\n ports.set(port, pending)\n try {\n return await pending\n } catch (error) {\n ports.delete(port)\n throw error\n }\n}\n\nasync function runCommand(\n sandbox: Runtime,\n command: string,\n options: RunCommandOptions = {},\n): Promise<CommandResult> {\n const started = performance.now()\n\n if (options.background && (options.onStdout || options.onStderr)) {\n throw new Error('runCommand with streaming callbacks does not support background mode.')\n }\n\n const environment = validateEnvironment(options.env)\n const opts: {\n workingDir?: string\n environment?: Record<string, string>\n timeout?: number\n background?: boolean\n onStdout?: (chunk: string) => void\n onStderr?: (chunk: string) => void\n } = {}\n\n if (options.cwd) opts.workingDir = options.cwd\n if (Object.keys(environment).length > 0) opts.environment = environment\n if (options.timeout !== undefined) {\n opts.timeout = toTimeoutSeconds(options.timeout, 'command timeout')\n }\n if (options.onStdout) opts.onStdout = options.onStdout\n if (options.onStderr) opts.onStderr = options.onStderr\n\n if (options.background) {\n await sandbox.runCmd(command, { ...opts, background: true })\n return { stdout: '', stderr: '', exitCode: 0, durationMs: elapsedMs(started) }\n }\n\n const result = await sandbox.runCmd(command, opts)\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs:\n typeof result.durationMs === 'number' && Number.isFinite(result.durationMs)\n ? Math.max(0, result.durationMs)\n : elapsedMs(started),\n }\n}\n\nfunction elapsedMs(started: number): number {\n return Math.max(0, Math.round(performance.now() - started))\n}\n\nconst createGravixLayerProvider = defineProvider<\n Runtime,\n GravixLayerConfig,\n GravixLayerTemplate,\n GravixLayerSnapshot\n>({\n name: 'gravixlayer',\n methods: {\n instances: {\n create: async (config: GravixLayerConfig, options: CreateInstanceOptions = {}) => {\n if (nonempty(options.image)) {\n throw new Error(\n 'GravixLayer runtimes start from a template, not an image. Pass `templateId`, or build a template from the image with `template.create({ name, fromImage })`.',\n )\n }\n const template = nonempty(options.templateId)\n if (template && options.snapshotId) {\n throw new Error('A runtime starts from a template or a snapshot, not both')\n }\n\n const envVars = validateEnvironment(options.envs)\n const client = getClient(config)\n\n const body: {\n template?: string\n snapshot?: string\n envVars?: Record<string, string>\n /** Sandbox lifetime in seconds. */\n timeout?: number\n /** HTTP deadline for this request, in milliseconds. */\n requestTimeoutMs?: number\n metadata?: Record<string, unknown>\n cloud?: string\n region?: string\n mounts?: Array<{ kind: 'bucket'; bucket: string; path: string; mode: 'ro' | 'rw' }>\n signal?: AbortSignal\n } = {}\n\n if (options.snapshotId) {\n body.snapshot = options.snapshotId\n } else if (template) {\n body.template = template\n }\n\n if (Object.keys(envVars).length > 0) body.envVars = envVars\n\n if (options.timeout !== undefined) {\n body.timeout = toTimeoutSeconds(options.timeout, 'sandbox timeout')\n }\n\n if (isPlainObject(options.metadata)) {\n body.metadata = options.metadata\n }\n\n // Unified mounts → gravixlayer's [{kind:'bucket',bucket,path,mode}] wire\n // shape; buckets are created via `provider.volume`/`compute.volume`.\n const volumes = options.volumes\n if (isUnifiedVolumeMounts(volumes) && volumes.length > 0) {\n body.mounts = volumes.map((m) => ({\n kind: 'bucket' as const,\n bucket: resolveVolumeRef(m.volume).id ?? resolveVolumeRef(m.volume).name ?? '',\n path: m.mountPath,\n mode: m.readOnly ? 'ro' : 'rw',\n }))\n }\n\n if (typeof options.cloud === 'string') body.cloud = options.cloud\n if (typeof options.region === 'string') body.region = options.region\n if (options.signal) body.signal = options.signal\n if (!options.snapshotId && config.timeout === undefined) {\n body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS\n }\n\n const sandbox = await client.runtime.create(body)\n // Report the lease the runtime actually got: seconds, rounded up.\n rememberTimeout(\n sandbox,\n body.timeout === undefined ? undefined : body.timeout * 1000,\n )\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n },\n\n getById: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n if (!RUNTIME_ID.test(sandboxId)) return null\n try {\n const sandbox = await client.runtime.get(sandboxId)\n if (ENDED_STATUSES.has(sandbox.status)) return null\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n } catch (error) {\n if (isNotFound(error)) return null\n throw error\n }\n },\n\n list: async (config: GravixLayerConfig) => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const sandboxes: Array<{ instance: Runtime; instanceId: string }> = []\n const seen = new Set<string>()\n\n for (;;) {\n const page = await client.runtime.list({ limit: pageSize, offset })\n const marker = page.runtimes[0]?.runtimeId\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const info of page.runtimes) {\n if (!info.runtimeId) continue\n // The list payload is enough to bind a handle. A follow-up get\n // per row would add one round trip per runtime.\n const sandbox = bindRuntime(client, info)\n sandboxes.push({ instance: sandbox, instanceId: sandbox.runtimeId })\n }\n offset += page.runtimes.length\n if (\n page.runtimes.length < pageSize ||\n !Number.isFinite(page.total) ||\n offset >= page.total\n ) {\n break\n }\n }\n\n return sandboxes\n },\n\n destroy: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n try {\n await client.runtime.kill(sandboxId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n\n runCommand,\n\n streamCommand: runCommand,\n\n getInfo: async (sandbox: Runtime): Promise<SandboxInfo> => {\n await sandbox.refresh()\n const info = sandbox.info\n return {\n id: sandbox.runtimeId,\n provider: 'gravixlayer',\n status: mapStatus(info.status),\n createdAt: parseCreatedAt(info.startedAt),\n timeout:\n createTimeoutMs.get(sandbox) ?? leaseTimeoutMs(info.startedAt, info.timeoutAt),\n ...(info.metadata !== undefined ? { metadata: info.metadata } : {}),\n }\n },\n\n getUrl: async (sandbox: Runtime, options: { port: number; protocol?: string }) => {\n const { port } = options\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`Invalid port: ${port}`)\n }\n const value = await publishedUrl(sandbox, port)\n if (!options.protocol) return value\n const url = new URL(value)\n url.protocol = `${options.protocol.replace(/:$/, '')}:`\n return url.toString()\n },\n\n getInstance: (sandbox: Runtime) => sandbox,\n\n attachVolume: async (instance: Runtime, volume, mountPath: string) => {\n const ref = resolveVolumeRef(volume)\n await instance.mounts.attach({\n kind: 'bucket',\n bucket: ref.id ?? ref.name ?? '',\n path: mountPath,\n mode: 'rw',\n })\n },\n\n detachVolume: async (instance: Runtime, volume, mountPath?: string) => {\n const ref = resolveVolumeRef(volume)\n const id = ref.id ?? ref.name\n const { mounts } = await instance.mounts.list()\n const mount = mounts.find(\n (m: { id?: string; targetId?: string; mountPath?: string }) =>\n id !== undefined\n ? (m.targetId === id || m.id === id) && (mountPath === undefined || m.mountPath === mountPath)\n : m.mountPath === mountPath,\n )\n if (mount?.id) await instance.mounts.detach(mount.id)\n },\n\n pause: async (sandbox: Runtime) => {\n await sandbox.pause()\n },\n\n resume: async (sandbox: Runtime) => {\n await sandbox.resume()\n },\n\n // Pause freezes memory: files and running processes survive resume.\n pauseCapabilities: { memory: true },\n\n filesystem: {\n readFile: async (sandbox: Runtime, path: string): Promise<string> => {\n return (await sandbox.file.read(path)).content\n },\n\n writeFile: async (sandbox: Runtime, path: string, content: string): Promise<void> => {\n await sandbox.file.write(path, content)\n },\n\n mkdir: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.createDirectory(path)\n },\n\n readdir: async (sandbox: Runtime, path: string): Promise<FileEntry[]> => {\n const listing = await sandbox.file.list(path)\n return listing.files.map((entry) => {\n const fileEntry: FileEntry = {\n name: entry.name,\n type: entry.isDir ? 'directory' : 'file',\n size: entry.size,\n }\n const modified = new Date(entry.modifiedAt)\n if (!Number.isNaN(modified.getTime())) {\n fileEntry.modified = modified\n }\n return fileEntry\n })\n },\n\n exists: async (sandbox: Runtime, path: string): Promise<boolean> => {\n return (await sandbox.file.getInfo(path)).exists\n },\n\n remove: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.delete(path)\n },\n },\n },\n\n snapshot: {\n // Hot snapshots (the default) keep the whole rootfs, `/tmp` included,\n // and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n\n create: async (\n config: GravixLayerConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ): Promise<GravixLayerSnapshot> => {\n const name = nonempty(options?.name) ?? defaultSnapshotName()\n const client = getClient(config)\n const description =\n options &&\n 'description' in options &&\n typeof (options as { description?: unknown }).description === 'string'\n ? (options as { description: string }).description\n : undefined\n const kind = snapshotKind(options)\n const snapshot = await client.snapshots.create(sandboxId, name, {\n kind,\n ...(description !== undefined ? { description } : {}),\n })\n return {\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListSnapshotsOptions,\n ): Promise<GravixLayerSnapshot[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const snapshots: GravixLayerSnapshot[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - snapshots.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.snapshots.list({\n limit: take,\n offset,\n ...(options?.sandboxId ? { runtimeId: options.sandboxId } : {}),\n })\n\n const marker = page.snapshots[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n\n for (const snapshot of page.snapshots) {\n snapshots.push({\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n })\n if (limit !== undefined && snapshots.length >= limit) return snapshots\n }\n\n offset += page.snapshots.length\n if (page.snapshots.length === 0 || offset >= page.total) break\n if (page.snapshots.length < take) break\n }\n\n return snapshots\n },\n\n delete: async (config: GravixLayerConfig, snapshotId: string) => {\n const client = getClient(config)\n try {\n await client.snapshots.delete(snapshotId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n template: {\n create: async (\n config: GravixLayerConfig,\n options: GravixLayerCreateTemplateOptions,\n ): Promise<GravixLayerTemplate> => {\n const name = nonempty(options.name)\n if (!name) {\n throw new Error('GravixLayer templates require a name.')\n }\n\n const fromImage = nonempty(options.fromImage)\n const dockerfile = nonempty(options.dockerfile)\n if (!fromImage && !dockerfile) {\n throw new Error(\n 'A GravixLayer template build needs `fromImage` or `dockerfile`. Select an existing template with `templateId` on sandbox create.',\n )\n }\n if (fromImage && dockerfile) {\n throw new Error('Specify either fromImage or dockerfile, not both.')\n }\n\n const builder = new TemplateBuilder(name, options.description ?? '')\n if (fromImage) builder.fromImage(fromImage)\n if (dockerfile) builder.dockerfile(dockerfile)\n\n if (Array.isArray(options.run)) {\n for (const command of options.run) {\n if (typeof command === 'string' && command.trim() !== '') {\n builder.run(command)\n }\n }\n }\n\n if (typeof options.vcpu === 'number' && Number.isFinite(options.vcpu) && options.vcpu > 0) {\n builder.vcpu(options.vcpu)\n }\n if (\n typeof options.memoryMb === 'number' &&\n Number.isFinite(options.memoryMb) &&\n options.memoryMb > 0\n ) {\n builder.memory(options.memoryMb)\n }\n if (\n typeof options.diskMb === 'number' &&\n Number.isFinite(options.diskMb) &&\n options.diskMb > 0\n ) {\n builder.disk(options.diskMb)\n }\n\n if (options.metadata) {\n const tags: Record<string, string> = {}\n for (const [key, value] of Object.entries(options.metadata)) {\n if (typeof value === 'string') tags[key] = value\n }\n if (Object.keys(tags).length > 0) builder.tags(tags)\n }\n\n const client = getClient(config)\n const status = await client.templates.buildAndWait(builder)\n return {\n id: status.templateId,\n provider: 'gravixlayer',\n name,\n createdAt: new Date(),\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListTemplatesOptions,\n ): Promise<GravixLayerTemplate[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const templates: GravixLayerTemplate[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - templates.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.templates.list({ limit: take, offset })\n const marker = page.templates[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const template of page.templates) {\n templates.push({\n id: template.id,\n provider: 'gravixlayer',\n name: template.name,\n createdAt: new Date(template.createdAt),\n })\n if (limit !== undefined && templates.length >= limit) return templates\n }\n\n offset += page.templates.length\n // TemplateListResponse has no total; stop on a short/empty page.\n if (page.templates.length === 0 || page.templates.length < take) break\n }\n\n return templates\n },\n\n delete: async (config: GravixLayerConfig, templateId: string) => {\n const client = getClient(config)\n try {\n await client.templates.delete(templateId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n // GravixLayer \"volumes\" are managed object-storage buckets mounted into a\n // runtime (`mounts: [{kind:'bucket'}]` at create, or runtime.attachVolume).\n volume: {\n create: async (config: GravixLayerConfig, options: CreateVolumeOptions) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.create(options.name)\n return { id: bucket.id, name: bucket.name, native: bucket }\n },\n\n get: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n return bucket ? { id: bucket.id, name: bucket.name, native: bucket } : null\n },\n\n list: async (config: GravixLayerConfig, options?: ListVolumesOptions) => {\n const client = getClient(config)\n const page = await client.storage.buckets.list()\n const buckets = page.buckets ?? []\n const limited = options?.limit === undefined ? buckets : buckets.slice(0, options.limit)\n return limited.map((b: { id?: string; name?: string }) => ({ id: b.id, name: b.name, native: b }))\n },\n\n delete: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n if (!bucket) return\n await client.storage.buckets.delete(bucket.id ?? idOrName)\n },\n },\n },\n})\n\n/** Preserve GravixLayer-specific template.create options on the public provider. */\nexport function gravixlayer(config: GravixLayerConfig = {}): GravixLayerProvider {\n const provider = createGravixLayerProvider(config)\n return { ...provider, template: provider.template! }\n}\n"],"mappings":";AASA,SAAS,gBAAgB,uBAAuB,wBAAwB;AAiBxE,SAAS,aAAa,SAAS,uBAAyC;AAmBxE,SAAS,aAAa,SAAiD;AACrE,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AAI,QAAQ,EAAE,MAAM,CAAC,QAAiB;AAChF,cAAK,KAA6B,WAAW,IAAK,QAAO;AACzD,gBAAM;AAAA,QACR,CAAC;AACD,eAAO,SAAS,EAAE,IAAI,OAAO,IAAI,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI;AAAA,MACzE;AAAA,MAEA,MAAM,OAAO,QAA2B,YAAiC;AACvE,cAAM,SAAS,UAAU,MAAM;AAC/B,cAAM,OAAO,MAAM,OAAO,QAAQ,QAAQ,KAAK;AAC/C,cAAM,UAAU,KAAK,WAAW,CAAC;AACjC,cAAM,UAAU,SAAS,UAAU,SAAY,UAAU,QAAQ,MAAM,GAAG,QAAQ,KAAK;AACvF,eAAO,QAAQ,IAAI,CAAC,OAAuC,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,QAAQ,EAAE,EAAE;AAAA,MACnG;AAAA,MAEA,QAAQ,OAAO,QAA2B,aAAqB;AAC7D,cAAM,SAAS,UAAU,MAAM;AAC/B,cAAM,SAAS,MAAM,OAAO,QAAQ,QAAQ,IAAI,QAAQ,EAAE,MAAM,CAAC,QAAiB;AAChF,cAAK,KAA6B,WAAW,IAAK,QAAO;AACzD,gBAAM;AAAA,QACR,CAAC;AACD,YAAI,CAAC,OAAQ;AACb,cAAM,OAAO,QAAQ,QAAQ,OAAO,OAAO,MAAM,QAAQ;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAGM,SAAS,YAAY,SAA4B,CAAC,GAAwB;AAC/E,QAAM,WAAW,0BAA0B,MAAM;AACjD,SAAO,EAAE,GAAG,UAAU,UAAU,SAAS,SAAU;AACrD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @computesdk/gravixlayer — GravixLayer provider for ComputeSDK.\n *\n * Cloud runtimes with a native filesystem API, live command streaming,\n * port publishing, templates, snapshots, and bucket-mount volumes.\n *\n * @see https://gravixlayer.ai\n */\n\nimport { defineProvider, isUnifiedVolumeMounts, resolveVolumeRef } from '@computesdk/provider'\n\nimport type {\n CommandResult,\n CreateInstanceOptions,\n CreateSnapshotOptions,\n CreateTemplateOptions,\n FileEntry,\n ListSnapshotsOptions,\n ListTemplatesOptions,\n InstanceSizeClass,\n InstanceSizeManager,\n Provider,\n ProviderTemplateManager,\n RunCommandOptions,\n SandboxInfo,\n CreateVolumeOptions,\n ListVolumesOptions,\n} from '@computesdk/provider'\nimport { GravixLayer, Runtime, TemplateBuilder, type RuntimeInfo } from 'gravixlayer'\n\nexport type { Runtime as GravixLayerRuntime }\n\nexport interface GravixLayerConfig {\n apiKey?: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries?: number\n http2?: boolean\n /** Template name to boot per standard `sizeClass`; defaults to {@link GRAVIXLAYER_SIZE_TEMPLATES}. */\n sizeTemplates?: Partial<Record<InstanceSizeClass, string>>\n}\n\n/**\n * GravixLayer fixes CPU and memory when a template is built, so each standard\n * size boots its own template. The platform ships these `base-*` templates\n * with matching shapes; `scripts/provider-setup.mjs gravixlayer` builds them\n * on deployments where they are absent.\n */\nexport const GRAVIXLAYER_SIZE_TEMPLATES: Readonly<Partial<Record<InstanceSizeClass, string>>> = Object.freeze({\n xs: 'base-xsmall',\n sm: 'base-small',\n md: 'base-medium',\n lg: 'base-large',\n xl: 'base-xlarge',\n '2xl': 'base-2xlarge',\n})\n\nfunction sizeTemplateOf(config: GravixLayerConfig, sizeClass: InstanceSizeClass): string | undefined {\n const name = config.sizeTemplates?.[sizeClass] ?? GRAVIXLAYER_SIZE_TEMPLATES[sizeClass]\n return typeof name === 'string' && name.trim() ? name : undefined\n}\n\n/** A create that failed because a standard-size template was never built on this project. */\nfunction missingSizeTemplate(config: GravixLayerConfig, templateId: unknown, error: unknown): string | undefined {\n if (typeof templateId !== 'string' || !isNotFound(error)) return undefined\n const sizeClass = (Object.keys(GRAVIXLAYER_SIZE_TEMPLATES) as InstanceSizeClass[]).find(c => sizeTemplateOf(config, c) === templateId)\n if (!sizeClass) return undefined\n return `GravixLayer size template '${templateId}' (sizeClass ${sizeClass}) is not available on this project; build it with \\`template.create\\` or point \\`sizeTemplates.${sizeClass}\\` at an existing template`\n}\n\n/**\n * Snapshots default to `hot` (filesystem and memory), so tmpfs paths such as\n * `/tmp` survive restore. Pass `kind: 'cold'` (or\n * `metadata.kind`) for a filesystem-only snapshot of the persistent disk.\n */\nfunction snapshotKind(options?: CreateSnapshotOptions): 'hot' | 'cold' {\n const value =\n (options as { kind?: unknown } | undefined)?.kind ?? options?.metadata?.kind ?? 'hot'\n if (value !== 'hot' && value !== 'cold') {\n throw new Error(`Invalid GravixLayer snapshot kind: ${String(value)}. Use 'hot' or 'cold'.`)\n }\n return value\n}\n\n/** GravixLayer requires a snapshot name; generate a unique one when none is given. */\nfunction defaultSnapshotName(): string {\n return `computesdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`\n}\n\n/** Snapshot returned by this provider's snapshot manager. */\nexport interface GravixLayerSnapshot {\n id: string\n provider: 'gravixlayer'\n createdAt: Date\n metadata: {\n name: string\n state: string\n kind: string\n }\n}\n\n/** Template returned by this provider's template manager. */\nexport interface GravixLayerTemplate {\n id: string\n provider: 'gravixlayer'\n name: string\n createdAt: Date\n}\n\n/** Extra fields accepted on template.create beyond ComputeSDK's base options. */\nexport interface GravixLayerCreateTemplateOptions extends CreateTemplateOptions {\n fromImage?: string\n dockerfile?: string\n run?: string[]\n vcpu?: number\n memoryMb?: number\n diskMb?: number\n}\n\n/** Public provider with GravixLayer-specific template.create options. */\nexport interface GravixLayerProvider\n extends Provider<Runtime, GravixLayerTemplate, GravixLayerSnapshot> {\n template: ProviderTemplateManager<GravixLayerTemplate, GravixLayerCreateTemplateOptions>\n readonly sizes: InstanceSizeManager\n}\n\ninterface ResolvedClientOptions {\n apiKey: string\n baseUrl?: string\n cloud?: string\n region?: string\n timeout?: number\n maxRetries: number\n http2: boolean\n}\n\nconst clients = new Map<string, GravixLayer>()\n\n/**\n * Fast path over `clients`: a provider instance's config object resolves once,\n * and later calls on the same instance skip resolution and the identity string.\n * The entry also snapshots the raw config fields and the env vars resolution\n * consulted, so a mutated config object or a changed env var falls through to a\n * fresh resolve — identical semantics to resolving on every call. `WeakMap`\n * means the entry dies with the config; it cannot leak. Two provider instances\n * with equivalent options still share one client through the `clients` map.\n */\ninterface CachedResolution {\n client: GravixLayer\n config: Pick<\n GravixLayerConfig,\n 'apiKey' | 'baseUrl' | 'cloud' | 'region' | 'timeout' | 'maxRetries' | 'http2'\n >\n env: [string | undefined, string | undefined, string | undefined, string | undefined]\n}\n\nlet clientsByConfig = new WeakMap<GravixLayerConfig, CachedResolution>()\n\n/** Clear the module-level GravixLayer client caches. For tests only. */\nexport function clearGravixLayerClients(): void {\n clients.clear()\n clientsByConfig = new WeakMap()\n}\n\nconst createTimeoutMs = new WeakMap<object, number>()\n\n/**\n * ComputeSDK status for every runtime status the API reports. Only a running\n * runtime accepts commands, so a paused or stopping one reports `stopped`.\n * A `Map`, so no status string can resolve to an `Object.prototype` member.\n */\nconst SANDBOX_STATUS: ReadonlyMap<string, SandboxInfo['status']> = new Map([\n ['creating', 'running'],\n ['running', 'running'],\n ['paused', 'stopped'],\n ['stopping', 'stopped'],\n ['stopped', 'stopped'],\n ['terminated', 'stopped'],\n ['timed_out', 'stopped'],\n ['failed', 'error'],\n])\n\n/** Statuses the API no longer counts as live. `getById` reports these as gone. */\nconst ENDED_STATUSES: ReadonlySet<string> = new Set(['stopped', 'failed', 'terminated', 'timed_out'])\n\n/** Runtime IDs are UUIDs. A string of any other shape cannot name a runtime. */\nconst RUNTIME_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\nfunction isNotFound(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { status?: unknown }).status === 404\n )\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction validateEnvironment(\n environment: Record<string, string> | undefined,\n): Record<string, string> {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(environment ?? {})) {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(name)}`)\n }\n result[name] = String(value)\n }\n return result\n}\n\n/** Convert a millisecond timeout to whole seconds. Zero is allowed. */\nfunction toTimeoutSeconds(ms: number, what: string): number {\n if (!Number.isFinite(ms) || ms < 0) {\n throw new Error(`GravixLayer ${what} must be a non-negative finite number of milliseconds`)\n }\n return Math.ceil(ms / 1000)\n}\n\nfunction nonempty(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed === '' ? undefined : trimmed\n}\n\nfunction resolveClientOptions(config: GravixLayerConfig): ResolvedClientOptions {\n const apiKey = (config.apiKey ?? process.env.GRAVIXLAYER_API_KEY)?.trim()\n if (!apiKey) {\n throw new Error(\n 'GravixLayer requires an API key. Pass `apiKey` or set the `GRAVIXLAYER_API_KEY` environment variable. Get a key at https://gravixlayer.ai .',\n )\n }\n\n const maxRetries = config.maxRetries ?? 0\n if (!Number.isInteger(maxRetries) || maxRetries < 0) {\n throw new Error('GravixLayer maxRetries must be a non-negative integer')\n }\n\n const resolved: ResolvedClientOptions = {\n apiKey,\n maxRetries,\n http2: config.http2 ?? true,\n }\n\n const baseUrl = nonempty(config.baseUrl ?? process.env.GRAVIXLAYER_BASE_URL)\n if (baseUrl !== undefined) resolved.baseUrl = baseUrl\n\n const cloud = nonempty(config.cloud ?? process.env.GRAVIXLAYER_CLOUD)\n if (cloud !== undefined) resolved.cloud = cloud\n\n const region = nonempty(config.region ?? process.env.GRAVIXLAYER_REGION)\n if (region !== undefined) resolved.region = region\n\n if (config.timeout !== undefined) {\n if (!Number.isFinite(config.timeout) || config.timeout < 0) {\n throw new Error('GravixLayer timeout must be a non-negative finite number of milliseconds')\n }\n resolved.timeout = config.timeout\n }\n\n return resolved\n}\n\nfunction clientIdentity(options: ResolvedClientOptions): string {\n return JSON.stringify([\n options.apiKey,\n options.baseUrl ?? null,\n options.cloud ?? null,\n options.region ?? null,\n options.timeout ?? null,\n options.maxRetries,\n options.http2,\n ])\n}\n\nfunction getClient(config: GravixLayerConfig): GravixLayer {\n const cached = clientsByConfig.get(config)\n if (\n cached &&\n cached.config.apiKey === config.apiKey &&\n cached.config.baseUrl === config.baseUrl &&\n cached.config.cloud === config.cloud &&\n cached.config.region === config.region &&\n cached.config.timeout === config.timeout &&\n cached.config.maxRetries === config.maxRetries &&\n cached.config.http2 === config.http2 &&\n // env is only consulted when the matching config field is unset\n (config.apiKey !== undefined || process.env.GRAVIXLAYER_API_KEY === cached.env[0]) &&\n (config.baseUrl !== undefined || process.env.GRAVIXLAYER_BASE_URL === cached.env[1]) &&\n (config.cloud !== undefined || process.env.GRAVIXLAYER_CLOUD === cached.env[2]) &&\n (config.region !== undefined || process.env.GRAVIXLAYER_REGION === cached.env[3])\n ) {\n return cached.client\n }\n const options = resolveClientOptions(config)\n const key = clientIdentity(options)\n let client = clients.get(key)\n if (!client) {\n client = new GravixLayer({\n apiKey: options.apiKey,\n ...(options.baseUrl !== undefined ? { baseUrl: options.baseUrl } : {}),\n ...(options.cloud !== undefined ? { cloud: options.cloud } : {}),\n ...(options.region !== undefined ? { region: options.region } : {}),\n ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),\n maxRetries: options.maxRetries,\n http2: options.http2,\n })\n clients.set(key, client)\n }\n clientsByConfig.set(config, {\n client,\n config: {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n cloud: config.cloud,\n region: config.region,\n timeout: config.timeout,\n maxRetries: config.maxRetries,\n http2: config.http2,\n },\n env: [\n process.env.GRAVIXLAYER_API_KEY,\n process.env.GRAVIXLAYER_BASE_URL,\n process.env.GRAVIXLAYER_CLOUD,\n process.env.GRAVIXLAYER_REGION,\n ],\n })\n return client\n}\n\n/**\n * The SDK keeps a small HTTP/2 session pool per origin: a burst spreads over\n * a handful of connections whose handshakes run in parallel, while a quiet\n * caller keeps one session. `maxRetries: 0` keeps a refused create from\n * sleeping inside the caller's timer. `connect()` is intentionally not\n * called: it issues its own request and would compete with create.\n *\n * A boot can outlast the client's 60-second default, so create gets its own\n * HTTP deadline — longer than a slow boot and shorter than the benchmark's\n * 120s create budget. It is sent as `requestTimeoutMs`: `timeout` on create\n * options is the sandbox lifetime in seconds, so putting the budget there\n * would store a multi-day lifetime. An explicit provider `timeout` is kept\n * as the caller's cap. It does not add latency on a fast create; it only\n * releases the HTTP/2 stream if a boot never returns. `0` would hold that\n * stream until the process exits.\n */\nconst CREATE_HTTP_TIMEOUT_MS = 180_000\n\n// `files/write` carries content inside a JSON string body, capped server-side\n// at 2 MiB; escapes (`\\\"`, `\\\\`, `\\n`, control chars) inflate it past raw\n// UTF-8 length, so writes switch to the binary `upload` endpoint with\n// headroom under the cap.\nconst FILE_WRITE_JSON_MAX_BYTES = 1024 * 1024\n\n/** In-flight or completed publish, so concurrent getUrl calls share one request. */\nconst publishedUrls = new WeakMap<Runtime, Map<number, Promise<string>>>()\n\n/** A status this version does not know is reported as stopped, never as running. */\nfunction mapStatus(status: string): SandboxInfo['status'] {\n return SANDBOX_STATUS.get(status) ?? 'stopped'\n}\n\nfunction parseCreatedAt(startedAt: string | undefined): Date {\n if (startedAt) {\n const date = new Date(startedAt)\n if (!Number.isNaN(date.getTime())) return date\n }\n return new Date()\n}\n\nfunction leaseTimeoutMs(startedAt: string | undefined, timeoutAt: string | undefined): number {\n if (!startedAt || !timeoutAt) return 0\n const start = new Date(startedAt).getTime()\n const end = new Date(timeoutAt).getTime()\n if (!Number.isFinite(start) || !Number.isFinite(end)) return 0\n const delta = end - start\n return delta > 0 ? delta : 0\n}\n\nfunction rememberTimeout(sandbox: Runtime, timeoutMs: number | undefined): Runtime {\n if (timeoutMs !== undefined) createTimeoutMs.set(sandbox, timeoutMs)\n return sandbox\n}\n\nfunction bindRuntime(client: GravixLayer, info: RuntimeInfo): Runtime {\n return new Runtime(client.runtime, info)\n}\n\nasync function publishedUrl(sandbox: Runtime, port: number): Promise<string> {\n let ports = publishedUrls.get(sandbox)\n const existing = ports?.get(port)\n if (existing) return existing\n\n const pending = sandbox.service(port).then((handle) => {\n if (!handle.url) {\n throw new Error(`GravixLayer did not return a URL for port ${port}.`)\n }\n return handle.url\n })\n if (!ports) {\n ports = new Map()\n publishedUrls.set(sandbox, ports)\n }\n ports.set(port, pending)\n try {\n return await pending\n } catch (error) {\n ports.delete(port)\n throw error\n }\n}\n\nasync function runCommand(\n sandbox: Runtime,\n command: string,\n options: RunCommandOptions = {},\n): Promise<CommandResult> {\n const started = performance.now()\n\n if (options.background && (options.onStdout || options.onStderr)) {\n throw new Error('runCommand with streaming callbacks does not support background mode.')\n }\n\n const environment = validateEnvironment(options.env)\n const opts: {\n workingDir?: string\n environment?: Record<string, string>\n timeout?: number\n background?: boolean\n onStdout?: (chunk: string) => void\n onStderr?: (chunk: string) => void\n } = {}\n\n if (options.cwd) opts.workingDir = options.cwd\n if (Object.keys(environment).length > 0) opts.environment = environment\n if (options.timeout !== undefined) {\n opts.timeout = toTimeoutSeconds(options.timeout, 'command timeout')\n }\n if (options.onStdout) opts.onStdout = options.onStdout\n if (options.onStderr) opts.onStderr = options.onStderr\n\n if (options.background) {\n await sandbox.runCmd(command, { ...opts, background: true })\n return { stdout: '', stderr: '', exitCode: 0, durationMs: elapsedMs(started) }\n }\n\n const result = await sandbox.runCmd(command, opts)\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n durationMs:\n typeof result.durationMs === 'number' && Number.isFinite(result.durationMs)\n ? Math.max(0, result.durationMs)\n : elapsedMs(started),\n }\n}\n\nfunction elapsedMs(started: number): number {\n return Math.max(0, Math.round(performance.now() - started))\n}\n\nconst createGravixLayerProvider = defineProvider<\n Runtime,\n GravixLayerConfig,\n GravixLayerTemplate,\n GravixLayerSnapshot\n>({\n name: 'gravixlayer',\n sizes: (config, profile, options) => {\n if (options?.templateId !== undefined || options?.snapshotId !== undefined || options?.sandboxId !== undefined || nonempty(options?.image)) {\n return { status: 'unsupported', reason: 'A GravixLayer template or snapshot fixes CPU and memory; drop templateId/image/snapshotId/sandboxId to boot the standard size template.' }\n }\n const templateId = sizeTemplateOf(config, profile.sizeClass)\n if (!templateId) {\n return { status: 'unknown', reason: 'No GravixLayer size template is set up for this standard shape.' }\n }\n return { status: 'supported', nativeOptions: { templateId } }\n },\n methods: {\n instances: {\n create: async (config: GravixLayerConfig, options: CreateInstanceOptions = {}) => {\n const template = nonempty(options.templateId)\n // `image` is a template name: the template built from that image.\n // Same source as `templateId`, so a differing pair is a conflict.\n const image = nonempty(options.image)\n if (template && image && template !== image) {\n throw new Error('`image` and `templateId` name two different templates; pass one')\n }\n const source = template ?? image\n if (source && options.snapshotId) {\n throw new Error('A runtime starts from a template or a snapshot, not both')\n }\n\n const envVars = validateEnvironment(options.envs)\n const client = getClient(config)\n\n const body: {\n template?: string\n snapshot?: string\n envVars?: Record<string, string>\n /** Sandbox lifetime in seconds. */\n timeout?: number\n /** HTTP deadline for this request, in milliseconds. */\n requestTimeoutMs?: number\n metadata?: Record<string, unknown>\n cloud?: string\n region?: string\n mounts?: Array<{ kind: 'bucket'; bucket: string; path: string; mode: 'ro' | 'rw' }>\n signal?: AbortSignal\n } = {}\n\n if (options.snapshotId) {\n body.snapshot = options.snapshotId\n } else if (source) {\n body.template = source\n }\n\n if (Object.keys(envVars).length > 0) body.envVars = envVars\n\n if (options.timeout !== undefined) {\n body.timeout = toTimeoutSeconds(options.timeout, 'sandbox timeout')\n }\n\n if (isPlainObject(options.metadata)) {\n body.metadata = options.metadata\n }\n\n // Unified mounts → gravixlayer's [{kind:'bucket',bucket,path,mode}] wire\n // shape; buckets are created via `provider.volume`/`compute.volume`.\n const volumes = options.volumes\n if (isUnifiedVolumeMounts(volumes) && volumes.length > 0) {\n body.mounts = volumes.map((m) => ({\n kind: 'bucket' as const,\n bucket: resolveVolumeRef(m.volume).id ?? resolveVolumeRef(m.volume).name ?? '',\n path: m.mountPath,\n mode: m.readOnly ? 'ro' : 'rw',\n }))\n }\n\n if (typeof options.cloud === 'string') body.cloud = options.cloud\n if (typeof options.region === 'string') body.region = options.region\n if (options.signal) body.signal = options.signal\n if (!options.snapshotId && config.timeout === undefined) {\n body.requestTimeoutMs = CREATE_HTTP_TIMEOUT_MS\n }\n\n let sandbox: Runtime\n try {\n sandbox = await client.runtime.create(body)\n } catch (error) {\n const notBuilt = missingSizeTemplate(config, options.templateId, error)\n if (notBuilt) throw Object.assign(new Error(notBuilt), { status: 404, cause: error })\n if (image && !template && isNotFound(error)) {\n throw Object.assign(new Error(\n `GravixLayer template '${image}' is not available on this project; build it with \\`template.create\\` or pass an existing \\`templateId\\``,\n ), { status: 404, cause: error })\n }\n throw error\n }\n // Report the lease the runtime actually got: seconds, rounded up.\n rememberTimeout(\n sandbox,\n body.timeout === undefined ? undefined : body.timeout * 1000,\n )\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n },\n\n getById: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n if (!RUNTIME_ID.test(sandboxId)) return null\n try {\n const sandbox = await client.runtime.get(sandboxId)\n if (ENDED_STATUSES.has(sandbox.status)) return null\n return { instance: sandbox, instanceId: sandbox.runtimeId }\n } catch (error) {\n if (isNotFound(error)) return null\n throw error\n }\n },\n\n list: async (config: GravixLayerConfig) => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const sandboxes: Array<{ instance: Runtime; instanceId: string }> = []\n const seen = new Set<string>()\n\n for (;;) {\n const page = await client.runtime.list({ limit: pageSize, offset })\n const marker = page.runtimes[0]?.runtimeId\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const info of page.runtimes) {\n if (!info.runtimeId) continue\n // The list payload is enough to bind a handle. A follow-up get\n // per row would add one round trip per runtime.\n const sandbox = bindRuntime(client, info)\n sandboxes.push({ instance: sandbox, instanceId: sandbox.runtimeId })\n }\n offset += page.runtimes.length\n if (\n page.runtimes.length < pageSize ||\n !Number.isFinite(page.total) ||\n offset >= page.total\n ) {\n break\n }\n }\n\n return sandboxes\n },\n\n destroy: async (config: GravixLayerConfig, sandboxId: string) => {\n const client = getClient(config)\n try {\n await client.runtime.kill(sandboxId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n\n runCommand,\n\n streamCommand: runCommand,\n\n getInfo: async (sandbox: Runtime): Promise<SandboxInfo> => {\n await sandbox.refresh()\n const info = sandbox.info\n return {\n id: sandbox.runtimeId,\n provider: 'gravixlayer',\n status: mapStatus(info.status),\n createdAt: parseCreatedAt(info.startedAt),\n timeout:\n createTimeoutMs.get(sandbox) ?? leaseTimeoutMs(info.startedAt, info.timeoutAt),\n ...(info.metadata !== undefined ? { metadata: info.metadata } : {}),\n }\n },\n\n getUrl: async (sandbox: Runtime, options: { port: number; protocol?: string }) => {\n const { port } = options\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`Invalid port: ${port}`)\n }\n const value = await publishedUrl(sandbox, port)\n if (!options.protocol) return value\n const url = new URL(value)\n url.protocol = `${options.protocol.replace(/:$/, '')}:`\n return url.toString()\n },\n\n getInstance: (sandbox: Runtime) => sandbox,\n\n attachVolume: async (instance: Runtime, volume, mountPath: string) => {\n const ref = resolveVolumeRef(volume)\n await instance.mounts.attach({\n kind: 'bucket',\n bucket: ref.id ?? ref.name ?? '',\n path: mountPath,\n mode: 'rw',\n })\n },\n\n detachVolume: async (instance: Runtime, volume, mountPath?: string) => {\n const ref = resolveVolumeRef(volume)\n const id = ref.id ?? ref.name\n const { mounts } = await instance.mounts.list()\n const mount = mounts.find(\n (m: { id?: string; targetId?: string; mountPath?: string }) =>\n id !== undefined\n ? (m.targetId === id || m.id === id) && (mountPath === undefined || m.mountPath === mountPath)\n : m.mountPath === mountPath,\n )\n if (mount?.id) await instance.mounts.detach(mount.id)\n },\n\n pause: async (sandbox: Runtime) => {\n await sandbox.pause()\n },\n\n resume: async (sandbox: Runtime) => {\n await sandbox.resume()\n },\n\n // Pause freezes memory: files and running processes survive resume.\n pauseCapabilities: { memory: true },\n\n filesystem: {\n readFile: async (sandbox: Runtime, path: string): Promise<string> => {\n return sandbox.file.downloadText(path)\n },\n\n writeFile: async (sandbox: Runtime, path: string, content: string): Promise<void> => {\n // `files/write` carries content inside a JSON string body capped\n // server-side; escapes inflate it past raw UTF-8 length, so measure\n // the encoded form. Larger payloads stream through binary upload.\n const jsonBytes = new TextEncoder().encode(JSON.stringify(content)).byteLength\n if (jsonBytes > FILE_WRITE_JSON_MAX_BYTES) {\n await sandbox.file.upload(path, new TextEncoder().encode(content))\n } else {\n await sandbox.file.write(path, content)\n }\n },\n\n mkdir: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.createDirectory(path)\n },\n\n readdir: async (sandbox: Runtime, path: string): Promise<FileEntry[]> => {\n const listing = await sandbox.file.list(path)\n return listing.files.map((entry) => {\n const fileEntry: FileEntry = {\n name: entry.name,\n type: entry.isDir ? 'directory' : 'file',\n size: entry.size,\n }\n const modified = new Date(entry.modifiedAt)\n if (!Number.isNaN(modified.getTime())) {\n fileEntry.modified = modified\n }\n return fileEntry\n })\n },\n\n exists: async (sandbox: Runtime, path: string): Promise<boolean> => {\n return (await sandbox.file.getInfo(path)).exists\n },\n\n remove: async (sandbox: Runtime, path: string): Promise<void> => {\n await sandbox.file.delete(path)\n },\n },\n },\n\n snapshot: {\n // Hot snapshots (the default) keep the whole rootfs, `/tmp` included,\n // and running processes. The source keeps running.\n capabilities: { scope: 'rootfs', memory: true, destroysSource: false },\n\n create: async (\n config: GravixLayerConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions,\n ): Promise<GravixLayerSnapshot> => {\n const name = nonempty(options?.name) ?? defaultSnapshotName()\n const client = getClient(config)\n const description =\n options &&\n 'description' in options &&\n typeof (options as { description?: unknown }).description === 'string'\n ? (options as { description: string }).description\n : undefined\n const kind = snapshotKind(options)\n const snapshot = await client.snapshots.create(sandboxId, name, {\n kind,\n ...(description !== undefined ? { description } : {}),\n })\n return {\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListSnapshotsOptions,\n ): Promise<GravixLayerSnapshot[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const snapshots: GravixLayerSnapshot[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - snapshots.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.snapshots.list({\n limit: take,\n offset,\n ...(options?.sandboxId ? { runtimeId: options.sandboxId } : {}),\n })\n\n const marker = page.snapshots[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n\n for (const snapshot of page.snapshots) {\n snapshots.push({\n id: snapshot.id,\n provider: 'gravixlayer',\n createdAt: new Date(snapshot.createdAt),\n metadata: {\n name: snapshot.name,\n state: snapshot.state,\n kind: snapshot.kind,\n },\n })\n if (limit !== undefined && snapshots.length >= limit) return snapshots\n }\n\n offset += page.snapshots.length\n if (page.snapshots.length === 0 || offset >= page.total) break\n if (page.snapshots.length < take) break\n }\n\n return snapshots\n },\n\n delete: async (config: GravixLayerConfig, snapshotId: string) => {\n const client = getClient(config)\n try {\n await client.snapshots.delete(snapshotId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n template: {\n create: async (\n config: GravixLayerConfig,\n options: GravixLayerCreateTemplateOptions,\n ): Promise<GravixLayerTemplate> => {\n const name = nonempty(options.name)\n if (!name) {\n throw new Error('GravixLayer templates require a name.')\n }\n\n const fromImage = nonempty(options.fromImage)\n const dockerfile = nonempty(options.dockerfile)\n if (!fromImage && !dockerfile) {\n throw new Error(\n 'A GravixLayer template build needs `fromImage` or `dockerfile`. Select an existing template with `templateId` on sandbox create.',\n )\n }\n if (fromImage && dockerfile) {\n throw new Error('Specify either fromImage or dockerfile, not both.')\n }\n\n const builder = new TemplateBuilder(name, options.description ?? '')\n if (fromImage) builder.fromImage(fromImage)\n if (dockerfile) builder.dockerfile(dockerfile)\n\n if (Array.isArray(options.run)) {\n for (const command of options.run) {\n if (typeof command === 'string' && command.trim() !== '') {\n builder.run(command)\n }\n }\n }\n\n if (typeof options.vcpu === 'number' && Number.isFinite(options.vcpu) && options.vcpu > 0) {\n builder.vcpu(options.vcpu)\n }\n if (\n typeof options.memoryMb === 'number' &&\n Number.isFinite(options.memoryMb) &&\n options.memoryMb > 0\n ) {\n builder.memory(options.memoryMb)\n }\n if (\n typeof options.diskMb === 'number' &&\n Number.isFinite(options.diskMb) &&\n options.diskMb > 0\n ) {\n builder.disk(options.diskMb)\n }\n\n if (options.metadata) {\n const tags: Record<string, string> = {}\n for (const [key, value] of Object.entries(options.metadata)) {\n if (typeof value === 'string') tags[key] = value\n }\n if (Object.keys(tags).length > 0) builder.tags(tags)\n }\n\n const client = getClient(config)\n const status = await client.templates.buildAndWait(builder)\n return {\n id: status.templateId,\n provider: 'gravixlayer',\n name,\n createdAt: new Date(),\n }\n },\n\n list: async (\n config: GravixLayerConfig,\n options?: ListTemplatesOptions,\n ): Promise<GravixLayerTemplate[]> => {\n const client = getClient(config)\n const pageSize = 100\n let offset = 0\n const templates: GravixLayerTemplate[] = []\n const limit = options?.limit\n const seen = new Set<string>()\n\n for (;;) {\n const take =\n limit === undefined ? pageSize : Math.min(pageSize, Math.max(0, limit - templates.length))\n if (limit !== undefined && take === 0) break\n\n const page = await client.templates.list({ limit: take, offset })\n const marker = page.templates[0]?.id\n if (marker && seen.has(marker)) break\n if (marker) seen.add(marker)\n for (const template of page.templates) {\n templates.push({\n id: template.id,\n provider: 'gravixlayer',\n name: template.name,\n createdAt: new Date(template.createdAt),\n })\n if (limit !== undefined && templates.length >= limit) return templates\n }\n\n offset += page.templates.length\n // TemplateListResponse has no total; stop on a short/empty page.\n if (page.templates.length === 0 || page.templates.length < take) break\n }\n\n return templates\n },\n\n delete: async (config: GravixLayerConfig, templateId: string) => {\n const client = getClient(config)\n try {\n await client.templates.delete(templateId)\n } catch (error) {\n if (!isNotFound(error)) throw error\n }\n },\n },\n\n // GravixLayer \"volumes\" are managed object-storage buckets mounted into a\n // runtime (`mounts: [{kind:'bucket'}]` at create, or runtime.attachVolume).\n volume: {\n create: async (config: GravixLayerConfig, options: CreateVolumeOptions) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.create(options.name)\n return { id: bucket.id, name: bucket.name, native: bucket }\n },\n\n get: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n return bucket ? { id: bucket.id, name: bucket.name, native: bucket } : null\n },\n\n list: async (config: GravixLayerConfig, options?: ListVolumesOptions) => {\n const client = getClient(config)\n const page = await client.storage.buckets.list()\n const buckets = page.buckets ?? []\n const limited = options?.limit === undefined ? buckets : buckets.slice(0, options.limit)\n return limited.map((b: { id?: string; name?: string }) => ({ id: b.id, name: b.name, native: b }))\n },\n\n delete: async (config: GravixLayerConfig, idOrName: string) => {\n const client = getClient(config)\n const bucket = await client.storage.buckets.get(idOrName).catch((err: unknown) => {\n if ((err as { status?: number })?.status === 404) return null\n throw err\n })\n if (!bucket) return\n await client.storage.buckets.delete(bucket.id ?? idOrName)\n },\n },\n },\n})\n\n/** Preserve GravixLayer-specific template.create options on the public provider. */\nexport function gravixlayer(config: GravixLayerConfig = {}): GravixLayerProvider {\n const provider = createGravixLayerProvider(config)\n return { ...provider, template: provider.template! }\n}\n"],"mappings":";AASA,SAAS,gBAAgB,uBAAuB,wBAAwB;AAmBxE,SAAS,aAAa,SAAS,uBAAyC;AAsBjE,IAAM,6BAAmF,OAAO,OAAO;AAAA,EAC5G,IAAI;AAAA,EACJ,IAAI;A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F;AAAA,EACF;AACF,CAAC;AAGM,SAAS,YAAY,SAA4B,CAAC,GAAwB;AAC/E,QAAM,WAAW,0BAA0B,MAAM;AACjD,SAAO,EAAE,GAAG,UAAU,UAAU,SAAS,SAAU;AACrD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/gravixlayer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "GravixLayer provider for ComputeSDK — cloud runtimes with a native filesystem, live command streaming, and snapshots",
|
|
5
5
|
"author": "Gravix Layer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"gravixlayer": "^0.1.51",
|
|
41
|
-
"computesdk": "
|
|
42
|
-
"
|
|
41
|
+
"@computesdk/provider": "2.1.26",
|
|
42
|
+
"computesdk": "4.1.20"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^20.0.0",
|