/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { sandboxCreate } from "../funcs/sandboxCreate.js"; import { sandboxDownloadArchive } from "../funcs/sandboxDownloadArchive.js"; import { sandboxDownloadFile } from "../funcs/sandboxDownloadFile.js"; import { sandboxGet } from "../funcs/sandboxGet.js"; import { sandboxGetBrowserUrl } from "../funcs/sandboxGetBrowserUrl.js"; import { sandboxGetPricing } from "../funcs/sandboxGetPricing.js"; import { sandboxGetUrl } from "../funcs/sandboxGetUrl.js"; import { sandboxGetWorkspace } from "../funcs/sandboxGetWorkspace.js"; import { sandboxList } from "../funcs/sandboxList.js"; import { sandboxProxyBrowserPortRequest } from "../funcs/sandboxProxyBrowserPortRequest.js"; import { sandboxRunCode } from "../funcs/sandboxRunCode.js"; import { sandboxRunCommand } from "../funcs/sandboxRunCommand.js"; import { sandboxSetPricing } from "../funcs/sandboxSetPricing.js"; import { sandboxTerminate } from "../funcs/sandboxTerminate.js"; import { sandboxUploadArchive } from "../funcs/sandboxUploadArchive.js"; import { sandboxUploadFile } from "../funcs/sandboxUploadFile.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; export class Sandbox extends ClientSDK { /** * Create Session * * @remarks * Create a sandbox session and return its public session metadata, session token, and provider. Set `session_kind` to `browser` to start a browser-backed session instead of a standard command/code sandbox. Set `queue_if_full` to `true` to queue the request instead of failing when runner capacity is temporarily unavailable. It does not queue requests for session kinds the deployment does not support. Browser sessions require a Firecracker-backed deployment; standard-only deployments reject them immediately with `browser_sessions_not_enabled`. */ async create( request: operations.CreateSessionRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxCreate( this, request, options, )); } /** * List Sessions * * @remarks * List sandbox sessions visible to the authenticated caller. */ async list( request: operations.ListSessionsRequest, options?: RequestOptions, ): Promise> { return unwrapAsync(sandboxList( this, request, options, )); } /** * Get Session * * @remarks * Return the current state, configuration, and resource allocation for a sandbox session. */ async get( request: operations.GetSessionRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxGet( this, request, options, )); } /** * Get Sandbox Pricing * * @remarks * Current sandbox pricing rate card, keyed by SKU (`standard`, `browser`, `eval-python`). Metered sandbox usage is billed `hours × (per_hour + reserved_memory_GiB × per_gib_hour)`; SKUs without a configured rate accrue no spend. Cluster admins only. */ async getPricing( options?: RequestOptions, ): Promise { return unwrapAsync(sandboxGetPricing( this, options, )); } /** * Set Sandbox Pricing * * @remarks * Replace the sandbox pricing rate card. Full-replace semantics: SKUs omitted from the request become unpriced and accrue no spend. Takes effect on the next meter window without a restart. Cluster admins only. */ async setPricing( request: components.SandboxPricingUpdate, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxSetPricing( this, request, options, )); } /** * Get Browser Session URL * * @remarks * Return the public gateway URL for a browser session's Chrome DevTools Protocol endpoint. Playwright can use this HTTP endpoint directly. For clients that require a WebSocket endpoint, request `json/version` and use its rewritten `webSocketDebuggerUrl`. Insert subpaths before the query string; for example, use `/ports/9222/json/version?session_token=...`. Send the same MKA1 API-key authorization header on the HTTP and WebSocket requests. Standard sessions do not expose a public URL; use the command, code, and workspace operations instead. */ async getBrowserUrl( request: operations.GetBrowserSessionUrlRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxGetBrowserUrl( this, request, options, )); } /** * Get Browser Session URL (Deprecated) * * @remarks * Deprecated compatibility alias for `getBrowserUrl`. Return the public gateway URL for a browser session's Chrome DevTools Protocol endpoint. Standard sessions do not expose a public URL; use the command, code, and workspace operations instead. * * @deprecated method: Use sandbox.getBrowserUrl instead.. Use getBrowserUrl instead. */ async getUrl( request: operations.GetSessionUrlRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxGetUrl( this, request, options, )); } /** * Proxy Browser Port Request * * @remarks * Proxy an HTTP request to an exposed browser-session port through the gateway. Use the URL returned by `GET /sessions/{session_id}/browser-url` as the base. Insert CDP subpaths such as `json/version` or `json/list` before its query string, preserving the `session_token` parameter. This low-level proxy is intended for browser sessions on port `9222` and still requires the normal MKA1 API-key authorization header. */ async proxyBrowserPortRequest( request: operations.ProxyBrowserPortRequestRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxProxyBrowserPortRequest( this, request, options, )); } /** * Run Command * * @remarks * Run a command in the session workspace and return stdout, stderr, exit code, and changed files. */ async runCommand( request: operations.RunCommandRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxRunCommand( this, request, options, )); } /** * Run Code * * @remarks * Execute source code in the session workspace using a supported runtime and return the execution result. */ async runCode( request: operations.RunCodeRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxRunCode( this, request, options, )); } /** * Terminate Session * * @remarks * Stop a sandbox session and release the backing sandbox resources. */ async terminate( request: operations.TerminateSessionRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxTerminate( this, request, options, )); } /** * Get Workspace Manifest * * @remarks * List files currently stored in the session workspace, including paths, sizes, and etags. */ async getWorkspace( request: operations.GetWorkspaceRequest, options?: RequestOptions, ): Promise { return unwrapAsync(sandboxGetWorkspace( this, request, options, )); } /** * Download Workspace File * * @remarks * Download raw bytes from a file in the session workspace. */ async downloadFile( request: operations.DownloadWorkspaceFileRequest, options?: RequestOptions, ): Promise> { return unwrapAsync(sandboxDownloadFile( this, request, options, )); } /** * Upload Workspace File * * @remarks * Upload raw bytes into the session workspace at the given path. */ async uploadFile( request: operations.UploadWorkspaceFileRequest, options?: RequestOptions, ): Promise<{ [k: string]: string }> { return unwrapAsync(sandboxUploadFile( this, request, options, )); } /** * Download Workspace Archive * * @remarks * Download a zip archive containing the selected workspace paths. */ async downloadArchive( request: operations.DownloadWorkspaceArchiveRequest, options?: RequestOptions, ): Promise> { return unwrapAsync(sandboxDownloadArchive( this, request, options, )); } /** * Upload Workspace Archive * * @remarks * Upload a zip archive and extract its files into the session workspace. */ async uploadArchive( request: operations.UploadWorkspaceArchiveRequest, options?: RequestOptions, ): Promise<{ [k: string]: string }> { return unwrapAsync(sandboxUploadArchive( this, request, options, )); } }