@code-yeongyu/senpi-codemode 2026.10.10 → 2026.10.12
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 +214 -0
- package/README.md +113 -11
- package/package.json +7 -6
- package/src/bridge/memory-protocol.ts +8 -1
- package/src/bridge/protocol.ts +9 -4
- package/src/bridge/reserved.ts +2 -0
- package/src/bridges/eval-environment-schemas.ts +52 -0
- package/src/bridges/eval-virtual-schemas.ts +11 -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/editable-check.ts +1 -1
- package/src/environments/packages-install.ts +98 -0
- package/src/environments/py-environment.ts +7 -3
- package/src/environments/py-installer.ts +80 -44
- package/src/environments/python-environments.ts +1 -1
- package/src/extension/bridge-tool-call.ts +5 -1
- package/src/extension/eval-cells-rpc.ts +62 -0
- package/src/extension/eval-notifier.ts +13 -2
- package/src/extension/kernel-registration.ts +7 -2
- package/src/extension/runtime-factory.ts +42 -13
- package/src/extension/runtime-info.ts +6 -2
- package/src/extension/session-cwd.ts +25 -9
- package/src/extension/session-manager-contract.ts +3 -0
- package/src/extension/session-manager.ts +20 -6
- package/src/index.ts +8 -3
- package/src/interpreters/detect.ts +34 -1
- package/src/kernels/AGENTS.md +2 -0
- package/src/kernels/jl/globals.jl +128 -0
- package/src/kernels/jl/prelude.jl +15 -2
- package/src/kernels/jl/runner.jl +35 -143
- 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 +23 -24
- package/src/kernels/js/control-frames.ts +24 -0
- package/src/kernels/js/group-signal-notice.js +117 -0
- package/src/kernels/js/inline-worker.ts +2 -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 +8 -0
- 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-tree-host.ts +4 -8
- package/src/kernels/js/process-tree.d.ts +11 -0
- package/src/kernels/js/process-tree.js +55 -10
- 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/windows-tree-kill-host.ts +117 -0
- package/src/kernels/js/windows-tree-kill.d.ts +19 -0
- package/src/kernels/js/windows-tree-kill.js +100 -0
- package/src/kernels/js/worker-core.js +51 -8
- package/src/kernels/js/worker-cwd.js +46 -12
- package/src/kernels/js/worker-host.ts +9 -2
- package/src/kernels/js/worker-indirect-eval.js +37 -13
- 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 +66 -13
- package/src/kernels/js/worker-shadow-guard.js +2 -6
- package/src/kernels/js/worker-shell-capture.js +9 -0
- package/src/kernels/js/worker-slot.ts +8 -0
- package/src/kernels/js/worker-startup.ts +49 -1
- package/src/kernels/js/worker-webview.js +15 -1
- package/src/kernels/py/prelude.py +69 -27
- package/src/kernels/py/process.ts +4 -0
- package/src/kernels/py/transport.ts +4 -0
- package/src/kernels/rb/runner.rb +9 -19
- package/src/kernels/sandbox/sandbox-cell.ts +26 -1
- package/src/kernels/sandbox/vendor/pi-codemode/runtime/host.ts +2 -2
- package/src/kernels/shared/bun-ffi.ts +24 -0
- package/src/kernels/shared/kernel-memory-host.ts +30 -7
- package/src/kernels/shared/process-cpu.ts +7 -3
- package/src/kernels/shared/process-group-cpu.ts +6 -3
- package/src/kernels/shared/subprocess-kernel.ts +29 -3
- package/src/kernels/shared/subprocess-memory-globals.ts +101 -0
- package/src/kernels/shared/subprocess-process.ts +24 -2
- package/src/kernels/shared/subprocess-queue.ts +1 -0
- package/src/prompt/eval-prompt.ts +8 -1
- package/src/tool/AGENTS.md +1 -0
- package/src/tool/cell-handler.ts +3 -0
- 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 +20 -11
- 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 +21 -10
- package/src/tool/detached-notification-queue.ts +1 -2
- package/src/tool/eval-tool.ts +4 -2
- package/src/tool/interrupt-note.ts +4 -5
- package/src/tool/live-headline.ts +60 -0
- package/src/tool/managed-cell.ts +0 -4
- package/src/tool/render-agent.ts +110 -0
- package/src/tool/render-blocks.ts +252 -0
- package/src/tool/render-call.ts +130 -0
- package/src/tool/render-cell.ts +165 -0
- package/src/tool/render-detail.ts +152 -0
- package/src/tool/render-live.ts +288 -0
- package/src/tool/render-result.ts +202 -0
- package/src/tool/render-status.ts +166 -0
- package/src/tool/render-tail.ts +139 -0
- package/src/tool/render.ts +3 -1069
- package/src/tool/run-eval-cell.ts +24 -14
- package/src/tool/runtime-label.ts +2 -1
- package/src/tool/types.ts +13 -2
|
@@ -9,12 +9,10 @@ import {
|
|
|
9
9
|
import type { KernelToHostMessage } from "../bridge/protocol.ts";
|
|
10
10
|
import { resolveSandbox } from "../config/feature-settings.ts";
|
|
11
11
|
import { DEFAULT_FOREGROUND_WINDOW_SECONDS, defaultCodemodeSettings } from "../config/settings.ts";
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "../kernels/js/kernel-tools-types.ts";
|
|
17
|
-
import { sandboxCellExecutor } from "../kernels/sandbox/sandbox-cell.ts";
|
|
12
|
+
import type { JsEnvironments } from "../environments/js-environments.ts";
|
|
13
|
+
import type { PackagesInstallEnvironments } from "../environments/packages-install.ts";
|
|
14
|
+
import { KERNEL_TOOLS_CAPABILITIES, type KernelToolsCapability } from "../kernels/js/kernel-tools-types.ts";
|
|
15
|
+
import { sandboxCellExecutor, sandboxRuntimeInfo } from "../kernels/sandbox/sandbox-cell.ts";
|
|
18
16
|
import { TIMEOUT_PAUSE_OP, TIMEOUT_RESUME_OP } from "../timeouts/bridge-timeout.ts";
|
|
19
17
|
import { abortError, CellExecution, defaultTimeoutFactory } from "./cell-execution.ts";
|
|
20
18
|
import { CellHandler, type CellState } from "./cell-handler.ts";
|
|
@@ -44,7 +42,8 @@ export async function runEvalCell(
|
|
|
44
42
|
const bridgeAbortController = new AbortController();
|
|
45
43
|
const cellSignal = AbortSignal.any([invocation.signal, bridgeAbortController.signal]);
|
|
46
44
|
const bridgeContext: ExtensionContext = { ...invocation.ctx, signal: cellSignal };
|
|
47
|
-
const runtime =
|
|
45
|
+
const runtime =
|
|
46
|
+
invocation.input.isolate === true ? sandboxRuntimeInfo() : options.runtimes?.[invocation.input.language];
|
|
48
47
|
const state: CellState = {
|
|
49
48
|
input: invocation.input,
|
|
50
49
|
...(runtime === undefined ? {} : { runtime }),
|
|
@@ -240,6 +239,7 @@ async function executeCell(
|
|
|
240
239
|
...(kernelTools === undefined ? {} : { kernelTools }),
|
|
241
240
|
...(options.handles === undefined ? {} : { handles: options.handles }),
|
|
242
241
|
hardDeadlineMs: cell.startedAtMs + cell.hardLimitSeconds * 1_000,
|
|
242
|
+
...cellEnvironments(invocation.input.language, options),
|
|
243
243
|
});
|
|
244
244
|
handler = activeHandler;
|
|
245
245
|
cellManager.bindKernel(
|
|
@@ -352,14 +352,24 @@ async function executeCell(
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
function kernelToolsFor(kernel: EvalKernel): KernelToolsCapability | undefined {
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
};
|
|
355
|
+
if (typeof kernel.describeKernelTools !== "function" || typeof kernel.invokeKernelTool !== "function")
|
|
356
|
+
return undefined;
|
|
357
|
+
const describeKernelTools = kernel.describeKernelTools.bind(kernel);
|
|
358
|
+
const invokeKernelTool = kernel.invokeKernelTool.bind(kernel);
|
|
360
359
|
return {
|
|
361
360
|
capabilities: KERNEL_TOOLS_CAPABILITIES,
|
|
362
|
-
describe:
|
|
363
|
-
invoke:
|
|
361
|
+
describe: describeKernelTools,
|
|
362
|
+
invoke: invokeKernelTool,
|
|
364
363
|
} satisfies ExtensionKernelTools;
|
|
365
364
|
}
|
|
365
|
+
|
|
366
|
+
// Only JS cells call tools in-process; a Python cell reaches packages.install() over the bridge, whose session manager
|
|
367
|
+
// holds the same Python environment its magics use.
|
|
368
|
+
function cellEnvironments(
|
|
369
|
+
language: string,
|
|
370
|
+
options: { readonly jsEnvironments?: JsEnvironments },
|
|
371
|
+
): { readonly environments?: PackagesInstallEnvironments } {
|
|
372
|
+
if (language === "js" && options.jsEnvironments !== undefined)
|
|
373
|
+
return { environments: { js: options.jsEnvironments } };
|
|
374
|
+
return {};
|
|
375
|
+
}
|
|
@@ -10,7 +10,8 @@ const ELLIPSIS = "\u2026";
|
|
|
10
10
|
* runtime name because node and bun are otherwise indistinguishable.
|
|
11
11
|
*/
|
|
12
12
|
export function formatRuntimeBadge(language: EvalLanguage, runtime: EvalRuntimeInfo, home: string = homedir()): string {
|
|
13
|
-
const
|
|
13
|
+
const base = language === "js" ? `${runtime.name} ${runtime.version}` : runtime.version;
|
|
14
|
+
const label = runtime.isolation === undefined ? base : `${base}, ${runtime.isolation}`;
|
|
14
15
|
if (runtime.path === undefined || runtime.path.length === 0) return label;
|
|
15
16
|
return `${label}, ${minifyPath(runtime.path, home)}`;
|
|
16
17
|
}
|
package/src/tool/types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AgentToolResult,
|
|
3
|
+
AgentToolUpdateCallback,
|
|
4
|
+
ExtensionKernelTools,
|
|
5
|
+
KernelPreludeContribution,
|
|
6
|
+
} from "@code-yeongyu/senpi";
|
|
2
7
|
import { type TSchema, type TUnsafe, Type } from "typebox";
|
|
3
8
|
import type { KernelMemoryReport } from "../bridge/memory-protocol.ts";
|
|
4
9
|
import type { HostToKernelMessage, KernelToHostMessage } from "../bridge/protocol.ts";
|
|
@@ -8,7 +13,7 @@ import {
|
|
|
8
13
|
DEFAULT_RUN_BUDGET_SECONDS,
|
|
9
14
|
defaultCodemodeSettings,
|
|
10
15
|
} from "../config/settings.ts";
|
|
11
|
-
import type { KernelToolsCapability } from "../kernels/js/kernel-tools-types.ts";
|
|
16
|
+
import type { KernelToolsCapability, KernelToolsDescribeResult } from "../kernels/js/kernel-tools-types.ts";
|
|
12
17
|
import type { TruncationMeta } from "../output/output-meta.ts";
|
|
13
18
|
|
|
14
19
|
export const evalLanguageOrder = ["js", "py", "rb", "jl"] as const;
|
|
@@ -238,6 +243,10 @@ export interface EvalKernel {
|
|
|
238
243
|
isAlive?(): boolean;
|
|
239
244
|
/** Hands over, and forgets, every queued cell of a dead kernel that never started. */
|
|
240
245
|
drainPending?(): readonly PendingCell[];
|
|
246
|
+
/** Describes this kernel's registered kernel tools; only an in-process JS kernel has them. */
|
|
247
|
+
describeKernelTools?(names: readonly string[]): Promise<KernelToolsDescribeResult>;
|
|
248
|
+
/** Invokes one of this kernel's kernel tools; present exactly when `describeKernelTools` is. */
|
|
249
|
+
invokeKernelTool?: ExtensionKernelTools["invoke"];
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
export interface EvalKernelManager {
|
|
@@ -279,6 +288,8 @@ export interface EvalRuntimeInfo {
|
|
|
279
288
|
readonly name: string;
|
|
280
289
|
readonly version: string;
|
|
281
290
|
readonly path?: string;
|
|
291
|
+
/** JS only: the kernel runs in a child process (`process`), or the cell ran in an isolated QuickJS VM (`sandbox`). */
|
|
292
|
+
readonly isolation?: "process" | "sandbox";
|
|
282
293
|
}
|
|
283
294
|
|
|
284
295
|
export type EvalRuntimes = Readonly<Partial<Record<EvalLanguage, EvalRuntimeInfo>>>;
|