@ractive-ch/tab-mcp-client 0.16.2 → 0.18.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +898 -0
  2. package/README.md +216 -90
  3. package/address.d.ts +8 -8
  4. package/allowed.d.ts +28 -0
  5. package/allowed.js +14 -0
  6. package/allowed.js.map +10 -0
  7. package/always-allowed.d.ts +140 -22
  8. package/cdn/allowed.min.js +4 -0
  9. package/cdn/allowed.min.js.map +10 -0
  10. package/cdn/confirm-f36n8xj5.min.js +4 -0
  11. package/cdn/confirm-f36n8xj5.min.js.map +10 -0
  12. package/cdn/connect-ph4xxen4.min.js +6 -0
  13. package/cdn/connect-ph4xxen4.min.js.map +12 -0
  14. package/cdn/{connection-w97tf22a.min.js → connection-0xqwz17v.min.js} +7 -7
  15. package/cdn/{connection-w97tf22a.min.js.map → connection-0xqwz17v.min.js.map} +5 -5
  16. package/cdn/{index-vt5zk9me.min.js → tab-mcp-client-2vx9mcww.min.js} +20 -9
  17. package/cdn/tab-mcp-client-2vx9mcww.min.js.map +12 -0
  18. package/cdn/tab-mcp-client-6gcmd7n8.min.js +5 -0
  19. package/cdn/tab-mcp-client-6gcmd7n8.min.js.map +10 -0
  20. package/cdn/tab-mcp-client.min.js +3 -3
  21. package/cdn/tab-mcp-client.min.js.map +4 -4
  22. package/{confirm-fgnjgd08.js → confirm-jbyqzy14.js} +29 -19
  23. package/confirm-jbyqzy14.js.map +10 -0
  24. package/confirm.d.ts +27 -20
  25. package/{connect-8jpb0k29.js → connect-13hkdpcx.js} +113 -16
  26. package/connect-13hkdpcx.js.map +10 -0
  27. package/connect.d.ts +2 -2
  28. package/{connection-g91xjjgm.js → connection-gang7f5x.js} +10 -23
  29. package/{connection-g91xjjgm.js.map → connection-gang7f5x.js.map} +5 -5
  30. package/connection.d.ts +2 -2
  31. package/dialog.d.ts +1 -1
  32. package/{index-jnz7w9xa.js → index-c1c266tm.js} +36 -98
  33. package/index-c1c266tm.js.map +11 -0
  34. package/index-dmh5vm5m.js.map +1 -1
  35. package/index-h8b3dc5p.js +245 -0
  36. package/index-h8b3dc5p.js.map +10 -0
  37. package/index.js +33 -22
  38. package/index.js.map +4 -4
  39. package/internal.d.ts +2 -0
  40. package/package.json +7 -2
  41. package/protocol.d.ts +6 -7
  42. package/react.d.ts +19 -0
  43. package/react.js +30 -1
  44. package/react.js.map +3 -3
  45. package/secret.d.ts +6 -0
  46. package/strings.d.ts +13 -4
  47. package/tab-mcp.d.ts +15 -5
  48. package/types.d.ts +32 -9
  49. package/visible.d.ts +1 -1
  50. package/cdn/confirm-y30cx7e1.min.js +0 -4
  51. package/cdn/confirm-y30cx7e1.min.js.map +0 -10
  52. package/cdn/connect-bbhj2y7w.min.js +0 -6
  53. package/cdn/connect-bbhj2y7w.min.js.map +0 -12
  54. package/cdn/index-vt5zk9me.min.js.map +0 -13
  55. package/confirm-fgnjgd08.js.map +0 -10
  56. package/connect-8jpb0k29.js.map +0 -10
  57. package/index-jnz7w9xa.js.map +0 -12
@@ -1,5 +1,8 @@
1
1
  import {
2
- allowedFor,
2
+ allowedFor
3
+ } from "./index-h8b3dc5p.js";
4
+ import"./index-dmh5vm5m.js";
5
+ import {
3
6
  nextId,
4
7
  stringsOf,
5
8
  format,
@@ -11,14 +14,115 @@ import {
11
14
  listOf,
12
15
  newDialog,
13
16
  copyButton
14
- } from "./index-jnz7w9xa.js";
15
- import"./index-dmh5vm5m.js";
17
+ } from "./index-c1c266tm.js";
16
18
  import {
17
19
  SETUP_GUIDE2,
18
20
  setupInstructions2
19
21
  } from "./index-5jyqehpk.js";
20
22
 
21
23
  // src/connect.ts
24
+ function switchOf(doc, text, onToggle) {
25
+ const input = el(doc, "input");
26
+ input.type = "checkbox";
27
+ input.setAttribute("role", "switch");
28
+ input.addEventListener("change", () => onToggle(input.checked));
29
+ const label = el(doc, "label", { className: "tab-mcp-switch" }, input, text);
30
+ return { label, input };
31
+ }
32
+ function allowedSwitches(doc, s, allowed, grantId, app) {
33
+ const title = el(doc, "p", {
34
+ className: "tab-mcp-allowed-title",
35
+ id: `${nextId()}-allowed`,
36
+ text: s.runsWithoutAsking
37
+ });
38
+ const list = el(doc, "div", { className: "tab-mcp-switches" });
39
+ const all = switchOf(doc, el(doc, "span", { text: s.allowEverything }), (on) => {
40
+ if (!on || allowed.offered)
41
+ allowed.setEverything(grantId, on);
42
+ render();
43
+ });
44
+ all.label.classList.add("tab-mcp-everything");
45
+ all.input.setAttribute("aria-label", format(s.allowEverythingApp, { app }));
46
+ const note = el(doc, "small", { className: "tab-mcp-everything-note", id: `${title.id}-note` }, ...fill(doc, s.allowEverythingNote, { app }));
47
+ all.input.setAttribute("aria-describedby", note.id);
48
+ const box = el(doc, "div", { className: "tab-mcp-allowed" });
49
+ box.setAttribute("role", "group");
50
+ box.setAttribute("aria-labelledby", title.id);
51
+ const switches = new Map;
52
+ const render = () => {
53
+ const everything = allowed.everything(grantId);
54
+ const listed = allowed.list(grantId);
55
+ const on = new Set(listed);
56
+ const asking = new Map(allowed.tools().map((t) => [t.name, t]));
57
+ const rows = [];
58
+ if (allowed.offered)
59
+ for (const t of asking.values())
60
+ rows.push({
61
+ name: t.name,
62
+ shown: t.title ?? t.name,
63
+ destructive: t.destructive,
64
+ offOnly: false
65
+ });
66
+ for (const name of listed) {
67
+ if (allowed.offered && asking.has(name))
68
+ continue;
69
+ const t = asking.get(name);
70
+ rows.push({
71
+ name,
72
+ shown: t?.title ?? name,
73
+ destructive: t?.destructive === true,
74
+ offOnly: true
75
+ });
76
+ }
77
+ const showAll = allowed.offered || everything;
78
+ box.hidden = rows.length === 0 && !everything;
79
+ if (box.hidden)
80
+ return;
81
+ if (!box.hasChildNodes())
82
+ box.append(title, list, all.label, note);
83
+ const names = new Set(rows.map((r) => r.name));
84
+ for (const [name, { label }] of switches) {
85
+ if (names.has(name))
86
+ continue;
87
+ label.remove();
88
+ switches.delete(name);
89
+ }
90
+ rows.forEach((row, i) => {
91
+ let entry = switches.get(row.name);
92
+ if (entry === undefined) {
93
+ const name = el(doc, "span");
94
+ const mark = el(doc, "small", {
95
+ className: "tab-mcp-destructive",
96
+ text: s.destructive
97
+ });
98
+ const made = switchOf(doc, el(doc, "span", {}, name, " ", mark), (turnedOn) => {
99
+ if (!turnedOn)
100
+ allowed.ask(grantId, row.name);
101
+ else if (switches.get(row.name)?.offOnly === false)
102
+ allowed.allow(grantId, row.name);
103
+ render();
104
+ });
105
+ entry = { ...made, name, mark, offOnly: row.offOnly };
106
+ switches.set(row.name, entry);
107
+ }
108
+ entry.offOnly = row.offOnly;
109
+ const shown = visible(row.shown);
110
+ entry.name.textContent = shown;
111
+ entry.mark.hidden = !row.destructive;
112
+ entry.input.setAttribute("aria-label", format(row.destructive ? s.allowDestructiveToolApp : s.allowToolApp, {
113
+ tool: shown,
114
+ app
115
+ }));
116
+ entry.input.checked = everything || on.has(row.name);
117
+ entry.input.disabled = everything;
118
+ if (list.children[i] !== entry.label)
119
+ list.insertBefore(entry.label, list.children[i] ?? null);
120
+ });
121
+ all.label.hidden = note.hidden = !showAll;
122
+ all.input.checked = everything;
123
+ };
124
+ return { box, render };
125
+ }
22
126
  function appLabels(grants, s) {
23
127
  return [...new Set(grants.map((g) => clientLabel(g.client, s)))];
24
128
  }
@@ -243,12 +347,9 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools", ui) {
243
347
  render();
244
348
  }, "tab-mcp-disconnect", "danger");
245
349
  disconnect.setAttribute("aria-label", format(s.disconnectApp, { app }));
246
- const askAgain = button(doc, s.askAgain, () => allowed.forget(grant.grantId), "tab-mcp-ask-again");
247
- askAgain.setAttribute("aria-label", format(s.askAgainApp, { app }));
248
- const allowedText = el(doc, "span");
249
- const allowedBox = el(doc, "div", { className: "tab-mcp-allowed" }, allowedText, " ", askAgain);
250
- const item = el(doc, "li", {}, el(doc, "span", { className: "tab-mcp-app" }, format(s.appConnected, { app })), " ", disconnect, allowedBox);
251
- return { item, disconnect, allowedText, allowedBox };
350
+ const switches = allowedSwitches(doc, s, allowed, grant.grantId, app);
351
+ const item = el(doc, "li", {}, el(doc, "span", { className: "tab-mcp-app" }, format(s.appConnected, { app })), " ", disconnect, switches.box);
352
+ return { item, disconnect, renderAllowed: switches.render };
252
353
  };
253
354
  const renderSteps = (session) => {
254
355
  if (stepsFor === session.address)
@@ -366,11 +467,7 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools", ui) {
366
467
  items.set(grant.grantId, entry);
367
468
  }
368
469
  entry.disconnect.disabled = !connected;
369
- const tools = allowed.list(grant.grantId);
370
- entry.allowedBox.hidden = tools.length === 0;
371
- entry.allowedText.textContent = format(s.runsWithoutAsking, {
372
- tools: tools.map(visible).join(", ")
373
- });
470
+ entry.renderAllowed();
374
471
  if (appList.children[i] !== entry.item)
375
472
  appList.insertBefore(entry.item, appList.children[i] ?? null);
376
473
  });
@@ -480,5 +577,5 @@ export {
480
577
  showConnectDialog
481
578
  };
482
579
 
483
- //# debugId=7DE523796225AEC064756E2164756E21
484
- //# sourceMappingURL=connect-8jpb0k29.js.map
580
+ //# debugId=90A68AE264A1104964756E2164756E21
581
+ //# sourceMappingURL=connect-13hkdpcx.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/connect.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The \"Connect your AI app\" dialog (DEC-028) and the notice that the page\n * lost its address, loaded on demand when a page opens the dialog.\n */\n\nimport { type Allowances, allowedFor } from \"./always-allowed.ts\";\nimport {\n\tbutton,\n\tclientLabel,\n\tcopyButton,\n\tel,\n\tfill,\n\tformat,\n\tlistOf,\n\tnewDialog,\n\tnextId,\n\tstringsOf,\n\tvisible,\n} from \"./dialog.ts\";\nimport { SETUP_GUIDE, setupInstructions } from \"./setup.ts\";\nimport type { DialogStrings } from \"./strings.ts\";\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type {\n\tDialogOptions,\n\tDisconnectReason,\n\tGrant,\n\tPairingCode,\n\tSessionInfo,\n\tStateChangeDetail,\n} from \"./types.ts\";\n\n/** A switch: a checkbox with `role=\"switch\"` in its label, which a click on the text turns too. */\nfunction switchOf(\n\tdoc: Document,\n\ttext: HTMLElement,\n\tonToggle: (on: boolean) => void,\n): { label: HTMLLabelElement; input: HTMLInputElement } {\n\tconst input = el(doc, \"input\");\n\tinput.type = \"checkbox\";\n\tinput.setAttribute(\"role\", \"switch\");\n\tinput.addEventListener(\"change\", () => onToggle(input.checked));\n\tconst label = el(doc, \"label\", { className: \"tab-mcp-switch\" }, input, text);\n\treturn { label, input };\n}\n\n/**\n * Under a connected app, the switches for what runs without asking. With\n * `alwaysAllow` (`offered`): a switch per tool that asks (its title or\n * name, destructive ones marked) and \"Allow everything, no questions asked\"\n * with what it means. Without it, only what is allowed now, as switches that\n * can only be turned off (\"everything\" only while it is on): the user sees\n * what runs without asking and can end it, and is never offered more than\n * the page chose to offer. Tools allowed but not registered right now are\n * listed by name, also only to turn off. Each switch's accessible name names\n * the app: the list has one set per app. `render` updates it in place, so a\n * focused switch keeps its focus.\n */\nfunction allowedSwitches(\n\tdoc: Document,\n\ts: DialogStrings,\n\tallowed: Allowances,\n\tgrantId: string,\n\tapp: string,\n): { box: HTMLElement; render: () => void } {\n\tconst title = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-allowed-title\",\n\t\tid: `${nextId()}-allowed`,\n\t\ttext: s.runsWithoutAsking,\n\t});\n\tconst list = el(doc, \"div\", { className: \"tab-mcp-switches\" });\n\t// Turning on only where the page offers it; the store decides the rest.\n\tconst all = switchOf(\n\t\tdoc,\n\t\tel(doc, \"span\", { text: s.allowEverything }),\n\t\t(on) => {\n\t\t\tif (!on || allowed.offered) allowed.setEverything(grantId, on);\n\t\t\trender();\n\t\t},\n\t);\n\tall.label.classList.add(\"tab-mcp-everything\");\n\tall.input.setAttribute(\"aria-label\", format(s.allowEverythingApp, { app }));\n\tconst note = el(\n\t\tdoc,\n\t\t\"small\",\n\t\t{ className: \"tab-mcp-everything-note\", id: `${title.id}-note` },\n\t\t...fill(doc, s.allowEverythingNote, { app }),\n\t);\n\tall.input.setAttribute(\"aria-describedby\", note.id);\n\t// Filled when first shown: a page without it has no switches in its DOM.\n\tconst box = el(doc, \"div\", { className: \"tab-mcp-allowed\" });\n\tbox.setAttribute(\"role\", \"group\");\n\tbox.setAttribute(\"aria-labelledby\", title.id);\n\tconst switches = new Map<\n\t\tstring,\n\t\tReturnType<typeof switchOf> & {\n\t\t\tname: HTMLElement;\n\t\t\tmark: HTMLElement;\n\t\t\toffOnly: boolean;\n\t\t}\n\t>();\n\tconst render = () => {\n\t\tconst everything = allowed.everything(grantId);\n\t\tconst listed = allowed.list(grantId);\n\t\tconst on = new Set(listed);\n\t\tconst asking = new Map(allowed.tools().map((t) => [t.name, t]));\n\t\tconst rows: {\n\t\t\tname: string;\n\t\t\tshown: string;\n\t\t\tdestructive: boolean;\n\t\t\toffOnly: boolean;\n\t\t}[] = [];\n\t\tif (allowed.offered)\n\t\t\tfor (const t of asking.values())\n\t\t\t\trows.push({\n\t\t\t\t\tname: t.name,\n\t\t\t\t\tshown: t.title ?? t.name,\n\t\t\t\t\tdestructive: t.destructive,\n\t\t\t\t\toffOnly: false,\n\t\t\t\t});\n\t\tfor (const name of listed) {\n\t\t\tif (allowed.offered && asking.has(name)) continue;\n\t\t\tconst t = asking.get(name);\n\t\t\trows.push({\n\t\t\t\tname,\n\t\t\t\tshown: t?.title ?? name,\n\t\t\t\tdestructive: t?.destructive === true,\n\t\t\t\toffOnly: true,\n\t\t\t});\n\t\t}\n\t\tconst showAll = allowed.offered || everything;\n\t\tbox.hidden = rows.length === 0 && !everything;\n\t\tif (box.hidden) return;\n\t\tif (!box.hasChildNodes()) box.append(title, list, all.label, note);\n\t\tconst names = new Set(rows.map((r) => r.name));\n\t\tfor (const [name, { label }] of switches) {\n\t\t\tif (names.has(name)) continue;\n\t\t\tlabel.remove();\n\t\t\tswitches.delete(name);\n\t\t}\n\t\trows.forEach((row, i) => {\n\t\t\tlet entry = switches.get(row.name);\n\t\t\tif (entry === undefined) {\n\t\t\t\tconst name = el(doc, \"span\");\n\t\t\t\tconst mark = el(doc, \"small\", {\n\t\t\t\t\tclassName: \"tab-mcp-destructive\",\n\t\t\t\t\ttext: s.destructive,\n\t\t\t\t});\n\t\t\t\tconst made = switchOf(\n\t\t\t\t\tdoc,\n\t\t\t\t\tel(doc, \"span\", {}, name, \" \", mark),\n\t\t\t\t\t(turnedOn) => {\n\t\t\t\t\t\tif (!turnedOn) allowed.ask(grantId, row.name);\n\t\t\t\t\t\telse if (switches.get(row.name)?.offOnly === false)\n\t\t\t\t\t\t\tallowed.allow(grantId, row.name);\n\t\t\t\t\t\trender(); // also when nothing changed: the switch says the truth\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tentry = { ...made, name, mark, offOnly: row.offOnly };\n\t\t\t\tswitches.set(row.name, entry);\n\t\t\t}\n\t\t\tentry.offOnly = row.offOnly;\n\t\t\tconst shown = visible(row.shown);\n\t\t\tentry.name.textContent = shown;\n\t\t\tentry.mark.hidden = !row.destructive;\n\t\t\tentry.input.setAttribute(\n\t\t\t\t\"aria-label\",\n\t\t\t\tformat(row.destructive ? s.allowDestructiveToolApp : s.allowToolApp, {\n\t\t\t\t\ttool: shown,\n\t\t\t\t\tapp,\n\t\t\t\t}),\n\t\t\t);\n\t\t\t// What runs without asking now: also every tool under \"everything\".\n\t\t\tentry.input.checked = everything || on.has(row.name);\n\t\t\tentry.input.disabled = everything;\n\t\t\tif (list.children[i] !== entry.label)\n\t\t\t\tlist.insertBefore(entry.label, list.children[i] ?? null);\n\t\t});\n\t\tall.label.hidden = note.hidden = !showAll;\n\t\tall.input.checked = everything;\n\t};\n\treturn { box, render };\n}\n\n/**\n * The labels of the apps behind these grants, each once: an app can hold\n * more than one grant (paired twice), and is still one app.\n */\nfunction appLabels(grants: readonly Grant[], s: DialogStrings): string[] {\n\treturn [...new Set(grants.map((g) => clientLabel(g.client, s)))];\n}\n\n/**\n * Why connecting failed, in the user's words (CU 4). The error itself, with\n * the relay's wording, goes to the console. Without a `reason` it never\n * started (no user action, cancelled): just not connected.\n */\nfunction connectFailure(error: unknown, s: DialogStrings): string {\n\tconsole.warn(\"tab-mcp: could not connect.\", error);\n\tconst reason = (error as { reason?: DisconnectReason } | null)?.reason;\n\tif (reason === undefined) return s.notConnected;\n\tif (reason === \"network\") return s.unreachable;\n\tif (reason === \"rate_limited\") return s.rateLimited;\n\treturn s.refused;\n}\n\n/** Why the page was disconnected, in the user's words (CU 4). */\nfunction disconnectedText(reason: DisconnectReason, s: DialogStrings): string {\n\tswitch (reason) {\n\t\tcase \"expired\":\n\t\tcase \"idle\":\n\t\t\treturn s.ended;\n\t\tcase \"user\":\n\t\t\treturn s.disconnected;\n\t\tcase \"network\":\n\t\tcase \"heartbeat\":\n\t\tcase \"shutdown\":\n\t\t\treturn s.lost;\n\t\tcase \"rate_limited\":\n\t\t\treturn s.rateLimited;\n\t\tdefault:\n\t\t\treturn s.closed;\n\t}\n}\n\n/**\n * With identity binding: what stands between the user and the address until\n * the relay knows who is signed in (CU 7). `undefined` once it does.\n */\nfunction signInText(mcp: TabMcp, s: DialogStrings): string | undefined {\n\tswitch (mcp.identity) {\n\t\tcase \"bound\":\n\t\t\treturn undefined;\n\t\tcase \"pending\":\n\t\t\treturn s.checkingSignIn;\n\t\tcase \"refused\":\n\t\t\treturn mcp.identityMessage\n\t\t\t\t? format(s.signInRefusedWhy, { reason: mcp.identityMessage })\n\t\t\t\t: s.signInRefused;\n\t\tdefault:\n\t\t\treturn s.signInFirst;\n\t}\n}\n\n/** The document and texts of the connect dialog per `TabMcp`, once it was opened. */\nconst watched = new WeakMap<TabMcp, { doc: Document; ui?: DialogOptions }>();\n\n/**\n * Once a page has opened the connect dialog, the default UI also says when\n * the page loses its address (`replaced`), in that dialog's document.\n */\nfunction watchReplaced(mcp: TabMcp, doc: Document, ui?: DialogOptions): void {\n\tconst known = watched.has(mcp);\n\twatched.set(mcp, ui === undefined ? { doc } : { doc, ui });\n\tif (known) return;\n\tmcp.addEventListener(\"replaced\", (event) => {\n\t\tconst current = watched.get(mcp);\n\t\t// Not when the page already went on (a New address or connect since).\n\t\tif (current !== undefined && mcp.state === \"disconnected\")\n\t\t\treplacedNotice(mcp, current.doc, event.detail.sibling, current.ui);\n\t});\n}\n\n/**\n * Says that the page lost its address (`replaced`, DEC-095). A sibling tab\n * that announced it: \"Opened in another tab\", nothing to do. Otherwise a\n * warning that another tab or program took over, with \"New address\", which\n * takes the address back, disconnects its apps, connects with a new one and\n * opens the connect dialog to add it to the AI apps again.\n */\nexport function replacedNotice(\n\tmcp: TabMcp,\n\tdoc: Document,\n\tsibling: boolean,\n\tui?: DialogOptions,\n): void {\n\tconst s = stringsOf(ui);\n\t(\n\t\tdoc.querySelector(\"dialog.tab-mcp-replaced\") as HTMLDialogElement | null\n\t)?.close();\n\tconst { dialog } = newDialog(\n\t\tdoc,\n\t\t\"tab-mcp-replaced\",\n\t\ts,\n\t\tsibling ? s.replacedSiblingTitle : s.replacedTitle,\n\t);\n\tconst status = el(doc, \"p\", { className: \"tab-mcp-status\" });\n\tstatus.setAttribute(\"role\", \"status\");\n\tstatus.hidden = true;\n\tconst close = button(\n\t\tdoc,\n\t\ts.close,\n\t\t() => dialog.close(),\n\t\t\"tab-mcp-replaced-close\",\n\t\tsibling ? \"primary\" : undefined,\n\t);\n\tconst actions = el(doc, \"div\", { className: \"tab-mcp-actions\" }, close);\n\tlet first = close;\n\tif (!sibling) {\n\t\tconst fresh = button(\n\t\t\tdoc,\n\t\t\ts.newAddress,\n\t\t\t() => {\n\t\t\t\tfresh.disabled = true;\n\t\t\t\tstatus.hidden = false;\n\t\t\t\tstatus.textContent = s.gettingNewAddress;\n\t\t\t\tmcp.newAddress().then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdialog.close();\n\t\t\t\t\t\tmcp.showConnectDialog({ document: doc }).catch(() => {});\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfresh.disabled = false;\n\t\t\t\t\t\tstatus.textContent =\n\t\t\t\t\t\t\t(error as { reason?: unknown } | null)?.reason === \"replaced\"\n\t\t\t\t\t\t\t\t? s.takenOverAgain\n\t\t\t\t\t\t\t\t: format(s.tryAgainOrClose, {\n\t\t\t\t\t\t\t\t\t\treason: connectFailure(error, s),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\t\t\t\"tab-mcp-new-address\",\n\t\t\t\"primary\",\n\t\t);\n\t\tactions.append(\" \", fresh);\n\t\tfirst = fresh;\n\t}\n\tdialog.append(\n\t\tel(doc, \"p\", {\n\t\t\tclassName: \"tab-mcp-description\",\n\t\t\ttext: sibling ? s.replacedSibling : s.replaced,\n\t\t}),\n\t\tstatus,\n\t\tactions,\n\t);\n\tdialog.addEventListener(\"close\", () => dialog.remove(), { once: true });\n\tdoc.body.append(dialog);\n\tdialog.showModal();\n\tfirst.focus();\n}\n\n/**\n * How long a used code stays \"Code used\" before its replacement is shown: the\n * AI app connects a moment after the code was entered (its token request), and\n * a new code in plain view meanwhile looks as if it did not work. Only when\n * the relay says the code was used (`reason: \"used\"`); a relay that does not\n * say why gets the new code shown at once.\n */\nexport const CODE_USED_WAIT_MS = 10_000;\n\n/**\n * The \"Connect your AI app\" dialog: the address with Copy, how to add it,\n * the pairing code (with Copy) while the relay sends one, New address, and\n * the connected apps with Disconnect (and, for each, switches for the tools\n * that run without asking). Pairing is on while it is open, so closing it\n * ends the code; the connection and the address stay. Until an app is\n * connected, only a small Close (and Escape) close it. Once one is, a\n * confirmation leads, the setup moves behind \"Connect another app\" and\n * Done is the primary button. New address asks first when it would\n * disconnect connected apps. When the page loses its address (`replaced`),\n * this dialog closes and `replacedNotice` says why, from then on also while\n * it is closed.\n *\n * Its nodes are built once; one `render()` derives what is shown from `mcp`\n * and a few flags of its own after every change, so nothing flickers and\n * focus stays, or moves to the next step when its control was hidden.\n */\nexport function showConnectDialog(\n\tmcp: TabMcp,\n\tconnecting: Promise<SessionInfo>,\n\tdoc: Document,\n\tserverName = \"tools\",\n\tui?: DialogOptions,\n): Promise<void> {\n\tconst s = stringsOf(ui);\n\tconst allowed = allowedFor(mcp);\n\tconst { dialog } = newDialog(doc, \"tab-mcp-connect\", s, s.connectTitle);\n\t// Focusable from script only, for the moment before the address is shown.\n\tdialog.tabIndex = -1;\n\tconst status = el(doc, \"p\", { className: \"tab-mcp-status\" });\n\tstatus.setAttribute(\"role\", \"status\");\n\t// What a Copy did, for assistive technology only; out of sight, also\n\t// without the stylesheet. The same message twice is still a change.\n\tconst live = el(doc, \"span\", { className: \"tab-mcp-announce\" });\n\tlive.setAttribute(\"aria-live\", \"polite\");\n\tfor (const [property, value] of [\n\t\t[\"position\", \"absolute\"],\n\t\t[\"width\", \"1px\"],\n\t\t[\"height\", \"1px\"],\n\t\t[\"overflow\", \"hidden\"],\n\t\t[\"clip-path\", \"inset(50%)\"],\n\t\t[\"white-space\", \"nowrap\"],\n\t] as const)\n\t\tlive.style.setProperty(property, value);\n\tconst announce = (text: string) => {\n\t\tlive.textContent = live.textContent === text ? `${text} ` : text;\n\t};\n\n\t// The confirmation once an app is connected: what happened, what next.\n\tconst successId = `${nextId()}-success`;\n\tconst successTitle = el(doc, \"p\", { className: \"tab-mcp-success-title\" });\n\tconst successNext = el(doc, \"p\", { className: \"tab-mcp-success-next\" });\n\t// A check mark in a tinted disk, drawn by the stylesheet (CU 19).\n\tconst check = el(doc, \"span\", { className: \"tab-mcp-success-icon\" });\n\tcheck.setAttribute(\"aria-hidden\", \"true\");\n\tconst success = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-success\", id: successId },\n\t\tcheck,\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"div\",\n\t\t\t{ className: \"tab-mcp-success-text\" },\n\t\t\tsuccessTitle,\n\t\t\tsuccessNext,\n\t\t),\n\t);\n\n\tconst addressId = `${nextId()}-address`;\n\tconst label = el(doc, \"label\", { text: s.addressLabel });\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\t// Copying the address is the first step: the primary button, until an\n\t// app is connected (then Done is).\n\tconst { button: copy, reset: resetCopy } = copyButton(\n\t\tdoc,\n\t\ts,\n\t\ts.copyAddress,\n\t\t() => address.value,\n\t\t() => address.select(),\n\t\tannounce,\n\t\t\"tab-mcp-address-copy\",\n\t\t\"primary\",\n\t);\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);\n\n\t// Not next to Copy, and saying what it does (CU 23): with no app connected\n\t// it changes the address at once, also one just pasted into an AI app.\n\tconst fresh = button(\n\t\tdoc,\n\t\ts.newAddress,\n\t\t() => askNewAddress(),\n\t\t\"tab-mcp-new-address\",\n\t);\n\tconst freshBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-new-address-row\" },\n\t\tel(doc, \"small\", { text: s.newAddressNote }),\n\t\t\" \",\n\t\tfresh,\n\t);\n\t// Asked in the dialog before New address disconnects connected apps.\n\tconst questionId = `${nextId()}-new-address`;\n\tconst questionText = el(doc, \"p\", { id: questionId });\n\tconst cancelNew = button(doc, s.cancel, () => {\n\t\tasking = false;\n\t\trender();\n\t\tfresh.focus();\n\t});\n\tconst confirmNew = button(\n\t\tdoc,\n\t\ts.newAddressConfirm,\n\t\t() => getNewAddress(),\n\t\t\"tab-mcp-new-address-confirm\",\n\t\t\"danger\",\n\t);\n\tconst question = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-new-address-question\" },\n\t\tquestionText,\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\tquestion.setAttribute(\"role\", \"group\");\n\tquestion.setAttribute(\"aria-labelledby\", questionId);\n\n\t// Large, in a monospace font: a new code takes the same room.\n\tconst code = el(doc, \"strong\", { className: \"tab-mcp-code-value\" });\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\ts,\n\t\ts.copyCode,\n\t\t() => code.textContent ?? \"\",\n\t\t() => doc.getSelection()?.selectAllChildren(code),\n\t\tannounce,\n\t\t\"tab-mcp-code-copy\",\n\t);\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(\n\t\tdoc,\n\t\t\"span\",\n\t\t{},\n\t\t...fill(doc, s.codeSentence, { code }),\n\t);\n\tcodeSentence.setAttribute(\"aria-live\", \"polite\");\n\t// In the code's place while the AI app finishes connecting with it.\n\tconst codeUsed = el(doc, \"span\", { className: \"tab-mcp-code-used\" });\n\tconst codeLine = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ className: \"tab-mcp-code\" },\n\t\tcodeSentence,\n\t\tcodeUsed,\n\t\t\" \",\n\t\tcopyCode,\n\t\tel(doc, \"br\"),\n\t\tel(doc, \"small\", { className: \"tab-mcp-code-note\", text: s.codeNote }),\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: s.signIn,\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: s.help }),\n\t\tsteps,\n\t);\n\tconst guideUrl =\n\t\tui?.setup?.guide === undefined ? SETUP_GUIDE : ui.setup.guide;\n\tif (guideUrl !== null) {\n\t\tconst guide = el(doc, \"a\", { text: s.guide });\n\t\tguide.href = guideUrl;\n\t\tguide.target = \"_blank\";\n\t\tguide.rel = \"noopener noreferrer\";\n\t\thelp.append(el(doc, \"p\", { className: \"tab-mcp-guide\" }, guide));\n\t}\n\tconst instructions = ui?.setup?.instructions ?? setupInstructions;\n\n\t// Everything for adding the page to an AI app. Once one is connected, it\n\t// is behind \"Connect another app\", closed: the next code is not news.\n\t// Where to paste the address comes right after it, the code after that\n\t// (CU 23); New address last. The help stays closed (DEC-147).\n\tconst setupId = `${nextId()}-setup`;\n\tconst setup = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-setup\", id: setupId },\n\t\taddressBox,\n\t\thelp,\n\t\tcodeLine,\n\t\tsignInLine,\n\t\tfreshBox,\n\t\tquestion,\n\t);\n\tconst setupToggle = button(\n\t\tdoc,\n\t\ts.connectAnother,\n\t\t() => {\n\t\t\texpanded = !expanded;\n\t\t\trender();\n\t\t},\n\t\t\"tab-mcp-setup-toggle\",\n\t);\n\tsetupToggle.setAttribute(\"aria-controls\", setupId);\n\n\tconst appList = el(doc, \"ul\");\n\tconst appsNote = el(doc, \"p\", { className: \"tab-mcp-apps-note\" });\n\tappsNote.setAttribute(\"role\", \"status\");\n\tconst apps = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-apps\" },\n\t\tel(doc, \"h3\", { text: s.connectedHeading }),\n\t\tappList,\n\t\tappsNote,\n\t);\n\n\t// Until an app is connected, closing it is not the next step: a small\n\t// Close at the end, saying what closing does (the code stops, the address\n\t// stays). Once one is, a prominent Done replaces both.\n\tconst closeNote = el(doc, \"small\", {\n\t\tclassName: \"tab-mcp-close-note\",\n\t\ttext: s.closeNote,\n\t});\n\tconst close = button(doc, s.close, () => dialog.close(), \"tab-mcp-close\");\n\tconst done = button(\n\t\tdoc,\n\t\ts.done,\n\t\t() => dialog.close(),\n\t\t\"tab-mcp-done\",\n\t\t\"primary\",\n\t);\n\t// While not connected (it failed, the session ended, it reconnects): the\n\t// next step, from a click, so it has the user action it needs (CU 4).\n\t// While reconnecting, connect() makes the next attempt at once.\n\tconst retry = button(\n\t\tdoc,\n\t\ts.connectAgain,\n\t\t() => {\n\t\t\tmessage = undefined;\n\t\t\tmcp.connect().then(\n\t\t\t\t() => {\n\t\t\t\t\tif (doc.activeElement === close) start().focus();\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tmessage = connectFailure(error, s);\n\t\t\t\t\trender();\n\t\t\t\t\t// Focus went to Close while it connected: back to Connect\n\t\t\t\t\t// again, so a second Enter tries again instead of closing.\n\t\t\t\t\tif (doc.activeElement === close && !retry.hidden) retry.focus();\n\t\t\t\t},\n\t\t\t);\n\t\t\trender();\n\t\t},\n\t\t\"tab-mcp-retry\",\n\t\t\"primary\",\n\t);\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\tretry,\n\t\tdone,\n\t);\n\tdialog.append(success, status, apps, setupToggle, setup, actions, live);\n\n\t// The dialog's own state; the rest is read from `mcp` in `render()`.\n\t/** The setup is open while an app is connected. */\n\tlet expanded = false;\n\t/** The New address question is open. */\n\tlet asking = false;\n\t/** New address waits for the new session. */\n\tlet renewing = false;\n\t/** New address got its session; until an app pairs or it disconnects. */\n\tlet renewed = false;\n\t/** Why it is not connected, in the user's words, while it is not. */\n\tlet message: string | undefined;\n\t/** Why the last Disconnect failed, while connected. */\n\tlet appsProblem: string | undefined;\n\t/** The grants of the last render: a new one is an app that just paired. */\n\tlet grantsSeen = new Set(mcp.grants.map((g) => g.grantId));\n\t/** The address the help's steps were made for. */\n\tlet stepsFor: string | undefined;\n\t/** The code shown, and the wait after it was used (until the app connects). */\n\tlet shownCode: PairingCode | undefined;\n\tlet usedTimer: ReturnType<typeof setTimeout> | undefined;\n\t/** Shown in the connected state. */\n\tlet connectedView = false;\n\n\t// Where focus goes when its control was hidden: the next step (Done or\n\t// Connect again), else Close.\n\tconst closer = () => (connectedView ? done : retry.hidden ? close : retry);\n\t// Where focus starts: Done once connected, else the address's Copy.\n\tconst start = () => (connectedView ? done : copy);\n\n\t// One item per grant, kept while the grant is: a focused Disconnect keeps\n\t// its focus. Under it, the switches for what runs without asking.\n\tconst items = new Map<\n\t\tstring,\n\t\t{\n\t\t\titem: HTMLLIElement;\n\t\t\tdisconnect: HTMLButtonElement;\n\t\t\trenderAllowed: () => void;\n\t\t}\n\t>();\n\tconst appItem = (grant: Grant) => {\n\t\tconst app = clientLabel(grant.client, s);\n\t\tconst disconnect = button(\n\t\t\tdoc,\n\t\t\ts.disconnect,\n\t\t\t() => {\n\t\t\t\tappsProblem = undefined;\n\t\t\t\tmcp.revoke(grant.grantId).catch((error: unknown) => {\n\t\t\t\t\t// Not connected any more: the note says so already.\n\t\t\t\t\tif (mcp.state === \"connected\")\n\t\t\t\t\t\tappsProblem =\n\t\t\t\t\t\t\t(error as { code?: unknown } | null)?.code === \"store_unavailable\"\n\t\t\t\t\t\t\t\t? s.storeUnavailable\n\t\t\t\t\t\t\t\t: s.disconnectFailed;\n\t\t\t\t\trender();\n\t\t\t\t});\n\t\t\t\trender();\n\t\t\t},\n\t\t\t\"tab-mcp-disconnect\",\n\t\t\t\"danger\",\n\t\t);\n\t\t// One name per button: each list item has its own Disconnect.\n\t\tdisconnect.setAttribute(\"aria-label\", format(s.disconnectApp, { app }));\n\t\tconst switches = allowedSwitches(doc, s, allowed, grant.grantId, app);\n\t\tconst item = el(\n\t\t\tdoc,\n\t\t\t\"li\",\n\t\t\t{},\n\t\t\tel(\n\t\t\t\tdoc,\n\t\t\t\t\"span\",\n\t\t\t\t{ className: \"tab-mcp-app\" },\n\t\t\t\tformat(s.appConnected, { app }),\n\t\t\t),\n\t\t\t\" \",\n\t\t\tdisconnect,\n\t\t\tswitches.box,\n\t\t);\n\t\treturn { item, disconnect, renderAllowed: switches.render };\n\t};\n\n\t/** The steps for `address` in the help, made again when it changes. */\n\tconst renderSteps = (session: SessionInfo) => {\n\t\tif (stepsFor === session.address) return;\n\t\tstepsFor = session.address;\n\t\tsteps.replaceChildren(\n\t\t\t...instructions(serverName, session.address).map(\n\t\t\t\t({ app, text: how, command, note }) => {\n\t\t\t\t\tconst item = el(\n\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\"li\",\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tel(doc, \"strong\", { text: `${app}:` }),\n\t\t\t\t\t\t` ${how}`,\n\t\t\t\t\t);\n\t\t\t\t\tif (command !== undefined) {\n\t\t\t\t\t\t// A block with its own Copy, like the code.\n\t\t\t\t\t\tconst text = el(doc, \"pre\", { text: command });\n\t\t\t\t\t\ttext.dir = \"ltr\";\n\t\t\t\t\t\tconst { button: copyCommand } = copyButton(\n\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\ts,\n\t\t\t\t\t\t\tformat(s.copyCommand, { app }),\n\t\t\t\t\t\t\t() => text.textContent ?? \"\",\n\t\t\t\t\t\t\t() => doc.getSelection()?.selectAllChildren(text),\n\t\t\t\t\t\t\tannounce,\n\t\t\t\t\t\t\t\"tab-mcp-command-copy\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\titem.append(\n\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\"div\",\n\t\t\t\t\t\t\t\t{ className: \"tab-mcp-command\" },\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tcopyCommand,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (note !== undefined)\n\t\t\t\t\t\titem.append(\n\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\"small\",\n\t\t\t\t\t\t\t\t{ className: \"tab-mcp-command-note\" },\n\t\t\t\t\t\t\t\t...note.map((part) =>\n\t\t\t\t\t\t\t\t\t\"code\" in part\n\t\t\t\t\t\t\t\t\t\t? el(doc, \"code\", { text: part.code })\n\t\t\t\t\t\t\t\t\t\t: part.text,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\treturn item;\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t};\n\n\t/** The pairing code, or \"Code used\" in its place while the AI app connects. */\n\tconst renderCode = (paired: boolean) => {\n\t\tconst current = mcp.pairingCode;\n\t\tif (current === undefined || paired) {\n\t\t\t// None any more, or the app connected: the next code shows.\n\t\t\tclearTimeout(usedTimer);\n\t\t\tusedTimer = undefined;\n\t\t} else if (current.code !== shownCode?.code) {\n\t\t\tif (current.reason === \"used\") {\n\t\t\t\t// Entered just now: no new code in plain view while the AI app\n\t\t\t\t// connects; it shows if none does.\n\t\t\t\tif (usedTimer === undefined) {\n\t\t\t\t\tusedTimer = setTimeout(() => {\n\t\t\t\t\t\t// No app came: the code shows (unless another came meanwhile).\n\t\t\t\t\t\tusedTimer = undefined;\n\t\t\t\t\t\tshownCode = mcp.pairingCode;\n\t\t\t\t\t\trender();\n\t\t\t\t\t}, CODE_USED_WAIT_MS);\n\t\t\t\t\tannounce(s.codeUsed);\n\t\t\t\t}\n\t\t\t} else if (usedTimer !== undefined) {\n\t\t\t\t// Expired meanwhile: the user needs this one now.\n\t\t\t\tclearTimeout(usedTimer);\n\t\t\t\tusedTimer = undefined;\n\t\t\t}\n\t\t}\n\t\tconst used = usedTimer !== undefined;\n\t\tif (!used) {\n\t\t\t// A new code is not copied yet.\n\t\t\tif (code.textContent !== (current?.code ?? \"\")) resetCopyCode();\n\t\t\tcode.textContent = current?.code ?? \"\";\n\t\t\tshownCode = current;\n\t\t}\n\t\tcodeSentence.hidden = used;\n\t\tcopyCode.hidden = used;\n\t\tcodeUsed.hidden = !used;\n\t\tcodeUsed.textContent = used ? s.codeUsed : \"\";\n\t\treturn current !== undefined;\n\t};\n\n\t/** Shows what `mcp` and the flags say; keeps the focus on a shown control. */\n\tconst render = () => {\n\t\tconst focused = doc.activeElement;\n\t\tconst { state, session, grants } = mcp;\n\t\tconst connected = state === \"connected\";\n\t\tconst oidc = session?.pairing === \"oidc\";\n\t\t// With identity binding, the address is of no use until the relay\n\t\t// knows who is signed in to the page: the status says what is missing.\n\t\tconst signIn = oidc ? signInText(mcp, s) : undefined;\n\t\tconst shown = session !== undefined && signIn === undefined;\n\n\t\t// An app that paired just now: the setup closes again (unless the New\n\t\t// address question is open in it), and the confirmation is announced.\n\t\tconst ids = new Set(grants.map((g) => g.grantId));\n\t\tconst paired = connected && grants.some((g) => !grantsSeen.has(g.grantId));\n\t\tgrantsSeen = ids;\n\t\tif (paired) {\n\t\t\trenewed = false;\n\t\t\tif (!asking) expanded = false;\n\t\t}\n\t\t// Nobody left to disconnect: no question needed.\n\t\tconst names = appLabels(grants, s);\n\t\tif (names.length === 0 || !shown) asking = false;\n\n\t\tconnectedView = !renewing && connected && grants.length > 0;\n\t\tconst one = names.length === 1;\n\t\tsuccessTitle.textContent = format(one ? s.connectedOne : s.connectedMany, {\n\t\t\tapps: listOf(names, s),\n\t\t});\n\t\tsuccessNext.textContent = one ? s.connectedNextOne : s.connectedNextMany;\n\t\tif (connectedView) dialog.setAttribute(\"aria-describedby\", successId);\n\t\telse dialog.removeAttribute(\"aria-describedby\");\n\t\tsuccess.hidden = !connectedView;\n\n\t\t// The status line is for the setup; the confirmation says it otherwise.\n\t\tif (connected) message = undefined;\n\t\tconst appName = session?.appName;\n\t\tstatus.textContent = renewing\n\t\t\t? s.gettingNewAddress\n\t\t\t: state === \"connecting\"\n\t\t\t\t? s.connecting\n\t\t\t\t: state === \"reconnecting\"\n\t\t\t\t\t? s.reconnecting\n\t\t\t\t\t: !connected\n\t\t\t\t\t\t? (message ?? s.notConnected)\n\t\t\t\t\t\t: (signIn ??\n\t\t\t\t\t\t\t(renewed\n\t\t\t\t\t\t\t\t? s.newAddressDone\n\t\t\t\t\t\t\t\t: appName !== undefined\n\t\t\t\t\t\t\t\t\t? format(s.readyApp, { app: appName })\n\t\t\t\t\t\t\t\t\t: s.readyPage));\n\t\tstatus.hidden = connectedView;\n\n\t\t// The address, its help and New address.\n\t\tconst addressShownBefore = !addressBox.hidden;\n\t\tif (shown && address.value !== session.address) {\n\t\t\taddress.value = session.address;\n\t\t\tresetCopy();\n\t\t}\n\t\tif (shown) renderSteps(session);\n\t\taddressBox.hidden = help.hidden = freshBox.hidden = !shown;\n\t\tfresh.disabled = !connected;\n\t\tquestion.hidden = !asking;\n\t\tif (asking)\n\t\t\tquestionText.textContent = format(\n\t\t\t\tone ? s.newAddressQuestionOne : s.newAddressQuestionMany,\n\t\t\t\t{ apps: listOf(names, s) },\n\t\t\t);\n\t\tconst hasCode = renderCode(paired);\n\t\tcodeLine.hidden = oidc || !hasCode || !connected;\n\t\tsignInLine.hidden = !oidc || mcp.identity !== \"bound\";\n\n\t\tsetupToggle.hidden = !connectedView;\n\t\tsetupToggle.setAttribute(\"aria-expanded\", String(expanded));\n\t\tsetup.hidden = connectedView && !expanded;\n\t\tcopy.classList.toggle(\"tab-mcp-primary\", !connectedView);\n\n\t\t// The connected apps; only the relay can revoke, so only while connected.\n\t\tfor (const [id, { item }] of items) {\n\t\t\tif (ids.has(id)) continue;\n\t\t\titem.remove();\n\t\t\titems.delete(id);\n\t\t}\n\t\tgrants.forEach((grant, i) => {\n\t\t\tlet entry = items.get(grant.grantId);\n\t\t\tif (entry === undefined) {\n\t\t\t\tentry = appItem(grant);\n\t\t\t\titems.set(grant.grantId, entry);\n\t\t\t}\n\t\t\tentry.disconnect.disabled = !connected;\n\t\t\tentry.renderAllowed();\n\t\t\tif (appList.children[i] !== entry.item)\n\t\t\t\tappList.insertBefore(entry.item, appList.children[i] ?? null);\n\t\t});\n\t\tappsNote.textContent = connected ? (appsProblem ?? \"\") : s.disconnectNote;\n\t\tappsNote.hidden = connected && appsProblem === undefined;\n\t\tapps.hidden = grants.length === 0;\n\n\t\t// The note is about the code: only while one is shown and none connected.\n\t\tcloseNote.hidden = connectedView || codeLine.hidden;\n\t\tclose.hidden = connectedView;\n\t\tdone.hidden = !connectedView;\n\t\tretry.hidden =\n\t\t\trenewing || (state !== \"disconnected\" && state !== \"reconnecting\");\n\n\t\t// Focus never stays on a control that was hidden or removed; from the\n\t\t// New address question that closed, back to New address.\n\t\tif (\n\t\t\tfocused !== null &&\n\t\t\tfocused !== dialog &&\n\t\t\tfocused !== doc.body &&\n\t\t\t(!focused.isConnected ||\n\t\t\t\t(dialog.contains(focused) && focused.closest(\"[hidden]\") !== null))\n\t\t)\n\t\t\t(question.contains(focused) && !freshBox.hidden\n\t\t\t\t? fresh\n\t\t\t\t: closer()\n\t\t\t).focus();\n\t\t// The address showed only now: start there (or at Done), or, after a\n\t\t// New address, at its Copy.\n\t\telse if (doc.activeElement === dialog && (connectedView || shown))\n\t\t\tstart().focus();\n\t\telse if (\n\t\t\trenewed &&\n\t\t\tshown &&\n\t\t\t!addressShownBefore &&\n\t\t\tdoc.activeElement === close\n\t\t)\n\t\t\tcopy.focus();\n\t\tif (paired && connectedView)\n\t\t\tannounce(`${successTitle.textContent}. ${successNext.textContent}`);\n\t};\n\n\tconst askNewAddress = () => {\n\t\tif (mcp.state !== \"connected\") return;\n\t\tif (mcp.grants.length === 0) {\n\t\t\tgetNewAddress();\n\t\t\treturn;\n\t\t}\n\t\tasking = true;\n\t\trender();\n\t\tcancelNew.focus(); // the safe choice is the default\n\t};\n\tconst getNewAddress = () => {\n\t\trenewing = true;\n\t\trenewed = false;\n\t\t// Focus moves before the focused control is hidden.\n\t\tclose.focus();\n\t\tasking = false;\n\t\trender();\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\trenewed = true;\n\t\t\t\trender();\n\t\t\t\t// At its Copy once the new address shows (with identity binding\n\t\t\t\t// maybe only later: `render()` moves it then).\n\t\t\t\tif (!addressBox.hidden) copy.focus();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\trenewing = false;\n\t\t\t\tmessage = connectFailure(error, s);\n\t\t\t\trender();\n\t\t\t\tcloser().focus();\n\t\t\t},\n\t\t);\n\t};\n\n\t// A refusal that stops reconnecting comes as `error` (with its `reason`)\n\t// just before the `statechange` to `disconnected`: that says why it stopped.\n\tlet stoppedBy: unknown;\n\tlet wasReconnecting = mcp.state === \"reconnecting\";\n\tconst onError = (event: CustomEvent<{ error: Error }>) => {\n\t\tconst { error } = event.detail;\n\t\tif (wasReconnecting && (error as { reason?: unknown }).reason !== undefined)\n\t\t\tstoppedBy = error;\n\t};\n\tconst onState = (event: CustomEvent<StateChangeDetail>) => {\n\t\tconst { state, reason } = event.detail;\n\t\tif (reason !== undefined && reason !== \"new_address\") {\n\t\t\tmessage = disconnectedText(reason, s);\n\t\t\trenewed = false;\n\t\t}\n\t\t// Refused, or ended by the page (`disconnect()`) while it waited.\n\t\tif (state === \"disconnected\" && wasReconnecting)\n\t\t\tmessage =\n\t\t\t\tstoppedBy === undefined ? s.disconnected : connectFailure(stoppedBy, s);\n\t\twasReconnecting = state === \"reconnecting\";\n\t\tstoppedBy = undefined;\n\t\trender();\n\t};\n\n\t// The address was taken over: the notice says so instead of this dialog.\n\tconst onReplaced = () => dialog.close();\n\twatchReplaced(mcp, doc, ui);\n\tconst stopAllowed = allowed.onChange(render);\n\tmcp.addEventListener(\"statechange\", onState);\n\tmcp.addEventListener(\"pairingcode\", render);\n\tmcp.addEventListener(\"grantschange\", render);\n\tmcp.addEventListener(\"identitychange\", render);\n\tmcp.addEventListener(\"error\", onError);\n\tmcp.addEventListener(\"replaced\", onReplaced);\n\tdoc.body.append(dialog);\n\tmcp.startPairing();\n\trender();\n\tconnecting.then(render, (error: unknown) => {\n\t\tmessage = connectFailure(error, s);\n\t\trender();\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\tclearTimeout(usedTimer);\n\t\t\t\tmcp.stopPairing();\n\t\t\t\tstopAllowed();\n\t\t\t\tmcp.removeEventListener(\"statechange\", onState);\n\t\t\t\tmcp.removeEventListener(\"pairingcode\", render);\n\t\t\t\tmcp.removeEventListener(\"grantschange\", render);\n\t\t\t\tmcp.removeEventListener(\"identitychange\", render);\n\t\t\t\tmcp.removeEventListener(\"error\", onError);\n\t\t\t\tmcp.removeEventListener(\"replaced\", onReplaced);\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 Done once connected, else at the address's Copy; until the\n\t\t// address is there, at the dialog itself (its title is read out), not\n\t\t// at Close.\n\t\tif (connectedView || !addressBox.hidden) start().focus();\n\t\telse dialog.focus();\n\t});\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,QAAQ,CAChB,KACA,MACA,UACuD;AAAA,EACvD,MAAM,QAAQ,GAAG,KAAK,OAAO;AAAA,EAC7B,MAAM,OAAO;AAAA,EACb,MAAM,aAAa,QAAQ,QAAQ;AAAA,EACnC,MAAM,iBAAiB,UAAU,MAAM,SAAS,MAAM,OAAO,CAAC;AAAA,EAC9D,MAAM,QAAQ,GAAG,KAAK,SAAS,EAAE,WAAW,iBAAiB,GAAG,OAAO,IAAI;AAAA,EAC3E,OAAO,EAAE,OAAO,MAAM;AAAA;AAevB,SAAS,eAAe,CACvB,KACA,GACA,SACA,SACA,KAC2C;AAAA,EAC3C,MAAM,QAAQ,GAAG,KAAK,KAAK;AAAA,IAC1B,WAAW;AAAA,IACX,IAAI,GAAG,OAAO;AAAA,IACd,MAAM,EAAE;AAAA,EACT,CAAC;AAAA,EACD,MAAM,OAAO,GAAG,KAAK,OAAO,EAAE,WAAW,mBAAmB,CAAC;AAAA,EAE7D,MAAM,MAAM,S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,oBAAoB,YAAY,UAAU;AAAA,MAC9C,OAAO,OAAO;AAAA,MACd,QAAQ;AAAA,OAET,EAAE,MAAM,KAAK,CACd;AAAA,IACA,OAAO,UAAU;AAAA,IAIjB,IAAI,iBAAiB,CAAC,WAAW;AAAA,MAAQ,MAAM,EAAE,MAAM;AAAA,IACvD;AAAA,MAAK,OAAO,MAAM;AAAA,GAClB;AAAA;",
8
+ "debugId": "90A68AE264A1104964756E2164756E21",
9
+ "names": []
10
+ }
package/connect.d.ts CHANGED
@@ -23,8 +23,8 @@ export declare const CODE_USED_WAIT_MS = 10000;
23
23
  /**
24
24
  * The "Connect your AI app" dialog: the address with Copy, how to add it,
25
25
  * the pairing code (with Copy) while the relay sends one, New address, and
26
- * the connected apps with Disconnect (and the tools allowed until reload
27
- * for each, with Ask again). Pairing is on while it is open, so closing it
26
+ * the connected apps with Disconnect (and, for each, switches for the tools
27
+ * that run without asking). Pairing is on while it is open, so closing it
28
28
  * ends the code; the connection and the address stay. Until an app is
29
29
  * connected, only a small Close (and Escape) close it. Once one is, a
30
30
  * confirmation leads, the setup moves behind "Connect another app" and
@@ -743,7 +743,7 @@ function createMcpHandler(options) {
743
743
 
744
744
  // src/protocol.ts
745
745
  var SUBPROTOCOL = "tab-mcp.v1";
746
- var CODE_REASONS = new Set(["start", "used", "locked", "expired"]);
746
+ var CODE_REASONS = new Set(["start", "used", "expired"]);
747
747
  function isObject3(v) {
748
748
  return typeof v === "object" && v !== null && !Array.isArray(v);
749
749
  }
@@ -1203,13 +1203,6 @@ async function addressIdOf(secret, subtle = globalThis.crypto?.subtle ?? null) {
1203
1203
  return;
1204
1204
  }
1205
1205
  }
1206
- function withAddress(url, address) {
1207
- if (address === undefined)
1208
- return url;
1209
- const u = new URL(url);
1210
- u.searchParams.set("a", address);
1211
- return u.href;
1212
- }
1213
1206
 
1214
1207
  // src/connection.ts
1215
1208
  function callFromWebMcp(host, tool, input, signal) {
@@ -1229,8 +1222,7 @@ var CLOSE_REASONS = {
1229
1222
  4003: "heartbeat",
1230
1223
  4004: "shutdown",
1231
1224
  4005: "replaced",
1232
- 4008: "rate_limited",
1233
- 4009: "policy"
1225
+ 4008: "rate_limited"
1234
1226
  };
1235
1227
  var BYE_REASONS = {
1236
1228
  replaced: "replaced",
@@ -1462,17 +1454,13 @@ function openConnection(host, url, secret, options = {}) {
1462
1454
  fail(refused(`The relay speaks ${ws.protocol}, not ${SUBPROTOCOL}.`, "policy"));
1463
1455
  return;
1464
1456
  }
1465
- const hello = {
1457
+ send({
1466
1458
  type: "hello",
1467
1459
  library: host.library,
1468
- page: { title: "" },
1469
- secret
1470
- };
1471
- if (host.appName !== undefined)
1472
- hello.app = { name: host.appName };
1473
- if (revokeAll)
1474
- hello.revokeAll = true;
1475
- send(hello);
1460
+ app: host.appName === undefined ? { id: host.app } : { id: host.app, name: host.appName },
1461
+ secret,
1462
+ ...revokeAll ? { revokeAll: true } : {}
1463
+ });
1476
1464
  });
1477
1465
  ws.addEventListener("message", (event) => {
1478
1466
  if (typeof event.data !== "string")
@@ -1522,9 +1510,8 @@ export {
1522
1510
  compileRegistry,
1523
1511
  openConnection,
1524
1512
  pieces,
1525
- servePort,
1526
- withAddress
1513
+ servePort
1527
1514
  };
1528
1515
 
1529
- //# debugId=F72380915EFCE0FC64756E2164756E21
1530
- //# sourceMappingURL=connection-g91xjjgm.js.map
1516
+ //# debugId=159BA8A8F36DAAB264756E2164756E21
1517
+ //# sourceMappingURL=connection-gang7f5x.js.map