@celestoai/sdk 0.1.2 → 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,10 +1,19 @@
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
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;
@@ -16,6 +25,7 @@ interface ComputerInfo {
16
25
  templateId: string;
17
26
  templateVersion?: string | null;
18
27
  connection?: ComputerConnectionInfo;
28
+ publishedPorts?: ComputerPublishedPortInfo[];
19
29
  lastError?: string | null;
20
30
  createdAt: string;
21
31
  stoppedAt?: string | null;
@@ -24,6 +34,16 @@ interface ComputerListResponse {
24
34
  computers: ComputerInfo[];
25
35
  count: number;
26
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
+ }
27
47
  interface ComputerExecResponse {
28
48
  exitCode: number;
29
49
  stdout: string;
@@ -48,6 +68,8 @@ interface CreateComputerParams {
48
68
  memory?: number;
49
69
  /** Memory in MB (512-32768). */
50
70
  ramMb?: number;
71
+ /** Disk size as MB or a string like "2gb". Alias for diskSizeMb. */
72
+ disk?: number | string;
51
73
  /** Disk size in MB (512-51200). */
52
74
  diskSizeMb?: number;
53
75
  /** Legacy OS image selector. */
@@ -66,7 +88,7 @@ interface ExecParams {
66
88
  *
67
89
  * Use with any WebSocket library:
68
90
  * ```ts
69
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
91
+ * const conn = await client.getTerminalConnection("my-computer");
70
92
  * const ws = new WebSocket(conn.url, { headers: conn.headers });
71
93
  * ws.on("open", () => ws.send(conn.firstMessage));
72
94
  * ```
@@ -80,52 +102,57 @@ interface TerminalConnectionInfo {
80
102
  firstMessage: string;
81
103
  }
82
104
 
83
- /**
84
- * Client for managing sandboxed computers (AI sandboxes).
85
- *
86
- * Provides create/list/get/exec/stop/start/delete over HTTP, plus
87
- * `getTerminalConnection()` which returns the URL and headers needed
88
- * to open a WebSocket terminal with any WS library of your choice.
89
- *
90
- * @example
91
- * ```ts
92
- * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
93
- * const computer = await celesto.computers.create({ templateId: "coding-agent" });
94
- * const result = await celesto.computers.exec(computer.id, "uname -a");
95
- * console.log(result.stdout);
96
- * await celesto.computers.delete(computer.id);
97
- * ```
98
- */
99
- declare class ComputersClient {
100
- private readonly config;
101
- constructor(config: ClientConfig);
102
- create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
103
- listTemplates(options?: RequestOverrides): Promise<SandboxTemplateInfo[]>;
104
- list(options?: RequestOverrides): Promise<ComputerListResponse>;
105
- get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
106
- exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
107
- stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
108
- start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
109
- delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
110
- /**
111
- * Get connection info for opening a WebSocket terminal session.
112
- *
113
- * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
114
- * The name is resolved to the canonical ID via a GET call — the backend's
115
- * WebSocket endpoint does not resolve names on its own.
116
- *
117
- * Returns the URL, headers, and first message needed to open the connection
118
- * with any WebSocket library of your choice.
119
- *
120
- * @example
121
- * ```ts
122
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
123
- * const ws = new WebSocket(conn.url, { headers: conn.headers });
124
- * ws.on("open", () => ws.send(conn.firstMessage));
125
- * ws.on("message", (data) => process.stdout.write(data));
126
- * ```
127
- */
128
- 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>;
129
156
  }
130
157
 
131
- export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type SandboxTemplateInfo, 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,10 +1,19 @@
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
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;
@@ -16,6 +25,7 @@ interface ComputerInfo {
16
25
  templateId: string;
17
26
  templateVersion?: string | null;
18
27
  connection?: ComputerConnectionInfo;
28
+ publishedPorts?: ComputerPublishedPortInfo[];
19
29
  lastError?: string | null;
20
30
  createdAt: string;
21
31
  stoppedAt?: string | null;
@@ -24,6 +34,16 @@ interface ComputerListResponse {
24
34
  computers: ComputerInfo[];
25
35
  count: number;
26
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
+ }
27
47
  interface ComputerExecResponse {
28
48
  exitCode: number;
29
49
  stdout: string;
@@ -48,6 +68,8 @@ interface CreateComputerParams {
48
68
  memory?: number;
49
69
  /** Memory in MB (512-32768). */
50
70
  ramMb?: number;
71
+ /** Disk size as MB or a string like "2gb". Alias for diskSizeMb. */
72
+ disk?: number | string;
51
73
  /** Disk size in MB (512-51200). */
52
74
  diskSizeMb?: number;
53
75
  /** Legacy OS image selector. */
@@ -66,7 +88,7 @@ interface ExecParams {
66
88
  *
67
89
  * Use with any WebSocket library:
68
90
  * ```ts
69
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
91
+ * const conn = await client.getTerminalConnection("my-computer");
70
92
  * const ws = new WebSocket(conn.url, { headers: conn.headers });
71
93
  * ws.on("open", () => ws.send(conn.firstMessage));
72
94
  * ```
@@ -80,52 +102,57 @@ interface TerminalConnectionInfo {
80
102
  firstMessage: string;
81
103
  }
82
104
 
83
- /**
84
- * Client for managing sandboxed computers (AI sandboxes).
85
- *
86
- * Provides create/list/get/exec/stop/start/delete over HTTP, plus
87
- * `getTerminalConnection()` which returns the URL and headers needed
88
- * to open a WebSocket terminal with any WS library of your choice.
89
- *
90
- * @example
91
- * ```ts
92
- * const celesto = new Celesto({ token: process.env.CELESTO_API_KEY });
93
- * const computer = await celesto.computers.create({ templateId: "coding-agent" });
94
- * const result = await celesto.computers.exec(computer.id, "uname -a");
95
- * console.log(result.stdout);
96
- * await celesto.computers.delete(computer.id);
97
- * ```
98
- */
99
- declare class ComputersClient {
100
- private readonly config;
101
- constructor(config: ClientConfig);
102
- create(params?: CreateComputerParams, options?: RequestOverrides): Promise<ComputerInfo>;
103
- listTemplates(options?: RequestOverrides): Promise<SandboxTemplateInfo[]>;
104
- list(options?: RequestOverrides): Promise<ComputerListResponse>;
105
- get(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
106
- exec(computerId: string, command: string, params?: ExecParams, options?: RequestOverrides): Promise<ComputerExecResponse>;
107
- stop(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
108
- start(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
109
- delete(computerId: string, options?: RequestOverrides): Promise<ComputerInfo>;
110
- /**
111
- * Get connection info for opening a WebSocket terminal session.
112
- *
113
- * Accepts either a computer ID (e.g. `cmp_xxx`) or a human-readable name.
114
- * The name is resolved to the canonical ID via a GET call — the backend's
115
- * WebSocket endpoint does not resolve names on its own.
116
- *
117
- * Returns the URL, headers, and first message needed to open the connection
118
- * with any WebSocket library of your choice.
119
- *
120
- * @example
121
- * ```ts
122
- * const conn = await celesto.computers.getTerminalConnection("my-computer");
123
- * const ws = new WebSocket(conn.url, { headers: conn.headers });
124
- * ws.on("open", () => ws.send(conn.firstMessage));
125
- * ws.on("message", (data) => process.stdout.write(data));
126
- * ```
127
- */
128
- 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>;
129
156
  }
130
157
 
131
- export { type ComputerConnectionInfo, type ComputerExecResponse, type ComputerInfo, type ComputerListResponse, type ComputerStatus, ComputersClient, type CreateComputerParams, type ExecParams, type SandboxTemplateInfo, 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-7OJDEZ7J.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