@code-yeongyu/senpi-codemode 2026.10.8 → 2026.10.10-10
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/CHANGELOG.md +178 -0
- package/README.md +212 -14
- package/package.json +6 -5
- package/src/bridge/http-server.ts +9 -1
- package/src/bridge/protocol.ts +12 -3
- package/src/bridge/reserved.ts +2 -0
- package/src/bridges/eval-environment-schemas.ts +48 -0
- package/src/bridges/eval-virtual-schemas.ts +12 -4
- package/src/bridges/reserved-dispatch.ts +13 -1
- package/src/config/executable-settings.json +5 -0
- package/src/config/project-trust.ts +51 -0
- package/src/config/settings-overrides.ts +2 -0
- package/src/environments/js-environments.ts +208 -0
- package/src/environments/js-installer.ts +268 -0
- package/src/environments/js-revision-files.ts +91 -0
- package/src/environments/no-links.ts +132 -0
- package/src/environments/packages-install.ts +98 -0
- package/src/environments/project-resolves.ts +54 -0
- package/src/environments/py-environment.ts +7 -3
- package/src/environments/py-installer.ts +68 -4
- package/src/environments/python-environments.ts +85 -0
- package/src/environments/revision-store.ts +38 -7
- package/src/extension/bridge-tool-call.ts +7 -1
- package/src/extension/cell-kernel-tools.ts +28 -0
- package/src/extension/eval-notifier.ts +13 -2
- package/src/extension/kernel-registration.ts +7 -2
- package/src/extension/kernel-replacement.ts +20 -0
- package/src/extension/runtime-factory.ts +53 -3
- package/src/extension/runtime-info.ts +6 -2
- package/src/extension/session-manager-contract.ts +3 -0
- package/src/extension/session-manager-proxy.ts +6 -0
- package/src/extension/session-manager.ts +26 -4
- package/src/index.ts +4 -2
- package/src/interpreters/detect.ts +34 -1
- package/src/kernels/AGENTS.md +2 -0
- package/src/kernels/jl/prelude.jl +6 -1
- package/src/kernels/js/cell-dispatch.ts +44 -0
- package/src/kernels/js/cell-ownership.js +268 -0
- package/src/kernels/js/cell-run-context.js +89 -0
- package/src/kernels/js/context-manager.ts +48 -39
- package/src/kernels/js/control-frames.ts +24 -0
- package/src/kernels/js/host-entries.ts +62 -0
- package/src/kernels/js/kernel-contract.ts +16 -1
- package/src/kernels/js/kernel-memory-bridge.ts +1 -1
- package/src/kernels/js/kernel-memory.ts +79 -0
- package/src/kernels/js/kernel-tools-registry.js +1 -0
- package/src/kernels/js/local-module-loader.ts +21 -5
- package/src/kernels/js/process-drain-scan.d.ts +8 -0
- package/src/kernels/js/process-drain-scan.js +28 -0
- package/src/kernels/js/process-entry.js +466 -0
- package/src/kernels/js/process-memory-host.ts +83 -0
- package/src/kernels/js/process-worker.ts +298 -0
- package/src/kernels/js/rejection-reports.js +61 -0
- package/src/kernels/js/run-queue.ts +7 -0
- package/src/kernels/js/worker-core.js +53 -8
- package/src/kernels/js/worker-cwd.js +5 -2
- package/src/kernels/js/worker-host.ts +9 -2
- package/src/kernels/js/worker-indirect-eval.js +37 -13
- package/src/kernels/js/worker-package-resolve.js +153 -0
- package/src/kernels/js/worker-require.d.ts +19 -0
- package/src/kernels/js/worker-require.js +52 -0
- package/src/kernels/js/worker-runtime.js +45 -9
- package/src/kernels/js/worker-shadow-guard.js +2 -6
- package/src/kernels/js/worker-shell-capture.js +5 -0
- package/src/kernels/js/worker-slot.ts +9 -0
- package/src/kernels/js/worker-startup.ts +49 -1
- package/src/kernels/js/worker-webview.js +15 -1
- package/src/kernels/js/workpool.js +5 -2
- package/src/kernels/py/host-cell.ts +8 -31
- package/src/kernels/py/kernel.ts +8 -2
- package/src/kernels/py/prelude.py +145 -11
- package/src/kernels/py/process.ts +4 -0
- package/src/kernels/py/transport.ts +13 -1
- package/src/kernels/rb/workpool.rb +7 -1
- package/src/kernels/sandbox/sandbox-cell.ts +141 -0
- package/src/kernels/sandbox/vendor/pi-codemode/VENDORED.md +1 -0
- package/src/kernels/sandbox/vendor/pi-codemode/runtime/prelude-source.ts +14 -1
- package/src/kernels/sandbox/vendor/pi-codemode/runtime/worker.ts +4 -1
- package/src/kernels/sandbox/vendor/pi-codemode/types.ts +2 -0
- package/src/kernels/shared/cell-source-at-start.ts +18 -0
- package/src/kernels/shared/host-cell.ts +57 -0
- package/src/kernels/shared/subprocess-process.ts +14 -0
- package/src/prompt/eval-prompt.ts +8 -1
- package/src/tool/AGENTS.md +1 -0
- package/src/tool/cell-handler.ts +13 -12
- package/src/tool/cell-reserved-dispatch.ts +1 -0
- package/src/tool/cell-runtime.ts +4 -2
- package/src/tool/detached-cell-contract.ts +3 -0
- package/src/tool/detached-cell-manager.ts +4 -8
- package/src/tool/detached-cell-notification.ts +11 -63
- package/src/tool/detached-cell-snapshot.ts +17 -0
- package/src/tool/detached-eval-result.ts +13 -7
- package/src/tool/detached-notification-queue.ts +1 -2
- package/src/tool/eval-request.ts +23 -1
- package/src/tool/eval-tool-options.ts +6 -0
- package/src/tool/eval-tool.ts +17 -4
- package/src/tool/interrupt-note.ts +4 -5
- package/src/tool/live-headline.ts +60 -0
- package/src/tool/load-cell.ts +88 -0
- package/src/tool/magic-cell-host.ts +123 -0
- package/src/tool/magic-cells.ts +75 -0
- package/src/tool/managed-cell.ts +0 -4
- package/src/tool/render.ts +74 -15
- package/src/tool/run-eval-cell.ts +73 -1
- package/src/tool/runtime-label.ts +2 -1
- package/src/tool/types.ts +50 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,184 @@
|
|
|
12
12
|
|
|
13
13
|
### Removed
|
|
14
14
|
|
|
15
|
+
## [2026.10.10-10] - 2026-10-09
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
## [2026.10.10-9] - 2026-10-08
|
|
28
|
+
|
|
29
|
+
### Breaking Changes
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
### Removed
|
|
38
|
+
|
|
39
|
+
## [2026.10.10-8] - 2026-10-08
|
|
40
|
+
|
|
41
|
+
### Breaking Changes
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `packages.install(manager, requirements, {timeout?})` in JavaScript and Python cells installs through the same session environment as `%pip install` / `%bun add` / `%npm add` and returns the install receipt; a stop cancels it and the timeout (600 seconds by default) fails it with `environment_install_timeout`.
|
|
46
|
+
|
|
47
|
+
- `tool_schema("eval:environments")` and `tool_schema("eval:isolation")` document the package magics (`%pip`, `%bun`/`%npm`, `%environment`, `%load`) and isolated cells on demand, with the error codes each one raises. Nothing is added to the eval prompt or its input schema.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- The eval timing benchmark's spike retry no longer waits for a load at or above its own refusal ceiling: the settle target is capped at 70, so a run whose calm load was near 80 cannot start its retries straight into another spike and burn them all in seconds. On a host whose normal load is above 70, each retry now waits the full 15 minutes and then retries anyway; the attempt's own spike checks still decide what is kept. ([#2922](https://github.com/code-yeongyu/senpi/issues/2922))
|
|
54
|
+
|
|
55
|
+
- The eval timing benchmark no longer throws away a whole multi-block run when the host's 1-minute load goes over 80 partway through: only the block that saw the spike is discarded and re-run (up to 3 retries, each after the load has fallen back under 70). A runtime failure in the same block is never discarded with the spike. A block that spikes on every attempt is labelled, making the run inconclusive rather than refused, and the other blocks still report. Re-run blocks are listed in the JSON report's `retriedBlocks`. ([#2909](https://github.com/code-yeongyu/senpi/issues/2909))
|
|
56
|
+
|
|
57
|
+
### Removed
|
|
58
|
+
|
|
59
|
+
## [2026.10.10-6] - 2026-10-07
|
|
60
|
+
|
|
61
|
+
### Breaking Changes
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
### Removed
|
|
70
|
+
|
|
71
|
+
## [2026.10.10-5] - 2026-10-07
|
|
72
|
+
|
|
73
|
+
### Breaking Changes
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- A running, queued or detached eval row now leads with the cell's summary (or its first code line), then the language, state and elapsed time, on one line; the code is shown on expand. A call still streaming its arguments shows that row instead of the raw `eval code="..."` fallback. Completed rows are unchanged ([#2802](https://github.com/code-yeongyu/senpi/issues/2802)).
|
|
80
|
+
|
|
81
|
+
- A JavaScript cell may declare a name the kernel or platform already defines (`log`, `fetch`, `print`, `URL`, ...): the value persists for your later cells while the kernel and imported libraries keep the original, `delete <name>` restores it, and the cell notes the shadowing ([#2793](https://github.com/code-yeongyu/senpi/issues/2793)).
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
|
|
85
|
+
- A live eval row whose cell has no summary skips a first code line that holds only escape or control characters and leads with the next line that has content, instead of showing only an ellipsis ([#2850](https://github.com/code-yeongyu/senpi/issues/2850)).
|
|
86
|
+
|
|
87
|
+
- The `require` in a JavaScript cell carries `require.resolve`, `require.resolve.paths` and `require.cache` like Node's own `require`, and the call and `resolve` share one lookup, so they always name the same copy: builtins natively (including Bun's, such as `bun:sqlite`), then the project, then the managed package environment ([#2832](https://github.com/code-yeongyu/senpi/issues/2832)).
|
|
88
|
+
|
|
89
|
+
- A live eval row whose cell has no summary sanitizes its first code line before measuring it, so escape and control characters in that line never reach the one-line row ([#2839](https://github.com/code-yeongyu/senpi/issues/2839)).
|
|
90
|
+
|
|
91
|
+
- A live eval row stays one line in every terminal: its headline is measured and cut in screen cells, so a summary with wide characters (Korean, Chinese, Japanese, emoji) no longer wraps a narrow terminal, and a `peek`/`stop` call still streaming in renders `eval peek` instead of `eval peek undefined` ([#2831](https://github.com/code-yeongyu/senpi/issues/2831)).
|
|
92
|
+
|
|
93
|
+
- Stopping or timing out a JavaScript cell that awaits something that never settles (a promise, a `fetch` whose server never answers, a polling loop on timers, `Bun.sleep` or `node:timers/promises`, a loop of short `Bun.spawn` children) now keeps the worker and every global instead of restarting it. Stop ends the cell and everything it started: its timers are cleared, pending sleeps and `fetch` requests reject, and the sockets, servers, WebSockets, WebViews, nested workers and child processes it opened are closed; the result arrives once its children are gone. A stopped cell's own `catch`/`finally` can no longer print, call tools, start processes, schedule timers or open connections. An unhandled promise rejection no longer crashes the JavaScript kernel: it is reported on the running or next cell, naming the cell it came from, with bursts folded into one line; an uncaught exception still restarts the worker. A cell stopped during a `Bun.$` command still restarts the worker, as before ([#2788](https://github.com/code-yeongyu/senpi/issues/2788)).
|
|
94
|
+
|
|
95
|
+
- JavaScript cells can call `require(...)` and `createRequire(...)`: builtins, relative CommonJS and JSON files, and packages from the project or the managed package environment resolve as they do for `import` ([#2792](https://github.com/code-yeongyu/senpi/issues/2792)).
|
|
96
|
+
|
|
97
|
+
- A detached eval cell's completion notification now carries the same output its result would have shown in the foreground (head, tail, elision marker and full-output notice) instead of a 512-byte tail, and images the cell displayed are delivered with the notification ([#2789](https://github.com/code-yeongyu/senpi/issues/2789)).
|
|
98
|
+
|
|
99
|
+
### Removed
|
|
100
|
+
|
|
101
|
+
## [2026.10.10-4] - 2026-10-06
|
|
102
|
+
|
|
103
|
+
### Breaking Changes
|
|
104
|
+
|
|
105
|
+
### Added
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- A detached eval cell that waits for its kernel to start now says so (`waiting for the js kernel to be ready`) instead of `queued behind in the js kernel` with an empty predecessor ([#2790](https://github.com/code-yeongyu/senpi/issues/2790)).
|
|
112
|
+
|
|
113
|
+
- A stopped (or failed) detached cell's result and notification show its buffered output instead of the live `1/1 cells running` frame, so a cancelled cell no longer reads as still running. The kernel-state note now says plainly whether the kernel was restarted: `The JavaScript worker was not restarted; variables from earlier cells are kept.` instead of `... remains running; its existing variables are preserved.`, or `The JavaScript worker was restarted; variables from earlier cells are lost.` instead of `... was unresponsive to interrupt and was restarted ...` (the worker may have answered the interrupt and still needed a restart) ([#2791](https://github.com/code-yeongyu/senpi/issues/2791)).
|
|
114
|
+
|
|
115
|
+
- An isolated (`isolate: true`) eval cell's result names QuickJS as its runtime (`quickjs <version>, sandbox`) instead of the persistent kernel's Bun or Node runtime ([#2811](https://github.com/code-yeongyu/senpi/issues/2811)).
|
|
116
|
+
|
|
117
|
+
### Removed
|
|
118
|
+
|
|
119
|
+
## [2026.10.10-3] - 2026-10-06
|
|
120
|
+
|
|
121
|
+
### Breaking Changes
|
|
122
|
+
|
|
123
|
+
### Added
|
|
124
|
+
|
|
125
|
+
- An opt-in process-isolated JavaScript kernel (`isolation.js: "process"` or `SENPI_CODEMODE_JS_ISOLATION=process`) runs each JavaScript kernel in its own subprocess instead of a worker thread, so a kernel crash (`SIGSEGV`, out-of-memory, `process.exit`, an uncaught error) can no longer take down the host session; the next cell runs on a replacement child with a restart notice naming the crash. It isolates crashes, not hostile code: a cell is trusted as in worker mode, and hostile code belongs in `isolate: true` sandbox cells ([#2752](https://github.com/code-yeongyu/senpi/issues/2752) tracks hostile-cell isolation). The child runs on the host's own runtime, exits as soon as its host is gone (including `SIGKILL`), carries large output and `BigInt`/`undefined` values as worker mode does, and its frames carry a per-process token so stray output is never taken for a frame. The default stays `"worker"` and worker-mode behaviour is unchanged ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- The README now documents every eval surface (helpers, magic cells, settings, JavaScript isolation modes and sandbox cells), and CI checks it against the helper census, so a new helper cannot ship undocumented ([#2787](https://github.com/code-yeongyu/senpi/pull/2787)).
|
|
130
|
+
|
|
131
|
+
### Fixed
|
|
132
|
+
|
|
133
|
+
### Removed
|
|
134
|
+
|
|
135
|
+
## [2026.10.10-2] - 2026-10-05
|
|
136
|
+
|
|
137
|
+
### Breaking Changes
|
|
138
|
+
|
|
139
|
+
### Added
|
|
140
|
+
|
|
141
|
+
- `@code-yeongyu/senpi-codemode/executable-settings.json` lists the settings that name an executable run at session start (today `languages.pyInterpreter`). senpi's project-trust check reads it, so a project codemode file that sets one asks for trust, and a test fails if a new free-form string setting is neither on the list nor marked as not naming an executable ([#2772](https://github.com/code-yeongyu/senpi/pull/2772)).
|
|
142
|
+
|
|
143
|
+
### Changed
|
|
144
|
+
|
|
145
|
+
### Fixed
|
|
146
|
+
|
|
147
|
+
- Settings that were accepted but did nothing now take effect ([#2763](https://github.com/code-yeongyu/senpi/issues/2763)): `kernelTools.enabled: false` makes JavaScript `tool(fn)` and Python `@tool` refuse with `tools_unavailable`; `languages.pyInterpreter` makes the Python kernel run exactly that executable (a path that does not answer makes Python unavailable, with a warning naming the setting; one named by a project's own settings file is honored only in a trusted project); `prompt.advertiseHelpers: true` adds one line pointing at `tool_schema('eval:helpers')` to the eval description. Settings-file warnings (an unknown key, a fallback to defaults) now reach the user as a notice, or on stderr without a UI.
|
|
148
|
+
|
|
149
|
+
### Removed
|
|
150
|
+
|
|
151
|
+
## [2026.10.10] - 2026-10-05
|
|
152
|
+
|
|
153
|
+
### Breaking Changes
|
|
154
|
+
|
|
155
|
+
### Added
|
|
156
|
+
|
|
157
|
+
- Isolated eval cells: with `sandbox.enabled`, `isolate: true` runs a JavaScript cell in a fresh QuickJS VM with no persistence and no ambient host (only `tools.*`, `print`, `display`), streaming output under a credit window. Off by default; the eval schema is unchanged until the setting is on.
|
|
158
|
+
- A JavaScript cell that is only `%bun add <package ...>` or `%npm add <package ...>` installs packages into a per-session managed environment without restarting the kernel; the next cell imports them by bare name, the project's `package.json` and `node_modules` are untouched, lifecycle scripts never run, and a failed or cancelled install leaves the previous packages active ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
159
|
+
|
|
160
|
+
### Changed
|
|
161
|
+
|
|
162
|
+
### Fixed
|
|
163
|
+
|
|
164
|
+
- An isolated (`isolate: true`) cell whose QuickJS runtime is missing now fails with `eval_isolate_unavailable` before any of its code runs, instead of a module-resolution error that named a host path ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
165
|
+
|
|
166
|
+
- `%bun add` over a package first installed from a local directory now works when the new archive's top directory is not `package/` (a GitHub-style `<repo>-<sha>.tgz`, or a plain `.tar`): its name is read from the archive's own top-level directory, so the old directory's links are removed before bun installs ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
167
|
+
|
|
168
|
+
- A nested tool call that is denied inside an `eval` cell (a permission denial or another hook's block) now reaches the cell as the plain denial, without the `Expected parameters:` schema hint that made it read like an argument error; argument failures still get the hint ([#2700](https://github.com/code-yeongyu/senpi/issues/2700)). Thanks to @MoerAI ([#2755](https://github.com/code-yeongyu/senpi/pull/2755)).
|
|
169
|
+
- An `eval` run with an invalid `language` value (for example `"python"`, `""` or `null`) now gets its own error listing the enabled languages, instead of the "run requires language" message meant for an omitted one; `peek` and `stop` still need no language ([#1395](https://github.com/code-yeongyu/senpi/issues/1395)). Thanks to @MoerAI.
|
|
170
|
+
|
|
171
|
+
### Removed
|
|
172
|
+
|
|
173
|
+
## [2026.10.9] - 2026-10-04
|
|
174
|
+
|
|
175
|
+
### Breaking Changes
|
|
176
|
+
|
|
177
|
+
### Added
|
|
178
|
+
|
|
179
|
+
- Python `agent(prompt, tools=[...])` grants the child the cell's `@tool` functions by name, like JavaScript's `agent(prompt, { tools })`; anything other than a list of names is refused with `invalid_tools` ([#2731](https://github.com/code-yeongyu/senpi/issues/2731)).
|
|
180
|
+
- `workpool(agent, name, {mode, tools})` forwards `tools`, a list of kernel-tool names the cell defined, to the host workpool unchanged in all four languages, so pool workers can call them; anything other than a list of names is refused with `invalid_tools` before reaching the host. Which kernels' tools a host accepts is the host's call: JavaScript `tool(fn)` tools work on omo today, while Python `@tool` tools need omo#9529 ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
181
|
+
- A Python or JavaScript cell that is only `%load <path>` runs that local file as the cell: its definitions persist, Python tracebacks name the file and its sibling modules import, and JavaScript resolves the file's relative imports from its directory; remote URLs are refused ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
182
|
+
- A Python cell that is only `%pip install <requirements>` installs packages without restarting the kernel; the next cell imports them. Packages go into the session's own environment (or `<cwd>/.senpi/python-packages` after `%environment project`), never the interpreter's site-packages or the user site, and a failed or cancelled install leaves the previous packages active ([#2452](https://github.com/code-yeongyu/senpi/issues/2452)).
|
|
183
|
+
|
|
184
|
+
### Changed
|
|
185
|
+
|
|
186
|
+
### Fixed
|
|
187
|
+
|
|
188
|
+
- A Python cell can now grant its `@tool` functions to a child ([#2731](https://github.com/code-yeongyu/senpi/issues/2731)). Host calls from Python cells (`tool.task(..., tools=[...])`, `agent(..., tools=[...])`, `workpool(..., tools=[...])`) reached the host with no kernel-tools capability, so every such grant was refused as unavailable. Each call now carries its cell, and the host gives it that cell's capability while the cell runs; a call from another, unknown or finished cell gets none.
|
|
189
|
+
- `%pip` parsing follow-ups ([#2689](https://github.com/code-yeongyu/senpi/pull/2689)): a `%pip` or `%environment` line after code now says to put it on its own cell instead of "Unsupported line magic"; a comment line ending in a backslash no longer swallows the `%pip` line after it; inside double quotes a backslash is kept unless it escapes a quote, backslash, `$` or a backtick, as a POSIX shell does.
|
|
190
|
+
|
|
191
|
+
### Removed
|
|
192
|
+
|
|
15
193
|
## [2026.10.8] - 2026-10-04
|
|
16
194
|
|
|
17
195
|
### Breaking Changes
|
package/README.md
CHANGED
|
@@ -59,6 +59,75 @@ task-tool names are known.
|
|
|
59
59
|
A missing optional interpreter removes that language from the session's `eval`
|
|
60
60
|
schema; it is not an installation failure.
|
|
61
61
|
|
|
62
|
+
### JavaScript process isolation
|
|
63
|
+
|
|
64
|
+
By default the JavaScript kernel runs as a worker thread on the host's own
|
|
65
|
+
runtime (`isolation.js: "worker"`). Setting `isolation.js: "process"` (or
|
|
66
|
+
`SENPI_CODEMODE_JS_ISOLATION=process`, which wins over the file) runs each
|
|
67
|
+
JavaScript kernel in its own subprocess instead, so a kernel crash (a native
|
|
68
|
+
`SIGSEGV`, an out-of-memory, `process.exit`, an uncaught error) cannot take down
|
|
69
|
+
the host session. The next cell runs on a replacement child, and its result
|
|
70
|
+
carries the restart notice and names the crash.
|
|
71
|
+
|
|
72
|
+
**Trust model.** Process mode isolates crashes, not hostile code. A cell runs in
|
|
73
|
+
the same process that talks to the host, so it can reach everything that process
|
|
74
|
+
holds, exactly as a worker-mode cell can. The frame token described below guards
|
|
75
|
+
only against accidental corruption of the channel. Hostile code belongs in
|
|
76
|
+
`isolate: true` sandbox cells. Hostile-cell isolation for process mode is tracked
|
|
77
|
+
in [#2752](https://github.com/code-yeongyu/senpi/issues/2752).
|
|
78
|
+
|
|
79
|
+
**Core dumps (Linux).** The kernel child marks itself non-dumpable at start
|
|
80
|
+
(`prctl(PR_SET_DUMPABLE, 0)`). A Linux system that pipes core dumps to
|
|
81
|
+
`systemd-coredump` or apport otherwise holds a crashed child until its dump is
|
|
82
|
+
read, which froze the cell for about 30 s; without the dump the crash is reported
|
|
83
|
+
at once, still naming its signal. Two side effects: no core file is written for a
|
|
84
|
+
crash of the kernel child itself, and a same-user debugger cannot attach to it
|
|
85
|
+
(`ptrace` needs a dumpable process). A cell's own subprocesses are unaffected,
|
|
86
|
+
because `exec` resets the flag. Set `SENPI_KERNEL_CORE_DUMPS=1` to keep dumps and
|
|
87
|
+
debugger access while debugging the kernel.
|
|
88
|
+
|
|
89
|
+
How it works:
|
|
90
|
+
|
|
91
|
+
- **Runtime.** The child runs on the host's own runtime: bun when senpi runs on
|
|
92
|
+
Bun, node otherwise. A compiled binary whose executable is neither falls back to
|
|
93
|
+
`bun` or `node` on `PATH`, preferring the host's kind. The badge names the
|
|
94
|
+
runtime that actually runs the child, for example `js (bun 1.4.x, process)`.
|
|
95
|
+
- **Frames.** The host writes a random token as the child's first line on fd 0,
|
|
96
|
+
and every frame the child sends carries it. The host parses only lines that
|
|
97
|
+
carry the token; any other line (a cell's raw fd write, a child process's
|
|
98
|
+
output) is delivered as text. Frames are written in full. Large text is split
|
|
99
|
+
below the 10 MiB frame limit, and a result too large to return fails its cell,
|
|
100
|
+
not the kernel. A `BigInt` or an `undefined` field reaches the host as it does
|
|
101
|
+
in worker mode.
|
|
102
|
+
- **File descriptors.** Under Bun, the control channel moves to a private
|
|
103
|
+
duplicate of fd 0, fd 0 becomes `/dev/null`, and fd 1 is re-pointed at a
|
|
104
|
+
pipe that a reader thread turns into `text` frames as it is written. The pipe is kept
|
|
105
|
+
blocking (a child that switches it to non-blocking is undone before every cell and around
|
|
106
|
+
every child process a cell starts),
|
|
107
|
+
so output is never held in memory while a cell is busy. A cell's direct
|
|
108
|
+
`process.stdout.write` or fd 1 write (or a child process inheriting fd 1)
|
|
109
|
+
arrives before that cell's result. In a bun child, raw fd 1 bytes are not
|
|
110
|
+
interleaved with `console` output in the order they were written. A node
|
|
111
|
+
child cannot move its fds: cell output shares the channel, and fd 0 is the
|
|
112
|
+
channel. If libc cannot be loaded through `bun:ffi`, a bun child runs
|
|
113
|
+
the same way and still starts; the first cell's stderr says why.
|
|
114
|
+
- **Lifetime.** The child exits as soon as its control channel closes. That
|
|
115
|
+
covers every way the host ends, including `SIGKILL`. A watchdog thread also
|
|
116
|
+
compares the parent pid with the one recorded at start, so a child whose cell
|
|
117
|
+
never yields (a busy loop, a blocking call) still ends with its host, including
|
|
118
|
+
under a Linux subreaper. A process-mode kernel never outlives its host.
|
|
119
|
+
- **Failed start.** There is no inline fallback in process mode. A failed start
|
|
120
|
+
settles the waiting cell with a capability-gap result naming the missing
|
|
121
|
+
runtime (`Install bun or node, or use isolation.js: "worker"`). The result's
|
|
122
|
+
memory reading is the child's process footprint.
|
|
123
|
+
|
|
124
|
+
The default stays `"worker"`, and worker-mode behaviour is unchanged.
|
|
125
|
+
|
|
126
|
+
To run the `environments` suites with bun children (the runtime the product
|
|
127
|
+
uses), run them under bun: `SENPI_CODEMODE_JS_ISOLATION=process bunx --bun vitest
|
|
128
|
+
run test/environments`. Under plain `vitest` the children follow the test
|
|
129
|
+
runner's runtime, which is node.
|
|
130
|
+
|
|
62
131
|
Python startup waits for the interpreter's `ready` event. It reports progress
|
|
63
132
|
through `stdlib-imports`, `runtime-init`, and `host-init`; advancing to the next
|
|
64
133
|
stage resets an inactivity guard rather than consuming a total startup budget.
|
|
@@ -67,6 +136,12 @@ Windows fresh-cache bootstrap p99 (30 samples). A stalled or failed start names
|
|
|
67
136
|
the last stage and retains the interpreter's diagnostic error. The low-level
|
|
68
137
|
`PythonKernel.start({ startupTimeoutMs })` override applies per stage.
|
|
69
138
|
|
|
139
|
+
Every `eval` run must explicitly select an enabled `language` (`js`, `py`, `rb`,
|
|
140
|
+
or `jl`); there is no default kernel, even when only one language is enabled.
|
|
141
|
+
Omitting `action` means `run`, so it also requires `language`. Control requests
|
|
142
|
+
with `action: "peek"` or `action: "stop"` use `cell_id` and do not require a
|
|
143
|
+
language.
|
|
144
|
+
|
|
70
145
|
### Session environment
|
|
71
146
|
|
|
72
147
|
Every kernel starts with the active session's `PI_*` environment — `PI_SESSION_ID`,
|
|
@@ -100,6 +175,93 @@ getter and may name a file that does not exist yet. It honors session-directory
|
|
|
100
175
|
and in-memory sessions; it cannot be derived reliably from `PI_SESSION_FILE`. If the host
|
|
101
176
|
omits the getter, the variable is unset rather than inherited from the launching process.
|
|
102
177
|
|
|
178
|
+
### Loading a file
|
|
179
|
+
|
|
180
|
+
A Python or JavaScript cell whose only line is `%load <path>` reads that file and
|
|
181
|
+
runs it as the cell, so its definitions persist like any cell. The path is relative
|
|
182
|
+
to the session directory, or a `local://` or `file://` URL; other URL schemes are
|
|
183
|
+
refused and nothing is fetched. The cell runs as its file: Python compiles it under
|
|
184
|
+
the file's name, so tracebacks name the file and line, and sets `__file__` and puts
|
|
185
|
+
the file's directory first on the import path, so `from sibling import g` resolves
|
|
186
|
+
next to it. JavaScript evaluates it under the file's name and resolves its relative
|
|
187
|
+
imports from the file's directory. The file is read when the cell's turn comes in
|
|
188
|
+
the kernel's queue, so a `%load` queued behind the cell that writes the file runs
|
|
189
|
+
what that cell wrote. When the cell ends, Python takes the file's directory back off
|
|
190
|
+
the import path and restores `__file__`, so later cells import as before. A file that
|
|
191
|
+
cannot be read fails the cell with a message naming the path as written
|
|
192
|
+
(`file not found: <path>`, `permission denied: <path>`); files over 8 MiB, and
|
|
193
|
+
anything that is not a regular file, are refused.
|
|
194
|
+
|
|
195
|
+
### JavaScript packages
|
|
196
|
+
|
|
197
|
+
A JavaScript cell whose only line is `%bun add <package ...>` or `%npm add <package ...>`
|
|
198
|
+
installs packages without restarting the kernel; the next cell imports them by bare name.
|
|
199
|
+
`%bun add` uses bun and `%npm add` uses npm; `environments.js.installer` (`bun`, `npm` or
|
|
200
|
+
`auto`: bun when it is on `PATH`, else npm) applies only where the magic names none, and the
|
|
201
|
+
kernel's own runtime never changes to get one.
|
|
202
|
+
|
|
203
|
+
In the default managed mode packages go into an environment revision under the session's
|
|
204
|
+
artifacts directory, never into the project's `package.json` or `node_modules`. With
|
|
205
|
+
`environments.managedRoot` set, every session using that root shares one revision chain: their
|
|
206
|
+
installs are serialized and each revision carries the packages installed before it.
|
|
207
|
+
A bare import resolves from the session directory's `node_modules` first and then from the
|
|
208
|
+
active revision, using each package's `exports` for `import` (ESM-only packages load), so the
|
|
209
|
+
project's own packages still win, and both win over Senpi's own dependencies (a package neither has may still load from Senpi's install). When a
|
|
210
|
+
newly added package is also in the project's `node_modules`, the result says
|
|
211
|
+
`environment_resolution_conflict` because the project copy resolves first.
|
|
212
|
+
|
|
213
|
+
Each install builds a new revision that carries the previous one forward (its `package.json`,
|
|
214
|
+
lockfile, and from `.npmrc` only `registry`, `@scope:registry`, `strict-ssl`, `ca` and `cafile`, rewritten as a regular file; credentials and every other key are dropped, and `bunfig.toml` is not carried)
|
|
215
|
+
and is published only when the installer succeeds; a failed or cancelled install, or one still
|
|
216
|
+
running when the session closes, leaves the previous revision active. Lifecycle scripts never run
|
|
217
|
+
(`--ignore-scripts`), installer flags are refused because the host picks the destination, and a
|
|
218
|
+
path-like package (`./pkg`, `file:../pkg`) is a path from the session directory. Package names
|
|
219
|
+
are split on whitespace; quoting is not supported. Error and installer text names the session directory as
|
|
220
|
+
`<cwd>`, the revision as `<root>`, the temp directory as `<tmp>`, the home directory as `~`, and an
|
|
221
|
+
absolute package path by its file name only. `%environment project` installs
|
|
222
|
+
into the session directory itself instead.
|
|
223
|
+
|
|
224
|
+
### Python packages
|
|
225
|
+
|
|
226
|
+
A Python cell whose only line is `%pip install <requirements>` installs packages
|
|
227
|
+
without restarting the kernel: variables, the process and its working directory
|
|
228
|
+
stay as they were. The cell runs in the kernel's queue like any other cell (it waits
|
|
229
|
+
for the cell ahead of it, can be cancelled while queued, and detaches past the
|
|
230
|
+
foreground window), but the install runs on the host, so its time does not count
|
|
231
|
+
against the run budget. The next cell imports the new packages; modules a cell
|
|
232
|
+
already imported stay cached until `reset`.
|
|
233
|
+
|
|
234
|
+
Packages go into the session's own environment, never into the interpreter's
|
|
235
|
+
site-packages or the user site: pip always runs as
|
|
236
|
+
`<kernel interpreter> -m pip install --target <environment>`, and flags that pick
|
|
237
|
+
another destination (`--target`, `--user`, `--prefix`, `--root`, `--home`,
|
|
238
|
+
`-e`) are refused. Each install builds a new revision of the environment and
|
|
239
|
+
publishes it only when pip succeeds, so a failed or cancelled install leaves the
|
|
240
|
+
previous packages active and importable. A cell that mixes `%pip` with code is
|
|
241
|
+
refused; put `%pip` on its own cell.
|
|
242
|
+
|
|
243
|
+
`%environment managed` (the default) keeps the environment under the session's
|
|
244
|
+
artifacts directory, or `environments.managedRoot` when set; `%environment project`
|
|
245
|
+
installs into `<cwd>/.senpi/python-packages` instead, shared by every session in
|
|
246
|
+
that project, with concurrent installs serialised by a lock. Setting
|
|
247
|
+
`environments.autoProvision` to `false` turns installs off
|
|
248
|
+
(`environment_installer_unavailable`). Failures carry pip's error output and one
|
|
249
|
+
of `environment_install_failed`, `environment_install_cancelled`,
|
|
250
|
+
`environment_installer_unavailable` or `environment_resolution_conflict`.
|
|
251
|
+
|
|
252
|
+
### Isolated cells
|
|
253
|
+
|
|
254
|
+
With `sandbox.enabled: true`, a JavaScript call may pass `isolate: true`. The cell then runs in a fresh QuickJS VM (the vendored pi codemode runtime) instead of the persistent kernel:
|
|
255
|
+
|
|
256
|
+
- Nothing persists: globals from the kernel are not visible, and a global set in one isolated cell is gone in the next. `store()` throws `eval_isolate_no_state` and `load()` returns `undefined`.
|
|
257
|
+
- No ambient host: there is no `process`, `require`, file system, network, child processes or timers. The cell's only reach is `tools.<name>` (also `tool.<name>`; every active tool except `eval`, run through the same permission hooks as a direct call) plus `print`, `display`, `text` and `image`.
|
|
258
|
+
- `isolate: true` isolates the JavaScript, not the tools it calls: a tool keeps its normal reach. `tools.bash`, for example, runs a shell with the session's environment and files, under the same permission hooks as any other call.
|
|
259
|
+
- Output streams from the VM in frames under a 256 KiB credit window, so the VM never holds a large item; the host joins an item's frames before adding it to the result, and memory stays bounded by `sandbox.memoryMb`.
|
|
260
|
+
- It is a host entry in the JavaScript queue: it waits for earlier cells, Stop and the run budget end it, and the persistent kernel is never restarted for it.
|
|
261
|
+
- Limits: `sandbox.memoryMb` (default 64) and `sandbox.timeoutSeconds` (default 300). Failures are named: `eval_isolate_memory_limit`, `eval_isolate_timeout`, `eval_isolate_unresolved_promise` (a top-level promise that can never settle) and `eval_isolate_unavailable` (the runtime could not start).
|
|
262
|
+
|
|
263
|
+
While `sandbox.enabled` is `false` (the default) the `isolate` field is absent from the eval schema, and passing it is refused with `eval_isolate_invalid`, as are `isolate` with another language and `isolate` with `reset`.
|
|
264
|
+
|
|
103
265
|
## Settings
|
|
104
266
|
|
|
105
267
|
Configuration is loaded in this order:
|
|
@@ -161,7 +323,7 @@ Configuration is loaded in this order:
|
|
|
161
323
|
| `memory.retainedResultsMb` | `32` | In-memory byte budget (MiB) for the settled cells kept for `peek`/`list`, on top of the 32-cell count cap; the oldest go first and the newest is always kept. `0` keeps only the count cap. Env override: `SENPI_CODEMODE_RETAINED_RESULTS_MB` (a non-negative integer). |
|
|
162
324
|
| `memory.retainedImagesMb` | `256` | Disk budget (MiB) for settled-cell images. Images of settled cells (foreground and detached) are written as base64 files under `<session artifacts>/settled-images/` instead of staying in memory, and `peek` reads them back, so it returns the full result. Beyond the budget the oldest files are deleted first; an evicted cell's files are deleted with it; the directory is removed when the session ends. A `peek` whose image file is gone returns the text plus a one-line note. `0` keeps only the count cap. Env override: `SENPI_CODEMODE_RETAINED_IMAGES_MB` (a non-negative integer). |
|
|
163
325
|
| `memory.idleParkMinutes` | `0` | Off by default. When greater than 0, a kernel with no cell running or queued for this many minutes is closed to give its memory back, and the next cell for that language starts a fresh one; that cell's result says the kernel was restarted and every earlier global is lost. Applies to every language. |
|
|
164
|
-
| `languages.pyInterpreter` | unset | Explicit Python interpreter path. Unset keeps
|
|
326
|
+
| `languages.pyInterpreter` | unset | Explicit Python interpreter path: the Python kernel runs exactly that executable (a path with spaces is fine). A path that does not answer `--version` makes Python unavailable for the session, with a warning naming the setting. Unset keeps `PATH` detection. |
|
|
165
327
|
| `environments.managedRoot` | unset | Root directory for managed per-session environments; unset uses the session's default location. |
|
|
166
328
|
| `environments.autoProvision` | `true` | Lets installs provision a managed environment. `false` makes installs refuse with `environment_installer_unavailable`. |
|
|
167
329
|
| `environments.js.installer` | `auto` | Installer for the managed JavaScript environment: `auto`, `bun` or `npm`. |
|
|
@@ -171,16 +333,16 @@ Configuration is loaded in this order:
|
|
|
171
333
|
| `sandbox.memoryMb` | `64` | Memory cap (MiB) for a sandbox cell. Env override: `SENPI_CODEMODE_SANDBOX_MEMORY_MB` (a positive integer wins). |
|
|
172
334
|
| `sandbox.timeoutSeconds` | `300` | Time limit for a sandbox cell. |
|
|
173
335
|
| `prompt.advertiseHelpers` | `false` | When `true`, one pointer line to `tool_schema('eval:helpers')` is appended to the eval description. |
|
|
174
|
-
| `kernelTools.enabled` | `true` | Allows cells to define kernel tools
|
|
336
|
+
| `kernelTools.enabled` | `true` | Allows cells to define kernel tools. `false` makes JavaScript `tool(fn)` and Python `@tool` refuse with `tools_unavailable`, naming this setting. |
|
|
175
337
|
|
|
176
|
-
|
|
338
|
+
Every key in the table takes the effect its row describes.
|
|
177
339
|
|
|
178
340
|
`SENPI_CODEMODE_PY`, `SENPI_CODEMODE_JS`, `SENPI_CODEMODE_RB`, and
|
|
179
341
|
`SENPI_CODEMODE_JL` override the corresponding file setting. `1` or `true`
|
|
180
342
|
enables; `0` or `false` disables. Any other value leaves the file setting in
|
|
181
343
|
effect.
|
|
182
344
|
|
|
183
|
-
A top-level key this version does not know is ignored with one warning naming it, and the rest of the file still applies, so a settings file written for a newer senpi keeps working. Malformed JSON, or an invalid value or an unknown key inside a known setting, falls back to all defaults with a warning.
|
|
345
|
+
Settings problems reach the user as a notice in the interactive UI, or a `[senpi-codemode]` line on stderr without one. A top-level key this version does not know is ignored with one warning naming it, and the rest of the file still applies, so a settings file written for a newer senpi keeps working. Malformed JSON, or an invalid value or an unknown key inside a known setting, falls back to all defaults with a warning.
|
|
184
346
|
The detached-cell environment override uses the run-budget parser: a positive
|
|
185
347
|
base-10 integer wins over the file value; zero, negative, and malformed values
|
|
186
348
|
leave the file value in effect.
|
|
@@ -195,19 +357,23 @@ options object and asynchronous helpers are `await`-able.
|
|
|
195
357
|
| --- | --- |
|
|
196
358
|
| `display(value)` | Emits text, structured JSON, markdown, or image display data. Images reach the model only through `display`: pass a figure, raw image bytes (PNG/JPEG/GIF/WebP/BMP sniffed), a `data:` URL, a `Blob`-like or `Bun.Image` value, a marshalled tool result, or one of its `images[i]` frames. |
|
|
197
359
|
| `print(value, ...)` | Emits text output. |
|
|
360
|
+
| `text(value)` (rb, jl) | Emits `value` as one text item without separators (`print` joins its arguments and calls it). |
|
|
361
|
+
| `display_image(base64, mime_type)` (rb, jl) | Emits an image from base64 data; `mime_type` defaults to `image/png` (Ruby: `mime_type:` keyword). |
|
|
198
362
|
| `read(path, offset?, limit?)` | Reads text with 1-indexed line slicing. `local://` paths resolve under the session artifact root. |
|
|
199
363
|
| `write(path, content)` | Creates parent directories and writes text. `local://` paths persist in the session artifact root. |
|
|
200
364
|
| `env(key?, value?)` | Reads all kernel environment values, one value, or sets one value. Includes the session's `PI_*` values (see [Session environment](#session-environment)). |
|
|
201
365
|
| `tool.<name>(args)` | Invokes an active Senpi tool through the normal `pi.executeTool` pipeline and returns `{ text, images?, details?, hasError? }` in every kernel; image blocks arrive as `images[i] = { mimeType, dataBase64 }`. |
|
|
202
|
-
| `
|
|
366
|
+
| `packages.install(manager, requirements, {timeout?})` (js, py) | The `%pip install` (py, manager `"pip"`) or `%bun add` / `%npm add` (js, `"bun"` / `"npm"`) installer as a call: same session environment, receipt (`py`: manager, mode, root, revision, requested, resolved, changed; `js`: installer, mode, revision, added, shadowed), cancellation by `stop` and `environment_install_*` codes; `timeout` defaults to 600 seconds and fails with `environment_install_timeout`. Python: `packages.install("pip", [...], timeout=...)`. |
|
|
367
|
+
| `tool_schema(name?)` | Returns a tool's parameter schema without calling it; omit `name` to list tool names. Five virtual entries document codemode itself on demand and are never listed: `eval:wait`, `eval:helpers`, `eval:kernel-tools`, `eval:environments` (the `%pip`, `%bun`/`%npm`, `%environment` and `%load` magics, their results and error codes) and `eval:isolation` (`isolate: true` cells, their limits and error codes). |
|
|
368
|
+
| `require(specifier)`, `createRequire(path)` (js) | CommonJS loading inside a cell, resolved like `import`: builtins (with or without `node:`), relative files and JSON from the cell's directory, bare packages from the session's project and then its managed package environment (`%bun add`/`%npm add`). A missing module raises the runtime's own `MODULE_NOT_FOUND` error. Like Node's `require`, it carries `require.resolve` (the same lookup the call uses, so both name the same copy; builtins resolve to the runtime's own id), `require.resolve.paths` and `require.cache` (the runtime's CommonJS cache). |
|
|
203
369
|
| `tool(fn, metadata?)` (js) | Registers a named function as a kernel tool for in-process children. `metadata.name` registers it under that name instead of the function's; arguments are still passed in the function's parameter order. |
|
|
204
370
|
| `tool.defined()` / `tool.undefine(name)` (js) | List the kernel tools this kernel defines (sorted), and remove one (`true` if it existed). A descriptor taken before `undefine` can no longer be invoked. Both names are reserved: a kernel tool can't be registered as `defined` or `undefine` (`reserved_tool_name`), and a host tool with either name is shadowed in the `tool` namespace, so it can't be called from a JavaScript cell. |
|
|
205
371
|
| `@tool` / `@tool(name=, description=, schema=)` (py) | Registers a Python function as a kernel tool for in-process children; the schema is inferred from its type hints (`tool_schema("eval:kernel-tools")` lists the rules). Callbacks run while the kernel is idle or its cell is parked in a host call, never in the middle of a running computation. `tool.defined()` and `tool.undefine(name)` work as in JavaScript. Ruby and Julia kernels answer `tools_unavailable`. |
|
|
206
372
|
| `completion(prompt, model?, system?, schema?)` | Requests a one-shot host completion; `schema` asks the host to parse structured output. |
|
|
207
373
|
| `agent(prompt, ...)` | Delegates to the configured active `taskTools.task` tool. Supports background handles and structured JSON results. |
|
|
208
374
|
| `wait(handles, timeout?, mode?)` | Blocks the cell until the given handles settle (agent handle records, `handle()` views, completion handles, closed workpools, or saved `{kind, id, run_epoch}` references). `mode` is `all` (values in input order; the first failed, cancelled, or lost handle raises), `any` (`{index, ref, value}` of the first success), or `settled` (one outcome per input slot). `timeout` is wall-clock seconds from entry; on expiry `eval_wait_timeout` is raised and nothing is cancelled. Rides the bridge-call path, so the run budget pauses while parked. Agent and workpool handles need the host's `EvalHandleHost` capability (`eval_wait_unavailable` without it); completion handles always work. Julia extends `Base.wait` for handle views (`wait(handle(node))`). Details: `tool_schema("eval:wait")`. |
|
|
209
|
-
| `handle(node \| ref \| {pool_id})` | Returns a rich view: the legacy record's fields plus a non-enumerable `control` (Python: attribute on a `dict` subclass; Ruby: singleton method) with
|
|
210
|
-
| `workpool(agent, name, mode?)` | Creates a thin adapter over the normal host `workpool` tool; exposes `pool_id`, `push(items)`, `close()`, `inspect()`, and `cancel()`. JS awaits creation and operations. |
|
|
375
|
+
| `handle(node \| ref \| {pool_id})` | Returns a rich view: the legacy record's fields plus a non-enumerable `control` (Python: attribute on a `dict` subclass; Ruby: singleton method) with `.status()`, `.output(format?, offset?, limit?)`, `.send(message)` (agent handles only), `.cancel()` (idempotent for that run epoch; never touches a successor run), and `.wait(timeout?)`. Every control call is fenced by owner, id, and `run_epoch` inside the task owner (`eval_handle_stale`, `eval_handle_forbidden`). `completion(prompt, handle: true)` returns such a view for a host completion. The `agent(..., handle: true)` record itself is unchanged. Details: `tool_schema("eval:helpers")`. |
|
|
376
|
+
| `workpool(agent, name, mode?, tools?)` | Creates a thin adapter over the normal host `workpool` tool; exposes `pool_id`, `push(items)`, `close()`, `inspect()`, and `cancel()`. JS awaits creation and operations. `tools` is a list of kernel-tool names this cell defined; the pool's workers may call exactly those, the host refuses any name the caller doesn't hold, and a value that isn't a list of names raises `invalid_tools`. Ruby and Julia define no kernel tools, so they have nothing to grant. |
|
|
211
377
|
| `output(ids, format?, offset?, limit?)` | Delegates transcript retrieval to the configured active `taskTools.output` tool. |
|
|
212
378
|
| `parallel(thunks)` | Runs thunks through the configured bounded pool while preserving input order. |
|
|
213
379
|
| `pipeline(items, ...stages)` | Applies stages left to right with a barrier between stages. |
|
|
@@ -256,8 +422,11 @@ Any isolation metadata supplied by the host on a handle is preserved as
|
|
|
256
422
|
`{subagent_type, prompt, model?}` as its plain-data agent spec. Mode is `fresh`
|
|
257
423
|
or `keep_alive`: pass `{mode: "fresh"}` in JS, `mode="fresh"` in Python/Julia,
|
|
258
424
|
or `mode: "fresh"` in Ruby. Omission is forwarded unchanged to the engine;
|
|
259
|
-
hosts without an approved default still require an explicit mode.
|
|
260
|
-
names
|
|
425
|
+
hosts without an approved default still require an explicit mode. `tools`
|
|
426
|
+
(kernel-tool names, for example from Python `@tool` or JavaScript `tool(fn)`) is
|
|
427
|
+
forwarded unchanged to the host's `create`, which validates it: `{tools: ["add"]}`
|
|
428
|
+
in JS, `tools=["add"]` in Python/Julia, `tools: ["add"]` in Ruby. There is no
|
|
429
|
+
`pool.wait()`; the host delivers the aggregate.
|
|
261
430
|
|
|
262
431
|
`push` forwards `[{key, input}]` and returns the host receipt without waiting
|
|
263
432
|
for admission. Operations return the same `{text, details, images?, hasError?}`
|
|
@@ -298,6 +467,10 @@ free; otherwise it settles `cancelled` with `eval_background_capacity_reached`,
|
|
|
298
467
|
listing the live cells and a stop-or-wait remedy. Cells that complete inside the
|
|
299
468
|
window return normally. Cancelling a queued cell never interrupts its predecessor.
|
|
300
469
|
Do not re-run a detached or queued cell; each detached cell completes as one notification.
|
|
470
|
+
The notification carries the same text the cell's result would have shown in the
|
|
471
|
+
foreground (the output sink's configured head, its tail, the middle-elision marker and
|
|
472
|
+
the full-output artifact notice), framed by the outcome line and the kernel-state note,
|
|
473
|
+
plus any images the cell displayed.
|
|
301
474
|
|
|
302
475
|
Queued steering also detaches an eligible interactive foreground call, including
|
|
303
476
|
one paused in a host tool bridge, without cancelling its computation. If the
|
|
@@ -338,11 +511,29 @@ Use `eval({ action: "peek", cell_id })` for its state and buffered output, or
|
|
|
338
511
|
`eval({ action: "stop", cell_id })` to cancel it. Stopping a queued cell removes it
|
|
339
512
|
without interrupting the active cell; kernel state is retained. Python running-cell stop interrupts the
|
|
340
513
|
existing kernel and preserves variables. JavaScript stop is cooperative first:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
514
|
+
Stop ends the cell and everything it started, not the kernel's variables. The
|
|
515
|
+
worker rejects the cell's pending bridge `tool.*` calls and releases the cell:
|
|
516
|
+
its timers are cleared (the globals and the `node:timers` module alike), its
|
|
517
|
+
pending `Bun.sleep`, `node:timers/promises` waits, `fetch` requests and file
|
|
518
|
+
reads reject with the interruption, and the sockets, servers, file streams,
|
|
519
|
+
`readline` interfaces, WebSockets, WebViews, nested workers and child processes
|
|
520
|
+
it opened are closed or terminated, whether made with a factory or a
|
|
521
|
+
constructor. A resource that will not close is reported on the cell output. The stop result arrives once those children are gone, and the
|
|
522
|
+
worker and every global from earlier cells survive. If the stopped cell's own
|
|
523
|
+
`catch`/`finally` still runs, it cannot print, call tools, start processes,
|
|
524
|
+
schedule timers or open connections. One boundary remains: code that resumes
|
|
525
|
+
because a later cell resolves a promise the stopped cell was awaiting runs
|
|
526
|
+
until it reaches an operation a stopped cell may no longer start (output, tool
|
|
527
|
+
calls, processes, timers, network, files, message channels, workers).
|
|
528
|
+
|
|
529
|
+
An unhandled promise rejection never crashes the JavaScript kernel; its
|
|
530
|
+
variables are kept, as in the Node REPL and Jupyter. The rejection is reported
|
|
531
|
+
on the cell that is running, or on the next cell, naming the cell that started
|
|
532
|
+
the work when it is known ("from cell <id>, after it was stopped"), with the
|
|
533
|
+
error message and the top of its stack. A burst becomes one report plus
|
|
534
|
+
"... and K more unhandled promise rejections". A fatal error (an uncaught
|
|
535
|
+
exception) still restarts the worker, and the result says variables are lost. Only a cell stopped during a `Bun.$` command costs
|
|
536
|
+
the worker VM. A worker blocked in a synchronous call (`Bun.spawnSync`,
|
|
346
537
|
`child_process.spawnSync`) cannot be stopped at all; after a 3 s termination
|
|
347
538
|
deadline a fresh worker replaces it, the cell output gains a stderr line naming
|
|
348
539
|
the blocked synchronous call, and the blocked call keeps running until it
|
|
@@ -395,6 +586,13 @@ original sizes, then a plain-path notice such as
|
|
|
395
586
|
package.
|
|
396
587
|
- Task transcript formats are limited to full (`raw`) and trailing (`tail`)
|
|
397
588
|
output. Query, JSON, and stripped metadata formats are task-engine concerns.
|
|
589
|
+
- There is no `pool.wait()`: a workpool's aggregate is delivered by the host after
|
|
590
|
+
`close()`, so a kernel never blocks on another engine's workers.
|
|
591
|
+
- There is no `code_mode_only` mode and no speculative cell execution; both are
|
|
592
|
+
deferred to a separate design (omo#9232) rather than approximated here.
|
|
593
|
+
- Kernels are never shared across owners: each session (and each in-process child
|
|
594
|
+
with its own eval tool) owns its kernels, and handles are fenced by owner, id and
|
|
595
|
+
run epoch.
|
|
398
596
|
|
|
399
597
|
## Security and lifecycle
|
|
400
598
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10-10",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"types": "./src/index.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./src/index.ts",
|
|
10
|
-
"./package.json": "./package.json"
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
"./executable-settings.json": "./src/config/executable-settings.json"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"src",
|
|
@@ -32,15 +33,15 @@
|
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@babel/parser": "8.0.4",
|
|
35
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.
|
|
36
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.10-10",
|
|
36
37
|
"quickjs-wasi": "3.6.2",
|
|
37
38
|
"typebox": "1.3.34"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@code-yeongyu/senpi": "2026.10.
|
|
41
|
+
"@code-yeongyu/senpi": "2026.10.10-10"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@code-yeongyu/senpi": "2026.10.
|
|
44
|
+
"@code-yeongyu/senpi": "2026.10.10-10"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
46
47
|
"senpi",
|
|
@@ -8,6 +8,8 @@ const LOOPBACK_HOST = "127.0.0.1";
|
|
|
8
8
|
|
|
9
9
|
export interface BridgeHttpCallRequest {
|
|
10
10
|
callId: string;
|
|
11
|
+
/** The calling run's secret; the host resolves that run's kernel-tools capability from it. */
|
|
12
|
+
cellToken?: string;
|
|
11
13
|
toolName: string;
|
|
12
14
|
args: unknown;
|
|
13
15
|
signal: AbortSignal;
|
|
@@ -132,7 +134,13 @@ async function dispatchCall(body: unknown, options: BridgeServerOptions, signal:
|
|
|
132
134
|
try {
|
|
133
135
|
return {
|
|
134
136
|
ok: true,
|
|
135
|
-
value: await options.onCall({
|
|
137
|
+
value: await options.onCall({
|
|
138
|
+
callId: body.callId,
|
|
139
|
+
...(typeof body.cellToken === "string" ? { cellToken: body.cellToken } : {}),
|
|
140
|
+
toolName: body.toolName,
|
|
141
|
+
args: body.args,
|
|
142
|
+
signal,
|
|
143
|
+
}),
|
|
136
144
|
};
|
|
137
145
|
} catch (error) {
|
|
138
146
|
return { ok: false, error: bridgeError(error) };
|
package/src/bridge/protocol.ts
CHANGED
|
@@ -44,6 +44,10 @@ const hostToKernelMessageSchema = Type.Union([
|
|
|
44
44
|
cellId: Type.String({ minLength: 1 }),
|
|
45
45
|
code: Type.String(),
|
|
46
46
|
timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
47
|
+
/** Python only: the published environment revision to import from, applied before the cell runs; empty removes the previous one. */
|
|
48
|
+
envRoot: Type.Optional(Type.String()),
|
|
49
|
+
/** The file a `%load` cell runs; the runner compiles under its name and imports beside it. */
|
|
50
|
+
sourceFile: Type.Optional(Type.String({ minLength: 1 })),
|
|
47
51
|
/** Python only: active tool globals to install before the cell and deactivated ones to remove. */
|
|
48
52
|
preludes: Type.Optional(
|
|
49
53
|
Type.Object({
|
|
@@ -233,10 +237,15 @@ export function parseBridgeJsonLine(line: string, options: BridgeFrameOptions =
|
|
|
233
237
|
export function decodeBridgeFrame(line: string, options: BridgeFrameOptions = {}): BridgeMessageDecodeResult {
|
|
234
238
|
const parsed = parseBridgeJsonLine(line, options);
|
|
235
239
|
if (!parsed.ok) return parsed;
|
|
236
|
-
|
|
237
|
-
|
|
240
|
+
return validateBridgeMessage(parsed.value);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Checks an already-parsed frame against the bridge schema (for transports that transform values before checking). */
|
|
244
|
+
export function validateBridgeMessage(value: unknown): BridgeMessageDecodeResult {
|
|
245
|
+
if (Value.Check(bridgeMessageSchema, value)) {
|
|
246
|
+
return { ok: true, message: value };
|
|
238
247
|
}
|
|
239
|
-
const firstError = Value.Errors(bridgeMessageSchema,
|
|
248
|
+
const firstError = Value.Errors(bridgeMessageSchema, value)[0];
|
|
240
249
|
const message = firstError ? `Invalid bridge message: ${firstError.message}` : "Invalid bridge message";
|
|
241
250
|
return { ok: false, error: { code: "invalid_message", message } };
|
|
242
251
|
}
|
package/src/bridge/reserved.ts
CHANGED
|
@@ -15,6 +15,8 @@ export const RESERVED_HANDLE_OUTPUT_TOOL = "__handle_output__" as const;
|
|
|
15
15
|
export const RESERVED_HANDLE_SEND_TOOL = "__handle_send__" as const;
|
|
16
16
|
/** `handle(node).control.cancel()`: idempotent for its epoch; a successor run is never touched. */
|
|
17
17
|
export const RESERVED_HANDLE_CANCEL_TOOL = "__handle_cancel__" as const;
|
|
18
|
+
/** In-cell `packages.install(manager, requirements, {timeout?})`: the `%pip` / `%bun` / `%npm` installer as a call. */
|
|
19
|
+
export const RESERVED_PACKAGES_INSTALL_TOOL = "__packages_install__" as const;
|
|
18
20
|
/** Canonical oh-my-pi eval-timeout pause operation. */
|
|
19
21
|
export const TIMEOUT_PAUSE_OP = "timeout-pause" as const;
|
|
20
22
|
/** Canonical oh-my-pi eval-timeout resume operation. */
|