import type { SandboxEnv } from '@fabric-harness/sdk'; import type { StatementExecutionClient } from '@databricks/sdk-statementexecution/v1'; import { type DatabricksPrincipal } from './identity.js'; /** * Sandbox backend that maps `exec(command)` to a Databricks SQL Statement * Execution API call against a SQL Warehouse. Useful for data agents whose * "shell" is a query interface. * * Behavior: * - `exec(sql)` runs the SQL synchronously (with a timeout) and returns the * serialized result set as `stdout` (newline-delimited JSON rows by default, * or CSV when `resultFormat: 'csv'`). * - File operations are intentionally minimal: the sandbox-virtual filesystem * keeps a small in-memory map. SQL warehouses are not file servers; mount * actual data via `databricksVolumeSource` from `@fabric-harness/connectors`. * * Usage: * ```ts * import { databricksSqlSandbox } from '@fabric-harness/databricks/sql-sandbox'; * * const fabric = await init({ * sandbox: databricksSqlSandbox({ * host: process.env.DATABRICKS_HOST!, * principal: { kind: 'pat', token: process.env.DATABRICKS_TOKEN! }, * warehouseId: process.env.DATABRICKS_WAREHOUSE_ID!, * }), * }); * ``` */ export interface DatabricksSqlSandboxOptions { host: string; principal: DatabricksPrincipal; /** SQL Warehouse ID to execute against. */ warehouseId: string; /** Optional Unity Catalog. */ catalog?: string; /** Optional schema. */ schema?: string; /** Result row serialization. Defaults to `'jsonl'`. */ resultFormat?: 'jsonl' | 'csv'; /** Wait timeout for the statement, in seconds (10–50). Defaults to `30`. */ waitTimeoutSeconds?: number; /** Custom fetch implementation (testing, OBO tokens, etc.). */ fetchImpl?: typeof fetch; /** Inject a pre-built native Statement Execution client. */ client?: Pick; } export interface DatabricksSqlSandboxRefData { host: string; warehouseId: string; catalog?: string; schema?: string; resultFormat?: 'jsonl' | 'csv'; waitTimeoutSeconds?: number; } export interface DatabricksSqlSandboxRegistrationOptions { /** Resolve credentials at creation/attach time. Credentials are never stored in a sandbox ref. */ resolvePrincipal?: (env: Record, target: DatabricksSqlSandboxRefData) => DatabricksPrincipal; /** Inject a client for tests or a provider-owned transport. */ client?: Pick; } export declare function databricksSqlSandbox(options: DatabricksSqlSandboxOptions): SandboxEnv; /** Register `sandbox: 'databricks'` and its credential-safe portable-ref decoder. */ export declare function registerDatabricksSqlSandboxBackend(registration?: DatabricksSqlSandboxRegistrationOptions): void; /** Remove both process-local registrations, primarily for tests and controlled shutdown. */ export declare function unregisterDatabricksSqlSandboxBackend(): void; //# sourceMappingURL=sql-sandbox.d.ts.map