@ractive-ch/tab-mcp-client 0.9.1 → 0.11.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 +86 -19
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/cdn/connection-8zhj84k2.min.js +11 -0
- package/cdn/connection-8zhj84k2.min.js.map +21 -0
- package/cdn/tab-mcp-client.min.js +3 -3
- package/cdn/tab-mcp-client.min.js.map +4 -4
- package/cdn/ui-0wa4gyh3.min.js +86 -0
- package/cdn/ui-0wa4gyh3.min.js.map +11 -0
- package/{connection-eqqkev02.js → connection-c0vttra5.js} +21 -5
- package/{connection-eqqkev02.js.map → connection-c0vttra5.js.map} +4 -4
- package/index.d.ts +1 -1
- package/index.js +6 -6
- package/index.js.map +4 -4
- package/package.json +2 -2
- package/protocol.d.ts +3 -1
- package/react.d.ts +1 -1
- package/react.js +3 -2
- package/react.js.map +3 -3
- package/tab-mcp.d.ts +1 -1
- package/types.d.ts +15 -3
- package/{ui-xjr9vzga.js → ui-50jse8y7.js} +207 -58
- package/ui-50jse8y7.js.map +11 -0
- package/ui.d.ts +17 -5
- package/version.d.ts +1 -1
- package/cdn/connection-0x5mr3te.min.js +0 -11
- package/cdn/connection-0x5mr3te.min.js.map +0 -21
- package/cdn/ui-6cdy3wps.min.js +0 -75
- package/cdn/ui-6cdy3wps.min.js.map +0 -11
- package/connecting.md +0 -77
- package/ui-xjr9vzga.js.map +0 -11
package/ui.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type { ConfirmRequest, SessionInfo } from "./types.js";
|
|
|
22
22
|
* page's `color-scheme`, so the dialogs follow its light or dark scheme. The
|
|
23
23
|
* `--_tab-mcp-*` properties are internal. Order matters among equals.
|
|
24
24
|
*/
|
|
25
|
-
export declare 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-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; 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));\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; }\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) { 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; 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; 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); }\n.tab-mcp-app { min-width: 0; overflow-wrap: anywhere; }\n.tab-mcp-apps-note { margin-top: 0.5rem; }\n.tab-mcp-new-address-question { display: grid; gap: 0.75rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--_tab-mcp-danger) 50%, transparent); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-connect > :where(.tab-mcp-actions) { gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--_tab-mcp-line); }\n.tab-mcp-close-note { flex: 1 1 12rem; }\n.tab-mcp-confirm :where(p bdi) { font-weight: 600; }\n.tab-mcp-arguments { box-sizing: content-box; font: 0.875em / 1.45 var(--_tab-mcp-mono); padding: 0.75rem; background: var(--_tab-mcp-surface); border: 1px solid var(--_tab-mcp-line); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-always-note { 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; } }\n@media (prefers-reduced-motion: no-preference) { .tab-mcp-dialog:where([open]) { animation: tab-mcp-in 0.15s ease-out; } }\n@media (forced-colors: active) { html button.tab-mcp-primary { border-color: ButtonText; } }\n@keyframes tab-mcp-in { from { opacity: 0; transform: translateY(0.5rem); } }\n";
|
|
25
|
+
export declare 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));\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; }\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) { 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; 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; 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); }\n.tab-mcp-app { min-width: 0; overflow-wrap: anywhere; }\n.tab-mcp-apps-note { margin-top: 0.5rem; }\n.tab-mcp-success { display: flex; align-items: center; gap: 0.875rem; padding: 1rem; background: color-mix(in srgb, var(--_tab-mcp-success) 10%, transparent); border: 1px solid color-mix(in srgb, var(--_tab-mcp-success) 45%, transparent); border-radius: var(--_tab-mcp-small-radius); }\n.tab-mcp-success-icon { flex: none; width: 2.75rem; height: 2.75rem; color: var(--_tab-mcp-success); }\n.tab-mcp-success-text { display: grid; gap: 0.125rem; min-width: 0; }\n.tab-mcp-success-title { font-size: 1.125em; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }\n.tab-mcp-setup { display: flex; flex-direction: column; gap: 1rem; }\n.tab-mcp-setup-toggle { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.75rem 1rem; text-align: start; font-weight: 600; border-color: var(--_tab-mcp-line); }\n.tab-mcp-setup-toggle::before { content: \"\"; flex: none; width: 0.45em; height: 0.45em; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateX(-0.1em) rotate(-45deg); }\n.tab-mcp-setup-toggle:where([aria-expanded=\"true\"])::before { transform: translateY(-0.15em) rotate(45deg); }\n.tab-mcp-code-used { display: flex; align-items: center; min-height: calc(var(--tab-mcp-code-size, 2em) * 1.2); }\n.tab-mcp-new-address-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 { 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; } }\n@media (prefers-reduced-motion: no-preference) { .tab-mcp-dialog:where([open]) { animation: tab-mcp-in 0.15s ease-out; } .tab-mcp-success-icon { animation: tab-mcp-pop 0.4s cubic-bezier(0.3, 1.4, 0.6, 1); } }\n@media (forced-colors: active) { html button.tab-mcp-primary { border-color: ButtonText; } }\n@keyframes tab-mcp-in { from { opacity: 0; transform: translateY(0.5rem); } }\n@keyframes tab-mcp-pop { from { opacity: 0; transform: scale(0.4); } }\n";
|
|
26
26
|
/** How long "Allow" stays disabled after the confirmation opens, and the floor. */
|
|
27
27
|
export declare const ALLOW_DELAY_MS = 750;
|
|
28
28
|
export declare const MIN_ALLOW_DELAY_MS = 500;
|
|
@@ -79,14 +79,26 @@ export declare function instructions(name: string, address: string): [string, st
|
|
|
79
79
|
* opens the connect dialog to add it to the AI apps again.
|
|
80
80
|
*/
|
|
81
81
|
export declare function replacedNotice(mcp: TabMcp, doc: Document, sibling: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* How long a used code stays "Code used" before its replacement is shown: the
|
|
84
|
+
* AI app connects a moment after the code was entered (its token request), and
|
|
85
|
+
* a new code in plain view meanwhile looks as if it did not work. Only when
|
|
86
|
+
* the relay says the code was used (`reason: "used"`); a relay that does not
|
|
87
|
+
* say why gets the new code shown at once.
|
|
88
|
+
*/
|
|
89
|
+
export declare const CODE_USED_WAIT_MS = 10000;
|
|
82
90
|
/**
|
|
83
91
|
* The "Connect your AI app" dialog: the address with Copy and New address,
|
|
84
92
|
* short instructions, the pairing code (with Copy) while the relay sends one,
|
|
85
93
|
* and the connected apps with Disconnect. Pairing is on while it is open, so
|
|
86
94
|
* closing it ends the code; the connection and the address stay. Until an app
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
95
|
+
* is connected, only a small Close (and Escape) close it. Once one is (it
|
|
96
|
+
* pairs here, or was paired when the dialog opened), a confirmation with a
|
|
97
|
+
* check mark leads, the setup moves behind "Connect another app" and Done is
|
|
98
|
+
* the primary button. New address asks first when it would disconnect
|
|
99
|
+
* connected apps (`newAddress()` revokes them). When the page loses its
|
|
100
|
+
* address (`replaced`), this dialog closes and `replacedNotice` says why,
|
|
101
|
+
* from then on also while it is closed. Its nodes are built once and shown or
|
|
102
|
+
* hidden, not rebuilt on a change, so nothing flickers and focus stays.
|
|
91
103
|
*/
|
|
92
104
|
export declare function showConnectDialog(mcp: TabMcp, connecting: Promise<SessionInfo>, doc: Document, serverName?: string): Promise<void>;
|
package/version.d.ts
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var at=/^(?:\d{1,4}x\d{1,4}|any)$/;function ut(e){let{src:t,mimeType:r,sizes:s,theme:i}=e;if(typeof t!=="string")return;let d=/^https?:/i.test(t)&&t.length<=2048,o=/^data:image\/(?:png|jpeg|gif|webp|x-icon|vnd\.microsoft\.icon)[;,]/i.test(t)&&t.length<=16384;if(!d&&!o)return;let u={src:t};if(typeof r==="string"&&/^image\/[\w.+-]+$/i.test(r))u.mimeType=r.toLowerCase();let x=Array.isArray(s)?s.map((O)=>String(O).toLowerCase()).filter((O)=>at.test(O)):[];if(x.length>0)u.sizes=x;if(i==="light"||i==="dark")u.theme=i;return u}function xe(e){let t=[];for(let r of e){let s=typeof r==="object"&&r!==null?ut(r):void 0;if(s!==void 0)t.push(s);if(t.length===8)break}return t}function Ne(e=globalThis.document){try{let t=e?.querySelectorAll('link[rel~="icon" i], link[rel~="apple-touch-icon" i]');return xe([...t??[]].filter((r)=>r.getAttribute("href")?.trim()).map((r)=>{let s={src:r.href};if(r.type)s.mimeType=r.type;let i=r.getAttribute("sizes");if(i)s.sizes=i.trim().split(/\s+/);let d=/prefers-color-scheme:\s*(light|dark)/i.exec(r.media);if(d)s.theme=d[1]?.toLowerCase();return s}))}catch{return[]}}function ae(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let s=e.length;if(s!==t.length)return!1;for(let i=0;i<s;i++)if(!ae(e[i],t[i]))return!1;return!0}if(r==="object"){if(!e||!t)return e===t;let s=Object.keys(e),i=Object.keys(t);if(s.length!==i.length)return!1;for(let o of s)if(!ae(e[o],t[o]))return!1;return!0}return e===t}function U(e){return encodeURI(lt(e))}function lt(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var ft={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},ct={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},pt={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},mt=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function ee(e,t=Object.create(null),r=mt,s=""){if(e&&typeof e==="object"&&!Array.isArray(e)){let d=e.$id||e.id;if(d){let o=new URL(d,r.href);if(o.hash.length>1)t[o.href]=e;else if(o.hash="",s==="")r=o;else ee(e,t,r)}}else if(e!==!0&&e!==!1)return t;let i=r.href+(s?"#"+s:"");if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0)Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i});if(e.$ref&&e.__absolute_ref__===void 0){let d=new URL(e.$ref,r.href);d.hash=d.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:d.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let d=new URL(e.$recursiveRef,r.href);d.hash=d.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:d.href})}if(e.$anchor){let d=new URL("#"+e.$anchor,r.href);t[d.href]=e}for(let d in e){if(pt[d])continue;let o=`${s}/${U(d)}`,u=e[d];if(Array.isArray(u)){if(ft[d]){let x=u.length;for(let O=0;O<x;O++)ee(u[O],t,r,`${o}/${O}`)}}else if(ct[d])for(let x in u)ee(u[x],t,r,`${o}/${U(x)}`);else ee(u,t,r,o)}return t}var yt=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gt=[0,31,28,31,30,31,30,31,31,30,31,30,31],ht=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,$t=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,bt=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,wt=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,kt=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Rt=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,It=/^(?:\/(?:[^~/]|~0|~1)*)*$/,xt=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Tt=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,_t=(e)=>{if(e[0]==='"')return!1;let[t,r,...s]=e.split("@");if(!t||!r||s.length!==0||t.length>64||r.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return r.split(".").every((i)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(i))},vt=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,St=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Mt=(e)=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Y(e){return e.test.bind(e)}var Te={date:je,time:qe.bind(void 0,!1),"date-time":At,duration:Mt,uri:Nt,"uri-reference":Y(bt),"uri-template":Y(wt),url:Y(kt),email:_t,hostname:Y($t),ipv4:Y(vt),ipv6:Y(St),regex:qt,uuid:Y(Rt),"json-pointer":Y(It),"json-pointer-uri-fragment":Y(xt),"relative-json-pointer":Y(Tt)};function Et(e){return e%4===0&&(e%100!==0||e%400===0)}function je(e){let t=e.match(yt);if(!t)return!1;let r=+t[1],s=+t[2],i=+t[3];return s>=1&&s<=12&&i>=1&&i<=(s==2&&Et(r)?29:gt[s])}function qe(e,t){let r=t.match(ht);if(!r)return!1;let s=+r[1],i=+r[2],d=+r[3],o=!!r[5];return(s<=23&&i<=59&&d<=59||s==23&&i==59&&d==60)&&(!e||o)}var Ot=/t|\s/i;function At(e){let t=e.split(Ot);return t.length==2&&je(t[0])&&qe(!0,t[1])}var Pt=/\/|:/,Ct=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Nt(e){return Pt.test(e)&&Ct.test(e)}var jt=/[^\\]\\Z/;function qt(e){if(jt.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function ze(e){let t=0,r=e.length,s=0,i;while(s<r)if(t++,i=e.charCodeAt(s++),i>=55296&&i<=56319&&s<r){if(i=e.charCodeAt(s),(i&64512)==56320)s++}return t}function E(e,t,r="2019-09",s=ee(t),i=!0,d=null,o="#",u="#",x=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};let O=typeof e,v;switch(O){case"boolean":case"number":case"string":v=O;break;case"object":if(e===null)v="null";else if(Array.isArray(e))v="array";else v="object";break;default:throw Error(`Instances of "${O}" type are not supported.`)}let{$ref:B,$recursiveRef:D,$recursiveAnchor:V,type:C,const:G,enum:W,required:Q,not:L,anyOf:A,allOf:l,oneOf:g,if:R,then:T,else:y,format:n,properties:h,patternProperties:p,additionalProperties:S,unevaluatedProperties:_,minProperties:N,maxProperties:P,propertyNames:K,dependentRequired:z,dependentSchemas:j,dependencies:H,prefixItems:fe,items:re,additionalItems:Me,unevaluatedItems:Ee,contains:Oe,minContains:X,maxContains:me,minItems:Re,maxItems:Ie,uniqueItems:it,minimum:ne,maximum:oe,exclusiveMinimum:ce,exclusiveMaximum:pe,multipleOf:ye,minLength:ge,maxLength:he,pattern:Ae,__absolute_ref__:$e,__absolute_recursive_ref__:dt}=t,f=[];if(V===!0&&d===null)d=t;if(D==="#"){let b=d===null?s[dt]:d,m=`${u}/$recursiveRef`,I=E(e,d===null?t:d,r,s,i,b,o,m,x);if(!I.valid)f.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:m,error:"A subschema had errors."},...I.errors)}if(B!==void 0){let m=s[$e||B];if(m===void 0){let a=`Unresolved $ref "${B}".`;if($e&&$e!==B)a+=` Absolute URI "${$e}".`;throw a+=`
|
|
2
|
-
Known schemas:
|
|
3
|
-
- ${Object.keys(s).join(`
|
|
4
|
-
- `)}`,Error(a)}let I=`${u}/$ref`,c=E(e,m,r,s,i,d,o,I,x);if(!c.valid)f.push({instanceLocation:o,keyword:"$ref",keywordLocation:I,error:"A subschema had errors."},...c.errors);if(r==="4"||r==="7")return{valid:f.length===0,errors:f}}if(Array.isArray(C)){let b=C.length,m=!1;for(let I=0;I<b;I++)if(v===C[I]||C[I]==="integer"&&v==="number"&&e%1===0&&e===e){m=!0;break}if(!m)f.push({instanceLocation:o,keyword:"type",keywordLocation:`${u}/type`,error:`Instance type "${v}" is invalid. Expected "${C.join('", "')}".`})}else if(C==="integer"){if(v!=="number"||e%1||e!==e)f.push({instanceLocation:o,keyword:"type",keywordLocation:`${u}/type`,error:`Instance type "${v}" is invalid. Expected "${C}".`})}else if(C!==void 0&&v!==C)f.push({instanceLocation:o,keyword:"type",keywordLocation:`${u}/type`,error:`Instance type "${v}" is invalid. Expected "${C}".`});if(G!==void 0){if(v==="object"||v==="array"){if(!ae(e,G))f.push({instanceLocation:o,keyword:"const",keywordLocation:`${u}/const`,error:`Instance does not match ${JSON.stringify(G)}.`})}else if(e!==G)f.push({instanceLocation:o,keyword:"const",keywordLocation:`${u}/const`,error:`Instance does not match ${JSON.stringify(G)}.`})}if(W!==void 0){if(v==="object"||v==="array"){if(!W.some((b)=>ae(e,b)))f.push({instanceLocation:o,keyword:"enum",keywordLocation:`${u}/enum`,error:`Instance does not match any of ${JSON.stringify(W)}.`})}else if(!W.some((b)=>e===b))f.push({instanceLocation:o,keyword:"enum",keywordLocation:`${u}/enum`,error:`Instance does not match any of ${JSON.stringify(W)}.`})}if(L!==void 0){let b=`${u}/not`;if(E(e,L,r,s,i,d,o,b).valid)f.push({instanceLocation:o,keyword:"not",keywordLocation:b,error:'Instance matched "not" schema.'})}let be=[];if(A!==void 0){let b=`${u}/anyOf`,m=f.length,I=!1;for(let c=0;c<A.length;c++){let a=A[c],k=Object.create(x),w=E(e,a,r,s,i,V===!0?d:null,o,`${b}/${c}`,k);if(f.push(...w.errors),I=I||w.valid,w.valid)be.push(k)}if(I)f.length=m;else f.splice(m,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:b,error:"Instance does not match any subschemas."})}if(l!==void 0){let b=`${u}/allOf`,m=f.length,I=!0;for(let c=0;c<l.length;c++){let a=l[c],k=Object.create(x),w=E(e,a,r,s,i,V===!0?d:null,o,`${b}/${c}`,k);if(f.push(...w.errors),I=I&&w.valid,w.valid)be.push(k)}if(I)f.length=m;else f.splice(m,0,{instanceLocation:o,keyword:"allOf",keywordLocation:b,error:"Instance does not match every subschema."})}if(g!==void 0){let b=`${u}/oneOf`,m=f.length,I=g.filter((c,a)=>{let k=Object.create(x),w=E(e,c,r,s,i,V===!0?d:null,o,`${b}/${a}`,k);if(f.push(...w.errors),w.valid)be.push(k);return w.valid}).length;if(I===1)f.length=m;else f.splice(m,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:b,error:`Instance does not match exactly one subschema (${I} matches).`})}if(v==="object"||v==="array")Object.assign(x,...be);if(R!==void 0){let b=`${u}/if`;if(E(e,R,r,s,i,d,o,b,x).valid){if(T!==void 0){let I=E(e,T,r,s,i,d,o,`${u}/then`,x);if(!I.valid)f.push({instanceLocation:o,keyword:"if",keywordLocation:b,error:'Instance does not match "then" schema.'},...I.errors)}}else if(y!==void 0){let I=E(e,y,r,s,i,d,o,`${u}/else`,x);if(!I.valid)f.push({instanceLocation:o,keyword:"if",keywordLocation:b,error:'Instance does not match "else" schema.'},...I.errors)}}if(v==="object"){if(Q!==void 0){for(let c of Q)if(!(c in e))f.push({instanceLocation:o,keyword:"required",keywordLocation:`${u}/required`,error:`Instance does not have required property "${c}".`})}let b=Object.keys(e);if(N!==void 0&&b.length<N)f.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${u}/minProperties`,error:`Instance does not have at least ${N} properties.`});if(P!==void 0&&b.length>P)f.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${u}/maxProperties`,error:`Instance does not have at least ${P} properties.`});if(K!==void 0){let c=`${u}/propertyNames`;for(let a in e){let k=`${o}/${U(a)}`,w=E(a,K,r,s,i,d,k,c);if(!w.valid)f.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:c,error:`Property name "${a}" does not match schema.`},...w.errors)}}if(z!==void 0){let c=`${u}/dependantRequired`;for(let a in z)if(a in e){let k=z[a];for(let w of k)if(!(w in e))f.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:c,error:`Instance has "${a}" but does not have "${w}".`})}}if(j!==void 0)for(let c in j){let a=`${u}/dependentSchemas`;if(c in e){let k=E(e,j[c],r,s,i,d,o,`${a}/${U(c)}`,x);if(!k.valid)f.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:a,error:`Instance has "${c}" but does not match dependant schema.`},...k.errors)}}if(H!==void 0){let c=`${u}/dependencies`;for(let a in H)if(a in e){let k=H[a];if(Array.isArray(k)){for(let w of k)if(!(w in e))f.push({instanceLocation:o,keyword:"dependencies",keywordLocation:c,error:`Instance has "${a}" but does not have "${w}".`})}else{let w=E(e,k,r,s,i,d,o,`${c}/${U(a)}`);if(!w.valid)f.push({instanceLocation:o,keyword:"dependencies",keywordLocation:c,error:`Instance has "${a}" but does not match dependant schema.`},...w.errors)}}}let m=Object.create(null),I=!1;if(h!==void 0){let c=`${u}/properties`;for(let a in h){if(!(a in e))continue;let k=`${o}/${U(a)}`,w=E(e[a],h[a],r,s,i,d,k,`${c}/${U(a)}`);if(w.valid)x[a]=m[a]=!0;else if(I=i,f.push({instanceLocation:o,keyword:"properties",keywordLocation:c,error:`Property "${a}" does not match schema.`},...w.errors),I)break}}if(!I&&p!==void 0){let c=`${u}/patternProperties`;for(let a in p){let k=new RegExp(a,"u"),w=p[a];for(let J in e){if(!k.test(J))continue;let Pe=`${o}/${U(J)}`,Ce=E(e[J],w,r,s,i,d,Pe,`${c}/${U(a)}`);if(Ce.valid)x[J]=m[J]=!0;else I=i,f.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:c,error:`Property "${J}" matches pattern "${a}" but does not match associated schema.`},...Ce.errors)}}}if(!I&&S!==void 0){let c=`${u}/additionalProperties`;for(let a in e){if(m[a])continue;let k=`${o}/${U(a)}`,w=E(e[a],S,r,s,i,d,k,c);if(w.valid)x[a]=!0;else I=i,f.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:c,error:`Property "${a}" does not match additional properties schema.`},...w.errors)}}else if(!I&&_!==void 0){let c=`${u}/unevaluatedProperties`;for(let a in e)if(!x[a]){let k=`${o}/${U(a)}`,w=E(e[a],_,r,s,i,d,k,c);if(w.valid)x[a]=!0;else f.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:c,error:`Property "${a}" does not match unevaluated properties schema.`},...w.errors)}}}else if(v==="array"){if(Ie!==void 0&&e.length>Ie)f.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${u}/maxItems`,error:`Array has too many items (${e.length} > ${Ie}).`});if(Re!==void 0&&e.length<Re)f.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${u}/minItems`,error:`Array has too few items (${e.length} < ${Re}).`});let b=e.length,m=0,I=!1;if(fe!==void 0){let c=`${u}/prefixItems`,a=Math.min(fe.length,b);for(;m<a;m++){let k=E(e[m],fe[m],r,s,i,d,`${o}/${m}`,`${c}/${m}`);if(x[m]=!0,!k.valid){if(I=i,f.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:c,error:"Items did not match schema."},...k.errors),I)break}}}if(re!==void 0){let c=`${u}/items`;if(Array.isArray(re)){let a=Math.min(re.length,b);for(;m<a;m++){let k=E(e[m],re[m],r,s,i,d,`${o}/${m}`,`${c}/${m}`);if(x[m]=!0,!k.valid){if(I=i,f.push({instanceLocation:o,keyword:"items",keywordLocation:c,error:"Items did not match schema."},...k.errors),I)break}}}else for(;m<b;m++){let a=E(e[m],re,r,s,i,d,`${o}/${m}`,c);if(x[m]=!0,!a.valid){if(I=i,f.push({instanceLocation:o,keyword:"items",keywordLocation:c,error:"Items did not match schema."},...a.errors),I)break}}if(!I&&Me!==void 0){let a=`${u}/additionalItems`;for(;m<b;m++){let k=E(e[m],Me,r,s,i,d,`${o}/${m}`,a);if(x[m]=!0,!k.valid)I=i,f.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:a,error:"Items did not match additional items schema."},...k.errors)}}}if(Oe!==void 0)if(b===0&&X===void 0)f.push({instanceLocation:o,keyword:"contains",keywordLocation:`${u}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(X!==void 0&&b<X)f.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${u}/minContains`,error:`Array has less items (${b}) than minContains (${X}).`});else{let c=`${u}/contains`,a=f.length,k=0;for(let w=0;w<b;w++){let J=E(e[w],Oe,r,s,i,d,`${o}/${w}`,c);if(J.valid)x[w]=!0,k++;else f.push(...J.errors)}if(k>=(X||0))f.length=a;if(X===void 0&&me===void 0&&k===0)f.splice(a,0,{instanceLocation:o,keyword:"contains",keywordLocation:c,error:"Array does not contain item matching schema."});else if(X!==void 0&&k<X)f.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${u}/minContains`,error:`Array must contain at least ${X} items matching schema. Only ${k} items were found.`});else if(me!==void 0&&k>me)f.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${u}/maxContains`,error:`Array may contain at most ${me} items matching schema. ${k} items were found.`})}if(!I&&Ee!==void 0){let c=`${u}/unevaluatedItems`;for(m;m<b;m++){if(x[m])continue;let a=E(e[m],Ee,r,s,i,d,`${o}/${m}`,c);if(x[m]=!0,!a.valid)f.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:c,error:"Items did not match unevaluated items schema."},...a.errors)}}if(it)for(let c=0;c<b;c++){let a=e[c],k=typeof a==="object"&&a!==null;for(let w=0;w<b;w++){if(c===w)continue;let J=e[w];if(a===J||k&&(typeof J==="object"&&J!==null)&&ae(a,J))f.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${u}/uniqueItems`,error:`Duplicate items at indexes ${c} and ${w}.`}),c=Number.MAX_SAFE_INTEGER,w=Number.MAX_SAFE_INTEGER}}}else if(v==="number"){if(r==="4"){if(ne!==void 0&&(ce===!0&&e<=ne||e<ne))f.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${u}/minimum`,error:`${e} is less than ${ce?"or equal to ":""} ${ne}.`});if(oe!==void 0&&(pe===!0&&e>=oe||e>oe))f.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${u}/maximum`,error:`${e} is greater than ${pe?"or equal to ":""} ${oe}.`})}else{if(ne!==void 0&&e<ne)f.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${u}/minimum`,error:`${e} is less than ${ne}.`});if(oe!==void 0&&e>oe)f.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${u}/maximum`,error:`${e} is greater than ${oe}.`});if(ce!==void 0&&e<=ce)f.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${u}/exclusiveMinimum`,error:`${e} is less than ${ce}.`});if(pe!==void 0&&e>=pe)f.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${u}/exclusiveMaximum`,error:`${e} is greater than or equal to ${pe}.`})}if(ye!==void 0){let b=e%ye;if(Math.abs(0-b)>=0.00000011920929&&Math.abs(ye-b)>=0.00000011920929)f.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${u}/multipleOf`,error:`${e} is not a multiple of ${ye}.`})}}else if(v==="string"){let b=ge===void 0&&he===void 0?0:ze(e);if(ge!==void 0&&b<ge)f.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${u}/minLength`,error:`String is too short (${b} < ${ge}).`});if(he!==void 0&&b>he)f.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${u}/maxLength`,error:`String is too long (${b} > ${he}).`});if(Ae!==void 0&&!new RegExp(Ae,"u").test(e))f.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${u}/pattern`,error:"String does not match pattern."});if(n!==void 0&&Te[n]&&!Te[n](e))f.push({instanceLocation:o,keyword:"format",keywordLocation:`${u}/format`,error:`String does not match format "${n}".`})}return{valid:f.length===0,errors:f}}var Je="ch.ractive.tab-mcp/annotations",zt=["readOnlyHint","untrustedContentHint","consequentialHint","debugging"],Ht=["destructiveHint","idempotentHint","openWorldHint"];function Ue(e){let t={};if(e.readOnlyHint===!0)t.readOnlyHint=!0,t.destructiveHint=!1;else if(e.readOnlyHint===!1)t.readOnlyHint=!1;if(e.consequentialHint===!0)t.destructiveHint=!0;if(e.untrustedContentHint===!0)t.openWorldHint=!0;for(let i of Ht){let d=e[i];if(d!==void 0)t[i]=d}let r={};for(let i of zt){let d=e[i];if(d!==void 0)r[i]=d}let s={};if(Object.keys(t).length>0)s.annotations=t;if(Object.keys(r).length>0)s.meta=r;return s}function Z(e){return{content:[{type:"text",text:e}],isError:!0}}function He(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Be(e){if(typeof e==="string")return{content:[{type:"text",text:e}]};if(e===void 0)return{content:[]};if(He(e)&&Array.isArray(e.content))return e;let t;try{t=JSON.stringify(e)}catch{}if(t===void 0)return Z("The tool returned a value that is not JSON.");let r={content:[{type:"text",text:t}]};if(He(e))r.structuredContent=e;return r}function De(e){let t=e instanceof Error?e.message:String(e);return Z(t||"The tool failed.")}var se="2026-07-28",te="io.modelcontextprotocol/protocolVersion",we="io.modelcontextprotocol/clientCapabilities",Ve="io.modelcontextprotocol/clientInfo",Ge="io.modelcontextprotocol/serverInfo",_e="io.modelcontextprotocol/subscriptionId",Jt=-32020,We=-32022,Ut=0,Ke=new WeakMap;function ve(e){let t=Ke.get(e);if(t!==void 0)return t;let r=e.inputSchema,s;try{s=ee(r)}catch(d){let o=d instanceof Error?d.message:String(d);throw Error(o.split(`
|
|
5
|
-
`)[0])}for(let d of Object.values(s)){if(typeof d!=="object"||d.$ref===void 0)continue;let o=d.__absolute_ref__;if(s[o??d.$ref]===void 0)throw Error(`$ref ${JSON.stringify(d.$ref)} does not resolve`)}let i=(d)=>E(d,r,"2020-12",s,!1);return Ke.set(e,i),i}function Ye(e,t,r=""){let s=t instanceof Error?t.message:String(t);return TypeError(`registerTool: the inputSchema of ${e}: ${s}${r}`)}function Bt(e){let t=[];for(let r of e.list())try{ve(r)}catch(s){e.remove(r),t.push(Ye(r.name,s,"; the tool was unregistered"))}return e.setCompiler((r)=>{try{ve(r)}catch(s){throw Ye(r.name,s)}}),t}function Fe(e){try{return structuredClone(e)}catch{return e}}var Dt=new TextEncoder;function ie(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Se(e,t){return new Response(JSON.stringify(t),{status:e,headers:{"content-type":"application/json"}})}function q(e,t,r,s,i){let d={code:r,message:s};if(i!==void 0)d.data=i;return Se(e,{jsonrpc:"2.0",id:t,error:d})}function F(e,t,r){return q(400,e,Jt,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}})}function ue(e){return Dt.encode(`event: message
|
|
6
|
-
data: ${JSON.stringify(e)}
|
|
7
|
-
|
|
8
|
-
`)}var Xe={"content-type":"text/event-stream","cache-control":"no-cache"};function Vt(e){return(e??"").split(";")[0]?.trim().toLowerCase()==="application/json"}function Gt(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,-2);if(!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return;try{let r=atob(t),s=Uint8Array.from(r,(i)=>i.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{return}}function Wt(e){if(!(te in e))return{key:te,problem:"missing"};if(!(we in e))return{key:we,problem:"missing"};if(typeof e[te]!=="string")return{key:te,problem:"expected a protocol version string"};if(!ie(e[we]))return{key:we,problem:"expected an object"};let t=e[Ve];if(t!==void 0&&!(ie(t)&&typeof t.name==="string"&&typeof t.version==="string"))return{key:Ve,problem:"expected {name, version}"};return}function Kt(e){let t=e.notifications;return ie(t)&&t.toolsListChanged===!0?{toolsListChanged:!0}:{}}function Ze(e){let{tools:t,server:r}=e,s={name:r.name,version:r.version};if(r.title!==void 0)s.title=r.title;let i=xe(r.icons??[]),d=i.length>0?{...s,icons:i}:s,o=new Set,u=!1,x=(l={})=>({...l,[Ge]:s});function O(l,g,R=x()){return{jsonrpc:"2.0",id:l,result:{...g,resultType:"complete",_meta:R}}}function v(l,g){let R;try{R=ve(l)(g)}catch(y){let n=y instanceof Error?y.message:String(y);return`The input schema of tool ${l.name} cannot be used: ${n}`}if(R.valid)return;let T=R.errors.filter((y)=>y.keyword!=="properties"&&y.keyword!=="$ref").map((y)=>`${y.instanceLocation} ${y.error}`).slice(0,5).join("; ");return`Input validation error: Invalid arguments for tool ${l.name}: ${T||"the arguments do not match the schema"}`}function B(){return t.list().map((l)=>{let g={name:l.name};if(l.title!==void 0)g.title=l.title;g.description=l.description,g.inputSchema=l.inputSchema;let{annotations:R,meta:T}=Ue(l.annotations);if(R!==void 0)g.annotations=R;if(T!==void 0)g._meta={[Je]:T};return g})}let D=(l)=>({kind:"invalid",message:l});async function V(l,g,R){let T=l.name;if(typeof T!=="string")return D("Invalid params: name must be a string");let y=t.get(T);if(y===void 0)return D(`Tool ${T} not found`);let n=l.arguments??{};if(!ie(n))return D("Invalid params: arguments must be an object");let h=e.client(R),p={id:++Ut,tool:y.name,arguments:Fe(n),client:{...h}};if(y.title!==void 0)p.title=y.title;let S=Date.now();e.observe?.start(p);let _="error",N=Z("Internal error");try{[_,N]=await C(y,n,g,h)}finally{e.observe?.end({id:p.id,tool:y.name,client:{...h},outcome:_,result:Fe(N),durationMs:Date.now()-S})}return{kind:"result",result:N}}async function C(l,g,R,T){let y=v(l,g);if(y!==void 0)return["error",Z(y)];if(l.annotations.consequentialHint===!0){let h={tool:{name:l.name,description:l.description},arguments:g,client:T,signal:R};if(l.title!==void 0)h.tool.title=l.title;let p=!1;try{p=await e.confirm(h)}catch{p=!1}if(!p)return[R.aborted?"cancelled":"declined",Z("The user declined")]}if(R.aborted)return["cancelled",Z("Cancelled")];if(t.get(l.name)!==l)return["error",Z("The tool is no longer available")];let n;try{n=Be(await l.execute(g,{signal:R,client:T}))}catch(h){n=De(h)}if(R.aborted)return["cancelled",n];return[n.isError===!0?"error":"ok",n]}function G(l,g,R,T){let y=new ReadableStream({start:(n)=>{let h=(p)=>{if(R.aborted)return;let S;try{S=ue(p)}catch{S=ue(O(l,Z("The tool returned a result that is not JSON.")))}try{n.enqueue(S),n.close()}catch{}};V(g,R,T).then((p)=>h(p.kind==="invalid"?{jsonrpc:"2.0",id:l,error:{code:-32602,message:p.message}}:O(l,p.result)),()=>h({jsonrpc:"2.0",id:l,error:{code:-32603,message:"Internal error"}}))}});return new Response(y,{status:200,headers:Xe})}function W(l,g,R){let T=Kt(g),y={jsonrpc:"2.0",id:l,result:{resultType:"complete",_meta:x({[_e]:l})}},n,h=new ReadableStream({start:(p)=>{if(p.enqueue(ue({jsonrpc:"2.0",method:"notifications/subscriptions/acknowledged",params:{notifications:T,_meta:{[_e]:l}}})),Object.keys(T).length===0){p.enqueue(ue(y)),p.close();return}let S={id:l,send:(_)=>{try{p.enqueue(ue(_))}catch{o.delete(S)}},end:()=>{o.delete(S);try{p.enqueue(ue(y)),p.close()}catch{}}};n=S,o.add(S),R.addEventListener("abort",()=>{o.delete(S);try{p.close()}catch{}})},cancel:()=>{if(n!==void 0)o.delete(n)}});return new Response(h,{status:200,headers:Xe})}function Q(l,g){if(Array.isArray(g))return q(400,null,-32600,"Bad Request: JSON-RPC batches are not supported by this endpoint");if(!ie(g)||g.jsonrpc!=="2.0")return q(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let{method:R,id:T}=g;if(typeof R!=="string")return"result"in g||"error"in g?q(400,null,-32600,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"):q(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let y=l.headers.get("mcp-protocol-version"),n=l.headers.get("mcp-method"),h=ie(g.params)?g.params:{},p=ie(h._meta)?h._meta:void 0,S=p!==void 0&&te in p,_=typeof p?.[te]==="string"?p[te]:void 0,N=y!==null&&y>=se;if(T===void 0){if(_!==void 0&&y!==null&&y!==_)return F(null,y,`the notification envelope names protocol version ${_} but the MCP-Protocol-Version header names ${y}`);if((S||N)&&n!==null&&n!==R)return F(null,n,`the notification body names method ${R} but the Mcp-Method header names ${n}`);return"notification"}if(typeof T!=="string"&&typeof T!=="number")return q(400,null,-32600,"Bad Request: the request body is not a valid JSON-RPC message");let P=T;if(!S||R==="initialize"&&(_===void 0||_<se)){if(R==="initialize"){if(N)return F(P,y,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let z=typeof h.protocolVersion==="string"?h.protocolVersion:void 0;return L(P,z)}if(N){let z=p===void 0?["_meta"]:[te];return q(400,P,-32602,`Invalid params: the MCP-Protocol-Version header names protocol revision ${y}, but the request is missing the required per-request envelope key(s): ${z.join(", ")}`,{envelope:{missing:z}})}return L(P,y??void 0)}let K=Wt(p);if(K!==void 0)return q(400,P,-32602,`Invalid _meta envelope for protocol revision ${se}: ${K.key}: ${K.problem}`,{envelope:K});if(y!==null&&_!==void 0&&y!==_)return F(P,y,`the body envelope names protocol version ${_} but the MCP-Protocol-Version header names ${y}`);if(n!==null&&n!==R)return F(P,n,`the body names method ${R} but the Mcp-Method header names ${n}`);if(_!==se)return L(P,_);if(y===null)return F(P,"(missing)",`the body envelope names protocol version ${_} but the required MCP-Protocol-Version header is absent`);if(n===null)return F(P,"(missing)",`the body names method ${R} but the required Mcp-Method header is absent`);if(R==="tools/call"&&typeof h.name==="string"){let z=h.name,j=l.headers.get("mcp-name");if(j===null)return F(P,"(missing)",`the body carries params.name="${z}" but the required Mcp-Name header is absent`);let H=Gt(j);if(H===void 0)return F(P,j,"the Mcp-Name header carries an invalid Base64 sentinel value");if(H!==z)return F(P,j,`the body carries params.name="${z}" but the Mcp-Name header names "${H}"`)}return{id:P,method:R,params:h}}function L(l,g){return g===void 0?q(400,l,We,"Unsupported protocol version: the request did not name a protocol version",{supported:[se]}):q(400,l,We,`Unsupported protocol version: ${g}`,{supported:[se],requested:g})}async function A(l,g){if(l.method.toUpperCase()!=="POST")return q(405,null,-32000,"Method not allowed.");if(!Vt(l.headers.get("content-type")))return q(415,null,-32000,"Unsupported Media Type: Content-Type must be application/json");let R;try{R=JSON.parse(g.body??await l.text())}catch{return q(400,null,-32700,"Parse error: the request body is not valid JSON")}let T=Q(l,R);if(T instanceof Response)return T;if(T==="notification")return new Response(null,{status:202});let{id:y,method:n,params:h}=T;switch(n){case"server/discover":{let p={supportedVersions:[se],capabilities:{tools:{listChanged:!0}}};if(r.instructions!==void 0)p.instructions=r.instructions;return p.ttlMs=0,p.cacheScope="private",Se(200,O(y,p,{[Ge]:d}))}case"tools/list":return Se(200,O(y,{tools:B(),ttlMs:0,cacheScope:"private"}));case"tools/call":return G(y,h,l.signal,g.grant);case"subscriptions/listen":return W(y,h,l.signal);default:return q(404,y,-32601,"Method not found")}}return{handle:(l,g)=>A(l,g).catch(()=>q(500,null,-32603,"Internal server error")),toolsChanged(){if(u)return;u=!0,queueMicrotask(()=>{u=!1;for(let l of[...o])l.send({jsonrpc:"2.0",method:"notifications/tools/list_changed",params:{_meta:{[_e]:l.id}}})})},close(){for(let l of[...o])l.end()}}}var ke="tab-mcp.v1";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var M=(e)=>typeof e==="string";function Qe(e){if(!le(e)||!M(e.grantId)||!M(e.createdAt))return!1;let t=e.client;return le(t)&&M(t.id)&&M(t.name)&&M(t.host)}function Yt(e){if(!le(e))return!1;return["maxMessageBytes","maxBodyBytes","requestTimeoutMs","idleTimeoutMs","heartbeatMs","keepAliveMs","maxConcurrentRequests"].every((t)=>typeof e[t]==="number")}function Ft(e){return le(e)&&Object.values(e).every(M)}function Le(e){let t;try{t=JSON.parse(e)}catch{return}if(!le(t))return;switch(t.type){case"session":return M(t.sessionId)&&M(t.address)&&M(t.origin)&&M(t.expiresAt)&&Yt(t.limits)&&Array.isArray(t.grants)&&t.grants.every(Qe)&&(t.appName===void 0||M(t.appName))&&(t.pairing===void 0||M(t.pairing))?t:void 0;case"ping":return typeof t.t==="number"?t:void 0;case"bye":return{type:"bye",reason:M(t.reason)?t.reason:""};case"http.request":return M(t.id)&&M(t.method)&&M(t.path)&&Ft(t.headers)&&M(t.body)&&le(t.grant)&&M(t.grant.grantId)&&M(t.grant.clientId)?t:void 0;case"http.cancel":return M(t.id)?t:void 0;case"pairing.code":return M(t.code)&&M(t.expiresAt)?t:void 0;case"grant.added":return Qe(t.grant)?t:void 0;case"grant.removed":return M(t.grantId)?{type:"grant.removed",grantId:t.grantId,reason:M(t.reason)?t.reason:""}:void 0;case"identity.bound":return typeof t.round==="number"?{type:"identity.bound",round:t.round}:{type:"identity.bound"};case"error":return M(t.code)?t:void 0;default:return}}function Xt(e){let t="",r=0,s=0;for(let i of e){r=r<<8|i,s+=8;while(s>=5)s-=5,t+="abcdefghijklmnopqrstuvwxyz234567"[r>>>s&31];r&=(1<<s)-1}if(s>0)t+="abcdefghijklmnopqrstuvwxyz234567"[r<<5-s&31];return t}async function Zt(e,t=globalThis.crypto?.subtle??null){if(t===null)return;try{let r=await t.digest("SHA-256",new TextEncoder().encode(e));return Xt(new Uint8Array(r))}catch{return}}function Qt(e,t){if(t===void 0)return e;let r=new URL(e);return r.searchParams.set("a",t),r.href}var Lt=15000,et={1000:"closed",1008:"policy",1009:"too_large",4001:"expired",4002:"idle",4003:"heartbeat",4004:"shutdown",4005:"replaced",4008:"rate_limited",4009:"policy"},tt={replaced:"replaced",expired:"expired",idle:"idle",shutdown:"shutdown"};function de(e,t){return Object.assign(Error(e),{reason:t})}var er=["content-type","cache-control"];function tr(){let e=globalThis.document?.title;return typeof e==="string"?e.slice(0,300):""}function rr(e){try{let t=JSON.parse(e);if(typeof t!=="object"||t===null||typeof t.type!=="string")return;return typeof t.id==="string"?{type:t.type,id:t.id}:{type:t.type}}catch{return}}var nr=new Set(["session","ping","bye","http.request","http.cancel","pairing.code","grant.added","grant.removed","identity.bound","error"]),nt=512,ot=6,st=64,or=nt+ot*st;function sr(e){let t=Math.floor((e-nt)/ot);return t>=st?t:void 0}function*rt(e,t){let r=0;while(r<e.length){let s=Math.min(r+t,e.length),i=e.charCodeAt(s-1);if(s<e.length&&i>=55296&&i<=56319)s+=s-1>r?-1:1;yield e.slice(r,s),r=s}}var ir=1e4,dr=1000;function ar(e){let t,r=Number.NEGATIVE_INFINITY,s;try{if(e!==void 0&&typeof BroadcastChannel==="function")t=new BroadcastChannel(e),t.onmessage=(i)=>{if(i.data?.type!=="claimed")return;r=Date.now(),s?.()}}catch{t=void 0}return{claimed(){try{t?.postMessage({type:"claimed"})}catch{}},heard(){if(Date.now()-r<=ir)return Promise.resolve(!0);if(t===void 0)return Promise.resolve(!1);return new Promise((i)=>{let d=setTimeout(()=>i(!1),dr);s=()=>{clearTimeout(d),i(!0)}})},close(){t?.close()}}}function Ar(e,t,r,s=!1){let i=new WebSocket(t,ke),d=new Map,o="opening",u,x=65536,O,v=0,B=ar(e.tabs),D,V,C,G=new Promise((n,h)=>{V=n,C=h});G.catch(()=>{});let W=setTimeout(()=>{g(de("The relay did not answer in time.","network"))},Lt),Q=Ze({tools:e.registry,server:{...e.server,icons:e.server.icons??Ne()},confirm:(n)=>e.confirm(n),client:(n)=>e.clientFor(n),observe:{start:(n)=>e.toolCallStarted(n),end:(n)=>e.toolCallEnded(n)}}),L=e.registry.onChange(()=>Q.toolsChanged());function A(n){if(i.readyState!==WebSocket.OPEN)return!1;try{return i.send(JSON.stringify(n)),!0}catch{return!1}}function l(){if(v<=0)return;clearTimeout(O),O=setTimeout(()=>{u??="heartbeat",R(4003);try{i.close()}catch{}},v*2.5)}function g(n){if(o!=="opening")return;R(0),C(n);try{i.close()}catch{}}function R(n){if(o==="closed")return;let h=o==="ready";o="closed",clearTimeout(W),clearTimeout(O),L();for(let p of d.values())p.abort();if(d.clear(),Q.close(),h){let p=u??et[n]??(n===1006?"network":"closed");if(C(de("The address was taken over again before its AI apps were disconnected.",p)),e.closed(p,n),p==="replaced"){B.heard().then((S)=>{B.close(),e.replaced({sibling:S})});return}}B.close()}async function T(n){let h=new AbortController;d.set(n.id,h);let p=()=>o==="ready"&&d.get(n.id)===h&&!h.signal.aborted;try{let S=new Request(`https://tab.invalid${n.path}`,{method:n.method,headers:n.headers,signal:h.signal}),_=await Q.handle(S,{grant:n.grant,body:n.body});if(!p()){await _.body?.cancel().catch(()=>{});return}let N={};for(let j of er){let H=_.headers.get(j);if(H!==null)N[j]=H}if(!(N["content-type"]??"").startsWith("text/event-stream")||_.body===null){let j=await _.text();if(!p())return;if(j.length<=x){A({type:"http.response",id:n.id,status:_.status,headers:N,body:j});return}A({type:"http.response.start",id:n.id,status:_.status,headers:N});for(let H of rt(j,x)){if(!p())break;A({type:"http.response.chunk",id:n.id,data:H})}if(p())A({type:"http.response.end",id:n.id});return}A({type:"http.response.start",id:n.id,status:_.status,headers:N});let K=_.body.getReader(),z=new TextDecoder;h.signal.addEventListener("abort",()=>{K.cancel().catch(()=>{})});for(;;){let{done:j,value:H}=await K.read();if(j||!p())break;let fe=z.decode(H,{stream:!0});for(let re of rt(fe,x))A({type:"http.response.chunk",id:n.id,data:re})}if(p())A({type:"http.response.end",id:n.id})}catch(S){if(p())e.error(S instanceof Error?S:Error(String(S))),A({type:"http.response",id:n.id,status:500,headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32603,message:"Internal server error"}})})}finally{if(d.get(n.id)===h)d.delete(n.id)}}function y(n){if(o==="opening"){if(n.type==="session"){let h=sr(n.limits.maxMessageBytes);if(h===void 0){g(de(`The relay's message limit (${n.limits.maxMessageBytes} bytes) is too small; tab-mcp needs at least ${or}.`,"policy"));return}x=h,o="ready",clearTimeout(W),v=n.limits.heartbeatMs,l(),B.claimed();let p=e.sessionStarted(n);if(s&&n.grants.length>0){D={left:new Set(n.grants.map((S)=>S.grantId)),session:p},A({type:"grants.revokeAll"});return}V(p)}else if(n.type==="error")g(de(`The relay refused the connection: ${n.message||n.code}`,n.code==="rate_limited"?"rate_limited":"policy"));else if(n.type==="bye")g(de(`The relay ended the connection: ${n.reason}`,tt[n.reason]??"closed"));return}if(o!=="ready")return;switch(n.type){case"ping":l(),A({type:"pong",t:n.t});return;case"http.request":T(n);return;case"http.cancel":d.get(n.id)?.abort(),d.delete(n.id);return;case"pairing.code":e.pairingCode({code:n.code,expiresAt:n.expiresAt});return;case"grant.added":e.grantAdded(n.grant);return;case"grant.removed":if(e.grantRemoved(n.grantId),D?.left.delete(n.grantId),D?.left.size===0)V(D.session);return;case"identity.bound":e.identityResult(!0,n.round);return;case"bye":if(u=tt[n.reason]??"closed",u==="replaced")R(4005);return;case"error":if(n.code==="identity_refused"){e.identityResult(!1,typeof n.round==="number"?n.round:void 0,n.message);return}e.error(Error(`Relay error ${n.code}: ${n.message}`));return;case"session":return}}return i.addEventListener("open",()=>{if(i.protocol!==""&&i.protocol!==ke){g(de(`The relay speaks ${i.protocol}, not ${ke}.`,"policy"));return}let n={type:"hello",library:e.library,page:{title:tr()},secret:r};if(e.appName!==void 0)n.app={name:e.appName};if(s)n.revokeAll=!0;A(n)}),i.addEventListener("message",(n)=>{if(typeof n.data!=="string")return;let h=Le(n.data);if(h!==void 0){if(o==="ready")l();y(h);return}let p=rr(n.data);if(p?.id!==void 0)A(nr.has(p.type)?{type:"error",code:"bad_message",message:`malformed ${p.type}`,id:p.id}:{type:"error",code:"unknown_type",message:`unknown type ${p.type}`,id:p.id})}),i.addEventListener("close",(n)=>{if(o==="opening"){R(n.code);let h=n.code===1006||n.code===1002;C(de(h?"Could not connect to the relay (refused, unreachable, or this page's origin is not allowed).":`The relay closed the connection (${n.code}${n.reason?`: ${n.reason}`:""}).`,et[n.code]??(h?"network":"closed")));return}R(n.code)}),{ready:G,send:A,close(n){if(o==="closed")return;if(o==="opening"){g(new DOMException("The connection was cancelled","AbortError"));return}u=n,A({type:"bye",reason:"user"}),R(1000);try{i.close(1000,"bye")}catch{}}}}export{Zt as addressIdOf,Bt as compileRegistry,Ar as openConnection,Qt as withAddress};
|
|
9
|
-
|
|
10
|
-
//# debugId=0B1EE263FE9616FD64756E2164756E21
|
|
11
|
-
//# sourceMappingURL=connection-0x5mr3te.min.js.map
|