import type { Observable } from "rxjs"; export { RelaySession, connectRelay, createRelay, openRelayPath } from "./relay"; export type { CommentsNotebookRef, CreateRelayOptions, DaemonInfo, OpenRelayOptions, QueryDaemonOptions, RelayFrame, RelayInfo, } from "./relay"; export type NotebookDocPhase = "pending" | "syncing" | "interactive"; export type RuntimeStatePhase = "pending" | "syncing" | "ready"; export type InitialLoadPhase = | { phase: "not_needed" } | { phase: "streaming" } | { phase: "ready" } | { phase: "failed"; reason: string }; export interface SessionStatus { notebook_doc: NotebookDocPhase; runtime_state: RuntimeStatePhase; initial_load: InitialLoadPhase; } export interface ExecutionTransition { execution_id: string; kind: "started" | "done" | "error"; execution_count: number | null; } export interface ExecutionViewSnapshot { execution_count: number | null; status: "queued" | "running" | "done" | "error" | (string & {}); success: boolean | null; output_ids: string[]; submitted_by_actor_label?: string | null; } export interface ExecutionQueueProjection { executing_execution_id?: string | null; queued_execution_ids: string[]; notebook?: { executing_cell_id?: string | null; queued_cell_ids: string[]; } | null; } export interface ExecutionViewChangeset { cell_pointer_changes?: Array<[cell_id: string, execution_id: string | null]>; execution_upserts?: Array<[execution_id: string, snapshot: ExecutionViewSnapshot]>; removed_execution_ids?: string[]; queue?: ExecutionQueueProjection; } export interface ExecutionView { /** * Current non-null NotebookDoc cell -> execution_id pointers. * * Cleared or deleted cells are omitted. Subscribe to `executionViewChanges$` * when null pointer transitions matter. */ cell_execution_ids: Record; executions: Record; queue: ExecutionQueueProjection | null; } export type RuntimeState = Record; export type RuntimeKind = "python" | "deno" | (string & {}); export const PackageManager: { readonly Uv: "uv"; readonly Conda: "conda"; readonly Pixi: "pixi"; }; export type PackageManager = (typeof PackageManager)[keyof typeof PackageManager]; export const CreateNotebookEnvironmentMode: { readonly Auto: "auto"; readonly Project: "project"; readonly Notebook: "notebook"; }; export type CreateNotebookEnvironmentMode = (typeof CreateNotebookEnvironmentMode)[keyof typeof CreateNotebookEnvironmentMode]; export interface CreateNotebookOptions { runtime?: RuntimeKind; workingDir?: string; socketPath?: string; peerLabel?: string; description?: string; dependencies?: string[]; packageManager?: PackageManager; environmentMode?: CreateNotebookEnvironmentMode; } export interface OpenNotebookOptions { socketPath?: string; peerLabel?: string; description?: string; } export interface RunCellOptions { timeoutMs?: number; cellType?: "code" | "markdown" | "raw"; onUpdate?: (progress: CellResult) => void; } export interface QueueCellOptions { cellType?: "code" | "markdown" | "raw"; } export interface DependencyEditOptions { packageManager?: PackageManager; } export interface WaitExecutionOptions { cellId?: string; timeoutMs?: number; onUpdate?: (progress: CellResult) => void; } export interface QueuedExecution { cellId: string; executionId: string; } export interface JsOutput { outputType: string; name?: string; text?: string; dataJson?: string; ename?: string; evalue?: string; traceback?: string[]; executionCount?: number; blobUrlsJson?: string; blobPathsJson?: string; } export interface CellResult { cellId: string; executionId: string; executionCount?: number; status: | "done" | "error" | "timeout" | "kernel_error" | "kernel_failed" | "closed" | "queued" | "running" | (string & {}); success: boolean; outputs: JsOutput[]; } export interface SnapshotPair { notebookId: string; notebookBytes: Uint8Array; runtimeStateBytes: Uint8Array; commsDocBytes: Uint8Array; notebookHeads: string[]; runtimeStateHeads: string[]; commsDocHeads: string[]; blobBaseUrl?: string | null; blobStorePath?: string | null; } export interface EventSubscription { dispose(): void; } export interface CellSnapshot { id: string; cellType: string; position: string; source: string; metadataJson: string; executionCount?: string; } export interface CreateCellOptions { cellType?: "code" | "markdown" | "raw"; /** Omit to append at the end. 0 prepends; out-of-range values append. */ index?: number; /** * Insert after this cell. Cannot be combined with index. */ afterCellId?: string; } export interface SetCellOptions { source?: string; cellType?: "code" | "markdown" | "raw"; } export interface RuntimeStatus { status: string; lifecycle: string; activity?: string; startingPhase: string; name: string; language: string; envSource: string; runtimeAgentId: string; errorReason?: string; errorDetails?: string; } export interface DependencyStatus { uv?: { dependencies: string[]; requiresPython?: string; }; conda?: { dependencies: string[]; channels: string[]; python?: string; }; pixi?: { dependencies: string[]; pypiDependencies: string[]; channels: string[]; python?: string; }; fingerprint?: string; trust?: unknown; } export class Session { readonly notebookId: string; readonly runtimeState$: Observable; readonly executionTransitions$: Observable; readonly executionViewChanges$: Observable; readonly cellChanges$: Observable; readonly broadcasts$: Observable; readonly sessionStatus$: Observable; queueCell(source: string, options?: QueueCellOptions): Promise; waitForExecution(executionId: string, options?: WaitExecutionOptions): Promise; runCell(source: string, options?: RunCellOptions): Promise; saveNotebook(path?: string): Promise; exportSnapshotPair(): Promise; listCells(): Promise; getCell(cellId: string): Promise; createCell(source: string, options?: CreateCellOptions): Promise; setCell(cellId: string, options: SetCellOptions): Promise; deleteCell(cellId: string): Promise; moveCell(cellId: string, afterCellId?: string | null): Promise; executeCell(cellId: string, options?: { timeoutMs?: number }): Promise; showNotebook(): Promise; interruptKernel(): Promise; shutdownKernel(): Promise; restartKernel(): Promise; shutdownNotebook(): Promise; addDependency(pkg: string, options?: DependencyEditOptions): Promise; addDependencies(packages: string[], options?: DependencyEditOptions): Promise; removeDependency(pkg: string, options?: DependencyEditOptions): Promise; removeDependencies(packages: string[], options?: DependencyEditOptions): Promise; getDependencyStatus(): Promise; getRuntimeStatus(): Promise; getExecutionView(): ExecutionView; dependencyFingerprint(): Promise; approveTrust(observedHeads?: string[]): Promise; syncEnvironment(): Promise; close(): Promise; } export const NativeSession: unknown; export function defaultSocketPath(): string; export function socketPathForChannel(channel: "stable" | "nightly"): string; export function createNotebook(options?: CreateNotebookOptions): Promise; export function openNotebook(notebookId: string, options?: OpenNotebookOptions): Promise; export function openNotebookPath(path: string, options?: OpenNotebookOptions): Promise; export function getExecutionResult( executionId: string, options?: { socketPath?: string }, ): Promise; export interface ParquetColumnInfo { name: string; dataType: string; nullCount: number; statsJson: string; } export interface ParquetRowPage { columns: string[]; rows: string[][]; totalRows: number; offset: number; } export interface ParquetSummaryResult { numRows: number; numBytes: number; columns: ParquetColumnInfo[]; } export type TableRowPage = ParquetRowPage; export type TableSummaryResult = ParquetSummaryResult; export function blobStorePath(socketPath?: string | null): string | null; export function resolveBlobPath(hash: string, socketPath?: string | null): string | null; export function readParquetFile(filePath: string, offset: number, limit: number): ParquetRowPage; export function readArrowFile(filePath: string, offset: number, limit: number): ParquetRowPage; export function readArrowChunks(filePaths: string[], offset: number, limit: number): ParquetRowPage; export function summarizeParquetFile(filePath: string): ParquetSummaryResult; export function summarizeArrowFile(filePath: string): ParquetSummaryResult; export function summarizeArrowChunks(filePaths: string[]): ParquetSummaryResult;