zerochat 10.25.0__tar.gz → 10.27.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zerochat
3
- Version: 10.25.0
3
+ Version: 10.27.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.25.0"
7
+ version = "10.27.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.25.0
3
+ Version: 10.27.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
@@ -1575,7 +1575,7 @@ def dispatch_browser(method: str, params: dict) -> RpcOutcome:
1575
1575
 
1576
1576
 
1577
1577
 
1578
- SOURCE_BACKEND_VERSION = "10.25.0"
1578
+ SOURCE_BACKEND_VERSION = "10.27.0"
1579
1579
 
1580
1580
 
1581
1581
  def _read_source_version(filename: str) -> str | None:
@@ -3379,11 +3379,18 @@ def delete_conversation(session_id: str) -> bool:
3379
3379
 
3380
3380
 
3381
3381
  def delete_project_conversations(project: str) -> list[str]:
3382
- """Elimina las conversaciones de un proyecto con sus mensajes y blobs propios, y devuelve sus identificadores."""
3383
- if not isinstance(project, str) or not project.strip() or len(project) > MAX_PATH_LENGTH:
3382
+ """Elimina las conversaciones de un proyecto (o de la carpeta general si es vacío) con sus mensajes y blobs propios."""
3383
+ if not isinstance(project, str) or (project and not project.strip()) or len(project) > MAX_PATH_LENGTH:
3384
3384
  raise ValueError("El proyecto de las conversaciones debe ser una ruta")
3385
+ clean_project = project.strip()
3385
3386
  with open_storage() as conn:
3386
- return _delete_conversations(conn, "json_extract(extra_json, '$.project') = ?", (project.strip(),))
3387
+ if not clean_project:
3388
+ return _delete_conversations(
3389
+ conn,
3390
+ "json_extract(extra_json, '$.project') IS NULL OR json_extract(extra_json, '$.project') = ''",
3391
+ (),
3392
+ )
3393
+ return _delete_conversations(conn, "json_extract(extra_json, '$.project') = ?", (clean_project,))
3387
3394
 
3388
3395
 
3389
3396
  def delete_all_conversations() -> int:
@@ -4447,7 +4454,7 @@ def _approved_call(tool_security) -> tuple[str, dict] | None:
4447
4454
  class RunSession:
4448
4455
  """Estado de la ejecución: prompt, opciones, último progreso, exportación, resultado y motivo de un final sin él."""
4449
4456
  def __init__(self, prompt: str | None = None, profile: str | None = None, export_path: Path | None = None, keep_page: bool = False,
4450
- allow_dangerous_tools: bool = False, conversation_id: str | None = None, run_id: str | None = None,
4457
+ conversation_id: str | None = None, run_id: str | None = None,
4451
4458
  tool_security: dict | None = None, profile_data: dict | None = None):
4452
4459
  env_run_id = os.environ.get("ZEROCHAT_RUN_ID", "").strip()
4453
4460
  self.run_id = run_id.strip() if (run_id and isinstance(run_id, str) and run_id.strip()) else (env_run_id or secrets.token_urlsafe(24))
@@ -4465,8 +4472,6 @@ class RunSession:
4465
4472
  self.export_error: str | None = None
4466
4473
  # La interfaz no cierra la página al terminar, para ver la conversación (sin --headless).
4467
4474
  self.keep_page = keep_page
4468
- # La interfaz aprueba también write_file, edit_file y run_command, que si no deniega.
4469
- self.allow_dangerous_tools = allow_dangerous_tools
4470
4475
  if tool_security is not None:
4471
4476
  self.tool_security = tool_security
4472
4477
  elif os.environ.get("ZEROCHAT_RUN_SECURITY"):
@@ -4563,8 +4568,7 @@ def _rpc_prompt(params: dict, session: RunSession) -> RpcOutcome:
4563
4568
  # Para switch_model, que busca por nombre: el runner no puede listar los perfiles con su credencial.
4564
4569
  # El listado no lleva API keys; la del que active la pide con zerochat/run/profile.
4565
4570
  "profiles": list_general_profiles(),
4566
- "export": export_format, "keep_page": session.keep_page,
4567
- "allow_dangerous_tools": session.allow_dangerous_tools})
4571
+ "export": export_format, "keep_page": session.keep_page})
4568
4572
 
4569
4573
 
4570
4574
  def _rpc_profile(params: dict, session: RunSession) -> RpcOutcome:
@@ -9618,7 +9622,6 @@ def build_parser() -> ZeroChatArgumentParser:
9618
9622
  parser.add_argument("--export", default=None, metavar="FICHERO", help=f"Con --prompt o --conversation, guardar la conversación en FICHERO; el formato sale de la extensión ({', '.join(RUN_EXPORT_FORMATS)})")
9619
9623
  parser.add_argument("--browser", action="store_true", help="Con --prompt o --conversation, abrir el navegador predeterminado del usuario en lugar del proceso Node.js sin ventana")
9620
9624
  parser.add_argument("--keep-page", action="store_true", help="Página: con --browser, no cerrar la página al terminar para ver la conversación (no se combina con --headless)")
9621
- parser.add_argument("--allow-dangerous-tools", action="store_true", help="Con --prompt sin --conversation, aprobar también las herramientas que escriben o ejecutan (write_file, edit_file, run_command); las demás se aprueban siempre para la sesión. Con --conversation nada se aprueba solo: la ejecución se pausa y pregunta")
9622
9625
  parser.add_argument("--headless", action="store_true", help="Con --browser, abrir el navegador predeterminado sin ventana (si ya está abierto puede verse la pestaña)")
9623
9626
  parser.add_argument("--version", action="version", version=f"ZeroChat {VERSION}")
9624
9627
  return parser
@@ -9626,8 +9629,6 @@ def build_parser() -> ZeroChatArgumentParser:
9626
9629
 
9627
9630
  def _check_run_flags(parser: ZeroChatArgumentParser, args):
9628
9631
  """Combinaciones de opciones que no admiten --prompt ni --conversation."""
9629
- if args.allow_dangerous_tools and args.conversation is not None:
9630
- parser.error("--conversation no aprueba nada sin preguntar: si una herramienta pide permiso, la ejecución se pausa (needs_input); --allow-dangerous-tools solo se usa con --prompt sin --conversation")
9631
9632
  if args.no_browser:
9632
9633
  parser.error("--prompt y --conversation ejecutan la interfaz de forma autónoma: no se combina con --no-browser")
9633
9634
  if args.keep_server:
@@ -9704,8 +9705,8 @@ def _run_export_path(parser: ZeroChatArgumentParser, args) -> Path | None:
9704
9705
  def run_session_from_args(parser: ZeroChatArgumentParser, args) -> RunSession | None:
9705
9706
  """Valida las combinaciones de opciones y devuelve la sesión de --prompt o --conversation, si la hay."""
9706
9707
  if args.prompt is None and args.conversation is None:
9707
- if args.browser or args.headless or args.keep_page or args.allow_dangerous_tools or args.profile is not None or args.export is not None:
9708
- parser.error("--browser, --headless, --keep-page, --allow-dangerous-tools, --profile y --export solo se usan con --prompt o --conversation")
9708
+ if args.browser or args.headless or args.keep_page or args.profile is not None or args.export is not None:
9709
+ parser.error("--browser, --headless, --keep-page, --profile y --export solo se usan con --prompt o --conversation")
9709
9710
  return None
9710
9711
  prompt = _run_prompt(parser, args)
9711
9712
  conversation_id, conv = _run_conversation(parser, args, prompt)
@@ -9714,7 +9715,7 @@ def run_session_from_args(parser: ZeroChatArgumentParser, args) -> RunSession |
9714
9715
  export_path = _run_export_path(parser, args)
9715
9716
  if conversation_id:
9716
9717
  mark_conversation_server_run(conversation_id, profile_name)
9717
- return RunSession(prompt, profile_name, export_path, args.keep_page, args.allow_dangerous_tools, conversation_id=conversation_id, profile_data=profile_data)
9718
+ return RunSession(prompt, profile_name, export_path, args.keep_page, conversation_id=conversation_id, profile_data=profile_data)
9718
9719
 
9719
9720
 
9720
9721
  def redirect_log(args):
@@ -9784,21 +9785,15 @@ def reset_session_authorizations():
9784
9785
  tool_name = tool_decision.get("toolName") or ""
9785
9786
  server_id = GLOBAL_MCP_MANAGER.server_of(tool_name) or ""
9786
9787
  ACCESS_CONTROLLER.apply_tool_decision(tool_decision, ctx, server_id=server_id)
9787
- if session.allow_dangerous_tools:
9788
- ACCESS_CONTROLLER.apply_session_overlay({
9789
- "globalMcpPolicy": GLOBAL_POLICY_ALLOW_ALL,
9790
- "tools": {name: {"policy": POLICY_ALLOW} for name in ("write_file", "edit_file", "run_command")}
9791
- }, ctx)
9792
- elif session.conversation_id is None:
9793
- permanent_tools = ACCESS_CONTROLLER.export_state(ctx).get("tools") or {}
9794
- ACCESS_CONTROLLER.apply_session_overlay({
9795
- "tools": {
9796
- name: {"policy": POLICY_ALLOW}
9797
- for name in LOCAL_TOOL_HANDLERS
9798
- if name not in ("write_file", "edit_file", "run_command")
9799
- and (permanent_tools.get(name) or {}).get("policy") != POLICY_DENY
9800
- }
9801
- }, ctx)
9788
+ permanent_tools = ACCESS_CONTROLLER.export_state(ctx).get("tools") or {}
9789
+ ACCESS_CONTROLLER.apply_session_overlay({
9790
+ "globalMcpPolicy": GLOBAL_POLICY_ALLOW_ALL,
9791
+ "tools": {
9792
+ name: {"policy": POLICY_ALLOW}
9793
+ for name in LOCAL_TOOL_HANDLERS
9794
+ if (permanent_tools.get(name) or {}).get("policy") != POLICY_DENY
9795
+ }
9796
+ }, ctx)
9802
9797
 
9803
9798
 
9804
9799
  def open_server(args, local_ui: bool) -> ThreadingHTTPServer:
@@ -9932,7 +9927,7 @@ def install_signal_handlers(server: ThreadingHTTPServer):
9932
9927
  def serve(server: ThreadingHTTPServer):
9933
9928
  """Atiende peticiones hasta la parada y libera después el servidor y la consola."""
9934
9929
  try:
9935
- server.serve_forever()
9930
+ server.serve_forever(poll_interval=0.05)
9936
9931
  finally:
9937
9932
  stop_zerochat_server(server)
9938
9933
  server.server_close()
File without changes
File without changes
File without changes