tzero-mcp 11.12.1 → 11.15.2

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 (45) hide show
  1. package/LICENSE +661 -21
  2. package/NOTICE +22 -0
  3. package/README.md +3 -3
  4. package/bin/postinstall.js +22 -0
  5. package/bin/tzero-mcp.js +2 -1
  6. package/bin/tzero.js +8 -1
  7. package/index.js +5 -0
  8. package/package.json +4 -2
  9. package/src/addmcp.py +3 -3
  10. package/src/app.py +1 -1
  11. package/src/tzero/__init__.py +5 -0
  12. package/src/tzero/addmcp.py +18 -0
  13. package/src/tzero/tzero_benchmark.py +2 -2
  14. package/src/tzero/tzero_blackboard.py +1 -1
  15. package/src/tzero/tzero_budget.py +1 -1
  16. package/src/tzero/tzero_card.py +1 -1
  17. package/src/tzero/tzero_ci.py +658 -10
  18. package/src/tzero/tzero_commit.py +1 -1
  19. package/src/tzero/tzero_contracts.py +2 -2
  20. package/src/tzero/tzero_cost.py +1 -1
  21. package/src/tzero/tzero_dashboard.py +3 -3
  22. package/src/tzero/tzero_debt.py +1 -1
  23. package/src/tzero/tzero_drift.py +1 -1
  24. package/src/tzero/tzero_explain.py +1 -1
  25. package/src/tzero/tzero_features.py +268 -37
  26. package/src/tzero/tzero_golden.py +2 -2
  27. package/src/tzero/tzero_hallucination_proof.py +901 -0
  28. package/src/tzero/tzero_infra.py +1 -1
  29. package/src/tzero/tzero_jarvis/__init__.py +15 -1
  30. package/src/tzero/tzero_jarvis/agent_guard.py +620 -0
  31. package/src/tzero/tzero_jarvis/creative_director.py +1 -1
  32. package/src/tzero/tzero_jarvis/orchestrator.py +36 -34
  33. package/src/tzero/tzero_jarvis/self_healing.py +325 -250
  34. package/src/tzero/tzero_lsp.py +1 -1
  35. package/src/tzero/tzero_mcp.py +184 -53
  36. package/src/tzero/tzero_promo.py +504 -0
  37. package/src/tzero/tzero_replay.py +1 -1
  38. package/src/tzero/tzero_semantic_merge.py +1 -1
  39. package/src/tzero/tzero_stubs.py +1 -1
  40. package/src/tzero/tzero_task_benchmark.py +2 -2
  41. package/src/tzero/tzero_tui.py +2 -2
  42. package/src/tzero/tzero_turbo.py +1 -1
  43. package/src/tzero/tzero_v3.py +124 -13
  44. package/src/tzero/tzero_welcome.py +135 -0
  45. package/test/package.test.js +1 -1
@@ -28,6 +28,13 @@ from typing import Dict, List, Optional, Any, Callable
28
28
  from .semantic_compressor import get_global_compressor
29
29
  from .zero_key_router import ZeroKeyAIRouter
30
30
  from .workspace_orchestrator import WorkspaceOrchestrator, WorkspaceProfile
31
+ from .agent_guard import (
32
+ CommandRiskAssessor,
33
+ CommandExecutionPolicy,
34
+ SecretRedactor,
35
+ GLOBAL_AUDIT_LOGGER,
36
+ )
37
+ from .self_healing import SelfHealingExecutionEngine
31
38
 
32
39
  # Core T-Zero Import
33
40
  try:
@@ -85,9 +92,25 @@ class JarvisOrchestrator:
85
92
  def execute_terminal(self, command: str, cwd: Optional[str] = None, timeout: int = 40) -> Dict[str, Any]:
86
93
  """PowerShell / Komut satırı üzerinden komut çalıştırır."""
87
94
  work_dir = cwd or self.workspace_root
95
+ policy = CommandExecutionPolicy.from_environment()
96
+ evaluation = CommandRiskAssessor.assess(command)
97
+
98
+ # Enforce operator policy when agent shell execution is evaluated
99
+ if os.environ.get("TZERO_ENFORCE_AGENT_POLICY") == "1" or not policy.allow_agent_shell:
100
+ allowed, reason = policy.is_command_allowed(evaluation)
101
+ if not allowed:
102
+ GLOBAL_AUDIT_LOGGER.record("ORCHESTRATOR_COMMAND_BLOCKED", command, "DENY", reason)
103
+ return {
104
+ "exit_code": -1,
105
+ "stdout": "",
106
+ "stderr": f"Command blocked by safety policy: {reason}",
107
+ "success": False
108
+ }
109
+
88
110
  try:
111
+ shell_cmd = ["powershell", "-NoProfile", "-Command", command] if os.name == "nt" else ["sh", "-c", command]
89
112
  p = subprocess.Popen(
90
- ["powershell", "-NoProfile", "-Command", command],
113
+ shell_cmd,
91
114
  cwd=work_dir,
92
115
  stdout=subprocess.PIPE,
93
116
  stderr=subprocess.PIPE,
@@ -96,54 +119,33 @@ class JarvisOrchestrator:
96
119
  errors="replace"
97
120
  )
98
121
  stdout, stderr = p.communicate(timeout=timeout)
122
+ safe_stdout = SecretRedactor.sanitize(stdout.strip())
123
+ safe_stderr = SecretRedactor.sanitize(stderr.strip())
99
124
  return {
100
125
  "exit_code": p.returncode,
101
- "stdout": stdout.strip(),
102
- "stderr": stderr.strip(),
126
+ "stdout": safe_stdout,
127
+ "stderr": safe_stderr,
103
128
  "success": p.returncode == 0
104
129
  }
105
130
  except subprocess.TimeoutExpired:
106
131
  p.kill()
107
132
  return {"exit_code": -1, "stdout": "", "stderr": f"Komut zaman aşımına uğradı ({timeout}s).", "success": False}
108
133
  except Exception as e:
109
- return {"exit_code": -1, "stdout": "", "stderr": str(e), "success": False}
134
+ return {"exit_code": -1, "stdout": "", "stderr": SecretRedactor.sanitize(str(e)), "success": False}
110
135
 
111
136
  def run_self_healing_command(self, command: str, max_retries: int = 2) -> Dict[str, Any]:
112
137
  """
113
138
  Komutu çalıştırır, hata oluşursa traceback'i analiz edip
114
139
  otonom iyileştirme adımlarıyla tekrar dener.
115
140
  """
116
- attempts = 0
117
- current_cmd = command
118
-
119
- while attempts <= max_retries:
120
- res = self.execute_terminal(current_cmd)
121
- if res["success"]:
122
- return {
123
- "success": True,
124
- "attempts": attempts,
125
- "final_output": res["stdout"],
126
- "error": None
127
- }
128
-
129
- attempts += 1
130
- err = res["stderr"]
131
- logger.warning(f"Otonom Hata Tespiti (Deneme {attempts}/{max_retries}): {err[:150]}")
132
-
133
- # Basit eksik paket tespiti (Örn: ModuleNotFoundError: No module named 'xyz')
134
- mod_match = re.search(r"No module named ['\"]([^'\"]+)['\"]", err)
135
- if mod_match:
136
- missing_pkg = mod_match.group(1)
137
- pip_res = self.execute_terminal(f"python -m pip install {missing_pkg}")
138
- if pip_res["success"]:
139
- logger.info(f"Otonom Paket Onarımı: {missing_pkg} yüklendi.")
140
- continue
141
-
141
+ engine = SelfHealingExecutionEngine(work_dir=self.workspace_root)
142
+ res = engine.execute_and_heal(command, max_retries=max_retries)
142
143
  return {
143
- "success": False,
144
- "attempts": attempts,
145
- "final_output": res["stdout"],
146
- "error": res["stderr"]
144
+ "success": res.success,
145
+ "attempts": len(res.applied_patches),
146
+ "final_output": res.stdout,
147
+ "error": res.stderr if not res.success else None,
148
+ "diagnostics": res.diagnostics
147
149
  }
148
150
 
149
151
  def orchestrate_goal(self, goal: str, auto_heal: bool = True) -> AutonomousGoalResult: