UNPKG

@luxorai/sandbox

Version:

TypeScript SDK for Luxor Sandbox: cloud sandboxes (microVMs) for AI agents on Luxor Agent Cloud

60 lines • 2.17 kB
import { timestampDate } from "@bufbuild/protobuf/wkt"; import { SnapshotState as ProtoSnapshotState, SnapshotType as ProtoSnapshotType, } from "./internal/proto/tenki/sandbox/v1/sandbox_pb.js"; export function snapshotStateFromProto(state) { switch (state) { case ProtoSnapshotState.CREATING: return "CREATING"; case ProtoSnapshotState.READY: return "READY"; case ProtoSnapshotState.FAILED: return "FAILED"; case ProtoSnapshotState.DELETING: return "DELETING"; case ProtoSnapshotState.DELETED: return "DELETED"; default: return "UNSPECIFIED"; } } export function snapshotIsReady(state) { return state === "READY"; } export function snapshotIsTerminal(state) { return state === "FAILED" || state === "DELETED"; } export function snapshotTypeFromProto(type) { switch (type) { case ProtoSnapshotType.USER: return "USER"; case ProtoSnapshotType.PAUSE: return "PAUSE"; case ProtoSnapshotType.TEMPLATE: return "TEMPLATE"; default: return "UNSPECIFIED"; } } export function snapshotFromProto(proto) { return { id: proto.id, sessionId: proto.sessionId, workspaceId: proto.workspaceId ?? "", name: proto.name ?? "", state: snapshotStateFromProto(proto.state), sizeBytes: Number(proto.sizeBytes), compressedBytes: Number(proto.compressedBytes), memoryBytes: Number(proto.memoryBytes), baseImageId: proto.baseImageId, createdAt: proto.createdAt ? timestampDate(proto.createdAt) : new Date(0), expiresAt: proto.expiresAt ? timestampDate(proto.expiresAt) : undefined, tags: [...(proto.tags ?? [])], type: snapshotTypeFromProto(proto.type), cpuCores: proto.cpuCores, memoryMb: proto.memoryMb, diskSizeGb: proto.diskSizeGb, rawImageAvailable: proto.rawImageAvailable, hasRuntimeSecrets: proto.hasRuntimeSecrets, failureReason: proto.failureReason || undefined, }; } //# sourceMappingURL=snapshot.js.map