${icon("warn")}The server's tools are not the ones approved on Nov 28. The unchanged tools keep working; the rest stay out of the run until you approve them.
` : "");
+ toast = "";
+ };
+
+ const toList = (message = "") => {
+ toast = message;
+ state = { view: "list" };
+ };
+
+ panel.addEventListener("change", (event) => {
+ const target = event.target;
+ if (state.view === "add" && target.dataset.f === "preset") {
+ const preset = PRESETS.find((p) => p.name === target.value);
+ state = {
+ ...state,
+ preset: target.value,
+ name: preset?.name ?? "",
+ url: preset?.url ?? "",
+ error: null,
+ };
+ render();
+ }
+ });
+
+ panel.addEventListener("input", (event) => {
+ const field = event.target.dataset?.f;
+ if (state.view === "add" && (field === "name" || field === "url")) {
+ state[field] = event.target.value;
+ }
+ });
+
+ panel.addEventListener("click", (event) => {
+ const el = event.target.closest("[data-act]");
+ if (!el) return;
+ const act = el.dataset.act;
+ const index = el.dataset.index === undefined ? null : Number(el.dataset.index);
+ if (index !== null && act !== "open") event.stopPropagation();
+ if (act === "open") {
+ const c = connectors[index];
+ if (c.readOnly) state = { view: "readonly", index };
+ else if (c.status === "auth") state = { view: "waiting", index };
+ else if (c.status === "changed") state = { view: "changed", index };
+ else if (c.status === "refused") state = { view: "add", preset: "", name: c.name, url: c.url, error: c.why, editing: index };
+ else if (c.tools.length) state = { view: "tools", index };
+ else return;
+ } else if (act === "connect") state = { view: "waiting", index };
+ else if (act === "review") state = { view: "changed", index };
+ else if (act === "turn-on") {
+ connectors[index].status = "auth";
+ toast = `${connectors[index].name} is on; connect it to use its tools`;
+ } else if (act === "add") state = { view: "add", preset: "", name: "", url: "", error: null };
+ else if (act === "back" || act === "to-list") {
+ if (panel.dataset.start === "chat" && act === "back") state = { view: "chat" };
+ else toList();
+ } else if (act === "save-add") {
+ let host = "";
+ try {
+ const url = new URL(state.url);
+ host = url.protocol === "https:" ? url.hostname : "";
+ } catch {
+ host = "";
+ }
+ const isPrivate = /^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|\[?::1\]?$)/.test(host);
+ if (state.name.trim() === "") {
+ state = { ...state, error: null };
+ toast = "Give it a name";
+ } else if (host === "" || isPrivate) {
+ state = {
+ ...state,
+ error: "Refused by the URL policy: only https, and no private, loopback or link-local address.",
+ };
+ } else {
+ const fresh = {
+ id: `new-${Date.now()}`,
+ name: state.name.trim(),
+ url: state.url,
+ scope: "personal",
+ status: "auth",
+ tools: [],
+ };
+ if (state.editing !== undefined) connectors.splice(state.editing, 1, fresh);
+ else connectors.unshift(fresh);
+ const index = connectors.indexOf(fresh);
+ if (PRESETS.find((p) => p.name === state.preset)?.token) {
+ fresh.status = "connected";
+ fresh.tools = LINEAR_TOOLS.map((t) => ({ ...t, on: false, always: false }));
+ toast = `Tested ${fresh.name}; choose its tools`;
+ state = { view: "tools", index };
+ } else state = { view: "waiting", index };
+ }
+ } else if (act === "authorized") {
+ const c = connectors[state.index];
+ c.status = "connected";
+ c.tools = LINEAR_TOOLS.map((t) => ({ ...t, on: false, always: false }));
+ toast = `Signed in to ${c.name}; choose its tools`;
+ state = { view: "tools", index: state.index };
+ } else if (act === "toggle") {
+ const tool = connectors[state.index].tools[Number(el.dataset.tool)];
+ tool.on = el.checked;
+ if (!tool.on) tool.always = false;
+ } else if (act === "ask" || act === "always") {
+ event.preventDefault();
+ connectors[state.index].tools[Number(el.dataset.tool)].always = act === "always";
+ } else if (act === "save-tools") toList(`Saved ${connectors[state.index].name}`);
+ else if (act === "disable") {
+ connectors[state.index].status = "off";
+ toList(`${connectors[state.index].name} is off; its sign-in and tools are kept`);
+ } else if (act === "remove") {
+ const [gone] = connectors.splice(state.index, 1);
+ toList(`Removed ${gone.name} and signed out of it`);
+ } else if (act === "approve-changes") {
+ const c = connectors[state.index];
+ c.status = "connected";
+ c.tools = [{ on: true }, { on: true }, { on: true }, { on: true }, { on: false }];
+ toList(`Approved the new tools of ${c.name}`);
+ } else return;
+ render();
+ });
+ render();
+}
+
+for (const panel of document.querySelectorAll(".panel")) mount(panel);
+
+for (const button of document.querySelectorAll("[data-theme-pick]")) {
+ button.addEventListener("click", () => {
+ const pick = button.dataset.themePick;
+ if (pick === "system") delete document.documentElement.dataset.theme;
+ else document.documentElement.dataset.theme = pick;
+ for (const other of document.querySelectorAll("[data-theme-pick]")) {
+ other.setAttribute("aria-pressed", String(other === button));
+ }
+ });
+}
diff --git a/demo/connectors/index.html b/demo/connectors/index.html
new file mode 100644
index 0000000..a989002
--- /dev/null
+++ b/demo/connectors/index.html
@@ -0,0 +1,1325 @@
+
+
+
+
+
+ Connectors design
+
+
+
+
+ Connectors
+ design study for the connectors panel; every frame is clickable
+
+
+
+
+
+
+
+
+
Remote MCP servers a user connects
+
+ A connector is a remote MCP server the user adds by URL or from a preset the host
+ offers. Its tools join the agent's run once the user has signed in to it and chosen which
+ tools to turn on. Every call to a connector tool asks for approval, whatever the server
+ says about the tool, unless the host's policy lets the user always allow that tool.
+
+
+ The same panel is drawn twice: inside the chat, as the routines and skills views are,
+ and as <ag-ui-connectors> on a settings page of the host's own, with
+ no chat beside it.
+
+
+
+
Inside the chat
+
A full-panel view in place of the conversation, with a back arrow to it.
+
+
+
+
+ 1. The list. One row per connector, grouped as the policy answers (personal or
+ team), each with its status: connected (and how many tools are on),
+ needs authorization (Connect), tools changed (Review), refused by the
+ URL policy (the reason, no way to connect), and off. A team connector the caller
+ may not write opens read-only.
+
+
+
+
+
+ 2. Adding one. A preset fills the name and the URL and locks the URL; Custom
+ leaves both free. A preset whose server takes a token asks for it here (pick Sentry);
+ it is tested straight away. The others sign in through the server's own page after saving. Try an
+ http:// or private address: the URL policy refuses it under the field.
+
+
+
+
+
+ 3. Connect. The server's authorization page opens in a popup and the panel waits
+ for the callback's message. Click Allow in the drawn popup: the panel then tests the
+ server and lists its tools (frame 4). If the popup is blocked or closed, Open again.
+
+
+
+
+
+ 4. Tools from the test, when the policy permits always allow. One switch per tool
+ puts it in the run. Each tool that is on asks every time by default; the user may set
+ it to Always allow. What the server says about a tool (read-only, destructive) is shown
+ as its claim, not acted on.
+
+
+
+
+
+ 5. The same, when the policy does not permit it. The choice is shown locked at
+ Ask every time, with one line saying why, rather than hidden, so a user who heard of it
+ learns it is the host's rule.
+
+
+
+
+
+ 6. Tools changed. The server's tools differ from what the user approved. The
+ unchanged tools keep working; a new tool comes in off, a changed one is out of the run
+ until approved again, and a removed one is listed so the user sees it went.
+
+
+
+
+
+ 7. Provenance, policy permits always allow. A connector tool's card and its
+ approval card name the connector, its host, and that it is the user's own, not the
+ app's. The server marks list_issues read-only and it still asks. Always
+ allow sits on the card, beside Approve.
+
+
+
+
+
+ 8. Provenance, policy forbids it, and an MCP App. No Always allow on the card,
+ only a line saying every call asks. Above it, a connector tool that carries an MCP Apps
+ view renders as a plain result, with one line saying the view is not shown.
+
+
+
+
+
On a page of its own: <ag-ui-connectors>
+
+ The same screens, on the host's settings page with no chat. Its first screen has no back
+ arrow (there is nothing to go back to); the screens behind a row do.
+
+
+
+
+
Connectors
+
Servers your assistant may call for you. Each call asks first.
+ Where Always allow is set: on the tools screen (frame 4), on the approval card
+ (frame 7), or both. Recommended: both, the card's box sets the same stored answer.
+
+
+ Always allow when the policy forbids it: locked with its reason on the tools
+ screen and absent from the approval card with one line (frames 5 and 8), or hidden
+ everywhere. Recommended: as drawn.
+
+
+ How the chat opens the panel: the header holds six buttons at 240px, so a
+ Connectors button comes behind its own opt-in attribute, as the skill editor's does;
+ or only a row in the header's More menu. Recommended: the More menu row by default,
+ the header button behind an opt-in.
+
+
+ Which tools are on after the first test: none (the user turns each on, with Turn
+ all on), or all. Recommended: none, as drawn; the stored allow-list's empty value
+ already means none.
+
+
+ Tools changed: only the changed tools leave the run until reviewed (drawn), or
+ the whole connector stops. Recommended: only the changed tools.
+
+
+ Off and Remove: both (off keeps the sign-in and the tool choices, Remove deletes
+ the connector and revokes its credential), or Remove only. Recommended: both, as drawn.
+
+
+ MCP Apps from a connector: out of the first cut? A connector tool with a view
+ renders as a plain result (frame 8). Recommended: yes, out of the first cut.
+
+
+
+
+
+
+
diff --git a/demo/mock-server.mjs b/demo/mock-server.mjs
index d7d5102..7906f4a 100644
--- a/demo/mock-server.mjs
+++ b/demo/mock-server.mjs
@@ -41,7 +41,7 @@ const HTML = "text/html; charset=utf-8";
const APP_PAGE = { path: "app/index.html", contentType: HTML };
const SCENARIO_PATH = /^\/scenarios\/[a-z0-9-]+\/$/;
// Static files are served from these directories only, by extension.
-const STATIC_DIRS = ["app", "page", "threads", "agents", "editors"];
+const STATIC_DIRS = ["app", "page", "threads", "agents", "editors", "connectors"];
const TYPES = new Map([
[".html", HTML],
[".js", "text/javascript"],
@@ -55,6 +55,8 @@ const PAGE_ASSETS = new Map([
["/agents/", { path: "agents/index.html", contentType: HTML }],
// The routines and skill editors as elements of their own, beside a chat or alone.
["/editors/", { path: "editors/index.html", contentType: HTML }],
+ // A static design study of the connectors panel; it loads no bundle.
+ ["/connectors/", { path: "connectors/index.html", contentType: HTML }],
// Every page loads it; it does nothing unless the URL carries `?readout`.
["/viewport-readout.js", { path: "viewport-readout.js", contentType: "text/javascript" }],
]);
@@ -1717,6 +1719,7 @@ server.listen(PORT, HOST, () => {
process.stdout.write(` thread list: http://localhost:${PORT}/threads/\n`);
process.stdout.write(` agents home: http://localhost:${PORT}/agents/\n`);
process.stdout.write(` editor elements: http://localhost:${PORT}/editors/\n`);
+ process.stdout.write(` connectors design: http://localhost:${PORT}/connectors/\n`);
// Any wildcard bind reaches the LAN, so the addresses are worth printing for
// both spellings rather than only the one this file happens to default to.
if (HOST === "::" || HOST === "0.0.0.0") {