wuying-agentbay-sdk 0.4.2 → 0.5.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/dist/index.d.mts CHANGED
@@ -41,10 +41,13 @@ declare class CreateMcpSessionRequestPersistenceDataList extends $dara.Model {
41
41
  declare class CreateMcpSessionResponseBodyData extends $dara.Model {
42
42
  appInstanceId?: string;
43
43
  errMsg?: string;
44
+ httpPort?: string;
45
+ networkInterfaceIp?: string;
44
46
  resourceId?: string;
45
47
  resourceUrl?: string;
46
48
  sessionId?: string;
47
49
  success?: boolean;
50
+ vpcResource?: boolean;
48
51
  static names(): {
49
52
  [key: string]: string;
50
53
  };
@@ -304,6 +307,7 @@ declare class CreateMcpSessionRequest extends $dara.Model {
304
307
  labels?: string;
305
308
  persistenceDataList?: CreateMcpSessionRequestPersistenceDataList[];
306
309
  sessionId?: string;
310
+ vpcResource?: boolean;
307
311
  static names(): {
308
312
  [key: string]: string;
309
313
  };
@@ -324,6 +328,7 @@ declare class CreateMcpSessionShrinkRequest extends $dara.Model {
324
328
  labels?: string;
325
329
  persistenceDataListShrink?: string;
326
330
  sessionId?: string;
331
+ vpcResource?: boolean;
327
332
  static names(): {
328
333
  [key: string]: string;
329
334
  };
@@ -695,6 +700,85 @@ declare class GetMcpResourceResponse extends $dara.Model {
695
700
  });
696
701
  }
697
702
 
703
+ declare class InitBrowserRequest extends $dara.Model {
704
+ authorization?: string;
705
+ persistentPath?: string;
706
+ sessionId?: string;
707
+ static names(): {
708
+ [key: string]: string;
709
+ };
710
+ static types(): {
711
+ [key: string]: any;
712
+ };
713
+ validate(): void;
714
+ constructor(map?: {
715
+ [key: string]: any;
716
+ });
717
+ static fromMap(m: {
718
+ [key: string]: any;
719
+ }): InitBrowserRequest;
720
+ }
721
+
722
+ declare class InitBrowserResponseBodyData extends $dara.Model {
723
+ port?: number;
724
+ static names(): {
725
+ [key: string]: string;
726
+ };
727
+ static types(): {
728
+ [key: string]: any;
729
+ };
730
+ validate(): void;
731
+ constructor(map?: {
732
+ [key: string]: any;
733
+ });
734
+ static fromMap(m: {
735
+ [key: string]: any;
736
+ }): InitBrowserResponseBodyData;
737
+ }
738
+
739
+ declare class InitBrowserResponseBody extends $dara.Model {
740
+ code?: string;
741
+ data?: InitBrowserResponseBodyData;
742
+ httpStatusCode?: number;
743
+ message?: string;
744
+ requestId?: string;
745
+ success?: boolean;
746
+ static names(): {
747
+ [key: string]: string;
748
+ };
749
+ static types(): {
750
+ [key: string]: any;
751
+ };
752
+ validate(): void;
753
+ constructor(map?: {
754
+ [key: string]: any;
755
+ });
756
+ static fromMap(m: {
757
+ [key: string]: any;
758
+ }): InitBrowserResponseBody;
759
+ }
760
+
761
+ declare class InitBrowserResponse extends $dara.Model {
762
+ headers?: {
763
+ [key: string]: string;
764
+ };
765
+ statusCode?: number;
766
+ body?: InitBrowserResponseBody;
767
+ static names(): {
768
+ [key: string]: string;
769
+ };
770
+ static types(): {
771
+ [key: string]: any;
772
+ };
773
+ validate(): void;
774
+ constructor(map?: {
775
+ [key: string]: any;
776
+ });
777
+ static fromMap(m: {
778
+ [key: string]: any;
779
+ }): InitBrowserResponse;
780
+ }
781
+
698
782
  declare class ListContextsRequest extends $dara.Model {
699
783
  authorization?: string;
700
784
  maxResults?: number;
@@ -1299,6 +1383,28 @@ declare class Client extends OpenApi {
1299
1383
  * @returns SyncContextResponse
1300
1384
  */
1301
1385
  syncContext(request: SyncContextRequest): Promise<SyncContextResponse>;
1386
+ /**
1387
+ * 初始化浏览器
1388
+ *
1389
+ * @param tmpReq - InitBrowserRequest
1390
+ * @param runtime - runtime options for this request RuntimeOptions
1391
+ * @returns InitBrowserResponse
1392
+ */
1393
+ initBrowserWithOptions(request: InitBrowserRequest, runtime: $dara.RuntimeOptions): Promise<InitBrowserResponse>;
1394
+ /**
1395
+ * 初始化浏览器
1396
+ *
1397
+ * @param request - InitBrowserRequest
1398
+ * @returns InitBrowserResponse
1399
+ */
1400
+ initBrowser(request: InitBrowserRequest): Promise<InitBrowserResponse>;
1401
+ /**
1402
+ * 初始化浏览器(同步版本)
1403
+ *
1404
+ * @param request - InitBrowserRequest
1405
+ * @returns InitBrowserResponse
1406
+ */
1407
+ initBrowserSync(request: InitBrowserRequest): InitBrowserResponse;
1302
1408
  }
1303
1409
 
1304
1410
  interface Config {
@@ -1618,6 +1724,12 @@ interface ContextListResult extends ApiResponse {
1618
1724
  success: boolean;
1619
1725
  /** List of contexts */
1620
1726
  contexts: any[];
1727
+ /** Token for the next page of results */
1728
+ nextToken?: string;
1729
+ /** Maximum number of results per page */
1730
+ maxResults?: number;
1731
+ /** Total number of contexts available */
1732
+ totalCount?: number;
1621
1733
  /** Optional error message if the operation failed */
1622
1734
  errorMessage?: string;
1623
1735
  }
@@ -1662,6 +1774,20 @@ declare class Context {
1662
1774
  */
1663
1775
  constructor(id: string, name: string, state?: string, createdAt?: string, lastUsedAt?: string, osType?: string);
1664
1776
  }
1777
+ /**
1778
+ * Parameters for listing contexts with pagination support.
1779
+ */
1780
+ interface ContextListParams {
1781
+ /**
1782
+ * Maximum number of results per page.
1783
+ * Defaults to 10 if not specified.
1784
+ */
1785
+ maxResults?: number;
1786
+ /**
1787
+ * Token for the next page of results.
1788
+ */
1789
+ nextToken?: string;
1790
+ }
1665
1791
  /**
1666
1792
  * Provides methods to manage persistent contexts in the AgentBay cloud environment.
1667
1793
  */
@@ -1674,12 +1800,13 @@ declare class ContextService {
1674
1800
  */
1675
1801
  constructor(agentBay: AgentBay);
1676
1802
  /**
1677
- * Lists all available contexts.
1803
+ * Lists all available contexts with pagination support.
1678
1804
  * Corresponds to Python's list() method
1679
1805
  *
1680
- * @returns ContextListResult with contexts list and requestId
1806
+ * @param params - Optional parameters for listing contexts.
1807
+ * @returns ContextListResult with contexts list and pagination information
1681
1808
  */
1682
- list(): Promise<ContextListResult>;
1809
+ list(params?: ContextListParams): Promise<ContextListResult>;
1683
1810
  /**
1684
1811
  * Gets a context by name. Optionally creates it if it doesn't exist.
1685
1812
  * Corresponds to Python's get() method
@@ -1746,6 +1873,15 @@ interface SyncPolicy {
1746
1873
  deletePolicy?: DeletePolicy;
1747
1874
  bwList?: BWList;
1748
1875
  }
1876
+ declare class SyncPolicyImpl implements SyncPolicy {
1877
+ uploadPolicy?: UploadPolicy;
1878
+ downloadPolicy?: DownloadPolicy;
1879
+ deletePolicy?: DeletePolicy;
1880
+ bwList?: BWList;
1881
+ constructor(policy?: Partial<SyncPolicy>);
1882
+ private ensureDefaults;
1883
+ toJSON(): SyncPolicy;
1884
+ }
1749
1885
  declare class ContextSync {
1750
1886
  contextId: string;
1751
1887
  path: string;
@@ -1757,10 +1893,80 @@ declare function newUploadPolicy(): UploadPolicy;
1757
1893
  declare function newDownloadPolicy(): DownloadPolicy;
1758
1894
  declare function newDeletePolicy(): DeletePolicy;
1759
1895
  declare function newSyncPolicy(): SyncPolicy;
1896
+ declare function newSyncPolicyWithDefaults(policy?: Partial<SyncPolicy>): SyncPolicy;
1760
1897
  declare function newContextSync(contextId: string, path: string, policy?: SyncPolicy): ContextSync;
1761
1898
 
1762
1899
  /**
1763
- * Represents an installed application.
1900
+ * Result of task execution.
1901
+ */
1902
+ interface ExecutionResult extends ApiResponse {
1903
+ success: boolean;
1904
+ errorMessage: string;
1905
+ taskId: string;
1906
+ taskStatus: string;
1907
+ }
1908
+ /**
1909
+ * Result of query operations.
1910
+ */
1911
+ interface QueryResult extends ApiResponse {
1912
+ success: boolean;
1913
+ output: string;
1914
+ errorMessage: string;
1915
+ }
1916
+ /**
1917
+ * Result of an MCP tool call.
1918
+ */
1919
+ interface McpToolResult {
1920
+ success: boolean;
1921
+ data: string;
1922
+ errorMessage: string;
1923
+ requestId: string;
1924
+ }
1925
+ /**
1926
+ * Interface defining the methods needed by Agent from Session.
1927
+ */
1928
+ interface McpSession {
1929
+ getAPIKey(): string;
1930
+ getSessionId(): string;
1931
+ callMcpTool(toolName: string, args: any): Promise<McpToolResult>;
1932
+ }
1933
+ /**
1934
+ * An Agent to manipulate applications to complete specific tasks.
1935
+ */
1936
+ declare class Agent {
1937
+ private session;
1938
+ /**
1939
+ * Initialize an Agent object.
1940
+ *
1941
+ * @param session - The Session instance that this Agent belongs to.
1942
+ */
1943
+ constructor(session: McpSession);
1944
+ /**
1945
+ * Execute a specific task described in human language.
1946
+ *
1947
+ * @param task - Task description in human language.
1948
+ * @param maxTryTimes - Maximum number of retry attempts.
1949
+ * @returns ExecutionResult containing success status, task output, and error message if any.
1950
+ */
1951
+ executeTask(task: string, maxTryTimes: number): Promise<ExecutionResult>;
1952
+ /**
1953
+ * Get the status of the task with the given task ID.
1954
+ *
1955
+ * @param taskId - Task ID
1956
+ * @returns QueryResult containing the task status
1957
+ */
1958
+ getTaskStatus(taskId: string): Promise<QueryResult>;
1959
+ /**
1960
+ * Terminate a task with a specified task ID.
1961
+ *
1962
+ * @param taskId - The ID of the running task.
1963
+ * @returns ExecutionResult containing success status, task output, and error message if any.
1964
+ */
1965
+ terminateTask(taskId: string): Promise<ExecutionResult>;
1966
+ }
1967
+
1968
+ /**
1969
+ * Represents an installed application
1764
1970
  */
1765
1971
  interface InstalledApp {
1766
1972
  name: string;
@@ -1769,7 +1975,7 @@ interface InstalledApp {
1769
1975
  work_directory?: string;
1770
1976
  }
1771
1977
  /**
1772
- * Represents a running process.
1978
+ * Represents a running process
1773
1979
  */
1774
1980
  interface Process {
1775
1981
  pname: string;
@@ -1778,29 +1984,33 @@ interface Process {
1778
1984
  path?: string;
1779
1985
  }
1780
1986
  /**
1781
- * Handles application management operations in the AgentBay cloud environment.
1987
+ * Handles application operations in the AgentBay cloud environment.
1782
1988
  */
1783
1989
  declare class Application {
1784
1990
  private session;
1785
1991
  /**
1786
- * Creates a new Application instance.
1787
- * @param session The session object that provides access to the AgentBay API.
1992
+ * Initialize an Application object.
1993
+ *
1994
+ * @param session - The Session instance that this Application belongs to.
1788
1995
  */
1789
1996
  constructor(session: {
1790
1997
  getAPIKey(): string;
1791
1998
  getClient(): Client;
1792
1999
  getSessionId(): string;
2000
+ callMcpTool(toolName: string, args: any): Promise<{
2001
+ success: boolean;
2002
+ data: string;
2003
+ errorMessage: string;
2004
+ requestId: string;
2005
+ }>;
1793
2006
  });
1794
2007
  /**
1795
- * Helper method to call MCP tools and handle common response processing
2008
+ * Sanitizes error messages to remove sensitive information like API keys.
1796
2009
  *
1797
- * @param toolName - Name of the MCP tool to call
1798
- * @param args - Arguments to pass to the tool
1799
- * @param defaultErrorMsg - Default error message if specific error details are not available
1800
- * @returns A CallMcpToolResult with the response data
1801
- * @throws APIError if the call fails
2010
+ * @param error - The error to sanitize
2011
+ * @returns The sanitized error
1802
2012
  */
1803
- private callMcpTool;
2013
+ private sanitizeError;
1804
2014
  /**
1805
2015
  * Helper method to parse JSON string into objects
1806
2016
  */
@@ -1809,9 +2019,9 @@ declare class Application {
1809
2019
  * Retrieves a list of installed applications.
1810
2020
  * Corresponds to Python's get_installed_apps() method
1811
2021
  *
1812
- * @param startMenu Whether to include applications from the start menu. Defaults to true.
1813
- * @param desktop Whether to include applications from the desktop. Defaults to true.
1814
- * @param ignoreSystemApps Whether to ignore system applications. Defaults to true.
2022
+ * @param startMenu - Whether to include applications from the start menu. Defaults to true.
2023
+ * @param desktop - Whether to include applications from the desktop. Defaults to true.
2024
+ * @param ignoreSystemApps - Whether to ignore system applications. Defaults to true.
1815
2025
  * @returns InstalledAppListResult with installed apps and requestId
1816
2026
  * @throws Error if the operation fails.
1817
2027
  */
@@ -1820,9 +2030,9 @@ declare class Application {
1820
2030
  * Starts an application with the given command and optional working directory.
1821
2031
  * Corresponds to Python's start_app() method
1822
2032
  *
1823
- * @param startCmd The command to start the application.
1824
- * @param workDirectory The working directory for the application. Defaults to an empty string.
1825
- * @param activity Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
2033
+ * @param startCmd - The command to start the application.
2034
+ * @param workDirectory - The working directory for the application. Defaults to an empty string.
2035
+ * @param activity - Activity name to launch (e.g. ".SettingsActivity" or "com.package/.Activity"). Defaults to an empty string.
1826
2036
  * @returns ProcessListResult with started processes and requestId
1827
2037
  * @throws Error if the operation fails.
1828
2038
  */
@@ -1831,8 +2041,8 @@ declare class Application {
1831
2041
  * Stops an application by process name.
1832
2042
  * Corresponds to Python's stop_app_by_pname() method
1833
2043
  *
1834
- * @param pname The name of the process to stop.
1835
- * @returns AppOperationResult with requestId
2044
+ * @param pname - The process name to stop.
2045
+ * @returns AppOperationResult with operation result and requestId
1836
2046
  * @throws Error if the operation fails.
1837
2047
  */
1838
2048
  stopAppByPName(pname: string): Promise<AppOperationResult>;
@@ -1840,8 +2050,8 @@ declare class Application {
1840
2050
  * Stops an application by process ID.
1841
2051
  * Corresponds to Python's stop_app_by_pid() method
1842
2052
  *
1843
- * @param pid The ID of the process to stop.
1844
- * @returns AppOperationResult with requestId
2053
+ * @param pid - The process ID to stop.
2054
+ * @returns AppOperationResult with operation result and requestId
1845
2055
  * @throws Error if the operation fails.
1846
2056
  */
1847
2057
  stopAppByPID(pid: number): Promise<AppOperationResult>;
@@ -1849,28 +2059,59 @@ declare class Application {
1849
2059
  * Stops an application by stop command.
1850
2060
  * Corresponds to Python's stop_app_by_cmd() method
1851
2061
  *
1852
- * @param stopCmd The command to stop the application.
1853
- * @returns AppOperationResult with requestId
2062
+ * @param stopCmd - The stop command to execute.
2063
+ * @returns AppOperationResult with operation result and requestId
1854
2064
  * @throws Error if the operation fails.
1855
2065
  */
1856
2066
  stopAppByCmd(stopCmd: string): Promise<AppOperationResult>;
1857
2067
  /**
1858
- * Lists all currently visible applications.
2068
+ * Returns a list of currently visible applications.
1859
2069
  * Corresponds to Python's list_visible_apps() method
1860
2070
  *
1861
- * @returns ProcessListResult with visible processes and requestId
2071
+ * @returns ProcessListResult with visible apps and requestId
1862
2072
  * @throws Error if the operation fails.
1863
2073
  */
1864
2074
  listVisibleApps(): Promise<ProcessListResult>;
1865
2075
  }
1866
2076
 
2077
+ /**
2078
+ * Handles code execution operations in the AgentBay cloud environment.
2079
+ */
2080
+ declare class Code {
2081
+ private session;
2082
+ /**
2083
+ * Initialize a Code object.
2084
+ *
2085
+ * @param session - The Session instance that this Code belongs to.
2086
+ */
2087
+ constructor(session: {
2088
+ getAPIKey(): string;
2089
+ getSessionId(): string;
2090
+ callMcpTool(toolName: string, args: any): Promise<{
2091
+ success: boolean;
2092
+ data: string;
2093
+ errorMessage: string;
2094
+ requestId: string;
2095
+ }>;
2096
+ });
2097
+ /**
2098
+ * Execute code in the specified language with a timeout.
2099
+ * Corresponds to Python's run_code() method
2100
+ *
2101
+ * @param code - The code to execute.
2102
+ * @param language - The programming language of the code. Must be either 'python' or 'javascript'.
2103
+ * @param timeoutS - The timeout for the code execution in seconds. Default is 300s.
2104
+ * @returns CodeExecutionResult with code execution output and requestId
2105
+ * @throws Error if an unsupported language is specified.
2106
+ */
2107
+ runCode(code: string, language: string, timeoutS?: number): Promise<CodeExecutionResult>;
2108
+ }
2109
+
1867
2110
  /**
1868
2111
  * Handles command execution operations in the AgentBay cloud environment.
1869
2112
  */
1870
2113
  declare class Command {
1871
2114
  private session;
1872
- private client;
1873
- private baseUrl;
1874
2115
  /**
1875
2116
  * Initialize a Command object.
1876
2117
  *
@@ -1878,35 +2119,22 @@ declare class Command {
1878
2119
  */
1879
2120
  constructor(session: Session);
1880
2121
  /**
1881
- * Helper method to call MCP tools and handle common response processing
2122
+ * Sanitizes error messages to remove sensitive information like API keys.
1882
2123
  *
1883
- * @param toolName - Name of the MCP tool to call
1884
- * @param args - Arguments to pass to the tool
1885
- * @param defaultErrorMsg - Default error message if specific error details are not available
1886
- * @returns A CallMcpToolResult with the response data
1887
- * @throws APIError if the call fails
2124
+ * @param error - The error to sanitize
2125
+ * @returns The sanitized error
1888
2126
  */
1889
- private callMcpTool;
2127
+ private sanitizeError;
1890
2128
  /**
1891
- * Execute a command in the cloud environment with a specified timeout.
2129
+ * Execute a command in the session environment.
1892
2130
  * Corresponds to Python's execute_command() method
1893
2131
  *
1894
- * @param command - The command to execute.
1895
- * @param timeoutMs - The timeout for the command execution in milliseconds. Default is 1000ms.
2132
+ * @param command - The command to execute
2133
+ * @param timeoutMs - The timeout in milliseconds. Default is 1000ms.
1896
2134
  * @returns CommandResult with command output and requestId
2135
+ * @throws APIError if the operation fails.
1897
2136
  */
1898
2137
  executeCommand(command: string, timeoutMs?: number): Promise<CommandResult>;
1899
- /**
1900
- * Execute code in the specified language with a timeout.
1901
- * Corresponds to Python's run_code() method
1902
- *
1903
- * @param code - The code to execute.
1904
- * @param language - The programming language of the code. Must be either 'python' or 'javascript'.
1905
- * @param timeoutS - The timeout for the code execution in seconds. Default is 300s.
1906
- * @returns CodeExecutionResult with code execution output and requestId
1907
- * @throws Error if an unsupported language is specified.
1908
- */
1909
- runCode(code: string, language: string, timeoutS?: number): Promise<CodeExecutionResult>;
1910
2138
  }
1911
2139
 
1912
2140
  interface ContextStatusData {
@@ -1968,24 +2196,21 @@ interface DirectoryEntry {
1968
2196
  */
1969
2197
  declare class FileSystem {
1970
2198
  private session;
1971
- private client;
1972
- private baseUrl;
1973
2199
  /**
1974
2200
  * Initialize a FileSystem object.
1975
2201
  *
1976
2202
  * @param session - The Session instance that this FileSystem belongs to.
1977
2203
  */
1978
- constructor(session: Session);
1979
- /**
1980
- * Helper method to call MCP tools and handle common response processing
1981
- *
1982
- * @param toolName - Name of the MCP tool to call
1983
- * @param args - Arguments to pass to the tool
1984
- * @param defaultErrorMsg - Default error message if specific error details are not available
1985
- * @returns A CallMcpToolResult with the response data
1986
- * @throws APIError if the call fails
1987
- */
1988
- private callMcpTool;
2204
+ constructor(session: {
2205
+ getAPIKey(): string;
2206
+ getSessionId(): string;
2207
+ callMcpTool(toolName: string, args: any): Promise<{
2208
+ success: boolean;
2209
+ data: string;
2210
+ errorMessage: string;
2211
+ requestId: string;
2212
+ }>;
2213
+ });
1989
2214
  /**
1990
2215
  * Creates a new directory at the specified path.
1991
2216
  * Corresponds to Python's create_directory() method
@@ -2037,8 +2262,8 @@ declare class FileSystem {
2037
2262
  * Corresponds to Python's read_file() method
2038
2263
  *
2039
2264
  * @param path - Path to the file to read.
2040
- * @param offset - Optional: Line offset to start reading from.
2041
- * @param length - Optional: Number of lines to read. If 0, reads the entire file.
2265
+ * @param offset - Optional: Byte offset to start reading from (0-based).
2266
+ * @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
2042
2267
  * @returns FileContentResult with file content and requestId
2043
2268
  */
2044
2269
  readFile(path: string, offset?: number, length?: number): Promise<FileContentResult>;
@@ -2092,12 +2317,10 @@ declare class FileSystem {
2092
2317
  }
2093
2318
 
2094
2319
  /**
2095
- * Handles Object Storage Service operations in the AgentBay cloud environment.
2320
+ * Handles OSS operations in the AgentBay cloud environment.
2096
2321
  */
2097
2322
  declare class Oss {
2098
2323
  private session;
2099
- private client;
2100
- private baseUrl;
2101
2324
  /**
2102
2325
  * Initialize an Oss object.
2103
2326
  *
@@ -2105,67 +2328,80 @@ declare class Oss {
2105
2328
  */
2106
2329
  constructor(session: Session);
2107
2330
  /**
2108
- * Helper method to call MCP tools and handle common response processing
2331
+ * Sanitizes error messages to remove sensitive information like API keys.
2109
2332
  *
2110
- * @param toolName - Name of the MCP tool to call
2111
- * @param args - Arguments to pass to the tool
2112
- * @param defaultErrorMsg - Default error message if specific error details are not available
2113
- * @returns A CallMcpToolResult with the response data
2114
- * @throws APIError if the call fails
2333
+ * @param error - The error to sanitize
2334
+ * @returns The sanitized error
2115
2335
  */
2116
- private callMcpTool;
2336
+ private sanitizeError;
2117
2337
  /**
2118
2338
  * Initialize OSS environment variables with the specified credentials.
2119
2339
  * Corresponds to Python's env_init() method
2120
2340
  *
2121
- * @param accessKeyId - The Access Key ID for OSS authentication.
2122
- * @param accessKeySecret - The Access Key Secret for OSS authentication.
2123
- * @param securityToken - The security token for OSS authentication.
2124
- * @param endpoint - The OSS service endpoint. If not specified, the default is used.
2125
- * @param region - The OSS region. If not specified, the default is used.
2126
- * @returns OSSClientResult with initialization result and requestId
2341
+ * @param accessKeyId - The access key ID
2342
+ * @param accessKeySecret - The access key secret
2343
+ * @param securityToken - The security token (optional)
2344
+ * @param endpoint - The OSS endpoint (optional)
2345
+ * @param region - The OSS region (optional)
2346
+ * @returns OSSClientResult with client configuration and requestId
2347
+ * @throws APIError if the operation fails.
2127
2348
  */
2128
2349
  envInit(accessKeyId: string, accessKeySecret: string, securityToken?: string, endpoint?: string, region?: string): Promise<OSSClientResult>;
2129
2350
  /**
2130
- * Upload a local file or directory to OSS.
2351
+ * Upload a file to OSS.
2131
2352
  * Corresponds to Python's upload() method
2132
2353
  *
2133
- * @param bucket - OSS bucket name.
2134
- * @param object - ObjectS.
2135
- * @param path - Local file or directory path to upload.
2354
+ * @param bucket - The OSS bucket name
2355
+ * @param object - The OSS object key
2356
+ * @param path - The local file path to upload
2136
2357
  * @returns OSSUploadResult with upload result and requestId
2358
+ * @throws APIError if the operation fails.
2137
2359
  */
2138
2360
  upload(bucket: string, object: string, path: string): Promise<OSSUploadResult>;
2139
2361
  /**
2140
- * Upload a local file or directory to OSS using a pre-signed URL.
2362
+ * Upload a file to OSS using an anonymous URL.
2141
2363
  * Corresponds to Python's upload_anonymous() method
2142
2364
  *
2143
- * @param url - Pre-signed URL for anonymous upload.
2144
- * @param path - Local file or directory path to upload.
2365
+ * @param url - The anonymous upload URL
2366
+ * @param path - The local file path to upload
2145
2367
  * @returns OSSUploadResult with upload result and requestId
2368
+ * @throws APIError if the operation fails.
2146
2369
  */
2147
2370
  uploadAnonymous(url: string, path: string): Promise<OSSUploadResult>;
2148
2371
  /**
2149
- * Download an object from OSS to a local file or directory.
2372
+ * Download a file from OSS.
2150
2373
  * Corresponds to Python's download() method
2151
2374
  *
2152
- * @param bucket - OSS bucket name.
2153
- * @param object - Object key in OSS.
2154
- * @param path - Local file or directory path to save the downloaded content.
2375
+ * @param bucket - The OSS bucket name
2376
+ * @param object - The OSS object key
2377
+ * @param path - The local file path to save the downloaded file
2155
2378
  * @returns OSSDownloadResult with download result and requestId
2379
+ * @throws APIError if the operation fails.
2156
2380
  */
2157
2381
  download(bucket: string, object: string, path: string): Promise<OSSDownloadResult>;
2158
2382
  /**
2159
- * Download an object from OSS using a pre-signed URL.
2383
+ * Download a file from OSS using an anonymous URL.
2160
2384
  * Corresponds to Python's download_anonymous() method
2161
2385
  *
2162
- * @param url - Pre-signed URL for anonymous download.
2163
- * @param path - Local file or directory path to save the downloaded content.
2386
+ * @param url - The anonymous download URL
2387
+ * @param path - The local file path to save the downloaded file
2164
2388
  * @returns OSSDownloadResult with download result and requestId
2389
+ * @throws APIError if the operation fails.
2165
2390
  */
2166
2391
  downloadAnonymous(url: string, path: string): Promise<OSSDownloadResult>;
2167
2392
  }
2168
2393
 
2394
+ /**
2395
+ * Key codes for UI operations
2396
+ */
2397
+ declare enum KeyCode {
2398
+ HOME = 3,
2399
+ BACK = 4,
2400
+ VOLUME_UP = 24,
2401
+ VOLUME_DOWN = 25,
2402
+ POWER = 26,
2403
+ MENU = 82
2404
+ }
2169
2405
  /**
2170
2406
  * Interface representing a UI element in the UI hierarchy
2171
2407
  */
@@ -2180,18 +2416,7 @@ interface UIElement {
2180
2416
  children?: UIElement[];
2181
2417
  }
2182
2418
  /**
2183
- * KeyCode constants for mobile device input
2184
- */
2185
- declare const KeyCode: {
2186
- HOME: number;
2187
- BACK: number;
2188
- VOLUME_UP: number;
2189
- VOLUME_DOWN: number;
2190
- POWER: number;
2191
- MENU: number;
2192
- };
2193
- /**
2194
- * UI handles UI operations in the AgentBay cloud environment.
2419
+ * Handles UI operations in the AgentBay cloud environment.
2195
2420
  */
2196
2421
  declare class UI {
2197
2422
  private session;
@@ -2200,76 +2425,96 @@ declare class UI {
2200
2425
  *
2201
2426
  * @param session - The Session instance that this UI belongs to.
2202
2427
  */
2203
- constructor(session: Session);
2428
+ constructor(session: {
2429
+ getAPIKey(): string;
2430
+ getClient(): any;
2431
+ getSessionId(): string;
2432
+ callMcpTool(toolName: string, args: any): Promise<{
2433
+ success: boolean;
2434
+ data: string;
2435
+ errorMessage: string;
2436
+ requestId: string;
2437
+ }>;
2438
+ });
2204
2439
  /**
2205
- * Helper method to call MCP tools and handle common response processing
2440
+ * Sanitizes error messages to remove sensitive information like API keys.
2206
2441
  *
2207
- * @param toolName - Name of the MCP tool to call
2208
- * @param args - Arguments to pass to the tool
2209
- * @param defaultErrorMsg - Default error message if specific error details are not available
2210
- * @returns A CallMcpToolResult with the response data
2211
- * @throws APIError if the call fails
2442
+ * @param error - The error to sanitize
2443
+ * @returns The sanitized error
2212
2444
  */
2213
- private callMcpTool;
2445
+ private sanitizeError;
2214
2446
  /**
2215
2447
  * Retrieves all clickable UI elements within the specified timeout.
2216
2448
  * Corresponds to Python's get_clickable_ui_elements() method
2217
2449
  *
2218
2450
  * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
2219
2451
  * @returns UIElementListResult with clickable UI elements and requestId
2452
+ * @throws APIError if the operation fails.
2220
2453
  */
2221
2454
  getClickableUIElements(timeoutMs?: number): Promise<UIElementListResult>;
2222
2455
  /**
2223
- * Retrieves all UI elements within the specified timeout.
2456
+ * Retrieves all UI elements regardless of their clickable status.
2224
2457
  * Corresponds to Python's get_all_ui_elements() method
2225
2458
  *
2226
2459
  * @param timeoutMs - The timeout in milliseconds. Default is 2000ms.
2227
2460
  * @returns UIElementListResult with all UI elements and requestId
2461
+ * @throws APIError if the operation fails.
2228
2462
  */
2229
2463
  getAllUIElements(timeoutMs?: number): Promise<UIElementListResult>;
2230
2464
  /**
2231
2465
  * Sends a key press event.
2232
2466
  * Corresponds to Python's send_key() method
2233
2467
  *
2234
- * @param key - The key code to send.
2235
- * @returns BoolResult with key press result and requestId
2468
+ * @param key - The key code to send. Supported key codes are:
2469
+ * - 3 : HOME
2470
+ * - 4 : BACK
2471
+ * - 24 : VOLUME UP
2472
+ * - 25 : VOLUME DOWN
2473
+ * - 26 : POWER
2474
+ * - 82 : MENU
2475
+ * @returns BoolResult with success status and requestId
2476
+ * @throws APIError if the operation fails.
2236
2477
  */
2237
2478
  sendKey(key: number): Promise<BoolResult>;
2238
2479
  /**
2239
- * Inputs text into the active field.
2480
+ * Inputs text into the currently focused UI element.
2240
2481
  * Corresponds to Python's input_text() method
2241
2482
  *
2242
- * @param text - The text to input.
2243
- * @returns BoolResult with input result and requestId
2483
+ * @param text - The text to input
2484
+ * @returns BoolResult with success status and requestId
2485
+ * @throws APIError if the operation fails.
2244
2486
  */
2245
2487
  inputText(text: string): Promise<BoolResult>;
2246
2488
  /**
2247
2489
  * Performs a swipe gesture on the screen.
2248
2490
  * Corresponds to Python's swipe() method
2249
2491
  *
2250
- * @param startX - The starting X coordinate.
2251
- * @param startY - The starting Y coordinate.
2252
- * @param endX - The ending X coordinate.
2253
- * @param endY - The ending Y coordinate.
2492
+ * @param startX - The starting X coordinate
2493
+ * @param startY - The starting Y coordinate
2494
+ * @param endX - The ending X coordinate
2495
+ * @param endY - The ending Y coordinate
2254
2496
  * @param durationMs - The duration of the swipe in milliseconds. Default is 300ms.
2255
- * @returns BoolResult with swipe result and requestId
2497
+ * @returns BoolResult with success status and requestId
2498
+ * @throws APIError if the operation fails.
2256
2499
  */
2257
2500
  swipe(startX: number, startY: number, endX: number, endY: number, durationMs?: number): Promise<BoolResult>;
2258
2501
  /**
2259
- * Performs a click at the specified coordinates.
2502
+ * Clicks on the screen at the specified coordinates.
2260
2503
  * Corresponds to Python's click() method
2261
2504
  *
2262
- * @param x - The X coordinate.
2263
- * @param y - The Y coordinate.
2264
- * @param button - The mouse button to click. Default is 'left'.
2265
- * @returns BoolResult with click result and requestId
2505
+ * @param x - The X coordinate
2506
+ * @param y - The Y coordinate
2507
+ * @param button - The mouse button to use. Default is 'left'
2508
+ * @returns BoolResult with success status and requestId
2509
+ * @throws APIError if the operation fails.
2266
2510
  */
2267
2511
  click(x: number, y: number, button?: string): Promise<BoolResult>;
2268
2512
  /**
2269
2513
  * Takes a screenshot of the current screen.
2270
2514
  * Corresponds to Python's screenshot() method
2271
2515
  *
2272
- * @returns OperationResult with screenshot data and requestId
2516
+ * @returns OperationResult with success status and requestId
2517
+ * @throws APIError if the operation fails.
2273
2518
  */
2274
2519
  screenshot(): Promise<OperationResult>;
2275
2520
  }
@@ -2285,19 +2530,14 @@ declare class WindowManager {
2285
2530
  */
2286
2531
  constructor(session: {
2287
2532
  getAPIKey(): string;
2288
- getClient(): any;
2289
2533
  getSessionId(): string;
2534
+ callMcpTool(toolName: string, args: any): Promise<{
2535
+ success: boolean;
2536
+ data: string;
2537
+ errorMessage: string;
2538
+ requestId: string;
2539
+ }>;
2290
2540
  });
2291
- /**
2292
- * Helper method to call MCP tools and handle common response processing
2293
- *
2294
- * @param toolName - Name of the MCP tool to call
2295
- * @param args - Arguments to pass to the tool
2296
- * @param defaultErrorMsg - Default error message if specific error details are not available
2297
- * @returns A CallMcpToolResult with the response data
2298
- * @throws APIError if the call fails
2299
- */
2300
- private callMcpTool;
2301
2541
  /**
2302
2542
  * Helper method to parse JSON string into Window objects
2303
2543
  * @param jsonStr - JSON string to parse
@@ -2388,6 +2628,124 @@ declare class WindowManager {
2388
2628
  focusMode(on: boolean): Promise<BoolResult>;
2389
2629
  }
2390
2630
 
2631
+ interface ActOptions {
2632
+ action: string;
2633
+ timeoutMS?: number;
2634
+ iframes?: boolean;
2635
+ domSettleTimeoutMS?: number;
2636
+ }
2637
+ interface ObserveOptions {
2638
+ instruction: string;
2639
+ returnActions?: number;
2640
+ iframes?: boolean;
2641
+ domSettleTimeoutMS?: number;
2642
+ }
2643
+ interface ExtractOptions<T = any> {
2644
+ instruction: string;
2645
+ schema: new (...args: any[]) => T;
2646
+ selector?: string;
2647
+ iframe?: boolean;
2648
+ domSettleTimeoutsMS?: number;
2649
+ }
2650
+ declare class ActResult {
2651
+ success: boolean;
2652
+ message: string;
2653
+ action: string;
2654
+ constructor(success: boolean, message: string, action: string);
2655
+ }
2656
+ declare class ObserveResult {
2657
+ selector: string;
2658
+ description: string;
2659
+ method: string;
2660
+ args: Record<string, any>;
2661
+ constructor(selector: string, description: string, method: string, args: Record<string, any>);
2662
+ }
2663
+ declare class BrowserAgent {
2664
+ private session;
2665
+ private browser;
2666
+ constructor(session: Session, browser: Browser);
2667
+ /**
2668
+ * Perform an action on the given Playwright Page object, using ActOptions to configure behavior.
2669
+ * Returns the result of the action.
2670
+ */
2671
+ act(page: any, options: ActOptions): Promise<ActResult>;
2672
+ /**
2673
+ * Async version of act method for performing actions on the given Playwright Page object.
2674
+ */
2675
+ actAsync(page: any, options: ActOptions): Promise<ActResult>;
2676
+ /**
2677
+ * Observe elements or state on the given Playwright Page object.
2678
+ * Returns a tuple containing (success, results).
2679
+ */
2680
+ observe(page: any, options: ObserveOptions): Promise<[boolean, ObserveResult[]]>;
2681
+ /**
2682
+ * Async version of observe method.
2683
+ */
2684
+ observeAsync(page: any, options: ObserveOptions): Promise<[boolean, ObserveResult[]]>;
2685
+ /**
2686
+ * Extract information from the given Playwright Page object.
2687
+ */
2688
+ extract<T>(page: any, options: ExtractOptions<T>): Promise<[boolean, T[]]>;
2689
+ /**
2690
+ * Async version of extract method.
2691
+ */
2692
+ extractAsync<T>(page: any, options: ExtractOptions<T>): Promise<[boolean, T[]]>;
2693
+ private _getPageAndContextIndex;
2694
+ private _getPageAndContextIndexAsync;
2695
+ private _callMcpTool;
2696
+ }
2697
+
2698
+ interface BrowserOption {
2699
+ persistentPath?: string;
2700
+ }
2701
+ declare class Browser {
2702
+ private session;
2703
+ private _endpointUrl;
2704
+ private _initialized;
2705
+ private _option;
2706
+ agent: BrowserAgent;
2707
+ constructor(session: Session);
2708
+ /**
2709
+ * Initialize the browser instance with the given options.
2710
+ * Returns true if successful, false otherwise.
2711
+ */
2712
+ initialize(option: BrowserOption): boolean;
2713
+ /**
2714
+ * Initialize the browser instance with the given options asynchronously.
2715
+ * Returns true if successful, false otherwise.
2716
+ */
2717
+ initializeAsync(option: BrowserOption): Promise<boolean>;
2718
+ /**
2719
+ * Returns the endpoint URL if the browser is initialized, otherwise throws an exception.
2720
+ * When initialized, always fetches the latest CDP url from session.getLink().
2721
+ */
2722
+ getEndpointUrl(): Promise<string>;
2723
+ /**
2724
+ * Returns the current BrowserOption used to initialize the browser, or null if not set.
2725
+ */
2726
+ getOption(): BrowserOption | null;
2727
+ /**
2728
+ * Returns true if the browser was initialized, false otherwise.
2729
+ */
2730
+ isInitialized(): boolean;
2731
+ }
2732
+
2733
+ /**
2734
+ * Represents an MCP tool with complete information.
2735
+ */
2736
+ interface McpTool {
2737
+ name: string;
2738
+ description: string;
2739
+ inputSchema: Record<string, any>;
2740
+ server: string;
2741
+ tool: string;
2742
+ }
2743
+ /**
2744
+ * Result containing MCP tools list and request ID.
2745
+ */
2746
+ interface McpToolsResult extends OperationResult {
2747
+ tools: McpTool[];
2748
+ }
2391
2749
  /**
2392
2750
  * Represents a session in the AgentBay cloud environment.
2393
2751
  */
@@ -2395,13 +2753,20 @@ declare class Session {
2395
2753
  private agentBay;
2396
2754
  sessionId: string;
2397
2755
  resourceUrl: string;
2756
+ isVpc: boolean;
2757
+ networkInterfaceIp: string;
2758
+ httpPort: string;
2398
2759
  fileSystem: FileSystem;
2399
2760
  command: Command;
2761
+ code: Code;
2400
2762
  oss: Oss;
2401
2763
  application: Application;
2402
2764
  window: WindowManager;
2403
2765
  ui: UI;
2766
+ agent: Agent;
2767
+ browser: Browser;
2404
2768
  context: ContextManager;
2769
+ mcpTools: McpTool[];
2405
2770
  /**
2406
2771
  * Initialize a Session object.
2407
2772
  *
@@ -2421,6 +2786,22 @@ declare class Session {
2421
2786
  * Return the session_id for this session.
2422
2787
  */
2423
2788
  getSessionId(): string;
2789
+ /**
2790
+ * Return whether this session uses VPC resources.
2791
+ */
2792
+ isVpcEnabled(): boolean;
2793
+ /**
2794
+ * Return the network interface IP for VPC sessions.
2795
+ */
2796
+ getNetworkInterfaceIp(): string;
2797
+ /**
2798
+ * Return the HTTP port for VPC sessions.
2799
+ */
2800
+ getHttpPort(): string;
2801
+ /**
2802
+ * Find the server that provides the given tool.
2803
+ */
2804
+ findServerForTool(toolName: string): string;
2424
2805
  /**
2425
2806
  * Delete this session.
2426
2807
  *
@@ -2428,6 +2809,13 @@ declare class Session {
2428
2809
  * @returns DeleteResult indicating success or failure and request ID
2429
2810
  */
2430
2811
  delete(syncContext?: boolean): Promise<DeleteResult>;
2812
+ /**
2813
+ * Validates labels parameter for label operations.
2814
+ *
2815
+ * @param labels - The labels to validate
2816
+ * @returns null if validation passes, or OperationResult with error if validation fails
2817
+ */
2818
+ private validateLabels;
2431
2819
  /**
2432
2820
  * Sets the labels for this session.
2433
2821
  *
@@ -2468,7 +2856,140 @@ declare class Session {
2468
2856
  * @throws Error if the operation fails (matching Python SessionError)
2469
2857
  */
2470
2858
  getLinkAsync(protocolType?: string, port?: number): Promise<OperationResult>;
2859
+ /**
2860
+ * List MCP tools available for this session.
2861
+ *
2862
+ * @param imageId Optional image ID, defaults to session's imageId or "linux_latest"
2863
+ * @returns McpToolsResult containing tools list and request ID
2864
+ */
2865
+ listMcpTools(imageId?: string): Promise<McpToolsResult>;
2866
+ /**
2867
+ * Call an MCP tool and return the result in a format compatible with Agent.
2868
+ *
2869
+ * @param toolName - Name of the MCP tool to call
2870
+ * @param args - Arguments to pass to the tool
2871
+ * @returns McpToolResult containing the response data
2872
+ */
2873
+ callMcpTool(toolName: string, args: any): Promise<McpToolResult>;
2874
+ }
2875
+
2876
+ /**
2877
+ * Browser context configuration for session.
2878
+ */
2879
+ interface BrowserContext {
2880
+ /** ID of the browser context to bind to the session */
2881
+ contextId: string;
2882
+ /** Whether to automatically upload browser data when the session ends */
2883
+ autoUpload: boolean;
2884
+ }
2885
+ /**
2886
+ * Configuration interface for CreateSessionParams
2887
+ */
2888
+ interface CreateSessionParamsConfig {
2889
+ labels: Record<string, string>;
2890
+ /**
2891
+ * @deprecated This field is deprecated and will be removed in a future version.
2892
+ * Please use contextSync instead for more flexible and powerful data persistence.
2893
+ */
2894
+ contextId?: string;
2895
+ imageId?: string;
2896
+ contextSync: ContextSync[];
2897
+ /** Optional configuration for browser data synchronization */
2898
+ browserContext?: BrowserContext;
2899
+ /** Whether to create a VPC-based session. Defaults to false. */
2900
+ isVpc?: boolean;
2901
+ }
2902
+ /**
2903
+ * CreateSessionParams provides a way to configure the parameters for creating a new session
2904
+ * in the AgentBay cloud environment.
2905
+ */
2906
+ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
2907
+ /** Custom labels for the Session. These can be used for organizing and filtering sessions. */
2908
+ labels: Record<string, string>;
2909
+ /**
2910
+ * ID of the context to bind to the session.
2911
+ * The context can include various types of persistence like file system (volume) and cookies.
2912
+ *
2913
+ * @deprecated This field is deprecated and will be removed in a future version.
2914
+ * Please use contextSync instead for more flexible and powerful data persistence.
2915
+ *
2916
+ * Important Limitations:
2917
+ * 1. One session at a time: A context can only be used by one session at a time.
2918
+ * If you try to create a session with a context ID that is already in use by another active session,
2919
+ * the session creation will fail.
2920
+ *
2921
+ * 2. OS binding: A context is bound to the operating system of the first session that uses it.
2922
+ * When a context is first used with a session, it becomes bound to that session's OS.
2923
+ * Any attempt to use the context with a session running on a different OS will fail.
2924
+ * For example, if a context is first used with a Linux session, it cannot later be used
2925
+ * with a Windows or Android session.
2926
+ */
2927
+ contextId?: string;
2928
+ /** Image ID to use for the session. */
2929
+ imageId?: string;
2930
+ /**
2931
+ * List of context synchronization configurations.
2932
+ * These configurations define how contexts should be synchronized and mounted.
2933
+ */
2934
+ contextSync: ContextSync[];
2935
+ /** Optional configuration for browser data synchronization. */
2936
+ browserContext?: BrowserContext;
2937
+ /** Whether to create a VPC-based session. Defaults to false. */
2938
+ isVpc: boolean;
2939
+ constructor();
2940
+ /**
2941
+ * WithLabels sets the labels for the session parameters and returns the updated parameters.
2942
+ */
2943
+ withLabels(labels: Record<string, string>): CreateSessionParams$1;
2944
+ /**
2945
+ * WithContextID sets the context ID for the session parameters and returns the updated parameters.
2946
+ */
2947
+ withContextID(contextId: string): CreateSessionParams$1;
2948
+ /**
2949
+ * WithImageId sets the image ID for the session parameters and returns the updated parameters.
2950
+ */
2951
+ withImageId(imageId: string): CreateSessionParams$1;
2952
+ /**
2953
+ * WithBrowserContext sets the browser context for the session parameters and returns the updated parameters.
2954
+ */
2955
+ withBrowserContext(browserContext: BrowserContext): CreateSessionParams$1;
2956
+ /**
2957
+ * WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
2958
+ */
2959
+ withIsVpc(isVpc: boolean): CreateSessionParams$1;
2960
+ /**
2961
+ * GetLabelsJSON returns the labels as a JSON string.
2962
+ * Returns an object with success status and result/error message to match Go version behavior.
2963
+ */
2964
+ getLabelsJSON(): {
2965
+ result: string;
2966
+ error?: string;
2967
+ };
2968
+ /**
2969
+ * AddContextSync adds a context sync configuration to the session parameters.
2970
+ */
2971
+ addContextSync(contextId: string, path: string, policy?: SyncPolicy): CreateSessionParams$1;
2972
+ /**
2973
+ * AddContextSyncConfig adds a pre-configured context sync to the session parameters.
2974
+ */
2975
+ addContextSyncConfig(contextSync: ContextSync): CreateSessionParams$1;
2976
+ /**
2977
+ * WithContextSync sets the context sync configurations for the session parameters.
2978
+ */
2979
+ withContextSync(contextSyncs: ContextSync[]): CreateSessionParams$1;
2980
+ /**
2981
+ * Convert to plain object for JSON serialization
2982
+ */
2983
+ toJSON(): CreateSessionParamsConfig;
2984
+ /**
2985
+ * Create from plain object
2986
+ */
2987
+ static fromJSON(config: CreateSessionParamsConfig): CreateSessionParams$1;
2471
2988
  }
2989
+ /**
2990
+ * NewCreateSessionParams creates a new CreateSessionParams with default values.
2991
+ */
2992
+ declare function newCreateSessionParams(): CreateSessionParams$1;
2472
2993
 
2473
2994
  /**
2474
2995
  * Parameters for listing sessions with pagination support
@@ -2499,11 +3020,13 @@ interface SessionListResult extends ApiResponse {
2499
3020
  /**
2500
3021
  * Parameters for creating a session.
2501
3022
  */
2502
- interface CreateSessionParams$1 {
3023
+ interface CreateSessionParams {
2503
3024
  contextId?: string;
2504
3025
  labels?: Record<string, string>;
2505
3026
  imageId?: string;
2506
3027
  contextSync?: ContextSync[];
3028
+ browserContext?: BrowserContext;
3029
+ isVpc?: boolean;
2507
3030
  }
2508
3031
  /**
2509
3032
  * Main class for interacting with the AgentBay cloud runtime environment.
@@ -2535,7 +3058,7 @@ declare class AgentBay {
2535
3058
  * @param params - Optional parameters for creating the session
2536
3059
  * @returns SessionResult containing the created session and request ID
2537
3060
  */
2538
- create(params?: CreateSessionParams$1): Promise<SessionResult>;
3061
+ create(params?: CreateSessionParams): Promise<SessionResult>;
2539
3062
  /**
2540
3063
  * List all available sessions.
2541
3064
  *
@@ -2625,99 +3148,12 @@ declare class ApplicationError extends AgentBayError {
2625
3148
  declare class UIError extends AgentBayError {
2626
3149
  constructor(message?: string, extra?: Record<string, any>);
2627
3150
  }
2628
-
2629
3151
  /**
2630
- * Configuration interface for CreateSessionParams
3152
+ * Raised for errors related to browser operations.
2631
3153
  */
2632
- interface CreateSessionParamsConfig {
2633
- labels: Record<string, string>;
2634
- /**
2635
- * @deprecated This field is deprecated and will be removed in a future version.
2636
- * Please use contextSync instead for more flexible and powerful data persistence.
2637
- */
2638
- contextId?: string;
2639
- imageId?: string;
2640
- contextSync: ContextSync[];
2641
- }
2642
- /**
2643
- * CreateSessionParams provides a way to configure the parameters for creating a new session
2644
- * in the AgentBay cloud environment.
2645
- */
2646
- declare class CreateSessionParams implements CreateSessionParamsConfig {
2647
- /** Custom labels for the Session. These can be used for organizing and filtering sessions. */
2648
- labels: Record<string, string>;
2649
- /**
2650
- * ID of the context to bind to the session.
2651
- * The context can include various types of persistence like file system (volume) and cookies.
2652
- *
2653
- * @deprecated This field is deprecated and will be removed in a future version.
2654
- * Please use contextSync instead for more flexible and powerful data persistence.
2655
- *
2656
- * Important Limitations:
2657
- * 1. One session at a time: A context can only be used by one session at a time.
2658
- * If you try to create a session with a context ID that is already in use by another active session,
2659
- * the session creation will fail.
2660
- *
2661
- * 2. OS binding: A context is bound to the operating system of the first session that uses it.
2662
- * When a context is first used with a session, it becomes bound to that session's OS.
2663
- * Any attempt to use the context with a session running on a different OS will fail.
2664
- * For example, if a context is first used with a Linux session, it cannot later be used
2665
- * with a Windows or Android session.
2666
- */
2667
- contextId?: string;
2668
- /** Image ID to use for the session. */
2669
- imageId?: string;
2670
- /**
2671
- * List of context synchronization configurations.
2672
- * These configurations define how contexts should be synchronized and mounted.
2673
- */
2674
- contextSync: ContextSync[];
2675
- constructor();
2676
- /**
2677
- * WithLabels sets the labels for the session parameters and returns the updated parameters.
2678
- */
2679
- withLabels(labels: Record<string, string>): CreateSessionParams;
2680
- /**
2681
- * WithContextID sets the context ID for the session parameters and returns the updated parameters.
2682
- */
2683
- withContextID(contextId: string): CreateSessionParams;
2684
- /**
2685
- * WithImageId sets the image ID for the session parameters and returns the updated parameters.
2686
- */
2687
- withImageId(imageId: string): CreateSessionParams;
2688
- /**
2689
- * GetLabelsJSON returns the labels as a JSON string.
2690
- * Returns an object with success status and result/error message to match Go version behavior.
2691
- */
2692
- getLabelsJSON(): {
2693
- result: string;
2694
- error?: string;
2695
- };
2696
- /**
2697
- * AddContextSync adds a context sync configuration to the session parameters.
2698
- */
2699
- addContextSync(contextId: string, path: string, policy?: SyncPolicy): CreateSessionParams;
2700
- /**
2701
- * AddContextSyncConfig adds a pre-configured context sync to the session parameters.
2702
- */
2703
- addContextSyncConfig(contextSync: ContextSync): CreateSessionParams;
2704
- /**
2705
- * WithContextSync sets the context sync configurations for the session parameters.
2706
- */
2707
- withContextSync(contextSyncs: ContextSync[]): CreateSessionParams;
2708
- /**
2709
- * Convert to plain object for JSON serialization
2710
- */
2711
- toJSON(): CreateSessionParamsConfig;
2712
- /**
2713
- * Create from plain object
2714
- */
2715
- static fromJSON(config: CreateSessionParamsConfig): CreateSessionParams;
3154
+ declare class BrowserError extends AgentBayError {
3155
+ constructor(message?: string, extra?: Record<string, any>);
2716
3156
  }
2717
- /**
2718
- * NewCreateSessionParams creates a new CreateSessionParams with default values.
2719
- */
2720
- declare function newCreateSessionParams(): CreateSessionParams;
2721
3157
 
2722
3158
  /**
2723
3159
  * Utility functions for logging in a clean format
@@ -2735,4 +3171,4 @@ declare function log(message: string, ...args: any[]): void;
2735
3171
  */
2736
3172
  declare function logError(message: string, error?: any): void;
2737
3173
 
2738
- export { APIError, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, CallMcpToolRequest, CallMcpToolResponse, CallMcpToolResponseBody, Client, Command, CommandError, Context, type ContextInfoResult, ContextManager, ContextService, type ContextStatusData, type ContextStatusItem, ContextSync, type ContextSyncResult, CreateMcpSessionRequest, CreateMcpSessionRequestPersistenceDataList, CreateMcpSessionResponse, CreateMcpSessionResponseBody, CreateMcpSessionResponseBodyData, CreateMcpSessionShrinkRequest, type CreateSessionParams$1 as CreateSessionParams, type CreateSessionParamsConfig, DeleteContextRequest, DeleteContextResponse, DeleteContextResponseBody, type DeletePolicy, type DirectoryEntry, type DownloadPolicy, DownloadStrategy, FileError, type FileInfo, FileSystem, GetContextInfoRequest, GetContextInfoResponse, GetContextInfoResponseBody, GetContextInfoResponseBodyData, GetContextRequest, GetContextResponse, GetContextResponseBody, GetContextResponseBodyData, GetLabelRequest, GetLabelResponse, GetLabelResponseBody, GetLabelResponseBodyData, GetLinkRequest, GetLinkResponse, GetLinkResponseBody, GetLinkResponseBodyData, GetMcpResourceRequest, GetMcpResourceResponse, GetMcpResourceResponseBody, GetMcpResourceResponseBodyData, GetMcpResourceResponseBodyDataDesktopInfo, type InstalledApp, KeyCode, ListContextsRequest, ListContextsResponse, ListContextsResponseBody, ListContextsResponseBodyData, ListMcpToolsRequest, ListMcpToolsResponse, ListMcpToolsResponseBody, type ListSessionParams, ListSessionRequest, ListSessionResponse, ListSessionResponseBody, ListSessionResponseBodyData, ModifyContextRequest, ModifyContextResponse, ModifyContextResponseBody, Oss, OssError, type Process, ReleaseMcpSessionRequest, ReleaseMcpSessionResponse, ReleaseMcpSessionResponseBody, Session, SessionError, type SessionInterface, SetLabelRequest, SetLabelResponse, SetLabelResponseBody, SyncContextRequest, SyncContextResponse, SyncContextResponseBody, type SyncPolicy, UI, type UIElement, UIError, type UploadPolicy, UploadStrategy, type WhiteList, log, logError, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newSyncPolicy, newUploadPolicy };
3174
+ export { APIError, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, Browser, BrowserAgent, type BrowserContext, BrowserError, type BrowserOption, CallMcpToolRequest, CallMcpToolResponse, CallMcpToolResponseBody, Client, Command, CommandError, Context, type ContextInfoResult, ContextManager, ContextService, type ContextStatusData, type ContextStatusItem, ContextSync, type ContextSyncResult, CreateMcpSessionRequest, CreateMcpSessionRequestPersistenceDataList, CreateMcpSessionResponse, CreateMcpSessionResponseBody, CreateMcpSessionResponseBodyData, CreateMcpSessionShrinkRequest, type CreateSessionParams, type CreateSessionParamsConfig, DeleteContextRequest, DeleteContextResponse, DeleteContextResponseBody, type DeletePolicy, type DirectoryEntry, type DownloadPolicy, DownloadStrategy, type ExecutionResult, type ExtractOptions, FileError, type FileInfo, FileSystem, 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, log, logError, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newSyncPolicy, newSyncPolicyWithDefaults, newUploadPolicy };