zerochat 10.1.0__tar.gz → 10.2.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.

Potentially problematic release.


This version of zerochat might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zerochat
3
- Version: 10.1.0
3
+ Version: 10.2.0
4
4
  Summary: Private local web client for AI models, tools and MCP services
5
5
  Author: Alberto Alday
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "zerochat"
7
- version = "10.1.0"
7
+ version = "10.2.0"
8
8
  description = "Private local web client for AI models, tools and MCP services"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zerochat
3
- Version: 10.1.0
3
+ Version: 10.2.0
4
4
  Summary: Private local web client for AI models, tools and MCP services
5
5
  Author: Alberto Alday
6
6
  License-Expression: MIT
@@ -53,7 +53,7 @@ import zlib
53
53
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
54
54
  from pathlib import Path
55
55
 
56
- SOURCE_BACKEND_VERSION = "10.1.0"
56
+ SOURCE_BACKEND_VERSION = "10.2.0"
57
57
 
58
58
  def _read_source_version(filename: str) -> str | None:
59
59
  """Lee la versión de un archivo del repositorio cuando se ejecuta desde fuentes."""
@@ -3481,6 +3481,9 @@ STORAGE_MIGRATIONS = [
3481
3481
  created_at INTEGER NOT NULL
3482
3482
  );
3483
3483
  CREATE INDEX IF NOT EXISTS idx_blobs_created_at ON blobs(created_at);
3484
+ """),
3485
+ (4, "004_add_extra_json_to_conversations", """
3486
+ ALTER TABLE conversations ADD COLUMN extra_json TEXT DEFAULT '{}';
3484
3487
  """)
3485
3488
  ]
3486
3489
 
@@ -3724,13 +3727,20 @@ def _validate_conversation_title(title, allow_empty: bool = False) -> str:
3724
3727
 
3725
3728
  def _row_to_conversation_header(row: sqlite3.Row) -> dict:
3726
3729
  """Transforma una fila SQLite en la cabecera de una conversación."""
3727
- return {
3730
+ header = {
3728
3731
  "id": row["id"],
3729
3732
  "title": row["title"],
3730
3733
  "createdAt": row["created_at"],
3731
3734
  "updatedAt": row["updated_at"],
3732
3735
  "messageCount": row["message_count"]
3733
3736
  }
3737
+ raw_extra = row["extra_json"]
3738
+ extra = json.loads(raw_extra) if raw_extra else {}
3739
+ if extra:
3740
+ header["extra"] = extra
3741
+ if "profile_id" in extra:
3742
+ header["profileId"] = extra["profile_id"]
3743
+ return header
3734
3744
 
3735
3745
 
3736
3746
  def _row_to_message(row: sqlite3.Row) -> dict:
@@ -3783,15 +3793,27 @@ def save_conversation(session_meta: dict, messages: list[dict] | None = None) ->
3783
3793
  created_at = int(session_meta.get("createdAt") or now)
3784
3794
  updated_at = int(session_meta.get("updatedAt") or now)
3785
3795
 
3796
+ extra = session_meta.get("extra")
3797
+ if not isinstance(extra, dict):
3798
+ extra = {}
3799
+ else:
3800
+ extra = dict(extra)
3801
+ profile_id = session_meta.get("profileId")
3802
+ if profile_id and isinstance(profile_id, str) and profile_id.strip():
3803
+ extra["profile_id"] = profile_id.strip()
3804
+
3805
+ extra_json = json.dumps(extra, ensure_ascii=False) if extra else "{}"
3806
+
3786
3807
  with open_storage() as conn:
3787
3808
  conn.execute("""
3788
- INSERT INTO conversations (id, title, created_at, updated_at, message_count)
3789
- VALUES (?, ?, ?, ?, ?)
3809
+ INSERT INTO conversations (id, title, created_at, updated_at, message_count, extra_json)
3810
+ VALUES (?, ?, ?, ?, ?, ?)
3790
3811
  ON CONFLICT(id) DO UPDATE SET
3791
3812
  title = excluded.title,
3792
3813
  updated_at = excluded.updated_at,
3793
- message_count = excluded.message_count;
3794
- """, (session_id, title, created_at, updated_at, len(messages)))
3814
+ message_count = excluded.message_count,
3815
+ extra_json = excluded.extra_json;
3816
+ """, (session_id, title, created_at, updated_at, len(messages), extra_json))
3795
3817
 
3796
3818
  conn.execute("DELETE FROM messages WHERE conversation_id = ?;", (session_id,))
3797
3819
 
@@ -5314,12 +5336,17 @@ def start_server_run(params: dict) -> dict:
5314
5336
  if not isinstance(conv_id, str) or not conv_id.strip():
5315
5337
  raise ValueError("conversation_id requerido.")
5316
5338
  clean_conv_id = _validate_conversation_id(conv_id)
5317
- if get_conversation(clean_conv_id) is None:
5339
+ conv = get_conversation(clean_conv_id)
5340
+ if conv is None:
5318
5341
  raise ValueError(f"Conversación '{clean_conv_id}' no encontrada.")
5319
5342
 
5320
5343
  profile = params.get("profile")
5321
5344
  if not isinstance(profile, str) or not profile.strip():
5322
- raise ValueError("profile requerido.")
5345
+ conv_profile = conv.get("profileId")
5346
+ if isinstance(conv_profile, str) and conv_profile.strip():
5347
+ profile = conv_profile.strip()
5348
+ else:
5349
+ raise ValueError("profile requerido.")
5323
5350
  profile_entry = get_general_profile(profile) or get_general_profile_by_name(profile)
5324
5351
  if not profile_entry:
5325
5352
  raise ValueError(f"Perfil general '{profile}' no encontrado.")
@@ -5713,6 +5740,7 @@ def run_session_from_args(parser: ZeroChatArgumentParser, args) -> RunSession |
5713
5740
  if not prompt:
5714
5741
  parser.error("el prompt está vacío")
5715
5742
  conversation_id = None
5743
+ conv = None
5716
5744
  if args.conversation is not None:
5717
5745
  raw_conv = args.conversation.strip()
5718
5746
  if not raw_conv:
@@ -5743,6 +5771,18 @@ def run_session_from_args(parser: ZeroChatArgumentParser, args) -> RunSession |
5743
5771
  parser.error("--profile no puede estar vacío")
5744
5772
  general_match = get_general_profile_by_name(clean_profile) or get_general_profile(clean_profile)
5745
5773
  profile_name = general_match["name"] if general_match else clean_profile
5774
+ elif conversation_id:
5775
+ conv_profile = conv.get("profileId") if conv else None
5776
+ if conv_profile:
5777
+ match = get_general_profile_by_name(conv_profile) or get_general_profile(conv_profile)
5778
+ if not match:
5779
+ parser.error(f"no existe el perfil general '{conv_profile}' de la conversación; créalo o indica uno con --profile")
5780
+ profile_name = match["name"]
5781
+ else:
5782
+ default_match = get_general_profile_by_name(DEFAULT_RUN_PROFILE)
5783
+ if default_match is None:
5784
+ parser.error(f"no existe el perfil general por defecto '{DEFAULT_RUN_PROFILE}'; créalo o indica uno con --profile")
5785
+ profile_name = default_match["name"]
5746
5786
  else:
5747
5787
  default_match = get_general_profile_by_name(DEFAULT_RUN_PROFILE)
5748
5788
  if default_match is None:
File without changes
File without changes
File without changes