wuying-agentbay-sdk 0.6.1 → 0.7.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/dist/index.cjs +628 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +367 -18
- package/dist/index.d.ts +367 -18
- package/dist/index.mjs +625 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1739,6 +1739,19 @@ interface Config {
|
|
|
1739
1739
|
endpoint: string;
|
|
1740
1740
|
timeout_ms: number;
|
|
1741
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Load .env file into process.env if it exists
|
|
1744
|
+
* This function should be called early to ensure .env variables are available
|
|
1745
|
+
*/
|
|
1746
|
+
declare function loadDotEnv(): void;
|
|
1747
|
+
/**
|
|
1748
|
+
* The SDK uses the following precedence order for configuration (highest to lowest):
|
|
1749
|
+
* 1. Explicitly passed configuration in code.
|
|
1750
|
+
* 2. Environment variables.
|
|
1751
|
+
* 3. .env file.
|
|
1752
|
+
* 4. Default configuration.
|
|
1753
|
+
*/
|
|
1754
|
+
declare function loadConfig(customConfig?: Config): Config;
|
|
1742
1755
|
|
|
1743
1756
|
/**
|
|
1744
1757
|
* Base interface for API responses
|
|
@@ -2246,6 +2259,25 @@ interface DownloadPolicy {
|
|
|
2246
2259
|
interface DeletePolicy {
|
|
2247
2260
|
syncLocalFile: boolean;
|
|
2248
2261
|
}
|
|
2262
|
+
interface ExtractPolicy {
|
|
2263
|
+
extract: boolean;
|
|
2264
|
+
deleteSrcFile: boolean;
|
|
2265
|
+
extractToCurrentFolder: boolean;
|
|
2266
|
+
}
|
|
2267
|
+
declare class ExtractPolicyClass implements ExtractPolicy {
|
|
2268
|
+
extract: boolean;
|
|
2269
|
+
deleteSrcFile: boolean;
|
|
2270
|
+
extractToCurrentFolder: boolean;
|
|
2271
|
+
constructor(extract?: boolean, deleteSrcFile?: boolean, extractToCurrentFolder?: boolean);
|
|
2272
|
+
/**
|
|
2273
|
+
* Creates a new extract policy with default values
|
|
2274
|
+
*/
|
|
2275
|
+
static default(): ExtractPolicyClass;
|
|
2276
|
+
/**
|
|
2277
|
+
* Converts to plain object for JSON serialization
|
|
2278
|
+
*/
|
|
2279
|
+
toDict(): Record<string, any>;
|
|
2280
|
+
}
|
|
2249
2281
|
interface WhiteList {
|
|
2250
2282
|
path: string;
|
|
2251
2283
|
excludePaths?: string[];
|
|
@@ -2257,12 +2289,14 @@ interface SyncPolicy {
|
|
|
2257
2289
|
uploadPolicy?: UploadPolicy;
|
|
2258
2290
|
downloadPolicy?: DownloadPolicy;
|
|
2259
2291
|
deletePolicy?: DeletePolicy;
|
|
2292
|
+
extractPolicy?: ExtractPolicy;
|
|
2260
2293
|
bwList?: BWList;
|
|
2261
2294
|
}
|
|
2262
2295
|
declare class SyncPolicyImpl implements SyncPolicy {
|
|
2263
2296
|
uploadPolicy?: UploadPolicy;
|
|
2264
2297
|
downloadPolicy?: DownloadPolicy;
|
|
2265
2298
|
deletePolicy?: DeletePolicy;
|
|
2299
|
+
extractPolicy?: ExtractPolicy;
|
|
2266
2300
|
bwList?: BWList;
|
|
2267
2301
|
constructor(policy?: Partial<SyncPolicy>);
|
|
2268
2302
|
private ensureDefaults;
|
|
@@ -2278,6 +2312,7 @@ declare class ContextSync {
|
|
|
2278
2312
|
declare function newUploadPolicy(): UploadPolicy;
|
|
2279
2313
|
declare function newDownloadPolicy(): DownloadPolicy;
|
|
2280
2314
|
declare function newDeletePolicy(): DeletePolicy;
|
|
2315
|
+
declare function newExtractPolicy(): ExtractPolicy;
|
|
2281
2316
|
declare function newSyncPolicy(): SyncPolicy;
|
|
2282
2317
|
declare function newSyncPolicyWithDefaults(policy?: Partial<SyncPolicy>): SyncPolicy;
|
|
2283
2318
|
declare function newContextSync(contextId: string, path: string, policy?: SyncPolicy): ContextSync;
|
|
@@ -2644,15 +2679,14 @@ declare class FileSystem {
|
|
|
2644
2679
|
*/
|
|
2645
2680
|
moveFile(source: string, destination: string): Promise<BoolResult>;
|
|
2646
2681
|
/**
|
|
2647
|
-
*
|
|
2648
|
-
* Corresponds to Python's read_file() method
|
|
2682
|
+
* Internal method to read a file chunk. Used for chunked file operations.
|
|
2649
2683
|
*
|
|
2650
2684
|
* @param path - Path to the file to read.
|
|
2651
2685
|
* @param offset - Optional: Byte offset to start reading from (0-based).
|
|
2652
2686
|
* @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
|
|
2653
2687
|
* @returns FileContentResult with file content and requestId
|
|
2654
2688
|
*/
|
|
2655
|
-
|
|
2689
|
+
private readFileChunk;
|
|
2656
2690
|
/**
|
|
2657
2691
|
* Reads the content of multiple files.
|
|
2658
2692
|
* Corresponds to Python's read_multiple_files() method
|
|
@@ -2672,34 +2706,30 @@ declare class FileSystem {
|
|
|
2672
2706
|
*/
|
|
2673
2707
|
searchFiles(path: string, pattern: string, excludePatterns?: string[]): Promise<FileSearchResult>;
|
|
2674
2708
|
/**
|
|
2675
|
-
*
|
|
2676
|
-
* Corresponds to Python's write_file() method
|
|
2709
|
+
* Internal method to write a file chunk. Used for chunked file operations.
|
|
2677
2710
|
*
|
|
2678
2711
|
* @param path - Path to the file to write.
|
|
2679
2712
|
* @param content - Content to write to the file.
|
|
2680
2713
|
* @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
|
|
2681
2714
|
* @returns BoolResult with write result and requestId
|
|
2682
2715
|
*/
|
|
2683
|
-
|
|
2716
|
+
private writeFileChunk;
|
|
2684
2717
|
/**
|
|
2685
|
-
* Reads
|
|
2686
|
-
* Corresponds to Python's read_large_file() method
|
|
2718
|
+
* Reads the contents of a file. Automatically handles large files by chunking.
|
|
2687
2719
|
*
|
|
2688
2720
|
* @param path - Path to the file to read.
|
|
2689
|
-
* @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
|
|
2690
2721
|
* @returns FileContentResult with complete file content and requestId
|
|
2691
2722
|
*/
|
|
2692
|
-
|
|
2723
|
+
readFile(path: string): Promise<FileContentResult>;
|
|
2693
2724
|
/**
|
|
2694
|
-
* Writes a
|
|
2695
|
-
* Corresponds to Python's write_large_file() method
|
|
2725
|
+
* Writes content to a file. Automatically handles large files by chunking.
|
|
2696
2726
|
*
|
|
2697
2727
|
* @param path - Path to the file to write.
|
|
2698
2728
|
* @param content - Content to write to the file.
|
|
2699
|
-
* @param
|
|
2729
|
+
* @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
|
|
2700
2730
|
* @returns BoolResult indicating success or failure with requestId
|
|
2701
2731
|
*/
|
|
2702
|
-
|
|
2732
|
+
writeFile(path: string, content: string, mode?: string): Promise<BoolResult>;
|
|
2703
2733
|
}
|
|
2704
2734
|
|
|
2705
2735
|
/**
|
|
@@ -3123,6 +3153,8 @@ interface BrowserOption {
|
|
|
3123
3153
|
screen?: BrowserScreen;
|
|
3124
3154
|
fingerprint?: BrowserFingerprint;
|
|
3125
3155
|
proxies?: BrowserProxy[];
|
|
3156
|
+
/** Path to the extensions directory. Defaults to "/tmp/extensions/" */
|
|
3157
|
+
extensionPath?: string;
|
|
3126
3158
|
}
|
|
3127
3159
|
declare class BrowserOptionClass implements BrowserOption {
|
|
3128
3160
|
persistentPath?: string;
|
|
@@ -3132,6 +3164,7 @@ declare class BrowserOptionClass implements BrowserOption {
|
|
|
3132
3164
|
screen?: BrowserScreen;
|
|
3133
3165
|
fingerprint?: BrowserFingerprint;
|
|
3134
3166
|
proxies?: BrowserProxy[];
|
|
3167
|
+
extensionPath?: string;
|
|
3135
3168
|
constructor(useStealth?: boolean, userAgent?: string, viewport?: BrowserViewport, screen?: BrowserScreen, fingerprint?: BrowserFingerprint, proxies?: BrowserProxy[]);
|
|
3136
3169
|
toMap(): Record<string, any>;
|
|
3137
3170
|
fromMap(m: Record<string, any> | null | undefined): BrowserOptionClass;
|
|
@@ -3194,7 +3227,6 @@ interface McpToolsResult extends OperationResult {
|
|
|
3194
3227
|
declare class Session {
|
|
3195
3228
|
private agentBay;
|
|
3196
3229
|
sessionId: string;
|
|
3197
|
-
resourceUrl: string;
|
|
3198
3230
|
isVpc: boolean;
|
|
3199
3231
|
networkInterfaceIp: string;
|
|
3200
3232
|
httpPort: string;
|
|
@@ -3316,13 +3348,330 @@ declare class Session {
|
|
|
3316
3348
|
}
|
|
3317
3349
|
|
|
3318
3350
|
/**
|
|
3319
|
-
*
|
|
3351
|
+
* Represents a browser extension as a cloud resource.
|
|
3320
3352
|
*/
|
|
3321
|
-
|
|
3353
|
+
declare class Extension {
|
|
3354
|
+
/**
|
|
3355
|
+
* The unique identifier of the extension.
|
|
3356
|
+
*/
|
|
3357
|
+
id: string;
|
|
3358
|
+
/**
|
|
3359
|
+
* The name of the extension.
|
|
3360
|
+
*/
|
|
3361
|
+
name: string;
|
|
3362
|
+
/**
|
|
3363
|
+
* Date and time when the extension was created.
|
|
3364
|
+
*/
|
|
3365
|
+
createdAt?: string;
|
|
3366
|
+
/**
|
|
3367
|
+
* Initialize an Extension object.
|
|
3368
|
+
*
|
|
3369
|
+
* @param id - The unique identifier of the extension.
|
|
3370
|
+
* @param name - The name of the extension.
|
|
3371
|
+
* @param createdAt - Date and time when the extension was created.
|
|
3372
|
+
*/
|
|
3373
|
+
constructor(id: string, name: string, createdAt?: string);
|
|
3374
|
+
}
|
|
3375
|
+
/**
|
|
3376
|
+
* Configuration options for browser extension integration.
|
|
3377
|
+
*
|
|
3378
|
+
* This class encapsulates the necessary parameters for setting up
|
|
3379
|
+
* browser extension synchronization and context management.
|
|
3380
|
+
*/
|
|
3381
|
+
declare class ExtensionOption {
|
|
3382
|
+
/**
|
|
3383
|
+
* ID of the extension context for browser extensions.
|
|
3384
|
+
*/
|
|
3385
|
+
contextId: string;
|
|
3386
|
+
/**
|
|
3387
|
+
* List of extension IDs to be loaded/synchronized.
|
|
3388
|
+
*/
|
|
3389
|
+
extensionIds: string[];
|
|
3390
|
+
/**
|
|
3391
|
+
* Initialize ExtensionOption with context and extension configuration.
|
|
3392
|
+
*
|
|
3393
|
+
* @param contextId - ID of the extension context for browser extensions.
|
|
3394
|
+
* This should match the context where extensions are stored.
|
|
3395
|
+
* @param extensionIds - List of extension IDs to be loaded in the browser session.
|
|
3396
|
+
* Each ID should correspond to a valid extension in the context.
|
|
3397
|
+
*
|
|
3398
|
+
* @throws {Error} If contextId is empty or extensionIds is empty.
|
|
3399
|
+
*/
|
|
3400
|
+
constructor(contextId: string, extensionIds: string[]);
|
|
3401
|
+
/**
|
|
3402
|
+
* String representation of ExtensionOption.
|
|
3403
|
+
*/
|
|
3404
|
+
toString(): string;
|
|
3405
|
+
/**
|
|
3406
|
+
* Human-readable string representation.
|
|
3407
|
+
*/
|
|
3408
|
+
toDisplayString(): string;
|
|
3409
|
+
/**
|
|
3410
|
+
* Validate the extension option configuration.
|
|
3411
|
+
*
|
|
3412
|
+
* @returns True if configuration is valid, false otherwise.
|
|
3413
|
+
*/
|
|
3414
|
+
validate(): boolean;
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* Provides methods to manage user browser extensions.
|
|
3418
|
+
* This service integrates with the existing context functionality for file operations.
|
|
3419
|
+
*
|
|
3420
|
+
* **Usage** (Simplified - Auto-detection):
|
|
3421
|
+
* ```typescript
|
|
3422
|
+
* // Service automatically detects if context exists and creates if needed
|
|
3423
|
+
* const extensionsService = new ExtensionsService(agentBay, "browser_extensions");
|
|
3424
|
+
*
|
|
3425
|
+
* // Or use with empty contextId to auto-generate context name
|
|
3426
|
+
* const extensionsService = new ExtensionsService(agentBay); // Uses default generated name
|
|
3427
|
+
*
|
|
3428
|
+
* // Use the service immediately - initialization happens automatically
|
|
3429
|
+
* const extension = await extensionsService.create("/path/to/plugin.zip");
|
|
3430
|
+
* ```
|
|
3431
|
+
*
|
|
3432
|
+
* **Integration with ExtensionOption (Simplified)**:
|
|
3433
|
+
* ```typescript
|
|
3434
|
+
* // Create extensions and configure for browser sessions
|
|
3435
|
+
* const extensionsService = new ExtensionsService(agentBay, "my_extensions");
|
|
3436
|
+
* const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
3437
|
+
* const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
3438
|
+
*
|
|
3439
|
+
* // Create extension option for browser integration (no contextId needed!)
|
|
3440
|
+
* const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
3441
|
+
*
|
|
3442
|
+
* // Use with BrowserContext for session creation
|
|
3443
|
+
* const browserContext = new BrowserContext({
|
|
3444
|
+
* contextId: "browser_session",
|
|
3445
|
+
* autoUpload: true,
|
|
3446
|
+
* extensionOption: extOption // All extension config encapsulated
|
|
3447
|
+
* });
|
|
3448
|
+
* ```
|
|
3449
|
+
*
|
|
3450
|
+
* **Context Management**:
|
|
3451
|
+
* - If contextId provided and exists: Uses the existing context
|
|
3452
|
+
* - If contextId provided but doesn't exist: Creates context with provided name
|
|
3453
|
+
* - If contextId empty or not provided: Generates default name and creates context
|
|
3454
|
+
* - No need to manually manage context creation or call initialize()
|
|
3455
|
+
* - Context initialization happens automatically on first method call
|
|
3456
|
+
*/
|
|
3457
|
+
declare class ExtensionsService {
|
|
3458
|
+
private agentBay;
|
|
3459
|
+
private contextService;
|
|
3460
|
+
private extensionContext;
|
|
3461
|
+
private contextId;
|
|
3462
|
+
private contextName;
|
|
3463
|
+
private autoCreated;
|
|
3464
|
+
private _initializationPromise;
|
|
3465
|
+
/**
|
|
3466
|
+
* Initializes the ExtensionsService with a context.
|
|
3467
|
+
*
|
|
3468
|
+
* @param agentBay - The AgentBay client instance.
|
|
3469
|
+
* @param contextId - The context ID or name. If empty or not provided,
|
|
3470
|
+
* a default context name will be generated automatically.
|
|
3471
|
+
* If the context doesn't exist, it will be automatically created.
|
|
3472
|
+
*
|
|
3473
|
+
* Note:
|
|
3474
|
+
* The service automatically detects if the context exists. If not,
|
|
3475
|
+
* it creates a new context with the provided name or a generated default name.
|
|
3476
|
+
* Context initialization is handled lazily on first use.
|
|
3477
|
+
*/
|
|
3478
|
+
constructor(agentBay: AgentBay, contextId?: string);
|
|
3479
|
+
/**
|
|
3480
|
+
* Internal method to initialize the context.
|
|
3481
|
+
* This ensures the context is ready before any operations.
|
|
3482
|
+
*/
|
|
3483
|
+
private _initializeContext;
|
|
3484
|
+
/**
|
|
3485
|
+
* Ensures the service is initialized before performing operations.
|
|
3486
|
+
*/
|
|
3487
|
+
private _ensureInitialized;
|
|
3488
|
+
/**
|
|
3489
|
+
* An internal helper method that encapsulates the flow of "get upload URL for a specific path and upload".
|
|
3490
|
+
* Uses the existing context service for file operations.
|
|
3491
|
+
*
|
|
3492
|
+
* @param localPath - The path to the local file.
|
|
3493
|
+
* @param remotePath - The path of the file in context storage.
|
|
3494
|
+
*
|
|
3495
|
+
* @throws {AgentBayError} If getting the credential or uploading fails.
|
|
3496
|
+
*/
|
|
3497
|
+
private _uploadToCloud;
|
|
3498
|
+
/**
|
|
3499
|
+
* Lists all available browser extensions within this context from the cloud.
|
|
3500
|
+
* Uses the context service to list files under the extensions directory.
|
|
3501
|
+
*
|
|
3502
|
+
* @returns Promise that resolves to an array of Extension objects.
|
|
3503
|
+
* @throws {AgentBayError} If listing extensions fails.
|
|
3504
|
+
*/
|
|
3505
|
+
list(): Promise<Extension[]>;
|
|
3506
|
+
/**
|
|
3507
|
+
* Uploads a new browser extension from a local path into the current context.
|
|
3508
|
+
*
|
|
3509
|
+
* @param localPath - Path to the local extension file (must be a .zip file).
|
|
3510
|
+
* @returns Promise that resolves to an Extension object.
|
|
3511
|
+
* @throws {Error} If the local file doesn't exist.
|
|
3512
|
+
* @throws {Error} If the file format is not supported (only .zip is supported).
|
|
3513
|
+
* @throws {AgentBayError} If upload fails.
|
|
3514
|
+
*/
|
|
3515
|
+
create(localPath: string): Promise<Extension>;
|
|
3516
|
+
/**
|
|
3517
|
+
* Updates an existing browser extension in the current context with a new file.
|
|
3518
|
+
*
|
|
3519
|
+
* @param extensionId - ID of the extension to update.
|
|
3520
|
+
* @param newLocalPath - Path to the new local extension file.
|
|
3521
|
+
* @returns Promise that resolves to an Extension object.
|
|
3522
|
+
* @throws {Error} If the new local file doesn't exist.
|
|
3523
|
+
* @throws {Error} If the extension doesn't exist in the context.
|
|
3524
|
+
* @throws {AgentBayError} If update fails.
|
|
3525
|
+
*/
|
|
3526
|
+
update(extensionId: string, newLocalPath: string): Promise<Extension>;
|
|
3527
|
+
/**
|
|
3528
|
+
* Gets detailed information about a specific browser extension.
|
|
3529
|
+
*
|
|
3530
|
+
* @param extensionId - The ID of the extension to get info for.
|
|
3531
|
+
* @returns Promise that resolves to an Extension object if found, undefined otherwise.
|
|
3532
|
+
*/
|
|
3533
|
+
private _getExtensionInfo;
|
|
3534
|
+
/**
|
|
3535
|
+
* Cleans up the auto-created context if it was created by this service.
|
|
3536
|
+
*
|
|
3537
|
+
* @returns Promise that resolves to true if cleanup was successful or not needed, false if cleanup failed.
|
|
3538
|
+
*
|
|
3539
|
+
* Note:
|
|
3540
|
+
* This method only works if the context was auto-created by this service.
|
|
3541
|
+
* For existing contexts, no cleanup is performed.
|
|
3542
|
+
*/
|
|
3543
|
+
cleanup(): Promise<boolean>;
|
|
3544
|
+
/**
|
|
3545
|
+
* Deletes a browser extension from the current context.
|
|
3546
|
+
*
|
|
3547
|
+
* @param extensionId - ID of the extension to delete.
|
|
3548
|
+
* @returns Promise that resolves to true if deletion was successful, false otherwise.
|
|
3549
|
+
*/
|
|
3550
|
+
delete(extensionId: string): Promise<boolean>;
|
|
3551
|
+
/**
|
|
3552
|
+
* Create an ExtensionOption for the current context with specified extension IDs.
|
|
3553
|
+
*
|
|
3554
|
+
* This is a convenience method that creates an ExtensionOption using the current
|
|
3555
|
+
* service's contextId and the provided extension IDs. This option can then be
|
|
3556
|
+
* used with BrowserContext for browser session creation.
|
|
3557
|
+
*
|
|
3558
|
+
* @param extensionIds - List of extension IDs to include in the option.
|
|
3559
|
+
* These should be extensions that exist in the current context.
|
|
3560
|
+
* @returns ExtensionOption configuration object for browser extension integration.
|
|
3561
|
+
* @throws {Error} If extensionIds is empty or invalid.
|
|
3562
|
+
*
|
|
3563
|
+
* @example
|
|
3564
|
+
* ```typescript
|
|
3565
|
+
* // Create extensions
|
|
3566
|
+
* const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
3567
|
+
* const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
3568
|
+
*
|
|
3569
|
+
* // Create extension option for browser integration
|
|
3570
|
+
* const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
3571
|
+
*
|
|
3572
|
+
* // Use with BrowserContext
|
|
3573
|
+
* const browserContext = new BrowserContext({
|
|
3574
|
+
* contextId: "browser_session",
|
|
3575
|
+
* autoUpload: true,
|
|
3576
|
+
* extensionContextId: extOption.contextId,
|
|
3577
|
+
* extensionIds: extOption.extensionIds
|
|
3578
|
+
* });
|
|
3579
|
+
* ```
|
|
3580
|
+
*/
|
|
3581
|
+
createExtensionOption(extensionIds: string[]): ExtensionOption;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
/**
|
|
3585
|
+
* Browser context configuration for session with optional extension support.
|
|
3586
|
+
*
|
|
3587
|
+
* This class provides browser context configuration for cloud sessions and supports
|
|
3588
|
+
* automatic extension synchronization when ExtensionOption is provided.
|
|
3589
|
+
*
|
|
3590
|
+
* Key Features:
|
|
3591
|
+
* - Browser context binding for sessions
|
|
3592
|
+
* - Automatic browser data upload on session end
|
|
3593
|
+
* - Optional extension integration with automatic context sync generation
|
|
3594
|
+
* - Clean API with ExtensionOption encapsulation
|
|
3595
|
+
*
|
|
3596
|
+
* Extension Configuration:
|
|
3597
|
+
* - **ExtensionOption**: Pass an ExtensionOption object with contextId and extensionIds
|
|
3598
|
+
* - **No Extensions**: Don't provide extensionOption parameter (extensionContextSyncs will be undefined)
|
|
3599
|
+
*
|
|
3600
|
+
* Usage Examples:
|
|
3601
|
+
* ```typescript
|
|
3602
|
+
* // With extensions using ExtensionOption
|
|
3603
|
+
* import { ExtensionOption } from "./extension";
|
|
3604
|
+
*
|
|
3605
|
+
* const extOption = new ExtensionOption(
|
|
3606
|
+
* "my_extensions",
|
|
3607
|
+
* ["ext1", "ext2"]
|
|
3608
|
+
* );
|
|
3609
|
+
*
|
|
3610
|
+
* const browserContext = new BrowserContext(
|
|
3611
|
+
* "browser_session",
|
|
3612
|
+
* true,
|
|
3613
|
+
* extOption
|
|
3614
|
+
* );
|
|
3615
|
+
*
|
|
3616
|
+
* // Without extensions (minimal configuration)
|
|
3617
|
+
* const browserContext = new BrowserContext(
|
|
3618
|
+
* "browser_session",
|
|
3619
|
+
* true
|
|
3620
|
+
* );
|
|
3621
|
+
* // extensionContextSyncs will be undefined
|
|
3622
|
+
* ```
|
|
3623
|
+
*/
|
|
3624
|
+
declare class BrowserContext {
|
|
3322
3625
|
/** ID of the browser context to bind to the session */
|
|
3323
3626
|
contextId: string;
|
|
3324
3627
|
/** Whether to automatically upload browser data when the session ends */
|
|
3325
3628
|
autoUpload: boolean;
|
|
3629
|
+
/** Optional extension configuration object containing context_id and extension_ids */
|
|
3630
|
+
extensionOption?: ExtensionOption;
|
|
3631
|
+
/** ID of the extension context for browser extensions. Set automatically from extension_option. */
|
|
3632
|
+
extensionContextId?: string;
|
|
3633
|
+
/** List of extension IDs to synchronize. Set automatically from extension_option. */
|
|
3634
|
+
extensionIds?: string[];
|
|
3635
|
+
/** Auto-generated context syncs for extensions. None if no extension configuration provided. */
|
|
3636
|
+
extensionContextSyncs?: ContextSync[];
|
|
3637
|
+
/**
|
|
3638
|
+
* Initialize BrowserContextImpl with optional extension support.
|
|
3639
|
+
*
|
|
3640
|
+
* @param contextId - ID of the browser context to bind to the session.
|
|
3641
|
+
* This identifies the browser instance for the session.
|
|
3642
|
+
* @param autoUpload - Whether to automatically upload browser data
|
|
3643
|
+
* when the session ends. Defaults to true.
|
|
3644
|
+
* @param extensionOption - Extension configuration object containing
|
|
3645
|
+
* contextId and extensionIds. This encapsulates
|
|
3646
|
+
* all extension-related configuration.
|
|
3647
|
+
* Defaults to undefined.
|
|
3648
|
+
*
|
|
3649
|
+
* Extension Configuration:
|
|
3650
|
+
* - **ExtensionOption**: Use extensionOption parameter with an ExtensionOption object
|
|
3651
|
+
* - **No Extensions**: Don't provide extensionOption parameter
|
|
3652
|
+
*
|
|
3653
|
+
* Auto-generation:
|
|
3654
|
+
* - extensionContextSyncs is automatically generated when extensionOption is provided
|
|
3655
|
+
* - extensionContextSyncs will be undefined if no extensionOption is provided
|
|
3656
|
+
* - extensionContextSyncs will be a ContextSync[] if extensionOption is valid
|
|
3657
|
+
*/
|
|
3658
|
+
constructor(contextId: string, autoUpload?: boolean, extensionOption?: ExtensionOption);
|
|
3659
|
+
/**
|
|
3660
|
+
* Create ContextSync configurations for browser extensions.
|
|
3661
|
+
*
|
|
3662
|
+
* This method is called only when extensionOption is provided and contains
|
|
3663
|
+
* valid extension configuration (contextId and extensionIds).
|
|
3664
|
+
*
|
|
3665
|
+
* @returns ContextSync[] - List of context sync configurations for extensions.
|
|
3666
|
+
* Returns empty list if extension configuration is invalid.
|
|
3667
|
+
*/
|
|
3668
|
+
private _createExtensionContextSyncs;
|
|
3669
|
+
/**
|
|
3670
|
+
* Get all context syncs including extension syncs.
|
|
3671
|
+
*
|
|
3672
|
+
* @returns ContextSync[] - All context sync configurations. Returns empty list if no extensions configured.
|
|
3673
|
+
*/
|
|
3674
|
+
getAllContextSyncs(): ContextSync[];
|
|
3326
3675
|
}
|
|
3327
3676
|
/**
|
|
3328
3677
|
* Configuration interface for CreateSessionParams
|
|
@@ -3593,4 +3942,4 @@ declare function log(message: string, ...args: any[]): void;
|
|
|
3593
3942
|
*/
|
|
3594
3943
|
declare function logError(message: string, error?: any): void;
|
|
3595
3944
|
|
|
3596
|
-
export { APIError, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, Browser, BrowserAgent,
|
|
3945
|
+
export { APIError, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, Browser, BrowserAgent, BrowserContext, BrowserError, type BrowserFingerprint, type BrowserOption, BrowserOptionClass, type BrowserProxy, BrowserProxyClass, type BrowserScreen, type BrowserViewport, CallMcpToolRequest, CallMcpToolResponse, CallMcpToolResponseBody, Client, Command, CommandError, type Config, Context, type ContextInfoResult, ContextManager, ContextService, type ContextStatusData, type ContextStatusItem, ContextSync, type ContextSyncResult, CreateMcpSessionRequest, CreateMcpSessionRequestPersistenceDataList, CreateMcpSessionResponse, CreateMcpSessionResponseBody, CreateMcpSessionResponseBodyData, CreateMcpSessionShrinkRequest, type CreateSessionParams, type CreateSessionParamsConfig, DeleteContextFileRequest, DeleteContextFileResponse, DeleteContextFileResponseBody, DeleteContextRequest, DeleteContextResponse, DeleteContextResponseBody, type DeletePolicy, DescribeContextFilesRequest, DescribeContextFilesResponse, DescribeContextFilesResponseBody, type DirectoryEntry, type DownloadPolicy, DownloadStrategy, type ExecutionResult, Extension, ExtensionOption, ExtensionsService, type ExtractOptions, type ExtractPolicy, ExtractPolicyClass, FileError, type FileInfo, FileSystem, GetContextFileDownloadUrlRequest, GetContextFileDownloadUrlResponse, GetContextFileDownloadUrlResponseBody, GetContextFileUploadUrlRequest, GetContextFileUploadUrlResponse, GetContextFileUploadUrlResponseBody, GetContextInfoRequest, GetContextInfoResponse, GetContextInfoResponseBody, GetContextInfoResponseBodyData, GetContextRequest, GetContextResponse, GetContextResponseBody, GetContextResponseBodyData, GetLabelRequest, GetLabelResponse, GetLabelResponseBody, GetLabelResponseBodyData, GetLinkRequest, GetLinkResponse, GetLinkResponseBody, GetLinkResponseBodyData, GetMcpResourceRequest, GetMcpResourceResponse, GetMcpResourceResponseBody, GetMcpResourceResponseBodyData, GetMcpResourceResponseBodyDataDesktopInfo, InitBrowserRequest, InitBrowserResponse, InitBrowserResponseBody, InitBrowserResponseBodyData, type InstalledApp, KeyCode, ListContextsRequest, ListContextsResponse, ListContextsResponseBody, ListContextsResponseBodyData, ListMcpToolsRequest, ListMcpToolsResponse, ListMcpToolsResponseBody, type ListSessionParams, ListSessionRequest, ListSessionResponse, ListSessionResponseBody, ListSessionResponseBodyData, type McpSession, type McpToolResult, ModifyContextRequest, ModifyContextResponse, ModifyContextResponseBody, type ObserveOptions, ObserveResult, Oss, OssError, type Process, type QueryResult, ReleaseMcpSessionRequest, ReleaseMcpSessionResponse, ReleaseMcpSessionResponseBody, Session, SessionError, type SessionInterface, SetLabelRequest, SetLabelResponse, SetLabelResponseBody, SyncContextRequest, SyncContextResponse, SyncContextResponseBody, type SyncPolicy, SyncPolicyImpl, UI, type UIElement, UIError, type UploadPolicy, UploadStrategy, type WhiteList, loadConfig, loadDotEnv, log, logError, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newExtractPolicy, newSyncPolicy, newSyncPolicyWithDefaults, newUploadPolicy };
|