zerochat 10.13.0__tar.gz → 10.14.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.13.0/zerochat.egg-info → zerochat-10.14.0}/PKG-INFO +1 -1
- {zerochat-10.13.0 → zerochat-10.14.0}/pyproject.toml +1 -1
- {zerochat-10.13.0 → zerochat-10.14.0/zerochat.egg-info}/PKG-INFO +1 -1
- {zerochat-10.13.0 → zerochat-10.14.0}/zerochat.py +35 -20
- {zerochat-10.13.0 → zerochat-10.14.0}/LICENSE +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/README.md +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/setup.cfg +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/zerochat.egg-info/SOURCES.txt +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/zerochat.egg-info/dependency_links.txt +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/zerochat.egg-info/entry_points.txt +0 -0
- {zerochat-10.13.0 → zerochat-10.14.0}/zerochat.egg-info/top_level.txt +0 -0
|
@@ -56,7 +56,7 @@ import zlib
|
|
|
56
56
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
57
57
|
from pathlib import Path
|
|
58
58
|
|
|
59
|
-
SOURCE_BACKEND_VERSION = "10.
|
|
59
|
+
SOURCE_BACKEND_VERSION = "10.14.0"
|
|
60
60
|
|
|
61
61
|
def _read_source_version(filename: str) -> str | None:
|
|
62
62
|
"""Lee la versión de un archivo del repositorio cuando se ejecuta desde fuentes."""
|
|
@@ -5236,16 +5236,13 @@ def _row_to_conversation_header(row: sqlite3.Row) -> dict:
|
|
|
5236
5236
|
"updatedAt": row["updated_at"],
|
|
5237
5237
|
"messageCount": row["message_count"]
|
|
5238
5238
|
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
header["serverRun"] = bool(extra["server_run"])
|
|
5247
|
-
if extra.get("project"):
|
|
5248
|
-
header["project"] = extra["project"]
|
|
5239
|
+
extra = json.loads(row["extra_json"]) if row["extra_json"] else {}
|
|
5240
|
+
if "profile_id" in extra:
|
|
5241
|
+
header["profileId"] = extra["profile_id"]
|
|
5242
|
+
if "server_run" in extra:
|
|
5243
|
+
header["serverRun"] = bool(extra["server_run"])
|
|
5244
|
+
if extra.get("project"):
|
|
5245
|
+
header["project"] = extra["project"]
|
|
5249
5246
|
return header
|
|
5250
5247
|
|
|
5251
5248
|
|
|
@@ -5299,11 +5296,8 @@ def save_conversation(session_meta: dict, messages: list[dict] | None = None) ->
|
|
|
5299
5296
|
created_at = int(session_meta.get("createdAt") or now)
|
|
5300
5297
|
updated_at = int(session_meta.get("updatedAt") or now)
|
|
5301
5298
|
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
extra = {}
|
|
5305
|
-
else:
|
|
5306
|
-
extra = dict(extra)
|
|
5299
|
+
# extra_json guarda el perfil, el modo servidor y el proyecto; la cabecera los expone como campos propios.
|
|
5300
|
+
extra = {}
|
|
5307
5301
|
profile_id = session_meta.get("profileId")
|
|
5308
5302
|
if profile_id and isinstance(profile_id, str) and profile_id.strip():
|
|
5309
5303
|
extra["profile_id"] = profile_id.strip()
|
|
@@ -5324,12 +5318,10 @@ def save_conversation(session_meta: dict, messages: list[dict] | None = None) ->
|
|
|
5324
5318
|
if not title and existing["title"]:
|
|
5325
5319
|
title = existing["title"]
|
|
5326
5320
|
existing_extra = json.loads(existing["extra_json"]) if existing["extra_json"] else {}
|
|
5327
|
-
|
|
5328
|
-
merged_extra.update(extra)
|
|
5321
|
+
extra = {**existing_extra, **extra}
|
|
5329
5322
|
# El proyecto se fija al crear la conversación y no cambia después.
|
|
5330
5323
|
if existing_extra.get("project"):
|
|
5331
|
-
|
|
5332
|
-
extra = merged_extra
|
|
5324
|
+
extra["project"] = existing_extra["project"]
|
|
5333
5325
|
|
|
5334
5326
|
extra_json = json.dumps(extra, ensure_ascii=False) if extra else "{}"
|
|
5335
5327
|
|
|
@@ -5409,6 +5401,21 @@ def delete_conversation(session_id: str) -> bool:
|
|
|
5409
5401
|
return cursor.rowcount > 0
|
|
5410
5402
|
|
|
5411
5403
|
|
|
5404
|
+
def delete_project_conversations(project: str) -> list[str]:
|
|
5405
|
+
"""Elimina las conversaciones de un proyecto con sus mensajes y devuelve sus identificadores."""
|
|
5406
|
+
if not isinstance(project, str) or not project.strip() or len(project) > MAX_PATH_LENGTH:
|
|
5407
|
+
raise ValueError("El proyecto de las conversaciones debe ser una ruta")
|
|
5408
|
+
with open_storage() as conn:
|
|
5409
|
+
rows = conn.execute(
|
|
5410
|
+
"SELECT id FROM conversations WHERE json_extract(extra_json, '$.project') = ?;",
|
|
5411
|
+
(project.strip(),)
|
|
5412
|
+
).fetchall()
|
|
5413
|
+
ids = [row["id"] for row in rows]
|
|
5414
|
+
conn.executemany("DELETE FROM conversations WHERE id = ?;", [(conv_id,) for conv_id in ids])
|
|
5415
|
+
conn.commit()
|
|
5416
|
+
return ids
|
|
5417
|
+
|
|
5418
|
+
|
|
5412
5419
|
def delete_all_conversations() -> int:
|
|
5413
5420
|
"""Elimina todas las conversaciones y sus mensajes en cascada."""
|
|
5414
5421
|
with open_storage() as conn:
|
|
@@ -6410,6 +6417,14 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
|
|
|
6410
6417
|
except (ValueError, OSError):
|
|
6411
6418
|
pass
|
|
6412
6419
|
return {"deleted": True, "count": delete_all_conversations()}, None, ""
|
|
6420
|
+
if "project" in params:
|
|
6421
|
+
deleted_ids = delete_project_conversations(params.get("project"))
|
|
6422
|
+
for deleted_id in deleted_ids:
|
|
6423
|
+
try:
|
|
6424
|
+
cancel_server_run(deleted_id)
|
|
6425
|
+
except (ValueError, OSError):
|
|
6426
|
+
pass
|
|
6427
|
+
return {"deleted": True, "count": len(deleted_ids)}, None, ""
|
|
6413
6428
|
conv_id = params.get("id")
|
|
6414
6429
|
if isinstance(conv_id, str) and conv_id.strip():
|
|
6415
6430
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|