@ractive-ch/tab-mcp-client 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,25 +56,45 @@ function newDialog(doc, className, title) {
56
56
  dialog.append(heading);
57
57
  return { dialog, heading };
58
58
  }
59
+ var INVISIBLE = /[\p{Cf}\p{Default_Ignorable_Code_Point}\p{Co}\p{Cn}\u0080-\u009F\u2028\u2029]/gu;
60
+ function visible(text) {
61
+ return text.replace(INVISIBLE, (ch) => {
62
+ let escaped = "";
63
+ for (let i = 0;i < ch.length; i++)
64
+ escaped += `\\u${ch.charCodeAt(i).toString(16).toUpperCase().padStart(4, "0")}`;
65
+ return escaped;
66
+ });
67
+ }
59
68
  function clientLabel(client) {
60
- const host = client.host || client.id;
61
- return client.name !== undefined && client.name !== "" ? `${client.name} (${host})` : host;
69
+ const host = visible(client.host || client.id);
70
+ return client.name !== undefined && client.name !== "" ? `${visible(client.name)} (${host})` : host;
71
+ }
72
+ function name(doc, text) {
73
+ const node = el(doc, "bdi", { text });
74
+ node.dir = "ltr";
75
+ return node;
62
76
  }
63
77
  function showArguments(args) {
64
78
  try {
65
- return JSON.stringify(args, null, 2);
79
+ return visible(JSON.stringify(args, null, 2));
66
80
  } catch {
67
81
  return;
68
82
  }
69
83
  }
70
84
  var ALLOW_DELAY_MS = 750;
71
85
  var MIN_ALLOW_DELAY_MS = 500;
86
+ function allowDelay(ms) {
87
+ const value = typeof ms === "number" && Number.isFinite(ms) && ms < 2 ** 31 ? ms : ALLOW_DELAY_MS;
88
+ return Math.max(MIN_ALLOW_DELAY_MS, value);
89
+ }
72
90
  function confirmDialog(request, doc, options = {}) {
73
- const delay = Math.max(MIN_ALLOW_DELAY_MS, options.allowDelayMs ?? ALLOW_DELAY_MS);
91
+ const delay = allowDelay(options.allowDelayMs);
74
92
  if (request.signal.aborted)
75
93
  return Promise.resolve("deny");
76
94
  const title = request.tool.title ?? request.tool.name;
77
- const { dialog } = newDialog(doc, "tab-mcp-confirm", `Allow ${title}?`);
95
+ const { dialog, heading } = newDialog(doc, "tab-mcp-confirm", "");
96
+ heading.append("Allow ", name(doc, title), "?");
97
+ const client = clientLabel(request.client);
78
98
  const deny = button(doc, "Don't allow", () => dialog.close("deny"));
79
99
  const allow = button(doc, "Allow", () => {
80
100
  if (!allow.disabled)
@@ -87,10 +107,7 @@ function confirmDialog(request, doc, options = {}) {
87
107
  allow.disabled = true;
88
108
  always.disabled = true;
89
109
  const actions = el(doc, "div", { className: "tab-mcp-actions" }, deny, " ", allow, " ", always);
90
- const alwaysNote = el(doc, "p", {
91
- className: "tab-mcp-always-note",
92
- text: `Always allow: ${title} runs without asking for ${clientLabel(request.client)} until you reload this page or disconnect it.`
93
- });
110
+ const alwaysNote = el(doc, "p", { className: "tab-mcp-always-note" }, "Always allow: ", name(doc, title), " runs without asking for ", name(doc, client), " until you reload this page or disconnect it.");
94
111
  const shown = showArguments(request.arguments);
95
112
  const args = el(doc, "pre", {
96
113
  className: "tab-mcp-arguments",
@@ -101,23 +118,41 @@ function confirmDialog(request, doc, options = {}) {
101
118
  always.hidden = true;
102
119
  alwaysNote.hidden = true;
103
120
  }
121
+ args.dir = "ltr";
104
122
  args.style.setProperty("white-space", "pre-wrap");
105
123
  args.style.setProperty("max-height", "12rem");
106
124
  args.style.setProperty("overflow", "auto");
107
125
  args.hidden = Object.keys(request.arguments).length === 0;
108
- dialog.append(el(doc, "p", {
109
- text: `${clientLabel(request.client)} wants to run ${title}.`
110
- }), el(doc, "p", {
126
+ dialog.append(el(doc, "p", {}, name(doc, client), " wants to run ", name(doc, title), "."), el(doc, "p", {
111
127
  className: "tab-mcp-description",
112
128
  text: request.tool.description
113
129
  }), args, actions, alwaysNote);
114
130
  doc.body.append(dialog);
131
+ const view = doc.defaultView;
115
132
  return new Promise((resolve) => {
116
133
  const onAbort = () => dialog.close("deny");
117
134
  request.signal.addEventListener("abort", onAbort, { once: true });
118
135
  let timer;
136
+ const arm = (event) => {
137
+ clearTimeout(timer);
138
+ timer = undefined;
139
+ allow.disabled = true;
140
+ always.disabled = true;
141
+ if (event?.type === "blur" || doc.visibilityState === "hidden" || !doc.hasFocus())
142
+ return;
143
+ timer = setTimeout(() => {
144
+ allow.disabled = false;
145
+ always.disabled = false;
146
+ }, delay);
147
+ };
148
+ doc.addEventListener("visibilitychange", arm);
149
+ view?.addEventListener("focus", arm);
150
+ view?.addEventListener("blur", arm);
119
151
  dialog.addEventListener("close", () => {
120
152
  clearTimeout(timer);
153
+ doc.removeEventListener("visibilitychange", arm);
154
+ view?.removeEventListener("focus", arm);
155
+ view?.removeEventListener("blur", arm);
121
156
  request.signal.removeEventListener("abort", onAbort);
122
157
  const value = dialog.returnValue;
123
158
  dialog.remove();
@@ -125,10 +160,7 @@ function confirmDialog(request, doc, options = {}) {
125
160
  }, { once: true });
126
161
  dialog.showModal();
127
162
  deny.focus();
128
- timer = setTimeout(() => {
129
- allow.disabled = false;
130
- always.disabled = false;
131
- }, delay);
163
+ arm();
132
164
  });
133
165
  }
134
166
  var INSTRUCTIONS = [
@@ -394,5 +426,5 @@ export {
394
426
  showConnectDialog
395
427
  };
396
428
 
397
- //# debugId=3D42E4AA9603278F64756E2164756E21
398
- //# sourceMappingURL=ui-rtahm62h.js.map
429
+ //# debugId=62FD792E93994A5B64756E2164756E21
430
+ //# sourceMappingURL=ui-htav9g19.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/ui.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The default UI, loaded on demand: the \"Connect your AI app\" dialog\n * (DEC-028) and the confirmation of consequential tools. Plain `<dialog>`\n * elements, no styles beyond a few CSS custom properties (`--tab-mcp-*`), all\n * text set with `textContent`. Pages with their own UI use the events and\n * methods of `TabMcp` instead.\n */\n\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type {\n\tConfirmRequest,\n\tDisconnectDetail,\n\tGrant,\n\tSessionInfo,\n\tToolCallClient,\n} from \"./types.ts\";\n\nlet counter = 0;\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n\tdoc: Document,\n\ttag: K,\n\tprops: { className?: string; text?: string; id?: string } = {},\n\t...children: (Node | string)[]\n): HTMLElementTagNameMap[K] {\n\tconst node = doc.createElement(tag);\n\tif (props.className !== undefined) node.className = props.className;\n\tif (props.id !== undefined) node.id = props.id;\n\tif (props.text !== undefined) node.textContent = props.text;\n\tnode.append(...children);\n\treturn node;\n}\n\nfunction button(\n\tdoc: Document,\n\ttext: string,\n\tonClick: () => void,\n): HTMLButtonElement {\n\tconst node = el(doc, \"button\", { text });\n\tnode.type = \"button\";\n\tnode.addEventListener(\"click\", onClick);\n\treturn node;\n}\n\n/**\n * A Copy button for `value()`, read at click time. Shows \"Copied\" once the\n * clipboard took it; without a clipboard (or when it refuses) `select()` puts\n * the text in the selection for Ctrl+C instead. `noun` names it for assistive\n * technology (\"Copy code\"), as the dialog has more than one Copy.\n */\nfunction copyButton(\n\tdoc: Document,\n\tnoun: string,\n\tvalue: () => string,\n\tselect: () => void,\n): { button: HTMLButtonElement; reset: () => void } {\n\tconst node = button(doc, \"Copy\", () => {\n\t\tconst done = () => {\n\t\t\tnode.textContent = \"Copied\";\n\t\t\tnode.setAttribute(\"aria-label\", `Copied ${noun}`);\n\t\t};\n\t\tconst clipboard = (doc.defaultView?.navigator as Navigator | undefined)\n\t\t\t?.clipboard;\n\t\tif (clipboard !== undefined)\n\t\t\tclipboard.writeText(value()).then(done, select);\n\t\telse select();\n\t});\n\tconst reset = () => {\n\t\tnode.textContent = \"Copy\";\n\t\tnode.setAttribute(\"aria-label\", `Copy ${noun}`);\n\t};\n\treset();\n\treturn { button: node, reset };\n}\n\nfunction newDialog(\n\tdoc: Document,\n\tclassName: string,\n\ttitle: string,\n): { dialog: HTMLDialogElement; heading: HTMLHeadingElement } {\n\tconst id = `tab-mcp-${++counter}`;\n\tconst dialog = el(doc, \"dialog\", {\n\t\tclassName: `tab-mcp-dialog ${className}`,\n\t});\n\tdialog.setAttribute(\"aria-labelledby\", `${id}-title`);\n\t// CSSOM properties are allowed under a strict CSP (no inline style attribute).\n\tconst style = dialog.style;\n\tstyle.setProperty(\"max-width\", \"var(--tab-mcp-max-width, 34rem)\");\n\tstyle.setProperty(\"font\", \"var(--tab-mcp-font, inherit)\");\n\tstyle.setProperty(\"color\", \"var(--tab-mcp-color, CanvasText)\");\n\tstyle.setProperty(\"background\", \"var(--tab-mcp-background, Canvas)\");\n\tstyle.setProperty(\"border\", \"var(--tab-mcp-border, 1px solid GrayText)\");\n\tstyle.setProperty(\"border-radius\", \"var(--tab-mcp-radius, 0.5rem)\");\n\tstyle.setProperty(\"padding\", \"var(--tab-mcp-padding, 1rem 1.25rem)\");\n\tconst heading = el(doc, \"h2\", { id: `${id}-title`, text: title });\n\theading.style.setProperty(\"margin-top\", \"0\");\n\theading.style.setProperty(\"font-size\", \"var(--tab-mcp-title-size, 1.25em)\");\n\tdialog.append(heading);\n\treturn { dialog, heading };\n}\n\n/**\n * Characters that are invisible or change the direction of the text around\n * them: format characters (bidi controls and isolates, zero-width ones, tags),\n * the other default-ignorable ones (fillers, variation selectors), private-use\n * and unassigned code points, C1 controls, and line and paragraph separators.\n */\nconst INVISIBLE =\n\t/[\\p{Cf}\\p{Default_Ignorable_Code_Point}\\p{Co}\\p{Cn}\\u0080-\\u009F\\u2028\\u2029]/gu;\n\n/** Each such character as `\\uXXXX` (a pair for one beyond U+FFFF), as JSON would write it. */\nfunction visible(text: string): string {\n\treturn text.replace(INVISIBLE, (ch) => {\n\t\tlet escaped = \"\";\n\t\tfor (let i = 0; i < ch.length; i++)\n\t\t\tescaped += `\\\\u${ch.charCodeAt(i).toString(16).toUpperCase().padStart(4, \"0\")}`;\n\t\treturn escaped;\n\t});\n}\n\nfunction clientLabel(client: ToolCallClient | Grant[\"client\"]): string {\n\tconst host = visible(client.host || client.id);\n\treturn client.name !== undefined && client.name !== \"\"\n\t\t? `${visible(client.name)} (${host})`\n\t\t: host;\n}\n\n/** A name in a sentence, isolated so that it cannot reorder the words around it. */\nfunction name(doc: Document, text: string): HTMLElement {\n\tconst node = el(doc, \"bdi\", { text });\n\tnode.dir = \"ltr\";\n\treturn node;\n}\n\n/**\n * The arguments as text, in full: what the user approves must be visible.\n * (The relay caps a request at 1 MiB, so this stays bounded.) Invisible and\n * direction characters are shown as escapes, so the text is still JSON for\n * the same arguments; the tool gets them unchanged. `undefined` when they\n * cannot be shown, and then \"Allow\" is not offered.\n */\nfunction showArguments(args: Record<string, unknown>): string | undefined {\n\ttry {\n\t\treturn visible(JSON.stringify(args, null, 2));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** How long \"Allow\" stays disabled after the confirmation opens, and the floor. */\nexport const ALLOW_DELAY_MS = 750;\nexport const MIN_ALLOW_DELAY_MS = 500;\n\n/** The user's answer: \"always\" allows this tool for this AI app from now on. */\nexport type ConfirmAnswer = \"allow\" | \"always\" | \"deny\";\n\n/** `allowDelayMs` as a usable delay: the default unless a number of ms, never below the floor. */\nfunction allowDelay(ms: number | undefined): number {\n\tconst value =\n\t\ttypeof ms === \"number\" && Number.isFinite(ms) && ms < 2 ** 31\n\t\t\t? ms\n\t\t\t: ALLOW_DELAY_MS;\n\treturn Math.max(MIN_ALLOW_DELAY_MS, value);\n}\n\n/**\n * Ask whether a consequential tool may run. \"Allow\" and \"Always allow\" stay\n * disabled until the page has been visible and focused for `allowDelayMs`\n * (default 750, at least 500) while the dialog is open, so a click meant for\n * the page, or the click that brings the tab or window back, cannot approve.\n * Leaving the page disables them again. Everything else (Don't allow,\n * Escape, an aborted call) is \"deny\".\n */\nexport function confirmDialog(\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: { allowDelayMs?: number } = {},\n): Promise<ConfirmAnswer> {\n\tconst delay = allowDelay(options.allowDelayMs);\n\tif (request.signal.aborted) return Promise.resolve(\"deny\");\n\tconst title = request.tool.title ?? request.tool.name;\n\tconst { dialog, heading } = newDialog(doc, \"tab-mcp-confirm\", \"\");\n\theading.append(\"Allow \", name(doc, title), \"?\");\n\tconst client = clientLabel(request.client);\n\tconst deny = button(doc, \"Don't allow\", () => dialog.close(\"deny\"));\n\tconst allow = button(doc, \"Allow\", () => {\n\t\tif (!allow.disabled) dialog.close(\"allow\");\n\t});\n\tconst always = button(doc, \"Always allow\", () => {\n\t\tif (!always.disabled) dialog.close(\"always\");\n\t});\n\tallow.disabled = true;\n\talways.disabled = true;\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tdeny,\n\t\t\" \",\n\t\tallow,\n\t\t\" \",\n\t\talways,\n\t);\n\tconst alwaysNote = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ className: \"tab-mcp-always-note\" },\n\t\t\"Always allow: \",\n\t\tname(doc, title),\n\t\t\" runs without asking for \",\n\t\tname(doc, client),\n\t\t\" until you reload this page or disconnect it.\",\n\t);\n\tconst shown = showArguments(request.arguments);\n\tconst args = el(doc, \"pre\", {\n\t\tclassName: \"tab-mcp-arguments\",\n\t\ttext:\n\t\t\tshown ?? \"The arguments cannot be shown, so this call cannot be allowed.\",\n\t});\n\tif (shown === undefined) {\n\t\tallow.hidden = true;\n\t\talways.hidden = true;\n\t\talwaysNote.hidden = true;\n\t}\n\targs.dir = \"ltr\";\n\targs.style.setProperty(\"white-space\", \"pre-wrap\");\n\targs.style.setProperty(\"max-height\", \"12rem\");\n\targs.style.setProperty(\"overflow\", \"auto\");\n\targs.hidden = Object.keys(request.arguments).length === 0;\n\tdialog.append(\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"p\",\n\t\t\t{},\n\t\t\tname(doc, client),\n\t\t\t\" wants to run \",\n\t\t\tname(doc, title),\n\t\t\t\".\",\n\t\t),\n\t\tel(doc, \"p\", {\n\t\t\tclassName: \"tab-mcp-description\",\n\t\t\ttext: request.tool.description,\n\t\t}),\n\t\targs,\n\t\tactions,\n\t\talwaysNote,\n\t);\n\tdoc.body.append(dialog);\n\tconst view = doc.defaultView;\n\treturn new Promise((resolve) => {\n\t\tconst onAbort = () => dialog.close(\"deny\");\n\t\trequest.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t// The delay counts only while the user can see the page: tools are\n\t\t// called while the user is in the AI app, so the dialog often opens in\n\t\t// a background tab or window. Any change starts it again from zero (DEC-087).\n\t\tconst arm = (event?: Event) => {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t\tallow.disabled = true;\n\t\t\talways.disabled = true;\n\t\t\tif (\n\t\t\t\tevent?.type === \"blur\" ||\n\t\t\t\tdoc.visibilityState === \"hidden\" ||\n\t\t\t\t!doc.hasFocus()\n\t\t\t)\n\t\t\t\treturn;\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tallow.disabled = false;\n\t\t\t\talways.disabled = false;\n\t\t\t}, delay);\n\t\t};\n\t\tdoc.addEventListener(\"visibilitychange\", arm);\n\t\tview?.addEventListener(\"focus\", arm);\n\t\tview?.addEventListener(\"blur\", arm);\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tdoc.removeEventListener(\"visibilitychange\", arm);\n\t\t\t\tview?.removeEventListener(\"focus\", arm);\n\t\t\t\tview?.removeEventListener(\"blur\", arm);\n\t\t\t\trequest.signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tconst value = dialog.returnValue;\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve(value === \"allow\" || value === \"always\" ? value : \"deny\");\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\tdeny.focus(); // the safe choice is the default\n\t\t// Counted from when the dialog is shown, not from when it was built.\n\t\tarm();\n\t});\n}\n\nconst INSTRUCTIONS: [string, string][] = [\n\t[\n\t\t\"Claude (claude.ai and the desktop app)\",\n\t\t\"Settings → Connectors → Add custom connector, then paste the address.\",\n\t],\n\t[\n\t\t\"ChatGPT\",\n\t\t\"Settings → Apps and connectors → Advanced settings: turn on developer mode, then Create and paste the address.\",\n\t],\n\t[\"Claude Code\", \"Run: claude mcp add --transport http tools ADDRESS\"],\n];\n\n/** \"A and B\", \"A, B and C\". */\nfunction listOf(items: string[]): string {\n\treturn items.length < 2\n\t\t? (items[0] ?? \"\")\n\t\t: `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`;\n}\n\n/**\n * The \"Connect your AI app\" dialog: the address with Copy and New address,\n * short instructions, the pairing code (with Copy) while the relay sends one,\n * and the connected apps with Disconnect. Pairing is on while it is open, so\n * closing it ends the code; the connection and the address stay. Until an app\n * connects, only a small Close (and Escape) close it; then a Done. New address\n * asks first when it would disconnect connected apps (`newAddress()` revokes\n * them).\n */\nexport function showConnectDialog(\n\tmcp: TabMcp,\n\tconnecting: Promise<SessionInfo>,\n\tdoc: Document,\n): Promise<void> {\n\tconst { dialog } = newDialog(doc, \"tab-mcp-connect\", \"Connect your AI app\");\n\t// Focusable from script only, for the moment before the address is shown.\n\tdialog.tabIndex = -1;\n\tdialog.style.setProperty(\"outline\", \"none\");\n\tconst status = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-status\",\n\t\ttext: \"Connecting…\",\n\t});\n\tstatus.setAttribute(\"role\", \"status\");\n\n\tconst addressId = `tab-mcp-${++counter}-address`;\n\tconst label = el(doc, \"label\", { text: \"Add this address to your AI app:\" });\n\tlabel.htmlFor = addressId;\n\tconst address = el(doc, \"input\", {\n\t\tid: addressId,\n\t\tclassName: \"tab-mcp-address-input\",\n\t});\n\taddress.readOnly = true;\n\taddress.style.setProperty(\"width\", \"100%\");\n\taddress.style.setProperty(\"font-family\", \"var(--tab-mcp-mono, monospace)\");\n\tconst { button: copy, reset: resetCopy } = copyButton(\n\t\tdoc,\n\t\t\"address\",\n\t\t() => address.value,\n\t\t() => address.select(),\n\t);\n\tcopy.className = \"tab-mcp-address-copy\";\n\tconst fresh = button(doc, \"New address\", () => askNewAddress());\n\tfresh.className = \"tab-mcp-new-address\";\n\tconst addressBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-address\" },\n\t\tlabel,\n\t\taddress,\n\t\t\" \",\n\t\tcopy,\n\t\t\" \",\n\t\tfresh,\n\t);\n\n\t// Asked in the dialog before New address disconnects connected apps.\n\tconst confirmId = `tab-mcp-${++counter}-new-address`;\n\tconst confirmText = el(doc, \"p\", { id: confirmId });\n\tconst cancelNew = button(doc, \"Cancel\", () => {\n\t\tconfirmBox.hidden = true;\n\t\tfresh.focus();\n\t});\n\tconst confirmNew = button(doc, \"Disconnect and get new address\", () =>\n\t\tgetNewAddress(),\n\t);\n\tconfirmNew.className = \"tab-mcp-new-address-confirm\";\n\tconst confirmBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-new-address-question\" },\n\t\tconfirmText,\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"div\",\n\t\t\t{ className: \"tab-mcp-actions\" },\n\t\t\tcancelNew,\n\t\t\t\" \",\n\t\t\tconfirmNew,\n\t\t),\n\t);\n\tconfirmBox.setAttribute(\"role\", \"group\");\n\tconfirmBox.setAttribute(\"aria-labelledby\", confirmId);\n\tconfirmBox.hidden = true;\n\n\tconst code = el(doc, \"strong\", { className: \"tab-mcp-code-value\" });\n\tcode.style.setProperty(\"font-size\", \"var(--tab-mcp-code-size, 1.5em)\");\n\tcode.style.setProperty(\"letter-spacing\", \"0.1em\");\n\tcode.style.setProperty(\"font-family\", \"var(--tab-mcp-mono, monospace)\");\n\t// One click selects the whole code; it stays plain, selectable text.\n\tcode.style.setProperty(\"user-select\", \"all\");\n\tcode.style.setProperty(\"-webkit-user-select\", \"all\");\n\t// Reads the code shown at click time, so a rotated code is copied as shown.\n\tconst { button: copyCode, reset: resetCopyCode } = copyButton(\n\t\tdoc,\n\t\t\"code\",\n\t\t() => code.textContent ?? \"\",\n\t\t() => doc.getSelection()?.selectAllChildren(code),\n\t);\n\tcopyCode.className = \"tab-mcp-code-copy\";\n\t// Only the sentence with the code is announced when the code changes,\n\t// not its Copy button's \"Copied\".\n\tconst codeSentence = el(doc, \"span\", {}, \"When asked, enter the code \", code);\n\tcodeSentence.setAttribute(\"aria-live\", \"polite\");\n\tconst codeLine = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ className: \"tab-mcp-code\" },\n\t\tcodeSentence,\n\t\t\" \",\n\t\tcopyCode,\n\t\tel(doc, \"br\"),\n\t\tel(doc, \"small\", {\n\t\t\tclassName: \"tab-mcp-code-note\",\n\t\t\ttext: \"A new code appears every 2 minutes and after each use.\",\n\t\t}),\n\t);\n\t// Identity binding: no code, the same account at the AI app's sign-in.\n\tconst signInLine = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-sign-in\",\n\t\ttext: \"When your AI app asks, sign in with the account you use on this page. No code is needed.\",\n\t});\n\n\tconst steps = el(doc, \"ul\");\n\tconst help = el(\n\t\tdoc,\n\t\t\"details\",\n\t\t{ className: \"tab-mcp-help\" },\n\t\tel(doc, \"summary\", { text: \"How do I add it?\" }),\n\t\tsteps,\n\t);\n\n\tconst appList = el(doc, \"ul\");\n\tconst apps = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-apps\" },\n\t\tel(doc, \"h3\", { text: \"Connected\" }),\n\t\tappList,\n\t);\n\n\t// Until an app connects in this dialog, closing it is not the next step:\n\t// a small Close at the end, saying what closing does (the code stops, the\n\t// address stays). Once one connects, a prominent Done replaces both.\n\tconst closeNote = el(doc, \"small\", {\n\t\tclassName: \"tab-mcp-close-note\",\n\t\ttext: \"Closing this stops the code. The address stays the same: to connect later, open this again from the page.\",\n\t});\n\tconst close = button(doc, \"Close\", () => dialog.close());\n\tclose.className = \"tab-mcp-close\";\n\tclose.style.setProperty(\"font-size\", \"0.875em\");\n\tconst done = button(doc, \"Done\", () => dialog.close());\n\tdone.className = \"tab-mcp-done\";\n\tdone.style.setProperty(\"font-weight\", \"bold\");\n\tdone.hidden = true;\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tcloseNote,\n\t\t\" \",\n\t\tclose,\n\t\tdone,\n\t);\n\t// The note on the left, the button at the far right, apart from the code.\n\tactions.style.setProperty(\"display\", \"flex\");\n\tactions.style.setProperty(\"align-items\", \"center\");\n\tactions.style.setProperty(\"justify-content\", \"flex-end\");\n\tactions.style.setProperty(\"gap\", \"0.75rem\");\n\tactions.style.setProperty(\"margin-top\", \"1rem\");\n\tcloseNote.style.setProperty(\"flex\", \"1\");\n\t// An app connected while this dialog is open (since the last new address),\n\t// and still connected: the grants that made it so.\n\tlet paired = false;\n\tconst pairedGrants = new Set<string>();\n\t// The note is about the code: only while one is shown and nothing paired.\n\tconst renderCloseNote = () => {\n\t\tcloseNote.hidden = paired || codeLine.hidden;\n\t};\n\tconst setPaired = (value: boolean) => {\n\t\tpaired = value;\n\t\tif (!paired) pairedGrants.clear();\n\t\tconst focused = doc.activeElement;\n\t\trenderCloseNote();\n\t\tclose.hidden = paired;\n\t\tdone.hidden = !paired;\n\t\t// Focus never stays on a control that was just hidden.\n\t\tif (paired && focused === close) done.focus();\n\t\tif (!paired && focused === done) close.focus();\n\t};\n\t// The visible button that closes the dialog.\n\tconst closer = () => (paired ? done : close);\n\n\tdialog.append(\n\t\tstatus,\n\t\taddressBox,\n\t\tconfirmBox,\n\t\tcodeLine,\n\t\tsignInLine,\n\t\thelp,\n\t\tapps,\n\t\tactions,\n\t);\n\taddressBox.hidden = true;\n\tcodeLine.hidden = true;\n\tsignInLine.hidden = true;\n\thelp.hidden = true;\n\tapps.hidden = true;\n\n\t// Set while New address waits for the new session.\n\tlet renewing = false;\n\t// The question names the apps connected now; pairing goes on while it is open.\n\tconst renderQuestion = (): boolean => {\n\t\tconst names = mcp.grants.map((g) => clientLabel(g.client));\n\t\tif (names.length === 0) return false;\n\t\tconfirmText.textContent = `A new address disconnects ${listOf(names)}. To use this page again, add the new address to ${names.length === 1 ? \"it\" : \"them\"}.`;\n\t\treturn true;\n\t};\n\tconst askNewAddress = () => {\n\t\tif (mcp.state !== \"connected\") return;\n\t\tif (!renderQuestion()) {\n\t\t\tgetNewAddress();\n\t\t\treturn;\n\t\t}\n\t\tconfirmBox.hidden = false;\n\t\tcancelNew.focus(); // the safe choice is the default\n\t};\n\tconst getNewAddress = () => {\n\t\t// The apps are disconnected: the next one has to pair again.\n\t\tsetPaired(false);\n\t\t// Focus moves before the focused control is hidden.\n\t\tclose.focus();\n\t\tconfirmBox.hidden = true;\n\t\trenewing = true;\n\t\tstatus.textContent = \"Getting a new address…\";\n\t\t// Called from the click, so the reconnect has the user action it needs.\n\t\tmcp.newAddress().then(\n\t\t\t() => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent =\n\t\t\t\t\t\"This is a new address. Add it to your AI app again.\";\n\t\t\t\tcopy.focus();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}. Close this and connect again.`;\n\t\t\t\tcloser().focus();\n\t\t\t},\n\t\t);\n\t};\n\tconst renderSession = (session: SessionInfo | undefined) => {\n\t\tif (session === undefined) {\n\t\t\taddressBox.hidden = true;\n\t\t\tconfirmBox.hidden = true;\n\t\t\thelp.hidden = true;\n\t\t\treturn;\n\t\t}\n\t\taddress.value = session.address;\n\t\tresetCopy();\n\t\tconst appName = session.appName ?? mcp.appName;\n\t\tif (!renewing)\n\t\t\tstatus.textContent =\n\t\t\t\tappName !== undefined\n\t\t\t\t\t? `${appName} is ready for your AI app.`\n\t\t\t\t\t: \"This page is ready for your AI app.\";\n\t\tfresh.disabled = mcp.state !== \"connected\";\n\t\taddressBox.hidden = false;\n\t\t// Opened before the session was known: start at the address's Copy.\n\t\tif (doc.activeElement === dialog) copy.focus();\n\t\thelp.hidden = false;\n\t\tsteps.replaceChildren(\n\t\t\t...INSTRUCTIONS.map(([app, how]) =>\n\t\t\t\tel(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"li\",\n\t\t\t\t\t{},\n\t\t\t\t\tel(doc, \"strong\", { text: app }),\n\t\t\t\t\t`: ${how.replace(\"ADDRESS\", session.address)}`,\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t};\n\tconst renderCode = () => {\n\t\tconst current = mcp.pairingCode;\n\t\tconst oidc = mcp.session?.pairing === \"oidc\";\n\t\t// A new code is not copied yet.\n\t\tif (code.textContent !== (current?.code ?? \"\")) resetCopyCode();\n\t\tcode.textContent = current?.code ?? \"\";\n\t\tcodeLine.hidden = oidc || current === undefined;\n\t\tsignInLine.hidden = !oidc;\n\t\trenderCloseNote();\n\t};\n\tconst appsNote = el(doc, \"p\", { className: \"tab-mcp-apps-note\" });\n\tapps.append(appsNote);\n\t// Grants that were there when the dialog opened; a new one is announced.\n\tconst known = new Set(mcp.grants.map((g) => g.grantId));\n\t// Grants that come with a (new) session were there before; only the ones\n\t// added during a session are new connections.\n\tlet session = mcp.session;\n\tconst renderGrants = () => {\n\t\tif (mcp.session !== session) {\n\t\t\tsession = mcp.session;\n\t\t\tfor (const grant of mcp.grants) known.add(grant.grantId);\n\t\t}\n\t\tfor (const grant of mcp.grants) {\n\t\t\tif (known.has(grant.grantId)) continue;\n\t\t\tknown.add(grant.grantId);\n\t\t\tstatus.textContent = `${clientLabel(grant.client)} is connected.`;\n\t\t\tpairedGrants.add(grant.grantId);\n\t\t\tif (!paired) setPaired(true);\n\t\t}\n\t\t// The app that connected here is gone again (Disconnect, or revoked):\n\t\t// back to Close and the note, the code still runs.\n\t\tif (paired && !mcp.grants.some((g) => pairedGrants.has(g.grantId))) {\n\t\t\tsetPaired(false);\n\t\t}\n\t\tconst connected = mcp.state === \"connected\";\n\t\tappList.replaceChildren(\n\t\t\t...mcp.grants.map((grant) => {\n\t\t\t\tconst disconnect = button(doc, \"Disconnect\", () => {\n\t\t\t\t\tif (!mcp.revoke(grant.grantId)) renderGrants();\n\t\t\t\t});\n\t\t\t\t// Only the relay can revoke, so only while connected.\n\t\t\t\tdisconnect.disabled = !connected;\n\t\t\t\treturn el(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"li\",\n\t\t\t\t\t{},\n\t\t\t\t\t`${clientLabel(grant.client)} connected `,\n\t\t\t\t\tdisconnect,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tappsNote.textContent = connected\n\t\t\t? \"\"\n\t\t\t: \"To disconnect an app, connect this page again first.\";\n\t\tappsNote.hidden = connected;\n\t\tapps.hidden = mcp.grants.length === 0;\n\t\tif (!confirmBox.hidden && !renderQuestion()) {\n\t\t\t// Nobody left to disconnect: no question needed.\n\t\t\tconfirmBox.hidden = true;\n\t\t\tfresh.focus();\n\t\t}\n\t};\n\tconst onDisconnected = (event: CustomEvent<DisconnectDetail>) => {\n\t\tif (event.detail.reason !== \"new_address\")\n\t\t\tstatus.textContent =\n\t\t\t\t\"Disconnected. AI apps can use this page again after you connect.\";\n\t\trenderSession(undefined);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\tconst onConnected = () => {\n\t\trenderSession(mcp.session);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\n\tmcp.addEventListener(\"pairingcode\", renderCode);\n\tmcp.addEventListener(\"grantschange\", renderGrants);\n\tmcp.addEventListener(\"connected\", onConnected);\n\tmcp.addEventListener(\"disconnected\", onDisconnected);\n\tdoc.body.append(dialog);\n\tmcp.startPairing();\n\trenderGrants();\n\trenderCode();\n\trenderSession(mcp.session);\n\tconnecting.then(\n\t\t(session) => renderSession(session),\n\t\t(error: unknown) => {\n\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}`;\n\t\t},\n\t);\n\n\treturn new Promise((resolve) => {\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tmcp.stopPairing();\n\t\t\t\tmcp.removeEventListener(\"pairingcode\", renderCode);\n\t\t\t\tmcp.removeEventListener(\"grantschange\", renderGrants);\n\t\t\t\tmcp.removeEventListener(\"connected\", onConnected);\n\t\t\t\tmcp.removeEventListener(\"disconnected\", onDisconnected);\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\t// Start at the address's Copy; until the address is there, at the\n\t\t// dialog itself (its title is read out), not at Close.\n\t\tif (!addressBox.hidden) copy.focus();\n\t\telse dialog.focus();\n\t});\n}\n"
6
+ ],
7
+ "mappings": ";AAiBA,IAAI,UAAU;AAEd,SAAS,EAAyC,CACjD,KACA,KACA,QAA4D,CAAC,MAC1D,UACwB;AAAA,EAC3B,MAAM,OAAO,IAAI,cAAc,GAAG;AAAA,EAClC,IAAI,MAAM,cAAc;AAAA,IAAW,KAAK,YAAY,MAAM;AAAA,EAC1D,IAAI,MAAM,OAAO;AAAA,IAAW,KAAK,KAAK,MAAM;AAAA,EAC5C,IAAI,MAAM,SAAS;AAAA,IAAW,KAAK,cAAc,MAAM;AAAA,EACvD,KAAK,OAAO,GAAG,QAAQ;AAAA,EACvB,OAAO;AAAA;AAGR,SAAS,MAAM,CACd,KACA,MACA,SACoB;AAAA,EACpB,MAAM,OAAO,GAAG,KAAK,UAAU,EAAE,KAAK,CAAC;AAAA,EACvC,KAAK,OAAO;AAAA,EACZ,KAAK,iBAAiB,SAAS,OAAO;AAAA,EACtC,OAAO;AAAA;AASR,SAAS,UAAU,CAClB,KACA,MACA,OACA,QACmD;AAAA,EACnD,MAAM,OAAO,OAAO,KAAK,QAAQ,MAAM;AAAA,IACtC,MAAM,OAAO,MAAM;AAAA,MAClB,KAAK,cAAc;AAAA,MACnB,KAAK,aAAa,cAAc,UAAU,MAAM;AAAA;AAAA,IAEjD,MAAM,YAAa,IAAI,aAAa,WACjC;AAAA,IACH,IAAI,cAAc;AAAA,MACjB,UAAU,UAAU,MAAM,CAAC,EAAE,KAAK,MAAM,MAAM;AAAA,IAC1C;AAAA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A5B64756E2164756E21",
9
+ "names": []
10
+ }
package/ui.d.ts CHANGED
@@ -14,9 +14,11 @@ export declare const MIN_ALLOW_DELAY_MS = 500;
14
14
  export type ConfirmAnswer = "allow" | "always" | "deny";
15
15
  /**
16
16
  * Ask whether a consequential tool may run. "Allow" and "Always allow" stay
17
- * disabled for `allowDelayMs` (default 750, at least 500) after the dialog
18
- * opens, so a click meant for the page cannot approve. Everything else
19
- * (Don't allow, Escape, an aborted call) is "deny".
17
+ * disabled until the page has been visible and focused for `allowDelayMs`
18
+ * (default 750, at least 500) while the dialog is open, so a click meant for
19
+ * the page, or the click that brings the tab or window back, cannot approve.
20
+ * Leaving the page disables them again. Everything else (Don't allow,
21
+ * Escape, an aborted call) is "deny".
20
22
  */
21
23
  export declare function confirmDialog(request: ConfirmRequest, doc: Document, options?: {
22
24
  allowDelayMs?: number;
package/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /** The library's name and version, sent in `hello` (a test keeps it equal to package.json). */
2
2
  export declare const LIBRARY_NAME = "@ractive-ch/tab-mcp-client";
3
- export declare const VERSION = "0.5.1";
3
+ export declare const VERSION = "0.6.0";
@@ -1,10 +0,0 @@
1
- function oe(e,t){let o=typeof e;if(o!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let s=e.length;if(s!==t.length)return!1;for(let i=0;i<s;i++)if(!oe(e[i],t[i]))return!1;return!0}if(o==="object"){if(!e||!t)return e===t;let s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(let n of s)if(!oe(e[n],t[n]))return!1;return!0}return e===t}function H(e){return encodeURI(nt(e))}function nt(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var ot={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},st={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},it={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},dt=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function F(e,t=Object.create(null),o=dt,s=""){if(e&&typeof e==="object"&&!Array.isArray(e)){let d=e.$id||e.id;if(d){let n=new URL(d,o.href);if(n.hash.length>1)t[n.href]=e;else if(n.hash="",s==="")o=n;else F(e,t,o)}}else if(e!==!0&&e!==!1)return t;let i=o.href+(s?"#"+s:"");if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0)Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i});if(e.$ref&&e.__absolute_ref__===void 0){let d=new URL(e.$ref,o.href);d.hash=d.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:d.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let d=new URL(e.$recursiveRef,o.href);d.hash=d.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:d.href})}if(e.$anchor){let d=new URL("#"+e.$anchor,o.href);t[d.href]=e}for(let d in e){if(it[d])continue;let n=`${s}/${H(d)}`,f=e[d];if(Array.isArray(f)){if(ot[d]){let I=f.length;for(let q=0;q<I;q++)F(f[q],t,o,`${n}/${q}`)}}else if(st[d])for(let I in f)F(f[I],t,o,`${n}/${H(I)}`);else F(f,t,o,n)}return t}var at=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ut=[0,31,28,31,30,31,30,31,31,30,31,30,31],lt=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,ft=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a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2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,pt=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,yt=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,mt=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,gt=/^(?:\/(?:[^~/]|~0|~1)*)*$/,ht=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,$t=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,bt=(e)=>{if(e[0]==='"')return!1;let[t,o,...s]=e.split("@");if(!t||!o||s.length!==0||t.length>64||o.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return o.split(".").every((i)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},wt=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,kt=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Rt=(e)=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function V(e){return e.test.bind(e)}var Ie={date:Ce,time:Ne.bind(void 0,!1),"date-time":vt,duration:Rt,uri:_t,"uri-reference":V(ct),"uri-template":V(pt),url:V(yt),email:bt,hostname:V(ft),ipv4:V(wt),ipv6:V(kt),regex:Ot,uuid:V(mt),"json-pointer":V(gt),"json-pointer-uri-fragment":V(ht),"relative-json-pointer":V($t)};function xt(e){return e%4===0&&(e%100!==0||e%400===0)}function Ce(e){let t=e.match(at);if(!t)return!1;let o=+t[1],s=+t[2],i=+t[3];return s>=1&&s<=12&&i>=1&&i<=(s==2&&xt(o)?29:ut[s])}function Ne(e,t){let o=t.match(lt);if(!o)return!1;let s=+o[1],i=+o[2],d=+o[3],n=!!o[5];return(s<=23&&i<=59&&d<=59||s==23&&i==59&&d==60)&&(!e||n)}var It=/t|\s/i;function vt(e){let t=e.split(It);return t.length==2&&Ce(t[0])&&Ne(!0,t[1])}var Mt=/\/|:/,Tt=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _t(e){return Mt.test(e)&&Tt.test(e)}var St=/[^\\]\\Z/;function Ot(e){if(St.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function qe(e){let t=0,o=e.length,s=0,i;while(s<o)if(t++,i=e.charCodeAt(s++),i>=55296&&i<=56319&&s<o){if(i=e.charCodeAt(s),(i&64512)==56320)s++}return t}function O(e,t,o="2019-09",s=F(t),i=!0,d=null,n="#",f="#",I=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:n,keyword:"false",keywordLocation:n,error:"False boolean schema."}]};let q=typeof e,T;switch(q){case"boolean":case"number":case"string":T=q;break;case"object":if(e===null)T="null";else if(Array.isArray(e))T="array";else T="object";break;default:throw Error(`Instances of "${q}" type are not supported.`)}let{$ref:J,$recursiveRef:ne,$recursiveAnchor:G,type:C,const:K,enum:E,required:Z,not:u,anyOf:m,allOf:x,oneOf:v,if:r,then:p,else:b,format:R,properties:M,patternProperties:_,additionalProperties:U,unevaluatedProperties:A,minProperties:B,maxProperties:P,propertyNames:j,dependentRequired:W,dependentSchemas:ae,dependencies:we,prefixItems:ke,items:ue,additionalItems:_e,unevaluatedItems:Se,contains:Oe,minContains:Y,maxContains:ce,minItems:Re,maxItems:xe,uniqueItems:tt,minimum:Q,maximum:L,exclusiveMinimum:le,exclusiveMaximum:fe,multipleOf:pe,minLength:ye,maxLength:me,pattern:Ee,__absolute_ref__:ge,__absolute_recursive_ref__:rt}=t,l=[];if(G===!0&&d===null)d=t;if(ne==="#"){let g=d===null?s[rt]:d,y=`${f}/$recursiveRef`,k=O(e,d===null?t:d,o,s,i,g,n,y,I);if(!k.valid)l.push({instanceLocation:n,keyword:"$recursiveRef",keywordLocation:y,error:"A subschema had errors."},...k.errors)}if(J!==void 0){let y=s[ge||J];if(y===void 0){let a=`Unresolved $ref "${J}".`;if(ge&&ge!==J)a+=` Absolute URI "${ge}".`;throw a+=`
2
- Known schemas:
3
- - ${Object.keys(s).join(`
4
- - `)}`,Error(a)}let k=`${f}/$ref`,c=O(e,y,o,s,i,d,n,k,I);if(!c.valid)l.push({instanceLocation:n,keyword:"$ref",keywordLocation:k,error:"A subschema had errors."},...c.errors);if(o==="4"||o==="7")return{valid:l.length===0,errors:l}}if(Array.isArray(C)){let g=C.length,y=!1;for(let k=0;k<g;k++)if(T===C[k]||C[k]==="integer"&&T==="number"&&e%1===0&&e===e){y=!0;break}if(!y)l.push({instanceLocation:n,keyword:"type",keywordLocation:`${f}/type`,error:`Instance type "${T}" is invalid. Expected "${C.join('", "')}".`})}else if(C==="integer"){if(T!=="number"||e%1||e!==e)l.push({instanceLocation:n,keyword:"type",keywordLocation:`${f}/type`,error:`Instance type "${T}" is invalid. Expected "${C}".`})}else if(C!==void 0&&T!==C)l.push({instanceLocation:n,keyword:"type",keywordLocation:`${f}/type`,error:`Instance type "${T}" is invalid. Expected "${C}".`});if(K!==void 0){if(T==="object"||T==="array"){if(!oe(e,K))l.push({instanceLocation:n,keyword:"const",keywordLocation:`${f}/const`,error:`Instance does not match ${JSON.stringify(K)}.`})}else if(e!==K)l.push({instanceLocation:n,keyword:"const",keywordLocation:`${f}/const`,error:`Instance does not match ${JSON.stringify(K)}.`})}if(E!==void 0){if(T==="object"||T==="array"){if(!E.some((g)=>oe(e,g)))l.push({instanceLocation:n,keyword:"enum",keywordLocation:`${f}/enum`,error:`Instance does not match any of ${JSON.stringify(E)}.`})}else if(!E.some((g)=>e===g))l.push({instanceLocation:n,keyword:"enum",keywordLocation:`${f}/enum`,error:`Instance does not match any of ${JSON.stringify(E)}.`})}if(u!==void 0){let g=`${f}/not`;if(O(e,u,o,s,i,d,n,g).valid)l.push({instanceLocation:n,keyword:"not",keywordLocation:g,error:'Instance matched "not" schema.'})}let he=[];if(m!==void 0){let g=`${f}/anyOf`,y=l.length,k=!1;for(let c=0;c<m.length;c++){let a=m[c],w=Object.create(I),h=O(e,a,o,s,i,G===!0?d:null,n,`${g}/${c}`,w);if(l.push(...h.errors),k=k||h.valid,h.valid)he.push(w)}if(k)l.length=y;else l.splice(y,0,{instanceLocation:n,keyword:"anyOf",keywordLocation:g,error:"Instance does not match any subschemas."})}if(x!==void 0){let g=`${f}/allOf`,y=l.length,k=!0;for(let c=0;c<x.length;c++){let a=x[c],w=Object.create(I),h=O(e,a,o,s,i,G===!0?d:null,n,`${g}/${c}`,w);if(l.push(...h.errors),k=k&&h.valid,h.valid)he.push(w)}if(k)l.length=y;else l.splice(y,0,{instanceLocation:n,keyword:"allOf",keywordLocation:g,error:"Instance does not match every subschema."})}if(v!==void 0){let g=`${f}/oneOf`,y=l.length,k=v.filter((c,a)=>{let w=Object.create(I),h=O(e,c,o,s,i,G===!0?d:null,n,`${g}/${a}`,w);if(l.push(...h.errors),h.valid)he.push(w);return h.valid}).length;if(k===1)l.length=y;else l.splice(y,0,{instanceLocation:n,keyword:"oneOf",keywordLocation:g,error:`Instance does not match exactly one subschema (${k} matches).`})}if(T==="object"||T==="array")Object.assign(I,...he);if(r!==void 0){let g=`${f}/if`;if(O(e,r,o,s,i,d,n,g,I).valid){if(p!==void 0){let k=O(e,p,o,s,i,d,n,`${f}/then`,I);if(!k.valid)l.push({instanceLocation:n,keyword:"if",keywordLocation:g,error:'Instance does not match "then" schema.'},...k.errors)}}else if(b!==void 0){let k=O(e,b,o,s,i,d,n,`${f}/else`,I);if(!k.valid)l.push({instanceLocation:n,keyword:"if",keywordLocation:g,error:'Instance does not match "else" schema.'},...k.errors)}}if(T==="object"){if(Z!==void 0){for(let c of Z)if(!(c in e))l.push({instanceLocation:n,keyword:"required",keywordLocation:`${f}/required`,error:`Instance does not have required property "${c}".`})}let g=Object.keys(e);if(B!==void 0&&g.length<B)l.push({instanceLocation:n,keyword:"minProperties",keywordLocation:`${f}/minProperties`,error:`Instance does not have at least ${B} properties.`});if(P!==void 0&&g.length>P)l.push({instanceLocation:n,keyword:"maxProperties",keywordLocation:`${f}/maxProperties`,error:`Instance does not have at least ${P} properties.`});if(j!==void 0){let c=`${f}/propertyNames`;for(let a in e){let w=`${n}/${H(a)}`,h=O(a,j,o,s,i,d,w,c);if(!h.valid)l.push({instanceLocation:n,keyword:"propertyNames",keywordLocation:c,error:`Property name "${a}" does not match schema.`},...h.errors)}}if(W!==void 0){let c=`${f}/dependantRequired`;for(let a in W)if(a in e){let w=W[a];for(let h of w)if(!(h in e))l.push({instanceLocation:n,keyword:"dependentRequired",keywordLocation:c,error:`Instance has "${a}" but does not have "${h}".`})}}if(ae!==void 0)for(let c in ae){let a=`${f}/dependentSchemas`;if(c in e){let w=O(e,ae[c],o,s,i,d,n,`${a}/${H(c)}`,I);if(!w.valid)l.push({instanceLocation:n,keyword:"dependentSchemas",keywordLocation:a,error:`Instance has "${c}" but does not match dependant schema.`},...w.errors)}}if(we!==void 0){let c=`${f}/dependencies`;for(let a in we)if(a in e){let w=we[a];if(Array.isArray(w)){for(let h of w)if(!(h in e))l.push({instanceLocation:n,keyword:"dependencies",keywordLocation:c,error:`Instance has "${a}" but does not have "${h}".`})}else{let h=O(e,w,o,s,i,d,n,`${c}/${H(a)}`);if(!h.valid)l.push({instanceLocation:n,keyword:"dependencies",keywordLocation:c,error:`Instance has "${a}" but does not match dependant schema.`},...h.errors)}}}let y=Object.create(null),k=!1;if(M!==void 0){let c=`${f}/properties`;for(let a in M){if(!(a in e))continue;let w=`${n}/${H(a)}`,h=O(e[a],M[a],o,s,i,d,w,`${c}/${H(a)}`);if(h.valid)I[a]=y[a]=!0;else if(k=i,l.push({instanceLocation:n,keyword:"properties",keywordLocation:c,error:`Property "${a}" does not match schema.`},...h.errors),k)break}}if(!k&&_!==void 0){let c=`${f}/patternProperties`;for(let a in _){let w=new RegExp(a,"u"),h=_[a];for(let z in e){if(!w.test(z))continue;let Pe=`${n}/${H(z)}`,Ae=O(e[z],h,o,s,i,d,Pe,`${c}/${H(a)}`);if(Ae.valid)I[z]=y[z]=!0;else k=i,l.push({instanceLocation:n,keyword:"patternProperties",keywordLocation:c,error:`Property "${z}" matches pattern "${a}" but does not match associated schema.`},...Ae.errors)}}}if(!k&&U!==void 0){let c=`${f}/additionalProperties`;for(let a in e){if(y[a])continue;let w=`${n}/${H(a)}`,h=O(e[a],U,o,s,i,d,w,c);if(h.valid)I[a]=!0;else k=i,l.push({instanceLocation:n,keyword:"additionalProperties",keywordLocation:c,error:`Property "${a}" does not match additional properties schema.`},...h.errors)}}else if(!k&&A!==void 0){let c=`${f}/unevaluatedProperties`;for(let a in e)if(!I[a]){let w=`${n}/${H(a)}`,h=O(e[a],A,o,s,i,d,w,c);if(h.valid)I[a]=!0;else l.push({instanceLocation:n,keyword:"unevaluatedProperties",keywordLocation:c,error:`Property "${a}" does not match unevaluated properties schema.`},...h.errors)}}}else if(T==="array"){if(xe!==void 0&&e.length>xe)l.push({instanceLocation:n,keyword:"maxItems",keywordLocation:`${f}/maxItems`,error:`Array has too many items (${e.length} > ${xe}).`});if(Re!==void 0&&e.length<Re)l.push({instanceLocation:n,keyword:"minItems",keywordLocation:`${f}/minItems`,error:`Array has too few items (${e.length} < ${Re}).`});let g=e.length,y=0,k=!1;if(ke!==void 0){let c=`${f}/prefixItems`,a=Math.min(ke.length,g);for(;y<a;y++){let w=O(e[y],ke[y],o,s,i,d,`${n}/${y}`,`${c}/${y}`);if(I[y]=!0,!w.valid){if(k=i,l.push({instanceLocation:n,keyword:"prefixItems",keywordLocation:c,error:"Items did not match schema."},...w.errors),k)break}}}if(ue!==void 0){let c=`${f}/items`;if(Array.isArray(ue)){let a=Math.min(ue.length,g);for(;y<a;y++){let w=O(e[y],ue[y],o,s,i,d,`${n}/${y}`,`${c}/${y}`);if(I[y]=!0,!w.valid){if(k=i,l.push({instanceLocation:n,keyword:"items",keywordLocation:c,error:"Items did not match schema."},...w.errors),k)break}}}else for(;y<g;y++){let a=O(e[y],ue,o,s,i,d,`${n}/${y}`,c);if(I[y]=!0,!a.valid){if(k=i,l.push({instanceLocation:n,keyword:"items",keywordLocation:c,error:"Items did not match schema."},...a.errors),k)break}}if(!k&&_e!==void 0){let a=`${f}/additionalItems`;for(;y<g;y++){let w=O(e[y],_e,o,s,i,d,`${n}/${y}`,a);if(I[y]=!0,!w.valid)k=i,l.push({instanceLocation:n,keyword:"additionalItems",keywordLocation:a,error:"Items did not match additional items schema."},...w.errors)}}}if(Oe!==void 0)if(g===0&&Y===void 0)l.push({instanceLocation:n,keyword:"contains",keywordLocation:`${f}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(Y!==void 0&&g<Y)l.push({instanceLocation:n,keyword:"minContains",keywordLocation:`${f}/minContains`,error:`Array has less items (${g}) than minContains (${Y}).`});else{let c=`${f}/contains`,a=l.length,w=0;for(let h=0;h<g;h++){let z=O(e[h],Oe,o,s,i,d,`${n}/${h}`,c);if(z.valid)I[h]=!0,w++;else l.push(...z.errors)}if(w>=(Y||0))l.length=a;if(Y===void 0&&ce===void 0&&w===0)l.splice(a,0,{instanceLocation:n,keyword:"contains",keywordLocation:c,error:"Array does not contain item matching schema."});else if(Y!==void 0&&w<Y)l.push({instanceLocation:n,keyword:"minContains",keywordLocation:`${f}/minContains`,error:`Array must contain at least ${Y} items matching schema. Only ${w} items were found.`});else if(ce!==void 0&&w>ce)l.push({instanceLocation:n,keyword:"maxContains",keywordLocation:`${f}/maxContains`,error:`Array may contain at most ${ce} items matching schema. ${w} items were found.`})}if(!k&&Se!==void 0){let c=`${f}/unevaluatedItems`;for(y;y<g;y++){if(I[y])continue;let a=O(e[y],Se,o,s,i,d,`${n}/${y}`,c);if(I[y]=!0,!a.valid)l.push({instanceLocation:n,keyword:"unevaluatedItems",keywordLocation:c,error:"Items did not match unevaluated items schema."},...a.errors)}}if(tt)for(let c=0;c<g;c++){let a=e[c],w=typeof a==="object"&&a!==null;for(let h=0;h<g;h++){if(c===h)continue;let z=e[h];if(a===z||w&&(typeof z==="object"&&z!==null)&&oe(a,z))l.push({instanceLocation:n,keyword:"uniqueItems",keywordLocation:`${f}/uniqueItems`,error:`Duplicate items at indexes ${c} and ${h}.`}),c=Number.MAX_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER}}}else if(T==="number"){if(o==="4"){if(Q!==void 0&&(le===!0&&e<=Q||e<Q))l.push({instanceLocation:n,keyword:"minimum",keywordLocation:`${f}/minimum`,error:`${e} is less than ${le?"or equal to ":""} ${Q}.`});if(L!==void 0&&(fe===!0&&e>=L||e>L))l.push({instanceLocation:n,keyword:"maximum",keywordLocation:`${f}/maximum`,error:`${e} is greater than ${fe?"or equal to ":""} ${L}.`})}else{if(Q!==void 0&&e<Q)l.push({instanceLocation:n,keyword:"minimum",keywordLocation:`${f}/minimum`,error:`${e} is less than ${Q}.`});if(L!==void 0&&e>L)l.push({instanceLocation:n,keyword:"maximum",keywordLocation:`${f}/maximum`,error:`${e} is greater than ${L}.`});if(le!==void 0&&e<=le)l.push({instanceLocation:n,keyword:"exclusiveMinimum",keywordLocation:`${f}/exclusiveMinimum`,error:`${e} is less than ${le}.`});if(fe!==void 0&&e>=fe)l.push({instanceLocation:n,keyword:"exclusiveMaximum",keywordLocation:`${f}/exclusiveMaximum`,error:`${e} is greater than or equal to ${fe}.`})}if(pe!==void 0){let g=e%pe;if(Math.abs(0-g)>=0.00000011920929&&Math.abs(pe-g)>=0.00000011920929)l.push({instanceLocation:n,keyword:"multipleOf",keywordLocation:`${f}/multipleOf`,error:`${e} is not a multiple of ${pe}.`})}}else if(T==="string"){let g=ye===void 0&&me===void 0?0:qe(e);if(ye!==void 0&&g<ye)l.push({instanceLocation:n,keyword:"minLength",keywordLocation:`${f}/minLength`,error:`String is too short (${g} < ${ye}).`});if(me!==void 0&&g>me)l.push({instanceLocation:n,keyword:"maxLength",keywordLocation:`${f}/maxLength`,error:`String is too long (${g} > ${me}).`});if(Ee!==void 0&&!new RegExp(Ee,"u").test(e))l.push({instanceLocation:n,keyword:"pattern",keywordLocation:`${f}/pattern`,error:"String does not match pattern."});if(R!==void 0&&Ie[R]&&!Ie[R](e))l.push({instanceLocation:n,keyword:"format",keywordLocation:`${f}/format`,error:`String does not match format "${R}".`})}return{valid:l.length===0,errors:l}}class ve{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=F(e)}validate(e){return O(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};F(e,this.lookup)}}var ze="ch.ractive.tab-mcp/annotations",Et=["readOnlyHint","untrustedContentHint","consequentialHint","debugging"],Pt=["destructiveHint","idempotentHint","openWorldHint"];function He(e){let t={};if(e.readOnlyHint===!0)t.readOnlyHint=!0,t.destructiveHint=!1;else if(e.readOnlyHint===!1)t.readOnlyHint=!1;if(e.consequentialHint===!0)t.destructiveHint=!0;if(e.untrustedContentHint===!0)t.openWorldHint=!0;for(let i of Pt){let d=e[i];if(d!==void 0)t[i]=d}let o={};for(let i of Et){let d=e[i];if(d!==void 0)o[i]=d}let s={};if(Object.keys(t).length>0)s.annotations=t;if(Object.keys(o).length>0)s.meta=o;return s}function ee(e){return{content:[{type:"text",text:e}],isError:!0}}function je(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Je(e){if(typeof e==="string")return{content:[{type:"text",text:e}]};if(e===void 0)return{content:[]};if(je(e)&&Array.isArray(e.content))return e;let t;try{t=JSON.stringify(e)}catch{}if(t===void 0)return ee("The tool returned a value that is not JSON.");let o={content:[{type:"text",text:t}]};if(je(e))o.structuredContent=e;return o}function Ue(e){let t=e instanceof Error?e.message:String(e);return ee(t||"The tool failed.")}var te="2026-07-28",X="io.modelcontextprotocol/protocolVersion",$e="io.modelcontextprotocol/clientCapabilities",Be="io.modelcontextprotocol/clientInfo",At="io.modelcontextprotocol/serverInfo",Me="io.modelcontextprotocol/subscriptionId",Ct=-32020,Ve=-32022,Nt=0;function De(e){try{return structuredClone(e)}catch{return e}}var qt=new TextEncoder;function re(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Te(e,t){return new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json"}})}function N(e,t,o,s,i){let d={code:o,message:s};if(i!==void 0)d.data=i;return Te(e,{jsonrpc:"2.0",id:t,error:d})}function D(e,t,o){return N(400,e,Ct,`Bad Request: the request headers and body disagree: ${o}`,{mismatch:{header:t,body:o}})}function se(e){return qt.encode(`event: message
5
- data: ${JSON.stringify(e)}
6
-
7
- `)}var Ge={"content-type":"text/event-stream","cache-control":"no-cache"};function jt(e){return(e??"").split(";")[0]?.trim().toLowerCase()==="application/json"}function zt(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,-2);if(!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return;try{let o=atob(t),s=Uint8Array.from(o,(i)=>i.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{return}}function Ht(e){if(!(X in e))return{key:X,problem:"missing"};if(!($e in e))return{key:$e,problem:"missing"};if(typeof e[X]!=="string")return{key:X,problem:"expected a protocol version string"};if(!re(e[$e]))return{key:$e,problem:"expected an object"};let t=e[Be];if(t!==void 0&&!(re(t)&&typeof t.name==="string"&&typeof t.version==="string"))return{key:Be,problem:"expected {name, version}"};return}function Jt(e){let t=e.notifications;return re(t)&&t.toolsListChanged===!0?{toolsListChanged:!0}:{}}function Ke(e){let{tools:t,server:o}=e,s={name:o.name,version:o.version};if(o.title!==void 0)s.title=o.title;let i=new WeakMap,d=new Set,n=!1,f=(u={})=>({...u,[At]:s});function I(u,m){return{jsonrpc:"2.0",id:u,result:{...m,resultType:"complete",_meta:f()}}}function q(u,m){let x=i.get(u);if(x===void 0)x=new ve(u.inputSchema,"2020-12",!1),i.set(u,x);let v=x.validate(m);if(v.valid)return;let r=v.errors.filter((p)=>p.keyword!=="properties"&&p.keyword!=="$ref").map((p)=>`${p.instanceLocation} ${p.error}`).slice(0,5).join("; ");return`Input validation error: Invalid arguments for tool ${u.name}: ${r||"the arguments do not match the schema"}`}function T(){return t.list().map((u)=>{let m={name:u.name};if(u.title!==void 0)m.title=u.title;m.description=u.description,m.inputSchema=u.inputSchema;let{annotations:x,meta:v}=He(u.annotations);if(x!==void 0)m.annotations=x;if(v!==void 0)m._meta={[ze]:v};return m})}async function J(u,m,x){let v=u.name;if(typeof v!=="string")return{invalid:"Invalid params: name must be a string"};let r=t.get(v);if(r===void 0)return{invalid:`Tool ${v} not found`};let p=u.arguments??{};if(!re(p))return{invalid:"Invalid params: arguments must be an object"};let b=e.client(x),R={id:++Nt,tool:r.name,arguments:De(p),client:{...b}};if(r.title!==void 0)R.title=r.title;let M=Date.now();e.observe?.start(R);let[_,U]=await ne(r,p,m,b);return e.observe?.end({id:R.id,tool:r.name,client:{...b},outcome:_,result:De(U),durationMs:Date.now()-M}),U}async function ne(u,m,x,v){let r=q(u,m);if(r!==void 0)return["error",ee(r)];if(u.annotations.consequentialHint===!0){let b={tool:{name:u.name,description:u.description},arguments:m,client:v,signal:x};if(u.title!==void 0)b.tool.title=u.title;let R=!1;try{R=await e.confirm(b)}catch{R=!1}if(!R)return[x.aborted?"cancelled":"declined",ee("The user declined")]}if(x.aborted)return["cancelled",ee("Cancelled")];let p;try{p=Je(await u.execute(m,{signal:x,client:v}))}catch(b){p=Ue(b)}if(x.aborted)return["cancelled",p];return[p.isError===!0?"error":"ok",p]}function G(u,m,x,v){let r=new ReadableStream({start:(p)=>{let b=(R)=>{if(x.aborted)return;let M;try{M=se(R)}catch{M=se(I(u,ee("The tool returned a result that is not JSON.")))}try{p.enqueue(M),p.close()}catch{}};J(m,x,v).then((R)=>b(typeof R.invalid==="string"?{jsonrpc:"2.0",id:u,error:{code:-32602,message:R.invalid}}:I(u,R)),()=>b({jsonrpc:"2.0",id:u,error:{code:-32603,message:"Internal error"}}))}});return new Response(r,{status:200,headers:Ge})}function C(u,m,x){let v=Jt(m),r={jsonrpc:"2.0",id:u,result:{resultType:"complete",_meta:f({[Me]:u})}},p,b=new ReadableStream({start:(R)=>{if(R.enqueue(se({jsonrpc:"2.0",method:"notifications/subscriptions/acknowledged",params:{notifications:v,_meta:{[Me]:u}}})),Object.keys(v).length===0){R.enqueue(se(r)),R.close();return}let M={id:u,send:(_)=>{try{R.enqueue(se(_))}catch{d.delete(M)}},end:()=>{d.delete(M);try{R.enqueue(se(r)),R.close()}catch{}}};p=M,d.add(M),x.addEventListener("abort",()=>{d.delete(M);try{R.close()}catch{}})},cancel:()=>{if(p!==void 0)d.delete(p)}});return new Response(b,{status:200,headers:Ge})}function K(u,m){if(Array.isArray(m))return N(400,null,-32600,"Bad Request: JSON-RPC batches are not supported by this endpoint");if(!re(m)||m.jsonrpc!=="2.0")return N(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let{method:x,id:v}=m;if(typeof x!=="string")return"result"in m||"error"in m?N(400,null,-32600,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"):N(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let r=u.headers.get("mcp-protocol-version"),p=u.headers.get("mcp-method"),b=re(m.params)?m.params:{},R=re(b._meta)?b._meta:void 0,M=R!==void 0&&X in R,_=typeof R?.[X]==="string"?R[X]:void 0,U=r!==null&&r>=te;if(v===void 0){if(_!==void 0&&r!==null&&r!==_)return D(null,r,`the notification envelope names protocol version ${_} but the MCP-Protocol-Version header names ${r}`);if((M||U)&&p!==null&&p!==x)return D(null,p,`the notification body names method ${x} but the Mcp-Method header names ${p}`);return"notification"}if(typeof v!=="string"&&typeof v!=="number")return N(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let A=v;if(!M||x==="initialize"&&(_===void 0||_<te)){if(x==="initialize"){if(U)return D(A,r,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let P=typeof b.protocolVersion==="string"?b.protocolVersion:void 0;return E(A,P)}if(U){let P=R===void 0?["_meta"]:[X];return N(400,A,-32602,`Invalid params: the MCP-Protocol-Version header names protocol revision ${r}, but the request is missing the required per-request envelope key(s): ${P.join(", ")}`,{envelope:{missing:P}})}return E(A,r??void 0)}let B=Ht(R);if(B!==void 0)return N(400,A,-32602,`Invalid _meta envelope for protocol revision ${te}: ${B.key}: ${B.problem}`,{envelope:B});if(r!==null&&_!==void 0&&r!==_)return D(A,r,`the body envelope names protocol version ${_} but the MCP-Protocol-Version header names ${r}`);if(p!==null&&p!==x)return D(A,p,`the body names method ${x} but the Mcp-Method header names ${p}`);if(_!==te)return E(A,_);if(r===null)return D(A,"(missing)",`the body envelope names protocol version ${_} but the required MCP-Protocol-Version header is absent`);if(p===null)return D(A,"(missing)",`the body names method ${x} but the required Mcp-Method header is absent`);if(x==="tools/call"&&typeof b.name==="string"){let P=b.name,j=u.headers.get("mcp-name");if(j===null)return D(A,"(missing)",`the body carries params.name="${P}" but the required Mcp-Name header is absent`);let W=zt(j);if(W===void 0)return D(A,j,"the Mcp-Name header carries an invalid Base64 sentinel value");if(W!==P)return D(A,j,`the body carries params.name="${P}" but the Mcp-Name header names "${W}"`)}return{id:A,method:x,params:b}}function E(u,m){return m===void 0?N(400,u,Ve,"Unsupported protocol version: the request did not name a protocol version",{supported:[te]}):N(400,u,Ve,`Unsupported protocol version: ${m}`,{supported:[te],requested:m})}async function Z(u,m){if(u.method.toUpperCase()!=="POST")return N(405,null,-32000,"Method not allowed.");if(!jt(u.headers.get("content-type")))return N(415,null,-32000,"Unsupported Media Type: Content-Type must be application/json");let x;try{x=JSON.parse(m.body??await u.text())}catch{return N(400,null,-32700,"Parse error: the request body is not valid JSON")}let v=K(u,x);if(v instanceof Response)return v;if(v==="notification")return new Response(null,{status:202});let{id:r,method:p,params:b}=v;switch(p){case"server/discover":{let R={supportedVersions:[te],capabilities:{tools:{listChanged:!0}}};if(o.instructions!==void 0)R.instructions=o.instructions;return R.ttlMs=0,R.cacheScope="private",Te(200,I(r,R))}case"tools/list":return Te(200,I(r,{tools:T(),ttlMs:0,cacheScope:"private"}));case"tools/call":return G(r,b,u.signal,m.grant);case"subscriptions/listen":return C(r,b,u.signal);default:return N(404,r,-32601,"Method not found")}}return{handle:(u,m)=>Z(u,m).catch(()=>N(500,null,-32603,"Internal server error")),toolsChanged(){if(n)return;n=!0,queueMicrotask(()=>{n=!1;for(let u of[...d])u.send({jsonrpc:"2.0",method:"notifications/tools/list_changed",params:{_meta:{[Me]:u.id}}})})},close(){for(let u of[...d])u.end()}}}var be="tab-mcp.v1";function ie(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var S=(e)=>typeof e==="string";function We(e){if(!ie(e)||!S(e.grantId)||!S(e.createdAt))return!1;let t=e.client;return ie(t)&&S(t.id)&&S(t.name)&&S(t.host)}function Ut(e){if(!ie(e))return!1;return["maxMessageBytes","maxBodyBytes","requestTimeoutMs","idleTimeoutMs","heartbeatMs","keepAliveMs","maxConcurrentRequests"].every((t)=>typeof e[t]==="number")}function Bt(e){return ie(e)&&Object.values(e).every(S)}function Ye(e){let t;try{t=JSON.parse(e)}catch{return}if(!ie(t))return;switch(t.type){case"session":return S(t.sessionId)&&S(t.address)&&S(t.origin)&&S(t.expiresAt)&&Ut(t.limits)&&Array.isArray(t.grants)&&t.grants.every(We)&&(t.appName===void 0||S(t.appName))&&(t.pairing===void 0||S(t.pairing))?t:void 0;case"ping":return typeof t.t==="number"?t:void 0;case"bye":return{type:"bye",reason:S(t.reason)?t.reason:""};case"http.request":return S(t.id)&&S(t.method)&&S(t.path)&&Bt(t.headers)&&S(t.body)&&ie(t.grant)&&S(t.grant.grantId)&&S(t.grant.clientId)?t:void 0;case"http.cancel":return S(t.id)?t:void 0;case"pairing.code":return S(t.code)&&S(t.expiresAt)?t:void 0;case"grant.added":return We(t.grant)?t:void 0;case"grant.removed":return S(t.grantId)?{type:"grant.removed",grantId:t.grantId,reason:S(t.reason)?t.reason:""}:void 0;case"identity.bound":return typeof t.round==="number"?{type:"identity.bound",round:t.round}:{type:"identity.bound"};case"error":return S(t.code)?t:void 0;default:return}}var Vt=15000,Fe={1000:"closed",1008:"policy",1009:"too_large",4001:"expired",4002:"idle",4003:"heartbeat",4004:"shutdown",4005:"replaced",4008:"rate_limited"},Ze={replaced:"replaced",expired:"expired",idle:"idle",shutdown:"shutdown"};function de(e,t){return Object.assign(Error(e),{reason:t})}var Dt=["content-type","cache-control"];function Gt(){let e=globalThis.document?.title;return typeof e==="string"?e.slice(0,300):""}function Kt(e){try{let t=JSON.parse(e);if(typeof t!=="object"||t===null||typeof t.type!=="string")return;return typeof t.id==="string"?{type:t.type,id:t.id}:{type:t.type}}catch{return}}var Wt=new Set(["session","ping","bye","http.request","http.cancel","pairing.code","grant.added","grant.removed","identity.bound","error"]),Qe=512,Le=6,et=64,Yt=Qe+Le*et;function Ft(e){let t=Math.floor((e-Qe)/Le);return t>=et?t:void 0}function*Xe(e,t){let o=0;while(o<e.length){let s=Math.min(o+t,e.length),i=e.charCodeAt(s-1);if(s<e.length&&i>=55296&&i<=56319)s+=s-1>o?-1:1;yield e.slice(o,s),o=s}}function $r(e,t,o){let s=new WebSocket(t,be),i=new Map,d="opening",n,f=65536,I,q=0,T,J,ne=new Promise((r,p)=>{T=r,J=p});ne.catch(()=>{});let G=setTimeout(()=>{u(de("The relay did not answer in time.","network"))},Vt),C=Ke({tools:e.registry,server:e.server,confirm:(r)=>e.confirm(r),client:(r)=>e.clientFor(r),observe:{start:(r)=>e.toolCallStarted(r),end:(r)=>e.toolCallEnded(r)}}),K=e.registry.onChange(()=>C.toolsChanged());function E(r){if(s.readyState!==WebSocket.OPEN)return!1;try{return s.send(JSON.stringify(r)),!0}catch{return!1}}function Z(){if(q<=0)return;clearTimeout(I),I=setTimeout(()=>{n??="heartbeat",m(4003);try{s.close()}catch{}},q*2.5)}function u(r){if(d!=="opening")return;m(0),J(r);try{s.close()}catch{}}function m(r){if(d==="closed")return;let p=d==="ready";d="closed",clearTimeout(G),clearTimeout(I),K();for(let b of i.values())b.abort();if(i.clear(),C.close(),p){let b=n??Fe[r]??(r===1006?"network":"closed");e.closed(b,r)}}async function x(r){let p=new AbortController;i.set(r.id,p);let b=()=>d==="ready"&&i.get(r.id)===p&&!p.signal.aborted;try{let R=new Request(`https://tab.invalid${r.path}`,{method:r.method,headers:r.headers,signal:p.signal}),M=await C.handle(R,{grant:r.grant,body:r.body});if(!b()){await M.body?.cancel().catch(()=>{});return}let _={};for(let P of Dt){let j=M.headers.get(P);if(j!==null)_[P]=j}if(!(_["content-type"]??"").startsWith("text/event-stream")||M.body===null){let P=await M.text();if(!b())return;if(P.length<=f){E({type:"http.response",id:r.id,status:M.status,headers:_,body:P});return}E({type:"http.response.start",id:r.id,status:M.status,headers:_});for(let j of Xe(P,f)){if(!b())break;E({type:"http.response.chunk",id:r.id,data:j})}if(b())E({type:"http.response.end",id:r.id});return}E({type:"http.response.start",id:r.id,status:M.status,headers:_});let A=M.body.getReader(),B=new TextDecoder;p.signal.addEventListener("abort",()=>{A.cancel().catch(()=>{})});for(;;){let{done:P,value:j}=await A.read();if(P||!b())break;let W=B.decode(j,{stream:!0});for(let ae of Xe(W,f))E({type:"http.response.chunk",id:r.id,data:ae})}if(b())E({type:"http.response.end",id:r.id})}catch(R){if(b())e.error(R instanceof Error?R:Error(String(R))),E({type:"http.response",id:r.id,status:500,headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32603,message:"Internal server error"}})})}finally{if(i.get(r.id)===p)i.delete(r.id)}}function v(r){if(d==="opening"){if(r.type==="session"){let p=Ft(r.limits.maxMessageBytes);if(p===void 0){u(de(`The relay's message limit (${r.limits.maxMessageBytes} bytes) is too small; tab-mcp needs at least ${Yt}.`,"policy"));return}f=p,d="ready",clearTimeout(G),q=r.limits.heartbeatMs,Z(),T(e.sessionStarted(r))}else if(r.type==="error")u(de(`The relay refused the connection: ${r.message||r.code}`,r.code==="rate_limited"?"rate_limited":"policy"));else if(r.type==="bye")u(de(`The relay ended the connection: ${r.reason}`,Ze[r.reason]??"closed"));return}if(d!=="ready")return;switch(r.type){case"ping":Z(),E({type:"pong",t:r.t});return;case"http.request":x(r);return;case"http.cancel":i.get(r.id)?.abort(),i.delete(r.id);return;case"pairing.code":e.pairingCode({code:r.code,expiresAt:r.expiresAt});return;case"grant.added":e.grantAdded(r.grant);return;case"grant.removed":e.grantRemoved(r.grantId);return;case"identity.bound":e.identityResult(!0,r.round);return;case"bye":if(n=Ze[r.reason]??"closed",n==="replaced")e.replaced();return;case"error":if(r.code==="identity_refused"){e.identityResult(!1,typeof r.round==="number"?r.round:void 0,r.message);return}e.error(Error(`Relay error ${r.code}: ${r.message}`));return;case"session":return}}return s.addEventListener("open",()=>{if(s.protocol!==""&&s.protocol!==be){u(de(`The relay speaks ${s.protocol}, not ${be}.`,"policy"));return}let r={type:"hello",library:e.library,page:{title:Gt()},secret:o};if(e.appName!==void 0)r.app={name:e.appName};E(r)}),s.addEventListener("message",(r)=>{if(typeof r.data!=="string")return;let p=Ye(r.data);if(p!==void 0){if(d==="ready")Z();v(p);return}let b=Kt(r.data);if(b?.id!==void 0)E(Wt.has(b.type)?{type:"error",code:"bad_message",message:`malformed ${b.type}`,id:b.id}:{type:"error",code:"unknown_type",message:`unknown type ${b.type}`,id:b.id})}),s.addEventListener("close",(r)=>{if(d==="opening"){m(r.code);let p=r.code===1006||r.code===1002;J(de(p?"Could not connect to the relay (refused, unreachable, or this page's origin is not allowed).":`The relay closed the connection (${r.code}${r.reason?`: ${r.reason}`:""}).`,Fe[r.code]??(p?"network":"closed")));return}m(r.code)}),{ready:ne,send:E,close(r){if(d==="closed")return;if(d==="opening"){u(new DOMException("The connection was cancelled","AbortError"));return}n=r,E({type:"bye",reason:"user"}),m(1000);try{s.close(1000,"bye")}catch{}}}}export{$r as openConnection};
8
-
9
- //# debugId=E7A8964C77CC552E64756E2164756E21
10
- //# sourceMappingURL=connection-by0y4k0a.min.js.map
@@ -1,4 +0,0 @@
1
- var W=0;function s(e,r,t={},...o){let a=e.createElement(r);if(t.className!==void 0)a.className=t.className;if(t.id!==void 0)a.id=t.id;if(t.text!==void 0)a.textContent=t.text;return a.append(...o),a}function g(e,r,t){let o=s(e,"button",{text:r});return o.type="button",o.addEventListener("click",t),o}function q(e,r,t,o){let a=g(e,"Copy",()=>{let p=()=>{a.textContent="Copied",a.setAttribute("aria-label",`Copied ${r}`)},l=e.defaultView?.navigator?.clipboard;if(l!==void 0)l.writeText(t()).then(p,o);else o()}),i=()=>{a.textContent="Copy",a.setAttribute("aria-label",`Copy ${r}`)};return i(),{button:a,reset:i}}function ee(e,r,t){let o=`tab-mcp-${++W}`,a=s(e,"dialog",{className:`tab-mcp-dialog ${r}`});a.setAttribute("aria-labelledby",`${o}-title`);let i=a.style;i.setProperty("max-width","var(--tab-mcp-max-width, 34rem)"),i.setProperty("font","var(--tab-mcp-font, inherit)"),i.setProperty("color","var(--tab-mcp-color, CanvasText)"),i.setProperty("background","var(--tab-mcp-background, Canvas)"),i.setProperty("border","var(--tab-mcp-border, 1px solid GrayText)"),i.setProperty("border-radius","var(--tab-mcp-radius, 0.5rem)"),i.setProperty("padding","var(--tab-mcp-padding, 1rem 1.25rem)");let p=s(e,"h2",{id:`${o}-title`,text:t});return p.style.setProperty("margin-top","0"),p.style.setProperty("font-size","var(--tab-mcp-title-size, 1.25em)"),a.append(p),{dialog:a,heading:p}}function E(e){let r=e.host||e.id;return e.name!==void 0&&e.name!==""?`${e.name} (${r})`:r}function oe(e){try{return JSON.stringify(e,null,2)}catch{return}}var re=750,ie=500;function ce(e,r,t={}){let o=Math.max(ie,t.allowDelayMs??re);if(e.signal.aborted)return Promise.resolve("deny");let a=e.tool.title??e.tool.name,{dialog:i}=ee(r,"tab-mcp-confirm",`Allow ${a}?`),p=g(r,"Don't allow",()=>i.close("deny")),l=g(r,"Allow",()=>{if(!l.disabled)i.close("allow")}),u=g(r,"Always allow",()=>{if(!u.disabled)i.close("always")});l.disabled=!0,u.disabled=!0;let H=s(r,"div",{className:"tab-mcp-actions"},p," ",l," ",u),y=s(r,"p",{className:"tab-mcp-always-note",text:`Always allow: ${a} runs without asking for ${E(e.client)} until you reload this page or disconnect it.`}),h=oe(e.arguments),b=s(r,"pre",{className:"tab-mcp-arguments",text:h??"The arguments cannot be shown, so this call cannot be allowed."});if(h===void 0)l.hidden=!0,u.hidden=!0,y.hidden=!0;return b.style.setProperty("white-space","pre-wrap"),b.style.setProperty("max-height","12rem"),b.style.setProperty("overflow","auto"),b.hidden=Object.keys(e.arguments).length===0,i.append(s(r,"p",{text:`${E(e.client)} wants to run ${a}.`}),s(r,"p",{className:"tab-mcp-description",text:e.tool.description}),b,H,y),r.body.append(i),new Promise((L)=>{let N=()=>i.close("deny");e.signal.addEventListener("abort",N,{once:!0});let A;i.addEventListener("close",()=>{clearTimeout(A),e.signal.removeEventListener("abort",N);let c=i.returnValue;i.remove(),L(c==="allow"||c==="always"?c:"deny")},{once:!0}),i.showModal(),p.focus(),A=setTimeout(()=>{l.disabled=!1,u.disabled=!1},o)})}var de=[["Claude (claude.ai and the desktop app)","Settings → Connectors → Add custom connector, then paste the address."],["ChatGPT","Settings → Apps and connectors → Advanced settings: turn on developer mode, then Create and paste the address."],["Claude Code","Run: claude mcp add --transport http tools ADDRESS"]];function le(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function pe(e,r,t){let{dialog:o}=ee(t,"tab-mcp-connect","Connect your AI app");o.tabIndex=-1,o.style.setProperty("outline","none");let a=s(t,"p",{className:"tab-mcp-status",text:"Connecting…"});a.setAttribute("role","status");let i=`tab-mcp-${++W}-address`,p=s(t,"label",{text:"Add this address to your AI app:"});p.htmlFor=i;let l=s(t,"input",{id:i,className:"tab-mcp-address-input"});l.readOnly=!0,l.style.setProperty("width","100%"),l.style.setProperty("font-family","var(--tab-mcp-mono, monospace)");let{button:u,reset:H}=q(t,"address",()=>l.value,()=>l.select());u.className="tab-mcp-address-copy";let y=g(t,"New address",()=>se());y.className="tab-mcp-new-address";let h=s(t,"div",{className:"tab-mcp-address"},p,l," ",u," ",y),b=`tab-mcp-${++W}-new-address`,L=s(t,"p",{id:b}),N=g(t,"Cancel",()=>{c.hidden=!0,y.focus()}),A=g(t,"Disconnect and get new address",()=>Q());A.className="tab-mcp-new-address-confirm";let c=s(t,"div",{className:"tab-mcp-new-address-question"},L,s(t,"div",{className:"tab-mcp-actions"},N," ",A));c.setAttribute("role","group"),c.setAttribute("aria-labelledby",b),c.hidden=!0;let m=s(t,"strong",{className:"tab-mcp-code-value"});m.style.setProperty("font-size","var(--tab-mcp-code-size, 1.5em)"),m.style.setProperty("letter-spacing","0.1em"),m.style.setProperty("font-family","var(--tab-mcp-mono, monospace)"),m.style.setProperty("user-select","all"),m.style.setProperty("-webkit-user-select","all");let{button:j,reset:te}=q(t,"code",()=>m.textContent??"",()=>t.getSelection()?.selectAllChildren(m));j.className="tab-mcp-code-copy";let K=s(t,"span",{},"When asked, enter the code ",m);K.setAttribute("aria-live","polite");let T=s(t,"p",{className:"tab-mcp-code"},K," ",j,s(t,"br"),s(t,"small",{className:"tab-mcp-code-note",text:"A new code appears every 2 minutes and after each use."})),R=s(t,"p",{className:"tab-mcp-sign-in",text:"When your AI app asks, sign in with the account you use on this page. No code is needed."}),V=s(t,"ul"),D=s(t,"details",{className:"tab-mcp-help"},s(t,"summary",{text:"How do I add it?"}),V),Y=s(t,"ul"),I=s(t,"div",{className:"tab-mcp-apps"},s(t,"h3",{text:"Connected"}),Y),G=s(t,"small",{className:"tab-mcp-close-note",text:"Closing this stops the code. The address stays the same: to connect later, open this again from the page."}),w=g(t,"Close",()=>o.close());w.className="tab-mcp-close",w.style.setProperty("font-size","0.875em");let v=g(t,"Done",()=>o.close());v.className="tab-mcp-done",v.style.setProperty("font-weight","bold"),v.hidden=!0;let C=s(t,"div",{className:"tab-mcp-actions"},G," ",w,v);C.style.setProperty("display","flex"),C.style.setProperty("align-items","center"),C.style.setProperty("justify-content","flex-end"),C.style.setProperty("gap","0.75rem"),C.style.setProperty("margin-top","1rem"),G.style.setProperty("flex","1");let f=!1,O=new Set,F=()=>{G.hidden=f||T.hidden},_=(n)=>{if(f=n,!f)O.clear();let d=t.activeElement;if(F(),w.hidden=f,v.hidden=!f,f&&d===w)v.focus();if(!f&&d===v)w.focus()},ne=()=>f?v:w;o.append(a,h,c,T,R,D,I,C),h.hidden=!0,T.hidden=!0,R.hidden=!0,D.hidden=!0,I.hidden=!0;let S=!1,J=()=>{let n=e.grants.map((d)=>E(d.client));if(n.length===0)return!1;return L.textContent=`A new address disconnects ${le(n)}. To use this page again, add the new address to ${n.length===1?"it":"them"}.`,!0},se=()=>{if(e.state!=="connected")return;if(!J()){Q();return}c.hidden=!1,N.focus()},Q=()=>{_(!1),w.focus(),c.hidden=!0,S=!0,a.textContent="Getting a new address…",e.newAddress().then(()=>{S=!1,a.textContent="This is a new address. Add it to your AI app again.",u.focus()},(n)=>{S=!1,a.textContent=`Could not connect: ${n instanceof Error?n.message:String(n)}. Close this and connect again.`,ne().focus()})},M=(n)=>{if(n===void 0){h.hidden=!0,c.hidden=!0,D.hidden=!0;return}l.value=n.address,H();let d=n.appName??e.appName;if(!S)a.textContent=d!==void 0?`${d} is ready for your AI app.`:"This page is ready for your AI app.";if(y.disabled=e.state!=="connected",h.hidden=!1,t.activeElement===o)u.focus();D.hidden=!1,V.replaceChildren(...de.map(([k,ae])=>s(t,"li",{},s(t,"strong",{text:k}),`: ${ae.replace("ADDRESS",n.address)}`)))},P=()=>{let n=e.pairingCode,d=e.session?.pairing==="oidc";if(m.textContent!==(n?.code??""))te();m.textContent=n?.code??"",T.hidden=d||n===void 0,R.hidden=!d,F()},z=s(t,"p",{className:"tab-mcp-apps-note"});I.append(z);let B=new Set(e.grants.map((n)=>n.grantId)),U=e.session,x=()=>{if(e.session!==U){U=e.session;for(let d of e.grants)B.add(d.grantId)}for(let d of e.grants){if(B.has(d.grantId))continue;if(B.add(d.grantId),a.textContent=`${E(d.client)} is connected.`,O.add(d.grantId),!f)_(!0)}if(f&&!e.grants.some((d)=>O.has(d.grantId)))_(!1);let n=e.state==="connected";if(Y.replaceChildren(...e.grants.map((d)=>{let k=g(t,"Disconnect",()=>{if(!e.revoke(d.grantId))x()});return k.disabled=!n,s(t,"li",{},`${E(d.client)} connected `,k)})),z.textContent=n?"":"To disconnect an app, connect this page again first.",z.hidden=n,I.hidden=e.grants.length===0,!c.hidden&&!J())c.hidden=!0,y.focus()},X=(n)=>{if(n.detail.reason!=="new_address")a.textContent="Disconnected. AI apps can use this page again after you connect.";M(void 0),x(),P()},Z=()=>{M(e.session),x(),P()};return e.addEventListener("pairingcode",P),e.addEventListener("grantschange",x),e.addEventListener("connected",Z),e.addEventListener("disconnected",X),t.body.append(o),e.startPairing(),x(),P(),M(e.session),r.then((n)=>M(n),(n)=>{a.textContent=`Could not connect: ${n instanceof Error?n.message:String(n)}`}),new Promise((n)=>{if(o.addEventListener("close",()=>{e.stopPairing(),e.removeEventListener("pairingcode",P),e.removeEventListener("grantschange",x),e.removeEventListener("connected",Z),e.removeEventListener("disconnected",X),o.remove(),n()},{once:!0}),o.showModal(),!h.hidden)u.focus();else o.focus()})}export{ce as confirmDialog,pe as showConnectDialog};
2
-
3
- //# debugId=DBF47105B5244B5564756E2164756E21
4
- //# sourceMappingURL=ui-xh7shp5z.min.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/ui.ts"],
4
- "sourcesContent": [
5
- "/**\n * The default UI, loaded on demand: the \"Connect your AI app\" dialog\n * (DEC-028) and the confirmation of consequential tools. Plain `<dialog>`\n * elements, no styles beyond a few CSS custom properties (`--tab-mcp-*`), all\n * text set with `textContent`. Pages with their own UI use the events and\n * methods of `TabMcp` instead.\n */\n\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type {\n\tConfirmRequest,\n\tDisconnectDetail,\n\tGrant,\n\tSessionInfo,\n\tToolCallClient,\n} from \"./types.ts\";\n\nlet counter = 0;\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n\tdoc: Document,\n\ttag: K,\n\tprops: { className?: string; text?: string; id?: string } = {},\n\t...children: (Node | string)[]\n): HTMLElementTagNameMap[K] {\n\tconst node = doc.createElement(tag);\n\tif (props.className !== undefined) node.className = props.className;\n\tif (props.id !== undefined) node.id = props.id;\n\tif (props.text !== undefined) node.textContent = props.text;\n\tnode.append(...children);\n\treturn node;\n}\n\nfunction button(\n\tdoc: Document,\n\ttext: string,\n\tonClick: () => void,\n): HTMLButtonElement {\n\tconst node = el(doc, \"button\", { text });\n\tnode.type = \"button\";\n\tnode.addEventListener(\"click\", onClick);\n\treturn node;\n}\n\n/**\n * A Copy button for `value()`, read at click time. Shows \"Copied\" once the\n * clipboard took it; without a clipboard (or when it refuses) `select()` puts\n * the text in the selection for Ctrl+C instead. `noun` names it for assistive\n * technology (\"Copy code\"), as the dialog has more than one Copy.\n */\nfunction copyButton(\n\tdoc: Document,\n\tnoun: string,\n\tvalue: () => string,\n\tselect: () => void,\n): { button: HTMLButtonElement; reset: () => void } {\n\tconst node = button(doc, \"Copy\", () => {\n\t\tconst done = () => {\n\t\t\tnode.textContent = \"Copied\";\n\t\t\tnode.setAttribute(\"aria-label\", `Copied ${noun}`);\n\t\t};\n\t\tconst clipboard = (doc.defaultView?.navigator as Navigator | undefined)\n\t\t\t?.clipboard;\n\t\tif (clipboard !== undefined)\n\t\t\tclipboard.writeText(value()).then(done, select);\n\t\telse select();\n\t});\n\tconst reset = () => {\n\t\tnode.textContent = \"Copy\";\n\t\tnode.setAttribute(\"aria-label\", `Copy ${noun}`);\n\t};\n\treset();\n\treturn { button: node, reset };\n}\n\nfunction newDialog(\n\tdoc: Document,\n\tclassName: string,\n\ttitle: string,\n): { dialog: HTMLDialogElement; heading: HTMLHeadingElement } {\n\tconst id = `tab-mcp-${++counter}`;\n\tconst dialog = el(doc, \"dialog\", {\n\t\tclassName: `tab-mcp-dialog ${className}`,\n\t});\n\tdialog.setAttribute(\"aria-labelledby\", `${id}-title`);\n\t// CSSOM properties are allowed under a strict CSP (no inline style attribute).\n\tconst style = dialog.style;\n\tstyle.setProperty(\"max-width\", \"var(--tab-mcp-max-width, 34rem)\");\n\tstyle.setProperty(\"font\", \"var(--tab-mcp-font, inherit)\");\n\tstyle.setProperty(\"color\", \"var(--tab-mcp-color, CanvasText)\");\n\tstyle.setProperty(\"background\", \"var(--tab-mcp-background, Canvas)\");\n\tstyle.setProperty(\"border\", \"var(--tab-mcp-border, 1px solid GrayText)\");\n\tstyle.setProperty(\"border-radius\", \"var(--tab-mcp-radius, 0.5rem)\");\n\tstyle.setProperty(\"padding\", \"var(--tab-mcp-padding, 1rem 1.25rem)\");\n\tconst heading = el(doc, \"h2\", { id: `${id}-title`, text: title });\n\theading.style.setProperty(\"margin-top\", \"0\");\n\theading.style.setProperty(\"font-size\", \"var(--tab-mcp-title-size, 1.25em)\");\n\tdialog.append(heading);\n\treturn { dialog, heading };\n}\n\nfunction clientLabel(client: ToolCallClient | Grant[\"client\"]): string {\n\tconst host = client.host || client.id;\n\treturn client.name !== undefined && client.name !== \"\"\n\t\t? `${client.name} (${host})`\n\t\t: host;\n}\n\n/**\n * The arguments as text, in full: what the user approves must be visible.\n * (The relay caps a request at 1 MiB, so this stays bounded.) `undefined`\n * when they cannot be shown, and then \"Allow\" is not offered.\n */\nfunction showArguments(args: Record<string, unknown>): string | undefined {\n\ttry {\n\t\treturn JSON.stringify(args, null, 2);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** How long \"Allow\" stays disabled after the confirmation opens, and the floor. */\nexport const ALLOW_DELAY_MS = 750;\nexport const MIN_ALLOW_DELAY_MS = 500;\n\n/** The user's answer: \"always\" allows this tool for this AI app from now on. */\nexport type ConfirmAnswer = \"allow\" | \"always\" | \"deny\";\n\n/**\n * Ask whether a consequential tool may run. \"Allow\" and \"Always allow\" stay\n * disabled for `allowDelayMs` (default 750, at least 500) after the dialog\n * opens, so a click meant for the page cannot approve. Everything else\n * (Don't allow, Escape, an aborted call) is \"deny\".\n */\nexport function confirmDialog(\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: { allowDelayMs?: number } = {},\n): Promise<ConfirmAnswer> {\n\tconst delay = Math.max(\n\t\tMIN_ALLOW_DELAY_MS,\n\t\toptions.allowDelayMs ?? ALLOW_DELAY_MS,\n\t);\n\tif (request.signal.aborted) return Promise.resolve(\"deny\");\n\tconst title = request.tool.title ?? request.tool.name;\n\tconst { dialog } = newDialog(doc, \"tab-mcp-confirm\", `Allow ${title}?`);\n\tconst deny = button(doc, \"Don't allow\", () => dialog.close(\"deny\"));\n\tconst allow = button(doc, \"Allow\", () => {\n\t\tif (!allow.disabled) dialog.close(\"allow\");\n\t});\n\tconst always = button(doc, \"Always allow\", () => {\n\t\tif (!always.disabled) dialog.close(\"always\");\n\t});\n\tallow.disabled = true;\n\talways.disabled = true;\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tdeny,\n\t\t\" \",\n\t\tallow,\n\t\t\" \",\n\t\talways,\n\t);\n\tconst alwaysNote = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-always-note\",\n\t\ttext: `Always allow: ${title} runs without asking for ${clientLabel(request.client)} until you reload this page or disconnect it.`,\n\t});\n\tconst shown = showArguments(request.arguments);\n\tconst args = el(doc, \"pre\", {\n\t\tclassName: \"tab-mcp-arguments\",\n\t\ttext:\n\t\t\tshown ?? \"The arguments cannot be shown, so this call cannot be allowed.\",\n\t});\n\tif (shown === undefined) {\n\t\tallow.hidden = true;\n\t\talways.hidden = true;\n\t\talwaysNote.hidden = true;\n\t}\n\targs.style.setProperty(\"white-space\", \"pre-wrap\");\n\targs.style.setProperty(\"max-height\", \"12rem\");\n\targs.style.setProperty(\"overflow\", \"auto\");\n\targs.hidden = Object.keys(request.arguments).length === 0;\n\tdialog.append(\n\t\tel(doc, \"p\", {\n\t\t\ttext: `${clientLabel(request.client)} wants to run ${title}.`,\n\t\t}),\n\t\tel(doc, \"p\", {\n\t\t\tclassName: \"tab-mcp-description\",\n\t\t\ttext: request.tool.description,\n\t\t}),\n\t\targs,\n\t\tactions,\n\t\talwaysNote,\n\t);\n\tdoc.body.append(dialog);\n\treturn new Promise((resolve) => {\n\t\tconst onAbort = () => dialog.close(\"deny\");\n\t\trequest.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\trequest.signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tconst value = dialog.returnValue;\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve(value === \"allow\" || value === \"always\" ? value : \"deny\");\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\tdeny.focus(); // the safe choice is the default\n\t\t// Counted from when the dialog is shown, not from when it was built.\n\t\ttimer = setTimeout(() => {\n\t\t\tallow.disabled = false;\n\t\t\talways.disabled = false;\n\t\t}, delay);\n\t});\n}\n\nconst INSTRUCTIONS: [string, string][] = [\n\t[\n\t\t\"Claude (claude.ai and the desktop app)\",\n\t\t\"Settings → Connectors → Add custom connector, then paste the address.\",\n\t],\n\t[\n\t\t\"ChatGPT\",\n\t\t\"Settings → Apps and connectors → Advanced settings: turn on developer mode, then Create and paste the address.\",\n\t],\n\t[\"Claude Code\", \"Run: claude mcp add --transport http tools ADDRESS\"],\n];\n\n/** \"A and B\", \"A, B and C\". */\nfunction listOf(items: string[]): string {\n\treturn items.length < 2\n\t\t? (items[0] ?? \"\")\n\t\t: `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`;\n}\n\n/**\n * The \"Connect your AI app\" dialog: the address with Copy and New address,\n * short instructions, the pairing code (with Copy) while the relay sends one,\n * and the connected apps with Disconnect. Pairing is on while it is open, so\n * closing it ends the code; the connection and the address stay. Until an app\n * connects, only a small Close (and Escape) close it; then a Done. New address\n * asks first when it would disconnect connected apps (`newAddress()` revokes\n * them).\n */\nexport function showConnectDialog(\n\tmcp: TabMcp,\n\tconnecting: Promise<SessionInfo>,\n\tdoc: Document,\n): Promise<void> {\n\tconst { dialog } = newDialog(doc, \"tab-mcp-connect\", \"Connect your AI app\");\n\t// Focusable from script only, for the moment before the address is shown.\n\tdialog.tabIndex = -1;\n\tdialog.style.setProperty(\"outline\", \"none\");\n\tconst status = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-status\",\n\t\ttext: \"Connecting…\",\n\t});\n\tstatus.setAttribute(\"role\", \"status\");\n\n\tconst addressId = `tab-mcp-${++counter}-address`;\n\tconst label = el(doc, \"label\", { text: \"Add this address to your AI app:\" });\n\tlabel.htmlFor = addressId;\n\tconst address = el(doc, \"input\", {\n\t\tid: addressId,\n\t\tclassName: \"tab-mcp-address-input\",\n\t});\n\taddress.readOnly = true;\n\taddress.style.setProperty(\"width\", \"100%\");\n\taddress.style.setProperty(\"font-family\", \"var(--tab-mcp-mono, monospace)\");\n\tconst { button: copy, reset: resetCopy } = copyButton(\n\t\tdoc,\n\t\t\"address\",\n\t\t() => address.value,\n\t\t() => address.select(),\n\t);\n\tcopy.className = \"tab-mcp-address-copy\";\n\tconst fresh = button(doc, \"New address\", () => askNewAddress());\n\tfresh.className = \"tab-mcp-new-address\";\n\tconst addressBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-address\" },\n\t\tlabel,\n\t\taddress,\n\t\t\" \",\n\t\tcopy,\n\t\t\" \",\n\t\tfresh,\n\t);\n\n\t// Asked in the dialog before New address disconnects connected apps.\n\tconst confirmId = `tab-mcp-${++counter}-new-address`;\n\tconst confirmText = el(doc, \"p\", { id: confirmId });\n\tconst cancelNew = button(doc, \"Cancel\", () => {\n\t\tconfirmBox.hidden = true;\n\t\tfresh.focus();\n\t});\n\tconst confirmNew = button(doc, \"Disconnect and get new address\", () =>\n\t\tgetNewAddress(),\n\t);\n\tconfirmNew.className = \"tab-mcp-new-address-confirm\";\n\tconst confirmBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-new-address-question\" },\n\t\tconfirmText,\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"div\",\n\t\t\t{ className: \"tab-mcp-actions\" },\n\t\t\tcancelNew,\n\t\t\t\" \",\n\t\t\tconfirmNew,\n\t\t),\n\t);\n\tconfirmBox.setAttribute(\"role\", \"group\");\n\tconfirmBox.setAttribute(\"aria-labelledby\", confirmId);\n\tconfirmBox.hidden = true;\n\n\tconst code = el(doc, \"strong\", { className: \"tab-mcp-code-value\" });\n\tcode.style.setProperty(\"font-size\", \"var(--tab-mcp-code-size, 1.5em)\");\n\tcode.style.setProperty(\"letter-spacing\", \"0.1em\");\n\tcode.style.setProperty(\"font-family\", \"var(--tab-mcp-mono, monospace)\");\n\t// One click selects the whole code; it stays plain, selectable text.\n\tcode.style.setProperty(\"user-select\", \"all\");\n\tcode.style.setProperty(\"-webkit-user-select\", \"all\");\n\t// Reads the code shown at click time, so a rotated code is copied as shown.\n\tconst { button: copyCode, reset: resetCopyCode } = copyButton(\n\t\tdoc,\n\t\t\"code\",\n\t\t() => code.textContent ?? \"\",\n\t\t() => doc.getSelection()?.selectAllChildren(code),\n\t);\n\tcopyCode.className = \"tab-mcp-code-copy\";\n\t// Only the sentence with the code is announced when the code changes,\n\t// not its Copy button's \"Copied\".\n\tconst codeSentence = el(doc, \"span\", {}, \"When asked, enter the code \", code);\n\tcodeSentence.setAttribute(\"aria-live\", \"polite\");\n\tconst codeLine = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ className: \"tab-mcp-code\" },\n\t\tcodeSentence,\n\t\t\" \",\n\t\tcopyCode,\n\t\tel(doc, \"br\"),\n\t\tel(doc, \"small\", {\n\t\t\tclassName: \"tab-mcp-code-note\",\n\t\t\ttext: \"A new code appears every 2 minutes and after each use.\",\n\t\t}),\n\t);\n\t// Identity binding: no code, the same account at the AI app's sign-in.\n\tconst signInLine = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-sign-in\",\n\t\ttext: \"When your AI app asks, sign in with the account you use on this page. No code is needed.\",\n\t});\n\n\tconst steps = el(doc, \"ul\");\n\tconst help = el(\n\t\tdoc,\n\t\t\"details\",\n\t\t{ className: \"tab-mcp-help\" },\n\t\tel(doc, \"summary\", { text: \"How do I add it?\" }),\n\t\tsteps,\n\t);\n\n\tconst appList = el(doc, \"ul\");\n\tconst apps = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-apps\" },\n\t\tel(doc, \"h3\", { text: \"Connected\" }),\n\t\tappList,\n\t);\n\n\t// Until an app connects in this dialog, closing it is not the next step:\n\t// a small Close at the end, saying what closing does (the code stops, the\n\t// address stays). Once one connects, a prominent Done replaces both.\n\tconst closeNote = el(doc, \"small\", {\n\t\tclassName: \"tab-mcp-close-note\",\n\t\ttext: \"Closing this stops the code. The address stays the same: to connect later, open this again from the page.\",\n\t});\n\tconst close = button(doc, \"Close\", () => dialog.close());\n\tclose.className = \"tab-mcp-close\";\n\tclose.style.setProperty(\"font-size\", \"0.875em\");\n\tconst done = button(doc, \"Done\", () => dialog.close());\n\tdone.className = \"tab-mcp-done\";\n\tdone.style.setProperty(\"font-weight\", \"bold\");\n\tdone.hidden = true;\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tcloseNote,\n\t\t\" \",\n\t\tclose,\n\t\tdone,\n\t);\n\t// The note on the left, the button at the far right, apart from the code.\n\tactions.style.setProperty(\"display\", \"flex\");\n\tactions.style.setProperty(\"align-items\", \"center\");\n\tactions.style.setProperty(\"justify-content\", \"flex-end\");\n\tactions.style.setProperty(\"gap\", \"0.75rem\");\n\tactions.style.setProperty(\"margin-top\", \"1rem\");\n\tcloseNote.style.setProperty(\"flex\", \"1\");\n\t// An app connected while this dialog is open (since the last new address),\n\t// and still connected: the grants that made it so.\n\tlet paired = false;\n\tconst pairedGrants = new Set<string>();\n\t// The note is about the code: only while one is shown and nothing paired.\n\tconst renderCloseNote = () => {\n\t\tcloseNote.hidden = paired || codeLine.hidden;\n\t};\n\tconst setPaired = (value: boolean) => {\n\t\tpaired = value;\n\t\tif (!paired) pairedGrants.clear();\n\t\tconst focused = doc.activeElement;\n\t\trenderCloseNote();\n\t\tclose.hidden = paired;\n\t\tdone.hidden = !paired;\n\t\t// Focus never stays on a control that was just hidden.\n\t\tif (paired && focused === close) done.focus();\n\t\tif (!paired && focused === done) close.focus();\n\t};\n\t// The visible button that closes the dialog.\n\tconst closer = () => (paired ? done : close);\n\n\tdialog.append(\n\t\tstatus,\n\t\taddressBox,\n\t\tconfirmBox,\n\t\tcodeLine,\n\t\tsignInLine,\n\t\thelp,\n\t\tapps,\n\t\tactions,\n\t);\n\taddressBox.hidden = true;\n\tcodeLine.hidden = true;\n\tsignInLine.hidden = true;\n\thelp.hidden = true;\n\tapps.hidden = true;\n\n\t// Set while New address waits for the new session.\n\tlet renewing = false;\n\t// The question names the apps connected now; pairing goes on while it is open.\n\tconst renderQuestion = (): boolean => {\n\t\tconst names = mcp.grants.map((g) => clientLabel(g.client));\n\t\tif (names.length === 0) return false;\n\t\tconfirmText.textContent = `A new address disconnects ${listOf(names)}. To use this page again, add the new address to ${names.length === 1 ? \"it\" : \"them\"}.`;\n\t\treturn true;\n\t};\n\tconst askNewAddress = () => {\n\t\tif (mcp.state !== \"connected\") return;\n\t\tif (!renderQuestion()) {\n\t\t\tgetNewAddress();\n\t\t\treturn;\n\t\t}\n\t\tconfirmBox.hidden = false;\n\t\tcancelNew.focus(); // the safe choice is the default\n\t};\n\tconst getNewAddress = () => {\n\t\t// The apps are disconnected: the next one has to pair again.\n\t\tsetPaired(false);\n\t\t// Focus moves before the focused control is hidden.\n\t\tclose.focus();\n\t\tconfirmBox.hidden = true;\n\t\trenewing = true;\n\t\tstatus.textContent = \"Getting a new address…\";\n\t\t// Called from the click, so the reconnect has the user action it needs.\n\t\tmcp.newAddress().then(\n\t\t\t() => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent =\n\t\t\t\t\t\"This is a new address. Add it to your AI app again.\";\n\t\t\t\tcopy.focus();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}. Close this and connect again.`;\n\t\t\t\tcloser().focus();\n\t\t\t},\n\t\t);\n\t};\n\tconst renderSession = (session: SessionInfo | undefined) => {\n\t\tif (session === undefined) {\n\t\t\taddressBox.hidden = true;\n\t\t\tconfirmBox.hidden = true;\n\t\t\thelp.hidden = true;\n\t\t\treturn;\n\t\t}\n\t\taddress.value = session.address;\n\t\tresetCopy();\n\t\tconst appName = session.appName ?? mcp.appName;\n\t\tif (!renewing)\n\t\t\tstatus.textContent =\n\t\t\t\tappName !== undefined\n\t\t\t\t\t? `${appName} is ready for your AI app.`\n\t\t\t\t\t: \"This page is ready for your AI app.\";\n\t\tfresh.disabled = mcp.state !== \"connected\";\n\t\taddressBox.hidden = false;\n\t\t// Opened before the session was known: start at the address's Copy.\n\t\tif (doc.activeElement === dialog) copy.focus();\n\t\thelp.hidden = false;\n\t\tsteps.replaceChildren(\n\t\t\t...INSTRUCTIONS.map(([app, how]) =>\n\t\t\t\tel(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"li\",\n\t\t\t\t\t{},\n\t\t\t\t\tel(doc, \"strong\", { text: app }),\n\t\t\t\t\t`: ${how.replace(\"ADDRESS\", session.address)}`,\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t};\n\tconst renderCode = () => {\n\t\tconst current = mcp.pairingCode;\n\t\tconst oidc = mcp.session?.pairing === \"oidc\";\n\t\t// A new code is not copied yet.\n\t\tif (code.textContent !== (current?.code ?? \"\")) resetCopyCode();\n\t\tcode.textContent = current?.code ?? \"\";\n\t\tcodeLine.hidden = oidc || current === undefined;\n\t\tsignInLine.hidden = !oidc;\n\t\trenderCloseNote();\n\t};\n\tconst appsNote = el(doc, \"p\", { className: \"tab-mcp-apps-note\" });\n\tapps.append(appsNote);\n\t// Grants that were there when the dialog opened; a new one is announced.\n\tconst known = new Set(mcp.grants.map((g) => g.grantId));\n\t// Grants that come with a (new) session were there before; only the ones\n\t// added during a session are new connections.\n\tlet session = mcp.session;\n\tconst renderGrants = () => {\n\t\tif (mcp.session !== session) {\n\t\t\tsession = mcp.session;\n\t\t\tfor (const grant of mcp.grants) known.add(grant.grantId);\n\t\t}\n\t\tfor (const grant of mcp.grants) {\n\t\t\tif (known.has(grant.grantId)) continue;\n\t\t\tknown.add(grant.grantId);\n\t\t\tstatus.textContent = `${clientLabel(grant.client)} is connected.`;\n\t\t\tpairedGrants.add(grant.grantId);\n\t\t\tif (!paired) setPaired(true);\n\t\t}\n\t\t// The app that connected here is gone again (Disconnect, or revoked):\n\t\t// back to Close and the note, the code still runs.\n\t\tif (paired && !mcp.grants.some((g) => pairedGrants.has(g.grantId))) {\n\t\t\tsetPaired(false);\n\t\t}\n\t\tconst connected = mcp.state === \"connected\";\n\t\tappList.replaceChildren(\n\t\t\t...mcp.grants.map((grant) => {\n\t\t\t\tconst disconnect = button(doc, \"Disconnect\", () => {\n\t\t\t\t\tif (!mcp.revoke(grant.grantId)) renderGrants();\n\t\t\t\t});\n\t\t\t\t// Only the relay can revoke, so only while connected.\n\t\t\t\tdisconnect.disabled = !connected;\n\t\t\t\treturn el(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"li\",\n\t\t\t\t\t{},\n\t\t\t\t\t`${clientLabel(grant.client)} connected `,\n\t\t\t\t\tdisconnect,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tappsNote.textContent = connected\n\t\t\t? \"\"\n\t\t\t: \"To disconnect an app, connect this page again first.\";\n\t\tappsNote.hidden = connected;\n\t\tapps.hidden = mcp.grants.length === 0;\n\t\tif (!confirmBox.hidden && !renderQuestion()) {\n\t\t\t// Nobody left to disconnect: no question needed.\n\t\t\tconfirmBox.hidden = true;\n\t\t\tfresh.focus();\n\t\t}\n\t};\n\tconst onDisconnected = (event: CustomEvent<DisconnectDetail>) => {\n\t\tif (event.detail.reason !== \"new_address\")\n\t\t\tstatus.textContent =\n\t\t\t\t\"Disconnected. AI apps can use this page again after you connect.\";\n\t\trenderSession(undefined);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\tconst onConnected = () => {\n\t\trenderSession(mcp.session);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\n\tmcp.addEventListener(\"pairingcode\", renderCode);\n\tmcp.addEventListener(\"grantschange\", renderGrants);\n\tmcp.addEventListener(\"connected\", onConnected);\n\tmcp.addEventListener(\"disconnected\", onDisconnected);\n\tdoc.body.append(dialog);\n\tmcp.startPairing();\n\trenderGrants();\n\trenderCode();\n\trenderSession(mcp.session);\n\tconnecting.then(\n\t\t(session) => renderSession(session),\n\t\t(error: unknown) => {\n\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}`;\n\t\t},\n\t);\n\n\treturn new Promise((resolve) => {\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tmcp.stopPairing();\n\t\t\t\tmcp.removeEventListener(\"pairingcode\", renderCode);\n\t\t\t\tmcp.removeEventListener(\"grantschange\", renderGrants);\n\t\t\t\tmcp.removeEventListener(\"connected\", onConnected);\n\t\t\t\tmcp.removeEventListener(\"disconnected\", onDisconnected);\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\t// Start at the address's Copy; until the address is there, at the\n\t\t// dialog itself (its title is read out), not at Close.\n\t\tif (!addressBox.hidden) copy.focus();\n\t\telse dialog.focus();\n\t});\n}\n"
6
- ],
7
- "mappings": "AAiBA,IAAI,EAAU,EAEd,SAAS,CAAyC,CACjD,EACA,EACA,EAA4D,CAAC,KAC1D,EACwB,CAC3B,IAAM,EAAO,EAAI,cAAc,CAAG,EAClC,GAAI,EAAM,YAAc,OAAW,EAAK,UAAY,EAAM,UAC1D,GAAI,EAAM,KAAO,OAAW,EAAK,GAAK,EAAM,GAC5C,GAAI,EAAM,OAAS,OAAW,EAAK,YAAc,EAAM,KAEvD,OADA,EAAK,OAAO,GAAG,CAAQ,EAChB,EAGR,SAAS,CAAM,CACd,EACA,EACA,EACoB,CACpB,IAAM,EAAO,EAAG,EAAK,SAAU,CAAE,MAAK,CAAC,EAGvC,OAFA,EAAK,KAAO,SACZ,EAAK,iBAAiB,QAAS,CAAO,EAC/B,EASR,SAAS,CAAU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