tzero-mcp 11.0.0 → 11.12.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +56 -56
  2. package/CONTRIBUTING.md +71 -71
  3. package/LICENSE +21 -21
  4. package/README.md +64 -64
  5. package/bin/tzero-mcp.js +62 -62
  6. package/bin/tzero.js +61 -61
  7. package/index.d.ts +25 -25
  8. package/index.js +15 -15
  9. package/package.json +89 -88
  10. package/src/addmcp.py +1203 -1197
  11. package/src/app.py +1810 -1810
  12. package/src/main.py +60 -60
  13. package/src/pc_fixer_mcp.py +25 -25
  14. package/src/tzero/__init__.py +54 -54
  15. package/src/tzero/__main__.py +6 -6
  16. package/src/tzero/siber_akademi_icon.py +77 -77
  17. package/src/tzero/tzero_arch_test.py +463 -463
  18. package/src/tzero/tzero_benchmark.py +475 -475
  19. package/src/tzero/tzero_blackboard.py +257 -257
  20. package/src/tzero/tzero_bridge.py +546 -546
  21. package/src/tzero/tzero_budget.py +195 -195
  22. package/src/tzero/tzero_card.py +431 -0
  23. package/src/tzero/tzero_ci.py +153 -153
  24. package/src/tzero/tzero_commit.py +192 -192
  25. package/src/tzero/tzero_contracts.py +1093 -1093
  26. package/src/tzero/tzero_cost.py +166 -166
  27. package/src/tzero/tzero_dashboard.py +1960 -1960
  28. package/src/tzero/tzero_debt.py +461 -461
  29. package/src/tzero/tzero_deps.py +462 -462
  30. package/src/tzero/tzero_drift.py +208 -208
  31. package/src/tzero/tzero_explain.py +306 -306
  32. package/src/tzero/tzero_features.py +3024 -3024
  33. package/src/tzero/tzero_federation.py +299 -299
  34. package/src/tzero/tzero_fix.py +557 -228
  35. package/src/tzero/tzero_fixer/__init__.py +63 -63
  36. package/src/tzero/tzero_fixer/amalgamation.py +334 -334
  37. package/src/tzero/tzero_fixer/ast_syntax_healer.py +464 -464
  38. package/src/tzero/tzero_fixer/ast_type_modernizer.py +288 -288
  39. package/src/tzero/tzero_fixer/async_io_modernizer.py +127 -127
  40. package/src/tzero/tzero_fixer/automated_regression_suite.py +600 -600
  41. package/src/tzero/tzero_fixer/benchmarks_and_diagnostics.py +174 -174
  42. package/src/tzero/tzero_fixer/ci_cd_self_healing_gate.py +246 -246
  43. package/src/tzero/tzero_fixer/code_duplicity_and_refactorer.py +151 -151
  44. package/src/tzero/tzero_fixer/code_smells_healer.py +260 -260
  45. package/src/tzero/tzero_fixer/cwe_remediator.py +171 -171
  46. package/src/tzero/tzero_fixer/dead_code_eliminator.py +150 -150
  47. package/src/tzero/tzero_fixer/dependency_vulnerability_auditor.py +309 -309
  48. package/src/tzero/tzero_fixer/git_advanced_surgeon.py +280 -280
  49. package/src/tzero/tzero_fixer/hardware_and_disk_doctor.py +325 -325
  50. package/src/tzero/tzero_fixer/import_graph_healer.py +412 -412
  51. package/src/tzero/tzero_fixer/interactive_tui.py +91 -91
  52. package/src/tzero/tzero_fixer/knowledge_base.py +295 -295
  53. package/src/tzero/tzero_fixer/knowledge_base_extended.py +940 -940
  54. package/src/tzero/tzero_fixer/linters_and_static_analyzer.py +307 -307
  55. package/src/tzero/tzero_fixer/mcp_server.py +489 -489
  56. package/src/tzero/tzero_fixer/models.py +385 -385
  57. package/src/tzero/tzero_fixer/orchestrator.py +375 -375
  58. package/src/tzero/tzero_fixer/os_doctor.py +502 -502
  59. package/src/tzero/tzero_fixer/packaging_abi_surgeon.py +323 -323
  60. package/src/tzero/tzero_fixer/pc_fixer_doctor.py +600 -600
  61. package/src/tzero/tzero_fixer/performance_and_memory_profiler.py +274 -274
  62. package/src/tzero/tzero_fixer/polyglot_ast_parsers.py +313 -313
  63. package/src/tzero/tzero_fixer/polyglot_build_healer.py +364 -364
  64. package/src/tzero/tzero_fixer/polyglot_config_healer.py +318 -318
  65. package/src/tzero/tzero_fixer/polyglot_doctor.py +372 -372
  66. package/src/tzero/tzero_fixer/polyglot_linters.py +619 -619
  67. package/src/tzero/tzero_fixer/polyglot_schema_validator.py +305 -305
  68. package/src/tzero/tzero_fixer/security_cwe_database.py +444 -444
  69. package/src/tzero/tzero_fixer/security_deep_rules.py +114 -114
  70. package/src/tzero/tzero_fixer/security_rules_catalog.py +110 -110
  71. package/src/tzero/tzero_fixer/security_zero_leak.py +326 -326
  72. package/src/tzero/tzero_fixer/smart_patch_recommender.py +223 -223
  73. package/src/tzero/tzero_fixer/synthetic_workspace_generator.py +220 -220
  74. package/src/tzero/tzero_fixer/system_diagnostics_extended.py +493 -493
  75. package/src/tzero/tzero_fixer/system_repair_recipes.py +447 -447
  76. package/src/tzero/tzero_fixer/venv_doctor.py +309 -309
  77. package/src/tzero/tzero_golden.py +319 -319
  78. package/src/tzero/tzero_graph_hud.html +338 -338
  79. package/src/tzero/tzero_graph_rag.py +263 -263
  80. package/src/tzero/tzero_growth.py +415 -0
  81. package/src/tzero/tzero_guard.py +251 -243
  82. package/src/tzero/tzero_hooks.py +565 -565
  83. package/src/tzero/tzero_infra.py +274 -274
  84. package/src/tzero/tzero_jarvis/__init__.py +134 -124
  85. package/src/tzero/tzero_jarvis/causal_graph.py +310 -310
  86. package/src/tzero/tzero_jarvis/creative_director.py +333 -0
  87. package/src/tzero/tzero_jarvis/graph_visualizer.py +395 -395
  88. package/src/tzero/tzero_jarvis/hybrid_search.py +214 -214
  89. package/src/tzero/tzero_jarvis/latent_press.py +137 -137
  90. package/src/tzero/tzero_jarvis/memory_consolidation.py +212 -212
  91. package/src/tzero/tzero_jarvis/minhash_lsh.py +184 -184
  92. package/src/tzero/tzero_jarvis/orchestrator.py +335 -335
  93. package/src/tzero/tzero_jarvis/self_healing.py +308 -308
  94. package/src/tzero/tzero_jarvis/semantic_compressor.py +887 -887
  95. package/src/tzero/tzero_jarvis/swarm.py +261 -261
  96. package/src/tzero/tzero_jarvis/swarm_bft.py +144 -144
  97. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1167 -1167
  98. package/src/tzero/tzero_jarvis/zero_key_router.py +173 -173
  99. package/src/tzero/tzero_lsp.py +634 -634
  100. package/src/tzero/tzero_mcp.py +5314 -5237
  101. package/src/tzero/tzero_mutation.py +358 -358
  102. package/src/tzero/tzero_neural_cortex.py +1425 -1425
  103. package/src/tzero/tzero_packer.py +577 -577
  104. package/src/tzero/tzero_patch.py +624 -624
  105. package/src/tzero/tzero_pc_fixer.py +12699 -12699
  106. package/src/tzero/tzero_pipe.py +95 -95
  107. package/src/tzero/tzero_polyglot.py +799 -799
  108. package/src/tzero/tzero_proxy.py +127 -127
  109. package/src/tzero/tzero_reachability.py +272 -272
  110. package/src/tzero/tzero_replay.py +141 -141
  111. package/src/tzero/tzero_rust_bridge.py +198 -198
  112. package/src/tzero/tzero_scip.py +368 -368
  113. package/src/tzero/tzero_security.py +573 -573
  114. package/src/tzero/tzero_semantic_merge.py +189 -189
  115. package/src/tzero/tzero_snapshot.py +471 -471
  116. package/src/tzero/tzero_stubs.py +313 -313
  117. package/src/tzero/tzero_subagent_engine.py +459 -459
  118. package/src/tzero/tzero_superdesign.py +774 -774
  119. package/src/tzero/tzero_sync.py +241 -241
  120. package/src/tzero/tzero_task_benchmark.py +506 -458
  121. package/src/tzero/tzero_tui.py +313 -313
  122. package/src/tzero/tzero_turbo.py +264 -264
  123. package/src/tzero/tzero_v3.py +9997 -9900
  124. package/src/tzero.py +6 -6
  125. package/src/tzero_mcp.py +25 -0
  126. package/test/package.test.js +55 -55
@@ -1,198 +1,198 @@
1
- # -*- coding: utf-8 -*-
2
- """T-Zero Rust Core Bridge (ctypes / subprocess / WASM Agent Kernel Sandbox).
3
-
4
- Bridges Python engines to `crates/tzero_jarvis_core` compiled shared libraries
5
- (`cdylib` via `ctypes`) or native CLI binaries when compiled, with an identical
6
- pure-Python fallback when Rust binaries are not present on the host.
7
-
8
- 100% Free, Local, Offline, Zero-Leak Certified.
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- import ctypes
14
- import json
15
- import os
16
- import shutil
17
- from typing import Any, Dict, List, Optional, Set
18
-
19
-
20
- def _repo_crate_dir() -> str:
21
- return os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "crates", "tzero_jarvis_core")
22
-
23
-
24
- def _pure_fnv1a_64(text: str) -> int:
25
- h = 0xCBF29CE484222325
26
- prime = 0x100000001B3
27
- mask = 0xFFFFFFFFFFFFFFFF
28
- for b in (text or "").encode("utf-8", errors="replace"):
29
- h ^= b
30
- h = (h * prime) & mask
31
- return h
32
-
33
-
34
- def _pure_jaccard_shingles(a: str, b: str, ngram: int = 3) -> float:
35
- sa = a or ""
36
- sb = b or ""
37
- if sa == sb:
38
- return 1.0
39
- n = max(1, int(ngram))
40
- if len(sa) < n or len(sb) < n:
41
- ta: Set[str] = set(sa.split())
42
- tb: Set[str] = set(sb.split())
43
- else:
44
- ta = {sa[i:i + n] for i in range(len(sa) - n + 1)}
45
- tb = {sb[i:i + n] for i in range(len(sb) - n + 1)}
46
- if not ta and not tb:
47
- return 1.0
48
- union = len(ta | tb)
49
- return round(len(ta & tb) / union, 6) if union else 0.0
50
-
51
-
52
- class RustCoreBridge:
53
- """Adaptive FFI/subprocess bridge to crates/tzero_jarvis_core with pure-Python fallback."""
54
-
55
- def __init__(self, prefer_native: bool = True) -> None:
56
- self._cdylib: Optional[Any] = None
57
- self._pyo3_mod: Optional[Any] = None
58
- self._bin_path: Optional[str] = None
59
- if prefer_native:
60
- self._cdylib = self._try_load_cdylib()
61
- if self._cdylib is None:
62
- self._pyo3_mod = self._try_load_pyo3()
63
- if self._cdylib is None and self._pyo3_mod is None:
64
- self._bin_path = self._find_native_binary()
65
-
66
- @classmethod
67
- def _try_load_cdylib(cls) -> Optional[Any]:
68
- crate = _repo_crate_dir()
69
- ext = ".dll" if os.name == "nt" else (".dylib" if os.uname().sysname == "Darwin" else ".so")
70
- names = [f"tzero_jarvis_core{ext}", f"libtzero_jarvis_core{ext}"]
71
- for build in ("release", "debug"):
72
- for fname in names:
73
- cand = os.path.join(crate, "target", build, fname)
74
- if os.path.isfile(cand):
75
- try:
76
- lib = ctypes.CDLL(cand)
77
- if hasattr(lib, "tzero_fnv1a_hash64"):
78
- lib.tzero_fnv1a_hash64.argtypes = [ctypes.c_char_p, ctypes.c_size_t]
79
- lib.tzero_fnv1a_hash64.restype = ctypes.c_uint64
80
- if hasattr(lib, "tzero_jaccard_shingles_f64"):
81
- lib.tzero_jaccard_shingles_f64.argtypes = [
82
- ctypes.c_char_p, ctypes.c_size_t,
83
- ctypes.c_char_p, ctypes.c_size_t,
84
- ctypes.c_size_t,
85
- ]
86
- lib.tzero_jaccard_shingles_f64.restype = ctypes.c_double
87
- return lib
88
- except OSError:
89
- pass
90
- return None
91
-
92
- @classmethod
93
- def _try_load_pyo3(cls) -> Optional[Any]:
94
- try:
95
- import tzero_jarvis_core # type: ignore
96
- return tzero_jarvis_core
97
- except ImportError:
98
- return None
99
-
100
- @classmethod
101
- def _find_native_binary(cls) -> Optional[str]:
102
- crate = _repo_crate_dir()
103
- exe = "tzero-jarvis.exe" if os.name == "nt" else "tzero-jarvis"
104
- for build in ("release", "debug"):
105
- cand = os.path.join(crate, "target", build, exe)
106
- if os.path.isfile(cand):
107
- return cand
108
- return None
109
-
110
- def backend(self) -> str:
111
- if self._cdylib is not None:
112
- return "ctypes"
113
- if self._pyo3_mod is not None:
114
- return "pyo3"
115
- if self._bin_path is not None:
116
- return "subprocess"
117
- return "python-fallback"
118
-
119
- def fnv1a_hash(self, text: str) -> int:
120
- if self._cdylib is not None and hasattr(self._cdylib, "tzero_fnv1a_hash64"):
121
- raw = (text or "").encode("utf-8", errors="replace")
122
- return int(self._cdylib.tzero_fnv1a_hash64(raw, len(raw)))
123
- return _pure_fnv1a_64(text)
124
-
125
- def shingle_similarity(self, a: str, b: str, ngram: int = 3) -> float:
126
- if self._cdylib is not None and hasattr(self._cdylib, "tzero_jaccard_shingles_f64"):
127
- ba = (a or "").encode("utf-8", errors="replace")
128
- bb = (b or "").encode("utf-8", errors="replace")
129
- return float(self._cdylib.tzero_jaccard_shingles_f64(ba, len(ba), bb, len(bb), max(1, int(ngram))))
130
- if self._pyo3_mod is not None and hasattr(self._pyo3_mod, "jaccard_shingles"):
131
- return float(self._pyo3_mod.jaccard_shingles(a, b, int(ngram)))
132
- return _pure_jaccard_shingles(a, b, ngram=ngram)
133
-
134
-
135
- class AgentKernelSandbox:
136
- """Zero-network WASM/capability validator for autonomous T-Zero agent kernel tasks."""
137
-
138
- def __init__(self, workspace_dir: str = ".") -> None:
139
- self.workspace_dir = os.path.abspath(workspace_dir)
140
- self.bridge = RustCoreBridge()
141
-
142
- def detect_wasm_runtime(self) -> Optional[str]:
143
- for tool in ("wasmtime", "wasmer", "wazero"):
144
- if shutil.which(tool):
145
- return tool
146
- return None
147
-
148
- def validate_execution_plan(self, plan: Dict[str, Any]) -> Dict[str, Any]:
149
- allow_network = bool(plan.get("allow_network", False))
150
- if allow_network:
151
- return {
152
- "allowed": False,
153
- "reason": "Blocked by T-Zero Agent Kernel Sandbox: outbound network access forbidden.",
154
- "backend": self.bridge.backend(),
155
- }
156
-
157
- all_paths: List[Any] = []
158
- for path_key in ("read_paths", "write_paths", "target_paths", "paths"):
159
- all_paths.extend(plan.get(path_key) or [])
160
-
161
- for p in all_paths:
162
- abs_p = os.path.abspath(str(p))
163
- try:
164
- if os.path.commonpath([self.workspace_dir, abs_p]) != self.workspace_dir:
165
- return {
166
- "allowed": False,
167
- "reason": f"Blocked path outside workspace sandbox: {p}",
168
- "backend": self.bridge.backend(),
169
- }
170
- except ValueError:
171
- return {
172
- "allowed": False,
173
- "reason": f"Blocked invalid path: {p}",
174
- "backend": self.bridge.backend(),
175
- }
176
-
177
- return {
178
- "allowed": True,
179
- "workspace_dir": self.workspace_dir,
180
- "backend": self.bridge.backend(),
181
- "wasm_runtime": self.detect_wasm_runtime() or "policy-dryrun",
182
- "zero_leak": True,
183
- "memory_limit_mb": int(plan.get("memory_limit_mb", 128)),
184
- }
185
-
186
-
187
- def run_agent_kernel_cli(workspace_dir: str = ".") -> int:
188
- """Runs Agent Kernel Sandbox capability manifest & validation check."""
189
- kernel = AgentKernelSandbox(workspace_dir=workspace_dir)
190
- manifest = kernel.validate_execution_plan({
191
- "action": "sandbox-status",
192
- "allow_network": False,
193
- "read_paths": [workspace_dir],
194
- "memory_limit_mb": 128,
195
- })
196
- manifest["cargo_available"] = shutil.which("cargo") is not None
197
- print(json.dumps(manifest, indent=2))
198
- return 0 if manifest["allowed"] else 1
1
+ # -*- coding: utf-8 -*-
2
+ """T-Zero Rust Core Bridge (ctypes / subprocess / WASM Agent Kernel Sandbox).
3
+
4
+ Bridges Python engines to `crates/tzero_jarvis_core` compiled shared libraries
5
+ (`cdylib` via `ctypes`) or native CLI binaries when compiled, with an identical
6
+ pure-Python fallback when Rust binaries are not present on the host.
7
+
8
+ 100% Free, Local, Offline, Zero-Leak Certified.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import ctypes
14
+ import json
15
+ import os
16
+ import shutil
17
+ from typing import Any, Dict, List, Optional, Set
18
+
19
+
20
+ def _repo_crate_dir() -> str:
21
+ return os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "crates", "tzero_jarvis_core")
22
+
23
+
24
+ def _pure_fnv1a_64(text: str) -> int:
25
+ h = 0xCBF29CE484222325
26
+ prime = 0x100000001B3
27
+ mask = 0xFFFFFFFFFFFFFFFF
28
+ for b in (text or "").encode("utf-8", errors="replace"):
29
+ h ^= b
30
+ h = (h * prime) & mask
31
+ return h
32
+
33
+
34
+ def _pure_jaccard_shingles(a: str, b: str, ngram: int = 3) -> float:
35
+ sa = a or ""
36
+ sb = b or ""
37
+ if sa == sb:
38
+ return 1.0
39
+ n = max(1, int(ngram))
40
+ if len(sa) < n or len(sb) < n:
41
+ ta: Set[str] = set(sa.split())
42
+ tb: Set[str] = set(sb.split())
43
+ else:
44
+ ta = {sa[i:i + n] for i in range(len(sa) - n + 1)}
45
+ tb = {sb[i:i + n] for i in range(len(sb) - n + 1)}
46
+ if not ta and not tb:
47
+ return 1.0
48
+ union = len(ta | tb)
49
+ return round(len(ta & tb) / union, 6) if union else 0.0
50
+
51
+
52
+ class RustCoreBridge:
53
+ """Adaptive FFI/subprocess bridge to crates/tzero_jarvis_core with pure-Python fallback."""
54
+
55
+ def __init__(self, prefer_native: bool = True) -> None:
56
+ self._cdylib: Optional[Any] = None
57
+ self._pyo3_mod: Optional[Any] = None
58
+ self._bin_path: Optional[str] = None
59
+ if prefer_native:
60
+ self._cdylib = self._try_load_cdylib()
61
+ if self._cdylib is None:
62
+ self._pyo3_mod = self._try_load_pyo3()
63
+ if self._cdylib is None and self._pyo3_mod is None:
64
+ self._bin_path = self._find_native_binary()
65
+
66
+ @classmethod
67
+ def _try_load_cdylib(cls) -> Optional[Any]:
68
+ crate = _repo_crate_dir()
69
+ ext = ".dll" if os.name == "nt" else (".dylib" if os.uname().sysname == "Darwin" else ".so")
70
+ names = [f"tzero_jarvis_core{ext}", f"libtzero_jarvis_core{ext}"]
71
+ for build in ("release", "debug"):
72
+ for fname in names:
73
+ cand = os.path.join(crate, "target", build, fname)
74
+ if os.path.isfile(cand):
75
+ try:
76
+ lib = ctypes.CDLL(cand)
77
+ if hasattr(lib, "tzero_fnv1a_hash64"):
78
+ lib.tzero_fnv1a_hash64.argtypes = [ctypes.c_char_p, ctypes.c_size_t]
79
+ lib.tzero_fnv1a_hash64.restype = ctypes.c_uint64
80
+ if hasattr(lib, "tzero_jaccard_shingles_f64"):
81
+ lib.tzero_jaccard_shingles_f64.argtypes = [
82
+ ctypes.c_char_p, ctypes.c_size_t,
83
+ ctypes.c_char_p, ctypes.c_size_t,
84
+ ctypes.c_size_t,
85
+ ]
86
+ lib.tzero_jaccard_shingles_f64.restype = ctypes.c_double
87
+ return lib
88
+ except OSError:
89
+ pass
90
+ return None
91
+
92
+ @classmethod
93
+ def _try_load_pyo3(cls) -> Optional[Any]:
94
+ try:
95
+ import tzero_jarvis_core # type: ignore
96
+ return tzero_jarvis_core
97
+ except ImportError:
98
+ return None
99
+
100
+ @classmethod
101
+ def _find_native_binary(cls) -> Optional[str]:
102
+ crate = _repo_crate_dir()
103
+ exe = "tzero-jarvis.exe" if os.name == "nt" else "tzero-jarvis"
104
+ for build in ("release", "debug"):
105
+ cand = os.path.join(crate, "target", build, exe)
106
+ if os.path.isfile(cand):
107
+ return cand
108
+ return None
109
+
110
+ def backend(self) -> str:
111
+ if self._cdylib is not None:
112
+ return "ctypes"
113
+ if self._pyo3_mod is not None:
114
+ return "pyo3"
115
+ if self._bin_path is not None:
116
+ return "subprocess"
117
+ return "python-fallback"
118
+
119
+ def fnv1a_hash(self, text: str) -> int:
120
+ if self._cdylib is not None and hasattr(self._cdylib, "tzero_fnv1a_hash64"):
121
+ raw = (text or "").encode("utf-8", errors="replace")
122
+ return int(self._cdylib.tzero_fnv1a_hash64(raw, len(raw)))
123
+ return _pure_fnv1a_64(text)
124
+
125
+ def shingle_similarity(self, a: str, b: str, ngram: int = 3) -> float:
126
+ if self._cdylib is not None and hasattr(self._cdylib, "tzero_jaccard_shingles_f64"):
127
+ ba = (a or "").encode("utf-8", errors="replace")
128
+ bb = (b or "").encode("utf-8", errors="replace")
129
+ return float(self._cdylib.tzero_jaccard_shingles_f64(ba, len(ba), bb, len(bb), max(1, int(ngram))))
130
+ if self._pyo3_mod is not None and hasattr(self._pyo3_mod, "jaccard_shingles"):
131
+ return float(self._pyo3_mod.jaccard_shingles(a, b, int(ngram)))
132
+ return _pure_jaccard_shingles(a, b, ngram=ngram)
133
+
134
+
135
+ class AgentKernelSandbox:
136
+ """Zero-network WASM/capability validator for autonomous T-Zero agent kernel tasks."""
137
+
138
+ def __init__(self, workspace_dir: str = ".") -> None:
139
+ self.workspace_dir = os.path.abspath(workspace_dir)
140
+ self.bridge = RustCoreBridge()
141
+
142
+ def detect_wasm_runtime(self) -> Optional[str]:
143
+ for tool in ("wasmtime", "wasmer", "wazero"):
144
+ if shutil.which(tool):
145
+ return tool
146
+ return None
147
+
148
+ def validate_execution_plan(self, plan: Dict[str, Any]) -> Dict[str, Any]:
149
+ allow_network = bool(plan.get("allow_network", False))
150
+ if allow_network:
151
+ return {
152
+ "allowed": False,
153
+ "reason": "Blocked by T-Zero Agent Kernel Sandbox: outbound network access forbidden.",
154
+ "backend": self.bridge.backend(),
155
+ }
156
+
157
+ all_paths: List[Any] = []
158
+ for path_key in ("read_paths", "write_paths", "target_paths", "paths"):
159
+ all_paths.extend(plan.get(path_key) or [])
160
+
161
+ for p in all_paths:
162
+ abs_p = os.path.abspath(str(p))
163
+ try:
164
+ if os.path.commonpath([self.workspace_dir, abs_p]) != self.workspace_dir:
165
+ return {
166
+ "allowed": False,
167
+ "reason": f"Blocked path outside workspace sandbox: {p}",
168
+ "backend": self.bridge.backend(),
169
+ }
170
+ except ValueError:
171
+ return {
172
+ "allowed": False,
173
+ "reason": f"Blocked invalid path: {p}",
174
+ "backend": self.bridge.backend(),
175
+ }
176
+
177
+ return {
178
+ "allowed": True,
179
+ "workspace_dir": self.workspace_dir,
180
+ "backend": self.bridge.backend(),
181
+ "wasm_runtime": self.detect_wasm_runtime() or "policy-dryrun",
182
+ "zero_leak": True,
183
+ "memory_limit_mb": int(plan.get("memory_limit_mb", 128)),
184
+ }
185
+
186
+
187
+ def run_agent_kernel_cli(workspace_dir: str = ".") -> int:
188
+ """Runs Agent Kernel Sandbox capability manifest & validation check."""
189
+ kernel = AgentKernelSandbox(workspace_dir=workspace_dir)
190
+ manifest = kernel.validate_execution_plan({
191
+ "action": "sandbox-status",
192
+ "allow_network": False,
193
+ "read_paths": [workspace_dir],
194
+ "memory_limit_mb": 128,
195
+ })
196
+ manifest["cargo_available"] = shutil.which("cargo") is not None
197
+ print(json.dumps(manifest, indent=2))
198
+ return 0 if manifest["allowed"] else 1