instavm 0.15.0 → 0.17.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 (50) hide show
  1. package/README.md +133 -9
  2. package/dist/InstaVM-DjkmUcaP.d.mts +1393 -0
  3. package/dist/InstaVM-DjkmUcaP.d.ts +1393 -0
  4. package/dist/_instavmToolsCore-34H4iqVZ.d.mts +26 -0
  5. package/dist/_instavmToolsCore-BuaJyxXB.d.ts +26 -0
  6. package/dist/cli.js +7973 -2227
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.d.mts +12 -919
  9. package/dist/index.d.ts +12 -919
  10. package/dist/index.js +1465 -141
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +1450 -136
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/integrations/azure-openai.d.mts +18 -0
  15. package/dist/integrations/azure-openai.d.ts +18 -0
  16. package/dist/integrations/azure-openai.js +332 -0
  17. package/dist/integrations/azure-openai.js.map +1 -0
  18. package/dist/integrations/azure-openai.mjs +299 -0
  19. package/dist/integrations/azure-openai.mjs.map +1 -0
  20. package/dist/integrations/langchain.d.mts +7 -0
  21. package/dist/integrations/langchain.d.ts +7 -0
  22. package/dist/integrations/langchain.js +364 -0
  23. package/dist/integrations/langchain.js.map +1 -0
  24. package/dist/integrations/langchain.mjs +327 -0
  25. package/dist/integrations/langchain.mjs.map +1 -0
  26. package/dist/integrations/llamaindex.d.mts +11 -0
  27. package/dist/integrations/llamaindex.d.ts +11 -0
  28. package/dist/integrations/llamaindex.js +415 -0
  29. package/dist/integrations/llamaindex.js.map +1 -0
  30. package/dist/integrations/llamaindex.mjs +378 -0
  31. package/dist/integrations/llamaindex.mjs.map +1 -0
  32. package/dist/integrations/ollama.d.mts +35 -0
  33. package/dist/integrations/ollama.d.ts +35 -0
  34. package/dist/integrations/ollama.js +421 -0
  35. package/dist/integrations/ollama.js.map +1 -0
  36. package/dist/integrations/ollama.mjs +391 -0
  37. package/dist/integrations/ollama.mjs.map +1 -0
  38. package/dist/integrations/openai.d.mts +19 -0
  39. package/dist/integrations/openai.d.ts +19 -0
  40. package/dist/integrations/openai.js +302 -0
  41. package/dist/integrations/openai.js.map +1 -0
  42. package/dist/integrations/openai.mjs +272 -0
  43. package/dist/integrations/openai.mjs.map +1 -0
  44. package/package.json +46 -4
  45. package/dist/integrations/openai/index.d.mts +0 -16
  46. package/dist/integrations/openai/index.d.ts +0 -16
  47. package/dist/integrations/openai/index.js +0 -38
  48. package/dist/integrations/openai/index.js.map +0 -1
  49. package/dist/integrations/openai/index.mjs +0 -12
  50. package/dist/integrations/openai/index.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,922 +1,9 @@
1
- import FormData from 'form-data';
2
- import { EventEmitter } from 'eventemitter3';
1
+ export { aX as APIKey, aY as APIKeyCreateRequest, A as APIKeysManager, ai as AddVaultCredentialOptions, aj as AddVaultServiceOptions, M as ApiResponse, m as AsyncExecutionResult, aZ as AuditEventQuery, e as AuditManager, B as BrowserManager, b as BrowserSession, r as BrowserSessionInfo, q as BrowserSessionOptions, t as ClickOptions, d as ComputerUseManager, aW as ComputerUseProxyOptions, L as ContentAnchor, aq as CreditAllocation, ar as CreditCheckResponse, as as CreditForecastResponse, at as CreditPeriod, au as CreditRates, av as CreditSummary, aw as CreditTrendsGranularity, ax as CreditTrendsPeriod, ay as CreditTrendsResponse, az as CreditUsageEntry, h as CreditsManager, $ as CurrentUserResponse, aV as CustomDomainCreateRequest, C as CustomDomainsManager, D as DownloadOptions, p as DownloadResult, Y as EgressPolicy, Z as EgressPolicyOptions, E as ExecuteOptions, l as ExecutionResult, H as ExtractContentOptions, G as ExtractOptions, J as ExtractedContent, z as ExtractedElement, F as FileUpload, v as FillOptions, O as HttpClientConfig, I as InstaVM, a as InstaVMOptions, K as InteractiveElement, aA as JsonMap, N as NavigateOptions, s as NavigationResult, al as PTYCreateOptions, P as PTYManager, am as PTYRecord, ap as RecordingDownloadResult, an as RecordingListQuery, ao as RecordingRecord, R as RecordingsManager, Q as RequestConfig, X as RetryConfig, _ as SSHKey, x as ScreenshotOptions, w as ScrollOptions, a0 as SessionStatusResponse, aT as ShareCreateRequest, aU as ShareUpdateRequest, c as SharesManager, aF as SnapshotBuildArgs, aG as SnapshotCreateRequest, aH as SnapshotQueryOptions, S as SnapshotsManager, a4 as TapeAppendEventOptions, a5 as TapeBranchOptions, aa as TapeBranchResponse, i as TapeContext, a9 as TapeDiffResponse, a7 as TapeEvent, a3 as TapeEventsQuery, ab as TapeExportBundle, a8 as TapeLanesResponse, a2 as TapeListQuery, a6 as TapeRecord, a1 as TapeStartOptions, T as TapesManager, j as ToolCallRecorder, k as ToolCallSpan, u as TypeOptions, ak as UpdateVaultOptions, U as UploadOptions, n as UploadResult, o as UsageStats, aD as VMCloneRequest, aB as VMCreateRequest, aS as VMMountedVolumeResponse, aE as VMSnapshotRequest, aC as VMUpdateRequest, aR as VMVolumeMountRequest, V as VMsManager, ah as VaultCatalogTemplate, ad as VaultCredential, ag as VaultDiscoverResponse, ac as VaultRecord, af as VaultRequestLog, ae as VaultService, g as VaultsManager, aL as VolumeCheckpointCreateRequest, aM as VolumeCheckpointResponse, aI as VolumeCreateRequest, aO as VolumeFileDownloadResponse, aN as VolumeFileEntry, aQ as VolumeFileListQuery, aP as VolumeFileUploadRequest, aK as VolumeResponse, aJ as VolumeUpdateRequest, f as VolumesManager, y as WaitCondition, b0 as WebhookDeliveryQuery, a_ as WebhookEndpointCreateRequest, a$ as WebhookEndpointUpdateRequest, W as WebhooksManager } from './InstaVM-DjkmUcaP.mjs';
2
+ import 'form-data';
3
+ import 'eventemitter3';
3
4
 
4
- interface ApiResponse<T = any> {
5
- success?: boolean;
6
- data?: T;
7
- error?: string;
8
- message?: string;
9
- }
10
- interface HttpClientConfig {
11
- baseURL: string;
12
- timeout: number;
13
- maxRetries: number;
14
- retryDelay: number;
15
- apiKey: string;
16
- }
17
- interface RequestConfig {
18
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
19
- url: string;
20
- headers?: Record<string, string>;
21
- data?: any;
22
- params?: Record<string, any>;
23
- timeout?: number;
24
- }
25
- interface RetryConfig {
26
- retries: number;
27
- retryDelay: number;
28
- retryCondition?: (error: any) => boolean;
29
- }
30
-
31
- /**
32
- * HTTP client with authentication, retry logic, and error handling
33
- */
34
- declare class HTTPClient {
35
- private client;
36
- private config;
37
- get apiKey(): string;
38
- constructor(config: HttpClientConfig);
39
- private setupInterceptors;
40
- /**
41
- * Make an HTTP request with retry logic
42
- */
43
- request<T = any>(requestConfig: RequestConfig): Promise<T>;
44
- /**
45
- * POST request with JSON body
46
- */
47
- post<T = any>(url: string, data?: any, headers?: Record<string, string>, timeout?: number): Promise<T>;
48
- /**
49
- * POST request for code execution (uses X-API-Key header like Python client)
50
- */
51
- postExecution<T = any>(url: string, data: any, headers?: Record<string, string>, timeout?: number): Promise<T>;
52
- /**
53
- * POST request with form data (for file uploads)
54
- */
55
- postFormData<T = any>(url: string, formData: FormData, headers?: Record<string, string>): Promise<T>;
56
- /**
57
- * POST request with URL-encoded form data (like Python requests data= parameter)
58
- */
59
- postFormUrlEncoded<T = any>(url: string, data: any, headers?: Record<string, string>): Promise<T>;
60
- /**
61
- * GET request
62
- */
63
- get<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
64
- /**
65
- * DELETE request
66
- */
67
- delete<T = any>(url: string, headers?: Record<string, string>): Promise<T>;
68
- /**
69
- * PUT request
70
- */
71
- put<T = any>(url: string, data?: any, headers?: Record<string, string>): Promise<T>;
72
- /**
73
- * PATCH request
74
- */
75
- patch<T = any>(url: string, data?: any, headers?: Record<string, string>): Promise<T>;
76
- /**
77
- * OPTIONS request
78
- */
79
- options<T = any>(url: string, headers?: Record<string, string>, params?: Record<string, any>): Promise<T>;
80
- /**
81
- * POST request that returns raw binary data (for file downloads)
82
- */
83
- postRaw(url: string, data?: any, headers?: Record<string, string>): Promise<ArrayBuffer>;
84
- }
85
-
86
- interface BrowserSessionOptions {
87
- viewportWidth?: number;
88
- viewportHeight?: number;
89
- userAgent?: string;
90
- }
91
- interface BrowserSessionInfo {
92
- sessionId: string;
93
- status: 'active' | 'inactive' | 'closed';
94
- createdAt: string;
95
- viewportWidth: number;
96
- viewportHeight: number;
97
- userAgent?: string;
98
- }
99
- interface NavigateOptions {
100
- waitTimeout?: number;
101
- waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
102
- }
103
- interface NavigationResult {
104
- success: boolean;
105
- url: string;
106
- title?: string;
107
- status?: number;
108
- }
109
- interface ClickOptions {
110
- timeout?: number;
111
- button?: 'left' | 'right' | 'middle';
112
- clickCount?: number;
113
- force?: boolean;
114
- }
115
- interface TypeOptions {
116
- timeout?: number;
117
- delay?: number;
118
- clear?: boolean;
119
- }
120
- interface FillOptions {
121
- timeout?: number;
122
- force?: boolean;
123
- }
124
- interface ScrollOptions {
125
- x?: number;
126
- y?: number;
127
- behavior?: 'auto' | 'smooth';
128
- }
129
- interface ScreenshotOptions {
130
- fullPage?: boolean;
131
- format?: 'png' | 'jpeg';
132
- quality?: number;
133
- clip?: {
134
- x: number;
135
- y: number;
136
- width: number;
137
- height: number;
138
- };
139
- }
140
- type WaitCondition = {
141
- type: 'visible';
142
- selector: string;
143
- } | {
144
- type: 'hidden';
145
- selector: string;
146
- } | {
147
- type: 'attached';
148
- selector: string;
149
- } | {
150
- type: 'detached';
151
- selector: string;
152
- } | {
153
- type: 'timeout';
154
- ms: number;
155
- };
156
- interface ExtractedElement {
157
- text?: string;
158
- href?: string;
159
- src?: string;
160
- class?: string;
161
- id?: string;
162
- tagName?: string;
163
- [attribute: string]: any;
164
- }
165
- interface ExtractOptions {
166
- attributes?: string[];
167
- maxResults?: number;
168
- }
169
- interface ExtractContentOptions {
170
- url?: string;
171
- includeInteractive?: boolean;
172
- includeAnchors?: boolean;
173
- maxAnchors?: number;
174
- }
175
- interface InteractiveElement {
176
- type: 'button' | 'link' | 'input' | 'select' | 'textarea';
177
- selector: string;
178
- text?: string;
179
- label?: string;
180
- placeholder?: string;
181
- value?: string;
182
- }
183
- interface ContentAnchor {
184
- text: string;
185
- selector: string;
186
- }
187
- interface ExtractedContent {
188
- readableContent: {
189
- content: string;
190
- title?: string;
191
- byline?: string;
192
- excerpt?: string;
193
- siteName?: string;
194
- };
195
- interactiveElements?: InteractiveElement[];
196
- contentAnchors?: ContentAnchor[];
197
- }
198
-
199
- /**
200
- * Browser session for automation
201
- */
202
- declare class BrowserSession extends EventEmitter {
203
- readonly sessionId: string;
204
- private httpClient;
205
- private _isActive;
206
- constructor(sessionId: string, httpClient: HTTPClient);
207
- /**
208
- * Navigate to a URL
209
- */
210
- navigate(url: string, options?: NavigateOptions): Promise<NavigationResult>;
211
- /**
212
- * Click an element
213
- */
214
- click(selector: string, options?: ClickOptions): Promise<void>;
215
- /**
216
- * Type text into an element
217
- */
218
- type(selector: string, text: string, options?: TypeOptions): Promise<void>;
219
- /**
220
- * Fill a form field
221
- */
222
- fill(selector: string, value: string, options?: FillOptions): Promise<void>;
223
- /**
224
- * Scroll the page
225
- */
226
- scroll(options?: ScrollOptions): Promise<void>;
227
- /**
228
- * Take a screenshot
229
- */
230
- screenshot(options?: ScreenshotOptions): Promise<string>;
231
- /**
232
- * Extract elements from the page
233
- */
234
- extractElements(selector: string, attributes?: string[], options?: ExtractOptions): Promise<ExtractedElement[]>;
235
- /**
236
- * Extract LLM-friendly content from the current page
237
- *
238
- * Returns clean article content, interactive elements, and content anchors
239
- * for intelligent browser automation with LLMs.
240
- *
241
- * @param options - Content extraction options
242
- * @returns Extracted content with readable text, interactive elements, and content anchors
243
- *
244
- * @example
245
- * ```typescript
246
- * const content = await session.extractContent();
247
- *
248
- * // LLM reads clean content
249
- * const article = content.readableContent.content;
250
- *
251
- * // LLM finds "Sign Up" in content and uses anchors to get selector
252
- * const signUpAnchor = content.contentAnchors?.find(
253
- * anchor => anchor.text.toLowerCase().includes('sign up')
254
- * );
255
- * if (signUpAnchor) {
256
- * await session.click(signUpAnchor.selector);
257
- * }
258
- * ```
259
- */
260
- extractContent(options?: ExtractContentOptions): Promise<ExtractedContent>;
261
- /**
262
- * Wait for a condition
263
- */
264
- wait(condition: WaitCondition, timeout?: number): Promise<void>;
265
- /**
266
- * Close the browser session
267
- */
268
- close(): Promise<void>;
269
- /**
270
- * Check if session is active
271
- */
272
- get isActive(): boolean;
273
- /**
274
- * Ensure session is active before operations
275
- */
276
- private ensureActive;
277
- }
278
-
279
- /**
280
- * Browser automation manager
281
- */
282
- declare class BrowserManager {
283
- private httpClient;
284
- private activeSessions;
285
- private local;
286
- constructor(httpClient: HTTPClient, local?: boolean);
287
- /**
288
- * Create a new browser session
289
- */
290
- createSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
291
- /**
292
- * Get information about a specific session
293
- */
294
- getSession(sessionId: string): Promise<BrowserSessionInfo>;
295
- /**
296
- * List all browser sessions
297
- */
298
- listSessions(): Promise<BrowserSessionInfo[]>;
299
- /**
300
- * Get a locally tracked session
301
- */
302
- getLocalSession(sessionId: string): BrowserSession | undefined;
303
- /**
304
- * Get all locally tracked sessions
305
- */
306
- getLocalSessions(): BrowserSession[];
307
- /**
308
- * Close all active sessions
309
- */
310
- closeAllSessions(): Promise<void>;
311
- /**
312
- * Navigate to a URL (local mode support - no session required)
313
- */
314
- navigate(url: string, options?: NavigateOptions): Promise<NavigationResult>;
315
- /**
316
- * Extract LLM-friendly content (local mode support - no session required)
317
- */
318
- extractContent(options?: ExtractContentOptions): Promise<ExtractedContent>;
319
- /**
320
- * Clean up resources
321
- */
322
- dispose(): Promise<void>;
323
- }
324
-
325
- type JsonMap = Record<string, any>;
326
- interface VMCreateRequest extends JsonMap {
327
- session_id?: string | null;
328
- vm_lifetime_seconds?: number | null;
329
- memory_mb?: number | null;
330
- vcpu_count?: number | null;
331
- metadata?: JsonMap | null;
332
- egress_policy?: JsonMap | null;
333
- snapshot_id?: string | null;
334
- snapshot_on_terminate?: boolean | null;
335
- snapshot_name?: string | null;
336
- share?: JsonMap | null;
337
- custom_domain?: JsonMap | null;
338
- image_variant?: string | null;
339
- volumes?: VMVolumeMountRequest[] | null;
340
- }
341
- interface VMUpdateRequest extends JsonMap {
342
- memory_mb?: number | null;
343
- egress_policy?: JsonMap | null;
344
- snapshot_on_terminate?: boolean | null;
345
- snapshot_name?: string | null;
346
- }
347
- interface VMCloneRequest extends JsonMap {
348
- snapshot_name?: string | null;
349
- }
350
- interface VMSnapshotRequest extends JsonMap {
351
- name?: string | null;
352
- }
353
- interface SnapshotBuildArgs extends JsonMap {
354
- extra_apt_packages?: string | null;
355
- extra_pip_packages?: string | null;
356
- extra_npm_packages?: string | null;
357
- git_clone_url?: string | null;
358
- git_clone_branch?: string | null;
359
- disk_size_gb?: number | null;
360
- envs?: Record<string, string> | null;
361
- post_build_cmd?: string | null;
362
- }
363
- interface SnapshotCreateRequest extends JsonMap {
364
- oci_image: string;
365
- name?: string | null;
366
- vcpu_count?: number;
367
- memory_mb?: number;
368
- build_args?: SnapshotBuildArgs | null;
369
- type?: 'user' | 'system';
370
- }
371
- interface SnapshotQueryOptions {
372
- type?: 'user' | 'system';
373
- }
374
- interface VolumeCreateRequest extends JsonMap {
375
- name: string;
376
- quota_bytes: number;
377
- }
378
- interface VolumeUpdateRequest extends JsonMap {
379
- name?: string | null;
380
- quota_bytes?: number | null;
381
- }
382
- interface VolumeResponse extends JsonMap {
383
- id: string;
384
- name: string;
385
- quota_bytes: number;
386
- used_bytes: number;
387
- status: string;
388
- created_at?: string | null;
389
- updated_at?: string | null;
390
- }
391
- interface VolumeCheckpointCreateRequest extends JsonMap {
392
- name?: string | null;
393
- }
394
- interface VolumeCheckpointResponse extends JsonMap {
395
- id: string;
396
- volume_id: string;
397
- name?: string | null;
398
- status: string;
399
- created_at?: string | null;
400
- }
401
- interface VolumeFileEntry extends JsonMap {
402
- path: string;
403
- filename: string;
404
- size: number;
405
- }
406
- interface VolumeFileDownloadResponse extends JsonMap {
407
- path: string;
408
- filename: string;
409
- size: number;
410
- content: Buffer;
411
- }
412
- interface VolumeFileUploadRequest extends JsonMap {
413
- path: string;
414
- overwrite?: boolean;
415
- filePath?: string;
416
- fileContent?: Buffer | string;
417
- filename?: string;
418
- }
419
- interface VolumeFileListQuery {
420
- prefix?: string;
421
- recursive?: boolean;
422
- limit?: number;
423
- }
424
- interface VMVolumeMountRequest extends JsonMap {
425
- volume_id: string;
426
- mount_path: string;
427
- mode?: string;
428
- checkpoint_id?: string | null;
429
- }
430
- interface VMMountedVolumeResponse extends JsonMap {
431
- volume_id: string;
432
- mount_path: string;
433
- mode: string;
434
- checkpoint_id?: string | null;
435
- status: string;
436
- }
437
- interface ShareCreateRequest extends JsonMap {
438
- session_id?: string | null;
439
- vm_id?: string | null;
440
- port: number;
441
- is_public?: boolean;
442
- }
443
- interface ShareUpdateRequest extends JsonMap {
444
- is_public?: boolean | null;
445
- revoke?: boolean | null;
446
- }
447
- interface CustomDomainCreateRequest extends JsonMap {
448
- domain: string;
449
- share_id: string;
450
- dns_provider: string;
451
- dns_credentials?: Record<string, string> | null;
452
- }
453
- interface ComputerUseProxyOptions {
454
- params?: Record<string, any>;
455
- body?: any;
456
- }
457
- interface APIKeyCreateRequest extends JsonMap {
458
- description?: string | null;
459
- expires_at?: string | null;
460
- }
461
- interface APIKey extends JsonMap {
462
- id?: number;
463
- description?: string | null;
464
- /** @deprecated Use key_prefix instead */
465
- prefix?: string;
466
- key_prefix?: string;
467
- full_key?: string;
468
- created_at?: string;
469
- expires_at?: string | null;
470
- }
471
- interface AuditEventQuery {
472
- event_group?: string;
473
- event_type?: string;
474
- status?: string;
475
- user_id?: number;
476
- vm_id?: string;
477
- session_id?: string;
478
- cursor?: string;
479
- limit?: number;
480
- }
481
- interface WebhookEndpointCreateRequest extends JsonMap {
482
- url: string;
483
- description?: string | null;
484
- event_patterns?: string[] | null;
485
- timeout_seconds?: number;
486
- max_retries?: number;
487
- }
488
- interface WebhookEndpointUpdateRequest extends JsonMap {
489
- url?: string | null;
490
- description?: string | null;
491
- enabled?: boolean | null;
492
- event_patterns?: string[] | null;
493
- timeout_seconds?: number | null;
494
- max_retries?: number | null;
495
- }
496
- interface WebhookDeliveryQuery {
497
- endpoint_id?: string;
498
- status?: string;
499
- event_type?: string;
500
- cursor?: string;
501
- limit?: number;
502
- }
503
-
504
- declare class VMsManager {
505
- private httpClient;
506
- private local;
507
- constructor(httpClient: HTTPClient, local?: boolean);
508
- private ensureCloud;
509
- create(payload?: VMCreateRequest, wait?: boolean): Promise<JsonMap>;
510
- list(): Promise<JsonMap[]>;
511
- listAll(): Promise<JsonMap[]>;
512
- /**
513
- * Calls GET /v1/vms/ (trailing slash), a distinct route from GET /v1/vms.
514
- */
515
- listAllRecords(): Promise<JsonMap[]>;
516
- get(itemId: string | number): Promise<JsonMap>;
517
- update(vmId: string, payload?: VMUpdateRequest): Promise<JsonMap>;
518
- delete(vmId: string): Promise<JsonMap>;
519
- clone(vmId: string, payload?: VMCloneRequest, wait?: boolean): Promise<JsonMap>;
520
- snapshot(vmId: string, payload?: VMSnapshotRequest, wait?: boolean): Promise<JsonMap>;
521
- mountVolume(vmId: string, payload: VMVolumeMountRequest, wait?: boolean): Promise<VMMountedVolumeResponse>;
522
- listVolumes(vmId: string): Promise<VMMountedVolumeResponse[]>;
523
- unmountVolume(vmId: string, volumeId: string, mountPath: string, wait?: boolean): Promise<JsonMap>;
524
- }
525
-
526
- declare class SnapshotsManager {
527
- private httpClient;
528
- private local;
529
- constructor(httpClient: HTTPClient, local?: boolean);
530
- private ensureCloud;
531
- create(payload: SnapshotCreateRequest): Promise<JsonMap>;
532
- list(options?: SnapshotQueryOptions): Promise<JsonMap[]>;
533
- get(snapshotId: string): Promise<JsonMap>;
534
- delete(snapshotId: string): Promise<JsonMap>;
535
- }
536
-
537
- declare class SharesManager {
538
- private httpClient;
539
- private local;
540
- private getSessionId;
541
- constructor(httpClient: HTTPClient, local?: boolean, getSessionId?: () => string | null);
542
- private ensureCloud;
543
- create(payload: ShareCreateRequest): Promise<JsonMap>;
544
- update(shareId: string, payload: ShareUpdateRequest): Promise<JsonMap>;
545
- }
546
-
547
- declare class CustomDomainsManager {
548
- private httpClient;
549
- private local;
550
- constructor(httpClient: HTTPClient, local?: boolean);
551
- private ensureCloud;
552
- create(payload: CustomDomainCreateRequest): Promise<JsonMap>;
553
- list(): Promise<JsonMap[]>;
554
- health(domainId: number): Promise<JsonMap>;
555
- verify(domainId: number): Promise<JsonMap>;
556
- delete(domainId: number): Promise<JsonMap>;
557
- }
558
-
559
- type ProxyMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
560
- declare class ComputerUseManager {
561
- private httpClient;
562
- private local;
563
- constructor(httpClient: HTTPClient, local?: boolean);
564
- private ensureCloud;
565
- viewerUrl(sessionId: string): Promise<JsonMap>;
566
- proxy(sessionId: string, path: string, method?: ProxyMethod, options?: ComputerUseProxyOptions): Promise<any>;
567
- get(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
568
- post(sessionId: string, path: string, body?: any): Promise<any>;
569
- put(sessionId: string, path: string, body?: any): Promise<any>;
570
- patch(sessionId: string, path: string, body?: any): Promise<any>;
571
- delete(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
572
- options(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
573
- head(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
574
- /**
575
- * Get the VNC WebSocket URL for a computer-use session.
576
- * Returns the URL to connect to; the actual connection requires a WebSocket client.
577
- */
578
- vncWebsockify(sessionId: string): Promise<JsonMap>;
579
- }
580
-
581
- declare class APIKeysManager {
582
- private httpClient;
583
- private local;
584
- constructor(httpClient: HTTPClient, local?: boolean);
585
- private ensureCloud;
586
- create(payload?: APIKeyCreateRequest): Promise<APIKey>;
587
- list(): Promise<APIKey[]>;
588
- get(itemId: number): Promise<APIKey>;
589
- update(itemId: number, payload: APIKeyCreateRequest): Promise<APIKey>;
590
- delete(itemId: number): Promise<JsonMap>;
591
- }
592
-
593
- declare class AuditManager {
594
- private httpClient;
595
- private local;
596
- constructor(httpClient: HTTPClient, local?: boolean);
597
- private ensureCloud;
598
- catalog(): Promise<JsonMap>;
599
- events(query?: AuditEventQuery): Promise<JsonMap>;
600
- getEvent(eventId: string): Promise<JsonMap>;
601
- }
602
-
603
- declare class WebhooksManager {
604
- private httpClient;
605
- private local;
606
- constructor(httpClient: HTTPClient, local?: boolean);
607
- private ensureCloud;
608
- createEndpoint(payload: WebhookEndpointCreateRequest): Promise<JsonMap>;
609
- listEndpoints(): Promise<JsonMap[]>;
610
- getEndpoint(endpointId: string): Promise<JsonMap>;
611
- updateEndpoint(endpointId: string, payload: WebhookEndpointUpdateRequest): Promise<JsonMap>;
612
- deleteEndpoint(endpointId: string): Promise<JsonMap>;
613
- rotateSecret(endpointId: string): Promise<JsonMap>;
614
- sendTestEvent(endpointId: string): Promise<JsonMap>;
615
- verifyEndpoint(endpointId: string): Promise<JsonMap>;
616
- listDeliveries(query?: WebhookDeliveryQuery): Promise<JsonMap>;
617
- replayDelivery(deliveryId: string): Promise<JsonMap>;
618
- }
619
-
620
- declare class VolumesManager {
621
- private httpClient;
622
- private local;
623
- constructor(httpClient: HTTPClient, local?: boolean);
624
- private ensureCloud;
625
- create(payload: VolumeCreateRequest): Promise<VolumeResponse>;
626
- list(refreshUsage?: boolean): Promise<VolumeResponse[]>;
627
- get(volumeId: string, refreshUsage?: boolean): Promise<VolumeResponse>;
628
- update(volumeId: string, payload: VolumeUpdateRequest): Promise<VolumeResponse>;
629
- delete(volumeId: string): Promise<JsonMap>;
630
- createCheckpoint(volumeId: string, payload?: VolumeCheckpointCreateRequest): Promise<VolumeCheckpointResponse>;
631
- listCheckpoints(volumeId: string): Promise<VolumeCheckpointResponse[]>;
632
- deleteCheckpoint(volumeId: string, checkpointId: string): Promise<JsonMap>;
633
- uploadFile(volumeId: string, payload: VolumeFileUploadRequest): Promise<VolumeFileEntry>;
634
- downloadFile(volumeId: string, path: string): Promise<VolumeFileDownloadResponse>;
635
- listFiles(volumeId: string, options?: VolumeFileListQuery): Promise<VolumeFileEntry[]>;
636
- deleteFile(volumeId: string, targetPath: string): Promise<JsonMap>;
637
- }
638
-
639
- interface ExecuteOptions {
640
- language?: 'python' | 'bash';
641
- timeout?: number;
642
- sessionId?: string;
643
- }
644
- interface ExecutionResult {
645
- stdout: string;
646
- stderr: string;
647
- success: boolean;
648
- executionTime?: number;
649
- cpuTime?: number;
650
- createdAt?: string;
651
- sessionId?: string;
652
- error?: string;
653
- }
654
- interface AsyncExecutionResult {
655
- taskId: string;
656
- status: 'pending' | 'running' | 'completed' | 'failed';
657
- output?: string;
658
- success?: boolean;
659
- executionTime?: number;
660
- sessionId?: string;
661
- error?: string;
662
- }
663
- interface TaskResult {
664
- stdout: string;
665
- stderr: string;
666
- executionTime?: number;
667
- cpuTime?: number;
668
- createdAt?: string;
669
- }
670
- interface FileUpload {
671
- name: string;
672
- content: Buffer | string;
673
- path?: string;
674
- }
675
- interface UploadOptions {
676
- sessionId?: string;
677
- remotePath?: string;
678
- recursive?: boolean;
679
- }
680
- interface UploadResult {
681
- success: boolean;
682
- files: string[];
683
- message?: string;
684
- }
685
- interface UsageStats {
686
- sessionsUsed: number;
687
- executionTime: number;
688
- quotaRemaining: number;
689
- quotaLimit: number;
690
- }
691
- interface DownloadOptions {
692
- sessionId?: string;
693
- }
694
- interface DownloadResult {
695
- success: boolean;
696
- filename: string;
697
- content: Buffer;
698
- size: number;
699
- }
700
-
701
- interface EgressPolicy {
702
- allowPackageManagers: boolean;
703
- allowHttp: boolean;
704
- allowHttps: boolean;
705
- allowedDomains: string[];
706
- allowedCidrs: string[];
707
- }
708
- interface EgressPolicyOptions {
709
- allowPackageManagers?: boolean;
710
- allowHttp?: boolean;
711
- allowHttps?: boolean;
712
- allowedDomains?: string[];
713
- allowedCidrs?: string[];
714
- }
715
-
716
- interface SSHKey {
717
- id: number;
718
- fingerprint: string;
719
- keyType: string;
720
- comment: string | null;
721
- createdAt: string;
722
- }
723
-
724
- interface CurrentUserResponse extends Record<string, any> {
725
- id: number;
726
- name: string;
727
- email: string;
728
- is_verified: boolean;
729
- }
730
- interface SessionStatusResponse extends Record<string, any> {
731
- session_id: string;
732
- exists: boolean;
733
- vm_assigned: boolean;
734
- vm_status?: string | null;
735
- vm_id?: string | null;
736
- vm_alive: boolean;
737
- uptime_seconds?: number | null;
738
- expires_in_seconds?: number | null;
739
- created_at?: string | null;
740
- }
741
-
742
- interface InstaVMOptions {
743
- baseURL?: string;
744
- /**
745
- * Timeout in milliseconds. Used for HTTP request timeout and sent to API as VM lifetime (in seconds).
746
- * Default: 300000 (5 minutes)
747
- */
748
- timeout?: number;
749
- maxRetries?: number;
750
- retryDelay?: number;
751
- local?: boolean;
752
- localURL?: string;
753
- /** VM memory in megabytes (optional). Range: 128-8192 MB */
754
- memory_mb?: number;
755
- /** VM vCPU count (optional). Valid values: 1, 2, 4, 6, 8 */
756
- cpu_count?: number;
757
- /** Optional user-defined metadata for filtering */
758
- metadata?: Record<string, any>;
759
- /** Optional environment variables to set in the VM */
760
- env?: Record<string, any>;
761
- }
762
- /**
763
- * Main InstaVM client class
764
- */
765
- declare class InstaVM {
766
- private httpClient;
767
- private _sessionId;
768
- readonly browser: BrowserManager;
769
- readonly vms: VMsManager;
770
- readonly snapshots: SnapshotsManager;
771
- readonly shares: SharesManager;
772
- readonly customDomains: CustomDomainsManager;
773
- readonly computerUse: ComputerUseManager;
774
- readonly apiKeys: APIKeysManager;
775
- readonly audit: AuditManager;
776
- readonly webhooks: WebhooksManager;
777
- readonly volumes: VolumesManager;
778
- readonly local: boolean;
779
- private readonly timeout;
780
- readonly memory_mb?: number;
781
- readonly cpu_count?: number;
782
- readonly metadata?: Record<string, any>;
783
- readonly env?: Record<string, any>;
784
- private _vmUsed;
785
- constructor(apiKey: string, options?: InstaVMOptions);
786
- /**
787
- * Ensure operation is not called in local mode
788
- */
789
- private ensureNotLocal;
790
- /**
791
- * Execute code synchronously
792
- *
793
- * @param command - Command to execute
794
- * @param options - Execution options
795
- * @param options.timeout - Request timeout in milliseconds (used for HTTP request timeout and sent to API in seconds)
796
- * @returns Execution result
797
- */
798
- execute(command: string, options?: ExecuteOptions): Promise<ExecutionResult>;
799
- /**
800
- * Execute code asynchronously
801
- */
802
- executeAsync(command: string, options?: ExecuteOptions): Promise<AsyncExecutionResult>;
803
- /**
804
- * Poll for async task result
805
- *
806
- * @param taskId - The task ID from executeAsync
807
- * @param pollInterval - Seconds between polls (default: 1)
808
- * @param timeout - Maximum seconds to wait (default: 60)
809
- * @returns Task result with stdout, stderr, execution time, etc.
810
- * @throws Error if task doesn't complete within timeout
811
- */
812
- getTaskResult(taskId: string, pollInterval?: number, timeout?: number): Promise<TaskResult>;
813
- /**
814
- * Upload files to the execution environment
815
- */
816
- upload(files: FileUpload[], options?: UploadOptions): Promise<UploadResult>;
817
- /**
818
- * Create a new execution session
819
- */
820
- createSession(): Promise<string>;
821
- /**
822
- * Close a session
823
- * Note: Sessions auto-expire on the server side. This just clears local state.
824
- */
825
- closeSession(sessionId?: string): Promise<void>;
826
- /**
827
- * Check if current session is still active by checking VM status
828
- *
829
- * @returns true if session is active, false otherwise
830
- */
831
- isSessionActive(sessionId?: string): Promise<boolean>;
832
- /**
833
- * Get the app URL for a session
834
- *
835
- * @param sessionId - Session ID (uses current session if not provided)
836
- * @param port - Port to expose (1-65535, default: 80)
837
- */
838
- getSessionAppUrl(sessionId?: string, port?: number): Promise<Record<string, any>>;
839
- /**
840
- * List sandbox records with optional filtering
841
- *
842
- * @param options.metadata - JSON-serializable metadata filters
843
- * @param options.limit - Maximum number of results (1-1000, default: 100)
844
- */
845
- listSandboxes(options?: {
846
- metadata?: Record<string, any>;
847
- limit?: number;
848
- }): Promise<Record<string, any>[]>;
849
- /**
850
- * Get usage statistics for a session
851
- */
852
- getUsage(sessionId?: string): Promise<UsageStats>;
853
- /**
854
- * Get the current user profile.
855
- */
856
- getCurrentUser(): Promise<CurrentUserResponse>;
857
- /**
858
- * Get the current status of a session.
859
- */
860
- getSessionStatus(sessionId?: string): Promise<SessionStatusResponse>;
861
- /**
862
- * Download a file from the remote VM
863
- */
864
- download(filename: string, options?: DownloadOptions): Promise<DownloadResult>;
865
- /**
866
- * Get the current session ID
867
- */
868
- get sessionId(): string | null;
869
- /**
870
- * Kill the VM associated with a session
871
- *
872
- * @param sessionId - The session UUID whose VM should be killed. If not provided, uses current sessionId
873
- * @returns Result containing success message and killed VM ID
874
- */
875
- kill(sessionId?: string): Promise<{
876
- success: boolean;
877
- killed: string;
878
- }>;
879
- /**
880
- * Set egress policy for a session
881
- */
882
- setSessionEgress(options?: EgressPolicyOptions, sessionId?: string): Promise<{
883
- status: string;
884
- sessionId: string;
885
- }>;
886
- /**
887
- * Get egress policy for a session
888
- */
889
- getSessionEgress(sessionId?: string): Promise<EgressPolicy>;
890
- /**
891
- * Set egress policy for a specific VM
892
- */
893
- setVmEgress(vmId: string, options?: EgressPolicyOptions): Promise<{
894
- status: string;
895
- vmId: string;
896
- }>;
897
- /**
898
- * Get egress policy for a specific VM
899
- */
900
- getVmEgress(vmId: string): Promise<EgressPolicy>;
901
- /**
902
- * Add an SSH public key
903
- */
904
- addSshKey(publicKey: string): Promise<SSHKey>;
905
- /**
906
- * List all active SSH keys
907
- */
908
- listSshKeys(): Promise<SSHKey[]>;
909
- /**
910
- * Delete an SSH key by ID
911
- */
912
- deleteSshKey(keyId: number): Promise<{
913
- status: string;
914
- }>;
915
- /**
916
- * Clean up resources
917
- */
918
- dispose(): Promise<void>;
919
- }
5
+ /** Keep in sync with root `package.json` `version`. */
6
+ declare const INSTAVM_JS_SDK_VERSION = "0.17.0";
920
7
 
921
8
  /**
922
9
  * Base error class for all InstaVM SDK errors
@@ -952,6 +39,12 @@ declare class RateLimitError extends InstaVMError {
952
39
  declare class QuotaExceededError extends InstaVMError {
953
40
  constructor(message?: string, options?: any);
954
41
  }
42
+ /**
43
+ * Forbidden errors (403, tier limits, ownership mismatch).
44
+ */
45
+ declare class ForbiddenError extends InstaVMError {
46
+ constructor(message?: string, options?: any);
47
+ }
955
48
  /**
956
49
  * Network-related errors (timeouts, connection issues, 5xx errors)
957
50
  */
@@ -1016,4 +109,4 @@ declare class UnsupportedOperationError extends InstaVMError {
1016
109
  constructor(message?: string, options?: any);
1017
110
  }
1018
111
 
1019
- export { type APIKey, type APIKeyCreateRequest, APIKeysManager, type ApiResponse, type AsyncExecutionResult, type AuditEventQuery, AuditManager, AuthenticationError, BrowserError, BrowserInteractionError, BrowserManager, BrowserNavigationError, BrowserSession, BrowserSessionError, type BrowserSessionInfo, type BrowserSessionOptions, BrowserTimeoutError, type ClickOptions, ComputerUseManager, type ComputerUseProxyOptions, type ContentAnchor, type CurrentUserResponse, type CustomDomainCreateRequest, CustomDomainsManager, type DownloadOptions, type DownloadResult, type EgressPolicy, type EgressPolicyOptions, ElementNotFoundError, type ExecuteOptions, ExecutionError, type ExecutionResult, type ExtractContentOptions, type ExtractOptions, type ExtractedContent, type ExtractedElement, type FileUpload, type FillOptions, type HttpClientConfig, InstaVM, InstaVMError, type InstaVMOptions, type InteractiveElement, type JsonMap, type NavigateOptions, type NavigationResult, NetworkError, QuotaExceededError, RateLimitError, type RequestConfig, type RetryConfig, type SSHKey, type ScreenshotOptions, type ScrollOptions, SessionError, type SessionStatusResponse, type ShareCreateRequest, type ShareUpdateRequest, SharesManager, type SnapshotBuildArgs, type SnapshotCreateRequest, type SnapshotQueryOptions, SnapshotsManager, type TypeOptions, UnsupportedOperationError, type UploadOptions, type UploadResult, type UsageStats, type VMCloneRequest, type VMCreateRequest, type VMMountedVolumeResponse, type VMSnapshotRequest, type VMUpdateRequest, type VMVolumeMountRequest, VMsManager, type VolumeCheckpointCreateRequest, type VolumeCheckpointResponse, type VolumeCreateRequest, type VolumeFileDownloadResponse, type VolumeFileEntry, type VolumeFileListQuery, type VolumeFileUploadRequest, type VolumeResponse, type VolumeUpdateRequest, VolumesManager, type WaitCondition, type WebhookDeliveryQuery, type WebhookEndpointCreateRequest, type WebhookEndpointUpdateRequest, WebhooksManager };
112
+ export { AuthenticationError, BrowserError, BrowserInteractionError, BrowserNavigationError, BrowserSessionError, BrowserTimeoutError, ElementNotFoundError, ExecutionError, ForbiddenError, INSTAVM_JS_SDK_VERSION, InstaVMError, NetworkError, QuotaExceededError, RateLimitError, SessionError, UnsupportedOperationError };