zerochat 10.22.0__tar.gz → 10.24.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.22.0/zerochat.egg-info → zerochat-10.24.0}/PKG-INFO +1 -1
- {zerochat-10.22.0 → zerochat-10.24.0}/pyproject.toml +1 -1
- {zerochat-10.22.0 → zerochat-10.24.0/zerochat.egg-info}/PKG-INFO +1 -1
- {zerochat-10.22.0 → zerochat-10.24.0}/zerochat.py +38 -19
- {zerochat-10.22.0 → zerochat-10.24.0}/LICENSE +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/README.md +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/setup.cfg +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/zerochat.egg-info/SOURCES.txt +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/zerochat.egg-info/dependency_links.txt +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/zerochat.egg-info/entry_points.txt +0 -0
- {zerochat-10.22.0 → zerochat-10.24.0}/zerochat.egg-info/top_level.txt +0 -0
|
@@ -1560,7 +1560,7 @@ def dispatch_browser(method: str, params: dict) -> RpcOutcome:
|
|
|
1560
1560
|
|
|
1561
1561
|
|
|
1562
1562
|
|
|
1563
|
-
SOURCE_BACKEND_VERSION = "10.
|
|
1563
|
+
SOURCE_BACKEND_VERSION = "10.24.0"
|
|
1564
1564
|
|
|
1565
1565
|
|
|
1566
1566
|
def _read_source_version(filename: str) -> str | None:
|
|
@@ -2915,12 +2915,20 @@ def open_storage():
|
|
|
2915
2915
|
|
|
2916
2916
|
|
|
2917
2917
|
def normalize_profile_id(name: str, given_id: str | None = None) -> str:
|
|
2918
|
-
"""Genera o normaliza un identificador único para el perfil
|
|
2918
|
+
"""Genera o normaliza un identificador único para el perfil."""
|
|
2919
2919
|
if given_id and isinstance(given_id, str) and given_id.strip():
|
|
2920
2920
|
clean = given_id.strip()
|
|
2921
2921
|
return clean if clean.startswith("profile:") else f"profile:{clean}"
|
|
2922
|
-
clean_name = urllib.parse.quote(name.strip())
|
|
2923
|
-
return f"profile:
|
|
2922
|
+
clean_name = urllib.parse.quote(name.strip(), safe="-_.!~*'()")
|
|
2923
|
+
return f"profile:{clean_name}"
|
|
2924
|
+
|
|
2925
|
+
|
|
2926
|
+
def _parse_optional_timestamp(value, field_name: str) -> int | None:
|
|
2927
|
+
if value is None:
|
|
2928
|
+
return None
|
|
2929
|
+
if isinstance(value, bool) or not isinstance(value, (int, float)) or not math.isfinite(value) or value <= 0:
|
|
2930
|
+
raise ValueError(f"{field_name} debe ser una marca de tiempo positiva")
|
|
2931
|
+
return int(value)
|
|
2924
2932
|
|
|
2925
2933
|
|
|
2926
2934
|
def validate_profile_payload(record: dict) -> tuple[str, str, str, dict, str | None]:
|
|
@@ -2956,7 +2964,7 @@ def validate_profile_payload(record: dict) -> tuple[str, str, str, dict, str | N
|
|
|
2956
2964
|
|
|
2957
2965
|
def _row_to_profile(row: sqlite3.Row) -> dict:
|
|
2958
2966
|
"""Transforma una fila SQLite en el objeto de perfil del servidor, sin su API key: solo `hasApiKey`.
|
|
2959
|
-
La clave la entrega get_general_profile_with_key
|
|
2967
|
+
La clave la entrega get_general_profile_with_key al runner o bajo demanda con zerochat/profiles/reveal."""
|
|
2960
2968
|
try:
|
|
2961
2969
|
settings = json.loads(row["settings_json"])
|
|
2962
2970
|
except (json.JSONDecodeError, TypeError):
|
|
@@ -3010,21 +3018,17 @@ def get_general_profile_by_name(name: str) -> dict | None:
|
|
|
3010
3018
|
"""Recupera un perfil de servidor por su nombre."""
|
|
3011
3019
|
if not name or not isinstance(name, str) or not name.strip():
|
|
3012
3020
|
return None
|
|
3013
|
-
clean = name.strip()
|
|
3014
|
-
stripped = clean[2:].strip() if clean[:2].upper() == "Z-" else clean
|
|
3015
|
-
candidates = list(dict.fromkeys([clean, stripped, f"Z-{stripped}", f"Z- {stripped}"]))
|
|
3016
3021
|
with open_storage() as conn:
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
if row:
|
|
3020
|
-
return _row_to_profile(row)
|
|
3021
|
-
return None
|
|
3022
|
+
row = conn.execute("SELECT * FROM profiles WHERE name = ? COLLATE NOCASE;", (name.strip(),)).fetchone()
|
|
3023
|
+
return _row_to_profile(row) if row else None
|
|
3022
3024
|
|
|
3023
3025
|
|
|
3024
3026
|
def save_general_profile(record: dict) -> dict:
|
|
3025
|
-
"""Guarda (crea o actualiza) un perfil de
|
|
3027
|
+
"""Guarda (crea o actualiza) un perfil en SQLite conservando el updatedAt de origen si se indica."""
|
|
3026
3028
|
profile_id, name, description, settings, api_key = validate_profile_payload(record)
|
|
3027
3029
|
now = int(time.time() * 1000)
|
|
3030
|
+
updated_at = _parse_optional_timestamp(record.get("updatedAt"), "updatedAt") or now
|
|
3031
|
+
created_at = _parse_optional_timestamp(record.get("createdAt"), "createdAt") or updated_at
|
|
3028
3032
|
|
|
3029
3033
|
with open_storage() as conn:
|
|
3030
3034
|
existing = conn.execute("SELECT * FROM profiles WHERE id = ?;", (profile_id,)).fetchone()
|
|
@@ -3050,12 +3054,12 @@ def save_general_profile(record: dict) -> dict:
|
|
|
3050
3054
|
UPDATE profiles
|
|
3051
3055
|
SET name = ?, description = ?, settings_json = ?, api_key = ?, version = ?, updated_at = ?
|
|
3052
3056
|
WHERE id = ?;
|
|
3053
|
-
""", (name, description, json.dumps(settings), final_api_key, version,
|
|
3057
|
+
""", (name, description, json.dumps(settings), final_api_key, version, updated_at, profile_id))
|
|
3054
3058
|
else:
|
|
3055
3059
|
conn.execute("""
|
|
3056
3060
|
INSERT INTO profiles (id, name, description, settings_json, api_key, version, created_at, updated_at)
|
|
3057
3061
|
VALUES (?, ?, ?, ?, ?, 1, ?, ?);
|
|
3058
|
-
""", (profile_id, name, description, json.dumps(settings), obfuscate_secret(api_key or ""),
|
|
3062
|
+
""", (profile_id, name, description, json.dumps(settings), obfuscate_secret(api_key or ""), created_at, updated_at))
|
|
3059
3063
|
|
|
3060
3064
|
conn.commit()
|
|
3061
3065
|
saved_row = conn.execute("SELECT * FROM profiles WHERE id = ?;", (profile_id,)).fetchone()
|
|
@@ -3526,6 +3530,20 @@ def secret_names(prefix: str) -> set[str]:
|
|
|
3526
3530
|
rows = conn.execute("SELECT name FROM secrets WHERE substr(name, 1, ?) = ?;", (len(prefix), prefix)).fetchall()
|
|
3527
3531
|
return {row["name"] for row in rows}
|
|
3528
3532
|
|
|
3533
|
+
|
|
3534
|
+
SERVER_ID_KEY = "system:server_id"
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
def get_server_id() -> str:
|
|
3538
|
+
"""Identificador único y persistente de este servidor en SQLite."""
|
|
3539
|
+
with _STORAGE_LOCK:
|
|
3540
|
+
existing = get_secret(SERVER_ID_KEY)
|
|
3541
|
+
if existing:
|
|
3542
|
+
return existing
|
|
3543
|
+
server_id = str(uuid.uuid4())
|
|
3544
|
+
save_secret(SERVER_ID_KEY, server_id)
|
|
3545
|
+
return server_id
|
|
3546
|
+
|
|
3529
3547
|
# --- mcp.manager ---
|
|
3530
3548
|
"""Gestor de servicios MCP: descubrimiento en ~/zerochat/services, actualización desde el catálogo, preferencias,
|
|
3531
3549
|
arranque y parada, y nombres públicos de sus herramientas."""
|
|
@@ -4722,8 +4740,8 @@ def _delete_profile(params: dict) -> RpcOutcome:
|
|
|
4722
4740
|
|
|
4723
4741
|
|
|
4724
4742
|
def _reveal_profile(params: dict) -> RpcOutcome:
|
|
4725
|
-
"""El perfil con su API key
|
|
4726
|
-
|
|
4743
|
+
"""El perfil con su API key bajo demanda cuando la interfaz ejecuta en el navegador o edita un perfil
|
|
4744
|
+
cuya clave solo está en el servidor (docs/M75-apikeys.md), y deja constancia en el registro."""
|
|
4727
4745
|
profile_id = params.get("id")
|
|
4728
4746
|
profile = get_general_profile_with_key(profile_id) if isinstance(profile_id, str) else None
|
|
4729
4747
|
if profile is None:
|
|
@@ -7640,6 +7658,7 @@ def live_state(ctx: SecurityContext, focus_conversation_id: str | None = None) -
|
|
|
7640
7658
|
"""
|
|
7641
7659
|
runs, focus_run = list_server_runs(focus_conversation_id)
|
|
7642
7660
|
return {
|
|
7661
|
+
"serverId": get_server_id(),
|
|
7643
7662
|
"cwd": str(ctx.workspace_dir),
|
|
7644
7663
|
"jobs": [{**job.summary(), "last_line": job.last_line()} for job in JOBS.running(ctx.key)],
|
|
7645
7664
|
"exit_on_close": EXIT_ON_CLOSE,
|
|
@@ -8479,7 +8498,7 @@ def _authorize(params: dict, ctx: SecurityContext) -> RpcOutcome:
|
|
|
8479
8498
|
exec_res, exec_err, tool_err = execute_tool(t_origin, ch["toolName"], with_job_key(t_args, ch.get("jobKey")), ctx, ch.get("conversationId") or "")
|
|
8480
8499
|
if exec_err:
|
|
8481
8500
|
return None, exec_err, tool_err
|
|
8482
|
-
return {"authorized": True, "result": exec_res}, None, tool_err
|
|
8501
|
+
return {"authorized": True, "result": exec_res, "policies": ACCESS_CONTROLLER.export_state(ctx)}, None, tool_err
|
|
8483
8502
|
|
|
8484
8503
|
|
|
8485
8504
|
SECURITY_METHODS = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|