tokensafe 4.8.0 → 4.9.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.8.0",
2
+ "version": "4.9.1",
3
3
  "name": "tokensafe",
4
4
  "description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
5
5
  "author": {
package/kimi.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokensafe",
3
- "version": "4.8.0",
3
+ "version": "4.9.1",
4
4
  "description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
5
5
  "homepage": "https://tokensafe.dev",
6
6
  "license": "Apache-2.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tokensafe",
3
3
  "mcpName": "dev.tokensafe/tokensafe",
4
- "version": "4.8.0",
4
+ "version": "4.9.1",
5
5
  "description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
6
6
  "main": "bin/tokensafe.js",
7
7
  "bin": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tokensafe",
3
3
  "displayName": "TokenSafe",
4
- "version": "4.8.0",
4
+ "version": "4.9.1",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
7
7
  "logo": "assets/logo.png",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "dev.tokensafe/tokensafe",
4
4
  "title": "TokenSafe",
5
5
  "description": "Your AI agent is smart enough to code all day. Local firewall & zero-loss runtime.",
6
- "version": "4.8.0",
6
+ "version": "4.9.1",
7
7
  "websiteUrl": "https://tokensafe.dev",
8
8
  "repository": {
9
9
  "url": "https://github.com/tokensafe-dev/tokensafe",
@@ -23,7 +23,7 @@
23
23
  "registryType": "npm",
24
24
  "registryBaseUrl": "https://registry.npmjs.org",
25
25
  "identifier": "tokensafe",
26
- "version": "4.8.0",
26
+ "version": "4.9.1",
27
27
  "runtimeHint": "npx",
28
28
  "transport": {
29
29
  "type": "stdio"
@@ -39,7 +39,7 @@
39
39
  "registryType": "pypi",
40
40
  "registryBaseUrl": "https://pypi.org",
41
41
  "identifier": "tokensafe",
42
- "version": "4.8.0",
42
+ "version": "4.9.1",
43
43
  "runtimeHint": "uvx",
44
44
  "transport": {
45
45
  "type": "stdio"
@@ -1376,17 +1376,17 @@ def revert_dotnet_patch(workspace: str) -> Dict[str, Any]:
1376
1376
  # Pinned to the backend release: the sidecars are single files, so the cache is
1377
1377
  # content-addressed by SHA-256 and a clean machine downloads the exact bytes the
1378
1378
  # release was certified from. Bump both the tag and the hashes together.
1379
- _SIDECAR_RELEASE_TAG = "v0.16.0"
1379
+ _SIDECAR_RELEASE_TAG = "v0.18.0"
1380
1380
  _SIDECARS = {
1381
1381
  "spring": (
1382
1382
  "java/src/dev/tokensafe/oumv/OumvSpring.java",
1383
1383
  "OumvSpring.java",
1384
- "28491844ab13199da0d3972420101b415a1ba5dd78067a4482fd6546932cf86c",
1384
+ "7e31b52d6646e960101f24b5f4e85c89706b37ffc4252945bb112ea657b6c662",
1385
1385
  ),
1386
1386
  "php": (
1387
1387
  "php/bin/oumv-php",
1388
1388
  "oumv-php",
1389
- "74301298cec2867f9e67eb35f09edc95137b15fd49b60105cc2db54bb7d07346",
1389
+ "1ca76f6b1ed3f1a72ef18d8dbc85a54197341d6b95d47d3a7c48bf265aca4c6d",
1390
1390
  ),
1391
1391
  }
1392
1392
 
@@ -1403,11 +1403,15 @@ def sidecar_run_command(kind: str, sidecar_path: str, workspace: str) -> Optiona
1403
1403
  """The exact command that starts the sidecar against `workspace`."""
1404
1404
  if not sidecar_path:
1405
1405
  return None
1406
- # Java only knows the CLI flag; the PHP sidecar also reads OUMV_READ_ONLY,
1407
- # which run-backend sets, so its command line stays unchanged.
1406
+ # Java only knows the CLI flag; the PHP sidecar also reads OUMV_READ_ONLY and
1407
+ # OUMV_APP_URL, which run-backend sets, so its command line stays unchanged.
1408
1408
  read_only = " --read-only" if oumv_policy.current()[0] == oumv_policy.PROFILE_READ_ONLY else ""
1409
+ # Pointing a sidecar at the running app is what turns verify into a real
1410
+ # dispatch and observe L4 into recorded traces (wire 1.6.0).
1411
+ app_url = (os.environ.get("TOKENSAFE_OUMV_APP_URL") or "").strip().rstrip("/")
1412
+ dispatch = f" --app-url {app_url}" if app_url else ""
1409
1413
  if kind == "spring":
1410
- return f"tokensafe run-backend java {sidecar_path} --root {workspace} --port 7331{read_only}"
1414
+ return f"tokensafe run-backend java {sidecar_path} --root {workspace} --port 7331{read_only}{dispatch}"
1411
1415
  if kind == "php":
1412
1416
  return f"tokensafe run-backend php -S 127.0.0.1:7332 {sidecar_path} --root {workspace}"
1413
1417
  return None
package/src/mcp_server.py CHANGED
@@ -45,7 +45,7 @@ from src.session_context import current_root, current_session_id
45
45
 
46
46
  SERVER_INFO = {
47
47
  "name": "tokensafe-mcp",
48
- "version": "4.8.0"
48
+ "version": "4.9.1"
49
49
  }
50
50
 
51
51
  # MCP client attribution: the initialize handshake carries clientInfo, which
@@ -82,9 +82,20 @@ def _mcp_session_id() -> str:
82
82
  def _workspace_root() -> Optional[str]:
83
83
  """Project root for relative-path resolution.
84
84
 
85
- Session scope first, then the machine-wide marker written by lifecycle
86
- hooks. Never returns scratch space (``get_active_workspace`` filters it)."""
87
- return current_root() or get_active_workspace()
85
+ Session scope first, then this server's own spawn cwd — the host starts one
86
+ server per workspace, so cwd is per-server and race-free. The machine-wide
87
+ marker is only a fallback: it is rewritten by the hooks of *every* concurrent
88
+ session, so preferring it made a server spawned in repo A answer relative
89
+ paths (and endpoint lookups) for repo B. A spawn cwd may live in scratch
90
+ space — that is still the workspace the host asked for; the scratch filter
91
+ belongs to the marker, which must never leak a temp dir machine-wide."""
92
+ scoped = current_root()
93
+ if scoped:
94
+ return scoped
95
+ cwd = os.getcwd()
96
+ if cwd and os.path.isdir(cwd) and not is_plugin_or_system_dir(cwd):
97
+ return cwd
98
+ return get_active_workspace() or cwd or None
88
99
 
89
100
 
90
101
  def _plausible_project_root(path: Optional[str]) -> bool:
@@ -3287,7 +3298,7 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3287
3298
  elif name == "slice_external_type":
3288
3299
  pkg = str(args.get("package_name") or args.get("package") or "").strip()
3289
3300
  sym = str(args.get("symbol") or args.get("type") or args.get("type_name") or "").strip()
3290
- proj_root = str(args.get("project_root") or "").strip() or get_active_workspace() or None
3301
+ proj_root = str(args.get("project_root") or "").strip() or _workspace_root() or None
3291
3302
  if not pkg or not sym:
3292
3303
  return _fallback_error("slice_external_type", "missing required 'package_name' or 'symbol' argument")
3293
3304
  try:
@@ -91,11 +91,18 @@ def spawn_env(env: Optional[Dict[str, str]] = None) -> Dict[str, str]:
91
91
  Node/Go/.NET and the generated Python sitecustomize read
92
92
  ``TOKENSAFE_OUMV_READ_ONLY``; the PHP sidecar reads ``OUMV_READ_ONLY``. Java
93
93
  takes the CLI flag instead (see ``sidecar_run_command``).
94
+
95
+ ``TOKENSAFE_OUMV_APP_URL`` is forwarded as ``OUMV_APP_URL`` so a sidecar (PHP
96
+ in built-in-server mode) dispatches verify to the running application and
97
+ records real L4 traces instead of running only the static check.
94
98
  """
95
99
  base = dict(os.environ if env is None else env)
96
100
  if current()[0] == PROFILE_READ_ONLY:
97
101
  base["TOKENSAFE_OUMV_READ_ONLY"] = "1"
98
102
  base["OUMV_READ_ONLY"] = "1"
103
+ app_url = str(base.get("TOKENSAFE_OUMV_APP_URL") or "").strip()
104
+ if app_url:
105
+ base["OUMV_APP_URL"] = app_url
99
106
  return base
100
107
 
101
108
 
package/src/retrofit.py CHANGED
@@ -69,7 +69,18 @@ def _detect_package_json_entry(pkg_json_path: str, rel_dir: str = ".") -> Tuple[
69
69
  elif "vue" in deps:
70
70
  fe_info.update({"framework": "vue", "provider": "vue", "adapter": "tokensafe-ui/oumv/vue", "version": deps.get("vue"), "oumv_supported": has_vite, "status": "ready" if has_vite else "needs-vite"})
71
71
  elif "solid-js" in deps or "@tokensafe-ui/core" in deps:
72
- fe_info.update({"framework": "solid", "provider": "solid", "adapter": "tokensafe-ui/core", "version": deps.get("solid-js") or deps.get("@tokensafe-ui/core"), "oumv_supported": False, "status": "planned"})
72
+ # Solid has no DOM-attached component registry: the bridge reads the dev
73
+ # build's owner tree (DEV.hooks.afterCreateOwner), so it needs a Vite dev
74
+ # server like React/Vue do.
75
+ fe_info.update({
76
+ "framework": "solid",
77
+ "provider": "solid",
78
+ "adapter": "tokensafe-ui/solid",
79
+ "version": deps.get("solid-js") or deps.get("@tokensafe-ui/core"),
80
+ "oumv_supported": has_vite,
81
+ "status": "ready" if has_vite else "needs-vite",
82
+ "note": "component discovery uses the Solid dev build's owner tree; the in-page bridge is the shared bridge-core generator",
83
+ })
73
84
  elif "svelte" in deps:
74
85
  fe_info.update({"framework": "svelte", "provider": "svelte", "adapter": "tokensafe-ui/core", "version": deps.get("svelte"), "oumv_supported": False, "status": "planned"})
75
86
 
@@ -313,11 +324,12 @@ def detect_project_stack(workspace_dir: str) -> Dict[str, Any]:
313
324
  framework = "flask"
314
325
  elif "starlette" in c:
315
326
  framework = "starlette"
316
- supported = framework in ("fastapi",)
327
+ supported = framework in ("fastapi", "starlette")
317
328
  py_entry = {
318
329
  "framework": framework,
319
330
  "provider": "fastapi" if framework == "fastapi" else "python",
320
- "adapter": "tokensafe-backend/python",
331
+ "adapter": ("tokensafe-backend/starlette" if framework == "starlette"
332
+ else "tokensafe-backend/python"),
321
333
  "language": "python",
322
334
  "root": os.path.dirname(rel_pf) or ".",
323
335
  "oumv_supported": supported,
@@ -332,7 +344,7 @@ def detect_project_stack(workspace_dir: str) -> Dict[str, Any]:
332
344
  "path": py_entry["root"],
333
345
  "framework": framework,
334
346
  "provider": py_entry["provider"],
335
- "adapter": "tokensafe-backend/python",
347
+ "adapter": py_entry["adapter"],
336
348
  "oumvSupported": supported,
337
349
  "status": py_entry["status"],
338
350
  })
@@ -574,19 +586,26 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
574
586
  },
575
587
  {
576
588
  "id": "frontend/solid",
577
- "name": "SolidJS / TokenSafe UI Native Adapter",
589
+ "name": "Solid + Vite Adapter (signals, owner-tree discovery)",
578
590
  "profile": "frontend",
579
591
  "profiles": ["frontend"],
580
592
  "repo": "tokensafe-ui",
581
593
  "mode": "hybrid",
582
- "status": "planned",
583
- "description": "Planned: fine-grained reactive signals causality + virtual DOM observer. No Solid runtime adapter is implemented yet (the tokensafe-ui plugin ships React and Vue); a Solid repo must use static analysis tools instead",
594
+ "status": "ready",
595
+ "description": "Solid has no DOM-attached component registry, so the bridge reads the dev build's owner tree (DEV.hooks.afterCreateOwner) and strips vite-plugin-solid's [solid-refresh] prefix; the in-page bridge is generated by the shared bridge-core module (React, Vue and Next use the same generator). Browser-certified 47/47 Level 3 on fixtures v17, including the three browserCases.",
584
596
  "technology": {
585
597
  "language": "typescript",
586
598
  "framework": "solidjs",
587
- "package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install tokensafe-ui"},
599
+ "package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install -D tokensafe-ui @tokensafe-ui/vite"},
588
600
  },
589
- "capabilities": [],
601
+ "capabilities": [
602
+ {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": True}},
603
+ {"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": True}},
604
+ {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
605
+ {"name": "mutate.multiFile", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
606
+ {"name": "mutate.preview", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
607
+ {"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": True}},
608
+ ],
590
609
  },
591
610
  {
592
611
  "id": "frontend/vue",
@@ -655,6 +674,27 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
655
674
  {"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
656
675
  ],
657
676
  },
677
+ {
678
+ "id": "backend/starlette",
679
+ "name": "Python Starlette Adapter (plain ASGI)",
680
+ "profile": "backend",
681
+ "profiles": ["backend"],
682
+ "repo": "tokensafe-backend/python",
683
+ "mode": "hybrid",
684
+ "status": "ready",
685
+ "description": "Duck-typed Starlette binding: introspects Route/WebSocketRoute, serves HTTP/SSE/WebSocket from the same runtime as the FastAPI adapter, discovers a DB engine from app.state. Certified Level 3 48/48 over HTTP, 49/49 over WS and 52/52 over SSE on fixtures v17; the read-only profile certifies 28/28.",
686
+ "technology": {
687
+ "language": "python",
688
+ "framework": "starlette",
689
+ "package": {"manager": "pip", "name": "tokensafe-backend-python", "install": 'pip install "tokensafe-backend-python @ git+https://github.com/tokensafe-dev/tokensafe-backend.git#subdirectory=python"'},
690
+ },
691
+ "capabilities": [
692
+ {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
693
+ {"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": False}},
694
+ {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
695
+ {"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
696
+ ],
697
+ },
658
698
  {
659
699
  "id": "backend/node",
660
700
  "name": "Node.js Backend Adapter (Express, Fastify)",
@@ -776,7 +816,7 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
776
816
  "repo": "tokensafe-backend/java",
777
817
  "mode": "sidecar",
778
818
  "status": "ready",
779
- "description": "Single-file JDK sidecar: scans @RestController mappings statically, serves HTTP and stdio, applies OCC edits (single or 1..16-file atomic batch), previews without writing, searches symbols, runs a real build/verify command and negotiates session TTL/cancel/idempotency. Wire 1.6.0. Certified Level 2 44/45: the only failure is the L4 trace case, which it refuses instead of fabricating traces; the read-only profile certifies 26/26.",
819
+ "description": "Single-file JDK sidecar: scans @RestController mappings statically, serves HTTP and stdio, applies OCC edits (single or 1..16-file atomic batch), previews without writing, searches symbols, runs a real build/verify command and negotiates session TTL/cancel/idempotency. Wire 1.6.0. Certified Level 3 45/45 with --app-url: verify dispatches to the running Spring app and the real responses become L4 traces (without --app-url it answers L4 with -32006 and attains Level 2); the read-only profile certifies 26/26.",
780
820
  "technology": {
781
821
  "language": "java",
782
822
  "framework": "spring",
@@ -789,7 +829,9 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
789
829
  "capabilities": [
790
830
  {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
791
831
  {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
832
+ {"name": "observe.traces", "constraints": {"readOnly": True, "developmentOnly": False, "requiresConfig": "TOKENSAFE_OUMV_APP_URL (verify dispatches to the running app; without it L4 is -32006)"}},
792
833
  {"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
834
+ {"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": False, "requiresConfig": "TOKENSAFE_OUMV_APP_URL"}},
793
835
  {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
794
836
  {"name": "mutate.multiFile", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
795
837
  {"name": "mutate.preview", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
@@ -809,7 +851,7 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
809
851
  "repo": "tokensafe-backend/php",
810
852
  "mode": "sidecar",
811
853
  "status": "ready",
812
- "description": "Dependency-free PHP sidecar: Laravel Route:: and Symfony #[Route] discovery, token_get_all handler ranges, php -l pre-flight, OCC edits (single or 1..16-file atomic batch), preview, symbol index, build command and session TTL/cancel/idempotency. Wire 1.6.0. Certified Level 3 41/41; the read-only profile certifies 26/26.",
854
+ "description": "Dependency-free PHP sidecar: Laravel Route:: and Symfony #[Route] discovery, token_get_all handler ranges, php -l pre-flight, OCC edits (single or 1..16-file atomic batch), preview, symbol index, build command and session TTL/cancel/idempotency. Wire 1.6.0. Certified Level 3 45/45 with --app-url: verify dispatches to the running Laravel app and the real responses become L4 traces (without --app-url it answers L4 with -32006); the read-only profile certifies 26/26.",
813
855
  "technology": {
814
856
  "language": "php",
815
857
  "framework": "laravel | symfony",
@@ -822,6 +864,9 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
822
864
  "capabilities": [
823
865
  {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
824
866
  {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
867
+ {"name": "observe.traces", "constraints": {"readOnly": True, "developmentOnly": False, "requiresConfig": "TOKENSAFE_OUMV_APP_URL (verify dispatches to the running app; without it L4 is -32006)"}},
868
+ {"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
869
+ {"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": False, "requiresConfig": "TOKENSAFE_OUMV_APP_URL"}},
825
870
  {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
826
871
  {"name": "mutate.multiFile", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
827
872
  {"name": "mutate.preview", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
@@ -24,6 +24,11 @@ _FRONTEND_LINES = {
24
24
  "(zero repo footprint, L0-L4, OCC edits). Call tokensafe:oumv(action='observe', level='L1') "
25
25
  "before reading files; run `tokensafe dev` if no runtime is live."
26
26
  ),
27
+ "solid": (
28
+ "frontend solid/{framework}: OUMV live via `tokensafe dev --framework solid` "
29
+ "(zero repo footprint, L0-L4, OCC edits; certified L3 in a browser). Call "
30
+ "tokensafe:oumv(action='observe', level='L1') before reading files."
31
+ ),
27
32
  "vue": (
28
33
  "frontend {provider}/{framework}: OUMV live via `tokensafe dev --framework vue` "
29
34
  "(zero repo footprint, L0-L4, OCC edits; certified L3 in a browser). Call "
@@ -48,6 +53,11 @@ _BACKEND_LINES = {
48
53
  "(`mountTokensafe(app)` for Express, `registerTokensafe(app)` for Fastify); "
49
54
  "then use tokensafe:oumv for endpoints/impact and oumv_verify for live checks."
50
55
  ),
56
+ "python": (
57
+ "backend python/{framework}: install `tokensafe-backend-python` and mount the adapter "
58
+ "(`mount_tokensafe(app)` for FastAPI, `mount_tokensafe_starlette(app)` for Starlette); "
59
+ "then use tokensafe:oumv for endpoints/impact and oumv_verify for live checks."
60
+ ),
51
61
  "elysia": (
52
62
  "backend elysia/{framework} (Bun): install `tokensafe-backend-node` and add "
53
63
  "`app.use(require('tokensafe-backend-node/elysia').oumv())` before `app.listen()`; "
@@ -311,7 +311,7 @@ class TelemetrySync:
311
311
  current_last_id = last_id
312
312
  headers = {
313
313
  "Content-Type": "application/json",
314
- "User-Agent": "TokenSafe-Sync/4.8.0"
314
+ "User-Agent": "TokenSafe-Sync/4.9.1"
315
315
  }
316
316
  if active_key:
317
317
  headers["Authorization"] = f"Bearer {active_key}"
@@ -17,7 +17,7 @@ import urllib.request
17
17
  import urllib.error
18
18
  from typing import Dict, Any, Optional, Tuple
19
19
 
20
- CURRENT_VERSION = "4.8.0"
20
+ CURRENT_VERSION = "4.9.1"
21
21
  CACHE_TTL = 86400 # 24 hours
22
22
  # When the cloud is unreachable we must NOT cache the synthesized "up to date"
23
23
  # answer for a full day — otherwise an update released right after an outage