@ractive-ch/tab-mcp-client 0.17.0 → 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 (47) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +116 -19
  3. package/allowed.d.ts +28 -0
  4. package/allowed.js +14 -0
  5. package/allowed.js.map +10 -0
  6. package/always-allowed.d.ts +140 -22
  7. package/cdn/allowed.min.js +4 -0
  8. package/cdn/allowed.min.js.map +10 -0
  9. package/cdn/confirm-f36n8xj5.min.js +4 -0
  10. package/cdn/confirm-f36n8xj5.min.js.map +10 -0
  11. package/cdn/connect-ph4xxen4.min.js +6 -0
  12. package/cdn/connect-ph4xxen4.min.js.map +12 -0
  13. package/cdn/{index-t33bb2g4.min.js → tab-mcp-client-2vx9mcww.min.js} +20 -9
  14. package/cdn/tab-mcp-client-2vx9mcww.min.js.map +12 -0
  15. package/cdn/tab-mcp-client-6gcmd7n8.min.js +5 -0
  16. package/cdn/tab-mcp-client-6gcmd7n8.min.js.map +10 -0
  17. package/cdn/tab-mcp-client.min.js +3 -3
  18. package/cdn/tab-mcp-client.min.js.map +4 -4
  19. package/{confirm-vj2zbq4w.js → confirm-jbyqzy14.js} +29 -19
  20. package/confirm-jbyqzy14.js.map +10 -0
  21. package/confirm.d.ts +27 -20
  22. package/{connect-9pefy0xe.js → connect-13hkdpcx.js} +113 -16
  23. package/connect-13hkdpcx.js.map +10 -0
  24. package/connect.d.ts +2 -2
  25. package/dialog.d.ts +1 -1
  26. package/{index-qw8qy5ed.js → index-c1c266tm.js} +27 -89
  27. package/index-c1c266tm.js.map +11 -0
  28. package/index-h8b3dc5p.js +245 -0
  29. package/index-h8b3dc5p.js.map +10 -0
  30. package/index.js +16 -19
  31. package/index.js.map +4 -4
  32. package/package.json +7 -2
  33. package/react.d.ts +19 -0
  34. package/react.js +30 -1
  35. package/react.js.map +3 -3
  36. package/secret.d.ts +6 -0
  37. package/strings.d.ts +12 -3
  38. package/tab-mcp.d.ts +5 -4
  39. package/types.d.ts +16 -7
  40. package/cdn/confirm-mqmvsxg1.min.js +0 -4
  41. package/cdn/confirm-mqmvsxg1.min.js.map +0 -10
  42. package/cdn/connect-c7wn48yp.min.js +0 -6
  43. package/cdn/connect-c7wn48yp.min.js.map +0 -12
  44. package/cdn/index-t33bb2g4.min.js.map +0 -13
  45. package/confirm-vj2zbq4w.js.map +0 -10
  46. package/connect-9pefy0xe.js.map +0 -10
  47. package/index-qw8qy5ed.js.map +0 -12
package/secret.d.ts CHANGED
@@ -10,6 +10,12 @@ export declare function isSecret(value: unknown): value is string;
10
10
  /** Reads, creates and rotates the secret; falls back to memory without storage. */
11
11
  export declare class SecretStore {
12
12
  #private;
13
+ /**
14
+ * Where the secret is kept (`null`: memory) and under which key; the
15
+ * allowed tools (`always-allowed.ts`) are kept next to it.
16
+ */
17
+ readonly storage: SecretStorage | null;
18
+ readonly key: string;
13
19
  constructor(storage: SecretStorage | null | undefined, key: string);
14
20
  /**
15
21
  * The current secret, or `undefined` while this page has none (none made
package/strings.d.ts CHANGED
@@ -16,6 +16,10 @@ export declare const STRINGS: {
16
16
  confirmWho: string;
17
17
  deny: string;
18
18
  allow: string;
19
+ /** `alwaysAllow: true`: kept until the app is disconnected. */
20
+ alwaysAllow: string;
21
+ alwaysAllowNote: string;
22
+ /** `alwaysAllow: "until-reload"`, or kept in memory only (`storage: null`). */
19
23
  allowUntilReload: string;
20
24
  allowUntilReloadNote: string;
21
25
  argumentsHidden: string;
@@ -86,10 +90,15 @@ export declare const STRINGS: {
86
90
  storeUnavailable: string;
87
91
  /** Disconnect failed for another reason. */
88
92
  disconnectFailed: string;
89
- /** Under a connected app: the tools allowed until reload for it. */
90
93
  runsWithoutAsking: string;
91
- askAgain: string;
92
- askAgainApp: string;
94
+ /** After a tool's name: it may delete or overwrite (`destructiveHint`). */
95
+ destructive: string;
96
+ /** A tool's switch, as read out: starts with what it shows (WCAG 2.5.3). */
97
+ allowToolApp: string;
98
+ allowDestructiveToolApp: string;
99
+ allowEverything: string;
100
+ allowEverythingApp: string;
101
+ allowEverythingNote: string;
93
102
  closeNote: string;
94
103
  close: string;
95
104
  done: string;
package/tab-mcp.d.ts CHANGED
@@ -161,10 +161,11 @@ export declare class TabMcp extends EventTarget {
161
161
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
162
162
  /**
163
163
  * The library's own confirmation: the dialog in the page with Don't allow
164
- * and Allow, and Allow until reload with `alwaysAllow: true` (what runs
165
- * without `onConfirm`), in `options.document` (default: the global one).
166
- * An `onConfirm` may hand some calls to it. Resolves `false` where there
167
- * is no document.
164
+ * and Allow, and Always allow with `alwaysAllow` (what runs without
165
+ * `onConfirm`), in `options.document` (default: the global one). An
166
+ * `onConfirm` may hand some calls to it. A call the user allowed for its
167
+ * AI app resolves `true` unasked. Resolves `false` where there is no
168
+ * document.
168
169
  */
169
170
  confirmInPage(request: ConfirmRequest, options?: {
170
171
  document?: Document;
package/types.d.ts CHANGED
@@ -300,14 +300,23 @@ export interface TabMcpOptions {
300
300
  /** Approves consequential tool calls; default: a dialog in the page. */
301
301
  onConfirm?: ConfirmHandler;
302
302
  /**
303
- * Offer "Allow until reload" in the default confirmation: it lets a tool
304
- * run without asking for one AI app, with any arguments, until the page
305
- * is reloaded or the app is disconnected; the connect dialog lists it
306
- * with a reset. Off by default (DEC-096): the confirmation then shows
307
- * only "Don't allow" and "Allow", and every call asks. Turn it on only
308
- * for tools whose calls the user does not need to check one by one.
303
+ * Let the user allow tools in the library's dialogs, so that their calls
304
+ * run without asking for one AI app, with any arguments (DEC-200):
305
+ *
306
+ * - `true`: the confirmation offers "Always allow", and the connect
307
+ * dialog a switch per tool and "Allow everything, no questions asked"
308
+ * under each connected app. Kept in `storage` next to the secret until
309
+ * the app is disconnected (in memory with `storage: null`).
310
+ * - `"until-reload"`: the same, offered as "Allow until reload": kept in
311
+ * memory only, until the page is reloaded or the app is disconnected.
312
+ * - unset or `false` (DEC-096): the confirmation shows only "Don't allow"
313
+ * and "Allow", and every call asks. A page can still offer its own
314
+ * switches with `@ractive-ch/tab-mcp-client/allowed`, kept as with `true`.
315
+ *
316
+ * Turn it on only for tools whose calls the user does not need to check
317
+ * one by one: an AI app can be steered by what it reads.
309
318
  */
310
- alwaysAllow?: boolean;
319
+ alwaysAllow?: boolean | "until-reload";
311
320
  /** Texts and help of the library's dialogs. */
312
321
  ui?: DialogOptions;
313
322
  /**
@@ -1,4 +0,0 @@
1
- import{c,o,n,s,e,t,r,a,d}from"./index-t33bb2g4.min.js";function q(u){try{return r(JSON.stringify(u,null,2))}catch{return}}var ee=750,te=500,G=new WeakMap;function J(u,i,v={}){if(u.signal.aborted)return Promise.resolve("deny");let p=G.get(i);if(p===void 0)p={shown:!1,waiting:[]},G.set(i,p);let f=p,l=()=>{let y=f.waiting.shift();f.shown=y!==void 0,y?.(),f.changed?.()},D=()=>{try{return ne(u,i,v,f,l)}catch(y){return l(),Promise.reject(y)}};if(!f.shown)return f.shown=!0,D();return new Promise((y)=>{let L=()=>{if(u.signal.removeEventListener("abort",b),v.allowedNow?.()===!0){y("allow"),l();return}y(D())},b=()=>{f.waiting.splice(f.waiting.indexOf(L),1),f.changed?.(),y("deny")};u.signal.addEventListener("abort",b,{once:!0}),f.waiting.push(L),f.changed?.()})}function ne(u,i,v,p,f){let l=v.strings??o(void 0),D=v.allowDelayMs??ee,y=u.tool.title??u.tool.name,L=a(u.client,l),b={tool:y,client:L},{dialog:w,id:_}=d(i,"tab-mcp-confirm",l,...s(i,l.confirmTitle,b)),S=e(i,"p",{className:"tab-mcp-waiting"}),I=()=>{let h=p.waiting.length;S.hidden=h===0,S.textContent=h===1?l.waitingOne:n(l.waitingMany,{n:String(h)})};p.changed=I,I();let j=t(i,l.deny,()=>w.close("deny"),"tab-mcp-deny","primary"),z=(h,U,k)=>{let A=t(i,h,()=>{if(!A.disabled)w.close(U)},k);return A},N=[z(l.allow,"allow","tab-mcp-allow")],H=[];if(v.alwaysAllow===!0)N.unshift(z(l.allowUntilReload,"always","tab-mcp-always")),H.push(e(i,"p",{className:"tab-mcp-always-note"},...s(i,l.allowUntilReloadNote,b)));let K=e(i,"div",{className:"tab-mcp-actions"},j,...N.flatMap((h)=>[" ",h])),M=!1,W=!1,P=()=>{for(let h of N)h.disabled=!(M&&W)};P();let O=q(u.arguments),g=e(i,"pre",{className:"tab-mcp-arguments",id:`${_}-arguments`,text:O??l.argumentsHidden});if(O===void 0)for(let h of[...N,...H])h.hidden=!0;g.dir="ltr",g.style.setProperty("white-space","pre-wrap"),g.style.setProperty("overflow-wrap","anywhere"),g.style.setProperty("max-height","var(--tab-mcp-arguments-height, min(50vh, 24rem))"),g.style.setProperty("overflow","auto"),g.hidden=Object.keys(u.arguments).length===0;let T=e(i,"p",{className:"tab-mcp-scroll-note",text:l.scrollToAllow});T.hidden=!0;let Q=e(i,"p",{id:`${_}-who`},...s(i,l.confirmWho,b));w.setAttribute("aria-describedby",O!==void 0&&!g.hidden&&O.length<=te?`${Q.id} ${g.id}`:Q.id),w.append(Q,e(i,"p",{className:"tab-mcp-description",text:u.tool.description}),g,T,K,...H,S),i.body.append(w);let C=i.defaultView;return new Promise((h,U)=>{let k=()=>w.close("deny");u.signal.addEventListener("abort",k,{once:!0});let A,x,B=()=>{if(x!==void 0&&i.title===x.shown)i.title=x.page;x=void 0},Y=()=>{if(i.visibilityState!=="hidden")B();else if(x===void 0)x={page:i.title,shown:`${l.titlePrefix}${i.title}`},i.title=x.shown},E=(m)=>{if(m?.type==="close"&&m.target===w)return;if(Y(),clearTimeout(A),A=void 0,M=!1,P(),m?.type==="blur"||i.visibilityState==="hidden"||!i.hasFocus())return;A=setTimeout(()=>{M=!0,P()},D)},R=()=>{if(W)return;if(g.scrollTop+g.clientHeight<g.scrollHeight-2){T.hidden=!1,g.tabIndex=0;return}W=!0,T.hidden=!0,P()},F=(m)=>{if(M)return;let Z=m.target?.localName==="button";if(m.key==="Escape"||Z&&(m.key==="Enter"||m.key===" "))m.preventDefault()},X=(m)=>{if(!M)m.preventDefault()};i.addEventListener("visibilitychange",E),i.addEventListener("close",E,!0),C?.addEventListener("focus",E),C?.addEventListener("blur",E),C?.addEventListener("resize",R),g.addEventListener("scroll",R),w.addEventListener("keydown",F),w.addEventListener("keyup",F),w.addEventListener("cancel",X);let V=()=>{if(clearTimeout(A),B(),i.removeEventListener("visibilitychange",E),i.removeEventListener("close",E,!0),C?.removeEventListener("focus",E),C?.removeEventListener("blur",E),C?.removeEventListener("resize",R),u.signal.removeEventListener("abort",k),w.remove(),p.changed===I)p.changed=void 0};w.addEventListener("close",()=>{let m=w.returnValue;V(),h(m==="allow"||m==="always"?m:"deny"),f()},{once:!0});try{w.showModal()}catch(m){V(),U(m),f();return}j.focus(),E(),R()})}function re(u,i,v,p={}){let{client:f}=i,l={strings:o(p.ui),allowDelayMs:p.allowDelayMs};if(f.kind!=="relay")return J(i,v,l).then((b)=>b==="allow");let{grantId:D}=f,y=c(u),L=()=>y.has(D,i.tool);if(L())return Promise.resolve(!0);return J(i,v,{...l,alwaysAllow:p.alwaysAllow,allowedNow:L}).then((b)=>{if(b==="always"&&u.grants.some((w)=>w.grantId===D))y.add(D,i.tool);return b!=="deny"})}export{re as confirmInPage};
2
-
3
- //# debugId=9D80C139269021CA64756E2164756E21
4
- //# sourceMappingURL=confirm-mqmvsxg1.min.js.map
@@ -1,10 +0,0 @@
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 the tools a user allowed\n * until reload (`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 { ConfirmRequest, DialogOptions } 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 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/** Offer \"Allow until reload\". */\n\talwaysAllow?: boolean | 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. \"Allow until reload\" is offered\n * only with `alwaysAllow` (DEC-096). 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 \"Allow until reload\" 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 until reload 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 Allow until reload when the page offers it.\n\tconst approve = [approving(s.allow, \"allow\", \"tab-mcp-allow\")];\n\tconst extra: HTMLElement[] = [];\n\tif (options.alwaysAllow === true) {\n\t\t// Left of Allow: not where most platforms put the default (CU 11).\n\t\tapprove.unshift(approving(s.allowUntilReload, \"always\", \"tab-mcp-always\"));\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, 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 allowed until\n * reload (`always-allowed.ts`). Only for an AI app through the relay: an\n * agent in the browser and a served port have no identity to remember an\n * answer for (DEC-115, DEC-124).\n */\nexport function confirmInPage(\n\tmcp: TabMcp,\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: {\n\t\talwaysAllow?: boolean | undefined;\n\t\tui?: DialogOptions | undefined;\n\t\t/** Tests only. */\n\t\tallowDelayMs?: number | undefined;\n\t} = {},\n): Promise<boolean> {\n\tconst { client } = request;\n\tconst dialogOptions = {\n\t\tstrings: stringsOf(options.ui),\n\t\tallowDelayMs: options.allowDelayMs,\n\t};\n\tif (client.kind !== \"relay\")\n\t\treturn confirmDialog(request, doc, dialogOptions).then(\n\t\t\t(answer) => answer === \"allow\",\n\t\t);\n\tconst { grantId } = client;\n\tconst allowed = allowedFor(mcp);\n\tconst allowedNow = () => allowed.has(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 until reload.\n\treturn confirmDialog(request, doc, {\n\t\t...dialogOptions,\n\t\talwaysAllow: options.alwaysAllow,\n\t\tallowedNow,\n\t}).then((answer) => {\n\t\t// Only while the grant is still there: a revoked app gets nothing.\n\t\tif (answer === \"always\" && mcp.grants.some((g) => g.grantId === grantId))\n\t\t\tallowed.add(grantId, request.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269021CA64756E2164756E21",
9
- "names": []
10
- }
@@ -1,6 +0,0 @@
1
- import{c,i,o,n,s,e,t,r,a,u,d,l}from"./index-t33bb2g4.min.js";function ze(f){let h=f.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(f){try{let h=new URL(f).href;return/^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(h)?h:void 0}catch{return}}var Ke="https://ractive.ch/tab-mcp/connect/",je="mcp_2026_07_28";function Ve(f,h){let p=ze(f),M=Qe(h),w=(m)=>M===void 0?{}:{text:"Run:",command:m};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.",...w(`claude mcp add --transport http ${p} ${M}`),note:[{text:"Then type "},{code:"/mcp"},{text:" in Claude Code and choose Authenticate."}]},{id:"codex",app:"Codex",text:`Run codex features enable ${je}, then add the address with codex mcp add --url and sign in with codex mcp login.`,...w(`codex features enable ${je}
2
- codex mcp add ${p} --url ${M}
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 ct(f,h){return[...new Set(f.map((p)=>a(p.client,h)))]}function X(f,h){console.warn("tab-mcp: could not connect.",f);let p=f?.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 rt(f,h){switch(f){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 lt(f,h){switch(f.identity){case"bound":return;case"pending":return h.checkingSignIn;case"refused":return f.identityMessage?n(h.signInRefusedWhy,{reason:f.identityMessage}):h.signInRefused;default:return h.signInFirst}}var xe=new WeakMap;function ut(f,h,p){let M=xe.has(f);if(xe.set(f,p===void 0?{doc:h}:{doc:h,ui:p}),M)return;f.addEventListener("replaced",(w)=>{let m=xe.get(f);if(m!==void 0&&f.state==="disconnected")pt(f,m.doc,w.detail.sibling,m.ui)})}function pt(f,h,p,M){let w=o(M);h.querySelector("dialog.tab-mcp-replaced")?.close();let{dialog:m}=d(h,"tab-mcp-replaced",w,p?w.replacedSiblingTitle:w.replacedTitle),T=e(h,"p",{className:"tab-mcp-status"});T.setAttribute("role","status"),T.hidden=!0;let y=t(h,w.close,()=>m.close(),"tab-mcp-replaced-close",p?"primary":void 0),R=e(h,"div",{className:"tab-mcp-actions"},y),P=y;if(!p){let I=t(h,w.newAddress,()=>{I.disabled=!0,T.hidden=!1,T.textContent=w.gettingNewAddress,f.newAddress().then(()=>{m.close(),f.showConnectDialog({document:h}).catch(()=>{})},(z)=>{I.disabled=!1,T.textContent=z?.reason==="replaced"?w.takenOverAgain:n(w.tryAgainOrClose,{reason:X(z,w)})})},"tab-mcp-new-address","primary");R.append(" ",I),P=I}m.append(e(h,"p",{className:"tab-mcp-description",text:p?w.replacedSibling:w.replaced}),T,R),m.addEventListener("close",()=>m.remove(),{once:!0}),h.body.append(m),m.showModal(),P.focus()}var mt=1e4;function vt(f,h,p,M="tools",w){let m=o(w),T=c(f),{dialog:y}=d(p,"tab-mcp-connect",m,m.connectTitle);y.tabIndex=-1;let R=e(p,"p",{className:"tab-mcp-status"});R.setAttribute("role","status");let P=e(p,"span",{className:"tab-mcp-announce"});P.setAttribute("aria-live","polite");for(let[g,b]of[["position","absolute"],["width","1px"],["height","1px"],["overflow","hidden"],["clip-path","inset(50%)"],["white-space","nowrap"]])P.style.setProperty(g,b);let I=(g)=>{P.textContent=P.textContent===g?`${g} `:g},z=`${i()}-success`,de=e(p,"p",{className:"tab-mcp-success-title"}),ce=e(p,"p",{className:"tab-mcp-success-next"}),ve=e(p,"span",{className:"tab-mcp-success-icon"});ve.setAttribute("aria-hidden","true");let ye=e(p,"div",{className:"tab-mcp-success",id:z},ve,e(p,"div",{className:"tab-mcp-success-text"},de,ce)),Ce=`${i()}-address`,Ne=e(p,"label",{text:m.addressLabel});Ne.htmlFor=Ce;let G=e(p,"input",{id:Ce,className:"tab-mcp-address-input"});G.readOnly=!0;let{button:Q,reset:Xe}=l(p,m,m.copyAddress,()=>G.value,()=>G.select(),I,"tab-mcp-address-copy","primary"),j=e(p,"div",{className:"tab-mcp-address"},Ne,G," ",Q),Z=t(p,m.newAddress,()=>at(),"tab-mcp-new-address"),re=e(p,"div",{className:"tab-mcp-new-address-row"},e(p,"small",{text:m.newAddressNote})," ",Z),Ae=`${i()}-new-address`,Se=e(p,"p",{id:Ae}),Ee=t(p,m.cancel,()=>{F=!1,x(),Z.focus()}),Ze=t(p,m.newAddressConfirm,()=>Ue(),"tab-mcp-new-address-confirm","danger"),K=e(p,"div",{className:"tab-mcp-new-address-question"},Se,e(p,"div",{className:"tab-mcp-actions"},Ee," ",Ze));K.setAttribute("role","group"),K.setAttribute("aria-labelledby",Ae);let U=e(p,"strong",{className:"tab-mcp-code-value"});U.style.setProperty("user-select","all"),U.style.setProperty("-webkit-user-select","all");let{button:Te,reset:Je}=l(p,m,m.copyCode,()=>U.textContent??"",()=>p.getSelection()?.selectAllChildren(U),I,"tab-mcp-code-copy"),le=e(p,"span",{},...s(p,m.codeSentence,{code:U}));le.setAttribute("aria-live","polite");let ue=e(p,"span",{className:"tab-mcp-code-used"}),pe=e(p,"p",{className:"tab-mcp-code"},le,ue," ",Te,e(p,"br"),e(p,"small",{className:"tab-mcp-code-note",text:m.codeNote})),Ie=e(p,"p",{className:"tab-mcp-sign-in",text:m.signIn}),Le=e(p,"ul"),me=e(p,"details",{className:"tab-mcp-help"},e(p,"summary",{text:m.help}),Le),De=w?.setup?.guide===void 0?Ke:w.setup.guide;if(De!==null){let g=e(p,"a",{text:m.guide});g.href=De,g.target="_blank",g.rel="noopener noreferrer",me.append(e(p,"p",{className:"tab-mcp-guide"},g))}let Ye=w?.setup?.instructions??Ve,ke=`${i()}-setup`,Me=e(p,"div",{className:"tab-mcp-setup",id:ke},j,me,pe,Ie,re,K),J=t(p,m.connectAnother,()=>{V=!V,x()},"tab-mcp-setup-toggle");J.setAttribute("aria-controls",ke);let Y=e(p,"ul"),ee=e(p,"p",{className:"tab-mcp-apps-note"});ee.setAttribute("role","status");let Pe=e(p,"div",{className:"tab-mcp-apps"},e(p,"h3",{text:m.connectedHeading}),Y,ee),$e=e(p,"small",{className:"tab-mcp-close-note",text:m.closeNote}),B=t(p,m.close,()=>y.close(),"tab-mcp-close"),te=t(p,m.done,()=>y.close(),"tab-mcp-done","primary"),H=t(p,m.connectAgain,()=>{_=void 0,f.connect().then(()=>{if(p.activeElement===B)ge().focus()},(g)=>{if(_=X(g,m),x(),p.activeElement===B&&!H.hidden)H.focus()}),x()},"tab-mcp-retry","primary"),et=e(p,"div",{className:"tab-mcp-actions"},$e," ",B,H,te);y.append(ye,R,Pe,J,Me,et,P);let V=!1,F=!1,q=!1,W=!1,_,ne,_e=new Set(f.grants.map((g)=>g.grantId)),Oe,fe,L,C=!1,Re=()=>C?te:H.hidden?B:H,ge=()=>C?te:Q,se=new Map,tt=(g)=>{let b=a(g.client,m),v=t(p,m.disconnect,()=>{ne=void 0,f.revoke(g.grantId).catch((k)=>{if(f.state==="connected")ne=k?.code==="store_unavailable"?m.storeUnavailable:m.disconnectFailed;x()}),x()},"tab-mcp-disconnect","danger");v.setAttribute("aria-label",n(m.disconnectApp,{app:b}));let A=t(p,m.askAgain,()=>T.forget(g.grantId),"tab-mcp-ask-again");A.setAttribute("aria-label",n(m.askAgainApp,{app:b}));let N=e(p,"span"),D=e(p,"div",{className:"tab-mcp-allowed"},N," ",A);return{item:e(p,"li",{},e(p,"span",{className:"tab-mcp-app"},n(m.appConnected,{app:b}))," ",v,D),disconnect:v,allowedText:N,allowedBox:D}},nt=(g)=>{if(Oe===g.address)return;Oe=g.address,Le.replaceChildren(...Ye(M,g.address).map(({app:b,text:v,command:A,note:N})=>{let D=e(p,"li",{},e(p,"strong",{text:`${b}:`}),` ${v}`);if(A!==void 0){let S=e(p,"pre",{text:A});S.dir="ltr";let{button:k}=l(p,m,n(m.copyCommand,{app:b}),()=>S.textContent??"",()=>p.getSelection()?.selectAllChildren(S),I,"tab-mcp-command-copy");D.append(e(p,"div",{className:"tab-mcp-command"},S,k))}if(N!==void 0)D.append(e(p,"small",{className:"tab-mcp-command-note"},...N.map((S)=>("code"in S)?e(p,"code",{text:S.code}):S.text)));return D}))},st=(g)=>{let b=f.pairingCode;if(b===void 0||g)clearTimeout(L),L=void 0;else if(b.code!==fe?.code){if(b.reason==="used"){if(L===void 0)L=setTimeout(()=>{L=void 0,fe=f.pairingCode,x()},mt),I(m.codeUsed)}else if(L!==void 0)clearTimeout(L),L=void 0}let v=L!==void 0;if(!v){if(U.textContent!==(b?.code??""))Je();U.textContent=b?.code??"",fe=b}return le.hidden=v,Te.hidden=v,ue.hidden=!v,ue.textContent=v?m.codeUsed:"",b!==void 0},x=()=>{let g=p.activeElement,{state:b,session:v,grants:A}=f,N=b==="connected",D=v?.pairing==="oidc",S=D?lt(f,m):void 0,k=v!==void 0&&S===void 0,He=new Set(A.map((E)=>E.grantId)),be=N&&A.some((E)=>!_e.has(E.grantId));if(_e=He,be){if(W=!1,!F)V=!1}let oe=ct(A,m);if(oe.length===0||!k)F=!1;C=!q&&N&&A.length>0;let we=oe.length===1;if(de.textContent=n(we?m.connectedOne:m.connectedMany,{apps:u(oe,m)}),ce.textContent=we?m.connectedNextOne:m.connectedNextMany,C)y.setAttribute("aria-describedby",z);else y.removeAttribute("aria-describedby");if(ye.hidden=!C,N)_=void 0;let qe=v?.appName;R.textContent=q?m.gettingNewAddress:b==="connecting"?m.connecting:b==="reconnecting"?m.reconnecting:!N?_??m.notConnected:S??(W?m.newAddressDone:qe!==void 0?n(m.readyApp,{app:qe}):m.readyPage),R.hidden=C;let it=!j.hidden;if(k&&G.value!==v.address)G.value=v.address,Xe();if(k)nt(v);if(j.hidden=me.hidden=re.hidden=!k,Z.disabled=!N,K.hidden=!F,F)Se.textContent=n(we?m.newAddressQuestionOne:m.newAddressQuestionMany,{apps:u(oe,m)});let dt=st(be);pe.hidden=D||!dt||!N,Ie.hidden=!D||f.identity!=="bound",J.hidden=!C,J.setAttribute("aria-expanded",String(V)),Me.hidden=C&&!V,Q.classList.toggle("tab-mcp-primary",!C);for(let[E,{item:ie}]of se){if(He.has(E))continue;ie.remove(),se.delete(E)}if(A.forEach((E,ie)=>{let O=se.get(E.grantId);if(O===void 0)O=tt(E),se.set(E.grantId,O);O.disconnect.disabled=!N;let We=T.list(E.grantId);if(O.allowedBox.hidden=We.length===0,O.allowedText.textContent=n(m.runsWithoutAsking,{tools:We.map(r).join(", ")}),Y.children[ie]!==O.item)Y.insertBefore(O.item,Y.children[ie]??null)}),ee.textContent=N?ne??"":m.disconnectNote,ee.hidden=N&&ne===void 0,Pe.hidden=A.length===0,$e.hidden=C||pe.hidden,B.hidden=C,te.hidden=!C,H.hidden=q||b!=="disconnected"&&b!=="reconnecting",g!==null&&g!==y&&g!==p.body&&(!g.isConnected||y.contains(g)&&g.closest("[hidden]")!==null))(K.contains(g)&&!re.hidden?Z:Re()).focus();else if(p.activeElement===y&&(C||k))ge().focus();else if(W&&k&&!it&&p.activeElement===B)Q.focus();if(be&&C)I(`${de.textContent}. ${ce.textContent}`)},at=()=>{if(f.state!=="connected")return;if(f.grants.length===0){Ue();return}F=!0,x(),Ee.focus()},Ue=()=>{q=!0,W=!1,B.focus(),F=!1,x(),f.newAddress().then(()=>{if(q=!1,W=!0,x(),!j.hidden)Q.focus()},(g)=>{q=!1,_=X(g,m),x(),Re().focus()})},ae,he=f.state==="reconnecting",Be=(g)=>{let{error:b}=g.detail;if(he&&b.reason!==void 0)ae=b},Fe=(g)=>{let{state:b,reason:v}=g.detail;if(v!==void 0&&v!=="new_address")_=rt(v,m),W=!1;if(b==="disconnected"&&he)_=ae===void 0?m.disconnected:X(ae,m);he=b==="reconnecting",ae=void 0,x()},Ge=()=>y.close();ut(f,p,w);let ot=T.onChange(x);return f.addEventListener("statechange",Fe),f.addEventListener("pairingcode",x),f.addEventListener("grantschange",x),f.addEventListener("identitychange",x),f.addEventListener("error",Be),f.addEventListener("replaced",Ge),p.body.append(y),f.startPairing(),x(),h.then(x,(g)=>{_=X(g,m),x()}),new Promise((g)=>{if(y.addEventListener("close",()=>{clearTimeout(L),f.stopPairing(),ot(),f.removeEventListener("statechange",Fe),f.removeEventListener("pairingcode",x),f.removeEventListener("grantschange",x),f.removeEventListener("identitychange",x),f.removeEventListener("error",Be),f.removeEventListener("replaced",Ge),y.remove(),g()},{once:!0}),y.showModal(),C||!j.hidden)ge().focus();else y.focus()})}export{vt as showConnectDialog};
4
-
5
- //# debugId=3DB23946634FC9AE64756E2164756E21
6
- //# sourceMappingURL=connect-c7wn48yp.min.js.map
@@ -1,12 +0,0 @@
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 { 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/**\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 the tools allowed until reload\n * for each, with Ask again). 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 tools allowed until reload, with Ask again.\n\tconst items = new Map<\n\t\tstring,\n\t\t{\n\t\t\titem: HTMLLIElement;\n\t\t\tdisconnect: HTMLButtonElement;\n\t\t\tallowedText: HTMLElement;\n\t\t\tallowedBox: HTMLElement;\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 askAgain = button(\n\t\t\tdoc,\n\t\t\ts.askAgain,\n\t\t\t() => allowed.forget(grant.grantId),\n\t\t\t\"tab-mcp-ask-again\",\n\t\t);\n\t\taskAgain.setAttribute(\"aria-label\", format(s.askAgainApp, { app }));\n\t\tconst allowedText = el(doc, \"span\");\n\t\tconst allowedBox = el(\n\t\t\tdoc,\n\t\t\t\"div\",\n\t\t\t{ className: \"tab-mcp-allowed\" },\n\t\t\tallowedText,\n\t\t\t\" \",\n\t\t\taskAgain,\n\t\t);\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\tallowedBox,\n\t\t);\n\t\treturn { item, disconnect, allowedText, allowedBox };\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\tconst tools = allowed.list(grant.grantId);\n\t\t\tentry.allowedBox.hidden = tools.length === 0;\n\t\t\tentry.allowedText.textContent = format(s.runsWithoutAsking, {\n\t\t\t\ttools: tools.map(visible).join(\", \"),\n\t\t\t});\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": "6DAcO,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,CAAC,IACZ,IAAM,OAAY,CAAC,EAAI,CAAE,KAAM,OAAQ,SAAQ,EAChD,MAAO,CACN,CACC,GAAI,SACJ,IAAK,yCACL,KAAM,uEACP,EACA,CACC,GAAI,UACJ,IAAK,UACL,KAAM,yHACP,EACA,CACC,GAAI,cACJ,IAAK,cACL,KAAM,2DACH,EAAI,mCAAmC,KAAK,GAAG,EAGlD,KAAM,CACL,CAAE,KAAM,YAAa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CAC3C,EAAU,EAAe,EAAO,CAAC,EACjC,EAAO,EACP,EAEM,IAAI,QAAQ,CAAC,IAAY,CAsB/B,GArBA,EAAO,iBACN,QACA,IAAM,CACL,aAAa,CAAS,EACtB,EAAI,YAAY,EAChB,GAAY,EACZ,EAAI,oBAAoB,cAAe,EAAO,EAC9C,EAAI,oBAAoB,cAAe,CAAM,EAC7C,EAAI,oBAAoB,eAAgB,CAAM,EAC9C,EAAI,oBAAoB,iBAAkB,CAAM,EAChD,EAAI,oBAAoB,QAAS,EAAO,EACxC,EAAI,oBAAoB,WAAY,EAAU,EAC9C,EAAO,OAAO,EACd,EAAQ,GAET,CAAE,KAAM,EAAK,CACd,EACA,EAAO,UAAU,EAIb,GAAiB,CAAC,EAAW,OAAQ,GAAM,EAAE,MAAM,EACvD,KAAK,EAAO,MAAM,EAClB",
10
- "debugId": "3DB23946634FC9AE64756E2164756E21",
11
- "names": []
12
- }
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/always-allowed.ts", "../../src/strings.ts", "../../src/visible.ts", "../../src/dialog.ts"],
4
- "sourcesContent": [
5
- "/**\n * The tools a user chose \"Allow until reload\" for, per AI app (grant), kept\n * in memory for the page's lifetime. An entry goes when its grant goes, when\n * the user resets it in the connect dialog, or when its tool is gone. A tool\n * registered again as it was (React's `useTool` does that on a remount) keeps\n * it; one whose title or description changed, what the user saw when\n * allowing it, is asked again.\n */\n\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type { ConfirmRequest } from \"./types.ts\";\n\ntype ToolSeen = ConfirmRequest[\"tool\"];\n\n/** What the user saw of a tool when allowing it. */\nconst seen = (tool: ToolSeen) => JSON.stringify([tool.title, tool.description]);\n\nexport class AlwaysAllowed {\n\t/** Per grant: the tools by name, with what the user saw of each. */\n\treadonly #tools = new Map<\n\t\tstring,\n\t\tMap<string, { seen: string; label: string }>\n\t>();\n\treadonly #listeners = new Set<() => void>();\n\n\thas(grantId: string, tool: ToolSeen): boolean {\n\t\tconst tools = this.#tools.get(grantId);\n\t\tconst allowed = tools?.get(tool.name)?.seen;\n\t\tif (allowed === undefined || allowed === seen(tool)) {\n\t\t\treturn allowed !== undefined;\n\t\t}\n\t\t// The tool changed since: asked again, and no longer listed.\n\t\ttools?.delete(tool.name);\n\t\tthis.#changed();\n\t\treturn false;\n\t}\n\n\tadd(grantId: string, tool: ToolSeen): void {\n\t\tconst tools = this.#tools.get(grantId) ?? new Map();\n\t\ttools.set(tool.name, { seen: seen(tool), label: tool.title ?? tool.name });\n\t\tthis.#tools.set(grantId, tools);\n\t\tthis.#changed();\n\t}\n\n\t/** The tools allowed for a grant (title, else name), in the order allowed. */\n\tlist(grantId: string): string[] {\n\t\treturn [...(this.#tools.get(grantId)?.values() ?? [])].map((t) => t.label);\n\t}\n\n\t/** Ask again for every tool of a grant. */\n\tforget(grantId: string): void {\n\t\tif (this.#tools.delete(grantId)) this.#changed();\n\t}\n\n\t/** Forget every grant not in `grantIds`. */\n\tkeepGrants(grantIds: Iterable<string>): void {\n\t\tconst keep = new Set(grantIds);\n\t\tfor (const grantId of this.#tools.keys())\n\t\t\tif (!keep.has(grantId)) this.forget(grantId);\n\t}\n\n\t/** Forget every tool not in `names`. */\n\tkeepTools(names: Iterable<string>): void {\n\t\tconst keep = new Set(names);\n\t\tlet changed = false;\n\t\tfor (const tools of this.#tools.values()) {\n\t\t\tfor (const tool of tools.keys()) {\n\t\t\t\tif (keep.has(tool)) continue;\n\t\t\t\ttools.delete(tool);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t\tif (changed) this.#changed();\n\t}\n\n\t/** Calls `listener` on every change; returns what stops it. */\n\tonChange(listener: () => void): () => void {\n\t\tthis.#listeners.add(listener);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\t#changed(): void {\n\t\tfor (const listener of [...this.#listeners]) listener();\n\t}\n}\n\n/** The tools allowed until reload, per `TabMcp`. */\nconst allowed = new WeakMap<TabMcp, AlwaysAllowed>();\n\n/**\n * The tools allowed until reload of `mcp`, made on first use. Its grants\n * and tools are followed: a tool's absence counts only after the current\n * task, so that one unregistered and registered again at once (React) keeps\n * its entries.\n */\nexport function allowedFor(mcp: TabMcp): AlwaysAllowed {\n\tconst kept = allowed.get(mcp);\n\tif (kept !== undefined) return kept;\n\tconst made = new AlwaysAllowed();\n\tmcp.addEventListener(\"grantschange\", (e) =>\n\t\tmade.keepGrants(e.detail.grants.map((g) => g.grantId)),\n\t);\n\tlet tools: readonly string[] | undefined;\n\tmcp.addEventListener(\"toolschange\", (e) => {\n\t\tif (tools === undefined)\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (tools !== undefined) made.keepTools(tools);\n\t\t\t\ttools = undefined;\n\t\t\t});\n\t\ttools = e.detail.tools;\n\t});\n\tallowed.set(mcp, made);\n\treturn made;\n}\n",
6
- "/**\n * Every text of the library's dialogs, in one table (CU 5). A page passes\n * its own for some or all keys (`ui: { strings }`); the dialogs use these for\n * the rest. `{name}` is a placeholder the dialog fills in: names of tools\n * and AI apps (isolated, so that they cannot reorder the sentence), the\n * code, counts. Where English needs two forms, there are two keys\n * (`…One` for one, `…Many` for more). `lang` and `dir` are the language and\n * direction of the texts, set on every dialog.\n */\nexport const STRINGS = {\n\tlang: \"en\",\n\tdir: \"ltr\",\n\t/** Between the last two items of a list (\"A, B and C\"). */\n\tand: \"and\",\n\n\t// The confirmation of a consequential tool call.\n\tconfirmTitle: \"Allow {tool}?\",\n\tconfirmWho: \"{client} wants to run {tool}.\",\n\tdeny: \"Don't allow\",\n\tallow: \"Allow\",\n\tallowUntilReload: \"Allow until reload\",\n\tallowUntilReloadNote:\n\t\t\"Allow until reload: {tool} will run for {client} without asking, with any arguments, until you reload this page or disconnect {client}.\",\n\targumentsHidden:\n\t\t\"The arguments cannot be shown, so this call cannot be allowed.\",\n\tscrollToAllow: \"Scroll to the end of the arguments to allow this call.\",\n\twaitingOne: \"1 more call is waiting after this one.\",\n\twaitingMany: \"{n} more calls are waiting after this one.\",\n\t/** Before the page's title while a confirmation waits in a hidden tab. */\n\ttitlePrefix: \"Allow? – \",\n\n\t// How the dialogs name a caller.\n\tclientWebMcp: \"An agent in this browser\",\n\tclientLocal: \"{name} (this site's assistant)\",\n\t/** An AI app through the relay: its name and the host of its client id. */\n\tclientRelay: \"{name} ({host})\",\n\n\t// Copy buttons.\n\tcopy: \"Copy\",\n\tcopied: \"Copied\",\n\t/** On the button after a refused Copy: the text is selected instead. */\n\tpressMac: \"Press ⌘C\",\n\tpressOther: \"Press Ctrl+C\",\n\t/** The same on a touch screen, where there is no key to press. */\n\tselected: \"Selected\",\n\tcopyAddress: \"Copy address\",\n\tcopyCode: \"Copy code\",\n\tcopyCommand: \"Copy {app} command\",\n\n\t// The connect dialog.\n\tconnectTitle: \"Connect your AI app\",\n\tconnecting: \"Connecting…\",\n\tconnectAgain: \"Connect again\",\n\treconnecting: \"Connection lost. Reconnecting…\",\n\tnotConnected: \"Not connected.\",\n\tunreachable: \"Could not connect. Check your internet connection.\",\n\trateLimited: \"Too many attempts. Wait a minute, then connect again.\",\n\trefused: \"The connection was refused.\",\n\tended: \"The session ended.\",\n\tlost: \"The connection was lost.\",\n\tclosed: \"The connection was closed.\",\n\tdisconnected: \"Disconnected.\",\n\tcheckingSignIn: \"Checking your sign-in…\",\n\tsignInFirst: \"Sign in to this page first.\",\n\tsignInRefused: \"Your sign-in on this page was not accepted.\",\n\t/** `{reason}`: the relay's reason, as it gave it. */\n\tsignInRefusedWhy: \"Your sign-in on this page was not accepted ({reason}).\",\n\treadyApp: \"{app} is ready for your AI app.\",\n\treadyPage: \"This page is ready for your AI app.\",\n\taddressLabel: \"Add this address to your AI app:\",\n\thelp: \"How do I add it?\",\n\tguide: \"Step by step, and what to do when it fails\",\n\tcodeSentence: \"When asked, enter the code {code}\",\n\tcodeNote: \"A new code appears every 2 minutes and after each use.\",\n\tcodeUsed: \"Code used. Waiting for your AI app…\",\n\tsignIn:\n\t\t\"When your AI app asks, sign in with the account you use on this page. No code is needed.\",\n\tnewAddress: \"Disconnect all apps\",\n\tnewAddressNote:\n\t\t\"An AI app is connected that should not be? This disconnects every AI app from this page; each one has to connect again with a new code.\",\n\tnewAddressQuestionOne:\n\t\t\"This disconnects {apps}. To use this page with it again, connect it again and enter a new code.\",\n\tnewAddressQuestionMany:\n\t\t\"This disconnects {apps}. To use this page with them again, connect them again and enter a new code.\",\n\tnewAddressConfirm: \"Disconnect all\",\n\tcancel: \"Cancel\",\n\tgettingNewAddress: \"Disconnecting…\",\n\tnewAddressDone: \"Every AI app is disconnected. Connect yours again.\",\n\tconnectedOne: \"{apps} is connected\",\n\tconnectedMany: \"{apps} are connected\",\n\tconnectedNextOne:\n\t\t\"You can close this now and ask it to use the tools of this page.\",\n\tconnectedNextMany:\n\t\t\"You can close this now and ask them to use the tools of this page.\",\n\tconnectAnother: \"Connect another app\",\n\tconnectedHeading: \"Connected\",\n\tappConnected: \"{app} connected\",\n\tdisconnect: \"Disconnect\",\n\tdisconnectApp: \"Disconnect {app}\",\n\tdisconnectNote: \"To disconnect an app, connect this page again first.\",\n\t/** Disconnect failed: the relay could not save it (`store_unavailable`). */\n\tstoreUnavailable: \"The relay could not save this. Try again.\",\n\t/** Disconnect failed for another reason. */\n\tdisconnectFailed: \"Could not disconnect the app. Try again.\",\n\t/** Under a connected app: the tools allowed until reload for it. */\n\trunsWithoutAsking: \"Runs without asking: {tools}\",\n\taskAgain: \"Ask again\",\n\taskAgainApp: \"Ask again before {app} runs a tool\",\n\tcloseNote:\n\t\t\"Closing this stops the code. To connect later, open this again from the page.\",\n\tclose: \"Close\",\n\tdone: \"Done\",\n\n\t// The notice when another tab or program took over the address.\n\treplacedSiblingTitle: \"Opened in another tab\",\n\treplacedSibling:\n\t\t\"This page is open in another tab, and your AI apps now use that one. To use them here, connect this page again.\",\n\treplacedTitle: \"Another tab or program took over this page\",\n\treplaced:\n\t\t\"Your AI apps now reach that tab or program instead of this page. If you did not open this page in another tab or browser, someone may have copied what this page keeps to connect. “Disconnect all apps” ends that; then connect your AI apps again with a new code.\",\n\ttakenOverAgain:\n\t\t\"It was taken over again before its AI apps were disconnected. Try again.\",\n\t/** `{reason}`: why disconnecting all apps failed, one of the texts above. */\n\ttryAgainOrClose: \"{reason} Try again, or close this.\",\n};\n\n/** The texts of the dialogs: the keys of {@link STRINGS}, each a string. */\nexport type DialogStrings = { [K in keyof typeof STRINGS]: string };\n",
7
- "/**\n * Text an AI app or a page wrote, made safe to show to the user before they\n * approve something: characters that are invisible, blank or turn the text's\n * direction are written as escapes, so the text cannot look like something\n * else. Shared by the library's confirmation dialog and the tab-mcp browser extension.\n */\n\n/**\n * Characters that are invisible, blank or change the direction of the text\n * around them: controls (C0 and C1, but tab and line feed, which are only\n * JSON's layout), format characters (bidi controls and isolates, zero-width\n * ones, tags), the other default-ignorable ones (variation selectors, U+034F,\n * the Hangul fillers), private-use, unassigned and lone surrogate code\n * points, line and paragraph separators, every space but the plain one\n * (U+00A0, U+2007, U+3000…) and the Braille blank (U+2800).\n */\nconst INVISIBLE =\n\t/(?![\\t\\n ])[\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}\\p{Co}\\p{Cn}\\p{Cs}\\p{Zl}\\p{Zp}\\p{Zs}\\u{2800}]/gu;\n\n/**\n * `text` with each such character as `\\uXXXX` (a surrogate pair for one\n * beyond U+FFFF), as JSON would write it: JSON stays JSON for the same value.\n */\nexport function escapeInvisible(text: string): string {\n\treturn text.replace(INVISIBLE, (ch) => {\n\t\tlet escaped = \"\";\n\t\tfor (let i = 0; i < ch.length; i++)\n\t\t\tescaped += `\\\\u${ch.charCodeAt(i).toString(16).toUpperCase().padStart(4, \"0\")}`;\n\t\treturn escaped;\n\t});\n}\n",
8
- "/**\n * What the library's dialogs share: the stylesheet, elements, buttons, the\n * texts (`strings.ts`) and how a caller is named. The confirmation\n * (`confirm.ts`) and the connect dialog (`connect.ts`) are chunks of their\n * own, loaded on demand; pages with their own UI use the events and methods\n * of `TabMcp` instead.\n */\n\nimport { type DialogStrings, STRINGS } from \"./strings.ts\";\nimport type { DialogOptions, Grant, ToolCallClient } from \"./types.ts\";\nimport { escapeInvisible } from \"./visible.ts\";\n\nlet counter = 0;\n\n/** A new id for the elements of one dialog. */\nexport function nextId(): string {\n\treturn `tab-mcp-${++counter}`;\n}\n\n/** The texts: the page's own where it gave them, else the English ones. */\nexport function stringsOf(options: DialogOptions | undefined): DialogStrings {\n\tconst s: DialogStrings = { ...STRINGS };\n\t// Only strings: a missing translation (`undefined`) keeps the English text.\n\tfor (const [key, value] of Object.entries(options?.strings ?? {}))\n\t\tif (typeof value === \"string\" && key in s)\n\t\t\ts[key as keyof DialogStrings] = value;\n\treturn s;\n}\n\n/** `template` with its `{name}` placeholders filled in, as text. */\nexport function format(\n\ttemplate: string,\n\tvalues: Record<string, string>,\n): string {\n\treturn template.replace(\n\t\t/\\{(\\w+)\\}/g,\n\t\t(all, key: string) => values[key] ?? all,\n\t);\n}\n\n/**\n * `template` with its `{name}` placeholders filled in, as nodes: a string\n * value is a name, isolated so that it cannot reorder the words around it\n * (and may stand twice); a node is put in as it is.\n */\nexport function fill(\n\tdoc: Document,\n\ttemplate: string,\n\tvalues: Record<string, string | Node>,\n): (Node | string)[] {\n\treturn template.split(/\\{(\\w+)\\}/).map((part, i) => {\n\t\tif (i % 2 === 0) return part;\n\t\tconst value = values[part];\n\t\tif (value === undefined) return `{${part}}`;\n\t\treturn typeof value === \"string\" ? name(doc, value) : value;\n\t});\n}\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n\tdoc: Document,\n\ttag: K,\n\tprops: { className?: string; text?: string; id?: string } = {},\n\t...children: (Node | string)[]\n): HTMLElementTagNameMap[K] {\n\tconst node = doc.createElement(tag);\n\tif (props.className !== undefined) node.className = props.className;\n\tif (props.id !== undefined) node.id = props.id;\n\tif (props.text !== undefined) node.textContent = props.text;\n\tnode.append(...children);\n\treturn node;\n}\n\n/**\n * A button. `className` is its own class; `kind` marks the one next step\n * (`tab-mcp-primary`) or one that disconnects (`tab-mcp-danger`); without\n * one it is a plain, outlined button.\n */\nexport function button(\n\tdoc: Document,\n\ttext: string,\n\tonClick: () => void,\n\tclassName?: string,\n\tkind?: \"primary\" | \"danger\",\n): HTMLButtonElement {\n\tconst node = el(doc, \"button\", { text });\n\tnode.type = \"button\";\n\tif (className !== undefined) node.classList.add(className);\n\tif (kind !== undefined) node.classList.add(`tab-mcp-${kind}`);\n\tnode.addEventListener(\"click\", onClick);\n\treturn node;\n}\n\n/** A name in a sentence, isolated so that it cannot reorder the words around it. */\nexport function name(doc: Document, text: string): HTMLElement {\n\tconst node = el(doc, \"bdi\", { text });\n\tnode.dir = \"ltr\";\n\treturn node;\n}\n\n/** Invisible, blank and direction characters as `\\uXXXX` (`visible.ts`). */\nexport const visible: (text: string) => string = escapeInvisible;\n\n/**\n * How the dialogs name a caller: an AI app's name and verified host; for\n * the caller of a served port, the name the page gave it and what it is.\n */\nexport function clientLabel(\n\tclient: ToolCallClient | Grant[\"client\"],\n\ts: DialogStrings,\n): string {\n\tif (\"kind\" in client && client.kind === \"webmcp\") return s.clientWebMcp;\n\tif (\"kind\" in client && client.kind === \"local\")\n\t\treturn format(s.clientLocal, { name: visible(client.name ?? client.id) });\n\tconst host = visible(client.host || client.id);\n\treturn client.name !== undefined && client.name !== \"\"\n\t\t? format(s.clientRelay, { name: visible(client.name), host })\n\t\t: host;\n}\n\n/** \"A and B\", \"A, B and C\". */\nexport function listOf(items: string[], s: DialogStrings): string {\n\treturn items.length < 2\n\t\t? (items[0] ?? \"\")\n\t\t: `${items.slice(0, -1).join(\", \")} ${s.and} ${items.at(-1)}`;\n}\n\n/**\n * The look of the dialogs. Every selector has the specificity of one class\n * (the rest is in `:where()`), so rules of the page for elements, such as\n * `button { … }` or a reset's `* { border-width: 0 }`, do not change the\n * dialogs. The rules for states (hover, focus, disabled) and the primary\n * and danger buttons add two elements (`html dialog.…`, `html button.…`),\n * so `button:hover`, `button:focus` or `button:disabled` of the page do not\n * either. A page overrides with two classes, `.tab-mcp-dialog .tab-mcp-x`,\n * which wins over all of them; one class does not. The `--tab-mcp-*`\n * custom properties (on `:root` or on `.tab-mcp-dialog`) change single\n * values; the library only reads them. The defaults use system colours and the\n * page's `color-scheme`, so the dialogs follow its light or dark scheme. The\n * `--_tab-mcp-*` properties are internal. Order matters among equals.\n */\nexport const DIALOG_CSS = `.tab-mcp-dialog {\n--_tab-mcp-fg: var(--tab-mcp-color, CanvasText);\n--_tab-mcp-bg: var(--tab-mcp-background, Canvas);\n--_tab-mcp-muted: var(--tab-mcp-muted, color-mix(in srgb, var(--_tab-mcp-fg) 72%, transparent));\n--_tab-mcp-line: color-mix(in srgb, var(--_tab-mcp-fg) 22%, transparent);\n--_tab-mcp-surface: var(--tab-mcp-surface, color-mix(in srgb, var(--_tab-mcp-fg) 6%, transparent));\n--_tab-mcp-danger: var(--tab-mcp-danger, light-dark(#b3261e, #ffb4ab));\n--_tab-mcp-success: var(--tab-mcp-success, light-dark(#1a7f37, #6fdd8b));\n--_tab-mcp-mono: var(--tab-mcp-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);\n--_tab-mcp-small-radius: calc(var(--tab-mcp-radius, 0.75rem) * 0.6);\nbox-sizing: border-box; margin: auto; width: calc(100% - 2rem); max-width: var(--tab-mcp-max-width, 34rem); max-height: calc(100% - 2rem); overflow: auto;\nfont: var(--tab-mcp-font, inherit); line-height: 1.5; color: var(--_tab-mcp-fg); background: var(--_tab-mcp-bg);\nborder: var(--tab-mcp-border, 1px solid var(--_tab-mcp-line)); border-radius: var(--tab-mcp-radius, 0.75rem);\npadding: var(--tab-mcp-padding, clamp(1rem, 5vw, 1.5rem)); box-shadow: var(--tab-mcp-shadow, 0 1rem 3rem rgb(0 0 0 / 0.3));\npointer-events: auto;\n}\n.tab-mcp-dialog::backdrop { background: var(--tab-mcp-backdrop, rgb(0 0 0 / 0.4)); }\n.tab-mcp-dialog:where([open]) { display: flex; flex-direction: column; gap: 1rem; }\n.tab-mcp-dialog:where([open]) > * { flex-shrink: 0; }\n.tab-mcp-dialog :where([hidden]) { display: none !important; }\nhtml dialog.tab-mcp-dialog:where(:focus) { outline: none; }\n.tab-mcp-dialog :where(*) { box-sizing: border-box; color: inherit; }\n.tab-mcp-dialog :where(h2, h3, p, ul, li, pre) { margin: 0; }\n.tab-mcp-dialog :where(h2) { font-size: var(--tab-mcp-title-size, 1.25em); line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }\n.tab-mcp-dialog :where(h3) { font-size: 0.875em; font-weight: 600; color: var(--_tab-mcp-muted); margin-bottom: 0.5rem; }\n.tab-mcp-dialog :where(small) { font-size: 0.875em; }\n.tab-mcp-dialog :where(small, .tab-mcp-status, .tab-mcp-description, .tab-mcp-always-note, .tab-mcp-apps-note, .tab-mcp-success-next, .tab-mcp-waiting, .tab-mcp-scroll-note, .tab-mcp-allowed) { color: var(--_tab-mcp-muted); }\nhtml dialog.tab-mcp-dialog :where(:focus-visible) { outline: 2px solid var(--tab-mcp-focus, var(--_tab-mcp-fg)); outline-offset: 2px; }\n.tab-mcp-dialog :where(button) { font: inherit; font-size: 0.9375em; line-height: 1.25; text-transform: none; letter-spacing: normal; width: auto; min-height: 2.5rem; padding: 0.5rem 1rem; margin: 0; border: 1px solid color-mix(in srgb, currentColor 35%, transparent); border-radius: var(--_tab-mcp-small-radius); background: transparent; color: inherit; cursor: pointer; }\nhtml dialog.tab-mcp-dialog :where(button:hover:not(:disabled)) { color: inherit; background: color-mix(in srgb, currentColor 8%, transparent); }\nhtml dialog.tab-mcp-dialog :where(button:disabled) { opacity: 0.45; cursor: not-allowed; }\nhtml button.tab-mcp-primary { background: var(--tab-mcp-accent, var(--_tab-mcp-fg)); color: var(--tab-mcp-accent-text, var(--_tab-mcp-bg)); border-color: transparent; font-weight: 600; }\nhtml button.tab-mcp-primary:where(:hover:not(:disabled)) { background: var(--tab-mcp-accent, var(--_tab-mcp-fg)); opacity: 0.85; }\nhtml button.tab-mcp-danger { color: var(--_tab-mcp-danger); border-color: color-mix(in srgb, currentColor 45%, transparent); }\n.tab-mcp-copy { min-width: 6em; }\n.tab-mcp-close { font-size: 0.875em; }\n.tab-mcp-status { margin-top: -0.5rem; }\n.tab-mcp-description:where(:empty) { display: none; }\n.tab-mcp-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; }\n.tab-mcp-address { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }\n.tab-mcp-address :where(label) { flex-basis: 100%; font-weight: 600; }\n.tab-mcp-address :where(input) { flex: 1 1 12rem; min-width: 0; min-height: 2.5rem; margin: 0; padding: 0.5rem 0.625rem; font: 0.875em var(--_tab-mcp-mono); text-overflow: ellipsis; color: inherit; background: var(--_tab-mcp-surface); border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-code { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0.25rem 1rem; padding: 1rem; background: var(--_tab-mcp-surface); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-code > :where(span) { font-weight: 600; }\n.tab-mcp-code :where(br) { display: none; }\n.tab-mcp-code :where(small) { grid-column: 1 / -1; }\n.tab-mcp-code-value { display: block; font: 700 var(--tab-mcp-code-size, 2em) / 1.2 var(--_tab-mcp-mono); letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }\n.tab-mcp-help { border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-help :where(summary) { padding: 0.75rem 1rem; font-weight: 600; cursor: pointer; }\n.tab-mcp-help > :where(:not(summary)) { margin-inline: 1rem; }\n.tab-mcp-help > :where(:last-child:not(summary)) { margin-bottom: 1rem; }\n.tab-mcp-dialog :where(.tab-mcp-help ul, .tab-mcp-apps ul) { list-style: none; padding: 0; display: grid; gap: 0.5rem; }\n.tab-mcp-help :where(ul) { margin-top: 0.25rem; margin-bottom: 0.75rem; gap: 0.75rem; }\n.tab-mcp-help :where(li) { overflow-wrap: anywhere; }\n.tab-mcp-help :where(strong) { display: block; font-weight: 600; }\n.tab-mcp-command { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 0.5rem; margin-top: 0.375rem; }\n.tab-mcp-command > :where(pre) { flex: 1 1 16rem; min-width: 0; margin: 0; padding: 0.5rem 0.625rem; font: 0.8125em / 1.5 var(--_tab-mcp-mono); white-space: pre-wrap; word-break: break-all; background: var(--_tab-mcp-surface); border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-command-note { display: block; margin-top: 0.375rem; }\n.tab-mcp-help :where(code) { font: 0.875em var(--_tab-mcp-mono); padding: 0.125em 0.375em; background: var(--_tab-mcp-surface); border-radius: 0.25rem; -webkit-box-decoration-break: clone; box-decoration-break: clone; }\n.tab-mcp-apps :where(li) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; padding: 0.5rem 0.5rem 0.5rem 0.75rem; border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-app { flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }\n.tab-mcp-allowed { display: flex; flex-basis: 100%; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.875em; overflow-wrap: anywhere; }\n.tab-mcp-apps-note { margin-top: 0.5rem; }\n.tab-mcp-success { display: flex; align-items: center; gap: 0.875rem; padding: 1rem; background: color-mix(in srgb, var(--_tab-mcp-success) 10%, transparent); border: 1px solid color-mix(in srgb, var(--_tab-mcp-success) 45%, transparent); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-success-icon { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; font-size: 1.5em; font-weight: 700; line-height: 1; color: var(--_tab-mcp-success); background: color-mix(in srgb, var(--_tab-mcp-success) 16%, transparent); }\n.tab-mcp-success-icon::before { content: \"\\\\2713\"; }\n.tab-mcp-success-text { display: grid; gap: 0.125rem; min-width: 0; }\n.tab-mcp-success-title { font-size: 1.125em; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }\n.tab-mcp-setup { display: flex; flex-direction: column; gap: 1rem; }\n.tab-mcp-setup-toggle { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.75rem 1rem; text-align: start; font-weight: 600; border-color: var(--_tab-mcp-line); }\n.tab-mcp-setup-toggle::before { content: \"\"; flex: none; width: 0.45em; height: 0.45em; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateX(-0.1em) rotate(-45deg); }\n.tab-mcp-setup-toggle:where([aria-expanded=\"true\"])::before { transform: translateY(-0.15em) rotate(45deg); }\n.tab-mcp-code-used { display: flex; align-items: center; min-height: calc(var(--tab-mcp-code-size, 2em) * 1.2); }\n.tab-mcp-new-address-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }\n.tab-mcp-new-address-row > :where(small) { flex: 1 1 14rem; color: var(--_tab-mcp-muted); }\n.tab-mcp-new-address-question { display: grid; gap: 0.75rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--_tab-mcp-danger) 50%, transparent); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-connect > :where(.tab-mcp-actions) { gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--_tab-mcp-line); }\n.tab-mcp-close-note { flex: 1 1 12rem; }\n.tab-mcp-confirm :where(p bdi) { font-weight: 600; }\n.tab-mcp-arguments { box-sizing: content-box; font: 0.875em / 1.45 var(--_tab-mcp-mono); padding: 0.75rem; background: var(--_tab-mcp-surface); border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-always-note, .tab-mcp-waiting, .tab-mcp-scroll-note { font-size: 0.875em; }\n@media (max-width: 30rem) { .tab-mcp-actions > :where(button) { flex: 1 1 auto; } .tab-mcp-connect > :where(.tab-mcp-actions) > :where(button) { flex: 0 0 auto; } .tab-mcp-code { grid-template-columns: minmax(0, 1fr); } .tab-mcp-code > :where(button) { justify-self: start; } }\n@media (prefers-reduced-motion: no-preference) { .tab-mcp-dialog:where([open]) { animation: tab-mcp-in 0.15s ease-out; } .tab-mcp-success-icon { animation: tab-mcp-pop 0.4s cubic-bezier(0.3, 1.4, 0.6, 1); } }\n@media (forced-colors: active) { html button.tab-mcp-primary { border-color: ButtonText; } }\n@keyframes tab-mcp-in { from { opacity: 0; transform: translateY(0.5rem); } }\n@keyframes tab-mcp-pop { from { opacity: 0; transform: scale(0.4); } }\n`;\n\nconst sheets = new WeakMap<Document, CSSStyleSheet>();\n\n/**\n * Adopts `DIALOG_CSS` into the document once, next to the page's own adopted\n * sheets. A constructed stylesheet needs no `style-src` exception under a\n * strict CSP. Where constructed stylesheets are not supported, the dialogs\n * keep the browser's default look and work the same.\n */\nfunction adoptStyles(doc: Document): void {\n\ttry {\n\t\tlet sheet = sheets.get(doc);\n\t\tif (sheet === undefined) {\n\t\t\tconst Sheet = (doc.defaultView as (Window & typeof globalThis) | null)\n\t\t\t\t?.CSSStyleSheet;\n\t\t\tif (Sheet === undefined || !Array.isArray(doc.adoptedStyleSheets)) return;\n\t\t\tsheet = new Sheet();\n\t\t\tsheet.replaceSync(DIALOG_CSS);\n\t\t\tsheets.set(doc, sheet);\n\t\t}\n\t\t// The page may have replaced the list since.\n\t\tif (!doc.adoptedStyleSheets.includes(sheet))\n\t\t\tdoc.adoptedStyleSheets = [...doc.adoptedStyleSheets, sheet];\n\t} catch {\n\t\t// Not supported: the default look.\n\t}\n}\n\n/**\n * A dialog with its heading (`title`, or filled in by the caller). It\n * carries the texts' language and direction (`lang`, `dir` of the\n * strings), whatever the page's: read out with that voice, laid out that way.\n */\nexport function newDialog(\n\tdoc: Document,\n\tclassName: string,\n\ts: DialogStrings,\n\t...title: (Node | string)[]\n): { dialog: HTMLDialogElement; heading: HTMLHeadingElement; id: string } {\n\tconst id = nextId();\n\tconst dialog = el(doc, \"dialog\", {\n\t\tclassName: `tab-mcp-dialog ${className}`,\n\t});\n\tdialog.setAttribute(\"aria-labelledby\", `${id}-title`);\n\tdialog.lang = s.lang;\n\tdialog.dir = s.dir;\n\tadoptStyles(doc);\n\tconst heading = el(doc, \"h2\", { id: `${id}-title` }, ...title);\n\tdialog.append(heading);\n\treturn { dialog, heading, id };\n}\n\n/** How long a Copy button says \"Copied\", and how long it says to press Ctrl+C. */\nexport const COPIED_MS = 2000;\nexport const SELECTED_MS = 8000;\n\n/** What the button says after a refused Copy, by the user's device. */\nfunction pressToCopy(doc: Document, s: DialogStrings): string {\n\tconst view = doc.defaultView;\n\tif (view?.matchMedia?.(\"(pointer: coarse)\").matches === true)\n\t\treturn s.selected;\n\tconst platform = view?.navigator.platform ?? \"\";\n\treturn /^(Mac|iP)/.test(platform) ? s.pressMac : s.pressOther;\n}\n\n/**\n * A Copy button for `value()`, read at click time. Says \"Copied\" for a\n * moment once the clipboard took it; without a clipboard (or when it refuses)\n * `select()` puts the text in the selection and the button says to press\n * Ctrl+C (⌘C on Apple devices). `label` names it for assistive technology\n * (\"Copy code\"), as the dialog has more than one Copy; while it says what\n * happened, that is its name, and `announce` says it too.\n */\nexport function copyButton(\n\tdoc: Document,\n\ts: DialogStrings,\n\tlabel: string,\n\tvalue: () => string,\n\tselect: () => void,\n\tannounce: (text: string) => void,\n\tclassName: string,\n\tkind?: \"primary\",\n): { button: HTMLButtonElement; reset: () => void } {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst say = (text: string, ms: number) => {\n\t\tnode.textContent = text;\n\t\tnode.removeAttribute(\"aria-label\");\n\t\tannounce(text);\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(reset, ms);\n\t};\n\tconst node = button(\n\t\tdoc,\n\t\ts.copy,\n\t\t() => {\n\t\t\tconst clipboard = (doc.defaultView?.navigator as Navigator | undefined)\n\t\t\t\t?.clipboard;\n\t\t\tconst selected = () => {\n\t\t\t\tselect();\n\t\t\t\tsay(pressToCopy(doc, s), SELECTED_MS);\n\t\t\t};\n\t\t\tif (clipboard !== undefined)\n\t\t\t\tclipboard\n\t\t\t\t\t.writeText(value())\n\t\t\t\t\t.then(() => say(s.copied, COPIED_MS), selected);\n\t\t\telse selected();\n\t\t},\n\t\tclassName,\n\t\tkind,\n\t);\n\t// The same width for \"Copy\" and \"Copied\": nothing moves.\n\tnode.classList.add(\"tab-mcp-copy\");\n\tconst reset = () => {\n\t\tclearTimeout(timer);\n\t\ttimer = undefined;\n\t\tnode.textContent = s.copy;\n\t\tnode.setAttribute(\"aria-label\", label);\n\t};\n\treset();\n\treturn { button: node, reset };\n}\n"
9
- ],
10
- "mappings": "AAeA,IAAM,EAAO,CAAC,IAAmB,KAAK,UAAU,CAAC,EAAK,MAAO,EAAK,WAAW,CAAC,EAEvE,MAAM,CAAc,CAEjB,GAAS,IAAI,IAIb,GAAa,IAAI,IAE1B,GAAG,CAAC,EAAiB,EAAyB,CAC7C,IAAM,EAAQ,KAAK,GAAO,IAAI,CAAO,EAC/B,EAAU,GAAO,IAAI,EAAK,IAAI,GAAG,KACvC,GAAI,IAAY,QAAa,IAAY,EAAK,CAAI,EACjD,OAAO,IAAY,OAKpB,OAFA,GAAO,OAAO,EAAK,IAAI,EACvB,KAAK,GAAS,EACP,GAGR,GAAG,CAAC,EAAiB,EAAsB,CAC1C,IAAM,EAAQ,KAAK,GAAO,IAAI,CAAO,GAAK,IAAI,IAC9C,EAAM,IAAI,EAAK,KAAM,CAAE,KAAM,EAAK,CAAI,EAAG,MAAO,EAAK,OAAS,EAAK,IAAK,CAAC,EACzE,KAAK,GAAO,IAAI,EAAS,CAAK,EAC9B,KAAK,GAAS,EAIf,IAAI,CAAC,EAA2B,CAC/B,MAAO,CAAC,GAAI,KAAK,GAAO,IAAI,CAAO,GAAG,OAAO,GAAK,CAAC,CAAE,EAAE,IAAI,CAAC,IAAM,EAAE,KAAK,EAI1E,MAAM,CAAC,EAAuB,CAC7B,GAAI,KAAK,GAAO,OAAO,CAAO,EAAG,KAAK,GA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EAAY,EAAK,CAAC,EAAG,CAAW,GAErC,GAAI,IAAc,OACjB,EACE,UAAU,EAAM,CAAC,EACjB,KAAK,IAAM,EAAI,EAAE,OAAQ,CAAS,EAAG,CAAQ,EAChD,KAAK,EAAS,GAEf,EACA,CACD,EAEA,EAAK,UAAU,IAAI,cAAc,EACjC,IAAM,EAAQ,IAAM,CACnB,aAAa,CAAK,EAClB,EAAQ,OACR,EAAK,YAAc,EAAE,KACrB,EAAK,aAAa,aAAc,CAAK,GAGtC,OADA,EAAM,EACC,CAAE,OAAQ,EAAM,OAAM",
11
- "debugId": "137DBC183F30B17464756E2164756E21",
12
- "names": []
13
- }
@@ -1,10 +0,0 @@
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 the tools a user allowed\n * until reload (`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 { ConfirmRequest, DialogOptions } 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 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/** Offer \"Allow until reload\". */\n\talwaysAllow?: boolean | 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. \"Allow until reload\" is offered\n * only with `alwaysAllow` (DEC-096). 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 \"Allow until reload\" 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 until reload 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 Allow until reload when the page offers it.\n\tconst approve = [approving(s.allow, \"allow\", \"tab-mcp-allow\")];\n\tconst extra: HTMLElement[] = [];\n\tif (options.alwaysAllow === true) {\n\t\t// Left of Allow: not where most platforms put the default (CU 11).\n\t\tapprove.unshift(approving(s.allowUntilReload, \"always\", \"tab-mcp-always\"));\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, 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 allowed until\n * reload (`always-allowed.ts`). Only for an AI app through the relay: an\n * agent in the browser and a served port have no identity to remember an\n * answer for (DEC-115, DEC-124).\n */\nexport function confirmInPage(\n\tmcp: TabMcp,\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: {\n\t\talwaysAllow?: boolean | undefined;\n\t\tui?: DialogOptions | undefined;\n\t\t/** Tests only. */\n\t\tallowDelayMs?: number | undefined;\n\t} = {},\n): Promise<boolean> {\n\tconst { client } = request;\n\tconst dialogOptions = {\n\t\tstrings: stringsOf(options.ui),\n\t\tallowDelayMs: options.allowDelayMs,\n\t};\n\tif (client.kind !== \"relay\")\n\t\treturn confirmDialog(request, doc, dialogOptions).then(\n\t\t\t(answer) => answer === \"allow\",\n\t\t);\n\tconst { grantId } = client;\n\tconst allowed = allowedFor(mcp);\n\tconst allowedNow = () => allowed.has(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 until reload.\n\treturn confirmDialog(request, doc, {\n\t\t...dialogOptions,\n\t\talwaysAllow: options.alwaysAllow,\n\t\tallowedNow,\n\t}).then((answer) => {\n\t\t// Only while the grant is still there: a revoked app gets nothing.\n\t\tif (answer === \"always\" && mcp.grants.some((g) => g.grantId === grantId))\n\t\t\tallowed.add(grantId, request.tool);\n\t\treturn answer !== \"deny\";\n\t});\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;AA4BA,SAAS,aAAa,CAAC,MAAmD;AAAA,EACzE,IAAI;AAAA,IACH,OAAO,QAAQ,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,IAC3C,MAAM;AAAA,IACP;AAAA;AAAA;AAQK,IAAM,iBAAiB;AAM9B,IAAM,sBAAsB;AAyB5B,IAAM,SAAS,IAAI;AAkBZ,SAAS,aAAa,CAC5B,SACA,KACA,UAAgC,CAAC,GACT;AAAA,EACxB,IAAI,QAAQ,OAAO;AAAA,IAAS,OAAO,QAAQ,QAAQ,MAAM;AAAA,EACzD,IAAI,QAAQ,OAAO,I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