@miosa/sdk 0.3.0

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 (81) hide show
  1. package/README.md +181 -0
  2. package/dist/index.d.ts +4689 -0
  3. package/dist/index.js +6045 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +63 -0
  6. package/src/client.ts +249 -0
  7. package/src/errors.ts +136 -0
  8. package/src/http.test.ts +374 -0
  9. package/src/http.ts +390 -0
  10. package/src/index.ts +452 -0
  11. package/src/resources/admin.ts +348 -0
  12. package/src/resources/analytics.ts +60 -0
  13. package/src/resources/api-keys.ts +119 -0
  14. package/src/resources/audit-log.ts +64 -0
  15. package/src/resources/benchmarks.ts +104 -0
  16. package/src/resources/builder-sessions.ts +75 -0
  17. package/src/resources/channels.ts +143 -0
  18. package/src/resources/checkpoints.ts +225 -0
  19. package/src/resources/command-center.ts +73 -0
  20. package/src/resources/community.ts +103 -0
  21. package/src/resources/completions.ts +104 -0
  22. package/src/resources/computer-auto-stop.ts +43 -0
  23. package/src/resources/computer-env.ts +76 -0
  24. package/src/resources/computer-logs.ts +50 -0
  25. package/src/resources/computer-osa.ts +76 -0
  26. package/src/resources/computer-ports.ts +91 -0
  27. package/src/resources/computer-terminal.ts +61 -0
  28. package/src/resources/computer-volumes.ts +64 -0
  29. package/src/resources/computer.ts +530 -0
  30. package/src/resources/computers.ts +75 -0
  31. package/src/resources/credits.ts +43 -0
  32. package/src/resources/cron-jobs.ts +191 -0
  33. package/src/resources/custom_domains.ts +123 -0
  34. package/src/resources/dashboard.ts +49 -0
  35. package/src/resources/databases.ts +218 -0
  36. package/src/resources/deployments.ts +777 -0
  37. package/src/resources/desktop.ts +134 -0
  38. package/src/resources/email.ts +212 -0
  39. package/src/resources/embeddings.ts +36 -0
  40. package/src/resources/events.ts +296 -0
  41. package/src/resources/exec.ts +319 -0
  42. package/src/resources/external-keys.ts +79 -0
  43. package/src/resources/files.test.ts +339 -0
  44. package/src/resources/files.ts +220 -0
  45. package/src/resources/flat-custom-domains.ts +127 -0
  46. package/src/resources/functions.ts +178 -0
  47. package/src/resources/health-checks.ts +165 -0
  48. package/src/resources/integrations.ts +183 -0
  49. package/src/resources/mcp.ts +70 -0
  50. package/src/resources/models.ts +45 -0
  51. package/src/resources/network_policy.ts +73 -0
  52. package/src/resources/open-computers/agents.ts +91 -0
  53. package/src/resources/open-computers/apps.ts +102 -0
  54. package/src/resources/open-computers/clusters.ts +88 -0
  55. package/src/resources/open-computers/desktop.ts +34 -0
  56. package/src/resources/open-computers/files.ts +97 -0
  57. package/src/resources/open-computers/hosts.ts +85 -0
  58. package/src/resources/open-computers/index.ts +98 -0
  59. package/src/resources/open-computers/jobs.ts +75 -0
  60. package/src/resources/open-computers/open_computers.test.ts +288 -0
  61. package/src/resources/open-computers/secrets.ts +115 -0
  62. package/src/resources/open-computers/terminal.ts +33 -0
  63. package/src/resources/open-computers/tunnels.ts +87 -0
  64. package/src/resources/open-computers/types.ts +343 -0
  65. package/src/resources/open-computers/workspaces.ts +135 -0
  66. package/src/resources/project-auth.ts +142 -0
  67. package/src/resources/project-integrations.ts +133 -0
  68. package/src/resources/provider-defaults.ts +89 -0
  69. package/src/resources/regions.ts +94 -0
  70. package/src/resources/sandbox-templates.ts +195 -0
  71. package/src/resources/sandboxes.live.test.ts +92 -0
  72. package/src/resources/sandboxes.test.ts +624 -0
  73. package/src/resources/sandboxes.ts +1173 -0
  74. package/src/resources/settings.ts +143 -0
  75. package/src/resources/snapshots-standalone.ts +51 -0
  76. package/src/resources/storage.ts +221 -0
  77. package/src/resources/tenant.ts +39 -0
  78. package/src/resources/usage.ts +85 -0
  79. package/src/resources/volumes.ts +117 -0
  80. package/src/resources/webhooks.ts +171 -0
  81. package/src/types.ts +460 -0
@@ -0,0 +1,4689 @@
1
+ import * as ws from 'ws';
2
+ import EventEmitter from 'node:events';
3
+
4
+ interface RequestOptions {
5
+ method?: string;
6
+ headers?: Record<string, string>;
7
+ body?: unknown;
8
+ timeout?: number;
9
+ /** Return raw Response instead of parsing JSON */
10
+ rawResponse?: boolean;
11
+ /** Send body as multipart/form-data */
12
+ formData?: FormData;
13
+ /** Expected response is binary */
14
+ binary?: boolean;
15
+ }
16
+ interface HttpClientConfig {
17
+ baseUrl: string;
18
+ apiKey: string;
19
+ timeout: number;
20
+ maxRetries: number;
21
+ }
22
+ declare class HttpClient {
23
+ /** Public for WebSocket clients that need to derive their own URL. */
24
+ readonly baseUrl: string;
25
+ /** Public for WebSocket clients that need to send the same auth. */
26
+ readonly apiKey: string;
27
+ private readonly timeout;
28
+ private readonly maxRetries;
29
+ constructor(config: HttpClientConfig);
30
+ private buildUrl;
31
+ private baseHeaders;
32
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
33
+ get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
34
+ post<T>(path: string, body?: unknown): Promise<T>;
35
+ patch<T>(path: string, body?: unknown): Promise<T>;
36
+ put<T>(path: string, body?: unknown): Promise<T>;
37
+ delete<T>(path: string, body?: unknown): Promise<T>;
38
+ getBinary(path: string): Promise<Uint8Array>;
39
+ postFormData<T>(path: string, formData: FormData): Promise<T>;
40
+ /**
41
+ * Open a Server-Sent Events stream. Returns an AsyncIterableIterator of
42
+ * parsed event data objects. The caller is responsible for breaking the loop.
43
+ */
44
+ stream<T>(path: string, options?: RequestOptions): AsyncIterableIterator<T>;
45
+ }
46
+
47
+ type Json = Record<string, unknown>;
48
+ type Query = Record<string, string | number | boolean | undefined>;
49
+ interface ListAdminUsersParams {
50
+ limit?: number;
51
+ cursor?: string;
52
+ q?: string;
53
+ status?: "active" | "suspended" | "deleted";
54
+ }
55
+ interface ListAdminTenantsParams {
56
+ limit?: number;
57
+ cursor?: string;
58
+ q?: string;
59
+ }
60
+ interface ListAdminComputersParams {
61
+ limit?: number;
62
+ cursor?: string;
63
+ status?: "creating" | "provisioning" | "running" | "stopped" | "paused" | "error";
64
+ tenantId?: string;
65
+ }
66
+ interface ListAdminApiKeysParams {
67
+ limit?: number;
68
+ cursor?: string;
69
+ tenantId?: string;
70
+ status?: "active" | "revoked" | "expired";
71
+ }
72
+ interface CreateAdminApiKeyParams {
73
+ name: string;
74
+ tenantId: string;
75
+ userId: string;
76
+ keyType?: "user" | "admin" | "platform";
77
+ purpose?: "api" | "optimal";
78
+ rateLimitRpm?: number;
79
+ expiresAt?: string;
80
+ allowedIps?: string[];
81
+ }
82
+ interface BulkUserActionParams {
83
+ userIds: string[];
84
+ action: "suspend" | "unsuspend" | "delete" | "tag" | "notify";
85
+ params?: Json;
86
+ }
87
+ /**
88
+ * Admin surface — `/api/v1/admin/*` endpoints.
89
+ *
90
+ * Requires a `msk_a_*` or `msk_p_*` API key, or an admin JWT. Calls from
91
+ * a user-role credential return 403 Forbidden.
92
+ */
93
+ declare class Admin {
94
+ private readonly http;
95
+ constructor(http: HttpClient);
96
+ /** Escape hatch — call any admin endpoint by method + path. */
97
+ request<T = Json>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", path: string, body?: unknown, query?: Query): Promise<T>;
98
+ dashboard(): Promise<Json>;
99
+ stats(): Promise<Json>;
100
+ auditLog(params?: {
101
+ limit?: number;
102
+ cursor?: string;
103
+ }): Promise<Json>;
104
+ detailedHealth(): Promise<Json>;
105
+ grantCredits(params: {
106
+ tenantId: string;
107
+ amount: number;
108
+ description: string;
109
+ expiresAt?: string;
110
+ }): Promise<Json>;
111
+ deductCredits(params: {
112
+ tenantId: string;
113
+ amount: number;
114
+ description: string;
115
+ }): Promise<Json>;
116
+ refundCredits(params: {
117
+ tenantId: string;
118
+ amount: number;
119
+ description: string;
120
+ transactionId?: string;
121
+ }): Promise<Json>;
122
+ tenantBalance(tenantId: string): Promise<Json>;
123
+ tenantCreditHistory(tenantId: string, params?: {
124
+ limit?: number;
125
+ cursor?: string;
126
+ }): Promise<Json>;
127
+ listUsers(params?: ListAdminUsersParams): Promise<Json>;
128
+ getUser(userId: string): Promise<Json>;
129
+ updateUser(userId: string, attrs: Json): Promise<Json>;
130
+ deleteUser(userId: string): Promise<Json>;
131
+ changeUserRole(userId: string, role: "user" | "admin" | "owner" | "super_admin"): Promise<Json>;
132
+ forceLogout(userId: string): Promise<Json>;
133
+ suspendUser(userId: string, reason?: string): Promise<Json>;
134
+ unsuspendUser(userId: string): Promise<Json>;
135
+ banUser(userId: string, reason: string, expiresAt?: string): Promise<Json>;
136
+ unbanUser(userId: string): Promise<Json>;
137
+ bulkUserAction(params: BulkUserActionParams): Promise<Json>;
138
+ listTenants(params?: ListAdminTenantsParams): Promise<Json>;
139
+ tenantDetail(tenantId: string): Promise<Json>;
140
+ suspendTenant(tenantId: string, reason?: string): Promise<Json>;
141
+ unsuspendTenant(tenantId: string): Promise<Json>;
142
+ changeTenantPlan(tenantId: string, plan: "free" | "starter" | "pro" | "scale", prorate?: boolean): Promise<Json>;
143
+ deleteTenant(tenantId: string): Promise<Json>;
144
+ listComputers(params?: ListAdminComputersParams): Promise<Json>;
145
+ deleteComputer(computerId: string): Promise<Json>;
146
+ suspendComputer(computerId: string): Promise<Json>;
147
+ resumeComputer(computerId: string): Promise<Json>;
148
+ restartComputer(computerId: string): Promise<Json>;
149
+ purgeStaleComputers(): Promise<Json>;
150
+ listApiKeys(params?: ListAdminApiKeysParams): Promise<Json>;
151
+ createApiKey(params: CreateAdminApiKeyParams): Promise<Json>;
152
+ apiKeyStats(): Promise<Json>;
153
+ bulkRevokeApiKeys(keyIds: string[]): Promise<Json>;
154
+ revokeApiKey(keyId: string): Promise<Json>;
155
+ optimalStatus(): Promise<Json>;
156
+ listOptimalModels(): Promise<Json>;
157
+ switchOptimalModel(modelId: string): Promise<Json>;
158
+ }
159
+
160
+ /**
161
+ * Analytics — overview + timeseries (admin scope).
162
+ */
163
+
164
+ interface AnalyticsFilters {
165
+ [key: string]: string | number | boolean | undefined;
166
+ }
167
+ interface TimeseriesParams extends AnalyticsFilters {
168
+ metric?: string;
169
+ period?: string;
170
+ }
171
+ declare class Analytics {
172
+ private readonly http;
173
+ constructor(http: HttpClient);
174
+ /** Get the platform analytics overview. */
175
+ overview(filters?: AnalyticsFilters): Promise<Record<string, unknown>>;
176
+ /** Get a timeseries for a metric over a period. */
177
+ timeseries(params?: TimeseriesParams): Promise<Record<string, unknown>>;
178
+ }
179
+
180
+ /**
181
+ * ApiKeys resource — programmatic API key management.
182
+ *
183
+ * The plaintext key is returned ONLY at create time. Store it immediately;
184
+ * the server only keeps a hash.
185
+ */
186
+
187
+ type ApiKeyId = string & {
188
+ readonly __brand: "ApiKeyId";
189
+ };
190
+ interface ApiKeyData {
191
+ id: ApiKeyId;
192
+ tenant_id: string;
193
+ name: string;
194
+ prefix?: string;
195
+ scopes?: string[];
196
+ expires_at?: string | null;
197
+ last_used_at?: string | null;
198
+ created_at?: string;
199
+ [key: string]: unknown;
200
+ }
201
+ interface ApiKeyCreateResult extends ApiKeyData {
202
+ /** One-time plaintext key. Store immediately. */
203
+ token?: string;
204
+ key?: string;
205
+ }
206
+ interface ApiKeyListParams {
207
+ limit?: number;
208
+ cursor?: string;
209
+ [key: string]: string | number | boolean | undefined;
210
+ }
211
+ interface ApiKeyCreateParams {
212
+ name: string;
213
+ scopes?: string[];
214
+ expires_at?: string;
215
+ expiresAt?: string;
216
+ idempotencyKey?: string;
217
+ [key: string]: unknown;
218
+ }
219
+ declare class ApiKeys {
220
+ private readonly http;
221
+ constructor(http: HttpClient);
222
+ list(params?: ApiKeyListParams): Promise<ApiKeyData[]>;
223
+ create(params: ApiKeyCreateParams): Promise<ApiKeyCreateResult>;
224
+ delete(keyId: string): Promise<void>;
225
+ }
226
+
227
+ /**
228
+ * Audit log — admin-scoped event history.
229
+ */
230
+
231
+ interface AuditLogEvent {
232
+ id?: string;
233
+ action?: string;
234
+ actor_id?: string;
235
+ resource_type?: string;
236
+ resource_id?: string;
237
+ metadata?: Record<string, unknown>;
238
+ inserted_at?: string;
239
+ [key: string]: unknown;
240
+ }
241
+ interface AuditLogListParams {
242
+ action?: string;
243
+ actor_id?: string;
244
+ resource_type?: string;
245
+ limit?: number;
246
+ cursor?: string;
247
+ [key: string]: string | number | boolean | undefined;
248
+ }
249
+ declare class AuditLog {
250
+ private readonly http;
251
+ constructor(http: HttpClient);
252
+ /** List audit-log events with optional filters. */
253
+ list(params?: AuditLogListParams): Promise<AuditLogEvent[]>;
254
+ }
255
+
256
+ /**
257
+ * Benchmarks — admin-triggered platform benchmark runs.
258
+ *
259
+ * Routes: /admin/benchmarks/*
260
+ * Requires admin credential (msk_a_* / msk_p_* or admin JWT).
261
+ * Available kinds: cold_boot, fleet_routing, concurrent_create, full_e2e.
262
+ */
263
+
264
+ interface BenchmarkCreateParams {
265
+ kind: string;
266
+ [key: string]: unknown;
267
+ }
268
+ interface BenchmarkCompareParams {
269
+ left_id: string;
270
+ right_id: string;
271
+ [key: string]: unknown;
272
+ }
273
+ declare class Benchmarks {
274
+ private readonly http;
275
+ constructor(http: HttpClient);
276
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
277
+ get(benchmarkId: string): Promise<Record<string, unknown>>;
278
+ /** Start a new benchmark run — pass kind and run-specific options. */
279
+ create(params: BenchmarkCreateParams): Promise<Record<string, unknown>>;
280
+ cancel(benchmarkId: string): Promise<Record<string, unknown>>;
281
+ /** Return per-iteration timing samples for a benchmark run. */
282
+ samples(benchmarkId: string, filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
283
+ /** Compare two benchmark runs. */
284
+ compare(params: BenchmarkCompareParams): Promise<Record<string, unknown>>;
285
+ }
286
+
287
+ /**
288
+ * BuilderSessions — durable, cross-device Builder UI state.
289
+ *
290
+ * Routes: /builder/sessions/*
291
+ * Accepts msk_* API keys or JWT.
292
+ * Sessions are optimal_sessions with resource_type="sandbox".
293
+ */
294
+
295
+ interface BuilderSessionListParams {
296
+ limit?: number;
297
+ [key: string]: string | number | boolean | undefined;
298
+ }
299
+ declare class BuilderSessions {
300
+ private readonly http;
301
+ constructor(http: HttpClient);
302
+ list(params?: BuilderSessionListParams): Promise<Record<string, unknown>[]>;
303
+ /**
304
+ * Get a single session. The platform router only exposes index +
305
+ * title-update + delete, so this filters list() client-side.
306
+ */
307
+ get(sessionId: string): Promise<Record<string, unknown>>;
308
+ updateTitle(sessionId: string, title: string): Promise<Record<string, unknown>>;
309
+ delete(sessionId: string): Promise<void>;
310
+ }
311
+
312
+ /**
313
+ * Channels — notification preferences + per-channel enable/disable.
314
+ */
315
+
316
+ interface ChannelData {
317
+ id?: string;
318
+ type?: string;
319
+ name?: string;
320
+ enabled?: boolean;
321
+ config?: Record<string, unknown>;
322
+ [key: string]: unknown;
323
+ }
324
+ interface ChannelListParams {
325
+ type?: string;
326
+ enabled?: boolean;
327
+ [key: string]: string | number | boolean | undefined;
328
+ }
329
+ interface ChannelCreateParams {
330
+ type: string;
331
+ name?: string;
332
+ config?: Record<string, unknown>;
333
+ [key: string]: unknown;
334
+ }
335
+ interface ChannelUpdateParams {
336
+ name?: string;
337
+ config?: Record<string, unknown>;
338
+ [key: string]: unknown;
339
+ }
340
+ interface NotificationPrefsUpdateParams {
341
+ [key: string]: unknown;
342
+ }
343
+ declare class Channels {
344
+ private readonly http;
345
+ constructor(http: HttpClient);
346
+ /** List all channels for the tenant. */
347
+ list(params?: ChannelListParams): Promise<ChannelData[]>;
348
+ /** Get a single channel. */
349
+ get(channelId: string): Promise<ChannelData>;
350
+ /** Create a new channel. */
351
+ create(params: ChannelCreateParams): Promise<ChannelData>;
352
+ /** Update a channel. */
353
+ update(channelId: string, params: ChannelUpdateParams): Promise<ChannelData>;
354
+ /** Delete a channel. */
355
+ delete(channelId: string): Promise<void>;
356
+ /** Get notification preferences across all channels. */
357
+ listNotifications(): Promise<Record<string, unknown>>;
358
+ /** Update notification preferences. */
359
+ updateNotifications(params: NotificationPrefsUpdateParams): Promise<Record<string, unknown>>;
360
+ /** Enable a channel. */
361
+ enable(channelId: string): Promise<ChannelData>;
362
+ /** Disable a channel. */
363
+ disable(channelId: string): Promise<ChannelData>;
364
+ }
365
+
366
+ /**
367
+ * CommandCenter — agent fleet, orchestrations, metrics.
368
+ *
369
+ * Routes: /command-center/*
370
+ * Requires JWT or msk_u_* API key.
371
+ */
372
+
373
+ declare class CommandCenter {
374
+ private readonly http;
375
+ constructor(http: HttpClient);
376
+ /** Top-level snapshot (GET /command-center). */
377
+ overview(): Promise<Record<string, unknown>>;
378
+ agents(): Promise<Record<string, unknown>[]>;
379
+ runningAgents(): Promise<Record<string, unknown>[]>;
380
+ metrics(): Promise<Record<string, unknown>>;
381
+ presets(): Promise<Record<string, unknown>[]>;
382
+ tiers(): Promise<Record<string, unknown>>;
383
+ /** Stream live command-center events via SSE. */
384
+ events(): AsyncIterableIterator<Record<string, unknown>>;
385
+ }
386
+
387
+ /**
388
+ * Community — public template + agent catalog with install + rate.
389
+ *
390
+ * Routes: /community/*
391
+ * Requires JWT.
392
+ */
393
+
394
+ declare class Community {
395
+ private readonly http;
396
+ constructor(http: HttpClient);
397
+ listAgents(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
398
+ getAgent(agentId: string): Promise<Record<string, unknown>>;
399
+ listTemplates(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
400
+ getTemplate(templateId: string): Promise<Record<string, unknown>>;
401
+ /** Install a community template into the caller's tenant. */
402
+ installTemplate(templateId: string, opts?: Record<string, unknown>): Promise<Record<string, unknown>>;
403
+ /** Rate a community template (1–5). */
404
+ rateTemplate(templateId: string, rating: number, opts?: Record<string, unknown>): Promise<Record<string, unknown>>;
405
+ }
406
+
407
+ /**
408
+ * Completions — OpenAI-compatible chat / text completion endpoints.
409
+ *
410
+ * Routes: POST /intelligence/completions, POST /intelligence/chat/completions
411
+ * Requires an mki_* intelligence key. Supports stream=true via SSE.
412
+ */
413
+
414
+ interface CompletionBase {
415
+ model: string;
416
+ prompt?: string | string[];
417
+ [key: string]: unknown;
418
+ }
419
+ interface CompletionCreateParams extends CompletionBase {
420
+ stream?: false;
421
+ }
422
+ interface CompletionCreateStreamParams extends CompletionBase {
423
+ stream: true;
424
+ }
425
+ interface ChatBase {
426
+ model: string;
427
+ messages: Record<string, unknown>[];
428
+ [key: string]: unknown;
429
+ }
430
+ interface ChatCompletionCreateParams extends ChatBase {
431
+ stream?: false;
432
+ }
433
+ interface ChatCompletionCreateStreamParams extends ChatBase {
434
+ stream: true;
435
+ }
436
+ declare class Completions {
437
+ private readonly http;
438
+ constructor(http: HttpClient);
439
+ /** Create a text completion (POST /intelligence/completions). */
440
+ create(params: CompletionCreateParams): Promise<Record<string, unknown>>;
441
+ create(params: CompletionCreateStreamParams): AsyncIterableIterator<Record<string, unknown>>;
442
+ /** Create a chat completion (POST /intelligence/chat/completions). */
443
+ chat(params: ChatCompletionCreateParams): Promise<Record<string, unknown>>;
444
+ chat(params: ChatCompletionCreateStreamParams): AsyncIterableIterator<Record<string, unknown>>;
445
+ }
446
+
447
+ /** Producer names that can be subscribed to. */
448
+ type EventProducer = "window" | "clipboard" | "file" | "process" | "idle";
449
+ /** Options for `Events.subscribe()`. */
450
+ interface EventSubscribeOptions {
451
+ /** At least one producer is required. */
452
+ subscribe: EventProducer[];
453
+ /** Paths to watch for the `file` producer. Defaults to `["/home/user"]`. */
454
+ paths?: string[];
455
+ /** Idle threshold in seconds for the `idle` producer. Defaults to 30. */
456
+ idleThresholdSec?: number;
457
+ }
458
+ interface WindowFocusChangedPayload {
459
+ window_id: string;
460
+ pid: string;
461
+ title: string;
462
+ }
463
+ interface WindowOpenedPayload {
464
+ window_id: string;
465
+ pid: string;
466
+ title: string;
467
+ }
468
+ interface WindowClosedPayload {
469
+ window_id: string;
470
+ pid: string;
471
+ title: string;
472
+ }
473
+ interface ClipboardChangedPayload {
474
+ size_bytes: number;
475
+ }
476
+ interface FileCreatedPayload {
477
+ path: string;
478
+ }
479
+ interface FileModifiedPayload {
480
+ path: string;
481
+ }
482
+ interface FileDeletedPayload {
483
+ path: string;
484
+ }
485
+ interface ProcessStartedPayload {
486
+ pid: number;
487
+ cmd: string;
488
+ ppid: string;
489
+ }
490
+ interface ProcessStoppedPayload {
491
+ pid: number;
492
+ cmd: string;
493
+ }
494
+ interface IdleInactivePayload {
495
+ idle_ms: number;
496
+ }
497
+ interface IdleActivePayload {
498
+ idle_ms: number;
499
+ }
500
+ interface ProducerUnavailablePayload {
501
+ producer: EventProducer;
502
+ reason: string;
503
+ }
504
+ /** Union of all typed event envelopes. */
505
+ type ComputerEvent = {
506
+ type: "window.focus_changed";
507
+ timestamp: string;
508
+ payload: WindowFocusChangedPayload;
509
+ } | {
510
+ type: "window.opened";
511
+ timestamp: string;
512
+ payload: WindowOpenedPayload;
513
+ } | {
514
+ type: "window.closed";
515
+ timestamp: string;
516
+ payload: WindowClosedPayload;
517
+ } | {
518
+ type: "clipboard.changed";
519
+ timestamp: string;
520
+ payload: ClipboardChangedPayload;
521
+ } | {
522
+ type: "file.created";
523
+ timestamp: string;
524
+ payload: FileCreatedPayload;
525
+ } | {
526
+ type: "file.modified";
527
+ timestamp: string;
528
+ payload: FileModifiedPayload;
529
+ } | {
530
+ type: "file.deleted";
531
+ timestamp: string;
532
+ payload: FileDeletedPayload;
533
+ } | {
534
+ type: "process.started";
535
+ timestamp: string;
536
+ payload: ProcessStartedPayload;
537
+ } | {
538
+ type: "process.stopped";
539
+ timestamp: string;
540
+ payload: ProcessStoppedPayload;
541
+ } | {
542
+ type: "idle.inactive";
543
+ timestamp: string;
544
+ payload: IdleInactivePayload;
545
+ } | {
546
+ type: "idle.active";
547
+ timestamp: string;
548
+ payload: IdleActivePayload;
549
+ } | {
550
+ type: "producer.unavailable";
551
+ timestamp: string;
552
+ payload: ProducerUnavailablePayload;
553
+ };
554
+ type EventMap = {
555
+ [K in ComputerEvent["type"]]: [
556
+ Extract<ComputerEvent, {
557
+ type: K;
558
+ }>["payload"]
559
+ ];
560
+ } & {
561
+ error: [Error];
562
+ close: [{
563
+ code: number;
564
+ reason: string;
565
+ }];
566
+ };
567
+ /**
568
+ * Typed event stream returned by `computer.events.subscribe()`.
569
+ *
570
+ * ```ts
571
+ * const stream = computer.events.subscribe({ subscribe: ["file", "process"] });
572
+ * stream.on("file.created", e => console.log("created:", e.path));
573
+ * stream.on("process.started", e => console.log("pid:", e.pid));
574
+ * stream.on("error", err => console.error(err));
575
+ * await stream.close();
576
+ * ```
577
+ */
578
+ declare class EventStream extends EventEmitter<EventMap> {
579
+ private ws;
580
+ private closed;
581
+ /** @internal — use `Events.subscribe()` instead. */
582
+ constructor(ws: WebSocket | ws.WebSocket);
583
+ private attachHandlers;
584
+ /** Close the event stream. Idempotent. */
585
+ close(): Promise<void>;
586
+ /** Whether the stream has been closed (by client or server). */
587
+ get isClosed(): boolean;
588
+ }
589
+ /**
590
+ * Events resource attached to every `Computer` instance.
591
+ * Exposes `subscribe()` for real-time in-VM event streaming.
592
+ */
593
+ declare class Events {
594
+ private readonly baseUrl;
595
+ private readonly apiKey;
596
+ private readonly computerId;
597
+ constructor(baseUrl: string, apiKey: string, computerId: string);
598
+ /**
599
+ * Open a WebSocket subscription for the specified producers.
600
+ *
601
+ * ```ts
602
+ * const stream = computer.events.subscribe({
603
+ * subscribe: ["window", "clipboard", "file"],
604
+ * paths: ["/home/user", "/workspace"],
605
+ * });
606
+ * stream.on("window.focus_changed", e => ...);
607
+ * stream.on("file.created", e => ...);
608
+ * stream.on("error", err => ...);
609
+ * await stream.close();
610
+ * ```
611
+ */
612
+ subscribe(options: EventSubscribeOptions): EventStream;
613
+ private buildWsUrl;
614
+ }
615
+
616
+ type CustomDomainStatus = "pending" | "verified" | "active" | "failed" | "removed";
617
+ interface CustomDomainData$1 {
618
+ id: string;
619
+ computer_id: string;
620
+ tenant_id: string;
621
+ fqdn: string;
622
+ status: CustomDomainStatus;
623
+ /** The CNAME target the user must point their DNS record at. */
624
+ verification_target: string;
625
+ /** Human-readable DNS setup instructions. */
626
+ instructions: string;
627
+ verified_at: string | null;
628
+ tls_issued_at: string | null;
629
+ created_at: string;
630
+ updated_at: string;
631
+ }
632
+ /**
633
+ * Custom domain management for a Computer.
634
+ *
635
+ * Accessed via `computer.domains`.
636
+ *
637
+ * ## Workflow
638
+ * ```ts
639
+ * // 1. Register the domain
640
+ * const domain = await computer.domains.register("app.example.com");
641
+ * console.log(domain.instructions);
642
+ * // => "Add a CNAME record: app.example.com → <slug>.sandbox.miosa.ai"
643
+ *
644
+ * // 2. Add the CNAME in your DNS registrar, then...
645
+ *
646
+ * // 3. Verify ownership
647
+ * const verified = await computer.domains.verify(domain.id);
648
+ * // Caddy auto-issues a TLS certificate after this point.
649
+ * ```
650
+ */
651
+ declare class CustomDomains {
652
+ private readonly http;
653
+ private readonly computerId;
654
+ constructor(http: HttpClient, computerId: string);
655
+ private base;
656
+ /**
657
+ * Register a custom FQDN for this computer.
658
+ *
659
+ * Returns the domain record with `verification_target` and `instructions`
660
+ * showing which CNAME record to add. The domain starts in `pending` status.
661
+ *
662
+ * @param fqdn - The fully-qualified domain name to register
663
+ * (e.g. `"app.example.com"`). Must be lowercase RFC 1123, ≤ 253 chars,
664
+ * and must NOT end with `miosa.ai`.
665
+ */
666
+ register(fqdn: string): Promise<CustomDomainData$1>;
667
+ /**
668
+ * List all custom domains registered for this computer.
669
+ */
670
+ list(): Promise<CustomDomainData$1[]>;
671
+ /**
672
+ * Verify DNS ownership of a registered domain.
673
+ *
674
+ * The control plane resolves the domain's CNAME and confirms it points to
675
+ * the expected `verification_target`. On success the domain transitions to
676
+ * `verified` status and Caddy will auto-issue a TLS certificate on the next
677
+ * inbound request.
678
+ *
679
+ * @param id - The custom domain record id (from `register()` or `list()`).
680
+ * @throws `ApiError` with code `CNAME_MISMATCH` if the CNAME doesn't match.
681
+ * @throws `ApiError` with code `DNS_LOOKUP_FAILED` if DNS is unreachable.
682
+ */
683
+ verify(id: string): Promise<CustomDomainData$1>;
684
+ /**
685
+ * Delete a custom domain mapping.
686
+ *
687
+ * The domain is immediately removed from the routing cache and Caddy will
688
+ * stop serving it on the next cert renewal cycle.
689
+ *
690
+ * @param id - The custom domain record id.
691
+ */
692
+ delete(id: string): Promise<void>;
693
+ }
694
+
695
+ type ComputerId = string & {
696
+ readonly __brand: "ComputerId";
697
+ };
698
+ type SessionId = string & {
699
+ readonly __brand: "SessionId";
700
+ };
701
+ type TenantId = string & {
702
+ readonly __brand: "TenantId";
703
+ };
704
+ type ComputerSize = "small" | "medium" | "large";
705
+ /**
706
+ * Lifecycle states emitted by the control plane.
707
+ *
708
+ * Canonical states (what the server actually emits):
709
+ * provisioning — VM is being created + booted (~30-50s on small tier)
710
+ * active — running and reachable (same as legacy "running")
711
+ * paused — RAM snapshot on disk, cold start available
712
+ * stopped — explicitly halted
713
+ * error — terminal failure; destroy and retry
714
+ * destroyed — terminal; gone
715
+ *
716
+ * Legacy aliases (`running`, `starting`, `creating`, `stopping`) are kept
717
+ * in the union so older callers still typecheck, but the server will emit
718
+ * the canonical names. Treat `active` and `running` as synonymous.
719
+ */
720
+ type ComputerStatus = "provisioning" | "active" | "paused" | "stopped" | "error" | "destroyed" | "creating" | "starting" | "running" | "stopping";
721
+ /**
722
+ * Template slug for the rootfs a computer boots into.
723
+ *
724
+ * - `miosa-desktop` — full KasmVNC + Xfce GUI (default)
725
+ * - `miosa-sandbox` — lightweight code-exec rootfs, no desktop
726
+ *
727
+ * Additional templates can be added at the platform level; the type is kept
728
+ * open so future templates don't require an SDK release.
729
+ */
730
+ type ComputerTemplateType = "miosa-desktop" | "miosa-sandbox" | (string & {});
731
+ /**
732
+ * Controls who can access the computer's HTTP preview URL.
733
+ *
734
+ * - `public` — unauthenticated access to preview paths (default)
735
+ * - `tenant` — requires a valid JWT with matching tenant_id
736
+ * - `key` — requires a Bearer `msk_u_*` key matching the owner tenant
737
+ *
738
+ * Sensitive paths (`/api/*`, `/vnc/*`, `/term/*`) are always auth-gated
739
+ * regardless of visibility mode.
740
+ */
741
+ type ComputerVisibility = "public" | "tenant" | "key";
742
+ interface ComputerCreateParams {
743
+ name: string;
744
+ template_type?: ComputerTemplateType;
745
+ size?: ComputerSize;
746
+ visibility?: ComputerVisibility;
747
+ metadata?: Record<string, string>;
748
+ }
749
+ interface ComputerUpdateParams {
750
+ name?: string;
751
+ visibility?: ComputerVisibility;
752
+ metadata?: Record<string, string>;
753
+ }
754
+ interface ComputerData {
755
+ id: ComputerId;
756
+ name: string;
757
+ /**
758
+ * URL-safe identifier used in preview URLs: `https://{port}-{slug}.sandbox.miosa.ai`.
759
+ * Falls back to the computer id when no slug is assigned.
760
+ */
761
+ slug: string;
762
+ status: ComputerStatus;
763
+ template_type: ComputerTemplateType;
764
+ size: ComputerSize;
765
+ tenant_id: TenantId;
766
+ ip_address: string | null;
767
+ metadata: Record<string, string>;
768
+ /** Controls who can access the HTTP preview URL. Defaults to `"public"`. */
769
+ visibility: ComputerVisibility;
770
+ /** Public ingress root, e.g. `https://<slug>.sandbox.miosa.ai`. */
771
+ sandbox_url?: string;
772
+ /** KasmVNC URL for desktop templates. */
773
+ desktop_url?: string;
774
+ created_at: string;
775
+ updated_at: string;
776
+ }
777
+ type NetworkPolicyEffect = "allow" | "deny";
778
+ type NetworkPolicyProtocol = "tcp" | "udp" | "any";
779
+ /**
780
+ * A single egress rule.
781
+ *
782
+ * - `effect` — `"allow"` or `"deny"`
783
+ * - `destination` — CIDR (`"10.0.0.0/8"`), IP, domain (`"example.com"`),
784
+ * wildcard (`"*.example.com"`), or `"any"`
785
+ * - `ports` — optional: `"80"`, `"80,443"`, `"8000-9000"` (omit = all ports)
786
+ * - `protocol` — `"tcp"` | `"udp"` | `"any"` (default `"any"`)
787
+ */
788
+ interface NetworkPolicyRule {
789
+ effect: NetworkPolicyEffect;
790
+ destination: string;
791
+ ports?: string;
792
+ protocol?: NetworkPolicyProtocol;
793
+ }
794
+ interface NetworkPolicySetParams {
795
+ /** Rules evaluated top-to-bottom. */
796
+ rules: NetworkPolicyRule[];
797
+ /**
798
+ * Verdict when no rule matches.
799
+ * `"allow"` = allowlist entries, deny everything else.
800
+ * `"deny"` = blocklist entries, allow everything else (default).
801
+ */
802
+ default_effect?: NetworkPolicyEffect;
803
+ }
804
+ interface NetworkPolicyData {
805
+ computer_id: ComputerId;
806
+ tenant_id: TenantId;
807
+ rules: NetworkPolicyRule[];
808
+ default_effect: NetworkPolicyEffect;
809
+ inserted_at?: string;
810
+ updated_at?: string;
811
+ }
812
+ interface ComputerListResponse {
813
+ data: ComputerData[];
814
+ meta: {
815
+ total: number;
816
+ page: number;
817
+ per_page: number;
818
+ };
819
+ }
820
+ interface ComputerListParams {
821
+ page?: number;
822
+ per_page?: number;
823
+ status?: ComputerStatus;
824
+ }
825
+ type MouseButton = "left" | "right" | "middle";
826
+ type ScrollDirection = "up" | "down" | "left" | "right";
827
+ interface ClickParams {
828
+ x: number;
829
+ y: number;
830
+ button?: MouseButton;
831
+ }
832
+ interface DoubleClickParams {
833
+ x: number;
834
+ y: number;
835
+ }
836
+ interface TypeParams {
837
+ text: string;
838
+ delay?: number;
839
+ }
840
+ interface KeyParams {
841
+ key: string;
842
+ }
843
+ interface ScrollParams {
844
+ x?: number;
845
+ y?: number;
846
+ direction: ScrollDirection;
847
+ clicks?: number;
848
+ }
849
+ interface DragParams {
850
+ from_x: number;
851
+ from_y: number;
852
+ to_x: number;
853
+ to_y: number;
854
+ }
855
+ interface WaitParams {
856
+ seconds: number;
857
+ }
858
+ interface WindowInfo {
859
+ id: string;
860
+ title: string;
861
+ x: number;
862
+ y: number;
863
+ width: number;
864
+ height: number;
865
+ is_focused: boolean;
866
+ }
867
+ interface CursorInfo {
868
+ x: number;
869
+ y: number;
870
+ }
871
+ interface WindowFocusParams {
872
+ window_id: string;
873
+ }
874
+ interface LaunchParams {
875
+ app_name: string;
876
+ }
877
+ interface DesktopActionResult {
878
+ success: boolean;
879
+ }
880
+ interface ExecParams {
881
+ command: string;
882
+ timeout?: number;
883
+ }
884
+ interface ExecPythonParams {
885
+ code: string;
886
+ timeout?: number;
887
+ }
888
+ /**
889
+ * Result of `exec.bash()` / `exec.python()`.
890
+ *
891
+ * The server returns stdout and stderr separately (what every other
892
+ * runtime does too) — the older `{output, success}` shape was never
893
+ * actually emitted. `output` is kept as a read-only alias of `stdout`
894
+ * for backwards compatibility; new code should use `stdout` + `stderr`.
895
+ */
896
+ interface ExecResult {
897
+ /** Standard output from the command. */
898
+ stdout: string;
899
+ /** Standard error from the command. Empty string when no error output. */
900
+ stderr: string;
901
+ /** Process exit code. 0 = success. */
902
+ exit_code: number;
903
+ /** @deprecated alias for `stdout`; prefer `stdout` in new code. */
904
+ output?: string;
905
+ /** @deprecated derive from `exit_code === 0` in new code. */
906
+ success?: boolean;
907
+ }
908
+ interface FileEntry {
909
+ name: string;
910
+ path: string;
911
+ size: number;
912
+ is_dir: boolean;
913
+ modified_at: string;
914
+ }
915
+ interface FileListParams {
916
+ path: string;
917
+ }
918
+ interface FileDownloadParams {
919
+ path: string;
920
+ }
921
+ interface FileDeleteParams {
922
+ path: string;
923
+ }
924
+ interface FileExportParams {
925
+ path: string;
926
+ }
927
+ interface FileExportResult {
928
+ url: string;
929
+ expires_at: string;
930
+ }
931
+ interface FileListResult {
932
+ entries: FileEntry[];
933
+ path: string;
934
+ }
935
+ interface FileStat {
936
+ path: string;
937
+ /** File size in bytes. */
938
+ size: number;
939
+ /** Unix mode bits (e.g. 0o100644 for a regular file with rw-r--r--). */
940
+ mode: number;
941
+ is_dir: boolean;
942
+ is_symlink: boolean;
943
+ /** Populated when is_symlink is true. */
944
+ symlink_target?: string;
945
+ modified_at: string;
946
+ }
947
+ interface DirEntry {
948
+ name: string;
949
+ is_dir: boolean;
950
+ is_symlink: boolean;
951
+ size: number;
952
+ modified_at: string;
953
+ }
954
+ interface MkdirParams {
955
+ /** Create parent directories as needed. Defaults to true. */
956
+ recursive?: boolean;
957
+ /** Octal mode bits (e.g. 0o755). Defaults to 0o755. */
958
+ mode?: number;
959
+ }
960
+ interface CopyParams {
961
+ /** Copy directory trees recursively. Defaults to false. */
962
+ recursive?: boolean;
963
+ }
964
+ interface DirListResult {
965
+ data: {
966
+ entries: DirEntry[];
967
+ path: string;
968
+ };
969
+ }
970
+ type AgentSessionStatus$1 = "pending" | "running" | "completed" | "failed" | "cancelled";
971
+ interface AgentSessionCreateParams {
972
+ goal: string;
973
+ model_id?: string;
974
+ max_turns?: number;
975
+ }
976
+ interface AgentSessionData {
977
+ id: SessionId;
978
+ computer_id: ComputerId;
979
+ goal: string;
980
+ model_id: string;
981
+ status: AgentSessionStatus$1;
982
+ max_turns: number;
983
+ turns_used: number;
984
+ created_at: string;
985
+ updated_at: string;
986
+ completed_at: string | null;
987
+ error: string | null;
988
+ }
989
+ interface AgentSessionListResponse$1 {
990
+ data: AgentSessionData[];
991
+ }
992
+ type AgentEventType = "session_started" | "turn_started" | "thinking" | "tool_call" | "tool_result" | "streaming_token" | "agent_response" | "turn_completed" | "session_completed" | "session_failed" | "done" | "error";
993
+ interface AgentEvent$1 {
994
+ type: AgentEventType;
995
+ session_id: SessionId;
996
+ data: unknown;
997
+ timestamp: string;
998
+ }
999
+ interface CreditBalance {
1000
+ balance: number;
1001
+ expires_at: string | null;
1002
+ }
1003
+ interface CreditTransaction {
1004
+ id: string;
1005
+ amount: number;
1006
+ type: "credit" | "debit";
1007
+ description: string;
1008
+ created_at: string;
1009
+ }
1010
+ interface CreditTransactionListResponse {
1011
+ data: CreditTransaction[];
1012
+ meta: {
1013
+ total: number;
1014
+ page: number;
1015
+ per_page: number;
1016
+ };
1017
+ }
1018
+ interface CreditUsage {
1019
+ period_start: string;
1020
+ period_end: string;
1021
+ compute_credits: number;
1022
+ ai_credits: number;
1023
+ total_credits: number;
1024
+ }
1025
+
1026
+ interface MiosaClientConfig {
1027
+ apiKey: string;
1028
+ baseUrl?: string;
1029
+ timeout?: number;
1030
+ maxRetries?: number;
1031
+ }
1032
+
1033
+ type SnapshotStatus = "creating" | "uploading" | "ready" | "restoring" | "failed" | "deleted";
1034
+ interface SnapshotData {
1035
+ id: string;
1036
+ computer_id: string;
1037
+ tenant_id: string;
1038
+ comment: string | null;
1039
+ status: SnapshotStatus;
1040
+ state_size_bytes: number | null;
1041
+ memory_size_bytes: number | null;
1042
+ rootfs_size_bytes: number | null;
1043
+ compressed_size_bytes: number | null;
1044
+ s3_bucket: string | null;
1045
+ s3_prefix: string | null;
1046
+ parent_snapshot_id: string | null;
1047
+ error: string | null;
1048
+ created_at: string;
1049
+ updated_at: string;
1050
+ }
1051
+ interface SnapshotCreateParams {
1052
+ /** Optional human-readable label for this checkpoint. */
1053
+ comment?: string;
1054
+ }
1055
+ interface SnapshotRestoreResult {
1056
+ /** The newly provisioned Computer booted from this snapshot. */
1057
+ data: ComputerData;
1058
+ /** The source snapshot used for the restore. */
1059
+ snapshot: SnapshotData;
1060
+ }
1061
+ interface SnapshotListResponse {
1062
+ data: SnapshotData[];
1063
+ }
1064
+ type SnapshotProgressEvent = {
1065
+ type: "snapshot_progress";
1066
+ snapshot_id: string;
1067
+ status: SnapshotStatus | string;
1068
+ step?: string;
1069
+ progress?: number;
1070
+ error?: string;
1071
+ };
1072
+ /**
1073
+ * Firecracker microVM checkpoint management for a Computer.
1074
+ *
1075
+ * Accessed via `computer.checkpoints`.
1076
+ *
1077
+ * @example
1078
+ * ```ts
1079
+ * const snap = await computer.checkpoints.create({ comment: "before upgrade" });
1080
+ * // ... do risky work ...
1081
+ * const fresh = await computer.checkpoints.restore(snap.id);
1082
+ * ```
1083
+ */
1084
+ declare class Checkpoints {
1085
+ private readonly http;
1086
+ private readonly computerId;
1087
+ constructor(http: HttpClient, computerId: string);
1088
+ private base;
1089
+ /**
1090
+ * Create a checkpoint of the running computer.
1091
+ *
1092
+ * The returned snapshot starts in `creating` status and progresses
1093
+ * through `uploading` → `ready` asynchronously. Poll `get()` or subscribe
1094
+ * to progress events via `onProgress` to know when it's ready.
1095
+ *
1096
+ * @param params - Optional `comment` label.
1097
+ * @param onProgress - Optional callback fired for each SSE progress event.
1098
+ * Only called if a SSE ticket is available (the `events` endpoint requires
1099
+ * a prior `POST /api/v1/auth/sse-ticket` call).
1100
+ */
1101
+ create(params?: SnapshotCreateParams, onProgress?: (event: SnapshotProgressEvent) => void): Promise<SnapshotData>;
1102
+ /**
1103
+ * List all non-deleted checkpoints for this computer.
1104
+ */
1105
+ list(): Promise<SnapshotData[]>;
1106
+ /**
1107
+ * Fetch a single checkpoint by id.
1108
+ */
1109
+ get(id: string): Promise<SnapshotData>;
1110
+ /**
1111
+ * Delete a checkpoint.
1112
+ *
1113
+ * Transitions the snapshot to `deleted` and schedules S3 cleanup on the
1114
+ * server. After deletion the snapshot object is returned with
1115
+ * `status: "deleted"`.
1116
+ */
1117
+ delete(id: string): Promise<SnapshotData>;
1118
+ /**
1119
+ * Restore a checkpoint onto a fresh Computer.
1120
+ *
1121
+ * The returned Computer starts in `provisioning` status. Use
1122
+ * `computer.checkpoints.restore(id, onProgress)` to subscribe to restore
1123
+ * progress events.
1124
+ *
1125
+ * @param id - Snapshot id to restore (must be in `ready` status).
1126
+ * @param onProgress - Optional callback for SSE progress events during restore.
1127
+ * @returns A `SnapshotRestoreResult` containing the new Computer and the
1128
+ * source snapshot.
1129
+ */
1130
+ restore(id: string, onProgress?: (event: SnapshotProgressEvent) => void): Promise<SnapshotRestoreResult>;
1131
+ /**
1132
+ * Subscribe to Server-Sent Events for a snapshot's progress.
1133
+ *
1134
+ * Yields `SnapshotProgressEvent` objects until the stream closes or
1135
+ * `status` reaches a terminal state (`ready`, `failed`, `deleted`).
1136
+ *
1137
+ * Requires a valid SSE ticket obtained via
1138
+ * `POST /api/v1/auth/sse-ticket` and passed as `?ticket=<token>`.
1139
+ *
1140
+ * @param id - Snapshot id to watch.
1141
+ * @param ticket - Short-lived SSE ticket from the auth endpoint.
1142
+ */
1143
+ events(id: string, ticket: string): AsyncIterableIterator<SnapshotProgressEvent>;
1144
+ /**
1145
+ * Internal: subscribe to SSE progress events and call `cb` for each.
1146
+ *
1147
+ * Resolves when the stream closes. Any auth/network errors are silently
1148
+ * swallowed so the caller isn't blocked on progress-tracking failures.
1149
+ */
1150
+ private subscribeProgress;
1151
+ }
1152
+
1153
+ /**
1154
+ * ComputerAutoStop — read/update idle-timeout config.
1155
+ *
1156
+ * Routes:
1157
+ * GET /computers/:id/auto-stop
1158
+ * PATCH /computers/:id/auto-stop
1159
+ */
1160
+
1161
+ declare class ComputerAutoStop {
1162
+ private readonly http;
1163
+ private readonly computerId;
1164
+ constructor(http: HttpClient, computerId: string);
1165
+ /** Return the current auto-stop configuration. */
1166
+ get(): Promise<Record<string, unknown>>;
1167
+ /** Set the idle timeout in seconds (0 disables auto-stop). */
1168
+ update(seconds: number): Promise<Record<string, unknown>>;
1169
+ }
1170
+
1171
+ /**
1172
+ * ComputerEnv — encrypted env var CRUD scoped to one Computer.
1173
+ *
1174
+ * Routes:
1175
+ * GET /computers/:id/env → list
1176
+ * POST /computers/:id/env → create (single)
1177
+ * PATCH /computers/:id/env/:name → update value
1178
+ * DELETE /computers/:id/env/:name → remove
1179
+ *
1180
+ * bulkSet falls back to N individual POSTs (no bulk endpoint yet).
1181
+ */
1182
+
1183
+ declare class ComputerEnv {
1184
+ private readonly http;
1185
+ private readonly computerId;
1186
+ constructor(http: HttpClient, computerId: string);
1187
+ private base;
1188
+ /** List all env vars (values may be masked depending on server policy). */
1189
+ list(): Promise<Record<string, unknown>[]>;
1190
+ /** Create a new env var. Use update() to change an existing one. */
1191
+ set(name: string, value: string): Promise<Record<string, unknown>>;
1192
+ /** Patch the value of an existing env var by name. */
1193
+ update(name: string, value: string): Promise<Record<string, unknown>>;
1194
+ /** Remove an env var by name. */
1195
+ delete(name: string): Promise<void>;
1196
+ /** Convenience: create one env var per entry. */
1197
+ bulkSet(env: Record<string, string>): Promise<Record<string, unknown>[]>;
1198
+ }
1199
+
1200
+ /**
1201
+ * ComputerLogs — read + stream VM logs.
1202
+ *
1203
+ * Routes:
1204
+ * GET /computers/:id/logs — JSON snapshot (last N lines)
1205
+ * GET /computers/:id/logs/stream — text/event-stream of new lines (SSE)
1206
+ */
1207
+
1208
+ interface ComputerLogsGetParams {
1209
+ lines?: number;
1210
+ since?: string;
1211
+ }
1212
+ declare class ComputerLogs {
1213
+ private readonly http;
1214
+ private readonly computerId;
1215
+ constructor(http: HttpClient, computerId: string);
1216
+ /** Fetch the most recent log snapshot. */
1217
+ get(params?: ComputerLogsGetParams): Promise<Record<string, unknown>>;
1218
+ /** Stream live log events as SSE dicts `{type, data, id}`. */
1219
+ stream(): AsyncIterableIterator<Record<string, unknown>>;
1220
+ }
1221
+
1222
+ /**
1223
+ * ComputerOsa — task dispatch to the in-VM OSA agent.
1224
+ *
1225
+ * Routes:
1226
+ * POST /computers/:id/osa/task
1227
+ * DELETE /computers/:id/osa/task
1228
+ * GET /computers/:id/osa/status
1229
+ * POST /computers/:id/osa/configure
1230
+ */
1231
+
1232
+ declare class ComputerOsa {
1233
+ private readonly http;
1234
+ private readonly computerId;
1235
+ constructor(http: HttpClient, computerId: string);
1236
+ /** Submit a free-form task to the in-VM OSA agent. */
1237
+ submitTask(task: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
1238
+ /** Cancel the currently-running OSA task, if any. */
1239
+ cancelTask(): Promise<Record<string, unknown>>;
1240
+ /** Return OSA's current task / configuration / health snapshot. */
1241
+ status(): Promise<Record<string, unknown>>;
1242
+ /** Update OSA runtime configuration (model, tools, secrets, etc.). */
1243
+ configure(config: Record<string, unknown>): Promise<Record<string, unknown>>;
1244
+ }
1245
+
1246
+ /**
1247
+ * ComputerPorts — per-port visibility control.
1248
+ *
1249
+ * Routes:
1250
+ * GET /computers/:id/ports — list
1251
+ * POST /computers/:id/ports — create
1252
+ * PATCH /computers/:id/ports/:port — update
1253
+ * DELETE /computers/:id/ports/:port — delete
1254
+ *
1255
+ * The backend does not expose a single-port GET; get() filters the list
1256
+ * response client-side for ergonomics.
1257
+ */
1258
+
1259
+ declare class ComputerPorts {
1260
+ private readonly http;
1261
+ private readonly computerId;
1262
+ constructor(http: HttpClient, computerId: string);
1263
+ private base;
1264
+ list(): Promise<Record<string, unknown>[]>;
1265
+ /** Return the port record for port, or null if not exposed. */
1266
+ get(port: number): Promise<Record<string, unknown> | null>;
1267
+ /** Expose port with the given visibility options. */
1268
+ create(port: number, opts?: Record<string, unknown>): Promise<Record<string, unknown>>;
1269
+ /** Patch visibility / auth options for port. */
1270
+ update(port: number, opts: Record<string, unknown>): Promise<Record<string, unknown>>;
1271
+ /** Stop exposing port. */
1272
+ delete(port: number): Promise<void>;
1273
+ }
1274
+
1275
+ /**
1276
+ * ComputerTerminal — PTY session management for a Computer.
1277
+ *
1278
+ * Routes:
1279
+ * POST /computers/:id/terminal
1280
+ * POST /computers/:id/pty/:sessionId/resize
1281
+ */
1282
+
1283
+ interface TerminalCreateParams {
1284
+ cols?: number;
1285
+ rows?: number;
1286
+ shell?: string;
1287
+ cwd?: string;
1288
+ env?: Record<string, string>;
1289
+ }
1290
+ declare class ComputerTerminal {
1291
+ private readonly http;
1292
+ private readonly computerId;
1293
+ constructor(http: HttpClient, computerId: string);
1294
+ /** Open a new PTY session. Returns the server payload (session id, etc.). */
1295
+ create(params?: TerminalCreateParams): Promise<Record<string, unknown>>;
1296
+ /** Resize an existing PTY session. */
1297
+ resize(sessionId: string, cols: number, rows: number): Promise<Record<string, unknown>>;
1298
+ }
1299
+
1300
+ /**
1301
+ * ComputerVolumes — per-computer volume attachment.
1302
+ *
1303
+ * Routes:
1304
+ * GET /computers/:id/volumes — list attachments
1305
+ * POST /computers/:id/volumes — attach a volume
1306
+ * DELETE /computers/:id/volumes/:aid — detach an attachment
1307
+ */
1308
+
1309
+ declare class ComputerVolumes {
1310
+ private readonly http;
1311
+ private readonly computerId;
1312
+ constructor(http: HttpClient, computerId: string);
1313
+ private base;
1314
+ list(): Promise<Record<string, unknown>[]>;
1315
+ /** Attach volumeId at mountPath inside the VM. */
1316
+ attach(volumeId: string, mountPath: string): Promise<Record<string, unknown>>;
1317
+ /** Detach an existing attachment by attachment id. */
1318
+ detach(attachmentId: string): Promise<void>;
1319
+ }
1320
+
1321
+ declare class Desktop$1 {
1322
+ private readonly http;
1323
+ private readonly computerId;
1324
+ constructor(http: HttpClient, computerId: string);
1325
+ private base;
1326
+ /** Capture a screenshot of the desktop. Returns raw PNG bytes. */
1327
+ screenshot(): Promise<Uint8Array>;
1328
+ /** Click at the given coordinates. */
1329
+ click(x: number, y: number, button?: ClickParams["button"]): Promise<DesktopActionResult>;
1330
+ /** Double-click at the given coordinates. */
1331
+ doubleClick(x: number, y: number): Promise<DesktopActionResult>;
1332
+ /** Type text into the currently focused element. */
1333
+ type(text: string, delay?: number): Promise<DesktopActionResult>;
1334
+ /** Send a key or key combination (e.g. "Enter", "ctrl+c"). */
1335
+ key(key: string): Promise<DesktopActionResult>;
1336
+ /** Scroll in a direction at an optional position. */
1337
+ scroll(direction: ScrollParams["direction"], clicks?: number, x?: number, y?: number): Promise<DesktopActionResult>;
1338
+ /** Click and drag from one coordinate to another. */
1339
+ drag(fromX: number, fromY: number, toX: number, toY: number): Promise<DesktopActionResult>;
1340
+ /** Wait for the given number of seconds. */
1341
+ wait(seconds: number): Promise<DesktopActionResult>;
1342
+ /** List all open windows on the desktop. */
1343
+ windows(): Promise<WindowInfo[]>;
1344
+ /** Get the current cursor position. */
1345
+ cursor(): Promise<CursorInfo>;
1346
+ /** Bring the given window into focus. */
1347
+ focusWindow(windowId: string): Promise<DesktopActionResult>;
1348
+ /** Launch an application by name. */
1349
+ launch(appName: string): Promise<DesktopActionResult>;
1350
+ }
1351
+
1352
+ /** Options for `Exec.stream()`. */
1353
+ interface ExecStreamOptions {
1354
+ /** Command to execute. */
1355
+ command: string;
1356
+ /** Optional arguments. */
1357
+ args?: string[];
1358
+ /** Optional environment variables as KEY=VALUE strings. */
1359
+ env?: string[];
1360
+ /** Working directory inside the VM. */
1361
+ cwd?: string;
1362
+ /** Allocate a PTY. Defaults to false. */
1363
+ tty?: boolean;
1364
+ /** Terminal rows (when tty=true). */
1365
+ rows?: number;
1366
+ /** Terminal columns (when tty=true). */
1367
+ cols?: number;
1368
+ }
1369
+ type ExecStreamEventMap = {
1370
+ stdout: [data: Uint8Array];
1371
+ stderr: [data: Uint8Array];
1372
+ exit: [code: number];
1373
+ error: [err: Error];
1374
+ close: [code: number, reason: string];
1375
+ };
1376
+ /**
1377
+ * Live bidirectional exec stream backed by a `miosa-exec-v1` WebSocket.
1378
+ *
1379
+ * The binary wire protocol (1-byte frame ID) is handled by the server-side
1380
+ * proxy and envd. The SDK exposes typed events on the received frames:
1381
+ *
1382
+ * - `stdout` — chunk of stdout bytes
1383
+ * - `stderr` — chunk of stderr bytes
1384
+ * - `exit` — process exit code (stream ends after this)
1385
+ * - `error` — WebSocket error
1386
+ * - `close` — WebSocket closed
1387
+ *
1388
+ * Obtain via `computer.exec.stream({ command: "bash", tty: true })`.
1389
+ *
1390
+ * ```ts
1391
+ * const s = computer.exec.stream({ command: "python3", args: ["script.py"] });
1392
+ * s.on("stdout", chunk => process.stdout.write(chunk));
1393
+ * s.on("exit", code => console.log("exit:", code));
1394
+ * s.sendStdin(new TextEncoder().encode("hello\n"));
1395
+ * await s.close();
1396
+ * ```
1397
+ */
1398
+ declare class ExecStreamHandle {
1399
+ private ws;
1400
+ private closed;
1401
+ private readonly listeners;
1402
+ private static readonly FRAME_STDIN;
1403
+ private static readonly FRAME_STDOUT;
1404
+ private static readonly FRAME_STDERR;
1405
+ private static readonly FRAME_EXIT;
1406
+ /** @internal — use `Exec.stream()` instead. */
1407
+ constructor(ws: WebSocket | ws.WebSocket);
1408
+ on<K extends keyof ExecStreamEventMap>(event: K, handler: (...args: ExecStreamEventMap[K]) => void): this;
1409
+ off<K extends keyof ExecStreamEventMap>(event: K, handler: (...args: ExecStreamEventMap[K]) => void): this;
1410
+ private emit;
1411
+ /**
1412
+ * Send stdin bytes to the running process.
1413
+ * Prepends the 0x00 frame ID byte automatically.
1414
+ */
1415
+ sendStdin(data: Uint8Array): void;
1416
+ /**
1417
+ * Send a terminal resize event.
1418
+ * Encodes as 0x05 + rows (u16 BE) + cols (u16 BE).
1419
+ */
1420
+ sendResize(rows: number, cols: number): void;
1421
+ /** Close the stream. Idempotent. */
1422
+ close(): Promise<void>;
1423
+ /** Whether the stream has ended (by client or server). */
1424
+ get isClosed(): boolean;
1425
+ private attachHandlers;
1426
+ }
1427
+ /**
1428
+ * Exec resource attached to every `Computer` instance.
1429
+ * Exposes `bash()`, `python()`, and `stream()` for command execution.
1430
+ */
1431
+ declare class Exec {
1432
+ private readonly http;
1433
+ private readonly computerId;
1434
+ constructor(http: HttpClient, computerId: string);
1435
+ private base;
1436
+ /**
1437
+ * Run a shell command inside the computer.
1438
+ * @param command - Shell command string to execute.
1439
+ * @param timeout - Optional timeout in seconds.
1440
+ */
1441
+ bash(command: string, timeout?: number): Promise<ExecResult>;
1442
+ /**
1443
+ * Execute Python code inside the computer.
1444
+ * @param code - Python source code string.
1445
+ * @param timeout - Optional timeout in seconds.
1446
+ */
1447
+ python(code: string, timeout?: number): Promise<ExecResult>;
1448
+ /**
1449
+ * Open a live binary exec stream using the `miosa-exec-v1` subprotocol.
1450
+ *
1451
+ * The WebSocket negotiates `Sec-WebSocket-Protocol: miosa-exec-v1` to
1452
+ * ensure version compatibility. Future protocol versions can be added
1453
+ * server-side without breaking v1 clients.
1454
+ *
1455
+ * ```ts
1456
+ * const stream = computer.exec.stream({ command: "bash", tty: true, rows: 24, cols: 80 });
1457
+ * stream.on("stdout", data => process.stdout.write(data));
1458
+ * stream.on("exit", code => console.log("done:", code));
1459
+ * stream.sendStdin(new TextEncoder().encode("echo hello\n"));
1460
+ * ```
1461
+ */
1462
+ stream(options: ExecStreamOptions): ExecStreamHandle;
1463
+ private buildWsUrl;
1464
+ }
1465
+
1466
+ declare class Files {
1467
+ private readonly http;
1468
+ private readonly computerId;
1469
+ constructor(http: HttpClient, computerId: string);
1470
+ private base;
1471
+ /**
1472
+ * Upload a local file to the computer.
1473
+ *
1474
+ * In a Node.js environment pass a Buffer or Blob; in a browser pass a File
1475
+ * or Blob. The remote path is where the file will be written inside the VM.
1476
+ *
1477
+ * @param content - File content as Blob, Buffer, Uint8Array, or string.
1478
+ * @param remotePath - Absolute path inside the VM (e.g. /home/user/file.txt).
1479
+ * @param filename - Optional filename hint (defaults to basename of remotePath).
1480
+ */
1481
+ upload(content: Blob | Uint8Array | string, remotePath: string, _filename?: string): Promise<FileEntry>;
1482
+ /**
1483
+ * List files and directories at the given path inside the VM.
1484
+ */
1485
+ list(path: string): Promise<FileListResult>;
1486
+ /**
1487
+ * Download a file from the computer. Returns raw bytes.
1488
+ */
1489
+ download(path: string): Promise<Uint8Array>;
1490
+ /**
1491
+ * Export a file from the computer and receive a temporary signed URL.
1492
+ */
1493
+ export(path: string): Promise<FileExportResult>;
1494
+ /**
1495
+ * Delete a file or directory inside the computer.
1496
+ */
1497
+ delete(path: string): Promise<void>;
1498
+ /**
1499
+ * Stat a path inside the computer. Does not follow symlinks (lstat semantics).
1500
+ *
1501
+ * Returns `{path, size, mode, is_dir, is_symlink, symlink_target?, modified_at}`.
1502
+ */
1503
+ stat(path: string): Promise<FileStat>;
1504
+ /**
1505
+ * Create a directory inside the computer.
1506
+ *
1507
+ * @param path - Absolute path to create (e.g. `/home/user/project`).
1508
+ * @param options - `{ recursive?: boolean, mode?: number }`. Defaults: recursive=true, mode=0o755.
1509
+ */
1510
+ mkdir(path: string, options?: MkdirParams): Promise<void>;
1511
+ /**
1512
+ * Rename (move) a path inside the computer.
1513
+ *
1514
+ * Creates the destination parent directory if it does not exist.
1515
+ */
1516
+ rename(from: string, to: string): Promise<void>;
1517
+ /**
1518
+ * Copy a file or directory inside the computer.
1519
+ *
1520
+ * @param from - Source absolute path.
1521
+ * @param to - Destination absolute path.
1522
+ * @param options - `{ recursive?: boolean }`. Required when source is a directory.
1523
+ */
1524
+ copy(from: string, to: string, options?: CopyParams): Promise<void>;
1525
+ /**
1526
+ * Change permissions on a path inside the computer.
1527
+ *
1528
+ * @param path - Absolute path inside the VM.
1529
+ * @param mode - Unix mode bits as an octal integer (e.g. `0o755`) or string (`"0755"`).
1530
+ */
1531
+ chmod(path: string, mode: number | string): Promise<void>;
1532
+ /**
1533
+ * Return a rich directory listing for the given path.
1534
+ *
1535
+ * Each entry includes `{name, is_dir, is_symlink, size, modified_at}`.
1536
+ * Richer than `list()` which uses `find` under the hood.
1537
+ *
1538
+ * @param path - Absolute path to list.
1539
+ * @param _withTypes - Kept for API symmetry; types are always returned.
1540
+ */
1541
+ readdir(path: string, _withTypes?: boolean): Promise<DirEntry[]>;
1542
+ /**
1543
+ * Write a UTF-8 string to a file inside the computer.
1544
+ * Convenience wrapper around `upload()`.
1545
+ */
1546
+ writeFile(path: string, content: string): Promise<void>;
1547
+ /**
1548
+ * Read a file from the computer and return its contents as a UTF-8 string.
1549
+ */
1550
+ readFile(path: string): Promise<string>;
1551
+ }
1552
+
1553
+ /**
1554
+ * Manage egress network policy for a computer.
1555
+ *
1556
+ * A policy is a list of rules evaluated top-to-bottom, with a `default_effect`
1557
+ * applied when no rule matches.
1558
+ *
1559
+ * Example — block IMDS and allow everything else:
1560
+ * ```ts
1561
+ * await computer.networkPolicy.set({
1562
+ * default_effect: "allow",
1563
+ * rules: [
1564
+ * { effect: "deny", destination: "169.254.169.254/32" },
1565
+ * { effect: "deny", destination: "metadata.google.internal" },
1566
+ * ],
1567
+ * });
1568
+ * ```
1569
+ *
1570
+ * Example — allowlist mode (deny all by default, allow only example.com):
1571
+ * ```ts
1572
+ * await computer.networkPolicy.set({
1573
+ * default_effect: "deny",
1574
+ * rules: [
1575
+ * { effect: "allow", destination: "example.com", ports: "443", protocol: "tcp" },
1576
+ * ],
1577
+ * });
1578
+ * ```
1579
+ */
1580
+ declare class NetworkPolicy {
1581
+ private readonly http;
1582
+ private readonly computerId;
1583
+ constructor(http: HttpClient, computerId: string);
1584
+ /**
1585
+ * Get the current network policy.
1586
+ * Returns an empty allow-all policy if none is set.
1587
+ */
1588
+ get(): Promise<NetworkPolicyData>;
1589
+ /**
1590
+ * Set (create or replace) the network policy.
1591
+ * Triggers immediate nftables update on the host — running VMs pick up
1592
+ * the new rules without a restart.
1593
+ */
1594
+ set(params: NetworkPolicySetParams): Promise<NetworkPolicyData>;
1595
+ /**
1596
+ * Reset to the default policy (allow all egress).
1597
+ * Idempotent — safe to call even if no policy was set.
1598
+ */
1599
+ reset(): Promise<void>;
1600
+ }
1601
+
1602
+ /**
1603
+ * Per-computer inbox config (GET/PATCH /computers/:id/inbox).
1604
+ * Defined inline because it has no separate file (small surface).
1605
+ */
1606
+ declare class ComputerInbox {
1607
+ private readonly http;
1608
+ private readonly computerId;
1609
+ constructor(http: HttpClient, computerId: string);
1610
+ get(): Promise<Record<string, unknown>>;
1611
+ update(fields: Record<string, unknown>): Promise<Record<string, unknown>>;
1612
+ }
1613
+ /**
1614
+ * A Computer instance bound to a specific computer ID.
1615
+ *
1616
+ * Returned by `miosa.computers.create()`, `miosa.computers.get()`, and
1617
+ * `miosa.computers.list()`. Exposes all per-computer actions as methods and
1618
+ * sub-resources as properties.
1619
+ */
1620
+ declare class Computer {
1621
+ /** Raw data from the API. Refresh with `await computer.reload()`. */
1622
+ data: ComputerData;
1623
+ /** Desktop control — screenshot, click, type, drag, etc. */
1624
+ readonly desktop: Desktop$1;
1625
+ /** Execute shell and Python commands. */
1626
+ readonly exec: Exec;
1627
+ /** File operations — upload, download, list, delete. */
1628
+ readonly files: Files;
1629
+ /** Firecracker checkpoint (snapshot) management. */
1630
+ readonly checkpoints: Checkpoints;
1631
+ /** Egress network policy — allow/deny rules applied at the host TAP level. */
1632
+ readonly networkPolicy: NetworkPolicy;
1633
+ /** Real-time event subscription (window, clipboard, file, process, idle). */
1634
+ readonly events: Events;
1635
+ /** Custom domain management — map your own FQDNs to this sandbox. */
1636
+ readonly domains: CustomDomains;
1637
+ /** PTY session management — create/resize. */
1638
+ readonly terminal: ComputerTerminal;
1639
+ /** In-VM OSA agent dispatch — submitTask, cancelTask, status, configure. */
1640
+ readonly osa: ComputerOsa;
1641
+ /** Idle auto-stop config — get/update. */
1642
+ readonly autoStop: ComputerAutoStop;
1643
+ /** Per-computer inbox config — get/update. */
1644
+ readonly inbox: ComputerInbox;
1645
+ /** Encrypted env var CRUD — list, set, update, delete, bulkSet. */
1646
+ readonly env: ComputerEnv;
1647
+ /** VM log read + SSE stream. */
1648
+ readonly logs: ComputerLogs;
1649
+ /** Per-port visibility control — list, get, create, update, delete. */
1650
+ readonly ports: ComputerPorts;
1651
+ /** Volume attachment — list, attach, detach. */
1652
+ readonly volumes: ComputerVolumes;
1653
+ private readonly http;
1654
+ constructor(http: HttpClient, data: ComputerData);
1655
+ get id(): ComputerId;
1656
+ get name(): string;
1657
+ get status(): ComputerData["status"];
1658
+ /** URL-safe slug; falls back to the raw id when unset. */
1659
+ get slug(): string;
1660
+ /**
1661
+ * Public HTTPS URL that forwards to a given port inside the VM.
1662
+ *
1663
+ * Example — expose a dev server running on port 3000:
1664
+ * ```ts
1665
+ * await computer.exec.bash("npm run dev &");
1666
+ * const url = computer.previewUrl(3000);
1667
+ * // => https://3000-<slug>.sandbox.miosa.ai
1668
+ * ```
1669
+ *
1670
+ * Works for any TCP HTTP listener. Public (no auth required); anyone with
1671
+ * the URL can see it. Served over the ingress proxy so it inherits the
1672
+ * wildcard TLS cert — no per-sandbox certs to manage.
1673
+ */
1674
+ previewUrl(port: number, path?: string): string;
1675
+ /** Root preview URL — serves whatever is on the default app port. */
1676
+ get publicUrl(): string;
1677
+ /** Start the computer. */
1678
+ start(): Promise<Computer>;
1679
+ /** Stop the computer. */
1680
+ stop(): Promise<Computer>;
1681
+ /** Restart the computer. */
1682
+ restart(): Promise<Computer>;
1683
+ /** Permanently destroy the computer. After this call the instance is invalid. */
1684
+ destroy(): Promise<void>;
1685
+ /** Reload metadata from the API and update `this.data`. */
1686
+ reload(): Promise<Computer>;
1687
+ /**
1688
+ * Capture a desktop screenshot as PNG bytes.
1689
+ * Shortcut for `computer.desktop.screenshot()`.
1690
+ */
1691
+ screenshot(): Promise<Uint8Array>;
1692
+ /**
1693
+ * Capture a desktop screenshot encoded as a base64 string.
1694
+ * Convenience for AI agents that pass screenshots to LLMs.
1695
+ */
1696
+ screenshotBase64(): Promise<string>;
1697
+ /**
1698
+ * Click at the given coordinates (default left button).
1699
+ * Shortcut for `computer.desktop.click(x, y)`.
1700
+ */
1701
+ click(x: number, y: number): Promise<void>;
1702
+ /** Explicit left-button click. Alias for `click(x, y)`. */
1703
+ leftClick(x: number, y: number): Promise<void>;
1704
+ /** Right-button click. */
1705
+ rightClick(x: number, y: number): Promise<void>;
1706
+ /** Double-click at the given coordinates. */
1707
+ doubleClick(x: number, y: number): Promise<void>;
1708
+ /**
1709
+ * Type text into the focused element.
1710
+ * Shortcut for `computer.desktop.type(text)`.
1711
+ */
1712
+ type(text: string): Promise<void>;
1713
+ /**
1714
+ * Send a key or key combo.
1715
+ * Shortcut for `computer.desktop.key(key)`.
1716
+ */
1717
+ key(key: string): Promise<void>;
1718
+ /**
1719
+ * Scroll in a direction.
1720
+ * Shortcut for `computer.desktop.scroll(direction, clicks)`.
1721
+ */
1722
+ scroll(direction: Parameters<Desktop$1["scroll"]>[0], clicks?: number): Promise<void>;
1723
+ /**
1724
+ * Click and drag between two points.
1725
+ * Shortcut for `computer.desktop.drag(fromX, fromY, toX, toY)`.
1726
+ */
1727
+ drag(fromX: number, fromY: number, toX: number, toY: number): Promise<void>;
1728
+ /**
1729
+ * Wait for N seconds inside the desktop environment.
1730
+ * Shortcut for `computer.desktop.wait(seconds)`.
1731
+ */
1732
+ wait(seconds: number): Promise<void>;
1733
+ /**
1734
+ * Run a shell command.
1735
+ * Shortcut for `computer.exec.bash(command)`.
1736
+ */
1737
+ bash(command: string, timeout?: number): Promise<ExecResult>;
1738
+ /**
1739
+ * Run Python code.
1740
+ * Shortcut for `computer.exec.python(code)`.
1741
+ */
1742
+ python(code: string, timeout?: number): Promise<ExecResult>;
1743
+ /** List open windows on the desktop. */
1744
+ windows(): Promise<Awaited<ReturnType<Desktop$1["windows"]>>>;
1745
+ /** Get the current cursor position. */
1746
+ cursor(): Promise<Awaited<ReturnType<Desktop$1["cursor"]>>>;
1747
+ /** Focus a specific window by ID. */
1748
+ focusWindow(windowId: string): Promise<void>;
1749
+ /** Launch an installed app inside the VM. */
1750
+ launch(appName: string): Promise<void>;
1751
+ /**
1752
+ * Return a `ScopedFs` bound to `workingDir`. All path arguments to
1753
+ * `readFile`, `writeFile`, and `readdir` are resolved relative to that
1754
+ * directory — no need to repeat the prefix on every call.
1755
+ *
1756
+ * ```ts
1757
+ * const fs = computer.fs("/workspace");
1758
+ * await fs.writeFile("main.py", "print(1)");
1759
+ * const src = await fs.readFile("main.py");
1760
+ * const entries = await fs.readdir(".");
1761
+ * ```
1762
+ */
1763
+ fs(workingDir: string): ScopedFs;
1764
+ /** Get VNC credentials for this computer. */
1765
+ vncCredentials(): Promise<Record<string, unknown>>;
1766
+ /** List installed apps inside the VM. */
1767
+ apps(): Promise<Record<string, unknown>>;
1768
+ /** Get URL map for this computer (VNC, preview, etc.). */
1769
+ urls(): Promise<Record<string, unknown>>;
1770
+ /** Mint a short-lived stream token for this computer. */
1771
+ streamToken(): Promise<Record<string, unknown>>;
1772
+ /** Clone this computer into a new one. */
1773
+ clone(opts?: Record<string, unknown>): Promise<Computer>;
1774
+ /** Resize the computer (change CPU/memory/disk). */
1775
+ resize(size: string): Promise<Computer>;
1776
+ /** Move the computer to a different region or host. */
1777
+ move(opts: Record<string, unknown>): Promise<Computer>;
1778
+ /** Capture a region of the desktop as PNG bytes. */
1779
+ screenshotRegion(x: number, y: number, width: number, height: number): Promise<Uint8Array>;
1780
+ /** Get time-series metrics (window: "1h" | "24h" | "7d"). */
1781
+ metrics(window?: string): Promise<Record<string, unknown>>;
1782
+ toJSON(): ComputerData;
1783
+ toString(): string;
1784
+ }
1785
+ /**
1786
+ * A thin filesystem wrapper that prepends a fixed working directory to all
1787
+ * path arguments, mirroring the Node.js `fs/promises` surface.
1788
+ *
1789
+ * Obtain via `computer.fs("/workspace")`.
1790
+ */
1791
+ declare class ScopedFs {
1792
+ private readonly files;
1793
+ private readonly workingDir;
1794
+ constructor(files: Files, workingDir: string);
1795
+ /** Resolve a relative or absolute path against `workingDir`. */
1796
+ private resolve;
1797
+ /** Write a UTF-8 string to a file (relative or absolute path). */
1798
+ writeFile(path: string, content: string): Promise<void>;
1799
+ /** Read a file and return its UTF-8 contents (relative or absolute path). */
1800
+ readFile(path: string): Promise<string>;
1801
+ /** List a directory (relative or absolute path). */
1802
+ readdir(path: string): Promise<DirEntry[]>;
1803
+ /** Stat a path (relative or absolute). */
1804
+ stat(path: string): Promise<FileStat>;
1805
+ /** Create a directory (relative or absolute). */
1806
+ mkdir(path: string, options?: MkdirParams): Promise<void>;
1807
+ }
1808
+
1809
+ declare class Computers {
1810
+ private readonly http;
1811
+ constructor(http: HttpClient);
1812
+ /**
1813
+ * Create a new computer. The computer starts in `creating` state — call
1814
+ * `computer.start()` once it reaches `stopped` to boot it.
1815
+ */
1816
+ create(params: ComputerCreateParams): Promise<Computer>;
1817
+ /**
1818
+ * List all computers for the authenticated tenant.
1819
+ */
1820
+ list(params?: ComputerListParams): Promise<Computer[]>;
1821
+ /**
1822
+ * Fetch a single computer by ID.
1823
+ */
1824
+ get(id: ComputerId | string): Promise<Computer>;
1825
+ /**
1826
+ * Update computer metadata or name.
1827
+ */
1828
+ update(id: ComputerId | string, params: ComputerUpdateParams): Promise<Computer>;
1829
+ /**
1830
+ * Permanently delete a computer.
1831
+ */
1832
+ delete(id: ComputerId | string): Promise<void>;
1833
+ }
1834
+
1835
+ interface CreditTransactionListParams {
1836
+ page?: number;
1837
+ per_page?: number;
1838
+ }
1839
+ declare class Credits {
1840
+ private readonly http;
1841
+ constructor(http: HttpClient);
1842
+ /** Get the current credit balance for the authenticated tenant. */
1843
+ balance(): Promise<CreditBalance>;
1844
+ /** List credit transactions (purchases, deductions). */
1845
+ transactions(params?: CreditTransactionListParams): Promise<CreditTransactionListResponse>;
1846
+ /** Get aggregated credit usage for the current billing period. */
1847
+ usage(): Promise<CreditUsage>;
1848
+ }
1849
+
1850
+ /**
1851
+ * CronJobs resource — scheduled work.
1852
+ */
1853
+
1854
+ type CronJobId = string & {
1855
+ readonly __brand: "CronJobId";
1856
+ };
1857
+ type CronJobExecutionId = string & {
1858
+ readonly __brand: "CronJobExecutionId";
1859
+ };
1860
+ interface CronJobData {
1861
+ id: CronJobId;
1862
+ tenant_id: string;
1863
+ name: string;
1864
+ schedule: string;
1865
+ state?: string;
1866
+ paused?: boolean;
1867
+ last_run_at?: string | null;
1868
+ next_run_at?: string | null;
1869
+ created_at?: string;
1870
+ updated_at?: string;
1871
+ [key: string]: unknown;
1872
+ }
1873
+ interface CronJobExecutionData {
1874
+ id: CronJobExecutionId;
1875
+ cron_job_id: CronJobId;
1876
+ state?: string;
1877
+ started_at?: string | null;
1878
+ finished_at?: string | null;
1879
+ duration_ms?: number | null;
1880
+ exit_code?: number | null;
1881
+ error?: string | null;
1882
+ created_at?: string;
1883
+ [key: string]: unknown;
1884
+ }
1885
+ interface CronJobListParams {
1886
+ limit?: number;
1887
+ cursor?: string;
1888
+ state?: string;
1889
+ [key: string]: string | number | boolean | undefined;
1890
+ }
1891
+ interface CronJobCreateParams {
1892
+ name: string;
1893
+ schedule: string;
1894
+ idempotencyKey?: string;
1895
+ [key: string]: unknown;
1896
+ }
1897
+ interface CronJobUpdateParams {
1898
+ name?: string;
1899
+ schedule?: string;
1900
+ [key: string]: unknown;
1901
+ }
1902
+ declare class CronJobs {
1903
+ private readonly http;
1904
+ constructor(http: HttpClient);
1905
+ list(params?: CronJobListParams): Promise<CronJobData[]>;
1906
+ get(jobId: string): Promise<CronJobData>;
1907
+ create(params: CronJobCreateParams): Promise<CronJobData>;
1908
+ update(jobId: string, params: CronJobUpdateParams): Promise<CronJobData>;
1909
+ delete(jobId: string): Promise<void>;
1910
+ pause(jobId: string): Promise<CronJobData>;
1911
+ resume(jobId: string): Promise<CronJobData>;
1912
+ runNow(jobId: string, opts?: {
1913
+ idempotencyKey?: string;
1914
+ }): Promise<CronJobData>;
1915
+ listExecutions(jobId: string): Promise<CronJobExecutionData[]>;
1916
+ getExecution(jobId: string, executionId: string): Promise<CronJobExecutionData>;
1917
+ }
1918
+
1919
+ /**
1920
+ * Dashboard — aggregated platform overview.
1921
+ */
1922
+
1923
+ interface DashboardSummary {
1924
+ computers?: unknown;
1925
+ sandboxes?: unknown;
1926
+ credits?: unknown;
1927
+ [key: string]: unknown;
1928
+ }
1929
+ interface OverviewData {
1930
+ status?: string;
1931
+ [key: string]: unknown;
1932
+ }
1933
+ declare class Dashboard {
1934
+ private readonly http;
1935
+ constructor(http: HttpClient);
1936
+ /** Aggregated user dashboard payload. */
1937
+ summary(): Promise<DashboardSummary>;
1938
+ /** Status / health overview (public endpoint). */
1939
+ overview(): Promise<OverviewData>;
1940
+ }
1941
+
1942
+ /**
1943
+ * Databases resource — managed Postgres / databases.
1944
+ */
1945
+
1946
+ type DatabaseId = string & {
1947
+ readonly __brand: "DatabaseId";
1948
+ };
1949
+ interface DatabaseData {
1950
+ id: DatabaseId;
1951
+ tenant_id: string;
1952
+ name: string;
1953
+ state?: string;
1954
+ engine?: string;
1955
+ engine_version?: string;
1956
+ version?: string;
1957
+ cpu_count?: number;
1958
+ memory_mb?: number;
1959
+ storage_mb?: number;
1960
+ host?: string | null;
1961
+ port?: number | null;
1962
+ created_at?: string;
1963
+ updated_at?: string;
1964
+ [key: string]: unknown;
1965
+ }
1966
+ interface DatabaseCredentials {
1967
+ url?: string;
1968
+ host?: string;
1969
+ port?: number;
1970
+ user?: string;
1971
+ username?: string;
1972
+ password?: string;
1973
+ database?: string;
1974
+ [key: string]: unknown;
1975
+ }
1976
+ interface DatabaseLogsResult {
1977
+ lines?: string[];
1978
+ logs?: string[];
1979
+ [key: string]: unknown;
1980
+ }
1981
+ interface DatabaseListParams {
1982
+ limit?: number;
1983
+ cursor?: string;
1984
+ state?: string;
1985
+ [key: string]: string | number | boolean | undefined;
1986
+ }
1987
+ interface DatabaseCreateParams {
1988
+ name: string;
1989
+ engine?: string;
1990
+ engine_version?: string;
1991
+ cpu_count?: number;
1992
+ memory_mb?: number;
1993
+ storage_mb?: number;
1994
+ external_workspace_id?: string;
1995
+ external_user_id?: string;
1996
+ external_project_id?: string;
1997
+ metadata?: Record<string, unknown>;
1998
+ /** @deprecated use engine_version. */
1999
+ version?: string;
2000
+ /** @deprecated use cpu_count/memory_mb/storage_mb. */
2001
+ size?: string;
2002
+ region?: string;
2003
+ idempotencyKey?: string;
2004
+ idempotency_key?: string;
2005
+ [key: string]: unknown;
2006
+ }
2007
+ interface DatabaseLogsParams {
2008
+ lines?: number;
2009
+ since?: string;
2010
+ }
2011
+ declare class Databases {
2012
+ private readonly http;
2013
+ constructor(http: HttpClient);
2014
+ list(params?: DatabaseListParams): Promise<DatabaseData[]>;
2015
+ get(databaseId: string): Promise<DatabaseData>;
2016
+ create(params: DatabaseCreateParams): Promise<DatabaseData>;
2017
+ delete(databaseId: string): Promise<void>;
2018
+ start(databaseId: string): Promise<DatabaseData>;
2019
+ stop(databaseId: string): Promise<DatabaseData>;
2020
+ restart(databaseId: string): Promise<DatabaseData>;
2021
+ credentials(databaseId: string): Promise<DatabaseCredentials>;
2022
+ logs(databaseId: string, params?: DatabaseLogsParams): Promise<DatabaseLogsResult>;
2023
+ streamLogs(databaseId: string): AsyncIterableIterator<unknown>;
2024
+ }
2025
+
2026
+ /**
2027
+ * Deployments resource — sandbox→production publishing surface.
2028
+ *
2029
+ * Backend phase status:
2030
+ * - list / get / create / update / delete / env: repo deployment surface.
2031
+ * - publish / versions.* / releases.* / rollback / domains.*: live release surface.
2032
+ * - runtimeInstances.*: dynamic runtime status/log inspection.
2033
+ * - publishFromSandbox: direct sandbox -> deployment bridge.
2034
+ *
2035
+ * See docs/deploy/* for the conceptual model.
2036
+ */
2037
+
2038
+ type DeploymentId = string & {
2039
+ readonly __brand: "DeploymentId";
2040
+ };
2041
+ type DeploymentVersionId = string & {
2042
+ readonly __brand: "DeploymentVersionId";
2043
+ };
2044
+ type DeploymentReleaseId = string & {
2045
+ readonly __brand: "DeploymentReleaseId";
2046
+ };
2047
+ type DeploymentServiceId = string & {
2048
+ readonly __brand: "DeploymentServiceId";
2049
+ };
2050
+ type RuntimeInstanceId = string & {
2051
+ readonly __brand: "RuntimeInstanceId";
2052
+ };
2053
+ type DeploymentState = "pending" | "building" | "running" | "stopped" | "failed";
2054
+ type DeploymentVersionKind = "static" | "dynamic" | "sandbox_backed";
2055
+ type DeploymentVersionState = "created" | "building" | "ready" | "failed" | "archived";
2056
+ type DeploymentSourceType = "repo" | "sandbox" | "upload";
2057
+ type DeploymentServiceType = "static_web" | "web" | "api" | "function" | "worker" | "cron" | "postgres" | "redis" | "bucket" | "volume";
2058
+ type RuntimeInstanceState = "provisioning" | "starting" | "healthy" | "unhealthy" | "error" | "stopped" | "destroyed";
2059
+ interface ExternalAttribution {
2060
+ externalWorkspaceId?: string;
2061
+ external_workspace_id?: string;
2062
+ externalUserId?: string;
2063
+ external_user_id?: string;
2064
+ externalProjectId?: string;
2065
+ external_project_id?: string;
2066
+ }
2067
+ interface DeploymentData {
2068
+ id: DeploymentId;
2069
+ tenant_id: string;
2070
+ owner_id?: string;
2071
+ name: string;
2072
+ slug: string;
2073
+ /**
2074
+ * @deprecated — repo-based model. New deployments use source_type: "sandbox"
2075
+ * with `source_sandbox_id` on the version row. Will become nullable.
2076
+ */
2077
+ repo_url?: string;
2078
+ repo_provider?: "github";
2079
+ branch?: string;
2080
+ build_command?: string | null;
2081
+ run_command?: string | null;
2082
+ runtime_image?: string | null;
2083
+ current_build_id?: string | null;
2084
+ active_version_id?: string | null;
2085
+ source_type?: DeploymentSourceType;
2086
+ state: DeploymentState;
2087
+ auto_deploy?: boolean;
2088
+ custom_domain_id?: string | null;
2089
+ linked_database_id?: string | null;
2090
+ metadata?: Record<string, unknown>;
2091
+ external_workspace_id?: string | null;
2092
+ external_user_id?: string | null;
2093
+ external_project_id?: string | null;
2094
+ public_url?: string | null;
2095
+ created_at?: string;
2096
+ updated_at?: string;
2097
+ }
2098
+ type DeploymentDatabaseRequest = boolean | {
2099
+ engine?: "postgresql" | "mysql" | "redis";
2100
+ size?: "xs" | "small" | "medium" | "large";
2101
+ storage_mb?: number;
2102
+ region?: string;
2103
+ };
2104
+ interface DeploymentVersionData {
2105
+ id: DeploymentVersionId;
2106
+ deployment_id: DeploymentId;
2107
+ tenant_id: string;
2108
+ created_by?: string | null;
2109
+ source_sandbox_id?: string | null;
2110
+ build_id?: string | null;
2111
+ version_number: number;
2112
+ kind: DeploymentVersionKind;
2113
+ state: DeploymentVersionState;
2114
+ artifact_uri?: string | null;
2115
+ artifact_manifest?: Record<string, unknown>;
2116
+ artifact_sha256?: string | null;
2117
+ runtime_image?: string | null;
2118
+ runtime_command?: string | null;
2119
+ runtime_port?: number | null;
2120
+ health_check_path?: string | null;
2121
+ build_log_uri?: string | null;
2122
+ metadata?: Record<string, unknown>;
2123
+ promoted_at?: string | null;
2124
+ archived_at?: string | null;
2125
+ external_workspace_id?: string | null;
2126
+ external_user_id?: string | null;
2127
+ external_project_id?: string | null;
2128
+ created_at?: string;
2129
+ updated_at?: string;
2130
+ }
2131
+ interface DeploymentReleaseData {
2132
+ id: DeploymentReleaseId;
2133
+ deployment_id?: DeploymentId;
2134
+ environment_id?: string | null;
2135
+ deployment_version_id: DeploymentVersionId;
2136
+ service_id?: DeploymentServiceId | null;
2137
+ tenant_id: string;
2138
+ external_workspace_id?: string | null;
2139
+ external_user_id?: string | null;
2140
+ external_project_id?: string | null;
2141
+ source_sandbox_id?: string | null;
2142
+ build_id?: string | null;
2143
+ kind: "static" | "oci" | "rootfs" | string;
2144
+ state?: string;
2145
+ artifact_uri?: string | null;
2146
+ artifact_sha256?: string | null;
2147
+ artifact_manifest?: Record<string, unknown>;
2148
+ storage_backend?: string | null;
2149
+ storage_uri?: string;
2150
+ sha256?: string;
2151
+ size_bytes?: number;
2152
+ start_command?: string | null;
2153
+ port?: number | null;
2154
+ health_check_path?: string | null;
2155
+ build_log_uri?: string | null;
2156
+ metadata?: Record<string, unknown>;
2157
+ ready_at?: string | null;
2158
+ archived_at?: string | null;
2159
+ created_at?: string;
2160
+ updated_at?: string;
2161
+ }
2162
+ interface DeploymentServiceData {
2163
+ id: DeploymentServiceId;
2164
+ deployment_id: DeploymentId;
2165
+ environment_id?: string | null;
2166
+ tenant_id: string;
2167
+ type: DeploymentServiceType;
2168
+ name?: string | null;
2169
+ desired_replicas?: number;
2170
+ state: string;
2171
+ metadata?: Record<string, unknown>;
2172
+ }
2173
+ interface RuntimeInstanceData {
2174
+ id: RuntimeInstanceId;
2175
+ deployment_id?: DeploymentId;
2176
+ environment_id?: string | null;
2177
+ service_id?: DeploymentServiceId | null;
2178
+ release_id?: DeploymentReleaseId;
2179
+ tenant_id: string;
2180
+ external_workspace_id?: string | null;
2181
+ external_user_id?: string | null;
2182
+ external_project_id?: string | null;
2183
+ host_id?: string | null;
2184
+ node_id?: string | null;
2185
+ vm_id?: string | null;
2186
+ desired_state?: string | null;
2187
+ state: RuntimeInstanceState;
2188
+ ip_address?: string | null;
2189
+ port?: number | null;
2190
+ health_check_path?: string | null;
2191
+ last_health_check_at?: string | null;
2192
+ last_heartbeat_at?: string | null;
2193
+ started_at?: string | null;
2194
+ stopped_at?: string | null;
2195
+ error_message?: string | null;
2196
+ restart_count?: number;
2197
+ cpu_limit_millicores?: number | null;
2198
+ memory_limit_mb?: number | null;
2199
+ runtime_log_path?: string | null;
2200
+ metadata?: Record<string, unknown>;
2201
+ created_at?: string;
2202
+ updated_at?: string;
2203
+ }
2204
+ interface DeploymentBuildData {
2205
+ id: string;
2206
+ deployment_id: DeploymentId;
2207
+ commit_sha?: string | null;
2208
+ commit_message?: string | null;
2209
+ triggered_by?: string;
2210
+ state: string;
2211
+ started_at?: string | null;
2212
+ finished_at?: string | null;
2213
+ duration_ms?: number | null;
2214
+ log_url?: string | null;
2215
+ image_digest?: string | null;
2216
+ error_message?: string | null;
2217
+ external_workspace_id?: string | null;
2218
+ external_user_id?: string | null;
2219
+ external_project_id?: string | null;
2220
+ created_at?: string;
2221
+ }
2222
+ interface DeploymentListParams extends ExternalAttribution {
2223
+ project_id?: string;
2224
+ projectId?: string;
2225
+ state?: DeploymentState | string;
2226
+ limit?: number;
2227
+ cursor?: string;
2228
+ }
2229
+ interface DeploymentCreateParams extends ExternalAttribution {
2230
+ name: string;
2231
+ /** Current backend create route is repo-backed; project IDs are attribution, not route ownership. */
2232
+ project_id?: string;
2233
+ projectId?: string;
2234
+ /** @deprecated Ignored by the backend create route. Use sandbox.deploy() for sandbox-backed deployments. */
2235
+ source_type?: DeploymentSourceType;
2236
+ /** @deprecated Ignored by the backend create route. Use sandbox.deploy() for sandbox-backed deployments. */
2237
+ sourceType?: DeploymentSourceType;
2238
+ repo_url?: string;
2239
+ repoUrl?: string;
2240
+ branch?: string;
2241
+ build_command?: string;
2242
+ buildCommand?: string;
2243
+ run_command?: string;
2244
+ runCommand?: string;
2245
+ auto_deploy?: boolean;
2246
+ autoDeploy?: boolean;
2247
+ database?: DeploymentDatabaseRequest;
2248
+ metadata?: Record<string, unknown>;
2249
+ idempotencyKey?: string;
2250
+ }
2251
+ interface DeploymentUpdateParams {
2252
+ name?: string;
2253
+ branch?: string;
2254
+ build_command?: string;
2255
+ buildCommand?: string;
2256
+ run_command?: string;
2257
+ runCommand?: string;
2258
+ auto_deploy?: boolean;
2259
+ autoDeploy?: boolean;
2260
+ }
2261
+ interface PublishParams extends ExternalAttribution {
2262
+ sourceSandboxId: string;
2263
+ source_sandbox_id?: string;
2264
+ name?: string;
2265
+ deploymentId?: string;
2266
+ deployment_id?: string;
2267
+ /** @deprecated Reserved for dynamic runtime publish; ignored by current static publish route. */
2268
+ kind?: "auto" | "static" | "dynamic";
2269
+ /** @deprecated Reserved for deployment environments; ignored by current static publish route. */
2270
+ environment?: "production" | "staging" | string;
2271
+ outputPath?: string;
2272
+ output_path?: string;
2273
+ /** @deprecated Current /deployments/:id/publish snapshots /workspace internally. */
2274
+ sourceSnapshotPath?: string;
2275
+ /** @deprecated Current /deployments/:id/publish snapshots /workspace internally. */
2276
+ source_snapshot_path?: string;
2277
+ entrypoint?: string;
2278
+ promote?: boolean;
2279
+ domain?: string;
2280
+ customDomain?: string;
2281
+ custom_domain?: string;
2282
+ /** @deprecated Reserved for dynamic runtime publish. */
2283
+ buildCommand?: string;
2284
+ /** @deprecated Reserved for dynamic runtime publish. */
2285
+ build_command?: string;
2286
+ /** @deprecated Reserved for dynamic runtime publish. */
2287
+ runCommand?: string;
2288
+ /** @deprecated Reserved for dynamic runtime publish. */
2289
+ run_command?: string;
2290
+ /** @deprecated Reserved for dynamic runtime publish. */
2291
+ port?: number;
2292
+ /** @deprecated Reserved for dynamic runtime publish. */
2293
+ healthCheckPath?: string;
2294
+ /** @deprecated Reserved for dynamic runtime publish. */
2295
+ health_check_path?: string;
2296
+ /** @deprecated Reserved for managed data-service binding. */
2297
+ dataServices?: string[];
2298
+ /** @deprecated Reserved for managed data-service binding. */
2299
+ data_services?: string[];
2300
+ idempotencyKey?: string;
2301
+ }
2302
+ interface PublishResult {
2303
+ deployment: DeploymentData;
2304
+ version: DeploymentVersionData;
2305
+ release?: DeploymentReleaseData;
2306
+ services?: DeploymentServiceData[];
2307
+ promoted: boolean;
2308
+ }
2309
+ type PublishFromSandboxParams = Omit<PublishParams, "sourceSandboxId" | "source_sandbox_id"> & {
2310
+ sourceSandboxId?: string;
2311
+ source_sandbox_id?: string;
2312
+ };
2313
+ interface RollbackParams {
2314
+ versionId?: string;
2315
+ version_id?: string;
2316
+ idempotencyKey?: string;
2317
+ }
2318
+ interface VersionListParams extends ExternalAttribution {
2319
+ state?: DeploymentVersionState | string;
2320
+ limit?: number;
2321
+ cursor?: string;
2322
+ }
2323
+ interface RuntimeLogsResult {
2324
+ runtime_instance_id?: string;
2325
+ deployment_id?: string;
2326
+ log_path?: string;
2327
+ logs: string;
2328
+ }
2329
+ interface AddDomainParams extends ExternalAttribution {
2330
+ redirectPolicy?: "none" | "www_to_apex" | "apex_to_www";
2331
+ redirect_policy?: "none" | "www_to_apex" | "apex_to_www";
2332
+ idempotencyKey?: string;
2333
+ }
2334
+ declare class DeploymentVersions {
2335
+ private readonly http;
2336
+ private readonly deploymentId;
2337
+ constructor(http: HttpClient, deploymentId: string);
2338
+ list(params?: VersionListParams): Promise<DeploymentVersionData[]>;
2339
+ get(versionId: string): Promise<DeploymentVersionData>;
2340
+ promote(versionId: string, opts?: {
2341
+ environment?: string;
2342
+ idempotencyKey?: string;
2343
+ }): Promise<DeploymentData>;
2344
+ }
2345
+ declare class DeploymentReleases {
2346
+ private readonly http;
2347
+ private readonly deploymentId;
2348
+ constructor(http: HttpClient, deploymentId: string);
2349
+ list(): Promise<DeploymentReleaseData[]>;
2350
+ get(releaseId: string): Promise<DeploymentReleaseData>;
2351
+ }
2352
+ declare class DeploymentRuntimeInstances {
2353
+ private readonly http;
2354
+ private readonly deploymentId;
2355
+ constructor(http: HttpClient, deploymentId: string);
2356
+ list(): Promise<RuntimeInstanceData[]>;
2357
+ get(instanceId: string): Promise<RuntimeInstanceData>;
2358
+ logs(instanceId: string, lines?: number): Promise<RuntimeLogsResult>;
2359
+ }
2360
+ declare class DeploymentDomains {
2361
+ private readonly http;
2362
+ private readonly deploymentId;
2363
+ constructor(http: HttpClient, deploymentId: string);
2364
+ add(domain: string, params?: AddDomainParams): Promise<Record<string, unknown>>;
2365
+ list(filters?: ExternalAttribution): Promise<Record<string, unknown>[]>;
2366
+ verify(domainId: string): Promise<Record<string, unknown>>;
2367
+ delete(domainId: string): Promise<void>;
2368
+ }
2369
+ declare class Deployments {
2370
+ private readonly http;
2371
+ constructor(http: HttpClient);
2372
+ list(params?: DeploymentListParams): Promise<DeploymentData[]>;
2373
+ get(deploymentId: string): Promise<DeploymentData>;
2374
+ create(params: DeploymentCreateParams): Promise<DeploymentData>;
2375
+ update(deploymentId: string, params: DeploymentUpdateParams): Promise<DeploymentData>;
2376
+ delete(deploymentId: string): Promise<void>;
2377
+ publish(deploymentId: string, params: PublishParams): Promise<PublishResult>;
2378
+ /**
2379
+ * Backward-compatible bridge: POST /sandboxes/:id/deploy. Works today;
2380
+ * returns either release-backed or sandbox-backed depending on backend
2381
+ * phase. Prefer `publish()` once Phase 2B/3 lands.
2382
+ */
2383
+ publishFromSandbox(sandboxId: string, params?: PublishFromSandboxParams): Promise<Record<string, unknown>>;
2384
+ rollback(deploymentId: string, params?: RollbackParams): Promise<DeploymentData>;
2385
+ listBuilds(deploymentId: string): Promise<DeploymentBuildData[]>;
2386
+ getBuild(deploymentId: string, buildId: string): Promise<DeploymentBuildData>;
2387
+ listEnv(deploymentId: string): Promise<Record<string, unknown>[]>;
2388
+ setEnv(deploymentId: string, vars: Record<string, string>, opts?: {
2389
+ environment?: string;
2390
+ }): Promise<Record<string, unknown>[]>;
2391
+ versions(deploymentId: string): DeploymentVersions;
2392
+ releases(deploymentId: string): DeploymentReleases;
2393
+ runtimeInstances(deploymentId: string): DeploymentRuntimeInstances;
2394
+ runtime_instances(deploymentId: string): DeploymentRuntimeInstances;
2395
+ domains(deploymentId: string): DeploymentDomains;
2396
+ }
2397
+
2398
+ /**
2399
+ * Email — admin email campaigns, templates, and inbox surfaces.
2400
+ *
2401
+ * Sub-namespaces:
2402
+ * client.email.campaigns — bulk email send-out lifecycle
2403
+ * client.email.templates — reusable templates (keyed by name)
2404
+ * client.email.inbox — inbound + outbound direct messages
2405
+ *
2406
+ * Routes: /admin/email-{campaigns,templates,inbox}/*
2407
+ * Requires admin credential (msk_a_* / msk_p_* or admin JWT).
2408
+ */
2409
+
2410
+ declare class EmailCampaigns {
2411
+ private readonly http;
2412
+ constructor(http: HttpClient);
2413
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
2414
+ create(attrs: Record<string, unknown>): Promise<Record<string, unknown>>;
2415
+ recipientCount(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>>;
2416
+ send(campaignId: string, opts?: Record<string, unknown>): Promise<Record<string, unknown>>;
2417
+ cancel(campaignId: string): Promise<Record<string, unknown>>;
2418
+ deliveries(campaignId: string, filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
2419
+ }
2420
+ declare class EmailTemplates {
2421
+ private readonly http;
2422
+ constructor(http: HttpClient);
2423
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
2424
+ create(key: string, attrs?: Record<string, unknown>): Promise<Record<string, unknown>>;
2425
+ update(key: string, attrs: Record<string, unknown>): Promise<Record<string, unknown>>;
2426
+ reset(key: string): Promise<Record<string, unknown>>;
2427
+ }
2428
+ declare class EmailInbox {
2429
+ private readonly http;
2430
+ constructor(http: HttpClient);
2431
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
2432
+ send(attrs: Record<string, unknown>): Promise<Record<string, unknown>>;
2433
+ markRead(messageId: string): Promise<Record<string, unknown>>;
2434
+ archive(messageId: string): Promise<Record<string, unknown>>;
2435
+ }
2436
+ declare class Email {
2437
+ readonly campaigns: EmailCampaigns;
2438
+ readonly templates: EmailTemplates;
2439
+ readonly inbox: EmailInbox;
2440
+ constructor(http: HttpClient);
2441
+ }
2442
+
2443
+ /**
2444
+ * Embeddings — OpenAI-compatible embedding vectors.
2445
+ *
2446
+ * Route: POST /intelligence/embeddings
2447
+ * Requires an mki_* intelligence key.
2448
+ */
2449
+
2450
+ interface EmbeddingCreateParams {
2451
+ input: string | string[];
2452
+ model: string;
2453
+ [key: string]: unknown;
2454
+ }
2455
+ declare class Embeddings {
2456
+ private readonly http;
2457
+ constructor(http: HttpClient);
2458
+ /**
2459
+ * Create one or more embedding vectors.
2460
+ *
2461
+ * Returns the full OpenAI-compatible envelope
2462
+ * `{ object: "list", data: [...], model, usage }`.
2463
+ */
2464
+ create(params: EmbeddingCreateParams): Promise<Record<string, unknown>>;
2465
+ }
2466
+
2467
+ /**
2468
+ * External keys — BYOK encrypted per-user provider keys.
2469
+ */
2470
+
2471
+ interface ExternalKeyData {
2472
+ provider?: string;
2473
+ masked_key?: string;
2474
+ created_at?: string;
2475
+ [key: string]: unknown;
2476
+ }
2477
+ interface ExternalKeyCreateParams {
2478
+ provider: string;
2479
+ key: string;
2480
+ [key: string]: unknown;
2481
+ }
2482
+ declare class ExternalKeys {
2483
+ private readonly http;
2484
+ constructor(http: HttpClient);
2485
+ /** List configured external keys. */
2486
+ list(): Promise<ExternalKeyData[]>;
2487
+ /** Create / register an external provider key. */
2488
+ create(params: ExternalKeyCreateParams): Promise<ExternalKeyData>;
2489
+ /** Resolve (preview) the stored key for a provider. */
2490
+ resolve(provider: string): Promise<ExternalKeyData>;
2491
+ /**
2492
+ * Delete the stored key for a provider.
2493
+ * Keys are addressed by provider name, not by id.
2494
+ */
2495
+ delete(provider: string): Promise<void>;
2496
+ }
2497
+
2498
+ /**
2499
+ * FlatCustomDomains resource — tenant-scoped custom domains at /custom-domains.
2500
+ *
2501
+ * The per-computer and per-deployment domain APIs live on those resources;
2502
+ * this is the flat tenant-level list view for white-label platforms managing
2503
+ * many domains across all resources.
2504
+ */
2505
+
2506
+ type CustomDomainId = string & {
2507
+ readonly __brand: "CustomDomainId";
2508
+ };
2509
+ interface CustomDomainData {
2510
+ id: CustomDomainId;
2511
+ tenant_id: string;
2512
+ domain: string;
2513
+ state?: string;
2514
+ resource_type?: string | null;
2515
+ resource_id?: string | null;
2516
+ verified?: boolean;
2517
+ verification_token?: string | null;
2518
+ created_at?: string;
2519
+ updated_at?: string;
2520
+ [key: string]: unknown;
2521
+ }
2522
+ interface CustomDomainListParams {
2523
+ limit?: number;
2524
+ cursor?: string;
2525
+ [key: string]: string | number | boolean | undefined;
2526
+ }
2527
+ interface CustomDomainCreateParams {
2528
+ domain: string;
2529
+ resource_type?: string;
2530
+ resourceType?: string;
2531
+ resource_id?: string;
2532
+ resourceId?: string;
2533
+ redirect_policy?: "none" | "www_to_apex" | "apex_to_www";
2534
+ redirectPolicy?: "none" | "www_to_apex" | "apex_to_www";
2535
+ idempotencyKey?: string;
2536
+ [key: string]: unknown;
2537
+ }
2538
+ declare class FlatCustomDomains {
2539
+ private readonly http;
2540
+ constructor(http: HttpClient);
2541
+ list(params?: CustomDomainListParams): Promise<CustomDomainData[]>;
2542
+ create(params: CustomDomainCreateParams): Promise<CustomDomainData>;
2543
+ delete(domainId: string): Promise<void>;
2544
+ }
2545
+
2546
+ /**
2547
+ * Functions resource — serverless edge functions.
2548
+ */
2549
+
2550
+ type FunctionId = string & {
2551
+ readonly __brand: "FunctionId";
2552
+ };
2553
+ interface FunctionData {
2554
+ id: FunctionId;
2555
+ tenant_id: string;
2556
+ name: string;
2557
+ state?: string;
2558
+ runtime?: string | null;
2559
+ handler?: string | null;
2560
+ memory_mb?: number | null;
2561
+ timeout_sec?: number | null;
2562
+ env?: Record<string, string>;
2563
+ created_at?: string;
2564
+ updated_at?: string;
2565
+ [key: string]: unknown;
2566
+ }
2567
+ interface FunctionListParams {
2568
+ limit?: number;
2569
+ cursor?: string;
2570
+ state?: string;
2571
+ [key: string]: string | number | boolean | undefined;
2572
+ }
2573
+ interface FunctionCreateParams {
2574
+ name: string;
2575
+ runtime?: string;
2576
+ handler?: string;
2577
+ memory_mb?: number;
2578
+ memoryMb?: number;
2579
+ timeout_sec?: number;
2580
+ timeoutSec?: number;
2581
+ env?: Record<string, string>;
2582
+ idempotencyKey?: string;
2583
+ [key: string]: unknown;
2584
+ }
2585
+ interface FunctionUpdateParams {
2586
+ name?: string;
2587
+ runtime?: string;
2588
+ handler?: string;
2589
+ memory_mb?: number;
2590
+ memoryMb?: number;
2591
+ timeout_sec?: number;
2592
+ timeoutSec?: number;
2593
+ env?: Record<string, string>;
2594
+ [key: string]: unknown;
2595
+ }
2596
+ interface FunctionInvokeParams {
2597
+ payload?: Record<string, unknown>;
2598
+ headers?: Record<string, string>;
2599
+ idempotencyKey?: string;
2600
+ }
2601
+ declare class Functions {
2602
+ private readonly http;
2603
+ constructor(http: HttpClient);
2604
+ list(params?: FunctionListParams): Promise<FunctionData[]>;
2605
+ get(functionId: string): Promise<FunctionData>;
2606
+ create(params: FunctionCreateParams): Promise<FunctionData>;
2607
+ update(functionId: string, params: FunctionUpdateParams): Promise<FunctionData>;
2608
+ delete(functionId: string): Promise<void>;
2609
+ invoke(functionId: string, params?: FunctionInvokeParams): Promise<Record<string, unknown>>;
2610
+ }
2611
+
2612
+ /**
2613
+ * HealthChecks resource — uptime monitoring.
2614
+ */
2615
+
2616
+ type HealthCheckId = string & {
2617
+ readonly __brand: "HealthCheckId";
2618
+ };
2619
+ interface HealthCheckData {
2620
+ id: HealthCheckId;
2621
+ tenant_id: string;
2622
+ name: string;
2623
+ url: string;
2624
+ state?: string;
2625
+ interval_sec?: number;
2626
+ timeout_sec?: number;
2627
+ method?: string;
2628
+ expected_status?: number | null;
2629
+ last_checked_at?: string | null;
2630
+ last_status?: "up" | "down" | null;
2631
+ created_at?: string;
2632
+ updated_at?: string;
2633
+ [key: string]: unknown;
2634
+ }
2635
+ interface HealthCheckListParams {
2636
+ limit?: number;
2637
+ cursor?: string;
2638
+ state?: string;
2639
+ [key: string]: string | number | boolean | undefined;
2640
+ }
2641
+ interface HealthCheckCreateParams {
2642
+ name: string;
2643
+ url: string;
2644
+ interval_sec?: number;
2645
+ intervalSec?: number;
2646
+ timeout_sec?: number;
2647
+ timeoutSec?: number;
2648
+ method?: string;
2649
+ expected_status?: number;
2650
+ expectedStatus?: number;
2651
+ idempotencyKey?: string;
2652
+ [key: string]: unknown;
2653
+ }
2654
+ interface HealthCheckUpdateParams {
2655
+ name?: string;
2656
+ url?: string;
2657
+ interval_sec?: number;
2658
+ intervalSec?: number;
2659
+ timeout_sec?: number;
2660
+ timeoutSec?: number;
2661
+ method?: string;
2662
+ expected_status?: number;
2663
+ expectedStatus?: number;
2664
+ [key: string]: unknown;
2665
+ }
2666
+ declare class HealthChecks {
2667
+ private readonly http;
2668
+ constructor(http: HttpClient);
2669
+ list(params?: HealthCheckListParams): Promise<HealthCheckData[]>;
2670
+ get(checkId: string): Promise<HealthCheckData>;
2671
+ create(params: HealthCheckCreateParams): Promise<HealthCheckData>;
2672
+ update(checkId: string, params: HealthCheckUpdateParams): Promise<HealthCheckData>;
2673
+ delete(checkId: string): Promise<void>;
2674
+ }
2675
+
2676
+ /**
2677
+ * Integrations — OAuth account-level connections (GitHub, Slack, Linear, Discord).
2678
+ */
2679
+
2680
+ interface IntegrationData {
2681
+ id?: string;
2682
+ provider?: string;
2683
+ status?: string;
2684
+ connected_at?: string;
2685
+ [key: string]: unknown;
2686
+ }
2687
+ interface IntegrationCatalogEntry {
2688
+ provider?: string;
2689
+ name?: string;
2690
+ description?: string;
2691
+ [key: string]: unknown;
2692
+ }
2693
+ interface GithubRepo {
2694
+ id?: number;
2695
+ name?: string;
2696
+ full_name?: string;
2697
+ private?: boolean;
2698
+ [key: string]: unknown;
2699
+ }
2700
+ interface GithubSshKey {
2701
+ id?: number;
2702
+ title?: string;
2703
+ key?: string;
2704
+ [key: string]: unknown;
2705
+ }
2706
+ interface SlackSendTestParams {
2707
+ message?: string;
2708
+ channel?: string;
2709
+ [key: string]: unknown;
2710
+ }
2711
+ interface DiscordSendTestParams {
2712
+ message?: string;
2713
+ channel_id?: string;
2714
+ [key: string]: unknown;
2715
+ }
2716
+ interface LinearCreateIssueParams {
2717
+ title?: string;
2718
+ description?: string;
2719
+ team_id?: string;
2720
+ [key: string]: unknown;
2721
+ }
2722
+ declare class Integrations {
2723
+ private readonly http;
2724
+ constructor(http: HttpClient);
2725
+ /** List active OAuth integrations for the tenant. */
2726
+ list(): Promise<IntegrationData[]>;
2727
+ /** List available providers in the integration catalog. */
2728
+ catalog(): Promise<IntegrationCatalogEntry[]>;
2729
+ /** Begin the OAuth flow for a provider — returns an authorize URL. */
2730
+ start(provider: string): Promise<Record<string, unknown>>;
2731
+ /** Force-refresh the access token for a provider. */
2732
+ refresh(provider: string): Promise<Record<string, unknown>>;
2733
+ /** Disconnect (revoke) an integration. */
2734
+ disconnect(provider: string): Promise<void>;
2735
+ /** List GitHub repositories accessible to this integration. */
2736
+ githubRepos(): Promise<GithubRepo[]>;
2737
+ /** List configured GitHub deploy keys. */
2738
+ githubSshKeys(): Promise<GithubSshKey[]>;
2739
+ /** Send a test message to the connected Slack channel. */
2740
+ slackSendTest(params?: SlackSendTestParams): Promise<Record<string, unknown>>;
2741
+ /** Send a test message to the connected Discord channel. */
2742
+ discordSendTest(params?: DiscordSendTestParams): Promise<Record<string, unknown>>;
2743
+ /** Begin Linear OAuth — Linear has provider-specific error shapes. */
2744
+ linearStart(): Promise<Record<string, unknown>>;
2745
+ /** Create a Linear issue via the connected workspace. */
2746
+ linearCreateIssue(params?: LinearCreateIssueParams): Promise<Record<string, unknown>>;
2747
+ }
2748
+
2749
+ /**
2750
+ * Mcp — Model Context Protocol streamable-HTTP transport.
2751
+ *
2752
+ * Clients (Claude Code, Cursor, Gemini CLI, Copilot) point at /api/v1/mcp
2753
+ * with a msk_* Bearer token and discover the MIOSA tool-belt.
2754
+ */
2755
+
2756
+ interface McpDispatchParams {
2757
+ method?: string;
2758
+ params?: Record<string, unknown>;
2759
+ [key: string]: unknown;
2760
+ }
2761
+ declare class Mcp {
2762
+ private readonly http;
2763
+ constructor(http: HttpClient);
2764
+ /** Send a JSON-RPC request to the MCP endpoint. */
2765
+ dispatch(params?: McpDispatchParams): Promise<Record<string, unknown>>;
2766
+ /**
2767
+ * Open the MCP listen channel (GET).
2768
+ *
2769
+ * Returns whatever the server returns. For true SSE streaming, use
2770
+ * `http.stream("/mcp")` directly.
2771
+ */
2772
+ listen(): Promise<unknown>;
2773
+ /** Close (terminate) the MCP session. */
2774
+ close(): Promise<void>;
2775
+ }
2776
+
2777
+ /**
2778
+ * Models — list available LLMs across providers.
2779
+ *
2780
+ * Routes: GET /intelligence/models
2781
+ * Requires an mki_* intelligence key or JWT.
2782
+ */
2783
+
2784
+ declare class Models {
2785
+ private readonly http;
2786
+ constructor(http: HttpClient);
2787
+ /** List all models available to the calling tenant (OpenAI-compatible shape). */
2788
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
2789
+ /**
2790
+ * Get a single model by id.
2791
+ *
2792
+ * The platform router does not expose a per-model GET; this filters
2793
+ * the list payload client-side.
2794
+ */
2795
+ get(modelId: string): Promise<Record<string, unknown>>;
2796
+ }
2797
+
2798
+ type HostId = string & {
2799
+ readonly __brand: "HostId";
2800
+ };
2801
+ type JobId = string & {
2802
+ readonly __brand: "JobId";
2803
+ };
2804
+ type TunnelId = string & {
2805
+ readonly __brand: "TunnelId";
2806
+ };
2807
+ type ClusterId = string & {
2808
+ readonly __brand: "ClusterId";
2809
+ };
2810
+ type WorkspaceId = string & {
2811
+ readonly __brand: "WorkspaceId";
2812
+ };
2813
+ type SecretId = string & {
2814
+ readonly __brand: "SecretId";
2815
+ };
2816
+ type HostStatus = "pending" | "online" | "offline" | "error" | "revoked";
2817
+ interface HostData {
2818
+ id: HostId;
2819
+ name: string;
2820
+ region: string | null;
2821
+ status: HostStatus;
2822
+ tenant_id: string;
2823
+ labels: Record<string, string>;
2824
+ /** Present only on create response — treat as write-once. */
2825
+ host_key?: string;
2826
+ created_at: string;
2827
+ updated_at: string;
2828
+ }
2829
+ interface HostCreateParams {
2830
+ name: string;
2831
+ region?: string;
2832
+ labels?: Record<string, string>;
2833
+ }
2834
+ interface HostUpdateParams {
2835
+ name?: string;
2836
+ labels?: Record<string, string>;
2837
+ }
2838
+ interface HostListResponse {
2839
+ data: HostData[];
2840
+ meta: {
2841
+ total: number;
2842
+ page: number;
2843
+ per_page: number;
2844
+ };
2845
+ }
2846
+ interface HostEvent {
2847
+ type: "host_connected" | "host_disconnected" | "host_error" | string;
2848
+ host_id: HostId;
2849
+ data: unknown;
2850
+ timestamp: string;
2851
+ }
2852
+ type JobStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
2853
+ interface JobData {
2854
+ id: JobId;
2855
+ host_id: HostId;
2856
+ status: JobStatus;
2857
+ command: string;
2858
+ args: string[];
2859
+ env: string[];
2860
+ cwd: string | null;
2861
+ exit_code: number | null;
2862
+ stdout: string | null;
2863
+ stderr: string | null;
2864
+ created_at: string;
2865
+ updated_at: string;
2866
+ completed_at: string | null;
2867
+ }
2868
+ interface JobRunParams {
2869
+ command: string;
2870
+ args?: string[];
2871
+ env?: string[];
2872
+ cwd?: string;
2873
+ timeout?: number;
2874
+ }
2875
+ interface JobListResponse {
2876
+ data: JobData[];
2877
+ meta: {
2878
+ total: number;
2879
+ page: number;
2880
+ per_page: number;
2881
+ };
2882
+ }
2883
+ type JobEventType = "stdout" | "stderr" | "exit" | "error" | "started" | "done";
2884
+ interface JobEvent {
2885
+ type: JobEventType;
2886
+ job_id: JobId;
2887
+ data: string | number | null;
2888
+ timestamp: string;
2889
+ }
2890
+ interface FsEntry {
2891
+ name: string;
2892
+ path: string;
2893
+ size: number;
2894
+ is_dir: boolean;
2895
+ modified_at: string;
2896
+ }
2897
+ interface FsStat {
2898
+ path: string;
2899
+ size: number;
2900
+ mode: number;
2901
+ is_dir: boolean;
2902
+ is_symlink: boolean;
2903
+ symlink_target?: string;
2904
+ modified_at: string;
2905
+ }
2906
+ interface FsListResponse {
2907
+ entries: FsEntry[];
2908
+ path: string;
2909
+ }
2910
+ interface WsTicket {
2911
+ /** Short-lived JWT for WS authentication. */
2912
+ ticket: string;
2913
+ /** Fully-qualified WS URL to connect to. */
2914
+ ws_url: string;
2915
+ expires_at: string;
2916
+ }
2917
+ type TunnelAuthMode = "public" | "tenant_only" | "password";
2918
+ interface TunnelData {
2919
+ id: TunnelId;
2920
+ host_id: HostId;
2921
+ slug: string;
2922
+ target_port: number;
2923
+ auth_mode: TunnelAuthMode;
2924
+ public_url: string;
2925
+ enabled: boolean;
2926
+ created_at: string;
2927
+ updated_at: string;
2928
+ }
2929
+ interface TunnelCreateParams {
2930
+ target_port: number;
2931
+ auth_mode?: TunnelAuthMode;
2932
+ slug?: string;
2933
+ }
2934
+ interface TunnelUpdateParams {
2935
+ target_port?: number;
2936
+ auth_mode?: TunnelAuthMode;
2937
+ enabled?: boolean;
2938
+ }
2939
+ interface TunnelListResponse {
2940
+ data: TunnelData[];
2941
+ }
2942
+ type AgentSessionStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
2943
+ interface OcAgentSessionData {
2944
+ id: string;
2945
+ host_id: HostId;
2946
+ task: string;
2947
+ model_id: string | null;
2948
+ status: AgentSessionStatus;
2949
+ max_turns: number;
2950
+ turns_used: number;
2951
+ created_at: string;
2952
+ updated_at: string;
2953
+ completed_at: string | null;
2954
+ error: string | null;
2955
+ }
2956
+ interface AgentDispatchParams {
2957
+ task: string;
2958
+ model_id?: string;
2959
+ max_turns?: number;
2960
+ context?: Record<string, unknown>;
2961
+ }
2962
+ interface AgentSessionListResponse {
2963
+ data: OcAgentSessionData[];
2964
+ }
2965
+ interface AgentEvent {
2966
+ type: string;
2967
+ session_id: string;
2968
+ data: unknown;
2969
+ timestamp: string;
2970
+ }
2971
+ type ClusterStatus = "provisioning" | "active" | "stopped" | "error" | "destroyed";
2972
+ interface ClusterData {
2973
+ id: ClusterId;
2974
+ name: string;
2975
+ model: string;
2976
+ slug: string;
2977
+ status: ClusterStatus;
2978
+ host_ids: HostId[];
2979
+ /** OpenAI-compatible endpoint: POST /inference/{slug}/v1/chat/completions */
2980
+ inference_url: string;
2981
+ created_at: string;
2982
+ updated_at: string;
2983
+ }
2984
+ interface ClusterCreateParams {
2985
+ name: string;
2986
+ model: string;
2987
+ host_ids: string[];
2988
+ }
2989
+ interface ClusterListResponse {
2990
+ data: ClusterData[];
2991
+ }
2992
+ interface ClusterEvent {
2993
+ type: string;
2994
+ cluster_id: ClusterId;
2995
+ data: unknown;
2996
+ timestamp: string;
2997
+ }
2998
+ interface AppCatalogEntry {
2999
+ id: string;
3000
+ name: string;
3001
+ description: string;
3002
+ category: string;
3003
+ version: string;
3004
+ icon_url: string | null;
3005
+ }
3006
+ interface AppInstallData {
3007
+ id: string;
3008
+ host_id: HostId;
3009
+ app_id: string;
3010
+ status: "pending" | "installing" | "installed" | "failed" | "uninstalled";
3011
+ error: string | null;
3012
+ created_at: string;
3013
+ updated_at: string;
3014
+ }
3015
+ interface AppInstallEvent {
3016
+ type: string;
3017
+ install_id: string;
3018
+ data: unknown;
3019
+ timestamp: string;
3020
+ }
3021
+ type OcWorkspaceStatus = "creating" | "ready" | "running" | "stopped" | "error";
3022
+ interface OcWorkspaceData {
3023
+ id: WorkspaceId;
3024
+ host_id: HostId;
3025
+ name: string;
3026
+ repo_url: string | null;
3027
+ branch: string | null;
3028
+ status: OcWorkspaceStatus;
3029
+ directory: string;
3030
+ created_at: string;
3031
+ updated_at: string;
3032
+ }
3033
+ interface OcWorkspaceCreateParams {
3034
+ name: string;
3035
+ repo_url?: string;
3036
+ branch?: string;
3037
+ directory?: string;
3038
+ }
3039
+ interface OcWorkspaceUpdateParams {
3040
+ name?: string;
3041
+ branch?: string;
3042
+ }
3043
+ interface OcWorkspaceListResponse {
3044
+ data: OcWorkspaceData[];
3045
+ }
3046
+ interface OcWorkspaceEvent {
3047
+ type: string;
3048
+ workspace_id: WorkspaceId;
3049
+ data: unknown;
3050
+ timestamp: string;
3051
+ }
3052
+ interface SecretData {
3053
+ id: SecretId;
3054
+ name: string;
3055
+ description: string | null;
3056
+ host_id: HostId | null;
3057
+ tenant_id: string;
3058
+ created_at: string;
3059
+ updated_at: string;
3060
+ }
3061
+ interface SecretCreateParams {
3062
+ name: string;
3063
+ value: string;
3064
+ description?: string;
3065
+ }
3066
+ interface SecretUpdateParams {
3067
+ value?: string;
3068
+ description?: string;
3069
+ }
3070
+
3071
+ /**
3072
+ * Agents resource — dispatch Optimal AI agent sessions that execute on a
3073
+ * remote OpenComputers host via the OSA/WS tunnel.
3074
+ *
3075
+ * ```ts
3076
+ * const session = await client.openComputers.agents.dispatch(hostId, {
3077
+ * task: "Run the test suite and report failures",
3078
+ * });
3079
+ *
3080
+ * for await (const event of client.openComputers.agents.events(hostId, session.id)) {
3081
+ * console.log(event.type, event.data);
3082
+ * if (event.type === "session_completed" || event.type === "done") break;
3083
+ * }
3084
+ * ```
3085
+ */
3086
+ declare class Agents {
3087
+ private readonly http;
3088
+ constructor(http: HttpClient);
3089
+ private base;
3090
+ /**
3091
+ * Dispatch a new agent session on the host.
3092
+ */
3093
+ dispatch(hostId: HostId | string, params: AgentDispatchParams): Promise<OcAgentSessionData>;
3094
+ /**
3095
+ * List all agent sessions for a host.
3096
+ */
3097
+ list(hostId: HostId | string): Promise<AgentSessionListResponse>;
3098
+ /**
3099
+ * Fetch the current state of a specific agent session.
3100
+ */
3101
+ get(hostId: HostId | string, sessionId: string): Promise<OcAgentSessionData>;
3102
+ /**
3103
+ * Stream live events from an agent session.
3104
+ *
3105
+ * Yields `AgentEvent` objects. Break on `type === "done"` or
3106
+ * `type === "session_completed"`.
3107
+ */
3108
+ events(hostId: HostId | string, sessionId: string): AsyncIterableIterator<AgentEvent>;
3109
+ /**
3110
+ * Cancel a running or pending agent session.
3111
+ */
3112
+ cancel(hostId: HostId | string, sessionId: string): Promise<void>;
3113
+ }
3114
+
3115
+ /**
3116
+ * Apps resource — one-click install of common dev services on a remote host.
3117
+ *
3118
+ * ```ts
3119
+ * const catalog = await client.openComputers.apps.catalog();
3120
+ * const install = await client.openComputers.apps.install(hostId, "postgres");
3121
+ *
3122
+ * for await (const evt of client.openComputers.apps.installEvents(hostId, install.id)) {
3123
+ * console.log(evt.type, evt.data);
3124
+ * if (evt.type === "installed" || evt.type === "failed") break;
3125
+ * }
3126
+ * ```
3127
+ */
3128
+ declare class Apps {
3129
+ private readonly http;
3130
+ constructor(http: HttpClient);
3131
+ /**
3132
+ * List all available apps in the MIOSA app library.
3133
+ */
3134
+ catalog(): Promise<AppCatalogEntry[]>;
3135
+ /**
3136
+ * List apps installed on a specific host.
3137
+ */
3138
+ listInstalled(hostId: HostId | string): Promise<AppInstallData[]>;
3139
+ /**
3140
+ * Install an app on a host by app catalog ID.
3141
+ */
3142
+ install(hostId: HostId | string, appId: string): Promise<AppInstallData>;
3143
+ /**
3144
+ * Get the current state of an install operation.
3145
+ */
3146
+ getInstall(hostId: HostId | string, installId: string): Promise<AppInstallData>;
3147
+ /**
3148
+ * Stream install progress events.
3149
+ */
3150
+ installEvents(hostId: HostId | string, installId: string): AsyncIterableIterator<AppInstallEvent>;
3151
+ /**
3152
+ * Uninstall an app from a host.
3153
+ */
3154
+ uninstall(hostId: HostId | string, appId: string): Promise<void>;
3155
+ /**
3156
+ * Start a previously installed app (e.g. start the postgres service).
3157
+ */
3158
+ startApp(hostId: HostId | string, appId: string): Promise<void>;
3159
+ }
3160
+
3161
+ /**
3162
+ * Clusters resource — manage multi-host LLM inference clusters (exo / MLX
3163
+ * Distributed). Hosts must be Apple Silicon.
3164
+ *
3165
+ * Once a cluster is active it exposes an OpenAI-compatible endpoint at:
3166
+ * `POST /inference/{slug}/v1/chat/completions`
3167
+ *
3168
+ * Point any OpenAI client at `https://api.miosa.ai/inference/{slug}/v1` with
3169
+ * your `msk_*` Bearer token.
3170
+ *
3171
+ * ```ts
3172
+ * const cluster = await client.openComputers.clusters.create({
3173
+ * name: "llama-cluster",
3174
+ * model: "llama3:70b",
3175
+ * host_ids: [hostA.id, hostB.id],
3176
+ * });
3177
+ * console.log(cluster.inference_url); // OpenAI-compatible base URL
3178
+ * ```
3179
+ */
3180
+ declare class Clusters {
3181
+ private readonly http;
3182
+ constructor(http: HttpClient);
3183
+ private base;
3184
+ /**
3185
+ * List all inference clusters for the tenant.
3186
+ */
3187
+ list(): Promise<ClusterListResponse>;
3188
+ /**
3189
+ * Create and provision a new inference cluster.
3190
+ */
3191
+ create(params: ClusterCreateParams): Promise<ClusterData>;
3192
+ /**
3193
+ * Fetch a single cluster.
3194
+ */
3195
+ get(id: ClusterId | string): Promise<ClusterData>;
3196
+ /**
3197
+ * Start a stopped cluster.
3198
+ */
3199
+ start(id: ClusterId | string): Promise<ClusterData>;
3200
+ /**
3201
+ * Stop a running cluster (preserves configuration).
3202
+ */
3203
+ stop(id: ClusterId | string): Promise<ClusterData>;
3204
+ /**
3205
+ * Permanently delete a cluster.
3206
+ */
3207
+ delete(id: ClusterId | string): Promise<void>;
3208
+ /**
3209
+ * Stream cluster provisioning / health events.
3210
+ */
3211
+ events(id: ClusterId | string): AsyncIterableIterator<ClusterEvent>;
3212
+ }
3213
+
3214
+ /**
3215
+ * Desktop resource — issue WebSocket tickets for KasmVNC desktop streaming on
3216
+ * a remote OpenComputers host.
3217
+ *
3218
+ * The ticket is consumed by a WebSocket upgrade at the URL in `ws_url`. Connect
3219
+ * a KasmVNC-compatible client (or an iframe pointing at the VNC web client) to
3220
+ * drive the desktop.
3221
+ *
3222
+ * ```ts
3223
+ * const { ws_url } = await client.openComputers.desktop.ticket(hostId);
3224
+ * // Open ws_url in an iframe or VNC client
3225
+ * ```
3226
+ */
3227
+ declare class Desktop {
3228
+ private readonly http;
3229
+ constructor(http: HttpClient);
3230
+ /**
3231
+ * Issue a short-lived WebSocket ticket for a desktop streaming session.
3232
+ *
3233
+ * The ticket expires quickly — open the WebSocket immediately after receiving it.
3234
+ */
3235
+ ticket(hostId: HostId | string): Promise<WsTicket>;
3236
+ }
3237
+
3238
+ /**
3239
+ * Files resource — direct file-system access on a remote OpenComputers host.
3240
+ *
3241
+ * Operations are proxied through the OSA daemon running on the host.
3242
+ *
3243
+ * ```ts
3244
+ * const entries = await client.openComputers.files.list(hostId, "/home/user");
3245
+ * const bytes = await client.openComputers.files.download(hostId, "/home/user/report.pdf");
3246
+ * await client.openComputers.files.upload(hostId, "/tmp/data.json", new TextEncoder().encode("{}"));
3247
+ * ```
3248
+ */
3249
+ declare class OcFiles {
3250
+ private readonly http;
3251
+ constructor(http: HttpClient);
3252
+ private base;
3253
+ /**
3254
+ * List directory entries at `path`.
3255
+ */
3256
+ list(hostId: HostId | string, path: string): Promise<FsListResponse>;
3257
+ /**
3258
+ * Stat a path (does not follow symlinks).
3259
+ */
3260
+ stat(hostId: HostId | string, path: string): Promise<FsStat>;
3261
+ /**
3262
+ * Download a file from the host. Returns raw bytes.
3263
+ */
3264
+ download(hostId: HostId | string, path: string): Promise<Uint8Array>;
3265
+ /**
3266
+ * Upload content to `remotePath` on the host.
3267
+ *
3268
+ * @param content - `Blob`, `Uint8Array`, or UTF-8 string.
3269
+ * @param remotePath - Absolute destination path on the host.
3270
+ * @param filename - Optional filename hint; defaults to `remotePath` basename.
3271
+ */
3272
+ upload(hostId: HostId | string, remotePath: string, content: Blob | Uint8Array | string, filename?: string): Promise<FsEntry>;
3273
+ /**
3274
+ * Delete a file or directory.
3275
+ *
3276
+ * @param recursive - When `true`, delete non-empty directories recursively.
3277
+ */
3278
+ delete(hostId: HostId | string, path: string, recursive?: boolean): Promise<void>;
3279
+ /**
3280
+ * Create a directory (and any missing parents).
3281
+ */
3282
+ mkdir(hostId: HostId | string, path: string): Promise<void>;
3283
+ }
3284
+
3285
+ /**
3286
+ * Hosts resource — manage BYOC (Bring Your Own Computer) hosts registered
3287
+ * under your tenant.
3288
+ *
3289
+ * ```ts
3290
+ * const host = await client.openComputers.hosts.create({ name: "my-mac" });
3291
+ * console.log(host.host_key); // store this — shown only once
3292
+ * ```
3293
+ */
3294
+ declare class Hosts {
3295
+ private readonly http;
3296
+ constructor(http: HttpClient);
3297
+ private base;
3298
+ /**
3299
+ * List all hosts registered for the tenant.
3300
+ */
3301
+ list(): Promise<HostListResponse>;
3302
+ /**
3303
+ * Register a new host. The returned `host_key` is shown **once** — store it
3304
+ * immediately and install it on the target machine.
3305
+ */
3306
+ create(params: HostCreateParams): Promise<HostData>;
3307
+ /**
3308
+ * Fetch a single host by ID.
3309
+ */
3310
+ get(id: HostId | string): Promise<HostData>;
3311
+ /**
3312
+ * Update host metadata (name / labels).
3313
+ */
3314
+ update(id: HostId | string, params: HostUpdateParams): Promise<HostData>;
3315
+ /**
3316
+ * Revoke a host. Permanently removes the registration; the host key is
3317
+ * invalidated and the host will disconnect on next heartbeat.
3318
+ */
3319
+ revoke(id: HostId | string): Promise<void>;
3320
+ /**
3321
+ * Stream host state-change events (connect / disconnect / error) as an
3322
+ * `AsyncIterable`.
3323
+ *
3324
+ * ```ts
3325
+ * for await (const event of client.openComputers.hosts.events()) {
3326
+ * console.log(event.type, event.host_id);
3327
+ * if (shouldStop) break;
3328
+ * }
3329
+ * ```
3330
+ */
3331
+ events(): AsyncIterableIterator<HostEvent>;
3332
+ }
3333
+
3334
+ /**
3335
+ * Jobs resource — run commands on a remote OpenComputers host and stream output.
3336
+ *
3337
+ * ```ts
3338
+ * const job = await client.openComputers.jobs.run(hostId, { command: "npm test" });
3339
+ * for await (const event of client.openComputers.jobs.stream(hostId, job.id)) {
3340
+ * process.stdout.write(String(event.data ?? ""));
3341
+ * if (event.type === "done") break;
3342
+ * }
3343
+ * ```
3344
+ */
3345
+ declare class Jobs {
3346
+ private readonly http;
3347
+ constructor(http: HttpClient);
3348
+ private base;
3349
+ /**
3350
+ * Dispatch a command to run on the remote host.
3351
+ */
3352
+ run(hostId: HostId | string, params: JobRunParams): Promise<JobData>;
3353
+ /**
3354
+ * List all jobs for a host.
3355
+ */
3356
+ list(hostId: HostId | string): Promise<JobListResponse>;
3357
+ /**
3358
+ * Fetch the current state of a job.
3359
+ */
3360
+ get(hostId: HostId | string, jobId: JobId | string): Promise<JobData>;
3361
+ /**
3362
+ * Stream live output from a running job.
3363
+ *
3364
+ * Yields `JobEvent` objects with `type` of `stdout`, `stderr`, `exit`, or
3365
+ * `done`. Break the loop when you receive `done` or `exit`.
3366
+ */
3367
+ stream(hostId: HostId | string, jobId: JobId | string): AsyncIterableIterator<JobEvent>;
3368
+ /**
3369
+ * Cancel a running or queued job.
3370
+ */
3371
+ cancel(hostId: HostId | string, jobId: JobId | string): Promise<void>;
3372
+ }
3373
+
3374
+ /**
3375
+ * Secrets resource — manage encrypted per-host (and per-tenant) env vars.
3376
+ *
3377
+ * Secrets are injected into exec sessions and PTY sessions on the host.
3378
+ * The value is encrypted at rest; `reveal()` decrypts it for one-time display.
3379
+ *
3380
+ * ```ts
3381
+ * // Tenant-wide secret (shared across all hosts)
3382
+ * await client.openComputers.secrets.createForTenant({ name: "OPENAI_KEY", value: "sk-..." });
3383
+ *
3384
+ * // Host-specific secret
3385
+ * const secret = await client.openComputers.secrets.createForHost(hostId, {
3386
+ * name: "DB_PASSWORD", value: "hunter2",
3387
+ * });
3388
+ * ```
3389
+ */
3390
+ declare class Secrets {
3391
+ private readonly http;
3392
+ constructor(http: HttpClient);
3393
+ /**
3394
+ * List all tenant-scoped secrets.
3395
+ */
3396
+ listForTenant(): Promise<SecretData[]>;
3397
+ /**
3398
+ * Create a tenant-scoped secret (available to all hosts).
3399
+ */
3400
+ createForTenant(params: SecretCreateParams): Promise<SecretData>;
3401
+ /**
3402
+ * List secrets scoped to a specific host.
3403
+ */
3404
+ listForHost(hostId: HostId | string): Promise<SecretData[]>;
3405
+ /**
3406
+ * Create a secret scoped to a specific host.
3407
+ */
3408
+ createForHost(hostId: HostId | string, params: SecretCreateParams): Promise<SecretData>;
3409
+ /**
3410
+ * Update a host-scoped secret (rotate value or update description).
3411
+ */
3412
+ updateForHost(hostId: HostId | string, secretId: SecretId | string, params: SecretUpdateParams): Promise<SecretData>;
3413
+ /**
3414
+ * Delete a host-scoped secret.
3415
+ */
3416
+ deleteForHost(hostId: HostId | string, secretId: SecretId | string): Promise<void>;
3417
+ /**
3418
+ * Reveal (decrypt and return) the plaintext value of a secret.
3419
+ * Use sparingly — each call is audit-logged.
3420
+ */
3421
+ reveal(hostId: HostId | string, secretId: SecretId | string): Promise<{
3422
+ value: string;
3423
+ }>;
3424
+ }
3425
+
3426
+ /**
3427
+ * Terminal resource — issue WebSocket tickets for interactive PTY sessions on
3428
+ * a remote OpenComputers host.
3429
+ *
3430
+ * The ticket is consumed by a WebSocket upgrade at the URL in `ws_url`. Use
3431
+ * xterm.js or any raw WebSocket client to drive the terminal.
3432
+ *
3433
+ * ```ts
3434
+ * const { ws_url } = await client.openComputers.terminal.ticket(hostId);
3435
+ * const ws = new WebSocket(ws_url);
3436
+ * ```
3437
+ */
3438
+ declare class Terminal {
3439
+ private readonly http;
3440
+ constructor(http: HttpClient);
3441
+ /**
3442
+ * Issue a short-lived WebSocket ticket for a terminal session.
3443
+ *
3444
+ * The ticket expires quickly — open the WebSocket immediately after receiving it.
3445
+ */
3446
+ ticket(hostId: HostId | string): Promise<WsTicket>;
3447
+ }
3448
+
3449
+ /**
3450
+ * Tunnels resource — expose ports on a remote host as publicly reachable URLs.
3451
+ *
3452
+ * The public proxy is served at `/t/:slug/*path`. The `auth_mode` field on each
3453
+ * tunnel controls whether the URL is open to the internet or requires
3454
+ * tenant credentials / a password.
3455
+ *
3456
+ * ```ts
3457
+ * const tunnel = await client.openComputers.tunnels.create(hostId, {
3458
+ * target_port: 8080,
3459
+ * auth_mode: "public",
3460
+ * });
3461
+ * console.log(tunnel.public_url); // https://api.miosa.ai/t/<slug>
3462
+ * ```
3463
+ */
3464
+ declare class Tunnels {
3465
+ private readonly http;
3466
+ constructor(http: HttpClient);
3467
+ private base;
3468
+ /**
3469
+ * List all tunnels for a host.
3470
+ */
3471
+ list(hostId: HostId | string): Promise<TunnelListResponse>;
3472
+ /**
3473
+ * Create a new tunnel that forwards traffic to `target_port` on the host.
3474
+ */
3475
+ create(hostId: HostId | string, params: TunnelCreateParams): Promise<TunnelData>;
3476
+ /**
3477
+ * Fetch a single tunnel.
3478
+ */
3479
+ get(hostId: HostId | string, tunnelId: TunnelId | string): Promise<TunnelData>;
3480
+ /**
3481
+ * Update a tunnel (target port, auth mode, or enabled state).
3482
+ */
3483
+ update(hostId: HostId | string, tunnelId: TunnelId | string, params: TunnelUpdateParams): Promise<TunnelData>;
3484
+ /**
3485
+ * Delete a tunnel. The public URL immediately becomes unreachable.
3486
+ */
3487
+ delete(hostId: HostId | string, tunnelId: TunnelId | string): Promise<void>;
3488
+ }
3489
+
3490
+ /**
3491
+ * Workspaces resource — git-backed development environments on a remote host.
3492
+ *
3493
+ * A workspace clones a repository, installs dependencies, and gives you a
3494
+ * ready-to-use terminal scoped to the project root.
3495
+ *
3496
+ * ```ts
3497
+ * const ws = await client.openComputers.workspaces.create(hostId, {
3498
+ * name: "my-project",
3499
+ * repo_url: "https://github.com/acme/backend",
3500
+ * branch: "main",
3501
+ * });
3502
+ * const { ws_url } = await client.openComputers.workspaces.openTerminal(hostId, ws.id);
3503
+ * ```
3504
+ */
3505
+ declare class OcWorkspaces {
3506
+ private readonly http;
3507
+ constructor(http: HttpClient);
3508
+ private base;
3509
+ /**
3510
+ * List all workspaces across all hosts for the tenant.
3511
+ */
3512
+ listAll(): Promise<OcWorkspaceListResponse>;
3513
+ /**
3514
+ * List workspaces on a specific host.
3515
+ */
3516
+ list(hostId: HostId | string): Promise<OcWorkspaceListResponse>;
3517
+ /**
3518
+ * Create a new workspace on a host.
3519
+ */
3520
+ create(hostId: HostId | string, params: OcWorkspaceCreateParams): Promise<OcWorkspaceData>;
3521
+ /**
3522
+ * Fetch a single workspace.
3523
+ */
3524
+ get(hostId: HostId | string, workspaceId: WorkspaceId | string): Promise<OcWorkspaceData>;
3525
+ /**
3526
+ * Update workspace metadata (name, branch).
3527
+ */
3528
+ update(hostId: HostId | string, workspaceId: WorkspaceId | string, params: OcWorkspaceUpdateParams): Promise<OcWorkspaceData>;
3529
+ /**
3530
+ * Delete a workspace.
3531
+ */
3532
+ delete(hostId: HostId | string, workspaceId: WorkspaceId | string): Promise<void>;
3533
+ /**
3534
+ * Pull the latest changes from the remote repository.
3535
+ */
3536
+ pull(hostId: HostId | string, workspaceId: WorkspaceId | string): Promise<OcWorkspaceData>;
3537
+ /**
3538
+ * Open a terminal session scoped to the workspace root directory.
3539
+ * Returns a short-lived WebSocket ticket.
3540
+ */
3541
+ openTerminal(hostId: HostId | string, workspaceId: WorkspaceId | string): Promise<WsTicket>;
3542
+ /**
3543
+ * Stream workspace setup / clone / install events.
3544
+ */
3545
+ events(hostId: HostId | string, workspaceId: WorkspaceId | string): AsyncIterableIterator<OcWorkspaceEvent>;
3546
+ }
3547
+
3548
+ /**
3549
+ * OpenComputers namespace — BYOC (Bring Your Own Computer) host management.
3550
+ *
3551
+ * Register your own machines (Mac, Linux, Windows) with MIOSA and use them
3552
+ * just like cloud computers: run jobs, manage files, open terminals, expose
3553
+ * ports, dispatch AI agents, and run LLM inference clusters.
3554
+ *
3555
+ * Access via `client.openComputers`:
3556
+ *
3557
+ * ```ts
3558
+ * const miosa = new Miosa({ apiKey: "msk_u_..." });
3559
+ *
3560
+ * // Register a host — save host_key immediately, shown only once
3561
+ * const host = await miosa.openComputers.hosts.create({ name: "my-mac" });
3562
+ *
3563
+ * // Run a command
3564
+ * const job = await miosa.openComputers.jobs.run(host.id, { command: "npm test" });
3565
+ *
3566
+ * // Stream output
3567
+ * for await (const event of miosa.openComputers.jobs.stream(host.id, job.id)) {
3568
+ * process.stdout.write(String(event.data ?? ""));
3569
+ * if (event.type === "done") break;
3570
+ * }
3571
+ *
3572
+ * // Expose a port
3573
+ * const tunnel = await miosa.openComputers.tunnels.create(host.id, { target_port: 3000 });
3574
+ * console.log(tunnel.public_url);
3575
+ *
3576
+ * // Dispatch an AI agent
3577
+ * const session = await miosa.openComputers.agents.dispatch(host.id, {
3578
+ * task: "Run tests and fix failing ones",
3579
+ * });
3580
+ * ```
3581
+ */
3582
+ declare class OpenComputers {
3583
+ /** Host registration and lifecycle. */
3584
+ readonly hosts: Hosts;
3585
+ /** Command execution on remote hosts. */
3586
+ readonly jobs: Jobs;
3587
+ /** File system access on remote hosts. */
3588
+ readonly files: OcFiles;
3589
+ /** Interactive terminal session tickets. */
3590
+ readonly terminal: Terminal;
3591
+ /** Desktop streaming session tickets. */
3592
+ readonly desktop: Desktop;
3593
+ /** HTTP tunnel management (expose host ports publicly). */
3594
+ readonly tunnels: Tunnels;
3595
+ /** AI agent dispatch and session management. */
3596
+ readonly agents: Agents;
3597
+ /** Multi-host LLM inference clusters. */
3598
+ readonly clusters: Clusters;
3599
+ /** App library — one-click installs on hosts. */
3600
+ readonly apps: Apps;
3601
+ /** Git-backed workspace environments. */
3602
+ readonly workspaces: OcWorkspaces;
3603
+ /** Encrypted per-host / per-tenant secrets. */
3604
+ readonly secrets: Secrets;
3605
+ constructor(http: HttpClient);
3606
+ }
3607
+
3608
+ /**
3609
+ * Project auth — built-in auth for sandboxes and deployments.
3610
+ */
3611
+
3612
+ interface ProjectAuthStatus {
3613
+ enabled?: boolean;
3614
+ state?: string;
3615
+ database_id?: string | null;
3616
+ config?: Record<string, unknown>;
3617
+ [key: string]: unknown;
3618
+ }
3619
+ type ProjectAuthResourceType = "sandbox" | "deployment";
3620
+ interface ProjectAuthResourceParams {
3621
+ resourceType?: ProjectAuthResourceType;
3622
+ resource_type?: ProjectAuthResourceType;
3623
+ resourceId?: string;
3624
+ resource_id?: string;
3625
+ }
3626
+ interface ProjectAuthEnableParams extends ProjectAuthResourceParams {
3627
+ signupEnabled?: boolean;
3628
+ signup_enabled?: boolean;
3629
+ emailConfirmRequired?: boolean;
3630
+ email_confirm_required?: boolean;
3631
+ tokenExpirySec?: number;
3632
+ token_expiry_sec?: number;
3633
+ config?: Record<string, unknown>;
3634
+ [key: string]: unknown;
3635
+ }
3636
+ interface ProjectAuthUpdateParams extends ProjectAuthEnableParams {
3637
+ }
3638
+ interface ProjectAuthDisableParams extends ProjectAuthResourceParams {
3639
+ [key: string]: unknown;
3640
+ }
3641
+ interface ProjectAuthStatusParams extends ProjectAuthResourceParams {
3642
+ [key: string]: unknown;
3643
+ }
3644
+ declare class ProjectAuth {
3645
+ private readonly http;
3646
+ constructor(http: HttpClient);
3647
+ /** Get the current project-auth status and config. */
3648
+ status(params: ProjectAuthStatusParams): Promise<ProjectAuthStatus>;
3649
+ /** Enable project auth. */
3650
+ enable(params: ProjectAuthEnableParams): Promise<ProjectAuthStatus>;
3651
+ /** Disable project auth. */
3652
+ disable(params: ProjectAuthDisableParams): Promise<ProjectAuthStatus>;
3653
+ /** Update project-auth configuration. */
3654
+ update(params: ProjectAuthUpdateParams): Promise<ProjectAuthStatus>;
3655
+ }
3656
+
3657
+ /**
3658
+ * Project integrations — third-party API key connections injected into VMs.
3659
+ */
3660
+
3661
+ interface ProjectIntegrationData {
3662
+ id?: string;
3663
+ project_id?: string;
3664
+ provider?: string;
3665
+ status?: string;
3666
+ [key: string]: unknown;
3667
+ }
3668
+ interface ProjectIntegrationCatalogEntry {
3669
+ provider?: string;
3670
+ name?: string;
3671
+ description?: string;
3672
+ schema?: Record<string, unknown>;
3673
+ [key: string]: unknown;
3674
+ }
3675
+ interface ProjectIntegrationListParams {
3676
+ project_id?: string;
3677
+ provider?: string;
3678
+ [key: string]: string | number | boolean | undefined;
3679
+ }
3680
+ interface ProjectIntegrationCreateParams {
3681
+ project_id?: string;
3682
+ provider?: string;
3683
+ credentials?: Record<string, unknown>;
3684
+ [key: string]: unknown;
3685
+ }
3686
+ interface ProjectIntegrationUpdateParams {
3687
+ credentials?: Record<string, unknown>;
3688
+ [key: string]: unknown;
3689
+ }
3690
+ declare class ProjectIntegrations {
3691
+ private readonly http;
3692
+ constructor(http: HttpClient);
3693
+ /** List project integrations. */
3694
+ list(params?: ProjectIntegrationListParams): Promise<ProjectIntegrationData[]>;
3695
+ /** List supported providers and their schemas. */
3696
+ catalog(): Promise<ProjectIntegrationCatalogEntry[]>;
3697
+ /** Get a project integration by id. */
3698
+ get(integrationId: string): Promise<ProjectIntegrationData>;
3699
+ /** Create a project integration. */
3700
+ create(params: ProjectIntegrationCreateParams): Promise<ProjectIntegrationData>;
3701
+ /** Update a project integration. */
3702
+ update(integrationId: string, params: ProjectIntegrationUpdateParams): Promise<ProjectIntegrationData>;
3703
+ /** Delete a project integration. */
3704
+ delete(integrationId: string): Promise<void>;
3705
+ }
3706
+
3707
+ /**
3708
+ * ProviderDefaults — admin LLM provider routing config.
3709
+ *
3710
+ * Routes:
3711
+ * GET /admin/provider-defaults
3712
+ * PUT /admin/provider-defaults
3713
+ * GET /admin/tenants/:id/provider-config
3714
+ * PUT /admin/tenants/:id/provider-config
3715
+ * DELETE /admin/tenants/:id/provider-config
3716
+ *
3717
+ * Requires admin credential (msk_a_* / msk_p_* or admin JWT).
3718
+ */
3719
+
3720
+ declare class ProviderDefaults {
3721
+ private readonly http;
3722
+ constructor(http: HttpClient);
3723
+ /** Get the current fleet-wide provider defaults. */
3724
+ list(): Promise<Record<string, unknown>>;
3725
+ /** Return the defaults entry for a single provider, or {} if missing. */
3726
+ get(provider: string): Promise<Record<string, unknown>>;
3727
+ /** Replace the fleet-wide defaults (PUT /admin/provider-defaults). */
3728
+ update(opts: Record<string, unknown>): Promise<Record<string, unknown>>;
3729
+ getTenant(tenantId: string): Promise<Record<string, unknown>>;
3730
+ setTenant(tenantId: string, opts: Record<string, unknown>): Promise<Record<string, unknown>>;
3731
+ resetTenant(tenantId: string): Promise<void>;
3732
+ }
3733
+
3734
+ /**
3735
+ * Regions — datacenter availability, sizes, pricing, templates.
3736
+ */
3737
+
3738
+ interface RegionData {
3739
+ id?: string;
3740
+ name?: string;
3741
+ slug?: string;
3742
+ available?: boolean;
3743
+ [key: string]: unknown;
3744
+ }
3745
+ interface SizeData {
3746
+ id?: string;
3747
+ name?: string;
3748
+ slug?: string;
3749
+ cpu?: number;
3750
+ memory_mb?: number;
3751
+ [key: string]: unknown;
3752
+ }
3753
+ interface TemplateData {
3754
+ id?: string;
3755
+ name?: string;
3756
+ slug?: string;
3757
+ [key: string]: unknown;
3758
+ }
3759
+ declare class Regions {
3760
+ private readonly http;
3761
+ constructor(http: HttpClient);
3762
+ /** List datacenter regions. */
3763
+ listRegions(): Promise<RegionData[]>;
3764
+ /** List available compute sizes. */
3765
+ listSizes(): Promise<SizeData[]>;
3766
+ /** Get static compute pricing data. */
3767
+ pricing(): Promise<unknown>;
3768
+ /** List community computer templates. */
3769
+ listTemplates(): Promise<TemplateData[]>;
3770
+ /** Get a single community template by id. */
3771
+ getTemplate(templateId: string): Promise<TemplateData>;
3772
+ }
3773
+
3774
+ declare const SANDBOX_TEMPLATE = "miosa-sandbox";
3775
+ type SandboxId = string & {
3776
+ readonly __brand: "SandboxId";
3777
+ };
3778
+ type SandboxState = "provisioning" | "running" | "paused" | "destroyed" | "error";
3779
+ interface SandboxCreateParams {
3780
+ templateId?: string;
3781
+ template_id?: string;
3782
+ image?: string;
3783
+ cpuCount?: number;
3784
+ cpu_count?: number;
3785
+ memoryMb?: number;
3786
+ memory_mb?: number;
3787
+ diskMb?: number;
3788
+ disk_mb?: number;
3789
+ diskSizeMb?: number;
3790
+ disk_size_mb?: number;
3791
+ timeoutSec?: number;
3792
+ timeout_sec?: number;
3793
+ idleTimeoutSec?: number;
3794
+ idle_timeout_sec?: number;
3795
+ alwaysOn?: boolean;
3796
+ always_on?: boolean;
3797
+ env?: Record<string, string>;
3798
+ metadata?: Record<string, unknown>;
3799
+ services?: Array<Record<string, unknown>>;
3800
+ readinessProbe?: Record<string, unknown>;
3801
+ readiness_probe?: Record<string, unknown>;
3802
+ database?: Record<string, unknown> | boolean;
3803
+ githubRepoUrl?: string;
3804
+ github_repo_url?: string;
3805
+ githubBranch?: string;
3806
+ github_branch?: string;
3807
+ githubClonePath?: string;
3808
+ github_clone_path?: string;
3809
+ name?: string;
3810
+ region?: string;
3811
+ entrypoint?: string;
3812
+ tags?: string[];
3813
+ idempotencyKey?: string;
3814
+ idempotency_key?: string;
3815
+ externalWorkspaceId?: string;
3816
+ external_workspace_id?: string;
3817
+ externalUserId?: string;
3818
+ external_user_id?: string;
3819
+ externalProjectId?: string;
3820
+ external_project_id?: string;
3821
+ }
3822
+ interface SandboxListParams {
3823
+ state?: SandboxState | string;
3824
+ tags?: string[];
3825
+ externalWorkspaceId?: string;
3826
+ external_workspace_id?: string;
3827
+ externalUserId?: string;
3828
+ external_user_id?: string;
3829
+ externalProjectId?: string;
3830
+ external_project_id?: string;
3831
+ }
3832
+ interface SandboxExecOptions {
3833
+ cwd?: string;
3834
+ workingDir?: string;
3835
+ working_dir?: string;
3836
+ env?: Record<string, string>;
3837
+ timeout?: number;
3838
+ timeoutSec?: number;
3839
+ timeout_sec?: number;
3840
+ }
3841
+ interface SandboxExecResult {
3842
+ stdout: string;
3843
+ stderr: string;
3844
+ exitCode: number;
3845
+ exit_code: number;
3846
+ durationMs?: number;
3847
+ duration_ms?: number;
3848
+ }
3849
+ type SandboxExecEvent = {
3850
+ type?: "stdout";
3851
+ line: string;
3852
+ } | {
3853
+ type?: "stderr";
3854
+ line: string;
3855
+ } | {
3856
+ type?: "exit";
3857
+ exit_code: number;
3858
+ exitCode?: number;
3859
+ } | Record<string, unknown>;
3860
+ interface SandboxExecRunner {
3861
+ (command: string, options?: SandboxExecOptions): Promise<SandboxExecResult>;
3862
+ run(command: string, options?: SandboxExecOptions): Promise<SandboxExecResult>;
3863
+ stream(command: string, options?: SandboxExecOptions): AsyncIterableIterator<SandboxExecEvent>;
3864
+ }
3865
+ interface SandboxData {
3866
+ id: SandboxId;
3867
+ state: SandboxState;
3868
+ ready?: boolean;
3869
+ template_id?: string;
3870
+ image_id?: string | null;
3871
+ cpu_count?: number | null;
3872
+ memory_mb?: number | null;
3873
+ disk_mb?: number | null;
3874
+ disk_size_mb?: number | null;
3875
+ timeout_sec?: number | null;
3876
+ boot_path?: string | null;
3877
+ boot_ms?: number | null;
3878
+ ready_at?: string | null;
3879
+ preview_url?: string | null;
3880
+ metadata?: Record<string, unknown>;
3881
+ inserted_at?: string;
3882
+ created_at?: string;
3883
+ started_at?: string | null;
3884
+ destroyed_at?: string | null;
3885
+ total_runtime_sec?: number | null;
3886
+ }
3887
+ interface SandboxTemplate {
3888
+ id: string;
3889
+ name?: string;
3890
+ slug?: string;
3891
+ description?: string;
3892
+ image_id?: string;
3893
+ built_in?: boolean;
3894
+ status?: string;
3895
+ preview_port?: number | null;
3896
+ workdir?: string;
3897
+ install_command?: string | null;
3898
+ start_command?: string | null;
3899
+ readiness_probe?: Record<string, unknown> | null;
3900
+ artifact_paths?: string[];
3901
+ runtimes?: string[];
3902
+ tags?: string[];
3903
+ build_spec?: Record<string, unknown>;
3904
+ current_build_id?: string | null;
3905
+ }
3906
+ interface SandboxTemplateList {
3907
+ data: SandboxTemplate[];
3908
+ default_template_id?: string;
3909
+ }
3910
+ interface SandboxBuildSpec {
3911
+ from: string;
3912
+ vcpu?: number;
3913
+ memoryMib?: number;
3914
+ diskMib?: number;
3915
+ steps?: Array<Record<string, unknown>>;
3916
+ env?: Record<string, string>;
3917
+ workdir?: string;
3918
+ user?: string;
3919
+ startCmd?: string;
3920
+ readyCmd?: string;
3921
+ previewPort?: number;
3922
+ artifactPaths?: string[];
3923
+ }
3924
+ interface SandboxBuildSpecError {
3925
+ code: string;
3926
+ field: string;
3927
+ message: string;
3928
+ }
3929
+ interface SandboxBuildSpecValidation {
3930
+ valid: boolean;
3931
+ build_spec?: Record<string, unknown>;
3932
+ errors?: SandboxBuildSpecError[];
3933
+ }
3934
+ interface SandboxTemplateCreateParams {
3935
+ name: string;
3936
+ buildSpec?: SandboxBuildSpec;
3937
+ build_spec?: SandboxBuildSpec;
3938
+ slug?: string;
3939
+ description?: string;
3940
+ metadata?: Record<string, unknown>;
3941
+ }
3942
+ interface SandboxTemplateBuildCreateParams {
3943
+ buildSpec?: SandboxBuildSpec;
3944
+ build_spec?: SandboxBuildSpec;
3945
+ metadata?: Record<string, unknown>;
3946
+ }
3947
+ interface SandboxTemplateBuild {
3948
+ id: string;
3949
+ sandbox_template_id: string;
3950
+ source_type: "build_spec" | string;
3951
+ state: "queued" | "building" | "certifying" | "snapshotting" | "ready" | "failed" | "cancelled";
3952
+ image_id?: string | null;
3953
+ rootfs_path?: string | null;
3954
+ snapshot_manifest?: Record<string, unknown>;
3955
+ log_url?: string | null;
3956
+ error_code?: string | null;
3957
+ error_message?: string | null;
3958
+ started_at?: string | null;
3959
+ finished_at?: string | null;
3960
+ duration_ms?: number | null;
3961
+ build_spec?: Record<string, unknown>;
3962
+ inserted_at?: string;
3963
+ updated_at?: string;
3964
+ }
3965
+ interface SandboxFileEntry {
3966
+ name: string;
3967
+ path: string;
3968
+ size?: number;
3969
+ is_dir?: boolean;
3970
+ isDir?: boolean;
3971
+ modified_at?: string;
3972
+ modifiedAt?: string;
3973
+ [key: string]: unknown;
3974
+ }
3975
+ interface SandboxFileList {
3976
+ path?: string;
3977
+ entries: SandboxFileEntry[];
3978
+ }
3979
+ interface SandboxFileStat {
3980
+ path: string;
3981
+ size?: number;
3982
+ is_dir?: boolean;
3983
+ isDir?: boolean;
3984
+ mode?: string;
3985
+ modified_at?: string;
3986
+ modifiedAt?: string;
3987
+ [key: string]: unknown;
3988
+ }
3989
+ interface SandboxSnapshot {
3990
+ id: string;
3991
+ sandbox_id?: string;
3992
+ status?: string;
3993
+ comment?: string;
3994
+ created_at?: string;
3995
+ updated_at?: string;
3996
+ [key: string]: unknown;
3997
+ }
3998
+ interface SandboxDeployParams {
3999
+ name?: string;
4000
+ deploymentId?: string;
4001
+ deployment_id?: string;
4002
+ path?: string;
4003
+ sourcePath?: string;
4004
+ source_path?: string;
4005
+ outputPath?: string;
4006
+ output_path?: string;
4007
+ sourceSnapshotPath?: string;
4008
+ source_snapshot_path?: string;
4009
+ entrypoint?: string;
4010
+ domain?: string;
4011
+ customDomain?: string;
4012
+ custom_domain?: string;
4013
+ idempotencyKey?: string;
4014
+ idempotency_key?: string;
4015
+ }
4016
+ declare class SandboxCommands {
4017
+ private readonly sandbox;
4018
+ constructor(sandbox: Sandbox);
4019
+ run(command: string, options?: SandboxExecOptions): Promise<SandboxExecResult>;
4020
+ stream(command: string, options?: SandboxExecOptions): AsyncIterableIterator<SandboxExecEvent>;
4021
+ }
4022
+ declare class SandboxFiles {
4023
+ private readonly sandbox;
4024
+ constructor(sandbox: Sandbox);
4025
+ write(path: string, content: string | Uint8Array): Promise<void>;
4026
+ read(path: string): Promise<Uint8Array>;
4027
+ readText(path: string): Promise<string>;
4028
+ list(path?: string): Promise<SandboxFileList>;
4029
+ stat(path: string): Promise<SandboxFileStat>;
4030
+ upload(path: string, content: string | Uint8Array): Promise<void>;
4031
+ download(path: string): Promise<Uint8Array>;
4032
+ }
4033
+ declare class SandboxPreview {
4034
+ private readonly sandbox;
4035
+ constructor(sandbox: Sandbox);
4036
+ expose(port?: number): Promise<string>;
4037
+ }
4038
+ declare class SandboxArtifacts {
4039
+ private readonly sandbox;
4040
+ constructor(sandbox: Sandbox);
4041
+ list(): Promise<Record<string, unknown>>;
4042
+ }
4043
+ declare class SandboxLogs {
4044
+ private readonly sandbox;
4045
+ constructor(sandbox: Sandbox);
4046
+ get(lines?: number): Promise<string | Record<string, unknown>>;
4047
+ stream(): AsyncIterableIterator<Record<string, unknown>>;
4048
+ }
4049
+ declare class SandboxSnapshots {
4050
+ private readonly sandbox;
4051
+ constructor(sandbox: Sandbox);
4052
+ create(comment?: string): Promise<SandboxSnapshot>;
4053
+ list(): Promise<SandboxSnapshot[]>;
4054
+ restore(snapshotId: string): Promise<Sandbox>;
4055
+ delete(snapshotId: string): Promise<void>;
4056
+ }
4057
+ declare class SandboxTerminal {
4058
+ private readonly sandbox;
4059
+ constructor(sandbox: Sandbox);
4060
+ create(params?: {
4061
+ cols?: number;
4062
+ rows?: number;
4063
+ shell?: string;
4064
+ cwd?: string;
4065
+ env?: Record<string, string>;
4066
+ }): Promise<Record<string, unknown>>;
4067
+ delete(sessionId: string): Promise<void>;
4068
+ }
4069
+ declare class SandboxEvents {
4070
+ private readonly sandbox;
4071
+ constructor(sandbox: Sandbox);
4072
+ /** Stream live sandbox events via SSE. */
4073
+ stream(): AsyncIterableIterator<Record<string, unknown>>;
4074
+ }
4075
+ declare class SandboxPreviews {
4076
+ private readonly sandbox;
4077
+ constructor(sandbox: Sandbox);
4078
+ private get http();
4079
+ list(): Promise<Record<string, unknown>[]>;
4080
+ create(port: number, opts?: Record<string, unknown>): Promise<Record<string, unknown>>;
4081
+ get(previewId: string): Promise<Record<string, unknown>>;
4082
+ delete(previewId: string): Promise<void>;
4083
+ /** Mint a share token for previewId. */
4084
+ share(previewId: string, opts?: {
4085
+ ttl_seconds?: number;
4086
+ expires_in_sec?: number;
4087
+ }): Promise<Record<string, unknown>>;
4088
+ /** Invalidate every share token associated with previewId. */
4089
+ revokeShare(previewId: string): Promise<void>;
4090
+ }
4091
+ declare class SandboxEnv {
4092
+ private readonly sandbox;
4093
+ constructor(sandbox: Sandbox);
4094
+ /**
4095
+ * Read-only listing of sandbox env vars.
4096
+ * The backend has no per-name CRUD route; use Sandbox.create(env=...) to set values.
4097
+ */
4098
+ list(): Promise<Record<string, unknown>>;
4099
+ }
4100
+ declare class SandboxTags {
4101
+ private readonly sandbox;
4102
+ constructor(sandbox: Sandbox);
4103
+ /** Replace the full tag list with tags. */
4104
+ set(tags: string[]): Promise<Record<string, unknown>>;
4105
+ }
4106
+ declare class Sandbox {
4107
+ private readonly http;
4108
+ data: SandboxData;
4109
+ readonly commands: SandboxCommands;
4110
+ readonly exec: SandboxExecRunner;
4111
+ readonly files: SandboxFiles;
4112
+ readonly preview: SandboxPreview;
4113
+ readonly artifacts: SandboxArtifacts;
4114
+ readonly logs: SandboxLogs;
4115
+ readonly snapshots: SandboxSnapshots;
4116
+ /** PTY session control — create/delete. */
4117
+ readonly terminal: SandboxTerminal;
4118
+ /** SSE event stream. */
4119
+ readonly events: SandboxEvents;
4120
+ /** Preview CRUD + share/revokeShare. */
4121
+ readonly previews: SandboxPreviews;
4122
+ /** Read-only env var listing. */
4123
+ readonly env: SandboxEnv;
4124
+ /** Tag replacement. */
4125
+ readonly tags: SandboxTags;
4126
+ constructor(http: HttpClient, data: SandboxData);
4127
+ get id(): SandboxId;
4128
+ get state(): SandboxState;
4129
+ get ready(): boolean;
4130
+ get templateId(): string;
4131
+ refresh(): Promise<Sandbox>;
4132
+ private runExec;
4133
+ private execStream;
4134
+ writeFile(path: string, content: string | Uint8Array): Promise<void>;
4135
+ download(path: string): Promise<Uint8Array>;
4136
+ readFile(path: string): Promise<string>;
4137
+ listFiles(path?: string): Promise<SandboxFileList>;
4138
+ statFile(path: string): Promise<SandboxFileStat>;
4139
+ expose(port?: number): Promise<string>;
4140
+ startTemplate(options?: Record<string, unknown>): Promise<Record<string, unknown>>;
4141
+ getArtifacts(): Promise<Record<string, unknown>>;
4142
+ getLogs(lines?: number): Promise<string | Record<string, unknown>>;
4143
+ streamLogs(): AsyncIterableIterator<Record<string, unknown>>;
4144
+ createSnapshot(comment?: string): Promise<SandboxSnapshot>;
4145
+ listSnapshots(): Promise<SandboxSnapshot[]>;
4146
+ restoreSnapshot(snapshotId: string): Promise<Sandbox>;
4147
+ deleteSnapshot(snapshotId: string): Promise<void>;
4148
+ pause(): Promise<Sandbox>;
4149
+ resume(): Promise<Sandbox>;
4150
+ deploy(params?: SandboxDeployParams): Promise<Record<string, unknown>>;
4151
+ /** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
4152
+ readiness(): Promise<Record<string, unknown>>;
4153
+ destroy(): Promise<void>;
4154
+ delete(): Promise<void>;
4155
+ private assertRunning;
4156
+ }
4157
+ declare class Sandboxes {
4158
+ private readonly http;
4159
+ constructor(http: HttpClient);
4160
+ create(params?: SandboxCreateParams): Promise<Sandbox>;
4161
+ list(params?: SandboxListParams): Promise<Sandbox[]>;
4162
+ get(id: SandboxId | string): Promise<Sandbox>;
4163
+ connect(id: SandboxId | string): Promise<Sandbox>;
4164
+ delete(id: SandboxId | string): Promise<void>;
4165
+ listTemplates(options?: {
4166
+ includeAliases?: boolean;
4167
+ }): Promise<SandboxTemplateList>;
4168
+ getTemplate(id: string): Promise<SandboxTemplate>;
4169
+ getBuildSpecSchema(): Promise<Record<string, unknown>>;
4170
+ validateBuildSpec(buildSpec: SandboxBuildSpec): Promise<SandboxBuildSpecValidation>;
4171
+ createTemplate(params: SandboxTemplateCreateParams): Promise<SandboxTemplate>;
4172
+ createTemplateBuild(templateId: string, params?: SandboxTemplateBuildCreateParams): Promise<SandboxTemplateBuild>;
4173
+ listTemplateBuilds(templateId: string): Promise<SandboxTemplateBuild[]>;
4174
+ getTemplateBuild(buildId: string): Promise<SandboxTemplateBuild>;
4175
+ }
4176
+
4177
+ /**
4178
+ * SandboxTemplates resource — tenant sandbox template management.
4179
+ */
4180
+
4181
+ type SandboxTemplateResourceId = string & {
4182
+ readonly __brand: "SandboxTemplateResourceId";
4183
+ };
4184
+ type SandboxTemplateBuildResourceId = string & {
4185
+ readonly __brand: "SandboxTemplateBuildResourceId";
4186
+ };
4187
+ interface SandboxTemplateResourceData {
4188
+ id: SandboxTemplateResourceId;
4189
+ tenant_id: string;
4190
+ name: string;
4191
+ state?: string;
4192
+ build_spec?: Record<string, unknown>;
4193
+ aliases?: string[];
4194
+ created_at?: string;
4195
+ updated_at?: string;
4196
+ [key: string]: unknown;
4197
+ }
4198
+ interface SandboxTemplateBuildResourceData {
4199
+ id: SandboxTemplateBuildResourceId;
4200
+ template_id: SandboxTemplateResourceId;
4201
+ state?: string;
4202
+ started_at?: string | null;
4203
+ finished_at?: string | null;
4204
+ error?: string | null;
4205
+ created_at?: string;
4206
+ [key: string]: unknown;
4207
+ }
4208
+ interface SandboxTemplateListParams {
4209
+ include_aliases?: boolean;
4210
+ includeAliases?: boolean;
4211
+ }
4212
+ interface TemplateCreateParams {
4213
+ name: string;
4214
+ build_spec: Record<string, unknown>;
4215
+ buildSpec?: Record<string, unknown>;
4216
+ idempotencyKey?: string;
4217
+ [key: string]: unknown;
4218
+ }
4219
+ interface TemplateBuildCreateParams {
4220
+ idempotencyKey?: string;
4221
+ [key: string]: unknown;
4222
+ }
4223
+ declare class SandboxTemplates {
4224
+ private readonly http;
4225
+ constructor(http: HttpClient);
4226
+ list(params?: SandboxTemplateListParams): Promise<SandboxTemplateResourceData[]>;
4227
+ get(templateId: string): Promise<SandboxTemplateResourceData>;
4228
+ create(params: TemplateCreateParams): Promise<SandboxTemplateResourceData>;
4229
+ buildSpecSchema(): Promise<Record<string, unknown>>;
4230
+ validate(buildSpec: Record<string, unknown>): Promise<Record<string, unknown>>;
4231
+ listBuilds(templateId: string): Promise<SandboxTemplateBuildResourceData[]>;
4232
+ createBuild(templateId: string, params?: TemplateBuildCreateParams): Promise<SandboxTemplateBuildResourceData>;
4233
+ }
4234
+
4235
+ /**
4236
+ * Settings — tenant config, branding, BYOK provider keys.
4237
+ */
4238
+
4239
+ interface SettingsUpdateParams {
4240
+ [key: string]: unknown;
4241
+ }
4242
+ interface BrandingUpdateParams {
4243
+ logo_url?: string;
4244
+ primary_color?: string;
4245
+ wordmark?: string;
4246
+ [key: string]: unknown;
4247
+ }
4248
+ interface ProviderKeyUpsertParams {
4249
+ key: string;
4250
+ [key: string]: unknown;
4251
+ }
4252
+ declare class Settings {
4253
+ private readonly http;
4254
+ constructor(http: HttpClient);
4255
+ /** Get the current tenant settings. */
4256
+ get(): Promise<Record<string, unknown>>;
4257
+ /** Update tenant settings. */
4258
+ update(params: SettingsUpdateParams): Promise<Record<string, unknown>>;
4259
+ /** Get tenant branding (logo, colors, custom wordmark). */
4260
+ getBranding(): Promise<Record<string, unknown>>;
4261
+ /** Update tenant branding. */
4262
+ updateBranding(params: BrandingUpdateParams): Promise<Record<string, unknown>>;
4263
+ /** Get tenant-scoped compute pricing. */
4264
+ computePricing(): Promise<unknown>;
4265
+ /** Get tenant-scoped GPU pricing. */
4266
+ gpuPricing(): Promise<unknown>;
4267
+ /** List models available to this tenant. */
4268
+ availableModels(): Promise<unknown>;
4269
+ /** List regions enabled for this tenant. */
4270
+ regions(): Promise<unknown>;
4271
+ /** List tenant-level BYOK provider keys (Anthropic, OpenAI, etc.). */
4272
+ listProviderKeys(): Promise<Record<string, unknown>[]>;
4273
+ /** Create or update a BYOK provider key. */
4274
+ upsertProviderKey(provider: string, params: ProviderKeyUpsertParams): Promise<Record<string, unknown>>;
4275
+ /** Delete a BYOK provider key. */
4276
+ deleteProviderKey(provider: string): Promise<void>;
4277
+ }
4278
+
4279
+ /**
4280
+ * SnapshotsStandalone — fleet-wide snapshot index for admin callers.
4281
+ *
4282
+ * Routes: /admin/snapshots/*
4283
+ * Requires admin credential.
4284
+ *
4285
+ * Per-computer snapshots remain nested under client.computers.get(id).checkpoints.
4286
+ * This resource exposes the fleet-wide read-only index used by the admin dashboard.
4287
+ */
4288
+
4289
+ declare class SnapshotsStandalone {
4290
+ private readonly http;
4291
+ constructor(http: HttpClient);
4292
+ list(filters?: Record<string, string | number | boolean | undefined>): Promise<Record<string, unknown>[]>;
4293
+ get(snapshotId: string): Promise<Record<string, unknown>>;
4294
+ }
4295
+
4296
+ /**
4297
+ * Storage resource — managed S3-compatible buckets, objects, and presigned URLs.
4298
+ */
4299
+
4300
+ type BucketId = string & {
4301
+ readonly __brand: "BucketId";
4302
+ };
4303
+ interface BucketData {
4304
+ id: BucketId;
4305
+ tenant_id: string;
4306
+ name: string;
4307
+ region?: string | null;
4308
+ visibility?: "private" | "public" | string;
4309
+ quota_bytes?: number | null;
4310
+ used_bytes?: number | null;
4311
+ public?: boolean;
4312
+ object_count?: number | null;
4313
+ size_bytes?: number | null;
4314
+ created_at?: string;
4315
+ updated_at?: string;
4316
+ [key: string]: unknown;
4317
+ }
4318
+ interface StorageObjectData {
4319
+ key: string;
4320
+ size_bytes?: number;
4321
+ content_type?: string;
4322
+ etag?: string | null;
4323
+ last_modified?: string | null;
4324
+ [key: string]: unknown;
4325
+ }
4326
+ interface PresignResult {
4327
+ url: string;
4328
+ expires_at?: string;
4329
+ [key: string]: unknown;
4330
+ }
4331
+ interface BucketCreateParams {
4332
+ name: string;
4333
+ region?: string;
4334
+ visibility?: "private" | "public";
4335
+ quota_bytes?: number;
4336
+ public?: boolean;
4337
+ [key: string]: unknown;
4338
+ }
4339
+ interface ObjectListParams {
4340
+ prefix?: string;
4341
+ maxKeys?: number;
4342
+ max_keys?: number;
4343
+ marker?: string;
4344
+ /** @deprecated use maxKeys/max_keys; kept as a convenience alias. */
4345
+ limit?: number;
4346
+ /** @deprecated use marker; kept as a convenience alias. */
4347
+ cursor?: string;
4348
+ }
4349
+ interface PresignParams {
4350
+ key: string;
4351
+ method?: "GET" | "PUT";
4352
+ expiresIn?: number;
4353
+ expires_in?: number;
4354
+ /** @deprecated use method; kept as a convenience alias. */
4355
+ operation?: "get" | "put";
4356
+ /** @deprecated use expiresIn/expires_in; kept as a convenience alias. */
4357
+ expiresInSec?: number;
4358
+ /** @deprecated use expiresIn/expires_in; kept as a convenience alias. */
4359
+ expires_in_sec?: number;
4360
+ contentType?: string;
4361
+ content_type?: string;
4362
+ }
4363
+ declare class Storage {
4364
+ private readonly http;
4365
+ constructor(http: HttpClient);
4366
+ listBuckets(): Promise<BucketData[]>;
4367
+ createBucket(params: BucketCreateParams): Promise<BucketData>;
4368
+ getBucket(bucketId: string): Promise<BucketData>;
4369
+ deleteBucket(bucketId: string): Promise<void>;
4370
+ listObjects(bucketId: string, params?: ObjectListParams): Promise<StorageObjectData[]>;
4371
+ putObject(bucketId: string, key: string, content: Uint8Array | ArrayBuffer, opts?: {
4372
+ contentType?: string;
4373
+ }): Promise<Record<string, unknown>>;
4374
+ getObject(bucketId: string, key: string): Promise<Uint8Array>;
4375
+ deleteObject(bucketId: string, key: string): Promise<void>;
4376
+ presign(bucketId: string, params: PresignParams): Promise<PresignResult>;
4377
+ }
4378
+
4379
+ /**
4380
+ * Tenant — current tenant info and plan/usage.
4381
+ */
4382
+
4383
+ interface TenantPlan {
4384
+ id?: string;
4385
+ name?: string;
4386
+ limits?: Record<string, unknown>;
4387
+ usage?: Record<string, unknown>;
4388
+ [key: string]: unknown;
4389
+ }
4390
+ declare class Tenant {
4391
+ private readonly http;
4392
+ constructor(http: HttpClient);
4393
+ /** Get the current tenant's plan, limits, and live usage counters. */
4394
+ current(): Promise<TenantPlan>;
4395
+ }
4396
+
4397
+ /**
4398
+ * Usage — per-session metering, summary, and reports.
4399
+ */
4400
+
4401
+ interface UsageSummary {
4402
+ period_start?: string;
4403
+ period_end?: string;
4404
+ total_credits?: number;
4405
+ [key: string]: unknown;
4406
+ }
4407
+ interface UsageSession {
4408
+ id?: string;
4409
+ computer_id?: string;
4410
+ started_at?: string;
4411
+ ended_at?: string;
4412
+ credits_used?: number;
4413
+ [key: string]: unknown;
4414
+ }
4415
+ interface UsageSessionsParams {
4416
+ computer_id?: string;
4417
+ limit?: number;
4418
+ cursor?: string;
4419
+ [key: string]: string | number | boolean | undefined;
4420
+ }
4421
+ interface UsageReportParams extends UsageSessionsParams {
4422
+ period_start?: string;
4423
+ period_end?: string;
4424
+ }
4425
+ declare class Usage {
4426
+ private readonly http;
4427
+ constructor(http: HttpClient);
4428
+ /** Get the current period usage summary. */
4429
+ current(): Promise<UsageSummary>;
4430
+ /** List per-session metering events. */
4431
+ sessions(params?: UsageSessionsParams): Promise<UsageSession[]>;
4432
+ /** Get a usage report for a period. */
4433
+ report(params?: UsageReportParams): Promise<UsageSummary>;
4434
+ }
4435
+
4436
+ /**
4437
+ * Volumes resource — persistent block storage.
4438
+ */
4439
+
4440
+ type VolumeId = string & {
4441
+ readonly __brand: "VolumeId";
4442
+ };
4443
+ interface VolumeData {
4444
+ id: VolumeId;
4445
+ tenant_id: string;
4446
+ name: string;
4447
+ size_gb: number;
4448
+ state?: string;
4449
+ region?: string | null;
4450
+ attached_to?: string | null;
4451
+ created_at?: string;
4452
+ updated_at?: string;
4453
+ [key: string]: unknown;
4454
+ }
4455
+ interface VolumeListParams {
4456
+ limit?: number;
4457
+ cursor?: string;
4458
+ state?: string;
4459
+ [key: string]: string | number | boolean | undefined;
4460
+ }
4461
+ interface VolumeCreateParams {
4462
+ name: string;
4463
+ size_gb: number;
4464
+ sizeGb?: number;
4465
+ region?: string;
4466
+ idempotencyKey?: string;
4467
+ [key: string]: unknown;
4468
+ }
4469
+ declare class Volumes {
4470
+ private readonly http;
4471
+ constructor(http: HttpClient);
4472
+ list(params?: VolumeListParams): Promise<VolumeData[]>;
4473
+ get(volumeId: string): Promise<VolumeData>;
4474
+ create(params: VolumeCreateParams): Promise<VolumeData>;
4475
+ delete(volumeId: string): Promise<void>;
4476
+ }
4477
+
4478
+ /**
4479
+ * Webhooks resource — tenant outgoing event delivery.
4480
+ */
4481
+
4482
+ type WebhookId = string & {
4483
+ readonly __brand: "WebhookId";
4484
+ };
4485
+ type WebhookDeliveryId = string & {
4486
+ readonly __brand: "WebhookDeliveryId";
4487
+ };
4488
+ interface WebhookData {
4489
+ id: WebhookId;
4490
+ tenant_id: string;
4491
+ url: string;
4492
+ events: string[];
4493
+ state?: string;
4494
+ secret?: string | null;
4495
+ enabled?: boolean;
4496
+ created_at?: string;
4497
+ updated_at?: string;
4498
+ [key: string]: unknown;
4499
+ }
4500
+ interface WebhookDeliveryData {
4501
+ id: WebhookDeliveryId;
4502
+ webhook_id: WebhookId;
4503
+ event?: string;
4504
+ state?: string;
4505
+ response_status?: number | null;
4506
+ attempt_count?: number;
4507
+ next_retry_at?: string | null;
4508
+ delivered_at?: string | null;
4509
+ created_at?: string;
4510
+ [key: string]: unknown;
4511
+ }
4512
+ interface WebhookListParams {
4513
+ limit?: number;
4514
+ cursor?: string;
4515
+ [key: string]: string | number | boolean | undefined;
4516
+ }
4517
+ interface WebhookCreateParams {
4518
+ url: string;
4519
+ events: string[];
4520
+ secret?: string;
4521
+ enabled?: boolean;
4522
+ idempotencyKey?: string;
4523
+ [key: string]: unknown;
4524
+ }
4525
+ interface WebhookUpdateParams {
4526
+ url?: string;
4527
+ events?: string[];
4528
+ secret?: string;
4529
+ enabled?: boolean;
4530
+ [key: string]: unknown;
4531
+ }
4532
+ declare class Webhooks {
4533
+ private readonly http;
4534
+ constructor(http: HttpClient);
4535
+ list(params?: WebhookListParams): Promise<WebhookData[]>;
4536
+ get(webhookId: string): Promise<WebhookData>;
4537
+ create(params: WebhookCreateParams): Promise<WebhookData>;
4538
+ update(webhookId: string, params: WebhookUpdateParams): Promise<WebhookData>;
4539
+ delete(webhookId: string): Promise<void>;
4540
+ test(webhookId: string, opts?: {
4541
+ idempotencyKey?: string;
4542
+ }): Promise<Record<string, unknown>>;
4543
+ deliveries(webhookId: string): Promise<WebhookDeliveryData[]>;
4544
+ }
4545
+
4546
+ /**
4547
+ * The top-level MIOSA client.
4548
+ *
4549
+ * @example
4550
+ * ```ts
4551
+ * import { Miosa } from '@miosa/sdk';
4552
+ *
4553
+ * const miosa = new Miosa({ apiKey: 'msk_u_...' });
4554
+ *
4555
+ * const computer = await miosa.computers.create({ name: 'my-agent' });
4556
+ * await computer.start();
4557
+ * ```
4558
+ */
4559
+ declare class Miosa {
4560
+ /** Current tenant plan, limits, and live usage counters. */
4561
+ readonly tenant: Tenant;
4562
+ /** Datacenter regions, compute sizes, pricing, community templates. */
4563
+ readonly regions: Regions;
4564
+ /** Tenant settings — workspace config, branding, BYOK provider keys. */
4565
+ readonly settings: Settings;
4566
+ /** Aggregated platform dashboard and health overview. */
4567
+ readonly dashboard: Dashboard;
4568
+ /** Admin-scoped analytics overview and timeseries metrics. */
4569
+ readonly analytics: Analytics;
4570
+ /** Admin-scoped audit log event stream. */
4571
+ readonly auditLog: AuditLog;
4572
+ /** Current-period usage summary, sessions, and report queries. */
4573
+ readonly usage: Usage;
4574
+ /** Notification channels — Slack, Discord, email, etc. */
4575
+ readonly channels: Channels;
4576
+ /** OAuth integrations — GitHub, Slack, Linear, Discord. */
4577
+ readonly integrations: Integrations;
4578
+ /** Per-project integrations (Stripe, Resend, Twilio, etc.). */
4579
+ readonly projectIntegrations: ProjectIntegrations;
4580
+ /** Built-in auth for generated apps inside sandboxes/deployments. */
4581
+ readonly projectAuth: ProjectAuth;
4582
+ /** BYOK encrypted per-user provider keys. */
4583
+ readonly externalKeys: ExternalKeys;
4584
+ /** Model Context Protocol — JSON-RPC dispatch + streaming channel. */
4585
+ readonly mcp: Mcp;
4586
+ /** Computer management — create, list, get, delete. */
4587
+ readonly computers: Computers;
4588
+ /** Sandboxes — native code-execution environments under `/sandboxes`. */
4589
+ readonly sandboxes: Sandboxes;
4590
+ /**
4591
+ * Deployments — publish from a sandbox to a stable production URL.
4592
+ * Versions, releases, rollback, custom domains.
4593
+ */
4594
+ readonly deployments: Deployments;
4595
+ /** Credit balance and usage. */
4596
+ readonly credits: Credits;
4597
+ /** Admin surface (`/api/v1/admin/*`) — requires an admin credential. */
4598
+ readonly admin: Admin;
4599
+ /**
4600
+ * OpenComputers — BYOC host management: register your own machines and use
4601
+ * them like cloud computers (jobs, files, tunnels, AI agents, clusters).
4602
+ */
4603
+ readonly openComputers: OpenComputers;
4604
+ /** Managed Postgres databases — lifecycle, credentials, logs. */
4605
+ readonly databases: Databases;
4606
+ /** Managed object storage — buckets, objects, presigned URLs. */
4607
+ readonly storage: Storage;
4608
+ /** Persistent block storage volumes. */
4609
+ readonly volumes: Volumes;
4610
+ /** Tenant-scoped custom domains across all resources. */
4611
+ readonly customDomains: FlatCustomDomains;
4612
+ /** Serverless edge functions — CRUD and invoke. */
4613
+ readonly functions: Functions;
4614
+ /** Scheduled cron jobs — CRUD, pause/resume, execution history. */
4615
+ readonly cronJobs: CronJobs;
4616
+ /** Uptime health checks. */
4617
+ readonly healthChecks: HealthChecks;
4618
+ /** Outgoing tenant webhooks — CRUD, test, delivery history. */
4619
+ readonly webhooks: Webhooks;
4620
+ /** Sandbox templates — CRUD, build-spec schema, builds. */
4621
+ readonly sandboxTemplates: SandboxTemplates;
4622
+ /** API key management — list, create, delete. */
4623
+ readonly apiKeys: ApiKeys;
4624
+ /** Available LLM models via the intelligence gateway. */
4625
+ readonly models: Models;
4626
+ /** OpenAI-compatible text + chat completions (supports SSE streaming). */
4627
+ readonly completions: Completions;
4628
+ /** OpenAI-compatible embedding vectors. */
4629
+ readonly embeddings: Embeddings;
4630
+ /** Admin: fleet-wide + per-tenant LLM provider routing defaults. */
4631
+ readonly providerDefaults: ProviderDefaults;
4632
+ /** Admin: trigger + inspect platform benchmark runs. */
4633
+ readonly benchmarks: Benchmarks;
4634
+ /** Read-only views of the Optimal AI agent fleet. */
4635
+ readonly commandCenter: CommandCenter;
4636
+ /** Community template + agent catalog. */
4637
+ readonly community: Community;
4638
+ /** Admin email campaigns, templates, and inbox. */
4639
+ readonly email: Email;
4640
+ /** Builder UI session metadata. */
4641
+ readonly builderSessions: BuilderSessions;
4642
+ /** Admin: fleet-wide snapshot index. */
4643
+ readonly snapshotsStandalone: SnapshotsStandalone;
4644
+ private readonly http;
4645
+ constructor(config: MiosaClientConfig);
4646
+ }
4647
+
4648
+ interface MiosaErrorBody {
4649
+ error?: {
4650
+ code?: string;
4651
+ message?: string;
4652
+ details?: unknown;
4653
+ };
4654
+ message?: string;
4655
+ code?: string;
4656
+ }
4657
+ declare class MiosaError extends Error {
4658
+ readonly status: number;
4659
+ readonly code: string;
4660
+ readonly details: unknown;
4661
+ readonly requestId: string | undefined;
4662
+ constructor(message: string, status: number, code: string, details?: unknown, requestId?: string);
4663
+ static fromResponse(status: number, body: MiosaErrorBody, requestId?: string): MiosaError;
4664
+ }
4665
+ declare class AuthError extends MiosaError {
4666
+ constructor(message: string, status?: number, code?: string, details?: unknown, requestId?: string);
4667
+ }
4668
+ declare class NotFoundError extends MiosaError {
4669
+ constructor(message: string, code?: string, details?: unknown, requestId?: string);
4670
+ }
4671
+ declare class RateLimitError extends MiosaError {
4672
+ readonly retryAfter: number | undefined;
4673
+ constructor(message: string, details?: unknown, requestId?: string, retryAfter?: number);
4674
+ }
4675
+ declare class InsufficientCreditsError extends MiosaError {
4676
+ constructor(message: string, details?: unknown, requestId?: string);
4677
+ }
4678
+ declare class ValidationError extends MiosaError {
4679
+ constructor(message: string, status: number, code?: string, details?: unknown, requestId?: string);
4680
+ }
4681
+ declare class TimeoutError extends MiosaError {
4682
+ constructor(message?: string);
4683
+ }
4684
+ declare class NetworkError extends MiosaError {
4685
+ readonly cause: Error;
4686
+ constructor(message: string, cause: Error);
4687
+ }
4688
+
4689
+ export { type AddDomainParams, Admin, type AgentDispatchParams, type AgentEvent$1 as AgentEvent, type AgentEventType, type AgentSessionCreateParams, type AgentSessionData, type AgentSessionListResponse$1 as AgentSessionListResponse, type AgentSessionStatus$1 as AgentSessionStatus, Analytics, type AnalyticsFilters, type ApiKeyCreateParams, type ApiKeyCreateResult, type ApiKeyData, type ApiKeyId, type ApiKeyListParams, ApiKeys, type AppCatalogEntry, type AppInstallData, type AppInstallEvent, AuditLog, type AuditLogEvent, type AuditLogListParams, AuthError, type BenchmarkCompareParams, type BenchmarkCreateParams, Benchmarks, type BrandingUpdateParams, type BucketCreateParams, type BucketData, type BucketId, type BuilderSessionListParams, BuilderSessions, type BulkUserActionParams, type ChannelCreateParams, type ChannelData, type ChannelListParams, type ChannelUpdateParams, Channels, type ChatCompletionCreateParams, type ChatCompletionCreateStreamParams, Checkpoints, type ClickParams, type ClusterCreateParams, type ClusterData, type ClusterEvent, type ClusterId, type ClusterListResponse, type ClusterStatus, CommandCenter, Community, type CompletionCreateParams, type CompletionCreateStreamParams, Completions, Computer, ComputerAutoStop, type ComputerCreateParams, type ComputerData, ComputerEnv, type ComputerId, ComputerInbox, type ComputerListParams, type ComputerListResponse, ComputerLogs, type ComputerLogsGetParams, ComputerOsa, ComputerPorts, type ComputerSize, type ComputerStatus, type ComputerTemplateType, ComputerTerminal, type ComputerUpdateParams, type ComputerVisibility, ComputerVolumes, Computers, type CopyParams, type CreateAdminApiKeyParams, type CreditBalance, type CreditTransaction, type CreditTransactionListResponse, type CreditUsage, Credits, type CronJobCreateParams, type CronJobData, type CronJobExecutionData, type CronJobExecutionId, type CronJobId, type CronJobListParams, type CronJobUpdateParams, CronJobs, type CursorInfo, type CustomDomainCreateParams, type CustomDomainData, type CustomDomainId, type CustomDomainListParams, Dashboard, type DashboardSummary, type DatabaseCreateParams, type DatabaseCredentials, type DatabaseData, type DatabaseId, type DatabaseListParams, type DatabaseLogsParams, type DatabaseLogsResult, Databases, type DeploymentBuildData, type DeploymentCreateParams, type DeploymentData, DeploymentDomains, type DeploymentId, type DeploymentListParams, type DeploymentReleaseData, type DeploymentReleaseId, DeploymentReleases, DeploymentRuntimeInstances, type DeploymentServiceData, type DeploymentServiceId, type DeploymentServiceType, type DeploymentSourceType, type DeploymentState, type DeploymentUpdateParams, type DeploymentVersionData, type DeploymentVersionId, type DeploymentVersionKind, type DeploymentVersionState, DeploymentVersions, Deployments, Desktop$1 as Desktop, type DesktopActionResult, type DirEntry, type DirListResult, type DiscordSendTestParams, type DoubleClickParams, type DragParams, Email, EmailCampaigns, EmailInbox, EmailTemplates, type EmbeddingCreateParams, Embeddings, Exec, type ExecParams, type ExecPythonParams, type ExecResult, type ExternalAttribution, type ExternalKeyCreateParams, type ExternalKeyData, ExternalKeys, type FileDeleteParams, type FileDownloadParams, type FileEntry, type FileExportParams, type FileExportResult, type FileListParams, type FileListResult, type FileStat, Files, FlatCustomDomains, type FsEntry, type FsListResponse, type FsStat, type FunctionCreateParams, type FunctionData, type FunctionId, type FunctionInvokeParams, type FunctionListParams, type FunctionUpdateParams, Functions, type GithubRepo, type GithubSshKey, type HealthCheckCreateParams, type HealthCheckData, type HealthCheckId, type HealthCheckListParams, type HealthCheckUpdateParams, HealthChecks, type HostCreateParams, type HostData, type HostEvent, type HostId, type HostListResponse, type HostStatus, type HostUpdateParams, InsufficientCreditsError, type IntegrationCatalogEntry, type IntegrationData, Integrations, type JobData, type JobEvent, type JobEventType, type JobId, type JobListResponse, type JobRunParams, type JobStatus, type KeyParams, type LaunchParams, type LinearCreateIssueParams, type ListAdminApiKeysParams, type ListAdminComputersParams, type ListAdminTenantsParams, type ListAdminUsersParams, Mcp, type McpDispatchParams, Miosa, type MiosaClientConfig, MiosaError, type MkdirParams, Models, type MouseButton, NetworkError, NetworkPolicy, type NetworkPolicyData, type NetworkPolicyEffect, type NetworkPolicyProtocol, type NetworkPolicyRule, type NetworkPolicySetParams, NotFoundError, type NotificationPrefsUpdateParams, type ObjectListParams, type AgentEvent as OcAgentEvent, type OcAgentSessionData, type AgentSessionListResponse as OcAgentSessionListResponse, type OcWorkspaceCreateParams, type OcWorkspaceData, type OcWorkspaceEvent, type OcWorkspaceListResponse, type OcWorkspaceStatus, type OcWorkspaceUpdateParams, OpenComputers, type OverviewData, type PresignParams, type PresignResult, ProjectAuth, type ProjectAuthEnableParams, type ProjectAuthStatus, type ProjectAuthUpdateParams, type ProjectIntegrationCatalogEntry, type ProjectIntegrationCreateParams, type ProjectIntegrationData, type ProjectIntegrationListParams, type ProjectIntegrationUpdateParams, ProjectIntegrations, ProviderDefaults, type ProviderKeyUpsertParams, type PublishFromSandboxParams, type PublishParams, type PublishResult, RateLimitError, type RegionData, Regions, type RollbackParams, type RuntimeInstanceData, type RuntimeInstanceId, type RuntimeInstanceState, type RuntimeLogsResult, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, type SandboxBuildSpec, type SandboxBuildSpecError, type SandboxBuildSpecValidation, SandboxCommands, type SandboxCreateParams, type SandboxData, SandboxEnv, SandboxEvents, type SandboxExecOptions, type SandboxExecResult, SandboxFiles, type SandboxId, type SandboxListParams, SandboxPreview, SandboxPreviews, type SandboxState, SandboxTags, type SandboxTemplate, type SandboxTemplateBuild, type SandboxTemplateBuildCreateParams, type SandboxTemplateBuildResourceData, type SandboxTemplateBuildResourceId, type SandboxTemplateCreateParams, type SandboxTemplateList, type SandboxTemplateListParams, type SandboxTemplateResourceData, type SandboxTemplateResourceId, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, type ScrollDirection, type ScrollParams, type SecretCreateParams, type SecretData, type SecretId, type SecretUpdateParams, type SessionId, Settings, type SettingsUpdateParams, type SizeData, type SlackSendTestParams, type SnapshotCreateParams, type SnapshotData, type SnapshotListResponse, type SnapshotProgressEvent, type SnapshotRestoreResult, type SnapshotStatus, SnapshotsStandalone, Storage, type StorageObjectData, type TemplateBuildCreateParams, type TemplateCreateParams, type TemplateData, Tenant, type TenantId, type TenantPlan, type TerminalCreateParams, TimeoutError, type TimeseriesParams, type TunnelAuthMode, type TunnelCreateParams, type TunnelData, type TunnelId, type TunnelListResponse, type TunnelUpdateParams, type TypeParams, Usage, type UsageReportParams, type UsageSession, type UsageSessionsParams, type UsageSummary, ValidationError, type VersionListParams, type VolumeCreateParams, type VolumeData, type VolumeId, type VolumeListParams, Volumes, type WaitParams, type WebhookCreateParams, type WebhookData, type WebhookDeliveryData, type WebhookDeliveryId, type WebhookId, type WebhookListParams, type WebhookUpdateParams, Webhooks, type WindowFocusParams, type WindowInfo, type WorkspaceId, type WsTicket };