/* auto-generated by NAPI-RS */ /* eslint-disable */ /** A live event subscription returned by `Session.on*` methods. */ export declare class EventSubscription { /** Stop delivering events to the callback. */ dispose(): void } /** A native byte pipe between a Node host and one daemon notebook room. */ export declare class NativeRelaySession { get notebookId(): string get info(): RelayInfo get closed(): boolean /** Forward one complete typed frame (`type byte | payload`) to the daemon. */ send(frame: Buffer): Promise /** * Subscribe once to lossless inbound typed frames and relay closure. * * The receiver is single-consumer by design: one browser transport owns a * daemon connection. The returned subscription must stay alive for the * lifetime of the bridge. */ subscribeFrames(onFrame: (arg0: Buffer) => void, onClose: () => void): EventSubscription /** Close the native relay. Idempotent. */ close(): void } /** A connected notebook session. */ export declare class Session { /** The notebook ID (always a UUID). */ get notebookId(): string /** Subscribe to RuntimeStateDoc snapshots. Callback receives a JSON string. */ onRuntimeState(callback: (arg0: string) => void): EventSubscription /** Subscribe to execution lifecycle transitions. Callback receives a JSON string. */ onExecutionTransition(callback: (arg0: string) => void): EventSubscription /** Subscribe to shared execution-view changes. Callback receives a JSON string. */ onExecutionViewChange(callback: (arg0: string) => void): EventSubscription /** * Subscribe to resolved progress snapshots for one execution. * * Callback receives the same JSON shape as `CellResult`, emitted whenever * the RuntimeStateDoc entry for the execution changes. The subscription * ends after an authoritative terminal snapshot, including kernel * failure/close. */ onExecutionProgress(executionId: string, cellId: string | undefined | null, callback: (arg0: string) => void): EventSubscription /** * Subscribe to notebook document changes. Callback receives a JSON string. * * The native handle currently reports `null` as a full-materialization * marker, matching the browser SyncEngine's no-changeset fallback. */ onCellChange(callback: (arg0: string) => void): EventSubscription /** Subscribe to comm broadcasts. Callback receives a JSON string. */ onBroadcast(callback: (arg0: string) => void): EventSubscription /** Subscribe to handshake/readiness status updates. Callback receives a JSON string. */ onSessionStatus(callback: (arg0: string) => void): EventSubscription /** * Save the notebook to disk. If a path is given, saves to that path * (creating the file if needed). Otherwise saves to the original location. */ saveNotebook(path?: string | undefined | null): Promise /** * Export the live synced notebook, runtime-state, and comms documents. * * This waits for all document channels to converge with the daemon * before serializing, so hosted publish clients can upload a coherent * `NotebookDoc` + `RuntimeStateDoc` + `CommsDoc` snapshot triplet. */ exportSnapshotPair(): Promise /** Close the session and release the underlying connection. */ close(): Promise /** * Add dependencies to the selected package manager in one CRDT transaction. * When no manager is provided, the running/configured notebook manager is used. * Call `syncEnvironment()` or restart the kernel to install them. */ addDependencies(packages: Array, options?: DependencyEditOptions | undefined | null): Promise /** * Add a dependency to the selected package manager. * When no manager is provided, the running/configured notebook manager is used. * Call `syncEnvironment()` or restart the kernel to install it. */ addDependency(pkg: string, options?: DependencyEditOptions | undefined | null): Promise /** * Remove dependencies from the selected package manager in one CRDT transaction. * When no manager is provided, the running/configured notebook manager is used. * Returns the number of dependencies removed. */ removeDependencies(packages: Array, options?: DependencyEditOptions | undefined | null): Promise /** * Remove a dependency from the selected package manager. * When no manager is provided, the running/configured notebook manager is used. * Returns true if a dependency was removed. */ removeDependency(pkg: string, options?: DependencyEditOptions | undefined | null): Promise /** * Add a UV dependency to the notebook (e.g. `"matplotlib>=3.8"`). * Call `syncEnvironment()` or restart the kernel to install it. */ addUvDependency(pkg: string): Promise /** Get runtime/kernel state, including lifecycle error details. */ getRuntimeStatus(): Promise /** Get dependency metadata, fingerprint, and current trust state. */ getDependencyStatus(): Promise /** Get the current dependency fingerprint for diagnostics. */ dependencyFingerprint(): Promise /** Approve and sign the current dependency metadata. */ approveTrust(observedHeads?: Array | undefined | null): Promise /** * Ask the daemon to hot-install any pending dependency changes into * the running kernel's env. Starts the kernel first if needed. * Returns once the install finishes. */ syncEnvironment(): Promise /** Return all cells in notebook order. */ listCells(): Promise> /** Return one cell by ID, or null if it does not exist. */ getCell(cellId: string): Promise /** Create a cell without executing it. Returns the new cell ID. */ createCell(source: string, options?: CreateCellOptions | undefined | null): Promise /** Replace a cell's source and/or type. Returns true if the cell existed. */ setCell(cellId: string, options: SetCellOptions): Promise /** Delete a cell. Returns true if the cell existed. */ deleteCell(cellId: string): Promise /** * Move a cell after another cell, or to the beginning when omitted/null. * Returns the new position string. */ moveCell(cellId: string, options?: MoveCellOptions | undefined | null): Promise /** Execute an existing code cell and wait for terminal outputs. */ executeCell(cellId: string, options?: ExecuteCellOptions | undefined | null): Promise /** * Execute a source string as a new cell. Starts the kernel on demand. * Returns the cell's outputs once execution is terminal. */ runCell(source: string, options?: RunCellOptions | undefined | null): Promise /** Queue a source string as a new cell without waiting for execution. */ queueCell(source: string, options?: QueueCellOptions | undefined | null): Promise /** Interrupt the currently executing cell. */ interruptKernel(): Promise /** Shutdown the running kernel. Returns false when no kernel is running. */ shutdownKernel(): Promise /** Restart the kernel, clearing in-memory state while preserving notebook dependencies. */ restartKernel(): Promise /** Shutdown this notebook's kernel and evict its daemon room. */ shutdownNotebook(): Promise /** * Open this notebook in nteract Desktop. In headless environments, returns * `opened: false` with a reason instead of failing. */ showNotebook(): Promise /** Wait for an already-queued execution in this live session. */ waitForExecution(executionId: string, options?: WaitExecutionOptions | undefined | null): Promise } /** An active notebook room reported by the daemon. */ export interface ActiveNotebook { notebookId: string activePeers: number hadPeers: boolean hasKernel: boolean kernelType?: string envSource?: string kernelStatus?: string ephemeral: boolean notebookPath?: string } /** Return the local blob store root for the selected daemon, when present. */ export declare function blobStorePath(socketPath?: string | undefined | null): string | null /** Result of running a cell. */ export interface CellResult { cellId: string executionId: string executionCount?: number /** One of: `"done"`, `"error"`, `"timeout"`, `"kernel_error"`. */ status: string success: boolean outputs: Array } /** Conda dependency metadata. */ export interface CondaDependencyStatus { dependencies: Array channels: Array python?: string } /** * Join an active notebook room by ID and return its native typed-frame relay. * * The daemon treats this API as an operator connection. Embedding hosts must * authorize the requested notebook ID before calling it and must not expose * room discovery or this relay directly to an untrusted browser context. */ export declare function connectRelay(notebookId: string, options?: OpenRelayOptions | undefined | null): Promise /** Options for `Session.createCell()`. */ export interface CreateCellOptions { /** Cell source type: `"code"` (default), `"markdown"`, or `"raw"`. */ cellType?: string /** Insert after this cell, or omit to append at the end. */ afterCellId?: string /** * Position to insert at. Omit to append; 0 prepends; out-of-range appends. * Cannot be combined with `afterCellId`. */ index?: number } /** Create a new (ephemeral) notebook against the daemon. */ export declare function createNotebook(options?: CreateNotebookOptions | undefined | null): Promise /** Environment source mode for `createNotebook()`. */ export declare const enum CreateNotebookEnvironmentMode { Auto = 'auto', Project = 'project', Notebook = 'notebook' } /** Options for `createNotebook()`. */ export interface CreateNotebookOptions { /** Runtime type: `"python"` or `"deno"`. Defaults to `"python"`. */ runtime?: string /** Working directory for the kernel. */ workingDir?: string /** Override daemon socket path (otherwise uses `default_socket_path()`). */ socketPath?: string /** Actor label for presence / Automerge provenance. */ peerLabel?: string /** Human-readable session description. Used as the peer label when `peerLabel` is omitted. */ description?: string /** * Packages to record before the kernel starts (for example `["numpy", "matplotlib"]`). * Python notebooks use the selected package manager; Deno notebooks treat these as * runtime-native import dependencies. */ dependencies?: Array /** Package manager for Python dependencies. Defaults to the daemon/user setting. */ packageManager?: PackageManager /** Environment source mode. Defaults to auto. */ environmentMode?: CreateNotebookEnvironmentMode } /** Create a notebook room and return its native typed-frame relay. */ export declare function createRelay(options?: CreateRelayOptions | undefined | null): Promise export interface CreateRelayOptions { /** Runtime type. Defaults to `"python"`. */ runtime?: string /** Kernel working directory. */ workingDir?: string /** Override the daemon endpoint. */ socketPath?: string /** Restore or join an untitled notebook room by ID. */ notebookId?: string /** Actor/operator label advertised during the handshake. */ peerLabel?: string /** Human-readable fallback for `peerLabel`. */ description?: string /** Keep the notebook only in memory. Defaults to false. */ ephemeral?: boolean /** Dependencies to seed into notebook metadata. */ dependencies?: Array /** Package manager preference for seeded dependencies. */ packageManager?: PackageManager /** Project/notebook environment inheritance mode. */ environmentMode?: CreateNotebookEnvironmentMode } /** Daemon metadata needed by a Node host before it opens a notebook relay. */ export interface DaemonInfo { version: string socketPath: string isDevMode: boolean blobPort?: number } /** * Return the default daemon socket path. * * Respects `RUNTIMED_SOCKET_PATH` if set. In dev mode * (`RUNTIMED_WORKSPACE_PATH` set) returns the per-worktree socket. */ export declare function defaultSocketPath(): string /** Options for dependency edit methods. */ export interface DependencyEditOptions { /** * Dependency manager to edit. Defaults to the running/configured manager, * falling back to UV for fresh Python notebooks. */ packageManager?: PackageManager } /** Notebook dependency metadata and trust/runtime status. */ export interface DependencyStatus { uv?: UvDependencyStatus conda?: CondaDependencyStatus pixi?: PixiDependencyStatus fingerprint?: string trust: DependencyTrustStatus } /** Notebook trust state for dependency metadata. */ export interface DependencyTrustStatus { status?: string needsApproval?: boolean approvedUvDependencies: Array approvedCondaDependencies: Array approvedPixiDependencies: Array approvedPixiPypiDependencies: Array } /** Options for `Session.executeCell()`. */ export interface ExecuteCellOptions { /** Max milliseconds to wait for execution. Default 120_000 (2 min). */ timeoutMs?: number } /** Read a terminal execution result from the daemon's durable execution store. */ export declare function getExecutionResult(executionId: string, options?: GetExecutionResultOptions | undefined | null): Promise /** Options for top-level `getExecutionResult()`. */ export interface GetExecutionResultOptions { /** Override daemon socket path (otherwise uses `defaultSocketPath()`). */ socketPath?: string } /** A notebook cell snapshot. */ export interface JsCellSnapshot { id: string cellType: string position: string source: string /** JSON-encoded metadata object. */ metadataJson: string /** Legacy execution count as stored in the notebook doc. */ executionCount?: string } /** One output from a cell. `data` values are: `{ type: "text"|"binary"|"json", value: ... }`. */ export interface JsOutput { outputType: string name?: string text?: string /** MIME-keyed map, serialized via JSON. Binary values become base64 strings. */ dataJson?: string ename?: string evalue?: string traceback?: Array executionCount?: number blobUrlsJson?: string blobPathsJson?: string } /** List active notebook rooms from the daemon. */ export declare function listActiveNotebooks(options?: ListActiveNotebooksOptions | undefined | null): Promise> /** Options for top-level `listActiveNotebooks()`. */ export interface ListActiveNotebooksOptions { /** Override daemon socket path (otherwise uses `defaultSocketPath()`). */ socketPath?: string } /** Options for `Session.moveCell()`. */ export interface MoveCellOptions { /** Move after this cell, or omit/null to move to the beginning. */ afterCellId?: string } /** Open an existing notebook by ID. */ export declare function openNotebook(notebookId: string, options?: OpenNotebookOptions | undefined | null): Promise /** Options for `openNotebook()` and `openNotebookPath()`. */ export interface OpenNotebookOptions { socketPath?: string peerLabel?: string /** Human-readable session description. Used as the peer label when `peerLabel` is omitted. */ description?: string } /** Open an existing notebook file by path. */ export declare function openNotebookPath(path: string, options?: OpenNotebookOptions | undefined | null): Promise export interface OpenRelayOptions { /** Override the daemon endpoint. */ socketPath?: string /** Actor/operator label advertised during the handshake. */ peerLabel?: string /** Human-readable fallback for `peerLabel`. */ description?: string } /** Open a notebook file and return its native typed-frame relay. */ export declare function openRelayPath(path: string, options?: OpenRelayOptions | undefined | null): Promise /** * Package manager for Python notebook dependencies. * * This mirrors `notebook_protocol::connection::PackageManager` at the N-API * boundary. We cannot attach `#[napi]` to the protocol crate's external enum, * and that enum intentionally includes an `Unknown(String)` wire-compatibility * variant that should not be exposed as a typed JavaScript option. */ export declare const enum PackageManager { Uv = 'uv', Conda = 'conda', Pixi = 'pixi' } export interface ParquetColumnInfo { name: string dataType: string nullCount: number /** JSON-encoded column stats (numeric: {min, max}, string: {distinct_count, top}, etc.) */ statsJson: string } /** A page of rows from a parquet file, as string values for display. */ export interface ParquetRowPage { columns: Array /** Row data — outer vec is rows, inner vec is column values as display strings. */ rows: Array> totalRows: number offset: number } /** Summary of a parquet dataset — column names, types, stats. */ export interface ParquetSummaryResult { numRows: number numBytes: number columns: Array } /** Pixi dependency metadata. */ export interface PixiDependencyStatus { dependencies: Array pypiDependencies: Array channels: Array python?: string } /** * Probe the selected daemon and return its host-facing metadata when ready. * * `None` intentionally covers both an absent endpoint and a daemon that has * bound its socket but is not ready to answer pool requests yet. Hosts can * poll this function while supervising a cold start without cloning the wire * protocol in JavaScript. */ export declare function queryDaemonInfo(options?: QueryDaemonOptions | undefined | null): Promise export interface QueryDaemonOptions { /** Override the daemon endpoint. */ socketPath?: string } /** Options for `Session.queueCell()`. */ export interface QueueCellOptions { /** Cell source type: `"code"` (default), `"markdown"`, or `"raw"`. */ cellType?: string } /** A queued execution handle. */ export interface QueuedExecution { cellId: string executionId: string } /** Read a page of rows from ordered Arrow IPC chunk files as one logical table. */ export declare function readArrowChunks(filePaths: Array, offset: number, limit: number): ParquetRowPage /** Read a page of rows from an Arrow IPC stream at a local blob/file path. */ export declare function readArrowFile(filePath: string, offset: number, limit: number): ParquetRowPage /** * Read a page of rows from a local blob/file path. * Returns string representations of each cell for display. */ export declare function readParquetFile(filePath: string, offset: number, limit: number): ParquetRowPage /** Bootstrap and daemon metadata needed by a browser host. */ export interface RelayInfo { notebookId: string cellCount?: number needsTrustApproval?: boolean ephemeral?: boolean notebookPath?: string runtime?: string actorLabel?: string connectionScope?: string commentsDocId?: string /** JSON encoding of the daemon-authoritative notebook reference. */ commentsNotebookRefJson?: string protocol: string protocolVersion?: number daemonVersion?: string socketPath: string blobPort?: number isDevMode: boolean } /** Resolve a blob hash to the local on-disk blob path for the selected daemon. */ export declare function resolveBlobPath(hash: string, socketPath?: string | undefined | null): string | null /** Options for `Session.runCell()`. */ export interface RunCellOptions { /** Max milliseconds to wait for execution. Default 120_000 (2 min). */ timeoutMs?: number /** Cell source type: `"code"` (default), `"markdown"`, or `"raw"`. */ cellType?: string } /** Runtime/kernel status from RuntimeStateDoc. */ export interface RuntimeStatus { status: string lifecycle: string activity?: string startingPhase: string name: string language: string envSource: string runtimeAgentId: string errorReason?: string errorDetails?: string } /** Options for `Session.setCell()`. */ export interface SetCellOptions { /** New source text. Omit to leave unchanged. */ source?: string /** New cell source type. Omit to leave unchanged. */ cellType?: string } /** * Open a notebook in nteract Desktop by active notebook ID or file path. * In headless environments, returns `opened: false` with a reason instead of failing. */ export declare function showNotebook(options?: ShowNotebookOptions | undefined | null): Promise /** Options for top-level `showNotebook()`. */ export interface ShowNotebookOptions { /** Override daemon socket path (otherwise uses `defaultSocketPath()`). */ socketPath?: string /** Active notebook UUID to open in the app. */ notebookId?: string /** File path to open in the app. If both path and notebookId are provided, path wins. */ path?: string } /** Result of asking nteract Desktop to show a notebook. */ export interface ShowNotebookResult { notebookId?: string path?: string opened: boolean reason?: string warning?: string } /** Shutdown a notebook's kernel and evict its daemon room by notebook ID. */ export declare function shutdownNotebook(notebookId: string, options?: ShutdownNotebookOptions | undefined | null): Promise /** Options for top-level `shutdownNotebook()`. */ export interface ShutdownNotebookOptions { /** Override daemon socket path (otherwise uses `defaultSocketPath()`). */ socketPath?: string } /** Serialized notebook + runtime-state + comms snapshots for hosted publishing. */ export interface SnapshotPair { notebookId: string notebookBytes: Buffer runtimeStateBytes: Buffer commsDocBytes: Buffer notebookHeads: Array runtimeStateHeads: Array commsDocHeads: Array blobBaseUrl?: string blobStorePath?: string } /** * Return the daemon socket path for a specific channel ("stable" or * "nightly"). Ignores `RUNTIMED_SOCKET_PATH`. */ export declare function socketPathForChannel(channel: string): string /** Summarize ordered Arrow IPC chunk files as one logical table. */ export declare function summarizeArrowChunks(filePaths: Array): ParquetSummaryResult /** Summarize an Arrow IPC stream from a local blob/file path. */ export declare function summarizeArrowFile(filePath: string): ParquetSummaryResult /** Summarize a parquet file from a local blob/file path. */ export declare function summarizeParquetFile(filePath: string): ParquetSummaryResult /** UV dependency metadata. */ export interface UvDependencyStatus { dependencies: Array requiresPython?: string } /** Options for `Session.waitForExecution()`. */ export interface WaitExecutionOptions { /** Cell ID to use when reporting kernel failures before terminal state syncs. */ cellId?: string /** Max milliseconds to wait for execution. Default 120_000 (2 min). */ timeoutMs?: number }