zerochat 10.9.0__tar.gz → 10.10.0__tar.gz
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.
- {zerochat-10.9.0/zerochat.egg-info → zerochat-10.10.0}/PKG-INFO +1 -1
- {zerochat-10.9.0 → zerochat-10.10.0}/pyproject.toml +1 -1
- {zerochat-10.9.0 → zerochat-10.10.0/zerochat.egg-info}/PKG-INFO +1 -1
- {zerochat-10.9.0 → zerochat-10.10.0}/zerochat.py +36 -4
- {zerochat-10.9.0 → zerochat-10.10.0}/LICENSE +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/README.md +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/setup.cfg +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/zerochat.egg-info/SOURCES.txt +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/zerochat.egg-info/dependency_links.txt +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/zerochat.egg-info/entry_points.txt +0 -0
- {zerochat-10.9.0 → zerochat-10.10.0}/zerochat.egg-info/top_level.txt +0 -0
|
@@ -54,7 +54,7 @@ import zlib
|
|
|
54
54
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
55
55
|
from pathlib import Path
|
|
56
56
|
|
|
57
|
-
SOURCE_BACKEND_VERSION = "10.
|
|
57
|
+
SOURCE_BACKEND_VERSION = "10.10.0"
|
|
58
58
|
|
|
59
59
|
def _read_source_version(filename: str) -> str | None:
|
|
60
60
|
"""Lee la versión de un archivo del repositorio cuando se ejecuta desde fuentes."""
|
|
@@ -2217,6 +2217,7 @@ class AccessController:
|
|
|
2217
2217
|
self.session_tools: dict[str, dict] = {}
|
|
2218
2218
|
self.session_servers: dict[str, dict] = {}
|
|
2219
2219
|
self.pending_challenges: dict[str, dict] = {}
|
|
2220
|
+
self.allow_once: set[str] = set()
|
|
2220
2221
|
|
|
2221
2222
|
def _ensure_loaded(self, context: SecurityContext | None = None):
|
|
2222
2223
|
with self._lock:
|
|
@@ -2284,6 +2285,10 @@ class AccessController:
|
|
|
2284
2285
|
self.servers = dict(servers_map)
|
|
2285
2286
|
else:
|
|
2286
2287
|
raise ValueError("servers debe ser un diccionario de servidores.")
|
|
2288
|
+
if "allow_once" in state:
|
|
2289
|
+
raw_once = state["allow_once"]
|
|
2290
|
+
if isinstance(raw_once, (list, tuple, set)):
|
|
2291
|
+
self.allow_once = {str(item).strip() for item in raw_once if item and isinstance(item, str)}
|
|
2287
2292
|
if persist:
|
|
2288
2293
|
self.save_to_storage(context=context)
|
|
2289
2294
|
|
|
@@ -2443,12 +2448,21 @@ class AccessController:
|
|
|
2443
2448
|
self.save_to_storage()
|
|
2444
2449
|
return del_session or del_perm
|
|
2445
2450
|
|
|
2451
|
+
def set_allow_once(self, tools: list[str] | set[str] | tuple[str]):
|
|
2452
|
+
"""Define herramientas permitidas para una única ejecución inmediata."""
|
|
2453
|
+
with self._lock:
|
|
2454
|
+
if isinstance(tools, (list, tuple, set)):
|
|
2455
|
+
self.allow_once = {str(item).strip() for item in tools if item and isinstance(item, str)}
|
|
2456
|
+
else:
|
|
2457
|
+
self.allow_once.clear()
|
|
2458
|
+
|
|
2446
2459
|
def clear_session(self):
|
|
2447
2460
|
"""Limpia todas las autorizaciones temporales de la sesión activa."""
|
|
2448
2461
|
with self._lock:
|
|
2449
2462
|
self.session_tools.clear()
|
|
2450
2463
|
self.session_servers.clear()
|
|
2451
2464
|
self.pending_challenges.clear()
|
|
2465
|
+
self.allow_once.clear()
|
|
2452
2466
|
|
|
2453
2467
|
def create_challenge(self, tool_name: str, args: dict, decision: AccessDecision,
|
|
2454
2468
|
server_name: str = "", server_id: str = "") -> dict:
|
|
@@ -2635,7 +2649,14 @@ class AccessController:
|
|
|
2635
2649
|
if tool_name == JOB_CONTROL_TOOL or orig_name == JOB_CONTROL_TOOL:
|
|
2636
2650
|
return make_decision(TOOL_POLICY_ALLOW, "job_control_tool")
|
|
2637
2651
|
|
|
2638
|
-
# 3.
|
|
2652
|
+
# 3. Permiso de un solo uso (allow_once)
|
|
2653
|
+
with self._lock:
|
|
2654
|
+
if tool_name in self.allow_once or orig_name in self.allow_once:
|
|
2655
|
+
self.allow_once.discard(tool_name)
|
|
2656
|
+
self.allow_once.discard(orig_name)
|
|
2657
|
+
return make_decision(TOOL_POLICY_ALLOW, "allow_once_rule")
|
|
2658
|
+
|
|
2659
|
+
# 4. Política global allow_all
|
|
2639
2660
|
if self.global_policy == GLOBAL_POLICY_ALLOW_ALL:
|
|
2640
2661
|
return make_decision(TOOL_POLICY_ALLOW, "mcp_global_allow_all")
|
|
2641
2662
|
|
|
@@ -5149,9 +5170,20 @@ def save_conversation(session_meta: dict, messages: list[dict] | None = None) ->
|
|
|
5149
5170
|
if session_meta.get("serverRun") is not None:
|
|
5150
5171
|
extra["server_run"] = bool(session_meta.get("serverRun"))
|
|
5151
5172
|
|
|
5152
|
-
extra_json = json.dumps(extra, ensure_ascii=False) if extra else "{}"
|
|
5153
|
-
|
|
5154
5173
|
with open_storage() as conn:
|
|
5174
|
+
existing = conn.execute("SELECT created_at, extra_json, title FROM conversations WHERE id = ?;", (session_id,)).fetchone()
|
|
5175
|
+
if existing:
|
|
5176
|
+
if not session_meta.get("createdAt") and existing["created_at"]:
|
|
5177
|
+
created_at = int(existing["created_at"])
|
|
5178
|
+
if not title and existing["title"]:
|
|
5179
|
+
title = existing["title"]
|
|
5180
|
+
existing_extra = json.loads(existing["extra_json"]) if existing["extra_json"] else {}
|
|
5181
|
+
merged_extra = dict(existing_extra)
|
|
5182
|
+
merged_extra.update(extra)
|
|
5183
|
+
extra = merged_extra
|
|
5184
|
+
|
|
5185
|
+
extra_json = json.dumps(extra, ensure_ascii=False) if extra else "{}"
|
|
5186
|
+
|
|
5155
5187
|
conn.execute("""
|
|
5156
5188
|
INSERT INTO conversations (id, title, created_at, updated_at, message_count, extra_json)
|
|
5157
5189
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|