@ractive-ch/tab-mcp-client 0.20.0 → 0.21.0-rc.2

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 (65) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +156 -58
  3. package/cdn/confirm-xgm1ymd0.min.js +4 -0
  4. package/cdn/confirm-xgm1ymd0.min.js.map +10 -0
  5. package/cdn/{connect-my0pbqd7.min.js → connect-3reh9k1f.min.js} +4 -4
  6. package/cdn/{connect-my0pbqd7.min.js.map → connect-3reh9k1f.min.js.map} +4 -4
  7. package/cdn/connection-cxgns38v.min.js +17 -0
  8. package/cdn/{connection-5x2krvfs.min.js.map → connection-cxgns38v.min.js.map} +5 -5
  9. package/cdn/strings.min.js +1 -1
  10. package/cdn/tab-mcp-client-gdj1e1wh.min.js +5 -0
  11. package/cdn/tab-mcp-client-gdj1e1wh.min.js.map +11 -0
  12. package/cdn/{tab-mcp-client-8r6h3wza.min.js → tab-mcp-client-yjcmhpdf.min.js} +5 -5
  13. package/cdn/tab-mcp-client-yjcmhpdf.min.js.map +11 -0
  14. package/cdn/tab-mcp-client.min.js +3 -3
  15. package/cdn/tab-mcp-client.min.js.map +4 -4
  16. package/cdn/webmcp-8xby3trn.min.js +4 -0
  17. package/cdn/{webmcp-ny13npet.min.js.map → webmcp-8xby3trn.min.js.map} +3 -3
  18. package/command.d.ts +9 -3
  19. package/{confirm-hymzwx3b.js → confirm-7de6dvpb.js} +11 -6
  20. package/confirm-7de6dvpb.js.map +10 -0
  21. package/confirm.d.ts +10 -5
  22. package/{connect-fhtjdmf3.js → connect-bc628ax6.js} +4 -4
  23. package/{connection-krd3ncrn.js → connection-arq7qm7b.js} +26 -11
  24. package/connection-arq7qm7b.js.map +16 -0
  25. package/connection.d.ts +8 -3
  26. package/dialog.d.ts +2 -2
  27. package/{index-7qqhn3zv.js → index-bt1rkngm.js} +3 -5
  28. package/index-bt1rkngm.js.map +10 -0
  29. package/{index-00p8b969.js → index-erm4h3sn.js} +2 -3
  30. package/index-erm4h3sn.js.map +11 -0
  31. package/{index-1tssct09.js → index-xx4gmtk5.js} +6 -4
  32. package/index-xx4gmtk5.js.map +11 -0
  33. package/index.js +15 -8
  34. package/index.js.map +4 -4
  35. package/internal.d.ts +7 -3
  36. package/mcp.d.ts +12 -5
  37. package/package.json +1 -1
  38. package/react.js +9 -5
  39. package/react.js.map +3 -3
  40. package/secret.d.ts +2 -1
  41. package/setup.d.ts +5 -5
  42. package/setup.js +2 -2
  43. package/skill/SKILL.md +476 -0
  44. package/skill/references/react.md +59 -0
  45. package/skill/references/sign-in.md +28 -0
  46. package/strings.d.ts +0 -1
  47. package/strings.js +1 -1
  48. package/tab-mcp.d.ts +2 -2
  49. package/types.d.ts +40 -18
  50. package/{webmcp-acj1tef8.js → webmcp-gw6rrbnh.js} +24 -3
  51. package/{webmcp-acj1tef8.js.map → webmcp-gw6rrbnh.js.map} +3 -3
  52. package/webmcp.d.ts +11 -4
  53. package/cdn/confirm-ba3dkf9p.min.js +0 -4
  54. package/cdn/confirm-ba3dkf9p.min.js.map +0 -10
  55. package/cdn/connection-5x2krvfs.min.js +0 -17
  56. package/cdn/tab-mcp-client-8r6h3wza.min.js.map +0 -11
  57. package/cdn/tab-mcp-client-nnxcwrxp.min.js +0 -5
  58. package/cdn/tab-mcp-client-nnxcwrxp.min.js.map +0 -11
  59. package/cdn/webmcp-ny13npet.min.js +0 -4
  60. package/confirm-hymzwx3b.js.map +0 -10
  61. package/connection-krd3ncrn.js.map +0 -16
  62. package/index-00p8b969.js.map +0 -11
  63. package/index-1tssct09.js.map +0 -11
  64. package/index-7qqhn3zv.js.map +0 -10
  65. /package/{connect-fhtjdmf3.js.map → connect-bc628ax6.js.map} +0 -0
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/dialog.ts"],
4
+ "sourcesContent": [
5
+ "/**\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, type PluralText, withEnglish } from \"./strings.ts\";\nimport { directionOf, format, listFormat, pluralForm } from \"./text.ts\";\nimport type {\n\tDialogOptions,\n\tGrant,\n\tLocalClient,\n\tRelayClient,\n} from \"./types.ts\";\nimport { escapeInvisible } from \"./visible.ts\";\n\nexport { format, listOf, plural } from \"./text.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 (`ui.strings`) where it gave them, else English. */\nexport function stringsOf(options: DialogOptions | undefined): DialogStrings {\n\treturn withEnglish(options?.strings);\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/**\n * The form of `text` for the number of `names`, with `{apps}` the names as\n * the texts' language lists them (\"A, B and C\"), each name isolated like\n * every other name in a dialog, as nodes.\n */\nexport function pluralNames(\n\tdoc: Document,\n\ttext: PluralText,\n\tnames: string[],\n\ts: DialogStrings,\n): (Node | string)[] {\n\tconst list = el(\n\t\tdoc,\n\t\t\"span\",\n\t\t{},\n\t\t...listFormat(s)\n\t\t\t.formatToParts(names)\n\t\t\t.map((part) =>\n\t\t\t\tpart.type === \"element\" ? name(doc, part.value) : part.value,\n\t\t\t),\n\t);\n\treturn fill(doc, pluralForm(text, names.length, s), { apps: list });\n}\n\n/** What each element shows through `showNames`, so that it is made only on a change. */\nconst shownNames = new WeakMap<Element, string>();\n\n/**\n * `node` says `text` for `names` (`pluralNames`), or nothing when there are\n * none. Its nodes are made again only when the words change: a render that\n * changes nothing removes nothing (a screen reader keeps its place).\n */\nexport function showNames(\n\tdoc: Document,\n\tnode: Element,\n\ttext: PluralText,\n\tnames: string[],\n\ts: DialogStrings,\n): void {\n\tconst key =\n\t\tnames.length === 0\n\t\t\t? \"\"\n\t\t\t: [pluralForm(text, names.length, s), ...names].join(\"\\n\");\n\tif ((shownNames.get(node) ?? \"\") === key) return;\n\tshownNames.set(node, key);\n\tnode.replaceChildren(\n\t\t...(names.length === 0 ? [] : pluralNames(doc, text, names, s)),\n\t);\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: RelayClient | LocalClient | Grant[\"client\"],\n\ts: DialogStrings,\n): string {\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/**\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) { 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: grid; flex-basis: 100%; gap: 0.25rem; padding-top: 0.5rem; border-top: 1px solid var(--_tab-mcp-line); font-size: 0.875em; overflow-wrap: anywhere; }\n.tab-mcp-allowed-title { font-weight: 600; color: var(--_tab-mcp-muted); }\n.tab-mcp-switches { display: grid; gap: 0.125rem; }\n.tab-mcp-switch { display: flex; align-items: center; gap: 0.625rem; min-height: 2rem; cursor: pointer; }\n.tab-mcp-switch > :where(input) { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 2.25rem; height: 1.25rem; margin: 0; padding: 0; border: 1px solid var(--_tab-mcp-line); border-radius: 0.625rem; background: var(--_tab-mcp-surface); cursor: pointer; }\n.tab-mcp-switch > :where(input)::before { content: \"\"; position: absolute; top: 2px; left: 2px; width: calc(1.25rem - 6px); height: calc(1.25rem - 6px); border-radius: 50%; background: var(--_tab-mcp-muted); }\n.tab-mcp-switch > :where(input:checked) { background: var(--tab-mcp-accent, var(--_tab-mcp-fg)); border-color: transparent; }\n.tab-mcp-switch > :where(input:checked)::before { left: calc(100% - 1.25rem + 4px); background: var(--tab-mcp-accent-text, var(--_tab-mcp-bg)); }\nhtml dialog.tab-mcp-dialog :where(.tab-mcp-switch > input:disabled) { opacity: 0.45; cursor: not-allowed; }\n.tab-mcp-destructive { color: var(--_tab-mcp-danger); }\n.tab-mcp-everything { font-weight: 600; }\n.tab-mcp-everything-note { color: var(--_tab-mcp-muted); }\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-disconnect-all-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }\n.tab-mcp-disconnect-all-row > :where(small) { flex: 1 1 14rem; color: var(--_tab-mcp-muted); }\n.tab-mcp-disconnect-all-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); } .tab-mcp-switch > :where(input)::before { transition: left 0.15s ease-out; } }\n@media (forced-colors: active) { html button.tab-mcp-primary { border-color: ButtonText; } .tab-mcp-switch > :where(input) { forced-color-adjust: none; background: Canvas; border-color: ButtonText; } .tab-mcp-switch > :where(input)::before { forced-color-adjust: none; background: ButtonText; } .tab-mcp-switch > :where(input:checked) { background: Highlight; } .tab-mcp-switch > :where(input:checked)::before { background: HighlightText; } }\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` of the strings, and\n * `dir` or the direction of that language), whatever the page's: read out\n * 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 = directionOf(s);\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"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;AAoBA,IAAI,UAAU;AAGP,SAAS,MAAM,GAAW;AAAA,EAChC,OAAO,WAAW,EAAE;AAAA;AAId,SAAS,SAAS,CAAC,SAAmD;AAAA,EAC5E,OAAO,aAAY,SAAS,OAAO;AAAA;AAQ7B,SAAS,IAAI,CACnB,KACA,UACA,QACoB;AAAA,EACpB,OAAO,SAAS,MAAM,WAAW,EAAE,IAAI,CAAC,MAAM,MAAM;AAAA,IACnD,IAAI,IAAI,MAAM;AAAA,MAAG,OAAO;AAAA,IACxB,MAAM,QAAQ,OAAO;AAAA,IACrB,IAAI,UAAU;AAAA,MAAW,OAAO,IAAI;AAAA,IACpC,OAAO,OAAO,UAAU,WAAW,KAAK,KAAK,KAAK,IAAI;AAAA,GACtD;AAAA;AAGK,SAAS,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AC7C,OAAO,YAAY,KAAK,QAAQ,IAAI,EAAE,WAAW,EAAE;AAAA;AAW7C,SAAS,UAAU,CACzB,KACA,GACA,OACA,OACA,QACA,UACA,WACA,MACmD;AAAA,EACnD,IAAI;AAAA,EACJ,MAAM,MAAM,CAAC,MAAc,OAAe;AAAA,IACzC,KAAK,cAAc;AAAA,IACnB,KAAK,gBAAgB,YAAY;AAAA,IACjC,SAAS,IAAI;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,QAAQ,WAAW,OAAO,EAAE;AAAA;AAAA,EAE7B,MAAM,OAAO,OACZ,KACA,EAAE,MACF,MAAM;AAAA,IACL,MAAM,YAAa,IAAI,aAAa,WACjC;AAAA,IACH,MAAM,WAAW,MAAM;AAAA,MACtB,OAAO;AAAA,MACP,IAAI,YAAY,KAAK,CAAC,GAAG,WAAW;AAAA;AAAA,IAErC,IAAI,cAAc;AAAA,MACjB,UACE,UAAU,MAAM,CAAC,EACjB,KAAK,MAAM,IAAI,EAAE,QAAQ,SAAS,GAAG,QAAQ;AAAA,IAChD;AAAA,MAAK,SAAS;AAAA,KAEf,WACA,IACD;AAAA,EAEA,KAAK,UAAU,IAAI,cAAc;AAAA,EACjC,MAAM,QAAQ,MAAM;AAAA,IACnB,aAAa,KAAK;AAAA,IAClB,QAAQ;AAAA,IACR,KAAK,cAAc,EAAE;AAAA,IACrB,KAAK,aAAa,cAAc,KAAK;AAAA;AAAA,EAEtC,MAAM;AAAA,EACN,OAAO,EAAE,QAAQ,MAAM,MAAM;AAAA;",
8
+ "debugId": "41B35B2C4BA2238564756E2164756E21",
9
+ "names": []
10
+ }
@@ -60,7 +60,6 @@ var english = {
60
60
  other: "{n} more calls are waiting after this one."
61
61
  },
62
62
  titlePrefix: "Allow? – ",
63
- clientWebMcp: "An agent in this browser",
64
63
  clientLocal: "{name} (this site's assistant)",
65
64
  clientRelay: "{name} ({host})",
66
65
  copy: "Copy",
@@ -217,5 +216,5 @@ async function pickStrings2(tables, languages = globalThis.navigator?.languages
217
216
 
218
217
  export { format, pluralForm, plural, listFormat, directionOf, STRINGS2, withEnglish2, pickStrings2 };
219
218
 
220
- //# debugId=395C334D22BBAAE964756E2164756E21
221
- //# sourceMappingURL=index-00p8b969.js.map
219
+ //# debugId=A18E3688F5C8FB3A64756E2164756E21
220
+ //# sourceMappingURL=index-erm4h3sn.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/text.ts", "../src/strings.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Filling in the texts of `strings.ts`: placeholders, plural forms and lists,\n * by the rules of the texts' language (`Intl`), not by grammar made by hand.\n * No DOM and no texts, so that `./react` can use it without loading the\n * table, as well as the dialogs.\n */\n\nimport type { DialogStrings, PluralText } from \"./strings.ts\";\n\n/** What the helpers need of the texts: their language. */\ntype InLanguage = { lang: string };\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 * `Intl` objects for the texts' language; a `lang` the browser cannot\n * read (a malformed tag throws) uses English rules instead.\n */\nfunction inLanguage<T>(make: (lang: string) => T, lang: string): T {\n\ttry {\n\t\treturn make(lang);\n\t} catch {\n\t\treturn make(\"en\");\n\t}\n}\n\n/** Whether `value` is a plural text: an object of strings with `other`. */\nexport const isPlural = (value: unknown): value is PluralText =>\n\ttypeof value === \"object\" &&\n\tvalue !== null &&\n\ttypeof (value as { other?: unknown }).other === \"string\" &&\n\tObject.values(value).every((form) => typeof form === \"string\");\n\nconst warned = new WeakSet<object>();\n\n/**\n * A table with texts but no `lang` is taken as English: its plural forms\n * follow English rules and the dialogs say `lang=\"en\"`. Said once per table\n * in the console, as it is almost always a translation that forgot its tag.\n */\nexport function warnWithoutLang(strings: object | undefined): void {\n\tif (strings === undefined || warned.has(strings)) return;\n\tconst texts = Object.entries(strings).filter(\n\t\t([key, value]) => key !== \"lang\" && key !== \"dir\" && value !== undefined,\n\t);\n\tif (texts.length === 0 || typeof (strings as InLanguage).lang === \"string\")\n\t\treturn;\n\twarned.add(strings);\n\tconsole.warn(\n\t\t\"tab-mcp: ui.strings has texts but no lang, so they count as English (plural forms, lists, the dialogs' lang). Add lang, the language tag of the texts.\",\n\t);\n}\n\n/**\n * The form of `text` for the count `n`, by the plural rules of the texts'\n * language, with `{n}` filled in; `other` where the table lacks the form.\n */\nexport function pluralForm(text: PluralText, n: number, s: InLanguage): string {\n\tconst category = inLanguage((l) => new Intl.PluralRules(l), s.lang).select(n);\n\treturn format(text[category] ?? text.other, { n: String(n) });\n}\n\n/** `pluralForm` with the other placeholders filled in too, as text. */\nexport function plural(\n\ttext: PluralText,\n\tn: number,\n\ts: InLanguage,\n\tvalues: Record<string, string> = {},\n): string {\n\treturn format(pluralForm(text, n, s), values);\n}\n\n/** How the texts' language joins a list (\"A, B and C\"). */\nexport function listFormat(s: InLanguage): Intl.ListFormat {\n\treturn inLanguage(\n\t\t(l) => new Intl.ListFormat(l, { type: \"conjunction\" }),\n\t\ts.lang,\n\t);\n}\n\n/** \"A and B\", \"A, B and C\", as the texts' language joins a list. */\nexport function listOf(items: string[], s: InLanguage): string {\n\treturn listFormat(s).format(items);\n}\n\n/**\n * The direction of the texts: their own `dir`, else the one the browser\n * knows for `lang` (`Intl.Locale`'s text info, not in every browser), else\n * left to right.\n */\nexport function directionOf(s: DialogStrings): \"ltr\" | \"rtl\" {\n\tif (s.dir !== undefined) return s.dir;\n\ttry {\n\t\tconst locale = new Intl.Locale(s.lang) as Intl.Locale & {\n\t\t\tgetTextInfo?: () => { direction?: string };\n\t\t\ttextInfo?: { direction?: string };\n\t\t};\n\t\tconst info = locale.getTextInfo?.() ?? locale.textInfo;\n\t\treturn info?.direction === \"rtl\" ? \"rtl\" : \"ltr\";\n\t} catch {\n\t\treturn \"ltr\";\n\t}\n}\n",
6
+ "/**\n * `@ractive-ch/tab-mcp-client/strings`: every text the library can show to\n * a person, in English, in one table (`STRINGS`), `pickStrings` to choose\n * a page's own translation by the user's languages, and `withEnglish` for\n * a page that shows these texts in its own UI. The package ships English only;\n * a page passes its own table once, as `ui.strings` of `TabMcp` (or of\n * `<TabMcpProvider>`), and every missing key stays English.\n *\n * `{name}` is a placeholder the library fills in: names of tools and AI\n * apps (isolated, so that they cannot reorder the sentence), the code,\n * counts. A text that depends on a count is a {@link PluralText}, one form\n * per plural category of the language (`Intl.PluralRules`). Lists of names\n * are joined by `Intl.ListFormat`. Both follow `lang`, the language of the\n * texts, which the dialogs also set on themselves with its direction.\n *\n * Texts an AI app reads (tool results, refusals) are not here: they stay\n * English on purpose, as the AI app quotes them back in its own words.\n */\n\nimport { isPlural, warnWithoutLang } from \"./text.ts\";\n\n/**\n * A text that depends on a count `{n}` (or on the number of names in a\n * list): one form per plural category the language has, as\n * `Intl.PluralRules` names them. `other` is required; English needs `one`\n * and `other`, Polish `one`, `few`, `many` and `other`, Japanese only\n * `other`. A category the table lacks uses `other`.\n */\nexport type PluralText = { other: string } & {\n\t[category in Intl.LDMLPluralRule]?: string;\n};\n\nconst english = {\n\t/**\n\t * The language of the texts (a BCP 47 tag): set on every dialog, and the\n\t * language `Intl.PluralRules` and `Intl.ListFormat` follow.\n\t */\n\tlang: \"en\",\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 once\",\n\t/** `alwaysAllow: true`: kept until the AI app is disconnected. */\n\talwaysAllow: \"Always allow\",\n\talwaysAllowNote:\n\t\t\"Always allow: {tool} will run for {client} without asking, with any arguments, until you disconnect {client} from this page.\",\n\t/** `alwaysAllow: \"until-reload\"`, or kept in memory only (`storage: null`). */\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\twaiting: {\n\t\tone: \"{n} more call is waiting after this one.\",\n\t\tother: \"{n} more calls are waiting after this one.\",\n\t},\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\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; its title is also `ConnectButton`'s label.\n\tconnectTitle: \"Connect your AI app\",\n\t/**\n\t * At the top, while AI apps reach the page through the tab-mcp browser\n\t * extension (`TabMcp.extension`, DEC-207); `…InFront` when the extension\n\t * serves only the tab in front, as it does. `{apps}`: their names, as a\n\t * list.\n\t */\n\tviaExtension: {\n\t\tone: \"{apps} is connected through the tab-mcp browser extension.\",\n\t\tother: \"{apps} are connected through the tab-mcp browser extension.\",\n\t},\n\tviaExtensionInFront: {\n\t\tone: \"{apps} is connected through the tab-mcp browser extension, while this tab is in front.\",\n\t\tother:\n\t\t\t\"{apps} are connected through the tab-mcp browser extension, while this tab is in front.\",\n\t},\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, type the code {code}\",\n\tcodeNote: \"The code changes 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\t/** Under `signIn`: until when the relay pairs a sign-in (`{time}`: hours and minutes). */\n\tsignInUntil: \"Your AI app can connect until {time}.\",\n\t/** The status once that time is up; Continue starts it again. */\n\tsignInTimeUp:\n\t\t\"The time to connect your AI app is up. To connect it now, continue.\",\n\tcontinuePairing: \"Continue\",\n\tdisconnectAll: \"Disconnect all apps\",\n\tdisconnectAllNote:\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.\",\n\t/** `{apps}`: the AI apps it disconnects, as a list. */\n\tdisconnectAllQuestion: {\n\t\tone: \"This disconnects {apps}. To use this page with it again, connect it again.\",\n\t\tother:\n\t\t\t\"This disconnects {apps}. To use this page with them again, connect them again.\",\n\t},\n\t/** Repeats the button that asked. */\n\tdisconnectAllConfirm: \"Disconnect all apps\",\n\tcancel: \"Cancel\",\n\tdisconnectingAll: \"Disconnecting…\",\n\tdisconnectAllDone: \"Every AI app is disconnected. Connect yours again.\",\n\t/** `{apps}`: the connected AI apps, as a list. */\n\tconnected: { one: \"{apps} is connected\", other: \"{apps} are connected\" },\n\tconnectedNext: {\n\t\tone: \"You can close this now and ask it to use the tools of this page.\",\n\t\tother: \"You can close this now and ask them to use the tools of this page.\",\n\t},\n\tconnectAnother: \"Connect another AI app\",\n\tconnectedHeading: \"Connected AI apps\",\n\tappConnected: \"{app} connected\",\n\tdisconnect: \"Disconnect\",\n\tdisconnectApp: \"Disconnect {app}\",\n\tdisconnectNote: \"To disconnect an AI 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 AI app. Try again.\",\n\t// Under a connected AI app: a switch per tool that asks, and one for all,\n\t// headed by the confirmation's own label (`alwaysAllow` or\n\t// `allowUntilReload`), so that the button and its switches read alike.\n\t/** After a tool's name: it may delete or overwrite (`destructiveHint`). */\n\tdestructive: \"destructive\",\n\t/** A tool's switch, as read out: starts with what it shows (WCAG 2.5.3). */\n\tallowToolApp: \"{tool} runs without asking for {app}\",\n\tallowDestructiveToolApp: \"{tool} (destructive) runs without asking for {app}\",\n\tallowEverything: \"Always allow everything\",\n\tallowEverythingApp: \"Always allow everything for {app}\",\n\t/** Kept until the AI app is disconnected (`alwaysAllow: true`). */\n\tallowEverythingNote:\n\t\t\"Every tool of this page runs for {app} without asking, with any arguments: also tools you have not seen yet and ones that delete or overwrite, until you disconnect {app}.\",\n\t/** Kept in memory only (`alwaysAllow: \"until-reload\"`, `storage: null`). */\n\tallowEverythingUntilReloadNote:\n\t\t\"Every tool of this page runs for {app} without asking, with any arguments: also tools you have not seen yet and ones that delete or overwrite, until you reload this page or disconnect {app}.\",\n\tcloseNote:\n\t\t\"Closing this ends the code. To connect an AI app later, open this again from the page.\",\n\tclose: \"Close\",\n\tdone: \"Done\",\n\n\t// The steps under \"How do I add it?\" (`setupInstructions`).\n\tsetupClaudeApp: \"Claude (claude.ai and the desktop app)\",\n\tsetupClaude:\n\t\t\"Settings → Connectors → Add custom connector, then paste the address.\",\n\tsetupChatGpt:\n\t\t\"On chatgpt.com: Plugins, add an MCP server with the address, then Connect. The Mac app needs more steps: see the guide.\",\n\t/** Before a command to run in a terminal. */\n\tsetupRun: \"Run:\",\n\t/** Without a command (an address a shell would not read as plain). */\n\tsetupClaudeCode: \"Add the address with claude mcp add --transport http.\",\n\t/** `{command}`: `/mcp`, shown as code. */\n\tsetupClaudeCodeNote:\n\t\t\"Then type {command} in Claude Code and choose Authenticate.\",\n\t/** Without a command; `{feature}`: the Codex feature to turn on. */\n\tsetupCodex:\n\t\t\"Run codex features enable {feature}, then add the address with codex mcp add --url and sign in with codex mcp login.\",\n\tsetupCodexNote:\n\t\t\"The last line opens the sign-in that asks for the code. Start a new chat in Codex after it connects.\",\n\n\t// `ConnectButton` of `./react`; otherwise it says `connectTitle`,\n\t// `connecting` or, after a few failed attempts, `reconnecting`.\n\t/** While reconnecting, before it says the connection is lost. */\n\tbuttonReconnecting: \"Reconnecting…\",\n\tbuttonConnected: { one: \"AI app connected\", other: \"{n} AI apps connected\" },\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 use that tab or program instead of this page. If you did not open this page in another tab or window of this browser, someone may have copied this page's saved connection. “Disconnect all apps” ends that; then connect your AI apps again.\",\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/**\n * The texts of the library, key by key: each a string, or a\n * {@link PluralText} where it depends on a count. `dir` is the direction of\n * the texts; without it, the dialogs take it from `lang` where the browser\n * knows it (`Intl.Locale`), else left to right: set `dir: \"rtl\"` for a\n * right-to-left language to be sure.\n *\n * Type a translation as `DialogStrings` and the type check names every key\n * it lacks or misspells, also after an upgrade added one; as\n * `Partial<DialogStrings>` it may leave keys out (they stay English).\n */\nexport type DialogStrings = {\n\t[K in keyof typeof english]: (typeof english)[K] extends string\n\t\t? string\n\t\t: PluralText;\n} & { dir?: \"ltr\" | \"rtl\" };\n\n/** The English texts, the defaults for every key. */\nexport const STRINGS: DialogStrings = english;\n\n/**\n * Every text: `strings` where it has one of the right kind, English for\n * the rest. A missing translation (`undefined`), an unknown key or a plain\n * string where the English text has plural forms keeps the English text:\n * a table from an older version still works, only less translated. A table\n * with texts but no `lang` counts as English, and the console says so once.\n */\nexport function withEnglish(\n\tstrings: Partial<DialogStrings> | undefined,\n): DialogStrings {\n\twarnWithoutLang(strings);\n\tconst s: Record<string, unknown> = { ...STRINGS };\n\tfor (const [key, value] of Object.entries(strings ?? {})) {\n\t\tconst english = s[key];\n\t\tif (\n\t\t\tkey === \"dir\"\n\t\t\t\t? value === \"ltr\" || value === \"rtl\"\n\t\t\t\t: typeof english === \"string\"\n\t\t\t\t\t? typeof value === \"string\"\n\t\t\t\t\t: english !== undefined && isPlural(value)\n\t\t)\n\t\t\ts[key] = value;\n\t}\n\treturn s as DialogStrings;\n}\n\n/** A table of texts, or a module whose default export is one. */\ntype Loaded = Partial<DialogStrings> | { default: Partial<DialogStrings> };\n\n/** A tag's language, script and region, as the browser fills them in. */\nfunction subtags(tag: string): {\n\tlanguage: string;\n\tscript?: string;\n\tregion?: string;\n} {\n\tconst language = tag.toLowerCase().split(\"-\")[0] ?? \"\";\n\ttry {\n\t\tconst { script, region } = new Intl.Locale(tag).maximize();\n\t\treturn {\n\t\t\tlanguage,\n\t\t\t...(script === undefined ? {} : { script }),\n\t\t\t...(region === undefined ? {} : { region }),\n\t\t};\n\t} catch {\n\t\treturn { language };\n\t}\n}\n\n/**\n * Of the tags in `tags`, the one for the user's language `wanted`: the same\n * tag; else, among those of the same language, the one with the same script\n * (`zh-TW` is written `Hant`, so it takes `zh-Hant` over `zh-Hans` or `zh`),\n * then the same region, then the language alone (`de-CH` takes `de` over\n * `de-AT`), then the first in alphabetical order. The browser's likely\n * subtags (`Intl.Locale.maximize`) fill in what a tag leaves out.\n */\nfunction matchTag(tags: string[], wanted: string): string | undefined {\n\tconst exact = tags.find((t) => t.toLowerCase() === wanted.toLowerCase());\n\tif (exact !== undefined) return exact;\n\tconst want = subtags(wanted);\n\tconst score = (tag: string) => {\n\t\tconst has = subtags(tag);\n\t\treturn (\n\t\t\t(has.script !== undefined && has.script === want.script ? 4 : 0) +\n\t\t\t(has.region !== undefined && has.region === want.region ? 2 : 0) +\n\t\t\t(tag.toLowerCase() === want.language ? 1 : 0)\n\t\t);\n\t};\n\treturn tags\n\t\t.filter((t) => subtags(t).language === want.language)\n\t\t.sort((a, b) => score(b) - score(a) || (a < b ? -1 : a > b ? 1 : 0))[0];\n}\n\n/**\n * The page's own table for the user's language, loaded only once chosen:\n * `tables` maps language tags (`\"de\"`, `\"pt-BR\"`, `\"zh-Hant\"`) to functions\n * that load one, such as `() => import(\"./tab-mcp.de.ts\")`. The user's\n * languages (`navigator.languages`, most preferred first) are tried in\n * order; each takes the same tag, else a table of the same language: the\n * same script first, then the same region, then the language alone, then\n * the first in alphabetical order. English is built in: a user who prefers\n * English before any of the tables, or none of them, gets `undefined`,\n * which keeps the English texts. The table comes with `lang` set to the\n * matched tag unless it has its own.\n *\n * It never rejects: a table that fails to load (a chunk gone after a\n * deploy, offline) or is not an object is said in the console and gives\n * `undefined`, so the page still starts, in English.\n *\n * ```ts\n * const strings = await pickStrings({ de: () => import(\"./tab-mcp.de.ts\") });\n * const mcp = new TabMcp({ relay, server, ui: { strings } });\n * ```\n */\nexport async function pickStrings(\n\ttables: Record<string, () => Promise<Loaded>>,\n\tlanguages: readonly string[] = globalThis.navigator?.languages ?? [],\n): Promise<Partial<DialogStrings> | undefined> {\n\tconst tags = Object.keys(tables);\n\tfor (const wanted of languages) {\n\t\tconst tag = matchTag(tags, wanted);\n\t\tif (tag !== undefined) {\n\t\t\ttry {\n\t\t\t\tconst loaded: unknown = await (tables[tag] as () => Promise<Loaded>)();\n\t\t\t\tconst table: unknown =\n\t\t\t\t\ttypeof loaded === \"object\" && loaded !== null && \"default\" in loaded\n\t\t\t\t\t\t? loaded.default\n\t\t\t\t\t\t: loaded;\n\t\t\t\tif (typeof table !== \"object\" || table === null)\n\t\t\t\t\tthrow new TypeError(`not a table of texts: ${String(table)}`);\n\t\t\t\tconst texts = table as Partial<DialogStrings>;\n\t\t\t\treturn { ...texts, lang: texts.lang ?? tag };\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`tab-mcp: could not load the texts for ${tag}; English instead.`,\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t\t// English is built in: the user reads it before any later language.\n\t\tif (subtags(wanted).language === \"en\") return undefined;\n\t}\n\treturn undefined;\n}\n"
7
+ ],
8
+ "mappings": ";AAaO,SAAS,MAAM,CACrB,UACA,QACS;AAAA,EACT,OAAO,SAAS,QACf,cACA,CAAC,KAAK,QAAgB,OAAO,QAAQ,GACtC;AAAA;AAOD,SAAS,UAAa,CAAC,MAA2B,MAAiB;AAAA,EAClE,IAAI;AAAA,IACH,OAAO,KAAK,IAAI;AAAA,IACf,MAAM;AAAA,IACP,OAAO,KAAK,IAAI;AAAA;AAAA;AAKX,IAAM,WAAW,CAAC,UACxB,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA8B,UAAU,YAChD,OAAO,OAAO,KAAK,EAAE,MAAM,CAAC,SAAS,OAAO,SAAS,QAAQ;AAE9D,IAAM,SAAS,IAAI;AAOZ,SAAS,eAAe,CAAC,SAAmC;AAAA,EAClE,IAAI,YAAY,aAAa,OAAO,IAAI,OAAO;AAAA,IAAG;AAAA,EAClD,MAAM,QAAQ,OAAO,QAAQ,OAAO,EAAE,OACrC,EAAE,KAAK,WAAW,QAAQ,UAAU,QAAQ,SAAS,UAAU,SAChE;AAAA,EACA,IAAI,MAAM,WAAW,KAAK,OAAQ,QAAuB,SA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KACP,yCAAyC,yBACzC,KACD;AAAA,QACA;AAAA;AAAA,IAEF;AAAA,IAEA,IAAI,QAAQ,MAAM,EAAE,aAAa;AAAA,MAAM;AAAA,EACxC;AAAA,EACA;AAAA;",
9
+ "debugId": "A18E3688F5C8FB3A64756E2164756E21",
10
+ "names": []
11
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withEnglish2
3
- } from "./index-00p8b969.js";
3
+ } from "./index-erm4h3sn.js";
4
4
 
5
5
  // src/command.ts
6
6
  function commandName(name) {
@@ -10,7 +10,9 @@ function commandName(name) {
10
10
  function commandAddress(address) {
11
11
  try {
12
12
  const href = new URL(address).href;
13
- return /^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(href) ? href : undefined;
13
+ if (!/^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(href))
14
+ return;
15
+ return /[[\]~]/.test(href) ? `"${href}"` : href;
14
16
  } catch {
15
17
  return;
16
18
  }
@@ -54,5 +56,5 @@ function noteOf(template, code) {
54
56
 
55
57
  export { SETUP_GUIDE2, setupInstructions2 };
56
58
 
57
- //# debugId=345110FFDC6B520564756E2164756E21
58
- //# sourceMappingURL=index-1tssct09.js.map
59
+ //# debugId=22AC37848696188A64756E2164756E21
60
+ //# sourceMappingURL=index-xx4gmtk5.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/command.ts", "../src/setup.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 it has nothing but http or https,\n * letters, digits and . : [ ] / _ ~ -; else `undefined`, and the help shows\n * the steps without commands. The relay's addresses are plain words.\n *\n * `[`, `]` (an IPv6 address, `http://[::1]:8080/…`) and `~` are patterns in\n * zsh, which refuses the command (\"no matches found\"; `~` with its\n * `extendedglob`): such an address goes in double quotes. With nothing else\n * in it, POSIX shells, zsh, fish, PowerShell and cmd.exe all read that as\n * the address (single quotes would reach the program in cmd.exe).\n */\nexport function commandAddress(address: string): string | undefined {\n\ttry {\n\t\tconst href = new URL(address).href;\n\t\tif (!/^https?:\\/\\/[A-Za-z0-9.:[\\]/_~-]+$/.test(href)) return undefined;\n\t\treturn /[[\\]~]/.test(href) ? `\"${href}\"` : href;\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 DialogStrings, withEnglish } from \"./strings.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, zsh, PowerShell, cmd.exe) reads the same, an address with `[`, `]`\n * or `~` (an IPv6 address) in double quotes, as zsh reads those as patterns.\n * It is absent for apps without a command, and when the address has anything\n * but http or https, letters, digits and `. : [ ] / _ ~ -`; then `text` names\n * the command instead. The relay's addresses are plain words.\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 * `strings` translates the texts (the `setup…` keys of `./strings`, the\n * same table as the dialogs' `ui.strings`); missing keys stay English.\n */\nexport function setupInstructions(\n\tserverName: string,\n\taddress: string,\n\tstrings?: Partial<DialogStrings>,\n): SetupInstruction[] {\n\tconst s = withEnglish(strings);\n\tconst n = commandName(serverName);\n\tconst a = commandAddress(address);\n\tconst run = (command: string) =>\n\t\ta === undefined ? {} : { text: s.setupRun, command };\n\treturn [\n\t\t{ id: \"claude\", app: s.setupClaudeApp, text: s.setupClaude },\n\t\t{ id: \"chatgpt\", app: \"ChatGPT\", text: s.setupChatGpt },\n\t\t{\n\t\t\tid: \"claude-code\",\n\t\t\tapp: \"Claude Code\",\n\t\t\ttext: s.setupClaudeCode,\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: noteOf(s.setupClaudeCodeNote, { command: \"/mcp\" }),\n\t\t},\n\t\t{\n\t\t\tid: \"codex\",\n\t\t\tapp: \"Codex\",\n\t\t\ttext: s.setupCodex.replace(\"{feature}\", CODEX_FEATURE),\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: noteOf(s.setupCodexNote, {}),\n\t\t},\n\t];\n}\n\n/** `template` as note parts: its text, and each `{name}` of `code` as code. */\nfunction noteOf(\n\ttemplate: string,\n\tcode: Record<string, string>,\n): SetupNotePart[] {\n\treturn template\n\t\t.split(/\\{(\\w+)\\}/)\n\t\t.map((part, i): SetupNotePart => {\n\t\t\tconst value = i % 2 === 1 ? code[part] : undefined;\n\t\t\treturn value === undefined\n\t\t\t\t? { text: i % 2 === 1 ? `{${part}}` : part }\n\t\t\t\t: { code: value };\n\t\t})\n\t\t.filter((part) => !(\"text\" in part) || part.text !== \"\");\n}\n"
7
+ ],
8
+ "mappings": ";;;;;AAcO,SAAS,WAAW,CAAC,MAAsB;AAAA,EACjD,MAAM,QAAQ,KACZ,UAAU,MAAM,EAChB,QAAQ,WAAW,EAAE,EACrB,YAAY,EACZ,QAAQ,iBAAiB,GAAG,EAC5B,QAAQ,UAAU,GAAG,EACrB,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE,EACX,QAAQ,OAAO,EAAE;AAAA,EACnB,OAAO,UAAU,KAAK,UAAU;AAAA;AAc1B,SAAS,cAAc,CAAC,SAAqC;AAAA,EACnE,IAAI;AAAA,IACH,MAAM,OAAO,IAAI,IAAI,OAAO,EAAE;AAAA,IAC9B,IAAI,CAAC,qCAAqC,KAAK,IAAI;AAAA,MAAG;AAAA,IACtD,OAAO,SAAS,KAAK,IAAI,IAAI,IAAI,UAAU;AAAA,IAC1C,MAAM;AAAA,IACP;AAAA;AAAA;;;AC9BK,IAAM,eAAc;AAG3B,IAAM,gBAAgB;AA4Bf,SAAS,kBAAiB,CAChC,YACA,SACA,SACqB;AAAA,EACrB,MAAM,IAAI,aAAY,OAAO;AAAA,EAC7B,MAAM,IAAI,YAAY,UAAU;AAAA,EAChC,MAAM,IAAI,eAAe,OAAO;AAAA,EAChC,MAAM,MAAM,CAAC,YACZ,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,QAAQ;AAAA,EACpD,OAAO;AAAA,IACN,EAAE,IAAI,UAAU,KAAK,EAAE,gBAAgB,MAAM,EAAE,YAAY;AAAA,IAC3D,EAAE,IAAI,WAAW,KAAK,WAAW,MAAM,EAAE,aAAa;AAAA,IACtD;AAAA,MACC,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,EAAE;AAAA,SACL,IAAI,mCAAmC,KAAK,GAAG;AAAA,MAGlD,MAAM,OAAO,EAAE,qBAAqB,EAAE,SAAS,OAAO,CAAC;AAAA,IACxD;AAAA,IACA;AAAA,MACC,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,EAAE,WAAW,QAAQ,aAAa,aAAa;AAAA,SAClD,IACF,yBAAyB;AAAA,gBAAgC,WAAW;AAAA,kBAAsB,GAC3F;AAAA,MACA,MAAM,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAAA,IAClC;AAAA,EACD;AAAA;AAID,SAAS,MAAM,CACd,UACA,MACkB;AAAA,EAClB,OAAO,SACL,MAAM,WAAW,EACjB,IAAI,CAAC,MAAM,MAAqB;AAAA,IAChC,MAAM,QAAQ,IAAI,MAAM,IAAI,KAAK,QAAQ;AAAA,IACzC,OAAO,UAAU,YACd,EAAE,MAAM,IAAI,MAAM,IAAI,IAAI,UAAU,KAAK,IACzC,EAAE,MAAM,MAAM;AAAA,GACjB,EACA,OAAO,CAAC,SAAS,EAAE,UAAU,SAAS,KAAK,SAAS,EAAE;AAAA;",
9
+ "debugId": "22AC37848696188A64756E2164756E21",
10
+ "names": []
11
+ }
package/index.js CHANGED
@@ -203,11 +203,14 @@ class SecretStore {
203
203
  storage;
204
204
  key;
205
205
  #memory;
206
+ #unsaved = false;
206
207
  constructor(storage, key) {
207
208
  this.storage = storage === undefined ? defaultStorage() : storage;
208
209
  this.key = key;
209
210
  }
210
211
  current() {
212
+ if (this.#unsaved)
213
+ return this.#memory;
211
214
  let stored = null;
212
215
  try {
213
216
  stored = this.storage?.getItem(this.key) ?? null;
@@ -221,14 +224,16 @@ class SecretStore {
221
224
  rotate() {
222
225
  const secret = newSecret();
223
226
  this.#memory = secret;
227
+ this.#unsaved = true;
224
228
  try {
225
229
  this.storage?.setItem(this.key, secret);
230
+ this.#unsaved = false;
226
231
  } catch {}
227
232
  return secret;
228
233
  }
229
234
  }
230
235
  // package.json
231
- var version = "0.20.0";
236
+ var version = "0.21.0-rc.2";
232
237
 
233
238
  // src/version.ts
234
239
  var LIBRARY_NAME = "@ractive-ch/tab-mcp-client";
@@ -357,7 +362,7 @@ class TabMcp extends EventTarget {
357
362
  #calls = {
358
363
  registry: this.#registry,
359
364
  confirm: (request) => this.#confirm(request),
360
- ownConfirm: () => !!this.#onConfirm,
365
+ onConfirm: () => this.#onConfirm,
361
366
  toolCallStarted: (call) => this.#emit("toolcall", call),
362
367
  toolCallEnded: (call) => this.#emit("toolcallend", call)
363
368
  };
@@ -392,7 +397,7 @@ class TabMcp extends EventTarget {
392
397
  this.#registry.onChange(() => this.#emit("toolschange", { tools: this.tools }));
393
398
  const context = options.webmcp === true ? nativeContext() : undefined;
394
399
  if (context !== undefined)
395
- import("./webmcp-acj1tef8.js").then((m) => m.mirror(this.#registry, context, (tool, input, signal, by) => this.#load().then((lazy) => lazy.callFromWebMcp(this.#calls, tool, input, signal, by)), this, app, options, VERSION), (error) => console.warn("tab-mcp: no tools are offered through WebMCP:", error));
400
+ import("./webmcp-gw6rrbnh.js").then((m) => m.mirror(this.#registry, context, (tool, input, signal, by) => this.#load().then((lazy) => lazy.callFromWebMcp(this.#calls, tool, input, signal, by)), this, app, options, VERSION), (error) => console.warn("tab-mcp: no tools are offered through WebMCP:", error));
396
401
  }
397
402
  registerTool(tool, options = {}) {
398
403
  try {
@@ -517,7 +522,7 @@ class TabMcp extends EventTarget {
517
522
  return connecting;
518
523
  }
519
524
  async#load() {
520
- const lazy = await import("./connection-krd3ncrn.js");
525
+ const lazy = await import("./connection-arq7qm7b.js");
521
526
  for (const error of lazy.compileRegistry(this.#registry))
522
527
  this.#emit("error", { error });
523
528
  this.#lazy = lazy;
@@ -708,7 +713,7 @@ class TabMcp extends EventTarget {
708
713
  async#showConnectDialog(doc) {
709
714
  const connecting = this.connect();
710
715
  connecting.catch(() => {});
711
- const { showConnectDialog } = await import("./connect-fhtjdmf3.js");
716
+ const { showConnectDialog } = await import("./connect-bc628ax6.js");
712
717
  await showConnectDialog(this, connecting, doc, this.#server.name, this.#ui);
713
718
  }
714
719
  addEventListener(type, listener, options) {
@@ -754,7 +759,7 @@ class TabMcp extends EventTarget {
754
759
  }
755
760
  #confirm(request) {
756
761
  const ask = this.#onConfirm;
757
- return import("./confirm-hymzwx3b.js").then((m) => m.confirmCall(this, request, ask), () => ask?.(request) ?? false);
762
+ return import("./confirm-7de6dvpb.js").then((m) => m.confirmCall(this, request, ask), () => ask?.(request) ?? false);
758
763
  }
759
764
  get _allowed() {
760
765
  return [this.#registry, this.#secrets, this.#alwaysAllow];
@@ -763,10 +768,12 @@ class TabMcp extends EventTarget {
763
768
  return this.#ui;
764
769
  }
765
770
  confirmInPage(request, options = {}) {
771
+ if (request.client.kind === "webmcp")
772
+ return Promise.resolve(true);
766
773
  const doc = options.document ?? globalThis.document;
767
774
  if (doc === undefined)
768
775
  return Promise.resolve(false);
769
- return import("./confirm-hymzwx3b.js").then((ui) => ui.confirmInPage(this, request, doc, { ui: this.#ui }));
776
+ return import("./confirm-7de6dvpb.js").then((ui) => ui.confirmInPage(this, request, doc, { ui: this.#ui }));
770
777
  }
771
778
  #host(ref) {
772
779
  const current = () => ref.connection !== undefined && this.#connection === ref.connection;
@@ -874,5 +881,5 @@ export {
874
881
  VERSION
875
882
  };
876
883
 
877
- //# debugId=D02F778A3674F9C064756E2164756E21
884
+ //# debugId=1F6D88F7E0FABC2364756E2164756E21
878
885
  //# sourceMappingURL=index.js.map