tokensafe 4.7.4 → 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.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +17 -13
- package/bin/tokensafe.js +41 -39
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/auto_inject.py +248 -8
- package/src/batch_editor.py +12 -2
- package/src/bench/go_target.py +135 -14
- package/src/cli.py +1 -1
- package/src/installer.py +5 -23
- package/src/mcp_server.py +315 -21
- package/src/oumv_gateway.py +8 -3
- package/src/retrofit.py +154 -16
- package/src/session_brief.py +4 -3
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +1 -1
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
|
-
|
|
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":
|
|
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":
|
|
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":
|
|
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":
|
|
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
|
-
|
|
85
|
-
|
|
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",
|
|
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": "
|
|
428
|
-
"description": "
|
|
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 +
|
|
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
|
|
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
|
|
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"
|
|
903
|
-
|
|
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
|
package/src/session_brief.py
CHANGED
|
@@ -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}:
|
|
29
|
-
"
|
|
30
|
-
"
|
|
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
|
|
package/src/telemetry_sync.py
CHANGED
|
@@ -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.
|
|
314
|
+
"User-Agent": "TokenSafe-Sync/4.7.7"
|
|
315
315
|
}
|
|
316
316
|
if active_key:
|
|
317
317
|
headers["Authorization"] = f"Bearer {active_key}"
|
package/src/version_checker.py
CHANGED
|
@@ -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.
|
|
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
|