@code-yeongyu/senpi-codemode 2026.11.10 → 2026.11.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 +67 -0
- package/package.json +4 -4
- package/src/bridges/schema-bridge.ts +1 -0
- package/src/extension/kernel-preludes.ts +5 -3
- package/src/extension/reachable-tools.ts +31 -0
- package/src/extension/runtime-factory.ts +17 -4
- package/src/kernels/py/interpose.py +11 -9
- package/src/kernels/py/sqlite_uri.py +46 -0
- package/src/tool/render-blocks.ts +23 -1
- package/src/tool/render-call.ts +1 -1
- package/src/tool/render-result.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2026.11.12] - 2026-11-12
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- A running eval cell no longer makes the TUI below it jump while parallel nested tool calls with different output heights stream ([#6406](https://github.com/code-yeongyu/senpi/pull/6406))
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
## [2026.11.11] - 2026-11-11
|
|
18
|
+
|
|
19
|
+
### Breaking Changes
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- The Python sqlite permission guard no longer depends on `urllib.parse`, which cell code could rebind to crash the guard (Python 3.11) or bypass a read-only check (#6376). A `%00` inside the URI can no longer make the guard skip the check while SQLite opens the real file.
|
|
28
|
+
- `show_html_page` called from an eval cell is refused with an error that says to call it directly; before, the page never reached the reader while the tool reported it as shown ([#6393](https://github.com/code-yeongyu/senpi/pull/6393))
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
|
|
32
|
+
## [2026.11.10-3] - 2026-11-10
|
|
33
|
+
|
|
34
|
+
### Breaking Changes
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
### Removed
|
|
43
|
+
|
|
44
|
+
## [2026.11.10-2] - 2026-11-10
|
|
45
|
+
|
|
46
|
+
### Breaking Changes
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
### Removed
|
|
55
|
+
|
|
56
|
+
## [2026.11.10-1] - 2026-11-10
|
|
57
|
+
|
|
58
|
+
### Breaking Changes
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- `agent()`, `output()` and the eval prompt's spawn helpers keep working when the task tools are eval-only (`exposure: "eval"`, withheld from the model while eval exists), and an eval-only tool's kernel prelude stays loaded ([#6276](https://github.com/code-yeongyu/senpi/pull/6276))
|
|
67
|
+
|
|
68
|
+
### Removed
|
|
69
|
+
|
|
3
70
|
## [2026.11.10] - 2026-11-10
|
|
4
71
|
|
|
5
72
|
### Breaking Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.12",
|
|
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.11.
|
|
36
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.12",
|
|
37
37
|
"quickjs-wasi": "3.6.2",
|
|
38
38
|
"typebox": "1.3.34"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@code-yeongyu/senpi": "2026.11.
|
|
41
|
+
"@code-yeongyu/senpi": "2026.11.12"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@code-yeongyu/senpi": "2026.11.
|
|
44
|
+
"@code-yeongyu/senpi": "2026.11.12"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"senpi",
|
|
@@ -13,6 +13,7 @@ type SchemaArgs = Static<typeof schemaArgsSchema>;
|
|
|
13
13
|
export interface EvalSchemaToolInfo {
|
|
14
14
|
readonly name: string;
|
|
15
15
|
readonly description?: string | undefined;
|
|
16
|
+
readonly exposure?: string | undefined;
|
|
16
17
|
readonly parameters?: unknown;
|
|
17
18
|
readonly kernelPrelude?: KernelPreludeContribution | undefined;
|
|
18
19
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { KernelPreludeContribution } from "@code-yeongyu/senpi";
|
|
2
2
|
import type { CodemodeRuntimeAPI } from "./runtime-factory.ts";
|
|
3
|
+
import { reachableToolNames } from "./reachable-tools.ts";
|
|
3
4
|
|
|
4
5
|
type ToolRegistry = Pick<CodemodeRuntimeAPI, "getActiveTools" | "getAllTools">;
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* Kernel globals of the tools
|
|
8
|
-
*
|
|
8
|
+
* Kernel globals of the tools a cell can reach right now (active, or eval-exposed and withheld from the model).
|
|
9
|
+
* Read per cell, so a tool activated by `tool_search`, a by-name call, or a command shows up in the next cell
|
|
10
|
+
* and a deactivated one disappears, whatever the registration order.
|
|
9
11
|
*/
|
|
10
12
|
export function activeKernelPreludes(pi: ToolRegistry): readonly KernelPreludeContribution[] {
|
|
11
|
-
const active =
|
|
13
|
+
const active = reachableToolNames(pi);
|
|
12
14
|
return pi.getAllTools().flatMap((tool) => (tool.kernelPrelude && active.has(tool.name) ? [tool.kernelPrelude] : []));
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EvalSchemaToolInfo } from "../bridges/schema-bridge.ts";
|
|
2
|
+
|
|
3
|
+
export interface ReachableToolRegistry {
|
|
4
|
+
getActiveTools(): string[];
|
|
5
|
+
getAllTools(): readonly EvalSchemaToolInfo[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The tools a cell can call: the model-visible active tools plus every registered tool whose declared
|
|
10
|
+
* exposure is `eval`. The session withholds an eval-exposed tool from the model whenever eval itself is
|
|
11
|
+
* registered (bash, grep, glob, generate_image, a plugin's thread_* or task_* family), so it is absent
|
|
12
|
+
* from `getActiveTools()` while `executeTool` still reaches it; reading only the active list made
|
|
13
|
+
* `agent()`/`output()` report the task tool unavailable and dropped its kernel prelude the moment it
|
|
14
|
+
* became eval-only (senpi#6269 follow-up).
|
|
15
|
+
*/
|
|
16
|
+
export function reachableToolNames(pi: ReachableToolRegistry): Set<string> {
|
|
17
|
+
const names = new Set(pi.getActiveTools());
|
|
18
|
+
for (const tool of registeredTools(pi)) if (tool.exposure === "eval") names.add(tool.name);
|
|
19
|
+
return names;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The loader's registry methods throw until the runtime binds (the dedupe probe in
|
|
23
|
+
// coding-agent's codemode-builtin-dedupe.test.ts registers eval before that point); an
|
|
24
|
+
// unreadable registry adds nothing, like promptKernelPreludes.
|
|
25
|
+
function registeredTools(pi: ReachableToolRegistry): readonly EvalSchemaToolInfo[] {
|
|
26
|
+
try {
|
|
27
|
+
return pi.getAllTools();
|
|
28
|
+
} catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -27,6 +27,7 @@ import { processRuntimeInfo } from "../kernels/js/process-worker.ts";
|
|
|
27
27
|
import { sessionEnvironmentFrom } from "../kernels/session-env.ts";
|
|
28
28
|
import { resolveSessionArtifactsDir } from "../output/streaming-output.ts";
|
|
29
29
|
import type { EnabledEvalLanguages, EvalLanguage, EvalRuntimes } from "../tool/types.ts";
|
|
30
|
+
import { reachableToolNames } from "./reachable-tools.ts";
|
|
30
31
|
import { jsRuntimeInfo, runtimesFromAvailability } from "./runtime-info.ts";
|
|
31
32
|
import {
|
|
32
33
|
type CodemodeSessionManager,
|
|
@@ -90,7 +91,7 @@ export async function createRuntime(
|
|
|
90
91
|
const enabledLanguages = enabledLanguagesFrom(settings, availability);
|
|
91
92
|
const jsProcessIsolation = resolveJsIsolation(settings) === "process";
|
|
92
93
|
const artifacts = resolveSessionArtifactsDir(ctx.sessionManager.getSessionFile());
|
|
93
|
-
const activeTools =
|
|
94
|
+
const activeTools = reachableToolNames(pi);
|
|
94
95
|
const executeTool = createExecuteTool(pi, activeTools);
|
|
95
96
|
const create = options.createSessionManager ?? createCodemodeSessionManager;
|
|
96
97
|
const sessionId = sessionIdFrom(event);
|
|
@@ -160,13 +161,25 @@ function reportSettingsProblems(ctx: ExtensionContext, problems: readonly string
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
// The OmO desktop renders a page only from a top-level show_html_page call; one made from a cell is recorded inside
|
|
165
|
+
// the eval call, so the page was never shown while the tool told the model it was (senpi#6391).
|
|
166
|
+
const TOP_LEVEL_ONLY_TOOL_REFUSALS: ReadonlyMap<string, string> = new Map([
|
|
167
|
+
[
|
|
168
|
+
"show_html_page",
|
|
169
|
+
"show_html_page cannot run inside eval: a page shown from a cell never reaches the reader. Build the HTML in the cell if you like, then call show_html_page directly as its own tool call.",
|
|
170
|
+
],
|
|
171
|
+
]);
|
|
172
|
+
|
|
163
173
|
export function createExecuteTool(pi: CodemodeRuntimeAPI, activeTools?: ReadonlySet<string>): AgentExecuteTool {
|
|
164
174
|
// A cell names tools directly and cannot run tool_search first, so eval opts in to
|
|
165
175
|
// lazy activation. Eligibility still belongs to the extension that registered the tool.
|
|
166
|
-
const executeTool: AgentExecuteTool = (toolName, params, executeOptions) =>
|
|
167
|
-
|
|
176
|
+
const executeTool: AgentExecuteTool = (toolName, params, executeOptions) => {
|
|
177
|
+
const refusal = TOP_LEVEL_ONLY_TOOL_REFUSALS.get(toolName);
|
|
178
|
+
if (refusal !== undefined) return Promise.reject(new Error(refusal));
|
|
179
|
+
return pi.executeTool(toolName, params, { ...executeOptions, activateInactiveTool: true });
|
|
180
|
+
};
|
|
168
181
|
return Object.assign(executeTool, {
|
|
169
|
-
isToolAvailable: (name: string): boolean => activeTools
|
|
182
|
+
isToolAvailable: (name: string): boolean => (activeTools ?? reachableToolNames(pi)).has(name),
|
|
170
183
|
});
|
|
171
184
|
}
|
|
172
185
|
|
|
@@ -24,7 +24,6 @@ import sqlite3
|
|
|
24
24
|
import subprocess
|
|
25
25
|
import sys
|
|
26
26
|
import types
|
|
27
|
-
import urllib.parse
|
|
28
27
|
import weakref
|
|
29
28
|
import zipfile
|
|
30
29
|
from typing import Callable
|
|
@@ -39,6 +38,12 @@ with open(_identity_path, "rb") as _identity_source:
|
|
|
39
38
|
exec(compile(_identity_source.read(), _identity_path, "exec"), _identity_namespace)
|
|
40
39
|
create_identity = _identity_namespace["create_identity"]
|
|
41
40
|
|
|
41
|
+
_sqlite_uri_path = os.path.join(os.path.dirname(__file__), "sqlite_uri.py")
|
|
42
|
+
_sqlite_uri_namespace = {"__builtins__": __builtins__, "__file__": _sqlite_uri_path}
|
|
43
|
+
with open(_sqlite_uri_path, "rb") as _sqlite_uri_source:
|
|
44
|
+
exec(compile(_sqlite_uri_source.read(), _sqlite_uri_path, "exec"), _sqlite_uri_namespace)
|
|
45
|
+
parse_sqlite_uri = _sqlite_uri_namespace["parse_sqlite_uri"]
|
|
46
|
+
|
|
42
47
|
|
|
43
48
|
def install(check, enforcing, refuse, runtime):
|
|
44
49
|
identity = create_identity(runtime)
|
|
@@ -54,7 +59,6 @@ def install(check, enforcing, refuse, runtime):
|
|
|
54
59
|
getframe = sys._getframe
|
|
55
60
|
resolve_name = importlib.util.resolve_name
|
|
56
61
|
reference, UnsupportedOperation = weakref.ref, io.UnsupportedOperation
|
|
57
|
-
urlsplit, parse_qs, unquote = urllib.parse.urlsplit, urllib.parse.parse_qs, urllib.parse.unquote
|
|
58
62
|
DatabaseError = sqlite3.DatabaseError
|
|
59
63
|
SQLITE_ATTACH, SQLITE_DENY, SQLITE_OK = sqlite3.SQLITE_ATTACH, sqlite3.SQLITE_DENY, sqlite3.SQLITE_OK
|
|
60
64
|
native = importlib.import_module(os.name)
|
|
@@ -78,7 +82,6 @@ def install(check, enforcing, refuse, runtime):
|
|
|
78
82
|
isabs = capture(isabs, os=path_os)
|
|
79
83
|
quote = capture(quote)
|
|
80
84
|
resolve_name = capture(resolve_name)
|
|
81
|
-
urlsplit, parse_qs, unquote = capture(urlsplit), capture(parse_qs), capture(unquote)
|
|
82
85
|
grants = {}
|
|
83
86
|
modules = sys.modules
|
|
84
87
|
# The interpreter's own registries, never replaced: CPython's C-level import
|
|
@@ -607,16 +610,15 @@ def install(check, enforcing, refuse, runtime):
|
|
|
607
610
|
path = fsdecode(fspath(database))
|
|
608
611
|
if path in ("", ":memory:"):
|
|
609
612
|
return None, ()
|
|
610
|
-
|
|
613
|
+
modes = ()
|
|
611
614
|
if uri and path.startswith("file:"):
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if mode == "memory":
|
|
615
|
+
path, modes = parse_sqlite_uri(path)
|
|
616
|
+
if modes and all(mode == "memory" for mode in modes):
|
|
615
617
|
return None, ()
|
|
616
|
-
path = unquote(parsed.path)
|
|
617
618
|
if path == ":memory:":
|
|
618
619
|
return None, ()
|
|
619
|
-
|
|
620
|
+
read_only = bool(modes) and all(mode == "ro" for mode in modes)
|
|
621
|
+
return path, ("read",) if read_only else ("read", "write")
|
|
620
622
|
class Cursor(sqlite3.Cursor):
|
|
621
623
|
pass
|
|
622
624
|
for name in ("execute", "executemany", "executescript", "fetchone", "fetchmany", "fetchall", "__next__"):
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""SQLite URI filename parsing for the permission guard.
|
|
2
|
+
|
|
3
|
+
The guard must not read anything cell code can rebind, so this module uses no
|
|
4
|
+
imports: only str/bytes methods and the frozen builtins interpose.py executes it
|
|
5
|
+
with. It follows SQLite's own URI rules (sqlite3ParseUri) instead of urllib's:
|
|
6
|
+
'+' is not a space, the authority is dropped, the fragment is ignored, and a
|
|
7
|
+
%00 ends the path, key or value it appears in.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
_HEX = "0123456789abcdefABCDEF"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _percent_decode(text):
|
|
14
|
+
if "%" not in text:
|
|
15
|
+
return text
|
|
16
|
+
raw = text.encode("utf-8", "surrogateescape")
|
|
17
|
+
decoded = bytearray()
|
|
18
|
+
index, size = 0, len(raw)
|
|
19
|
+
while index < size:
|
|
20
|
+
byte = raw[index]
|
|
21
|
+
if byte == 37 and index + 2 < size and chr(raw[index + 1]) in _HEX and chr(raw[index + 2]) in _HEX:
|
|
22
|
+
octet = int(raw[index + 1:index + 3].decode("ascii"), 16)
|
|
23
|
+
if octet == 0:
|
|
24
|
+
# sqlite3ParseUri ignores the rest of the token after %00, so the guard must too.
|
|
25
|
+
break
|
|
26
|
+
decoded.append(octet)
|
|
27
|
+
index += 3
|
|
28
|
+
continue
|
|
29
|
+
decoded.append(byte)
|
|
30
|
+
index += 1
|
|
31
|
+
return bytes(decoded).decode("utf-8", "surrogateescape")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def parse_sqlite_uri(uri):
|
|
35
|
+
rest = uri[5:]
|
|
36
|
+
rest = rest.partition("#")[0]
|
|
37
|
+
rest, _, query = rest.partition("?")
|
|
38
|
+
if rest.startswith("//"):
|
|
39
|
+
slash = rest.find("/", 2)
|
|
40
|
+
rest = "" if slash < 0 else rest[slash:]
|
|
41
|
+
modes = []
|
|
42
|
+
for pair in query.split("&"):
|
|
43
|
+
key, _, value = pair.partition("=")
|
|
44
|
+
if _percent_decode(key) == "mode":
|
|
45
|
+
modes.append(_percent_decode(value))
|
|
46
|
+
return _percent_decode(rest), tuple(modes)
|
|
@@ -67,6 +67,12 @@ class PlainTextComponent implements EvalRenderComponent {
|
|
|
67
67
|
#live = false;
|
|
68
68
|
#invalidate: (() => void) | undefined;
|
|
69
69
|
#idleTicks = 0;
|
|
70
|
+
// While a cell runs, the row never shrinks (senpi#6390): nested calls of different heights slide through the
|
|
71
|
+
// collapsed window, and a shrinking block moves every line below it. The floor resets when the cell stops
|
|
72
|
+
// running, the width changes, or the layout (expanded/collapsed) changes.
|
|
73
|
+
#heightFloor = 0;
|
|
74
|
+
#floorKey = "";
|
|
75
|
+
#layoutKey = "";
|
|
70
76
|
|
|
71
77
|
setBlocks(blocks: readonly RenderBlock[]): void {
|
|
72
78
|
this.#blocks = blocks;
|
|
@@ -81,8 +87,9 @@ class PlainTextComponent implements EvalRenderComponent {
|
|
|
81
87
|
* rebuild, session switch) stops itself after LIVE_TICKER_MAX_IDLE_TICKS and rearms on
|
|
82
88
|
* the next render, so dropped rows cannot accumulate intervals.
|
|
83
89
|
*/
|
|
84
|
-
syncLiveTicker(isLive: boolean, invalidate: () => void): void {
|
|
90
|
+
syncLiveTicker(isLive: boolean, invalidate: () => void, layoutKey = ""): void {
|
|
85
91
|
this.#live = isLive;
|
|
92
|
+
this.#layoutKey = layoutKey;
|
|
86
93
|
this.#invalidate = invalidate;
|
|
87
94
|
if (!isLive) {
|
|
88
95
|
this.stopLiveTicker();
|
|
@@ -134,6 +141,21 @@ class PlainTextComponent implements EvalRenderComponent {
|
|
|
134
141
|
assertNever(block);
|
|
135
142
|
}
|
|
136
143
|
}
|
|
144
|
+
return this.#holdLiveHeight(lines, width);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#holdLiveHeight(lines: string[], width: number): string[] {
|
|
148
|
+
if (!this.#live) {
|
|
149
|
+
this.#heightFloor = 0;
|
|
150
|
+
return lines;
|
|
151
|
+
}
|
|
152
|
+
const key = `${width}|${this.#layoutKey}`;
|
|
153
|
+
if (key !== this.#floorKey) {
|
|
154
|
+
this.#floorKey = key;
|
|
155
|
+
this.#heightFloor = 0;
|
|
156
|
+
}
|
|
157
|
+
while (lines.length < this.#heightFloor) lines.push("");
|
|
158
|
+
this.#heightFloor = lines.length;
|
|
137
159
|
return lines;
|
|
138
160
|
}
|
|
139
161
|
|
package/src/tool/render-call.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function renderEvalCall(
|
|
|
54
54
|
// renders (the host would otherwise fall back to a raw key=value row).
|
|
55
55
|
const code = typeof args.code === "string" ? args.code : "";
|
|
56
56
|
const language = knownLanguage(args.language);
|
|
57
|
-
component.syncLiveTicker(theme !== undefined, context.invalidate);
|
|
57
|
+
component.syncLiveTicker(theme !== undefined, context.invalidate, context.expanded ? "expanded" : "collapsed");
|
|
58
58
|
if (theme === undefined && context.spinnerFrame === undefined) {
|
|
59
59
|
const reset = args.reset === true ? " reset" : "";
|
|
60
60
|
const timeout = args.timeout === undefined ? "" : ` timeout ${args.timeout}s`;
|
|
@@ -101,7 +101,7 @@ export function renderEvalResult(
|
|
|
101
101
|
}
|
|
102
102
|
const expanded = options.expanded || context.expanded;
|
|
103
103
|
const imageProtocol = context.imageProtocol ?? null;
|
|
104
|
-
component.syncLiveTicker(hasLiveCell(details), context.invalidate);
|
|
104
|
+
component.syncLiveTicker(hasLiveCell(details), context.invalidate, expanded ? "expanded" : "collapsed");
|
|
105
105
|
if (details?.cells !== undefined && details.cells.length > 0) {
|
|
106
106
|
const blocks: RenderBlock[] = [
|
|
107
107
|
{
|