@celestoai/sdk 0.1.1 → 0.1.3

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.
@@ -1,18 +1,31 @@
1
- import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.cjs';
1
+ import { C as ClientConfig } from '../config-BTTpuv_b.cjs';
2
2
 
3
- type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "deleting" | "deleted" | "error";
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "error";
4
4
  interface ComputerConnectionInfo {
5
5
  ssh?: string;
6
6
  accessUrl?: string;
7
7
  }
8
+ type PublishedPortStatus = "publishing" | "published" | "unpublishing" | "unpublished" | "error";
9
+ interface ComputerPublishedPortInfo {
10
+ id?: string | null;
11
+ computerId: string;
12
+ port: number;
13
+ url?: string | null;
14
+ status: PublishedPortStatus;
15
+ createdAt?: string | null;
16
+ }
8
17
  interface ComputerInfo {
9
18
  id: string;
10
19
  name: string;
11
20
  status: ComputerStatus;
12
21
  vcpus: number;
13
22
  ramMb: number;
23
+ diskSizeMb: number;
14
24
  image: string;
25
+ templateId: string;
26
+ templateVersion?: string | null;
15
27
  connection?: ComputerConnectionInfo;
28
+ publishedPorts?: ComputerPublishedPortInfo[];
16
29
  lastError?: string | null;
17
30
  createdAt: string;
18
31
  stoppedAt?: string | null;
@@ -21,18 +34,50 @@ interface ComputerListResponse {
21
34
  computers: ComputerInfo[];
22
35
  count: number;
23
36
  }
37
+ interface ListComputersParams {
38
+ /** Optional status filter, such as "running" or "stopped". */
39
+ status?: ComputerStatus;
40
+ /** Optional template filter, such as "coding-agent". */
41
+ templateId?: string;
42
+ /** Optional project ID filter. */
43
+ projectId?: string;
44
+ /** Optional maximum number of computers to return. */
45
+ limit?: number;
46
+ }
24
47
  interface ComputerExecResponse {
25
48
  exitCode: number;
26
49
  stdout: string;
27
50
  stderr: string;
28
51
  }
52
+ interface SandboxTemplateInfo {
53
+ id: string;
54
+ displayName: string;
55
+ description: string;
56
+ defaultVcpus: number;
57
+ defaultRamMb: number;
58
+ defaultDiskSizeMb: number;
59
+ version?: string | null;
60
+ experimental: boolean;
61
+ }
29
62
  interface CreateComputerParams {
30
- /** Number of virtual CPUs (1-16). Defaults to 1. */
63
+ /** Number of virtual CPUs (1-16). Alias for vcpus. */
31
64
  cpus?: number;
32
- /** Memory in MB (512-32768). Defaults to 1024. */
65
+ /** Number of virtual CPUs (1-16). */
66
+ vcpus?: number;
67
+ /** Memory in MB (512-32768). Alias for ramMb. */
33
68
  memory?: number;
34
- /** OS image name. Defaults to "ubuntu-desktop-24.04". */
69
+ /** Memory in MB (512-32768). */
70
+ ramMb?: number;
71
+ /** Disk size as MB or a string like "2gb". Alias for diskSizeMb. */
72
+ disk?: number | string;
73
+ /** Disk size in MB (512-51200). */
74
+ diskSizeMb?: number;
75
+ /** Legacy OS image selector. */
35
76
  image?: string;
77
+ /** Sandbox template id, such as "scratch" or "coding-agent". */
78
+ templateId?: string;
79
+ /** Optional immutable template version. */
80
+ templateVersion?: string;
36
81
  }
37
82
  interface ExecParams {
38
83
  /** Timeout in seconds (1-300). Defaults to 30. */
@@ -43,7 +88,7 @@ interface ExecParams {
43
88
  *
44
89
  * Use with any WebSocket library:
45
90
  * ```ts
46
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
91
+ * const conn = await client.getTerminalConnection("my-computer");
47
92
  * const ws = new WebSocket(conn.url, { headers: conn.headers });
48
93
  * ws.on("open", () => ws.send(conn.firstMessage));
49
94
  * ```
@@ -57,51 +102,57 @@ interface TerminalConnectionInfo {
57
102
  firstMessage: string;
58
103
  }
59
104
 
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
+ /** Convenience object for one Celesto computer. */
106
+ declare class Computer {
107
+ private readonly client;
108
+ private info;
109
+ private constructor();
110
+ /** Create a new computer and return an object with methods on it. */
111
+ static create(params?: CreateComputerParams, config?: ClientConfig): Promise<Computer>;
112
+ /** Load an existing computer by name or ID. */
113
+ static get(computerIdOrName: string, config?: ClientConfig): Promise<Computer>;
114
+ /** List computers in the current account. */
115
+ static list(params?: ListComputersParams, config?: ClientConfig): Promise<Computer[]>;
116
+ /** List available computer templates. */
117
+ static listTemplates(config?: ClientConfig): Promise<SandboxTemplateInfo[]>;
118
+ /** Wrap an existing API response in the convenience object. */
119
+ static fromInfo(info: ComputerInfo, config?: ClientConfig): Computer;
120
+ get id(): string;
121
+ get name(): string;
122
+ get status(): ComputerStatus;
123
+ get vcpus(): number;
124
+ get ramMb(): number;
125
+ get diskSizeMb(): number;
126
+ get image(): string;
127
+ get templateId(): string;
128
+ get templateVersion(): string | null | undefined;
129
+ get connection(): ComputerConnectionInfo | undefined;
130
+ get publishedPorts(): ComputerPublishedPortInfo[] | undefined;
131
+ get lastError(): string | null | undefined;
132
+ get createdAt(): string;
133
+ get stoppedAt(): string | null | undefined;
134
+ /** Get one field from the latest computer data. */
135
+ get<K extends keyof ComputerInfo>(key: K): ComputerInfo[K];
136
+ /** Return a copy of the latest computer data. */
137
+ toJSON(): ComputerInfo;
138
+ /** Reload this computer from Celesto. */
139
+ refresh(): Promise<this>;
140
+ /** Run a shell command on this computer. */
141
+ run(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
142
+ /** Alias for run(). */
143
+ exec(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
144
+ /** Stop this computer and update the local data. */
145
+ stop(): Promise<this>;
146
+ /** Start this computer and update the local data. */
147
+ start(): Promise<this>;
148
+ /** Delete this computer and update the local data. */
149
+ delete(): Promise<this>;
150
+ /** Publish a port and return its public URL when the API provides one. */
151
+ publishPort(port?: number): Promise<string | null>;
152
+ /** List public ports for this computer. */
153
+ listPublishedPorts(): Promise<ComputerPublishedPortInfo[]>;
154
+ /** Remove a public port route. */
155
+ unpublishPort(port?: number): Promise<ComputerPublishedPortInfo>;
105
156
  }
106
157
 
107
- export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type TerminalConnectionInfo };
158
+ export { Computer, type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerPublishedPortInfo, type ComputerStatus, type CreateComputerParams, type ExecParams, type ListComputersParams, type PublishedPortStatus, type SandboxTemplateInfo, type TerminalConnectionInfo };
@@ -1,18 +1,31 @@
1
- import { C as ClientConfig, R as RequestOverrides } from '../config-BTTpuv_b.js';
1
+ import { C as ClientConfig } from '../config-BTTpuv_b.js';
2
2
 
3
- type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "deleting" | "deleted" | "error";
3
+ type ComputerStatus = "creating" | "running" | "stopping" | "stopped" | "starting" | "restoring" | "restorable" | "deleting" | "deleted" | "error";
4
4
  interface ComputerConnectionInfo {
5
5
  ssh?: string;
6
6
  accessUrl?: string;
7
7
  }
8
+ type PublishedPortStatus = "publishing" | "published" | "unpublishing" | "unpublished" | "error";
9
+ interface ComputerPublishedPortInfo {
10
+ id?: string | null;
11
+ computerId: string;
12
+ port: number;
13
+ url?: string | null;
14
+ status: PublishedPortStatus;
15
+ createdAt?: string | null;
16
+ }
8
17
  interface ComputerInfo {
9
18
  id: string;
10
19
  name: string;
11
20
  status: ComputerStatus;
12
21
  vcpus: number;
13
22
  ramMb: number;
23
+ diskSizeMb: number;
14
24
  image: string;
25
+ templateId: string;
26
+ templateVersion?: string | null;
15
27
  connection?: ComputerConnectionInfo;
28
+ publishedPorts?: ComputerPublishedPortInfo[];
16
29
  lastError?: string | null;
17
30
  createdAt: string;
18
31
  stoppedAt?: string | null;
@@ -21,18 +34,50 @@ interface ComputerListResponse {
21
34
  computers: ComputerInfo[];
22
35
  count: number;
23
36
  }
37
+ interface ListComputersParams {
38
+ /** Optional status filter, such as "running" or "stopped". */
39
+ status?: ComputerStatus;
40
+ /** Optional template filter, such as "coding-agent". */
41
+ templateId?: string;
42
+ /** Optional project ID filter. */
43
+ projectId?: string;
44
+ /** Optional maximum number of computers to return. */
45
+ limit?: number;
46
+ }
24
47
  interface ComputerExecResponse {
25
48
  exitCode: number;
26
49
  stdout: string;
27
50
  stderr: string;
28
51
  }
52
+ interface SandboxTemplateInfo {
53
+ id: string;
54
+ displayName: string;
55
+ description: string;
56
+ defaultVcpus: number;
57
+ defaultRamMb: number;
58
+ defaultDiskSizeMb: number;
59
+ version?: string | null;
60
+ experimental: boolean;
61
+ }
29
62
  interface CreateComputerParams {
30
- /** Number of virtual CPUs (1-16). Defaults to 1. */
63
+ /** Number of virtual CPUs (1-16). Alias for vcpus. */
31
64
  cpus?: number;
32
- /** Memory in MB (512-32768). Defaults to 1024. */
65
+ /** Number of virtual CPUs (1-16). */
66
+ vcpus?: number;
67
+ /** Memory in MB (512-32768). Alias for ramMb. */
33
68
  memory?: number;
34
- /** OS image name. Defaults to "ubuntu-desktop-24.04". */
69
+ /** Memory in MB (512-32768). */
70
+ ramMb?: number;
71
+ /** Disk size as MB or a string like "2gb". Alias for diskSizeMb. */
72
+ disk?: number | string;
73
+ /** Disk size in MB (512-51200). */
74
+ diskSizeMb?: number;
75
+ /** Legacy OS image selector. */
35
76
  image?: string;
77
+ /** Sandbox template id, such as "scratch" or "coding-agent". */
78
+ templateId?: string;
79
+ /** Optional immutable template version. */
80
+ templateVersion?: string;
36
81
  }
37
82
  interface ExecParams {
38
83
  /** Timeout in seconds (1-300). Defaults to 30. */
@@ -43,7 +88,7 @@ interface ExecParams {
43
88
  *
44
89
  * Use with any WebSocket library:
45
90
  * ```ts
46
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
91
+ * const conn = await client.getTerminalConnection("my-computer");
47
92
  * const ws = new WebSocket(conn.url, { headers: conn.headers });
48
93
  * ws.on("open", () => ws.send(conn.firstMessage));
49
94
  * ```
@@ -57,51 +102,57 @@ interface TerminalConnectionInfo {
57
102
  firstMessage: string;
58
103
  }
59
104
 
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
+ /** Convenience object for one Celesto computer. */
106
+ declare class Computer {
107
+ private readonly client;
108
+ private info;
109
+ private constructor();
110
+ /** Create a new computer and return an object with methods on it. */
111
+ static create(params?: CreateComputerParams, config?: ClientConfig): Promise<Computer>;
112
+ /** Load an existing computer by name or ID. */
113
+ static get(computerIdOrName: string, config?: ClientConfig): Promise<Computer>;
114
+ /** List computers in the current account. */
115
+ static list(params?: ListComputersParams, config?: ClientConfig): Promise<Computer[]>;
116
+ /** List available computer templates. */
117
+ static listTemplates(config?: ClientConfig): Promise<SandboxTemplateInfo[]>;
118
+ /** Wrap an existing API response in the convenience object. */
119
+ static fromInfo(info: ComputerInfo, config?: ClientConfig): Computer;
120
+ get id(): string;
121
+ get name(): string;
122
+ get status(): ComputerStatus;
123
+ get vcpus(): number;
124
+ get ramMb(): number;
125
+ get diskSizeMb(): number;
126
+ get image(): string;
127
+ get templateId(): string;
128
+ get templateVersion(): string | null | undefined;
129
+ get connection(): ComputerConnectionInfo | undefined;
130
+ get publishedPorts(): ComputerPublishedPortInfo[] | undefined;
131
+ get lastError(): string | null | undefined;
132
+ get createdAt(): string;
133
+ get stoppedAt(): string | null | undefined;
134
+ /** Get one field from the latest computer data. */
135
+ get<K extends keyof ComputerInfo>(key: K): ComputerInfo[K];
136
+ /** Return a copy of the latest computer data. */
137
+ toJSON(): ComputerInfo;
138
+ /** Reload this computer from Celesto. */
139
+ refresh(): Promise<this>;
140
+ /** Run a shell command on this computer. */
141
+ run(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
142
+ /** Alias for run(). */
143
+ exec(command: string, params?: ExecParams): Promise<ComputerExecResponse>;
144
+ /** Stop this computer and update the local data. */
145
+ stop(): Promise<this>;
146
+ /** Start this computer and update the local data. */
147
+ start(): Promise<this>;
148
+ /** Delete this computer and update the local data. */
149
+ delete(): Promise<this>;
150
+ /** Publish a port and return its public URL when the API provides one. */
151
+ publishPort(port?: number): Promise<string | null>;
152
+ /** List public ports for this computer. */
153
+ listPublishedPorts(): Promise<ComputerPublishedPortInfo[]>;
154
+ /** Remove a public port route. */
155
+ unpublishPort(port?: number): Promise<ComputerPublishedPortInfo>;
105
156
  }
106
157
 
107
- export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type TerminalConnectionInfo };
158
+ export { Computer, type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerPublishedPortInfo, type ComputerStatus, type CreateComputerParams, type ExecParams, type ListComputersParams, type PublishedPortStatus, type SandboxTemplateInfo, type TerminalConnectionInfo };
@@ -1,8 +1,8 @@
1
1
  import {
2
- ComputersClient
3
- } from "../chunk-OGMV3NFZ.js";
2
+ Computer
3
+ } from "../chunk-LPTIN7LO.js";
4
4
  import "../chunk-N3HU6ONW.js";
5
5
  export {
6
- ComputersClient
6
+ Computer
7
7
  };
8
8
  //# sourceMappingURL=index.js.map