@ractive-ch/tab-mcp-client 0.18.1 → 0.19.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 (86) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +360 -68
  3. package/allowed.d.ts +2 -2
  4. package/allowed.js.map +1 -1
  5. package/always-allowed.d.ts +15 -15
  6. package/cdn/allowed.min.js +2 -2
  7. package/cdn/allowed.min.js.map +2 -2
  8. package/cdn/confirm-ba3dkf9p.min.js +4 -0
  9. package/cdn/confirm-ba3dkf9p.min.js.map +10 -0
  10. package/cdn/connect-my0pbqd7.min.js +6 -0
  11. package/cdn/connect-my0pbqd7.min.js.map +12 -0
  12. package/cdn/connection-yf2x9zz2.min.js +17 -0
  13. package/cdn/{connection-0xqwz17v.min.js.map → connection-yf2x9zz2.min.js.map} +5 -5
  14. package/cdn/strings.min.js +4 -0
  15. package/cdn/strings.min.js.map +9 -0
  16. package/cdn/{tab-mcp-client-2vx9mcww.min.js → tab-mcp-client-8r6h3wza.min.js} +9 -8
  17. package/cdn/tab-mcp-client-8r6h3wza.min.js.map +11 -0
  18. package/cdn/tab-mcp-client-nnxcwrxp.min.js +5 -0
  19. package/cdn/tab-mcp-client-nnxcwrxp.min.js.map +11 -0
  20. package/cdn/{tab-mcp-client-5j3brdf3.min.js → tab-mcp-client-q758jr4g.min.js} +4 -4
  21. package/cdn/tab-mcp-client-q758jr4g.min.js.map +10 -0
  22. package/cdn/tab-mcp-client.min.js +3 -3
  23. package/cdn/tab-mcp-client.min.js.map +4 -4
  24. package/cdn/webmcp-84k58gsw.min.js +4 -0
  25. package/cdn/webmcp-84k58gsw.min.js.map +11 -0
  26. package/{confirm-bqfdrx3f.js → confirm-hymzwx3b.js} +7 -5
  27. package/confirm-hymzwx3b.js.map +10 -0
  28. package/confirm.d.ts +2 -2
  29. package/{connect-ztsgybpq.js → connect-fhtjdmf3.js} +75 -37
  30. package/connect-fhtjdmf3.js.map +10 -0
  31. package/connect.d.ts +7 -6
  32. package/{connection-gang7f5x.js → connection-73fbg99k.js} +70 -8
  33. package/connection-73fbg99k.js.map +16 -0
  34. package/connection.d.ts +23 -2
  35. package/dialog.d.ts +19 -9
  36. package/extension.d.ts +373 -0
  37. package/extension.js +415 -0
  38. package/extension.js.map +10 -0
  39. package/handshake.d.ts +82 -0
  40. package/index-00p8b969.js +221 -0
  41. package/index-00p8b969.js.map +11 -0
  42. package/index-1tssct09.js +58 -0
  43. package/index-1tssct09.js.map +11 -0
  44. package/{index-c1c266tm.js → index-7qqhn3zv.js} +28 -110
  45. package/index-7qqhn3zv.js.map +10 -0
  46. package/index-s31xrfa2.js.map +1 -1
  47. package/index.d.ts +1 -1
  48. package/index.js +59 -64
  49. package/index.js.map +4 -4
  50. package/internal.d.ts +2 -0
  51. package/mcp.d.ts +5 -3
  52. package/package.json +11 -2
  53. package/protocol.d.ts +11 -1
  54. package/react.d.ts +11 -4
  55. package/react.js +57 -10
  56. package/react.js.map +5 -4
  57. package/secret.d.ts +1 -1
  58. package/setup.d.ts +4 -1
  59. package/setup.js +3 -2
  60. package/setup.js.map +1 -1
  61. package/strings.d.ts +149 -28
  62. package/strings.js +13 -0
  63. package/strings.js.map +9 -0
  64. package/tab-mcp.d.ts +30 -7
  65. package/text.d.ts +39 -0
  66. package/types.d.ts +76 -17
  67. package/webmcp-d2ec3v3g.js +221 -0
  68. package/webmcp-d2ec3v3g.js.map +11 -0
  69. package/webmcp.d.ts +17 -4
  70. package/cdn/confirm-d722a9eb.min.js +0 -4
  71. package/cdn/confirm-d722a9eb.min.js.map +0 -10
  72. package/cdn/connect-x6ws6wqt.min.js +0 -6
  73. package/cdn/connect-x6ws6wqt.min.js.map +0 -12
  74. package/cdn/connection-0xqwz17v.min.js +0 -17
  75. package/cdn/tab-mcp-client-2vx9mcww.min.js.map +0 -12
  76. package/cdn/tab-mcp-client-5j3brdf3.min.js.map +0 -10
  77. package/cdn/webmcp-khy4f5rj.min.js +0 -4
  78. package/cdn/webmcp-khy4f5rj.min.js.map +0 -10
  79. package/confirm-bqfdrx3f.js.map +0 -10
  80. package/connect-ztsgybpq.js.map +0 -10
  81. package/connection-gang7f5x.js.map +0 -16
  82. package/index-5jyqehpk.js +0 -63
  83. package/index-5jyqehpk.js.map +0 -11
  84. package/index-c1c266tm.js.map +0 -11
  85. package/webmcp-zq1enyz0.js +0 -57
  86. package/webmcp-zq1enyz0.js.map +0 -10
@@ -0,0 +1,221 @@
1
+ // src/text.ts
2
+ function format(template, values) {
3
+ return template.replace(/\{(\w+)\}/g, (all, key) => values[key] ?? all);
4
+ }
5
+ function inLanguage(make, lang) {
6
+ try {
7
+ return make(lang);
8
+ } catch {
9
+ return make("en");
10
+ }
11
+ }
12
+ var isPlural = (value) => typeof value === "object" && value !== null && typeof value.other === "string" && Object.values(value).every((form) => typeof form === "string");
13
+ var warned = new WeakSet;
14
+ function warnWithoutLang(strings) {
15
+ if (strings === undefined || warned.has(strings))
16
+ return;
17
+ const texts = Object.entries(strings).filter(([key, value]) => key !== "lang" && key !== "dir" && value !== undefined);
18
+ if (texts.length === 0 || typeof strings.lang === "string")
19
+ return;
20
+ warned.add(strings);
21
+ console.warn("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.");
22
+ }
23
+ function pluralForm(text, n, s) {
24
+ const category = inLanguage((l) => new Intl.PluralRules(l), s.lang).select(n);
25
+ return format(text[category] ?? text.other, { n: String(n) });
26
+ }
27
+ function plural(text, n, s, values = {}) {
28
+ return format(pluralForm(text, n, s), values);
29
+ }
30
+ function listFormat(s) {
31
+ return inLanguage((l) => new Intl.ListFormat(l, { type: "conjunction" }), s.lang);
32
+ }
33
+ function directionOf(s) {
34
+ if (s.dir !== undefined)
35
+ return s.dir;
36
+ try {
37
+ const locale = new Intl.Locale(s.lang);
38
+ const info = locale.getTextInfo?.() ?? locale.textInfo;
39
+ return info?.direction === "rtl" ? "rtl" : "ltr";
40
+ } catch {
41
+ return "ltr";
42
+ }
43
+ }
44
+
45
+ // src/strings.ts
46
+ var english = {
47
+ lang: "en",
48
+ confirmTitle: "Allow {tool}?",
49
+ confirmWho: "{client} wants to run {tool}.",
50
+ deny: "Don't allow",
51
+ allow: "Allow once",
52
+ alwaysAllow: "Always allow",
53
+ alwaysAllowNote: "Always allow: {tool} will run for {client} without asking, with any arguments, until you disconnect {client} from this page.",
54
+ allowUntilReload: "Allow until reload",
55
+ allowUntilReloadNote: "Allow until reload: {tool} will run for {client} without asking, with any arguments, until you reload this page or disconnect {client}.",
56
+ argumentsHidden: "The arguments cannot be shown, so this call cannot be allowed.",
57
+ scrollToAllow: "Scroll to the end of the arguments to allow this call.",
58
+ waiting: {
59
+ one: "{n} more call is waiting after this one.",
60
+ other: "{n} more calls are waiting after this one."
61
+ },
62
+ titlePrefix: "Allow? – ",
63
+ clientWebMcp: "An agent in this browser",
64
+ clientLocal: "{name} (this site's assistant)",
65
+ clientRelay: "{name} ({host})",
66
+ copy: "Copy",
67
+ copied: "Copied",
68
+ pressMac: "Press ⌘C",
69
+ pressOther: "Press Ctrl+C",
70
+ selected: "Selected",
71
+ copyAddress: "Copy address",
72
+ copyCode: "Copy code",
73
+ copyCommand: "Copy {app} command",
74
+ connectTitle: "Connect your AI app",
75
+ viaExtension: {
76
+ one: "{apps} is connected through the tab-mcp browser extension.",
77
+ other: "{apps} are connected through the tab-mcp browser extension."
78
+ },
79
+ viaExtensionInFront: {
80
+ one: "{apps} is connected through the tab-mcp browser extension, while this tab is in front.",
81
+ other: "{apps} are connected through the tab-mcp browser extension, while this tab is in front."
82
+ },
83
+ connecting: "Connecting…",
84
+ connectAgain: "Connect again",
85
+ reconnecting: "Connection lost. Reconnecting…",
86
+ notConnected: "Not connected.",
87
+ unreachable: "Could not connect. Check your internet connection.",
88
+ rateLimited: "Too many attempts. Wait a minute, then connect again.",
89
+ refused: "The connection was refused.",
90
+ ended: "The session ended.",
91
+ lost: "The connection was lost.",
92
+ closed: "The connection was closed.",
93
+ disconnected: "Disconnected.",
94
+ checkingSignIn: "Checking your sign-in…",
95
+ signInFirst: "Sign in to this page first.",
96
+ signInRefused: "Your sign-in on this page was not accepted.",
97
+ signInRefusedWhy: "Your sign-in on this page was not accepted ({reason}).",
98
+ readyApp: "{app} is ready for your AI app.",
99
+ readyPage: "This page is ready for your AI app.",
100
+ addressLabel: "Add this address to your AI app:",
101
+ help: "How do I add it?",
102
+ guide: "Step by step, and what to do when it fails",
103
+ codeSentence: "When asked, type the code {code}",
104
+ codeNote: "The code changes every 2 minutes and after each use.",
105
+ codeUsed: "Code used. Waiting for your AI app…",
106
+ signIn: "When your AI app asks, sign in with the account you use on this page. No code is needed.",
107
+ signInUntil: "Your AI app can connect until {time}.",
108
+ signInTimeUp: "The time to connect your AI app is up. To connect it now, continue.",
109
+ continuePairing: "Continue",
110
+ disconnectAll: "Disconnect all apps",
111
+ disconnectAllNote: "An AI app is connected that should not be? This disconnects every AI app from this page; each one has to connect again.",
112
+ disconnectAllQuestion: {
113
+ one: "This disconnects {apps}. To use this page with it again, connect it again.",
114
+ other: "This disconnects {apps}. To use this page with them again, connect them again."
115
+ },
116
+ disconnectAllConfirm: "Disconnect all apps",
117
+ cancel: "Cancel",
118
+ disconnectingAll: "Disconnecting…",
119
+ disconnectAllDone: "Every AI app is disconnected. Connect yours again.",
120
+ connected: { one: "{apps} is connected", other: "{apps} are connected" },
121
+ connectedNext: {
122
+ one: "You can close this now and ask it to use the tools of this page.",
123
+ other: "You can close this now and ask them to use the tools of this page."
124
+ },
125
+ connectAnother: "Connect another AI app",
126
+ connectedHeading: "Connected AI apps",
127
+ appConnected: "{app} connected",
128
+ disconnect: "Disconnect",
129
+ disconnectApp: "Disconnect {app}",
130
+ disconnectNote: "To disconnect an AI app, connect this page again first.",
131
+ storeUnavailable: "The relay could not save this. Try again.",
132
+ disconnectFailed: "Could not disconnect the AI app. Try again.",
133
+ destructive: "destructive",
134
+ allowToolApp: "{tool} runs without asking for {app}",
135
+ allowDestructiveToolApp: "{tool} (destructive) runs without asking for {app}",
136
+ allowEverything: "Always allow everything",
137
+ allowEverythingApp: "Always allow everything for {app}",
138
+ allowEverythingNote: "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}.",
139
+ allowEverythingUntilReloadNote: "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}.",
140
+ closeNote: "Closing this ends the code. To connect an AI app later, open this again from the page.",
141
+ close: "Close",
142
+ done: "Done",
143
+ setupClaudeApp: "Claude (claude.ai and the desktop app)",
144
+ setupClaude: "Settings → Connectors → Add custom connector, then paste the address.",
145
+ setupChatGpt: "On chatgpt.com: Plugins, add an MCP server with the address, then Connect. The Mac app needs more steps: see the guide.",
146
+ setupRun: "Run:",
147
+ setupClaudeCode: "Add the address with claude mcp add --transport http.",
148
+ setupClaudeCodeNote: "Then type {command} in Claude Code and choose Authenticate.",
149
+ setupCodex: "Run codex features enable {feature}, then add the address with codex mcp add --url and sign in with codex mcp login.",
150
+ setupCodexNote: "The last line opens the sign-in that asks for the code. Start a new chat in Codex after it connects.",
151
+ buttonReconnecting: "Reconnecting…",
152
+ buttonConnected: { one: "AI app connected", other: "{n} AI apps connected" },
153
+ replacedSiblingTitle: "Opened in another tab",
154
+ replacedSibling: "This page is open in another tab, and your AI apps now use that one. To use them here, connect this page again.",
155
+ replacedTitle: "Another tab or program took over this page",
156
+ replaced: "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.",
157
+ takenOverAgain: "It was taken over again before its AI apps were disconnected. Try again.",
158
+ tryAgainOrClose: "{reason} Try again, or close this."
159
+ };
160
+ var STRINGS2 = english;
161
+ function withEnglish2(strings) {
162
+ warnWithoutLang(strings);
163
+ const s = { ...STRINGS2 };
164
+ for (const [key, value] of Object.entries(strings ?? {})) {
165
+ const english = s[key];
166
+ if (key === "dir" ? value === "ltr" || value === "rtl" : typeof english === "string" ? typeof value === "string" : english !== undefined && isPlural(value))
167
+ s[key] = value;
168
+ }
169
+ return s;
170
+ }
171
+ function subtags(tag) {
172
+ const language = tag.toLowerCase().split("-")[0] ?? "";
173
+ try {
174
+ const { script, region } = new Intl.Locale(tag).maximize();
175
+ return {
176
+ language,
177
+ ...script === undefined ? {} : { script },
178
+ ...region === undefined ? {} : { region }
179
+ };
180
+ } catch {
181
+ return { language };
182
+ }
183
+ }
184
+ function matchTag(tags, wanted) {
185
+ const exact = tags.find((t) => t.toLowerCase() === wanted.toLowerCase());
186
+ if (exact !== undefined)
187
+ return exact;
188
+ const want = subtags(wanted);
189
+ const score = (tag) => {
190
+ const has = subtags(tag);
191
+ return (has.script !== undefined && has.script === want.script ? 4 : 0) + (has.region !== undefined && has.region === want.region ? 2 : 0) + (tag.toLowerCase() === want.language ? 1 : 0);
192
+ };
193
+ return tags.filter((t) => subtags(t).language === want.language).sort((a, b) => score(b) - score(a) || (a < b ? -1 : a > b ? 1 : 0))[0];
194
+ }
195
+ async function pickStrings2(tables, languages = globalThis.navigator?.languages ?? []) {
196
+ const tags = Object.keys(tables);
197
+ for (const wanted of languages) {
198
+ const tag = matchTag(tags, wanted);
199
+ if (tag !== undefined) {
200
+ try {
201
+ const loaded = await tables[tag]();
202
+ const table = typeof loaded === "object" && loaded !== null && "default" in loaded ? loaded.default : loaded;
203
+ if (typeof table !== "object" || table === null)
204
+ throw new TypeError(`not a table of texts: ${String(table)}`);
205
+ const texts = table;
206
+ return { ...texts, lang: texts.lang ?? tag };
207
+ } catch (error) {
208
+ console.warn(`tab-mcp: could not load the texts for ${tag}; English instead.`, error);
209
+ return;
210
+ }
211
+ }
212
+ if (subtags(wanted).language === "en")
213
+ return;
214
+ }
215
+ return;
216
+ }
217
+
218
+ export { format, pluralForm, plural, listFormat, directionOf, STRINGS2, withEnglish2, pickStrings2 };
219
+
220
+ //# debugId=395C334D22BBAAE964756E2164756E21
221
+ //# sourceMappingURL=index-00p8b969.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\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; 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,SAAS;AAAA,IACjE;AAAA,EACD,OAAO,IAAI,OAAO;AAAA,EAClB,QAAQ,KACP,wJACD;AAAA;AAOM,SAAS,UAAU,CAAC,MAAkB,GAAW,GAAuB;AAAA,EAC9E,MAAM,WAAW,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AAA;",
9
+ "debugId": "395C334D22BBAAE964756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,58 @@
1
+ import {
2
+ withEnglish2
3
+ } from "./index-00p8b969.js";
4
+
5
+ // src/command.ts
6
+ function commandName(name) {
7
+ const label = name.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").slice(0, 40).replace(/-+$/, "");
8
+ return label === "" ? "tools" : label;
9
+ }
10
+ function commandAddress(address) {
11
+ try {
12
+ const href = new URL(address).href;
13
+ return /^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(href) ? href : undefined;
14
+ } catch {
15
+ return;
16
+ }
17
+ }
18
+
19
+ // src/setup.ts
20
+ var SETUP_GUIDE2 = "https://ractive.ch/tab-mcp/connect/";
21
+ var CODEX_FEATURE = "mcp_2026_07_28";
22
+ function setupInstructions2(serverName, address, strings) {
23
+ const s = withEnglish2(strings);
24
+ const n = commandName(serverName);
25
+ const a = commandAddress(address);
26
+ const run = (command) => a === undefined ? {} : { text: s.setupRun, command };
27
+ return [
28
+ { id: "claude", app: s.setupClaudeApp, text: s.setupClaude },
29
+ { id: "chatgpt", app: "ChatGPT", text: s.setupChatGpt },
30
+ {
31
+ id: "claude-code",
32
+ app: "Claude Code",
33
+ text: s.setupClaudeCode,
34
+ ...run(`claude mcp add --transport http ${n} ${a}`),
35
+ note: noteOf(s.setupClaudeCodeNote, { command: "/mcp" })
36
+ },
37
+ {
38
+ id: "codex",
39
+ app: "Codex",
40
+ text: s.setupCodex.replace("{feature}", CODEX_FEATURE),
41
+ ...run(`codex features enable ${CODEX_FEATURE}
42
+ codex mcp add ${n} --url ${a}
43
+ codex mcp login ${n}`),
44
+ note: noteOf(s.setupCodexNote, {})
45
+ }
46
+ ];
47
+ }
48
+ function noteOf(template, code) {
49
+ return template.split(/\{(\w+)\}/).map((part, i) => {
50
+ const value = i % 2 === 1 ? code[part] : undefined;
51
+ return value === undefined ? { text: i % 2 === 1 ? `{${part}}` : part } : { code: value };
52
+ }).filter((part) => !("text" in part) || part.text !== "");
53
+ }
54
+
55
+ export { SETUP_GUIDE2, setupInstructions2 };
56
+
57
+ //# debugId=345110FFDC6B520564756E2164756E21
58
+ //# sourceMappingURL=index-1tssct09.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 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 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, 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 * `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,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K,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": "345110FFDC6B520564756E2164756E21",
10
+ "names": []
11
+ }
@@ -1,113 +1,21 @@
1
+ import {
2
+ format,
3
+ pluralForm,
4
+ listFormat,
5
+ directionOf,
6
+ withEnglish2
7
+ } from "./index-00p8b969.js";
1
8
  import {
2
9
  escapeInvisible2
3
10
  } from "./index-dmh5vm5m.js";
4
11
 
5
- // src/strings.ts
6
- var STRINGS = {
7
- lang: "en",
8
- dir: "ltr",
9
- and: "and",
10
- confirmTitle: "Allow {tool}?",
11
- confirmWho: "{client} wants to run {tool}.",
12
- deny: "Don't allow",
13
- allow: "Allow",
14
- alwaysAllow: "Always allow",
15
- alwaysAllowNote: "Always allow: {tool} will run for {client} without asking, with any arguments, until you disconnect {client} from this page.",
16
- allowUntilReload: "Allow until reload",
17
- allowUntilReloadNote: "Allow until reload: {tool} will run for {client} without asking, with any arguments, until you reload this page or disconnect {client}.",
18
- argumentsHidden: "The arguments cannot be shown, so this call cannot be allowed.",
19
- scrollToAllow: "Scroll to the end of the arguments to allow this call.",
20
- waitingOne: "1 more call is waiting after this one.",
21
- waitingMany: "{n} more calls are waiting after this one.",
22
- titlePrefix: "Allow? – ",
23
- clientWebMcp: "An agent in this browser",
24
- clientLocal: "{name} (this site's assistant)",
25
- clientRelay: "{name} ({host})",
26
- copy: "Copy",
27
- copied: "Copied",
28
- pressMac: "Press ⌘C",
29
- pressOther: "Press Ctrl+C",
30
- selected: "Selected",
31
- copyAddress: "Copy address",
32
- copyCode: "Copy code",
33
- copyCommand: "Copy {app} command",
34
- connectTitle: "Connect your AI app",
35
- connecting: "Connecting…",
36
- connectAgain: "Connect again",
37
- reconnecting: "Connection lost. Reconnecting…",
38
- notConnected: "Not connected.",
39
- unreachable: "Could not connect. Check your internet connection.",
40
- rateLimited: "Too many attempts. Wait a minute, then connect again.",
41
- refused: "The connection was refused.",
42
- ended: "The session ended.",
43
- lost: "The connection was lost.",
44
- closed: "The connection was closed.",
45
- disconnected: "Disconnected.",
46
- checkingSignIn: "Checking your sign-in…",
47
- signInFirst: "Sign in to this page first.",
48
- signInRefused: "Your sign-in on this page was not accepted.",
49
- signInRefusedWhy: "Your sign-in on this page was not accepted ({reason}).",
50
- readyApp: "{app} is ready for your AI app.",
51
- readyPage: "This page is ready for your AI app.",
52
- addressLabel: "Add this address to your AI app:",
53
- help: "How do I add it?",
54
- guide: "Step by step, and what to do when it fails",
55
- codeSentence: "When asked, enter the code {code}",
56
- codeNote: "A new code appears every 2 minutes and after each use.",
57
- codeUsed: "Code used. Waiting for your AI app…",
58
- signIn: "When your AI app asks, sign in with the account you use on this page. No code is needed.",
59
- newAddress: "Disconnect all apps",
60
- newAddressNote: "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.",
61
- newAddressQuestionOne: "This disconnects {apps}. To use this page with it again, connect it again and enter a new code.",
62
- newAddressQuestionMany: "This disconnects {apps}. To use this page with them again, connect them again and enter a new code.",
63
- newAddressConfirm: "Disconnect all",
64
- cancel: "Cancel",
65
- gettingNewAddress: "Disconnecting…",
66
- newAddressDone: "Every AI app is disconnected. Connect yours again.",
67
- connectedOne: "{apps} is connected",
68
- connectedMany: "{apps} are connected",
69
- connectedNextOne: "You can close this now and ask it to use the tools of this page.",
70
- connectedNextMany: "You can close this now and ask them to use the tools of this page.",
71
- connectAnother: "Connect another app",
72
- connectedHeading: "Connected",
73
- appConnected: "{app} connected",
74
- disconnect: "Disconnect",
75
- disconnectApp: "Disconnect {app}",
76
- disconnectNote: "To disconnect an app, connect this page again first.",
77
- storeUnavailable: "The relay could not save this. Try again.",
78
- disconnectFailed: "Could not disconnect the app. Try again.",
79
- runsWithoutAsking: "Runs without asking",
80
- destructive: "destructive",
81
- allowToolApp: "{tool} runs without asking for {app}",
82
- allowDestructiveToolApp: "{tool} (destructive) runs without asking for {app}",
83
- allowEverything: "Allow everything, no questions asked",
84
- allowEverythingApp: "Allow everything, no questions asked, for {app}",
85
- allowEverythingNote: "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.",
86
- closeNote: "Closing this stops the code. To connect later, open this again from the page.",
87
- close: "Close",
88
- done: "Done",
89
- replacedSiblingTitle: "Opened in another tab",
90
- replacedSibling: "This page is open in another tab, and your AI apps now use that one. To use them here, connect this page again.",
91
- replacedTitle: "Another tab or program took over this page",
92
- replaced: "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.",
93
- takenOverAgain: "It was taken over again before its AI apps were disconnected. Try again.",
94
- tryAgainOrClose: "{reason} Try again, or close this."
95
- };
96
-
97
12
  // src/dialog.ts
98
13
  var counter = 0;
99
14
  function nextId() {
100
15
  return `tab-mcp-${++counter}`;
101
16
  }
102
17
  function stringsOf(options) {
103
- const s = { ...STRINGS };
104
- for (const [key, value] of Object.entries(options?.strings ?? {}))
105
- if (typeof value === "string" && key in s)
106
- s[key] = value;
107
- return s;
108
- }
109
- function format(template, values) {
110
- return template.replace(/\{(\w+)\}/g, (all, key) => values[key] ?? all);
18
+ return withEnglish2(options?.strings);
111
19
  }
112
20
  function fill(doc, template, values) {
113
21
  return template.split(/\{(\w+)\}/).map((part, i) => {
@@ -145,6 +53,19 @@ function name(doc, text) {
145
53
  node.dir = "ltr";
146
54
  return node;
147
55
  }
56
+ function pluralNames(doc, text, names, s) {
57
+ const list = el(doc, "span", {}, ...listFormat(s).formatToParts(names).map((part) => part.type === "element" ? name(doc, part.value) : part.value));
58
+ return fill(doc, pluralForm(text, names.length, s), { apps: list });
59
+ }
60
+ var shownNames = new WeakMap;
61
+ function showNames(doc, node, text, names, s) {
62
+ const key = names.length === 0 ? "" : [pluralForm(text, names.length, s), ...names].join(`
63
+ `);
64
+ if ((shownNames.get(node) ?? "") === key)
65
+ return;
66
+ shownNames.set(node, key);
67
+ node.replaceChildren(...names.length === 0 ? [] : pluralNames(doc, text, names, s));
68
+ }
148
69
  var visible = escapeInvisible2;
149
70
  function clientLabel(client, s) {
150
71
  if ("kind" in client && client.kind === "webmcp")
@@ -154,9 +75,6 @@ function clientLabel(client, s) {
154
75
  const host = visible(client.host || client.id);
155
76
  return client.name !== undefined && client.name !== "" ? format(s.clientRelay, { name: visible(client.name), host }) : host;
156
77
  }
157
- function listOf(items, s) {
158
- return items.length < 2 ? items[0] ?? "" : `${items.slice(0, -1).join(", ")} ${s.and} ${items.at(-1)}`;
159
- }
160
78
  var DIALOG_CSS = `.tab-mcp-dialog {
161
79
  --_tab-mcp-fg: var(--tab-mcp-color, CanvasText);
162
80
  --_tab-mcp-bg: var(--tab-mcp-background, Canvas);
@@ -241,9 +159,9 @@ html dialog.tab-mcp-dialog :where(.tab-mcp-switch > input:disabled) { opacity: 0
241
159
  .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); }
242
160
  .tab-mcp-setup-toggle:where([aria-expanded="true"])::before { transform: translateY(-0.15em) rotate(45deg); }
243
161
  .tab-mcp-code-used { display: flex; align-items: center; min-height: calc(var(--tab-mcp-code-size, 2em) * 1.2); }
244
- .tab-mcp-new-address-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
245
- .tab-mcp-new-address-row > :where(small) { flex: 1 1 14rem; color: var(--_tab-mcp-muted); }
246
- .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); }
162
+ .tab-mcp-disconnect-all-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
163
+ .tab-mcp-disconnect-all-row > :where(small) { flex: 1 1 14rem; color: var(--_tab-mcp-muted); }
164
+ .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); }
247
165
  .tab-mcp-connect > :where(.tab-mcp-actions) { gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--_tab-mcp-line); }
248
166
  .tab-mcp-close-note { flex: 1 1 12rem; }
249
167
  .tab-mcp-confirm :where(p bdi) { font-weight: 600; }
@@ -278,7 +196,7 @@ function newDialog(doc, className, s, ...title) {
278
196
  });
279
197
  dialog.setAttribute("aria-labelledby", `${id}-title`);
280
198
  dialog.lang = s.lang;
281
- dialog.dir = s.dir;
199
+ dialog.dir = directionOf(s);
282
200
  adoptStyles(doc);
283
201
  const heading = el(doc, "h2", { id: `${id}-title` }, ...title);
284
202
  dialog.append(heading);
@@ -324,7 +242,7 @@ function copyButton(doc, s, label, value, select, announce, className, kind) {
324
242
  return { button: node, reset };
325
243
  }
326
244
 
327
- export { nextId, stringsOf, format, fill, el, button, visible, clientLabel, listOf, newDialog, copyButton };
245
+ export { nextId, stringsOf, fill, el, button, showNames, visible, clientLabel, newDialog, copyButton };
328
246
 
329
- //# debugId=461C87FA3A5E330064756E2164756E21
330
- //# sourceMappingURL=index-c1c266tm.js.map
247
+ //# debugId=9A3B4D9B1229979964756E2164756E21
248
+ //# sourceMappingURL=index-7qqhn3zv.js.map
@@ -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 { DialogOptions, Grant, ToolCallClient } 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: 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/**\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": ";;;;;;;;;;;;AAeA,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,EAAyC,CACxD,KACA,KACA,QAA4D,CAAC,MAC1D,UACwB;AAAA,EAC3B,MAAM,OAAO,IAAI,cAAc,GAAG;AAAA,EAClC,IAAI,MAAM,cAAc;AAAA,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