tzero-mcp 11.14.0 → 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.
- package/LICENSE +661 -21
- package/NOTICE +22 -0
- package/README.md +3 -3
- package/index.js +5 -0
- package/package.json +3 -2
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +5 -0
- package/src/tzero/tzero_benchmark.py +2 -2
- package/src/tzero/tzero_blackboard.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +658 -10
- package/src/tzero/tzero_commit.py +1 -1
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_cost.py +1 -1
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +1 -1
- package/src/tzero/tzero_drift.py +1 -1
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_infra.py +1 -1
- package/src/tzero/tzero_jarvis/__init__.py +15 -1
- package/src/tzero/tzero_jarvis/agent_guard.py +620 -0
- package/src/tzero/tzero_jarvis/creative_director.py +1 -1
- package/src/tzero/tzero_jarvis/orchestrator.py +36 -34
- package/src/tzero/tzero_jarvis/self_healing.py +325 -250
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +121 -63
- package/src/tzero/tzero_promo.py +504 -0
- package/src/tzero/tzero_replay.py +1 -1
- package/src/tzero/tzero_semantic_merge.py +1 -1
- package/src/tzero/tzero_stubs.py +1 -1
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_tui.py +2 -2
- package/src/tzero/tzero_turbo.py +1 -1
- package/src/tzero/tzero_v3.py +61 -8
- package/src/tzero/tzero_welcome.py +2 -2
- 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
|
-
|
|
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":
|
|
102
|
-
"stderr":
|
|
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
|
-
|
|
117
|
-
|
|
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":
|
|
144
|
-
"attempts":
|
|
145
|
-
"final_output": res
|
|
146
|
-
"error": res
|
|
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:
|