@code-yeongyu/senpi-codemode 2026.11.29-2 → 2026.11.29-3
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 +12 -0
- package/package.json +5 -5
- package/src/bridge/kernel-tools-protocol.ts +1 -1
- package/src/bridges/agent-bridge.ts +1 -1
- package/src/bridges/handle-bridge.ts +1 -1
- package/src/config/feature-settings.ts +2 -2
- package/src/environments/js-installer.ts +2 -2
- package/src/environments/packages-install.ts +1 -1
- package/src/extension/eval-status.ts +2 -2
- package/src/extension/kernel-registration.ts +1 -1
- package/src/extension/removed-tool-hints.ts +1 -1
- package/src/extension/skill-contribution.ts +1 -3
- package/src/handles/handle-args.ts +2 -2
- package/src/handles/wait.ts +2 -2
- package/src/kernels/AGENTS.md +1 -1
- package/src/kernels/js/interrupt-bounds.ts +3 -3
- package/src/kernels/js/kernel-tools-errors.ts +1 -1
- package/src/kernels/js/process-tree-host.ts +5 -5
- package/src/kernels/js/process-worker.ts +1 -1
- package/src/kernels/js/worker-host.ts +1 -5
- package/src/kernels/js/worker-startup.ts +1 -1
- package/src/kernels/py/startup.ts +1 -1
- package/src/kernels/shared/bun-ffi.ts +1 -1
- package/src/kernels/shared/kernel-death.ts +1 -1
- package/src/kernels/shared/subprocess-startup.ts +1 -1
- package/src/output/streaming-output.ts +2 -4
- package/src/prompt/eval-prompt.ts +1 -1
- package/src/timeouts/run-budget.ts +1 -1
- package/src/tool/call-capture.ts +2 -2
- package/src/tool/cell-deadlines.ts +1 -1
- package/src/tool/detached-cell-snapshot.ts +1 -1
- package/src/tool/image-resize.ts +1 -1
- package/src/tool/image.ts +1 -7
- package/src/tool/render-cell.ts +0 -2
- package/src/tool/render-live.ts +1 -2
- package/src/tool/terminal-snapshot-store.ts +2 -2
- package/src/kernels/js/prelude.ts +0 -17
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.11.29-
|
|
3
|
+
"version": "2026.11.29-3",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "8.0.4",
|
|
36
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.29-
|
|
37
|
-
"@earendil-works/pi-realm-registry": "npm:@code-yeongyu/senpi-realm-registry@2026.11.29-
|
|
36
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.29-3",
|
|
37
|
+
"@earendil-works/pi-realm-registry": "npm:@code-yeongyu/senpi-realm-registry@2026.11.29-3",
|
|
38
38
|
"quickjs-wasi": "3.6.2",
|
|
39
39
|
"typebox": "1.3.34"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@code-yeongyu/senpi": "2026.11.29-
|
|
42
|
+
"@code-yeongyu/senpi": "2026.11.29-3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@code-yeongyu/senpi": "2026.11.29-
|
|
45
|
+
"@code-yeongyu/senpi": "2026.11.29-3"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"senpi",
|
|
@@ -16,7 +16,7 @@ const kernelToolErrorSchema = Type.Object({
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
/** Per-call execution scope for the nested host calls the invoked closure makes (#1731). */
|
|
19
|
-
|
|
19
|
+
const kernelToolInvokeScopeSchema = Type.Object({
|
|
20
20
|
tools: Type.Optional(
|
|
21
21
|
Type.Object({
|
|
22
22
|
allow: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
@@ -73,7 +73,7 @@ export type EvalAgentResult = (
|
|
|
73
73
|
// The session-owned executor identifies a bridge across JS and HTTP calls; do not retain retired sessions.
|
|
74
74
|
const isolationCapabilities = new WeakMap<AgentExecuteTool, Map<string, boolean>>();
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
class AgentIsolationNotAppliedError extends Error {
|
|
77
77
|
readonly name = "AgentIsolationNotAppliedError";
|
|
78
78
|
readonly code = "isolation_not_applied";
|
|
79
79
|
|
|
@@ -10,7 +10,7 @@ import { parseOutputArgs, parseRefArgs, parseSendArgs, parseWaitArgs } from "../
|
|
|
10
10
|
import type { HandleBackend, HandleRegistry } from "../handles/handle-registry.ts";
|
|
11
11
|
import { waitForHandles } from "../handles/wait.ts";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const HANDLE_TOOL_NAMES = [
|
|
14
14
|
RESERVED_WAIT_TOOL,
|
|
15
15
|
RESERVED_HANDLE_STATUS_TOOL,
|
|
16
16
|
RESERVED_HANDLE_OUTPUT_TOOL,
|
|
@@ -4,8 +4,8 @@ import { runtimeNameOf } from "../kernels/js/runtime-name.ts";
|
|
|
4
4
|
|
|
5
5
|
type Environment = Readonly<Record<string, string | undefined>>;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const JS_ISOLATION_ENVIRONMENT_FLAG = "SENPI_CODEMODE_JS_ISOLATION";
|
|
8
|
+
const SANDBOX_MEMORY_ENVIRONMENT_FLAG = "SENPI_CODEMODE_SANDBOX_MEMORY_MB";
|
|
9
9
|
|
|
10
10
|
export const featureSettingsProperties = {
|
|
11
11
|
environments: Type.Optional(
|
|
@@ -68,13 +68,13 @@ export function absoluteSpec(spec: string, cwd: string): string {
|
|
|
68
68
|
return file === undefined ? absolute : `file:${absolute}`;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
function jsInstallArgv(installer: JsInstaller, root: string, packages: readonly string[]): string[] {
|
|
72
72
|
return installer === "bun"
|
|
73
73
|
? ["add", "--ignore-scripts", "--cwd", root, ...packages]
|
|
74
74
|
: ["install", "--ignore-scripts", "--no-audit", "--no-fund", "--prefix", root, ...packages];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
function jsRemoveArgv(installer: JsInstaller, root: string, name: string): string[] {
|
|
78
78
|
return installer === "bun"
|
|
79
79
|
? ["remove", "--ignore-scripts", "--cwd", root, name]
|
|
80
80
|
: ["uninstall", "--ignore-scripts", "--no-audit", "--no-fund", "--prefix", root, name];
|
|
@@ -8,7 +8,7 @@ export interface PackagesInstallEnvironments {
|
|
|
8
8
|
readonly js?: JsEnvironments;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const PACKAGES_INSTALL_DEFAULT_TIMEOUT_SECONDS = 600;
|
|
12
12
|
|
|
13
13
|
interface PackagesInstallRequest {
|
|
14
14
|
readonly manager: "pip" | "bun" | "npm";
|
|
@@ -37,7 +37,7 @@ function labelOf(entry: EvalDetachedCellStatusEntry): string {
|
|
|
37
37
|
* the monitor builtin's formatElapsedSeconds; kept local like the rest of the
|
|
38
38
|
* duplicated status-file helpers between the two packages.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
function formatElapsedSeconds(value: number): string {
|
|
41
41
|
const seconds = Math.max(0, Math.trunc(value));
|
|
42
42
|
if (seconds < 60) return `${seconds}s`;
|
|
43
43
|
const minutes = Math.trunc(seconds / 60);
|
|
@@ -54,7 +54,7 @@ export function formatElapsedSeconds(value: number): string {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/** Whole seconds since the oldest executing detached cell started; queued cells do not tick. */
|
|
57
|
-
|
|
57
|
+
function evalCellElapsedSeconds(entries: readonly EvalDetachedCellStatusEntry[], nowMs: number): number {
|
|
58
58
|
let oldest = Number.POSITIVE_INFINITY;
|
|
59
59
|
for (const entry of entries) {
|
|
60
60
|
if (entry.queuedBehind === undefined) oldest = Math.min(oldest, entry.startedAtMs);
|
|
@@ -34,7 +34,7 @@ export interface SubprocessKernelStart {
|
|
|
34
34
|
readonly peerKernelToolsDescribe?: PeerKernelToolsDescribe;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
function registerKernel(sessionId: string, language: EvalLanguage, memory: RegisteredKernelSource): string {
|
|
38
38
|
const id = crypto.randomUUID();
|
|
39
39
|
kernelRegistry.register({ id, sessionId, language, source: memory });
|
|
40
40
|
return id;
|
|
@@ -3,7 +3,7 @@ export interface RemovedToolHintRegistrar {
|
|
|
3
3
|
registerRemovedToolHint(name: string, hint: string): void;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const WAIT_REMOVED_TOOL_HINT =
|
|
7
7
|
"wait is not a tool; inside a cell use the wait(handles) helper (tool_schema('eval:wait')), or let detached cells notify.";
|
|
8
8
|
|
|
9
9
|
export function registerRemovedToolHints(pi: RemovedToolHintRegistrar): void {
|
|
@@ -7,15 +7,13 @@ const BUN_SKILL_BASE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
|
7
7
|
|
|
8
8
|
let loggedMissingBunSkill = false;
|
|
9
9
|
|
|
10
|
-
export const BUN_SKILL_MIN_VERSION = "1.4.0";
|
|
11
|
-
|
|
12
10
|
/** Reads the js eval kernel's bun version; undefined on a node kernel. */
|
|
13
11
|
export type BunKernelVersionSource = () => string | undefined;
|
|
14
12
|
|
|
15
13
|
const kernelBunVersion: BunKernelVersionSource = () => process.versions.bun;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* True when the version is at least
|
|
16
|
+
* True when the version is at least 1.4: parses the leading
|
|
19
17
|
* `<major>.<minor>` integers of the string and gates on major > 1 || (major === 1 && minor >= 4).
|
|
20
18
|
* Unparseable or missing versions never enable the skill.
|
|
21
19
|
*/
|
|
@@ -12,7 +12,7 @@ const handleRefSchema = Type.Object(
|
|
|
12
12
|
{ additionalProperties: true },
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const WAIT_MODES = ["all", "any", "settled"] as const;
|
|
16
16
|
export type WaitMode = (typeof WAIT_MODES)[number];
|
|
17
17
|
|
|
18
18
|
const waitArgsSchema = Type.Object(
|
|
@@ -44,7 +44,7 @@ export interface WaitRequest {
|
|
|
44
44
|
readonly timeoutSeconds?: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
class HandleArgumentsError extends Error {
|
|
48
48
|
readonly name = "HandleArgumentsError";
|
|
49
49
|
readonly code = "eval_handle_invalid_arguments";
|
|
50
50
|
|
package/src/handles/wait.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface WaitBackend {
|
|
|
19
19
|
export type WaitAnyResult = { readonly index: number; readonly ref: HandleRef; readonly value: unknown };
|
|
20
20
|
|
|
21
21
|
/** A handle's own failure, raised by `wait(..., {mode: "all"})` and `control.wait()`; `code` is in the text. */
|
|
22
|
-
|
|
22
|
+
class HandleOutcomeError extends Error {
|
|
23
23
|
readonly name = "HandleOutcomeError";
|
|
24
24
|
readonly code: string;
|
|
25
25
|
readonly ref: HandleRef;
|
|
@@ -33,7 +33,7 @@ export class HandleOutcomeError extends Error {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
class WaitAllRejectedError extends Error {
|
|
37
37
|
readonly name = "WaitAllRejectedError";
|
|
38
38
|
readonly code = "eval_wait_all_rejected";
|
|
39
39
|
readonly outcomes: readonly HandleOutcome[];
|
package/src/kernels/AGENTS.md
CHANGED
|
@@ -10,7 +10,7 @@ runner/prelude assets).
|
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| JavaScript host API | `js/context-manager.ts` (`JavaScriptKernel`), `js/worker-host.ts` |
|
|
12
12
|
| JS worker runtime, entries | `js/worker-runtime.js`, `js/worker-entry.js`, `js/inline-worker-entry.js`, `js/inline-worker.ts`, `js/worker-core.js` (+ `worker-core.d.ts`) |
|
|
13
|
-
| JS import rewriting, queueing | `js/rewrite-imports.ts`, `js/run-queue.ts`, `js/
|
|
13
|
+
| JS import rewriting, queueing | `js/rewrite-imports.ts`, `js/run-queue.ts`, `js/local-module-loader.ts` |
|
|
14
14
|
| Python kernel | `py/kernel.ts`, `py/transport.ts`, `py/process.ts`, `py/prelude.py` |
|
|
15
15
|
| Ruby kernel | `rb/kernel.ts` + `rb/prelude.rb`, `rb/runner.rb` |
|
|
16
16
|
| Julia kernel | `jl/kernel.ts` + `jl/prelude.jl`, `jl/runner.jl` |
|
|
@@ -3,11 +3,11 @@ import type { WorkerLike } from "./inline-worker.ts";
|
|
|
3
3
|
import { type PendingJavaScriptRun, stoppedResult } from "./run-queue.ts";
|
|
4
4
|
|
|
5
5
|
/** How long the worker gets to acknowledge `interrupt`; silence means its event loop is blocked in synchronous code. */
|
|
6
|
-
|
|
6
|
+
const INTERRUPT_ACK_MS = 500;
|
|
7
7
|
/** How long an acknowledged cell gets to settle before the VM is replaced. */
|
|
8
8
|
export const JS_INTERRUPT_GRACE_MS = 2_000;
|
|
9
9
|
/** How long `worker.terminate()` may take before the worker is abandoned as blocked in a synchronous call. */
|
|
10
|
-
|
|
10
|
+
const WORKER_TERMINATE_DEADLINE_MS = 3_000;
|
|
11
11
|
|
|
12
12
|
export type CooperativeSettlement = "settled" | "unresponsive";
|
|
13
13
|
export type WorkerRetirement = "terminated" | "abandoned";
|
|
@@ -50,7 +50,7 @@ export async function retireWorker(
|
|
|
50
50
|
return outcome;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
function abandonedWorkerNote(deadlineMs = WORKER_TERMINATE_DEADLINE_MS): string {
|
|
54
54
|
return `JavaScript worker did not stop within ${deadlineMs}ms: a synchronous call (for example Bun.spawnSync or child_process.spawnSync) is blocking it. A fresh worker replaced it; the blocked call keeps running until it returns.\n`;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -23,7 +23,7 @@ function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
|
23
23
|
return typeof value === "object" && value !== null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
function isProcessAlive(pid: number): boolean {
|
|
27
27
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
28
28
|
try {
|
|
29
29
|
process.kill(pid, 0);
|
|
@@ -33,7 +33,7 @@ export function isProcessAlive(pid: number): boolean {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
function signalProcess(pid: number, signal: NodeJS.Signals): boolean {
|
|
37
37
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
38
38
|
try {
|
|
39
39
|
process.kill(pid, signal);
|
|
@@ -52,7 +52,7 @@ function ps(args: readonly string[]): Promise<string> {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
async function readProcessTable(): Promise<Map<number, number[]>> {
|
|
56
56
|
const children = new Map<number, number[]>();
|
|
57
57
|
if (process.platform === "win32") return children;
|
|
58
58
|
const stdout = await ps(["-axo", "pid=,ppid="]);
|
|
@@ -68,7 +68,7 @@ export async function readProcessTable(): Promise<Map<number, number[]>> {
|
|
|
68
68
|
return children;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
function collectDescendants(table: ReadonlyMap<number, readonly number[]>, roots: readonly number[]): number[] {
|
|
72
72
|
const seen = new Set<number>(roots);
|
|
73
73
|
const queue = [...roots];
|
|
74
74
|
const descendants: number[] = [];
|
|
@@ -85,7 +85,7 @@ export function collectDescendants(table: ReadonlyMap<number, readonly number[]>
|
|
|
85
85
|
return descendants;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
function ownedRoots(
|
|
89
89
|
table: ReadonlyMap<number, readonly number[]>,
|
|
90
90
|
parentPid: number,
|
|
91
91
|
roots: readonly number[],
|
|
@@ -26,7 +26,7 @@ export function resolveJsProcessEntryUrl(options: JavaScriptProcessEntryUrlOptio
|
|
|
26
26
|
return pathToFileURL(requireCodemodeRuntimeAsset(localPath, join("kernels", "js", "process-entry.js"), options));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
class JavaScriptProcessRuntimeUnavailableError extends Error {
|
|
30
30
|
readonly name = "JavaScriptProcessRuntimeUnavailableError";
|
|
31
31
|
readonly runtime: string;
|
|
32
32
|
readonly searchPath: string;
|
|
@@ -85,11 +85,7 @@ export function waitForReady(worker: WorkerLike, signal: AbortSignal): Promise<v
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
readonly message: string;
|
|
90
|
-
readonly name?: string;
|
|
91
|
-
readonly stack?: string;
|
|
92
|
-
}): Error {
|
|
88
|
+
function errorFromBridge(error: { readonly message: string; readonly name?: string; readonly stack?: string }): Error {
|
|
93
89
|
const result = new Error(error.message);
|
|
94
90
|
if (error.name) result.name = error.name;
|
|
95
91
|
if (error.stack) result.stack = error.stack;
|
|
@@ -25,7 +25,7 @@ export function resolveJsWorkerEntryUrl(options: JavaScriptWorkerEntryUrlOptions
|
|
|
25
25
|
*/
|
|
26
26
|
export const PROCESS_STARTUP_DEADLINE_MS = 30_000;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
class ProcessKernelStartupTimeoutError extends Error {
|
|
29
29
|
constructor(deadlineMs: number) {
|
|
30
30
|
super(
|
|
31
31
|
`JavaScript kernel process did not become ready within ${deadlineMs / 1000}s; it was stopped, and the next cell starts a fresh one`,
|
|
@@ -18,7 +18,7 @@ export const pythonStartupCeilingMs = 120_000;
|
|
|
18
18
|
const stages = ["interpreter-launch", "stdlib-imports", "runtime-init", "host-init"] as const;
|
|
19
19
|
export type PythonStartupStage = (typeof stages)[number];
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
class PythonKernelStartupError extends Error {
|
|
22
22
|
readonly stage: PythonStartupStage;
|
|
23
23
|
|
|
24
24
|
constructor(stage: PythonStartupStage, reason: string, cause?: Error) {
|
|
@@ -10,7 +10,7 @@ export type BunFfi = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/** True when `value` carries the `bun:ffi` surface the kernel CPU readers use (`dlopen`, `FFIType`, `ptr`). */
|
|
13
|
-
|
|
13
|
+
function isBunFfi(value: unknown): value is BunFfi {
|
|
14
14
|
if (typeof value !== "object" || value === null) return false;
|
|
15
15
|
if (!("dlopen" in value) || typeof value.dlopen !== "function") return false;
|
|
16
16
|
if (!("ptr" in value) || typeof value.ptr !== "function") return false;
|
|
@@ -40,7 +40,7 @@ function lostPhrase(lost: LostGlobals | undefined): string {
|
|
|
40
40
|
return `. Lost: ${named.join(", ")}${more > 0 ? ` and ${more} more` : ""}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const EVAL_KERNEL_UNAVAILABLE = "eval_kernel_unavailable";
|
|
44
44
|
|
|
45
45
|
/** A queued cell that never ran: its kernel died again before the replacement finished one cell. */
|
|
46
46
|
export class KernelUnavailableError extends Error {
|
|
@@ -7,7 +7,7 @@ import type { KernelToHostMessage } from "../../bridge/protocol.ts";
|
|
|
7
7
|
* (blocked on a lock, a pipe or a stopped process) does. It restarts on every sign of progress, so it is
|
|
8
8
|
* not a total startup budget. Where the group's CPU cannot be read it never fires.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
const subprocessStartupNoProgressMs = 30_000;
|
|
11
11
|
|
|
12
12
|
const STDERR_TAIL_CHARS = 2_000;
|
|
13
13
|
const stages = ["interpreter-launch", "stdlib-imports", "runtime-init", "host-init"] as const;
|
|
@@ -4,12 +4,10 @@ import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, truncateTail } from "../host-sdk.
|
|
|
4
4
|
import { formatMiddleElisionMarker } from "./output-meta.ts";
|
|
5
5
|
import { TailBuffer, TailLineRing, truncateHeadBytes } from "./streaming-output-buffer.ts";
|
|
6
6
|
|
|
7
|
-
export { artifactNotice,
|
|
8
|
-
export {
|
|
7
|
+
export { artifactNotice, resolveSessionArtifactsDir } from "./output-meta.ts";
|
|
8
|
+
export { truncateTailBytes } from "./streaming-output-buffer.ts";
|
|
9
9
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, TailBuffer, TailLineRing, truncateTail };
|
|
10
10
|
|
|
11
|
-
export const ARTIFACT_DEFAULT_HEAD_BYTES = 3 * 1024 * 1024;
|
|
12
|
-
|
|
13
11
|
export interface OutputSummary {
|
|
14
12
|
readonly output: string;
|
|
15
13
|
readonly truncated: boolean;
|
|
@@ -67,7 +67,7 @@ const OPENAI_MODEL_RE = /(^|[/.:])(gpt|chatgpt|codex)[-.]|(^|[/.:])o[134](?:[-.]
|
|
|
67
67
|
* - `default`: everything else (and no model) — maximum-emphasis fallback.
|
|
68
68
|
*/
|
|
69
69
|
/** True only for GPT model ids that receive the terse eval composition dialect. */
|
|
70
|
-
|
|
70
|
+
function isGptCodeModeModel(modelId: string | undefined): boolean {
|
|
71
71
|
return modelId !== undefined && /(^|[/.:])gpt[-.]/iu.test(modelId);
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -12,7 +12,7 @@ export interface RunBudgetOptions {
|
|
|
12
12
|
readonly onExhausted: (event: RunBudgetEvent) => void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
function runBudgetError(cellId: string, budgetSeconds: number): Error {
|
|
16
16
|
const error = new Error(
|
|
17
17
|
`Eval cell ${cellId} exhausted its ${budgetSeconds}s run budget (own execution time; host tool calls excluded) and was killed.`,
|
|
18
18
|
);
|
package/src/tool/call-capture.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { EvalToolCallSummary } from "./types.ts";
|
|
|
4
4
|
export const MAX_ENRICHED_TOOL_CALLS = 30;
|
|
5
5
|
export const MAX_AGGREGATED_TOOL_NAMES = 64;
|
|
6
6
|
export const MAX_CAPTURED_IDENTIFIER_CODE_POINTS = 128;
|
|
7
|
-
|
|
7
|
+
const MAX_CAPTURED_TOOL_NAME_CODE_POINTS = 128;
|
|
8
8
|
export const MAX_RPC_EVENT_BYTES = 32 * 1024;
|
|
9
9
|
|
|
10
10
|
const MAX_ARGUMENT_STRING_CODE_POINTS = 512;
|
|
@@ -115,7 +115,7 @@ export function createToolCallMetric(name: string, startedAt: number): EvalToolC
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
function settleToolCallMetric(metric: EvalToolCallMetric, ok: boolean, completedAt: number): void {
|
|
119
119
|
metric.ok = ok;
|
|
120
120
|
metric.durationMs = Math.max(0, completedAt - metric.startedAt);
|
|
121
121
|
}
|
|
@@ -15,7 +15,7 @@ export interface CellDeadlinesOptions {
|
|
|
15
15
|
readonly onExpire: (expiry: CellDeadlineExpiry) => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function hardLimitError(cellId: string, hardLimitSeconds: number): Error {
|
|
19
19
|
const error = new Error(`Eval cell ${cellId} was killed at the ${hardLimitSeconds}s hard limit.`);
|
|
20
20
|
error.name = "TimeoutError";
|
|
21
21
|
return error;
|
|
@@ -59,7 +59,7 @@ export function queuedBehindCell(
|
|
|
59
59
|
];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
function currentDetachedResult(cell: DetachedCellResultSource): AgentToolResult<EvalToolDetails> {
|
|
63
63
|
return cell.terminalResult ?? cell.liveResult?.() ?? fallbackResult(cell.input);
|
|
64
64
|
}
|
|
65
65
|
|
package/src/tool/image-resize.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type EvalImageResizer = (
|
|
|
19
19
|
|
|
20
20
|
type WebpModel = { readonly provider: string; readonly api: string } | undefined;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function webpExclusionForModel(model: WebpModel): true | undefined {
|
|
23
23
|
if (model === undefined) return undefined;
|
|
24
24
|
return model.provider === "ollama" ||
|
|
25
25
|
model.provider === "ollama-cloud" ||
|
package/src/tool/image.ts
CHANGED
|
@@ -15,13 +15,7 @@ import { sanitizeDisplayJson } from "./display-json-bounds.ts";
|
|
|
15
15
|
import { MAX_DISPLAY_TEXT_BYTES } from "./display-json-size.ts";
|
|
16
16
|
import { type EvalImageContent, type EvalImageResizer, resizeEvalImage } from "./image-resize.ts";
|
|
17
17
|
|
|
18
|
-
export {
|
|
19
|
-
type EvalImageContent,
|
|
20
|
-
type EvalImageResizeResult,
|
|
21
|
-
type EvalImageResizer,
|
|
22
|
-
resizeEvalImage,
|
|
23
|
-
webpExclusionForModel,
|
|
24
|
-
} from "./image-resize.ts";
|
|
18
|
+
export { type EvalImageContent, type EvalImageResizeResult, type EvalImageResizer } from "./image-resize.ts";
|
|
25
19
|
export { marshalToolResult, toolResultIsError } from "./tool-result-marshal.ts";
|
|
26
20
|
|
|
27
21
|
// Per-cell display caps: display payloads are retained for the whole result lifetime, so an unbounded
|
package/src/tool/render-cell.ts
CHANGED
|
@@ -32,8 +32,6 @@ import { formatDuration } from "./tool-widgets.ts";
|
|
|
32
32
|
import type { EvalCellResult } from "./types.ts";
|
|
33
33
|
|
|
34
34
|
export type { CellBadges } from "./render-live.ts";
|
|
35
|
-
export { LIVE_CODE_WINDOW_LINES } from "./render-live.ts";
|
|
36
|
-
|
|
37
35
|
// A summary has no length limit, so a collapsed block shows its first lines and marks the cut.
|
|
38
36
|
function summaryVisualLines(summary: string, width: number, expanded: boolean): string[] {
|
|
39
37
|
const lines = renderAllVisualLines(summary, width);
|
package/src/tool/render-live.ts
CHANGED
|
@@ -33,14 +33,13 @@ const FRAME_HEADER_PREFIX: PrefixStyle = { prefix: "╭─ ", continuation: "│
|
|
|
33
33
|
const FRAME_INNER_PREFIX: PrefixStyle = { prefix: "│ ", continuation: "│ ", color: "borderMuted" };
|
|
34
34
|
const FRAME_SECTION_PREFIX: PrefixStyle = { prefix: "├─ ", continuation: "│ ", color: "dim" };
|
|
35
35
|
|
|
36
|
-
export const LIVE_CODE_WINDOW_LINES = 6;
|
|
37
36
|
// The live block's total height never changes: header + 6 body rows + border. When output or
|
|
38
37
|
// status events exist, they take a fixed tail section and the code window shrinks inside the
|
|
39
38
|
// same total (review MEDIUM-2): 6 code rows alone, or 3 code + 3 tail rows.
|
|
40
39
|
const LIVE_BODY_ROWS = 6;
|
|
41
40
|
const LIVE_TAIL_ROWS = 3;
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
function isLiveCellStatus(status: CellStatus): boolean {
|
|
44
43
|
return status === "pending" || status === "running";
|
|
45
44
|
}
|
|
46
45
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EvalDetachedCellSnapshot } from "./detached-cell-contract.ts";
|
|
2
2
|
import type { RetainedContentPart, SettledContentPart, SettledImageSpill } from "./settled-image-spill.ts";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const TERMINAL_SNAPSHOT_CAP = 32;
|
|
5
5
|
|
|
6
6
|
export interface TerminalSnapshotStoreOptions {
|
|
7
7
|
readonly cap?: number;
|
|
@@ -97,7 +97,7 @@ function withContent(
|
|
|
97
97
|
return { ...snapshot, result: { ...snapshot.result, content: [...content] } };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
function estimateSnapshotBytes(snapshot: EvalDetachedCellSnapshot): number {
|
|
101
101
|
let bytes = snapshot.outputTail.length * 2;
|
|
102
102
|
for (const part of snapshot.result.content) {
|
|
103
103
|
bytes += part.type === "text" ? part.text.length * 2 : part.data.length;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const JAVASCRIPT_KERNEL_PRELUDE = [
|
|
2
|
-
"print(...values): write stdout text.",
|
|
3
|
-
"display(value): emit JSON, markdown, or image display output; image bytes, data: URLs, Blob-like values, tool results, and their images[i] frames all render as images.",
|
|
4
|
-
"log(message): emit a progress log line.",
|
|
5
|
-
"phase(title): emit a progress phase.",
|
|
6
|
-
"env(key?, value?): read, set, or list environment values.",
|
|
7
|
-
"read(path, options?): read UTF-8 text; plain paths use cwd and local:// uses the session local root.",
|
|
8
|
-
"write(path, content): write UTF-8 or binary data and return the resolved path.",
|
|
9
|
-
"tool.<name>(args): request a host tool call through the bridge; resolves to { text, images?, details?, hasError? }.",
|
|
10
|
-
"tool(fn, metadata?): register a named JavaScript function as a fenced kernel tool for in-process children.",
|
|
11
|
-
"completion(prompt, options?): request a host completion bridge call.",
|
|
12
|
-
"output(...ids, options?): retrieve task output through the reserved output bridge.",
|
|
13
|
-
'agent(prompt, options?): delegate work; isolated/apply/merge need a host that supports isolation, otherwise a warning. merge: "patch"/"branch" (false/true aliases). Unapplied foreground changes throw with recovery instructions. Handles return immediately; await the completion notification or read task_output for the isolation result.',
|
|
14
|
-
"workpool(agent, name, options?): await a host-owned pool adapter with pool_id, push, close, inspect, and cancel; options only accept mode.",
|
|
15
|
-
"parallel(thunks): run async thunks through the configured bounded pool; preserves order and rethrows the lowest-index error after all settle.",
|
|
16
|
-
"pipeline(items, ...stages): map items through staged async transforms with a barrier between stages.",
|
|
17
|
-
].join("\n");
|