UNPKG

@luxorai/sandbox

Version:

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

78 lines • 3.71 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkspaceClient = void 0; const connect_1 = require("@connectrpc/connect"); const connect_node_1 = require("@connectrpc/connect-node"); const auth_js_1 = require("./auth.js"); const constants_js_1 = require("./constants.js"); const env_js_1 = require("./env.js"); const http2_drain_js_1 = require("./http2-drain.js"); const pb = __importStar(require("./internal/proto/tenki/cloud/workspace/v1beta1/secrets_pb.js")); const variablesPb = __importStar(require("./internal/proto/tenki/cloud/workspace/v1beta1/variables_pb.js")); const workspace_secrets_js_1 = require("./workspace-secrets.js"); const workspace_variables_js_1 = require("./workspace-variables.js"); /** Owns workspace scope, authentication, and connection lifetime. */ class WorkspaceClient { secrets; variables; sessionManager; constructor(options = {}) { const token = (0, auth_js_1.resolveAuthToken)(options.authToken, options.apiKey); const baseUrl = options.baseUrl || (0, env_js_1.readEnv)(constants_js_1.CLOUD_API_URL_ENVS) || constants_js_1.DEFAULT_BASE_URL; this.sessionManager = options.transport ? undefined : new http2_drain_js_1.DrainingHttp2SessionManager(baseUrl, undefined, options.rootCertificates !== undefined ? { ca: options.rootCertificates } : undefined); const transport = options.transport ?? (0, connect_node_1.createGrpcTransport)({ baseUrl, defaultTimeoutMs: options.timeoutMs ?? 30_000, sessionManager: this.sessionManager, interceptors: [(0, auth_js_1.createAuthInterceptor)(token)], }); const workspaceId = options.workspaceId ?? ""; const secrets = (0, connect_1.createClient)(pb.WorkspaceSecretsService, transport); this.secrets = new workspace_secrets_js_1.Secrets(workspaceId, secrets); this.variables = new workspace_variables_js_1.Variables(workspaceId, (0, connect_1.createClient)(variablesPb.WorkspaceVariablesService, transport), secrets); } async close() { await this.sessionManager?.abort(); } async [Symbol.asyncDispose]() { await this.close(); } } exports.WorkspaceClient = WorkspaceClient; //# sourceMappingURL=workspace.js.map