zerochat 10.17.0__tar.gz → 10.18.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.17.0
3
+ Version: 10.18.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.17.0"
7
+ version = "10.18.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.17.0
3
+ Version: 10.18.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
@@ -14,6 +14,7 @@ from __future__ import annotations
14
14
  import argparse
15
15
  import atexit
16
16
  import base64
17
+ import codecs
17
18
  import contextlib
18
19
  import ctypes
19
20
  import ctypes.util
@@ -1381,7 +1382,7 @@ def _pid_alive(pid: int) -> bool:
1381
1382
 
1382
1383
 
1383
1384
 
1384
- SOURCE_BACKEND_VERSION = "10.17.0"
1385
+ SOURCE_BACKEND_VERSION = "10.18.0"
1385
1386
 
1386
1387
 
1387
1388
  def _read_source_version(filename: str) -> str | None:
@@ -4975,8 +4976,69 @@ def list_directory(path: str = ".", recursive: bool = False, *, ctx: SecurityCon
4975
4976
  return _tool_error(str(e))
4976
4977
 
4977
4978
 
4978
- def read_file(path: str, start_line: int = 1, end_line: int = None, max_lines: int = 500, max_bytes: int = 100000, *, ctx: SecurityContext) -> str:
4979
- """Read text content from a local file in streaming mode with safe ranges and bounds."""
4979
+ # Códigos de control de terminal (colores, movimiento del cursor) que un log trae y el modelo no necesita.
4980
+ ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-9;?]*[ -/]*[@-~]|\x1b[@-Z\\-_]")
4981
+ READ_TAIL_BLOCK_BYTES = 64 * 1024
4982
+ MAX_READ_LINES = 2000
4983
+
4984
+
4985
+ def _terminal_line(line: str) -> str:
4986
+ """Una línea como la deja una terminal: sin códigos de color y, si se reescribe con \\r, su último tramo."""
4987
+ ending = "\n" if line.endswith("\n") else ""
4988
+ text = ANSI_ESCAPE_RE.sub("", line[:-1] if ending else line).rstrip("\r")
4989
+ return text[text.rfind("\r") + 1:] + ending
4990
+
4991
+
4992
+ def _count_lines(target: Path) -> int:
4993
+ lines = 0
4994
+ last = b""
4995
+ with open(target, "rb") as handle:
4996
+ while chunk := handle.read(1024 * 1024):
4997
+ lines += chunk.count(b"\n")
4998
+ last = chunk[-1:]
4999
+ return lines + (1 if last and last != b"\n" else 0)
5000
+
5001
+
5002
+ def _read_tail(target: Path, tail_lines: int, max_bytes: int) -> str:
5003
+ """Las últimas tail_lines líneas, leyendo el fichero desde el final por bloques y sin pasar de max_bytes."""
5004
+ file_size = target.stat().st_size
5005
+ wanted = max(1, min(int(tail_lines), MAX_READ_LINES))
5006
+ data = b""
5007
+ with open(target, "rb") as handle:
5008
+ position = file_size
5009
+ # Una línea más de las pedidas: la primera del bloque puede estar a medias.
5010
+ while position > 0 and data.count(b"\n") <= wanted and len(data) < max_bytes:
5011
+ step = min(READ_TAIL_BLOCK_BYTES, position)
5012
+ position -= step
5013
+ handle.seek(position)
5014
+ data = handle.read(step) + data
5015
+ truncated_bytes = len(data) > max_bytes
5016
+ if truncated_bytes:
5017
+ data = data[-max_bytes:]
5018
+ # Solo \n separa líneas: splitlines también parte en \r y desharía las barras de progreso.
5019
+ parts = data.decode("utf-8", errors="replace").split("\n")
5020
+ lines = [part + "\n" for part in parts[:-1]] + ([parts[-1]] if parts[-1] else [])
5021
+ if (position > 0 or truncated_bytes) and lines:
5022
+ lines = lines[1:]
5023
+ lines = lines[-wanted:]
5024
+ total_lines = _count_lines(target)
5025
+ start_line = total_lines - len(lines) + 1
5026
+ return json.dumps({
5027
+ "success": True,
5028
+ "path": str(target),
5029
+ "size_bytes": file_size,
5030
+ "total_lines": total_lines,
5031
+ "start_line": start_line,
5032
+ "end_line": total_lines,
5033
+ "lines_returned": len(lines),
5034
+ "truncated": start_line > 1,
5035
+ "content": "".join(_terminal_line(line) for line in lines)
5036
+ }, ensure_ascii=False, indent=2)
5037
+
5038
+
5039
+ def read_file(path: str, start_line: int = 1, end_line: int = None, max_lines: int = 500, max_bytes: int = 100000,
5040
+ tail_lines: int | None = None, *, ctx: SecurityContext) -> str:
5041
+ """Read text content from a local file in streaming mode with safe ranges and bounds, or its last lines."""
4980
5042
  try:
4981
5043
  target = ctx.absolute(path)
4982
5044
  if not target.exists():
@@ -4986,15 +5048,17 @@ def read_file(path: str, start_line: int = 1, end_line: int = None, max_lines: i
4986
5048
 
4987
5049
  file_size = target.stat().st_size
4988
5050
  safe_max_bytes = max(1024, min(int(max_bytes), 2000000))
5051
+ if tail_lines is not None:
5052
+ return _read_tail(target, tail_lines, safe_max_bytes)
4989
5053
  safe_start_line = max(1, int(start_line))
4990
5054
 
4991
5055
  if end_line is not None:
4992
5056
  safe_end_line = max(safe_start_line, int(end_line))
4993
- target_line_count = min(safe_end_line - safe_start_line + 1, 2000)
5057
+ target_line_count = min(safe_end_line - safe_start_line + 1, MAX_READ_LINES)
4994
5058
  safe_end_line = safe_start_line + target_line_count - 1
4995
5059
  else:
4996
5060
  safe_end_line = None
4997
- target_line_count = max(1, min(int(max_lines), 2000))
5061
+ target_line_count = max(1, min(int(max_lines), MAX_READ_LINES))
4998
5062
 
4999
5063
  selected_lines = []
5000
5064
  current_bytes = 0
@@ -5536,7 +5600,6 @@ class CommandJob:
5536
5600
  self.exit_code: int | None = None
5537
5601
  self.status = "running"
5538
5602
  self.stop_reason: str | None = None
5539
- self.timeout_seconds: int | None = None
5540
5603
  # Hasta dónde ha leído el modelo la salida, y si ya ha visto el final.
5541
5604
  self.model_cursor = 0
5542
5605
  self.reported = False
@@ -5760,6 +5823,16 @@ class JobManager:
5760
5823
  if key is not None and not (isinstance(key, str) and JOB_KEY_PATTERN.fullmatch(key)):
5761
5824
  key = None
5762
5825
  with self._lock:
5826
+ # Relanzar lo que ya está en marcha duplica el trabajo (dos envíos a la misma cola, dos
5827
+ # servidores en el mismo puerto): se sigue el que hay.
5828
+ same = next((job for job in self._jobs.values()
5829
+ if job.status == "running" and job.project == project.key and job.command.strip() == command.strip()), None)
5830
+ if same is not None:
5831
+ raise ValueError(
5832
+ f"This command is already running as job_id {same.id} (for {int(same.elapsed())} s). Do not run it again: "
5833
+ f"follow it with check_command(job_id={same.id}, wait_seconds=600), or stop it first with "
5834
+ f"check_command(job_id={same.id}, stop=true) if you really need a new run."
5835
+ )
5763
5836
  if sum(1 for job in self._jobs.values() if job.status == "running") >= MAX_RUNNING_JOBS:
5764
5837
  raise ValueError(
5765
5838
  f"Too many commands running ({MAX_RUNNING_JOBS}). "
@@ -5794,6 +5867,9 @@ class JobManager:
5794
5867
  stdout=subprocess.PIPE,
5795
5868
  # Una sola salida, en el orden en que la escribe el comando, como en una terminal.
5796
5869
  stderr=subprocess.STDOUT,
5870
+ # La salida va a un pipe, no a una terminal: sin esto Python la retiene en el búfer hasta salir
5871
+ # y ni la tarjeta, ni check_command, ni su pattern ven nada mientras el programa trabaja.
5872
+ env={**os.environ, "PYTHONUNBUFFERED": "1"},
5797
5873
  start_new_session=DETECTED_OS != "windows" and hasattr(os, "setsid")
5798
5874
  )
5799
5875
  if DETECTED_OS == "windows":
@@ -5837,9 +5913,7 @@ class JobManager:
5837
5913
  job.ended_mono = time.monotonic()
5838
5914
  job.ended_at = time.time()
5839
5915
  job.exit_code = returncode
5840
- if job.stop_reason == "timeout":
5841
- job.status = "timeout"
5842
- elif job.stop_reason:
5916
+ if job.stop_reason:
5843
5917
  job.status = "stopped"
5844
5918
  else:
5845
5919
  job.status = "exited"
@@ -5965,10 +6039,8 @@ def _job_result(job: CommandJob, note: str | None = None, output_field: str = "o
5965
6039
  output, truncated = truncate_terminal_output(job.output_since(start))
5966
6040
  job.model_cursor = total
5967
6041
  # Detener un comando a propósito no es un fallo; sí lo son salir con error o agotar el plazo.
5968
- failed = job.status == "timeout" or (job.status == "exited" and job.exit_code != 0)
6042
+ failed = job.status == "exited" and job.exit_code != 0
5969
6043
  result = {"success": not failed, "status": job.status, "job_id": job.id}
5970
- if job.status == "timeout":
5971
- result["error"] = f"Command timed out after {job.timeout_seconds} s and was killed."
5972
6044
  if job.status == "running":
5973
6045
  result["elapsed_s"] = job.elapsed()
5974
6046
  else:
@@ -5997,17 +6069,18 @@ def run_command(command: str, timeout_seconds: int = COMMAND_DEFAULT_TIMEOUT, ba
5997
6069
  if background:
5998
6070
  if not job.done.wait(BACKGROUND_STARTUP_WAIT):
5999
6071
  return _job_result(job, note=(
6000
- f"Running in background. Follow it with check_command(job_id={job.id}, wait_seconds=...) "
6001
- f"and stop it with check_command(job_id={job.id}, stop=true)."
6072
+ f"Running in background. Follow it with check_command(job_id={job.id}, wait_seconds=600, pattern='error|Traceback'), "
6073
+ f"which returns when it finishes, prints an error or after 600 s, and stop it with check_command(job_id={job.id}, stop=true)."
6002
6074
  ))
6003
6075
  return _job_result(job)
6004
6076
  timeout = _clamp_seconds(timeout_seconds, COMMAND_DEFAULT_TIMEOUT, 1, COMMAND_MAX_TIMEOUT)
6005
6077
  if not job.done.wait(timeout):
6006
- job.timeout_seconds = timeout
6007
- JOBS.stop(job, "timeout")
6078
+ # No se mata: lo hecho no se pierde y relanzarlo no lo duplica.
6079
+ job.background = True
6008
6080
  return _job_result(job, note=(
6009
- f"Killed after {timeout} s. If this command is expected to take longer, re-run it with "
6010
- f"a larger timeout_seconds (max {COMMAND_MAX_TIMEOUT}) or with background=true."
6081
+ f"Still running after {timeout} s, so it was moved to the background instead of being killed. "
6082
+ f"Do not run it again. Follow it with check_command(job_id={job.id}, wait_seconds=600) "
6083
+ f"and stop it with check_command(job_id={job.id}, stop=true)."
6011
6084
  ))
6012
6085
  return _job_result(job)
6013
6086
 
@@ -6103,6 +6176,11 @@ def check_command(job_id: int | None = None, wait_seconds: int = 0, stop: bool =
6103
6176
  finally:
6104
6177
  JOBS.close_wait(job_key)
6105
6178
  extra = {"returned_because": reason, "waited_s": round(time.monotonic() - started, 1)}
6179
+ if reason == "wait_elapsed" and job.total == job.model_cursor and not job.done.is_set():
6180
+ extra["note"] = (
6181
+ "No new output while waiting. The command may still be working without printing, or write its progress "
6182
+ "to a log file: read that file with read_file. It is still running: wait again or check that file."
6183
+ )
6106
6184
  if line is not None:
6107
6185
  extra["matched_line"] = line if len(line) <= MATCHED_LINE_MAX_CHARS else line[:MATCHED_LINE_MAX_CHARS] + "…"
6108
6186
  return _job_result(job, output_field="new_output", extra=extra)
@@ -6917,6 +6995,143 @@ class ConsoleControl:
6917
6995
  return
6918
6996
  self._handle_command(line)
6919
6997
 
6998
+ # --- tools.project_files ---
6999
+ """Navegador de ficheros del proyecto para la interfaz: lista, lee y descarga sin salir de su carpeta.
7000
+
7001
+ Lo usa la persona, no el modelo: lo limita la carpeta del proyecto de la petición, no el motor de permisos.
7002
+ """
7003
+
7004
+
7005
+
7006
+
7007
+ # Entradas de una carpeta en una respuesta: una carpeta con más (node_modules) avisa de las que faltan.
7008
+ MAX_LIST_ENTRIES = 2000
7009
+ # Bytes del comienzo que deciden si un fichero es texto: un byte nulo o un UTF-8 no válido lo hacen binario.
7010
+ TEXT_SNIFF_BYTES = 8192
7011
+ # Un texto más grande no se abre en una pestaña: se descarga.
7012
+ MAX_TEXT_VIEW_BYTES = 2 * 1024 * 1024
7013
+ DOWNLOAD_PAGE_BYTES = 512 * 1024
7014
+ MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024
7015
+
7016
+
7017
+ def _project_root(ctx: SecurityContext) -> Path:
7018
+ return ctx.workspace_dir.resolve()
7019
+
7020
+
7021
+ def _inside(ctx: SecurityContext, path) -> tuple[Path, Path]:
7022
+ """La ruta pedida, resuelta con sus enlaces simbólicos, y la raíz; ValueError si sale de la carpeta del proyecto."""
7023
+ root = _project_root(ctx)
7024
+ if path in (None, ""):
7025
+ return root, root
7026
+ if not isinstance(path, str):
7027
+ raise ValueError("path debe ser una cadena.")
7028
+ target = ctx.absolute(path)
7029
+ if target != root and root not in target.parents:
7030
+ raise ValueError("La ruta queda fuera de la carpeta del proyecto.")
7031
+ return target, root
7032
+
7033
+
7034
+ def _relative(target: Path, root: Path) -> str:
7035
+ return "" if target == root else target.relative_to(root).as_posix()
7036
+
7037
+
7038
+ def list_project_dir(params: dict, ctx: SecurityContext) -> dict:
7039
+ """Carpetas primero y después ficheros, por nombre, con su tamaño y fecha; como mucho MAX_LIST_ENTRIES."""
7040
+ target, root = _inside(ctx, params.get("path"))
7041
+ if not target.is_dir():
7042
+ raise ValueError("La carpeta no existe.")
7043
+ entries = []
7044
+ with os.scandir(target) as items:
7045
+ for item in items:
7046
+ try:
7047
+ is_dir = item.is_dir()
7048
+ info = item.stat()
7049
+ except OSError:
7050
+ continue
7051
+ entries.append({
7052
+ "name": item.name,
7053
+ "type": "dir" if is_dir else "file",
7054
+ "size": None if is_dir else info.st_size,
7055
+ "modified": int(info.st_mtime * 1000),
7056
+ })
7057
+ entries.sort(key=lambda entry: (entry["type"] != "dir", entry["name"].lower(), entry["name"]))
7058
+ return {
7059
+ "path": _relative(target, root),
7060
+ "entries": entries[:MAX_LIST_ENTRIES],
7061
+ "total": len(entries),
7062
+ "truncated": len(entries) > MAX_LIST_ENTRIES,
7063
+ }
7064
+
7065
+
7066
+ def _regular_file(params: dict, ctx: SecurityContext) -> tuple[Path, Path]:
7067
+ target, root = _inside(ctx, params.get("path"))
7068
+ if not target.is_file():
7069
+ raise ValueError("El fichero no existe.")
7070
+ return target, root
7071
+
7072
+
7073
+ def read_project_file(params: dict, ctx: SecurityContext) -> dict:
7074
+ """El texto de un fichero, o que es binario o demasiado grande para abrirlo (entonces se descarga)."""
7075
+ target, root = _regular_file(params, ctx)
7076
+ size = target.stat().st_size
7077
+ result = {"path": _relative(target, root), "size": size}
7078
+ with open(target, "rb") as handle:
7079
+ head = handle.read(TEXT_SNIFF_BYTES)
7080
+ try:
7081
+ # Incremental: un carácter de varios bytes cortado al final del comienzo no lo hace binario.
7082
+ codecs.getincrementaldecoder("utf-8")().decode(head, final=len(head) == size)
7083
+ except UnicodeDecodeError:
7084
+ return {**result, "binary": True}
7085
+ if b"\0" in head:
7086
+ return {**result, "binary": True}
7087
+ if size > MAX_TEXT_VIEW_BYTES:
7088
+ return {**result, "binary": False, "too_large": True}
7089
+ try:
7090
+ text = target.read_bytes().decode("utf-8")
7091
+ except UnicodeDecodeError:
7092
+ return {**result, "binary": True}
7093
+ return {**result, "binary": False, "text": text}
7094
+
7095
+
7096
+ def download_project_file(params: dict, ctx: SecurityContext) -> dict:
7097
+ """Una página del fichero en base64 desde offset; la interfaz las pide hasta done."""
7098
+ target, root = _regular_file(params, ctx)
7099
+ size = target.stat().st_size
7100
+ if size > MAX_DOWNLOAD_BYTES:
7101
+ raise ValueError(f"El fichero ocupa más de {MAX_DOWNLOAD_BYTES // (1024 * 1024)} MB y no se descarga desde aquí.")
7102
+ offset = params.get("offset", 0)
7103
+ if isinstance(offset, bool) or not isinstance(offset, int) or offset < 0 or offset > size:
7104
+ raise ValueError("offset debe ser un entero entre 0 y el tamaño del fichero.")
7105
+ with open(target, "rb") as handle:
7106
+ handle.seek(offset)
7107
+ chunk = handle.read(DOWNLOAD_PAGE_BYTES)
7108
+ following = offset + len(chunk)
7109
+ return {
7110
+ "path": _relative(target, root),
7111
+ "name": target.name,
7112
+ "size": size,
7113
+ "data": base64.b64encode(chunk).decode("ascii"),
7114
+ "next": following,
7115
+ "done": following >= size,
7116
+ }
7117
+
7118
+
7119
+ def dispatch_files(method: str, params: dict, ctx: SecurityContext) -> tuple[dict | None, dict | None, str]:
7120
+ """zerochat/files/list, zerochat/files/read y zerochat/files/download sobre la carpeta del proyecto."""
7121
+ params = params if isinstance(params, dict) else {}
7122
+ handlers = {
7123
+ "zerochat/files/list": list_project_dir,
7124
+ "zerochat/files/read": read_project_file,
7125
+ "zerochat/files/download": download_project_file,
7126
+ }
7127
+ handler = handlers.get(method)
7128
+ if handler is None:
7129
+ return None, {"code": -32601, "message": f"Método '{method}' no soportado."}, ""
7130
+ try:
7131
+ return handler(params, ctx), None, ""
7132
+ except (ValueError, OSError) as exc:
7133
+ return None, {"code": -32602, "message": str(exc)}, str(exc)
7134
+
6920
7135
  # --- tools.registry ---
6921
7136
  """Registro de las herramientas locales: definiciones publicadas al modelo, manejadores y validación de argumentos contra su esquema."""
6922
7137
 
@@ -6936,7 +7151,7 @@ LOCAL_TOOLS_DEFINITIONS = [
6936
7151
  },
6937
7152
  {
6938
7153
  "name": "read_file",
6939
- "description": "Read a text file, whole or by line range.",
7154
+ "description": "Read a text file, whole or by line range, or only its last lines with tail_lines (like tail -n): use tail_lines for logs that keep growing.",
6940
7155
  "inputSchema": {
6941
7156
  "type": "object",
6942
7157
  "properties": {
@@ -6944,7 +7159,11 @@ LOCAL_TOOLS_DEFINITIONS = [
6944
7159
  "start_line": {"type": "integer", "description": "First line (1-based)", "default": 1},
6945
7160
  "end_line": {"type": "integer", "description": "Last line (inclusive)"},
6946
7161
  "max_lines": {"type": "integer", "description": "Line cap if no end_line", "default": 500},
6947
- "max_bytes": {"type": "integer", "description": "Byte cap", "default": 100000}
7162
+ "max_bytes": {"type": "integer", "description": "Byte cap", "default": 100000},
7163
+ "tail_lines": {
7164
+ "type": "integer",
7165
+ "description": "Return only the last N lines (max 2000), without terminal color codes and keeping the last state of progress bars; start_line and end_line are ignored"
7166
+ }
6948
7167
  },
6949
7168
  "required": ["path"]
6950
7169
  }
@@ -7005,9 +7224,11 @@ LOCAL_TOOLS_DEFINITIONS = [
7005
7224
  "Each call starts a fresh shell in the project directory: cd, export or source/activate do not carry over to later calls, "
7006
7225
  "so chain them with && in the same command. "
7007
7226
  ) + (
7008
- "By default it waits up to timeout_seconds and kills the command if it has not finished. "
7009
- "Use background=true for servers, watchers or anything that does not finish on its own; "
7010
- f"then follow or stop it with check_command. Host OS: {DETECTED_OS}."
7227
+ "It waits up to timeout_seconds; a command still running then is not killed: it keeps running in the background "
7228
+ "and the result gives its job_id. "
7229
+ "Use background=true from the start for anything that takes minutes (generations, builds, training, long test suites) "
7230
+ "and for servers or watchers that do not finish on its own; then follow it with check_command. "
7231
+ f"Never run a command again while it is still running. Host OS: {DETECTED_OS}."
7011
7232
  ),
7012
7233
  "inputSchema": {
7013
7234
  "type": "object",
@@ -7021,7 +7242,7 @@ LOCAL_TOOLS_DEFINITIONS = [
7021
7242
  else "Shell command to run (e.g. git status, npm test)"
7022
7243
  )
7023
7244
  },
7024
- "timeout_seconds": {"type": "integer", "description": f"Seconds to wait before killing the command (default {COMMAND_DEFAULT_TIMEOUT}, max {COMMAND_MAX_TIMEOUT}). Ignored with background=true.", "default": COMMAND_DEFAULT_TIMEOUT},
7245
+ "timeout_seconds": {"type": "integer", "description": f"Seconds to wait for the command before moving it to the background (default {COMMAND_DEFAULT_TIMEOUT}, max {COMMAND_MAX_TIMEOUT}). Ignored with background=true.", "default": COMMAND_DEFAULT_TIMEOUT},
7025
7246
  "background": {"type": "boolean", "description": "Return after a few seconds and keep the command running; returns a job_id for check_command.", "default": False}
7026
7247
  },
7027
7248
  "required": ["command"]
@@ -7031,8 +7252,10 @@ LOCAL_TOOLS_DEFINITIONS = [
7031
7252
  "name": "check_command",
7032
7253
  "description": (
7033
7254
  "Check a command started by run_command: returns its status and the output produced since the last check. "
7034
- "Use wait_seconds to wait for it to finish, add pattern to return as soon as a new output line matches it "
7035
- "(for example 'error|listening on'), or stop=true to terminate it. "
7255
+ "Use wait_seconds to wait for it to finish, add pattern to return as soon as a new output line matches it, "
7256
+ "or stop=true to terminate it. Example: check_command(job_id=4, wait_seconds=600, pattern='error|Traceback') "
7257
+ "returns when the command finishes, prints an error, or after 600 s. To follow a long command until it finishes "
7258
+ "(also when the user asks to be told when it ends), call it again with wait_seconds=600 each time it returns still running. "
7036
7259
  "Without job_id it just waits wait_seconds, with no shell, and returns early if a background command finishes: "
7037
7260
  "use it instead of sleep."
7038
7261
  ),
@@ -7807,9 +8030,10 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
7807
8030
  except ValueError:
7808
8031
  return False
7809
8032
 
7810
- # Whitelist de archivos y carpetas autorizados para servir la interfaz web
8033
+ # Whitelist de archivos y carpetas autorizados para servir la interfaz web: sus dos páginas
8034
+ # (el chat y el navegador de ficheros del proyecto) y sus recursos.
7811
8035
  is_allowed_static = (
7812
- clean_rel == "zerochat.html" or
8036
+ clean_rel in ("zerochat.html", "files.html") or
7813
8037
  clean_rel in ("manifest.webmanifest", "sw.js", "favicon.ico") or
7814
8038
  clean_rel.startswith("js/") or
7815
8039
  clean_rel.startswith("css/") or
@@ -8210,6 +8434,8 @@ class ZeroChatServerHandler(BaseHTTPRequestHandler):
8210
8434
  return None, {"code": -32603, "message": f"Error en sandbox JS: {exc}"}, str(exc)
8211
8435
  if method.startswith("zerochat/jobs/"):
8212
8436
  return self._dispatch_jobs(method, params, ctx)
8437
+ if method.startswith("zerochat/files/"):
8438
+ return dispatch_files(method, params, ctx)
8213
8439
  if method.startswith("zerochat/run/"):
8214
8440
  return dispatch_run(method, params, ctx)
8215
8441
  if method in ("zerochat/external/servers/start", "zerochat/external/servers/stop", "zerochat/external/servers/configure"):
File without changes
File without changes
File without changes