mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 18:00:11 +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
127 lines
4.6 KiB
TypeScript
127 lines
4.6 KiB
TypeScript
"use client";
|
||
|
||
/**
|
||
* Provider-grouped whitelist editor: one tri-state row per MCP server that
|
||
* expands to the server's individual tools. With ~40 curated services × 10+
|
||
* tools each, assigning a whole service has to be one click while fine-grained
|
||
* control stays reachable.
|
||
*
|
||
* Shared by the partner tool picker and the admin grant editor: the grouping and
|
||
* tri-state behaviour are identical in both, only the per-tool row styling
|
||
* differs, so rows stay caller-rendered via `renderTool`. Deliberately free of
|
||
* copy (checkbox + provider id + count + chevron) — the admin surface is not
|
||
* wired to react-i18next, so any string here would end up duplicated or
|
||
* untranslated.
|
||
*/
|
||
|
||
import { useState, type ReactNode } from "react";
|
||
import { ChevronRight } from "lucide-react";
|
||
import {
|
||
groupProviderTools,
|
||
groupCounts,
|
||
selectionFromCounts,
|
||
setGroupSelected,
|
||
toggleToolName,
|
||
type ProviderToolLike,
|
||
} from "@/lib/mcp-tool-groups";
|
||
|
||
export default function McpToolGroups<T extends ProviderToolLike>({
|
||
tools,
|
||
selected,
|
||
onChange,
|
||
disabled = false,
|
||
rowsClassName,
|
||
renderTool,
|
||
}: {
|
||
tools: readonly T[];
|
||
/** Flat tool-name whitelist — exactly what the caller saves. */
|
||
selected: string[];
|
||
onChange: (next: string[]) => void;
|
||
disabled?: boolean;
|
||
/** Container class for an expanded group's rows (callers keep their layout). */
|
||
rowsClassName?: string;
|
||
renderTool: (args: {
|
||
tool: T;
|
||
checked: boolean;
|
||
onToggle: () => void;
|
||
}) => ReactNode;
|
||
}) {
|
||
// Expansion overrides keyed by provider id; a group with no override follows
|
||
// its selection state, so a partially granted service opens on its own
|
||
// (including after the options arrive asynchronously).
|
||
const [overrides, setOverrides] = useState<Record<string, boolean>>({});
|
||
|
||
return (
|
||
<div className="space-y-1.5">
|
||
{groupProviderTools(tools).map((group) => {
|
||
const counts = groupCounts(group.tools, selected);
|
||
const state = selectionFromCounts(counts);
|
||
const chosen = counts.hits;
|
||
const open = overrides[group.id] ?? state === "partial";
|
||
return (
|
||
<div key={group.id}>
|
||
<div className="flex items-center gap-2 rounded-lg px-2 py-1 hover:bg-[var(--muted)]/50">
|
||
<label className="flex min-w-0 flex-1 cursor-pointer items-center gap-2">
|
||
<input
|
||
type="checkbox"
|
||
checked={state === "all"}
|
||
disabled={disabled}
|
||
ref={(el) => {
|
||
if (el) el.indeterminate = state === "partial";
|
||
}}
|
||
onChange={() => {
|
||
// Pin the current expansion first: without an override the
|
||
// row follows `state === "partial"`, so ticking a partial
|
||
// group would flip it to "all" and snap it shut under the
|
||
// cursor mid-review.
|
||
setOverrides((current) => ({
|
||
...current,
|
||
[group.id]: open,
|
||
}));
|
||
onChange(
|
||
setGroupSelected(selected, group.tools, state !== "all"),
|
||
);
|
||
}}
|
||
/>
|
||
<span className="truncate font-mono text-[11.5px] text-[var(--foreground)]">
|
||
{group.id}
|
||
</span>
|
||
</label>
|
||
<span className="shrink-0 text-[11px] tabular-nums text-[var(--muted-foreground)]">
|
||
{chosen}/{group.tools.length}
|
||
</span>
|
||
<button
|
||
type="button"
|
||
aria-label={group.id}
|
||
aria-expanded={open}
|
||
onClick={() =>
|
||
setOverrides((current) => ({ ...current, [group.id]: !open }))
|
||
}
|
||
className="shrink-0 rounded p-0.5 text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
|
||
>
|
||
<ChevronRight
|
||
className={`h-3.5 w-3.5 transition-transform ${
|
||
open ? "rotate-90" : ""
|
||
}`}
|
||
/>
|
||
</button>
|
||
</div>
|
||
{open && (
|
||
<div className={`pl-4 ${rowsClassName ?? "space-y-1.5"}`}>
|
||
{group.tools.map((tool) =>
|
||
renderTool({
|
||
tool,
|
||
checked: selected.includes(tool.name),
|
||
onToggle: () =>
|
||
onChange(toggleToolName(selected, tool.name)),
|
||
}),
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
})}
|
||
</div>
|
||
);
|
||
}
|