@celestoai/sdk 0.1.0 → 0.1.1

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.
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/computers/index.ts
21
+ var computers_exports = {};
22
+ __export(computers_exports, {
23
+ ComputersClient: () => ComputersClient
24
+ });
25
+ module.exports = __toCommonJS(computers_exports);
26
+
27
+ // src/core/config.ts
28
+ var DEFAULT_BASE_URL = "https://api.celesto.ai";
29
+ var buildRequestContext = (config) => ({
30
+ fetch: config.fetch ?? fetch,
31
+ baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
32
+ token: config.token ?? config.apiKey,
33
+ organizationId: config.organizationId,
34
+ userAgent: config.userAgent,
35
+ timeoutMs: config.timeoutMs,
36
+ headers: config.headers
37
+ });
38
+
39
+ // src/core/errors.ts
40
+ var CelestoError = class extends Error {
41
+ constructor(message) {
42
+ super(message);
43
+ this.name = "CelestoError";
44
+ }
45
+ };
46
+ var CelestoApiError = class extends CelestoError {
47
+ constructor(message, status, data, requestId) {
48
+ super(message);
49
+ this.name = "CelestoApiError";
50
+ this.status = status;
51
+ this.data = data;
52
+ this.requestId = requestId;
53
+ }
54
+ };
55
+ var CelestoNetworkError = class extends CelestoError {
56
+ constructor(message, cause) {
57
+ super(message);
58
+ this.name = "CelestoNetworkError";
59
+ this.cause = cause;
60
+ }
61
+ };
62
+
63
+ // src/core/http.ts
64
+ var joinUrl = (baseUrl, path) => {
65
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
66
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
67
+ return `${trimmedBase}${normalizedPath}`;
68
+ };
69
+ var buildQuery = (query) => {
70
+ if (!query) {
71
+ return "";
72
+ }
73
+ const params = new URLSearchParams();
74
+ for (const [key, value] of Object.entries(query)) {
75
+ if (value === void 0 || value === null) {
76
+ continue;
77
+ }
78
+ if (Array.isArray(value)) {
79
+ for (const item of value) {
80
+ params.append(key, String(item));
81
+ }
82
+ continue;
83
+ }
84
+ params.set(key, String(value));
85
+ }
86
+ const serialized = params.toString();
87
+ return serialized ? `?${serialized}` : "";
88
+ };
89
+ var parseResponseBody = async (response) => {
90
+ if (response.status === 204) {
91
+ return void 0;
92
+ }
93
+ const contentType = response.headers.get("content-type") ?? "";
94
+ if (contentType.includes("application/json")) {
95
+ return response.json();
96
+ }
97
+ return response.text();
98
+ };
99
+ var extractErrorMessage = (data, status) => {
100
+ if (data && typeof data === "object") {
101
+ const record = data;
102
+ if (typeof record.detail === "string") {
103
+ return record.detail;
104
+ }
105
+ if (typeof record.message === "string") {
106
+ return record.message;
107
+ }
108
+ if (typeof record.error === "string") {
109
+ return record.error;
110
+ }
111
+ }
112
+ return `Request failed with status ${status}`;
113
+ };
114
+ var request = async (ctx, options) => {
115
+ const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;
116
+ const headers = {
117
+ ...ctx.headers ?? {},
118
+ ...options.headers ?? {}
119
+ };
120
+ if (ctx.token) {
121
+ headers.Authorization = `Bearer ${ctx.token}`;
122
+ }
123
+ if (ctx.organizationId) {
124
+ headers["X-Current-Organization"] = ctx.organizationId;
125
+ }
126
+ if (ctx.userAgent && !headers["User-Agent"]) {
127
+ headers["User-Agent"] = ctx.userAgent;
128
+ }
129
+ const init = {
130
+ method: options.method,
131
+ headers,
132
+ body: void 0,
133
+ signal: options.signal
134
+ };
135
+ if (options.body !== void 0) {
136
+ headers["Content-Type"] = headers["Content-Type"] ?? "application/json";
137
+ init.body = headers["Content-Type"].includes("application/json") ? JSON.stringify(options.body) : options.body;
138
+ }
139
+ let timeoutId;
140
+ let controller;
141
+ if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {
142
+ controller = new AbortController();
143
+ timeoutId = setTimeout(() => controller?.abort(), ctx.timeoutMs);
144
+ init.signal = controller.signal;
145
+ }
146
+ try {
147
+ const response = await ctx.fetch(url, init);
148
+ const data = await parseResponseBody(response);
149
+ if (!response.ok) {
150
+ const message = extractErrorMessage(data, response.status);
151
+ throw new CelestoApiError(message, response.status, data, response.headers.get("x-request-id") ?? void 0);
152
+ }
153
+ return data;
154
+ } catch (err) {
155
+ if (err instanceof CelestoApiError) {
156
+ throw err;
157
+ }
158
+ const error = err instanceof Error ? err : new Error(String(err));
159
+ throw new CelestoNetworkError(error.message, error);
160
+ } finally {
161
+ if (timeoutId) {
162
+ clearTimeout(timeoutId);
163
+ }
164
+ }
165
+ };
166
+
167
+ // src/computers/client.ts
168
+ var toConnection = (payload) => {
169
+ if (!payload) {
170
+ return void 0;
171
+ }
172
+ const out = {};
173
+ if (payload.ssh != null) {
174
+ out.ssh = payload.ssh;
175
+ }
176
+ if (payload.access_url != null) {
177
+ out.accessUrl = payload.access_url;
178
+ }
179
+ return out;
180
+ };
181
+ var toComputerInfo = (payload) => ({
182
+ id: payload.id,
183
+ name: payload.name,
184
+ status: payload.status,
185
+ vcpus: payload.vcpus,
186
+ ramMb: payload.ram_mb,
187
+ image: payload.image,
188
+ connection: toConnection(payload.connection),
189
+ lastError: payload.last_error ?? null,
190
+ createdAt: payload.created_at,
191
+ stoppedAt: payload.stopped_at ?? null
192
+ });
193
+ var toExecResponse = (payload) => ({
194
+ exitCode: payload.exit_code,
195
+ stdout: payload.stdout,
196
+ stderr: payload.stderr
197
+ });
198
+ var computersPath = (path) => `/v1/computers${path}`;
199
+ var pickOverrides = (options) => ({
200
+ headers: options?.headers,
201
+ signal: options?.signal
202
+ });
203
+ var ComputersClient = class {
204
+ constructor(config) {
205
+ this.config = config;
206
+ }
207
+ async create(params = {}, options) {
208
+ const ctx = buildRequestContext(this.config);
209
+ const data = await request(ctx, {
210
+ method: "POST",
211
+ path: computersPath(""),
212
+ body: {
213
+ vcpus: params.cpus ?? 1,
214
+ ram_mb: params.memory ?? 1024,
215
+ image: params.image ?? "ubuntu-desktop-24.04"
216
+ },
217
+ ...pickOverrides(options)
218
+ });
219
+ return toComputerInfo(data);
220
+ }
221
+ async list(options) {
222
+ const ctx = buildRequestContext(this.config);
223
+ const data = await request(ctx, {
224
+ method: "GET",
225
+ path: computersPath(""),
226
+ ...pickOverrides(options)
227
+ });
228
+ return {
229
+ computers: data.computers.map(toComputerInfo),
230
+ count: data.count
231
+ };
232
+ }
233
+ async get(computerId, options) {
234
+ const ctx = buildRequestContext(this.config);
235
+ const data = await request(ctx, {
236
+ method: "GET",
237
+ path: computersPath(`/${encodeURIComponent(computerId)}`),
238
+ ...pickOverrides(options)
239
+ });
240
+ return toComputerInfo(data);
241
+ }
242
+ async exec(computerId, command, params = {}, options) {
243
+ const ctx = buildRequestContext(this.config);
244
+ const data = await request(ctx, {
245
+ method: "POST",
246
+ path: computersPath(`/${encodeURIComponent(computerId)}/exec`),
247
+ body: {
248
+ command,
249
+ timeout: params.timeout ?? 30
250
+ },
251
+ ...pickOverrides(options)
252
+ });
253
+ return toExecResponse(data);
254
+ }
255
+ async stop(computerId, options) {
256
+ const ctx = buildRequestContext(this.config);
257
+ const data = await request(ctx, {
258
+ method: "POST",
259
+ path: computersPath(`/${encodeURIComponent(computerId)}/stop`),
260
+ ...pickOverrides(options)
261
+ });
262
+ return toComputerInfo(data);
263
+ }
264
+ async start(computerId, options) {
265
+ const ctx = buildRequestContext(this.config);
266
+ const data = await request(ctx, {
267
+ method: "POST",
268
+ path: computersPath(`/${encodeURIComponent(computerId)}/start`),
269
+ ...pickOverrides(options)
270
+ });
271
+ return toComputerInfo(data);
272
+ }
273
+ async delete(computerId, options) {
274
+ const ctx = buildRequestContext(this.config);
275
+ const data = await request(ctx, {
276
+ method: "DELETE",
277
+ path: computersPath(`/${encodeURIComponent(computerId)}`),
278
+ ...pickOverrides(options)
279
+ });
280
+ return toComputerInfo(data);
281
+ }
282
+ /**
283
+ * Get connection info for opening a WebSocket terminal session.
284
+ *
285
+ * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
286
+ * The name is resolved to the canonical ID via a GET call — the backend's
287
+ * WebSocket endpoint does not resolve names on its own.
288
+ *
289
+ * Returns the URL, headers, and first message needed to open the connection
290
+ * with any WebSocket library of your choice.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
295
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
296
+ * ws.on("open", () => ws.send(conn.firstMessage));
297
+ * ws.on("message", (data) => process.stdout.write(data));
298
+ * ```
299
+ */
300
+ async getTerminalConnection(computerIdOrName) {
301
+ const info = await this.get(computerIdOrName);
302
+ const ctx = buildRequestContext(this.config);
303
+ if (!ctx.token) {
304
+ throw new Error("A token is required for terminal connections");
305
+ }
306
+ const wsBase = ctx.baseUrl.replace(/^https:/i, "wss:").replace(/^http:/i, "ws:");
307
+ const url = `${wsBase}/v1/computers/${encodeURIComponent(info.id)}/terminal`;
308
+ const headers = {
309
+ Authorization: `Bearer ${ctx.token}`
310
+ };
311
+ if (ctx.organizationId) {
312
+ headers["X-Current-Organization"] = ctx.organizationId;
313
+ }
314
+ return {
315
+ url,
316
+ headers,
317
+ firstMessage: JSON.stringify({ token: ctx.token })
318
+ };
319
+ }
320
+ };
321
+ // Annotate the CommonJS export names for ESM import in node:
322
+ 0 && (module.exports = {
323
+ ComputersClient
324
+ });
325
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/computers/index.ts","../../src/core/config.ts","../../src/core/errors.ts","../../src/core/http.ts","../../src/computers/client.ts"],"sourcesContent":["export { ComputersClient } from \"./client\";\nexport type {\n ComputerConnectionInfo,\n ComputerExecResponse,\n ComputerInfo,\n ComputerListResponse,\n ComputerStatus,\n CreateComputerParams,\n ExecParams,\n TerminalConnectionInfo,\n} from \"./types\";\n","export type FetchLike = typeof fetch;\n\nexport interface ClientConfig {\n /** Base API URL, e.g. https://api.celesto.ai */\n baseUrl?: string;\n /** Bearer token (API key or JWT). */\n token?: string;\n /** Alias for token. */\n apiKey?: string;\n /** Organization ID to send as X-Current-Organization. */\n organizationId?: string;\n /** Optional user agent for server-side requests. */\n userAgent?: string;\n /** Default request timeout in milliseconds. */\n timeoutMs?: number;\n /** Override fetch implementation (useful for testing). */\n fetch?: FetchLike;\n /** Default headers to include in every request. */\n headers?: Record<string, string>;\n}\n\nexport interface RequestOptions {\n method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path: string;\n query?: Record<string, string | number | boolean | undefined | null | (string | number | boolean)[]>;\n body?: unknown;\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestOverrides {\n headers?: Record<string, string>;\n signal?: AbortSignal;\n}\n\nexport interface RequestContext {\n fetch: FetchLike;\n baseUrl: string;\n token?: string;\n organizationId?: string;\n userAgent?: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n}\n\nexport const DEFAULT_BASE_URL = \"https://api.celesto.ai\";\n\nexport const buildRequestContext = (config: ClientConfig): RequestContext => ({\n fetch: config.fetch ?? fetch,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n token: config.token ?? config.apiKey,\n organizationId: config.organizationId,\n userAgent: config.userAgent,\n timeoutMs: config.timeoutMs,\n headers: config.headers,\n});\n","/** Base error for all Celesto SDK errors. */\nexport class CelestoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CelestoError\";\n }\n}\n\n/** Thrown when an API request returns a non-2xx HTTP status. */\nexport class CelestoApiError extends CelestoError {\n readonly status: number;\n readonly data: unknown;\n readonly requestId?: string;\n\n constructor(message: string, status: number, data: unknown, requestId?: string) {\n super(message);\n this.name = \"CelestoApiError\";\n this.status = status;\n this.data = data;\n this.requestId = requestId;\n }\n}\n\n/** Thrown when fetch() itself fails — DNS, network, timeout, abort. */\nexport class CelestoNetworkError extends CelestoError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = \"CelestoNetworkError\";\n this.cause = cause;\n }\n}\n","import { CelestoApiError, CelestoNetworkError } from \"./errors\";\nimport { RequestContext, RequestOptions } from \"./config\";\n\nconst joinUrl = (baseUrl: string, path: string): string => {\n const trimmedBase = baseUrl.endsWith(\"/\") ? baseUrl.slice(0, -1) : baseUrl;\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n return `${trimmedBase}${normalizedPath}`;\n};\n\nconst buildQuery = (\n query?: RequestOptions[\"query\"],\n): string => {\n if (!query) {\n return \"\";\n }\n\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n params.append(key, String(item));\n }\n continue;\n }\n params.set(key, String(value));\n }\n\n const serialized = params.toString();\n return serialized ? `?${serialized}` : \"\";\n};\n\nconst parseResponseBody = async (response: Response): Promise<unknown> => {\n if (response.status === 204) {\n return undefined;\n }\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return response.json();\n }\n\n return response.text();\n};\n\nconst extractErrorMessage = (data: unknown, status: number): string => {\n if (data && typeof data === \"object\") {\n const record = data as Record<string, unknown>;\n if (typeof record.detail === \"string\") {\n return record.detail;\n }\n if (typeof record.message === \"string\") {\n return record.message;\n }\n if (typeof record.error === \"string\") {\n return record.error;\n }\n }\n return `Request failed with status ${status}`;\n};\n\nexport const request = async <T>(ctx: RequestContext, options: RequestOptions): Promise<T> => {\n const url = `${joinUrl(ctx.baseUrl, options.path)}${buildQuery(options.query)}`;\n\n const headers: Record<string, string> = {\n ...(ctx.headers ?? {}),\n ...(options.headers ?? {}),\n };\n\n if (ctx.token) {\n headers.Authorization = `Bearer ${ctx.token}`;\n }\n\n if (ctx.organizationId) {\n headers[\"X-Current-Organization\"] = ctx.organizationId;\n }\n\n if (ctx.userAgent && !headers[\"User-Agent\"]) {\n headers[\"User-Agent\"] = ctx.userAgent;\n }\n\n const init: RequestInit = {\n method: options.method,\n headers,\n body: undefined,\n signal: options.signal,\n };\n\n if (options.body !== undefined) {\n headers[\"Content-Type\"] = headers[\"Content-Type\"] ?? \"application/json\";\n init.body = headers[\"Content-Type\"].includes(\"application/json\")\n ? JSON.stringify(options.body)\n : (options.body as BodyInit);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let controller: AbortController | undefined;\n\n if (!options.signal && ctx.timeoutMs && ctx.timeoutMs > 0) {\n controller = new AbortController();\n timeoutId = setTimeout(() => controller?.abort(), ctx.timeoutMs);\n init.signal = controller.signal;\n }\n\n try {\n const response = await ctx.fetch(url, init);\n const data = await parseResponseBody(response);\n\n if (!response.ok) {\n const message = extractErrorMessage(data, response.status);\n throw new CelestoApiError(message, response.status, data, response.headers.get(\"x-request-id\") ?? undefined);\n }\n\n return data as T;\n } catch (err) {\n if (err instanceof CelestoApiError) {\n throw err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n throw new CelestoNetworkError(error.message, error);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n};\n","import { buildRequestContext, ClientConfig, RequestOverrides } from \"../core/config\";\nimport { request } from \"../core/http\";\nimport {\n ComputerConnectionInfo,\n ComputerExecResponse,\n ComputerInfo,\n ComputerListResponse,\n ComputerStatus,\n CreateComputerParams,\n ExecParams,\n TerminalConnectionInfo,\n} from \"./types\";\n\ninterface ComputerConnectionInfoWire {\n ssh?: string | null;\n access_url?: string | null;\n}\n\ninterface ComputerInfoWire {\n id: string;\n name: string;\n status: ComputerStatus;\n vcpus: number;\n ram_mb: number;\n image: string;\n connection?: ComputerConnectionInfoWire | null;\n last_error?: string | null;\n created_at: string;\n stopped_at?: string | null;\n}\n\ninterface ComputerListResponseWire {\n computers: ComputerInfoWire[];\n count: number;\n}\n\ninterface ComputerExecResponseWire {\n exit_code: number;\n stdout: string;\n stderr: string;\n}\n\nconst toConnection = (\n payload: ComputerConnectionInfoWire | null | undefined,\n): ComputerConnectionInfo | undefined => {\n if (!payload) {\n return undefined;\n }\n const out: ComputerConnectionInfo = {};\n if (payload.ssh != null) {\n out.ssh = payload.ssh;\n }\n if (payload.access_url != null) {\n out.accessUrl = payload.access_url;\n }\n return out;\n};\n\nconst toComputerInfo = (payload: ComputerInfoWire): ComputerInfo => ({\n id: payload.id,\n name: payload.name,\n status: payload.status,\n vcpus: payload.vcpus,\n ramMb: payload.ram_mb,\n image: payload.image,\n connection: toConnection(payload.connection),\n lastError: payload.last_error ?? null,\n createdAt: payload.created_at,\n stoppedAt: payload.stopped_at ?? null,\n});\n\nconst toExecResponse = (payload: ComputerExecResponseWire): ComputerExecResponse => ({\n exitCode: payload.exit_code,\n stdout: payload.stdout,\n stderr: payload.stderr,\n});\n\nconst computersPath = (path: string): string => `/v1/computers${path}`;\n\nconst pickOverrides = (options?: RequestOverrides): RequestOverrides => ({\n headers: options?.headers,\n signal: options?.signal,\n});\n\n/**\n * Client for managing sandboxed computers (AI sandboxes).\n *\n * Provides create/list/get/exec/stop/start/delete over HTTP, plus\n * `getTerminalConnection()` which returns the URL and headers needed\n * to open a WebSocket terminal with any WS library of your choice.\n *\n * @example\n * ```ts\n * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });\n * const computer = await celesto.computers.create({ cpus: 2, memory: 2048 });\n * const result = await celesto.computers.exec(computer.id, \"uname -a\");\n * console.log(result.stdout);\n * await celesto.computers.delete(computer.id);\n * ```\n */\nexport class ComputersClient {\n private readonly config: ClientConfig;\n\n constructor(config: ClientConfig) {\n this.config = config;\n }\n\n async create(params: CreateComputerParams = {}, options?: RequestOverrides): Promise<ComputerInfo> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerInfoWire>(ctx, {\n method: \"POST\",\n path: computersPath(\"\"),\n body: {\n vcpus: params.cpus ?? 1,\n ram_mb: params.memory ?? 1024,\n image: params.image ?? \"ubuntu-desktop-24.04\",\n },\n ...pickOverrides(options),\n });\n return toComputerInfo(data);\n }\n\n async list(options?: RequestOverrides): Promise<ComputerListResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerListResponseWire>(ctx, {\n method: \"GET\",\n path: computersPath(\"\"),\n ...pickOverrides(options),\n });\n return {\n computers: data.computers.map(toComputerInfo),\n count: data.count,\n };\n }\n\n async get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerInfoWire>(ctx, {\n method: \"GET\",\n path: computersPath(`/${encodeURIComponent(computerId)}`),\n ...pickOverrides(options),\n });\n return toComputerInfo(data);\n }\n\n async exec(\n computerId: string,\n command: string,\n params: ExecParams = {},\n options?: RequestOverrides,\n ): Promise<ComputerExecResponse> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerExecResponseWire>(ctx, {\n method: \"POST\",\n path: computersPath(`/${encodeURIComponent(computerId)}/exec`),\n body: {\n command,\n timeout: params.timeout ?? 30,\n },\n ...pickOverrides(options),\n });\n return toExecResponse(data);\n }\n\n async stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerInfoWire>(ctx, {\n method: \"POST\",\n path: computersPath(`/${encodeURIComponent(computerId)}/stop`),\n ...pickOverrides(options),\n });\n return toComputerInfo(data);\n }\n\n async start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerInfoWire>(ctx, {\n method: \"POST\",\n path: computersPath(`/${encodeURIComponent(computerId)}/start`),\n ...pickOverrides(options),\n });\n return toComputerInfo(data);\n }\n\n async delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo> {\n const ctx = buildRequestContext(this.config);\n const data = await request<ComputerInfoWire>(ctx, {\n method: \"DELETE\",\n path: computersPath(`/${encodeURIComponent(computerId)}`),\n ...pickOverrides(options),\n });\n return toComputerInfo(data);\n }\n\n /**\n * Get connection info for opening a WebSocket terminal session.\n *\n * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.\n * The name is resolved to the canonical ID via a GET call — the backend's\n * WebSocket endpoint does not resolve names on its own.\n *\n * Returns the URL, headers, and first message needed to open the connection\n * with any WebSocket library of your choice.\n *\n * @example\n * ```ts\n * const conn = await celesto.computers.getTerminalConnection(\"my-computer\");\n * const ws = new WebSocket(conn.url, { headers: conn.headers });\n * ws.on(\"open\", () => ws.send(conn.firstMessage));\n * ws.on(\"message\", (data) => process.stdout.write(data));\n * ```\n */\n async getTerminalConnection(computerIdOrName: string): Promise<TerminalConnectionInfo> {\n const info = await this.get(computerIdOrName);\n const ctx = buildRequestContext(this.config);\n\n if (!ctx.token) {\n throw new Error(\"A token is required for terminal connections\");\n }\n\n const wsBase = ctx.baseUrl.replace(/^https:/i, \"wss:\").replace(/^http:/i, \"ws:\");\n const url = `${wsBase}/v1/computers/${encodeURIComponent(info.id)}/terminal`;\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${ctx.token}`,\n };\n if (ctx.organizationId) {\n headers[\"X-Current-Organization\"] = ctx.organizationId;\n }\n\n return {\n url,\n headers,\n firstMessage: JSON.stringify({ token: ctx.token }),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6CO,IAAM,mBAAmB;AAEzB,IAAM,sBAAsB,CAAC,YAA0C;AAAA,EAC5E,OAAO,OAA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,MAC9D,GAAG,cAAc,OAAO;AAAA,IAC1B,CAAC;AACD,WAAO,eAAe,IAAI;AAAA,EAC5B;AAAA,EAEA,MAAM,OAAO,YAAoB,SAAmD;AAClF,UAAM,MAAM,oBAAoB,KAAK,MAAM;AAC3C,UAAM,OAAO,MAAM,QAA0B,KAAK;AAAA,MAChD,QAAQ;AAAA,MACR,MAAM,cAAc,IAAI,mBAAmB,UAAU,CAAC,EAAE;AAAA,MACxD,GAAG,cAAc,OAAO;AAAA,IAC1B,CAAC;AACD,WAAO,eAAe,IAAI;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,MAAM,sBAAsB,kBAA2D;AACrF,UAAM,OAAO,MAAM,KAAK,IAAI,gBAAgB;AAC5C,UAAM,MAAM,oBAAoB,KAAK,MAAM;AAE3C,QAAI,CAAC,IAAI,OAAO;AACd,YAAM,IAAI,MAAM,8CAA8C;AAAA,IAChE;AAEA,UAAM,SAAS,IAAI,QAAQ,QAAQ,YAAY,MAAM,EAAE,QAAQ,WAAW,KAAK;AAC/E,UAAM,MAAM,GAAG,MAAM,iBAAiB,mBAAmB,KAAK,EAAE,CAAC;AAEjE,UAAM,UAAkC;AAAA,MACtC,eAAe,UAAU,IAAI,KAAK;AAAA,IACpC;AACA,QAAI,IAAI,gBAAgB;AACtB,cAAQ,wBAAwB,IAAI,IAAI;AAAA,IAC1C;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,cAAc,KAAK,UAAU,EAAE,OAAO,IAAI,MAAM,CAAC;AAAA,IACnD;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,107 @@
1
+ import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.cjs';
2
+
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "deleting" | "deleted" | "error";
4
+ interface ComputerConnectionInfo {
5
+ ssh?: string;
6
+ accessUrl?: string;
7
+ }
8
+ interface ComputerInfo {
9
+ id: string;
10
+ name: string;
11
+ status: ComputerStatus;
12
+ vcpus: number;
13
+ ramMb: number;
14
+ image: string;
15
+ connection?: ComputerConnectionInfo;
16
+ lastError?: string | null;
17
+ createdAt: string;
18
+ stoppedAt?: string | null;
19
+ }
20
+ interface ComputerListResponse {
21
+ computers: ComputerInfo[];
22
+ count: number;
23
+ }
24
+ interface ComputerExecResponse {
25
+ exitCode: number;
26
+ stdout: string;
27
+ stderr: string;
28
+ }
29
+ interface CreateComputerParams {
30
+ /** Number of virtual CPUs (1-16). Defaults to 1. */
31
+ cpus?: number;
32
+ /** Memory in MB (512-32768). Defaults to 1024. */
33
+ memory?: number;
34
+ /** OS image name. Defaults to "ubuntu-desktop-24.04". */
35
+ image?: string;
36
+ }
37
+ interface ExecParams {
38
+ /** Timeout in seconds (1-300). Defaults to 30. */
39
+ timeout?: number;
40
+ }
41
+ /**
42
+ * Everything needed to open a WebSocket terminal connection.
43
+ *
44
+ * Use with any WebSocket library:
45
+ * ```ts
46
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
47
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
48
+ * ws.on("open", () => ws.send(conn.firstMessage));
49
+ * ```
50
+ */
51
+ interface TerminalConnectionInfo {
52
+ /** The wss:// URL to connect to. */
53
+ url: string;
54
+ /** Headers to send on the WebSocket handshake (includes Authorization). */
55
+ headers: Record<string, string>;
56
+ /** JSON string to send as the first message after connect (legacy token auth). */
57
+ firstMessage: string;
58
+ }
59
+
60
+ /**
61
+ * Client for managing sandboxed computers (AI sandboxes).
62
+ *
63
+ * Provides create/list/get/exec/stop/start/delete over HTTP, plus
64
+ * `getTerminalConnection()` which returns the URL and headers needed
65
+ * to open a WebSocket terminal with any WS library of your choice.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
70
+ * const computer = await celesto.computers.create({ cpus: 2, memory: 2048 });
71
+ * const result = await celesto.computers.exec(computer.id, "uname -a");
72
+ * console.log(result.stdout);
73
+ * await celesto.computers.delete(computer.id);
74
+ * ```
75
+ */
76
+ declare class ComputersClient {
77
+ private readonly config;
78
+ constructor(config: ClientConfig);
79
+ create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
80
+ list(options?: RequestOverrides): Promise<ComputerListResponse>;
81
+ get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
82
+ exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
83
+ stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
84
+ start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
85
+ delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
86
+ /**
87
+ * Get connection info for opening a WebSocket terminal session.
88
+ *
89
+ * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
90
+ * The name is resolved to the canonical ID via a GET call — the backend's
91
+ * WebSocket endpoint does not resolve names on its own.
92
+ *
93
+ * Returns the URL, headers, and first message needed to open the connection
94
+ * with any WebSocket library of your choice.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
99
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
100
+ * ws.on("open", () => ws.send(conn.firstMessage));
101
+ * ws.on("message", (data) => process.stdout.write(data));
102
+ * ```
103
+ */
104
+ getTerminalConnection(computerIdOrName: string): Promise<TerminalConnectionInfo>;
105
+ }
106
+
107
+ export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type TerminalConnectionInfo };
@@ -0,0 +1,107 @@
1
+ import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.js';
2
+
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "deleting" | "deleted" | "error";
4
+ interface ComputerConnectionInfo {
5
+ ssh?: string;
6
+ accessUrl?: string;
7
+ }
8
+ interface ComputerInfo {
9
+ id: string;
10
+ name: string;
11
+ status: ComputerStatus;
12
+ vcpus: number;
13
+ ramMb: number;
14
+ image: string;
15
+ connection?: ComputerConnectionInfo;
16
+ lastError?: string | null;
17
+ createdAt: string;
18
+ stoppedAt?: string | null;
19
+ }
20
+ interface ComputerListResponse {
21
+ computers: ComputerInfo[];
22
+ count: number;
23
+ }
24
+ interface ComputerExecResponse {
25
+ exitCode: number;
26
+ stdout: string;
27
+ stderr: string;
28
+ }
29
+ interface CreateComputerParams {
30
+ /** Number of virtual CPUs (1-16). Defaults to 1. */
31
+ cpus?: number;
32
+ /** Memory in MB (512-32768). Defaults to 1024. */
33
+ memory?: number;
34
+ /** OS image name. Defaults to "ubuntu-desktop-24.04". */
35
+ image?: string;
36
+ }
37
+ interface ExecParams {
38
+ /** Timeout in seconds (1-300). Defaults to 30. */
39
+ timeout?: number;
40
+ }
41
+ /**
42
+ * Everything needed to open a WebSocket terminal connection.
43
+ *
44
+ * Use with any WebSocket library:
45
+ * ```ts
46
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
47
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
48
+ * ws.on("open", () => ws.send(conn.firstMessage));
49
+ * ```
50
+ */
51
+ interface TerminalConnectionInfo {
52
+ /** The wss:// URL to connect to. */
53
+ url: string;
54
+ /** Headers to send on the WebSocket handshake (includes Authorization). */
55
+ headers: Record<string, string>;
56
+ /** JSON string to send as the first message after connect (legacy token auth). */
57
+ firstMessage: string;
58
+ }
59
+
60
+ /**
61
+ * Client for managing sandboxed computers (AI sandboxes).
62
+ *
63
+ * Provides create/list/get/exec/stop/start/delete over HTTP, plus
64
+ * `getTerminalConnection()` which returns the URL and headers needed
65
+ * to open a WebSocket terminal with any WS library of your choice.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
70
+ * const computer = await celesto.computers.create({ cpus: 2, memory: 2048 });
71
+ * const result = await celesto.computers.exec(computer.id, "uname -a");
72
+ * console.log(result.stdout);
73
+ * await celesto.computers.delete(computer.id);
74
+ * ```
75
+ */
76
+ declare class ComputersClient {
77
+ private readonly config;
78
+ constructor(config: ClientConfig);
79
+ create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
80
+ list(options?: RequestOverrides): Promise<ComputerListResponse>;
81
+ get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
82
+ exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
83
+ stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
84
+ start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
85
+ delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
86
+ /**
87
+ * Get connection info for opening a WebSocket terminal session.
88
+ *
89
+ * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
90
+ * The name is resolved to the canonical ID via a GET call — the backend's
91
+ * WebSocket endpoint does not resolve names on its own.
92
+ *
93
+ * Returns the URL, headers, and first message needed to open the connection
94
+ * with any WebSocket library of your choice.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const conn = await celesto.computers.getTerminalConnection("my-computer");
99
+ * const ws = new WebSocket(conn.url, { headers: conn.headers });
100
+ * ws.on("open", () => ws.send(conn.firstMessage));
101
+ * ws.on("message", (data) => process.stdout.write(data));
102
+ * ```
103
+ */
104
+ getTerminalConnection(computerIdOrName: string): Promise<TerminalConnectionInfo>;
105
+ }
106
+
107
+ export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type TerminalConnectionInfo };
@@ -0,0 +1,8 @@
1
+ import {
2
+ ComputersClient
3
+ } from "../chunk-OGMV3NFZ.js";
4
+ import "../chunk-N3HU6ONW.js";
5
+ export {
6
+ ComputersClient
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ type FetchLike = typeof fetch;
2
+ interface ClientConfig {
3
+ /** Base API URL, e.g. https://api.celesto.ai */
4
+ baseUrl?: string;
5
+ /** Bearer token (API key or JWT). */
6
+ token?: string;
7
+ /** Alias for token. */
8
+ apiKey?: string;
9
+ /** Organization ID to send as X-Current-Organization. */
10
+ organizationId?: string;
11
+ /** Optional user agent for server-side requests. */
12
+ userAgent?: string;
13
+ /** Default request timeout in milliseconds. */
14
+ timeoutMs?: number;
15
+ /** Override fetch implementation (useful for testing). */
16
+ fetch?: FetchLike;
17
+ /** Default headers to include in every request. */
18
+ headers?: Record<string, string>;
19
+ }
20
+ interface RequestOverrides {
21
+ headers?: Record<string, string>;
22
+ signal?: AbortSignal;
23
+ }
24
+
25
+ export type { ClientConfig as C, RequestOverrides as R };
@@ -0,0 +1,25 @@
1
+ type FetchLike = typeof fetch;
2
+ interface ClientConfig {
3
+ /** Base API URL, e.g. https://api.celesto.ai */
4
+ baseUrl?: string;
5
+ /** Bearer token (API key or JWT). */
6
+ token?: string;
7
+ /** Alias for token. */
8
+ apiKey?: string;
9
+ /** Organization ID to send as X-Current-Organization. */
10
+ organizationId?: string;
11
+ /** Optional user agent for server-side requests. */
12
+ userAgent?: string;
13
+ /** Default request timeout in milliseconds. */
14
+ timeoutMs?: number;
15
+ /** Override fetch implementation (useful for testing). */
16
+ fetch?: FetchLike;
17
+ /** Default headers to include in every request. */
18
+ headers?: Record<string, string>;
19
+ }
20
+ interface RequestOverrides {
21
+ headers?: Record<string, string>;
22
+ signal?: AbortSignal;
23
+ }
24
+
25
+ export type { ClientConfig as C, RequestOverrides as R };