UNPKG

@luxorai/sandbox

Version:

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

166 lines • 6.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registryKindFromProto = registryKindFromProto; exports.registryKindToProto = registryKindToProto; exports.registryVisibilityFromProto = registryVisibilityFromProto; exports.registryVisibilityToProto = registryVisibilityToProto; exports.registrySortToProto = registrySortToProto; exports.registryTagFromProto = registryTagFromProto; exports.registryImageFromProto = registryImageFromProto; exports.registryImageSummaryFromProto = registryImageSummaryFromProto; exports.registryImageDetailFromProto = registryImageDetailFromProto; exports.resolvedRegistryRefFromProto = resolvedRegistryRefFromProto; exports.registryShareGrantFromProto = registryShareGrantFromProto; const protobuf_1 = require("@bufbuild/protobuf"); const wkt_1 = require("@bufbuild/protobuf/wkt"); const registry_pb_js_1 = require("./internal/proto/tenki/sandbox/v1/registry_pb.js"); const secret_file_pb_js_1 = require("./internal/proto/tenki/sandbox/v1/secret_file_pb.js"); function registryKindFromProto(kind) { switch (kind) { case registry_pb_js_1.RegistryImageKind.SNAPSHOT: return "snapshot"; case registry_pb_js_1.RegistryImageKind.TEMPLATE: default: return "template"; } } function registryKindToProto(kind) { switch (kind) { case "snapshot": return registry_pb_js_1.RegistryImageKind.SNAPSHOT; case "template": return registry_pb_js_1.RegistryImageKind.TEMPLATE; } } function registryVisibilityFromProto(visibility) { switch (visibility) { case registry_pb_js_1.RegistryVisibility.PUBLIC: return "public"; case registry_pb_js_1.RegistryVisibility.SHARED: return "shared"; case registry_pb_js_1.RegistryVisibility.PRIVATE: default: return "private"; } } function registryVisibilityToProto(visibility) { switch (visibility) { case "public": return registry_pb_js_1.RegistryVisibility.PUBLIC; case "shared": return registry_pb_js_1.RegistryVisibility.SHARED; case "private": return registry_pb_js_1.RegistryVisibility.PRIVATE; } } function registrySortToProto(sort) { switch (sort) { case "name": return registry_pb_js_1.RegistrySortBy.NAME; case "updated_at": return registry_pb_js_1.RegistrySortBy.UPDATED_AT; } } function registryTagFromProto(proto) { if (!proto) return undefined; return { id: proto.id, imageId: proto.imageId, tag: proto.tag, snapshotId: proto.snapshotId, ref: proto.ref, updatedAt: proto.updatedAt ? (0, wkt_1.timestampDate)(proto.updatedAt) : new Date(0), }; } function registryImageFromProto(proto) { return { id: proto.id, workspaceId: proto.workspaceId ?? "", workspaceSlug: proto.workspaceSlug, name: proto.name, kind: registryKindFromProto(proto.kind), visibility: registryVisibilityFromProto(proto.visibility), title: proto.title, description: proto.description, labels: [...(proto.labels ?? [])], sourceTemplateId: proto.sourceTemplateId, sourceSnapshotId: proto.sourceSnapshotId, tags: (proto.tags ?? []).map((tag) => registryTagFromProto(tag)), createdAt: proto.createdAt ? (0, wkt_1.timestampDate)(proto.createdAt) : new Date(0), updatedAt: proto.updatedAt ? (0, wkt_1.timestampDate)(proto.updatedAt) : new Date(0), changesNotYetPublished: proto.changesNotYetPublished, }; } function registryImageSummaryFromProto(proto) { return { id: proto.id, workspaceId: proto.workspaceId ?? "", workspaceSlug: proto.workspaceSlug, name: proto.name, kind: registryKindFromProto(proto.kind), visibility: registryVisibilityFromProto(proto.visibility), labels: [...(proto.labels ?? [])], tags: (proto.tags ?? []).map((tag) => registryTagFromProto(tag)), latestSnapshotId: proto.latestSnapshotId, latestRef: proto.latestRef, updatedAt: proto.updatedAt ? (0, wkt_1.timestampDate)(proto.updatedAt) : new Date(0), changesNotYetPublished: proto.changesNotYetPublished, }; } function registryImageDetailFromProto(proto) { return { image: proto?.image ? registryImageFromProto(proto.image) : undefined, runtimeSecretEnv: { ...(proto?.runtimeSecretEnv ?? {}) }, runtimeSecretPolicies: [...(proto?.runtimeSecretPolicies ?? [])], runtimeSecretFiles: (proto?.runtimeSecretFiles ?? []).map((file) => (0, protobuf_1.toJson)(secret_file_pb_js_1.RuntimeSecretFileSchema, file)), runtimeVariableEnv: { ...(proto?.runtimeVariableEnv ?? {}) }, resolvedSnapshotId: proto?.resolvedSnapshotId, resolvedRef: proto?.resolvedRef, workspaceActive: proto?.workspaceActive ?? false, tombstoned: proto?.tombstoned ?? false, maskedEnvVarKeys: [...(proto?.maskedEnvVarKeys ?? [])], metadata: { ...(proto?.metadata ?? {}) }, envVars: { ...(proto?.envVars ?? {}) }, }; } function resolvedRegistryRefFromProto(proto) { return { imageId: proto?.imageId ?? "", owningWorkspaceId: proto?.owningWorkspaceId ?? "", owningWorkspaceSlug: proto?.owningWorkspaceSlug ?? "", imageName: proto?.imageName ?? "", snapshotId: proto?.snapshotId, resolvedRef: resolvedRegistryRefImage(proto), kind: registryKindFromProto(proto?.kind ?? registry_pb_js_1.RegistryImageKind.UNSPECIFIED), visibility: registryVisibilityFromProto(proto?.visibility ?? registry_pb_js_1.RegistryVisibility.UNSPECIFIED), }; } function registryShareGrantFromProto(proto) { if (!proto) return undefined; return { id: proto.id, imageId: proto.imageId, ownerWorkspaceId: proto.ownerWorkspaceId, targetWorkspaceId: proto.targetWorkspaceId, currentSnapshotId: proto.currentSnapshotId, grantedViaTokenId: proto.grantedViaTokenId, acceptedBy: proto.acceptedBy, acceptedAt: proto.acceptedAt ? (0, wkt_1.timestampDate)(proto.acceptedAt) : new Date(0), revokedAt: proto.revokedAt ? (0, wkt_1.timestampDate)(proto.revokedAt) : undefined, followMode: proto.followMode, followTag: proto.followTag, }; } function resolvedRegistryRefImage(proto) { if (!proto) return ""; const base = `${proto.owningWorkspaceSlug}/${proto.imageName}`; if (proto.tag) return `${base}:${proto.tag}`; if (proto.snapshotId) return `${base}@${proto.snapshotId}`; return base; } //# sourceMappingURL=registry.js.map