tokensafe 4.7.22 → 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.7.22",
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.7.22",
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.7.22",
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.7.22",
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.7.22",
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.7.22",
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.7.22",
42
+ "version": "4.9.0",
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.13.0"
1379
+ _SIDECAR_RELEASE_TAG = "v0.16.0"
1380
1380
  _SIDECARS = {
1381
1381
  "spring": (
1382
1382
  "java/src/dev/tokensafe/oumv/OumvSpring.java",
1383
1383
  "OumvSpring.java",
1384
- "a4defc121be23ce2266a1f7f8cfd361d5b5b1fe7ea85f818e5f322322ab2642e",
1384
+ "28491844ab13199da0d3972420101b415a1ba5dd78067a4482fd6546932cf86c",
1385
1385
  ),
1386
1386
  "php": (
1387
1387
  "php/bin/oumv-php",
1388
1388
  "oumv-php",
1389
- "3369ee5fd03ec9b16b7eaebc33cc003033cadcb1d325b3445661eba058405b5f",
1389
+ "74301298cec2867f9e67eb35f09edc95137b15fd49b60105cc2db54bb7d07346",
1390
1390
  ),
1391
1391
  }
1392
1392
 
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.7.22"
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)",
@@ -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 and runs a real verify command. Certified Level 2 32/33 (no live request traces, L4 not advertised). Frozen at wire 1.5.0 on purpose: the handshake negotiates 1.5.0 until the 1.6.0 surface is worth implementing.",
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 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.",
780
820
  "technology": {
781
821
  "language": "java",
782
822
  "framework": "spring",
@@ -791,7 +831,14 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
791
831
  {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
792
832
  {"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
793
833
  {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
834
+ {"name": "mutate.multiFile", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
835
+ {"name": "mutate.preview", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
836
+ {"name": "index.symbols", "constraints": {"readOnly": True, "developmentOnly": False}},
837
+ {"name": "sessions.ttlSeconds", "constraints": {"readOnly": True, "developmentOnly": False}},
838
+ {"name": "sessions.cancel", "constraints": {"readOnly": True, "developmentOnly": False}},
839
+ {"name": "sessions.idempotency", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
794
840
  {"name": "verify.behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
841
+ {"name": "verify.build", "constraints": {"readOnly": False, "developmentOnly": True}},
795
842
  ],
796
843
  },
797
844
  {
@@ -802,7 +849,7 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
802
849
  "repo": "tokensafe-backend/php",
803
850
  "mode": "sidecar",
804
851
  "status": "ready",
805
- "description": "Dependency-free PHP sidecar: Laravel Route:: and Symfony #[Route] discovery, token_get_all handler ranges, php -l pre-flight, OCC edits and stdio. Certified Level 2 32/33 (no live traces). Frozen at wire 1.5.0 on purpose: the handshake negotiates 1.5.0 until the 1.6.0 surface is worth implementing.",
852
+ "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.",
806
853
  "technology": {
807
854
  "language": "php",
808
855
  "framework": "laravel | symfony",
@@ -816,7 +863,14 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
816
863
  {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
817
864
  {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
818
865
  {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
866
+ {"name": "mutate.multiFile", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
867
+ {"name": "mutate.preview", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
868
+ {"name": "index.symbols", "constraints": {"readOnly": True, "developmentOnly": False}},
869
+ {"name": "sessions.ttlSeconds", "constraints": {"readOnly": True, "developmentOnly": False}},
870
+ {"name": "sessions.cancel", "constraints": {"readOnly": True, "developmentOnly": False}},
871
+ {"name": "sessions.idempotency", "constraints": {"readOnly": False, "developmentOnly": True, "requiresPermission": "permissions.mutate != false"}},
819
872
  {"name": "verify.behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
873
+ {"name": "verify.build", "constraints": {"readOnly": False, "developmentOnly": True}},
820
874
  ],
821
875
  },
822
876
  ]
@@ -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.7.22"
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.7.22"
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