tokensafe 4.7.5 → 4.7.7

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.5",
2
+ "version": "4.7.7",
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.5",
3
+ "version": "4.7.7",
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.5",
4
+ "version": "4.7.7",
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.5",
4
+ "version": "4.7.7",
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.5",
6
+ "version": "4.7.7",
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.5",
26
+ "version": "4.7.7",
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.5",
42
+ "version": "4.7.7",
43
43
  "runtimeHint": "uvx",
44
44
  "transport": {
45
45
  "type": "stdio"
@@ -233,7 +233,17 @@ def go_patch_state(workspace: str) -> Dict[str, Any]:
233
233
 
234
234
 
235
235
  _GO_MODULE = "github.com/tokensafe-dev/tokensafe-backend/go"
236
- _GO_MODULE_VERSION = "v0.4.3"
236
+ # Keep in step with the backend release tag (go/vX.Y.Z): injection must never
237
+ # downgrade an adapter that is already newer than this pin.
238
+ _GO_MODULE_VERSION = "v0.6.0"
239
+
240
+
241
+ def _version_tuple(tag: str):
242
+ """`v1.2.3` -> (1, 2, 3); raises ValueError when the tag is not semver."""
243
+ parts = tag.lstrip("v").split(".")
244
+ if len(parts) < 2:
245
+ raise ValueError(tag)
246
+ return tuple(int(part) for part in parts[:3] + ["0"] * (3 - len(parts[:3])))
237
247
 
238
248
 
239
249
  def _ensure_go_dependency(workspace: str) -> Optional[str]:
@@ -247,10 +257,10 @@ def _ensure_go_dependency(workspace: str) -> Optional[str]:
247
257
  except OSError as exc:
248
258
  return f"cannot read go.mod: {exc}"
249
259
 
250
- # Skip only when the pinned version is already required; an older requirement
251
- # would build against an adapter that lacks AutoMount.
260
+ # Never downgrade: a project already on a newer go/v* tag keeps it, and an
261
+ # older requirement is raised to the pin.
252
262
  match = re.search(re.escape(_GO_MODULE) + r"\s+v([0-9][\w.+-]*)", content)
253
- if match and f"v{match.group(1)}" == _GO_MODULE_VERSION:
263
+ if match and _version_tuple(f"v{match.group(1)}") >= _version_tuple(_GO_MODULE_VERSION):
254
264
  return None
255
265
 
256
266
  go_bin = shutil.which("go")
@@ -502,6 +512,181 @@ def revert_go_patch(workspace: str) -> Dict[str, Any]:
502
512
  # Plan / apply / revert for the CLI and the first-prompt hook
503
513
  # --------------------------------------------------------------------------- #
504
514
 
515
+ def _find_node_entrypoint(workspace: str) -> Optional[str]:
516
+ """Finds the Node entry file that creates the framework app."""
517
+ candidates: List[str] = []
518
+ pkg_path = os.path.join(workspace, "package.json")
519
+ try:
520
+ with open(pkg_path, "r", encoding="utf-8") as f:
521
+ pkg = json.load(f)
522
+ main = pkg.get("main")
523
+ if isinstance(main, str) and main:
524
+ candidates.append(main)
525
+ except Exception:
526
+ pass
527
+ candidates += ["src/index.js", "src/server.js", "src/app.js", "index.js", "server.js", "app.js"]
528
+ for rel in candidates:
529
+ path = os.path.join(workspace, rel)
530
+ if os.path.isfile(path):
531
+ return path
532
+ return None
533
+
534
+
535
+ def _node_framework_of(workspace: str) -> Optional[str]:
536
+ try:
537
+ with open(os.path.join(workspace, "package.json"), "r", encoding="utf-8") as f:
538
+ pkg = json.load(f)
539
+ deps = {**(pkg.get("dependencies") or {}), **(pkg.get("devDependencies") or {})}
540
+ except Exception:
541
+ return None
542
+ if "fastify" in deps:
543
+ return "fastify"
544
+ if "express" in deps:
545
+ return "express"
546
+ return None
547
+
548
+
549
+ def node_patch_state(workspace: str) -> Dict[str, Any]:
550
+ """Reports whether the one-line OUMV mount is already in the Node entrypoint."""
551
+ path = _find_node_entrypoint(workspace)
552
+ if not path:
553
+ return {"entrypoint": None, "patched": False, "framework": _node_framework_of(workspace)}
554
+ try:
555
+ with open(path, "r", encoding="utf-8") as f:
556
+ source = f.read()
557
+ except OSError:
558
+ return {"entrypoint": path, "patched": False, "framework": _node_framework_of(workspace)}
559
+ return {
560
+ "entrypoint": os.path.relpath(path, workspace),
561
+ "patched": _MARK_BEGIN in source and _MARK_END in source,
562
+ "framework": _node_framework_of(workspace),
563
+ }
564
+
565
+
566
+ def apply_node_patch(workspace: str, dry_run: bool = False) -> Dict[str, Any]:
567
+ """Inserts one mount line between tokensafe markers, with a byte-exact backup."""
568
+ framework = _node_framework_of(workspace)
569
+ path = _find_node_entrypoint(workspace)
570
+ if framework not in ("express", "fastify"):
571
+ return {"status": "skipped", "reason": "no supported Node framework (express/fastify) found"}
572
+ if not path:
573
+ return {"status": "skipped", "reason": "no Node entrypoint found"}
574
+
575
+ with open(path, "r", encoding="utf-8") as f:
576
+ source = f.read()
577
+ if _MARK_BEGIN in source:
578
+ return {"status": "already_patched", "entrypoint": os.path.relpath(path, workspace)}
579
+
580
+ if framework == "express":
581
+ pattern = re.compile(r"(?m)^(?P<indent>[ \t]*)(?:const|let|var)\s+\w+\s*=\s*express\(\)[ \t]*;?[ \t]*$")
582
+ mount = (
583
+ f"{_MARK_BEGIN}\n"
584
+ "require('tokensafe-backend-node').mountTokensafe(app);\n"
585
+ f"{_MARK_END}\n"
586
+ )
587
+ else:
588
+ pattern = re.compile(r"(?m)^(?P<indent>[ \t]*)(?:const|let|var)\s+(?P<var>\w+)\s*=\s*(?:Fastify|fastify)\([^)]*\)[ \t]*;?[ \t]*$")
589
+ mount = (
590
+ f"{_MARK_BEGIN}\n"
591
+ "void require('tokensafe-backend-node').registerTokensafe(app);\n"
592
+ f"{_MARK_END}\n"
593
+ )
594
+
595
+ found = pattern.search(source)
596
+ if not found:
597
+ return {
598
+ "status": "skipped",
599
+ "reason": f"could not find `{framework}(...)` assignment in {os.path.relpath(path, workspace)}",
600
+ }
601
+
602
+ line_end = source.find("\n", found.end())
603
+ insert_at = len(source) if line_end < 0 else line_end + 1
604
+ patched = source[:insert_at] + mount + source[insert_at:]
605
+
606
+ if dry_run:
607
+ return {"status": "dry_run", "entrypoint": os.path.relpath(path, workspace), "preview": mount.strip()}
608
+
609
+ backup_dir = _inject_dir(workspace)
610
+ os.makedirs(backup_dir, exist_ok=True)
611
+ backup_path = os.path.join(backup_dir, os.path.relpath(path, workspace).replace(os.sep, "__") + ".bak")
612
+ shutil.copy2(path, backup_path)
613
+ with open(path, "w", encoding="utf-8") as f:
614
+ f.write(patched)
615
+ with open(os.path.join(backup_dir, "manifest.json"), "w", encoding="utf-8") as f:
616
+ json.dump({"entrypoint": path, "backup": backup_path, "framework": framework, "mode": "node_mount"}, f, indent=2)
617
+ return {
618
+ "status": "patched",
619
+ "entrypoint": os.path.relpath(path, workspace),
620
+ "framework": framework,
621
+ "mode": "node_mount",
622
+ "backup": backup_path,
623
+ "line": mount.splitlines()[1],
624
+ }
625
+
626
+
627
+ def revert_node_patch(workspace: str) -> Dict[str, Any]:
628
+ manifest_path = os.path.join(_inject_dir(workspace), "manifest.json")
629
+ if not os.path.isfile(manifest_path):
630
+ return {"status": "clean", "reason": "no Node patch manifest"}
631
+ try:
632
+ with open(manifest_path, "r", encoding="utf-8") as f:
633
+ manifest = json.load(f)
634
+ except Exception as exc:
635
+ return {"status": "error", "reason": f"cannot read manifest: {exc}"}
636
+ if manifest.get("mode") != "node_mount":
637
+ return {"status": "clean", "reason": "manifest is not a Node patch"}
638
+ entrypoint = manifest.get("entrypoint")
639
+ backup = manifest.get("backup")
640
+ if not (entrypoint and backup and os.path.isfile(backup)):
641
+ return {"status": "error", "reason": "backup missing; restore manually"}
642
+ shutil.copy2(backup, entrypoint)
643
+ os.unlink(manifest_path)
644
+ return {"status": "reverted", "entrypoint": os.path.relpath(entrypoint, workspace)}
645
+
646
+
647
+ def _sidecar_cache_dir() -> str:
648
+ return os.path.join(_tokensafe_home(), "sidecars")
649
+
650
+
651
+ def ensure_sidecar(kind: str) -> Tuple[Optional[str], str]:
652
+ """Copies OumvSpring.java / oumv-php into ~/.tokensafe/sidecars.
653
+
654
+ Prefers a local backend checkout (OUMV_BACKEND_REPO or a sibling directory);
655
+ returns (path, note) where path is None when the source is not available.
656
+ """
657
+ source_map = {
658
+ "spring": ("java/src/dev/tokensafe/oumv/OumvSpring.java", "OumvSpring.java"),
659
+ "php": ("php/bin/oumv-php", "oumv-php"),
660
+ }
661
+ if kind not in source_map:
662
+ return None, f"unknown sidecar {kind!r}"
663
+ rel_source, filename = source_map[kind]
664
+
665
+ repo_candidates = []
666
+ env_repo = os.environ.get("OUMV_BACKEND_REPO")
667
+ if env_repo:
668
+ repo_candidates.append(env_repo)
669
+ here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
670
+ repo_candidates += [
671
+ os.path.join(os.path.dirname(here), "tokensafe-backend"),
672
+ os.path.join(here, "..", "tokensafe-backend"),
673
+ ]
674
+ for repo in repo_candidates:
675
+ candidate = os.path.join(os.path.abspath(repo), rel_source)
676
+ if os.path.isfile(candidate):
677
+ cache_dir = _sidecar_cache_dir()
678
+ os.makedirs(cache_dir, exist_ok=True)
679
+ target = os.path.join(cache_dir, filename)
680
+ shutil.copy2(candidate, target)
681
+ if kind == "php":
682
+ os.chmod(target, 0o755)
683
+ return target, f"cached from {candidate}"
684
+ return None, (
685
+ "sidecar source not found: set OUMV_BACKEND_REPO to a tokensafe-backend "
686
+ "checkout or clone it next to this one"
687
+ )
688
+
689
+
505
690
  def plan(workspace: str) -> Dict[str, Any]:
506
691
  """Describes what apply would do, without touching anything."""
507
692
  stack = detect_project_stack(workspace)
@@ -523,8 +708,15 @@ def plan(workspace: str) -> Dict[str, Any]:
523
708
  backend = stack.get("backend")
524
709
  if backend:
525
710
  provider = backend.get("provider")
526
- entry_id = "backend/fastapi" if provider == "fastapi" else "backend/go"
711
+ entry_id = {
712
+ "fastapi": "backend/fastapi",
713
+ "go": "backend/go",
714
+ "node": "backend/node",
715
+ "spring": "backend/spring",
716
+ "php": "backend/php",
717
+ }.get(provider, "backend/go")
527
718
  entry = catalog.get(entry_id, {})
719
+ install = entry.get("technology", {}).get("package", {}).get("install")
528
720
  if provider == "fastapi":
529
721
  actions.append({
530
722
  "kind": "python_autoload",
@@ -532,7 +724,7 @@ def plan(workspace: str) -> Dict[str, Any]:
532
724
  "framework": "fastapi",
533
725
  "writes_repo": False,
534
726
  "description": "sitecustomize patches uvicorn; mount_tokensafe(app) runs on import",
535
- "install": entry.get("technology", {}).get("package", {}).get("install", 'pip install "tokensafe-backend-python @ git+https://github.com/tokensafe-dev/tokensafe-backend.git#subdirectory=python"'),
727
+ "install": install or 'pip install "tokensafe-backend-python @ git+https://github.com/tokensafe-dev/tokensafe-backend.git#subdirectory=python"',
536
728
  "run": python_run_hint(workspace),
537
729
  })
538
730
  elif provider == "go":
@@ -545,7 +737,36 @@ def plan(workspace: str) -> Dict[str, Any]:
545
737
  "already_patched": state["patched"],
546
738
  "entrypoint": state["entrypoint"],
547
739
  "description": "one AutoMount() line between tokensafe markers; byte-exact backup + --revert",
548
- "install": entry.get("technology", {}).get("package", {}).get("install"),
740
+ "install": install,
741
+ })
742
+ elif provider == "node":
743
+ state = node_patch_state(workspace)
744
+ actions.append({
745
+ "kind": "node_one_line_patch",
746
+ "profile": "backend",
747
+ "framework": state.get("framework") or backend.get("framework"),
748
+ "writes_repo": True,
749
+ "already_patched": state["patched"],
750
+ "entrypoint": state["entrypoint"],
751
+ "description": "one mountTokensafe(app)/registerTokensafe(app) line between tokensafe markers; byte-exact backup + --revert",
752
+ "install": install or "npm install tokensafe-backend-node",
753
+ })
754
+ elif provider in ("spring", "php"):
755
+ sidecar_path, note = ensure_sidecar(provider)
756
+ command = (
757
+ f"tokensafe run-backend java {sidecar_path}"
758
+ if provider == "spring" and sidecar_path
759
+ else (f"tokensafe run-backend {sidecar_path}" if sidecar_path else None)
760
+ )
761
+ actions.append({
762
+ "kind": "sidecar",
763
+ "profile": "backend",
764
+ "framework": backend.get("framework", provider),
765
+ "writes_repo": False,
766
+ "sidecar": sidecar_path,
767
+ "install": note,
768
+ "run": command,
769
+ "description": "static route scan + OCC edits + verify through the single-file sidecar; nothing is written into the project",
549
770
  })
550
771
  else:
551
772
  actions.append({
@@ -595,9 +816,28 @@ def apply(workspace: str, dry_run: bool = False, include_go: bool = True) -> Dic
595
816
 
596
817
  if backend.get("provider") == "go" and include_go:
597
818
  results["actions"].append({"kind": "go_one_line_patch", **apply_go_patch(workspace, dry_run=dry_run)})
819
+ elif backend.get("provider") == "node":
820
+ results["actions"].append({"kind": "node_one_line_patch", **apply_node_patch(workspace, dry_run=dry_run)})
821
+ elif backend.get("provider") in ("spring", "php"):
822
+ sidecar_path, note = ensure_sidecar(backend["provider"])
823
+ results["actions"].append({
824
+ "kind": "sidecar",
825
+ "status": "ready" if sidecar_path else "needs-source",
826
+ "sidecar": sidecar_path,
827
+ "note": note,
828
+ "run": (
829
+ f"tokensafe run-backend java {sidecar_path}"
830
+ if backend["provider"] == "spring" and sidecar_path
831
+ else (f"tokensafe run-backend {sidecar_path}" if sidecar_path else None)
832
+ ),
833
+ })
598
834
 
599
835
  return results
600
836
 
601
837
 
602
838
  def revert(workspace: str) -> Dict[str, Any]:
603
- return {"workspace": workspace, "go": revert_go_patch(workspace)}
839
+ return {
840
+ "workspace": workspace,
841
+ "go": revert_go_patch(workspace),
842
+ "node": revert_node_patch(workspace),
843
+ }
package/src/cli.py CHANGED
@@ -903,7 +903,7 @@ def main(argv: Optional[List[str]] = None):
903
903
  cmd, source = resolve_zero_footprint_vite_command(
904
904
  target_dir, port=port_val, host=host_val, open_browser=open_browser
905
905
  )
906
- print(f"⚡ Launching Zero-Footprint Vite+React OUMV server ({source})...")
906
+ print(f"⚡ Launching Zero-Footprint Vite OUMV server ({source})...")
907
907
  proc = subprocess.run(cmd, cwd=target_dir)
908
908
  sys.exit(proc.returncode)
909
909
 
package/src/installer.py CHANGED
@@ -2818,16 +2818,9 @@ WantedBy=default.target
2818
2818
  except Exception:
2819
2819
  pass
2820
2820
 
2821
- if pip_cmd:
2822
- try:
2823
- res = subprocess.run([pip_cmd, "list"], capture_output=True, text=True, timeout=10)
2824
- if "tokensafe-python" in (res.stdout or ""):
2825
- print(f" {CYAN}→{RESET} Updating backend package ({pip_cmd} install --upgrade tokensafe-python)...")
2826
- up_res = subprocess.run([pip_cmd, "install", "--upgrade", "tokensafe-python"], capture_output=True, text=True, timeout=120)
2827
- if up_res.returncode == 0:
2828
- print(f" {GREEN}✔{RESET} tokensafe-python upgraded successfully.")
2829
- except Exception:
2830
- pass
2821
+ # The Python backend runtime is installed per project from git
2822
+ # (`tokensafe-backend-python @ git+…`), not as a global pip distribution —
2823
+ # there is no `tokensafe-python` package to upgrade here.
2831
2824
 
2832
2825
  # Project-level dependencies update (if inside a TokenSafe project)
2833
2826
  cwd = os.getcwd()
@@ -2846,18 +2839,7 @@ WantedBy=default.target
2846
2839
  except Exception:
2847
2840
  pass
2848
2841
 
2849
- for cand_py in [os.path.join(cwd, "pyproject.toml"), os.path.join(cwd, "backend", "pyproject.toml")]:
2850
- if os.path.isfile(cand_py):
2851
- try:
2852
- with open(cand_py, "r", encoding="utf-8") as f:
2853
- txt = f.read()
2854
- if "tokensafe-python" in txt and pip_cmd:
2855
- pdir = os.path.dirname(cand_py)
2856
- print(f" {CYAN}→{RESET} Updating local tokensafe-python in {pdir}...")
2857
- subprocess.run([pip_cmd, "install", "--upgrade", "tokensafe-python"], cwd=pdir, capture_output=True, text=True, timeout=60)
2858
- print(f" {GREEN}✔{RESET} Local tokensafe-python updated.")
2859
- except Exception:
2860
- pass
2842
+ # Per-project Python backend installs come from git; nothing global to update.
2861
2843
 
2862
2844
  # 4. Re-synchronize active/configured agents using the FRESHLY upgraded binary when available
2863
2845
  # (so plugins, hooks, skills, and rules come from the new release instead of the old process).
package/src/mcp_server.py CHANGED
@@ -44,7 +44,7 @@ from src.session_context import current_root, current_session_id
44
44
 
45
45
  SERVER_INFO = {
46
46
  "name": "tokensafe-mcp",
47
- "version": "4.7.5"
47
+ "version": "4.7.7"
48
48
  }
49
49
 
50
50
  # MCP client attribution: the initialize handshake carries clientInfo, which
@@ -430,7 +430,8 @@ FULL_TOOLS = [ { 'annotations': {'readOnlyHint': True},
430
430
  'target': { 'description': "Target component ID, route (e.g. 'POST "
431
431
  "/api/products'), or DOM element "
432
432
  "('#submit-btn')",
433
- 'type': 'string'}},
433
+ 'type': 'string'},
434
+ 'workspace_dir': {'type': 'string'}},
434
435
  'type': 'object'},
435
436
  'name': 'oumv_observe'},
436
437
  { 'annotations': {'readOnlyHint': True},
@@ -448,7 +449,8 @@ FULL_TOOLS = [ { 'annotations': {'readOnlyHint': True},
448
449
  'type': 'string'},
449
450
  'target': { 'description': 'Target component ID, state key, endpoint, '
450
451
  'or UI element',
451
- 'type': 'string'}},
452
+ 'type': 'string'},
453
+ 'workspace_dir': {'type': 'string'}},
452
454
  'type': 'object'},
453
455
  'name': 'oumv_understand'},
454
456
  { 'annotations': {'destructiveHint': False, 'readOnlyHint': False},
@@ -467,7 +469,8 @@ FULL_TOOLS = [ { 'annotations': {'readOnlyHint': True},
467
469
  "'backend', or 'auto')",
468
470
  'enum': ['frontend', 'backend', 'auto'],
469
471
  'type': 'string'},
470
- 'symbol': {'description': 'Target symbol to edit', 'type': 'string'}},
472
+ 'symbol': {'description': 'Target symbol to edit', 'type': 'string'},
473
+ 'workspace_dir': {'type': 'string'}},
471
474
  'required': ['path'],
472
475
  'type': 'object'},
473
476
  'name': 'oumv_mutate'},
@@ -486,9 +489,19 @@ FULL_TOOLS = [ { 'annotations': {'readOnlyHint': True},
486
489
  "'backend', or 'auto')",
487
490
  'enum': ['frontend', 'backend', 'auto'],
488
491
  'type': 'string'},
492
+ 'sandbox': { 'description': 'Transactional sandbox (backend only): '
493
+ '{"mode": "rollback"} runs the whole '
494
+ 'verify in one transaction and rolls it '
495
+ 'back; the result reports rolledBack, '
496
+ 'rollbackStatus and dbDiff',
497
+ 'properties': { 'mode': {'enum': ['rollback'],
498
+ 'type': 'string'}},
499
+ 'required': ['mode'],
500
+ 'type': 'object'},
489
501
  'target': { 'description': "Action target (component ID, e.g. 'cart', "
490
502
  "or 'POST /api/v1/orders' or '#submit-btn')",
491
- 'type': 'string'}},
503
+ 'type': 'string'},
504
+ 'workspace_dir': {'type': 'string'}},
492
505
  'required': ['target'],
493
506
  'type': 'object'},
494
507
  'name': 'oumv_verify'},
@@ -503,7 +516,8 @@ FULL_TOOLS = [ { 'annotations': {'readOnlyHint': True},
503
516
  'type': 'string'},
504
517
  'target': { 'description': "Target resource (e.g. '/api/orders' or "
505
518
  "'POST /api/orders')",
506
- 'type': 'string'}},
519
+ 'type': 'string'},
520
+ 'workspace_dir': {'type': 'string'}},
507
521
  'type': 'object'},
508
522
  'name': 'oumv_graph'},
509
523
  { 'annotations': {'readOnlyHint': False, 'destructiveHint': False},
@@ -780,7 +794,11 @@ TOOLS = [{'name': 'smart_read_file',
780
794
  'replacement': {'type': 'string'},
781
795
  'expectedVersion': {'type': 'string'},
782
796
  'verify_action': {'type': 'string'},
783
- 'payload': {'type': 'object'}}}},
797
+ 'payload': {'type': 'object'},
798
+ 'workspace_dir': {'type': 'string',
799
+ 'description': 'Target repo root; for '
800
+ 'status/observe/understand/verify/graph '
801
+ 'also accepted as path'}}}},
784
802
  {'name': 'run_helper',
785
803
  'annotations': {'readOnlyHint': False},
786
804
  'description': "Utilities: 'sanitize','guard','diff','deps','web','expand','image','compress'.",
@@ -1007,6 +1025,68 @@ def _resolve_project_root(args: dict) -> Tuple[Optional[str], Optional[str]]:
1007
1025
 
1008
1026
  return None, "Error: Invalid or root project_path. Please specify an explicit 'project_path' pointing to your project directory (e.g. project_path='/path/to/project')."
1009
1027
 
1028
+
1029
+ def _shared_batch_root(paths: List[str], real_cwd: str) -> Optional[str]:
1030
+ """Narrowest project directory that contains every absolute sub-query path.
1031
+
1032
+ Batch search is one root per call. When every explicit sub-query path lives
1033
+ outside the current root but inside one repo, that repo IS the root: rebasing
1034
+ there beats failing the call (agents batch a second checkout this way). Paths
1035
+ that share only a wide parent — the directory that also holds the current
1036
+ root, or two sibling repos — return None so the caller keeps the split rule.
1037
+ """
1038
+ try:
1039
+ shared = os.path.commonpath(paths)
1040
+ except ValueError:
1041
+ return None
1042
+ if os.path.isfile(shared):
1043
+ shared = os.path.dirname(shared)
1044
+ if not shared or shared == os.path.abspath(os.sep) or not os.path.isdir(shared):
1045
+ return None
1046
+
1047
+ def _swallows_cwd(candidate: str) -> bool:
1048
+ try:
1049
+ return os.path.commonpath([real_cwd, candidate]) == candidate
1050
+ except ValueError:
1051
+ return False
1052
+
1053
+ if _swallows_cwd(shared):
1054
+ return None
1055
+ # Prefer the enclosing project root, so a batch of sub-paths searches its
1056
+ # repo instead of just their common sub-directory.
1057
+ try:
1058
+ from src.graph_engine import GraphEngine
1059
+ shared = GraphEngine.find_project_root(shared)
1060
+ except Exception:
1061
+ pass
1062
+ if not os.path.isdir(shared) or _swallows_cwd(shared) or is_plugin_or_system_dir(shared):
1063
+ return None
1064
+ return shared
1065
+
1066
+
1067
+ def _oumv_workspace_arg(args: dict, allow_path: bool = False) -> Tuple[Optional[str], Optional[str]]:
1068
+ """Validated workspace root for an OUMV call; None means "use the active one".
1069
+
1070
+ The MCP server inherits the host process cwd, so without this an explicit
1071
+ target repo was either dropped (unadvertised property) or ignored, and the
1072
+ answer described the bound workspace. A root that does not exist now fails
1073
+ closed instead of reporting another repo's stack.
1074
+ """
1075
+ raw = str(args.get("workspace_dir") or "").strip()
1076
+ if not raw and allow_path:
1077
+ raw = str(args.get("path") or "").strip()
1078
+ if not raw:
1079
+ return None, None
1080
+ ws = os.path.abspath(raw)
1081
+ if os.path.isfile(ws):
1082
+ ws = os.path.dirname(ws)
1083
+ if not os.path.isdir(ws):
1084
+ return None, f"workspace_dir not found or not a directory: '{raw}'"
1085
+ if is_plugin_or_system_dir(ws):
1086
+ return None, f"refusing to use system root or plugin dir as workspace: '{ws}'"
1087
+ return ws, None
1088
+
1089
+
1010
1090
  MCP_TOOL_TIMEOUT = float(os.environ.get("TOKENSAFE_MCP_TIMEOUT", "8.0"))
1011
1091
 
1012
1092
 
@@ -1869,6 +1949,18 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
1869
1949
  action = str(args.get("action") or "status").strip().lower()
1870
1950
  if action not in _OUMV_ACTIONS:
1871
1951
  return _fallback_error("oumv", f"unknown action '{action}'")
1952
+ # Target-repo routing: the MCP server inherits the host's cwd, so an agent
1953
+ # inspecting a second repo (workspace_dir, or `path` for the read actions)
1954
+ # used to get the bound workspace's stack back with no error — a silently
1955
+ # wrong answer. Resolve the explicit root here and fail closed on a bad one.
1956
+ ws, ws_err = _oumv_workspace_arg(
1957
+ args,
1958
+ allow_path=action in ("status", "observe", "understand", "verify", "graph"),
1959
+ )
1960
+ if ws_err:
1961
+ return _fallback_error("oumv", ws_err)
1962
+ if ws:
1963
+ args = dict(args, workspace_dir=ws)
1872
1964
  mapped = _OUMV_ACTIONS[action]
1873
1965
  if action == "verify":
1874
1966
  args = dict(args, action=args.get("verify_action") or "invoke")
@@ -3149,7 +3241,10 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3149
3241
  elif name == "oumv_status":
3150
3242
  try:
3151
3243
  from src.oumv_gateway import OUMVGateway
3152
- ws = str(args.get("workspace_dir") or "").strip() or get_active_workspace() or os.getcwd()
3244
+ ws, ws_err = _oumv_workspace_arg(args, allow_path=True)
3245
+ if ws_err:
3246
+ return _fallback_error("oumv_status", ws_err)
3247
+ ws = ws or get_active_workspace() or os.getcwd()
3153
3248
  res = OUMVGateway.status(workspace_dir=ws)
3154
3249
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3155
3250
  except Exception as e:
@@ -3161,7 +3256,9 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3161
3256
  lvl = str(args.get("level") or "L0").strip()
3162
3257
  tgt = str(args.get("target") or "").strip() or None
3163
3258
  rt = str(args.get("runtime") or "auto").strip()
3164
- ws = str(args.get("workspace_dir") or "").strip() or None
3259
+ ws, ws_err = _oumv_workspace_arg(args)
3260
+ if ws_err:
3261
+ return _fallback_error("oumv_observe", ws_err)
3165
3262
  res = OUMVGateway.observe(level=lvl, target=tgt, runtime=rt, workspace_dir=ws)
3166
3263
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3167
3264
  except Exception as e:
@@ -3173,7 +3270,9 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3173
3270
  qry = str(args.get("query") or "causality").strip()
3174
3271
  tgt = str(args.get("target") or "").strip() or None
3175
3272
  rt = str(args.get("runtime") or "auto").strip()
3176
- ws = str(args.get("workspace_dir") or "").strip() or None
3273
+ ws, ws_err = _oumv_workspace_arg(args)
3274
+ if ws_err:
3275
+ return _fallback_error("oumv_understand", ws_err)
3177
3276
  res = OUMVGateway.understand(query=qry, target=tgt, runtime=rt, workspace_dir=ws)
3178
3277
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3179
3278
  except Exception as e:
@@ -3187,7 +3286,9 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3187
3286
  rep = args.get("replacement")
3188
3287
  ev = str(args.get("expectedVersion") or "").strip() or None
3189
3288
  rt = str(args.get("runtime") or "auto").strip()
3190
- ws = str(args.get("workspace_dir") or "").strip() or None
3289
+ ws, ws_err = _oumv_workspace_arg(args)
3290
+ if ws_err:
3291
+ return _fallback_error("oumv_mutate", ws_err)
3191
3292
  res = OUMVGateway.mutate(path=p, symbol=sym, replacement=rep, expected_version=ev, runtime=rt, workspace_dir=ws)
3192
3293
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3193
3294
  except Exception as e:
@@ -3200,8 +3301,11 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3200
3301
  act = str(args.get("action") or "invoke").strip()
3201
3302
  payload = args.get("payload") if isinstance(args.get("payload"), dict) else None
3202
3303
  rt = str(args.get("runtime") or "auto").strip()
3203
- ws = str(args.get("workspace_dir") or "").strip() or None
3204
- res = OUMVGateway.verify(target=tgt, action=act, payload=payload, runtime=rt, workspace_dir=ws)
3304
+ ws, ws_err = _oumv_workspace_arg(args)
3305
+ if ws_err:
3306
+ return _fallback_error("oumv_verify", ws_err)
3307
+ sandbox = args.get("sandbox") if isinstance(args.get("sandbox"), dict) else None
3308
+ res = OUMVGateway.verify(target=tgt, action=act, payload=payload, runtime=rt, workspace_dir=ws, sandbox=sandbox)
3205
3309
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3206
3310
  except Exception as e:
3207
3311
  return _fallback_error("oumv_verify", f"failed to verify OUMV action: {e}")
@@ -3211,7 +3315,9 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3211
3315
  from src.oumv_gateway import OUMVGateway
3212
3316
  qry = str(args.get("query") or "overview").strip()
3213
3317
  tgt = str(args.get("target") or "").strip() or None
3214
- ws = str(args.get("workspace_dir") or "").strip() or None
3318
+ ws, ws_err = _oumv_workspace_arg(args)
3319
+ if ws_err:
3320
+ return _fallback_error("oumv_graph", ws_err)
3215
3321
  res = OUMVGateway.graph(query=qry, target=tgt, workspace_dir=ws)
3216
3322
  return {"content": [{"type": "text", "text": json.dumps(res, indent=2, ensure_ascii=False)}]}
3217
3323
  except Exception as e:
@@ -3370,9 +3476,15 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3370
3476
 
3371
3477
  safe_queries: List[Dict[str, Any]] = []
3372
3478
  real_cwd = os.path.realpath(cwd)
3479
+ # Pass 1: resolve every sub-query path. A relative path that climbs out
3480
+ # of the root is still a hard error (traversal); absolute paths are an
3481
+ # explicit intent to search elsewhere, so they may be rebased below.
3482
+ q_copies: List[Any] = []
3483
+ path_abs: Dict[int, str] = {}
3484
+ outside: List[str] = []
3373
3485
  for q_item in queries:
3374
3486
  if not isinstance(q_item, dict):
3375
- safe_queries.append(q_item)
3487
+ q_copies.append(q_item)
3376
3488
  continue
3377
3489
  q_copy = dict(q_item)
3378
3490
  sub_p = q_copy.get("path")
@@ -3389,18 +3501,54 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
3389
3501
  except ValueError:
3390
3502
  inside = False
3391
3503
  if not inside:
3392
- return _fallback_error(
3393
- "batch_search",
3394
- f"subquery path '{sub_p}' resolves to '{sub_abs}', outside project root "
3395
- f"'{real_cwd}'. One call searches one root: pass that repo as cwd/project_path "
3396
- f"with repo-relative paths, and split queries for other repos into separate calls.",
3397
- )
3504
+ if not os.path.isabs(str(sub_p)):
3505
+ return _fallback_error(
3506
+ "batch_search",
3507
+ f"subquery path '{sub_p}' resolves to '{sub_abs}', outside project root "
3508
+ f"'{real_cwd}'. One call searches one root: pass that repo as cwd/project_path "
3509
+ f"with repo-relative paths, and split queries for other repos into separate calls.",
3510
+ )
3511
+ outside.append(sub_abs)
3512
+ path_abs[len(q_copies)] = sub_abs
3513
+ q_copies.append(q_copy)
3514
+
3515
+ rebased_from: Optional[str] = None
3516
+ if outside:
3517
+ shared_root = _shared_batch_root(outside, real_cwd) if len(outside) == len(path_abs) else None
3518
+ if not shared_root:
3519
+ detail = (
3520
+ "queries mix paths inside and outside it"
3521
+ if len(outside) != len(path_abs)
3522
+ else "they share no single enclosing project directory"
3523
+ )
3524
+ return _fallback_error(
3525
+ "batch_search",
3526
+ f"subquery paths resolve outside project root '{real_cwd}' and {detail}. "
3527
+ f"One call searches one root: pass that repo as cwd/project_path with "
3528
+ f"repo-relative paths, and split queries for other repos into separate calls.",
3529
+ )
3530
+ rebased_from = cwd
3531
+ cwd = shared_root
3532
+ real_cwd = os.path.realpath(shared_root)
3533
+ for idx, sub_abs in path_abs.items():
3534
+ if isinstance(q_copies[idx], dict):
3535
+ q_copies[idx]["path"] = os.path.relpath(sub_abs, shared_root)
3536
+
3537
+ for q_copy in q_copies:
3538
+ if not isinstance(q_copy, dict):
3539
+ safe_queries.append(q_copy)
3540
+ continue
3398
3541
  if is_quota_exceeded:
3399
3542
  q_copy["max_results"] = min(_safe_int(q_copy.get("max_results"), 3, lo=1, hi=100), 3)
3400
3543
  safe_queries.append(q_copy)
3401
3544
 
3402
3545
  res = execute_batch_search(queries=safe_queries, cwd=cwd)
3403
3546
  summary_md = res.get("summary_md", "")
3547
+ if rebased_from:
3548
+ summary_md = (
3549
+ f"// [TokenSafe: batch root auto-rebased to '{cwd}' (was '{rebased_from}') — "
3550
+ f"every subquery path lives there]\n" + summary_md
3551
+ )
3404
3552
  if is_quota_exceeded:
3405
3553
  banner = _quota_banner_if_due(quota, tracker, _mcp_session_id())
3406
3554
  current_tier = str(quota.get("tier") or "guest").lower()
@@ -801,7 +801,7 @@ class OUMVGateway:
801
801
 
802
802
  # 5. Tool: oumv_verify
803
803
  @classmethod
804
- def verify(cls, target: str, action: str = "invoke", payload: Optional[dict] = None, runtime: str = "auto", workspace_dir: Optional[str] = None) -> Any:
804
+ def verify(cls, target: str, action: str = "invoke", payload: Optional[dict] = None, runtime: str = "auto", workspace_dir: Optional[str] = None, sandbox: Optional[dict] = None) -> Any:
805
805
  cls.mark_oumv_used(workspace_dir)
806
806
  if runtime == "backend":
807
807
  _, be = cls.get_endpoints(workspace_dir=workspace_dir)
@@ -810,12 +810,17 @@ class OUMVGateway:
810
810
  if notice:
811
811
  return {"status": "unsupported", **notice}
812
812
  url = cls._resolve_client_url(runtime=runtime, target=target, workspace_dir=workspace_dir)
813
- res = cls._rpc_call(url, "oumv/verify", {
813
+ params = {
814
814
  "target": target,
815
815
  "componentId": target,
816
816
  "action": action,
817
817
  "payload": payload or {},
818
- })
818
+ }
819
+ # spec §4 (wire 1.4.0): the runtime decides whether it can honour the
820
+ # sandbox; we forward the request instead of guessing.
821
+ if isinstance(sandbox, dict) and sandbox.get("mode"):
822
+ params["sandbox"] = sandbox
823
+ res = cls._rpc_call(url, "oumv/verify", params)
819
824
  # Honest verification scope (spec §13): state exactly what was verified.
820
825
  if isinstance(res, dict):
821
826
  scope = res.setdefault("scope", {})
package/src/retrofit.py CHANGED
@@ -47,16 +47,18 @@ def _detect_package_json_entry(pkg_json_path: str, rel_dir: str = ".") -> Tuple[
47
47
  "root": rel_dir,
48
48
  }
49
49
 
50
+ has_vite = "vite" in deps
50
51
  if "next" in deps:
51
- fe_info.update({"framework": "nextjs", "provider": "react", "adapter": "tokensafe-ui/oumv/react", "version": deps.get("next"), "oumv_supported": True, "status": "ready"})
52
+ # Next has no Vite dev server; the zero-footprint plugin cannot mount there.
53
+ fe_info.update({"framework": "nextjs", "provider": "react", "adapter": "tokensafe-ui/oumv/react", "version": deps.get("next"), "oumv_supported": False, "status": "needs-vite"})
52
54
  elif "react" in deps:
53
- fe_info.update({"framework": "react", "provider": "react", "adapter": "tokensafe-ui/oumv/react", "version": deps.get("react"), "oumv_supported": True, "status": "ready"})
55
+ fe_info.update({"framework": "react", "provider": "react", "adapter": "tokensafe-ui/oumv/react", "version": deps.get("react"), "oumv_supported": has_vite, "status": "ready" if has_vite else "needs-vite"})
54
56
  elif "vue" in deps:
55
- fe_info.update({"framework": "vue", "provider": "vue", "adapter": "tokensafe-ui/oumv/vue", "version": deps.get("vue"), "oumv_supported": True, "status": "ready"})
57
+ 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"})
56
58
  elif "solid-js" in deps or "@tokensafe-ui/core" in deps:
57
- fe_info.update({"framework": "solid", "provider": "solid", "adapter": "tokensafe-ui/core", "version": deps.get("solid-js") or deps.get("@tokensafe-ui/core"), "oumv_supported": True, "status": "ready"})
59
+ 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"})
58
60
  elif "svelte" in deps:
59
- fe_info.update({"framework": "svelte", "provider": "svelte", "adapter": "tokensafe-ui/core", "version": deps.get("svelte"), "oumv_supported": True, "status": "ready"})
61
+ fe_info.update({"framework": "svelte", "provider": "svelte", "adapter": "tokensafe-ui/core", "version": deps.get("svelte"), "oumv_supported": False, "status": "planned"})
60
62
 
61
63
  if "framework" in fe_info:
62
64
  fe_out = fe_info
@@ -81,8 +83,10 @@ def _detect_package_json_entry(pkg_json_path: str, rel_dir: str = ".") -> Tuple[
81
83
  "adapter": "tokensafe-backend/node",
82
84
  "language": "node",
83
85
  "root": rel_dir,
84
- "oumv_supported": False,
85
- "status": "planned",
86
+ # Express/Fastify ship a certified adapter (npm tokensafe-backend-node);
87
+ # Nest/Hono/Koa do not yet.
88
+ "oumv_supported": node_fw in ("express", "fastify"),
89
+ "status": "ready" if node_fw in ("express", "fastify") else "planned",
86
90
  }
87
91
 
88
92
  if isinstance(pkg_data.get("workspaces"), (list, dict)):
@@ -244,7 +248,7 @@ def detect_project_stack(workspace_dir: str) -> Dict[str, Any]:
244
248
  framework = "flask"
245
249
  elif "starlette" in c:
246
250
  framework = "starlette"
247
- supported = framework in ("fastapi", "starlette")
251
+ supported = framework in ("fastapi",)
248
252
  py_entry = {
249
253
  "framework": framework,
250
254
  "provider": "fastapi" if framework == "fastapi" else "python",
@@ -271,6 +275,77 @@ def detect_project_stack(workspace_dir: str) -> Dict[str, Any]:
271
275
  pass
272
276
  break
273
277
 
278
+ # Spring (JDK-only sidecar) and PHP (Laravel/Symfony sidecar) detection.
279
+ # Both are source-level adapters: nothing is written into the project.
280
+ for java_manifest in ("pom.xml", "build.gradle", "build.gradle.kts"):
281
+ java_path = os.path.join(target_dir, java_manifest)
282
+ if not os.path.isfile(java_path):
283
+ continue
284
+ try:
285
+ with open(java_path, "r", encoding="utf-8", errors="replace") as f:
286
+ java_content = f.read().lower()
287
+ except Exception:
288
+ continue
289
+ if "spring-boot" in java_content or "org.springframework" in java_content:
290
+ _add_detected(os.path.relpath(java_path, workspace_dir))
291
+ sidecar = {
292
+ "framework": "spring",
293
+ "provider": "spring",
294
+ "adapter": "tokensafe-backend/java",
295
+ "language": "java",
296
+ "root": os.path.dirname(os.path.relpath(java_path, workspace_dir)) or ".",
297
+ "oumv_supported": True,
298
+ "status": "ready",
299
+ }
300
+ if not stack["backend"] or not stack["backend"].get("oumv_supported", False):
301
+ stack["backend"] = sidecar
302
+ _add_package({
303
+ "role": "backend",
304
+ "path": sidecar["root"],
305
+ "framework": "spring",
306
+ "provider": "spring",
307
+ "adapter": "tokensafe-backend/java",
308
+ "oumvSupported": True,
309
+ "status": "ready",
310
+ })
311
+ break
312
+
313
+ composer_path = os.path.join(target_dir, "composer.json")
314
+ if os.path.isfile(composer_path):
315
+ try:
316
+ with open(composer_path, "r", encoding="utf-8") as f:
317
+ composer = json.load(f)
318
+ requires = {**(composer.get("require") or {}), **(composer.get("require-dev") or {})}
319
+ except Exception:
320
+ requires = {}
321
+ php_framework = (
322
+ "laravel"
323
+ if any(str(name).startswith("laravel/") for name in requires)
324
+ else ("symfony" if any(str(name).startswith("symfony/") for name in requires) else None)
325
+ )
326
+ if php_framework:
327
+ _add_detected("composer.json")
328
+ sidecar = {
329
+ "framework": php_framework,
330
+ "provider": "php",
331
+ "adapter": "tokensafe-backend/php",
332
+ "language": "php",
333
+ "root": ".",
334
+ "oumv_supported": True,
335
+ "status": "ready",
336
+ }
337
+ if not stack["backend"] or not stack["backend"].get("oumv_supported", False):
338
+ stack["backend"] = sidecar
339
+ _add_package({
340
+ "role": "backend",
341
+ "path": ".",
342
+ "framework": php_framework,
343
+ "provider": "php",
344
+ "adapter": "tokensafe-backend/php",
345
+ "oumvSupported": True,
346
+ "status": "ready",
347
+ })
348
+
274
349
  _scan_dir(workspace_dir)
275
350
  if os.path.isfile(os.path.join(workspace_dir, "pnpm-workspace.yaml")):
276
351
  _add_detected("pnpm-workspace.yaml")
@@ -424,12 +499,12 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
424
499
  "profiles": ["frontend"],
425
500
  "repo": "tokensafe-ui",
426
501
  "mode": "hybrid",
427
- "status": "planned",
428
- "description": "Programmatic adapter exists (manual component registration); no Vite integration or OUMV certification yet — use static analysis for Vue today",
502
+ "status": "ready",
503
+ "description": "Vue 3 runtime adapter: tokensafe-ui() mounts /__oumv/rpc in the Vite dev server without touching the repo, reads the app instance through the bridge and is certified Level 3 in a real browser (agent-dom/certification/vue-vite-browser.json)",
429
504
  "technology": {
430
505
  "language": "typescript",
431
506
  "framework": "vue",
432
- "package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install tokensafe-ui"},
507
+ "package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install -D tokensafe-ui"},
433
508
  },
434
509
  "capabilities": [
435
510
  {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
@@ -445,7 +520,7 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
445
520
  "repo": "tokensafe-backend/go",
446
521
  "mode": "hybrid",
447
522
  "status": "ready",
448
- "description": "Go AST pre-flight compiler guard + transactional DB sandbox with rollback",
523
+ "description": "Go AST pre-flight compiler guard + optional database/sql sandbox: verify.sandboxRollback runs the request in one transaction and rolls it back (opt-in via SetDBSandbox)",
449
524
  "technology": {
450
525
  "language": "go",
451
526
  "framework": "gin/chi/net-http",
@@ -471,7 +546,7 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
471
546
  "repo": "tokensafe-backend/python",
472
547
  "mode": "hybrid",
473
548
  "status": "ready",
474
- "description": "FastAPI automatic route & schema introspection + SQLAlchemy dry-run sandbox",
549
+ "description": "FastAPI automatic route & schema introspection + SQLAlchemy sandbox: verify.sandboxRollback needs a SQLAlchemy engine and an app that honours X-TokenSafe-Dry-Run; otherwise the result says not_applicable/unverified",
475
550
  "technology": {
476
551
  "language": "python",
477
552
  "framework": "fastapi",
@@ -510,6 +585,57 @@ def get_adapters_catalog() -> List[Dict[str, Any]]:
510
585
  {"name": "verify.behavior", "constraints": {"readOnly": True, "developmentOnly": True}},
511
586
  ],
512
587
  },
588
+ {
589
+ "id": "backend/spring",
590
+ "name": "Spring Boot Adapter (JDK-only sidecar)",
591
+ "profile": "backend",
592
+ "profiles": ["backend"],
593
+ "repo": "tokensafe-backend/java",
594
+ "mode": "sidecar",
595
+ "status": "ready",
596
+ "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).",
597
+ "technology": {
598
+ "language": "java",
599
+ "framework": "spring",
600
+ "package": {
601
+ "manager": "binary",
602
+ "name": "OumvSpring.java",
603
+ "install": "tokensafe inject apply (caches the sidecar in ~/.tokensafe/sidecars)",
604
+ },
605
+ },
606
+ "capabilities": [
607
+ {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
608
+ {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
609
+ {"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
610
+ {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
611
+ {"name": "verify.behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
612
+ ],
613
+ },
614
+ {
615
+ "id": "backend/php",
616
+ "name": "Laravel / Symfony Adapter (PHP sidecar)",
617
+ "profile": "backend",
618
+ "profiles": ["backend"],
619
+ "repo": "tokensafe-backend/php",
620
+ "mode": "sidecar",
621
+ "status": "ready",
622
+ "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).",
623
+ "technology": {
624
+ "language": "php",
625
+ "framework": "laravel | symfony",
626
+ "package": {
627
+ "manager": "binary",
628
+ "name": "oumv-php",
629
+ "install": "tokensafe inject apply (caches the sidecar in ~/.tokensafe/sidecars)",
630
+ },
631
+ },
632
+ "capabilities": [
633
+ {"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
634
+ {"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
635
+ {"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
636
+ {"name": "verify.behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
637
+ ],
638
+ },
513
639
  ]
514
640
 
515
641
 
@@ -763,7 +889,7 @@ def resolve_zero_footprint_vite_command(
763
889
  host: Optional[str] = None,
764
890
  open_browser: bool = False,
765
891
  ) -> Tuple[List[str], str]:
766
- """Resolves zero-footprint tokensafe-ui Vite+React runner command without editing repo files."""
892
+ """Resolves the zero-footprint tokensafe-ui Vite runner command without editing repo files."""
767
893
  import shutil
768
894
 
769
895
  ws = os.path.abspath(workspace_dir)
@@ -774,6 +900,13 @@ def resolve_zero_footprint_vite_command(
774
900
  cli_flags.append(f"--host={host}")
775
901
  if open_browser:
776
902
  cli_flags.append("--open")
903
+ # `dev` defaults to React; a Vue project must say so explicitly or it gets the
904
+ # React controller and bridge.
905
+ stack = detect_project_stack(ws)
906
+ frontend = stack.get("frontend") or {}
907
+ framework = frontend.get("framework") if isinstance(frontend, dict) else None
908
+ if framework in ("react", "vue"):
909
+ cli_flags.append(f"--framework={framework}")
777
910
 
778
911
  resolved = resolve_tokensafe_ui_cli(ws)
779
912
  if resolved:
@@ -899,7 +1032,12 @@ def is_path_in_supported_oumv_scope(workspace_dir: str, file_path: str, use_cach
899
1032
  if "/" in rel and top in _FRONTEND_SOURCE_DIRS:
900
1033
  return pkg
901
1034
  return None
902
- if role == "backend" and ext in (".go", ".py"):
903
- return pkg
1035
+ if role == "backend":
1036
+ if ext in (".go", ".py"):
1037
+ return pkg
1038
+ # Express/Fastify adapters ship from npm; their sources are in scope.
1039
+ if pkg.get("provider") == "node" and ext in (".js", ".ts", ".mjs", ".cjs", ".jsx", ".tsx"):
1040
+ return pkg
1041
+ return None
904
1042
  return None
905
1043
  return None
@@ -25,9 +25,10 @@ _FRONTEND_LINES = {
25
25
  "before reading files; run `tokensafe dev` if no runtime is live."
26
26
  ),
27
27
  "vue": (
28
- "frontend {provider}/{framework}: no OUMV adapter yet (the Vite plugin serves no "
29
- "OUMV endpoints for Vue). Use tokensafe:repo_map, smart_read_file and scoped_search; "
30
- "verify UI changes with the app's own tests."
28
+ "frontend {provider}/{framework}: OUMV live via `tokensafe dev --framework vue` "
29
+ "(zero repo footprint, L0-L4, OCC edits; certified L3 in a browser). Call "
30
+ "tokensafe:oumv(action='observe', level='L1') before reading files; run "
31
+ "`tokensafe dev --framework vue` if no runtime is live."
31
32
  ),
32
33
  }
33
34
 
@@ -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.5"
314
+ "User-Agent": "TokenSafe-Sync/4.7.7"
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.5"
20
+ CURRENT_VERSION = "4.7.7"
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