Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aipoch/open-science/llms.txt
Use this file to discover all available pages before exploring further.
window.api.notebook provides full programmatic control over the Python kernel that Open Science manages for each session. The kernel persists across agent turns — variables, imports, and loaded data remain available throughout a conversation. All notebook commands are routed through typed IPC so renderer code never communicates with the local RPC server directly.
Session routing
Every notebook command requires aNotebookSessionRequest as its base, which provides the routing fields the main process uses to locate the correct kernel session:
| Field | Type | Required | Description |
|---|---|---|---|
sessionId | string | ✓ | ACP session ID that owns this notebook |
workspaceCwd | string | ✓ | Absolute path of the session working directory |
projectName | string | — | Project scope; defaults to the runtime default when omitted |
Methods
state(request)
Returns a snapshot of the current notebook session including kernel status, all cells, active write locks, and the full run history.
Session routing fields (
sessionId, workspaceCwd, projectName?).Promise<NotebookSessionState>
beginCodeCell(request)
Starts a streamed code write into a notebook cell. Acquires an exclusive write lock — subsequent appendCodeCell and finishCodeCell calls must reference the returned writeId.
Extends
NotebookSessionRequest with:Promise<{ sessionId: string; cellId: string; writeId: string; status: string }>
The resolved session ID.
ID of the cell that was opened for writing.
Exclusive write lock token. Pass this to every subsequent append and finish call.
Initial cell status (typically
'receiving-code').appendCodeCell(request)
Appends a text delta to the cell currently held by the given write lock. Call repeatedly to stream code content incrementally.
Extends
NotebookSessionRequest with:Promise<{ sessionId: string; cellId: string; writeId: string; receivedBytes: number }>
Total bytes received for this cell so far (useful for progress display).
finishCodeCell(request)
Releases the write lock after all code chunks have been appended. The cell transitions from 'receiving-code' to 'idle' and becomes ready for execution.
Extends
NotebookSessionRequest with:Promise<{ sessionId: string; cellId: string; code: string; status: string }>
The complete assembled code of the cell after all deltas were applied.
Final cell status after the lock is released.
runCell(request)
Executes an existing cell by ID in the shared Python interpreter. The cell must exist and must not currently hold a write lock.
Extends
NotebookSessionRequest with:Promise<NotebookRunSummary>
execute(request)
Convenience method that writes a temporary cell with the provided code and immediately executes it. Use this when you don’t need a persistent cell — for example, to run a single expression or a quick setup block.
Extends
NotebookSessionRequest with:Promise<NotebookRunSummary>
restart(request)
Restarts the Python kernel for the session, clearing all in-memory variables and module state. Previously written cells are preserved; only the runtime state is reset.
Session routing fields.
Promise<NotebookSessionState> — the updated session state with kernelStatus: 'starting'.
shutdown(request)
Shuts down the Python kernel for the session. The kernel will be restarted automatically on the next operation that requires it.
Session routing fields.
Promise<{ sessionId: string; status: 'shutdown' }>
Event listeners
onAvailable(listener)
Fired when a new notebook session becomes available (kernel started and ready). Subscribe to this to know when the notebook tab can be shown for a session.
Receives a
NotebookSessionReference with session routing fields.() => void — unsubscribe function.
onChanged(listener)
Fired when the notebook session state changes (cell added, run completed, kernel status changed, etc.). Use this to refresh the notebook view without polling.
Receives a
NotebookSessionReference with session routing fields.() => void — unsubscribe function.
Type reference
NotebookSessionState
The full renderer-facing snapshot of one shared notebook interpreter session.
Internal session record ID.
ACP session ID that owns this notebook.
Artifact session scope when set by the agent.
Current working directory of the kernel process.
Root directory for this notebook session’s persistent files.
Root directory for session data files.
Root directory for the Python runtime environment.
Absolute path to the Python executable.
Current kernel status:
'idle' | 'starting' | 'running' | 'error' | 'shutdown'Path to the
run.json file that persists run history.All notebook cells in creation order.
The currently held write lock, if any.
ID of the currently executing run, if any.
Full run history for this session.
A bounded subset of recent runs for fast UI rendering.
NotebookRunSummary
Extends NotebookRunRecord with workspace root paths so the agent can decide what to do next.
Unique run identifier.
Cell that was executed.
The Python code that was executed.
Final execution status.
Start time (epoch milliseconds).
End time (epoch milliseconds).
Kernel execution counter.
Structured stdout, stderr, traceback, and plain-text projection.
Rich output items (stream, error, text, JSON).
Files generated during this run.
Notebook session root (from
NotebookRunSummary extension).Data root.
Python runtime root.
Kernel display name.
NotebookRunStatus values
| Value | Description |
|---|---|
'queued' | Execution is scheduled but has not started |
'running' | Kernel is currently executing the cell |
'completed' | Execution finished successfully |
'failed' | Execution raised an unhandled exception |
'timeout' | Execution exceeded timeoutMs |
'interrupted' | Execution was cancelled by a kernel restart or explicit interrupt |
NotebookRunInputKind values
| Value | Description |
|---|---|
'cell' | Code originated from a notebook cell (default) |
'terminal' | Code submitted from the user terminal panel |