@celestoai/sdk 0.1.6 → 0.1.7

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +89 -270
  3. package/dist/{chunk-B4JRBDUO.js → chunk-3HEUI5UL.js} +278 -304
  4. package/dist/chunk-3HEUI5UL.js.map +1 -0
  5. package/dist/computers/index.cjs +148 -345
  6. package/dist/computers/index.cjs.map +1 -1
  7. package/dist/computers/index.d.cts +1 -270
  8. package/dist/computers/index.d.ts +1 -270
  9. package/dist/computers/index.js +1 -2
  10. package/dist/index-59d7VJXL.d.cts +303 -0
  11. package/dist/index-59d7VJXL.d.ts +303 -0
  12. package/dist/index.cjs +191 -1573
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +22 -4
  15. package/dist/index.d.ts +22 -4
  16. package/dist/index.js +5 -61
  17. package/package.json +25 -22
  18. package/dist/agents/index.cjs +0 -1226
  19. package/dist/agents/index.cjs.map +0 -1
  20. package/dist/agents/index.d.cts +0 -2
  21. package/dist/agents/index.d.ts +0 -2
  22. package/dist/agents/index.js +0 -60
  23. package/dist/agents/index.js.map +0 -1
  24. package/dist/chunk-6Y2YZCPU.js +0 -1007
  25. package/dist/chunk-6Y2YZCPU.js.map +0 -1
  26. package/dist/chunk-B4JRBDUO.js.map +0 -1
  27. package/dist/chunk-P7F52CSQ.js +0 -177
  28. package/dist/chunk-P7F52CSQ.js.map +0 -1
  29. package/dist/chunk-THPVQCTE.js +0 -183
  30. package/dist/chunk-THPVQCTE.js.map +0 -1
  31. package/dist/config-dDPvsH-K.d.cts +0 -42
  32. package/dist/config-dDPvsH-K.d.ts +0 -42
  33. package/dist/gatekeeper/index.cjs +0 -348
  34. package/dist/gatekeeper/index.cjs.map +0 -1
  35. package/dist/gatekeeper/index.d.cts +0 -104
  36. package/dist/gatekeeper/index.d.ts +0 -104
  37. package/dist/gatekeeper/index.js +0 -8
  38. package/dist/gatekeeper/index.js.map +0 -1
  39. package/dist/index-Cii1_OFg.d.ts +0 -696
  40. package/dist/index-CsEA7qMF.d.cts +0 -696
@@ -0,0 +1,303 @@
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
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "lost" | "error";
26
+ interface ComputerConnectionInfo {
27
+ ssh?: string;
28
+ accessUrl?: string;
29
+ }
30
+ type PublishedPortStatus = "publishing" | "published" | "unpublishing" | "unpublished" | "error";
31
+ interface ComputerPublishedPortInfo {
32
+ id?: string | null;
33
+ computerId: string;
34
+ port: number;
35
+ url?: string | null;
36
+ status: PublishedPortStatus;
37
+ createdAt?: string | null;
38
+ }
39
+ interface NetworkPolicy {
40
+ mode: "open" | "off";
41
+ }
42
+ interface ComputerInfo {
43
+ networkPolicy?: NetworkPolicy;
44
+ id: string;
45
+ name: string;
46
+ status: ComputerStatus;
47
+ /** Named Cloud size, when provided by the API. */
48
+ sizeId?: string | null;
49
+ vcpus: number;
50
+ ramMb: number;
51
+ diskSizeMb: number;
52
+ image: string;
53
+ templateId: string;
54
+ templateVersion?: string | null;
55
+ /** Whether /home/ohm survives stop and restore. */
56
+ persistentHome: boolean;
57
+ connection?: ComputerConnectionInfo;
58
+ publishedPorts?: ComputerPublishedPortInfo[];
59
+ lastError?: string | null;
60
+ createdAt: string;
61
+ stoppedAt?: string | null;
62
+ }
63
+ interface ComputerListResponse {
64
+ computers: ComputerInfo[];
65
+ count: number;
66
+ }
67
+ interface ListComputersParams {
68
+ /** Optional status filter, such as "running" or "stopped". */
69
+ status?: ComputerStatus;
70
+ /** Optional template filter, such as "coding-agent". */
71
+ templateId?: string;
72
+ /** Optional project ID filter. */
73
+ projectId?: string;
74
+ /** Optional maximum number of computers to return. */
75
+ limit?: number;
76
+ }
77
+ interface ComputerExecResponse {
78
+ exitCode: number;
79
+ stdout: string;
80
+ stderr: string;
81
+ commandId?: string | null;
82
+ durationMs?: number | null;
83
+ timedOut?: boolean | null;
84
+ }
85
+ /** Cloud command iterators yield output and exit events after completion. */
86
+ type ComputerExecStreamEvent = {
87
+ /** Legacy event kept for source compatibility; Cloud does not emit it. */
88
+ type: "started";
89
+ commandId: string;
90
+ startedAtUnixMs: number;
91
+ timeoutSeconds: number;
92
+ } | {
93
+ type: "stdout" | "stderr";
94
+ data: string;
95
+ } | {
96
+ type: "exit";
97
+ exitCode: number;
98
+ commandId?: string;
99
+ startedAtUnixMs?: number;
100
+ endedAtUnixMs?: number;
101
+ durationMs?: number;
102
+ timedOut?: boolean;
103
+ };
104
+ interface ComputerCommandHistoryEntry {
105
+ commandId: string;
106
+ source: string;
107
+ status: string;
108
+ startedAt?: string | null;
109
+ endedAt?: string | null;
110
+ durationMs?: number | null;
111
+ timeoutSeconds?: number | null;
112
+ exitCode?: number | null;
113
+ stdoutBytes?: number | null;
114
+ stderrBytes?: number | null;
115
+ errorType?: string | null;
116
+ }
117
+ interface ComputerCommandHistoryResponse {
118
+ commands: ComputerCommandHistoryEntry[];
119
+ count: number;
120
+ }
121
+ interface SandboxTemplateInfo {
122
+ id: string;
123
+ displayName: string;
124
+ description: string;
125
+ defaultVcpus: number;
126
+ defaultRamMb: number;
127
+ defaultDiskSizeMb: number;
128
+ version?: string | null;
129
+ experimental: boolean;
130
+ }
131
+ interface CreateComputerParams {
132
+ /** Stable key for retrying the same create request. Defaults to a new key. */
133
+ idempotencyKey?: string;
134
+ /** Named Cloud size (for example, "micro"). Omit for your account's default. */
135
+ sizeId?: string;
136
+ /** Outbound internet access, fixed at creation. Defaults to open. */
137
+ networkPolicy?: NetworkPolicy;
138
+ /** @deprecated Cloud does not support CPU overrides. Use sizeId. */
139
+ cpus?: number;
140
+ /** @deprecated Cloud does not support CPU overrides. Use sizeId. */
141
+ vcpus?: number;
142
+ /** @deprecated Cloud does not support memory overrides. Use sizeId. */
143
+ memory?: number;
144
+ /** @deprecated Cloud does not support memory overrides. Use sizeId. */
145
+ ramMb?: number;
146
+ /** @deprecated Cloud does not support disk overrides. Use sizeId. */
147
+ disk?: number | string;
148
+ /** @deprecated Cloud does not support disk overrides. Use sizeId. */
149
+ diskSizeMb?: number;
150
+ /** Legacy OS image selector. */
151
+ image?: string;
152
+ /** Sandbox template id, such as "scratch" or "coding-agent". */
153
+ templateId?: string;
154
+ /** Optional immutable template version. */
155
+ templateVersion?: string;
156
+ /** Request a separate home volume, if supported. Not available on pool computers. */
157
+ persistentHome?: boolean;
158
+ }
159
+ interface ExecParams {
160
+ /** Timeout in seconds (1-300). Defaults to 30. */
161
+ timeout?: number;
162
+ /** Abort the HTTP request. This does not guarantee that the command stops. */
163
+ signal?: AbortSignal;
164
+ }
165
+ interface ListCommandHistoryParams {
166
+ /** Maximum command records to return (1-200). Defaults to 50. */
167
+ limit?: number;
168
+ }
169
+ /** Legacy WebSocket connection fields retained for source compatibility. */
170
+ interface TerminalConnectionInfo {
171
+ /** Authenticated wss:// URL ready to pass to a WebSocket constructor. */
172
+ url: string;
173
+ /** @deprecated The fast terminal gateway does not require custom headers. */
174
+ headers: Record<string, string>;
175
+ /** @deprecated The fast terminal gateway does not require a first message. */
176
+ firstMessage: string;
177
+ }
178
+ /** A short-lived direct connection to Celesto's fast terminal gateway. */
179
+ interface TerminalSessionInfo extends TerminalConnectionInfo {
180
+ /** Durable terminal session ID. */
181
+ terminalId: string;
182
+ /** Gateway URL without credentials. */
183
+ gatewayUrl: string;
184
+ /** Short-lived terminal token. Treat this value as a secret. */
185
+ token: string;
186
+ /** ISO 8601 expiry time for the terminal token. */
187
+ expiresAt: string;
188
+ }
189
+ interface BrowserConnectionInfo {
190
+ /** Authenticated CDP WebSocket URL ready for a browser automation client. */
191
+ url: string;
192
+ /** Gateway URL without credentials. */
193
+ gatewayUrl: string;
194
+ /** Short-lived browser connection token. Treat this value as a secret. */
195
+ token: string;
196
+ /** ISO 8601 expiry time for the browser token. */
197
+ expiresAt: string;
198
+ }
199
+ type DisplayConnectionMode = "read_only" | "read_write";
200
+ interface DisplayConnectionParams {
201
+ /** Watch the display, or also allow pointer and keyboard input. Defaults to read_only. */
202
+ mode?: DisplayConnectionMode;
203
+ }
204
+ interface DisplayConnectionInfo {
205
+ /** Authenticated RFB WebSocket URL ready for an RFB/noVNC client. */
206
+ url: string;
207
+ /** Gateway URL without credentials. */
208
+ gatewayUrl: string;
209
+ /** Short-lived display connection token. Treat this value as a secret. */
210
+ token: string;
211
+ /** ISO 8601 expiry time for the display token. */
212
+ expiresAt: string;
213
+ /** Whether this connection can only watch or can also control the display. */
214
+ mode: DisplayConnectionMode;
215
+ }
216
+
217
+ /** Convenience object for one Celesto computer. */
218
+ declare class Computer {
219
+ private readonly client;
220
+ private info;
221
+ private constructor();
222
+ /** Create a new computer and return an object with methods on it. */
223
+ static create(params?: CreateComputerParams, config?: ClientConfig): Promise<Computer>;
224
+ /** Load an existing computer by name or ID. */
225
+ static get(computerIdOrName: string, config?: ClientConfig): Promise<Computer>;
226
+ /** List computers in the current account. */
227
+ static list(params?: ListComputersParams, config?: ClientConfig): Promise<Computer[]>;
228
+ /** List available computer templates. */
229
+ static listTemplates(config?: ClientConfig): Promise<SandboxTemplateInfo[]>;
230
+ /** Wrap an existing API response in the convenience object. */
231
+ static fromInfo(info: ComputerInfo, config?: ClientConfig): Computer;
232
+ get id(): string;
233
+ get name(): string;
234
+ get status(): ComputerStatus;
235
+ get sizeId(): string | null | undefined;
236
+ get vcpus(): number;
237
+ get ramMb(): number;
238
+ get diskSizeMb(): number;
239
+ get image(): string;
240
+ get templateId(): string;
241
+ get templateVersion(): string | null | undefined;
242
+ get connection(): ComputerConnectionInfo | undefined;
243
+ get publishedPorts(): ComputerPublishedPortInfo[] | undefined;
244
+ get lastError(): string | null | undefined;
245
+ get createdAt(): string;
246
+ get stoppedAt(): string | null | undefined;
247
+ /** Get one field from the latest computer data. */
248
+ get<K extends keyof ComputerInfo>(key: K): ComputerInfo[K];
249
+ /** Return a copy of the latest computer data. */
250
+ toJSON(): ComputerInfo;
251
+ /** Reload this computer from Celesto. */
252
+ refresh(): Promise<this>;
253
+ /** Run a shell command on this computer. */
254
+ run(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
255
+ /** Alias for run(). */
256
+ exec(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
257
+ /** Run a shell command and yield buffered output and exit events after it finishes. */
258
+ runStream(command: string, params?: ExecParams): AsyncGenerator<ComputerExecStreamEvent>;
259
+ /** Alias for runStream(). */
260
+ execStream(command: string, params?: ExecParams): AsyncGenerator<ComputerExecStreamEvent>;
261
+ /** List recent commands executed on this computer. */
262
+ listCommandHistory(params?: ListCommandHistoryParams): Promise<ComputerCommandHistoryResponse>;
263
+ /** Create a short-lived direct connection to Celesto's terminal gateway. */
264
+ createTerminalSession(): Promise<TerminalSessionInfo>;
265
+ /** Create a short-lived CDP connection for browser automation. */
266
+ createBrowserConnection(): Promise<BrowserConnectionInfo>;
267
+ /** Create a short-lived RFB connection to watch or control the graphical display. */
268
+ createDisplayConnection(params?: DisplayConnectionParams): Promise<DisplayConnectionInfo>;
269
+ /** @deprecated Use createTerminalSession(). */
270
+ getTerminalConnection(): Promise<TerminalSessionInfo>;
271
+ /** Stop this computer and update the local data. */
272
+ stop(): Promise<this>;
273
+ /** Start this computer and update the local data. */
274
+ start(): Promise<this>;
275
+ /** Delete this computer and update the local data. */
276
+ delete(): Promise<this>;
277
+ /** Publish a port and return its public URL when the API provides one. */
278
+ publishPort(port?: number): Promise<string | null>;
279
+ /** List public ports for this computer. */
280
+ listPublishedPorts(): Promise<ComputerPublishedPortInfo[]>;
281
+ /** Remove a public port route. */
282
+ unpublishPort(port?: number): Promise<ComputerPublishedPortInfo>;
283
+ }
284
+
285
+ declare const MISSING_CREDENTIALS_MESSAGE = "No Celesto credentials found. Run pip install celesto && celesto auth login, or export CELESTO_API_KEY.";
286
+ interface CredentialResolutionOptions {
287
+ /** Directory containing the local .env file. Defaults to process.cwd(). */
288
+ cwd?: string;
289
+ /** Environment variables to inspect. Defaults to process.env. */
290
+ env?: NodeJS.ProcessEnv;
291
+ /** Home directory containing the saved CLI login. Defaults to os.homedir(). */
292
+ homeDir?: string;
293
+ /** Test or host override for reading .env. */
294
+ readDotEnv?: (filePath: string) => Promise<string>;
295
+ /** Test or host override for loading credentials saved by the Celesto CLI. */
296
+ loadSavedApiKey?: () => Promise<string | undefined>;
297
+ }
298
+ /** Resolve a Celesto API key from local sources, in precedence order. */
299
+ declare function resolveCelestoApiKey(options?: CredentialResolutionOptions): Promise<string | undefined>;
300
+ /** Resolve an API key while preserving explicit SDK configuration. */
301
+ declare function resolveClientConfig(config?: ClientConfig, options?: CredentialResolutionOptions): Promise<ClientConfig>;
302
+
303
+ export { type BrowserConnectionInfo as B, type ClientConfig as C, type DisplayConnectionInfo as D, type ExecParams as E, type ListCommandHistoryParams as L, MISSING_CREDENTIALS_MESSAGE as M, type NetworkPolicy as N, type PublishedPortStatus as P, type RequestOverrides as R, type SandboxTemplateInfo as S, type TerminalConnectionInfo as T, Computer as a, type ComputerCommandHistoryEntry as b, type ComputerCommandHistoryResponse as c, type ComputerConnectionInfo as d, type ComputerExecResponse as e, type ComputerExecStreamEvent as f, type ComputerInfo as g, type ComputerListResponse as h, type ComputerPublishedPortInfo as i, type ComputerStatus as j, type CreateComputerParams as k, type CredentialResolutionOptions as l, type DisplayConnectionMode as m, type DisplayConnectionParams as n, type ListComputersParams as o, type TerminalSessionInfo as p, resolveClientConfig as q, resolveCelestoApiKey as r };