tokensafe 4.5.5 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/hooks/__pycache__/claude_code_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/cursor_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/kimi_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_invocation.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_tool_use.cpython-312.pyc +0 -0
- package/hooks/__pycache__/session_start.cpython-312.pyc +0 -0
- package/hooks/__pycache__/stop_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/zcode_hook.cpython-312.pyc +0 -0
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/rules/AGENTS.md +1 -1
- package/server.json +3 -3
- package/src/batch_editor.py +174 -48
- package/src/batch_search.py +186 -74
- package/src/cross_stack.py +212 -0
- package/src/mcp_server.py +170 -65
- package/src/oumv_gateway.py +89 -1
- package/src/retrofit.py +74 -1
- package/src/snapshot.py +98 -27
- package/src/telemetry_sync.py +1 -1
- package/src/transcript_analyzer.py +59 -36
- package/src/version_checker.py +1 -1
package/src/mcp_server.py
CHANGED
|
@@ -42,7 +42,7 @@ from src.paths import get_active_workspace, is_plugin_or_system_dir
|
|
|
42
42
|
|
|
43
43
|
SERVER_INFO = {
|
|
44
44
|
"name": "tokensafe-mcp",
|
|
45
|
-
"version": "4.
|
|
45
|
+
"version": "4.6.1"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
# MCP client attribution: the initialize handshake carries clientInfo, which
|
|
@@ -1357,19 +1357,24 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
1357
1357
|
q_spec = {
|
|
1358
1358
|
"pattern": q,
|
|
1359
1359
|
"type": mode,
|
|
1360
|
-
"path": args.get("path") or args.get("project_path") or "",
|
|
1361
1360
|
"case_sensitive": bool(args.get("case_sensitive", False)),
|
|
1362
1361
|
"max_results": int(args.get("max_results") or 25),
|
|
1363
1362
|
}
|
|
1363
|
+
# `path` is a sub-query scope relative to the project root, never the
|
|
1364
|
+
# root itself: joining it twice produced "src/x.py/src/x.py" errors.
|
|
1365
|
+
sub_path = args.get("path")
|
|
1366
|
+
if sub_path:
|
|
1367
|
+
q_spec["path"] = sub_path
|
|
1364
1368
|
raw_sc = str(args.get("scope") or "").strip()
|
|
1365
1369
|
if raw_sc.startswith("*.") or "*" in raw_sc:
|
|
1366
1370
|
q_spec["glob"] = raw_sc
|
|
1367
1371
|
elif raw_sc and raw_sc.lower() not in ("all", "code", "config"):
|
|
1368
1372
|
q_spec["file_type"] = raw_sc.lstrip(".")
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
+
rerouted = {"queries": [q_spec]}
|
|
1374
|
+
explicit_root = args.get("cwd") or args.get("project_path")
|
|
1375
|
+
if explicit_root:
|
|
1376
|
+
rerouted["cwd"] = explicit_root
|
|
1377
|
+
args = rerouted
|
|
1373
1378
|
name = "batch_search"
|
|
1374
1379
|
elif mode in ("text", "regex") and args.get("use_regex") is None:
|
|
1375
1380
|
args = dict(args, use_regex=(mode == "regex"))
|
|
@@ -2685,6 +2690,7 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
2685
2690
|
details={"cmd": str(verify or "")[:100], "reason": str(res.get("error") or "")}
|
|
2686
2691
|
)
|
|
2687
2692
|
return _fallback_error("apply_edits", str(res.get("error") or "verify command blocked"))
|
|
2693
|
+
applied_files = res.get("applied_files") or []
|
|
2688
2694
|
lines = []
|
|
2689
2695
|
if res.get("success"):
|
|
2690
2696
|
action_desc = "Validated" if dry_run else "Applied"
|
|
@@ -2713,6 +2719,31 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
2713
2719
|
lines.append(f"Error: {v['error']}")
|
|
2714
2720
|
|
|
2715
2721
|
out_msg = {"content": [{"type": "text", "text": "\n".join(lines)}]}
|
|
2722
|
+
if applied_files:
|
|
2723
|
+
# Dashboards must see batch edits: without this the batch editor is
|
|
2724
|
+
# invisible in metrics while every single-file edit is counted.
|
|
2725
|
+
payload_text = "".join(
|
|
2726
|
+
str(h.get("target") or "") + str(h.get("replacement") or "")
|
|
2727
|
+
for e in (edits or []) if isinstance(e, dict)
|
|
2728
|
+
for h in (e.get("hunks") or []) if isinstance(h, dict)
|
|
2729
|
+
) + "".join(
|
|
2730
|
+
str(e.get("create") or "") for e in (edits or []) if isinstance(e, dict)
|
|
2731
|
+
)
|
|
2732
|
+
edit_tokens = count_tokens(payload_text)
|
|
2733
|
+
# Same convention as SCOPED_SEARCH: serial per-file round-trips cost
|
|
2734
|
+
# roughly an order of magnitude more than the consolidated payload.
|
|
2735
|
+
tracker.record_event(
|
|
2736
|
+
session_id=_mcp_session_id(),
|
|
2737
|
+
event_type="BATCH_EDIT",
|
|
2738
|
+
original_tokens=max(1500, edit_tokens * 8),
|
|
2739
|
+
optimized_tokens=edit_tokens,
|
|
2740
|
+
details={
|
|
2741
|
+
"files": len(applied_files),
|
|
2742
|
+
"hunks": sum(int(f.get("hunks") or 0) for f in applied_files),
|
|
2743
|
+
"dry_run": dry_run,
|
|
2744
|
+
"verify": bool(verify),
|
|
2745
|
+
},
|
|
2746
|
+
)
|
|
2716
2747
|
if not res.get("success"):
|
|
2717
2748
|
out_msg["isError"] = True
|
|
2718
2749
|
return out_msg
|
|
@@ -2726,7 +2757,25 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
2726
2757
|
if isinstance(queries, dict):
|
|
2727
2758
|
queries = [queries]
|
|
2728
2759
|
elif not queries and (args.get("query") or args.get("pattern")):
|
|
2729
|
-
|
|
2760
|
+
# Shorthand: forward every per-query knob instead of silently
|
|
2761
|
+
# dropping glob/case_sensitive/max_results/output_mode/scope.
|
|
2762
|
+
# `path` is a sub-query scope ONLY when an explicit project root
|
|
2763
|
+
# is supplied; otherwise it is the legacy cwd and must not be
|
|
2764
|
+
# joined twice.
|
|
2765
|
+
q_spec: Dict[str, Any] = {
|
|
2766
|
+
"pattern": args.get("query") or args.get("pattern"),
|
|
2767
|
+
"type": args.get("type", "text"),
|
|
2768
|
+
}
|
|
2769
|
+
has_explicit_root = bool(args.get("cwd") or args.get("project_path"))
|
|
2770
|
+
for key in ("path", "glob", "file_type", "scope", "output_mode",
|
|
2771
|
+
"case_sensitive", "max_results", "use_regex"):
|
|
2772
|
+
if key == "path" and not has_explicit_root:
|
|
2773
|
+
continue
|
|
2774
|
+
if args.get(key) is not None:
|
|
2775
|
+
q_spec[key] = args.get(key)
|
|
2776
|
+
if q_spec.get("use_regex") is not None:
|
|
2777
|
+
q_spec["type"] = "regex" if q_spec.pop("use_regex") else "text"
|
|
2778
|
+
queries = [q_spec]
|
|
2730
2779
|
if not queries:
|
|
2731
2780
|
return _fallback_error("batch_search", "missing required 'queries' list")
|
|
2732
2781
|
|
|
@@ -2790,7 +2839,12 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
2790
2839
|
optimized_tokens=res_tokens,
|
|
2791
2840
|
details={"query_count": len(safe_queries), "mode": "batch_search"},
|
|
2792
2841
|
)
|
|
2793
|
-
|
|
2842
|
+
out = {"content": [{"type": "text", "text": summary_md}]}
|
|
2843
|
+
if not res.get("success"):
|
|
2844
|
+
# Every query errored: report a failed tool call instead of a
|
|
2845
|
+
# successful one whose body silently contains only errors.
|
|
2846
|
+
out["isError"] = True
|
|
2847
|
+
return out
|
|
2794
2848
|
except Exception as e:
|
|
2795
2849
|
return _fallback_error("batch_search", f"failed to execute batch search: {e}")
|
|
2796
2850
|
|
|
@@ -2836,71 +2890,122 @@ def _redact_result_secrets(result):
|
|
|
2836
2890
|
return redacted
|
|
2837
2891
|
|
|
2838
2892
|
|
|
2893
|
+
def _fold_text_for_guard(text: str, limit_bytes: int, tool_name: str) -> str:
|
|
2894
|
+
"""Folds `text` into at most `limit_bytes` UTF-8 bytes.
|
|
2895
|
+
|
|
2896
|
+
Never raises and never returns an over-budget string: if the stash write is
|
|
2897
|
+
unavailable the content is truncated with an explicit marker instead of
|
|
2898
|
+
being passed through uncapped.
|
|
2899
|
+
"""
|
|
2900
|
+
if limit_bytes <= 0:
|
|
2901
|
+
return ""
|
|
2902
|
+
try:
|
|
2903
|
+
from src.format_parsers.ansi import strip_ansi
|
|
2904
|
+
clean_text = strip_ansi(text)
|
|
2905
|
+
except Exception:
|
|
2906
|
+
clean_text = text
|
|
2907
|
+
raw = clean_text.encode("utf-8")
|
|
2908
|
+
if len(raw) <= limit_bytes:
|
|
2909
|
+
return clean_text
|
|
2910
|
+
|
|
2911
|
+
marker = ""
|
|
2912
|
+
try:
|
|
2913
|
+
from src.stash import stash_block
|
|
2914
|
+
_hash, marker = stash_block(clean_text, source=f"mcp:{tool_name}")
|
|
2915
|
+
except Exception:
|
|
2916
|
+
marker = ""
|
|
2917
|
+
if not marker:
|
|
2918
|
+
marker = "[TokenSafe Zero-Spill Guard: content folded; stash copy unavailable]"
|
|
2919
|
+
|
|
2920
|
+
footer = "\n" + marker
|
|
2921
|
+
footer_bytes = len(footer.encode("utf-8"))
|
|
2922
|
+
budget = limit_bytes - footer_bytes
|
|
2923
|
+
if budget <= 40:
|
|
2924
|
+
return marker.encode("utf-8")[:limit_bytes].decode("utf-8", errors="ignore")
|
|
2925
|
+
|
|
2926
|
+
lines = clean_text.splitlines()
|
|
2927
|
+
if len(lines) > 35:
|
|
2928
|
+
head = lines[:20]
|
|
2929
|
+
tail = lines[-15:]
|
|
2930
|
+
omitted = len(lines) - (len(head) + len(tail))
|
|
2931
|
+
msg = f"\n... [{omitted} lines / {len(clean_text)} chars folded by TokenSafe Zero-Spill Guard] ...\n"
|
|
2932
|
+
tail_str = "\n".join(tail)
|
|
2933
|
+
tail_bytes = len(tail_str.encode("utf-8"))
|
|
2934
|
+
msg_bytes = len(msg.encode("utf-8"))
|
|
2935
|
+
if msg_bytes + tail_bytes < budget:
|
|
2936
|
+
head_budget = budget - msg_bytes - tail_bytes
|
|
2937
|
+
head_str = ""
|
|
2938
|
+
for line in head:
|
|
2939
|
+
candidate = head_str + line + "\n"
|
|
2940
|
+
if len(candidate.encode("utf-8")) <= head_budget:
|
|
2941
|
+
head_str = candidate
|
|
2942
|
+
else:
|
|
2943
|
+
break
|
|
2944
|
+
folded = f"{head_str.rstrip()}{msg}{tail_str}{footer}"
|
|
2945
|
+
if len(folded.encode("utf-8")) <= limit_bytes:
|
|
2946
|
+
return folded
|
|
2947
|
+
|
|
2948
|
+
msg = "\n... [content folded by TokenSafe Zero-Spill Guard] ...\n"
|
|
2949
|
+
avail = budget - len(msg.encode("utf-8"))
|
|
2950
|
+
if avail <= 40:
|
|
2951
|
+
return marker.encode("utf-8")[:limit_bytes].decode("utf-8", errors="ignore")
|
|
2952
|
+
head_n = avail // 2
|
|
2953
|
+
tail_n = avail - head_n
|
|
2954
|
+
head_s = raw[:head_n].decode("utf-8", errors="ignore")
|
|
2955
|
+
tail_s = raw[len(raw) - tail_n:].decode("utf-8", errors="ignore") if tail_n else ""
|
|
2956
|
+
folded = f"{head_s}{msg}{tail_s}{footer}"
|
|
2957
|
+
if len(folded.encode("utf-8")) > limit_bytes:
|
|
2958
|
+
folded = folded.encode("utf-8")[:limit_bytes].decode("utf-8", errors="ignore")
|
|
2959
|
+
return folded
|
|
2960
|
+
|
|
2961
|
+
|
|
2839
2962
|
def _cap_mcp_output_size(result: Any, tool_name: str = "tool", max_bytes: int = 8800) -> Any:
|
|
2840
|
-
"""Zero-Spill Guard:
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2963
|
+
"""Zero-Spill Guard: keeps the whole tools/call payload under `max_bytes`.
|
|
2964
|
+
|
|
2965
|
+
The budget is per RESPONSE, not per text block: several medium blocks used
|
|
2966
|
+
to slip through and spill to disk. Only ~90% of `max_bytes` is spent on
|
|
2967
|
+
text, leaving headroom for the JSON escaping the JSON-RPC envelope adds.
|
|
2968
|
+
"""
|
|
2844
2969
|
if not isinstance(result, dict):
|
|
2845
2970
|
return result
|
|
2846
2971
|
content = result.get("content")
|
|
2847
2972
|
if not isinstance(content, list):
|
|
2848
2973
|
return result
|
|
2849
2974
|
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
if isinstance(block, dict) and block.get("type") == "text":
|
|
2854
|
-
text = block.get("text", "")
|
|
2855
|
-
raw_bytes = text.encode("utf-8")
|
|
2856
|
-
if len(raw_bytes) > max_bytes:
|
|
2857
|
-
try:
|
|
2858
|
-
from src.stash import stash_block
|
|
2859
|
-
from src.format_parsers.ansi import strip_ansi
|
|
2860
|
-
clean_text = strip_ansi(text)
|
|
2861
|
-
hash8, marker = stash_block(clean_text, source=f"mcp:{tool_name}")
|
|
2862
|
-
lines = clean_text.splitlines()
|
|
2863
|
-
footer = f"\n{marker}"
|
|
2864
|
-
footer_bytes = len(footer.encode("utf-8"))
|
|
2865
|
-
if len(lines) > 35:
|
|
2866
|
-
head = lines[:20]
|
|
2867
|
-
tail = lines[-15:]
|
|
2868
|
-
omitted = len(lines) - (len(head) + len(tail))
|
|
2869
|
-
folded_msg = f"\n... [{omitted} lines / {len(clean_text)} chars folded by TokenSafe Zero-Spill Guard] ...\n"
|
|
2870
|
-
tail_str = "\n".join(tail)
|
|
2871
|
-
budget = max_bytes - len(folded_msg.encode("utf-8")) - footer_bytes - len(tail_str.encode("utf-8")) - 50
|
|
2872
|
-
head_str = ""
|
|
2873
|
-
for line in head:
|
|
2874
|
-
if len((head_str + line + "\n").encode("utf-8")) <= budget:
|
|
2875
|
-
head_str += line + "\n"
|
|
2876
|
-
else:
|
|
2877
|
-
break
|
|
2878
|
-
folded_text = f"{head_str.rstrip()}{folded_msg}{tail_str}{footer}"
|
|
2879
|
-
else:
|
|
2880
|
-
msg_mid = f"\n... [{len(clean_text)} chars folded by TokenSafe Zero-Spill Guard] ...\n"
|
|
2881
|
-
avail = max(120, max_bytes - len(msg_mid.encode("utf-8")) - footer_bytes - 50)
|
|
2882
|
-
head_b = raw_bytes[: avail // 2].decode("utf-8", errors="ignore")
|
|
2883
|
-
tail_b = raw_bytes[-(avail - avail // 2):].decode("utf-8", errors="ignore")
|
|
2884
|
-
folded_text = f"{head_b.rstrip()}{msg_mid}{tail_b.lstrip()}{footer}"
|
|
2885
|
-
|
|
2886
|
-
if len(folded_text.encode("utf-8")) > max_bytes:
|
|
2887
|
-
allowed_head = max(80, max_bytes - footer_bytes - 60)
|
|
2888
|
-
folded_text = clean_text.encode("utf-8")[:allowed_head].decode("utf-8", errors="ignore") + f"\n... [folded]\n{footer}"
|
|
2889
|
-
|
|
2890
|
-
new_block = dict(block)
|
|
2891
|
-
new_block["text"] = folded_text
|
|
2892
|
-
new_content.append(new_block)
|
|
2893
|
-
modified = True
|
|
2894
|
-
continue
|
|
2895
|
-
except Exception:
|
|
2896
|
-
pass
|
|
2897
|
-
new_content.append(block)
|
|
2975
|
+
text_idx = [i for i, b in enumerate(content) if isinstance(b, dict) and b.get("type") == "text"]
|
|
2976
|
+
if not text_idx:
|
|
2977
|
+
return result
|
|
2898
2978
|
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2979
|
+
budget = max(256, int(max_bytes * 0.9))
|
|
2980
|
+
sizes = {i: len(str(content[i].get("text") or "").encode("utf-8")) for i in text_idx}
|
|
2981
|
+
total = sum(sizes.values())
|
|
2982
|
+
if total <= budget:
|
|
2983
|
+
return result
|
|
2984
|
+
|
|
2985
|
+
new_content = list(content)
|
|
2986
|
+
# Fold the largest blocks first: that frees the most bytes per block touched.
|
|
2987
|
+
for i in sorted(text_idx, key=lambda idx: sizes[idx], reverse=True):
|
|
2988
|
+
if total <= budget:
|
|
2989
|
+
break
|
|
2990
|
+
others = total - sizes[i]
|
|
2991
|
+
target = max(200, budget - others)
|
|
2992
|
+
if target >= sizes[i]:
|
|
2993
|
+
continue
|
|
2994
|
+
folded = _fold_text_for_guard(str(content[i].get("text") or ""), target, tool_name)
|
|
2995
|
+
new_content[i] = {**content[i], "text": folded}
|
|
2996
|
+
total = total - sizes[i] + len(folded.encode("utf-8"))
|
|
2997
|
+
|
|
2998
|
+
if total > budget:
|
|
2999
|
+
# Last resort: keep only the first block, folded to the full budget.
|
|
3000
|
+
first = text_idx[0]
|
|
3001
|
+
kept = _fold_text_for_guard(str(content[first].get("text") or ""), budget, tool_name)
|
|
3002
|
+
for i in text_idx[1:]:
|
|
3003
|
+
new_content[i] = {**new_content[i], "text": ""}
|
|
3004
|
+
new_content[first] = {**content[first], "text": kept}
|
|
3005
|
+
|
|
3006
|
+
new_res = dict(result)
|
|
3007
|
+
new_res["content"] = new_content
|
|
3008
|
+
return new_res
|
|
2904
3009
|
|
|
2905
3010
|
|
|
2906
3011
|
def _execute_with_timeout(tool_name: str, tool_args: dict, timeout: float = MCP_TOOL_TIMEOUT) -> dict:
|
package/src/oumv_gateway.py
CHANGED
|
@@ -238,11 +238,61 @@ class OUMVGateway:
|
|
|
238
238
|
"framework": stack_info.get("backend", {}).get("framework", "None") if stack_info.get("backend") else "None",
|
|
239
239
|
"tip": "Static AST analysis active. When backend DevServer starts (port 8080/8000), live OUMV auto-connects."
|
|
240
240
|
},
|
|
241
|
+
"adapters": cls._adapter_lifecycle(stack_info, fe, be),
|
|
241
242
|
"staticIntelligence": "ACTIVE (L0/L1/L2 AST observation & cross-stack linking ready)",
|
|
242
243
|
"detectedStack": stack_info,
|
|
243
244
|
"workspace": ws,
|
|
244
245
|
}
|
|
245
246
|
|
|
247
|
+
@staticmethod
|
|
248
|
+
def _adapter_lifecycle(stack_info: Dict[str, Any], fe: Optional[Dict[str, Any]], be: Optional[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
249
|
+
"""Per-adapter lifecycle + health per the OUMV Adapter Contract (schemas/adapter.json)."""
|
|
250
|
+
adapters: List[Dict[str, Any]] = []
|
|
251
|
+
fe_detected = bool(stack_info.get("frontend"))
|
|
252
|
+
be_detected = bool(stack_info.get("backend"))
|
|
253
|
+
if not fe_detected and not be_detected:
|
|
254
|
+
return adapters
|
|
255
|
+
|
|
256
|
+
try:
|
|
257
|
+
from src.retrofit import get_adapters_catalog
|
|
258
|
+
catalog = get_adapters_catalog()
|
|
259
|
+
except Exception:
|
|
260
|
+
catalog = []
|
|
261
|
+
|
|
262
|
+
def _find_adapter(profile: str, provider: Optional[str]) -> Dict[str, Any]:
|
|
263
|
+
if provider:
|
|
264
|
+
for a in catalog:
|
|
265
|
+
if a.get("id") == f"{profile}/{provider}" and a.get("status") == "ready":
|
|
266
|
+
return a
|
|
267
|
+
for a in catalog:
|
|
268
|
+
if a.get("profile") == profile and a.get("status") == "ready":
|
|
269
|
+
return a
|
|
270
|
+
return {}
|
|
271
|
+
|
|
272
|
+
def _entry(profile: str, connected: Optional[Dict[str, Any]], detected: bool, provider: Optional[str] = None) -> Dict[str, Any]:
|
|
273
|
+
adapter = _find_adapter(profile, provider)
|
|
274
|
+
if connected:
|
|
275
|
+
state, health, detail = "ACTIVE", "healthy", f"Live runtime: {connected.get('name', 'unknown')}"
|
|
276
|
+
elif detected:
|
|
277
|
+
state, health, detail = "HANDSHAKE", "degraded", "Detected statically; runtime offline — hybrid static fallback active"
|
|
278
|
+
else:
|
|
279
|
+
state, health, detail = "DISCOVER", "unavailable", "Not detected in this workspace"
|
|
280
|
+
return {
|
|
281
|
+
"profile": profile,
|
|
282
|
+
"adapter": adapter.get("id", f"{profile}/unknown"),
|
|
283
|
+
"technology": adapter.get("technology"),
|
|
284
|
+
"capabilities": adapter.get("capabilities"),
|
|
285
|
+
"lifecycle": {"state": state, "health": {"status": health, "detail": detail}},
|
|
286
|
+
"security": {
|
|
287
|
+
"productionFailClosed": True,
|
|
288
|
+
"workspaceBoundary": True,
|
|
289
|
+
},
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
adapters.append(_entry("frontend", fe, fe_detected, (stack_info.get("frontend") or {}).get("provider")))
|
|
293
|
+
adapters.append(_entry("backend", be, be_detected, (stack_info.get("backend") or {}).get("provider")))
|
|
294
|
+
return adapters
|
|
295
|
+
|
|
246
296
|
# 2. Tool: oumv_observe
|
|
247
297
|
@classmethod
|
|
248
298
|
def observe(cls, level: str = "L0", target: Optional[str] = None, runtime: str = "auto") -> Any:
|
|
@@ -471,9 +521,47 @@ class OUMVGateway:
|
|
|
471
521
|
@classmethod
|
|
472
522
|
def verify(cls, target: str, action: str = "invoke", payload: Optional[dict] = None, runtime: str = "auto") -> Any:
|
|
473
523
|
url = cls._resolve_client_url(runtime=runtime, target=target)
|
|
474
|
-
|
|
524
|
+
res = cls._rpc_call(url, "oumv/verify", {
|
|
475
525
|
"target": target,
|
|
476
526
|
"componentId": target,
|
|
477
527
|
"action": action,
|
|
478
528
|
"payload": payload or {},
|
|
479
529
|
})
|
|
530
|
+
# Honest verification scope (spec §13): state exactly what was verified.
|
|
531
|
+
if isinstance(res, dict):
|
|
532
|
+
scope = res.setdefault("scope", {})
|
|
533
|
+
checked = scope.setdefault("checked", [])
|
|
534
|
+
checked_entry = "in-memory dispatch against live runtime"
|
|
535
|
+
if checked_entry not in checked:
|
|
536
|
+
checked.append(checked_entry)
|
|
537
|
+
scope.setdefault("notExecuted", [
|
|
538
|
+
"end-to-end browser flow",
|
|
539
|
+
"production behavior",
|
|
540
|
+
"full test suite",
|
|
541
|
+
])
|
|
542
|
+
return res
|
|
543
|
+
|
|
544
|
+
# 6. Tool: oumv_graph — unified cross-stack intelligence graph (spec §11)
|
|
545
|
+
@classmethod
|
|
546
|
+
def graph(cls, query: str = "overview", target: Optional[str] = None, workspace_dir: Optional[str] = None) -> Any:
|
|
547
|
+
"""Unified graph over static + runtime evidence, with §11.4-style queries."""
|
|
548
|
+
fe, be = cls.get_endpoints()
|
|
549
|
+
from src.cross_stack import build_unified_graph, who_depends_on, impact_from_graph
|
|
550
|
+
|
|
551
|
+
ws = workspace_dir or get_active_workspace()
|
|
552
|
+
|
|
553
|
+
q = (query or "overview").strip()
|
|
554
|
+
if q == "who_depends_on":
|
|
555
|
+
full = build_unified_graph(workspace_dir=ws, fe=fe, be=be, rpc_call=cls._rpc_call)
|
|
556
|
+
return who_depends_on(target or "", full)
|
|
557
|
+
if q == "impact":
|
|
558
|
+
full = build_unified_graph(workspace_dir=ws, fe=fe, be=be, rpc_call=cls._rpc_call)
|
|
559
|
+
return impact_from_graph(target or "", full)
|
|
560
|
+
|
|
561
|
+
g = build_unified_graph(workspace_dir=ws, fe=fe, be=be, rpc_call=cls._rpc_call)
|
|
562
|
+
if target:
|
|
563
|
+
t = target.lower()
|
|
564
|
+
g["nodes"] = [n for n in g["nodes"] if t in str(n).lower()][:50]
|
|
565
|
+
g["edges"] = [e for e in g["edges"] if t in (e["source"] + e["target"]).lower()][:50]
|
|
566
|
+
g["filteredBy"] = target
|
|
567
|
+
return g
|
package/src/retrofit.py
CHANGED
|
@@ -197,57 +197,130 @@ def generate_config(
|
|
|
197
197
|
|
|
198
198
|
|
|
199
199
|
def get_adapters_catalog() -> List[Dict[str, Any]]:
|
|
200
|
-
"""Lists available OUMV adapters in the consolidated architecture.
|
|
200
|
+
"""Lists available OUMV adapters in the consolidated architecture.
|
|
201
|
+
|
|
202
|
+
Each entry follows the language-neutral OUMV Adapter Contract
|
|
203
|
+
(agent-oumv/schemas/adapter.json): identity, technology/package,
|
|
204
|
+
profiles, and baseline capabilities with constraints.
|
|
205
|
+
"""
|
|
201
206
|
return [
|
|
202
207
|
{
|
|
203
208
|
"id": "frontend/react",
|
|
204
209
|
"name": "React Adapter (Zustand, Redux, Context, useReducer)",
|
|
205
210
|
"profile": "frontend",
|
|
211
|
+
"profiles": ["frontend"],
|
|
206
212
|
"repo": "tokensafe-ui",
|
|
207
213
|
"mode": "hybrid",
|
|
208
214
|
"status": "ready",
|
|
209
215
|
"description": "Progressive AST component discovery + runtime action/state inspection",
|
|
216
|
+
"technology": {
|
|
217
|
+
"language": "typescript",
|
|
218
|
+
"framework": "react",
|
|
219
|
+
"package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install tokensafe-ui"},
|
|
220
|
+
},
|
|
221
|
+
"capabilities": [
|
|
222
|
+
{"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
223
|
+
{"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
224
|
+
{"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
225
|
+
{"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
|
|
226
|
+
{"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
227
|
+
],
|
|
210
228
|
},
|
|
211
229
|
{
|
|
212
230
|
"id": "frontend/solid",
|
|
213
231
|
"name": "SolidJS / TokenSafe UI Native Adapter",
|
|
214
232
|
"profile": "frontend",
|
|
233
|
+
"profiles": ["frontend"],
|
|
215
234
|
"repo": "tokensafe-ui",
|
|
216
235
|
"mode": "hybrid",
|
|
217
236
|
"status": "ready",
|
|
218
237
|
"description": "Fine-grained reactive signals causality + virtual DOM observer",
|
|
238
|
+
"technology": {
|
|
239
|
+
"language": "typescript",
|
|
240
|
+
"framework": "solidjs",
|
|
241
|
+
"package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install tokensafe-ui"},
|
|
242
|
+
},
|
|
243
|
+
"capabilities": [
|
|
244
|
+
{"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
245
|
+
{"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
246
|
+
{"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
247
|
+
{"name": "understand.impact", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
248
|
+
{"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
|
|
249
|
+
{"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
250
|
+
],
|
|
219
251
|
},
|
|
220
252
|
{
|
|
221
253
|
"id": "frontend/vue",
|
|
222
254
|
"name": "Vue 3 Adapter (Composition API, Pinia)",
|
|
223
255
|
"profile": "frontend",
|
|
256
|
+
"profiles": ["frontend"],
|
|
224
257
|
"repo": "tokensafe-ui",
|
|
225
258
|
"mode": "hybrid",
|
|
226
259
|
"status": "ready",
|
|
227
260
|
"description": "Vue component hierarchy and store snapshot observer",
|
|
261
|
+
"technology": {
|
|
262
|
+
"language": "typescript",
|
|
263
|
+
"framework": "vue",
|
|
264
|
+
"package": {"manager": "npm", "name": "tokensafe-ui", "install": "npm install tokensafe-ui"},
|
|
265
|
+
},
|
|
266
|
+
"capabilities": [
|
|
267
|
+
{"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
268
|
+
{"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": True}},
|
|
269
|
+
{"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
|
|
270
|
+
],
|
|
228
271
|
},
|
|
229
272
|
{
|
|
230
273
|
"id": "backend/go",
|
|
231
274
|
"name": "Go Backend Adapter (Gin, Chi, net/http)",
|
|
232
275
|
"profile": "backend",
|
|
276
|
+
"profiles": ["backend"],
|
|
233
277
|
"repo": "tokensafe-backend/go",
|
|
234
278
|
"mode": "hybrid",
|
|
235
279
|
"status": "ready",
|
|
236
280
|
"description": "Go AST pre-flight compiler guard + transactional DB sandbox with rollback",
|
|
281
|
+
"technology": {
|
|
282
|
+
"language": "go",
|
|
283
|
+
"framework": "gin/chi/net-http",
|
|
284
|
+
"package": {
|
|
285
|
+
"manager": "go",
|
|
286
|
+
"name": "github.com/tokensafe-dev/tokensafe-backend/go",
|
|
287
|
+
"install": "go get github.com/tokensafe-dev/tokensafe-backend/go",
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
"capabilities": [
|
|
291
|
+
{"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
292
|
+
{"name": "observe.runtime_state", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
293
|
+
{"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": False, "limitations": ["requires observed request traces (TraceHandler or oumv/verify)"]}},
|
|
294
|
+
{"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
|
|
295
|
+
{"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
296
|
+
],
|
|
237
297
|
},
|
|
238
298
|
{
|
|
239
299
|
"id": "backend/fastapi",
|
|
240
300
|
"name": "Python FastAPI Adapter (Starlette, Pydantic)",
|
|
241
301
|
"profile": "backend",
|
|
302
|
+
"profiles": ["backend"],
|
|
242
303
|
"repo": "tokensafe-backend/python",
|
|
243
304
|
"mode": "hybrid",
|
|
244
305
|
"status": "ready",
|
|
245
306
|
"description": "FastAPI automatic route & schema introspection + SQLAlchemy dry-run sandbox",
|
|
307
|
+
"technology": {
|
|
308
|
+
"language": "python",
|
|
309
|
+
"framework": "fastapi",
|
|
310
|
+
"package": {"manager": "pip", "name": "tokensafe-python", "install": "pip install tokensafe-python"},
|
|
311
|
+
},
|
|
312
|
+
"capabilities": [
|
|
313
|
+
{"name": "observe.resources", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
314
|
+
{"name": "understand.causality", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
315
|
+
{"name": "mutate.source", "constraints": {"readOnly": False, "developmentOnly": False, "requiresPermission": "permissions.mutate != false"}},
|
|
316
|
+
{"name": "verify.runtime_behavior", "constraints": {"readOnly": True, "developmentOnly": False}},
|
|
317
|
+
],
|
|
246
318
|
},
|
|
247
319
|
{
|
|
248
320
|
"id": "backend/node",
|
|
249
321
|
"name": "Node.js Backend Adapter (Express, Fastify)",
|
|
250
322
|
"profile": "backend",
|
|
323
|
+
"profiles": ["backend"],
|
|
251
324
|
"repo": "tokensafe-backend/node",
|
|
252
325
|
"mode": "hybrid",
|
|
253
326
|
"status": "planned",
|