@ractive-ch/tab-mcp-client 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -18
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/cdn/connection-gh2ayv77.min.js +11 -0
- package/cdn/connection-gh2ayv77.min.js.map +21 -0
- package/cdn/tab-mcp-client.min.js +3 -3
- package/cdn/tab-mcp-client.min.js.map +2 -2
- package/cdn/ui-j8sthahc.min.js +86 -0
- package/cdn/ui-j8sthahc.min.js.map +14 -0
- package/command.d.ts +20 -0
- package/{connection-eqqkev02.js → connection-c0vttra5.js} +21 -5
- package/{connection-eqqkev02.js.map → connection-c0vttra5.js.map} +4 -4
- package/index-dmh5vm5m.js +15 -0
- package/index-dmh5vm5m.js.map +10 -0
- package/index-nmn1j689.js +59 -0
- package/index-nmn1j689.js.map +11 -0
- package/index.d.ts +1 -1
- package/index.js +6 -6
- package/index.js.map +2 -2
- package/package.json +10 -2
- package/protocol.d.ts +3 -1
- package/setup.d.ts +44 -0
- package/setup.js +11 -0
- package/setup.js.map +9 -0
- package/types.d.ts +8 -0
- package/{ui-57hyd701.js → ui-azxkzgky.js} +217 -113
- package/ui-azxkzgky.js.map +11 -0
- package/ui.d.ts +17 -26
- package/version.d.ts +1 -1
- package/visible.d.ts +11 -0
- package/visible.js +9 -0
- package/visible.js.map +9 -0
- package/cdn/connection-9w0rx0vf.min.js +0 -11
- package/cdn/connection-9w0rx0vf.min.js.map +0 -21
- package/cdn/ui-406jbpym.min.js +0 -75
- package/cdn/ui-406jbpym.min.js.map +0 -11
- package/ui-57hyd701.js.map +0 -11
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SETUP_GUIDE2,
|
|
3
|
+
setupInstructions2
|
|
4
|
+
} from "./index-nmn1j689.js";
|
|
5
|
+
import {
|
|
6
|
+
escapeInvisible2
|
|
7
|
+
} from "./index-dmh5vm5m.js";
|
|
8
|
+
|
|
1
9
|
// src/always-allowed.ts
|
|
2
10
|
class AlwaysAllowed {
|
|
3
11
|
#tools = new Map;
|
|
@@ -56,6 +64,7 @@ var DIALOG_CSS = `.tab-mcp-dialog {
|
|
|
56
64
|
--_tab-mcp-line: color-mix(in srgb, var(--_tab-mcp-fg) 22%, transparent);
|
|
57
65
|
--_tab-mcp-surface: var(--tab-mcp-surface, color-mix(in srgb, var(--_tab-mcp-fg) 6%, transparent));
|
|
58
66
|
--_tab-mcp-danger: var(--tab-mcp-danger, light-dark(#b3261e, #ffb4ab));
|
|
67
|
+
--_tab-mcp-success: var(--tab-mcp-success, light-dark(#1a7f37, #6fdd8b));
|
|
59
68
|
--_tab-mcp-mono: var(--tab-mcp-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
|
60
69
|
--_tab-mcp-small-radius: calc(var(--tab-mcp-radius, 0.75rem) * 0.6);
|
|
61
70
|
box-sizing: border-box; margin: auto; width: calc(100% - 2rem); max-width: var(--tab-mcp-max-width, 34rem); max-height: calc(100% - 2rem); overflow: auto;
|
|
@@ -73,7 +82,7 @@ html dialog.tab-mcp-dialog:where(:focus) { outline: none; }
|
|
|
73
82
|
.tab-mcp-dialog :where(h2) { font-size: var(--tab-mcp-title-size, 1.25em); line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
|
|
74
83
|
.tab-mcp-dialog :where(h3) { font-size: 0.875em; font-weight: 600; color: var(--_tab-mcp-muted); margin-bottom: 0.5rem; }
|
|
75
84
|
.tab-mcp-dialog :where(small) { font-size: 0.875em; }
|
|
76
|
-
.tab-mcp-dialog :where(small, .tab-mcp-status, .tab-mcp-description, .tab-mcp-always-note, .tab-mcp-apps-note) { color: var(--_tab-mcp-muted); }
|
|
85
|
+
.tab-mcp-dialog :where(small, .tab-mcp-status, .tab-mcp-description, .tab-mcp-always-note, .tab-mcp-apps-note, .tab-mcp-success-next) { color: var(--_tab-mcp-muted); }
|
|
77
86
|
html dialog.tab-mcp-dialog :where(:focus-visible) { outline: 2px solid var(--tab-mcp-focus, var(--_tab-mcp-fg)); outline-offset: 2px; }
|
|
78
87
|
.tab-mcp-dialog :where(button) { font: inherit; font-size: 0.9375em; line-height: 1.25; 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; }
|
|
79
88
|
html dialog.tab-mcp-dialog :where(button:hover:not(:disabled)) { color: inherit; background: color-mix(in srgb, currentColor 8%, transparent); }
|
|
@@ -109,6 +118,15 @@ html button.tab-mcp-danger { color: var(--_tab-mcp-danger); border-color: color-
|
|
|
109
118
|
.tab-mcp-apps :where(li) { display: flex; align-items: center; justify-content: space-between; gap: 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); }
|
|
110
119
|
.tab-mcp-app { min-width: 0; overflow-wrap: anywhere; }
|
|
111
120
|
.tab-mcp-apps-note { margin-top: 0.5rem; }
|
|
121
|
+
.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); }
|
|
122
|
+
.tab-mcp-success-icon { flex: none; width: 2.75rem; height: 2.75rem; color: var(--_tab-mcp-success); }
|
|
123
|
+
.tab-mcp-success-text { display: grid; gap: 0.125rem; min-width: 0; }
|
|
124
|
+
.tab-mcp-success-title { font-size: 1.125em; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
|
|
125
|
+
.tab-mcp-setup { display: flex; flex-direction: column; gap: 1rem; }
|
|
126
|
+
.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); }
|
|
127
|
+
.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); }
|
|
128
|
+
.tab-mcp-setup-toggle:where([aria-expanded="true"])::before { transform: translateY(-0.15em) rotate(45deg); }
|
|
129
|
+
.tab-mcp-code-used { display: flex; align-items: center; min-height: calc(var(--tab-mcp-code-size, 2em) * 1.2); }
|
|
112
130
|
.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); }
|
|
113
131
|
.tab-mcp-connect > :where(.tab-mcp-actions) { gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--_tab-mcp-line); }
|
|
114
132
|
.tab-mcp-close-note { flex: 1 1 12rem; }
|
|
@@ -116,9 +134,10 @@ html button.tab-mcp-danger { color: var(--_tab-mcp-danger); border-color: color-
|
|
|
116
134
|
.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); }
|
|
117
135
|
.tab-mcp-always-note { font-size: 0.875em; }
|
|
118
136
|
@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; } }
|
|
119
|
-
@media (prefers-reduced-motion: no-preference) { .tab-mcp-dialog:where([open]) { animation: tab-mcp-in 0.15s ease-out; } }
|
|
137
|
+
@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); } }
|
|
120
138
|
@media (forced-colors: active) { html button.tab-mcp-primary { border-color: ButtonText; } }
|
|
121
139
|
@keyframes tab-mcp-in { from { opacity: 0; transform: translateY(0.5rem); } }
|
|
140
|
+
@keyframes tab-mcp-pop { from { opacity: 0; transform: scale(0.4); } }
|
|
122
141
|
`;
|
|
123
142
|
var sheets = new WeakMap;
|
|
124
143
|
function adoptStyles(doc) {
|
|
@@ -172,15 +191,7 @@ function newDialog(doc, className, title) {
|
|
|
172
191
|
dialog.append(heading);
|
|
173
192
|
return { dialog, heading };
|
|
174
193
|
}
|
|
175
|
-
var
|
|
176
|
-
function visible(text) {
|
|
177
|
-
return text.replace(INVISIBLE, (ch) => {
|
|
178
|
-
let escaped = "";
|
|
179
|
-
for (let i = 0;i < ch.length; i++)
|
|
180
|
-
escaped += `\\u${ch.charCodeAt(i).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
181
|
-
return escaped;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
194
|
+
var visible = escapeInvisible2;
|
|
184
195
|
function clientLabel(client) {
|
|
185
196
|
const host = visible(client.host || client.id);
|
|
186
197
|
return client.name !== undefined && client.name !== "" ? `${visible(client.name)} (${host})` : host;
|
|
@@ -305,50 +316,8 @@ function confirmInPage(mcp, request, doc, options) {
|
|
|
305
316
|
return answer !== "deny";
|
|
306
317
|
});
|
|
307
318
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
310
|
-
return label === "" ? "tools" : label;
|
|
311
|
-
}
|
|
312
|
-
function commandAddress(address) {
|
|
313
|
-
try {
|
|
314
|
-
const href = new URL(address).href;
|
|
315
|
-
return /^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(href) ? href : undefined;
|
|
316
|
-
} catch {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
var GUIDE = "https://ractive.ch/tab-mcp/connect/";
|
|
321
|
-
var CODEX_FEATURE = "mcp_2026_07_28";
|
|
322
|
-
function instructions(name, address) {
|
|
323
|
-
const n = commandName(name);
|
|
324
|
-
const a = commandAddress(address);
|
|
325
|
-
return [
|
|
326
|
-
[
|
|
327
|
-
"Claude (claude.ai and the desktop app)",
|
|
328
|
-
"Settings → Connectors → Add custom connector, then paste the address."
|
|
329
|
-
],
|
|
330
|
-
[
|
|
331
|
-
"ChatGPT",
|
|
332
|
-
"On chatgpt.com: Plugins, add an MCP server with the address. In the Mac app: Settings → Plugins → MCPs → Add, type Streamable HTTP; it needs the Codex feature below."
|
|
333
|
-
],
|
|
334
|
-
a === undefined ? ["Claude Code", "Add the address with claude mcp add --transport http."] : ["Claude Code", "Run:", `claude mcp add --transport http ${n} ${a}`],
|
|
335
|
-
[
|
|
336
|
-
"Codex",
|
|
337
|
-
...a === undefined ? [
|
|
338
|
-
`Run codex features enable ${CODEX_FEATURE}, then add the address with codex mcp add --url.`,
|
|
339
|
-
undefined
|
|
340
|
-
] : [
|
|
341
|
-
"Run:",
|
|
342
|
-
`codex features enable ${CODEX_FEATURE}
|
|
343
|
-
codex mcp add ${n} --url ${a}`
|
|
344
|
-
],
|
|
345
|
-
[
|
|
346
|
-
"Start a new chat in Codex after it connects. The first line turns on a feature for all of Codex's MCP servers; ",
|
|
347
|
-
`codex features disable ${CODEX_FEATURE}`,
|
|
348
|
-
" turns it off."
|
|
349
|
-
]
|
|
350
|
-
]
|
|
351
|
-
];
|
|
319
|
+
function appLabels(grants) {
|
|
320
|
+
return [...new Set(grants.map((g) => clientLabel(g.client)))];
|
|
352
321
|
}
|
|
353
322
|
function listOf(items) {
|
|
354
323
|
return items.length < 2 ? items[0] ?? "" : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
@@ -399,6 +368,42 @@ function replacedNotice(mcp, doc, sibling) {
|
|
|
399
368
|
dialog.showModal();
|
|
400
369
|
first.focus();
|
|
401
370
|
}
|
|
371
|
+
var CODE_USED_WAIT_MS = 1e4;
|
|
372
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
373
|
+
function checkIcon(doc) {
|
|
374
|
+
const set = (node, attributes) => {
|
|
375
|
+
for (const [key, value] of Object.entries(attributes))
|
|
376
|
+
node.setAttribute(key, value);
|
|
377
|
+
};
|
|
378
|
+
const svg = doc.createElementNS(SVG, "svg");
|
|
379
|
+
set(svg, {
|
|
380
|
+
class: "tab-mcp-success-icon",
|
|
381
|
+
viewBox: "0 0 48 48",
|
|
382
|
+
width: "44",
|
|
383
|
+
height: "44",
|
|
384
|
+
"aria-hidden": "true",
|
|
385
|
+
focusable: "false"
|
|
386
|
+
});
|
|
387
|
+
const disk = doc.createElementNS(SVG, "circle");
|
|
388
|
+
set(disk, {
|
|
389
|
+
cx: "24",
|
|
390
|
+
cy: "24",
|
|
391
|
+
r: "24",
|
|
392
|
+
fill: "currentColor",
|
|
393
|
+
"fill-opacity": "0.16"
|
|
394
|
+
});
|
|
395
|
+
const check = doc.createElementNS(SVG, "path");
|
|
396
|
+
set(check, {
|
|
397
|
+
d: "M14 24.5l7 7 13-14",
|
|
398
|
+
fill: "none",
|
|
399
|
+
stroke: "currentColor",
|
|
400
|
+
"stroke-width": "4",
|
|
401
|
+
"stroke-linecap": "round",
|
|
402
|
+
"stroke-linejoin": "round"
|
|
403
|
+
});
|
|
404
|
+
svg.append(disk, check);
|
|
405
|
+
return svg;
|
|
406
|
+
}
|
|
402
407
|
function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
403
408
|
const { dialog } = newDialog(doc, "tab-mcp-connect", "Connect your AI app");
|
|
404
409
|
dialog.tabIndex = -1;
|
|
@@ -421,6 +426,10 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
421
426
|
const announce = (text) => {
|
|
422
427
|
live.textContent = live.textContent === text ? `${text} ` : text;
|
|
423
428
|
};
|
|
429
|
+
const successId = `tab-mcp-${++counter}-success`;
|
|
430
|
+
const successTitle = el(doc, "p", { className: "tab-mcp-success-title" });
|
|
431
|
+
const successNext = el(doc, "p", { className: "tab-mcp-success-next" });
|
|
432
|
+
const success = el(doc, "div", { className: "tab-mcp-success", id: successId }, checkIcon(doc), el(doc, "div", { className: "tab-mcp-success-text" }, successTitle, successNext));
|
|
424
433
|
const addressId = `tab-mcp-${++counter}-address`;
|
|
425
434
|
const label = el(doc, "label", { text: "Add this address to your AI app:" });
|
|
426
435
|
label.htmlFor = addressId;
|
|
@@ -449,7 +458,9 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
449
458
|
const { button: copyCode, reset: resetCopyCode } = copyButton(doc, "code", () => code.textContent ?? "", () => doc.getSelection()?.selectAllChildren(code), announce, "tab-mcp-code-copy");
|
|
450
459
|
const codeSentence = el(doc, "span", {}, "When asked, enter the code ", code);
|
|
451
460
|
codeSentence.setAttribute("aria-live", "polite");
|
|
452
|
-
const
|
|
461
|
+
const codeUsed = el(doc, "span", { className: "tab-mcp-code-used" });
|
|
462
|
+
codeUsed.hidden = true;
|
|
463
|
+
const codeLine = el(doc, "p", { className: "tab-mcp-code" }, codeSentence, codeUsed, " ", copyCode, el(doc, "br"), el(doc, "small", {
|
|
453
464
|
className: "tab-mcp-code-note",
|
|
454
465
|
text: "A new code appears every 2 minutes and after each use."
|
|
455
466
|
}));
|
|
@@ -461,12 +472,21 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
461
472
|
const guide = el(doc, "a", {
|
|
462
473
|
text: "Step by step, and what to do when it fails"
|
|
463
474
|
});
|
|
464
|
-
guide.href =
|
|
475
|
+
guide.href = SETUP_GUIDE2;
|
|
465
476
|
guide.target = "_blank";
|
|
466
477
|
guide.rel = "noopener noreferrer";
|
|
467
478
|
const help = el(doc, "details", { className: "tab-mcp-help" }, el(doc, "summary", { text: "How do I add it?" }), steps, el(doc, "p", { className: "tab-mcp-guide" }, guide));
|
|
479
|
+
const setupId = `tab-mcp-${++counter}-setup`;
|
|
480
|
+
const setup = el(doc, "div", { className: "tab-mcp-setup", id: setupId }, addressBox, confirmBox, codeLine, signInLine, help);
|
|
481
|
+
let expanded = false;
|
|
482
|
+
const setupToggle = button(doc, "Connect another app", () => {
|
|
483
|
+
expanded = !expanded;
|
|
484
|
+
renderView(false);
|
|
485
|
+
}, "tab-mcp-setup-toggle");
|
|
486
|
+
setupToggle.setAttribute("aria-controls", setupId);
|
|
468
487
|
const appList = el(doc, "ul");
|
|
469
|
-
const
|
|
488
|
+
const appsNote = el(doc, "p", { className: "tab-mcp-apps-note" });
|
|
489
|
+
const apps = el(doc, "div", { className: "tab-mcp-apps" }, el(doc, "h3", { text: "Connected" }), appList, appsNote);
|
|
470
490
|
const closeNote = el(doc, "small", {
|
|
471
491
|
className: "tab-mcp-close-note",
|
|
472
492
|
text: "Closing this stops the code. The address stays the same: to connect later, open this again from the page."
|
|
@@ -475,34 +495,50 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
475
495
|
const done = button(doc, "Done", () => dialog.close(), "tab-mcp-done", "primary");
|
|
476
496
|
done.hidden = true;
|
|
477
497
|
const actions = el(doc, "div", { className: "tab-mcp-actions" }, closeNote, " ", close, done);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
closeNote.hidden = paired || codeLine.hidden;
|
|
482
|
-
};
|
|
483
|
-
const setPaired = (value) => {
|
|
484
|
-
paired = value;
|
|
485
|
-
if (!paired)
|
|
486
|
-
pairedGrants.clear();
|
|
487
|
-
const focused = doc.activeElement;
|
|
488
|
-
renderCloseNote();
|
|
489
|
-
close.hidden = paired;
|
|
490
|
-
done.hidden = !paired;
|
|
491
|
-
if (paired && focused === close)
|
|
492
|
-
done.focus();
|
|
493
|
-
if (!paired && focused === done)
|
|
494
|
-
close.focus();
|
|
495
|
-
};
|
|
496
|
-
const closer = () => paired ? done : close;
|
|
497
|
-
dialog.append(status, addressBox, confirmBox, codeLine, signInLine, help, apps, actions, live);
|
|
498
|
+
dialog.append(success, status, apps, setupToggle, setup, actions, live);
|
|
499
|
+
success.hidden = true;
|
|
500
|
+
setupToggle.hidden = true;
|
|
498
501
|
addressBox.hidden = true;
|
|
499
502
|
codeLine.hidden = true;
|
|
500
503
|
signInLine.hidden = true;
|
|
501
504
|
help.hidden = true;
|
|
502
505
|
apps.hidden = true;
|
|
503
506
|
let renewing = false;
|
|
507
|
+
const pairedGrants = new Set;
|
|
508
|
+
let connectedView = false;
|
|
509
|
+
let codeShown = false;
|
|
510
|
+
const closer = () => connectedView ? done : close;
|
|
511
|
+
const start = () => connectedView ? done : copy;
|
|
512
|
+
const focusLost = (focused) => focused !== null && focused !== dialog && focused !== doc.body && (!focused.isConnected || dialog.contains(focused) && focused.closest("[hidden]") !== null);
|
|
513
|
+
const renderView = (paired, focused = doc.activeElement) => {
|
|
514
|
+
connectedView = !renewing && mcp.state === "connected" && mcp.grants.length > 0;
|
|
515
|
+
if (paired && confirmBox.hidden)
|
|
516
|
+
expanded = false;
|
|
517
|
+
if (connectedView) {
|
|
518
|
+
const here = mcp.grants.filter((g) => pairedGrants.has(g.grantId));
|
|
519
|
+
const names = appLabels(here.length > 0 ? here : mcp.grants);
|
|
520
|
+
const one = names.length === 1;
|
|
521
|
+
successTitle.textContent = `${listOf(names)} ${one ? "is" : "are"} connected`;
|
|
522
|
+
successNext.textContent = `You can close this now and ask ${one ? "it" : "them"} to use the tools of this page.`;
|
|
523
|
+
dialog.setAttribute("aria-describedby", successId);
|
|
524
|
+
} else
|
|
525
|
+
dialog.removeAttribute("aria-describedby");
|
|
526
|
+
success.hidden = !connectedView;
|
|
527
|
+
status.hidden = connectedView;
|
|
528
|
+
setupToggle.hidden = !connectedView;
|
|
529
|
+
setupToggle.setAttribute("aria-expanded", String(expanded));
|
|
530
|
+
setup.hidden = connectedView && !expanded;
|
|
531
|
+
copy.classList.toggle("tab-mcp-primary", !connectedView);
|
|
532
|
+
closeNote.hidden = connectedView || !codeShown;
|
|
533
|
+
close.hidden = connectedView;
|
|
534
|
+
done.hidden = !connectedView;
|
|
535
|
+
if (focusLost(focused))
|
|
536
|
+
closer().focus();
|
|
537
|
+
if (paired && connectedView)
|
|
538
|
+
announce(`${successTitle.textContent}. ${successNext.textContent}`);
|
|
539
|
+
};
|
|
504
540
|
const renderQuestion = () => {
|
|
505
|
-
const names = mcp.grants
|
|
541
|
+
const names = appLabels(mcp.grants);
|
|
506
542
|
if (names.length === 0)
|
|
507
543
|
return false;
|
|
508
544
|
confirmText.textContent = `A new address disconnects ${listOf(names)}. To use this page again, add the new address to ${names.length === 1 ? "it" : "them"}.`;
|
|
@@ -519,39 +555,50 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
519
555
|
cancelNew.focus();
|
|
520
556
|
};
|
|
521
557
|
const getNewAddress = () => {
|
|
522
|
-
|
|
523
|
-
close.focus();
|
|
524
|
-
confirmBox.hidden = true;
|
|
558
|
+
pairedGrants.clear();
|
|
525
559
|
renewing = true;
|
|
526
560
|
status.textContent = "Getting a new address…";
|
|
561
|
+
renderView(false);
|
|
562
|
+
close.focus();
|
|
563
|
+
confirmBox.hidden = true;
|
|
527
564
|
mcp.newAddress().then(() => {
|
|
528
565
|
renewing = false;
|
|
529
566
|
status.textContent = "This is a new address. Add it to your AI app again.";
|
|
567
|
+
renderView(false);
|
|
530
568
|
copy.focus();
|
|
531
569
|
}, (error) => {
|
|
532
570
|
renewing = false;
|
|
533
571
|
status.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}. Close this and connect again.`;
|
|
572
|
+
renderView(false);
|
|
534
573
|
closer().focus();
|
|
535
574
|
});
|
|
536
575
|
};
|
|
576
|
+
let stepsFor;
|
|
537
577
|
const renderSession = (session) => {
|
|
538
578
|
if (session === undefined) {
|
|
539
579
|
addressBox.hidden = true;
|
|
540
580
|
confirmBox.hidden = true;
|
|
541
581
|
help.hidden = true;
|
|
582
|
+
renderView(false);
|
|
542
583
|
return;
|
|
543
584
|
}
|
|
544
|
-
address.value
|
|
545
|
-
|
|
585
|
+
if (address.value !== session.address) {
|
|
586
|
+
address.value = session.address;
|
|
587
|
+
resetCopy();
|
|
588
|
+
}
|
|
546
589
|
const appName = session.appName ?? mcp.appName;
|
|
547
590
|
if (!renewing)
|
|
548
591
|
status.textContent = appName !== undefined ? `${appName} is ready for your AI app.` : "This page is ready for your AI app.";
|
|
549
592
|
fresh.disabled = mcp.state !== "connected";
|
|
550
593
|
addressBox.hidden = false;
|
|
551
|
-
if (doc.activeElement === dialog)
|
|
552
|
-
copy.focus();
|
|
553
594
|
help.hidden = false;
|
|
554
|
-
|
|
595
|
+
renderView(false);
|
|
596
|
+
if (doc.activeElement === dialog)
|
|
597
|
+
start().focus();
|
|
598
|
+
if (stepsFor === session.address)
|
|
599
|
+
return;
|
|
600
|
+
stepsFor = session.address;
|
|
601
|
+
steps.replaceChildren(...setupInstructions2(serverName, session.address).map(({ app, text: how, command, note }) => {
|
|
555
602
|
const item = el(doc, "li", {}, el(doc, "strong", { text: `${app}:` }), ` ${how}`);
|
|
556
603
|
if (command !== undefined) {
|
|
557
604
|
const text = el(doc, "pre", { text: command });
|
|
@@ -560,22 +607,67 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
560
607
|
item.append(el(doc, "div", { className: "tab-mcp-command" }, text, copyCommand));
|
|
561
608
|
}
|
|
562
609
|
if (note !== undefined)
|
|
563
|
-
item.append(el(doc, "small", { className: "tab-mcp-command-note" }, ...note.map((part
|
|
610
|
+
item.append(el(doc, "small", { className: "tab-mcp-command-note" }, ...note.map((part) => ("code" in part) ? el(doc, "code", { text: part.code }) : part.text)));
|
|
564
611
|
return item;
|
|
565
612
|
}));
|
|
566
613
|
};
|
|
614
|
+
let shownCode;
|
|
615
|
+
let usedTimer;
|
|
616
|
+
const stopWaiting = () => {
|
|
617
|
+
clearTimeout(usedTimer);
|
|
618
|
+
usedTimer = undefined;
|
|
619
|
+
};
|
|
620
|
+
const endWait = () => {
|
|
621
|
+
stopWaiting();
|
|
622
|
+
shownCode = mcp.pairingCode;
|
|
623
|
+
renderCode();
|
|
624
|
+
};
|
|
567
625
|
const renderCode = () => {
|
|
626
|
+
const focused = doc.activeElement;
|
|
568
627
|
const current = mcp.pairingCode;
|
|
569
628
|
const oidc = mcp.session?.pairing === "oidc";
|
|
570
|
-
if (
|
|
571
|
-
|
|
572
|
-
code
|
|
629
|
+
if (current === undefined)
|
|
630
|
+
stopWaiting();
|
|
631
|
+
else if (current.code !== shownCode?.code) {
|
|
632
|
+
if (current.reason === "used") {
|
|
633
|
+
if (usedTimer === undefined) {
|
|
634
|
+
usedTimer = setTimeout(endWait, CODE_USED_WAIT_MS);
|
|
635
|
+
announce("Code used. Waiting for your AI app…");
|
|
636
|
+
}
|
|
637
|
+
} else if (usedTimer !== undefined) {
|
|
638
|
+
stopWaiting();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const used = usedTimer !== undefined;
|
|
642
|
+
if (!used) {
|
|
643
|
+
if (code.textContent !== (current?.code ?? ""))
|
|
644
|
+
resetCopyCode();
|
|
645
|
+
code.textContent = current?.code ?? "";
|
|
646
|
+
shownCode = current;
|
|
647
|
+
}
|
|
648
|
+
codeSentence.hidden = used;
|
|
649
|
+
copyCode.hidden = used;
|
|
650
|
+
codeUsed.hidden = !used;
|
|
651
|
+
codeUsed.textContent = used ? "Code used. Waiting for your AI app…" : "";
|
|
573
652
|
codeLine.hidden = oidc || current === undefined;
|
|
574
653
|
signInLine.hidden = !oidc;
|
|
575
|
-
|
|
654
|
+
codeShown = !codeLine.hidden;
|
|
655
|
+
closeNote.hidden = connectedView || !codeShown;
|
|
656
|
+
if (focusLost(focused))
|
|
657
|
+
closer().focus();
|
|
658
|
+
};
|
|
659
|
+
const items = new Map;
|
|
660
|
+
const appItem = (grant) => {
|
|
661
|
+
const disconnect = button(doc, "Disconnect", () => {
|
|
662
|
+
if (!mcp.revoke(grant.grantId))
|
|
663
|
+
renderGrants();
|
|
664
|
+
}, "tab-mcp-disconnect", "danger");
|
|
665
|
+
const item = el(doc, "li", {}, el(doc, "span", {
|
|
666
|
+
className: "tab-mcp-app",
|
|
667
|
+
text: `${clientLabel(grant.client)} connected `
|
|
668
|
+
}), disconnect);
|
|
669
|
+
return { item, disconnect };
|
|
576
670
|
};
|
|
577
|
-
const appsNote = el(doc, "p", { className: "tab-mcp-apps-note" });
|
|
578
|
-
apps.append(appsNote);
|
|
579
671
|
const known = new Set(mcp.grants.map((g) => g.grantId));
|
|
580
672
|
let session = mcp.session;
|
|
581
673
|
const renderGrants = () => {
|
|
@@ -584,30 +676,37 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
584
676
|
for (const grant of mcp.grants)
|
|
585
677
|
known.add(grant.grantId);
|
|
586
678
|
}
|
|
679
|
+
let paired = false;
|
|
587
680
|
for (const grant of mcp.grants) {
|
|
588
681
|
if (known.has(grant.grantId))
|
|
589
682
|
continue;
|
|
590
683
|
known.add(grant.grantId);
|
|
591
684
|
status.textContent = `${clientLabel(grant.client)} is connected.`;
|
|
592
685
|
pairedGrants.add(grant.grantId);
|
|
593
|
-
|
|
594
|
-
setPaired(true);
|
|
686
|
+
paired = true;
|
|
595
687
|
}
|
|
596
|
-
|
|
597
|
-
|
|
688
|
+
const ids = new Set(mcp.grants.map((g) => g.grantId));
|
|
689
|
+
for (const id of pairedGrants)
|
|
690
|
+
if (!ids.has(id))
|
|
691
|
+
pairedGrants.delete(id);
|
|
692
|
+
const focused = doc.activeElement;
|
|
693
|
+
for (const [id, { item }] of items) {
|
|
694
|
+
if (ids.has(id))
|
|
695
|
+
continue;
|
|
696
|
+
item.remove();
|
|
697
|
+
items.delete(id);
|
|
598
698
|
}
|
|
599
699
|
const connected = mcp.state === "connected";
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}));
|
|
700
|
+
mcp.grants.forEach((grant, i) => {
|
|
701
|
+
let entry = items.get(grant.grantId);
|
|
702
|
+
if (entry === undefined) {
|
|
703
|
+
entry = appItem(grant);
|
|
704
|
+
items.set(grant.grantId, entry);
|
|
705
|
+
}
|
|
706
|
+
entry.disconnect.disabled = !connected;
|
|
707
|
+
if (appList.children[i] !== entry.item)
|
|
708
|
+
appList.insertBefore(entry.item, appList.children[i] ?? null);
|
|
709
|
+
});
|
|
611
710
|
appsNote.textContent = connected ? "" : "To disconnect an app, connect this page again first.";
|
|
612
711
|
appsNote.hidden = connected;
|
|
613
712
|
apps.hidden = mcp.grants.length === 0;
|
|
@@ -615,6 +714,10 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
615
714
|
confirmBox.hidden = true;
|
|
616
715
|
fresh.focus();
|
|
617
716
|
}
|
|
717
|
+
if (paired && usedTimer !== undefined)
|
|
718
|
+
endWait();
|
|
719
|
+
const now = doc.activeElement;
|
|
720
|
+
renderView(paired, now === null || now === doc.body ? focused : now);
|
|
618
721
|
};
|
|
619
722
|
const onDisconnected = (event) => {
|
|
620
723
|
if (event.detail.reason !== "new_address")
|
|
@@ -645,6 +748,7 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
645
748
|
});
|
|
646
749
|
return new Promise((resolve) => {
|
|
647
750
|
dialog.addEventListener("close", () => {
|
|
751
|
+
stopWaiting();
|
|
648
752
|
mcp.stopPairing();
|
|
649
753
|
mcp.removeEventListener("pairingcode", renderCode);
|
|
650
754
|
mcp.removeEventListener("grantschange", renderGrants);
|
|
@@ -655,8 +759,8 @@ function showConnectDialog(mcp, connecting, doc, serverName = "tools") {
|
|
|
655
759
|
resolve();
|
|
656
760
|
}, { once: true });
|
|
657
761
|
dialog.showModal();
|
|
658
|
-
if (!addressBox.hidden)
|
|
659
|
-
|
|
762
|
+
if (connectedView || !addressBox.hidden)
|
|
763
|
+
start().focus();
|
|
660
764
|
else
|
|
661
765
|
dialog.focus();
|
|
662
766
|
});
|
|
@@ -666,5 +770,5 @@ export {
|
|
|
666
770
|
showConnectDialog
|
|
667
771
|
};
|
|
668
772
|
|
|
669
|
-
//# debugId=
|
|
670
|
-
//# sourceMappingURL=ui-
|
|
773
|
+
//# debugId=D7F498D31122679364756E2164756E21
|
|
774
|
+
//# sourceMappingURL=ui-azxkzgky.js.map
|