zerochat 10.44.0__tar.gz → 10.46.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.44.0
3
+ Version: 10.46.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.44.0"
7
+ version = "10.46.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.44.0
3
+ Version: 10.46.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
@@ -1164,7 +1164,7 @@ def parse_nonneg_int(value, label: str, default: int = 0) -> int:
1164
1164
 
1165
1165
 
1166
1166
 
1167
- SOURCE_BACKEND_VERSION = "10.44.0"
1167
+ SOURCE_BACKEND_VERSION = "10.46.0"
1168
1168
 
1169
1169
 
1170
1170
  def _read_source_version(filename: str) -> str | None:
@@ -8600,8 +8600,10 @@ class AccessController:
8600
8600
  return None
8601
8601
  if decision == "allow_server_always" and not challenge.get("serverId"):
8602
8602
  return None
8603
- pattern = self._validate_command_pattern(decision, command_pattern, challenge)
8604
8603
  rules = self._validate_directory_rules([directory_rule]) if directory_rule else []
8604
+ if rules and command_pattern:
8605
+ raise ValueError("Una decisión lleva un patrón de comando o una regla de carpeta, no los dos.")
8606
+ pattern = None if rules else self._validate_command_pattern(decision, command_pattern, challenge)
8605
8607
  challenges.pop(challenge_id)
8606
8608
  self._record_decision(challenge, decision, pattern, rules, context)
8607
8609
  return challenge
@@ -8635,6 +8637,9 @@ class AccessController:
8635
8637
  regla de directorio se escriben en una sola transacción y un error de persistencia se propaga.
8636
8638
  """
8637
8639
  tool, server_name, server_id = challenge["toolName"], challenge["serverName"], challenge["serverId"]
8640
+ if rules:
8641
+ # Una regla de carpeta es toda la decisión: no autoriza además la herramienta fuera de esa carpeta.
8642
+ decision, pattern = "", None
8638
8643
  if decision == "allow_session":
8639
8644
  self._allow_for_session(context, tool, server_name, pattern)
8640
8645
  permanent = decision in ("allow_project", "allow_always", "allow_server_always")
@@ -8774,6 +8779,8 @@ class AccessController:
8774
8779
  f"El comando usa sintaxis de shell que no se puede validar por partes: {raw_command}", None)
8775
8780
  patterns = self._command_patterns(view)
8776
8781
  cwd, by_rule, uncovered = ctx.workspace_dir, False, []
8782
+ # Rutas que dejan sin cubrir un subcomando; None si alguno pide permiso por otra causa ($, ~, órdenes globales).
8783
+ outside: list[str] | None = []
8777
8784
  for operator, segment in segments:
8778
8785
  directory = cd_target(segment)
8779
8786
  if directory is not None:
@@ -8792,6 +8799,12 @@ class AccessController:
8792
8799
  by_rule = True
8793
8800
  else:
8794
8801
  uncovered.append(segment)
8802
+ refs = command_outside_references(segment)
8803
+ if refs is None or outside is None:
8804
+ outside = None
8805
+ else:
8806
+ outside += [target for target in (self._command_target(cwd, ref) for ref in refs)
8807
+ if not self.evaluate_directory_rule("RW", target, view["directoryRules"], ctx)["allowed"]]
8795
8808
  if not uncovered:
8796
8809
  return POLICY_ALLOW, "directory_rule_allow" if by_rule else "command_pattern_allow", "", None
8797
8810
  reason, details = (
@@ -8799,7 +8812,30 @@ class AccessController:
8799
8812
  if patterns
8800
8813
  else ("command_outside_directory_rules", "El comando accede a recursos globales o rutas fuera de las reglas de directorio.")
8801
8814
  )
8802
- return POLICY_ASK, reason, details, command_rule_offer(uncovered)
8815
+ offer = self._command_folder_offer(raw_command, outside, view, ctx) if outside else None
8816
+ return POLICY_ASK, reason, details, offer or command_rule_offer(uncovered)
8817
+
8818
+ def _command_folder_offer(self, raw_command: str, targets: list[str], view: dict, ctx: SecurityContext) -> dict | None:
8819
+ """
8820
+ Regla RW sobre la carpeta común de las rutas que faltan, solo si con ella el comando entero pasaría y la
8821
+ carpeta está dentro de la personal (nunca ella entera, una oculta como .ssh ni las del sistema): un nombre de
8822
+ fichero que cambia cada día no cabe en un patrón de comando, y la carpeta sí se puede conceder en el proyecto.
8823
+ """
8824
+ folders = []
8825
+ for target in targets:
8826
+ resolved = ctx.resolve_path(target)
8827
+ if resolved is None:
8828
+ return None
8829
+ folders.append(resolved if resolved.is_dir() else resolved.parent)
8830
+ common = Path(os.path.commonpath(folders))
8831
+ home = Path.home().resolve()
8832
+ if home not in common.parents or any(part.startswith(".") for part in common.relative_to(home).parts):
8833
+ return None
8834
+ rule = f"RW:{normalize_directory_path(str(common))}/**"
8835
+ widened = {**view, "directoryRules": [*view["directoryRules"], rule]}
8836
+ if self._evaluate_command(raw_command, widened, ctx)[0] != POLICY_ALLOW:
8837
+ return None
8838
+ return {"type": "directory", "access": "RW", "directoryRule": rule}
8803
8839
 
8804
8840
  def _evaluate_path(self, tool_name: str, access: str, path: str, view: dict, ctx: SecurityContext) -> tuple[str, str, str, dict | None]:
8805
8841
  """Herramientas integradas de ficheros: reglas de directorio del proyecto."""
@@ -9783,7 +9819,11 @@ def _read_line_range(target: Path, start: int, count: int, max_bytes: int) -> tu
9783
9819
  return selected, total_lines, False
9784
9820
 
9785
9821
 
9786
- def read_file(path: str, start_line: int = 1, end_line: int = None, max_lines: int = 500, max_bytes: int = 100000,
9822
+ # Tope por defecto de read_file: alineado con los 60.000 chars de web/MCP, por debajo de los 64.000 de ChatContextManager.
9823
+ READ_FILE_DEFAULT_MAX_BYTES = 60000
9824
+
9825
+
9826
+ def read_file(path: str, start_line: int = 1, end_line: int = None, max_lines: int = 500, max_bytes: int = READ_FILE_DEFAULT_MAX_BYTES,
9787
9827
  tail_lines: int | None = None, *, ctx: SecurityContext) -> str:
9788
9828
  """Read text content from a local file in streaming mode with safe ranges and bounds, or its last lines."""
9789
9829
  try:
@@ -10436,7 +10476,7 @@ LOCAL_TOOLS_DEFINITIONS = [
10436
10476
  "start_line": {"type": "integer", "description": "First line (1-based)", "default": 1},
10437
10477
  "end_line": {"type": "integer", "description": "Last line (inclusive)"},
10438
10478
  "max_lines": {"type": "integer", "description": "Line cap if no end_line", "default": 500},
10439
- "max_bytes": {"type": "integer", "description": "Byte cap", "default": 100000},
10479
+ "max_bytes": {"type": "integer", "description": "Byte cap", "default": READ_FILE_DEFAULT_MAX_BYTES},
10440
10480
  "tail_lines": {
10441
10481
  "type": "integer",
10442
10482
  "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"
File without changes
File without changes
File without changes