@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/src/tool/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
DEFAULT_RUN_BUDGET_SECONDS,
|
|
9
9
|
defaultCodemodeSettings,
|
|
10
10
|
} from "../config/settings.ts";
|
|
11
|
+
import type { KernelToolsCapability } from "../kernels/js/kernel-tools-types.ts";
|
|
11
12
|
import type { TruncationMeta } from "../output/output-meta.ts";
|
|
12
13
|
|
|
13
14
|
export const evalLanguageOrder = ["js", "py", "rb", "jl"] as const;
|
|
@@ -51,6 +52,8 @@ export interface EvalToolInput {
|
|
|
51
52
|
readonly timeout?: number;
|
|
52
53
|
readonly on_timeout?: "detach" | "error";
|
|
53
54
|
readonly reset?: boolean;
|
|
55
|
+
/** Run in a fresh sandbox VM instead of the persistent kernel; accepted only while `sandbox.enabled` is on. */
|
|
56
|
+
readonly isolate?: boolean;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export interface EvalListInput {
|
|
@@ -116,14 +119,26 @@ const fullEvalInputSchema = Type.Object(
|
|
|
116
119
|
/** Runtime accepts a discriminated run/control union. */
|
|
117
120
|
export type EvalInputSchema = TUnsafe<EvalToolRequest> & Pick<typeof fullEvalInputSchema, "properties">;
|
|
118
121
|
|
|
122
|
+
const ISOLATE_FIELD_DESCRIPTION =
|
|
123
|
+
"js only. Fresh sandbox per call: no persistence, no fs/net/process/timers; only tool.* plus print/display.";
|
|
124
|
+
|
|
119
125
|
export function createEvalInputSchema(
|
|
120
126
|
enabled: EnabledEvalLanguages,
|
|
121
127
|
deadlines: EvalDeadlineSeconds = defaultEvalDeadlineSeconds,
|
|
128
|
+
options: { readonly sandbox?: boolean } = {},
|
|
122
129
|
): EvalInputSchema {
|
|
123
130
|
const languages = enabledLanguageList(enabled);
|
|
124
131
|
if (languages.length === 0) throw new Error("eval requires at least one enabled language");
|
|
125
132
|
const languageSchema = evalLanguageUnion(languages);
|
|
126
|
-
|
|
133
|
+
// The sandbox field exists in the schema only while sandbox cells are turned on, so the default schema
|
|
134
|
+
// (and the prompt built from it) stays exactly what it was.
|
|
135
|
+
const properties =
|
|
136
|
+
options.sandbox === true && languages.includes("js")
|
|
137
|
+
? {
|
|
138
|
+
...evalInputProperties(languageSchema, deadlines),
|
|
139
|
+
isolate: Type.Optional(Type.Boolean({ description: ISOLATE_FIELD_DESCRIPTION })),
|
|
140
|
+
}
|
|
141
|
+
: evalInputProperties(languageSchema, deadlines);
|
|
127
142
|
return Type.Unsafe<EvalToolRequest>(
|
|
128
143
|
Type.Object(properties, {
|
|
129
144
|
// Keep branches self-contained for Mistral-hosted GLM (#2240).
|
|
@@ -167,8 +182,35 @@ export interface EvalKernelRunInput {
|
|
|
167
182
|
readonly onMessage?: (message: KernelToHostMessage) => void;
|
|
168
183
|
/** Globals of the tools active when the cell was submitted; kernels without preludes ignore them. */
|
|
169
184
|
readonly kernelPreludes?: readonly KernelPreludeContribution[];
|
|
185
|
+
/**
|
|
186
|
+
* Python only: read when the cell starts running (not when it was queued), so a cell queued behind `%pip`
|
|
187
|
+
* sees the revision it published. `""` means no environment: the previous revision leaves the import path.
|
|
188
|
+
*/
|
|
189
|
+
readonly envRoot?: () => string;
|
|
190
|
+
/** The file a `%load` cell runs: tracebacks name it and its relative imports resolve from its directory. */
|
|
191
|
+
readonly sourceFile?: string;
|
|
192
|
+
/**
|
|
193
|
+
* JavaScript only: the session's managed package revision; bare imports that do not resolve from cwd fall back to
|
|
194
|
+
* it. Read when the cell starts running (not when it was queued), so a cell queued behind `%bun add` resolves the
|
|
195
|
+
* revision that install published.
|
|
196
|
+
*/
|
|
197
|
+
readonly packageRoot?: () => string | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Called when the cell's turn comes in the kernel's queue, never earlier: what to run instead of `code` (a `%load`
|
|
200
|
+
* cell's file), or a refusal that settles the cell as failed in queue order.
|
|
201
|
+
*/
|
|
202
|
+
readonly resolveAtStart?: () => CellSourceAtStart;
|
|
203
|
+
/**
|
|
204
|
+
* Subprocess kernels attach this to the cell's host calls, and the host gives those calls the cell's kernel tools.
|
|
205
|
+
* A fresh secret per run, sent only to the kernel that runs the cell; never a model-visible id.
|
|
206
|
+
*/
|
|
207
|
+
readonly bridgeCellToken?: string;
|
|
170
208
|
}
|
|
171
209
|
|
|
210
|
+
export type CellSourceAtStart =
|
|
211
|
+
| { readonly ok: true; readonly code: string; readonly sourceFile?: string }
|
|
212
|
+
| { readonly ok: false; readonly message: string };
|
|
213
|
+
|
|
172
214
|
export interface KernelInterruptHandle {
|
|
173
215
|
/** Resolves once the kernel knows whether user state survived the interrupt. */
|
|
174
216
|
readonly stateRetained: Promise<boolean>;
|
|
@@ -205,6 +247,11 @@ export interface EvalKernelManager {
|
|
|
205
247
|
* Identity-checked, so releasing a superseded listener never unbinds a newer cell's listener.
|
|
206
248
|
*/
|
|
207
249
|
releaseKernelListener?(language: EvalLanguage, onMessage: (message: KernelToHostMessage) => void): void;
|
|
250
|
+
/**
|
|
251
|
+
* Binds a running cell's kernel-tools capability to the host calls that carry `token` (subprocess kernels reach
|
|
252
|
+
* the host over the bridge, outside the cell's async context). The returned release runs when the cell settles.
|
|
253
|
+
*/
|
|
254
|
+
bindCellKernelTools?(token: string, capability: KernelToolsCapability): () => void;
|
|
208
255
|
}
|
|
209
256
|
|
|
210
257
|
export type ExecuteTool = (
|
|
@@ -232,6 +279,8 @@ export interface EvalRuntimeInfo {
|
|
|
232
279
|
readonly name: string;
|
|
233
280
|
readonly version: string;
|
|
234
281
|
readonly path?: string;
|
|
282
|
+
/** JS only: the kernel runs in a child process (`process`), or the cell ran in an isolated QuickJS VM (`sandbox`). */
|
|
283
|
+
readonly isolation?: "process" | "sandbox";
|
|
235
284
|
}
|
|
236
285
|
|
|
237
286
|
export type EvalRuntimes = Readonly<Partial<Record<EvalLanguage, EvalRuntimeInfo>>>;
|