wuying-agentbay-sdk 0.9.3 → 0.10.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.d.mts CHANGED
@@ -1,6 +1,39 @@
1
1
  import * as $dara from '@darabonba/typescript';
2
2
  import OpenApi, { $OpenApiUtil } from '@alicloud/openapi-core';
3
3
 
4
+ interface Config {
5
+ endpoint: string;
6
+ timeout_ms: number;
7
+ }
8
+ /**
9
+ * Load .env file into process.env if it exists
10
+ * This function should be called early to ensure .env variables are available
11
+ * @deprecated Use loadDotEnvWithFallback instead
12
+ */
13
+ declare function loadDotEnv(): void;
14
+ /**
15
+ * The SDK uses the following precedence order for configuration (highest to lowest):
16
+ * 1. Explicitly passed configuration in code.
17
+ * 2. Environment variables.
18
+ * 3. .env file.
19
+ * 4. Default configuration.
20
+ */
21
+ /**
22
+ * Load configuration with improved .env file search.
23
+ *
24
+ * @param customConfig Configuration object (if provided, skips env loading)
25
+ * @param customEnvPath Custom path to .env file (optional)
26
+ * @returns Configuration object
27
+ */
28
+ declare function loadConfig(customConfig?: Config, customEnvPath?: string): Config;
29
+
30
+ /**
31
+ * Version information for the AgentBay SDK
32
+ * Automatically read from package.json
33
+ */
34
+ declare const VERSION: string;
35
+ declare const IS_RELEASE: boolean;
36
+
4
37
  /**
5
38
  */
6
39
  declare class ApplyMqttTokenResponseBodyData extends $dara.Model {
@@ -323,6 +356,57 @@ declare class CallMcpToolResponse extends $dara.Model {
323
356
  });
324
357
  }
325
358
 
359
+ declare class ClearContextRequest extends $dara.Model {
360
+ authorization?: string;
361
+ id?: string;
362
+ static names(): {
363
+ [key: string]: string;
364
+ };
365
+ static types(): {
366
+ [key: string]: any;
367
+ };
368
+ validate(): void;
369
+ constructor(map?: {
370
+ [key: string]: any;
371
+ });
372
+ }
373
+
374
+ declare class ClearContextResponseBody extends $dara.Model {
375
+ code?: string;
376
+ httpStatusCode?: number;
377
+ message?: string;
378
+ requestId?: string;
379
+ success?: boolean;
380
+ static names(): {
381
+ [key: string]: string;
382
+ };
383
+ static types(): {
384
+ [key: string]: any;
385
+ };
386
+ validate(): void;
387
+ constructor(map?: {
388
+ [key: string]: any;
389
+ });
390
+ }
391
+
392
+ declare class ClearContextResponse extends $dara.Model {
393
+ headers?: {
394
+ [key: string]: string;
395
+ };
396
+ statusCode?: number;
397
+ body?: ClearContextResponseBody;
398
+ static names(): {
399
+ [key: string]: string;
400
+ };
401
+ static types(): {
402
+ [key: string]: any;
403
+ };
404
+ validate(): void;
405
+ constructor(map?: {
406
+ [key: string]: any;
407
+ });
408
+ }
409
+
326
410
  declare class CreateMcpSessionRequest extends $dara.Model {
327
411
  authorization?: string;
328
412
  contextId?: string;
@@ -333,6 +417,8 @@ declare class CreateMcpSessionRequest extends $dara.Model {
333
417
  persistenceDataList?: CreateMcpSessionRequestPersistenceDataList[];
334
418
  sessionId?: string;
335
419
  vpcResource?: boolean;
420
+ extraConfigs?: string;
421
+ sdkStats?: string;
336
422
  static names(): {
337
423
  [key: string]: string;
338
424
  };
@@ -355,6 +441,8 @@ declare class CreateMcpSessionShrinkRequest extends $dara.Model {
355
441
  persistenceDataListShrink?: string;
356
442
  sessionId?: string;
357
443
  vpcResource?: boolean;
444
+ extraConfigs?: string;
445
+ sdkStats?: string;
358
446
  static names(): {
359
447
  [key: string]: string;
360
448
  };
@@ -458,6 +546,7 @@ declare class DeleteContextResponse extends $dara.Model {
458
546
  declare class GetContextRequest extends $dara.Model {
459
547
  allowCreate?: boolean;
460
548
  authorization?: string;
549
+ contextId?: string;
461
550
  name?: string;
462
551
  static names(): {
463
552
  [key: string]: string;
@@ -677,6 +766,7 @@ declare class GetLinkRequest extends $dara.Model {
677
766
  port?: number;
678
767
  protocolType?: string;
679
768
  sessionId?: string;
769
+ option?: string;
680
770
  static names(): {
681
771
  [key: string]: string;
682
772
  };
@@ -1516,6 +1606,21 @@ declare class Client extends OpenApi {
1516
1606
  * @returns CallMcpToolResponse
1517
1607
  */
1518
1608
  callMcpTool(request: CallMcpToolRequest): Promise<CallMcpToolResponse>;
1609
+ /**
1610
+ * Delete Persistent Context
1611
+ *
1612
+ * @param request - ClearContextRequest
1613
+ * @param runtime - runtime options for this request RuntimeOptions
1614
+ * @returns ClearContextResponse
1615
+ */
1616
+ clearContextWithOptions(request: ClearContextRequest, runtime: $dara.RuntimeOptions): Promise<ClearContextResponse>;
1617
+ /**
1618
+ * Delete Persistent Context
1619
+ *
1620
+ * @param request - ClearContextRequest
1621
+ * @returns ClearContextResponse
1622
+ */
1623
+ clearContext(request: ClearContextRequest): Promise<ClearContextResponse>;
1519
1624
  /**
1520
1625
  * Create MCP session
1521
1626
  *
@@ -1825,32 +1930,6 @@ declare class Client extends OpenApi {
1825
1930
  getContextFileUploadUrl(request: GetContextFileUploadUrlRequest): Promise<GetContextFileUploadUrlResponse>;
1826
1931
  }
1827
1932
 
1828
- interface Config {
1829
- endpoint: string;
1830
- timeout_ms: number;
1831
- }
1832
- /**
1833
- * Load .env file into process.env if it exists
1834
- * This function should be called early to ensure .env variables are available
1835
- * @deprecated Use loadDotEnvWithFallback instead
1836
- */
1837
- declare function loadDotEnv(): void;
1838
- /**
1839
- * The SDK uses the following precedence order for configuration (highest to lowest):
1840
- * 1. Explicitly passed configuration in code.
1841
- * 2. Environment variables.
1842
- * 3. .env file.
1843
- * 4. Default configuration.
1844
- */
1845
- /**
1846
- * Load configuration with improved .env file search.
1847
- *
1848
- * @param customConfig Configuration object (if provided, skips env loading)
1849
- * @param customEnvPath Custom path to .env file (optional)
1850
- * @returns Configuration object
1851
- */
1852
- declare function loadConfig(customConfig?: Config, customEnvPath?: string): Config;
1853
-
1854
1933
  /**
1855
1934
  * Base interface for API responses
1856
1935
  */
@@ -1862,6 +1941,15 @@ interface ApiResponse {
1862
1941
  /** Optional status code if the operation failed */
1863
1942
  success?: boolean;
1864
1943
  }
1944
+ /**
1945
+ * Generic interface for API responses that include data payload
1946
+ * @template T The type of the data being returned
1947
+ */
1948
+ interface ApiResponseWithData<T> extends ApiResponse {
1949
+ /** The actual data payload returned by the API */
1950
+ session?: T;
1951
+ data?: T;
1952
+ }
1865
1953
  /**
1866
1954
  * Interface for delete operation responses
1867
1955
  */
@@ -2254,6 +2342,30 @@ interface ContextFileListResult extends ApiResponse {
2254
2342
  /** Optional error message if the operation failed */
2255
2343
  errorMessage?: string;
2256
2344
  }
2345
+ /**
2346
+ * Helper function to extract request ID from API responses
2347
+ */
2348
+ declare function extractRequestId(response: any): string | undefined;
2349
+ /**
2350
+ * Result of context clear operations, including the real-time status.
2351
+ * Corresponds to Python's ClearContextResult type
2352
+ */
2353
+ interface ClearContextResult extends ApiResponse {
2354
+ /** Request identifier for tracking API calls */
2355
+ requestId: string;
2356
+ /** Whether the operation was successful */
2357
+ success: boolean;
2358
+ /** Current status of the clearing task. This corresponds to the
2359
+ context's state field. Possible values:
2360
+ - "clearing": Context data is being cleared (in progress)
2361
+ - "available": Clearing completed successfully
2362
+ - Other values may indicate the context state after clearing */
2363
+ status?: string;
2364
+ /** The unique identifier of the context being cleared */
2365
+ contextId?: string;
2366
+ /** Optional error message if the operation failed */
2367
+ errorMessage?: string;
2368
+ }
2257
2369
 
2258
2370
  /**
2259
2371
  * Represents a persistent storage context in the AgentBay cloud environment.
@@ -2377,6 +2489,47 @@ declare class ContextService {
2377
2489
  * List files under a specific folder path in a context.
2378
2490
  */
2379
2491
  listFiles(contextId: string, parentFolderPath: string, pageNumber?: number, pageSize?: number): Promise<ContextFileListResult>;
2492
+ /**
2493
+ * Asynchronously initiate a task to clear the context's persistent data.
2494
+ *
2495
+ * This is a non-blocking method that returns immediately after initiating the clearing task
2496
+ * on the backend. The context's state will transition to "clearing" while the operation
2497
+ * is in progress.
2498
+ *
2499
+ * @param contextId - Unique ID of the context to clear.
2500
+ * @returns A ClearContextResult object indicating the task has been successfully started,
2501
+ * with status field set to "clearing".
2502
+ * @throws APIError - If the backend API rejects the clearing request (e.g., invalid ID).
2503
+ */
2504
+ clearAsync(contextId: string): Promise<ClearContextResult>;
2505
+ /**
2506
+ * Queries the status of the clearing task.
2507
+ *
2508
+ * This method calls GetContext API directly and parses the raw response to extract
2509
+ * the state field, which indicates the current clearing status.
2510
+ *
2511
+ * @param contextId - ID of the context.
2512
+ * @returns ClearContextResult object containing the current task status.
2513
+ */
2514
+ getClearStatus(contextId: string): Promise<ClearContextResult>;
2515
+ /**
2516
+ * Synchronously clear the context's persistent data and wait for the final result.
2517
+ *
2518
+ * This method wraps the `clearAsync` and `getClearStatus` polling logic,
2519
+ * providing the simplest and most direct way to handle clearing tasks.
2520
+ *
2521
+ * The clearing process transitions through the following states:
2522
+ * - "clearing": Data clearing is in progress
2523
+ * - "available": Clearing completed successfully (final success state)
2524
+ *
2525
+ * @param contextId - Unique ID of the context to clear.
2526
+ * @param timeout - (Optional) Timeout in seconds to wait for task completion, default is 60 seconds.
2527
+ * @param pollInterval - (Optional) Interval in seconds between status polls, default is 2 seconds.
2528
+ * @returns A ClearContextResult object containing the final task result.
2529
+ * The status field will be "available" on success, or other states if interrupted.
2530
+ * @throws APIError - If the task fails to complete within the specified timeout.
2531
+ */
2532
+ clear(contextId: string, timeout?: number, pollInterval?: number): Promise<ClearContextResult>;
2380
2533
  }
2381
2534
 
2382
2535
  declare enum UploadStrategy {
@@ -2385,6 +2538,10 @@ declare enum UploadStrategy {
2385
2538
  declare enum DownloadStrategy {
2386
2539
  DownloadAsync = "DownloadAsync"
2387
2540
  }
2541
+ declare enum UploadMode {
2542
+ File = "File",
2543
+ Archive = "Archive"
2544
+ }
2388
2545
  declare enum Lifecycle {
2389
2546
  Lifecycle_1Day = "Lifecycle_1Day",
2390
2547
  Lifecycle_3Days = "Lifecycle_3Days",
@@ -2400,6 +2557,7 @@ declare enum Lifecycle {
2400
2557
  interface UploadPolicy {
2401
2558
  autoUpload: boolean;
2402
2559
  uploadStrategy: UploadStrategy;
2560
+ uploadMode: UploadMode;
2403
2561
  }
2404
2562
  interface DownloadPolicy {
2405
2563
  autoDownload: boolean;
@@ -2774,6 +2932,12 @@ interface BrowserOption {
2774
2932
  proxies?: BrowserProxy[];
2775
2933
  /** Path to the extensions directory. Defaults to "/tmp/extensions/" */
2776
2934
  extensionPath?: string;
2935
+ /** Additional command line arguments for the browser */
2936
+ cmdArgs?: string[];
2937
+ /** Default URL to navigate to when browser starts */
2938
+ defaultNavigateUrl?: string;
2939
+ /** Browser type: 'chrome' or 'chromium'. Defaults to undefined */
2940
+ browserType?: 'chrome' | 'chromium' | undefined;
2777
2941
  }
2778
2942
  declare class BrowserOptionClass implements BrowserOption {
2779
2943
  persistentPath?: string;
@@ -2785,7 +2949,10 @@ declare class BrowserOptionClass implements BrowserOption {
2785
2949
  solveCaptchas?: boolean;
2786
2950
  proxies?: BrowserProxy[];
2787
2951
  extensionPath?: string;
2788
- constructor(useStealth?: boolean, userAgent?: string, viewport?: BrowserViewport, screen?: BrowserScreen, fingerprint?: BrowserFingerprint, solveCaptchas?: boolean, proxies?: BrowserProxy[]);
2952
+ cmdArgs?: string[];
2953
+ defaultNavigateUrl?: string;
2954
+ browserType?: 'chrome' | 'chromium' | undefined;
2955
+ constructor(useStealth?: boolean, userAgent?: string, viewport?: BrowserViewport, screen?: BrowserScreen, fingerprint?: BrowserFingerprint, solveCaptchas?: boolean, proxies?: BrowserProxy[], cmdArgs?: string[], defaultNavigateUrl?: string, browserType?: 'chrome' | 'chromium');
2789
2956
  toMap(): Record<string, any>;
2790
2957
  fromMap(m: Record<string, any> | null | undefined): BrowserOptionClass;
2791
2958
  }
@@ -2806,6 +2973,10 @@ declare class Browser {
2806
2973
  * Returns true if successful, false otherwise.
2807
2974
  */
2808
2975
  initializeAsync(option: BrowserOptionClass | BrowserOption): Promise<boolean>;
2976
+ /**
2977
+ * Destroy the browser instance.
2978
+ */
2979
+ destroy(): Promise<void>;
2809
2980
  /**
2810
2981
  * Returns the endpoint URL if the browser is initialized, otherwise throws an exception.
2811
2982
  * When initialized, always fetches the latest CDP url from session.getLink().
@@ -2889,6 +3060,83 @@ declare class Command {
2889
3060
  executeCommand(command: string, timeoutMs?: number): Promise<CommandResult>;
2890
3061
  }
2891
3062
 
3063
+ /**
3064
+ * Command templates for various AgentBay operations.
3065
+ *
3066
+ * This module contains shell command templates used by different modules
3067
+ * to execute operations in remote environments.
3068
+ *
3069
+ * Template naming convention:
3070
+ * - Use descriptive names that clearly indicate the operation
3071
+ * - Group templates by functionality (mobile, desktop, network, etc.)
3072
+ * - Use consistent parameter naming across similar templates
3073
+ *
3074
+ * Parameter conventions:
3075
+ * - Use snake_case for parameter names
3076
+ * - Include descriptive parameter names (e.g., lock_switch, package_list)
3077
+ * - Document expected parameter types and values
3078
+ */
3079
+ /**
3080
+ * Resolution lock template
3081
+ * Parameters:
3082
+ * lock_switch (string): "1" to enable lock, "0" to disable lock
3083
+ */
3084
+ declare const RESOLUTION_LOCK_TEMPLATE = "setprop sys.wuying.lockres {lock_switch}";
3085
+ /**
3086
+ * Application whitelist template
3087
+ * Parameters:
3088
+ * package_list (string): Newline-separated list of package names
3089
+ */
3090
+ declare const APP_WHITELIST_TEMPLATE = "cat > /data/system/pm_whitelist.txt << 'EOF'\n{package_list}\nEOF\nchmod 644 /data/system/pm_whitelist.txt\nsetprop rw.wy.pm_whitelist.refresh 1\nsetprop persist.wy.pm_blacklist.switch 2";
3091
+ /**
3092
+ * Application blacklist template
3093
+ * Parameters:
3094
+ * package_list (string): Newline-separated list of package names
3095
+ */
3096
+ declare const APP_BLACKLIST_TEMPLATE = "cat > /data/system/pm_blacklist.txt << 'EOF'\n{package_list}\nEOF\nchmod 644 /data/system/pm_blacklist.txt\nsetprop rw.wy.pm_blacklist.refresh 1\nsetprop persist.wy.pm_blacklist.switch 1";
3097
+ /**
3098
+ * Hide navigation bar template
3099
+ * Hides the system navigation bar by setting system property and restarting SystemUI
3100
+ */
3101
+ declare const HIDE_NAVIGATION_BAR_TEMPLATE = "setprop persist.wy.hasnavibar false; killall com.android.systemui";
3102
+ /**
3103
+ * Show navigation bar template
3104
+ * Shows the system navigation bar by setting system property and restarting SystemUI
3105
+ */
3106
+ declare const SHOW_NAVIGATION_BAR_TEMPLATE = "setprop persist.wy.hasnavibar true; killall com.android.systemui";
3107
+ /**
3108
+ * Uninstall blacklist template
3109
+ * Parameters:
3110
+ * package_list (string): Semicolon-separated list of package names
3111
+ */
3112
+ declare const UNINSTALL_BLACKLIST_TEMPLATE = "setprop persist.wy.pm_lock \"{package_list}\"";
3113
+ /**
3114
+ * Mobile command templates mapping for easy access
3115
+ */
3116
+ declare const MOBILE_COMMAND_TEMPLATES: Record<string, string>;
3117
+ /**
3118
+ * Get a mobile command template by name
3119
+ *
3120
+ * @param templateName - The name of the template to retrieve
3121
+ * @returns The template string if found, undefined otherwise
3122
+ */
3123
+ declare function getMobileCommandTemplate(templateName: string): string | undefined;
3124
+ /**
3125
+ * Check if a mobile command template exists
3126
+ *
3127
+ * @param templateName - The name of the template to check
3128
+ * @returns True if the template exists, false otherwise
3129
+ */
3130
+ declare function hasMobileCommandTemplate(templateName: string): boolean;
3131
+ /**
3132
+ * Replace placeholders in a template with actual values
3133
+ *
3134
+ * @param template - The template string with placeholders
3135
+ * @param replacements - Object containing placeholder-value pairs
3136
+ * @returns The template with placeholders replaced
3137
+ */
3138
+ declare function replaceTemplatePlaceholders(template: string, replacements: Record<string, string>): string;
3139
+
2892
3140
  /**
2893
3141
  * Computer module for desktop UI automation.
2894
3142
  * Provides mouse, keyboard, and screen operations for desktop environments.
@@ -3010,6 +3258,30 @@ declare class Computer {
3010
3258
  * Toggles focus mode on or off.
3011
3259
  */
3012
3260
  focusMode(on: boolean): Promise<BoolResult$2>;
3261
+ /**
3262
+ * Gets the list of installed applications.
3263
+ */
3264
+ getInstalledApps(): Promise<any>;
3265
+ /**
3266
+ * Starts the specified application.
3267
+ */
3268
+ startApp(startCmd: string, workDirectory?: string): Promise<any>;
3269
+ /**
3270
+ * Stops an application by process name.
3271
+ */
3272
+ stopAppByPName(pname: string): Promise<any>;
3273
+ /**
3274
+ * Stops an application by process ID.
3275
+ */
3276
+ stopAppByPID(pid: number): Promise<any>;
3277
+ /**
3278
+ * Stops an application by stop command.
3279
+ */
3280
+ stopAppByCmd(cmd: string): Promise<any>;
3281
+ /**
3282
+ * Lists all visible applications.
3283
+ */
3284
+ listVisibleApps(): Promise<any>;
3013
3285
  }
3014
3286
 
3015
3287
  interface ContextStatusData {
@@ -3275,6 +3547,106 @@ declare class FileSystem {
3275
3547
  }): Promise<any>;
3276
3548
  }
3277
3549
 
3550
+ /**
3551
+ * App manager rule for mobile device configuration.
3552
+ *
3553
+ * Defines rules for managing app access on mobile devices through whitelist or blacklist modes.
3554
+ */
3555
+ interface AppManagerRule {
3556
+ /**
3557
+ * Type of rule to apply.
3558
+ * - "White": Whitelist mode - only allow specified apps
3559
+ * - "Black": Blacklist mode - block specified apps
3560
+ */
3561
+ ruleType: "White" | "Black";
3562
+ /**
3563
+ * List of Android package names to apply the rule to.
3564
+ * Example: ["com.android.settings", "com.example.app"]
3565
+ */
3566
+ appPackageNameList: string[];
3567
+ }
3568
+ /**
3569
+ * Mobile-specific configuration settings for session creation.
3570
+ *
3571
+ * These settings allow control over mobile device behavior including
3572
+ * resolution locking, app access management, navigation bar visibility, and uninstall protection.
3573
+ */
3574
+ interface MobileExtraConfig {
3575
+ /**
3576
+ * Whether to lock the screen resolution.
3577
+ * - true: Locks resolution for consistent mobile testing environments
3578
+ * - false: Allows adaptive resolution for different device types
3579
+ */
3580
+ lockResolution: boolean;
3581
+ /**
3582
+ * Optional app manager rule for controlling app access.
3583
+ * Defines which apps are allowed (whitelist) or blocked (blacklist).
3584
+ */
3585
+ appManagerRule?: AppManagerRule;
3586
+ /**
3587
+ * Whether to hide the system navigation bar for immersive full-screen experience.
3588
+ * - true: Hide navigation bar
3589
+ * - false: Show navigation bar (default)
3590
+ */
3591
+ hideNavigationBar?: boolean;
3592
+ /**
3593
+ * List of package names to protect from uninstallation.
3594
+ * Prevents accidental or malicious removal of critical apps.
3595
+ * Example: ["com.android.systemui", "com.android.settings"]
3596
+ */
3597
+ uninstallBlacklist?: string[];
3598
+ }
3599
+ /**
3600
+ * Extra configuration settings for different session types.
3601
+ *
3602
+ * This container holds specialized configurations for various
3603
+ * session environments (mobile, desktop, etc.).
3604
+ */
3605
+ interface ExtraConfigs {
3606
+ /**
3607
+ * Mobile-specific configuration settings.
3608
+ * Only applicable when creating mobile sessions.
3609
+ */
3610
+ mobile?: MobileExtraConfig;
3611
+ }
3612
+ /**
3613
+ * Serializes ExtraConfigs to JSON string format.
3614
+ * Returns empty string if extraConfigs is null or undefined.
3615
+ *
3616
+ * @param extraConfigs - The extra configs to serialize
3617
+ * @returns JSON string representation
3618
+ */
3619
+ declare function extraConfigsToJSON(extraConfigs?: ExtraConfigs | null): string;
3620
+ /**
3621
+ * Deserializes ExtraConfigs from JSON string format.
3622
+ * Returns null if jsonStr is empty or invalid.
3623
+ *
3624
+ * @param jsonStr - JSON string to deserialize
3625
+ * @returns Parsed ExtraConfigs object or null
3626
+ */
3627
+ declare function extraConfigsFromJSON(jsonStr: string): ExtraConfigs | null;
3628
+ /**
3629
+ * Validates an AppManagerRule object.
3630
+ * Throws an error if validation fails.
3631
+ *
3632
+ * @param rule - The rule to validate
3633
+ */
3634
+ declare function validateAppManagerRule(rule: AppManagerRule): void;
3635
+ /**
3636
+ * Validates a MobileExtraConfig object.
3637
+ * Throws an error if validation fails.
3638
+ *
3639
+ * @param config - The config to validate
3640
+ */
3641
+ declare function validateMobileExtraConfig(config: MobileExtraConfig): void;
3642
+ /**
3643
+ * Validates an ExtraConfigs object.
3644
+ * Throws an error if validation fails.
3645
+ *
3646
+ * @param extraConfigs - The extra configs to validate
3647
+ */
3648
+ declare function validateExtraConfigs(extraConfigs: ExtraConfigs): void;
3649
+
3278
3650
  /**
3279
3651
  * Mobile module for mobile UI automation.
3280
3652
  * Provides touch, input, and app management operations for mobile environments.
@@ -3314,10 +3686,16 @@ interface ProcessResult extends OperationResult {
3314
3686
  interface ScreenshotResult extends OperationResult {
3315
3687
  data: string;
3316
3688
  }
3689
+ interface AdbUrlResult extends OperationResult {
3690
+ data?: string;
3691
+ url?: string;
3692
+ }
3317
3693
  interface MobileSession {
3318
3694
  callMcpTool(toolName: string, args: Record<string, any>): Promise<any>;
3319
3695
  sessionId: string;
3320
3696
  getAPIKey(): string;
3697
+ imageId?: string;
3698
+ getLink(protocolType?: string, port?: number, options?: string): Promise<any>;
3321
3699
  }
3322
3700
  declare class Mobile {
3323
3701
  private session;
@@ -3362,6 +3740,68 @@ declare class Mobile {
3362
3740
  * Take a screenshot.
3363
3741
  */
3364
3742
  screenshot(): Promise<ScreenshotResult>;
3743
+ /**
3744
+ * Retrieves the ADB connection URL for the mobile environment.
3745
+ * This method is only supported in mobile environments (mobile_latest image).
3746
+ * It uses the provided ADB public key to establish the connection and returns
3747
+ * the ADB connect URL.
3748
+ *
3749
+ * @param adbkeyPub - ADB public key for authentication
3750
+ * @returns AdbUrlResult containing the ADB connection URL
3751
+ */
3752
+ getAdbUrl(adbkeyPub: string): Promise<AdbUrlResult>;
3753
+ /**
3754
+ * Configure mobile device settings based on MobileExtraConfig.
3755
+ * This method applies various mobile configuration settings including
3756
+ * resolution lock and app access management.
3757
+ *
3758
+ * @param config - The mobile configuration to apply
3759
+ * @returns OperationResult indicating success or failure
3760
+ */
3761
+ configure(config: MobileExtraConfig): Promise<OperationResult>;
3762
+ /**
3763
+ * Set display resolution lock for mobile devices.
3764
+ *
3765
+ * @param enable - Whether to enable resolution lock
3766
+ * @returns OperationResult indicating success or failure
3767
+ */
3768
+ setResolutionLock(enable: boolean): Promise<OperationResult>;
3769
+ /**
3770
+ * Set app whitelist configuration.
3771
+ *
3772
+ * @param packageNames - List of package names to whitelist
3773
+ * @returns OperationResult indicating success or failure
3774
+ */
3775
+ setAppWhitelist(packageNames: string[]): Promise<OperationResult>;
3776
+ /**
3777
+ * Set app blacklist configuration.
3778
+ *
3779
+ * @param packageNames - List of package names to blacklist
3780
+ * @returns OperationResult indicating success or failure
3781
+ */
3782
+ setAppBlacklist(packageNames: string[]): Promise<OperationResult>;
3783
+ /**
3784
+ * Set navigation bar visibility for mobile devices.
3785
+ *
3786
+ * @param hide - True to hide navigation bar, false to show navigation bar
3787
+ * @returns OperationResult indicating success or failure
3788
+ */
3789
+ setNavigationBarVisibility(hide: boolean): Promise<OperationResult>;
3790
+ /**
3791
+ * Set uninstall protection blacklist for mobile devices.
3792
+ *
3793
+ * @param packageNames - List of Android package names to protect from uninstallation
3794
+ * @returns OperationResult indicating success or failure
3795
+ */
3796
+ setUninstallBlacklist(packageNames: string[]): Promise<OperationResult>;
3797
+ /**
3798
+ * Execute a command template for mobile configuration.
3799
+ *
3800
+ * @param command - The command to execute
3801
+ * @param description - Description of the operation
3802
+ * @returns OperationResult indicating success or failure
3803
+ */
3804
+ private executeCommand;
3365
3805
  }
3366
3806
 
3367
3807
  /**
@@ -3767,6 +4207,7 @@ declare class Session {
3767
4207
  private agentBay;
3768
4208
  sessionId: string;
3769
4209
  fileTransferContextId: string | null;
4210
+ recordContextId: string | null;
3770
4211
  isVpc: boolean;
3771
4212
  networkInterfaceIp: string;
3772
4213
  httpPort: string;
@@ -3873,7 +4314,7 @@ declare class Session {
3873
4314
  * @returns OperationResult containing the link as data and request ID
3874
4315
  * @throws Error if the operation fails (matching Python SessionError)
3875
4316
  */
3876
- getLink(protocolType?: string, port?: number): Promise<OperationResult>;
4317
+ getLink(protocolType?: string, port?: number, options?: string): Promise<OperationResult>;
3877
4318
  /**
3878
4319
  * Asynchronously get a link associated with the current session.
3879
4320
  *
@@ -3882,7 +4323,7 @@ declare class Session {
3882
4323
  * @returns OperationResult containing the link as data and request ID
3883
4324
  * @throws Error if the operation fails (matching Python SessionError)
3884
4325
  */
3885
- getLinkAsync(protocolType?: string, port?: number): Promise<OperationResult>;
4326
+ getLinkAsync(protocolType?: string, port?: number, options?: string): Promise<OperationResult>;
3886
4327
  /**
3887
4328
  * List MCP tools available for this session.
3888
4329
  *
@@ -4241,6 +4682,8 @@ interface CreateSessionParamsConfig {
4241
4682
  policyId?: string;
4242
4683
  /** Whether to enable browser recording for the session. Defaults to false. */
4243
4684
  enableBrowserReplay?: boolean;
4685
+ /** Extra configuration settings for different session types (e.g., mobile) */
4686
+ extraConfigs?: ExtraConfigs;
4244
4687
  }
4245
4688
  /**
4246
4689
  * CreateSessionParams provides a way to configure the parameters for creating a new session
@@ -4264,6 +4707,8 @@ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
4264
4707
  policyId?: string;
4265
4708
  /** Whether to enable browser recording for the session. Defaults to false. */
4266
4709
  enableBrowserReplay: boolean;
4710
+ /** Extra configuration settings for different session types (e.g., mobile) */
4711
+ extraConfigs?: ExtraConfigs;
4267
4712
  constructor();
4268
4713
  /**
4269
4714
  * WithLabels sets the labels for the session parameters and returns the updated parameters.
@@ -4293,6 +4738,10 @@ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
4293
4738
  * Alias for withEnableBrowserReplay for backward compatibility.
4294
4739
  */
4295
4740
  withEnableRecord(enableRecord: boolean): CreateSessionParams$1;
4741
+ /**
4742
+ * WithExtraConfigs sets the extra configurations for the session parameters and returns the updated parameters.
4743
+ */
4744
+ withExtraConfigs(extraConfigs: ExtraConfigs): CreateSessionParams$1;
4296
4745
  /**
4297
4746
  * GetLabelsJSON returns the labels as a JSON string.
4298
4747
  * Returns an object with success status and result/error message to match Go version behavior.
@@ -4301,6 +4750,14 @@ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
4301
4750
  result: string;
4302
4751
  error?: string;
4303
4752
  };
4753
+ /**
4754
+ * GetExtraConfigsJSON returns the extra configs as a JSON string.
4755
+ * Returns an object with result and optional error message to match Go version behavior.
4756
+ */
4757
+ getExtraConfigsJSON(): {
4758
+ result: string;
4759
+ error?: string;
4760
+ };
4304
4761
  /**
4305
4762
  * AddContextSync adds a context sync configuration to the session parameters.
4306
4763
  */
@@ -4351,6 +4808,10 @@ interface SessionListResult extends ApiResponse {
4351
4808
  /** Total number of results */
4352
4809
  totalCount?: number;
4353
4810
  }
4811
+ /**
4812
+ * Helper function to create ListSessionParams with default values
4813
+ */
4814
+ declare function createListSessionParams(labels?: Record<string, string>): ListSessionParams;
4354
4815
 
4355
4816
  /**
4356
4817
  * Parameters for creating a session.
@@ -4363,6 +4824,8 @@ interface CreateSessionParams {
4363
4824
  isVpc?: boolean;
4364
4825
  policyId?: string;
4365
4826
  enableBrowserReplay?: boolean;
4827
+ extraConfigs?: ExtraConfigs;
4828
+ framework?: string;
4366
4829
  }
4367
4830
  /**
4368
4831
  * Main class for interacting with the AgentBay cloud runtime environment.
@@ -4554,19 +5017,74 @@ declare class BrowserError extends AgentBayError {
4554
5017
  }
4555
5018
 
4556
5019
  /**
4557
- * Utility functions for logging in a clean format
5020
+ * Utility functions for structured logging with multiple levels, API tracking,
5021
+ * sensitive data masking, and RequestID management.
5022
+ */
5023
+ /**
5024
+ * Log level type
5025
+ */
5026
+ type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
5027
+ /**
5028
+ * Logger configuration options
5029
+ */
5030
+ interface LoggerConfig {
5031
+ level?: LogLevel;
5032
+ logFile?: string;
5033
+ maxFileSize?: string;
5034
+ enableConsole?: boolean;
5035
+ }
5036
+ /**
5037
+ * Mask sensitive information in data structures
5038
+ * @param data Data to mask (dict, str, list, etc.)
5039
+ * @param fields Additional sensitive field names
5040
+ * @returns Masked data (deep copy)
4558
5041
  */
5042
+ declare function maskSensitiveData(data: any, fields?: string[]): any;
5043
+ /**
5044
+ * Set the log level
5045
+ * @param level The log level to set
5046
+ */
5047
+ declare function setLogLevel(level: LogLevel): void;
5048
+ /**
5049
+ * Get the current log level
5050
+ * @returns The current log level
5051
+ */
5052
+ declare function getLogLevel(): LogLevel;
5053
+ /**
5054
+ * Setup logger configuration
5055
+ * @param config Logger configuration options
5056
+ */
5057
+ declare function setupLogger(config: LoggerConfig): void;
4559
5058
  /**
4560
5059
  * Log a message without the log prefix and file location
5060
+ * Treated as INFO level - will be filtered if log level is WARN or higher
4561
5061
  * @param message The message to log
4562
5062
  * @param args Optional arguments to log
4563
5063
  */
4564
5064
  declare function log(message: string, ...args: any[]): void;
4565
5065
  /**
4566
- * Log an error message
5066
+ * Log a debug level message
5067
+ * @param message The message to log
5068
+ * @param args Optional arguments to log
5069
+ */
5070
+ declare function logDebug(message: string, ...args: any[]): void;
5071
+ /**
5072
+ * Log an info level message
5073
+ * @param message The message to log
5074
+ * @param args Optional arguments to log
5075
+ */
5076
+ declare function logInfo(message: string, ...args: any[]): void;
5077
+ /**
5078
+ * Log a warning level message (outputs to stderr)
5079
+ * @param message The message to log
5080
+ * @param args Optional arguments to log
5081
+ */
5082
+ declare function logWarn(message: string, ...args: any[]): void;
5083
+ /**
5084
+ * Log an error message with optional error object (outputs to stderr)
4567
5085
  * @param message The error message to log
4568
5086
  * @param error Optional error object
4569
5087
  */
4570
5088
  declare function logError(message: string, error?: any): void;
4571
5089
 
4572
- 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, type FileChangeEvent, FileChangeEventHelper, type FileChangeResult, FileChangeResultHelper, 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, GetSessionRequest, GetSessionResponse, GetSessionResponseBody, GetSessionResponseBodyData, InitBrowserRequest, InitBrowserResponse, InitBrowserResponseBody, InitBrowserResponseBodyData, type InstalledApp$1 as InstalledApp, KeyCode, Lifecycle, 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$1 as Process, type QueryResult, type RecyclePolicy, ReleaseMcpSessionRequest, ReleaseMcpSessionResponse, ReleaseMcpSessionResponseBody, Session, SessionError, type SessionInterface, SetLabelRequest, SetLabelResponse, SetLabelResponseBody, type SyncCallback, SyncContextRequest, SyncContextResponse, SyncContextResponseBody, type SyncPolicy, SyncPolicyImpl, UI, type UIElement, UIError, type UploadPolicy, UploadStrategy, type WhiteList, WhiteListValidator, loadConfig, loadDotEnv, log, logError, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newExtractPolicy, newRecyclePolicy, newSyncPolicy, newSyncPolicyWithDefaults, newUploadPolicy, validateSyncPolicy };
5090
+ export { APIError, APP_BLACKLIST_TEMPLATE, APP_WHITELIST_TEMPLATE, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, type ApiResponse, type ApiResponseWithData, type AppManagerRule, 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, ClearContextRequest, ClearContextResponse, ClearContextResponseBody, 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, type DeleteResult, DescribeContextFilesRequest, DescribeContextFilesResponse, DescribeContextFilesResponseBody, type DirectoryEntry, type DownloadPolicy, DownloadStrategy, type ExecutionResult, Extension, ExtensionOption, ExtensionsService, type ExtraConfigs, type ExtractOptions, type ExtractPolicy, ExtractPolicyClass, type FileChangeEvent, FileChangeEventHelper, type FileChangeResult, FileChangeResultHelper, 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, GetSessionRequest, GetSessionResponse, GetSessionResponseBody, GetSessionResponseBodyData, HIDE_NAVIGATION_BAR_TEMPLATE, IS_RELEASE, InitBrowserRequest, InitBrowserResponse, InitBrowserResponseBody, InitBrowserResponseBodyData, type InstalledApp$1 as InstalledApp, KeyCode, Lifecycle, ListContextsRequest, ListContextsResponse, ListContextsResponseBody, ListContextsResponseBodyData, ListMcpToolsRequest, ListMcpToolsResponse, ListMcpToolsResponseBody, type ListSessionParams, ListSessionRequest, ListSessionResponse, ListSessionResponseBody, ListSessionResponseBodyData, type LogLevel, type LoggerConfig, MOBILE_COMMAND_TEMPLATES, type McpSession, type McpToolResult, type MobileExtraConfig, ModifyContextRequest, ModifyContextResponse, ModifyContextResponseBody, type ObserveOptions, ObserveResult, Oss, OssError, type Process$1 as Process, type QueryResult, RESOLUTION_LOCK_TEMPLATE, type RecyclePolicy, ReleaseMcpSessionRequest, ReleaseMcpSessionResponse, ReleaseMcpSessionResponseBody, SHOW_NAVIGATION_BAR_TEMPLATE, Session, SessionError, type SessionInterface, type SessionListResult, SetLabelRequest, SetLabelResponse, SetLabelResponseBody, type SyncCallback, SyncContextRequest, SyncContextResponse, SyncContextResponseBody, type SyncPolicy, SyncPolicyImpl, UI, type UIElement, UIError, UNINSTALL_BLACKLIST_TEMPLATE, UploadMode, type UploadPolicy, UploadStrategy, VERSION, type WhiteList, WhiteListValidator, createListSessionParams, extraConfigsFromJSON, extraConfigsToJSON, extractRequestId, getLogLevel, getMobileCommandTemplate, hasMobileCommandTemplate, loadConfig, loadDotEnv, log, logDebug, logError, logInfo, logWarn, maskSensitiveData, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newExtractPolicy, newRecyclePolicy, newSyncPolicy, newSyncPolicyWithDefaults, newUploadPolicy, replaceTemplatePlaceholders, setLogLevel, setupLogger, validateAppManagerRule, validateExtraConfigs, validateMobileExtraConfig, validateSyncPolicy };