Files
Bingxi Zhao (Frank) bd80a4d28a release: v1.5.17
Partners stop being a deployment-wide admin resource and become
per-user: three nested rights (manage / use / neither) replace the
blanket admin gate on the router, each member can build and own their
own, and every person's conversations with a partner stay private to
their account. Grants keep working and now offer only admin-managed
partners. Channel runtime state moves from one directory per channel to
one per partner — copied, not moved, and only when its owner is
unambiguous — so two partners can finally run the same channel.

Around that: a knowledge base can track GitHub repositories and re-sync
their Markdown (#903); Antigravity CLI joins My Agents now that Gemini
CLI is retired (#828); personal WeChat signs in from a QR code drawn in
the browser instead of the server log (#951); a chat account can be
linked to a DeepTutor account with /link; containers re-apply the extras
they declare instead of losing them at compose down (#762); and
`deeptutor doctor` answers whether a workspace is ready to run (#959).

Reliability, largely from community PRs: embeddings survive a
rate-limited provider through key rotation, a retry budget and a global
throttle (#962); MinerU parsing and code execution work on Windows
(#844, #964); indexing fails bounded instead of hanging (#946); MinerU
page-layout blocks stop being indexed as content (#949); voice uploads
carry a MIME the transcription API accepts (#945); and reasoning effort
can be overridden per conversation (#641).

Release plumbing: notes in assets/releases/ver1-5-17.md, v1.5.13
archived, __version__ 1.5.17, README Releases row and all eleven
translations synced.

Two defects found by the release gate and fixed here:

- Six partner routes — the four channel-onboarding endpoints and both
  WeChat QR endpoints — kept the _auth-only mount they had inherited
  from the blanket admin gate, so any signed-in account could start a
  QR login for someone else's partner and write a bot token into its
  channel config. All six now declare _MANAGEABLE, and a sweep test
  asserts no {partner_id} route is left ungated.
- A configured api_key became `str | list[str]` when key rotation
  landed, but ten call sites pass it somewhere that takes one key; a
  list would have rendered into an Authorization header verbatim.
  keypool.primary_api_key reduces at each boundary.

Gates: pre-commit (all 15 hooks), ruff check + format, pytest
5276 passed, web 605 node tests, docs build.
2026-08-25 02:24:35 +08:00

90 lines
3.2 KiB
Python

"""Path helpers for the Partners data tree (``data/partners/``)."""
from __future__ import annotations
from pathlib import Path
import re
from deeptutor.partners.helpers import ensure_dir
def _base_dir() -> Path:
# Anchored to the admin workspace root (data/partners), NOT the
# current-user path service: partner runtimes execute inside a synthetic
# partner scope whose workspace_root lives below this very tree, so
# resolving through the contextvar here would recurse the layout.
from deeptutor.multi_user.paths import get_admin_path_service
return ensure_dir(get_admin_path_service().workspace_root / "partners")
def get_data_dir() -> Path:
return _base_dir()
def get_runtime_subdir(name: str) -> Path:
return ensure_dir(_base_dir() / name)
def get_media_dir(channel: str | None = None) -> Path:
"""Shared media download dir used by channel implementations."""
base = get_runtime_subdir("media")
return ensure_dir(base / channel) if channel else base
# ── Per-partner path helpers ──────────────────────────────────────
def get_partner_dir(partner_id: str) -> Path:
"""data/partners/{partner_id}/ — config, sessions, and workspace."""
return ensure_dir(_base_dir() / partner_id)
def get_partner_workspace(partner_id: str) -> Path:
"""The partner's scope root (chat user-workspace layout lives below it)."""
return ensure_dir(get_partner_dir(partner_id) / "workspace")
def get_partner_sessions_dir(partner_id: str) -> Path:
return ensure_dir(get_partner_dir(partner_id) / "sessions")
def get_partner_media_dir(partner_id: str, channel: str | None = None) -> Path:
base = ensure_dir(get_partner_dir(partner_id) / "media")
return ensure_dir(base / channel) if channel else base
def get_partner_channel_dir(partner_id: str, channel: str) -> Path:
"""Private runtime state for one channel of one partner.
Nested under ``channels/`` so a channel name can never collide with the
partner dir's own entries (``workspace``, ``sessions``, ``users``, ...).
"""
return ensure_dir(get_partner_dir(partner_id) / "channels" / channel)
_ACCOUNT_ID_RE = re.compile(r"^[A-Za-z0-9_-]{1,64}$")
def _account_segment(user_id: str) -> str:
"""Return a filesystem-safe account id, failing closed on invalid input."""
value = str(user_id or "").strip()
if not _ACCOUNT_ID_RE.fullmatch(value):
raise ValueError("Invalid user id for partner data scope")
return value
def get_partner_user_dir(partner_id: str, user_id: str) -> Path:
"""Private relationship state for one user interacting with a partner."""
return ensure_dir(get_partner_dir(partner_id) / "users" / _account_segment(user_id))
def get_partner_user_workspace(partner_id: str, user_id: str) -> Path:
"""Per-user partner workspace used for relationship memory."""
return ensure_dir(get_partner_user_dir(partner_id, user_id) / "workspace")
def get_partner_user_sessions_dir(partner_id: str, user_id: str) -> Path:
"""Per-user conversation history for an assigned partner."""
return ensure_dir(get_partner_user_dir(partner_id, user_id) / "sessions")