test-wuying-agentbay-sdk 0.13.1-beta.20251224091333 → 0.13.1-beta.20251224100120

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.
@@ -336,7 +336,7 @@ ___
336
336
 
337
337
  ▸ **readFile**(`path`): `Promise`\<`FileContentResult`\>
338
338
 
339
- Reads the entire content of a file.
339
+ Reads the entire content of a file (text format, default).
340
340
 
341
341
  #### Parameters
342
342
 
@@ -354,6 +354,52 @@ Promise resolving to FileContentResult containing:
354
354
  - requestId: Unique identifier for this API request
355
355
  - errorMessage: Error description if read failed
356
356
 
357
+ ▸ **readFile**(`path`, `opts`): `Promise`\<`FileContentResult`\>
358
+
359
+ Reads the entire content of a file with explicit text format.
360
+
361
+ #### Parameters
362
+
363
+ | Name | Type | Description |
364
+ | :------ | :------ | :------ |
365
+ | `path` | `string` | Absolute path to the file to read. |
366
+ | `opts` | `Object` | Options object with format set to "text". |
367
+ | `opts.format` | `"text"` | Format to read the file in. |
368
+
369
+ #### Returns
370
+
371
+ `Promise`\<`FileContentResult`\>
372
+
373
+ Promise resolving to FileContentResult containing:
374
+ - success: Whether the read operation succeeded
375
+ - content: String content of the file
376
+ - requestId: Unique identifier for this API request
377
+ - errorMessage: Error description if read failed
378
+
379
+ ▸ **readFile**(`path`, `opts`): `Promise`\<`BinaryFileContentResult`\>
380
+
381
+ Reads the entire content of a file in binary format.
382
+
383
+ #### Parameters
384
+
385
+ | Name | Type | Description |
386
+ | :------ | :------ | :------ |
387
+ | `path` | `string` | Absolute path to the file to read. |
388
+ | `opts` | `Object` | Options object with format set to "bytes". |
389
+ | `opts.format` | `"bytes"` | Format to read the file in. |
390
+
391
+ #### Returns
392
+
393
+ `Promise`\<`BinaryFileContentResult`\>
394
+
395
+ Promise resolving to BinaryFileContentResult containing:
396
+ - success: Whether the read operation succeeded
397
+ - content: Uint8Array binary content of the file
398
+ - requestId: Unique identifier for this API request
399
+ - errorMessage: Error description if read failed
400
+ - contentType: Optional MIME type of the file
401
+ - size: Optional size of the file in bytes
402
+
357
403
  **`Throws`**
358
404
 
359
405
  Error if the API call fails.
@@ -369,13 +415,19 @@ const result = await agentBay.create();
369
415
  if (result.success) {
370
416
  const session = result.session;
371
417
 
372
- // Read a text file
418
+ // Read a text file (default)
373
419
  const fileResult = await session.fileSystem.readFile('/etc/hostname');
374
420
  if (fileResult.success) {
375
421
  console.log(`Content: ${fileResult.content}`);
376
422
  // Output: Content: agentbay-session-xyz
377
423
  }
378
424
 
425
+ // Read a binary file
426
+ const binaryResult = await session.fileSystem.readFile('/tmp/image.png', { format: 'bytes' });
427
+ if (binaryResult.success) {
428
+ console.log(`File size: ${binaryResult.content.length} bytes`);
429
+ }
430
+
379
431
  await session.delete();
380
432
  }
381
433
  ```
@@ -384,9 +436,10 @@ if (result.success) {
384
436
 
385
437
  **Behavior:**
386
438
  - Automatically handles large files by reading in 60KB chunks
387
- - Returns empty string for empty files
439
+ - Returns empty string/Uint8Array for empty files
388
440
  - Fails if path is a directory or doesn't exist
389
- - Content is returned as UTF-8 string
441
+ - Text format: Content is returned as UTF-8 string
442
+ - Binary format: Content is returned as Uint8Array (backend uses base64 encoding internally)
390
443
 
391
444
  **`See`**
392
445
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-wuying-agentbay-sdk",
3
- "version": "0.13.1-beta.20251224091333",
3
+ "version": "0.13.1-beta.20251224100120",
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",