@tlockney/cdp-kernel 0.3.0 → 0.5.0

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.
Files changed (56) hide show
  1. package/README.md +60 -404
  2. package/THIRD-PARTY-NOTICES +62 -0
  3. package/dist/bun-target.d.ts +4 -2
  4. package/dist/bun-target.js +35 -8
  5. package/dist/cdp.d.ts +6 -1
  6. package/dist/cdp.js +25 -10
  7. package/dist/celld-target.d.ts +1 -1
  8. package/dist/celld-target.js +46 -8
  9. package/dist/children.d.ts +7 -0
  10. package/dist/children.js +32 -0
  11. package/dist/debugger.d.ts +42 -0
  12. package/dist/debugger.js +545 -0
  13. package/dist/globals.d.ts +3 -3
  14. package/dist/globals.js +3 -3
  15. package/dist/history.d.ts +18 -0
  16. package/dist/history.js +45 -0
  17. package/dist/kernel.js +211 -32
  18. package/dist/main.js +3 -1
  19. package/dist/mod.d.ts +5 -3
  20. package/dist/mod.js +5 -3
  21. package/dist/murmur2.d.ts +2 -0
  22. package/dist/murmur2.js +41 -0
  23. package/dist/package.d.ts +16 -2
  24. package/dist/package.js +26 -3
  25. package/dist/sourcemap.d.ts +22 -0
  26. package/dist/sourcemap.js +86 -0
  27. package/dist/target.d.ts +39 -3
  28. package/dist/target.js +281 -30
  29. package/dist/text.d.ts +11 -1
  30. package/dist/text.js +72 -2
  31. package/dist/transform.d.ts +19 -0
  32. package/dist/transform.js +74 -13
  33. package/dist/wire.d.ts +8 -1
  34. package/dist/wire.js +3 -1
  35. package/dist/workerd-target.d.ts +9 -1
  36. package/dist/workerd-target.js +108 -9
  37. package/dist/ws-client.d.ts +5 -1
  38. package/dist/ws-client.js +46 -13
  39. package/dist/zmtp.d.ts +7 -1
  40. package/dist/zmtp.js +30 -1
  41. package/package.json +10 -4
  42. package/runtime/bootstrap.mjs +138 -12
  43. package/runtime/bun-channel.d.mts +3 -0
  44. package/runtime/bun-channel.mjs +2 -2
  45. package/runtime/comm.mjs +11 -1
  46. package/runtime/deno-compat.d.mts +2 -0
  47. package/runtime/deno-compat.mjs +17 -2
  48. package/runtime/display.d.mts +2 -0
  49. package/runtime/display.mjs +17 -2
  50. package/runtime/evaluator.d.mts +4 -0
  51. package/runtime/evaluator.mjs +8 -0
  52. package/runtime/introspect.d.mts +13 -0
  53. package/runtime/introspect.mjs +120 -0
  54. package/runtime/node-hooks.d.mts +61 -1
  55. package/runtime/node-hooks.mjs +354 -21
  56. package/runtime/workerd-worker.mjs +82 -6
package/README.md CHANGED
@@ -1,430 +1,86 @@
1
1
  # cdp-kernel
2
2
 
3
- A Jupyter kernel extracted from Deno's (`deno jupyter`, v2.9.6) that drives
4
- any V8 runtime over the Chrome DevTools Protocol. The kernel host runs on
5
- Node or Deno; the code you type runs in a separate **target** runtime:
6
- Node or Deno over CDP. Bun, workerd and celld evaluate cells in-process
7
- instead (see [Bun](#bun), [workerd](#workerd) and [celld](#celld)). In
8
- principle, anything else whose inspector speaks CDP works too.
3
+ A Jupyter kernel for TypeScript and JavaScript, extracted from the one built
4
+ into Deno 2.9.6 (`deno jupyter`), that runs notebooks on several JavaScript runtimes. The kernel
5
+ host runs on Node or Deno; the code you type runs in a separate **target**
6
+ runtime: Node or Deno over the Chrome DevTools Protocol, or Bun, workerd and
7
+ celld, which evaluate cells in-process. In principle, anything else whose
8
+ inspector speaks CDP works too.
9
+
10
+ **Website:** <https://cdp-kernel.org/> ·
11
+ **Docs:** [cdp-kernel.org/docs](https://cdp-kernel.org/docs/)
9
12
 
10
13
  This is early software. It passes a conformance suite derived from Deno's
11
14
  own Jupyter integration tests on every target, and it's packaged for npm and
12
- JSR as `@tlockney/cdp-kernel`, but it hasn't seen much real use yet. The
13
- feasibility study behind it covers the design,
14
- the other options considered (workerd, Bun, rusty_v8, FFI), and the
15
- evidence: [read it online](https://claude.ai/artifact/S66TnTmhCzPy2EW7jbeeue)
16
- (also in the repo as
17
- [`docs/life-after-deno-jupyter.html`](docs/life-after-deno-jupyter.html)). It
18
- was written before packaging, so it calls the project a spike.
19
- The scripts that produced its runtime findings are in [`probes/`](probes/).
20
-
21
- ## Why this shape
22
-
23
- Deno 2.9's kernel is already two halves joined by thirteen ops
24
- (denoland/deno#34083 rewrote it in JS and dropped libzmq):
25
-
26
- - `cli/js/jupyter_kernel.js`: ZMTP and the Jupyter wire protocol in plain
27
- JS over TCP.
28
- - A REPL isolate driven by CDP calls: `Runtime.evaluate` with
29
- `replMode: true`, `callFunctionOn`, `getProperties`,
30
- `globalLexicalScopeNames`.
15
+ JSR as `@tlockney/cdp-kernel`, but it hasn't seen much real use yet.
31
16
 
32
- So the extraction is:
17
+ ## Features
33
18
 
34
- - Port the protocol half to `node:net` and `node:crypto`: `src/zmtp.ts`,
35
- `src/wire.ts`, `src/kernel.ts`.
36
- - Point the CDP half at another runtime's `--inspect` WebSocket:
37
- `src/target.ts`, `src/cdp.ts`.
38
- - Replace what Deno's module loader did with esbuild + acorn
39
- (`src/transform.ts`) and Node resolve hooks (`runtime/node-hooks.mjs`).
40
- - Port `Deno.jupyter` (`40_jupyter.js`) to `runtime/display.mjs`.
19
+ - The `Deno.jupyter` display API (`jupyter.display`, `md`, `html`, `svg`,
20
+ `image`, …) on every target.
21
+ - TypeScript, TSX, top-level `await`, and `npm:`/`jsr:` imports, with an
22
+ optional lockfile.
23
+ - Deno projects (`deno.json` import maps, JSX settings) and Workers
24
+ projects (`wrangler` bindings in `env`).
25
+ - JupyterLab's visual debugger on Node and Deno targets.
26
+ - anywidget-style widgets and Jupyter comms.
27
+ - `prompt()` and `confirm()`, interrupt that keeps state, Shift-Tab
28
+ inspection, completion and history.
41
29
 
42
30
  ## Install
43
31
 
44
- Each install writes a Jupyter kernelspec: `cdp-node`, `cdp-deno`,
45
- `cdp-node-deno` (Node with the Deno compatibility namespace), `cdp-bun`,
46
- `cdp-workerd`, or `cdp-celld`. Then pick the kernel in JupyterLab or VS Code.
47
-
48
- **From npm** (host runs on Node 24+; Node 26 is what's been tested):
32
+ Node 24+ host, from npm:
49
33
 
50
34
  ```sh
51
35
  npm install -g @tlockney/cdp-kernel
52
- cdp-kernel install --runtime node
53
- cdp-kernel install --runtime deno
54
- cdp-kernel install --runtime node --deno-compat
55
- cdp-kernel install --runtime bun
56
- cdp-kernel install --runtime workerd
57
- cdp-kernel install --runtime celld
36
+ cdp-kernel install --runtime node # or deno, bun, workerd, celld
58
37
  ```
59
38
 
60
- The kernelspec records the absolute paths of `node` and the installed
61
- package. Re-run `install` after upgrading either.
62
-
63
- **From JSR** (host runs on Deno):
39
+ Deno host, from JSR:
64
40
 
65
41
  ```sh
66
42
  deno run -A jsr:@tlockney/cdp-kernel/cli install --runtime deno
67
43
  ```
68
44
 
69
- The kernelspec pins the release it was installed from
70
- (`jsr:@tlockney/cdp-kernel@<version>/cli`). On first launch the target's
71
- runtime modules are copied into `~/.cache/cdp-kernel/runtime/`. A Node
72
- target needs `node` on `PATH`, and a Bun target needs `bun` (1.4 is what's
73
- been tested). A workerd target uses the `workerd` in the notebook
74
- directory's `node_modules` (a Workers project has one through wrangler),
75
- or the one on `PATH` (`npm install -g workerd`; 2026-10-15 is what's been
76
- tested). A celld target uses `~/.local/bin/celld`, where celld's installer
77
- puts it, or the one on `PATH` (0.6.2 is what's been tested; celld has no
78
- Windows build).
79
-
80
- Deno 2.9+ refuses package versions less than 24 hours old by default
81
- ([minimum dependency age](https://docs.deno.com/go/minimum-dependency-age)).
82
- In a release's first day, the install command fails with "blocked by the
83
- minimum dependency age policy". Wait out the day, or install an earlier
84
- release. Passing `--min-dep-age=0` gets the install through, but the
85
- kernelspec doesn't carry the flag, so the kernel still won't launch until
86
- the release is a day old.
87
-
88
- **From a checkout**, for working on the kernel itself:
89
-
90
- ```sh
91
- npm ci
92
- npm run install:node # kernelspec cdp-node
93
- npm run install:deno # kernelspec cdp-deno
94
- npm run install:node-deno # kernelspec cdp-node-deno
95
- npm run install:bun # kernelspec cdp-bun
96
- npm run install:workerd # kernelspec cdp-workerd
97
- npm run install:celld # kernelspec cdp-celld
98
- ```
99
-
100
- These kernelspecs point at the checkout, so don't move it after installing.
101
-
102
- In a cell:
103
-
104
- - `jupyter.display`, `jupyter.md`, `jupyter.html`, `jupyter.svg`,
105
- `jupyter.image`, `jupyter.format`, `jupyter.broadcast`, and
106
- `Symbol.for("Jupyter.display")`: the same API as `Deno.jupyter`.
107
- - `Deno.jupyter` also works:
108
- - On a Deno target it is a proxy over the real namespace. Deno's own
109
- getter throws outside `deno jupyter`.
110
- - On Node it needs `--deno-compat`. That installs a `Deno` namespace for
111
- file, env and process APIs (`runtime/deno-compat.mjs`).
112
- - The shim is opt-in because libraries detect Deno with `typeof Deno`, and
113
- would take Deno code paths that call APIs it doesn't cover.
114
- - Imports work: TypeScript, TSX, enums, top-level `await`, and `const`
115
- redeclaration across cells. Specifiers can be `./local.ts`, bare packages
116
- from the notebook's `node_modules`, `node:` builtins, and `npm:pkg@range`
117
- or `jsr:@scope/pkg@range`.
118
- - On Node, `npm:` and `jsr:` install on first use into
119
- `~/.cache/cdp-kernel/npm`.
120
- - On Deno they use Deno's global cache, unless the notebook is in a Deno
121
- project (below).
122
- - On Bun they install with `bun add` into `~/.cache/cdp-kernel/bun`. Other
123
- bare imports resolve from the notebook's directory, so without a
124
- `node_modules` there, Bun auto-installs them.
125
- - On workerd, the host bundles every import other than a builtin
126
- (`node:`, `cloudflare:`) with esbuild, using Workers' resolution
127
- conditions, and sends it with the cell. `npm:` and `jsr:` install into
128
- the npm cache first, as on Node.
129
- - **Deno projects.** If a `deno.json` or `deno.jsonc` sits in the notebook's
130
- directory or above it, a Deno target uses it, as `deno jupyter` does:
131
- - its import map (`"@/": "./lib/"` aliases, mapped packages);
132
- - its `nodeModulesDir` setting, with `package.json` dependencies from the
133
- project's `node_modules`;
134
- - its JSX and decorator `compilerOptions`: `jsx` (`react-jsx`,
135
- `react-jsxdev`, `precompile`, `react`), `jsxImportSource`,
136
- `jsxFactory`, `jsxFragmentFactory`, `experimentalDecorators`.
137
-
138
- The import map wins over `node_modules`, as in Deno. The kernel never
139
- writes to the project's lockfile. A `deno.json` that doesn't parse is
140
- reported in the first cell's output, and the kernel runs as in a plain
141
- directory. Outside a project, the target runs with
142
- `--node-modules-dir=none --no-lock`.
143
- - `prompt()` and `confirm()` work over the stdin channel, except on
144
- workerd. Interrupt keeps state, except for a busy cell on Bun or workerd
145
- (below).
146
-
147
- ## Bun
148
-
149
- Bun's `--inspect` speaks the WebKit Inspector Protocol, which lacks what the
150
- CDP backend relies on: `replMode`, `Runtime.addBinding`,
151
- `Runtime.terminateExecution`, and top-level `await` in `Runtime.evaluate`.
152
- So the Bun target has its own backend (`src/bun-target.ts`,
153
- `runtime/bun-channel.mjs`):
154
-
155
- - **No inspector.** The host and Bun exchange JSON lines over a pipe on
156
- fd 3, which only the host holds, so there is no port to discover.
157
- - **Cells run in-process.** Each cell becomes global code wrapped in an
158
- async function (`transformCellForEval` in `src/transform.ts`). Its
159
- top-level declarations become properties of `globalThis`, so later
160
- cells, and closures from this one, see them. This is the
161
- tslab/IJavascript technique.
162
- - **Same output ordering.** stdout and stderr stay pipes, ordered against
163
- display messages by the same barrier markers as the CDP targets.
164
- - **Interrupt.** A cell that's waiting on a promise is interrupted in place,
165
- keeping state. A busy one (`while (true) {}`) can't be reached, so Bun is
166
- stopped and restarts on the next cell without the earlier state. The cell
167
- output says so.
168
-
169
- What differs from the CDP targets is listed under [Known gaps](#known-gaps).
170
-
171
- ## workerd
172
-
173
- workerd's inspector can evaluate code, but outside a request there is no
174
- I/O context: timers, `fetch` and `crypto.randomUUID()` throw "Disallowed
175
- operation called within global scope". So the workerd target runs its
176
- cells inside a driver Worker (`src/workerd-target.ts`,
177
- `runtime/workerd-worker.mjs`):
178
-
179
- - **One session.** The host opens a single WebSocket to the driver, and
180
- every cell runs inside that session's request. Cells get Workers'
181
- `fetch`, `Request`, `caches`, timers and randomness, and anything one
182
- cell makes carries over to the next: globals, a Durable Object stub, a
183
- stream, a timer still pending.
184
- - **A private socket.** Outside a Workers project, the host writes a
185
- workerd config into a private temporary directory and serves the driver
186
- on a Unix socket there, opened with a per-launch token. There is no TCP
187
- port and no inspector.
188
- - **Cells.** Cells are transformed as for Bun and run by workerd's
189
- `UnsafeEval` binding (hence `--experimental`).
190
- - **Output.** `console` output and display messages come back over the
191
- session as they happen, in order.
192
- - **Interrupt.** A cell that's waiting on something is abandoned in place,
193
- keeping state, as on Bun. A busy one gets Bun's treatment too: workerd is
194
- stopped and restarts on the next cell.
195
-
196
- What workerd's own process prints, such as its warnings, goes to the Jupyter
197
- server log, not the notebook.
198
-
199
- ### Workers projects
200
-
201
- If a `wrangler.jsonc`, `wrangler.json` or `wrangler.toml` sits in the
202
- notebook's directory or above it, the driver runs on the project's own
203
- Miniflare, the simulator `wrangler dev` uses, with the project's bindings
204
- (`src/workers-project.ts`):
205
-
206
- - `env` holds the bindings: whatever wrangler translates for Miniflare.
207
- Vars, KV, D1 and Durable Objects are tested; R2, Queues and the others
208
- go through the same path but aren't.
209
- - The project's `main` is bundled into the driver, so its Durable Object
210
- classes run, and `worker` is its default export:
211
- `await worker.fetch(new Request("https://x/"), env)`.
212
- - State lives in the project's `.wrangler/state/cdp-kernel`, beside
213
- `wrangler dev`'s own, so the two never open the same Durable Object.
214
- - The first cell's output names the bindings. If the project can't load,
215
- for example because wrangler isn't installed in it, the first cell says
216
- why and the kernel runs on plain workerd.
217
-
218
- wrangler and Miniflare come from the project's `node_modules`, so they match
219
- its versions. Miniflare 4 and 5 both work. Miniflare listens on a loopback
220
- TCP port, so there the per-launch token is what keeps other local processes
221
- out.
222
-
223
- ## celld
224
-
225
- [celld](https://github.com/denoland/celld) runs Workers and Durable Objects
226
- on your own storage. Like workerd it has no I/O outside a request, so the
227
- celld target runs the same driver Worker over the same WebSocket session
228
- (`src/celld-target.ts`). Cells, output, interrupts and host-bundled imports
229
- all work as on workerd. The differences:
230
-
231
- - **No `UnsafeEval` needed.** celld allows a plain global `eval`, so it runs
232
- without workerd's `--experimental`.
233
- - **One module.** The host bundles the driver, and a project's `main`, into
234
- a single module, and gives celld the result with `no_bundle`. celld
235
- doesn't need its own esbuild.
236
- - **Loopback TCP.** celld listens only on TCP, so the session is a loopback
237
- WebSocket opened with a per-launch token. The kernel picks a free port
238
- and runs `celld dev --no-watch` on a generated config.
239
- - **Projects.** In a celld project (a `wrangler.jsonc` or `wrangler.json`
240
- at or above the notebook), the generated config copies the project's
241
- compatibility settings and bindings: vars, KV, D1, R2, Durable Objects,
242
- Queues, Workflows, services, Worker Loaders. `env` and `worker` then work
243
- as on workerd. The generated config is written to the project's
244
- `.celld/cdp-kernel` and removed when the kernel stops. The state stays
245
- there across kernels, beside `celld dev`'s own `.celld/dev`. celld rejects `wrangler.toml`; a project
246
- that can't load is reported in the first cell, and the driver runs alone.
247
- - **Stopping.** `celld dev` runs its node in a separate process group and
248
- waits for it to stop gracefully, which a busy cell never allows. So an
249
- interrupt of a busy cell kills the node, then `celld dev`.
250
-
251
- ## Editor types
252
-
253
- Cells run untyped, as in `deno jupyter`. Notebook code your editor
254
- type-checks can declare the globals.
45
+ Each install writes a Jupyter kernelspec (`cdp-node`, `cdp-deno`, …). Pick
46
+ it in JupyterLab or VS Code. Linux and macOS are supported; Windows isn't
47
+ yet. See [Install](https://cdp-kernel.org/docs/install)
48
+ for `--deno-compat`, release-day installs on Deno, target runtime
49
+ requirements, and installing from a checkout.
255
50
 
256
- **Node notebooks.** The npm package ships the declarations. Add it as a dev
257
- dependency, then reference it once from a cell or a `.d.ts` in the project:
51
+ ## Quick start
258
52
 
259
53
  ```ts
260
- /// <reference types="@tlockney/cdp-kernel/globals" />
261
- await jupyter.display(jupyter.md`typed`);
262
- const name: string | null = prompt("Name?", "", { password: false });
263
- ```
264
-
265
- That declares `jupyter`, `prompt` and `confirm`. With the `cdp-node-deno`
266
- kernel, use `@tlockney/cdp-kernel/globals/deno-compat` instead: it adds the
267
- `Deno` namespace the compatibility shim implements. A custom display is a
268
- class with a `[jupyter.$display]()` method returning a MIME bundle.
269
- `jupyter.$display` is `Symbol.for("Jupyter.display")` at runtime, but only
270
- `jupyter.$display` carries the precise type.
271
-
272
- **Deno notebooks.** Use `Deno.jupyter`, which Deno already types and which a
273
- Deno target provides. The JSR package doesn't ship these globals, because
274
- JSR doesn't allow packages to augment global types.
275
-
276
- ## Widgets and comms
277
-
278
- `deno jupyter` has no comms. Here they're supported in both directions, so
279
- anywidget-style widgets work in frontends with the `anywidget` extension:
280
- JupyterLab, Notebook 7 and VS Code. Install it with
281
- `pip install anywidget`; that's the frontend half, no Python kernel needed.
282
-
283
- ```ts
284
- const counter = jupyter.widget({
285
- esm: `export default {
286
- render({ model, el }) {
287
- const btn = document.createElement("button");
288
- const update = () => { btn.textContent = \`count is \${model.get("count")}\`; };
289
- btn.onclick = () => { model.set("count", model.get("count") + 1); model.save_changes(); };
290
- model.on("change:count", update);
291
- update();
292
- el.append(btn);
293
- },
294
- };`,
295
- state: { count: 0 },
296
- });
297
- counter.on("change:count", (value) => console.log("clicked to", value));
298
- counter; // display it
299
- ```
54
+ import { format } from "npm:date-fns@4";
300
55
 
301
- The model API:
302
-
303
- - `get(key)`, and `set(key, value)` or `set({ ... })`, which syncs to every
304
- view.
305
- - `on("change:key" | "change" | "msg:custom", listener)` and `off(...)`.
306
- - `send(content, buffers)` for custom messages.
307
- - `close()`.
308
-
309
- `Uint8Array`, `ArrayBuffer` and `DataView` values in the state travel as
310
- binary buffers. JupyterLab restores widget state after a page reload over
311
- the `jupyter.widget.control` comm.
312
-
313
- The comm layer underneath is available directly, for other comm-based
314
- protocols:
315
-
316
- ```ts
317
- const comm = jupyter.comm.open("my.target", { hello: 1 });
318
- comm.onMsg(({ data, buffers }) => console.log(data, buffers.length));
319
- comm.send({ ping: true });
320
- jupyter.comm.registerTarget("echo", (comm) => comm.onMsg((m) => comm.send(m.data)));
56
+ const now: Date = new Date();
57
+ await jupyter.display(jupyter.md`**Today** is ${format(now, "PPPP")}`);
321
58
  ```
322
59
 
323
- Comm handlers run like cells. Their output goes to the notebook as replies
324
- to the message that triggered them, an exception is shown on stderr, and
325
- interrupt stops a stuck handler. Messages are processed one at a time with
326
- cell executions, as in ipykernel, so a widget event that arrives during a
327
- long cell waits for the cell to finish.
328
-
329
- ## How the tricky parts work
330
-
331
- | Problem | Approach |
332
- |---|---|
333
- | Inspector-evaluated code has no module referrer, so Node rejects `import()` | Static imports are rewritten to `var x = (await __cdpk.import("m")).x` (Deno's `var_decl_imports`), and `import()` and `import.meta` go through the bootstrap module. A resolve hook re-parents those imports to the notebook directory. |
334
- | A busy loop inside `Runtime.evaluate` blocks every inspector message, so interrupt is never seen | Each cell starts with `await __cdpk.tick()` (one macrotask), so user code runs as an ordinary task. `Runtime.terminateExecution` then arrives on a second CDP session. The host abandons the evaluate, whose promise never settles. |
335
- | stdout/stderr arrive over pipes and display messages over the WebSocket, so they race | Every display message is preceded by a numbered marker on both pipes. The host releases the message only after both pipes reach the marker, and holds later pipe output until the message is out. |
336
- | `prompt()` must be synchronous | The target sends an `input_request` through a CDP binding, then blocks on a `readSync` of stdin. The host writes the reply as one JSON line. |
337
- | Uncaught errors from timers would kill the target | `uncaughtException` and `unhandledrejection` handlers report them to stderr. |
338
-
339
- ## Tests
340
-
341
- ```sh
342
- npm run check # tsc --strict over src/ and test/
343
- npm test # unit tests (node:test)
344
- npm run e2e # conformance suite via jupyter_client/libzmq, on every target variant
345
- npm run test:lab # an anywidget counter in real JupyterLab, headless Chromium (node, deno, bun, workerd, celld)
346
- uv run --with nbclient --with nbformat python examples/run_notebook.py # Deno-style notebook on deno + node-deno
347
- ```
348
-
349
- The e2e suite follows Deno's `tests/integration/jupyter_tests.rs` and adds
350
- the gaps those tests leave: display ordering, TS, imports, `npm:`/`jsr:`,
351
- completion, and `update_display_data`. Set `CDPK_E2E_OFFLINE=1` to skip the
352
- registry-dependent checks. Set `CDPK_E2E_CLI` to run it through a different
353
- CLI: an installed npm bin, or `deno run -A src/main.ts` to test a Deno host.
354
-
355
- ## Releasing
356
-
357
- One version number lives in three places: `package.json`, `deno.jsonc` and
358
- `src/package.ts`. `test/package.test.ts` fails if they disagree. To release:
359
-
360
- 1. Bump all three, commit, and merge to `main`.
361
- 2. Tag and push: `git tag v0.1.1 && git push origin v0.1.1`.
362
-
363
- The `publish` workflow then:
364
-
365
- 1. Checks that the tag matches the version.
366
- 2. Runs the type check, the unit tests, and the e2e suite against the packed
367
- npm tarball and against a Deno host.
368
- 3. Publishes to JSR (`deno publish`).
369
- 4. Publishes to npm (`npm publish`).
370
-
371
- Both registries authenticate the workflow through GitHub OIDC, so no tokens
372
- are stored:
373
- - **npm:** a trusted publisher for `tlockney/cdp-kernel` + `publish.yml`.
374
- - **JSR:** the package is linked to this repo in its JSR settings.
375
-
376
- Neither registry lets a version be republished. Each job skips a version
377
- its registry already has, so re-running a release only fills in the half
378
- that failed.
379
-
380
- ## Known gaps
381
-
382
- - Widgets are anywidget-style (`jupyter.widget`). The classic ipywidgets
383
- controls (sliders, dropdowns) are Python classes, so they're not available.
384
- - No `inspect_request` content and no history. Deno has neither.
385
- - No debugger.
386
- - `npm:` on Node:
387
- - one npm alias per `name@range`;
388
- - no lockfile;
389
- - peer dependencies resolve by real name from the shared cache.
390
- - No type checking. Deno doesn't type-check REPL cells either.
391
- - Results are formatted with `util.inspect` on Node, so they look slightly
392
- different from Deno's `Deno.inspect`.
393
- - WebGPU texture and buffer display is dropped.
394
- - On Bun:
395
- - Interrupting a busy cell restarts Bun and loses state. An awaiting cell
396
- keeps it.
397
- - Top-level declarations are properties of `globalThis`. A `const` can be
398
- reassigned, and declaring a global's name (`const fetch = ...`) replaces
399
- that global rather than shadowing it.
400
- - Only a trailing expression statement shows a result: `x` does, but
401
- `if (c) { x }` doesn't.
402
- - Bun 1.4 can't import a module whose path contains `?`.
403
- - No `--deno-compat` namespace.
404
- - On workerd:
405
- - All cells share one request, so it never ends. Unlike production
406
- Workers, there is no per-request CPU or duration limit, and
407
- `ctx.waitUntil` isn't available in a cell.
408
- - No `prompt()` or `confirm()` answers: they return `null`, as without a
409
- stdin channel. `jupyter.image(path)` can't read files; pass the bytes.
410
- - Each imported module is bundled with its dependencies. Two imports that
411
- share a dependency each get their own copy.
412
- - Interrupting a busy cell restarts workerd and loses state.
413
- - Top-level declarations and results behave as on Bun: declarations are
414
- `globalThis` properties, and only a trailing expression shows a result.
415
- - In a Workers project, `main` is bundled with esbuild directly, not with
416
- wrangler's build. Custom `build` commands, `alias` and module `rules`
417
- aren't applied.
418
- - On celld, as on workerd, except:
419
- - Only the binding and compatibility keys of a project's config are
420
- copied. `assets`, `triggers` and `containers` aren't, and neither is
421
- `.dev.vars`. Relative paths inside the copied keys resolve from
422
- `.celld/cdp-kernel`, not from the project.
423
- - Interrupting a busy cell restarts celld and loses state.
424
-
425
- ## Provenance
426
-
427
- `src/zmtp.ts`, `src/wire.ts`, `src/kernel.ts`, `src/text.ts` and
428
- `runtime/display.mjs` are ports of Deno's `cli/js/jupyter_kernel.js` and
429
- `cli/js/40_jupyter.js` at v2.9.6 (commit `e518fbd`), Copyright 2018-2026 the
430
- Deno authors, MIT license. Each file header says which parts.
60
+ ## Documentation
61
+
62
+ New to Jupyter? Start with
63
+ [Getting started](https://cdp-kernel.org/docs/getting-started).
64
+
65
+ - Guides: [Writing notebooks](https://cdp-kernel.org/docs/notebooks),
66
+ [The `jupyter` namespace](https://cdp-kernel.org/docs/jupyter-api),
67
+ [Choosing a runtime](https://cdp-kernel.org/docs/runtimes),
68
+ [Widgets and comms](https://cdp-kernel.org/docs/widgets),
69
+ [Debugger](https://cdp-kernel.org/docs/debugger)
70
+ - Reference: [Editor types](https://cdp-kernel.org/docs/editor-types),
71
+ [Known gaps](https://cdp-kernel.org/docs/known-gaps)
72
+ - Internals: [Architecture](https://cdp-kernel.org/docs/architecture),
73
+ [Runtime integrations](https://cdp-kernel.org/docs/integrations)
74
+ - Contributing: [Development](https://cdp-kernel.org/docs/development)
75
+
76
+ The [feasibility study](https://cdp-kernel.org/docs/feasibility-study)
77
+ behind the project covers the design, the alternatives considered (workerd,
78
+ Bun, rusty_v8, FFI), and the evidence.
79
+
80
+ ## License
81
+
82
+ MIT. Parts are ports of Deno's Jupyter kernel, Copyright 2018-2026 the Deno
83
+ authors. The debugger's MurmurHash2 follows JupyterLab's (BSD-3-Clause) and
84
+ Gary Court's (MIT); their notices are in
85
+ [THIRD-PARTY-NOTICES](THIRD-PARTY-NOTICES). See
86
+ [Architecture › Provenance](https://cdp-kernel.org/docs/architecture#provenance).
@@ -0,0 +1,62 @@
1
+ Third-party notices for cdp-kernel
2
+
3
+ cdp-kernel itself is under the MIT license in LICENSE. The files below carry
4
+ code from other projects under their own licenses.
5
+
6
+ --------------------------------------------------------------------------------
7
+
8
+ src/murmur2.ts follows JupyterLab's packages/debugger/src/hash.ts
9
+ (Copyright (c) Jupyter Development Team), which is distributed under the
10
+ following license:
11
+
12
+ Copyright (c) 2015-2026 Project Jupyter Contributors
13
+ All rights reserved.
14
+
15
+ Redistribution and use in source and binary forms, with or without
16
+ modification, are permitted provided that the following conditions are met:
17
+
18
+ 1. Redistributions of source code must retain the above copyright notice, this
19
+ list of conditions and the following disclaimer.
20
+
21
+ 2. Redistributions in binary form must reproduce the above copyright notice,
22
+ this list of conditions and the following disclaimer in the documentation
23
+ and/or other materials provided with the distribution.
24
+
25
+ 3. Neither the name of the copyright holder nor the names of its
26
+ contributors may be used to endorse or promote products derived from
27
+ this software without specific prior written permission.
28
+
29
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
33
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
+
40
+ JupyterLab's hash.ts is in turn adapted from Gary Court's murmurhash2_gc.js
41
+ (https://github.com/garycourt/murmurhash-js), distributed under the following
42
+ license:
43
+
44
+ Copyright (c) 2011 Gary Court
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining a copy
47
+ of this software and associated documentation files (the "Software"), to deal
48
+ in the Software without restriction, including without limitation the rights
49
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50
+ copies of the Software, and to permit persons to whom the Software is
51
+ furnished to do so, subject to the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be included in all
54
+ copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62
+ SOFTWARE.
@@ -1,4 +1,4 @@
1
- import type { CdpParams, EvaluateResult, RemoteObject } from "./cdp.ts";
1
+ import { type CdpParams, type EvaluateResult, type RemoteObject } from "./cdp.ts";
2
2
  import { transformCellForEval } from "./transform.ts";
3
3
  import { type KernelTarget, type TargetEvents } from "./target.ts";
4
4
  /**
@@ -51,8 +51,10 @@ export declare class BunTarget implements KernelTarget {
51
51
  stack: string;
52
52
  }>;
53
53
  propertyNames(expression: string): Promise<string[]>;
54
+ /** Resolved by property descriptor in the target, so nothing runs (#10). */
55
+ inspect(path: string, detail: number): Promise<string | null>;
54
56
  /** None: top-level declarations here are properties of globalThis. */
55
57
  lexicalNames(): Promise<string[]>;
56
- replyInput(value: string | null): void;
58
+ replyInput(value: string | null, interrupted?: boolean): void;
57
59
  kill(): void;
58
60
  }