@code-yeongyu/senpi-codemode 2026.11.10 → 2026.11.11

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 CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changelog
2
2
 
3
+ ## [2026.11.11] - 2026-11-11
4
+
5
+ ### Breaking Changes
6
+
7
+ ### Added
8
+
9
+ ### Changed
10
+
11
+ ### Fixed
12
+
13
+ - 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.
14
+ - `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))
15
+
16
+ ### Removed
17
+
18
+ ## [2026.11.10-3] - 2026-11-10
19
+
20
+ ### Breaking Changes
21
+
22
+ ### Added
23
+
24
+ ### Changed
25
+
26
+ ### Fixed
27
+
28
+ ### Removed
29
+
30
+ ## [2026.11.10-2] - 2026-11-10
31
+
32
+ ### Breaking Changes
33
+
34
+ ### Added
35
+
36
+ ### Changed
37
+
38
+ ### Fixed
39
+
40
+ ### Removed
41
+
42
+ ## [2026.11.10-1] - 2026-11-10
43
+
44
+ ### Breaking Changes
45
+
46
+ ### Added
47
+
48
+ ### Changed
49
+
50
+ ### Fixed
51
+
52
+ - `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))
53
+
54
+ ### Removed
55
+
3
56
  ## [2026.11.10] - 2026-11-10
4
57
 
5
58
  ### Breaking Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-codemode",
3
- "version": "2026.11.10",
3
+ "version": "2026.11.11",
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.10",
36
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.11",
37
37
  "quickjs-wasi": "3.6.2",
38
38
  "typebox": "1.3.34"
39
39
  },
40
40
  "peerDependencies": {
41
- "@code-yeongyu/senpi": "2026.11.10"
41
+ "@code-yeongyu/senpi": "2026.11.11"
42
42
  },
43
43
  "devDependencies": {
44
- "@code-yeongyu/senpi": "2026.11.10"
44
+ "@code-yeongyu/senpi": "2026.11.11"
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 active right now. Read per cell, so a tool activated by `tool_search`, a by-name
8
- * call, or a command shows up in the next cell and a deactivated one disappears, whatever the registration order.
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 = new Set(pi.getActiveTools());
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 = new Set(pi.getActiveTools());
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
- pi.executeTool(toolName, params, { ...executeOptions, activateInactiveTool: true });
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?.has(name) ?? pi.getActiveTools().includes(name),
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
- mode = None
613
+ modes = ()
611
614
  if uri and path.startswith("file:"):
612
- parsed = urlsplit(path)
613
- mode = parse_qs(parsed.query).get("mode", [None])[0]
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
- return path, ("read",) if mode == "ro" else ("read", "write")
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)