tokensafe 4.8.0 → 4.9.0

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.0",
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.0",
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.0",
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.0",
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.0",
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.0",
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.0",
43
43
  "runtimeHint": "uvx",
44
44
  "transport": {
45
45
  "type": "stdio"
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.0"
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:
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)",
@@ -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.0"
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.0"
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