@howaboua/pi-durable-js-notebook 0.0.0-stage → 0.10.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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +39 -0
  3. package/README.md +38 -2
  4. package/dist/activation.js +6035 -0
  5. package/dist/execution/src/cell-contract.d.ts +49 -0
  6. package/dist/execution/src/cell-observation.d.ts +7 -0
  7. package/dist/execution/src/cell-progress.d.ts +4 -0
  8. package/dist/execution/src/cell-task.d.ts +17 -0
  9. package/dist/execution/src/cell-tools.d.ts +8 -0
  10. package/dist/execution/src/cells.d.ts +14 -0
  11. package/dist/execution/src/command-backend.d.ts +22 -0
  12. package/dist/execution/src/controls.d.ts +3 -0
  13. package/dist/execution/src/custom-command-config.d.ts +21 -0
  14. package/dist/execution/src/custom-commands.d.ts +62 -0
  15. package/dist/execution/src/exec-source.d.ts +21 -0
  16. package/dist/execution/src/forwarded-tools.d.ts +21 -0
  17. package/dist/execution/src/forwarding-hook.d.ts +6 -0
  18. package/dist/execution/src/forwarding.d.ts +15 -0
  19. package/dist/execution/src/index.d.ts +6 -0
  20. package/dist/execution/src/invocation-state.d.ts +26 -0
  21. package/dist/execution/src/invocation.d.ts +35 -0
  22. package/dist/execution/src/native-tools.d.ts +11 -0
  23. package/dist/execution/src/nested-call.d.ts +26 -0
  24. package/dist/execution/src/nested-result.d.ts +8 -0
  25. package/dist/execution/src/nested.d.ts +3 -0
  26. package/dist/execution/src/output.d.ts +48 -0
  27. package/dist/execution/src/presentation.d.ts +59 -0
  28. package/dist/execution/src/progress.d.ts +23 -0
  29. package/dist/execution/src/projection.d.ts +5 -0
  30. package/dist/execution/src/shell/backend.d.ts +28 -0
  31. package/dist/execution/src/shell/format.d.ts +2 -0
  32. package/dist/execution/src/shell/node-backend.d.ts +9 -0
  33. package/dist/execution/src/shell/output.d.ts +19 -0
  34. package/dist/execution/src/shell/process-session.d.ts +50 -0
  35. package/dist/execution/src/shell/results.d.ts +14 -0
  36. package/dist/execution/src/shell/session-manager.d.ts +46 -0
  37. package/dist/execution/src/shell/session-store.d.ts +53 -0
  38. package/dist/execution/src/shell/shell-args.d.ts +4 -0
  39. package/dist/execution/src/shell/shell.d.ts +14 -0
  40. package/dist/execution/src/shell/wait.d.ts +7 -0
  41. package/dist/execution/src/shell.d.ts +14 -0
  42. package/dist/execution/src/tool-contract.d.ts +34 -0
  43. package/dist/execution/src/tool-origin.d.ts +11 -0
  44. package/dist/execution/src/tool-source.d.ts +6 -0
  45. package/dist/execution/src/tool-value.d.ts +3 -0
  46. package/dist/execution/src/wait-session.d.ts +6 -0
  47. package/dist/index.js +6338 -0
  48. package/dist/js-notebook/src/activation.d.ts +5 -0
  49. package/dist/js-notebook/src/bindings.d.ts +6 -0
  50. package/dist/js-notebook/src/client.d.ts +34 -0
  51. package/dist/js-notebook/src/data-state.d.ts +20 -0
  52. package/dist/js-notebook/src/data-storage.d.ts +17 -0
  53. package/dist/js-notebook/src/engine.d.ts +16 -0
  54. package/dist/js-notebook/src/index.d.ts +53 -0
  55. package/dist/js-notebook/src/kernel.d.ts +25 -0
  56. package/dist/js-notebook/src/managed-bindings.d.ts +20 -0
  57. package/dist/js-notebook/src/managed-source.d.ts +9 -0
  58. package/dist/js-notebook/src/notebook-control.d.ts +7 -0
  59. package/dist/js-notebook/src/portable-state.d.ts +79 -0
  60. package/dist/js-notebook/src/prelude.d.ts +1 -0
  61. package/dist/js-notebook/src/project.d.ts +67 -0
  62. package/dist/js-notebook/src/protocol.d.ts +115 -0
  63. package/dist/js-notebook/src/runtime-cache.d.ts +2 -0
  64. package/dist/js-notebook/src/runtime-contract.d.ts +117 -0
  65. package/dist/js-notebook/src/runtime.d.ts +8 -0
  66. package/dist/js-notebook/src/state-validation.d.ts +2 -0
  67. package/dist/js-notebook/src/storage.d.ts +18 -0
  68. package/dist/js-notebook/src/support.d.ts +12 -0
  69. package/dist/js-notebook/src/tool-calls.d.ts +11 -0
  70. package/dist/js-notebook/src/worker.d.ts +1 -0
  71. package/dist/notebook/src/cell.d.ts +34 -0
  72. package/dist/notebook/src/checkpoint-activity.d.ts +7 -0
  73. package/dist/notebook/src/checkpoint-format.d.ts +32 -0
  74. package/dist/notebook/src/checkpoint-store.d.ts +8 -0
  75. package/dist/notebook/src/command-output.d.ts +1 -0
  76. package/dist/notebook/src/deno-syntax-diagnostics.d.ts +1 -0
  77. package/dist/notebook/src/directory-lock.d.ts +10 -0
  78. package/dist/notebook/src/glob.d.ts +1 -0
  79. package/dist/notebook/src/jupyter-connection.d.ts +17 -0
  80. package/dist/notebook/src/jupyter-execution.d.ts +29 -0
  81. package/dist/notebook/src/jupyter-kernel.d.ts +43 -0
  82. package/dist/notebook/src/jupyter-output.d.ts +32 -0
  83. package/dist/notebook/src/jupyter-shell.d.ts +18 -0
  84. package/dist/notebook/src/jupyter-socket.d.ts +17 -0
  85. package/dist/notebook/src/jupyter-wire.d.ts +16 -0
  86. package/dist/notebook/src/profile-state-format.d.ts +36 -0
  87. package/dist/notebook/src/project-identity.d.ts +1 -0
  88. package/dist/notebook/src/project-state-format.d.ts +80 -0
  89. package/dist/notebook/src/project-state-lock.d.ts +1 -0
  90. package/dist/notebook/src/runtime-contract.d.ts +117 -0
  91. package/dist/notebook/src/runtime-health.d.ts +9 -0
  92. package/dist/notebook/src/storage-retention.d.ts +21 -0
  93. package/dist/notebook/src/tool-observation.d.ts +21 -0
  94. package/dist/worker.js +1545 -0
  95. package/package.json +74 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Igor Warzocha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,39 @@
1
+ JS Notebook adapted from IgorWarzocha/howaboua-pi-stuff, merged PR #552
2
+ revision 84bd5bce60a77c4298484d4b7c810d4fe5220a1b.
3
+ Source: packages/pi-codex-conversion/src/tools/js-mode and the selected-data
4
+ graph definitions, remapping, validation and compaction in ts-mode.
5
+ Repository: https://github.com/IgorWarzocha/howaboua-pi-stuff
6
+
7
+ The source checkout was inspected read-only with git show. Integration uses
8
+ public Pi Durable APIs, ordinary selected tool registrations and the internal
9
+ shared shell implementation. No Pi ExtensionAPI or compatibility wrapper is
10
+ carried. QuickJS retains complete VM snapshots without replaying user cells.
11
+
12
+ QuickJS runtime: quickjs-wasi 3.6.3, MIT, vercel-labs/quickjs-wasi.
13
+ WASM loader: @earendil-works/pi-codemode 1.4.0, MIT.
14
+ Parser: acorn 8.19.0, MIT.
15
+ These are external package dependencies and retain their own licence files.
16
+
17
+ Upstream source licence:
18
+
19
+ MIT License
20
+
21
+ Copyright (c) 2026 Igor Warzocha
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # JS Notebook
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Persistent JavaScript execution for Pi Durable. Closures, class instances, cyclic objects and lexical bindings survive a host restart through complete QuickJS VM checkpoints. Cells are never replayed to restore state.
4
+
5
+ The component registers `exec`, `wait`, `notebook`, `exec_command` and `write_stdin`. Ordinary selected Durable tools are available through `tools` inside cells, with their original registered names. It works without Howcode.
6
+
7
+ ## Host setup
8
+
9
+ ```sh
10
+ npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.10.0/howaboua-pi-durable-js-notebook-0.10.0.tgz
11
+ ```
12
+
13
+ Use Node.js 22.19 or later. Bun hosts are rejected because worker termination is part of the cancellation boundary. Install the package and its declared Durable peers through your application's package manager. QuickJS and its WASM loader use exact versions. If the installed runtime is unavailable, the component can provision its owned cache on first use and reuse it offline.
14
+
15
+ Create `createJsNotebookMode` with a `stateDirectory`, `native: { environmentId }`, a matching shell backend and a `cancelTask` callback that calls the owning Harness's `abortTask`. Install its `extension` in your Durable registry, then call `bind(harness)`. Call `close()` when the application shuts down.
16
+
17
+ `maxHeapMiB` defaults to 4096 and must be at least 128. Half is the live VM budget. Each of at most four isolated VMs receives one quarter of that live budget. An optional `profile` selects initial saved state when the project has no checkpoint.
18
+
19
+ The execution environment must match the explicit native grant. Checkpoint files use the host filesystem beneath `stateDirectory`. Conversations using that directory and the same project share one serial notebook, including lexical state. Projects are identified by the nearest Git root, or by the working directory outside Git. Use separate state directories when applications must not share state.
20
+
21
+ Do not install multiple execution modes with the same tool names in one selected agent.
22
+
23
+ ## Cells and saved state
24
+
25
+ `exec` accepts JavaScript with top-level await. Bare values are discarded. Use `text(value)` or `image(value)` for output. `notify`, `generatedImage`, `store`, `load`, `exit` and `yield_control` are also available. `ALL_TOOLS` describes selected registrations. The VM has no Node globals, filesystem API or module imports. Use registered tools for external operations.
26
+
27
+ Normal successful cells save the complete VM. A leading `// @exec: {"isolated":true}` forks the last committed checkpoint without sampling a running live cell. Completion saves a named candidate without adopting it. External tool and file effects remain shared.
28
+
29
+ Call `notebook` without input for its action help. Whole-notebook profiles preserve the entire VM and replace live state when loaded. Selected-data profiles add noncolliding bindings. Pins preserve supported plain data across reset and protect names from release. Closures and class instances survive whole-VM checkpoints, but cannot be selected-data pins.
30
+
31
+ Startup and tool-result hooks use retained functions. Startup hooks cannot call tools. Failed startup blocks normal execution. Tool-result hooks run after settlement, and calls inside them do not recursively trigger hooks.
32
+
33
+ ## Recovery
34
+
35
+ `wait` continues a yielded cell or terminates it. Cancellation stops its owned worker, including infinite promise chains. Cancellation does not undo tool effects. A stopped live VM requires `notebook restart`, which restores the last completed checkpoint without replaying side effects. Errors that leave a VM alive can retain earlier mutations.
36
+
37
+ An isolated candidate cannot silently overwrite newer project state. A stale load is refused and produces a recovery profile for an explicit replacement. `reset` discards the live project VM, while saved profiles and reset-survival pins remain.
38
+
39
+ Snapshots are runtime-specific, not portable JavaScript serialisations. Preserve the matching runtime version when recovering saved state.