import { S3Client } from '@aws-sdk/client-s3'; import type { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@aws-sdk/types'; import type { FileContent, FileStat, FileEntry, ReadOptions, WriteOptions, ListOptions, RemoveOptions, CopyOptions, FilesystemMountConfig, FilesystemIcon, FilesystemInfo, ProviderStatus, MastraFilesystemOptions } from '@mastra/core/workspace'; import { MastraFilesystem } from '@mastra/core/workspace'; /** * S3 mount configuration. * Returned by S3Filesystem.getMountConfig() for FUSE mounting in sandboxes. */ export interface S3MountConfig extends FilesystemMountConfig { type: 's3'; /** S3 bucket name */ bucket: string; /** AWS region (use 'auto' for R2) */ region?: string; /** Optional endpoint for S3-compatible storage (MinIO, R2, etc.) */ endpoint?: string; /** AWS access key ID */ accessKeyId?: string; /** AWS secret access key */ secretAccessKey?: string; /** AWS session token for temporary credentials (SSO, AssumeRole, container credentials, etc.) */ sessionToken?: string; /** * Optional prefix (subdirectory) to mount instead of the entire bucket. * Uses s3fs `bucket:/prefix` syntax to scope the mount to a specific path. * Leading/trailing slashes are normalized automatically. */ prefix?: string; /** Mount as read-only */ readOnly?: boolean; } /** * S3 filesystem provider configuration. */ export interface S3FilesystemOptions extends MastraFilesystemOptions { /** Unique identifier for this filesystem instance */ id?: string; /** S3 bucket name */ bucket: string; /** Human-friendly display name for the UI */ displayName?: string; /** Icon identifier for the UI (defaults to 's3') */ icon?: FilesystemIcon; /** Description shown in tooltips */ description?: string; /** AWS region (use 'auto' for R2) */ region: string; /** * AWS credentials or credential provider function. * Accepts static credentials or a provider that auto-refreshes * (e.g. fromNodeProviderChain() from @aws-sdk/credential-providers). * When set, takes precedence over accessKeyId/secretAccessKey/sessionToken. * When ALL credential options are omitted, the SDK default credential * provider chain is used (env vars, ~/.aws, IMDS, ECS container credentials). */ credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider; /** * AWS access key ID. * Optional - omit to use the SDK default credential provider chain. */ accessKeyId?: string; /** * AWS secret access key. * Optional - omit to use the SDK default credential provider chain. */ secretAccessKey?: string; /** * AWS session token for temporary credentials. * Required when using SSO, AssumeRole, container credentials, or any other * temporary credential provider. */ sessionToken?: string; /** * Custom endpoint URL for S3-compatible storage. * Examples: * - Cloudflare R2: 'https://{accountId}.r2.cloudflarestorage.com' * - MinIO: 'http://localhost:9000' * - DigitalOcean Spaces: 'https://{region}.digitaloceanspaces.com' */ endpoint?: string; /** Force path-style URLs (required for some S3-compatible services) */ forcePathStyle?: boolean; /** Optional prefix for all keys (acts like a subdirectory) */ prefix?: string; /** Mount as read-only (blocks write operations, mounts read-only in sandboxes) */ readOnly?: boolean; } export declare class S3Filesystem extends MastraFilesystem { readonly id: string; readonly name = "S3Filesystem"; readonly provider = "s3"; readonly readOnly?: boolean; status: ProviderStatus; readonly displayName?: string; readonly icon: FilesystemIcon; readonly description?: string; private readonly bucket; private readonly region; private readonly credentials?; private readonly accessKeyId?; private readonly secretAccessKey?; private readonly sessionToken?; private readonly endpoint?; private readonly forcePathStyle; private readonly prefix; private _client; constructor(options: S3FilesystemOptions); /** * Get the underlying S3Client instance for direct access to AWS S3 APIs. * * Use this when you need to access S3 features not exposed through the * WorkspaceFilesystem interface (e.g., presigned URLs, multipart uploads, * custom S3 operations, etc.). * * @example Generate a presigned URL * ```typescript * import { GetObjectCommand } from '@aws-sdk/client-s3'; * import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; * * const s3Client = fs.client; * const url = await getSignedUrl(s3Client, new GetObjectCommand({ * Bucket: 'my-bucket', * Key: 'my-file.txt', * })); * ``` */ get client(): S3Client; /** * Get mount configuration for E2B sandbox. * Returns S3-compatible config that works with s3fs-fuse. * * Only static `accessKeyId`/`secretAccessKey`/`sessionToken` are included in the * returned config. If credentials are provided only via the `credentials` option * (provider function), the returned config will have no credentials because FUSE * mounts cannot call a provider function. Use static credentials for sandbox * mount compatibility. */ getMountConfig(): S3MountConfig; /** * Get filesystem info for status reporting. */ getInfo(): FilesystemInfo<{ bucket: string; region: string; endpoint?: string; prefix?: string; }>; /** * Handle an error, checking for access denied and updating status accordingly. * Returns the error for re-throwing. */ private handleError; /** * Get instructions describing this S3 filesystem. * Used by agents to understand storage semantics. */ getInstructions(): string; /** * Detect the appropriate icon based on the S3 endpoint. */ private detectIconFromEndpoint; /** * Get a user-friendly display name based on the icon/provider. */ private getDefaultDisplayName; private getClient; /** * Ensure the filesystem is initialized and return the S3 client. * Uses base class ensureReady() for status management, then returns client. */ private getReadyClient; private toKey; readFile(path: string, options?: ReadOptions): Promise; writeFile(path: string, content: FileContent, options?: WriteOptions): Promise; appendFile(path: string, content: FileContent): Promise; deleteFile(path: string, options?: RemoveOptions): Promise; copyFile(src: string, dest: string, options?: CopyOptions): Promise; moveFile(src: string, dest: string, options?: CopyOptions): Promise; mkdir(_path: string, _options?: { recursive?: boolean; }): Promise; rmdir(path: string, options?: RemoveOptions): Promise; readdir(path: string, options?: ListOptions): Promise; exists(path: string): Promise; stat(path: string): Promise; isFile(path: string): Promise; isDirectory(path: string): Promise; /** * Initialize the S3 client. * Status management is handled by the base class. */ init(): Promise; /** * Clean up the S3 client. * Status management is handled by the base class. */ destroy(): Promise; } //# sourceMappingURL=index.d.ts.map