import { Benchify } from "./client.js"; import { StackExecuteCommandResponse, StackWriteFileResponse, type StackRetrieveResponse, StackReadFileResponse, StackResetResponse, StackGetLogsResponse } from "./resources/stacks.js"; /** * A file to include in a stack */ export interface StackFile { /** Relative path within the stack (e.g. 'src/index.ts') */ path: string; /** File contents as string or binary data */ contents: string | Uint8Array; } /** * A file change to apply to a running stack * * Omit `contents` to delete the file. */ export interface FileChange { /** Path of the file to change or delete */ path: string; /** New contents, or undefined to delete */ contents?: string | Uint8Array; } /** * Configuration options for creating a stack */ export interface StackCreateOptions { name?: string; buildCommand?: string; startCommand?: string; port?: number; subdomain?: string; environment?: Record; runtime?: { nodeVersion?: string; packageManager?: 'npm' | 'yarn' | 'pnpm'; framework?: 'react' | 'nextjs' | 'vue' | 'nuxt' | 'express' | 'fastify' | 'nest' | 'vite'; }; bundle?: boolean; } /** * Handle for interacting with a running stack * * This is a stateless client - all stack state is managed server-side. * The handle only tracks the etag for optimistic concurrency control. */ export declare class StackHandle { private _client; private _id; private _url; private _stackId; private _kind; private _etag; private _workspaceMap; constructor(client: Benchify, id: string, url: string, kind: 'single' | 'stack', etag: string, stackId?: string, workspaceMap?: Record); get id(): string; get url(): string; get stackId(): string | undefined; get kind(): 'single' | 'stack'; /** * Apply file changes to the stack * * Changes are sent to the server which handles deduplication and change detection. * If a conflict occurs (another client modified the stack), will retry once automatically. * * @param changes - Array of file changes. Omit `contents` to delete a file. */ apply(changes: FileChange[]): Promise; /** * Fetch the current status of the stack */ status(): Promise; waitForDevServerURL(): Promise; executeCommand(command: string): Promise; getLogs(): Promise; getSandboxIP(): Promise; writeFile(path: string, content: string): Promise; resetSandbox(tarballBase64: string, tarballFilename: string): Promise; readFile(path: string): Promise; /** * Permanently destroy the stack and free resources */ destroy(): Promise; private _applyChangesInternal; private _refreshStatus; private _isConflictError; } /** * Stacks API for creating and managing sandboxes * * Use `stack.create()` to create a new stack, which returns a StackHandle. * Keep the handle to perform operations like applying changes or checking status. * * If you lose the handle, use `stack.get(id)` to retrieve it. * * @example * ```typescript * // Create a new stack * const handle = await client.stack.create(files); * * // Reconnect to an existing stack * const handle2 = await client.stack.get('stack_abc123'); * ``` */ export declare class Stacks { private _client; constructor(client: Benchify); /** * Create a new stack with the provided files and configuration * * Files are automatically filtered to exclude common build artifacts and dependencies. * Returns a StackHandle for interacting with the running stack. * * @param files - Array of files to include in the stack * @param opts - Stack configuration (name, build/start commands, environment, etc.) * @returns A handle for the created stack * * @example * ```typescript * const stack = await client.stack.create([ * { path: 'index.js', contents: 'console.log("Hello!")' } * ], { * name: 'my-app', * startCommand: 'node index.js' * }); * * console.log(stack.url); // https://... * ``` */ create(files: StackFile[], opts?: StackCreateOptions): Promise; /** * Get a handle to an existing stack by ID * * Useful if you lost the original handle or need to connect to a stack in a new session. * * @param id - The stack ID * @returns A handle for the existing stack * * @example * ```typescript * // Reconnect to an existing stack * const stack = await client.stack.get('stack_abc123'); * const status = await stack.status(); * ``` */ get(id: string): Promise; waitForDevServerURL(id: string, params?: { interval?: number; timeout?: number; }): Promise<{ url: string; }>; private _filterFiles; private _generateIdempotencyKey; } //# sourceMappingURL=stacks.d.ts.map