Skip to main content
Version: 0.1.22
Last Verified: 2025-01-27
Package: @hopx-ai/sdk on npm

Overview

The Files resource provides file operations for sandboxes. Access it via the files property on a Sandbox instance. All file operations are async and work with both text and binary files.

Access

Methods

read

Read text file contents.
Parameters:
  • path (string): File path to read
Returns: Promise<string> - File contents as string Example:

readBytes

Read binary file contents.
Returns: Promise<Buffer> - File contents as Buffer

write

Write text file.
Parameters:
  • path (string): File path to write
  • content (string): Text content
  • options.mode (string, optional): File permissions

writeBytes

Write binary file.

list

List directory contents.
Returns: Promise<EnhancedFileInfo[]> - Array of file/directory information objects

exists

Check if file/directory exists.
Returns: Promise<boolean> - true if exists, false otherwise

remove

Remove file or directory.

mkdir

Create directory.

download

Download file (alias for readBytes).

Examples

Example 1: Basic File Operations


  • Sandbox - Main sandbox class
  • Commands - Command execution resource
  • Types - TypeScript type definitions

See Also

Next Steps