wuying-agentbay-sdk 0.12.0 → 0.13.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/{chunk-BVWUCG4J.mjs → chunk-P2CXYF4T.mjs} +400 -163
- package/dist/chunk-P2CXYF4T.mjs.map +1 -0
- package/dist/{chunk-SL5GCAQE.cjs → chunk-WVWGLZDT.cjs} +337 -100
- package/dist/chunk-WVWGLZDT.cjs.map +1 -0
- package/dist/index.cjs +6854 -782
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +644 -166
- package/dist/index.d.ts +644 -166
- package/dist/index.mjs +6723 -651
- package/dist/index.mjs.map +1 -1
- package/dist/{model-LGWQJWKQ.mjs → model-BRLR6F3P.mjs} +16 -2
- package/dist/model-KJHN3WYY.cjs +214 -0
- package/dist/{model-CNCGFWJH.cjs.map → model-KJHN3WYY.cjs.map} +1 -1
- package/docs/api/README.md +6 -0
- package/docs/api/browser-use/browser-agent.md +188 -0
- package/docs/api/browser-use/browser.md +1 -1
- package/docs/api/browser-use/fingerprint.md +154 -0
- package/docs/api/codespace/code.md +3 -0
- package/docs/api/common-features/advanced/agent.md +7 -63
- package/docs/api/common-features/advanced/browser-use-agent.md +118 -0
- package/docs/api/common-features/advanced/computer-use-agent.md +85 -0
- package/docs/api/common-features/basics/agentbay.md +3 -2
- package/docs/api/common-features/basics/command.md +35 -18
- package/docs/api/common-features/basics/filesystem.md +36 -0
- package/docs/api/common-features/basics/session-params.md +382 -0
- package/docs/api/common-features/basics/session.md +0 -2
- package/docs/api/computer-use/computer.md +25 -25
- package/docs/api/mobile-use/mobile-simulate.md +135 -0
- package/docs/examples/browser-use/browser/basic-usage.ts +31 -24
- package/docs/examples/browser-use/browser/browser-type-example.ts +3 -4
- package/docs/examples/browser-use/browser/captcha_tongcheng.ts +60 -28
- package/docs/examples/browser-use/browser/run-2048.ts +47 -37
- package/docs/examples/browser-use/browser/run-sudoku.ts +55 -36
- package/docs/examples/browser-use/browser/screenshot-example.ts +6 -6
- package/docs/examples/browser-use/extension-example/extension-example.ts +1 -2
- package/docs/examples/codespace/enhanced_code/index.ts +86 -0
- package/docs/examples/common-features/advanced/agent-module-example.ts +1 -1
- package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +1 -1
- package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +5 -6
- package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +1 -1
- package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +1 -1
- package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +13 -0
- package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +6 -7
- package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +1 -1
- package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +1 -1
- package/package.json +4 -4
- package/dist/chunk-BVWUCG4J.mjs.map +0 -1
- package/dist/chunk-SL5GCAQE.cjs.map +0 -1
- package/dist/model-CNCGFWJH.cjs +0 -200
- package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +0 -279
- package/docs/examples/mobile-use/mobile-get-adb-url/package.json +0 -18
- /package/dist/{model-LGWQJWKQ.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
|
-
###
|
|
15
|
+
### Properties
|
|
13
16
|
|
|
14
|
-
- [executeTask](#executetask)
|
|
15
|
-
- [terminateTask](#terminatetask)
|
|
16
17
|
|
|
17
|
-
##
|
|
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
|
-
|
|
72
|
-
|
|
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
|
+
```
|
|
@@ -24,6 +24,7 @@ Main class for interacting with the AgentBay cloud runtime environment.
|
|
|
24
24
|
## Properties
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
+
client: ``Client``
|
|
27
28
|
context: [`ContextService`](context.md)
|
|
28
29
|
```
|
|
29
30
|
|
|
@@ -32,7 +33,7 @@ context: [`ContextService`](context.md)
|
|
|
32
33
|
|
|
33
34
|
### create
|
|
34
35
|
|
|
35
|
-
▸ **create**(`params
|
|
36
|
+
▸ **create**(`params`): `Promise`\<`SessionResult`\>
|
|
36
37
|
|
|
37
38
|
Creates a new AgentBay session with specified configuration.
|
|
38
39
|
|
|
@@ -40,7 +41,7 @@ Creates a new AgentBay session with specified configuration.
|
|
|
40
41
|
|
|
41
42
|
| Name | Type | Description |
|
|
42
43
|
| :------ | :------ | :------ |
|
|
43
|
-
| `params` |
|
|
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 |
|
|
44
45
|
|
|
45
46
|
#### Returns
|
|
46
47
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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:
|
|
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"',
|
|
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
|
-
**`
|
|
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
|
-
|
|
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
|
|
|
@@ -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`\>
|