mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:29:37 +08:00
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
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
"""An allowlist of tool names with an explicit *unrestricted* state.
|
|
|
|
The turn's provider authorisation has to combine several optional whitelists
|
|
(a partner's configured filter, the caller's grant, an implicit
|
|
resource-derived grant). Modelling "no restriction" as ``None`` inside bare
|
|
set arithmetic makes both directions of mistake easy and silent:
|
|
|
|
* ``None | {"x"}`` raises, so a widening step crashes on an unrestricted
|
|
caller (an administrator);
|
|
* "repairing" it as ``(base or set()) | extra`` turns *unrestricted* into
|
|
*only the extra names* — a silent, total loss of tool access.
|
|
|
|
This type makes the state explicit so both operations are total: narrowing an
|
|
unrestricted list yields the other list, widening one stays unrestricted.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Iterable
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Allowlist:
|
|
"""Allowed tool names, or unrestricted when :attr:`names` is ``None``."""
|
|
|
|
names: frozenset[str] | None = None
|
|
|
|
@classmethod
|
|
def unrestricted(cls) -> "Allowlist":
|
|
return cls(names=None)
|
|
|
|
@classmethod
|
|
def of(cls, names: Iterable[str] | None) -> "Allowlist":
|
|
"""Build from an optional iterable; ``None`` means unrestricted."""
|
|
if names is None:
|
|
return cls(names=None)
|
|
return cls(names=frozenset(str(name) for name in names))
|
|
|
|
@property
|
|
def is_unrestricted(self) -> bool:
|
|
return self.names is None
|
|
|
|
def allows(self, name: str) -> bool:
|
|
return self.names is None or name in self.names
|
|
|
|
def narrow(self, other: "Allowlist") -> "Allowlist":
|
|
"""Intersect with *other*; an unrestricted side imposes no limit."""
|
|
if self.names is None:
|
|
return other
|
|
if other.names is None:
|
|
return self
|
|
return Allowlist(names=self.names & other.names)
|
|
|
|
def widen(self, extra: Iterable[str]) -> "Allowlist":
|
|
"""Add *extra* names. Unrestricted stays unrestricted."""
|
|
if self.names is None:
|
|
return self
|
|
return Allowlist(names=self.names | frozenset(str(name) for name in extra))
|
|
|
|
def as_set(self) -> set[str] | None:
|
|
"""Plain-set form for APIs that use the ``set | None`` convention."""
|
|
return None if self.names is None else set(self.names)
|
|
|
|
|
|
__all__ = ["Allowlist"]
|