instavm 0.1.0 → 0.2.1
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 +3 -1
- package/package.json +3 -3
- package/dist/index.d.mts +0 -424
- package/dist/index.d.ts +0 -424
- package/dist/integrations/openai/index.d.mts +0 -16
- package/dist/integrations/openai/index.d.ts +0 -16
package/README.md
CHANGED
|
@@ -774,7 +774,9 @@ This is an official SDK. For issues and feature requests, please use the GitHub
|
|
|
774
774
|
|
|
775
775
|
## License
|
|
776
776
|
|
|
777
|
-
|
|
777
|
+
Proprietary. This SDK is provided for use with InstaVM services only.
|
|
778
|
+
|
|
779
|
+
All rights reserved. No redistribution or modification permitted.
|
|
778
780
|
|
|
779
781
|
---
|
|
780
782
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instavm",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Official JavaScript SDK for InstaVM API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"cloud"
|
|
46
46
|
],
|
|
47
47
|
"author": "InstaVM",
|
|
48
|
-
"license": "
|
|
48
|
+
"license": "UNLICENSED",
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
51
|
"url": "https://github.com/instavm/js.git"
|
|
@@ -77,4 +77,4 @@
|
|
|
77
77
|
"typescript": "^5.7.2",
|
|
78
78
|
"vitest": "^2.1.8"
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
|
-
|
|
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';
|
|
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>): 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>): 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
|
-
* GET request
|
|
58
|
-
*/
|
|
59
|
-
get<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
|
|
60
|
-
/**
|
|
61
|
-
* DELETE request
|
|
62
|
-
*/
|
|
63
|
-
delete<T = any>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface BrowserSessionOptions {
|
|
67
|
-
viewportWidth?: number;
|
|
68
|
-
viewportHeight?: number;
|
|
69
|
-
userAgent?: string;
|
|
70
|
-
}
|
|
71
|
-
interface BrowserSessionInfo {
|
|
72
|
-
sessionId: string;
|
|
73
|
-
status: 'active' | 'inactive' | 'closed';
|
|
74
|
-
createdAt: string;
|
|
75
|
-
viewportWidth: number;
|
|
76
|
-
viewportHeight: number;
|
|
77
|
-
userAgent?: string;
|
|
78
|
-
}
|
|
79
|
-
interface NavigateOptions {
|
|
80
|
-
waitTimeout?: number;
|
|
81
|
-
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
82
|
-
}
|
|
83
|
-
interface NavigationResult {
|
|
84
|
-
success: boolean;
|
|
85
|
-
url: string;
|
|
86
|
-
title?: string;
|
|
87
|
-
status?: number;
|
|
88
|
-
}
|
|
89
|
-
interface ClickOptions {
|
|
90
|
-
timeout?: number;
|
|
91
|
-
button?: 'left' | 'right' | 'middle';
|
|
92
|
-
clickCount?: number;
|
|
93
|
-
force?: boolean;
|
|
94
|
-
}
|
|
95
|
-
interface TypeOptions {
|
|
96
|
-
timeout?: number;
|
|
97
|
-
delay?: number;
|
|
98
|
-
clear?: boolean;
|
|
99
|
-
}
|
|
100
|
-
interface FillOptions {
|
|
101
|
-
timeout?: number;
|
|
102
|
-
force?: boolean;
|
|
103
|
-
}
|
|
104
|
-
interface ScrollOptions {
|
|
105
|
-
x?: number;
|
|
106
|
-
y?: number;
|
|
107
|
-
behavior?: 'auto' | 'smooth';
|
|
108
|
-
}
|
|
109
|
-
interface ScreenshotOptions {
|
|
110
|
-
fullPage?: boolean;
|
|
111
|
-
format?: 'png' | 'jpeg';
|
|
112
|
-
quality?: number;
|
|
113
|
-
clip?: {
|
|
114
|
-
x: number;
|
|
115
|
-
y: number;
|
|
116
|
-
width: number;
|
|
117
|
-
height: number;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
type WaitCondition = {
|
|
121
|
-
type: 'visible';
|
|
122
|
-
selector: string;
|
|
123
|
-
} | {
|
|
124
|
-
type: 'hidden';
|
|
125
|
-
selector: string;
|
|
126
|
-
} | {
|
|
127
|
-
type: 'attached';
|
|
128
|
-
selector: string;
|
|
129
|
-
} | {
|
|
130
|
-
type: 'detached';
|
|
131
|
-
selector: string;
|
|
132
|
-
} | {
|
|
133
|
-
type: 'timeout';
|
|
134
|
-
ms: number;
|
|
135
|
-
};
|
|
136
|
-
interface ExtractedElement {
|
|
137
|
-
text?: string;
|
|
138
|
-
href?: string;
|
|
139
|
-
src?: string;
|
|
140
|
-
class?: string;
|
|
141
|
-
id?: string;
|
|
142
|
-
tagName?: string;
|
|
143
|
-
[attribute: string]: any;
|
|
144
|
-
}
|
|
145
|
-
interface ExtractOptions {
|
|
146
|
-
attributes?: string[];
|
|
147
|
-
maxResults?: number;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Browser session for automation
|
|
152
|
-
*/
|
|
153
|
-
declare class BrowserSession extends EventEmitter {
|
|
154
|
-
readonly sessionId: string;
|
|
155
|
-
private httpClient;
|
|
156
|
-
private _isActive;
|
|
157
|
-
constructor(sessionId: string, httpClient: HTTPClient);
|
|
158
|
-
/**
|
|
159
|
-
* Navigate to a URL
|
|
160
|
-
*/
|
|
161
|
-
navigate(url: string, options?: NavigateOptions): Promise<NavigationResult>;
|
|
162
|
-
/**
|
|
163
|
-
* Click an element
|
|
164
|
-
*/
|
|
165
|
-
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Type text into an element
|
|
168
|
-
*/
|
|
169
|
-
type(selector: string, text: string, options?: TypeOptions): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Fill a form field
|
|
172
|
-
*/
|
|
173
|
-
fill(selector: string, value: string, options?: FillOptions): Promise<void>;
|
|
174
|
-
/**
|
|
175
|
-
* Scroll the page
|
|
176
|
-
*/
|
|
177
|
-
scroll(options?: ScrollOptions): Promise<void>;
|
|
178
|
-
/**
|
|
179
|
-
* Take a screenshot
|
|
180
|
-
*/
|
|
181
|
-
screenshot(options?: ScreenshotOptions): Promise<string>;
|
|
182
|
-
/**
|
|
183
|
-
* Extract elements from the page
|
|
184
|
-
*/
|
|
185
|
-
extractElements(selector: string, attributes?: string[], options?: ExtractOptions): Promise<ExtractedElement[]>;
|
|
186
|
-
/**
|
|
187
|
-
* Wait for a condition
|
|
188
|
-
*/
|
|
189
|
-
wait(condition: WaitCondition, timeout?: number): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Close the browser session
|
|
192
|
-
*/
|
|
193
|
-
close(): Promise<void>;
|
|
194
|
-
/**
|
|
195
|
-
* Check if session is active
|
|
196
|
-
*/
|
|
197
|
-
get isActive(): boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Ensure session is active before operations
|
|
200
|
-
*/
|
|
201
|
-
private ensureActive;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Browser automation manager
|
|
206
|
-
*/
|
|
207
|
-
declare class BrowserManager {
|
|
208
|
-
private httpClient;
|
|
209
|
-
private activeSessions;
|
|
210
|
-
constructor(httpClient: HTTPClient);
|
|
211
|
-
/**
|
|
212
|
-
* Create a new browser session
|
|
213
|
-
*/
|
|
214
|
-
createSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
|
|
215
|
-
/**
|
|
216
|
-
* Get information about a specific session
|
|
217
|
-
*/
|
|
218
|
-
getSession(sessionId: string): Promise<BrowserSessionInfo>;
|
|
219
|
-
/**
|
|
220
|
-
* List all browser sessions
|
|
221
|
-
*/
|
|
222
|
-
listSessions(): Promise<BrowserSessionInfo[]>;
|
|
223
|
-
/**
|
|
224
|
-
* Get a locally tracked session
|
|
225
|
-
*/
|
|
226
|
-
getLocalSession(sessionId: string): BrowserSession | undefined;
|
|
227
|
-
/**
|
|
228
|
-
* Get all locally tracked sessions
|
|
229
|
-
*/
|
|
230
|
-
getLocalSessions(): BrowserSession[];
|
|
231
|
-
/**
|
|
232
|
-
* Close all active sessions
|
|
233
|
-
*/
|
|
234
|
-
closeAllSessions(): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Clean up resources
|
|
237
|
-
*/
|
|
238
|
-
dispose(): Promise<void>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
interface ExecuteOptions {
|
|
242
|
-
language?: 'python' | 'bash';
|
|
243
|
-
timeout?: number;
|
|
244
|
-
sessionId?: string;
|
|
245
|
-
}
|
|
246
|
-
interface ExecutionResult {
|
|
247
|
-
output: string;
|
|
248
|
-
success: boolean;
|
|
249
|
-
executionTime: number;
|
|
250
|
-
sessionId?: string;
|
|
251
|
-
error?: string;
|
|
252
|
-
}
|
|
253
|
-
interface AsyncExecutionResult {
|
|
254
|
-
taskId: string;
|
|
255
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
256
|
-
output?: string;
|
|
257
|
-
success?: boolean;
|
|
258
|
-
executionTime?: number;
|
|
259
|
-
sessionId?: string;
|
|
260
|
-
error?: string;
|
|
261
|
-
}
|
|
262
|
-
interface FileUpload {
|
|
263
|
-
name: string;
|
|
264
|
-
content: Buffer | string;
|
|
265
|
-
path?: string;
|
|
266
|
-
}
|
|
267
|
-
interface UploadOptions {
|
|
268
|
-
sessionId?: string;
|
|
269
|
-
remotePath?: string;
|
|
270
|
-
recursive?: boolean;
|
|
271
|
-
}
|
|
272
|
-
interface UploadResult {
|
|
273
|
-
success: boolean;
|
|
274
|
-
files: string[];
|
|
275
|
-
message?: string;
|
|
276
|
-
}
|
|
277
|
-
interface UsageStats {
|
|
278
|
-
sessionsUsed: number;
|
|
279
|
-
executionTime: number;
|
|
280
|
-
quotaRemaining: number;
|
|
281
|
-
quotaLimit: number;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
interface InstaVMOptions {
|
|
285
|
-
baseURL?: string;
|
|
286
|
-
timeout?: number;
|
|
287
|
-
maxRetries?: number;
|
|
288
|
-
retryDelay?: number;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Main InstaVM client class
|
|
292
|
-
*/
|
|
293
|
-
declare class InstaVM {
|
|
294
|
-
private httpClient;
|
|
295
|
-
private _sessionId;
|
|
296
|
-
readonly browser: BrowserManager;
|
|
297
|
-
constructor(apiKey: string, options?: InstaVMOptions);
|
|
298
|
-
/**
|
|
299
|
-
* Execute code synchronously
|
|
300
|
-
*/
|
|
301
|
-
execute(command: string, options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
302
|
-
/**
|
|
303
|
-
* Execute code asynchronously
|
|
304
|
-
*/
|
|
305
|
-
executeAsync(command: string, options?: ExecuteOptions): Promise<AsyncExecutionResult>;
|
|
306
|
-
/**
|
|
307
|
-
* Upload files to the execution environment
|
|
308
|
-
*/
|
|
309
|
-
upload(files: FileUpload[], options?: UploadOptions): Promise<UploadResult>;
|
|
310
|
-
/**
|
|
311
|
-
* Create a new execution session
|
|
312
|
-
*/
|
|
313
|
-
createSession(): Promise<string>;
|
|
314
|
-
/**
|
|
315
|
-
* Close a session
|
|
316
|
-
*/
|
|
317
|
-
closeSession(sessionId?: string): Promise<void>;
|
|
318
|
-
/**
|
|
319
|
-
* Get usage statistics for a session
|
|
320
|
-
*/
|
|
321
|
-
getUsage(sessionId?: string): Promise<UsageStats>;
|
|
322
|
-
/**
|
|
323
|
-
* Get the current session ID
|
|
324
|
-
*/
|
|
325
|
-
get sessionId(): string | null;
|
|
326
|
-
/**
|
|
327
|
-
* Clean up resources
|
|
328
|
-
*/
|
|
329
|
-
dispose(): Promise<void>;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Base error class for all InstaVM SDK errors
|
|
334
|
-
*/
|
|
335
|
-
declare class InstaVMError extends Error {
|
|
336
|
-
readonly name: string;
|
|
337
|
-
readonly code?: string;
|
|
338
|
-
readonly statusCode?: number;
|
|
339
|
-
readonly response?: any;
|
|
340
|
-
constructor(message: string, options?: {
|
|
341
|
-
code?: string;
|
|
342
|
-
statusCode?: number;
|
|
343
|
-
response?: any;
|
|
344
|
-
cause?: Error;
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Authentication-related errors (401, invalid API key, etc.)
|
|
349
|
-
*/
|
|
350
|
-
declare class AuthenticationError extends InstaVMError {
|
|
351
|
-
constructor(message?: string, options?: any);
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Rate limiting errors (429)
|
|
355
|
-
*/
|
|
356
|
-
declare class RateLimitError extends InstaVMError {
|
|
357
|
-
readonly retryAfter?: number;
|
|
358
|
-
constructor(message?: string, retryAfter?: number, options?: any);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Quota/usage limit exceeded errors
|
|
362
|
-
*/
|
|
363
|
-
declare class QuotaExceededError extends InstaVMError {
|
|
364
|
-
constructor(message?: string, options?: any);
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Network-related errors (timeouts, connection issues, 5xx errors)
|
|
368
|
-
*/
|
|
369
|
-
declare class NetworkError extends InstaVMError {
|
|
370
|
-
constructor(message?: string, options?: any);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Code execution errors
|
|
374
|
-
*/
|
|
375
|
-
declare class ExecutionError extends InstaVMError {
|
|
376
|
-
readonly executionOutput?: string;
|
|
377
|
-
readonly executionTime?: number;
|
|
378
|
-
constructor(message: string, executionOutput?: string, executionTime?: number, options?: any);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Session management errors
|
|
382
|
-
*/
|
|
383
|
-
declare class SessionError extends InstaVMError {
|
|
384
|
-
constructor(message?: string, options?: any);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Browser automation base error
|
|
388
|
-
*/
|
|
389
|
-
declare class BrowserError extends InstaVMError {
|
|
390
|
-
constructor(message?: string, options?: any);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Browser session management errors
|
|
394
|
-
*/
|
|
395
|
-
declare class BrowserSessionError extends BrowserError {
|
|
396
|
-
constructor(message?: string, options?: any);
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Browser interaction errors (click, type, etc.)
|
|
400
|
-
*/
|
|
401
|
-
declare class BrowserInteractionError extends BrowserError {
|
|
402
|
-
constructor(message?: string, options?: any);
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Browser timeout errors
|
|
406
|
-
*/
|
|
407
|
-
declare class BrowserTimeoutError extends BrowserError {
|
|
408
|
-
constructor(message?: string, options?: any);
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Browser navigation errors
|
|
412
|
-
*/
|
|
413
|
-
declare class BrowserNavigationError extends BrowserError {
|
|
414
|
-
constructor(message?: string, options?: any);
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Element not found errors
|
|
418
|
-
*/
|
|
419
|
-
declare class ElementNotFoundError extends BrowserError {
|
|
420
|
-
readonly selector?: string;
|
|
421
|
-
constructor(message?: string, selector?: string, options?: any);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export { type ApiResponse, type AsyncExecutionResult, AuthenticationError, BrowserError, BrowserInteractionError, BrowserManager, BrowserNavigationError, BrowserSession, BrowserSessionError, type BrowserSessionInfo, type BrowserSessionOptions, BrowserTimeoutError, type ClickOptions, ElementNotFoundError, type ExecuteOptions, ExecutionError, type ExecutionResult, type ExtractOptions, type ExtractedElement, type FileUpload, type FillOptions, type HttpClientConfig, InstaVM, InstaVMError, type InstaVMOptions, type NavigateOptions, type NavigationResult, NetworkError, QuotaExceededError, RateLimitError, type RequestConfig, type RetryConfig, type ScreenshotOptions, type ScrollOptions, SessionError, type TypeOptions, type UploadOptions, type UploadResult, type UsageStats, type WaitCondition };
|
package/dist/index.d.ts
DELETED
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
|
-
import { EventEmitter } from 'eventemitter3';
|
|
3
|
-
|
|
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';
|
|
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>): 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>): 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
|
-
* GET request
|
|
58
|
-
*/
|
|
59
|
-
get<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
|
|
60
|
-
/**
|
|
61
|
-
* DELETE request
|
|
62
|
-
*/
|
|
63
|
-
delete<T = any>(url: string, headers?: Record<string, string>): Promise<T>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface BrowserSessionOptions {
|
|
67
|
-
viewportWidth?: number;
|
|
68
|
-
viewportHeight?: number;
|
|
69
|
-
userAgent?: string;
|
|
70
|
-
}
|
|
71
|
-
interface BrowserSessionInfo {
|
|
72
|
-
sessionId: string;
|
|
73
|
-
status: 'active' | 'inactive' | 'closed';
|
|
74
|
-
createdAt: string;
|
|
75
|
-
viewportWidth: number;
|
|
76
|
-
viewportHeight: number;
|
|
77
|
-
userAgent?: string;
|
|
78
|
-
}
|
|
79
|
-
interface NavigateOptions {
|
|
80
|
-
waitTimeout?: number;
|
|
81
|
-
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
82
|
-
}
|
|
83
|
-
interface NavigationResult {
|
|
84
|
-
success: boolean;
|
|
85
|
-
url: string;
|
|
86
|
-
title?: string;
|
|
87
|
-
status?: number;
|
|
88
|
-
}
|
|
89
|
-
interface ClickOptions {
|
|
90
|
-
timeout?: number;
|
|
91
|
-
button?: 'left' | 'right' | 'middle';
|
|
92
|
-
clickCount?: number;
|
|
93
|
-
force?: boolean;
|
|
94
|
-
}
|
|
95
|
-
interface TypeOptions {
|
|
96
|
-
timeout?: number;
|
|
97
|
-
delay?: number;
|
|
98
|
-
clear?: boolean;
|
|
99
|
-
}
|
|
100
|
-
interface FillOptions {
|
|
101
|
-
timeout?: number;
|
|
102
|
-
force?: boolean;
|
|
103
|
-
}
|
|
104
|
-
interface ScrollOptions {
|
|
105
|
-
x?: number;
|
|
106
|
-
y?: number;
|
|
107
|
-
behavior?: 'auto' | 'smooth';
|
|
108
|
-
}
|
|
109
|
-
interface ScreenshotOptions {
|
|
110
|
-
fullPage?: boolean;
|
|
111
|
-
format?: 'png' | 'jpeg';
|
|
112
|
-
quality?: number;
|
|
113
|
-
clip?: {
|
|
114
|
-
x: number;
|
|
115
|
-
y: number;
|
|
116
|
-
width: number;
|
|
117
|
-
height: number;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
type WaitCondition = {
|
|
121
|
-
type: 'visible';
|
|
122
|
-
selector: string;
|
|
123
|
-
} | {
|
|
124
|
-
type: 'hidden';
|
|
125
|
-
selector: string;
|
|
126
|
-
} | {
|
|
127
|
-
type: 'attached';
|
|
128
|
-
selector: string;
|
|
129
|
-
} | {
|
|
130
|
-
type: 'detached';
|
|
131
|
-
selector: string;
|
|
132
|
-
} | {
|
|
133
|
-
type: 'timeout';
|
|
134
|
-
ms: number;
|
|
135
|
-
};
|
|
136
|
-
interface ExtractedElement {
|
|
137
|
-
text?: string;
|
|
138
|
-
href?: string;
|
|
139
|
-
src?: string;
|
|
140
|
-
class?: string;
|
|
141
|
-
id?: string;
|
|
142
|
-
tagName?: string;
|
|
143
|
-
[attribute: string]: any;
|
|
144
|
-
}
|
|
145
|
-
interface ExtractOptions {
|
|
146
|
-
attributes?: string[];
|
|
147
|
-
maxResults?: number;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Browser session for automation
|
|
152
|
-
*/
|
|
153
|
-
declare class BrowserSession extends EventEmitter {
|
|
154
|
-
readonly sessionId: string;
|
|
155
|
-
private httpClient;
|
|
156
|
-
private _isActive;
|
|
157
|
-
constructor(sessionId: string, httpClient: HTTPClient);
|
|
158
|
-
/**
|
|
159
|
-
* Navigate to a URL
|
|
160
|
-
*/
|
|
161
|
-
navigate(url: string, options?: NavigateOptions): Promise<NavigationResult>;
|
|
162
|
-
/**
|
|
163
|
-
* Click an element
|
|
164
|
-
*/
|
|
165
|
-
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Type text into an element
|
|
168
|
-
*/
|
|
169
|
-
type(selector: string, text: string, options?: TypeOptions): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Fill a form field
|
|
172
|
-
*/
|
|
173
|
-
fill(selector: string, value: string, options?: FillOptions): Promise<void>;
|
|
174
|
-
/**
|
|
175
|
-
* Scroll the page
|
|
176
|
-
*/
|
|
177
|
-
scroll(options?: ScrollOptions): Promise<void>;
|
|
178
|
-
/**
|
|
179
|
-
* Take a screenshot
|
|
180
|
-
*/
|
|
181
|
-
screenshot(options?: ScreenshotOptions): Promise<string>;
|
|
182
|
-
/**
|
|
183
|
-
* Extract elements from the page
|
|
184
|
-
*/
|
|
185
|
-
extractElements(selector: string, attributes?: string[], options?: ExtractOptions): Promise<ExtractedElement[]>;
|
|
186
|
-
/**
|
|
187
|
-
* Wait for a condition
|
|
188
|
-
*/
|
|
189
|
-
wait(condition: WaitCondition, timeout?: number): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Close the browser session
|
|
192
|
-
*/
|
|
193
|
-
close(): Promise<void>;
|
|
194
|
-
/**
|
|
195
|
-
* Check if session is active
|
|
196
|
-
*/
|
|
197
|
-
get isActive(): boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Ensure session is active before operations
|
|
200
|
-
*/
|
|
201
|
-
private ensureActive;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Browser automation manager
|
|
206
|
-
*/
|
|
207
|
-
declare class BrowserManager {
|
|
208
|
-
private httpClient;
|
|
209
|
-
private activeSessions;
|
|
210
|
-
constructor(httpClient: HTTPClient);
|
|
211
|
-
/**
|
|
212
|
-
* Create a new browser session
|
|
213
|
-
*/
|
|
214
|
-
createSession(options?: BrowserSessionOptions): Promise<BrowserSession>;
|
|
215
|
-
/**
|
|
216
|
-
* Get information about a specific session
|
|
217
|
-
*/
|
|
218
|
-
getSession(sessionId: string): Promise<BrowserSessionInfo>;
|
|
219
|
-
/**
|
|
220
|
-
* List all browser sessions
|
|
221
|
-
*/
|
|
222
|
-
listSessions(): Promise<BrowserSessionInfo[]>;
|
|
223
|
-
/**
|
|
224
|
-
* Get a locally tracked session
|
|
225
|
-
*/
|
|
226
|
-
getLocalSession(sessionId: string): BrowserSession | undefined;
|
|
227
|
-
/**
|
|
228
|
-
* Get all locally tracked sessions
|
|
229
|
-
*/
|
|
230
|
-
getLocalSessions(): BrowserSession[];
|
|
231
|
-
/**
|
|
232
|
-
* Close all active sessions
|
|
233
|
-
*/
|
|
234
|
-
closeAllSessions(): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Clean up resources
|
|
237
|
-
*/
|
|
238
|
-
dispose(): Promise<void>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
interface ExecuteOptions {
|
|
242
|
-
language?: 'python' | 'bash';
|
|
243
|
-
timeout?: number;
|
|
244
|
-
sessionId?: string;
|
|
245
|
-
}
|
|
246
|
-
interface ExecutionResult {
|
|
247
|
-
output: string;
|
|
248
|
-
success: boolean;
|
|
249
|
-
executionTime: number;
|
|
250
|
-
sessionId?: string;
|
|
251
|
-
error?: string;
|
|
252
|
-
}
|
|
253
|
-
interface AsyncExecutionResult {
|
|
254
|
-
taskId: string;
|
|
255
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
256
|
-
output?: string;
|
|
257
|
-
success?: boolean;
|
|
258
|
-
executionTime?: number;
|
|
259
|
-
sessionId?: string;
|
|
260
|
-
error?: string;
|
|
261
|
-
}
|
|
262
|
-
interface FileUpload {
|
|
263
|
-
name: string;
|
|
264
|
-
content: Buffer | string;
|
|
265
|
-
path?: string;
|
|
266
|
-
}
|
|
267
|
-
interface UploadOptions {
|
|
268
|
-
sessionId?: string;
|
|
269
|
-
remotePath?: string;
|
|
270
|
-
recursive?: boolean;
|
|
271
|
-
}
|
|
272
|
-
interface UploadResult {
|
|
273
|
-
success: boolean;
|
|
274
|
-
files: string[];
|
|
275
|
-
message?: string;
|
|
276
|
-
}
|
|
277
|
-
interface UsageStats {
|
|
278
|
-
sessionsUsed: number;
|
|
279
|
-
executionTime: number;
|
|
280
|
-
quotaRemaining: number;
|
|
281
|
-
quotaLimit: number;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
interface InstaVMOptions {
|
|
285
|
-
baseURL?: string;
|
|
286
|
-
timeout?: number;
|
|
287
|
-
maxRetries?: number;
|
|
288
|
-
retryDelay?: number;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Main InstaVM client class
|
|
292
|
-
*/
|
|
293
|
-
declare class InstaVM {
|
|
294
|
-
private httpClient;
|
|
295
|
-
private _sessionId;
|
|
296
|
-
readonly browser: BrowserManager;
|
|
297
|
-
constructor(apiKey: string, options?: InstaVMOptions);
|
|
298
|
-
/**
|
|
299
|
-
* Execute code synchronously
|
|
300
|
-
*/
|
|
301
|
-
execute(command: string, options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
302
|
-
/**
|
|
303
|
-
* Execute code asynchronously
|
|
304
|
-
*/
|
|
305
|
-
executeAsync(command: string, options?: ExecuteOptions): Promise<AsyncExecutionResult>;
|
|
306
|
-
/**
|
|
307
|
-
* Upload files to the execution environment
|
|
308
|
-
*/
|
|
309
|
-
upload(files: FileUpload[], options?: UploadOptions): Promise<UploadResult>;
|
|
310
|
-
/**
|
|
311
|
-
* Create a new execution session
|
|
312
|
-
*/
|
|
313
|
-
createSession(): Promise<string>;
|
|
314
|
-
/**
|
|
315
|
-
* Close a session
|
|
316
|
-
*/
|
|
317
|
-
closeSession(sessionId?: string): Promise<void>;
|
|
318
|
-
/**
|
|
319
|
-
* Get usage statistics for a session
|
|
320
|
-
*/
|
|
321
|
-
getUsage(sessionId?: string): Promise<UsageStats>;
|
|
322
|
-
/**
|
|
323
|
-
* Get the current session ID
|
|
324
|
-
*/
|
|
325
|
-
get sessionId(): string | null;
|
|
326
|
-
/**
|
|
327
|
-
* Clean up resources
|
|
328
|
-
*/
|
|
329
|
-
dispose(): Promise<void>;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Base error class for all InstaVM SDK errors
|
|
334
|
-
*/
|
|
335
|
-
declare class InstaVMError extends Error {
|
|
336
|
-
readonly name: string;
|
|
337
|
-
readonly code?: string;
|
|
338
|
-
readonly statusCode?: number;
|
|
339
|
-
readonly response?: any;
|
|
340
|
-
constructor(message: string, options?: {
|
|
341
|
-
code?: string;
|
|
342
|
-
statusCode?: number;
|
|
343
|
-
response?: any;
|
|
344
|
-
cause?: Error;
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Authentication-related errors (401, invalid API key, etc.)
|
|
349
|
-
*/
|
|
350
|
-
declare class AuthenticationError extends InstaVMError {
|
|
351
|
-
constructor(message?: string, options?: any);
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Rate limiting errors (429)
|
|
355
|
-
*/
|
|
356
|
-
declare class RateLimitError extends InstaVMError {
|
|
357
|
-
readonly retryAfter?: number;
|
|
358
|
-
constructor(message?: string, retryAfter?: number, options?: any);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Quota/usage limit exceeded errors
|
|
362
|
-
*/
|
|
363
|
-
declare class QuotaExceededError extends InstaVMError {
|
|
364
|
-
constructor(message?: string, options?: any);
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Network-related errors (timeouts, connection issues, 5xx errors)
|
|
368
|
-
*/
|
|
369
|
-
declare class NetworkError extends InstaVMError {
|
|
370
|
-
constructor(message?: string, options?: any);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Code execution errors
|
|
374
|
-
*/
|
|
375
|
-
declare class ExecutionError extends InstaVMError {
|
|
376
|
-
readonly executionOutput?: string;
|
|
377
|
-
readonly executionTime?: number;
|
|
378
|
-
constructor(message: string, executionOutput?: string, executionTime?: number, options?: any);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Session management errors
|
|
382
|
-
*/
|
|
383
|
-
declare class SessionError extends InstaVMError {
|
|
384
|
-
constructor(message?: string, options?: any);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Browser automation base error
|
|
388
|
-
*/
|
|
389
|
-
declare class BrowserError extends InstaVMError {
|
|
390
|
-
constructor(message?: string, options?: any);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Browser session management errors
|
|
394
|
-
*/
|
|
395
|
-
declare class BrowserSessionError extends BrowserError {
|
|
396
|
-
constructor(message?: string, options?: any);
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Browser interaction errors (click, type, etc.)
|
|
400
|
-
*/
|
|
401
|
-
declare class BrowserInteractionError extends BrowserError {
|
|
402
|
-
constructor(message?: string, options?: any);
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Browser timeout errors
|
|
406
|
-
*/
|
|
407
|
-
declare class BrowserTimeoutError extends BrowserError {
|
|
408
|
-
constructor(message?: string, options?: any);
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Browser navigation errors
|
|
412
|
-
*/
|
|
413
|
-
declare class BrowserNavigationError extends BrowserError {
|
|
414
|
-
constructor(message?: string, options?: any);
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Element not found errors
|
|
418
|
-
*/
|
|
419
|
-
declare class ElementNotFoundError extends BrowserError {
|
|
420
|
-
readonly selector?: string;
|
|
421
|
-
constructor(message?: string, selector?: string, options?: any);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export { type ApiResponse, type AsyncExecutionResult, AuthenticationError, BrowserError, BrowserInteractionError, BrowserManager, BrowserNavigationError, BrowserSession, BrowserSessionError, type BrowserSessionInfo, type BrowserSessionOptions, BrowserTimeoutError, type ClickOptions, ElementNotFoundError, type ExecuteOptions, ExecutionError, type ExecutionResult, type ExtractOptions, type ExtractedElement, type FileUpload, type FillOptions, type HttpClientConfig, InstaVM, InstaVMError, type InstaVMOptions, type NavigateOptions, type NavigationResult, NetworkError, QuotaExceededError, RateLimitError, type RequestConfig, type RetryConfig, type ScreenshotOptions, type ScrollOptions, SessionError, type TypeOptions, type UploadOptions, type UploadResult, type UsageStats, type WaitCondition };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface OpenAITool {
|
|
2
|
-
type: 'function';
|
|
3
|
-
function: {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
parameters: {
|
|
7
|
-
type: 'object';
|
|
8
|
-
properties: Record<string, any>;
|
|
9
|
-
required?: string[];
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
declare function getOpenAITools(): OpenAITool[];
|
|
14
|
-
declare function executeToolCall(client: any, toolCall: any, session?: any): Promise<any>;
|
|
15
|
-
|
|
16
|
-
export { type OpenAITool, executeToolCall, getOpenAITools };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface OpenAITool {
|
|
2
|
-
type: 'function';
|
|
3
|
-
function: {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
parameters: {
|
|
7
|
-
type: 'object';
|
|
8
|
-
properties: Record<string, any>;
|
|
9
|
-
required?: string[];
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
declare function getOpenAITools(): OpenAITool[];
|
|
14
|
-
declare function executeToolCall(client: any, toolCall: any, session?: any): Promise<any>;
|
|
15
|
-
|
|
16
|
-
export { type OpenAITool, executeToolCall, getOpenAITools };
|