@code-yeongyu/senpi-codemode 2026.10.10-5 → 2026.10.10-6
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 +14 -0
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/bridges/eval-environment-schemas.ts +48 -0
- package/src/bridges/eval-virtual-schemas.ts +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
|
|
7
7
|
### Added
|
|
8
8
|
|
|
9
|
+
- `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.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
## [2026.10.10-6] - 2026-10-07
|
|
18
|
+
|
|
19
|
+
### Breaking Changes
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
9
23
|
### Changed
|
|
10
24
|
|
|
11
25
|
### Fixed
|
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ options object and asynchronous helpers are `await`-able.
|
|
|
363
363
|
| `write(path, content)` | Creates parent directories and writes text. `local://` paths persist in the session artifact root. |
|
|
364
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)). |
|
|
365
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 }`. |
|
|
366
|
-
| `tool_schema(name?)` | Returns a tool's parameter schema without calling it; omit `name` to list tool names. |
|
|
366
|
+
| `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). |
|
|
367
367
|
| `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). |
|
|
368
368
|
| `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. |
|
|
369
369
|
| `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. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.10.10-
|
|
3
|
+
"version": "2026.10.10-6",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "8.0.4",
|
|
36
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.10-
|
|
36
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.10-6",
|
|
37
37
|
"quickjs-wasi": "3.6.2",
|
|
38
38
|
"typebox": "1.3.34"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@code-yeongyu/senpi": "2026.10.10-
|
|
41
|
+
"@code-yeongyu/senpi": "2026.10.10-6"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@code-yeongyu/senpi": "2026.10.10-
|
|
44
|
+
"@code-yeongyu/senpi": "2026.10.10-6"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"senpi",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EvalSchemaResult } from "./schema-bridge.ts";
|
|
2
|
+
|
|
3
|
+
export type NamedEvalSchema = Extract<EvalSchemaResult, { readonly name: string }>;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The on-demand documentation for package environments and isolated cells (`tool_schema("eval:environments")` and
|
|
7
|
+
* `tool_schema("eval:isolation")`). Like the other virtual entries they are never listed, never run anything, and add
|
|
8
|
+
* nothing to the eval prompt or input schema. Every magic, code and message named here is the one the source emits.
|
|
9
|
+
*/
|
|
10
|
+
export const environmentsEntry: NamedEvalSchema = {
|
|
11
|
+
name: "eval:environments",
|
|
12
|
+
description: [
|
|
13
|
+
"Host magic cells: a cell whose first code line (blank and comment lines skipped) is one of these runs on the host, in the language kernel's queue, so it orders with ordinary cells and a queued one is removed by stop like any queued cell. A magic followed by more code is refused: put it on its own cell, then run the code that uses it in the next cell.",
|
|
14
|
+
"py: %pip install <requirements ...> installs into the session's environment (a trailing backslash continues the line). Result: installed <packages> into <mode> (revision <n>); already-imported modules stay cached until reset.",
|
|
15
|
+
"js: %bun add <packages ...> or %npm add <packages ...> (install is accepted as a synonym of add). Result: added <packages> with <installer> into <mode>[ (revision <n>)]; already-imported modules stay cached until reset. A package the project's own node_modules still shadows is named with environment_resolution_conflict in the result.",
|
|
16
|
+
"py and js: %environment managed | project selects where installs go. managed (the default) uses per-session revisions under the session's artifacts directory (or environments.managedRoot) and never touches project files; project installs into the session directory (py: .senpi/python-packages; js: the project root).",
|
|
17
|
+
"py and js: %load <file> runs a local file as a cell, read when its turn comes in the queue, with the file's name in tracebacks; definitions persist like any cell. It accepts a path relative to the session directory, local:// or file://, reads files up to 8 MiB and never fetches remote URLs.",
|
|
18
|
+
"Installs pause the run budget like a bridge call, stream the installer's output into the cell, detach past the foreground window like any cell, and are stopped by stop.",
|
|
19
|
+
"Install failures are cell errors that start with their code: environment_install_failed (a bad argument or an installer failure, with the installer's stderr tail), environment_install_cancelled (stopped before or during the install), environment_installer_unavailable (no interpreter or no pip; no JavaScript package environment in this session; neither bun nor npm on PATH, or the chosen one missing; the installer failed to start; or installs turned off with environments.autoProvision: false), environment_resolution_conflict (py: pip reported a dependency conflict). A %load failure, and a magic refused because more code follows it, are plain cell errors without a code.",
|
|
20
|
+
].join("\n"),
|
|
21
|
+
parameters: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
"%pip": { description: "py: %pip install <requirements ...>" },
|
|
25
|
+
"%bun": { description: "js: %bun add <packages ...>" },
|
|
26
|
+
"%npm": { description: "js: %npm add <packages ...>" },
|
|
27
|
+
"%environment": { enum: ["managed", "project"] },
|
|
28
|
+
"%load": { description: "py and js: %load <path | local://... | file://...>" },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const isolationEntry: NamedEvalSchema = {
|
|
34
|
+
name: "eval:isolation",
|
|
35
|
+
description: [
|
|
36
|
+
"isolate: true runs one JavaScript cell in a fresh QuickJS sandbox instead of the persistent kernel. It is available only when sandbox.enabled is on in the codemode settings; only then does the eval input schema carry the isolate field. An older senpi drops the field and would run the code as an ordinary cell, so check this entry before relying on it.",
|
|
37
|
+
'Requests are refused with eval_isolate_invalid when sandbox cells are turned off, when language is not "js", when isolate is not a boolean, with reset: true (a sandbox cell always starts fresh), or when eval runs through a proxy that cannot isolate a cell.',
|
|
38
|
+
"An isolated cell shares nothing with the kernel. Its globals are print, display, text, image, console, exit, tool.<name>(args) (also reachable as tools), ALL_TOOLS (the names and descriptions of the tools it may call), load and store. Its tool calls go through the host, so permission hooks still apply, and tool calls still pending when the script settles are aborted. The store is rejected: load returns nothing and store fails with eval_isolate_no_state.",
|
|
39
|
+
"Limits: sandbox.timeoutSeconds (default 300) and sandbox.memoryMb (default 64; SENPI_CODEMODE_SANDBOX_MEMORY_MB overrides it). The result's runtime names quickjs and its version, with isolation sandbox.",
|
|
40
|
+
"Failures start with their code: eval_isolate_timeout, eval_isolate_aborted, eval_isolate_memory_limit, eval_isolate_unresolved_promise (the script ended with a promise still pending), eval_isolate_no_state, eval_isolate_unavailable (the sandbox itself failed: it could not load, or its worker crashed, exited or lost its output; if that happened after the script started, tool calls the cell made may already have run, so check their effects before retrying).",
|
|
41
|
+
].join("\n"),
|
|
42
|
+
parameters: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
isolate: { type: "boolean", description: 'true with language: "js" runs the cell in a fresh sandbox' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { environmentsEntry, isolationEntry, type NamedEvalSchema } from "./eval-environment-schemas.ts";
|
|
1
2
|
import type { EvalSchemaResult } from "./schema-bridge.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -22,7 +23,7 @@ const handleRefSchema = {
|
|
|
22
23
|
required: ["kind", "id", "run_epoch"],
|
|
23
24
|
} as const;
|
|
24
25
|
|
|
25
|
-
const waitEntry:
|
|
26
|
+
const waitEntry: NamedEvalSchema = {
|
|
26
27
|
name: "eval:wait",
|
|
27
28
|
description: [
|
|
28
29
|
"wait(handles, {timeout?, mode?}) blocks the cell until the given handles settle (js: await wait(...); py/rb: wait(...); jl: wait(handle(node)) or wait([handle(a), handle(b)])).",
|
|
@@ -44,7 +45,7 @@ const waitEntry: EvalSchemaResult = {
|
|
|
44
45
|
},
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
const helpersEntry:
|
|
48
|
+
const helpersEntry: NamedEvalSchema = {
|
|
48
49
|
name: "eval:helpers",
|
|
49
50
|
description: [
|
|
50
51
|
"Advanced cell helpers (all four languages; js helpers are awaited).",
|
|
@@ -70,7 +71,7 @@ const helpersEntry: EvalSchemaResult = {
|
|
|
70
71
|
},
|
|
71
72
|
};
|
|
72
73
|
|
|
73
|
-
const kernelToolsEntry:
|
|
74
|
+
const kernelToolsEntry: NamedEvalSchema = {
|
|
74
75
|
name: "eval:kernel-tools",
|
|
75
76
|
description: [
|
|
76
77
|
"Kernel tools: functions a cell defines that in-process children can call (js and py; rb/jl answer tools_unavailable).",
|
|
@@ -90,12 +91,18 @@ const kernelToolsEntry: EvalSchemaResult = {
|
|
|
90
91
|
},
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
const VIRTUAL_ENTRIES: ReadonlyMap<string, EvalSchemaResult> = new Map([
|
|
94
|
+
const VIRTUAL_ENTRIES: ReadonlyMap<string, EvalSchemaResult> = new Map<string, EvalSchemaResult>([
|
|
94
95
|
[waitEntry.name, waitEntry],
|
|
95
96
|
[helpersEntry.name, helpersEntry],
|
|
96
97
|
[kernelToolsEntry.name, kernelToolsEntry],
|
|
98
|
+
[environmentsEntry.name, environmentsEntry],
|
|
99
|
+
[isolationEntry.name, isolationEntry],
|
|
97
100
|
]);
|
|
98
101
|
|
|
99
102
|
export function virtualEvalSchema(name: string): EvalSchemaResult | undefined {
|
|
100
103
|
return VIRTUAL_ENTRIES.get(name);
|
|
101
104
|
}
|
|
105
|
+
|
|
106
|
+
export function virtualEvalSchemaNames(): readonly string[] {
|
|
107
|
+
return [...VIRTUAL_ENTRIES.keys()];
|
|
108
|
+
}
|