@runtimed/node 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,6 @@ async function main() {
26
26
  workingDir: process.cwd(),
27
27
  // Record these before the first cell runs.
28
28
  dependencies: ["numpy", "matplotlib"],
29
- packageManager: "uv",
30
29
  description: "plotting smoke test",
31
30
  });
32
31
 
@@ -61,11 +60,15 @@ main().catch((error) => {
61
60
  ## Notebook Dependencies
62
61
 
63
62
  `createNotebook()` accepts `dependencies` so agent code can declare packages
64
- up-front instead of failing the first import and retrying after `addUvDependency()`.
65
- The `packageManager` option is typed from the native binding's `PackageManager`
66
- string enum (`"uv"`, `"conda"`, or `"pixi"`) and is converted to the shared
67
- notebook protocol enum before the daemon handshake. `description` can be used
68
- as a human-readable peer label for agent-created sessions.
63
+ up-front instead of failing the first import and retrying after `addDependencies()`.
64
+ When `packageManager` is omitted, the daemon/user environment choice remains in
65
+ charge. Later dependency edits also infer the manager from the running kernel,
66
+ inline notebook metadata (`uv`, then `conda`, then `pixi`), or detected project
67
+ file, falling back to UV for fresh Python notebooks with no other signal. Pass
68
+ the native binding's `PackageManager` string enum (`"uv"`, `"conda"`, or
69
+ `"pixi"`) only when you need to target a specific metadata section.
70
+ `description` can be used as a human-readable peer label for agent-created
71
+ sessions.
69
72
 
70
73
  ## API Surface
71
74
 
@@ -94,17 +97,22 @@ as a human-readable peer label for agent-created sessions.
94
97
  - `Session.runCell(source, options)` creates, runs, and waits for a cell.
95
98
  - `Session.queueCell(source, options)` queues a cell and returns IDs.
96
99
  - `Session.waitForExecution(executionId, options)` waits for queued work.
100
+ Pass `onUpdate(progress)` to receive resolved output snapshots while the
101
+ execution is still running.
102
+ - `Session.runtimeState$`, `Session.executionTransitions$`,
103
+ `Session.cellChanges$`, `Session.broadcasts$`, and `Session.sessionStatus$`
104
+ expose the same projected event families used by the browser sync engine.
97
105
  - `Session.addDependency(spec, { packageManager })` /
98
106
  `Session.addDependencies(specs, { packageManager })` and
99
107
  `Session.removeDependency(spec, { packageManager })` /
100
108
  `Session.removeDependencies(specs, { packageManager })` edit notebook
101
- dependency metadata for UV, Conda, or Pixi. Batch variants use one CRDT
109
+ dependency metadata for UV, Conda, or Pixi. Omit `packageManager` to follow
110
+ the notebook's running/configured manager. Batch variants use one CRDT
102
111
  metadata transaction.
103
112
  - `Session.getDependencyStatus()` returns dependency metadata, fingerprint, and
104
113
  trust state in one call.
105
114
  - `Session.getRuntimeStatus()` returns kernel lifecycle, activity, env source,
106
115
  and startup error details.
107
- - `Session.addUvDependency(spec)` records a UV dependency for the notebook.
108
116
  - `Session.syncEnvironment()` installs recorded notebook dependencies.
109
117
  - `Session.saveNotebook(path?)` saves the notebook.
110
118
  - `Session.close()` releases the daemon connection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtimed/node",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Node.js bindings for controlling nteract runtimed notebooks and Python kernels.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -35,6 +35,8 @@
35
35
  "README.md",
36
36
  "src/index.cjs",
37
37
  "src/index.d.ts",
38
+ "src/session.cjs",
39
+ "src/napi-observables.cjs",
38
40
  "src/binding.cjs",
39
41
  "src/binding.d.ts"
40
42
  ],
@@ -46,10 +48,14 @@
46
48
  "x86_64-pc-windows-msvc"
47
49
  ]
48
50
  },
51
+ "dependencies": {
52
+ "rxjs": "^7.8.2",
53
+ "runtimed": "0.2.4"
54
+ },
49
55
  "optionalDependencies": {
50
- "@runtimed/node-linux-x64-gnu": "0.2.0",
51
- "@runtimed/node-darwin-arm64": "0.2.0",
52
- "@runtimed/node-win32-x64-msvc": "0.2.0"
56
+ "@runtimed/node-darwin-arm64": "0.2.2",
57
+ "@runtimed/node-linux-x64-gnu": "0.2.2",
58
+ "@runtimed/node-win32-x64-msvc": "0.2.2"
53
59
  },
54
60
  "publishConfig": {
55
61
  "access": "public"
package/src/binding.cjs CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@runtimed/node-android-arm64')
79
79
  const bindingPackageVersion = require('@runtimed/node-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@runtimed/node-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@runtimed/node-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@runtimed/node-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@runtimed/node-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@runtimed/node-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@runtimed/node-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@runtimed/node-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@runtimed/node-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@runtimed/node-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@runtimed/node-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@runtimed/node-darwin-universal')
184
184
  const bindingPackageVersion = require('@runtimed/node-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@runtimed/node-darwin-x64')
200
200
  const bindingPackageVersion = require('@runtimed/node-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@runtimed/node-darwin-arm64')
216
216
  const bindingPackageVersion = require('@runtimed/node-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@runtimed/node-freebsd-x64')
236
236
  const bindingPackageVersion = require('@runtimed/node-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@runtimed/node-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@runtimed/node-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@runtimed/node-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@runtimed/node-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@runtimed/node-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@runtimed/node-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@runtimed/node-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@runtimed/node-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@runtimed/node-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@runtimed/node-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@runtimed/node-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@runtimed/node-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@runtimed/node-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@runtimed/node-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@runtimed/node-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@runtimed/node-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@runtimed/node-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@runtimed/node-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@runtimed/node-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@runtimed/node-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@runtimed/node-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@runtimed/node-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@runtimed/node-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@runtimed/node-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@runtimed/node-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@runtimed/node-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@runtimed/node-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@runtimed/node-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@runtimed/node-openharmony-x64')
494
494
  const bindingPackageVersion = require('@runtimed/node-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@runtimed/node-openharmony-arm')
510
510
  const bindingPackageVersion = require('@runtimed/node-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,6 +576,7 @@ if (!nativeBinding) {
576
576
  }
577
577
 
578
578
  module.exports = nativeBinding
579
+ module.exports.EventSubscription = nativeBinding.EventSubscription
579
580
  module.exports.Session = nativeBinding.Session
580
581
  module.exports.createNotebook = nativeBinding.createNotebook
581
582
  module.exports.defaultSocketPath = nativeBinding.defaultSocketPath
package/src/binding.d.ts CHANGED
@@ -1,9 +1,39 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ /** A live event subscription returned by `Session.on*` methods. */
4
+ export declare class EventSubscription {
5
+ /** Stop delivering events to the callback. */
6
+ dispose(): void
7
+ }
8
+
3
9
  /** A connected notebook session. */
4
10
  export declare class Session {
5
11
  /** The notebook ID (always a UUID). */
6
12
  get notebookId(): string
13
+ /** Subscribe to RuntimeStateDoc snapshots. Callback receives a JSON string. */
14
+ onRuntimeState(callback: (arg0: string) => void): EventSubscription
15
+ /** Subscribe to execution lifecycle transitions. Callback receives a JSON string. */
16
+ onExecutionTransition(callback: (arg0: string) => void): EventSubscription
17
+ /**
18
+ * Subscribe to resolved progress snapshots for one execution.
19
+ *
20
+ * Callback receives the same JSON shape as `CellResult`, emitted whenever
21
+ * the RuntimeStateDoc entry for the execution changes. The subscription
22
+ * ends after an authoritative terminal snapshot, including kernel
23
+ * failure/close.
24
+ */
25
+ onExecutionProgress(executionId: string, cellId: string | undefined | null, callback: (arg0: string) => void): EventSubscription
26
+ /**
27
+ * Subscribe to notebook document changes. Callback receives a JSON string.
28
+ *
29
+ * The native handle currently reports `null` as a full-materialization
30
+ * marker, matching the browser SyncEngine's no-changeset fallback.
31
+ */
32
+ onCellChange(callback: (arg0: string) => void): EventSubscription
33
+ /** Subscribe to comm broadcasts. Callback receives a JSON string. */
34
+ onBroadcast(callback: (arg0: string) => void): EventSubscription
35
+ /** Subscribe to handshake/readiness status updates. Callback receives a JSON string. */
36
+ onSessionStatus(callback: (arg0: string) => void): EventSubscription
7
37
  /**
8
38
  * Save the notebook to disk. If a path is given, saves to that path
9
39
  * (creating the file if needed). Otherwise saves to the original location.
@@ -12,22 +42,26 @@ export declare class Session {
12
42
  /** Close the session and release the underlying connection. */
13
43
  close(): Promise<void>
14
44
  /**
15
- * Add dependencies to the selected package manager (defaults to UV) in one CRDT transaction.
45
+ * Add dependencies to the selected package manager in one CRDT transaction.
46
+ * When no manager is provided, the running/configured notebook manager is used.
16
47
  * Call `syncEnvironment()` or restart the kernel to install them.
17
48
  */
18
49
  addDependencies(packages: Array<string>, options?: DependencyEditOptions | undefined | null): Promise<void>
19
50
  /**
20
- * Add a dependency to the selected package manager (defaults to UV).
51
+ * Add a dependency to the selected package manager.
52
+ * When no manager is provided, the running/configured notebook manager is used.
21
53
  * Call `syncEnvironment()` or restart the kernel to install it.
22
54
  */
23
55
  addDependency(pkg: string, options?: DependencyEditOptions | undefined | null): Promise<void>
24
56
  /**
25
- * Remove dependencies from the selected package manager (defaults to UV) in one CRDT transaction.
57
+ * Remove dependencies from the selected package manager in one CRDT transaction.
58
+ * When no manager is provided, the running/configured notebook manager is used.
26
59
  * Returns the number of dependencies removed.
27
60
  */
28
61
  removeDependencies(packages: Array<string>, options?: DependencyEditOptions | undefined | null): Promise<number>
29
62
  /**
30
- * Remove a dependency from the selected package manager (defaults to UV).
63
+ * Remove a dependency from the selected package manager.
64
+ * When no manager is provided, the running/configured notebook manager is used.
31
65
  * Returns true if a dependency was removed.
32
66
  */
33
67
  removeDependency(pkg: string, options?: DependencyEditOptions | undefined | null): Promise<boolean>
@@ -165,7 +199,10 @@ export declare function defaultSocketPath(): string
165
199
 
166
200
  /** Options for dependency edit methods. */
167
201
  export interface DependencyEditOptions {
168
- /** Dependency manager to edit. Defaults to `uv` for Python notebooks. */
202
+ /**
203
+ * Dependency manager to edit. Defaults to the running/configured manager,
204
+ * falling back to UV for fresh Python notebooks.
205
+ */
169
206
  packageManager?: PackageManager
170
207
  }
171
208
 
package/src/index.cjs CHANGED
@@ -8,5 +8,20 @@
8
8
  "use strict";
9
9
 
10
10
  const binding = require("./binding.cjs");
11
+ const { Session } = require("./session.cjs");
11
12
 
12
- module.exports = binding;
13
+ async function createNotebook(options) {
14
+ return new Session(await binding.createNotebook(options));
15
+ }
16
+
17
+ async function openNotebook(notebookId, options) {
18
+ return new Session(await binding.openNotebook(notebookId, options));
19
+ }
20
+
21
+ module.exports = {
22
+ ...binding,
23
+ createNotebook,
24
+ openNotebook,
25
+ NativeSession: binding.Session,
26
+ Session,
27
+ };
package/src/index.d.ts CHANGED
@@ -1,7 +1,203 @@
1
- /**
2
- * @runtimed/node — Node.js bindings for the runtimed daemon.
3
- *
4
- * This file re-exports the types generated by napi-rs into binding.d.ts.
5
- */
1
+ import type { Observable } from "rxjs";
2
+ import type { ExecutionTransition, RuntimeState, SessionStatus } from "runtimed";
6
3
 
7
- export * from "./binding.cjs";
4
+ export type RuntimeKind = "python" | "deno" | (string & {});
5
+ export type PackageManager = "uv" | "conda" | "pixi";
6
+
7
+ export const PackageManager: {
8
+ readonly Uv: "uv";
9
+ readonly Conda: "conda";
10
+ readonly Pixi: "pixi";
11
+ };
12
+
13
+ export interface CreateNotebookOptions {
14
+ runtime?: RuntimeKind;
15
+ workingDir?: string;
16
+ socketPath?: string;
17
+ peerLabel?: string;
18
+ description?: string;
19
+ dependencies?: string[];
20
+ packageManager?: PackageManager;
21
+ }
22
+
23
+ export interface OpenNotebookOptions {
24
+ socketPath?: string;
25
+ peerLabel?: string;
26
+ description?: string;
27
+ }
28
+
29
+ export interface RunCellOptions {
30
+ timeoutMs?: number;
31
+ cellType?: "code" | "markdown" | "raw";
32
+ onUpdate?: (progress: CellResult) => void;
33
+ }
34
+
35
+ export interface QueueCellOptions {
36
+ cellType?: "code" | "markdown" | "raw";
37
+ }
38
+
39
+ export interface DependencyEditOptions {
40
+ packageManager?: PackageManager;
41
+ }
42
+
43
+ export interface WaitExecutionOptions {
44
+ cellId?: string;
45
+ timeoutMs?: number;
46
+ onUpdate?: (progress: CellResult) => void;
47
+ }
48
+
49
+ export interface QueuedExecution {
50
+ cellId: string;
51
+ executionId: string;
52
+ }
53
+
54
+ export interface JsOutput {
55
+ outputType: string;
56
+ name?: string;
57
+ text?: string;
58
+ dataJson?: string;
59
+ ename?: string;
60
+ evalue?: string;
61
+ traceback?: string[];
62
+ executionCount?: number;
63
+ blobUrlsJson?: string;
64
+ blobPathsJson?: string;
65
+ }
66
+
67
+ export interface CellResult {
68
+ cellId: string;
69
+ executionId: string;
70
+ executionCount?: number;
71
+ status:
72
+ | "done"
73
+ | "error"
74
+ | "timeout"
75
+ | "kernel_error"
76
+ | "kernel_failed"
77
+ | "closed"
78
+ | "queued"
79
+ | "running"
80
+ | (string & {});
81
+ success: boolean;
82
+ outputs: JsOutput[];
83
+ }
84
+
85
+ export interface EventSubscription {
86
+ dispose(): void;
87
+ }
88
+
89
+ export interface CellSnapshot {
90
+ id: string;
91
+ cellType: string;
92
+ position: string;
93
+ source: string;
94
+ metadataJson: string;
95
+ executionCount?: string;
96
+ }
97
+
98
+ export interface CreateCellOptions {
99
+ cellType?: "code" | "markdown" | "raw";
100
+ afterCellId?: string | null;
101
+ }
102
+
103
+ export interface SetCellOptions {
104
+ source?: string;
105
+ cellType?: "code" | "markdown" | "raw";
106
+ }
107
+
108
+ export interface RuntimeStatus {
109
+ status: string;
110
+ lifecycle: string;
111
+ activity?: string;
112
+ startingPhase: string;
113
+ name: string;
114
+ language: string;
115
+ envSource: string;
116
+ runtimeAgentId: string;
117
+ errorReason?: string;
118
+ errorDetails?: string;
119
+ }
120
+
121
+ export interface DependencyStatus {
122
+ uv?: {
123
+ dependencies: string[];
124
+ requiresPython?: string;
125
+ };
126
+ conda?: {
127
+ dependencies: string[];
128
+ channels: string[];
129
+ python?: string;
130
+ };
131
+ pixi?: {
132
+ dependencies: string[];
133
+ pypiDependencies: string[];
134
+ channels: string[];
135
+ python?: string;
136
+ };
137
+ fingerprint?: string;
138
+ trust?: unknown;
139
+ }
140
+
141
+ export class Session {
142
+ readonly notebookId: string;
143
+ readonly runtimeState$: Observable<RuntimeState>;
144
+ readonly executionTransitions$: Observable<ExecutionTransition>;
145
+ readonly cellChanges$: Observable<null>;
146
+ readonly broadcasts$: Observable<unknown>;
147
+ readonly sessionStatus$: Observable<SessionStatus>;
148
+
149
+ queueCell(source: string, options?: QueueCellOptions): Promise<QueuedExecution>;
150
+ waitForExecution(executionId: string, options?: WaitExecutionOptions): Promise<CellResult>;
151
+ runCell(source: string, options?: RunCellOptions): Promise<CellResult>;
152
+ saveNotebook(path?: string): Promise<void>;
153
+ listCells(): Promise<CellSnapshot[]>;
154
+ getCell(cellId: string): Promise<CellSnapshot | null>;
155
+ createCell(source: string, options?: CreateCellOptions): Promise<string>;
156
+ setCell(cellId: string, options: SetCellOptions): Promise<boolean>;
157
+ deleteCell(cellId: string): Promise<boolean>;
158
+ moveCell(cellId: string, afterCellId?: string | null): Promise<string>;
159
+ executeCell(cellId: string, options?: { timeoutMs?: number }): Promise<CellResult>;
160
+ showNotebook(): Promise<unknown>;
161
+ interruptKernel(): Promise<void>;
162
+ shutdownKernel(): Promise<void>;
163
+ restartKernel(): Promise<void>;
164
+ shutdownNotebook(): Promise<boolean>;
165
+ addDependency(pkg: string, options?: DependencyEditOptions): Promise<void>;
166
+ addDependencies(packages: string[], options?: DependencyEditOptions): Promise<void>;
167
+ removeDependency(pkg: string, options?: DependencyEditOptions): Promise<boolean>;
168
+ removeDependencies(packages: string[], options?: DependencyEditOptions): Promise<number>;
169
+ getDependencyStatus(): Promise<DependencyStatus>;
170
+ getRuntimeStatus(): Promise<RuntimeStatus>;
171
+ dependencyFingerprint(): Promise<string | null>;
172
+ approveTrust(observedHeads?: string[]): Promise<void>;
173
+ syncEnvironment(): Promise<void>;
174
+ close(): Promise<void>;
175
+ }
176
+
177
+ export const NativeSession: unknown;
178
+
179
+ export function defaultSocketPath(): string;
180
+ export function socketPathForChannel(channel: "stable" | "nightly"): string;
181
+ export function createNotebook(options?: CreateNotebookOptions): Promise<Session>;
182
+ export function openNotebook(notebookId: string, options?: OpenNotebookOptions): Promise<Session>;
183
+ export function getExecutionResult(
184
+ executionId: string,
185
+ options?: { socketPath?: string },
186
+ ): Promise<CellResult>;
187
+
188
+ export function readParquetFile(
189
+ filePath: string,
190
+ offset: number,
191
+ limit: number,
192
+ ): {
193
+ columns: string[];
194
+ rows: string[][];
195
+ totalRows: number;
196
+ offset: number;
197
+ };
198
+
199
+ export function summarizeParquetFile(filePath: string): {
200
+ numRows: number;
201
+ numBytes: number;
202
+ columns: Array<{ name: string; dataType: string; nullCount: number; statsJson: string }>;
203
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ function parseJsonEvent(json) {
4
+ return typeof json === "string" ? JSON.parse(json) : json;
5
+ }
6
+
7
+ module.exports = {
8
+ parseJsonEvent,
9
+ };
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+
3
+ const { Subject } = require("rxjs");
4
+ const { parseJsonEvent } = require("./napi-observables.cjs");
5
+
6
+ class Session {
7
+ constructor(nativeSession) {
8
+ this._native = nativeSession;
9
+ this._subscriptions = [];
10
+ this._runtimeStateSubject = new Subject();
11
+ this._executionTransitionsSubject = new Subject();
12
+ this._cellChangesSubject = new Subject();
13
+ this._broadcastsSubject = new Subject();
14
+ this._sessionStatusSubject = new Subject();
15
+ this.runtimeState$ = this._runtimeStateSubject.asObservable();
16
+ this.executionTransitions$ = this._executionTransitionsSubject.asObservable();
17
+ this.cellChanges$ = this._cellChangesSubject.asObservable();
18
+ this.broadcasts$ = this._broadcastsSubject.asObservable();
19
+ this.sessionStatus$ = this._sessionStatusSubject.asObservable();
20
+
21
+ if (typeof nativeSession.onRuntimeState === "function") {
22
+ this._subscriptions.push(
23
+ nativeSession.onRuntimeState((json) =>
24
+ this._runtimeStateSubject.next(parseJsonEvent(json)),
25
+ ),
26
+ );
27
+ }
28
+ if (typeof nativeSession.onCellChange === "function") {
29
+ this._subscriptions.push(
30
+ nativeSession.onCellChange((json) => this._cellChangesSubject.next(parseJsonEvent(json))),
31
+ );
32
+ }
33
+ if (typeof nativeSession.onBroadcast === "function") {
34
+ this._subscriptions.push(
35
+ nativeSession.onBroadcast((json) => this._broadcastsSubject.next(parseJsonEvent(json))),
36
+ );
37
+ }
38
+ if (typeof nativeSession.onSessionStatus === "function") {
39
+ this._subscriptions.push(
40
+ nativeSession.onSessionStatus((json) =>
41
+ this._sessionStatusSubject.next(parseJsonEvent(json)),
42
+ ),
43
+ );
44
+ }
45
+ if (typeof nativeSession.onExecutionTransition === "function") {
46
+ this._subscriptions.push(
47
+ nativeSession.onExecutionTransition((json) =>
48
+ this._executionTransitionsSubject.next(parseJsonEvent(json)),
49
+ ),
50
+ );
51
+ }
52
+ }
53
+
54
+ get notebookId() {
55
+ return this._native.notebookId;
56
+ }
57
+
58
+ queueCell(source, options) {
59
+ return this._native.queueCell(source, options);
60
+ }
61
+
62
+ async waitForExecution(executionId, options = {}) {
63
+ const { onUpdate, ...nativeOptions } = options ?? {};
64
+ const cellId = nativeOptions.cellId;
65
+ let progressSubscription = null;
66
+ if (typeof onUpdate === "function" && typeof this._native.onExecutionProgress === "function") {
67
+ progressSubscription = this._native.onExecutionProgress(
68
+ executionId,
69
+ cellId ?? null,
70
+ (json) => {
71
+ onUpdate(parseJsonEvent(json));
72
+ },
73
+ );
74
+ }
75
+
76
+ try {
77
+ return await this._native.waitForExecution(executionId, nativeOptions);
78
+ } finally {
79
+ progressSubscription?.dispose?.();
80
+ }
81
+ }
82
+
83
+ async runCell(source, options = {}) {
84
+ if (typeof options?.onUpdate !== "function") {
85
+ return this._native.runCell(source, options);
86
+ }
87
+ const queued = await this.queueCell(source, options);
88
+ return this.waitForExecution(queued.executionId, {
89
+ ...options,
90
+ cellId: queued.cellId,
91
+ });
92
+ }
93
+
94
+ saveNotebook(path) {
95
+ return this._native.saveNotebook(path);
96
+ }
97
+
98
+ listCells() {
99
+ return this._native.listCells();
100
+ }
101
+
102
+ getCell(cellId) {
103
+ return this._native.getCell(cellId);
104
+ }
105
+
106
+ createCell(source, options) {
107
+ return this._native.createCell(source, options);
108
+ }
109
+
110
+ setCell(cellId, options) {
111
+ return this._native.setCell(cellId, options);
112
+ }
113
+
114
+ deleteCell(cellId) {
115
+ return this._native.deleteCell(cellId);
116
+ }
117
+
118
+ moveCell(cellId, afterCellId) {
119
+ return this._native.moveCell(cellId, { afterCellId: afterCellId ?? null });
120
+ }
121
+
122
+ executeCell(cellId, options) {
123
+ return this._native.executeCell(cellId, options);
124
+ }
125
+
126
+ showNotebook() {
127
+ return this._native.showNotebook();
128
+ }
129
+
130
+ interruptKernel() {
131
+ return this._native.interruptKernel();
132
+ }
133
+
134
+ shutdownKernel() {
135
+ return this._native.shutdownKernel();
136
+ }
137
+
138
+ restartKernel() {
139
+ return this._native.restartKernel();
140
+ }
141
+
142
+ shutdownNotebook() {
143
+ return this._native.shutdownNotebook();
144
+ }
145
+
146
+ addDependency(pkg, options) {
147
+ return this._native.addDependency(pkg, normalizeDependencyOptions(options));
148
+ }
149
+
150
+ addDependencies(packages, options) {
151
+ return this._native.addDependencies(
152
+ normalizePackages(packages),
153
+ normalizeDependencyOptions(options),
154
+ );
155
+ }
156
+
157
+ removeDependency(pkg, options) {
158
+ return this._native.removeDependency(pkg, normalizeDependencyOptions(options));
159
+ }
160
+
161
+ removeDependencies(packages, options) {
162
+ return this._native.removeDependencies(
163
+ normalizePackages(packages),
164
+ normalizeDependencyOptions(options),
165
+ );
166
+ }
167
+
168
+ getDependencyStatus() {
169
+ return this._native.getDependencyStatus();
170
+ }
171
+
172
+ getRuntimeStatus() {
173
+ return this._native.getRuntimeStatus();
174
+ }
175
+
176
+ dependencyFingerprint() {
177
+ return this._native.dependencyFingerprint();
178
+ }
179
+
180
+ approveTrust(observedHeads) {
181
+ return this._native.approveTrust(observedHeads);
182
+ }
183
+
184
+ syncEnvironment() {
185
+ return this._native.syncEnvironment();
186
+ }
187
+
188
+ close() {
189
+ for (const subscription of this._subscriptions.splice(0)) {
190
+ subscription?.dispose?.();
191
+ }
192
+ this._runtimeStateSubject.complete();
193
+ this._executionTransitionsSubject.complete();
194
+ this._cellChangesSubject.complete();
195
+ this._broadcastsSubject.complete();
196
+ this._sessionStatusSubject.complete();
197
+ return this._native.close();
198
+ }
199
+ }
200
+
201
+ function normalizePackages(packages) {
202
+ if (!Array.isArray(packages)) {
203
+ throw new TypeError("packages must be an array of dependency specifiers");
204
+ }
205
+ return Array.from(new Set(packages.map((pkg) => String(pkg).trim()).filter(Boolean)));
206
+ }
207
+
208
+ function normalizeDependencyOptions(options) {
209
+ if (!options?.packageManager) {
210
+ return undefined;
211
+ }
212
+ return { packageManager: options.packageManager };
213
+ }
214
+
215
+ module.exports = {
216
+ Session,
217
+ };