wuying-agentbay-sdk 0.10.2 → 0.12.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 (108) hide show
  1. package/dist/chunk-BVWUCG4J.mjs +3402 -0
  2. package/dist/chunk-BVWUCG4J.mjs.map +1 -0
  3. package/dist/chunk-SL5GCAQE.cjs +3393 -0
  4. package/dist/chunk-SL5GCAQE.cjs.map +1 -0
  5. package/dist/index.cjs +4623 -3978
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.mts +3934 -1964
  8. package/dist/index.d.ts +3934 -1964
  9. package/dist/index.mjs +4601 -3956
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/key-normalizer-AF7APGQZ.cjs +136 -0
  12. package/dist/key-normalizer-AF7APGQZ.cjs.map +1 -0
  13. package/dist/key-normalizer-QDBRLFHF.mjs +145 -0
  14. package/dist/key-normalizer-QDBRLFHF.mjs.map +1 -0
  15. package/dist/model-CNCGFWJH.cjs +200 -0
  16. package/dist/model-CNCGFWJH.cjs.map +1 -0
  17. package/dist/model-LGWQJWKQ.mjs +209 -0
  18. package/docs/api/README.md +26 -0
  19. package/docs/api/browser-use/browser.md +177 -0
  20. package/docs/api/browser-use/extension.md +284 -0
  21. package/docs/api/codespace/code.md +77 -0
  22. package/docs/api/common-features/advanced/agent.md +84 -0
  23. package/docs/api/common-features/advanced/oss.md +221 -0
  24. package/docs/api/common-features/basics/agentbay.md +277 -0
  25. package/docs/api/common-features/basics/command.md +83 -0
  26. package/docs/api/common-features/basics/context-manager.md +149 -0
  27. package/docs/api/common-features/basics/context-sync.md +51 -0
  28. package/docs/api/common-features/basics/context.md +348 -0
  29. package/docs/api/common-features/basics/filesystem.md +499 -0
  30. package/docs/api/common-features/basics/logging.md +77 -0
  31. package/docs/api/common-features/basics/session.md +542 -0
  32. package/docs/api/computer-use/computer.md +786 -0
  33. package/docs/api/mobile-use/mobile.md +395 -0
  34. package/docs/examples/README.md +332 -0
  35. package/docs/examples/basic-usage.ts +86 -0
  36. package/docs/examples/browser-use/browser/README.md +356 -0
  37. package/docs/examples/browser-use/browser/basic-usage.ts +136 -0
  38. package/docs/examples/browser-use/browser/browser-command-args.ts +117 -0
  39. package/docs/examples/browser-use/browser/browser-context-cookie-persistence.ts +348 -0
  40. package/docs/examples/browser-use/browser/browser-fingerprint-basic-usage.ts +121 -0
  41. package/docs/examples/browser-use/browser/browser-fingerprint-construct.ts +114 -0
  42. package/docs/examples/browser-use/browser/browser-fingerprint-local-sync.ts +98 -0
  43. package/docs/examples/browser-use/browser/browser-fingerprint-persistence.ts +242 -0
  44. package/docs/examples/browser-use/browser/browser-proxies.ts +149 -0
  45. package/docs/examples/browser-use/browser/browser-type-example.ts +266 -0
  46. package/docs/examples/browser-use/browser/browser-viewport.ts +129 -0
  47. package/docs/examples/browser-use/browser/call_for_user_jd.ts +184 -0
  48. package/docs/examples/browser-use/browser/captcha_tongcheng.ts +151 -0
  49. package/docs/examples/browser-use/browser/run-2048.ts +209 -0
  50. package/docs/examples/browser-use/browser/run-sudoku.ts +150 -0
  51. package/docs/examples/browser-use/browser/screenshot-example.ts +132 -0
  52. package/docs/examples/browser-use/extension-example/README.md +252 -0
  53. package/docs/examples/browser-use/extension-example/extension-example.ts +381 -0
  54. package/docs/examples/codespace/automation/automation-example.ts +322 -0
  55. package/docs/examples/common-features/advanced/agent-module-example/README.md +40 -0
  56. package/docs/examples/common-features/advanced/agent-module-example.ts +66 -0
  57. package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +212 -0
  58. package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +213 -0
  59. package/docs/examples/common-features/advanced/vpc-session-example/README.md +47 -0
  60. package/docs/examples/common-features/advanced/vpc-session-example.ts +106 -0
  61. package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +236 -0
  62. package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +236 -0
  63. package/docs/examples/common-features/basics/command-example/README.md +47 -0
  64. package/docs/examples/common-features/basics/command-example/command-example.ts +153 -0
  65. package/docs/examples/common-features/basics/context-management/README.md +55 -0
  66. package/docs/examples/common-features/basics/context-management/context-management.ts +140 -0
  67. package/docs/examples/common-features/basics/data-persistence/README.md +129 -0
  68. package/docs/examples/common-features/basics/data-persistence/context-sync-demo.md +144 -0
  69. package/docs/examples/common-features/basics/data-persistence/context-sync-demo.ts +275 -0
  70. package/docs/examples/common-features/basics/data-persistence/data-persistence.ts +259 -0
  71. package/docs/examples/common-features/basics/data-persistence/recycle-policy-example.ts +294 -0
  72. package/docs/examples/common-features/basics/filesystem-example/README.md +57 -0
  73. package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +164 -0
  74. package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +153 -0
  75. package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +168 -0
  76. package/docs/examples/common-features/basics/get/README.md +136 -0
  77. package/docs/examples/common-features/basics/get/main.ts +79 -0
  78. package/docs/examples/common-features/basics/list_sessions/README.md +54 -0
  79. package/docs/examples/common-features/basics/list_sessions/main.ts +258 -0
  80. package/docs/examples/common-features/basics/mcp_tool_direct_call/README.md +142 -0
  81. package/docs/examples/common-features/basics/mcp_tool_direct_call/main.ts +135 -0
  82. package/docs/examples/common-features/basics/session-creation/README.md +28 -0
  83. package/docs/examples/common-features/basics/session-creation/session-creation.ts +295 -0
  84. package/docs/examples/common-features/basics/session-pause-resume/README.md +53 -0
  85. package/docs/examples/common-features/basics/session-pause-resume/session-pause-resume.ts +237 -0
  86. package/docs/examples/mobile-use/mobile-get-adb-url/README.md +92 -0
  87. package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +80 -0
  88. package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +279 -0
  89. package/docs/examples/mobile-use/mobile-get-adb-url/package.json +18 -0
  90. package/docs/examples/mobile-use/mobile-simulate-basic-usage.ts +202 -0
  91. package/docs/examples/mobile-use/mobile-simulate-with-ctx.ts +170 -0
  92. package/package.json +19 -12
  93. package/dist/application-KZWXH46T.mjs +0 -17
  94. package/dist/application-LMA7KSRH.cjs +0 -8
  95. package/dist/application-LMA7KSRH.cjs.map +0 -1
  96. package/dist/chunk-BQNGKBQF.mjs +0 -386
  97. package/dist/chunk-BQNGKBQF.mjs.map +0 -1
  98. package/dist/chunk-IOVGAAJL.cjs +0 -558
  99. package/dist/chunk-IOVGAAJL.cjs.map +0 -1
  100. package/dist/chunk-UF2TC2R4.mjs +0 -567
  101. package/dist/chunk-UF2TC2R4.mjs.map +0 -1
  102. package/dist/chunk-X6MS7Z5L.cjs +0 -377
  103. package/dist/chunk-X6MS7Z5L.cjs.map +0 -1
  104. package/dist/window-DH37ZDD5.mjs +0 -17
  105. package/dist/window-DH37ZDD5.mjs.map +0 -1
  106. package/dist/window-U7N3H735.cjs +0 -8
  107. package/dist/window-U7N3H735.cjs.map +0 -1
  108. /package/dist/{application-KZWXH46T.mjs.map → model-LGWQJWKQ.mjs.map} +0 -0
@@ -0,0 +1,499 @@
1
+ # Class: FileSystem
2
+
3
+ ## 📁 Related Tutorial
4
+
5
+ - [File Operations Guide](../../../../../docs/guides/common-features/basics/file-operations.md) - Complete guide to file system operations
6
+
7
+ Handles file operations in the AgentBay cloud environment.
8
+
9
+ ## Table of contents
10
+
11
+
12
+ ### Methods
13
+
14
+ - [createDirectory](#createdirectory)
15
+ - [downloadFile](#downloadfile)
16
+ - [editFile](#editfile)
17
+ - [listDirectory](#listdirectory)
18
+ - [moveFile](#movefile)
19
+ - [readFile](#readfile)
20
+ - [readMultipleFiles](#readmultiplefiles)
21
+ - [searchFiles](#searchfiles)
22
+ - [uploadFile](#uploadfile)
23
+ - [watchDirectory](#watchdirectory)
24
+ - [writeFile](#writefile)
25
+
26
+ ## Methods
27
+
28
+ ### createDirectory
29
+
30
+ ▸ **createDirectory**(`path`): `Promise`\<`BoolResult`\>
31
+
32
+ Creates a new directory at the specified path.
33
+ Corresponds to Python's create_directory() method
34
+
35
+ #### Parameters
36
+
37
+ | Name | Type | Description |
38
+ | :------ | :------ | :------ |
39
+ | `path` | `string` | Path to the directory to create. |
40
+
41
+ #### Returns
42
+
43
+ `Promise`\<`BoolResult`\>
44
+
45
+ BoolResult with creation result and requestId
46
+
47
+ **`Example`**
48
+
49
+ ```typescript
50
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
51
+ const result = await agentBay.create();
52
+ if (result.success) {
53
+ const createResult = await result.session.fileSystem.createDirectory('/tmp/mydir');
54
+ console.log('Directory created:', createResult.success);
55
+ await result.session.delete();
56
+ }
57
+ ```
58
+
59
+ ___
60
+
61
+ ### downloadFile
62
+
63
+ ▸ **downloadFile**(`remotePath`, `localPath`, `options?`): `Promise`\<`any`\>
64
+
65
+ Download a file from remote path to local path using pre-signed URLs.
66
+ This is a synchronous wrapper around the FileTransfer.download method.
67
+
68
+ #### Parameters
69
+
70
+ | Name | Type | Description |
71
+ | :------ | :------ | :------ |
72
+ | `remotePath` | `string` | Remote file path to download from |
73
+ | `localPath` | `string` | Local file path to download to |
74
+ | `options?` | `Object` | Optional parameters |
75
+ | `options.overwrite?` | `boolean` | - |
76
+ | `options.pollInterval?` | `number` | - |
77
+ | `options.progressCb?` | (`bytesReceived`: `number`) => `void` | - |
78
+ | `options.wait?` | `boolean` | - |
79
+ | `options.waitTimeout?` | `number` | - |
80
+
81
+ #### Returns
82
+
83
+ `Promise`\<`any`\>
84
+
85
+ DownloadResult with download result and requestId
86
+
87
+ **`Example`**
88
+
89
+ ```typescript
90
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
91
+ const result = await agentBay.create({ imageId: 'code_latest' });
92
+ if (result.success) {
93
+ await result.session.fileSystem.writeFile('/workspace/remote.txt', 'Content to download');
94
+ const downloadResult = await result.session.fileSystem.downloadFile('/workspace/remote.txt', '/tmp/local.txt');
95
+ console.log('Download success:', downloadResult.success);
96
+ await result.session.delete();
97
+ }
98
+ ```
99
+
100
+ ___
101
+
102
+ ### editFile
103
+
104
+ ▸ **editFile**(`path`, `edits`, `dryRun?`): `Promise`\<`BoolResult`\>
105
+
106
+ Edits a file by replacing occurrences of oldText with newText.
107
+ Corresponds to Python's edit_file() method
108
+
109
+ #### Parameters
110
+
111
+ | Name | Type | Default value | Description |
112
+ | :------ | :------ | :------ | :------ |
113
+ | `path` | `string` | `undefined` | Path to the file to edit. |
114
+ | `edits` | \{ `newText`: `string` ; `oldText`: `string` }[] | `undefined` | Array of edit operations, each containing oldText and newText. |
115
+ | `dryRun` | `boolean` | `false` | Optional: If true, preview changes without applying them. |
116
+
117
+ #### Returns
118
+
119
+ `Promise`\<`BoolResult`\>
120
+
121
+ BoolResult with edit result and requestId
122
+
123
+ **`Example`**
124
+
125
+ ```typescript
126
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
127
+ const result = await agentBay.create();
128
+ if (result.success) {
129
+ await result.session.fileSystem.writeFile('/tmp/config.txt', 'DEBUG=false');
130
+ const edits = [{ oldText: 'DEBUG=false', newText: 'DEBUG=true' }];
131
+ const editResult = await result.session.fileSystem.editFile('/tmp/config.txt', edits);
132
+ console.log('File edited:', editResult.success);
133
+ await result.session.delete();
134
+ }
135
+ ```
136
+
137
+ ### listDirectory
138
+
139
+ ▸ **listDirectory**(`path`): `Promise`\<`DirectoryListResult`\>
140
+
141
+ Lists the contents of a directory.
142
+
143
+ #### Parameters
144
+
145
+ | Name | Type | Description |
146
+ | :------ | :------ | :------ |
147
+ | `path` | `string` | Absolute path to the directory to list. |
148
+
149
+ #### Returns
150
+
151
+ `Promise`\<`DirectoryListResult`\>
152
+
153
+ Promise resolving to DirectoryListResult containing array of entries.
154
+
155
+ **`Example`**
156
+
157
+ ```typescript
158
+ import { AgentBay } from 'wuying-agentbay-sdk';
159
+
160
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
161
+ const result = await agentBay.create();
162
+
163
+ if (result.success) {
164
+ const session = result.session;
165
+
166
+ // List directory contents
167
+ const listResult = await session.fileSystem.listDirectory('/tmp');
168
+ if (listResult.success) {
169
+ console.log(`Found ${listResult.entries.length} entries`);
170
+ for (const entry of listResult.entries) {
171
+ console.log(`${entry.name} (${entry.isDirectory ? 'dir' : 'file'})`);
172
+ }
173
+ }
174
+
175
+ await session.delete();
176
+ }
177
+ ```
178
+
179
+ **`See`**
180
+
181
+ [readFile](#readfile), [writeFile](#writefile)
182
+
183
+ ___
184
+
185
+ ### moveFile
186
+
187
+ ▸ **moveFile**(`source`, `destination`): `Promise`\<`BoolResult`\>
188
+
189
+ Moves a file or directory from source to destination.
190
+ Corresponds to Python's move_file() method
191
+
192
+ #### Parameters
193
+
194
+ | Name | Type | Description |
195
+ | :------ | :------ | :------ |
196
+ | `source` | `string` | Path to the source file or directory. |
197
+ | `destination` | `string` | Path to the destination file or directory. |
198
+
199
+ #### Returns
200
+
201
+ `Promise`\<`BoolResult`\>
202
+
203
+ BoolResult with move result and requestId
204
+
205
+ **`Example`**
206
+
207
+ ```typescript
208
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
209
+ const result = await agentBay.create();
210
+ if (result.success) {
211
+ await result.session.fileSystem.writeFile('/tmp/original.txt', 'Test content');
212
+ const moveResult = await result.session.fileSystem.moveFile('/tmp/original.txt', '/tmp/moved.txt');
213
+ console.log('File moved:', moveResult.success);
214
+ await result.session.delete();
215
+ }
216
+ ```
217
+
218
+ ___
219
+
220
+ ### readFile
221
+
222
+ ▸ **readFile**(`path`): `Promise`\<`FileContentResult`\>
223
+
224
+ Reads the entire content of a file.
225
+
226
+ #### Parameters
227
+
228
+ | Name | Type | Description |
229
+ | :------ | :------ | :------ |
230
+ | `path` | `string` | Absolute path to the file to read. |
231
+
232
+ #### Returns
233
+
234
+ `Promise`\<`FileContentResult`\>
235
+
236
+ Promise resolving to FileContentResult containing:
237
+ - success: Whether the read operation succeeded
238
+ - content: String content of the file
239
+ - requestId: Unique identifier for this API request
240
+ - errorMessage: Error description if read failed
241
+
242
+ **`Throws`**
243
+
244
+ Error if the API call fails.
245
+
246
+ **`Example`**
247
+
248
+ ```typescript
249
+ import { AgentBay } from 'wuying-agentbay-sdk';
250
+
251
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
252
+ const result = await agentBay.create();
253
+
254
+ if (result.success) {
255
+ const session = result.session;
256
+
257
+ // Read a text file
258
+ const fileResult = await session.fileSystem.readFile('/etc/hostname');
259
+ if (fileResult.success) {
260
+ console.log(`Content: ${fileResult.content}`);
261
+ // Output: Content: agentbay-session-xyz
262
+ }
263
+
264
+ await session.delete();
265
+ }
266
+ ```
267
+
268
+ **`Remarks`**
269
+
270
+ **Behavior:**
271
+ - Automatically handles large files by reading in 60KB chunks
272
+ - Returns empty string for empty files
273
+ - Fails if path is a directory or doesn't exist
274
+ - Content is returned as UTF-8 string
275
+
276
+ **`See`**
277
+
278
+ [writeFile](#writefile), [listDirectory](#listdirectory)
279
+
280
+ ___
281
+
282
+ ### readMultipleFiles
283
+
284
+ ▸ **readMultipleFiles**(`paths`): `Promise`\<`MultipleFileContentResult`\>
285
+
286
+ Reads the content of multiple files.
287
+ Corresponds to Python's read_multiple_files() method
288
+
289
+ #### Parameters
290
+
291
+ | Name | Type | Description |
292
+ | :------ | :------ | :------ |
293
+ | `paths` | `string`[] | Array of file paths to read. |
294
+
295
+ #### Returns
296
+
297
+ `Promise`\<`MultipleFileContentResult`\>
298
+
299
+ MultipleFileContentResult with file contents and requestId
300
+
301
+ **`Example`**
302
+
303
+ ```typescript
304
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
305
+ const result = await agentBay.create();
306
+ if (result.success) {
307
+ await result.session.fileSystem.writeFile('/tmp/file1.txt', 'Content 1');
308
+ await result.session.fileSystem.writeFile('/tmp/file2.txt', 'Content 2');
309
+ const readResult = await result.session.fileSystem.readMultipleFiles(['/tmp/file1.txt', '/tmp/file2.txt']);
310
+ console.log(`Read ${Object.keys(readResult.contents).length} files`);
311
+ await result.session.delete();
312
+ }
313
+ ```
314
+
315
+ ___
316
+
317
+ ### searchFiles
318
+
319
+ ▸ **searchFiles**(`path`, `pattern`, `excludePatterns?`): `Promise`\<`FileSearchResult`\>
320
+
321
+ Searches for files in a directory that match a wildcard pattern.
322
+ Corresponds to Python's search_files() method
323
+
324
+ #### Parameters
325
+
326
+ | Name | Type | Default value | Description |
327
+ | :------ | :------ | :------ | :------ |
328
+ | `path` | `string` | `undefined` | Path to the directory to search in. |
329
+ | `pattern` | `string` | `undefined` | Wildcard pattern to match against file names. Supports * (any characters) and ? (single character). Examples: "*.py", "test_*", "*config*". |
330
+ | `excludePatterns` | `string`[] | `[]` | Optional: Array of wildcard patterns to exclude. |
331
+
332
+ #### Returns
333
+
334
+ `Promise`\<`FileSearchResult`\>
335
+
336
+ FileSearchResult with search results and requestId
337
+
338
+ **`Example`**
339
+
340
+ ```typescript
341
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
342
+ const result = await agentBay.create();
343
+ if (result.success) {
344
+ await result.session.fileSystem.createDirectory('/tmp/test');
345
+ await result.session.fileSystem.writeFile('/tmp/test/file1.py', "print('hello')");
346
+ const searchResult = await result.session.fileSystem.searchFiles('/tmp/test', '*.py');
347
+ console.log(`Found ${searchResult.matches.length} Python files`);
348
+ await result.session.delete();
349
+ }
350
+ ```
351
+
352
+ ___
353
+
354
+ ### uploadFile
355
+
356
+ ▸ **uploadFile**(`localPath`, `remotePath`, `options?`): `Promise`\<`any`\>
357
+
358
+ Upload a file from local to remote path using pre-signed URLs.
359
+ This is a synchronous wrapper around the FileTransfer.upload method.
360
+
361
+ #### Parameters
362
+
363
+ | Name | Type | Description |
364
+ | :------ | :------ | :------ |
365
+ | `localPath` | `string` | Local file path to upload |
366
+ | `remotePath` | `string` | Remote file path to upload to |
367
+ | `options?` | `Object` | Optional parameters |
368
+ | `options.contentType?` | `string` | - |
369
+ | `options.pollInterval?` | `number` | - |
370
+ | `options.progressCb?` | (`bytesTransferred`: `number`) => `void` | - |
371
+ | `options.wait?` | `boolean` | - |
372
+ | `options.waitTimeout?` | `number` | - |
373
+
374
+ #### Returns
375
+
376
+ `Promise`\<`any`\>
377
+
378
+ UploadResult with upload result and requestId
379
+
380
+ **`Example`**
381
+
382
+ ```typescript
383
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
384
+ const result = await agentBay.create({ imageId: 'code_latest' });
385
+ if (result.success) {
386
+ const uploadResult = await result.session.fileSystem.uploadFile('/tmp/local.txt', '/workspace/remote.txt');
387
+ console.log('Upload success:', uploadResult.success);
388
+ await result.session.delete();
389
+ }
390
+ ```
391
+
392
+ ___
393
+
394
+ ### watchDirectory
395
+
396
+ ▸ **watchDirectory**(`path`, `callback`, `interval?`, `signal?`): `Promise`\<`void`\>
397
+
398
+ Watch a directory for file changes and call the callback function when changes occur
399
+
400
+ #### Parameters
401
+
402
+ | Name | Type | Default value | Description |
403
+ | :------ | :------ | :------ | :------ |
404
+ | `path` | `string` | `undefined` | Directory path to monitor |
405
+ | `callback` | (`events`: ``FileChangeEvent``[]) => `void` | `undefined` | Function called when changes are detected |
406
+ | `interval` | `number` | `500` | Polling interval in milliseconds (default: 500, minimum: 100) |
407
+ | `signal?` | `AbortSignal` | `undefined` | Signal to abort the monitoring |
408
+
409
+ #### Returns
410
+
411
+ `Promise`\<`void`\>
412
+
413
+ Promise that resolves when monitoring stops
414
+
415
+ **`Example`**
416
+
417
+ ```typescript
418
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
419
+ const result = await agentBay.create();
420
+ if (result.success) {
421
+ const testDir = '/tmp/watch_test';
422
+ await result.session.fileSystem.createDirectory(testDir);
423
+ const controller = new AbortController();
424
+ const callback = (events) => console.log(`Detected ${events.length} changes`);
425
+ await result.session.fileSystem.watchDirectory(testDir, callback, 1000, controller.signal);
426
+ await result.session.delete();
427
+ }
428
+ ```
429
+
430
+ ___
431
+
432
+ ### writeFile
433
+
434
+ ▸ **writeFile**(`path`, `content`, `mode?`): `Promise`\<`BoolResult`\>
435
+
436
+ Writes content to a file.
437
+
438
+ #### Parameters
439
+
440
+ | Name | Type | Default value | Description |
441
+ | :------ | :------ | :------ | :------ |
442
+ | `path` | `string` | `undefined` | Absolute path to the file to write. |
443
+ | `content` | `string` | `undefined` | String content to write to the file. |
444
+ | `mode` | `string` | `"overwrite"` | Write mode: "overwrite" (default) or "append". |
445
+
446
+ #### Returns
447
+
448
+ `Promise`\<`BoolResult`\>
449
+
450
+ Promise resolving to BoolResult with success status.
451
+
452
+ **`Example`**
453
+
454
+ ```typescript
455
+ import { AgentBay } from 'wuying-agentbay-sdk';
456
+
457
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
458
+ const result = await agentBay.create();
459
+
460
+ if (result.success) {
461
+ const session = result.session;
462
+
463
+ // Write to a file (overwrite mode)
464
+ const writeResult = await session.fileSystem.writeFile(
465
+ '/tmp/test.txt',
466
+ 'Hello, AgentBay!'
467
+ );
468
+ if (writeResult.success) {
469
+ console.log('File written successfully');
470
+ }
471
+
472
+ // Append to a file
473
+ const appendResult = await session.fileSystem.writeFile(
474
+ '/tmp/test.txt',
475
+ '\nNew line',
476
+ 'append'
477
+ );
478
+
479
+ await session.delete();
480
+ }
481
+ ```
482
+
483
+ **`Remarks`**
484
+
485
+ **Behavior:**
486
+ - Automatically handles large files by writing in 60KB chunks
487
+ - Creates parent directories if they don't exist
488
+ - "overwrite" mode replaces existing file content
489
+ - "append" mode adds content to the end of the file
490
+
491
+ **`See`**
492
+
493
+ [readFile](#readfile), [listDirectory](#listdirectory)
494
+
495
+ ## Related Resources
496
+
497
+ - [Session API Reference](session.md)
498
+ - [Command API Reference](command.md)
499
+
@@ -0,0 +1,77 @@
1
+ # Interface: LoggerConfig
2
+
3
+ ## 📝 Related Tutorial
4
+
5
+ - [Logging Configuration Guide](../../../../../docs/guides/common-features/configuration/logging.md) - Configure logging for the SDK
6
+
7
+ Logger configuration options
8
+
9
+ **`Example`**
10
+
11
+ ```typescript
12
+ import { AgentBay, setupLogger } from 'wuying-agentbay-sdk';
13
+
14
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
15
+
16
+ async function demonstrateLogging() {
17
+ try {
18
+ // Configure logging with file output
19
+ setupLogger({
20
+ level: 'DEBUG',
21
+ logFile: '/var/log/agentbay.log',
22
+ maxFileSize: '100 MB',
23
+ enableConsole: true
24
+ });
25
+
26
+ // Create a session - logs will be written to both console and file
27
+ const result = await agentBay.create();
28
+ if (result.success) {
29
+ const session = result.session;
30
+ console.log(`Session created: ${session.sessionId}`);
31
+ await session.delete();
32
+ }
33
+ } catch (error) {
34
+ console.error('Error:', error);
35
+ }
36
+ }
37
+
38
+ demonstrateLogging().catch(console.error);
39
+ ```
40
+
41
+ ## Table of contents
42
+
43
+ ### Properties
44
+
45
+ - `enableConsole`
46
+ - `level`
47
+ - `logFile`
48
+ - `maxFileSize`
49
+
50
+ ## Properties
51
+
52
+ ### enableConsole
53
+
54
+ • `Optional` **enableConsole**: `boolean`
55
+
56
+ ___
57
+
58
+ ### level
59
+
60
+ • `Optional` **level**: ``LogLevel``
61
+
62
+ ___
63
+
64
+ ### logFile
65
+
66
+ • `Optional` **logFile**: `string`
67
+
68
+ ___
69
+
70
+ ### maxFileSize
71
+
72
+ • `Optional` **maxFileSize**: `string`
73
+
74
+ ## Related Resources
75
+
76
+ - [AgentBay API Reference](agentbay.md)
77
+