@code-yeongyu/senpi-codemode 2026.11.28 → 2026.11.29
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,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2026.11.29] - 2026-11-29
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Every codemode bridge route requires the session bearer token; the Python kernel's permission and kill-guard checks send it ([#7681](https://github.com/code-yeongyu/senpi/pull/7681))
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
## [2026.11.28-2] - 2026-11-28
|
|
18
|
+
|
|
19
|
+
### Breaking Changes
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
## [2026.11.28-1] - 2026-11-28
|
|
30
|
+
|
|
31
|
+
### Breaking Changes
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
### Removed
|
|
40
|
+
|
|
3
41
|
## [2026.11.28] - 2026-11-28
|
|
4
42
|
|
|
5
43
|
### 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.29",
|
|
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.
|
|
37
|
-
"@earendil-works/pi-realm-registry": "npm:@code-yeongyu/senpi-realm-registry@2026.11.
|
|
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",
|
|
38
38
|
"quickjs-wasi": "3.6.2",
|
|
39
39
|
"typebox": "1.3.34"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@code-yeongyu/senpi": "2026.11.
|
|
42
|
+
"@code-yeongyu/senpi": "2026.11.29"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@code-yeongyu/senpi": "2026.11.
|
|
45
|
+
"@code-yeongyu/senpi": "2026.11.29"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"senpi",
|
|
@@ -34,7 +34,7 @@ export interface BridgeServerOptions {
|
|
|
34
34
|
onCall: (request: BridgeHttpCallRequest) => Promise<unknown>;
|
|
35
35
|
onEmit: (event: BridgeHttpEmitEvent, signal: AbortSignal) => Promise<void>;
|
|
36
36
|
onCompletion: (request: BridgeHttpCompletionRequest) => Promise<unknown>;
|
|
37
|
-
/** Decides a kernel's kill-guard check (senpi#5349)
|
|
37
|
+
/** Decides a kernel's kill-guard check (senpi#5349): the session bearer token, but no permission token, so it works in full-access mode. */
|
|
38
38
|
onKillGuardCheck?: (request: unknown) => unknown;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -96,12 +96,9 @@ async function handleRequest(
|
|
|
96
96
|
sendJson(response, 404, { ok: false, error: transportError("not_found", "Bridge route was not found") });
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
+
// Every route, the kernel shims' permission and kill-guard checks included, needs the session's bearer token.
|
|
99
100
|
const auth = parseBearerToken(request.headers.authorization);
|
|
100
|
-
if (
|
|
101
|
-
route !== "/permission_check" &&
|
|
102
|
-
route !== "/kill_guard_check" &&
|
|
103
|
-
(!auth || !verifyBridgeToken(token, auth).ok)
|
|
104
|
-
) {
|
|
101
|
+
if (!auth || !verifyBridgeToken(token, auth).ok) {
|
|
105
102
|
sendJson(response, 401, { ok: false, error: transportError("unauthorized", "Bridge authorization failed") });
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Installed for every kernel the host starts with the guard on, independent of permission enforcement: a subprocess
|
|
4
4
|
call, a shell string or a signal that could reach a kill-family command is sent to the host's judge over the bridge
|
|
5
|
-
(`/kill_guard_check`, no permission token) before it runs, and a refusal raises PermissionError. A cheap prefilter
|
|
5
|
+
(`/kill_guard_check`, with the session's bridge bearer token and no permission token) before it runs, and a refusal raises PermissionError. A cheap prefilter
|
|
6
6
|
keeps every other call local. The host decides from this kernel's vantage (its own process group, its own pid).
|
|
7
7
|
"""
|
|
8
8
|
import builtins
|
|
@@ -25,7 +25,7 @@ REACHES_KILL = KILL_FAMILY | SHELLS
|
|
|
25
25
|
DEADLINE_SECONDS = 6.0
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def install(port, protected):
|
|
28
|
+
def install(port, protected, token):
|
|
29
29
|
"""Wraps the cell-visible process and signal APIs; `protected` is the host's protected pid list."""
|
|
30
30
|
if getattr(subprocess.Popen.__init__, "__senpi_kill_guard__", False):
|
|
31
31
|
return
|
|
@@ -34,12 +34,13 @@ def install(port, protected):
|
|
|
34
34
|
create_connection = socket.create_connection
|
|
35
35
|
inside = contextvars.ContextVar("senpi_kill_guard_inside", default=False)
|
|
36
36
|
protected = frozenset(protected)
|
|
37
|
+
authorization = b"Authorization: Bearer " + token.encode() + b"\r\n"
|
|
37
38
|
|
|
38
39
|
def ask(request):
|
|
39
40
|
payload = dumps({**request, "vantagePid": getpid()}).encode()
|
|
40
41
|
deadline = monotonic() + DEADLINE_SECONDS
|
|
41
42
|
with create_connection(("127.0.0.1", port), timeout=DEADLINE_SECONDS) as sock:
|
|
42
|
-
sock.sendall(b"POST /kill_guard_check HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n"
|
|
43
|
+
sock.sendall(b"POST /kill_guard_check HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n" + authorization +
|
|
43
44
|
b"Content-Type: application/json\r\nContent-Length: " + str(len(payload)).encode() +
|
|
44
45
|
b"\r\n\r\n" + payload)
|
|
45
46
|
response = bytearray()
|
|
@@ -35,7 +35,7 @@ class CellPermissionError(RuntimeError):
|
|
|
35
35
|
super().__init__(f"Cell operation refused: {identity}: {reason}")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def initialize(config, port):
|
|
38
|
+
def initialize(config, port, bridge_token):
|
|
39
39
|
# The mapping and captured I/O never enter the user namespace.
|
|
40
40
|
with open(config["path"], "rb") as file:
|
|
41
41
|
words = mmap.mmap(file.fileno(), config["size"], access=mmap.ACCESS_READ)
|
|
@@ -53,6 +53,7 @@ def initialize(config, port):
|
|
|
53
53
|
family, stream = socket.AF_INET, socket.SOCK_STREAM
|
|
54
54
|
connect, sendall, recv = socket_type.connect, socket_type.sendall, socket_type.recv
|
|
55
55
|
settimeout, close = socket_type.settimeout, socket_type.close
|
|
56
|
+
authorization = b"Authorization: Bearer " + bridge_token.encode() + b"\r\n"
|
|
56
57
|
|
|
57
58
|
def rule():
|
|
58
59
|
token = context.get()
|
|
@@ -99,7 +100,7 @@ def initialize(config, port):
|
|
|
99
100
|
remaining()
|
|
100
101
|
connect(sock, ("127.0.0.1", port))
|
|
101
102
|
remaining()
|
|
102
|
-
sendall(sock, b"POST /permission_check HTTP/1.1\r\nHost: 127.0.0.1\r\n"
|
|
103
|
+
sendall(sock, b"POST /permission_check HTTP/1.1\r\nHost: 127.0.0.1\r\n" + authorization +
|
|
103
104
|
b"Connection: close\r\nContent-Type: application/json\r\nContent-Length: " +
|
|
104
105
|
str(len(payload)).encode() + b"\r\n\r\n" + payload)
|
|
105
106
|
response = bytearray()
|
|
@@ -2332,7 +2332,7 @@ def elapsed(start: float) -> int:
|
|
|
2332
2332
|
return max(0, int((time.monotonic() - start) * 1000))
|
|
2333
2333
|
|
|
2334
2334
|
|
|
2335
|
-
def _install_kill_guard(port: int) -> None:
|
|
2335
|
+
def _install_kill_guard(port: int, token: str) -> None:
|
|
2336
2336
|
# The host exports the protected pids only while the guard is on (`terminal.killGuard`); absent means off.
|
|
2337
2337
|
protected = os.environ.get("SENPI_KILL_GUARD_PROTECTED")
|
|
2338
2338
|
if protected is None:
|
|
@@ -2341,7 +2341,7 @@ def _install_kill_guard(port: int) -> None:
|
|
|
2341
2341
|
_kill_guard_path = Path(__file__).with_name("kill_guard.py")
|
|
2342
2342
|
namespace: dict[str, Any] = {"__builtins__": __builtins__, "__file__": str(_kill_guard_path)}
|
|
2343
2343
|
exec(compile(_kill_guard_path.read_bytes(), str(_kill_guard_path), "exec"), namespace)
|
|
2344
|
-
namespace["install"](port, [int(pid) for pid in protected.split(",") if pid.isdigit()])
|
|
2344
|
+
namespace["install"](port, [int(pid) for pid in protected.split(",") if pid.isdigit()], token)
|
|
2345
2345
|
|
|
2346
2346
|
|
|
2347
2347
|
def _handle_message(message: dict[str, Any]) -> bool:
|
|
@@ -2360,8 +2360,8 @@ def _handle_message(message: dict[str, Any]) -> bool:
|
|
|
2360
2360
|
if KERNEL_MEMORY.thresholds is not None:
|
|
2361
2361
|
KERNEL_MEMORY._footprint()
|
|
2362
2362
|
if message.get("permission") is not None:
|
|
2363
|
-
permission_context = initialize_permissions(message["permission"], connection["port"])
|
|
2364
|
-
_install_kill_guard(connection["port"])
|
|
2363
|
+
permission_context = initialize_permissions(message["permission"], connection["port"], connection["token"])
|
|
2364
|
+
_install_kill_guard(connection["port"], connection["token"])
|
|
2365
2365
|
emit({"type": "ready"})
|
|
2366
2366
|
return True
|
|
2367
2367
|
if message_type == "run":
|