wuying-agentbay-sdk 0.11.0 → 0.13.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.
Files changed (56) hide show
  1. package/dist/{chunk-E7QC5S76.mjs → chunk-P2CXYF4T.mjs} +650 -154
  2. package/dist/chunk-P2CXYF4T.mjs.map +1 -0
  3. package/dist/{chunk-ZUB35HKV.cjs → chunk-WVWGLZDT.cjs} +593 -97
  4. package/dist/chunk-WVWGLZDT.cjs.map +1 -0
  5. package/dist/index.cjs +7702 -687
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.mts +2660 -1619
  8. package/dist/index.d.ts +2660 -1619
  9. package/dist/index.mjs +7514 -499
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/{model-ZFTLKEMC.mjs → model-BRLR6F3P.mjs} +28 -2
  12. package/dist/model-KJHN3WYY.cjs +214 -0
  13. package/dist/{model-2G37RFQQ.cjs.map → model-KJHN3WYY.cjs.map} +1 -1
  14. package/docs/api/README.md +6 -0
  15. package/docs/api/browser-use/browser-agent.md +188 -0
  16. package/docs/api/browser-use/browser.md +1 -1
  17. package/docs/api/browser-use/fingerprint.md +154 -0
  18. package/docs/api/codespace/code.md +3 -0
  19. package/docs/api/common-features/advanced/agent.md +7 -63
  20. package/docs/api/common-features/advanced/browser-use-agent.md +118 -0
  21. package/docs/api/common-features/advanced/computer-use-agent.md +85 -0
  22. package/docs/api/common-features/basics/agentbay.md +99 -2
  23. package/docs/api/common-features/basics/command.md +35 -18
  24. package/docs/api/common-features/basics/context-manager.md +21 -2
  25. package/docs/api/common-features/basics/filesystem.md +36 -0
  26. package/docs/api/common-features/basics/session-params.md +382 -0
  27. package/docs/api/common-features/basics/session.md +130 -2
  28. package/docs/api/computer-use/computer.md +25 -25
  29. package/docs/api/mobile-use/mobile-simulate.md +135 -0
  30. package/docs/examples/browser-use/browser/basic-usage.ts +31 -24
  31. package/docs/examples/browser-use/browser/browser-type-example.ts +3 -4
  32. package/docs/examples/browser-use/browser/captcha_tongcheng.ts +60 -28
  33. package/docs/examples/browser-use/browser/run-2048.ts +47 -37
  34. package/docs/examples/browser-use/browser/run-sudoku.ts +55 -36
  35. package/docs/examples/browser-use/browser/screenshot-example.ts +6 -6
  36. package/docs/examples/codespace/enhanced_code/index.ts +86 -0
  37. package/docs/examples/common-features/advanced/agent-module-example.ts +1 -1
  38. package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +1 -1
  39. package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +5 -6
  40. package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +1 -1
  41. package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +1 -1
  42. package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +13 -0
  43. package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +6 -7
  44. package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +1 -1
  45. package/docs/examples/common-features/basics/session-pause-resume/README.md +53 -0
  46. package/docs/examples/common-features/basics/session-pause-resume/session-pause-resume.ts +237 -0
  47. package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +1 -1
  48. package/docs/examples/mobile-use/mobile-simulate-basic-usage.ts +202 -0
  49. package/docs/examples/mobile-use/mobile-simulate-with-ctx.ts +170 -0
  50. package/package.json +5 -5
  51. package/dist/chunk-E7QC5S76.mjs.map +0 -1
  52. package/dist/chunk-ZUB35HKV.cjs.map +0 -1
  53. package/dist/model-2G37RFQQ.cjs +0 -188
  54. package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +0 -279
  55. package/docs/examples/mobile-use/mobile-get-adb-url/package.json +0 -18
  56. /package/dist/{model-ZFTLKEMC.mjs.map → model-BRLR6F3P.mjs.map} +0 -0
@@ -5,77 +5,21 @@
5
5
  - [Agent Modules Guide](../../../../../docs/guides/common-features/advanced/agent-modules.md) - Learn about agent modules and custom agents
6
6
 
7
7
  An Agent to manipulate applications to complete specific tasks.
8
+ According to the use scenary, The agent can a browser use agent which is
9
+ specialized for browser automation tasks, The agent also can be a computer
10
+ use agent which is specialized for multiple applications automation tasks.
8
11
 
9
12
  ## Table of contents
10
13
 
11
14
 
12
- ### Methods
15
+ ### Properties
13
16
 
14
- - [executeTask](#executetask)
15
- - [terminateTask](#terminatetask)
16
17
 
17
- ## Methods
18
-
19
- ### executeTask
20
-
21
- ▸ **executeTask**(`task`, `maxTryTimes`): `Promise`\<``ExecutionResult``\>
22
-
23
- Execute a specific task described in human language.
24
-
25
- #### Parameters
26
-
27
- | Name | Type | Description |
28
- | :------ | :------ | :------ |
29
- | `task` | `string` | Task description in human language. |
30
- | `maxTryTimes` | `number` | Maximum number of retry attempts. |
31
-
32
- #### Returns
33
-
34
- `Promise`\<``ExecutionResult``\>
35
-
36
- ExecutionResult containing success status, task output, and error message if any.
37
-
38
- **`Example`**
39
-
40
- ```typescript
41
- const agentBay = new AgentBay({ apiKey: 'your_api_key' });
42
- const result = await agentBay.create({ imageId: 'windows_latest' });
43
- if (result.success) {
44
- const taskResult = await result.session.agent.executeTask('Open notepad', 10);
45
- console.log(`Task status: ${taskResult.taskStatus}`);
46
- await result.session.delete();
47
- }
48
- ```
49
-
50
- ### terminateTask
51
-
52
- ▸ **terminateTask**(`taskId`): `Promise`\<``ExecutionResult``\>
53
-
54
- Terminate a task with a specified task ID.
55
-
56
- #### Parameters
57
-
58
- | Name | Type | Description |
59
- | :------ | :------ | :------ |
60
- | `taskId` | `string` | The ID of the running task. |
61
-
62
- #### Returns
63
-
64
- `Promise`\<``ExecutionResult``\>
65
-
66
- ExecutionResult containing success status, task output, and error message if any.
67
-
68
- **`Example`**
18
+ ## Properties
69
19
 
70
20
  ```typescript
71
- const agentBay = new AgentBay({ apiKey: 'your_api_key' });
72
- const result = await agentBay.create({ imageId: 'windows_latest' });
73
- if (result.success) {
74
- const taskResult = await result.session.agent.executeTask('Open notepad', 5);
75
- const terminateResult = await result.session.agent.terminateTask(taskResult.taskId);
76
- console.log(`Terminated: ${terminateResult.taskStatus}`);
77
- await result.session.delete();
78
- }
21
+ browser: [`BrowserUseAgent`](browser-use-agent.md)
22
+ computer: [`ComputerUseAgent`](computer-use-agent.md)
79
23
  ```
80
24
 
81
25
  ## Related Resources
@@ -0,0 +1,118 @@
1
+ # Class: BrowserUseAgent
2
+
3
+ ## Table of contents
4
+
5
+
6
+ ### Methods
7
+
8
+ - [executeTask](#executetask)
9
+ - [initialize](#initialize)
10
+ - [terminateTask](#terminatetask)
11
+
12
+ ## Methods
13
+
14
+ ### executeTask
15
+
16
+ ▸ **executeTask**(`task`, `maxTryTimes`): `Promise`\<``ExecutionResult``\>
17
+
18
+ Execute a specific task described in human language.
19
+
20
+ #### Parameters
21
+
22
+ | Name | Type | Description |
23
+ | :------ | :------ | :------ |
24
+ | `task` | `string` | Task description in human language. |
25
+ | `maxTryTimes` | `number` | Maximum number of retry attempts. |
26
+
27
+ #### Returns
28
+
29
+ `Promise`\<``ExecutionResult``\>
30
+
31
+ ExecutionResult containing success status, task output, and
32
+ error message if any.
33
+
34
+ **`Example`**
35
+
36
+ ```typescript
37
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
38
+ const result = await agentBay.create({ imageId: 'linux_latest' });
39
+ if (result.success) {
40
+ const taskResult = await result.session.agent.browser.executeTask(
41
+ 'Navigate to baidu and query the weather of Shanghai',
42
+ 10
43
+ );
44
+ console.log(`Task status: ${taskResult.taskStatus}`);
45
+ await result.session.delete();
46
+ }
47
+ ```
48
+
49
+ ### initialize
50
+
51
+ ▸ **initialize**(`options`): `Promise`\<``InitializationResult``\>
52
+
53
+ Initialize the browser agent with specific options.
54
+
55
+ #### Parameters
56
+
57
+ | Name | Type | Description |
58
+ | :------ | :------ | :------ |
59
+ | `options` | ``AgentOptions`` | agent initialization options |
60
+
61
+ #### Returns
62
+
63
+ `Promise`\<``InitializationResult``\>
64
+
65
+ InitializationResult containing success status, task output,
66
+ and error message if any.
67
+
68
+ **`Example`**
69
+
70
+ ```typescript
71
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
72
+ const result = await agentBay.create({ imageId: 'linux_latest' });
73
+ if (result.success) {
74
+ options:AgentOptions = new AgentOptions(use_vision=False,
75
+ output_schema=""); const initResult = await
76
+ result.session.agent.browser.initialize(options); console.log(`Initialize
77
+ success: ${initResult.success}`); await result.session.delete();
78
+ }
79
+ ```
80
+
81
+ ___
82
+
83
+ ### terminateTask
84
+
85
+ ▸ **terminateTask**(`taskId`): `Promise`\<``ExecutionResult``\>
86
+
87
+ Terminate a task with a specified task ID.
88
+
89
+ #### Parameters
90
+
91
+ | Name | Type | Description |
92
+ | :------ | :------ | :------ |
93
+ | `taskId` | `string` | The ID of the running task. |
94
+
95
+ #### Returns
96
+
97
+ `Promise`\<``ExecutionResult``\>
98
+
99
+ ExecutionResult containing success status, task output, and
100
+ error message if any.
101
+
102
+ **`Example`**
103
+
104
+ ```typescript
105
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
106
+ const result = await agentBay.create({ imageId: 'linux_latest' });
107
+ if (result.success) {
108
+ const taskResult = await result.session.agent.browser.executeTask(
109
+ 'Navigate to baidu and query the weather of Shanghai',
110
+ 10
111
+ );
112
+ const terminateResult = await result.session.agent.browser.terminateTask(
113
+ taskResult.taskId
114
+ );
115
+ console.log(`Terminated: ${terminateResult.taskStatus}`);
116
+ await result.session.delete();
117
+ }
118
+ ```
@@ -0,0 +1,85 @@
1
+ # Class: ComputerUseAgent
2
+
3
+ An Agent to perform tasks on the computer.
4
+
5
+ ## Table of contents
6
+
7
+
8
+ ### Methods
9
+
10
+ - [executeTask](#executetask)
11
+ - [terminateTask](#terminatetask)
12
+
13
+ ## Methods
14
+
15
+ ### executeTask
16
+
17
+ ▸ **executeTask**(`task`, `maxTryTimes`): `Promise`\<``ExecutionResult``\>
18
+
19
+ Execute a specific task described in human language.
20
+
21
+ #### Parameters
22
+
23
+ | Name | Type | Description |
24
+ | :------ | :------ | :------ |
25
+ | `task` | `string` | Task description in human language. |
26
+ | `maxTryTimes` | `number` | Maximum number of retry attempts. |
27
+
28
+ #### Returns
29
+
30
+ `Promise`\<``ExecutionResult``\>
31
+
32
+ ExecutionResult containing success status, task output, and error
33
+ message if any.
34
+
35
+ **`Example`**
36
+
37
+ ```typescript
38
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
39
+ const result = await agentBay.create({ imageId: 'windows_latest' });
40
+ if (result.success) {
41
+ const taskResult = await result.session.agent.computer.executeTask(
42
+ 'Open notepad',
43
+ 10
44
+ );
45
+ console.log(`Task status: ${taskResult.taskStatus}`);
46
+ await result.session.delete();
47
+ }
48
+ ```
49
+
50
+ ### terminateTask
51
+
52
+ ▸ **terminateTask**(`taskId`): `Promise`\<``ExecutionResult``\>
53
+
54
+ Terminate a task with a specified task ID.
55
+
56
+ #### Parameters
57
+
58
+ | Name | Type | Description |
59
+ | :------ | :------ | :------ |
60
+ | `taskId` | `string` | The ID of the running task. |
61
+
62
+ #### Returns
63
+
64
+ `Promise`\<``ExecutionResult``\>
65
+
66
+ ExecutionResult containing success status, task output, and
67
+ error message if any.
68
+
69
+ **`Example`**
70
+
71
+ ```typescript
72
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
73
+ const result = await agentBay.create({ imageId: 'windows_latest' });
74
+ if (result.success) {
75
+ const taskResult = await result.session.agent.computer.executeTask(
76
+ 'Open notepad',
77
+ 5
78
+ );
79
+ const terminateResult = await result.session.agent.computer.terminateTask(
80
+ taskResult.taskId
81
+ );
82
+ console.log(`Terminated: ${terminateResult.taskStatus}`);
83
+ await result.session.delete();
84
+ }
85
+ ```
@@ -18,10 +18,13 @@ Main class for interacting with the AgentBay cloud runtime environment.
18
18
  - [delete](#delete)
19
19
  - [get](#get)
20
20
  - [list](#list)
21
+ - [pauseAsync](#pauseasync)
22
+ - [resumeAsync](#resumeasync)
21
23
 
22
24
  ## Properties
23
25
 
24
26
  ```typescript
27
+ client: ``Client``
25
28
  context: [`ContextService`](context.md)
26
29
  ```
27
30
 
@@ -30,7 +33,7 @@ context: [`ContextService`](context.md)
30
33
 
31
34
  ### create
32
35
 
33
- ▸ **create**(`params?`): `Promise`\<`SessionResult`\>
36
+ ▸ **create**(`params`): `Promise`\<`SessionResult`\>
34
37
 
35
38
  Creates a new AgentBay session with specified configuration.
36
39
 
@@ -38,7 +41,7 @@ Creates a new AgentBay session with specified configuration.
38
41
 
39
42
  | Name | Type | Description |
40
43
  | :------ | :------ | :------ |
41
- | `params` | ``CreateSessionParams`` | Configuration parameters for the session: - labels: Key-value pairs for session metadata - imageId: Custom image ID for the session environment - contextSync: Array of context synchronization configurations - browserContext: Browser-specific context configuration - isVpc: Whether to create a VPC session - policyId: Security policy ID - enableBrowserReplay: Enable browser session recording - extraConfigs: Additional configuration options - framework: Framework identifier for tracking |
44
+ | `params` | [`CreateSessionParams`](session-params.md) \| `CreateSeesionWithParams` | Configuration parameters for the session: - labels: Key-value pairs for session metadata - imageId: Custom image ID for the session environment - contextSync: Array of context synchronization configurations - browserContext: Browser-specific context configuration - isVpc: Whether to create a VPC session - policyId: Security policy ID - enableBrowserReplay: Enable browser session recording - extraConfigs: Additional configuration options - framework: Framework identifier for tracking |
42
45
 
43
46
  #### Returns
44
47
 
@@ -174,6 +177,100 @@ if (result.success) {
174
177
  }
175
178
  ```
176
179
 
180
+ ___
181
+
182
+ ### pauseAsync
183
+
184
+ ▸ **pauseAsync**(`session`, `timeout?`, `pollInterval?`): `Promise`\<`SessionPauseResult`\>
185
+
186
+ Asynchronously pause a session, putting it into a dormant state.
187
+
188
+ This method directly calls the PauseSessionAsync API without waiting for the session
189
+ to reach the PAUSED state.
190
+
191
+ #### Parameters
192
+
193
+ | Name | Type | Default value | Description |
194
+ | :------ | :------ | :------ | :------ |
195
+ | `session` | [`Session`](session.md) | `undefined` | The session to pause. |
196
+ | `timeout` | `number` | `600` | Timeout in seconds to wait for the session to pause. Defaults to 600 seconds. |
197
+ | `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
198
+
199
+ #### Returns
200
+
201
+ `Promise`\<`SessionPauseResult`\>
202
+
203
+ SessionPauseResult indicating success or failure and request ID
204
+
205
+ **`Example`**
206
+
207
+ ```typescript
208
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
209
+ const session = (await agentBay.create()).session;
210
+ const pauseResult = await agentBay.pauseAsync(session);
211
+ await agentBay.resumeAsync(session);
212
+ await session.delete();
213
+ ```
214
+
215
+ **`Remarks`**
216
+
217
+ **Behavior:**
218
+ - This method does not wait for the session to reach the PAUSED state
219
+ - It only submits the pause request to the API
220
+ - The session state transitions from RUNNING -> PAUSING -> PAUSED
221
+ - Paused sessions consume fewer resources but maintain their state
222
+
223
+ **`See`**
224
+
225
+ [resumeAsync](#resumeasync), [Session.pauseAsync](session.md#pauseasync)
226
+
227
+ ___
228
+
229
+ ### resumeAsync
230
+
231
+ ▸ **resumeAsync**(`session`, `timeout?`, `pollInterval?`): `Promise`\<`SessionResumeResult`\>
232
+
233
+ Asynchronously resume a session from a paused state.
234
+
235
+ This method directly calls the ResumeSessionAsync API without waiting for the session
236
+ to reach the RUNNING state.
237
+
238
+ #### Parameters
239
+
240
+ | Name | Type | Default value | Description |
241
+ | :------ | :------ | :------ | :------ |
242
+ | `session` | [`Session`](session.md) | `undefined` | The session to resume. |
243
+ | `timeout` | `number` | `600` | Timeout in seconds to wait for the session to resume. Defaults to 600 seconds. |
244
+ | `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
245
+
246
+ #### Returns
247
+
248
+ `Promise`\<`SessionResumeResult`\>
249
+
250
+ SessionResumeResult indicating success or failure and request ID
251
+
252
+ **`Example`**
253
+
254
+ ```typescript
255
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
256
+ const session = (await agentBay.create()).session;
257
+ await agentBay.pauseAsync(session);
258
+ const resumeResult = await agentBay.resumeAsync(session);
259
+ await session.delete();
260
+ ```
261
+
262
+ **`Remarks`**
263
+
264
+ **Behavior:**
265
+ - This method does not wait for the session to reach the RUNNING state
266
+ - It only submits the resume request to the API
267
+ - The session state transitions from PAUSED -> RESUMING -> RUNNING
268
+ - Only sessions in PAUSED state can be resumed
269
+
270
+ **`See`**
271
+
272
+ [pauseAsync](#pauseasync), [Session.resumeAsync](session.md#resumeasync)
273
+
177
274
  ## Related Resources
178
275
 
179
276
  - [Session API Reference](session.md)
@@ -7,7 +7,7 @@
7
7
  ## Overview
8
8
 
9
9
  The Command module provides methods for executing shell commands within a session in the AgentBay cloud environment.
10
- It supports both synchronous command execution with configurable timeouts.
10
+ Commands support configurable timeouts and optional working directory or environment settings.
11
11
 
12
12
  Handles command execution operations in the AgentBay cloud environment.
13
13
 
@@ -22,24 +22,34 @@ Handles command execution operations in the AgentBay cloud environment.
22
22
 
23
23
  ### executeCommand
24
24
 
25
- ▸ **executeCommand**(`command`, `timeoutMs?`): `Promise`\<`CommandResult`\>
25
+ ▸ **executeCommand**(`command`, `timeoutMs?`, `cwd?`, `envs?`): `Promise`\<`CommandResult`\>
26
26
 
27
- Executes a shell command in the session environment.
27
+ Execute a shell command with optional working directory and environment variables.
28
+
29
+ Executes a shell command in the session environment with configurable timeout,
30
+ working directory, and environment variables. The command runs with session
31
+ user permissions in a Linux shell environment.
28
32
 
29
33
  #### Parameters
30
34
 
31
35
  | Name | Type | Default value | Description |
32
36
  | :------ | :------ | :------ | :------ |
33
- | `command` | `string` | `undefined` | The shell command to execute. |
34
- | `timeoutMs` | `number` | `1000` | Timeout in milliseconds. Defaults to 1000ms. |
37
+ | `command` | `string` | `undefined` | The shell command to execute |
38
+ | `timeoutMs` | `number` | `1000` | Timeout in milliseconds (default: 1000ms/1s). Maximum allowed timeout is 50000ms (50s). If a larger value is provided, it will be automatically limited to 50000ms |
39
+ | `cwd?` | `string` | `undefined` | The working directory for command execution. If not specified, the command runs in the default session directory |
40
+ | `envs?` | `Record`\<`string`, `string`\> | `undefined` | Environment variables as a dictionary of key-value pairs. These variables are set for the command execution only |
35
41
 
36
42
  #### Returns
37
43
 
38
44
  `Promise`\<`CommandResult`\>
39
45
 
40
46
  Promise resolving to CommandResult containing:
41
- - success: Whether the command executed successfully
42
- - output: Combined stdout and stderr output
47
+ - success: Whether the command executed successfully (exitCode === 0)
48
+ - output: Command output for backward compatibility (stdout + stderr)
49
+ - exitCode: The exit code of the command execution (0 for success)
50
+ - stdout: Standard output from the command execution
51
+ - stderr: Standard error from the command execution
52
+ - traceId: Trace ID for error tracking (only present when exitCode !== 0)
43
53
  - requestId: Unique identifier for this API request
44
54
  - errorMessage: Error description if execution failed
45
55
 
@@ -49,23 +59,30 @@ Promise resolving to CommandResult containing:
49
59
  const agentBay = new AgentBay({ apiKey: 'your_api_key' });
50
60
  const result = await agentBay.create();
51
61
  if (result.success) {
52
- const cmdResult = await result.session.command.executeCommand('echo "Hello"', 3000);
62
+ const cmdResult = await result.session.command.executeCommand('echo "Hello"', 5000);
53
63
  console.log('Command output:', cmdResult.output);
64
+ console.log('Exit code:', cmdResult.exitCode);
65
+ console.log('Stdout:', cmdResult.stdout);
54
66
  await result.session.delete();
55
67
  }
56
68
  ```
57
69
 
58
- **`Remarks`**
59
-
60
- **Behavior:**
61
- - Executes in a Linux shell environment
62
- - Combines stdout and stderr in the output
63
- - Default timeout is 1000ms (1 second)
64
- - Command runs with session user permissions
65
-
66
- **`See`**
70
+ **`Example`**
67
71
 
68
- [FileSystem.readFile](filesystem.md#readfile), [FileSystem.writeFile](filesystem.md#writefile)
72
+ ```typescript
73
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
74
+ const result = await agentBay.create();
75
+ if (result.success) {
76
+ const cmdResult = await result.session.command.executeCommand(
77
+ 'pwd',
78
+ 5000,
79
+ '/tmp',
80
+ { TEST_VAR: 'test_value' }
81
+ );
82
+ console.log('Working directory:', cmdResult.stdout);
83
+ await result.session.delete();
84
+ }
85
+ ```
69
86
 
70
87
  ## Best Practices
71
88
 
@@ -93,8 +93,8 @@ Synchronizes a context with the session. Supports both async and callback modes.
93
93
 
94
94
  | Name | Type | Default value | Description |
95
95
  | :------ | :------ | :------ | :------ |
96
- | `contextId?` | `string` | `undefined` | Optional context ID to synchronize |
97
- | `path?` | `string` | `undefined` | Optional path where the context should be mounted |
96
+ | `contextId?` | `string` | `undefined` | Optional context ID to synchronize. If provided, `path` must also be provided. |
97
+ | `path?` | `string` | `undefined` | Optional path where the context should be mounted. If provided, `contextId` must also be provided. |
98
98
  | `mode?` | `string` | `undefined` | Optional synchronization mode (e.g., "upload", "download") |
99
99
  | `callback?` | ``SyncCallback`` | `undefined` | Optional callback function. If provided, runs in background and calls callback when complete |
100
100
  | `maxRetries` | `number` | `150` | Maximum number of retries for polling completion status (default: 150) |
@@ -110,8 +110,27 @@ Promise resolving to ContextSyncResult with success status and request ID
110
110
 
111
111
  Error if the API call fails
112
112
 
113
+ **`Throws`**
114
+
115
+ Error if `contextId` or `path` is provided without the other parameter.
116
+ Both must be provided together, or both must be omitted.
117
+
118
+ **`Example`**
119
+
120
+ Sync all contexts (no parameters):
121
+ ```typescript
122
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
123
+ const result = await agentBay.create();
124
+ if (result.success) {
125
+ const syncResult = await result.session.context.sync();
126
+ console.log(`Sync: ${syncResult.success}`);
127
+ await result.session.delete();
128
+ }
129
+ ```
130
+
113
131
  **`Example`**
114
132
 
133
+ Sync specific context with path:
115
134
  ```typescript
116
135
  const agentBay = new AgentBay({ apiKey: 'your_api_key' });
117
136
  const result = await agentBay.create();
@@ -12,6 +12,7 @@ Handles file operations in the AgentBay cloud environment.
12
12
  ### Methods
13
13
 
14
14
  - [createDirectory](#createdirectory)
15
+ - [deleteFile](#deletefile)
15
16
  - [downloadFile](#downloadfile)
16
17
  - [editFile](#editfile)
17
18
  - [listDirectory](#listdirectory)
@@ -58,6 +59,41 @@ if (result.success) {
58
59
 
59
60
  ___
60
61
 
62
+ ### deleteFile
63
+
64
+ ▸ **deleteFile**(`path`): `Promise`\<`BoolResult`\>
65
+
66
+ Deletes a file at the specified path.
67
+ Corresponds to Python's delete_file() method
68
+
69
+ #### Parameters
70
+
71
+ | Name | Type | Description |
72
+ | :------ | :------ | :------ |
73
+ | `path` | `string` | Path to the file to delete. |
74
+
75
+ #### Returns
76
+
77
+ `Promise`\<`BoolResult`\>
78
+
79
+ BoolResult with deletion result and requestId
80
+
81
+ **`Example`**
82
+
83
+ ```typescript
84
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
85
+ const result = await agentBay.create();
86
+ if (result.success) {
87
+ const session = result.session;
88
+ await session.fileSystem.writeFile('/tmp/to_delete.txt', 'hello');
89
+ const deleteResult = await session.fileSystem.deleteFile('/tmp/to_delete.txt');
90
+ console.log('File deleted:', deleteResult.success);
91
+ await session.delete();
92
+ }
93
+ ```
94
+
95
+ ___
96
+
61
97
  ### downloadFile
62
98
 
63
99
  ▸ **downloadFile**(`remotePath`, `localPath`, `options?`): `Promise`\<`any`\>