instavm 0.8.3 → 0.11.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.
- package/README.md +200 -812
- package/dist/index.d.mts +323 -2
- package/dist/index.d.ts +323 -2
- package/dist/index.js +769 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +760 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface HttpClientConfig {
|
|
|
15
15
|
apiKey: string;
|
|
16
16
|
}
|
|
17
17
|
interface RequestConfig {
|
|
18
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
18
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
19
19
|
url: string;
|
|
20
20
|
headers?: Record<string, string>;
|
|
21
21
|
data?: any;
|
|
@@ -65,6 +65,18 @@ declare class HTTPClient {
|
|
|
65
65
|
* DELETE request
|
|
66
66
|
*/
|
|
67
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>;
|
|
68
80
|
/**
|
|
69
81
|
* POST request that returns raw binary data (for file downloads)
|
|
70
82
|
*/
|
|
@@ -310,6 +322,225 @@ declare class BrowserManager {
|
|
|
310
322
|
dispose(): Promise<void>;
|
|
311
323
|
}
|
|
312
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
|
+
}
|
|
340
|
+
interface VMUpdateRequest extends JsonMap {
|
|
341
|
+
memory_mb?: number | null;
|
|
342
|
+
egress_policy?: JsonMap | null;
|
|
343
|
+
snapshot_on_terminate?: boolean | null;
|
|
344
|
+
snapshot_name?: string | null;
|
|
345
|
+
}
|
|
346
|
+
interface VMCloneRequest extends JsonMap {
|
|
347
|
+
snapshot_name?: string | null;
|
|
348
|
+
}
|
|
349
|
+
interface VMSnapshotRequest extends JsonMap {
|
|
350
|
+
name?: string | null;
|
|
351
|
+
}
|
|
352
|
+
interface SnapshotBuildArgs extends JsonMap {
|
|
353
|
+
extra_apt_packages?: string | null;
|
|
354
|
+
extra_pip_packages?: string | null;
|
|
355
|
+
extra_npm_packages?: string | null;
|
|
356
|
+
git_clone_url?: string | null;
|
|
357
|
+
git_clone_branch?: string | null;
|
|
358
|
+
disk_size_gb?: number | null;
|
|
359
|
+
envs?: Record<string, string> | null;
|
|
360
|
+
post_build_cmd?: string | null;
|
|
361
|
+
}
|
|
362
|
+
interface SnapshotCreateRequest extends JsonMap {
|
|
363
|
+
oci_image: string;
|
|
364
|
+
name?: string | null;
|
|
365
|
+
vcpu_count?: number;
|
|
366
|
+
memory_mb?: number;
|
|
367
|
+
build_args?: SnapshotBuildArgs | null;
|
|
368
|
+
type?: 'user' | 'system';
|
|
369
|
+
}
|
|
370
|
+
interface SnapshotQueryOptions {
|
|
371
|
+
type?: 'user' | 'system';
|
|
372
|
+
}
|
|
373
|
+
interface ShareCreateRequest extends JsonMap {
|
|
374
|
+
session_id?: string | null;
|
|
375
|
+
vm_id?: string | null;
|
|
376
|
+
port: number;
|
|
377
|
+
is_public?: boolean;
|
|
378
|
+
}
|
|
379
|
+
interface ShareUpdateRequest extends JsonMap {
|
|
380
|
+
is_public?: boolean | null;
|
|
381
|
+
revoke?: boolean | null;
|
|
382
|
+
}
|
|
383
|
+
interface CustomDomainCreateRequest extends JsonMap {
|
|
384
|
+
domain: string;
|
|
385
|
+
share_id: string;
|
|
386
|
+
dns_provider: string;
|
|
387
|
+
dns_credentials?: Record<string, string> | null;
|
|
388
|
+
}
|
|
389
|
+
interface ComputerUseProxyOptions {
|
|
390
|
+
params?: Record<string, any>;
|
|
391
|
+
body?: any;
|
|
392
|
+
}
|
|
393
|
+
interface APIKeyCreateRequest extends JsonMap {
|
|
394
|
+
description?: string | null;
|
|
395
|
+
expires_at?: string | null;
|
|
396
|
+
}
|
|
397
|
+
interface APIKey extends JsonMap {
|
|
398
|
+
id?: number;
|
|
399
|
+
description?: string | null;
|
|
400
|
+
prefix?: string;
|
|
401
|
+
created_at?: string;
|
|
402
|
+
expires_at?: string | null;
|
|
403
|
+
}
|
|
404
|
+
interface AuditEventQuery {
|
|
405
|
+
event_group?: string;
|
|
406
|
+
event_type?: string;
|
|
407
|
+
status?: string;
|
|
408
|
+
user_id?: number;
|
|
409
|
+
vm_id?: string;
|
|
410
|
+
session_id?: string;
|
|
411
|
+
cursor?: string;
|
|
412
|
+
limit?: number;
|
|
413
|
+
}
|
|
414
|
+
interface WebhookEndpointCreateRequest extends JsonMap {
|
|
415
|
+
url: string;
|
|
416
|
+
description?: string | null;
|
|
417
|
+
event_patterns?: string[] | null;
|
|
418
|
+
timeout_seconds?: number;
|
|
419
|
+
max_retries?: number;
|
|
420
|
+
}
|
|
421
|
+
interface WebhookEndpointUpdateRequest extends JsonMap {
|
|
422
|
+
url?: string | null;
|
|
423
|
+
description?: string | null;
|
|
424
|
+
enabled?: boolean | null;
|
|
425
|
+
event_patterns?: string[] | null;
|
|
426
|
+
timeout_seconds?: number | null;
|
|
427
|
+
max_retries?: number | null;
|
|
428
|
+
}
|
|
429
|
+
interface WebhookDeliveryQuery {
|
|
430
|
+
endpoint_id?: string;
|
|
431
|
+
status?: string;
|
|
432
|
+
event_type?: string;
|
|
433
|
+
cursor?: string;
|
|
434
|
+
limit?: number;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
declare class VMsManager {
|
|
438
|
+
private httpClient;
|
|
439
|
+
private local;
|
|
440
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
441
|
+
private ensureCloud;
|
|
442
|
+
create(payload?: VMCreateRequest, wait?: boolean): Promise<JsonMap>;
|
|
443
|
+
list(): Promise<JsonMap[]>;
|
|
444
|
+
listAll(): Promise<JsonMap[]>;
|
|
445
|
+
/**
|
|
446
|
+
* Calls GET /v1/vms/ (trailing slash), a distinct route from GET /v1/vms.
|
|
447
|
+
*/
|
|
448
|
+
listAllRecords(): Promise<JsonMap[]>;
|
|
449
|
+
get(itemId: string | number): Promise<JsonMap>;
|
|
450
|
+
update(vmId: string, payload?: VMUpdateRequest): Promise<JsonMap>;
|
|
451
|
+
delete(vmId: string): Promise<JsonMap>;
|
|
452
|
+
clone(vmId: string, payload?: VMCloneRequest, wait?: boolean): Promise<JsonMap>;
|
|
453
|
+
snapshot(vmId: string, payload?: VMSnapshotRequest, wait?: boolean): Promise<JsonMap>;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
declare class SnapshotsManager {
|
|
457
|
+
private httpClient;
|
|
458
|
+
private local;
|
|
459
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
460
|
+
private ensureCloud;
|
|
461
|
+
create(payload: SnapshotCreateRequest): Promise<JsonMap>;
|
|
462
|
+
list(options?: SnapshotQueryOptions): Promise<JsonMap[]>;
|
|
463
|
+
get(snapshotId: string): Promise<JsonMap>;
|
|
464
|
+
delete(snapshotId: string): Promise<JsonMap>;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
declare class SharesManager {
|
|
468
|
+
private httpClient;
|
|
469
|
+
private local;
|
|
470
|
+
private getSessionId;
|
|
471
|
+
constructor(httpClient: HTTPClient, local?: boolean, getSessionId?: () => string | null);
|
|
472
|
+
private ensureCloud;
|
|
473
|
+
create(payload: ShareCreateRequest): Promise<JsonMap>;
|
|
474
|
+
update(shareId: string, payload: ShareUpdateRequest): Promise<JsonMap>;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare class CustomDomainsManager {
|
|
478
|
+
private httpClient;
|
|
479
|
+
private local;
|
|
480
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
481
|
+
private ensureCloud;
|
|
482
|
+
create(payload: CustomDomainCreateRequest): Promise<JsonMap>;
|
|
483
|
+
list(): Promise<JsonMap[]>;
|
|
484
|
+
health(domainId: number): Promise<JsonMap>;
|
|
485
|
+
verify(domainId: number): Promise<JsonMap>;
|
|
486
|
+
delete(domainId: number): Promise<JsonMap>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
type ProxyMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
490
|
+
declare class ComputerUseManager {
|
|
491
|
+
private httpClient;
|
|
492
|
+
private local;
|
|
493
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
494
|
+
private ensureCloud;
|
|
495
|
+
viewerUrl(sessionId: string): Promise<JsonMap>;
|
|
496
|
+
proxy(sessionId: string, path: string, method?: ProxyMethod, options?: ComputerUseProxyOptions): Promise<any>;
|
|
497
|
+
get(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
|
|
498
|
+
post(sessionId: string, path: string, body?: any): Promise<any>;
|
|
499
|
+
put(sessionId: string, path: string, body?: any): Promise<any>;
|
|
500
|
+
patch(sessionId: string, path: string, body?: any): Promise<any>;
|
|
501
|
+
delete(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
|
|
502
|
+
options(sessionId: string, path: string, params?: Record<string, any>): Promise<any>;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
declare class APIKeysManager {
|
|
506
|
+
private httpClient;
|
|
507
|
+
private local;
|
|
508
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
509
|
+
private ensureCloud;
|
|
510
|
+
create(payload?: APIKeyCreateRequest): Promise<APIKey>;
|
|
511
|
+
list(): Promise<APIKey[]>;
|
|
512
|
+
get(itemId: number): Promise<APIKey>;
|
|
513
|
+
update(itemId: number, payload: APIKeyCreateRequest): Promise<APIKey>;
|
|
514
|
+
delete(itemId: number): Promise<JsonMap>;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
declare class AuditManager {
|
|
518
|
+
private httpClient;
|
|
519
|
+
private local;
|
|
520
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
521
|
+
private ensureCloud;
|
|
522
|
+
catalog(): Promise<JsonMap>;
|
|
523
|
+
events(query?: AuditEventQuery): Promise<JsonMap>;
|
|
524
|
+
getEvent(eventId: string): Promise<JsonMap>;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
declare class WebhooksManager {
|
|
528
|
+
private httpClient;
|
|
529
|
+
private local;
|
|
530
|
+
constructor(httpClient: HTTPClient, local?: boolean);
|
|
531
|
+
private ensureCloud;
|
|
532
|
+
createEndpoint(payload: WebhookEndpointCreateRequest): Promise<JsonMap>;
|
|
533
|
+
listEndpoints(): Promise<JsonMap[]>;
|
|
534
|
+
getEndpoint(endpointId: string): Promise<JsonMap>;
|
|
535
|
+
updateEndpoint(endpointId: string, payload: WebhookEndpointUpdateRequest): Promise<JsonMap>;
|
|
536
|
+
deleteEndpoint(endpointId: string): Promise<JsonMap>;
|
|
537
|
+
rotateSecret(endpointId: string): Promise<JsonMap>;
|
|
538
|
+
sendTestEvent(endpointId: string): Promise<JsonMap>;
|
|
539
|
+
verifyEndpoint(endpointId: string): Promise<JsonMap>;
|
|
540
|
+
listDeliveries(query?: WebhookDeliveryQuery): Promise<JsonMap>;
|
|
541
|
+
replayDelivery(deliveryId: string): Promise<JsonMap>;
|
|
542
|
+
}
|
|
543
|
+
|
|
313
544
|
interface ExecuteOptions {
|
|
314
545
|
language?: 'python' | 'bash';
|
|
315
546
|
timeout?: number;
|
|
@@ -372,6 +603,29 @@ interface DownloadResult {
|
|
|
372
603
|
size: number;
|
|
373
604
|
}
|
|
374
605
|
|
|
606
|
+
interface EgressPolicy {
|
|
607
|
+
allowPackageManagers: boolean;
|
|
608
|
+
allowHttp: boolean;
|
|
609
|
+
allowHttps: boolean;
|
|
610
|
+
allowedDomains: string[];
|
|
611
|
+
allowedCidrs: string[];
|
|
612
|
+
}
|
|
613
|
+
interface EgressPolicyOptions {
|
|
614
|
+
allowPackageManagers?: boolean;
|
|
615
|
+
allowHttp?: boolean;
|
|
616
|
+
allowHttps?: boolean;
|
|
617
|
+
allowedDomains?: string[];
|
|
618
|
+
allowedCidrs?: string[];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
interface SSHKey {
|
|
622
|
+
id: number;
|
|
623
|
+
fingerprint: string;
|
|
624
|
+
keyType: string;
|
|
625
|
+
comment: string | null;
|
|
626
|
+
createdAt: string;
|
|
627
|
+
}
|
|
628
|
+
|
|
375
629
|
interface InstaVMOptions {
|
|
376
630
|
baseURL?: string;
|
|
377
631
|
/**
|
|
@@ -383,6 +637,14 @@ interface InstaVMOptions {
|
|
|
383
637
|
retryDelay?: number;
|
|
384
638
|
local?: boolean;
|
|
385
639
|
localURL?: string;
|
|
640
|
+
/** VM memory in megabytes (optional). Range: 128-8192 MB */
|
|
641
|
+
memory_mb?: number;
|
|
642
|
+
/** VM vCPU count (optional). Valid values: 1, 2, 4, 6, 8 */
|
|
643
|
+
cpu_count?: number;
|
|
644
|
+
/** Optional user-defined metadata for filtering */
|
|
645
|
+
metadata?: Record<string, any>;
|
|
646
|
+
/** Optional environment variables to set in the VM */
|
|
647
|
+
env?: Record<string, any>;
|
|
386
648
|
}
|
|
387
649
|
/**
|
|
388
650
|
* Main InstaVM client class
|
|
@@ -391,8 +653,21 @@ declare class InstaVM {
|
|
|
391
653
|
private httpClient;
|
|
392
654
|
private _sessionId;
|
|
393
655
|
readonly browser: BrowserManager;
|
|
656
|
+
readonly vms: VMsManager;
|
|
657
|
+
readonly snapshots: SnapshotsManager;
|
|
658
|
+
readonly shares: SharesManager;
|
|
659
|
+
readonly customDomains: CustomDomainsManager;
|
|
660
|
+
readonly computerUse: ComputerUseManager;
|
|
661
|
+
readonly apiKeys: APIKeysManager;
|
|
662
|
+
readonly audit: AuditManager;
|
|
663
|
+
readonly webhooks: WebhooksManager;
|
|
394
664
|
readonly local: boolean;
|
|
395
665
|
private readonly timeout;
|
|
666
|
+
readonly memory_mb?: number;
|
|
667
|
+
readonly cpu_count?: number;
|
|
668
|
+
readonly metadata?: Record<string, any>;
|
|
669
|
+
readonly env?: Record<string, any>;
|
|
670
|
+
private _vmUsed;
|
|
396
671
|
constructor(apiKey: string, options?: InstaVMOptions);
|
|
397
672
|
/**
|
|
398
673
|
* Ensure operation is not called in local mode
|
|
@@ -452,6 +727,52 @@ declare class InstaVM {
|
|
|
452
727
|
* Get the current session ID
|
|
453
728
|
*/
|
|
454
729
|
get sessionId(): string | null;
|
|
730
|
+
/**
|
|
731
|
+
* Kill the VM associated with a session
|
|
732
|
+
*
|
|
733
|
+
* @param sessionId - The session UUID whose VM should be killed. If not provided, uses current sessionId
|
|
734
|
+
* @returns Result containing success message and killed VM ID
|
|
735
|
+
*/
|
|
736
|
+
kill(sessionId?: string): Promise<{
|
|
737
|
+
success: boolean;
|
|
738
|
+
killed: string;
|
|
739
|
+
}>;
|
|
740
|
+
/**
|
|
741
|
+
* Set egress policy for a session
|
|
742
|
+
*/
|
|
743
|
+
setSessionEgress(options?: EgressPolicyOptions, sessionId?: string): Promise<{
|
|
744
|
+
status: string;
|
|
745
|
+
sessionId: string;
|
|
746
|
+
}>;
|
|
747
|
+
/**
|
|
748
|
+
* Get egress policy for a session
|
|
749
|
+
*/
|
|
750
|
+
getSessionEgress(sessionId?: string): Promise<EgressPolicy>;
|
|
751
|
+
/**
|
|
752
|
+
* Set egress policy for a specific VM
|
|
753
|
+
*/
|
|
754
|
+
setVmEgress(vmId: string, options?: EgressPolicyOptions): Promise<{
|
|
755
|
+
status: string;
|
|
756
|
+
vmId: string;
|
|
757
|
+
}>;
|
|
758
|
+
/**
|
|
759
|
+
* Get egress policy for a specific VM
|
|
760
|
+
*/
|
|
761
|
+
getVmEgress(vmId: string): Promise<EgressPolicy>;
|
|
762
|
+
/**
|
|
763
|
+
* Add an SSH public key
|
|
764
|
+
*/
|
|
765
|
+
addSshKey(publicKey: string): Promise<SSHKey>;
|
|
766
|
+
/**
|
|
767
|
+
* List all active SSH keys
|
|
768
|
+
*/
|
|
769
|
+
listSshKeys(): Promise<SSHKey[]>;
|
|
770
|
+
/**
|
|
771
|
+
* Delete an SSH key by ID
|
|
772
|
+
*/
|
|
773
|
+
deleteSshKey(keyId: number): Promise<{
|
|
774
|
+
status: string;
|
|
775
|
+
}>;
|
|
455
776
|
/**
|
|
456
777
|
* Clean up resources
|
|
457
778
|
*/
|
|
@@ -556,4 +877,4 @@ declare class UnsupportedOperationError extends InstaVMError {
|
|
|
556
877
|
constructor(message?: string, options?: any);
|
|
557
878
|
}
|
|
558
879
|
|
|
559
|
-
export { type ApiResponse, type AsyncExecutionResult, AuthenticationError, BrowserError, BrowserInteractionError, BrowserManager, BrowserNavigationError, BrowserSession, BrowserSessionError, type BrowserSessionInfo, type BrowserSessionOptions, BrowserTimeoutError, type ClickOptions, type ContentAnchor, type DownloadOptions, type DownloadResult, 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 NavigateOptions, type NavigationResult, NetworkError, QuotaExceededError, RateLimitError, type RequestConfig, type RetryConfig, type ScreenshotOptions, type ScrollOptions, SessionError, type TypeOptions, UnsupportedOperationError, type UploadOptions, type UploadResult, type UsageStats, type WaitCondition };
|
|
880
|
+
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 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 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 VMSnapshotRequest, type VMUpdateRequest, VMsManager, type WaitCondition, type WebhookDeliveryQuery, type WebhookEndpointCreateRequest, type WebhookEndpointUpdateRequest, WebhooksManager };
|