@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,34 +1,152 @@
1
1
  /**
2
- * The tools a user chose "Allow until reload" for, per AI app (grant), kept
3
- * in memory for the page's lifetime. An entry goes when its grant goes, when
4
- * the user resets it in the connect dialog, or when its tool is gone. A tool
5
- * registered again as it was (React's `useTool` does that on a remount) keeps
6
- * it; one whose title or description changed, what the user saw when
7
- * allowing it, is asked again.
2
+ * The tools that run without asking, per AI app (grant), DEC-096 and
3
+ * DEC-200: the ones the user allowed one by one, each with what the user
4
+ * saw of it (title and description; a tool that changed since is asked
5
+ * again and leaves the list), and "everything", which covers every tool of
6
+ * the page, also ones the user has not seen.
7
+ *
8
+ * Kept in the page's `storage` under the secret's key with `#allowed`, so
9
+ * that they outlive a reload; in memory with `alwaysAllow: "until-reload"`,
10
+ * with `storage: null` and without a relay. Storage is read first on every
11
+ * question, so that a change in another tab of the same address counts at
12
+ * once (only one tab at a time holds the connection, DEC-095).
13
+ *
14
+ * An allowance ends with its grant, and only on what the relay says: the
15
+ * grants of a new session, a removed grant, `newAddress()` (the relay
16
+ * revoked them all). A dropped connection, or a page that has not connected
17
+ * yet, keeps them: `grantschange` does not fire then. They also belong to
18
+ * the address secret they were made under, so a new secret (`newAddress()`
19
+ * here or in another tab) ends them even where nothing listened.
20
+ *
21
+ * Out of the core: the confirmation (`confirm.ts`, which the core loads for
22
+ * every consequential call), the connect dialog and
23
+ * `@ractive-ch/tab-mcp-client/allowed` import it.
8
24
  */
9
25
  import type { TabMcp } from "./tab-mcp.js";
10
26
  import type { ConfirmRequest } from "./types.js";
27
+ /** What the user saw of a tool: its name, title and description. */
11
28
  type ToolSeen = ConfirmRequest["tool"];
12
- export declare class AlwaysAllowed {
13
- #private;
14
- has(grantId: string, tool: ToolSeen): boolean;
15
- add(grantId: string, tool: ToolSeen): void;
16
- /** The tools allowed for a grant (title, else name), in the order allowed. */
29
+ /** A tool as the registry or a call names it. */
30
+ type ToolNow = {
31
+ name: string;
32
+ title?: string | undefined;
33
+ description: string;
34
+ };
35
+ /** A tool that asks before it runs, for a page's switch. */
36
+ export interface AllowedTool {
37
+ name: string;
38
+ title?: string;
39
+ description: string;
40
+ /** Marked `destructiveHint`: it may delete or overwrite. */
41
+ destructive: boolean;
42
+ }
43
+ /**
44
+ * The tools that run without asking, per connected AI app (`Grant.grantId`),
45
+ * for a page that draws its own switches: `allowedTools(mcp)` of
46
+ * `@ractive-ch/tab-mcp-client/allowed`. The library's dialogs use the same.
47
+ * The methods are bound: `const { allow } = allowedTools(mcp)` works. The
48
+ * queries (`tools`, `list`, `has`, `everything`) only read: safe while
49
+ * drawing.
50
+ */
51
+ export interface AllowedTools {
52
+ /**
53
+ * `true`: kept in the page's `storage` until the app is disconnected;
54
+ * `false`: in memory, until the page is reloaded or the app is
55
+ * disconnected (`alwaysAllow: "until-reload"`, `storage: null`).
56
+ */
57
+ readonly kept: boolean;
58
+ /**
59
+ * The page's tools that ask before they run (`consequentialHint`, callable
60
+ * by AI apps through the relay), in the order registered.
61
+ */
62
+ tools(): AllowedTool[];
63
+ /**
64
+ * The names of the tools allowed one by one for this app, in the order
65
+ * allowed; also one that is not registered right now (it runs without
66
+ * asking again once it is back unchanged). One registered now with another
67
+ * title or description than the user allowed is not in it (it asks).
68
+ */
17
69
  list(grantId: string): string[];
18
- /** Ask again for every tool of a grant. */
70
+ /**
71
+ * Whether a call of this tool by this app runs without asking now:
72
+ * "everything" is on, or the tool is allowed and registered unchanged.
73
+ */
74
+ has(grantId: string, name: string): boolean;
75
+ /**
76
+ * Allow one tool for this app from now on, as it is registered now (its
77
+ * title and description). Nothing happens for an app that is not in
78
+ * `mcp.grants` or a tool that is not in `tools()`.
79
+ */
80
+ allow(grantId: string, name: string): void;
81
+ /**
82
+ * Ask again before this app runs this tool. While "everything" is on for
83
+ * the app, that goes off too (asking again errs towards asking); the
84
+ * other tools allowed one by one stay allowed.
85
+ */
86
+ ask(grantId: string, name: string): void;
87
+ /** Whether "Allow everything, no questions asked" is on for this app. */
88
+ everything(grantId: string): boolean;
89
+ /**
90
+ * "Allow everything, no questions asked" for this app: every tool runs
91
+ * without asking, with any arguments, also tools registered later, changed
92
+ * ones and destructive ones. Turning it on does nothing for an app that
93
+ * is not in `mcp.grants`.
94
+ */
95
+ setEverything(grantId: string, on: boolean): void;
96
+ /** Ask again for everything of this app: its tools and "everything". */
19
97
  forget(grantId: string): void;
20
- /** Forget every grant not in `grantIds`. */
21
- keepGrants(grantIds: Iterable<string>): void;
22
- /** Forget every tool not in `names`. */
23
- keepTools(names: Iterable<string>): void;
24
- /** Calls `listener` on every change; returns what stops it. */
98
+ /**
99
+ * Calls `listener` on every change of the allowances (also one in
100
+ * another tab of the same address) and of `tools()`; returns what stops it.
101
+ */
25
102
  onChange(listener: () => void): () => void;
26
103
  }
27
104
  /**
28
- * The tools allowed until reload of `mcp`, made on first use. Its grants
29
- * and tools are followed: a tool's absence counts only after the current
30
- * task, so that one unregistered and registered again at once (React) keeps
31
- * its entries.
105
+ * The allowances of one `TabMcp`. The public methods are arrow fields, so
106
+ * that they work taken off the object; the queries never write.
107
+ */
108
+ export declare class Allowances implements AllowedTools {
109
+ #private;
110
+ readonly kept: boolean;
111
+ /** The library's dialogs offer allowing (`alwaysAllow` on). */
112
+ readonly offered: boolean;
113
+ constructor(mcp: TabMcp);
114
+ readonly tools: () => AllowedTool[];
115
+ readonly list: (grantId: string) => string[];
116
+ readonly has: (grantId: string, name: string) => boolean;
117
+ /**
118
+ * Whether this call runs without asking: "everything", or this tool as
119
+ * the user saw it. Only reads: a tool that changed since asks, and leaves
120
+ * the list when the registry or another tab's change is seen
121
+ * (`toolsChanged`).
122
+ */
123
+ allows(grantId: string, tool: ToolNow): boolean;
124
+ readonly allow: (grantId: string, name: string) => void;
125
+ /** Allow `tool` as the user saw it, for an app the relay still lists. */
126
+ keep(grantId: string, tool: ToolSeen): void;
127
+ readonly ask: (grantId: string, name: string) => void;
128
+ readonly everything: (grantId: string) => boolean;
129
+ readonly setEverything: (grantId: string, on: boolean) => void;
130
+ readonly forget: (grantId: string) => void;
131
+ /**
132
+ * Only the grants the relay lists now: the others ended. What was kept
133
+ * under another secret is dropped from storage too (it allowed nothing
134
+ * already).
135
+ */
136
+ keepGrants(grantIds: Iterable<string>): void;
137
+ /**
138
+ * The registry changed, or another tab changed the allowances: a tool
139
+ * registered with another title or description than the user saw leaves
140
+ * every list. One that is not registered stays (a reload registers them
141
+ * all again, a page may offer some only on some views). Tells the
142
+ * listeners in any case.
143
+ */
144
+ toolsChanged(): void;
145
+ readonly onChange: (listener: () => void) => (() => void);
146
+ }
147
+ /**
148
+ * The allowances of `mcp`, made on first use. They follow its grants (only
149
+ * when the relay names them, see above) and its tools.
32
150
  */
33
- export declare function allowedFor(mcp: TabMcp): AlwaysAllowed;
151
+ export declare function allowedFor(mcp: TabMcp): Allowances;
34
152
  export {};
@@ -0,0 +1,4 @@
1
+ import{r}from"./tab-mcp-client-6gcmd7n8.min.js";function e(o){return r(o)}export{e as allowedTools};
2
+
3
+ //# debugId=276A38D7EC2846AF64756E2164756E21
4
+ //# sourceMappingURL=allowed.min.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/allowed.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * `@ractive-ch/tab-mcp-client/allowed`: the tools that run without asking,\n * per connected AI app, for a page that draws its own switches (\"always\n * allow this tool\", \"allow everything, no questions asked\"). The library's\n * dialogs use the same allowances. An entry of its own, out of the core\n * (DEC-200).\n *\n * ```ts\n * import { allowedTools } from \"@ractive-ch/tab-mcp-client/allowed\";\n * const allowed = allowedTools(mcp);\n * for (const tool of allowed.tools()) {\n * box.checked = allowed.has(grant.grantId, tool.name);\n * box.onchange = () => box.checked ? allowed.allow(grant.grantId, tool.name) : allowed.ask(grant.grantId, tool.name);\n * }\n * ```\n */\n\nimport {\n\ttype AllowedTool,\n\ttype AllowedTools,\n\tallowedFor,\n} from \"./always-allowed.ts\";\nimport type { TabMcp } from \"./tab-mcp.ts\";\n\nexport type { AllowedTool, AllowedTools };\n\n/**\n * The allowances of `mcp`: one object per `TabMcp`, the same for every\n * call. Kept in its `storage` next to the address secret until the app is\n * disconnected (in memory with `storage: null` or `alwaysAllow:\n * \"until-reload\"`); they end with the app's grant, as the relay reports it,\n * and with `newAddress()`. A call they allow runs without asking, with the\n * library's dialog and with the page's own `onConfirm` alike.\n */\nexport function allowedTools(mcp: TabMcp): AllowedTools {\n\treturn allowedFor(mcp);\n}\n"
6
+ ],
7
+ "mappings": "gDAkCO,SAAS,CAAY,CAAC,EAA2B,CACvD,OAAO,EAAW,CAAG",
8
+ "debugId": "276A38D7EC2846AF64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ import{a,t,o,e,n,s,d,l}from"./tab-mcp-client-2vx9mcww.min.js";import{r}from"./tab-mcp-client-6gcmd7n8.min.js";function ee(u){try{return s(JSON.stringify(u,null,2))}catch{return}}var ne=750,te=500,J=new WeakMap;function K(u,i,b={}){if(u.signal.aborted)return Promise.resolve("deny");let p=J.get(i);if(p===void 0)p={shown:!1,waiting:[]},J.set(i,p);let f=p,c=()=>{let g=f.waiting.shift();f.shown=g!==void 0,g?.(),f.changed?.()},D=()=>{try{return ie(u,i,b,f,c)}catch(g){return c(),Promise.reject(g)}};if(!f.shown)return f.shown=!0,D();return new Promise((g)=>{let L=()=>{if(u.signal.removeEventListener("abort",v),b.allowedNow?.()===!0){g("allow"),c();return}g(D())},v=()=>{f.waiting.splice(f.waiting.indexOf(L),1),f.changed?.(),g("deny")};u.signal.addEventListener("abort",v,{once:!0}),f.waiting.push(L),f.changed?.()})}function ie(u,i,b,p,f){let c=b.strings??a(void 0),D=b.allowDelayMs??ne,g=u.tool.title??u.tool.name,L=d(u.client,c),v={tool:g,client:L},{dialog:y,id:j}=l(i,"tab-mcp-confirm",c,...o(i,c.confirmTitle,v)),S=e(i,"p",{className:"tab-mcp-waiting"}),H=()=>{let w=p.waiting.length;S.hidden=w===0,S.textContent=w===1?c.waitingOne:t(c.waitingMany,{n:String(w)})};p.changed=H,H();let z=n(i,c.deny,()=>y.close("deny"),"tab-mcp-deny","primary"),B=(w,_,O)=>{let A=n(i,w,()=>{if(!A.disabled)y.close(_)},O);return A},N=[B(c.allow,"allow","tab-mcp-allow")],I=[],W=b.alwaysAllow;if(W===!0||W==="until-reload"){let w=W===!0;N.unshift(B(w?c.alwaysAllow:c.allowUntilReload,"always","tab-mcp-always")),I.push(e(i,"p",{className:"tab-mcp-always-note"},...o(i,w?c.alwaysAllowNote:c.allowUntilReloadNote,v)))}let Y=e(i,"div",{className:"tab-mcp-actions"},z,...N.flatMap((w)=>[" ",w])),x=!1,Q=!1,k=()=>{for(let w of N)w.disabled=!(x&&Q)};k();let T=ee(u.arguments),h=e(i,"pre",{className:"tab-mcp-arguments",id:`${j}-arguments`,text:T??c.argumentsHidden});if(T===void 0)for(let w of[...N,...I])w.hidden=!0;h.dir="ltr",h.style.setProperty("white-space","pre-wrap"),h.style.setProperty("overflow-wrap","anywhere"),h.style.setProperty("max-height","var(--tab-mcp-arguments-height, min(50vh, 24rem))"),h.style.setProperty("overflow","auto"),h.hidden=Object.keys(u.arguments).length===0;let M=e(i,"p",{className:"tab-mcp-scroll-note",text:c.scrollToAllow});M.hidden=!0;let U=e(i,"p",{id:`${j}-who`},...o(i,c.confirmWho,v));y.setAttribute("aria-describedby",T!==void 0&&!h.hidden&&T.length<=te?`${U.id} ${h.id}`:U.id),y.append(U,e(i,"p",{className:"tab-mcp-description",text:u.tool.description}),h,M,Y,...I,S),i.body.append(y);let P=i.defaultView;return new Promise((w,_)=>{let O=()=>y.close("deny");u.signal.addEventListener("abort",O,{once:!0});let A,C,F=()=>{if(C!==void 0&&i.title===C.shown)i.title=C.page;C=void 0},X=()=>{if(i.visibilityState!=="hidden")F();else if(C===void 0)C={page:i.title,shown:`${c.titlePrefix}${i.title}`},i.title=C.shown},E=(m)=>{if(m?.type==="close"&&m.target===y)return;if(X(),clearTimeout(A),A=void 0,x=!1,k(),m?.type==="blur"||i.visibilityState==="hidden"||!i.hasFocus())return;A=setTimeout(()=>{x=!0,k()},D)},R=()=>{if(Q)return;if(h.scrollTop+h.clientHeight<h.scrollHeight-2){M.hidden=!1,h.tabIndex=0;return}Q=!0,M.hidden=!0,k()},V=(m)=>{if(x)return;let q=m.target?.localName==="button";if(m.key==="Escape"||q&&(m.key==="Enter"||m.key===" "))m.preventDefault()},Z=(m)=>{if(!x)m.preventDefault()};i.addEventListener("visibilitychange",E),i.addEventListener("close",E,!0),P?.addEventListener("focus",E),P?.addEventListener("blur",E),P?.addEventListener("resize",R),h.addEventListener("scroll",R),y.addEventListener("keydown",V),y.addEventListener("keyup",V),y.addEventListener("cancel",Z);let G=()=>{if(clearTimeout(A),F(),i.removeEventListener("visibilitychange",E),i.removeEventListener("close",E,!0),P?.removeEventListener("focus",E),P?.removeEventListener("blur",E),P?.removeEventListener("resize",R),u.signal.removeEventListener("abort",O),y.remove(),p.changed===H)p.changed=void 0};y.addEventListener("close",()=>{let m=y.returnValue;G(),w(m==="allow"||m==="always"?m:"deny"),f()},{once:!0});try{y.showModal()}catch(m){G(),_(m),f();return}z.focus(),E(),R()})}function se(u,i,b,p){let{client:f}=i,c=a(p);if(f.kind!=="relay")return K(i,b,{strings:c}).then((v)=>v==="allow");let{grantId:D}=f,g=r(u),L=()=>g.allows(D,i.tool);if(L())return Promise.resolve(!0);return K(i,b,{strings:c,alwaysAllow:g.offered&&(g.kept||"until-reload"),allowedNow:L}).then((v)=>{if(v==="always")g.keep(D,i.tool);return v!=="deny"})}function ae(u,i,b){let{client:p}=i;if(p.kind==="relay"&&r(u).allows(p.grantId,i.tool))return Promise.resolve(!0);if(b===void 0)return u.confirmInPage(i);return Promise.resolve().then(()=>b(i)).then((f)=>f==="unanswered"?f:f===!0)}export{ae as confirmCall,se as confirmInPage};
2
+
3
+ //# debugId=296601402C8F7BB564756E2164756E21
4
+ //# sourceMappingURL=confirm-f36n8xj5.min.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/confirm.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The confirmation of consequential tools, loaded on demand: a `<dialog>`\n * per call, one shown at a time per document, and Always allow (or Allow\n * until reload) for the tools a user allows (`always-allowed.ts`).\n */\n\nimport { allowedFor } from \"./always-allowed.ts\";\nimport {\n\tbutton,\n\tclientLabel,\n\tel,\n\tfill,\n\tformat,\n\tnewDialog,\n\tstringsOf,\n\tvisible,\n} from \"./dialog.ts\";\nimport type { DialogStrings } from \"./strings.ts\";\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type {\n\tConfirmAnswer,\n\tConfirmHandler,\n\tConfirmRequest,\n\tDialogOptions,\n} from \"./types.ts\";\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/**\n * How long \"Allow\" stays disabled after the confirmation is shown, while the\n * page is visible and focused (CU 17: a constant; tests pass `allowDelayMs`).\n */\nexport const ALLOW_DELAY_MS = 750;\n\n/** The user's answer: \"always\" allows this tool for this AI app (Always allow, or until reload). */\nexport type DialogAnswer = \"allow\" | \"always\" | \"deny\";\n\n/** Arguments up to this many characters are read out with the question. */\nconst DESCRIBED_ARGUMENTS = 500;\n\n/** Options of `confirmDialog`. */\nexport interface ConfirmDialogOptions {\n\t/** Tests only: another delay than {@link ALLOW_DELAY_MS}. */\n\tallowDelayMs?: number | undefined;\n\t/**\n\t * Offer a third button: `true` \"Always allow\" (kept until the app is\n\t * disconnected), `\"until-reload\"` \"Allow until reload\" (kept in memory).\n\t */\n\talwaysAllow?: boolean | \"until-reload\" | undefined;\n\t/** Asked when a waiting call's turn comes: `true` answers \"allow\" unseen. */\n\tallowedNow?: () => boolean;\n\tstrings?: DialogStrings;\n}\n\n/**\n * The confirmations of one document: one is shown at a time, the others\n * wait in order, so that the click that answered one cannot answer the next\n * (each starts its own delay when it is shown).\n */\ninterface ConfirmQueue {\n\tshown: boolean;\n\twaiting: (() => void)[];\n\t/** Updates the shown dialog's line about the calls that wait. */\n\tchanged?: (() => void) | undefined;\n}\n\nconst queues = new WeakMap<Document, ConfirmQueue>();\n\n/**\n * Ask whether a consequential tool may run. \"Always allow\" (or \"Allow until\n * reload\") is offered only with `alwaysAllow` (DEC-096, DEC-200); never\n * \"allow everything\": that is a deliberate act in the connect dialog, not\n * an answer to one question. One confirmation is shown at a time per\n * document; the others wait their turn, and a call cancelled while it waits\n * is never shown. \"Allow\" and \"Always allow\" stay disabled until the\n * page has been visible and focused for 750 ms while the dialog is open and\n * is the top one, so a click meant for the page, the click that brings the\n * tab or window back, or the one that closed another dialog, cannot\n * approve; leaving the page disables them again. They also wait until the\n * arguments have been scrolled to their end. Before the delay has run out,\n * Enter or Space on a button and Escape are ignored, so typing meant for the\n * page cannot refuse either. Everything else (Don't allow, Escape, an\n * aborted call) is \"deny\". `allowedNow` is asked when a waiting call's turn\n * comes: `true` (the user allowed it meanwhile) answers \"allow\"\n * without showing it.\n */\nexport function confirmDialog(\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: ConfirmDialogOptions = {},\n): Promise<DialogAnswer> {\n\tif (request.signal.aborted) return Promise.resolve(\"deny\");\n\tlet queue = queues.get(doc);\n\tif (queue === undefined) {\n\t\tqueue = { shown: false, waiting: [] };\n\t\tqueues.set(doc, queue);\n\t}\n\tconst q = queue;\n\t/** The shown confirmation closed: the next one, if any. */\n\tconst next = () => {\n\t\tconst start = q.waiting.shift();\n\t\tq.shown = start !== undefined;\n\t\tstart?.();\n\t\tq.changed?.();\n\t};\n\tconst show = () => {\n\t\ttry {\n\t\t\treturn showConfirm(request, doc, options, q, next);\n\t\t} catch (error) {\n\t\t\tnext(); // not shown: the queue goes on\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t};\n\tif (!q.shown) {\n\t\tq.shown = true;\n\t\treturn show();\n\t}\n\treturn new Promise((resolve) => {\n\t\tconst start = () => {\n\t\t\trequest.signal.removeEventListener(\"abort\", onAbort);\n\t\t\tif (options.allowedNow?.() === true) {\n\t\t\t\tresolve(\"allow\");\n\t\t\t\tnext();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(show());\n\t\t};\n\t\tconst onAbort = () => {\n\t\t\tq.waiting.splice(q.waiting.indexOf(start), 1);\n\t\t\tq.changed?.();\n\t\t\tresolve(\"deny\");\n\t\t};\n\t\trequest.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tq.waiting.push(start);\n\t\tq.changed?.();\n\t});\n}\n\n/** `confirmDialog` once it is this request's turn; calls `next` when it closes. */\nfunction showConfirm(\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: ConfirmDialogOptions,\n\tqueue: ConfirmQueue,\n\tnext: () => void,\n): Promise<DialogAnswer> {\n\tconst s = options.strings ?? stringsOf(undefined);\n\tconst delay = options.allowDelayMs ?? ALLOW_DELAY_MS;\n\tconst tool = request.tool.title ?? request.tool.name;\n\tconst client = clientLabel(request.client, s);\n\tconst names = { tool, client };\n\tconst { dialog, id } = newDialog(\n\t\tdoc,\n\t\t\"tab-mcp-confirm\",\n\t\ts,\n\t\t...fill(doc, s.confirmTitle, names),\n\t);\n\tconst waiting = el(doc, \"p\", { className: \"tab-mcp-waiting\" });\n\tconst showWaiting = () => {\n\t\tconst n = queue.waiting.length;\n\t\twaiting.hidden = n === 0;\n\t\twaiting.textContent =\n\t\t\tn === 1 ? s.waitingOne : format(s.waitingMany, { n: String(n) });\n\t};\n\tqueue.changed = showWaiting;\n\tshowWaiting();\n\t// The safe choice is the default: focused, and the one that stands out.\n\tconst deny = button(\n\t\tdoc,\n\t\ts.deny,\n\t\t() => dialog.close(\"deny\"),\n\t\t\"tab-mcp-deny\",\n\t\t\"primary\",\n\t);\n\tconst approving = (text: string, answer: DialogAnswer, className: string) => {\n\t\tconst node = button(\n\t\t\tdoc,\n\t\t\ttext,\n\t\t\t() => {\n\t\t\t\tif (!node.disabled) dialog.close(answer);\n\t\t\t},\n\t\t\tclassName,\n\t\t);\n\t\treturn node;\n\t};\n\t// The approving buttons: Allow, and Always allow (or Allow until reload)\n\t// when the page offers it, saying how long it lasts.\n\tconst approve = [approving(s.allow, \"allow\", \"tab-mcp-allow\")];\n\tconst extra: HTMLElement[] = [];\n\tconst mode = options.alwaysAllow;\n\tif (mode === true || mode === \"until-reload\") {\n\t\tconst kept = mode === true;\n\t\t// Left of Allow: not where most platforms put the default (CU 11).\n\t\tapprove.unshift(\n\t\t\tapproving(\n\t\t\t\tkept ? s.alwaysAllow : s.allowUntilReload,\n\t\t\t\t\"always\",\n\t\t\t\t\"tab-mcp-always\",\n\t\t\t),\n\t\t);\n\t\textra.push(\n\t\t\tel(\n\t\t\t\tdoc,\n\t\t\t\t\"p\",\n\t\t\t\t{ className: \"tab-mcp-always-note\" },\n\t\t\t\t...fill(doc, kept ? s.alwaysAllowNote : s.allowUntilReloadNote, names),\n\t\t\t),\n\t\t);\n\t}\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tdeny,\n\t\t...approve.flatMap((b) => [\" \", b]),\n\t);\n\t// Approving needs both: the delay ran out while the user saw the page\n\t// (`settled`), and the arguments were seen to their end (`seen`).\n\tlet settled = false;\n\tlet seen = false;\n\tconst enable = () => {\n\t\tfor (const b of approve) b.disabled = !(settled && seen);\n\t};\n\tenable();\n\tconst shown = showArguments(request.arguments);\n\tconst args = el(doc, \"pre\", {\n\t\tclassName: \"tab-mcp-arguments\",\n\t\tid: `${id}-arguments`,\n\t\ttext: shown ?? s.argumentsHidden,\n\t});\n\tif (shown === undefined) {\n\t\tfor (const node of [...approve, ...extra]) node.hidden = true;\n\t}\n\targs.dir = \"ltr\";\n\t// Inline, so the arguments stay readable in full without the stylesheet:\n\t// wrapped (also a long word, at 360 px), scrolling when long.\n\targs.style.setProperty(\"white-space\", \"pre-wrap\");\n\targs.style.setProperty(\"overflow-wrap\", \"anywhere\");\n\targs.style.setProperty(\n\t\t\"max-height\",\n\t\t\"var(--tab-mcp-arguments-height, min(50vh, 24rem))\",\n\t);\n\targs.style.setProperty(\"overflow\", \"auto\");\n\targs.hidden = Object.keys(request.arguments).length === 0;\n\t// The caller chooses the order of the keys, so what matters may come\n\t// last: below the end of the box, the user is told, and Allow waits.\n\tconst scrollNote = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-scroll-note\",\n\t\ttext: s.scrollToAllow,\n\t});\n\tscrollNote.hidden = true;\n\tconst who = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ id: `${id}-who` },\n\t\t...fill(doc, s.confirmWho, names),\n\t);\n\tdialog.setAttribute(\n\t\t\"aria-describedby\",\n\t\tshown !== undefined && !args.hidden && shown.length <= DESCRIBED_ARGUMENTS\n\t\t\t? `${who.id} ${args.id}`\n\t\t\t: who.id,\n\t);\n\tdialog.append(\n\t\twho,\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\tscrollNote,\n\t\tactions,\n\t\t...extra,\n\t\twaiting,\n\t);\n\tdoc.body.append(dialog);\n\tconst view = doc.defaultView;\n\treturn new Promise((resolve, reject) => {\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// In a hidden tab, the tab's title says that the page asks (CU 9): the\n\t\t// AI app waits meanwhile. Put back when the tab is shown or the dialog\n\t\t// closes, unless the page changed its title since.\n\t\tlet title: { page: string; shown: string } | undefined;\n\t\tconst untitle = () => {\n\t\t\tif (title !== undefined && doc.title === title.shown)\n\t\t\t\tdoc.title = title.page;\n\t\t\ttitle = undefined;\n\t\t};\n\t\tconst retitle = () => {\n\t\t\tif (doc.visibilityState !== \"hidden\") untitle();\n\t\t\telse if (title === undefined) {\n\t\t\t\ttitle = { page: doc.title, shown: `${s.titlePrefix}${doc.title}` };\n\t\t\t\tdoc.title = title.shown;\n\t\t\t}\n\t\t};\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\n\t\t// (DEC-087), and so does another dialog of the page that closes over\n\t\t// this one.\n\t\tconst arm = (event?: Event) => {\n\t\t\tif (event?.type === \"close\" && event.target === dialog) return;\n\t\t\tretitle();\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t\tsettled = false;\n\t\t\tenable();\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\tsettled = true;\n\t\t\t\tenable();\n\t\t\t}, delay);\n\t\t};\n\t\t// Scrolled to the end, or nothing to scroll (also without layout).\n\t\tconst check = () => {\n\t\t\tif (seen) return;\n\t\t\tif (args.scrollTop + args.clientHeight < args.scrollHeight - 2) {\n\t\t\t\tscrollNote.hidden = false;\n\t\t\t\targs.tabIndex = 0; // to scroll it with the keyboard\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tseen = true;\n\t\t\tscrollNote.hidden = true;\n\t\t\tenable();\n\t\t};\n\t\t// Not answered by a key before the delay has run out.\n\t\tconst guard = (event: KeyboardEvent) => {\n\t\t\tif (settled) return;\n\t\t\tconst onButton = (event.target as Element | null)?.localName === \"button\";\n\t\t\tif (\n\t\t\t\tevent.key === \"Escape\" ||\n\t\t\t\t(onButton && (event.key === \"Enter\" || event.key === \" \"))\n\t\t\t)\n\t\t\t\tevent.preventDefault();\n\t\t};\n\t\tconst onCancel = (event: Event) => {\n\t\t\tif (!settled) event.preventDefault();\n\t\t};\n\t\tdoc.addEventListener(\"visibilitychange\", arm);\n\t\tdoc.addEventListener(\"close\", arm, true); // `close` does not bubble\n\t\tview?.addEventListener(\"focus\", arm);\n\t\tview?.addEventListener(\"blur\", arm);\n\t\tview?.addEventListener(\"resize\", check);\n\t\targs.addEventListener(\"scroll\", check);\n\t\tdialog.addEventListener(\"keydown\", guard);\n\t\tdialog.addEventListener(\"keyup\", guard);\n\t\tdialog.addEventListener(\"cancel\", onCancel);\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tuntitle();\n\t\t\tdoc.removeEventListener(\"visibilitychange\", arm);\n\t\t\tdoc.removeEventListener(\"close\", arm, true);\n\t\t\tview?.removeEventListener(\"focus\", arm);\n\t\t\tview?.removeEventListener(\"blur\", arm);\n\t\t\tview?.removeEventListener(\"resize\", check);\n\t\t\trequest.signal.removeEventListener(\"abort\", onAbort);\n\t\t\tdialog.remove();\n\t\t\tif (queue.changed === showWaiting) queue.changed = undefined;\n\t\t};\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tconst value = dialog.returnValue;\n\t\t\t\tcleanup();\n\t\t\t\tresolve(value === \"allow\" || value === \"always\" ? value : \"deny\");\n\t\t\t\tnext();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\ttry {\n\t\t\tdialog.showModal();\n\t\t} catch (error) {\n\t\t\t// Never shown, so never closed: the queue must not wait for it.\n\t\t\tcleanup();\n\t\t\treject(error);\n\t\t\tnext();\n\t\t\treturn;\n\t\t}\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\tcheck();\n\t});\n}\n\n/**\n * `TabMcp.confirmInPage`: the confirmation, and the tools the user allowed\n * (`always-allowed.ts`), which run unasked. Only for an AI app through the\n * relay: an agent in the browser and a served port have no identity to\n * remember an answer for (DEC-115, DEC-124).\n */\nexport function confirmInPage(\n\tmcp: TabMcp,\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\tui?: DialogOptions,\n): Promise<boolean> {\n\tconst { client } = request;\n\tconst strings = stringsOf(ui);\n\tif (client.kind !== \"relay\")\n\t\treturn confirmDialog(request, doc, { strings }).then(\n\t\t\t(answer) => answer === \"allow\",\n\t\t);\n\tconst { grantId } = client;\n\tconst allowed = allowedFor(mcp);\n\tconst allowedNow = () => allowed.allows(grantId, request.tool);\n\tif (allowedNow()) return Promise.resolve(true);\n\t// Asked again when its turn comes: the call before it in the queue may\n\t// have been allowed meanwhile.\n\treturn confirmDialog(request, doc, {\n\t\tstrings,\n\t\talwaysAllow: allowed.offered && (allowed.kept || \"until-reload\"),\n\t\tallowedNow,\n\t}).then((answer) => {\n\t\t// Only while the grant is still there: a revoked app gets nothing\n\t\t// (`keep` checks).\n\t\tif (answer === \"always\") allowed.keep(grantId, request.tool);\n\t\treturn answer !== \"deny\";\n\t});\n}\n\n/**\n * The core's question about a consequential call: an AI app's call that the\n * user allowed runs without asking, with the dialog and with the page's own\n * `onConfirm` alike; any other goes to `onConfirm`, else to the dialog.\n * Only AI apps through the relay have a grant to allow for.\n */\nexport function confirmCall(\n\tmcp: TabMcp,\n\trequest: ConfirmRequest,\n\tonConfirm: ConfirmHandler | undefined,\n): Promise<ConfirmAnswer> {\n\tconst { client } = request;\n\tif (\n\t\tclient.kind === \"relay\" &&\n\t\tallowedFor(mcp).allows(client.grantId, request.tool)\n\t)\n\t\treturn Promise.resolve(true);\n\tif (onConfirm === undefined) return mcp.confirmInPage(request);\n\t// Anything but true or \"unanswered\" is a refusal.\n\treturn Promise.resolve()\n\t\t.then(() => onConfirm(request))\n\t\t.then((answer) => (answer === \"unanswered\" ? answer : answer === true));\n}\n"
6
+ ],
7
+ "mappings": "8GAiCA,SAAS,EAAa,CAAC,EAAmD,CACzE,GAAI,CACH,OAAO,EAAQ,KAAK,UAAU,EAAM,KAAM,CAAC,CAAC,EAC3C,KAAM,CACP,QAQK,IAAM,GAAiB,IAMxB,GAAsB,IA4BtB,EAAS,IAAI,QAoBZ,SAAS,CAAa,CAC5B,EACA,EACA,EAAgC,CAAC,EACT,CACxB,GAAI,EAAQ,OAAO,QAAS,OAAO,QAAQ,QAAQ,MAAM,EACzD,IAAI,EAAQ,EAAO,IAAI,CAAG,EAC1B,GAAI,IAAU,OACb,EAAQ,CAAE,MAAO,GAAO,QAAS,CAAC,CAAE,EACpC,EAAO,IAAI,EAAK,CAAK,EAEtB,IAAM,EAAI,EAEJ,EAAO,IAAM,CAClB,IAAM,EAAQ,EAAE,QAAQ,MAAM,EAC9B,EAAE,MAAQ,IAAU,OACpB,IAAQ,EACR,EAAE,UAAU,GAEP,EAAO,IAAM,CAClB,GAAI,CACH,OAAO,GAAY,EAAS,EAAK,EAAS,EAAG,CAAI,EAChD,MAAO,EAAO,CAEf,OADA,EAAK,EACE,QAAQ,OA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UAAW,EACb,EAAU,EAAU,CAAE,EAC5B,GAAI,EAAO,OAAS,QACnB,OAAO,EAAc,EAAS,EAAK,CAAE,SAAQ,CAAC,EAAE,KAC/C,CAAC,IAAW,IAAW,OACxB,EACD,IAAQ,WAAY,EACd,EAAU,EAAW,CAAG,EACxB,EAAa,IAAM,EAAQ,OAAO,EAAS,EAAQ,IAAI,EAC7D,GAAI,EAAW,EAAG,OAAO,QAAQ,QAAQ,EAAI,EAG7C,OAAO,EAAc,EAAS,EAAK,CAClC,UACA,YAAa,EAAQ,UAAY,EAAQ,MAAQ,gBACjD,YACD,CAAC,EAAE,KAAK,CAAC,IAAW,CAGnB,GAAI,IAAW,SAAU,EAAQ,KAAK,EAAS,EAAQ,IAAI,EAC3D,OAAO,IAAW,OAClB,EASK,SAAS,EAAW,CAC1B,EACA,EACA,EACyB,CACzB,IAAQ,UAAW,EACnB,GACC,EAAO,OAAS,SAChB,EAAW,CAAG,EAAE,OAAO,EAAO,QAAS,EAAQ,IAAI,EAEnD,OAAO,QAAQ,QAAQ,EAAI,EAC5B,GAAI,IAAc,OAAW,OAAO,EAAI,cAAc,CAAO,EAE7D,OAAO,QAAQ,QAAQ,EACrB,KAAK,IAAM,EAAU,CAAO,CAAC,EAC7B,KAAK,CAAC,IAAY,IAAW,aAAe,EAAS,IAAW,EAAK",
8
+ "debugId": "296601402C8F7BB564756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,6 @@
1
+ import{i,a,t,o,e,n,s,d,u,l,c}from"./tab-mcp-client-2vx9mcww.min.js";import{r}from"./tab-mcp-client-6gcmd7n8.min.js";function ze(m){let h=m.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"");return h===""?"tools":h}function Qe(m){try{let h=new URL(m).href;return/^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(h)?h:void 0}catch{return}}var Ve="https://ractive.ch/tab-mcp/connect/",Ke="mcp_2026_07_28";function Xe(m,h){let p=ze(m),x=Qe(h),v=(f)=>x===void 0?{}:{text:"Run:",command:f};return[{id:"claude",app:"Claude (claude.ai and the desktop app)",text:"Settings → Connectors → Add custom connector, then paste the address."},{id:"chatgpt",app:"ChatGPT",text:"On chatgpt.com: Plugins, add an MCP server with the address, then Connect. The Mac app needs more steps: see the guide."},{id:"claude-code",app:"Claude Code",text:"Add the address with claude mcp add --transport http.",...v(`claude mcp add --transport http ${p} ${x}`),note:[{text:"Then type "},{code:"/mcp"},{text:" in Claude Code and choose Authenticate."}]},{id:"codex",app:"Codex",text:`Run codex features enable ${Ke}, then add the address with codex mcp add --url and sign in with codex mcp login.`,...v(`codex features enable ${Ke}
2
+ codex mcp add ${p} --url ${x}
3
+ codex mcp login ${p}`),note:[{text:"The last line opens the sign-in that asks for the code. Start a new chat in Codex after it connects."}]}]}function Ze(m,h,p){let x=e(m,"input");return x.type="checkbox",x.setAttribute("role","switch"),x.addEventListener("change",()=>p(x.checked)),{label:e(m,"label",{className:"tab-mcp-switch"},x,h),input:x}}function dt(m,h,p,x,v){let f=e(m,"p",{className:"tab-mcp-allowed-title",id:`${i()}-allowed`,text:h.runsWithoutAsking}),L=e(m,"div",{className:"tab-mcp-switches"}),y=Ze(m,e(m,"span",{text:h.allowEverything}),(D)=>{if(!D||p.offered)p.setEverything(x,D);R()});y.label.classList.add("tab-mcp-everything"),y.input.setAttribute("aria-label",t(h.allowEverythingApp,{app:v}));let M=e(m,"small",{className:"tab-mcp-everything-note",id:`${f.id}-note`},...o(m,h.allowEverythingNote,{app:v}));y.input.setAttribute("aria-describedby",M.id);let E=e(m,"div",{className:"tab-mcp-allowed"});E.setAttribute("role","group"),E.setAttribute("aria-labelledby",f.id);let S=new Map,R=()=>{let D=p.everything(x),X=p.list(x),ie=new Set(X),Z=new Map(p.tools().map((b)=>[b.name,b])),B=[];if(p.offered)for(let b of Z.values())B.push({name:b.name,shown:b.title??b.name,destructive:b.destructive,offOnly:!1});for(let b of X){if(p.offered&&Z.has(b))continue;let U=Z.get(b);B.push({name:b,shown:U?.title??b,destructive:U?.destructive===!0,offOnly:!0})}let oe=p.offered||D;if(E.hidden=B.length===0&&!D,E.hidden)return;if(!E.hasChildNodes())E.append(f,L,y.label,M);let F=new Set(B.map((b)=>b.name));for(let[b,{label:U}]of S){if(F.has(b))continue;U.remove(),S.delete(b)}B.forEach((b,U)=>{let A=S.get(b.name);if(A===void 0){let j=e(m,"span"),te=e(m,"small",{className:"tab-mcp-destructive",text:h.destructive});A={...Ze(m,e(m,"span",{},j," ",te),(ce)=>{if(!ce)p.ask(x,b.name);else if(S.get(b.name)?.offOnly===!1)p.allow(x,b.name);R()}),name:j,mark:te,offOnly:b.offOnly},S.set(b.name,A)}A.offOnly=b.offOnly;let W=s(b.shown);if(A.name.textContent=W,A.mark.hidden=!b.destructive,A.input.setAttribute("aria-label",t(b.destructive?h.allowDestructiveToolApp:h.allowToolApp,{tool:W,app:v})),A.input.checked=D||ie.has(b.name),A.input.disabled=D,L.children[U]!==A.label)L.insertBefore(A.label,L.children[U]??null)}),y.label.hidden=M.hidden=!oe,y.input.checked=D};return{box:E,render:R}}function rt(m,h){return[...new Set(m.map((p)=>d(p.client,h)))]}function ae(m,h){console.warn("tab-mcp: could not connect.",m);let p=m?.reason;if(p===void 0)return h.notConnected;if(p==="network")return h.unreachable;if(p==="rate_limited")return h.rateLimited;return h.refused}function lt(m,h){switch(m){case"expired":case"idle":return h.ended;case"user":return h.disconnected;case"network":case"heartbeat":case"shutdown":return h.lost;case"rate_limited":return h.rateLimited;default:return h.closed}}function ut(m,h){switch(m.identity){case"bound":return;case"pending":return h.checkingSignIn;case"refused":return m.identityMessage?t(h.signInRefusedWhy,{reason:m.identityMessage}):h.signInRefused;default:return h.signInFirst}}var Te=new WeakMap;function pt(m,h,p){let x=Te.has(m);if(Te.set(m,p===void 0?{doc:h}:{doc:h,ui:p}),x)return;m.addEventListener("replaced",(v)=>{let f=Te.get(m);if(f!==void 0&&m.state==="disconnected")ft(m,f.doc,v.detail.sibling,f.ui)})}function ft(m,h,p,x){let v=a(x);h.querySelector("dialog.tab-mcp-replaced")?.close();let{dialog:f}=l(h,"tab-mcp-replaced",v,p?v.replacedSiblingTitle:v.replacedTitle),L=e(h,"p",{className:"tab-mcp-status"});L.setAttribute("role","status"),L.hidden=!0;let y=n(h,v.close,()=>f.close(),"tab-mcp-replaced-close",p?"primary":void 0),M=e(h,"div",{className:"tab-mcp-actions"},y),E=y;if(!p){let S=n(h,v.newAddress,()=>{S.disabled=!0,L.hidden=!1,L.textContent=v.gettingNewAddress,m.newAddress().then(()=>{f.close(),m.showConnectDialog({document:h}).catch(()=>{})},(R)=>{S.disabled=!1,L.textContent=R?.reason==="replaced"?v.takenOverAgain:t(v.tryAgainOrClose,{reason:ae(R,v)})})},"tab-mcp-new-address","primary");M.append(" ",S),E=S}f.append(e(h,"p",{className:"tab-mcp-description",text:p?v.replacedSibling:v.replaced}),L,M),f.addEventListener("close",()=>f.remove(),{once:!0}),h.body.append(f),f.showModal(),E.focus()}var mt=1e4;function xt(m,h,p,x="tools",v){let f=a(v),L=r(m),{dialog:y}=l(p,"tab-mcp-connect",f,f.connectTitle);y.tabIndex=-1;let M=e(p,"p",{className:"tab-mcp-status"});M.setAttribute("role","status");let E=e(p,"span",{className:"tab-mcp-announce"});E.setAttribute("aria-live","polite");for(let[g,w]of[["position","absolute"],["width","1px"],["height","1px"],["overflow","hidden"],["clip-path","inset(50%)"],["white-space","nowrap"]])E.style.setProperty(g,w);let S=(g)=>{E.textContent=E.textContent===g?`${g} `:g},R=`${i()}-success`,D=e(p,"p",{className:"tab-mcp-success-title"}),X=e(p,"p",{className:"tab-mcp-success-next"}),ie=e(p,"span",{className:"tab-mcp-success-icon"});ie.setAttribute("aria-hidden","true");let Z=e(p,"div",{className:"tab-mcp-success",id:R},ie,e(p,"div",{className:"tab-mcp-success-text"},D,X)),B=`${i()}-address`,oe=e(p,"label",{text:f.addressLabel});oe.htmlFor=B;let F=e(p,"input",{id:B,className:"tab-mcp-address-input"});F.readOnly=!0;let{button:b,reset:U}=c(p,f,f.copyAddress,()=>F.value,()=>F.select(),S,"tab-mcp-address-copy","primary"),A=e(p,"div",{className:"tab-mcp-address"},oe,F," ",b),W=n(p,f.newAddress,()=>at(),"tab-mcp-new-address"),j=e(p,"div",{className:"tab-mcp-new-address-row"},e(p,"small",{text:f.newAddressNote})," ",W),te=`${i()}-new-address`,be=e(p,"p",{id:te}),ce=n(p,f.cancel,()=>{K=!1,C(),W.focus()}),je=n(p,f.newAddressConfirm,()=>He(),"tab-mcp-new-address-confirm","danger"),ne=e(p,"div",{className:"tab-mcp-new-address-question"},be,e(p,"div",{className:"tab-mcp-actions"},ce," ",je));ne.setAttribute("role","group"),ne.setAttribute("aria-labelledby",te);let z=e(p,"strong",{className:"tab-mcp-code-value"});z.style.setProperty("user-select","all"),z.style.setProperty("-webkit-user-select","all");let{button:Le,reset:Je}=c(p,f,f.copyCode,()=>z.textContent??"",()=>p.getSelection()?.selectAllChildren(z),S,"tab-mcp-code-copy"),we=e(p,"span",{},...o(p,f.codeSentence,{code:z}));we.setAttribute("aria-live","polite");let ve=e(p,"span",{className:"tab-mcp-code-used"}),ye=e(p,"p",{className:"tab-mcp-code"},we,ve," ",Le,e(p,"br"),e(p,"small",{className:"tab-mcp-code-note",text:f.codeNote})),ke=e(p,"p",{className:"tab-mcp-sign-in",text:f.signIn}),De=e(p,"ul"),xe=e(p,"details",{className:"tab-mcp-help"},e(p,"summary",{text:f.help}),De),Ie=v?.setup?.guide===void 0?Ve:v.setup.guide;if(Ie!==null){let g=e(p,"a",{text:f.guide});g.href=Ie,g.target="_blank",g.rel="noopener noreferrer",xe.append(e(p,"p",{className:"tab-mcp-guide"},g))}let Ye=v?.setup?.instructions??Xe,Me=`${i()}-setup`,Oe=e(p,"div",{className:"tab-mcp-setup",id:Me},A,xe,ye,ke,j,ne),de=n(p,f.connectAnother,()=>{se=!se,C()},"tab-mcp-setup-toggle");de.setAttribute("aria-controls",Me);let re=e(p,"ul"),le=e(p,"p",{className:"tab-mcp-apps-note"});le.setAttribute("role","status");let $e=e(p,"div",{className:"tab-mcp-apps"},e(p,"h3",{text:f.connectedHeading}),re,le),Pe=e(p,"small",{className:"tab-mcp-close-note",text:f.closeNote}),Q=n(p,f.close,()=>y.close(),"tab-mcp-close"),ue=n(p,f.done,()=>y.close(),"tab-mcp-done","primary"),J=n(p,f.connectAgain,()=>{G=void 0,m.connect().then(()=>{if(p.activeElement===Q)Ne().focus()},(g)=>{if(G=ae(g,f),C(),p.activeElement===Q&&!J.hidden)J.focus()}),C()},"tab-mcp-retry","primary"),et=e(p,"div",{className:"tab-mcp-actions"},Pe," ",Q,J,ue);y.append(Z,M,$e,de,Oe,et,E);let se=!1,K=!1,Y=!1,ee=!1,G,pe,_e=new Set(m.grants.map((g)=>g.grantId)),Re,Ce,P,T=!1,Ue=()=>T?ue:J.hidden?Q:J,Ne=()=>T?ue:b,fe=new Map,tt=(g)=>{let w=d(g.client,f),N=n(p,f.disconnect,()=>{pe=void 0,m.revoke(g.grantId).catch((H)=>{if(m.state==="connected")pe=H?.code==="store_unavailable"?f.storeUnavailable:f.disconnectFailed;C()}),C()},"tab-mcp-disconnect","danger");N.setAttribute("aria-label",t(f.disconnectApp,{app:w}));let I=dt(p,f,L,g.grantId,w);return{item:e(p,"li",{},e(p,"span",{className:"tab-mcp-app"},t(f.appConnected,{app:w}))," ",N,I.box),disconnect:N,renderAllowed:I.render}},nt=(g)=>{if(Re===g.address)return;Re=g.address,De.replaceChildren(...Ye(x,g.address).map(({app:w,text:N,command:I,note:k})=>{let H=e(p,"li",{},e(p,"strong",{text:`${w}:`}),` ${N}`);if(I!==void 0){let O=e(p,"pre",{text:I});O.dir="ltr";let{button:q}=c(p,f,t(f.copyCommand,{app:w}),()=>O.textContent??"",()=>p.getSelection()?.selectAllChildren(O),S,"tab-mcp-command-copy");H.append(e(p,"div",{className:"tab-mcp-command"},O,q))}if(k!==void 0)H.append(e(p,"small",{className:"tab-mcp-command-note"},...k.map((O)=>("code"in O)?e(p,"code",{text:O.code}):O.text)));return H}))},st=(g)=>{let w=m.pairingCode;if(w===void 0||g)clearTimeout(P),P=void 0;else if(w.code!==Ce?.code){if(w.reason==="used"){if(P===void 0)P=setTimeout(()=>{P=void 0,Ce=m.pairingCode,C()},mt),S(f.codeUsed)}else if(P!==void 0)clearTimeout(P),P=void 0}let N=P!==void 0;if(!N){if(z.textContent!==(w?.code??""))Je();z.textContent=w?.code??"",Ce=w}return we.hidden=N,Le.hidden=N,ve.hidden=!N,ve.textContent=N?f.codeUsed:"",w!==void 0},C=()=>{let g=p.activeElement,{state:w,session:N,grants:I}=m,k=w==="connected",H=N?.pairing==="oidc",O=H?ut(m,f):void 0,q=N!==void 0&&O===void 0,qe=new Set(I.map((_)=>_.grantId)),Ee=k&&I.some((_)=>!_e.has(_.grantId));if(_e=qe,Ee){if(ee=!1,!K)se=!1}let he=rt(I,f);if(he.length===0||!q)K=!1;T=!Y&&k&&I.length>0;let Se=he.length===1;if(D.textContent=t(Se?f.connectedOne:f.connectedMany,{apps:u(he,f)}),X.textContent=Se?f.connectedNextOne:f.connectedNextMany,T)y.setAttribute("aria-describedby",R);else y.removeAttribute("aria-describedby");if(Z.hidden=!T,k)G=void 0;let We=N?.appName;M.textContent=Y?f.gettingNewAddress:w==="connecting"?f.connecting:w==="reconnecting"?f.reconnecting:!k?G??f.notConnected:O??(ee?f.newAddressDone:We!==void 0?t(f.readyApp,{app:We}):f.readyPage),M.hidden=T;let ot=!A.hidden;if(q&&F.value!==N.address)F.value=N.address,U();if(q)nt(N);if(A.hidden=xe.hidden=j.hidden=!q,W.disabled=!k,ne.hidden=!K,K)be.textContent=t(Se?f.newAddressQuestionOne:f.newAddressQuestionMany,{apps:u(he,f)});let ct=st(Ee);ye.hidden=H||!ct||!k,ke.hidden=!H||m.identity!=="bound",de.hidden=!T,de.setAttribute("aria-expanded",String(se)),Oe.hidden=T&&!se,b.classList.toggle("tab-mcp-primary",!T);for(let[_,{item:ge}]of fe){if(qe.has(_))continue;ge.remove(),fe.delete(_)}if(I.forEach((_,ge)=>{let V=fe.get(_.grantId);if(V===void 0)V=tt(_),fe.set(_.grantId,V);if(V.disconnect.disabled=!k,V.renderAllowed(),re.children[ge]!==V.item)re.insertBefore(V.item,re.children[ge]??null)}),le.textContent=k?pe??"":f.disconnectNote,le.hidden=k&&pe===void 0,$e.hidden=I.length===0,Pe.hidden=T||ye.hidden,Q.hidden=T,ue.hidden=!T,J.hidden=Y||w!=="disconnected"&&w!=="reconnecting",g!==null&&g!==y&&g!==p.body&&(!g.isConnected||y.contains(g)&&g.closest("[hidden]")!==null))(ne.contains(g)&&!j.hidden?W:Ue()).focus();else if(p.activeElement===y&&(T||q))Ne().focus();else if(ee&&q&&!ot&&p.activeElement===Q)b.focus();if(Ee&&T)S(`${D.textContent}. ${X.textContent}`)},at=()=>{if(m.state!=="connected")return;if(m.grants.length===0){He();return}K=!0,C(),ce.focus()},He=()=>{Y=!0,ee=!1,Q.focus(),K=!1,C(),m.newAddress().then(()=>{if(Y=!1,ee=!0,C(),!A.hidden)b.focus()},(g)=>{Y=!1,G=ae(g,f),C(),Ue().focus()})},me,Ae=m.state==="reconnecting",Be=(g)=>{let{error:w}=g.detail;if(Ae&&w.reason!==void 0)me=w},Fe=(g)=>{let{state:w,reason:N}=g.detail;if(N!==void 0&&N!=="new_address")G=lt(N,f),ee=!1;if(w==="disconnected"&&Ae)G=me===void 0?f.disconnected:ae(me,f);Ae=w==="reconnecting",me=void 0,C()},Ge=()=>y.close();pt(m,p,v);let it=L.onChange(C);return m.addEventListener("statechange",Fe),m.addEventListener("pairingcode",C),m.addEventListener("grantschange",C),m.addEventListener("identitychange",C),m.addEventListener("error",Be),m.addEventListener("replaced",Ge),p.body.append(y),m.startPairing(),C(),h.then(C,(g)=>{G=ae(g,f),C()}),new Promise((g)=>{if(y.addEventListener("close",()=>{clearTimeout(P),m.stopPairing(),it(),m.removeEventListener("statechange",Fe),m.removeEventListener("pairingcode",C),m.removeEventListener("grantschange",C),m.removeEventListener("identitychange",C),m.removeEventListener("error",Be),m.removeEventListener("replaced",Ge),y.remove(),g()},{once:!0}),y.showModal(),T||!A.hidden)Ne().focus();else y.focus()})}export{xt as showConnectDialog};
4
+
5
+ //# debugId=29063111D96E787B64756E2164756E21
6
+ //# sourceMappingURL=connect-ph4xxen4.min.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/command.ts", "../../src/setup.ts", "../../src/connect.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The server's name and the address as words for the setup commands\n * (`setup.ts`), plain in every shell. Internal: not part of an entry.\n */\n\n/**\n * The server's name as a label that every shell (POSIX shells, PowerShell,\n * cmd.exe) reads as one plain word, so it needs no quoting: letters without\n * their marks (\"Bücher\" → \"bucher\"), lower case, each run of anything but\n * a-z, 0-9, _ and - as one \"-\", no \"-\" at either end (no option), at most 40\n * characters; \"tools\" when nothing is left. The page names its server, but\n * the command runs in the user's shell: nothing of the name may be quoted\n * text (review of PR 34).\n */\nexport function commandName(name: string): string {\n\tconst label = name\n\t\t.normalize(\"NFKD\")\n\t\t.replace(/\\p{M}/gu, \"\")\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_-]+/g, \"-\")\n\t\t.replace(/-{2,}/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\")\n\t\t.slice(0, 40)\n\t\t.replace(/-+$/, \"\");\n\treturn label === \"\" ? \"tools\" : label;\n}\n\n/**\n * The address for a command, only when all of it is plain in every shell\n * (http or https, letters, digits and . : [ ] / _ ~ -); else `undefined`, and\n * the help shows the steps without commands. The relay's addresses are.\n */\nexport function commandAddress(address: string): string | undefined {\n\ttry {\n\t\tconst href = new URL(address).href;\n\t\treturn /^https?:\\/\\/[A-Za-z0-9.:[\\]/_~-]+$/.test(href) ? href : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n",
6
+ "/**\n * `@ractive-ch/tab-mcp-client/setup`: how to add a page's address to each AI\n * app, the steps the connect dialog shows under \"How do I add it?\", for pages\n * and extensions that show them in their own UI. Plain data, no DOM. An entry\n * of its own, out of the core (DEC-118).\n */\n\nimport { commandAddress, commandName } from \"./command.ts\";\nimport type { SetupNotePart, SetupStep } from \"./types.ts\";\n\nexport type { SetupNotePart, SetupStep };\n\n/** The guide for every AI app, step by step and what to do when it fails (its source is on ractive.ch). */\nexport const SETUP_GUIDE = \"https://ractive.ch/tab-mcp/connect/\";\n\n/** Codex's feature for MCP 2026-07-28, which the relay speaks; off by default in Codex 0.163. */\nconst CODEX_FEATURE = \"mcp_2026_07_28\";\n\n/**\n * The steps for one AI app. All strings are plain text (set them with\n * `textContent`). `command`, where present, is safe to show and to run: the\n * server's name and the address in it are words that every shell (POSIX\n * shells, PowerShell, cmd.exe) reads as plain, with nothing to quote. It is\n * absent for apps without a command, and when the address is not\n * shell-plain (only http or https, letters, digits and `. : [ ] / _ ~ -`);\n * then `text` names the command instead. The relay's addresses are\n * shell-plain.\n */\nexport interface SetupInstruction extends SetupStep {\n\t/** Which app, stable across versions: `claude`, `chatgpt`, `claude-code` or `codex`. */\n\tid: \"claude\" | \"chatgpt\" | \"claude-code\" | \"codex\";\n}\n\n/**\n * The steps to add `address` (the page's MCP address from the relay) to\n * Claude, ChatGPT, Claude Code and Codex, in that order. `serverName` is the\n * page's `server.name`; the commands name the server by it, reduced to a\n * shell-plain label (lower case, letters without marks, each run of other\n * characters as `-`, at most 40 characters, `tools` if nothing is left).\n * End the list with a link to {@link SETUP_GUIDE}: the steps here are the\n * minimum (CU 20), the guide has the rest and follows the apps' menus.\n */\nexport function setupInstructions(\n\tserverName: string,\n\taddress: string,\n): SetupInstruction[] {\n\tconst n = commandName(serverName);\n\tconst a = commandAddress(address);\n\tconst run = (command: string) =>\n\t\ta === undefined ? {} : { text: \"Run:\", command };\n\treturn [\n\t\t{\n\t\t\tid: \"claude\",\n\t\t\tapp: \"Claude (claude.ai and the desktop app)\",\n\t\t\ttext: \"Settings → Connectors → Add custom connector, then paste the address.\",\n\t\t},\n\t\t{\n\t\t\tid: \"chatgpt\",\n\t\t\tapp: \"ChatGPT\",\n\t\t\ttext: \"On chatgpt.com: Plugins, add an MCP server with the address, then Connect. The Mac app needs more steps: see the guide.\",\n\t\t},\n\t\t{\n\t\t\tid: \"claude-code\",\n\t\t\tapp: \"Claude Code\",\n\t\t\ttext: \"Add the address with claude mcp add --transport http.\",\n\t\t\t...run(`claude mcp add --transport http ${n} ${a}`),\n\t\t\t// The command only adds the server; the sign-in that asks for the\n\t\t\t// code starts in Claude Code (CU 6).\n\t\t\tnote: [\n\t\t\t\t{ text: \"Then type \" },\n\t\t\t\t{ code: \"/mcp\" },\n\t\t\t\t{ text: \" in Claude Code and choose Authenticate.\" },\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tid: \"codex\",\n\t\t\tapp: \"Codex\",\n\t\t\ttext: `Run codex features enable ${CODEX_FEATURE}, then add the address with codex mcp add --url and sign in with codex mcp login.`,\n\t\t\t...run(\n\t\t\t\t`codex features enable ${CODEX_FEATURE}\\ncodex mcp add ${n} --url ${a}\\ncodex mcp login ${n}`,\n\t\t\t),\n\t\t\tnote: [\n\t\t\t\t{\n\t\t\t\t\ttext: \"The last line opens the sign-in that asks for the code. Start a new chat in Codex after it connects.\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n}\n",
7
+ "/**\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"
8
+ ],
9
+ "mappings": "oHAcO,SAAS,EAAW,CAAC,EAAsB,CACjD,IAAM,EAAQ,EACZ,UAAU,MAAM,EAChB,QAAQ,UAAW,EAAE,EACrB,YAAY,EACZ,QAAQ,gBAAiB,GAAG,EAC5B,QAAQ,SAAU,GAAG,EACrB,QAAQ,WAAY,EAAE,EACtB,MAAM,EAAG,EAAE,EACX,QAAQ,MAAO,EAAE,EACnB,OAAO,IAAU,GAAK,QAAU,EAQ1B,SAAS,EAAc,CAAC,EAAqC,CACnE,GAAI,CACH,IAAM,EAAO,IAAI,IAAI,CAAO,EAAE,KAC9B,MAAO,qCAAqC,KAAK,CAAI,EAAI,EAAO,OAC/D,KAAM,CACP,QCxBK,IAAM,GAAc,sCAGrB,GAAgB,iBA0Bf,SAAS,EAAiB,CAChC,EACA,EACqB,CACrB,IAAM,EAAI,GAAY,CAAU,EAC1B,EAAI,GAAe,CAAO,EAC1B,EAAM,CA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