@code-yeongyu/senpi-codemode 2026.11.10-3 → 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,20 @@
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
+
3
18
  ## [2026.11.10-3] - 2026-11-10
4
19
 
5
20
  ### 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",
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-3",
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-3"
41
+ "@code-yeongyu/senpi": "2026.11.11"
42
42
  },
43
43
  "devDependencies": {
44
- "@code-yeongyu/senpi": "2026.11.10-3"
44
+ "@code-yeongyu/senpi": "2026.11.11"
45
45
  },
46
46
  "keywords": [
47
47
  "senpi",
@@ -161,11 +161,23 @@ function reportSettingsProblems(ctx: ExtensionContext, problems: readonly string
161
161
  }
162
162
  }
163
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
+
164
173
  export function createExecuteTool(pi: CodemodeRuntimeAPI, activeTools?: ReadonlySet<string>): AgentExecuteTool {
165
174
  // A cell names tools directly and cannot run tool_search first, so eval opts in to
166
175
  // lazy activation. Eligibility still belongs to the extension that registered the tool.
167
- const executeTool: AgentExecuteTool = (toolName, params, executeOptions) =>
168
- 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
+ };
169
181
  return Object.assign(executeTool, {
170
182
  isToolAvailable: (name: string): boolean => (activeTools ?? reachableToolNames(pi)).has(name),
171
183
  });
@@ -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)