test-wuying-agentbay-sdk 0.13.0-beta.20251209163754 → 0.13.0-beta.20251209211023
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +125 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +47 -16
- package/dist/index.d.ts +47 -16
- package/dist/index.mjs +125 -21
- package/dist/index.mjs.map +1 -1
- package/docs/api/common-features/basics/command.md +34 -17
- package/package.json +1 -1
|
@@ -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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-wuying-agentbay-sdk",
|
|
3
|
-
"version": "0.13.0-beta.
|
|
3
|
+
"version": "0.13.0-beta.20251209211023",
|
|
4
4
|
"description": "TypeScript SDK for interacting with the Wuying AgentBay cloud runtime environment",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|