Files
DeepTutor/deeptutor/runtime/providers/scope.py
Bingxi Zhao (Frank) 740ec413a0 release: v1.5.7
Per-account MCP Services and CLI Apps — the two ways a deployment plugs in
tools DeepTutor never shipped — plus the isolation that makes them safe on a
shared install.

- MCP Services: a 45-entry curated store of hosted servers each account
  installs for itself, OAuth 2.1 (PKCE + dynamic client registration) for the
  servers that require it, static keys held by reference and resolved in memory
  at connect time, stdio refused for self-service. Settings no longer
  configures MCP; /settings/mcp redirects to the store.
- CLI Apps: 101 tools snapshotted from the two CLI-Anything registries.
  Installs are admin-only, the registry's install_cmd is parsed into an argv we
  build rather than executed, npm install scripts are forced off, and 66
  first-party entries are pinned to one reviewed commit. Apps land in
  data/cli-apps, one environment each, mounted read-only into the runner.
- Credentials that authorise a person move to data/system, the one branch the
  exec sandbox never mounts: Codex tokens relocate themselves on first use
  (refusing to follow a symlink), per-user MCP configs and keys land beside
  them.
- Grants gain a cli_apps whitelist with the same deny-by-default posture as
  MCP tools; a per-turn registry view keeps one owner's provider tools out of
  the process-global registry and refuses an unauthorised tool at execute, not
  just in the manifest.
- The composer reports what filled this turn's context window, a gutter rail
  jumps back through long conversations, and the workspace collapses to a
  drawer on small screens.
- The composer keeps focus after sending and across tab switches (#720);
  released images carry provenance and SBOM attestations (#722).

README prose, all ten translated READMEs, and the docs-site pages that named
Settings → MCP are updated to match. Release notes:
assets/releases/ver1-5-7.md
2026-07-31 00:25:48 +08:00

47 lines
2.2 KiB
Python

"""What a turn needs to know to decide which provider tools it may use.
Deliberately a plain input record, not a protocol every provider must
implement: MCP and CLI apps differ in what their grants are keyed by (tool
names vs. app ids), in what "not ready" means, and in whether preloading is
even meaningful. Forcing one policy interface over both would buy a shared
type and pay for it with per-kind branches hidden inside it. The branches
live in :mod:`deeptutor.runtime.providers.authorize`, named and readable.
"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True, slots=True)
class ToolScope:
"""Identity + per-turn policy inputs for external-provider tools."""
#: Id of the **owning account** — a partner resolves to the person who owns
#: it, and an administrator to the deployment id. Deliberately not "the
#: current user id": owner-keyed state (a caller's own MCP servers, their
#: secrets) is addressed by this, and reading it under one identity while
#: writing it under another is how one account's servers become invisible to
#: itself. Comes from ``multi_user.paths.current_owner_id``.
owner_id: str = ""
#: A partner is a synthetic non-admin user anchored to an owner's
#: workspace; its own configured filter is the authority for its surface,
#: not the (absent) per-user grant.
is_partner: bool = False
session_id: str = ""
#: The caller's own configured whitelist (a partner's ``mcp_tools``).
#: ``None`` = the caller imposes no restriction.
caller_whitelist: frozenset[str] | None = None
#: Providers authorised by holding a *resource* rather than by a grant:
#: attaching a PageIndex knowledge base authorises that server. Given as
#: provider ids because the turn knows which resources it holds, not which
#: tool names they expand to — the view resolves that against the live
#: pool.
implicit_provider_ids: frozenset[str] = frozenset()
#: An exclusive knowledge capability owns the turn and replaces the tool
#: surface, so provider tools must not be advertised (see ``authorize``).
exclusive_capability: bool = False
__all__ = ["ToolScope"]