Skip to content

smelt.notebook

Tier: Host - Available in every runtime, including headless mode.

Classification: Advanced - Documented low-level capability for plugins that need full control. It may evolve more freely than the Supported facade.

Parse and read notebook cells, apply edits, and compute preview data for the edit_notebook tool.

smelt.notebook.apply_edit

fun(args: table): any?, string?

Apply a notebook edit (cell insert/replace/delete) described by args and persist the new file. Returns (message_table, nil) on success or (nil, err_msg) on failure. Callers are expected to hold the per-path advisory flock.

smelt.notebook.apply_edit_async

fun(args: table): table?, string?

Apply a notebook edit off the main thread. Same return shape as smelt.notebook.apply_edit.

smelt.notebook.is_notebook_path

fun(path: string): boolean

Return true if path looks like a Jupyter notebook (.ipynb extension).

smelt.notebook.parse

fun(json: string): table?, string?

Parse a notebook JSON string. Returns (notebook, nil) with { nbformat, nbformat_minor, cells = { { kind, id?, source, execution_count? } } } on success, or (nil, error) on failure.

smelt.notebook.read

fun(path: string, offset: integer, limit: integer): string?, string?

Render a Jupyter notebook at path as cell-by-cell text starting at offset for at most limit cells. Returns (text, nil) on success or (nil, err_msg) on parse failure, matching the output the built-in read_file tool produces.

smelt.notebook.read_async

fun(path: string, offset: integer, limit: integer): string?, string?, string?, integer?

Render a notebook off the main thread. Same return shape as smelt.notebook.read, plus raw notebook JSON and mtime on success.