@ractive-ch/tab-mcp-client 0.9.1 → 0.10.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.
@@ -4,10 +4,10 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * The tool registry, mirroring WebMCP's `registerTool(tool, { signal })`\n * (DEC-010). Part of the eagerly loaded core.\n */\n\nimport type {\n\tJsonSchema,\n\tRegisterToolOptions,\n\tTool,\n\tToolAnnotations,\n} from \"./types.ts\";\n\nconst NAME = /^[A-Za-z0-9_.-]{1,128}$/;\n\n/** A validated tool as the registry keeps it. */\nexport interface RegisteredTool {\n\treadonly name: string;\n\treadonly title: string | undefined;\n\treadonly description: string;\n\treadonly inputSchema: JsonSchema;\n\treadonly annotations: ToolAnnotations;\n\treadonly execute: Tool[\"execute\"];\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** `x-mcp-header` makes the relay validate headers it does not know; not supported in v1. */\nfunction usesMcpHeader(schema: unknown, depth = 0): boolean {\n\tif (depth > 64 || typeof schema !== \"object\" || schema === null) return false;\n\tif (!Array.isArray(schema) && \"x-mcp-header\" in schema) return true;\n\treturn Object.values(schema).some((v) => usesMcpHeader(v, depth + 1));\n}\n\n/** A JSON pointer (`/a/b~1c`) inside `root`, or `undefined`. */\nfunction resolvePointer(root: unknown, pointer: string): unknown {\n\tlet node: unknown = root;\n\tfor (const raw of pointer.split(\"/\").slice(1)) {\n\t\tconst key = decodeURIComponent(raw)\n\t\t\t.replaceAll(\"~1\", \"/\")\n\t\t\t.replaceAll(\"~0\", \"~\");\n\t\tif (typeof node !== \"object\" || node === null || !Object.hasOwn(node, key))\n\t\t\treturn undefined;\n\t\tnode = (node as Record<string, unknown>)[key];\n\t}\n\treturn node;\n}\n\n/**\n * What the validator (loaded only on `connect()`) would throw on later, found\n * now so that a bad schema fails registration: patterns that are not\n * regular expressions, and `$ref`s that do not resolve inside the schema.\n * Without `$id`s; once the validator is loaded, it checks too (`setCompiler`).\n */\nfunction schemaProblem(root: unknown): string | undefined {\n\tconst anchors = new Set<string>();\n\tconst refs: string[] = [];\n\tconst patterns: string[] = [];\n\tconst walk = (node: unknown, depth: number): void => {\n\t\tif (depth > 64 || typeof node !== \"object\" || node === null) return;\n\t\tif (!Array.isArray(node)) {\n\t\t\tconst o = node as Record<string, unknown>;\n\t\t\tif (typeof o[\"$anchor\"] === \"string\") anchors.add(o[\"$anchor\"]);\n\t\t\tif (typeof o[\"$ref\"] === \"string\") refs.push(o[\"$ref\"]);\n\t\t\tif (typeof o[\"pattern\"] === \"string\") patterns.push(o[\"pattern\"]);\n\t\t\tconst pp = o[\"patternProperties\"];\n\t\t\tif (typeof pp === \"object\" && pp !== null)\n\t\t\t\tpatterns.push(...Object.keys(pp));\n\t\t}\n\t\tfor (const v of Object.values(node)) walk(v, depth + 1);\n\t};\n\twalk(root, 0);\n\tfor (const p of patterns) {\n\t\ttry {\n\t\t\tnew RegExp(p, \"u\");\n\t\t} catch {\n\t\t\treturn `pattern ${JSON.stringify(p)} is not a valid regular expression`;\n\t\t}\n\t}\n\tfor (const ref of refs) {\n\t\tif (!ref.startsWith(\"#\"))\n\t\t\treturn `$ref ${JSON.stringify(ref)} points outside the schema`;\n\t\tconst target = ref.slice(1);\n\t\tconst found =\n\t\t\ttarget === \"\" ||\n\t\t\t(target.startsWith(\"/\")\n\t\t\t\t? resolvePointer(root, target) !== undefined\n\t\t\t\t: anchors.has(target));\n\t\tif (!found) return `$ref ${JSON.stringify(ref)} does not resolve`;\n\t}\n\treturn undefined;\n}\n\n/** Validate a tool; throws a `TypeError` naming the problem. */\nexport function validateTool(tool: Tool): RegisteredTool {\n\tif (!isPlainObject(tool))\n\t\tthrow new TypeError(\"registerTool: the tool must be an object\");\n\tconst { name, title, description, inputSchema, execute, annotations } = tool;\n\tif (typeof name !== \"string\" || !NAME.test(name)) {\n\t\tthrow new TypeError(\n\t\t\t`registerTool: the name must be 1–128 characters of A–Z, a–z, 0–9, \"_\", \"-\" or \".\" (got ${JSON.stringify(name)})`,\n\t\t);\n\t}\n\tif (typeof description !== \"string\" || description.trim() === \"\") {\n\t\tthrow new TypeError(`registerTool: tool ${name} needs a description`);\n\t}\n\tif (title !== undefined && typeof title !== \"string\") {\n\t\tthrow new TypeError(`registerTool: the title of ${name} must be a string`);\n\t}\n\tif (typeof execute !== \"function\") {\n\t\tthrow new TypeError(`registerTool: tool ${name} needs an execute function`);\n\t}\n\tconst schema = inputSchema ?? { type: \"object\" };\n\tif (!isPlainObject(schema) || schema[\"type\"] !== \"object\") {\n\t\tthrow new TypeError(\n\t\t\t`registerTool: the inputSchema of ${name} must be a JSON Schema object with \"type\": \"object\"`,\n\t\t);\n\t}\n\tif (usesMcpHeader(schema)) {\n\t\tthrow new TypeError(\n\t\t\t`registerTool: ${name} uses x-mcp-header, which tab-mcp does not support`,\n\t\t);\n\t}\n\tconst problem = schemaProblem(schema);\n\tif (problem !== undefined) {\n\t\tthrow new TypeError(`registerTool: the inputSchema of ${name}: ${problem}`);\n\t}\n\tlet copied: JsonSchema;\n\ttry {\n\t\tcopied = JSON.parse(JSON.stringify(schema)) as JsonSchema;\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t`registerTool: the inputSchema of ${name} must be JSON`,\n\t\t);\n\t}\n\tif (annotations !== undefined && !isPlainObject(annotations)) {\n\t\tthrow new TypeError(\n\t\t\t`registerTool: the annotations of ${name} must be an object`,\n\t\t);\n\t}\n\tconst hints: ToolAnnotations = {};\n\tfor (const [key, value] of Object.entries(annotations ?? {})) {\n\t\tif (typeof value === \"boolean\")\n\t\t\t(hints as Record<string, boolean>)[key] = value;\n\t}\n\treturn {\n\t\tname,\n\t\ttitle,\n\t\tdescription,\n\t\tinputSchema: copied,\n\t\tannotations: hints,\n\t\texecute,\n\t};\n}\n\n/** The validator's check of a schema: throws a `TypeError` naming the problem. */\nexport type SchemaCompiler = (tool: RegisteredTool) => void;\n\nexport class ToolRegistry {\n\treadonly #tools = new Map<string, RegisteredTool>();\n\treadonly #listeners = new Set<() => void>();\n\t#compile: SchemaCompiler | undefined;\n\n\t/**\n\t * Register a tool; throws `TypeError` for an invalid tool and an\n\t * `InvalidStateError` `DOMException` for a duplicate name.\n\t */\n\tregister(tool: Tool, options: RegisterToolOptions = {}): void {\n\t\tconst registered = validateTool(tool);\n\t\tconst { signal } = options;\n\t\tif (signal?.aborted) return;\n\t\tif (this.#tools.has(registered.name)) {\n\t\t\tthrow new DOMException(\n\t\t\t\t`registerTool: a tool named ${registered.name} is already registered`,\n\t\t\t\t\"InvalidStateError\",\n\t\t\t);\n\t\t}\n\t\tthis.#compile?.(registered);\n\t\tthis.#tools.set(registered.name, registered);\n\t\tsignal?.addEventListener(\"abort\", () => this.remove(registered), {\n\t\t\tonce: true,\n\t\t});\n\t\tthis.#changed();\n\t}\n\n\t/**\n\t * The validator is loaded: from now on each schema is compiled when it is\n\t * registered, and a tool it refuses is refused (DEC-086).\n\t */\n\tsetCompiler(compile: SchemaCompiler): void {\n\t\tthis.#compile ??= compile;\n\t}\n\n\t/** Unregister this tool, if it still is. */\n\tremove(tool: RegisteredTool): void {\n\t\tif (this.#tools.get(tool.name) !== tool) return;\n\t\tthis.#tools.delete(tool.name);\n\t\tthis.#changed();\n\t}\n\n\tget(name: string): RegisteredTool | undefined {\n\t\treturn this.#tools.get(name);\n\t}\n\n\t/** Tools in registration order. */\n\tlist(): RegisteredTool[] {\n\t\treturn [...this.#tools.values()];\n\t}\n\n\t/** Listen for changes; returns a function that stops listening. */\n\tonChange(listener: () => void): () => void {\n\t\tthis.#listeners.add(listener);\n\t\treturn () => this.#listeners.delete(listener);\n\t}\n\n\t#changed(): void {\n\t\tfor (const listener of [...this.#listeners]) listener();\n\t}\n}\n",
6
6
  "/**\n * The address secret (DEC-027): 32 random bytes as base64url without padding,\n * kept in `localStorage`. The relay derives the stable address from it.\n */\n\nimport type { SecretStorage } from \"./types.ts\";\n\nconst SECRET = /^[A-Za-z0-9_-]{43}$/;\n/** base64url without padding. */\nexport function base64url(bytes: Uint8Array): string {\n\treturn btoa(String.fromCharCode(...bytes))\n\t\t.replaceAll(\"+\", \"-\")\n\t\t.replaceAll(\"/\", \"_\")\n\t\t.replace(/=+$/, \"\");\n}\n\nexport function newSecret(): string {\n\treturn base64url(crypto.getRandomValues(new Uint8Array(32)));\n}\n\nexport function isSecret(value: unknown): value is string {\n\treturn typeof value === \"string\" && SECRET.test(value);\n}\n\n/** `localStorage`, or `null` where it is missing or blocked. */\nfunction defaultStorage(): SecretStorage | null {\n\ttry {\n\t\tconst storage = (globalThis as { localStorage?: SecretStorage })\n\t\t\t.localStorage;\n\t\treturn storage ?? null;\n\t} catch {\n\t\treturn null; // SecurityError: storage blocked for this page\n\t}\n}\n\n/** Reads, creates and rotates the secret; falls back to memory without storage. */\nexport class SecretStore {\n\treadonly #storage: SecretStorage | null;\n\treadonly #key: string;\n\t/** A key the secret may still be under (the default of 0.4 and older). */\n\treadonly #oldKey: string | undefined;\n\t/** Set once a page of this origin took over the old key's secret. */\n\treadonly #claimKey: string | undefined;\n\t#memory: string | undefined;\n\n\tconstructor(\n\t\tstorage: SecretStorage | null | undefined,\n\t\tkey: string,\n\t\toldKey?: string,\n\t) {\n\t\tthis.#storage = storage === undefined ? defaultStorage() : storage;\n\t\tthis.#key = key;\n\t\tthis.#oldKey = oldKey;\n\t\tthis.#claimKey = oldKey === undefined ? undefined : `${oldKey}#moved`;\n\t}\n\n\t/** The current secret; storage first, so a rotation in another tab is seen. */\n\tget(): string {\n\t\tlet stored: string | null = null;\n\t\ttry {\n\t\t\tstored = this.#storage?.getItem(this.#key) ?? null;\n\t\t\t// The old shared key's secret is copied once (DEC-083): the first page\n\t\t\t// keeps the address and marks it taken, so the next page gets its own.\n\t\t\t// The old key stays, for pages still on 0.4 and for a rollback.\n\t\t\tif (\n\t\t\t\t!isSecret(stored) &&\n\t\t\t\tthis.#oldKey !== undefined &&\n\t\t\t\tthis.#claimKey !== undefined &&\n\t\t\t\tthis.#storage?.getItem(this.#claimKey) == null\n\t\t\t) {\n\t\t\t\tconst old = this.#storage?.getItem(this.#oldKey) ?? null;\n\t\t\t\tif (isSecret(old)) {\n\t\t\t\t\tstored = old; // kept for this page even if the writes below fail\n\t\t\t\t\tthis.#claim(old);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// unreadable: use a page-lifetime secret\n\t\t}\n\t\tif (isSecret(stored)) {\n\t\t\tthis.#memory = stored;\n\t\t\treturn stored;\n\t\t}\n\t\treturn this.#memory ?? this.rotate();\n\t}\n\n\t/** Make and keep a new secret (a new address). */\n\trotate(): string {\n\t\tconst secret = newSecret();\n\t\tthis.#memory = secret;\n\t\t// Also marks the old shared secret taken: an address abandoned with \"New\n\t\t// address\" is not picked up again by another page of the site.\n\t\tthis.#claim(secret);\n\t\treturn secret;\n\t}\n\n\t#claim(secret: string): void {\n\t\ttry {\n\t\t\tthis.#storage?.setItem(this.#key, secret);\n\t\t\tif (this.#claimKey !== undefined)\n\t\t\t\tthis.#storage?.setItem(this.#claimKey, this.#key);\n\t\t} catch {\n\t\t\t// quota or blocked: the secret lives as long as the page\n\t\t}\n\t}\n}\n",
7
- "/** The library's name and version, sent in `hello` (a test keeps it equal to package.json). */\nexport const LIBRARY_NAME = \"@ractive-ch/tab-mcp-client\";\nexport const VERSION = \"0.9.1\";\n",
8
- "/**\n * `TabMcp`: the eagerly loaded core (DEC-035). It holds the tool registry, the\n * events, the pairing state and the address secret; `connect()` loads the\n * connection and the MCP handler with a dynamic `import()`.\n */\n\nimport type { ConnectionHandle, ConnectionHost } from \"./internal.ts\";\nimport type { GrantRef, SessionMessage } from \"./protocol.ts\";\nimport { ToolRegistry } from \"./registry.ts\";\nimport { SecretStore } from \"./secret.ts\";\nimport type {\n\tConfirmHandler,\n\tConfirmRequest,\n\tConnectionState,\n\tConnectOptions,\n\tDisconnectReason,\n\tGrant,\n\tIdentityAssertionHandler,\n\tIdentityState,\n\tPairingCode,\n\tReconnectingInfo,\n\tRegisterToolOptions,\n\tServerInfo,\n\tSessionInfo,\n\tTabMcpEventMap,\n\tTabMcpOptions,\n\tTool,\n\tToolCallClient,\n} from \"./types.ts\";\nimport { LIBRARY_NAME, VERSION } from \"./version.ts\";\n\nconst LOOPBACK = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** The default waits before each reconnect attempt; the last one repeats. */\nconst RECONNECT_DELAYS_MS = [5_000, 10_000, 20_000, 40_000, 60_000];\n/** Reasons after which the library connects again by itself. */\nconst RECONNECT_REASONS = new Set<DisconnectReason>([\n\t\"network\",\n\t\"heartbeat\",\n\t\"shutdown\",\n]);\n\nfunction reconnectDelays(\n\toption: TabMcpOptions[\"reconnect\"],\n): readonly number[] | undefined {\n\tif (option === false) return undefined;\n\tif (option === undefined || option === true) return RECONNECT_DELAYS_MS;\n\tconst delays = option.delaysMs ?? RECONNECT_DELAYS_MS;\n\tif (\n\t\t!Array.isArray(delays) ||\n\t\tdelays.length === 0 ||\n\t\t!delays.every((d) => typeof d === \"number\" && d >= 0 && d < 2 ** 31)\n\t) {\n\t\tthrow new TypeError(\"TabMcp: reconnect.delaysMs: a non-empty list of ms\");\n\t}\n\treturn [...delays];\n}\n\n/** A delay option: `undefined`, or a whole wait `setTimeout` can keep (below 2^31 ms). */\nfunction delayOption(name: string, value: unknown): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isFinite(value) ||\n\t\tvalue < 0 ||\n\t\tvalue >= 2 ** 31\n\t) {\n\t\tthrow new TypeError(`TabMcp: ${name} must be a number of milliseconds`);\n\t}\n\treturn value;\n}\n\n/** A grant as the page sees it: frozen, so a page cannot change what decides Always allow. */\nfunction frozenGrant(grant: Grant): Grant {\n\treturn Object.freeze({\n\t\t...grant,\n\t\tclient: Object.freeze({ ...grant.client }),\n\t});\n}\n\n/** What the relay accepts as `hello.app.name` (protocol: session). */\nfunction isAppName(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\tvalue.trim().length > 0 &&\n\t\tvalue.length <= 64 &&\n\t\t![...value].some((ch) => {\n\t\t\tconst c = ch.codePointAt(0) ?? 0;\n\t\t\treturn c < 0x20 || (c >= 0x7f && c <= 0x9f);\n\t\t})\n\t);\n}\n\n/** `wss://host/tab` for a relay given as `https://host`, `wss://host` or with `/tab`. */\nexport function tabUrl(relay: string): { url: string; origin: string } {\n\tlet u: URL;\n\ttry {\n\t\tu = new URL(relay);\n\t} catch {\n\t\tthrow new TypeError(`TabMcp: relay is not a URL: ${relay}`);\n\t}\n\tconst secure = u.protocol === \"https:\" || u.protocol === \"wss:\";\n\tif (!secure && u.protocol !== \"http:\" && u.protocol !== \"ws:\") {\n\t\tthrow new TypeError(\n\t\t\t`TabMcp: relay must be an https: or wss: URL: ${relay}`,\n\t\t);\n\t}\n\t// The secret travels in hello: never in clear text beyond this machine.\n\tif (!secure && !LOOPBACK.has(u.hostname)) {\n\t\tthrow new TypeError(\n\t\t\t`TabMcp: relay must use https: or wss: (http: only for localhost): ${relay}`,\n\t\t);\n\t}\n\tconst origin = `${secure ? \"https:\" : \"http:\"}//${u.host}`;\n\tconst path = u.pathname.replace(/\\/+$/, \"\");\n\tu.protocol = secure ? \"wss:\" : \"ws:\";\n\tu.pathname = path.endsWith(\"/tab\") ? path : `${path}/tab`;\n\tu.search = \"\";\n\tu.hash = \"\";\n\treturn { url: u.href, origin };\n}\n\nfunction hostOf(url: string): string {\n\ttry {\n\t\treturn new URL(url).host;\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction sessionInfo(m: SessionMessage): SessionInfo {\n\tconst info: SessionInfo = {\n\t\tsessionId: m.sessionId,\n\t\taddress: m.address,\n\t\torigin: m.origin,\n\t\tpairing: m.pairing === \"oidc\" ? \"oidc\" : \"code\",\n\t\texpiresAt: m.expiresAt,\n\t\tlimits: m.limits,\n\t};\n\tif (m.appName !== undefined) info.appName = m.appName;\n\treturn info;\n}\n\ntype Listener<K extends keyof TabMcpEventMap> = (\n\tevent: TabMcpEventMap[K],\n) => void;\n\n/**\n * Offers a page's tools to AI apps through a tab-mcp relay.\n *\n * ```ts\n * const mcp = new TabMcp({ relay: \"https://relay.example\", server: { name: \"Calculator\", version: \"1.0.0\" } });\n * mcp.registerTool({ name: \"add\", description: \"Add two numbers\", execute: ({ a, b }) => Number(a) + Number(b) });\n * button.onclick = () => mcp.showConnectDialog();\n * ```\n */\nexport class TabMcp extends EventTarget {\n\treadonly #registry = new ToolRegistry();\n\treadonly #server: ServerInfo;\n\treadonly #appName: string | undefined;\n\treadonly #onConfirm: ConfirmHandler | undefined;\n\treadonly #confirmDelayMs: number | undefined;\n\treadonly #alwaysAllow: boolean;\n\treadonly #relayUrl: string;\n\treadonly #secrets: SecretStore;\n\t/** The channel of the tabs that share the secret (DEC-095). */\n\treadonly #tabs: string | undefined;\n\t/** Replaced since the last session: `newAddress()` takes the address back first. */\n\t#takenOver = false;\n\treadonly #identityAssertion: IdentityAssertionHandler | undefined;\n\t#identity: IdentityState = \"none\";\n\t#identityMessage: string | undefined;\n\t/** Incremented per identity request, so a late answer of an older one is dropped. */\n\t#identityRound = 0;\n\treadonly #identityTimeoutMs: number;\n\t#state: ConnectionState = \"disconnected\";\n\t#session: SessionInfo | undefined;\n\t#grants: readonly Grant[] = Object.freeze([]);\n\t#pairing = false;\n\t#pairingCode: PairingCode | undefined;\n\t#connection: ConnectionHandle | undefined;\n\t#connecting: Promise<SessionInfo> | undefined;\n\t/** Incremented when a connection ends or is cancelled. */\n\t#generation = 0;\n\t/** Waits between reconnect attempts; `undefined`: reconnecting is off. */\n\treadonly #reconnectDelays: readonly number[] | undefined;\n\t#reconnecting: ReconnectingInfo | undefined;\n\t#reconnectTimer: ReturnType<typeof setTimeout> | undefined;\n\t#unwatch: (() => void) | undefined;\n\t/** The page's `connect()` waits on the running reconnect attempt: its promise tells it. */\n\t#pageWaits = false;\n\t/** The open \"Connect your AI app\" dialog: one at a time. */\n\t#connectDialog: { doc: Document; shown: Promise<void> } | undefined;\n\n\tconstructor(options: TabMcpOptions) {\n\t\tsuper();\n\t\tconst { url, origin } = tabUrl(options.relay);\n\t\tconst { server, appName } = options;\n\t\tif (\n\t\t\ttypeof server?.name !== \"string\" ||\n\t\t\ttypeof server.version !== \"string\"\n\t\t) {\n\t\t\tthrow new TypeError(\"TabMcp: server needs a name and a version\");\n\t\t}\n\t\tif (appName !== undefined && !isAppName(appName)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"TabMcp: appName must be 1-64 characters without control characters\",\n\t\t\t);\n\t\t}\n\t\tthis.#relayUrl = url;\n\t\tthis.#server = { ...server };\n\t\tthis.#appName = appName;\n\t\tthis.#onConfirm = options.onConfirm;\n\t\tthis.#confirmDelayMs = delayOption(\n\t\t\t\"confirmDelayMs\",\n\t\t\toptions.confirmDelayMs,\n\t\t);\n\t\tthis.#alwaysAllow = options.alwaysAllow === true;\n\t\tthis.#identityAssertion = options.identityAssertion;\n\t\tthis.#identityTimeoutMs =\n\t\t\tdelayOption(\"identityTimeoutMs\", options.identityTimeoutMs) ?? 15_000;\n\t\tthis.#reconnectDelays = reconnectDelays(options.reconnect);\n\t\t// One address per relay and page (server name); the default of 0.4 and\n\t\t// older, per relay only, is moved over once (DEC-083).\n\t\tconst key =\n\t\t\toptions.storageKey ??\n\t\t\t`tab-mcp:secret:${origin}:${encodeURIComponent(server.name)}`;\n\t\tthis.#secrets = new SecretStore(\n\t\t\toptions.storage,\n\t\t\tkey,\n\t\t\toptions.storageKey === undefined ? `tab-mcp:secret:${origin}` : undefined,\n\t\t);\n\t\t// Tabs that share the secret share this channel; with `storage: null`\n\t\t// every tab has an address of its own (DEC-095).\n\t\tthis.#tabs = options.storage === null ? undefined : `${key}#tabs`;\n\t\tthis.#registry.onChange(() =>\n\t\t\tthis.#emit(\"toolschange\", { tools: this.tools }),\n\t\t);\n\t}\n\n\t/**\n\t * Register a tool (WebMCP shape). Allowed before and after `connect()`;\n\t * aborting `options.signal` unregisters it. Rejects with a `TypeError` for\n\t * an invalid tool and an `InvalidStateError` for a duplicate name.\n\t */\n\tregisterTool(tool: Tool, options: RegisterToolOptions = {}): Promise<void> {\n\t\ttry {\n\t\t\tthis.#registry.register(tool, options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\treturn Promise.resolve();\n\t}\n\n\t/** Names of the registered tools. */\n\tget tools(): readonly string[] {\n\t\treturn this.#registry.list().map((t) => t.name);\n\t}\n\n\tget state(): ConnectionState {\n\t\treturn this.#state;\n\t}\n\n\t/** The current session, while connected. */\n\tget session(): SessionInfo | undefined {\n\t\treturn this.#session;\n\t}\n\n\t/** The MCP address to give to AI apps, while connected. */\n\tget address(): string | undefined {\n\t\treturn this.#session?.address;\n\t}\n\n\t/** The app name AI apps see when pairing: the relay's (`session.appName`), else the page's own. */\n\tget appName(): string | undefined {\n\t\treturn this.#session?.appName ?? this.#appName;\n\t}\n\n\t/** The AI apps connected to this address (frozen; a new array when they change). */\n\tget grants(): readonly Grant[] {\n\t\treturn this.#grants;\n\t}\n\n\t/**\n\t * While the library connects again by itself after the connection broke:\n\t * the next attempt and when it starts. `undefined` otherwise.\n\t */\n\tget reconnecting(): ReconnectingInfo | undefined {\n\t\treturn this.#reconnecting;\n\t}\n\n\t/** Who the relay knows as the page's user (identity binding). */\n\tget identity(): IdentityState {\n\t\treturn this.#identity;\n\t}\n\n\t/** Why the relay refused the identity, while `identity` is `refused`. */\n\tget identityMessage(): string | undefined {\n\t\treturn this.#identityMessage;\n\t}\n\n\t/**\n\t * Ask the `identityAssertion` hook again and send the result, e.g. after\n\t * the user signed in without a page load. Resolves `true` once the relay\n\t * accepted it; `false` when nobody is signed in, it was refused, or the\n\t * page is not connected.\n\t */\n\trefreshIdentity(): Promise<boolean> {\n\t\tconst session = this.#session;\n\t\tconst ask = this.#identityAssertion;\n\t\tif (\n\t\t\tthis.#state !== \"connected\" ||\n\t\t\tsession === undefined ||\n\t\t\task === undefined\n\t\t) {\n\t\t\treturn Promise.resolve(false);\n\t\t}\n\t\tconst round = ++this.#identityRound;\n\t\tconst connection = this.#connection;\n\t\tthis.#setIdentity(\"pending\");\n\t\t// No answer in time, from the hook or the relay (an old relay, a lost\n\t\t// message, a hook that never settles): give up.\n\t\tconst timer = setTimeout(() => {\n\t\t\tif (round !== this.#identityRound || this.#identity !== \"pending\") return;\n\t\t\tthis.#identityRound++; // a late answer is dropped\n\t\t\tthis.#setIdentity(\"none\");\n\t\t}, this.#identityTimeoutMs);\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst settle = (event: TabMcpEventMap[\"identitychange\"]) => {\n\t\t\t\tif (event.detail.state === \"pending\") return;\n\t\t\t\tthis.removeEventListener(\"identitychange\", settle);\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(event.detail.state === \"bound\");\n\t\t\t};\n\t\t\tthis.addEventListener(\"identitychange\", settle);\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() =>\n\t\t\t\t\task({ address: session.address, sessionId: session.sessionId }),\n\t\t\t\t)\n\t\t\t\t.then(\n\t\t\t\t\t(assertion) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tround !== this.#identityRound ||\n\t\t\t\t\t\t\tthis.#connection !== connection\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Superseded (a newer request, a sign-out, a new connection): that one settles the state.\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof assertion !== \"string\" || assertion === \"\") {\n\t\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tconnection?.send({ type: \"identity\", assertion, round }) !== true\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (round !== this.#identityRound) return;\n\t\t\t\t\t\tthis.#emit(\"error\", {\n\t\t\t\t\t\t\terror: error instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * The page's user signed out: the relay ends every AI connection of this\n\t * address at once (identity binding). Call it from the web app's logout.\n\t * Returns `false` when it could not be sent (not connected); the grants\n\t * then stay, but work only while a page signed in as the same person is\n\t * open.\n\t */\n\tsignOut(): boolean {\n\t\tthis.#identityRound++;\n\t\tthis.#setIdentity(\"none\");\n\t\tif (this.#state !== \"connected\") return false;\n\t\treturn this.#connection?.send({ type: \"identity.logout\" }) === true;\n\t}\n\n\t/** Whether pairing is on (`startPairing()`). */\n\tget pairing(): boolean {\n\t\treturn this.#pairing;\n\t}\n\n\t/** The pairing code to show, if the relay sent one. */\n\tget pairingCode(): PairingCode | undefined {\n\t\treturn this.#pairingCode;\n\t}\n\n\t/**\n\t * Connect to the relay: loads the connection and MCP handler, opens the\n\t * WebSocket, resolves with the session. Call it from a user action (a\n\t * click): where browsers track user activation it is refused otherwise,\n\t * unless `options.resume` says the user already chose to keep AI access on.\n\t * While reconnecting (`reconnecting`), it makes the next attempt at once.\n\t */\n\tconnect(options: ConnectOptions = {}): Promise<SessionInfo> {\n\t\tif (this.#state === \"connected\" && this.#session !== undefined) {\n\t\t\treturn Promise.resolve(this.#session);\n\t\t}\n\t\tif (this.#connecting !== undefined) {\n\t\t\tif (this.#reconnecting !== undefined) this.#pageWaits = true;\n\t\t\treturn this.#connecting;\n\t\t}\n\t\tif (this.#reconnecting !== undefined) return this.#attemptReconnect(true);\n\t\tconst activation = (\n\t\t\tglobalThis.navigator as\n\t\t\t\t| { userActivation?: { isActive: boolean } }\n\t\t\t\t| undefined\n\t\t)?.userActivation;\n\t\tif (\n\t\t\toptions.resume !== true &&\n\t\t\tactivation !== undefined &&\n\t\t\t!activation.isActive\n\t\t) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew DOMException(\n\t\t\t\t\t\"connect() must be called from a user action, such as a click\",\n\t\t\t\t\t\"NotAllowedError\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn this.#start();\n\t}\n\n\t#start(revokeAll?: boolean): Promise<SessionInfo> {\n\t\tthis.#setState(\"connecting\");\n\t\tconst connecting = this.#open(this.#generation, revokeAll);\n\t\tthis.#connecting = connecting;\n\t\tconnecting.then(\n\t\t\t() => {\n\t\t\t\tif (this.#connecting === connecting) this.#connecting = undefined;\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tif (this.#connecting !== connecting) return; // superseded\n\t\t\t\tthis.#connecting = undefined;\n\t\t\t\tthis.#connection = undefined;\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t},\n\t\t);\n\t\treturn connecting;\n\t}\n\n\tasync #open(generation: number, revokeAll?: boolean): Promise<SessionInfo> {\n\t\tconst { openConnection, compileRegistry, addressIdOf, withAddress } =\n\t\t\tawait import(\"./connection.ts\");\n\t\t// The validator is loaded: it checks the schemas from now on (DEC-086).\n\t\tfor (const error of compileRegistry(this.#registry))\n\t\t\tthis.#emit(\"error\", { error });\n\t\tconst secret = this.#secrets.get();\n\t\tconst address = await addressIdOf(secret);\n\t\tif (generation !== this.#generation) {\n\t\t\tthrow new DOMException(\"The connection was cancelled\", \"AbortError\");\n\t\t}\n\t\tconst ref: { connection?: ConnectionHandle } = {};\n\t\tconst connection = openConnection(\n\t\t\tthis.#host(ref),\n\t\t\twithAddress(this.#relayUrl, address),\n\t\t\tsecret,\n\t\t\trevokeAll,\n\t\t);\n\t\tref.connection = connection;\n\t\tthis.#connection = connection;\n\t\treturn connection.ready;\n\t}\n\n\t/** End the session (`bye`). Grants stay: AI apps work again after the next `connect()`. */\n\tdisconnect(): void {\n\t\tthis.#end(\"user\");\n\t}\n\n\t/**\n\t * A new address: revokes every connected app of the old one (while\n\t * connected), makes a new secret, and connects again if it was connected or\n\t * connecting. After `replaced`, it first connects with the old address\n\t * again, so that the relay disconnects the apps that now talk to whoever\n\t * took it over (DEC-095), then connects with the new one. Call it from a\n\t * user action.\n\t */\n\tnewAddress(): Promise<SessionInfo | undefined> {\n\t\tif (this.#takenOver) {\n\t\t\t// `hello.revokeAll`: the relay revokes as it hands the address back, and\n\t\t\t// the connection resolves only once no grant is left. Taken over again\n\t\t\t// first: reject, keep the secret, so that a retry takes it back again.\n\t\t\tthis.#end(\"new_address\");\n\t\t\treturn this.#start(true).then(\n\t\t\t\t() => this.#renew(true),\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tthis.#takenOver = true;\n\t\t\t\t\tthrow error;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn this.#renew(false);\n\t}\n\n\t#renew(on: boolean): Promise<SessionInfo | undefined> {\n\t\tconst wasOn =\n\t\t\ton || this.#state !== \"disconnected\" || this.#reconnecting !== undefined;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"grants.revokeAll\" });\n\t\tthis.#end(\"new_address\");\n\t\tthis.#secrets.rotate();\n\t\tthis.#takenOver = false; // nobody else has the new secret\n\t\t// It was on: the user chose that already, as for a reconnect.\n\t\treturn wasOn ? this.connect({ resume: true }) : Promise.resolve(undefined);\n\t}\n\n\t/** Close the connection (or cancel connecting) and report it at once. */\n\t#end(reason: DisconnectReason): void {\n\t\tthis.#stopReconnecting();\n\t\tthis.#generation++;\n\t\tconst connection = this.#connection;\n\t\tconst wasConnected = this.#state === \"connected\";\n\t\tthis.#connection = undefined;\n\t\tthis.#connecting = undefined;\n\t\tconnection?.close(reason); // its callbacks are stale from here on\n\t\tif (this.#state === \"disconnected\") return;\n\t\tthis.#session = undefined;\n\t\tthis.#setPairingCode(undefined);\n\t\tthis.#identityRound++;\n\t\tthis.#setIdentity(\"none\");\n\t\tthis.#setState(\"disconnected\");\n\t\tif (wasConnected) this.#emit(\"disconnected\", { reason, code: 1000 });\n\t}\n\n\t/** Wait, then connect again (attempt `attempt`, from 1). */\n\t#scheduleReconnect(reason: DisconnectReason, attempt: number): void {\n\t\tconst delays = this.#reconnectDelays;\n\t\tif (delays === undefined) return;\n\t\tconst delay = delays[Math.min(attempt, delays.length) - 1] ?? 0;\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = setTimeout(() => {\n\t\t\tthis.#attemptReconnect().catch(() => {}); // the next one is scheduled\n\t\t}, delay);\n\t\tthis.#watch();\n\t\tthis.#reconnecting = { reason, attempt, at: Date.now() + delay };\n\t\tthis.#emit(\"reconnecting\", this.#reconnecting);\n\t}\n\n\t/**\n\t * Make the next reconnect attempt now; on failure, schedule the one after.\n\t * `byPage`: from `connect()`, whose promise tells the page why it failed.\n\t */\n\t#attemptReconnect(byPage = false): Promise<SessionInfo> {\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = undefined;\n\t\tif (this.#connecting !== undefined) return this.#connecting;\n\t\tconst info = this.#reconnecting;\n\t\tthis.#pageWaits = byPage;\n\t\tconst attempt = this.#start();\n\t\tattempt.catch((error: unknown) => {\n\t\t\tconst pageWaits = this.#pageWaits;\n\t\t\tthis.#pageWaits = false;\n\t\t\tif (info === undefined || this.#reconnecting !== info) return;\n\t\t\t// Only what may get better: an unreachable relay (network), a\n\t\t\t// heartbeat or a shutdown; a refusal stops it (DEC-082).\n\t\t\tconst reason = (error as { reason?: DisconnectReason } | null)?.reason;\n\t\t\tif (reason === undefined || RECONNECT_REASONS.has(reason)) {\n\t\t\t\tthis.#scheduleReconnect(info.reason, info.attempt + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// A refusal stops it. Without a connect() of the page's waiting on this\n\t\t\t// attempt, nothing else tells the page why: `error` does, before `null`.\n\t\t\tthis.#stopReconnecting(\n\t\t\t\tpageWaits\n\t\t\t\t\t? undefined\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new Error(String(error)),\n\t\t\t);\n\t\t});\n\t\treturn attempt;\n\t}\n\n\t/** Back to the front, or online again: try at once instead of waiting. */\n\t#watch(): void {\n\t\tif (this.#unwatch !== undefined) return;\n\t\tconst g = globalThis as Partial<EventTarget>;\n\t\tconst doc = (globalThis as { document?: Document }).document;\n\t\tconst now = () => {\n\t\t\t// Only while waiting: an attempt that is running is not doubled.\n\t\t\tif (this.#reconnectTimer !== undefined)\n\t\t\t\tthis.#attemptReconnect().catch(() => {});\n\t\t};\n\t\tconst visible = () => {\n\t\t\tif (doc?.visibilityState !== \"hidden\") now();\n\t\t};\n\t\tdoc?.addEventListener(\"visibilitychange\", visible);\n\t\tg.addEventListener?.(\"online\", now);\n\t\tthis.#unwatch = () => {\n\t\t\tdoc?.removeEventListener(\"visibilitychange\", visible);\n\t\t\tg.removeEventListener?.(\"online\", now);\n\t\t};\n\t}\n\n\t/**\n\t * Stop reconnecting. `why` (a refusal) goes out as `error` before the\n\t * `null`, once the state is clear: a listener that calls `connect()` then\n\t * starts afresh, with the user-activation check.\n\t */\n\t#stopReconnecting(why?: Error): void {\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = undefined;\n\t\tthis.#unwatch?.();\n\t\tthis.#unwatch = undefined;\n\t\tif (this.#reconnecting === undefined) return;\n\t\tthis.#reconnecting = undefined;\n\t\tif (why !== undefined) this.#emit(\"error\", { error: why });\n\t\tthis.#emit(\"reconnecting\", null);\n\t}\n\n\t/** The pairing dialog opened: ask the relay for codes (DEC-028). */\n\tstartPairing(): void {\n\t\tif (this.#pairing) return;\n\t\tthis.#pairing = true;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"pairing.start\" });\n\t}\n\n\t/** The pairing dialog closed: the code becomes invalid. */\n\tstopPairing(): void {\n\t\tif (!this.#pairing) return;\n\t\tthis.#pairing = false;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"pairing.stop\" });\n\t\tthis.#setPairingCode(undefined);\n\t}\n\n\t/**\n\t * Disconnect one AI app: its tokens stop working at once. Works only while\n\t * connected (the relay does it); returns `false` when it could not be sent.\n\t */\n\trevoke(grantId: string): boolean {\n\t\tif (this.#state !== \"connected\") return false;\n\t\treturn this.#connection?.send({ type: \"grant.revoke\", grantId }) === true;\n\t}\n\n\t/**\n\t * Open the default \"Connect your AI app\" dialog; connects first if needed\n\t * (call it from a click). Resolves when the dialog closes. One dialog at\n\t * a time (they would share one pairing): while it is open, a call for the\n\t * same document opens no second one and resolves with it, and a call for\n\t * another document rejects with an `InvalidStateError`. Pages with their\n\t * own UI use the events and methods instead.\n\t */\n\tshowConnectDialog(options: { document?: Document } = {}): Promise<void> {\n\t\tconst doc = options.document ?? globalThis.document;\n\t\tconst open = this.#connectDialog;\n\t\tif (open !== undefined) {\n\t\t\treturn open.doc === doc\n\t\t\t\t? open.shown\n\t\t\t\t: Promise.reject(\n\t\t\t\t\t\tnew DOMException(\n\t\t\t\t\t\t\t\"showConnectDialog: the dialog is already open in another document\",\n\t\t\t\t\t\t\t\"InvalidStateError\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t}\n\t\tconst shown = this.#showConnectDialog(doc).finally(() => {\n\t\t\tif (this.#connectDialog?.shown === shown) this.#connectDialog = undefined;\n\t\t});\n\t\tthis.#connectDialog = { doc, shown };\n\t\treturn shown;\n\t}\n\n\tasync #showConnectDialog(doc: Document): Promise<void> {\n\t\tconst connecting = this.connect();\n\t\tconnecting.catch(() => {}); // the dialog shows the error\n\t\tconst { showConnectDialog } = await import(\"./ui.ts\");\n\t\tawait showConnectDialog(this, connecting, doc, this.#server.name);\n\t}\n\n\toverride addEventListener<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tlistener: Listener<K> | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\toverride addEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\toverride addEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tsuper.addEventListener(type, listener, options);\n\t}\n\n\toverride removeEventListener<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tlistener: Listener<K> | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\toverride removeEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\toverride removeEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void {\n\t\tsuper.removeEventListener(type, listener, options);\n\t}\n\n\t#emit<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tdetail: TabMcpEventMap[K][\"detail\"],\n\t): void {\n\t\tthis.dispatchEvent(new CustomEvent(type, { detail }));\n\t}\n\n\t#setState(state: ConnectionState): void {\n\t\tif (this.#state === state) return;\n\t\tthis.#state = state;\n\t\tthis.#emit(\"statechange\", { state });\n\t}\n\n\t#setIdentity(state: IdentityState, message?: string): void {\n\t\tif (this.#identity === state && message === undefined) return;\n\t\tthis.#identity = state;\n\t\tthis.#identityMessage = state === \"refused\" ? message : undefined;\n\t\tthis.#emit(\n\t\t\t\"identitychange\",\n\t\t\tmessage === undefined ? { state } : { state, message },\n\t\t);\n\t}\n\n\t#setPairingCode(code: PairingCode | undefined): void {\n\t\tif (this.#pairingCode === undefined && code === undefined) return;\n\t\tthis.#pairingCode = code;\n\t\tthis.#emit(\"pairingcode\", code ?? null);\n\t}\n\n\t#setGrants(grants: readonly Grant[]): void {\n\t\tthis.#grants = Object.freeze(grants.map(frozenGrant));\n\t\tthis.#emit(\"grantschange\", { grants: this.#grants });\n\t}\n\n\t#confirm(request: ConfirmRequest): Promise<boolean> {\n\t\tif (this.#onConfirm !== undefined) {\n\t\t\tconst ask = this.#onConfirm;\n\t\t\treturn Promise.resolve()\n\t\t\t\t.then(() => ask(request))\n\t\t\t\t.then((allowed) => allowed === true);\n\t\t}\n\t\treturn this.confirmInPage(request);\n\t}\n\n\t/**\n\t * The library's own confirmation: the dialog in the page with Don't allow\n\t * and Allow, and Always allow with `alwaysAllow: true` (what runs without\n\t * `onConfirm`). An `onConfirm`\n\t * may hand some calls to it. Resolves `false` where there is no document.\n\t */\n\tconfirmInPage(request: ConfirmRequest): Promise<boolean> {\n\t\tconst doc = globalThis.document as Document | undefined;\n\t\tif (doc === undefined) return Promise.resolve(false); // nobody to ask: decline\n\t\t// The tools allowed always live in the UI chunk too: only it adds them.\n\t\treturn import(\"./ui.ts\").then((ui) =>\n\t\t\tui.confirmInPage(this, request, doc, {\n\t\t\t\tallowDelayMs: this.#confirmDelayMs,\n\t\t\t\talwaysAllow: this.#alwaysAllow,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** The callbacks of one connection; once it is not current they are ignored. */\n\t#host(ref: { connection?: ConnectionHandle }): ConnectionHost {\n\t\tconst current = () =>\n\t\t\tref.connection !== undefined && this.#connection === ref.connection;\n\t\tlet replacedHere = false;\n\t\treturn {\n\t\t\tregistry: this.#registry,\n\t\t\tserver: this.#server,\n\t\t\tappName: this.#appName,\n\t\t\ttabs: this.#tabs,\n\t\t\tlibrary: { name: LIBRARY_NAME, version: VERSION },\n\t\t\tconfirm: (request) => this.#confirm(request),\n\t\t\t// Both always, even from a connection that is no longer current: a\n\t\t\t// call that started must end, and every end has its start.\n\t\t\ttoolCallStarted: (call) => this.#emit(\"toolcall\", call),\n\t\t\ttoolCallEnded: (call) => this.#emit(\"toolcallend\", call),\n\t\t\tclientFor: (grant: GrantRef): ToolCallClient => {\n\t\t\t\tconst known = this.#grants.find((g) => g.grantId === grant.grantId);\n\t\t\t\tconst client: ToolCallClient = {\n\t\t\t\t\tgrantId: grant.grantId,\n\t\t\t\t\tid: grant.clientId,\n\t\t\t\t\thost: hostOf(grant.clientId),\n\t\t\t\t};\n\t\t\t\tif (known !== undefined) client.name = known.client.name;\n\t\t\t\treturn client;\n\t\t\t},\n\t\t\tsessionStarted: (m) => {\n\t\t\t\tconst session = sessionInfo(m);\n\t\t\t\tif (!current()) return session;\n\t\t\t\tthis.#session = session;\n\t\t\t\tthis.#takenOver = false;\n\t\t\t\tthis.#stopReconnecting();\n\t\t\t\tthis.#setState(\"connected\");\n\t\t\t\tthis.#setGrants([...m.grants]);\n\t\t\t\tif (this.#pairing) this.#connection?.send({ type: \"pairing.start\" });\n\t\t\t\tthis.#emit(\"connected\", session);\n\t\t\t\tif (session.pairing === \"oidc\") void this.refreshIdentity();\n\t\t\t\treturn session;\n\t\t\t},\n\t\t\tpairingCode: (code) => {\n\t\t\t\tif (current() && this.#pairing) this.#setPairingCode(code);\n\t\t\t},\n\t\t\tgrantAdded: (grant) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.#setGrants([\n\t\t\t\t\t...this.#grants.filter((g) => g.grantId !== grant.grantId),\n\t\t\t\t\tgrant,\n\t\t\t\t]);\n\t\t\t},\n\t\t\tgrantRemoved: (grantId) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.#setGrants(this.#grants.filter((g) => g.grantId !== grantId));\n\t\t\t},\n\t\t\t// After `closed`, so no longer current: only a connection that was\n\t\t\t// current when it was replaced reports it.\n\t\t\treplaced: (detail) => {\n\t\t\t\tif (replacedHere) this.#emit(\"replaced\", detail);\n\t\t\t},\n\t\t\tidentityResult: (bound, round, message) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\t// Only the answer to the newest assertion counts: the relay echoes\n\t\t\t\t// its round, so a lost or late answer cannot pass for a newer one.\n\t\t\t\tif (round !== this.#identityRound) return;\n\t\t\t\tif (bound) this.#setIdentity(\"bound\");\n\t\t\t\telse this.#setIdentity(\"refused\", message ?? \"\");\n\t\t\t},\n\t\t\terror: (error) => {\n\t\t\t\tif (current()) this.#emit(\"error\", { error });\n\t\t\t},\n\t\t\tclosed: (reason: DisconnectReason, code: number) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\t// Taken over: `newAddress()` takes it back first, whatever runs by\n\t\t\t\t// then (review of PR 39).\n\t\t\t\tif (reason === \"replaced\") this.#takenOver = replacedHere = true;\n\t\t\t\t// Any listener below may end it all (`disconnect()`, `newAddress()`):\n\t\t\t\t// that bumps the generation, and then nothing is scheduled.\n\t\t\t\tconst generation = this.#generation;\n\t\t\t\tthis.#connection = undefined;\n\t\t\t\tthis.#session = undefined;\n\t\t\t\tthis.#setPairingCode(undefined);\n\t\t\t\tthis.#identityRound++;\n\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t\tthis.#emit(\"disconnected\", { reason, code });\n\t\t\t\t// After the page heard of it: its listener may have connected or ended it.\n\t\t\t\tif (\n\t\t\t\t\tRECONNECT_REASONS.has(reason) &&\n\t\t\t\t\tthis.#generation === generation &&\n\t\t\t\t\tthis.#state === \"disconnected\" &&\n\t\t\t\t\tthis.#connecting === undefined\n\t\t\t\t)\n\t\t\t\t\tthis.#scheduleReconnect(reason, 1);\n\t\t\t},\n\t\t};\n\t}\n}\n"
7
+ "/** The library's name and version, sent in `hello` (a test keeps it equal to package.json). */\nexport const LIBRARY_NAME = \"@ractive-ch/tab-mcp-client\";\nexport const VERSION = \"0.10.0\";\n",
8
+ "/**\n * `TabMcp`: the eagerly loaded core (DEC-035). It holds the tool registry, the\n * events, the pairing state and the address secret; `connect()` loads the\n * connection and the MCP handler with a dynamic `import()`.\n */\n\nimport type { ConnectionHandle, ConnectionHost } from \"./internal.ts\";\nimport type { GrantRef, SessionMessage } from \"./protocol.ts\";\nimport { ToolRegistry } from \"./registry.ts\";\nimport { SecretStore } from \"./secret.ts\";\nimport type {\n\tConfirmHandler,\n\tConfirmRequest,\n\tConnectionState,\n\tConnectOptions,\n\tDisconnectReason,\n\tGrant,\n\tIdentityAssertionHandler,\n\tIdentityState,\n\tPairingCode,\n\tReconnectingInfo,\n\tRegisterToolOptions,\n\tServerInfo,\n\tSessionInfo,\n\tTabMcpEventMap,\n\tTabMcpOptions,\n\tTool,\n\tToolCallClient,\n} from \"./types.ts\";\nimport { LIBRARY_NAME, VERSION } from \"./version.ts\";\n\nconst LOOPBACK = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\"]);\n\n/** The default waits before each reconnect attempt; the last one repeats. */\nconst RECONNECT_DELAYS_MS = [5_000, 10_000, 20_000, 40_000, 60_000];\n/** Reasons after which the library connects again by itself. */\nconst RECONNECT_REASONS = new Set<DisconnectReason>([\n\t\"network\",\n\t\"heartbeat\",\n\t\"shutdown\",\n]);\n\nfunction reconnectDelays(\n\toption: TabMcpOptions[\"reconnect\"],\n): readonly number[] | undefined {\n\tif (option === false) return undefined;\n\tif (option === undefined || option === true) return RECONNECT_DELAYS_MS;\n\tconst delays = option.delaysMs ?? RECONNECT_DELAYS_MS;\n\tif (\n\t\t!Array.isArray(delays) ||\n\t\tdelays.length === 0 ||\n\t\t!delays.every((d) => typeof d === \"number\" && d >= 0 && d < 2 ** 31)\n\t) {\n\t\tthrow new TypeError(\"TabMcp: reconnect.delaysMs: a non-empty list of ms\");\n\t}\n\treturn [...delays];\n}\n\n/** A delay option: `undefined`, or a whole wait `setTimeout` can keep (below 2^31 ms). */\nfunction delayOption(name: string, value: unknown): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (\n\t\ttypeof value !== \"number\" ||\n\t\t!Number.isFinite(value) ||\n\t\tvalue < 0 ||\n\t\tvalue >= 2 ** 31\n\t) {\n\t\tthrow new TypeError(`TabMcp: ${name} must be a number of milliseconds`);\n\t}\n\treturn value;\n}\n\n/** A grant as the page sees it: frozen, so a page cannot change what decides Always allow. */\nfunction frozenGrant(grant: Grant): Grant {\n\treturn Object.freeze({\n\t\t...grant,\n\t\tclient: Object.freeze({ ...grant.client }),\n\t});\n}\n\n/** What the relay accepts as `hello.app.name` (protocol: session). */\nfunction isAppName(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === \"string\" &&\n\t\tvalue.trim().length > 0 &&\n\t\tvalue.length <= 64 &&\n\t\t![...value].some((ch) => {\n\t\t\tconst c = ch.codePointAt(0) ?? 0;\n\t\t\treturn c < 0x20 || (c >= 0x7f && c <= 0x9f);\n\t\t})\n\t);\n}\n\n/** `wss://host/tab` for a relay given as `https://host`, `wss://host` or with `/tab`. */\nexport function tabUrl(relay: string): { url: string; origin: string } {\n\tlet u: URL;\n\ttry {\n\t\tu = new URL(relay);\n\t} catch {\n\t\tthrow new TypeError(`TabMcp: relay is not a URL: ${relay}`);\n\t}\n\tconst secure = u.protocol === \"https:\" || u.protocol === \"wss:\";\n\tif (!secure && u.protocol !== \"http:\" && u.protocol !== \"ws:\") {\n\t\tthrow new TypeError(\n\t\t\t`TabMcp: relay must be an https: or wss: URL: ${relay}`,\n\t\t);\n\t}\n\t// The secret travels in hello: never in clear text beyond this machine.\n\tif (!secure && !LOOPBACK.has(u.hostname)) {\n\t\tthrow new TypeError(\n\t\t\t`TabMcp: relay must use https: or wss: (http: only for localhost): ${relay}`,\n\t\t);\n\t}\n\tconst origin = `${secure ? \"https:\" : \"http:\"}//${u.host}`;\n\tconst path = u.pathname.replace(/\\/+$/, \"\");\n\tu.protocol = secure ? \"wss:\" : \"ws:\";\n\tu.pathname = path.endsWith(\"/tab\") ? path : `${path}/tab`;\n\tu.search = \"\";\n\tu.hash = \"\";\n\treturn { url: u.href, origin };\n}\n\nfunction hostOf(url: string): string {\n\ttry {\n\t\treturn new URL(url).host;\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction sessionInfo(m: SessionMessage): SessionInfo {\n\tconst info: SessionInfo = {\n\t\tsessionId: m.sessionId,\n\t\taddress: m.address,\n\t\torigin: m.origin,\n\t\tpairing: m.pairing === \"oidc\" ? \"oidc\" : \"code\",\n\t\texpiresAt: m.expiresAt,\n\t\tlimits: m.limits,\n\t};\n\tif (m.appName !== undefined) info.appName = m.appName;\n\treturn info;\n}\n\ntype Listener<K extends keyof TabMcpEventMap> = (\n\tevent: TabMcpEventMap[K],\n) => void;\n\n/**\n * Offers a page's tools to AI apps through a tab-mcp relay.\n *\n * ```ts\n * const mcp = new TabMcp({ relay: \"https://relay.example\", server: { name: \"Calculator\", version: \"1.0.0\" } });\n * mcp.registerTool({ name: \"add\", description: \"Add two numbers\", execute: ({ a, b }) => Number(a) + Number(b) });\n * button.onclick = () => mcp.showConnectDialog();\n * ```\n */\nexport class TabMcp extends EventTarget {\n\treadonly #registry = new ToolRegistry();\n\treadonly #server: ServerInfo;\n\treadonly #appName: string | undefined;\n\treadonly #onConfirm: ConfirmHandler | undefined;\n\treadonly #confirmDelayMs: number | undefined;\n\treadonly #alwaysAllow: boolean;\n\treadonly #relayUrl: string;\n\treadonly #secrets: SecretStore;\n\t/** The channel of the tabs that share the secret (DEC-095). */\n\treadonly #tabs: string | undefined;\n\t/** Replaced since the last session: `newAddress()` takes the address back first. */\n\t#takenOver = false;\n\treadonly #identityAssertion: IdentityAssertionHandler | undefined;\n\t#identity: IdentityState = \"none\";\n\t#identityMessage: string | undefined;\n\t/** Incremented per identity request, so a late answer of an older one is dropped. */\n\t#identityRound = 0;\n\treadonly #identityTimeoutMs: number;\n\t#state: ConnectionState = \"disconnected\";\n\t#session: SessionInfo | undefined;\n\t#grants: readonly Grant[] = Object.freeze([]);\n\t#pairing = false;\n\t#pairingCode: PairingCode | undefined;\n\t#connection: ConnectionHandle | undefined;\n\t#connecting: Promise<SessionInfo> | undefined;\n\t/** Incremented when a connection ends or is cancelled. */\n\t#generation = 0;\n\t/** Waits between reconnect attempts; `undefined`: reconnecting is off. */\n\treadonly #reconnectDelays: readonly number[] | undefined;\n\t#reconnecting: ReconnectingInfo | undefined;\n\t#reconnectTimer: ReturnType<typeof setTimeout> | undefined;\n\t#unwatch: (() => void) | undefined;\n\t/** The page's `connect()` waits on the running reconnect attempt: its promise tells it. */\n\t#pageWaits = false;\n\t/** The open \"Connect your AI app\" dialog: one at a time. */\n\t#connectDialog: { doc: Document; shown: Promise<void> } | undefined;\n\n\tconstructor(options: TabMcpOptions) {\n\t\tsuper();\n\t\tconst { url, origin } = tabUrl(options.relay);\n\t\tconst { server, appName } = options;\n\t\tif (\n\t\t\ttypeof server?.name !== \"string\" ||\n\t\t\ttypeof server.version !== \"string\"\n\t\t) {\n\t\t\tthrow new TypeError(\"TabMcp: server needs a name and a version\");\n\t\t}\n\t\tif (appName !== undefined && !isAppName(appName)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"TabMcp: appName must be 1-64 characters without control characters\",\n\t\t\t);\n\t\t}\n\t\tthis.#relayUrl = url;\n\t\tthis.#server = { ...server };\n\t\tthis.#appName = appName;\n\t\tthis.#onConfirm = options.onConfirm;\n\t\tthis.#confirmDelayMs = delayOption(\n\t\t\t\"confirmDelayMs\",\n\t\t\toptions.confirmDelayMs,\n\t\t);\n\t\tthis.#alwaysAllow = options.alwaysAllow === true;\n\t\tthis.#identityAssertion = options.identityAssertion;\n\t\tthis.#identityTimeoutMs =\n\t\t\tdelayOption(\"identityTimeoutMs\", options.identityTimeoutMs) ?? 15_000;\n\t\tthis.#reconnectDelays = reconnectDelays(options.reconnect);\n\t\t// One address per relay and page (server name); the default of 0.4 and\n\t\t// older, per relay only, is moved over once (DEC-083).\n\t\tconst key =\n\t\t\toptions.storageKey ??\n\t\t\t`tab-mcp:secret:${origin}:${encodeURIComponent(server.name)}`;\n\t\tthis.#secrets = new SecretStore(\n\t\t\toptions.storage,\n\t\t\tkey,\n\t\t\toptions.storageKey === undefined ? `tab-mcp:secret:${origin}` : undefined,\n\t\t);\n\t\t// Tabs that share the secret share this channel; with `storage: null`\n\t\t// every tab has an address of its own (DEC-095).\n\t\tthis.#tabs = options.storage === null ? undefined : `${key}#tabs`;\n\t\tthis.#registry.onChange(() =>\n\t\t\tthis.#emit(\"toolschange\", { tools: this.tools }),\n\t\t);\n\t}\n\n\t/**\n\t * Register a tool (WebMCP shape). Allowed before and after `connect()`;\n\t * aborting `options.signal` unregisters it. Rejects with a `TypeError` for\n\t * an invalid tool and an `InvalidStateError` for a duplicate name.\n\t */\n\tregisterTool<Input extends object = Record<string, unknown>>(\n\t\ttool: Tool<Input>,\n\t\toptions: RegisterToolOptions = {},\n\t): Promise<void> {\n\t\ttry {\n\t\t\t// The arguments are checked against `inputSchema` before `execute` runs.\n\t\t\tthis.#registry.register(tool as unknown as Tool, options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\treturn Promise.resolve();\n\t}\n\n\t/** Names of the registered tools. */\n\tget tools(): readonly string[] {\n\t\treturn this.#registry.list().map((t) => t.name);\n\t}\n\n\tget state(): ConnectionState {\n\t\treturn this.#state;\n\t}\n\n\t/** The current session, while connected. */\n\tget session(): SessionInfo | undefined {\n\t\treturn this.#session;\n\t}\n\n\t/** The MCP address to give to AI apps, while connected. */\n\tget address(): string | undefined {\n\t\treturn this.#session?.address;\n\t}\n\n\t/** The app name AI apps see when pairing: the relay's (`session.appName`), else the page's own. */\n\tget appName(): string | undefined {\n\t\treturn this.#session?.appName ?? this.#appName;\n\t}\n\n\t/** The AI apps connected to this address (frozen; a new array when they change). */\n\tget grants(): readonly Grant[] {\n\t\treturn this.#grants;\n\t}\n\n\t/**\n\t * While the library connects again by itself after the connection broke:\n\t * the next attempt and when it starts. `undefined` otherwise.\n\t */\n\tget reconnecting(): ReconnectingInfo | undefined {\n\t\treturn this.#reconnecting;\n\t}\n\n\t/** Who the relay knows as the page's user (identity binding). */\n\tget identity(): IdentityState {\n\t\treturn this.#identity;\n\t}\n\n\t/** Why the relay refused the identity, while `identity` is `refused`. */\n\tget identityMessage(): string | undefined {\n\t\treturn this.#identityMessage;\n\t}\n\n\t/**\n\t * Ask the `identityAssertion` hook again and send the result, e.g. after\n\t * the user signed in without a page load. Resolves `true` once the relay\n\t * accepted it; `false` when nobody is signed in, it was refused, or the\n\t * page is not connected.\n\t */\n\trefreshIdentity(): Promise<boolean> {\n\t\tconst session = this.#session;\n\t\tconst ask = this.#identityAssertion;\n\t\tif (\n\t\t\tthis.#state !== \"connected\" ||\n\t\t\tsession === undefined ||\n\t\t\task === undefined\n\t\t) {\n\t\t\treturn Promise.resolve(false);\n\t\t}\n\t\tconst round = ++this.#identityRound;\n\t\tconst connection = this.#connection;\n\t\tthis.#setIdentity(\"pending\");\n\t\t// No answer in time, from the hook or the relay (an old relay, a lost\n\t\t// message, a hook that never settles): give up.\n\t\tconst timer = setTimeout(() => {\n\t\t\tif (round !== this.#identityRound || this.#identity !== \"pending\") return;\n\t\t\tthis.#identityRound++; // a late answer is dropped\n\t\t\tthis.#setIdentity(\"none\");\n\t\t}, this.#identityTimeoutMs);\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst settle = (event: TabMcpEventMap[\"identitychange\"]) => {\n\t\t\t\tif (event.detail.state === \"pending\") return;\n\t\t\t\tthis.removeEventListener(\"identitychange\", settle);\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(event.detail.state === \"bound\");\n\t\t\t};\n\t\t\tthis.addEventListener(\"identitychange\", settle);\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() =>\n\t\t\t\t\task({ address: session.address, sessionId: session.sessionId }),\n\t\t\t\t)\n\t\t\t\t.then(\n\t\t\t\t\t(assertion) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tround !== this.#identityRound ||\n\t\t\t\t\t\t\tthis.#connection !== connection\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Superseded (a newer request, a sign-out, a new connection): that one settles the state.\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof assertion !== \"string\" || assertion === \"\") {\n\t\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tconnection?.send({ type: \"identity\", assertion, round }) !== true\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (round !== this.#identityRound) return;\n\t\t\t\t\t\tthis.#emit(\"error\", {\n\t\t\t\t\t\t\terror: error instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * The page's user signed out: the relay ends every AI connection of this\n\t * address at once (identity binding). Call it from the web app's logout.\n\t * Returns `false` when it could not be sent (not connected); the grants\n\t * then stay, but work only while a page signed in as the same person is\n\t * open.\n\t */\n\tsignOut(): boolean {\n\t\tthis.#identityRound++;\n\t\tthis.#setIdentity(\"none\");\n\t\tif (this.#state !== \"connected\") return false;\n\t\treturn this.#connection?.send({ type: \"identity.logout\" }) === true;\n\t}\n\n\t/** Whether pairing is on (`startPairing()`). */\n\tget pairing(): boolean {\n\t\treturn this.#pairing;\n\t}\n\n\t/** The pairing code to show, if the relay sent one. */\n\tget pairingCode(): PairingCode | undefined {\n\t\treturn this.#pairingCode;\n\t}\n\n\t/**\n\t * Connect to the relay: loads the connection and MCP handler, opens the\n\t * WebSocket, resolves with the session. Call it from a user action (a\n\t * click): where browsers track user activation it is refused otherwise,\n\t * unless `options.resume` says the user already chose to keep AI access on.\n\t * While reconnecting (`reconnecting`), it makes the next attempt at once.\n\t */\n\tconnect(options: ConnectOptions = {}): Promise<SessionInfo> {\n\t\tif (this.#state === \"connected\" && this.#session !== undefined) {\n\t\t\treturn Promise.resolve(this.#session);\n\t\t}\n\t\tif (this.#connecting !== undefined) {\n\t\t\tif (this.#reconnecting !== undefined) this.#pageWaits = true;\n\t\t\treturn this.#connecting;\n\t\t}\n\t\tif (this.#reconnecting !== undefined) return this.#attemptReconnect(true);\n\t\tconst activation = (\n\t\t\tglobalThis.navigator as\n\t\t\t\t| { userActivation?: { isActive: boolean } }\n\t\t\t\t| undefined\n\t\t)?.userActivation;\n\t\tif (\n\t\t\toptions.resume !== true &&\n\t\t\tactivation !== undefined &&\n\t\t\t!activation.isActive\n\t\t) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew DOMException(\n\t\t\t\t\t\"connect() must be called from a user action, such as a click\",\n\t\t\t\t\t\"NotAllowedError\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn this.#start();\n\t}\n\n\t#start(revokeAll?: boolean): Promise<SessionInfo> {\n\t\tthis.#setState(\"connecting\");\n\t\tconst connecting = this.#open(this.#generation, revokeAll);\n\t\tthis.#connecting = connecting;\n\t\tconnecting.then(\n\t\t\t() => {\n\t\t\t\tif (this.#connecting === connecting) this.#connecting = undefined;\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tif (this.#connecting !== connecting) return; // superseded\n\t\t\t\tthis.#connecting = undefined;\n\t\t\t\tthis.#connection = undefined;\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t},\n\t\t);\n\t\treturn connecting;\n\t}\n\n\tasync #open(generation: number, revokeAll?: boolean): Promise<SessionInfo> {\n\t\tconst { openConnection, compileRegistry, addressIdOf, withAddress } =\n\t\t\tawait import(\"./connection.ts\");\n\t\t// The validator is loaded: it checks the schemas from now on (DEC-086).\n\t\tfor (const error of compileRegistry(this.#registry))\n\t\t\tthis.#emit(\"error\", { error });\n\t\tconst secret = this.#secrets.get();\n\t\tconst address = await addressIdOf(secret);\n\t\tif (generation !== this.#generation) {\n\t\t\tthrow new DOMException(\"The connection was cancelled\", \"AbortError\");\n\t\t}\n\t\tconst ref: { connection?: ConnectionHandle } = {};\n\t\tconst connection = openConnection(\n\t\t\tthis.#host(ref),\n\t\t\twithAddress(this.#relayUrl, address),\n\t\t\tsecret,\n\t\t\trevokeAll,\n\t\t);\n\t\tref.connection = connection;\n\t\tthis.#connection = connection;\n\t\treturn connection.ready;\n\t}\n\n\t/** End the session (`bye`). Grants stay: AI apps work again after the next `connect()`. */\n\tdisconnect(): void {\n\t\tthis.#end(\"user\");\n\t}\n\n\t/**\n\t * A new address: revokes every connected app of the old one (while\n\t * connected), makes a new secret, and connects again if it was connected or\n\t * connecting. After `replaced`, it first connects with the old address\n\t * again, so that the relay disconnects the apps that now talk to whoever\n\t * took it over (DEC-095), then connects with the new one. Call it from a\n\t * user action.\n\t */\n\tnewAddress(): Promise<SessionInfo | undefined> {\n\t\tif (this.#takenOver) {\n\t\t\t// `hello.revokeAll`: the relay revokes as it hands the address back, and\n\t\t\t// the connection resolves only once no grant is left. Taken over again\n\t\t\t// first: reject, keep the secret, so that a retry takes it back again.\n\t\t\tthis.#end(\"new_address\");\n\t\t\treturn this.#start(true).then(\n\t\t\t\t() => this.#renew(true),\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tthis.#takenOver = true;\n\t\t\t\t\tthrow error;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn this.#renew(false);\n\t}\n\n\t#renew(on: boolean): Promise<SessionInfo | undefined> {\n\t\tconst wasOn =\n\t\t\ton || this.#state !== \"disconnected\" || this.#reconnecting !== undefined;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"grants.revokeAll\" });\n\t\tthis.#end(\"new_address\");\n\t\tthis.#secrets.rotate();\n\t\tthis.#takenOver = false; // nobody else has the new secret\n\t\t// It was on: the user chose that already, as for a reconnect.\n\t\treturn wasOn ? this.connect({ resume: true }) : Promise.resolve(undefined);\n\t}\n\n\t/** Close the connection (or cancel connecting) and report it at once. */\n\t#end(reason: DisconnectReason): void {\n\t\tthis.#stopReconnecting();\n\t\tthis.#generation++;\n\t\tconst connection = this.#connection;\n\t\tconst wasConnected = this.#state === \"connected\";\n\t\tthis.#connection = undefined;\n\t\tthis.#connecting = undefined;\n\t\tconnection?.close(reason); // its callbacks are stale from here on\n\t\tif (this.#state === \"disconnected\") return;\n\t\tthis.#session = undefined;\n\t\tthis.#setPairingCode(undefined);\n\t\tthis.#identityRound++;\n\t\tthis.#setIdentity(\"none\");\n\t\tthis.#setState(\"disconnected\");\n\t\tif (wasConnected) this.#emit(\"disconnected\", { reason, code: 1000 });\n\t}\n\n\t/** Wait, then connect again (attempt `attempt`, from 1). */\n\t#scheduleReconnect(reason: DisconnectReason, attempt: number): void {\n\t\tconst delays = this.#reconnectDelays;\n\t\tif (delays === undefined) return;\n\t\tconst delay = delays[Math.min(attempt, delays.length) - 1] ?? 0;\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = setTimeout(() => {\n\t\t\tthis.#attemptReconnect().catch(() => {}); // the next one is scheduled\n\t\t}, delay);\n\t\tthis.#watch();\n\t\tthis.#reconnecting = { reason, attempt, at: Date.now() + delay };\n\t\tthis.#emit(\"reconnecting\", this.#reconnecting);\n\t}\n\n\t/**\n\t * Make the next reconnect attempt now; on failure, schedule the one after.\n\t * `byPage`: from `connect()`, whose promise tells the page why it failed.\n\t */\n\t#attemptReconnect(byPage = false): Promise<SessionInfo> {\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = undefined;\n\t\tif (this.#connecting !== undefined) return this.#connecting;\n\t\tconst info = this.#reconnecting;\n\t\tthis.#pageWaits = byPage;\n\t\tconst attempt = this.#start();\n\t\tattempt.catch((error: unknown) => {\n\t\t\tconst pageWaits = this.#pageWaits;\n\t\t\tthis.#pageWaits = false;\n\t\t\tif (info === undefined || this.#reconnecting !== info) return;\n\t\t\t// Only what may get better: an unreachable relay (network), a\n\t\t\t// heartbeat or a shutdown; a refusal stops it (DEC-082).\n\t\t\tconst reason = (error as { reason?: DisconnectReason } | null)?.reason;\n\t\t\tif (reason === undefined || RECONNECT_REASONS.has(reason)) {\n\t\t\t\tthis.#scheduleReconnect(info.reason, info.attempt + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// A refusal stops it. Without a connect() of the page's waiting on this\n\t\t\t// attempt, nothing else tells the page why: `error` does, before `null`.\n\t\t\tthis.#stopReconnecting(\n\t\t\t\tpageWaits\n\t\t\t\t\t? undefined\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new Error(String(error)),\n\t\t\t);\n\t\t});\n\t\treturn attempt;\n\t}\n\n\t/** Back to the front, or online again: try at once instead of waiting. */\n\t#watch(): void {\n\t\tif (this.#unwatch !== undefined) return;\n\t\tconst g = globalThis as Partial<EventTarget>;\n\t\tconst doc = (globalThis as { document?: Document }).document;\n\t\tconst now = () => {\n\t\t\t// Only while waiting: an attempt that is running is not doubled.\n\t\t\tif (this.#reconnectTimer !== undefined)\n\t\t\t\tthis.#attemptReconnect().catch(() => {});\n\t\t};\n\t\tconst visible = () => {\n\t\t\tif (doc?.visibilityState !== \"hidden\") now();\n\t\t};\n\t\tdoc?.addEventListener(\"visibilitychange\", visible);\n\t\tg.addEventListener?.(\"online\", now);\n\t\tthis.#unwatch = () => {\n\t\t\tdoc?.removeEventListener(\"visibilitychange\", visible);\n\t\t\tg.removeEventListener?.(\"online\", now);\n\t\t};\n\t}\n\n\t/**\n\t * Stop reconnecting. `why` (a refusal) goes out as `error` before the\n\t * `null`, once the state is clear: a listener that calls `connect()` then\n\t * starts afresh, with the user-activation check.\n\t */\n\t#stopReconnecting(why?: Error): void {\n\t\tclearTimeout(this.#reconnectTimer);\n\t\tthis.#reconnectTimer = undefined;\n\t\tthis.#unwatch?.();\n\t\tthis.#unwatch = undefined;\n\t\tif (this.#reconnecting === undefined) return;\n\t\tthis.#reconnecting = undefined;\n\t\tif (why !== undefined) this.#emit(\"error\", { error: why });\n\t\tthis.#emit(\"reconnecting\", null);\n\t}\n\n\t/** The pairing dialog opened: ask the relay for codes (DEC-028). */\n\tstartPairing(): void {\n\t\tif (this.#pairing) return;\n\t\tthis.#pairing = true;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"pairing.start\" });\n\t}\n\n\t/** The pairing dialog closed: the code becomes invalid. */\n\tstopPairing(): void {\n\t\tif (!this.#pairing) return;\n\t\tthis.#pairing = false;\n\t\tif (this.#state === \"connected\")\n\t\t\tthis.#connection?.send({ type: \"pairing.stop\" });\n\t\tthis.#setPairingCode(undefined);\n\t}\n\n\t/**\n\t * Disconnect one AI app: its tokens stop working at once. Works only while\n\t * connected (the relay does it); returns `false` when it could not be sent.\n\t */\n\trevoke(grantId: string): boolean {\n\t\tif (this.#state !== \"connected\") return false;\n\t\treturn this.#connection?.send({ type: \"grant.revoke\", grantId }) === true;\n\t}\n\n\t/**\n\t * Open the default \"Connect your AI app\" dialog; connects first if needed\n\t * (call it from a click). Resolves when the dialog closes. One dialog at\n\t * a time (they would share one pairing): while it is open, a call for the\n\t * same document opens no second one and resolves with it, and a call for\n\t * another document rejects with an `InvalidStateError`. Pages with their\n\t * own UI use the events and methods instead.\n\t */\n\tshowConnectDialog(options: { document?: Document } = {}): Promise<void> {\n\t\tconst doc = options.document ?? globalThis.document;\n\t\tconst open = this.#connectDialog;\n\t\tif (open !== undefined) {\n\t\t\treturn open.doc === doc\n\t\t\t\t? open.shown\n\t\t\t\t: Promise.reject(\n\t\t\t\t\t\tnew DOMException(\n\t\t\t\t\t\t\t\"showConnectDialog: the dialog is already open in another document\",\n\t\t\t\t\t\t\t\"InvalidStateError\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t}\n\t\tconst shown = this.#showConnectDialog(doc).finally(() => {\n\t\t\tif (this.#connectDialog?.shown === shown) this.#connectDialog = undefined;\n\t\t});\n\t\tthis.#connectDialog = { doc, shown };\n\t\treturn shown;\n\t}\n\n\tasync #showConnectDialog(doc: Document): Promise<void> {\n\t\tconst connecting = this.connect();\n\t\tconnecting.catch(() => {}); // the dialog shows the error\n\t\tconst { showConnectDialog } = await import(\"./ui.ts\");\n\t\tawait showConnectDialog(this, connecting, doc, this.#server.name);\n\t}\n\n\toverride addEventListener<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tlistener: Listener<K> | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\toverride addEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\toverride addEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tsuper.addEventListener(type, listener, options);\n\t}\n\n\toverride removeEventListener<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tlistener: Listener<K> | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\toverride removeEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\toverride removeEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject | null,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void {\n\t\tsuper.removeEventListener(type, listener, options);\n\t}\n\n\t#emit<K extends keyof TabMcpEventMap>(\n\t\ttype: K,\n\t\tdetail: TabMcpEventMap[K][\"detail\"],\n\t): void {\n\t\tthis.dispatchEvent(new CustomEvent(type, { detail }));\n\t}\n\n\t#setState(state: ConnectionState): void {\n\t\tif (this.#state === state) return;\n\t\tthis.#state = state;\n\t\tthis.#emit(\"statechange\", { state });\n\t}\n\n\t#setIdentity(state: IdentityState, message?: string): void {\n\t\tif (this.#identity === state && message === undefined) return;\n\t\tthis.#identity = state;\n\t\tthis.#identityMessage = state === \"refused\" ? message : undefined;\n\t\tthis.#emit(\n\t\t\t\"identitychange\",\n\t\t\tmessage === undefined ? { state } : { state, message },\n\t\t);\n\t}\n\n\t#setPairingCode(code: PairingCode | undefined): void {\n\t\tif (this.#pairingCode === undefined && code === undefined) return;\n\t\tthis.#pairingCode = code;\n\t\tthis.#emit(\"pairingcode\", code ?? null);\n\t}\n\n\t#setGrants(grants: readonly Grant[]): void {\n\t\tthis.#grants = Object.freeze(grants.map(frozenGrant));\n\t\tthis.#emit(\"grantschange\", { grants: this.#grants });\n\t}\n\n\t#confirm(request: ConfirmRequest): Promise<boolean> {\n\t\tif (this.#onConfirm !== undefined) {\n\t\t\tconst ask = this.#onConfirm;\n\t\t\treturn Promise.resolve()\n\t\t\t\t.then(() => ask(request))\n\t\t\t\t.then((allowed) => allowed === true);\n\t\t}\n\t\treturn this.confirmInPage(request);\n\t}\n\n\t/**\n\t * The library's own confirmation: the dialog in the page with Don't allow\n\t * and Allow, and Always allow with `alwaysAllow: true` (what runs without\n\t * `onConfirm`). An `onConfirm`\n\t * may hand some calls to it. Resolves `false` where there is no document.\n\t */\n\tconfirmInPage(request: ConfirmRequest): Promise<boolean> {\n\t\tconst doc = globalThis.document as Document | undefined;\n\t\tif (doc === undefined) return Promise.resolve(false); // nobody to ask: decline\n\t\t// The tools allowed always live in the UI chunk too: only it adds them.\n\t\treturn import(\"./ui.ts\").then((ui) =>\n\t\t\tui.confirmInPage(this, request, doc, {\n\t\t\t\tallowDelayMs: this.#confirmDelayMs,\n\t\t\t\talwaysAllow: this.#alwaysAllow,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** The callbacks of one connection; once it is not current they are ignored. */\n\t#host(ref: { connection?: ConnectionHandle }): ConnectionHost {\n\t\tconst current = () =>\n\t\t\tref.connection !== undefined && this.#connection === ref.connection;\n\t\tlet replacedHere = false;\n\t\treturn {\n\t\t\tregistry: this.#registry,\n\t\t\tserver: this.#server,\n\t\t\tappName: this.#appName,\n\t\t\ttabs: this.#tabs,\n\t\t\tlibrary: { name: LIBRARY_NAME, version: VERSION },\n\t\t\tconfirm: (request) => this.#confirm(request),\n\t\t\t// Both always, even from a connection that is no longer current: a\n\t\t\t// call that started must end, and every end has its start.\n\t\t\ttoolCallStarted: (call) => this.#emit(\"toolcall\", call),\n\t\t\ttoolCallEnded: (call) => this.#emit(\"toolcallend\", call),\n\t\t\tclientFor: (grant: GrantRef): ToolCallClient => {\n\t\t\t\tconst known = this.#grants.find((g) => g.grantId === grant.grantId);\n\t\t\t\tconst client: ToolCallClient = {\n\t\t\t\t\tgrantId: grant.grantId,\n\t\t\t\t\tid: grant.clientId,\n\t\t\t\t\thost: hostOf(grant.clientId),\n\t\t\t\t};\n\t\t\t\tif (known !== undefined) client.name = known.client.name;\n\t\t\t\treturn client;\n\t\t\t},\n\t\t\tsessionStarted: (m) => {\n\t\t\t\tconst session = sessionInfo(m);\n\t\t\t\tif (!current()) return session;\n\t\t\t\tthis.#session = session;\n\t\t\t\tthis.#takenOver = false;\n\t\t\t\tthis.#stopReconnecting();\n\t\t\t\tthis.#setState(\"connected\");\n\t\t\t\tthis.#setGrants([...m.grants]);\n\t\t\t\tif (this.#pairing) this.#connection?.send({ type: \"pairing.start\" });\n\t\t\t\tthis.#emit(\"connected\", session);\n\t\t\t\tif (session.pairing === \"oidc\") void this.refreshIdentity();\n\t\t\t\treturn session;\n\t\t\t},\n\t\t\tpairingCode: (code) => {\n\t\t\t\tif (current() && this.#pairing) this.#setPairingCode(code);\n\t\t\t},\n\t\t\tgrantAdded: (grant) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.#setGrants([\n\t\t\t\t\t...this.#grants.filter((g) => g.grantId !== grant.grantId),\n\t\t\t\t\tgrant,\n\t\t\t\t]);\n\t\t\t},\n\t\t\tgrantRemoved: (grantId) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.#setGrants(this.#grants.filter((g) => g.grantId !== grantId));\n\t\t\t},\n\t\t\t// After `closed`, so no longer current: only a connection that was\n\t\t\t// current when it was replaced reports it.\n\t\t\treplaced: (detail) => {\n\t\t\t\tif (replacedHere) this.#emit(\"replaced\", detail);\n\t\t\t},\n\t\t\tidentityResult: (bound, round, message) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\t// Only the answer to the newest assertion counts: the relay echoes\n\t\t\t\t// its round, so a lost or late answer cannot pass for a newer one.\n\t\t\t\tif (round !== this.#identityRound) return;\n\t\t\t\tif (bound) this.#setIdentity(\"bound\");\n\t\t\t\telse this.#setIdentity(\"refused\", message ?? \"\");\n\t\t\t},\n\t\t\terror: (error) => {\n\t\t\t\tif (current()) this.#emit(\"error\", { error });\n\t\t\t},\n\t\t\tclosed: (reason: DisconnectReason, code: number) => {\n\t\t\t\tif (!current()) return;\n\t\t\t\t// Taken over: `newAddress()` takes it back first, whatever runs by\n\t\t\t\t// then (review of PR 39).\n\t\t\t\tif (reason === \"replaced\") this.#takenOver = replacedHere = true;\n\t\t\t\t// Any listener below may end it all (`disconnect()`, `newAddress()`):\n\t\t\t\t// that bumps the generation, and then nothing is scheduled.\n\t\t\t\tconst generation = this.#generation;\n\t\t\t\tthis.#connection = undefined;\n\t\t\t\tthis.#session = undefined;\n\t\t\t\tthis.#setPairingCode(undefined);\n\t\t\t\tthis.#identityRound++;\n\t\t\t\tthis.#setIdentity(\"none\");\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t\tthis.#emit(\"disconnected\", { reason, code });\n\t\t\t\t// After the page heard of it: its listener may have connected or ended it.\n\t\t\t\tif (\n\t\t\t\t\tRECONNECT_REASONS.has(reason) &&\n\t\t\t\t\tthis.#generation === generation &&\n\t\t\t\t\tthis.#state === \"disconnected\" &&\n\t\t\t\t\tthis.#connecting === undefined\n\t\t\t\t)\n\t\t\t\t\tthis.#scheduleReconnect(reason, 1);\n\t\t\t},\n\t\t};\n\t}\n}\n"
9
9
  ],
10
- "mappings": ";AAYA,IAAM,EAAO,0BAYb,SAAS,CAAa,CAAC,EAA0C,CAChE,OAAO,OAAO,IAAM,UAAY,IAAM,MAAQ,CAAC,MAAM,QAAQ,CAAC,EAI/D,SAAS,CAAa,CAAC,EAAiB,EAAQ,EAAY,CAC3D,GAAI,EAAQ,IAAM,OAAO,IAAW,UAAY,IAAW,KAAM,MAAO,GACxE,GAAI,CAAC,MAAM,QAAQ,CAAM,GAAK,iBAAkB,EAAQ,MAAO,GAC/D,OAAO,OAAO,OAAO,CAAM,EAAE,KAAK,CAAC,IAAM,EAAc,EAAG,EAAQ,CAAC,CAAC,EAIrE,SAAS,CAAc,CAAC,EAAe,EAA0B,CAChE,IAAI,EAAgB,EACpB,QAAW,KAAO,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AAkB,IAAI,CAAM,GAC5B,KAAK,KAAgB,GACrB,KAAK,KAAW,gBAChB,KAAK,KAAgB,OAErB,KAAK,GAAmB,EAAQ,CAAC,EAEpC,EAEF",
11
+ "debugId": "5F62BFF627E293BF64756E2164756E21",
12
12
  "names": []
13
13
  }
@@ -7,7 +7,7 @@ class J{#e=new Map;has(e,n){return this.#e.get(e)?.has(n)===!0}add(e,n){let t=th
7
7
  --_tab-mcp-danger: var(--tab-mcp-danger, light-dark(#b3261e, #ffb4ab));
8
8
  --_tab-mcp-mono: var(--tab-mcp-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
9
9
  --_tab-mcp-small-radius: calc(var(--tab-mcp-radius, 0.75rem) * 0.6);
10
- box-sizing: border-box; width: calc(100% - 2rem); max-width: var(--tab-mcp-max-width, 34rem); max-height: calc(100% - 2rem); overflow: auto;
10
+ 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;
11
11
  font: var(--tab-mcp-font, inherit); line-height: 1.5; color: var(--_tab-mcp-fg); background: var(--_tab-mcp-bg);
12
12
  border: var(--tab-mcp-border, 1px solid var(--_tab-mcp-line)); border-radius: var(--tab-mcp-radius, 0.75rem);
13
13
  padding: var(--tab-mcp-padding, clamp(1rem, 5vw, 1.5rem)); box-shadow: var(--tab-mcp-shadow, 0 1rem 3rem rgb(0 0 0 / 0.3));
@@ -71,5 +71,5 @@ html button.tab-mcp-danger { color: var(--_tab-mcp-danger); border-color: color-
71
71
  `,he=new WeakMap;function Ae(e){try{let n=he.get(e);if(n===void 0){let t=e.defaultView?.CSSStyleSheet;if(t===void 0||!Array.isArray(e.adoptedStyleSheets))return;n=new t,n.replaceSync(Ce),he.set(e,n)}if(!e.adoptedStyleSheets.includes(n))e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{}}function Q(e,n,t,s,a,i,m){let c=f(e,"Copy",()=>{let p=()=>{c.textContent="Copied",c.setAttribute("aria-label",`Copied ${n}`),a(`${n[0]?.toUpperCase()}${n.slice(1)} copied`)},g=()=>{s(),a("Selected: copy it with Ctrl+C or ⌘C")},w=e.defaultView?.navigator?.clipboard;if(w!==void 0)w.writeText(t()).then(p,g);else g()},i,m);c.classList.add("tab-mcp-copy");let l=()=>{c.textContent="Copy",c.setAttribute("aria-label",`Copy ${n}`)};return l(),{button:c,reset:l}}function ne(e,n,t){let s=`tab-mcp-${++ee}`,a=r(e,"dialog",{className:`tab-mcp-dialog ${n}`});a.setAttribute("aria-labelledby",`${s}-title`),Ae(e);let i=r(e,"h2",{id:`${s}-title`,text:t});return a.append(i),{dialog:a,heading:i}}var _e=/[\p{Cf}\p{Default_Ignorable_Code_Point}\p{Co}\p{Cn}\u0080-\u009F\u2028\u2029]/gu;function te(e){return e.replace(_e,(n)=>{let t="";for(let s=0;s<n.length;s++)t+=`\\u${n.charCodeAt(s).toString(16).toUpperCase().padStart(4,"0")}`;return t})}function W(e){let n=te(e.host||e.id);return e.name!==void 0&&e.name!==""?`${te(e.name)} (${n})`:n}function M(e,n){let t=r(e,"bdi",{text:n});return t.dir="ltr",t}function ke(e){try{return te(JSON.stringify(e,null,2))}catch{return}}var Ne=750,Se=500;function Le(e){let n=typeof e==="number"&&Number.isFinite(e)&&e<2147483648?e:Ne;return Math.max(Se,n)}function Ee(e,n,t={}){let s=Le(t.allowDelayMs);if(e.signal.aborted)return Promise.resolve("deny");let a=e.tool.title??e.tool.name,{dialog:i,heading:m}=ne(n,"tab-mcp-confirm","");m.append("Allow ",M(n,a),"?");let c=W(e.client),l=f(n,"Don't allow",()=>i.close("deny"),"tab-mcp-deny","primary"),p=f(n,"Allow",()=>{if(!p.disabled)i.close("allow")},"tab-mcp-allow"),g=[p],w=r(n,"div",{className:"tab-mcp-actions"},l," ",p),T=[];if(t.alwaysAllow===!0){let h=f(n,"Always allow",()=>{if(!h.disabled)i.close("always")},"tab-mcp-always");g.push(h),w.append(" ",h),T.push(r(n,"p",{className:"tab-mcp-always-note"},"Always allow: ",M(n,a)," runs without asking for ",M(n,c)," until you reload this page or disconnect it."))}let x=(h)=>{for(let N of g)N.disabled=!h};x(!1);let C=ke(e.arguments),v=r(n,"pre",{className:"tab-mcp-arguments",text:C??"The arguments cannot be shown, so this call cannot be allowed."});if(C===void 0)for(let h of[...g,...T])h.hidden=!0;v.dir="ltr",v.style.setProperty("white-space","pre-wrap"),v.style.setProperty("overflow-wrap","anywhere"),v.style.setProperty("max-height","var(--tab-mcp-arguments-height, 12rem)"),v.style.setProperty("overflow","auto"),v.hidden=Object.keys(e.arguments).length===0,i.append(r(n,"p",{},M(n,c)," wants to run ",M(n,a),"."),r(n,"p",{className:"tab-mcp-description",text:e.tool.description}),v,w,...T),n.body.append(i);let A=n.defaultView;return new Promise((h)=>{let N=()=>i.close("deny");e.signal.addEventListener("abort",N,{once:!0});let u,b=(_)=>{if(clearTimeout(u),u=void 0,x(!1),_?.type==="blur"||n.visibilityState==="hidden"||!n.hasFocus())return;u=setTimeout(()=>x(!0),s)};n.addEventListener("visibilitychange",b),A?.addEventListener("focus",b),A?.addEventListener("blur",b),i.addEventListener("close",()=>{clearTimeout(u),n.removeEventListener("visibilitychange",b),A?.removeEventListener("focus",b),A?.removeEventListener("blur",b),e.signal.removeEventListener("abort",N);let _=i.returnValue;i.remove(),h(_==="allow"||_==="always"?_:"deny")},{once:!0}),i.showModal(),l.focus(),b()})}var X=new WeakMap;function Ge(e,n,t,s){let{grantId:a}=n.client,i=n.tool.name;if(X.get(e)?.has(a,i))return Promise.resolve(!0);return Ee(n,t,s).then((m)=>{if(m==="always"&&e.grants.some((c)=>c.grantId===a)){let c=X.get(e);if(c===void 0){let l=new J;e.addEventListener("grantschange",(p)=>l.keepGrants(p.detail.grants.map((g)=>g.grantId))),e.addEventListener("toolschange",(p)=>l.keepTools(p.detail.tools)),X.set(e,l),c=l}c.add(a,i)}return m!=="deny"})}function Te(e){let n=e.normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,"");return n===""?"tools":n}function Ie(e){try{let n=new URL(e).href;return/^https?:\/\/[A-Za-z0-9.:[\]/_~-]+$/.test(n)?n:void 0}catch{return}}var De="https://ractive.ch/tab-mcp/connect/",Z="mcp_2026_07_28";function Me(e,n){let t=Te(e),s=Ie(n);return[["Claude (claude.ai and the desktop app)","Settings → Connectors → Add custom connector, then paste the address."],["ChatGPT","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."],s===void 0?["Claude Code","Add the address with claude mcp add --transport http."]:["Claude Code","Run:",`claude mcp add --transport http ${t} ${s}`],["Codex",...s===void 0?[`Run codex features enable ${Z}, then add the address with codex mcp add --url.`,void 0]:["Run:",`codex features enable ${Z}
72
72
  codex mcp add ${t} --url ${s}`],["Start a new chat in Codex after it connects. The first line turns on a feature for all of Codex's MCP servers; ",`codex features disable ${Z}`," turns it off."]]]}function $e(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var q=new WeakMap;function Pe(e,n){let t=q.has(e);if(q.set(e,n),t)return;e.addEventListener("replaced",(s)=>{let a=q.get(e);if(a!==void 0&&e.state==="disconnected")ze(e,a,s.detail.sibling)})}function ze(e,n,t){n.querySelector("dialog.tab-mcp-replaced")?.close();let{dialog:s}=ne(n,"tab-mcp-replaced",t?"Opened in another tab":"Another tab or program took over this page"),a=r(n,"p",{className:"tab-mcp-status"});a.setAttribute("role","status"),a.hidden=!0;let i=f(n,"Close",()=>s.close(),"tab-mcp-replaced-close",t?"primary":void 0),m=r(n,"div",{className:"tab-mcp-actions"},i),c=i;if(!t){let l=f(n,"New address",()=>{l.disabled=!0,a.hidden=!1,a.textContent="Getting a new address…",e.newAddress().then(()=>{s.close(),e.showConnectDialog({document:n}).catch(()=>{})},(p)=>{l.disabled=!1,a.textContent=p?.reason==="replaced"?"It was taken over again before its AI apps were disconnected. Try again.":`Could not connect: ${p instanceof Error?p.message:String(p)}. Try again, or close this.`})},"tab-mcp-new-address","primary");m.append(" ",l),c=l}s.append(r(n,"p",{className:"tab-mcp-description",text:t?"This page is open in another tab, and your AI apps now use that one. To use them here, connect this page again.":"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 its address. A new address disconnects every AI app from the old one; then add the new address to your AI apps again."}),a,m),s.addEventListener("close",()=>s.remove(),{once:!0}),n.body.append(s),s.showModal(),c.focus()}function Oe(e,n,t,s="tools"){let{dialog:a}=ne(t,"tab-mcp-connect","Connect your AI app");a.tabIndex=-1;let i=r(t,"p",{className:"tab-mcp-status",text:"Connecting…"});i.setAttribute("role","status");let m=r(t,"span",{className:"tab-mcp-announce"});m.setAttribute("aria-live","polite");for(let[o,d]of[["position","absolute"],["width","1px"],["height","1px"],["overflow","hidden"],["clip-path","inset(50%)"],["white-space","nowrap"]])m.style.setProperty(o,d);let c=(o)=>{m.textContent=m.textContent===o?`${o} `:o},l=`tab-mcp-${++ee}-address`,p=r(t,"label",{text:"Add this address to your AI app:"});p.htmlFor=l;let g=r(t,"input",{id:l,className:"tab-mcp-address-input"});g.readOnly=!0;let{button:w,reset:T}=Q(t,"address",()=>g.value,()=>g.select(),c,"tab-mcp-address-copy","primary"),x=f(t,"New address",()=>ye(),"tab-mcp-new-address"),C=r(t,"div",{className:"tab-mcp-address"},p,g," ",w," ",x),v=`tab-mcp-${++ee}-new-address`,A=r(t,"p",{id:v}),h=f(t,"Cancel",()=>{u.hidden=!0,x.focus()}),N=f(t,"Disconnect and get new address",()=>ce(),"tab-mcp-new-address-confirm","danger"),u=r(t,"div",{className:"tab-mcp-new-address-question"},A,r(t,"div",{className:"tab-mcp-actions"},h," ",N));u.setAttribute("role","group"),u.setAttribute("aria-labelledby",v),u.hidden=!0;let b=r(t,"strong",{className:"tab-mcp-code-value"});b.style.setProperty("user-select","all"),b.style.setProperty("-webkit-user-select","all");let{button:_,reset:fe}=Q(t,"code",()=>b.textContent??"",()=>t.getSelection()?.selectAllChildren(b),c,"tab-mcp-code-copy"),ae=r(t,"span",{},"When asked, enter the code ",b);ae.setAttribute("aria-live","polite");let P=r(t,"p",{className:"tab-mcp-code"},ae," ",_,r(t,"br"),r(t,"small",{className:"tab-mcp-code-note",text:"A new code appears every 2 minutes and after each use."})),B=r(t,"p",{className:"tab-mcp-sign-in",text:"When your AI app asks, sign in with the account you use on this page. No code is needed."}),re=r(t,"ul"),z=r(t,"a",{text:"Step by step, and what to do when it fails"});z.href=De,z.target="_blank",z.rel="noopener noreferrer";let R=r(t,"details",{className:"tab-mcp-help"},r(t,"summary",{text:"How do I add it?"}),re,r(t,"p",{className:"tab-mcp-guide"},z)),oe=r(t,"ul"),H=r(t,"div",{className:"tab-mcp-apps"},r(t,"h3",{text:"Connected"}),oe),se=r(t,"small",{className:"tab-mcp-close-note",text:"Closing this stops the code. The address stays the same: to connect later, open this again from the page."}),S=f(t,"Close",()=>a.close(),"tab-mcp-close"),L=f(t,"Done",()=>a.close(),"tab-mcp-done","primary");L.hidden=!0;let we=r(t,"div",{className:"tab-mcp-actions"},se," ",S,L),y=!1,F=new Set,ie=()=>{se.hidden=y||P.hidden},j=(o)=>{if(y=o,!y)F.clear();let d=t.activeElement;if(ie(),S.hidden=y,L.hidden=!y,y&&d===S)L.focus();if(!y&&d===L)S.focus()},ve=()=>y?L:S;a.append(i,C,u,P,B,R,H,we,m),C.hidden=!0,P.hidden=!0,B.hidden=!0,R.hidden=!0,H.hidden=!0;let G=!1,de=()=>{let o=e.grants.map((d)=>W(d.client));if(o.length===0)return!1;return A.textContent=`A new address disconnects ${$e(o)}. To use this page again, add the new address to ${o.length===1?"it":"them"}.`,!0},ye=()=>{if(e.state!=="connected")return;if(!de()){ce();return}u.hidden=!1,h.focus()},ce=()=>{j(!1),S.focus(),u.hidden=!0,G=!0,i.textContent="Getting a new address…",e.newAddress().then(()=>{G=!1,i.textContent="This is a new address. Add it to your AI app again.",w.focus()},(o)=>{G=!1,i.textContent=`Could not connect: ${o instanceof Error?o.message:String(o)}. Close this and connect again.`,ve().focus()})},O=(o)=>{if(o===void 0){C.hidden=!0,u.hidden=!0,R.hidden=!0;return}g.value=o.address,T();let d=o.appName??e.appName;if(!G)i.textContent=d!==void 0?`${d} is ready for your AI app.`:"This page is ready for your AI app.";if(x.disabled=e.state!=="connected",C.hidden=!1,t.activeElement===a)w.focus();R.hidden=!1,re.replaceChildren(...Me(s,o.address).map(([D,xe,be,ge])=>{let K=r(t,"li",{},r(t,"strong",{text:`${D}:`}),` ${xe}`);if(be!==void 0){let k=r(t,"pre",{text:be});k.dir="ltr";let{button:Y}=Q(t,`${D} command`,()=>k.textContent??"",()=>t.getSelection()?.selectAllChildren(k),c,"tab-mcp-command-copy");K.append(r(t,"div",{className:"tab-mcp-command"},k,Y))}if(ge!==void 0)K.append(r(t,"small",{className:"tab-mcp-command-note"},...ge.map((k,Y)=>Y%2===1?r(t,"code",{text:k}):k)));return K}))},I=()=>{let o=e.pairingCode,d=e.session?.pairing==="oidc";if(b.textContent!==(o?.code??""))fe();b.textContent=o?.code??"",P.hidden=d||o===void 0,B.hidden=!d,ie()},U=r(t,"p",{className:"tab-mcp-apps-note"});H.append(U);let V=new Set(e.grants.map((o)=>o.grantId)),le=e.session,E=()=>{if(e.session!==le){le=e.session;for(let d of e.grants)V.add(d.grantId)}for(let d of e.grants){if(V.has(d.grantId))continue;if(V.add(d.grantId),i.textContent=`${W(d.client)} is connected.`,F.add(d.grantId),!y)j(!0)}if(y&&!e.grants.some((d)=>F.has(d.grantId)))j(!1);let o=e.state==="connected";if(oe.replaceChildren(...e.grants.map((d)=>{let D=f(t,"Disconnect",()=>{if(!e.revoke(d.grantId))E()},"tab-mcp-disconnect","danger");return D.disabled=!o,r(t,"li",{},r(t,"span",{className:"tab-mcp-app",text:`${W(d.client)} connected `}),D)})),U.textContent=o?"":"To disconnect an app, connect this page again first.",U.hidden=o,H.hidden=e.grants.length===0,!u.hidden&&!de())u.hidden=!0,x.focus()},pe=(o)=>{if(o.detail.reason!=="new_address")i.textContent="Disconnected. AI apps can use this page again after you connect.";O(void 0),E(),I()},me=()=>{O(e.session),E(),I()},ue=()=>a.close();return Pe(e,t),e.addEventListener("pairingcode",I),e.addEventListener("grantschange",E),e.addEventListener("connected",me),e.addEventListener("disconnected",pe),e.addEventListener("replaced",ue),t.body.append(a),e.startPairing(),E(),I(),O(e.session),n.then((o)=>O(o),(o)=>{i.textContent=`Could not connect: ${o instanceof Error?o.message:String(o)}`}),new Promise((o)=>{if(a.addEventListener("close",()=>{e.stopPairing(),e.removeEventListener("pairingcode",I),e.removeEventListener("grantschange",E),e.removeEventListener("connected",me),e.removeEventListener("disconnected",pe),e.removeEventListener("replaced",ue),a.remove(),o()},{once:!0}),a.showModal(),!C.hidden)w.focus();else a.focus()})}export{Ge as confirmInPage,Oe as showConnectDialog};
73
73
 
74
- //# debugId=7484372A955A988764756E2164756E21
75
- //# sourceMappingURL=ui-6cdy3wps.min.js.map
74
+ //# debugId=477549A4850858E864756E2164756E21
75
+ //# sourceMappingURL=ui-406jbpym.min.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/always-allowed.ts", "../../src/ui.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The tools a user chose \"Always allow\" for, per grant (AI app). Kept in\n * memory for the page's lifetime; an entry goes when its grant goes or its\n * tool is unregistered, so a re-paired app or a new tool under the same name\n * is asked again.\n */\nexport class AlwaysAllowed {\n\treadonly #tools = new Map<string, Set<string>>();\n\n\thas(grantId: string, tool: string): boolean {\n\t\treturn this.#tools.get(grantId)?.has(tool) === true;\n\t}\n\n\tadd(grantId: string, tool: string): void {\n\t\tconst tools = this.#tools.get(grantId) ?? new Set();\n\t\ttools.add(tool);\n\t\tthis.#tools.set(grantId, tools);\n\t}\n\n\t/** Forget every grant not in `grantIds`. */\n\tkeepGrants(grantIds: Iterable<string>): void {\n\t\tconst keep = new Set(grantIds);\n\t\tfor (const grantId of this.#tools.keys()) {\n\t\t\tif (!keep.has(grantId)) this.#tools.delete(grantId);\n\t\t}\n\t}\n\n\t/** Forget every tool not in `names`. */\n\tkeepTools(names: Iterable<string>): void {\n\t\tconst keep = new Set(names);\n\t\tfor (const tools of this.#tools.values()) {\n\t\t\tfor (const tool of tools) if (!keep.has(tool)) tools.delete(tool);\n\t\t}\n\t}\n}\n",
6
+ "/**\n * The default UI, loaded on demand: the \"Connect your AI app\" dialog\n * (DEC-028) and the confirmation of consequential tools. Plain `<dialog>`\n * elements, all text set with `textContent`, styled by one constructed\n * stylesheet (`DIALOG_CSS`) that pages adjust through `--tab-mcp-*` custom\n * properties or their own CSS. Pages with their own UI use the events and\n * methods of `TabMcp` instead.\n */\n\nimport { AlwaysAllowed } from \"./always-allowed.ts\";\nimport type { TabMcp } from \"./tab-mcp.ts\";\nimport type {\n\tConfirmRequest,\n\tDisconnectDetail,\n\tGrant,\n\tSessionInfo,\n\tToolCallClient,\n} from \"./types.ts\";\n\nlet counter = 0;\n\nfunction 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 */\nfunction 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/**\n * The look of both 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 rule with two classes, such as `.tab-mcp-dialog .tab-mcp-primary`,\n * wins over all of them. 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-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) { 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`;\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 Copy button for `value()`, read at click time. Shows \"Copied\" once the\n * clipboard took it; without a clipboard (or when it refuses) `select()` puts\n * the text in the selection for Ctrl+C instead. `noun` names it for assistive\n * technology (\"Copy code\"), as the dialog has more than one Copy; `announce`\n * says what happened (\"Code copied\", or that the text is selected).\n */\nfunction copyButton(\n\tdoc: Document,\n\tnoun: string,\n\tvalue: () => string,\n\tselect: () => void,\n\tannounce: (text: string) => void,\n\tclassName: string,\n\tkind?: \"primary\",\n): { button: HTMLButtonElement; reset: () => void } {\n\tconst node = button(\n\t\tdoc,\n\t\t\"Copy\",\n\t\t() => {\n\t\t\tconst done = () => {\n\t\t\t\tnode.textContent = \"Copied\";\n\t\t\t\tnode.setAttribute(\"aria-label\", `Copied ${noun}`);\n\t\t\t\tannounce(`${noun[0]?.toUpperCase()}${noun.slice(1)} copied`);\n\t\t\t};\n\t\t\tconst selected = () => {\n\t\t\t\tselect();\n\t\t\t\tannounce(\"Selected: copy it with Ctrl+C or ⌘C\");\n\t\t\t};\n\t\t\tconst clipboard = (doc.defaultView?.navigator as Navigator | undefined)\n\t\t\t\t?.clipboard;\n\t\t\tif (clipboard !== undefined)\n\t\t\t\tclipboard.writeText(value()).then(done, 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\tnode.textContent = \"Copy\";\n\t\tnode.setAttribute(\"aria-label\", `Copy ${noun}`);\n\t};\n\treset();\n\treturn { button: node, reset };\n}\n\nfunction newDialog(\n\tdoc: Document,\n\tclassName: string,\n\ttitle: string,\n): { dialog: HTMLDialogElement; heading: HTMLHeadingElement } {\n\tconst id = `tab-mcp-${++counter}`;\n\tconst dialog = el(doc, \"dialog\", {\n\t\tclassName: `tab-mcp-dialog ${className}`,\n\t});\n\tdialog.setAttribute(\"aria-labelledby\", `${id}-title`);\n\tadoptStyles(doc);\n\tconst heading = el(doc, \"h2\", { id: `${id}-title`, text: title });\n\tdialog.append(heading);\n\treturn { dialog, heading };\n}\n\n/**\n * Characters that are invisible or change the direction of the text around\n * them: format characters (bidi controls and isolates, zero-width ones, tags),\n * the other default-ignorable ones (fillers, variation selectors), private-use\n * and unassigned code points, C1 controls, and line and paragraph separators.\n */\nconst INVISIBLE =\n\t/[\\p{Cf}\\p{Default_Ignorable_Code_Point}\\p{Co}\\p{Cn}\\u0080-\\u009F\\u2028\\u2029]/gu;\n\n/** Each such character as `\\uXXXX` (a pair for one beyond U+FFFF), as JSON would write it. */\nfunction visible(text: string): string {\n\treturn text.replace(INVISIBLE, (ch) => {\n\t\tlet escaped = \"\";\n\t\tfor (let i = 0; i < ch.length; i++)\n\t\t\tescaped += `\\\\u${ch.charCodeAt(i).toString(16).toUpperCase().padStart(4, \"0\")}`;\n\t\treturn escaped;\n\t});\n}\n\nfunction clientLabel(client: ToolCallClient | Grant[\"client\"]): string {\n\tconst host = visible(client.host || client.id);\n\treturn client.name !== undefined && client.name !== \"\"\n\t\t? `${visible(client.name)} (${host})`\n\t\t: host;\n}\n\n/** A name in a sentence, isolated so that it cannot reorder the words around it. */\nfunction 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 arguments as text, in full: what the user approves must be visible.\n * (The relay caps a request at 1 MiB, so this stays bounded.) Invisible and\n * direction characters are shown as escapes, so the text is still JSON for\n * the same arguments; the tool gets them unchanged. `undefined` when they\n * cannot be shown, and then \"Allow\" is not offered.\n */\nfunction showArguments(args: Record<string, unknown>): string | undefined {\n\ttry {\n\t\treturn visible(JSON.stringify(args, null, 2));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** How long \"Allow\" stays disabled after the confirmation opens, and the floor. */\nexport const ALLOW_DELAY_MS = 750;\nexport const MIN_ALLOW_DELAY_MS = 500;\n\n/** The user's answer: \"always\" allows this tool for this AI app from now on. */\nexport type ConfirmAnswer = \"allow\" | \"always\" | \"deny\";\n\n/** `allowDelayMs` as a usable delay: the default unless a number of ms, never below the floor. */\nfunction allowDelay(ms: number | undefined): number {\n\tconst value =\n\t\ttypeof ms === \"number\" && Number.isFinite(ms) && ms < 2 ** 31\n\t\t\t? ms\n\t\t\t: ALLOW_DELAY_MS;\n\treturn Math.max(MIN_ALLOW_DELAY_MS, value);\n}\n\n/**\n * Ask whether a consequential tool may run. \"Always allow\" is offered only\n * with `alwaysAllow` (DEC-096). \"Allow\" and \"Always allow\" stay disabled\n * until the page has been visible and focused for `allowDelayMs` (default\n * 750, at least 500) while the dialog is open, so a click meant for the page,\n * or the click that brings the tab or window back, cannot approve. Leaving\n * the page disables them again. Everything else (Don't allow, Escape, an\n * aborted call) is \"deny\".\n */\nexport function confirmDialog(\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: { allowDelayMs?: number | undefined; alwaysAllow?: boolean } = {},\n): Promise<ConfirmAnswer> {\n\tconst delay = allowDelay(options.allowDelayMs);\n\tif (request.signal.aborted) return Promise.resolve(\"deny\");\n\tconst title = request.tool.title ?? request.tool.name;\n\tconst { dialog, heading } = newDialog(doc, \"tab-mcp-confirm\", \"\");\n\theading.append(\"Allow \", name(doc, title), \"?\");\n\tconst client = clientLabel(request.client);\n\t// The safe choice is the default: focused, and the one that stands out.\n\tconst deny = button(\n\t\tdoc,\n\t\t\"Don't allow\",\n\t\t() => dialog.close(\"deny\"),\n\t\t\"tab-mcp-deny\",\n\t\t\"primary\",\n\t);\n\tconst allow = button(\n\t\tdoc,\n\t\t\"Allow\",\n\t\t() => {\n\t\t\tif (!allow.disabled) dialog.close(\"allow\");\n\t\t},\n\t\t\"tab-mcp-allow\",\n\t);\n\t// The approving buttons: Allow, and Always allow when the page offers it.\n\tconst approve = [allow];\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tdeny,\n\t\t\" \",\n\t\tallow,\n\t);\n\tconst extra: HTMLElement[] = [];\n\tif (options.alwaysAllow === true) {\n\t\tconst always = button(\n\t\t\tdoc,\n\t\t\t\"Always allow\",\n\t\t\t() => {\n\t\t\t\tif (!always.disabled) dialog.close(\"always\");\n\t\t\t},\n\t\t\t\"tab-mcp-always\",\n\t\t);\n\t\tapprove.push(always);\n\t\tactions.append(\" \", always);\n\t\textra.push(\n\t\t\tel(\n\t\t\t\tdoc,\n\t\t\t\t\"p\",\n\t\t\t\t{ className: \"tab-mcp-always-note\" },\n\t\t\t\t\"Always allow: \",\n\t\t\t\tname(doc, title),\n\t\t\t\t\" runs without asking for \",\n\t\t\t\tname(doc, client),\n\t\t\t\t\" until you reload this page or disconnect it.\",\n\t\t\t),\n\t\t);\n\t}\n\tconst enable = (on: boolean) => {\n\t\tfor (const b of approve) b.disabled = !on;\n\t};\n\tenable(false);\n\tconst shown = showArguments(request.arguments);\n\tconst args = el(doc, \"pre\", {\n\t\tclassName: \"tab-mcp-arguments\",\n\t\ttext:\n\t\t\tshown ?? \"The arguments cannot be shown, so this call cannot be allowed.\",\n\t});\n\tif (shown === undefined) {\n\t\tfor (const node of [...approve, ...extra]) node.hidden = true;\n\t}\n\targs.dir = \"ltr\";\n\t// Inline, so the arguments stay readable in full without the stylesheet:\n\t// wrapped (also a long word, at 360 px), scrolling when long.\n\targs.style.setProperty(\"white-space\", \"pre-wrap\");\n\targs.style.setProperty(\"overflow-wrap\", \"anywhere\");\n\targs.style.setProperty(\n\t\t\"max-height\",\n\t\t\"var(--tab-mcp-arguments-height, 12rem)\",\n\t);\n\targs.style.setProperty(\"overflow\", \"auto\");\n\targs.hidden = Object.keys(request.arguments).length === 0;\n\tdialog.append(\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"p\",\n\t\t\t{},\n\t\t\tname(doc, client),\n\t\t\t\" wants to run \",\n\t\t\tname(doc, title),\n\t\t\t\".\",\n\t\t),\n\t\tel(doc, \"p\", {\n\t\t\tclassName: \"tab-mcp-description\",\n\t\t\ttext: request.tool.description,\n\t\t}),\n\t\targs,\n\t\tactions,\n\t\t...extra,\n\t);\n\tdoc.body.append(dialog);\n\tconst view = doc.defaultView;\n\treturn new Promise((resolve) => {\n\t\tconst onAbort = () => dialog.close(\"deny\");\n\t\trequest.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t// The delay counts only while the user can see the page: tools are\n\t\t// called while the user is in the AI app, so the dialog often opens in\n\t\t// a background tab or window. Any change starts it again from zero (DEC-087).\n\t\tconst arm = (event?: Event) => {\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t\tenable(false);\n\t\t\tif (\n\t\t\t\tevent?.type === \"blur\" ||\n\t\t\t\tdoc.visibilityState === \"hidden\" ||\n\t\t\t\t!doc.hasFocus()\n\t\t\t)\n\t\t\t\treturn;\n\t\t\ttimer = setTimeout(() => enable(true), delay);\n\t\t};\n\t\tdoc.addEventListener(\"visibilitychange\", arm);\n\t\tview?.addEventListener(\"focus\", arm);\n\t\tview?.addEventListener(\"blur\", arm);\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tdoc.removeEventListener(\"visibilitychange\", arm);\n\t\t\t\tview?.removeEventListener(\"focus\", arm);\n\t\t\t\tview?.removeEventListener(\"blur\", arm);\n\t\t\t\trequest.signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tconst value = dialog.returnValue;\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve(value === \"allow\" || value === \"always\" ? value : \"deny\");\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\tdeny.focus(); // the safe choice is the default\n\t\t// Counted from when the dialog is shown, not from when it was built.\n\t\tarm();\n\t});\n}\n\n/** The tools a user chose \"Always allow\" for, per `TabMcp`. */\nconst allowedAlways = new WeakMap<TabMcp, AlwaysAllowed>();\n\n/**\n * `TabMcp.confirmInPage`: the confirmation, and the tools allowed always. An\n * entry goes when its grant goes or its tool is unregistered, so a re-paired\n * app or a new tool under the same name is asked again.\n */\nexport function confirmInPage(\n\tmcp: TabMcp,\n\trequest: ConfirmRequest,\n\tdoc: Document,\n\toptions: { allowDelayMs?: number | undefined; alwaysAllow?: boolean },\n): Promise<boolean> {\n\tconst { grantId } = request.client;\n\tconst tool = request.tool.name;\n\tif (allowedAlways.get(mcp)?.has(grantId, tool)) return Promise.resolve(true);\n\treturn confirmDialog(request, doc, options).then((answer) => {\n\t\t// Only while the grant is still there: a revoked app gets nothing.\n\t\tif (answer === \"always\" && mcp.grants.some((g) => g.grantId === grantId)) {\n\t\t\tlet allowed = allowedAlways.get(mcp);\n\t\t\tif (allowed === undefined) {\n\t\t\t\tconst kept = new AlwaysAllowed();\n\t\t\t\tmcp.addEventListener(\"grantschange\", (e) =>\n\t\t\t\t\tkept.keepGrants(e.detail.grants.map((g) => g.grantId)),\n\t\t\t\t);\n\t\t\t\tmcp.addEventListener(\"toolschange\", (e) =>\n\t\t\t\t\tkept.keepTools(e.detail.tools),\n\t\t\t\t);\n\t\t\t\tallowedAlways.set(mcp, kept);\n\t\t\t\tallowed = kept;\n\t\t\t}\n\t\t\tallowed.add(grantId, tool);\n\t\t}\n\t\treturn answer !== \"deny\";\n\t});\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\n/** The guide for every AI app (its source is on ractive.ch). */\nconst 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 * Per AI app: its name, what to do, a command to run (one per line), and a\n * note after it, alternating text and code. `name` is the page's server name.\n */\nexport function instructions(\n\tname: string,\n\taddress: string,\n): [string, string, (string | undefined)?, string[]?][] {\n\tconst n = commandName(name);\n\tconst a = commandAddress(address);\n\treturn [\n\t\t[\n\t\t\t\"Claude (claude.ai and the desktop app)\",\n\t\t\t\"Settings → Connectors → Add custom connector, then paste the address.\",\n\t\t],\n\t\t[\n\t\t\t\"ChatGPT\",\n\t\t\t\"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.\",\n\t\t],\n\t\ta === undefined\n\t\t\t? [\"Claude Code\", \"Add the address with claude mcp add --transport http.\"]\n\t\t\t: [\"Claude Code\", \"Run:\", `claude mcp add --transport http ${n} ${a}`],\n\t\t[\n\t\t\t\"Codex\",\n\t\t\t...((a === undefined\n\t\t\t\t? [\n\t\t\t\t\t\t`Run codex features enable ${CODEX_FEATURE}, then add the address with codex mcp add --url.`,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t\t\"Run:\",\n\t\t\t\t\t\t`codex features enable ${CODEX_FEATURE}\\ncodex mcp add ${n} --url ${a}`,\n\t\t\t\t\t]) as [string, string | undefined]),\n\t\t\t[\n\t\t\t\t\"Start a new chat in Codex after it connects. The first line turns on a feature for all of Codex's MCP servers; \",\n\t\t\t\t`codex features disable ${CODEX_FEATURE}`,\n\t\t\t\t\" turns it off.\",\n\t\t\t],\n\t\t],\n\t];\n}\n\n/** \"A and B\", \"A, B and C\". */\nfunction listOf(items: string[]): string {\n\treturn items.length < 2\n\t\t? (items[0] ?? \"\")\n\t\t: `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`;\n}\n\n/** The document of the connect dialog per `TabMcp`, once it was opened. */\nconst watched = new WeakMap<TabMcp, Document>();\n\n/**\n * Once a page has opened the connect dialog, the default UI also says when\n * the page loses its address (`replaced`), in that dialog's document.\n */\nfunction watchReplaced(mcp: TabMcp, doc: Document): void {\n\tconst known = watched.has(mcp);\n\twatched.set(mcp, doc);\n\tif (known) return;\n\tmcp.addEventListener(\"replaced\", (event) => {\n\t\tconst current = watched.get(mcp);\n\t\t// Not when the page already went on (a New address or connect since).\n\t\tif (current !== undefined && mcp.state === \"disconnected\")\n\t\t\treplacedNotice(mcp, current, event.detail.sibling);\n\t});\n}\n\n/**\n * Says that the page lost its address (`replaced`, DEC-095). A sibling tab\n * that announced it: \"Opened in another tab\", nothing to do. Otherwise a\n * warning that another tab or program took over, with \"New address\", which\n * takes the address back, disconnects its apps, connects with a new one and\n * opens the connect dialog to add it to the AI apps again.\n */\nexport function replacedNotice(\n\tmcp: TabMcp,\n\tdoc: Document,\n\tsibling: boolean,\n): void {\n\t(\n\t\tdoc.querySelector(\"dialog.tab-mcp-replaced\") as HTMLDialogElement | null\n\t)?.close();\n\tconst { dialog } = newDialog(\n\t\tdoc,\n\t\t\"tab-mcp-replaced\",\n\t\tsibling\n\t\t\t? \"Opened in another tab\"\n\t\t\t: \"Another tab or program took over this page\",\n\t);\n\tconst status = el(doc, \"p\", { className: \"tab-mcp-status\" });\n\tstatus.setAttribute(\"role\", \"status\");\n\tstatus.hidden = true;\n\tconst close = button(\n\t\tdoc,\n\t\t\"Close\",\n\t\t() => dialog.close(),\n\t\t\"tab-mcp-replaced-close\",\n\t\tsibling ? \"primary\" : undefined,\n\t);\n\tconst actions = el(doc, \"div\", { className: \"tab-mcp-actions\" }, close);\n\tlet first = close;\n\tif (!sibling) {\n\t\tconst fresh = button(\n\t\t\tdoc,\n\t\t\t\"New address\",\n\t\t\t() => {\n\t\t\t\tfresh.disabled = true;\n\t\t\t\tstatus.hidden = false;\n\t\t\t\tstatus.textContent = \"Getting a new address…\";\n\t\t\t\tmcp.newAddress().then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tdialog.close();\n\t\t\t\t\t\tmcp.showConnectDialog({ document: doc }).catch(() => {});\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tfresh.disabled = false;\n\t\t\t\t\t\tstatus.textContent =\n\t\t\t\t\t\t\t(error as { reason?: unknown } | null)?.reason === \"replaced\"\n\t\t\t\t\t\t\t\t? \"It was taken over again before its AI apps were disconnected. Try again.\"\n\t\t\t\t\t\t\t\t: `Could not connect: ${error instanceof Error ? error.message : String(error)}. Try again, or close this.`;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\t\t\t\"tab-mcp-new-address\",\n\t\t\t\"primary\",\n\t\t);\n\t\tactions.append(\" \", fresh);\n\t\tfirst = fresh;\n\t}\n\tdialog.append(\n\t\tel(doc, \"p\", {\n\t\t\tclassName: \"tab-mcp-description\",\n\t\t\ttext: sibling\n\t\t\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\t\t\t\t: \"Your AI apps now reach that tab or program instead of this page. If you did not open this page in another tab or browser, someone may have copied its address. A new address disconnects every AI app from the old one; then add the new address to your AI apps again.\",\n\t\t}),\n\t\tstatus,\n\t\tactions,\n\t);\n\tdialog.addEventListener(\"close\", () => dialog.remove(), { once: true });\n\tdoc.body.append(dialog);\n\tdialog.showModal();\n\tfirst.focus();\n}\n\n/**\n * The \"Connect your AI app\" dialog: the address with Copy and New address,\n * short instructions, the pairing code (with Copy) while the relay sends one,\n * and the connected apps with Disconnect. Pairing is on while it is open, so\n * closing it ends the code; the connection and the address stay. Until an app\n * connects, only a small Close (and Escape) close it; then a Done. New address\n * asks first when it would disconnect connected apps (`newAddress()` revokes\n * them). When the page loses its address (`replaced`), this dialog closes and\n * `replacedNotice` says why, from then on also while it is closed.\n */\nexport function showConnectDialog(\n\tmcp: TabMcp,\n\tconnecting: Promise<SessionInfo>,\n\tdoc: Document,\n\tserverName = \"tools\",\n): Promise<void> {\n\tconst { dialog } = newDialog(doc, \"tab-mcp-connect\", \"Connect your AI app\");\n\t// Focusable from script only, for the moment before the address is shown.\n\tdialog.tabIndex = -1;\n\tconst status = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-status\",\n\t\ttext: \"Connecting…\",\n\t});\n\tstatus.setAttribute(\"role\", \"status\");\n\t// What a Copy did, for assistive technology only; out of sight, also\n\t// without the stylesheet. The same message twice is still a change.\n\tconst live = el(doc, \"span\", { className: \"tab-mcp-announce\" });\n\tlive.setAttribute(\"aria-live\", \"polite\");\n\tfor (const [property, value] of [\n\t\t[\"position\", \"absolute\"],\n\t\t[\"width\", \"1px\"],\n\t\t[\"height\", \"1px\"],\n\t\t[\"overflow\", \"hidden\"],\n\t\t[\"clip-path\", \"inset(50%)\"],\n\t\t[\"white-space\", \"nowrap\"],\n\t])\n\t\tlive.style.setProperty(property as string, value as string);\n\tconst announce = (text: string) => {\n\t\tlive.textContent = live.textContent === text ? `${text}\\u00a0` : text;\n\t};\n\n\tconst addressId = `tab-mcp-${++counter}-address`;\n\tconst label = el(doc, \"label\", { text: \"Add this address to your AI app:\" });\n\tlabel.htmlFor = addressId;\n\tconst address = el(doc, \"input\", {\n\t\tid: addressId,\n\t\tclassName: \"tab-mcp-address-input\",\n\t});\n\taddress.readOnly = true;\n\t// Copying the address is the first step: the primary button.\n\tconst { button: copy, reset: resetCopy } = copyButton(\n\t\tdoc,\n\t\t\"address\",\n\t\t() => address.value,\n\t\t() => address.select(),\n\t\tannounce,\n\t\t\"tab-mcp-address-copy\",\n\t\t\"primary\",\n\t);\n\tconst fresh = button(\n\t\tdoc,\n\t\t\"New address\",\n\t\t() => askNewAddress(),\n\t\t\"tab-mcp-new-address\",\n\t);\n\tconst addressBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-address\" },\n\t\tlabel,\n\t\taddress,\n\t\t\" \",\n\t\tcopy,\n\t\t\" \",\n\t\tfresh,\n\t);\n\n\t// Asked in the dialog before New address disconnects connected apps.\n\tconst confirmId = `tab-mcp-${++counter}-new-address`;\n\tconst confirmText = el(doc, \"p\", { id: confirmId });\n\tconst cancelNew = button(doc, \"Cancel\", () => {\n\t\tconfirmBox.hidden = true;\n\t\tfresh.focus();\n\t});\n\tconst confirmNew = button(\n\t\tdoc,\n\t\t\"Disconnect and get new address\",\n\t\t() => getNewAddress(),\n\t\t\"tab-mcp-new-address-confirm\",\n\t\t\"danger\",\n\t);\n\tconst confirmBox = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-new-address-question\" },\n\t\tconfirmText,\n\t\tel(\n\t\t\tdoc,\n\t\t\t\"div\",\n\t\t\t{ className: \"tab-mcp-actions\" },\n\t\t\tcancelNew,\n\t\t\t\" \",\n\t\t\tconfirmNew,\n\t\t),\n\t);\n\tconfirmBox.setAttribute(\"role\", \"group\");\n\tconfirmBox.setAttribute(\"aria-labelledby\", confirmId);\n\tconfirmBox.hidden = true;\n\n\t// Large, in a monospace font: a new code takes the same room.\n\tconst code = el(doc, \"strong\", { className: \"tab-mcp-code-value\" });\n\t// One click selects the whole code; it stays plain, selectable text.\n\tcode.style.setProperty(\"user-select\", \"all\");\n\tcode.style.setProperty(\"-webkit-user-select\", \"all\");\n\t// Reads the code shown at click time, so a rotated code is copied as shown.\n\tconst { button: copyCode, reset: resetCopyCode } = copyButton(\n\t\tdoc,\n\t\t\"code\",\n\t\t() => code.textContent ?? \"\",\n\t\t() => doc.getSelection()?.selectAllChildren(code),\n\t\tannounce,\n\t\t\"tab-mcp-code-copy\",\n\t);\n\t// Only the sentence with the code is announced when the code changes,\n\t// not its Copy button's \"Copied\".\n\tconst codeSentence = el(doc, \"span\", {}, \"When asked, enter the code \", code);\n\tcodeSentence.setAttribute(\"aria-live\", \"polite\");\n\tconst codeLine = el(\n\t\tdoc,\n\t\t\"p\",\n\t\t{ className: \"tab-mcp-code\" },\n\t\tcodeSentence,\n\t\t\" \",\n\t\tcopyCode,\n\t\tel(doc, \"br\"),\n\t\tel(doc, \"small\", {\n\t\t\tclassName: \"tab-mcp-code-note\",\n\t\t\ttext: \"A new code appears every 2 minutes and after each use.\",\n\t\t}),\n\t);\n\t// Identity binding: no code, the same account at the AI app's sign-in.\n\tconst signInLine = el(doc, \"p\", {\n\t\tclassName: \"tab-mcp-sign-in\",\n\t\ttext: \"When your AI app asks, sign in with the account you use on this page. No code is needed.\",\n\t});\n\n\tconst steps = el(doc, \"ul\");\n\tconst guide = el(doc, \"a\", {\n\t\ttext: \"Step by step, and what to do when it fails\",\n\t});\n\tguide.href = GUIDE;\n\tguide.target = \"_blank\";\n\tguide.rel = \"noopener noreferrer\";\n\tconst help = el(\n\t\tdoc,\n\t\t\"details\",\n\t\t{ className: \"tab-mcp-help\" },\n\t\tel(doc, \"summary\", { text: \"How do I add it?\" }),\n\t\tsteps,\n\t\tel(doc, \"p\", { className: \"tab-mcp-guide\" }, guide),\n\t);\n\n\tconst appList = el(doc, \"ul\");\n\tconst apps = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-apps\" },\n\t\tel(doc, \"h3\", { text: \"Connected\" }),\n\t\tappList,\n\t);\n\n\t// Until an app connects in this dialog, closing it is not the next step:\n\t// a small Close at the end, saying what closing does (the code stops, the\n\t// address stays). Once one connects, a prominent Done replaces both.\n\tconst closeNote = el(doc, \"small\", {\n\t\tclassName: \"tab-mcp-close-note\",\n\t\ttext: \"Closing this stops the code. The address stays the same: to connect later, open this again from the page.\",\n\t});\n\tconst close = button(doc, \"Close\", () => dialog.close(), \"tab-mcp-close\");\n\tconst done = button(\n\t\tdoc,\n\t\t\"Done\",\n\t\t() => dialog.close(),\n\t\t\"tab-mcp-done\",\n\t\t\"primary\",\n\t);\n\tdone.hidden = true;\n\tconst actions = el(\n\t\tdoc,\n\t\t\"div\",\n\t\t{ className: \"tab-mcp-actions\" },\n\t\tcloseNote,\n\t\t\" \",\n\t\tclose,\n\t\tdone,\n\t);\n\t// The note on the left, the button at the far right, apart from the code.\n\t// An app connected while this dialog is open (since the last new address),\n\t// and still connected: the grants that made it so.\n\tlet paired = false;\n\tconst pairedGrants = new Set<string>();\n\t// The note is about the code: only while one is shown and nothing paired.\n\tconst renderCloseNote = () => {\n\t\tcloseNote.hidden = paired || codeLine.hidden;\n\t};\n\tconst setPaired = (value: boolean) => {\n\t\tpaired = value;\n\t\tif (!paired) pairedGrants.clear();\n\t\tconst focused = doc.activeElement;\n\t\trenderCloseNote();\n\t\tclose.hidden = paired;\n\t\tdone.hidden = !paired;\n\t\t// Focus never stays on a control that was just hidden.\n\t\tif (paired && focused === close) done.focus();\n\t\tif (!paired && focused === done) close.focus();\n\t};\n\t// The visible button that closes the dialog.\n\tconst closer = () => (paired ? done : close);\n\n\tdialog.append(\n\t\tstatus,\n\t\taddressBox,\n\t\tconfirmBox,\n\t\tcodeLine,\n\t\tsignInLine,\n\t\thelp,\n\t\tapps,\n\t\tactions,\n\t\tlive,\n\t);\n\taddressBox.hidden = true;\n\tcodeLine.hidden = true;\n\tsignInLine.hidden = true;\n\thelp.hidden = true;\n\tapps.hidden = true;\n\n\t// Set while New address waits for the new session.\n\tlet renewing = false;\n\t// The question names the apps connected now; pairing goes on while it is open.\n\tconst renderQuestion = (): boolean => {\n\t\tconst names = mcp.grants.map((g) => clientLabel(g.client));\n\t\tif (names.length === 0) return false;\n\t\tconfirmText.textContent = `A new address disconnects ${listOf(names)}. To use this page again, add the new address to ${names.length === 1 ? \"it\" : \"them\"}.`;\n\t\treturn true;\n\t};\n\tconst askNewAddress = () => {\n\t\tif (mcp.state !== \"connected\") return;\n\t\tif (!renderQuestion()) {\n\t\t\tgetNewAddress();\n\t\t\treturn;\n\t\t}\n\t\tconfirmBox.hidden = false;\n\t\tcancelNew.focus(); // the safe choice is the default\n\t};\n\tconst getNewAddress = () => {\n\t\t// The apps are disconnected: the next one has to pair again.\n\t\tsetPaired(false);\n\t\t// Focus moves before the focused control is hidden.\n\t\tclose.focus();\n\t\tconfirmBox.hidden = true;\n\t\trenewing = true;\n\t\tstatus.textContent = \"Getting a new address…\";\n\t\t// Called from the click, so the reconnect has the user action it needs.\n\t\tmcp.newAddress().then(\n\t\t\t() => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent =\n\t\t\t\t\t\"This is a new address. Add it to your AI app again.\";\n\t\t\t\tcopy.focus();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\trenewing = false;\n\t\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}. Close this and connect again.`;\n\t\t\t\tcloser().focus();\n\t\t\t},\n\t\t);\n\t};\n\tconst renderSession = (session: SessionInfo | undefined) => {\n\t\tif (session === undefined) {\n\t\t\taddressBox.hidden = true;\n\t\t\tconfirmBox.hidden = true;\n\t\t\thelp.hidden = true;\n\t\t\treturn;\n\t\t}\n\t\taddress.value = session.address;\n\t\tresetCopy();\n\t\tconst appName = session.appName ?? mcp.appName;\n\t\tif (!renewing)\n\t\t\tstatus.textContent =\n\t\t\t\tappName !== undefined\n\t\t\t\t\t? `${appName} is ready for your AI app.`\n\t\t\t\t\t: \"This page is ready for your AI app.\";\n\t\tfresh.disabled = mcp.state !== \"connected\";\n\t\taddressBox.hidden = false;\n\t\t// Opened before the session was known: start at the address's Copy.\n\t\tif (doc.activeElement === dialog) copy.focus();\n\t\thelp.hidden = false;\n\t\tsteps.replaceChildren(\n\t\t\t...instructions(serverName, session.address).map(\n\t\t\t\t([app, how, command, note]) => {\n\t\t\t\t\tconst item = el(\n\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\"li\",\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tel(doc, \"strong\", { text: `${app}:` }),\n\t\t\t\t\t\t` ${how}`,\n\t\t\t\t\t);\n\t\t\t\t\tif (command !== undefined) {\n\t\t\t\t\t\t// A block with its own Copy, like the code.\n\t\t\t\t\t\tconst text = el(doc, \"pre\", { text: command });\n\t\t\t\t\t\ttext.dir = \"ltr\";\n\t\t\t\t\t\tconst { button: copyCommand } = copyButton(\n\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t`${app} command`,\n\t\t\t\t\t\t\t() => text.textContent ?? \"\",\n\t\t\t\t\t\t\t() => doc.getSelection()?.selectAllChildren(text),\n\t\t\t\t\t\t\tannounce,\n\t\t\t\t\t\t\t\"tab-mcp-command-copy\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\titem.append(\n\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\"div\",\n\t\t\t\t\t\t\t\t{ className: \"tab-mcp-command\" },\n\t\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t\tcopyCommand,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (note !== undefined)\n\t\t\t\t\t\titem.append(\n\t\t\t\t\t\t\tel(\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\"small\",\n\t\t\t\t\t\t\t\t{ className: \"tab-mcp-command-note\" },\n\t\t\t\t\t\t\t\t...note.map((part, i) =>\n\t\t\t\t\t\t\t\t\ti % 2 === 1 ? el(doc, \"code\", { text: part }) : part,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\treturn item;\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t};\n\tconst renderCode = () => {\n\t\tconst current = mcp.pairingCode;\n\t\tconst oidc = mcp.session?.pairing === \"oidc\";\n\t\t// A new code is not copied yet.\n\t\tif (code.textContent !== (current?.code ?? \"\")) resetCopyCode();\n\t\tcode.textContent = current?.code ?? \"\";\n\t\tcodeLine.hidden = oidc || current === undefined;\n\t\tsignInLine.hidden = !oidc;\n\t\trenderCloseNote();\n\t};\n\tconst appsNote = el(doc, \"p\", { className: \"tab-mcp-apps-note\" });\n\tapps.append(appsNote);\n\t// Grants that were there when the dialog opened; a new one is announced.\n\tconst known = new Set(mcp.grants.map((g) => g.grantId));\n\t// Grants that come with a (new) session were there before; only the ones\n\t// added during a session are new connections.\n\tlet session = mcp.session;\n\tconst renderGrants = () => {\n\t\tif (mcp.session !== session) {\n\t\t\tsession = mcp.session;\n\t\t\tfor (const grant of mcp.grants) known.add(grant.grantId);\n\t\t}\n\t\tfor (const grant of mcp.grants) {\n\t\t\tif (known.has(grant.grantId)) continue;\n\t\t\tknown.add(grant.grantId);\n\t\t\tstatus.textContent = `${clientLabel(grant.client)} is connected.`;\n\t\t\tpairedGrants.add(grant.grantId);\n\t\t\tif (!paired) setPaired(true);\n\t\t}\n\t\t// The app that connected here is gone again (Disconnect, or revoked):\n\t\t// back to Close and the note, the code still runs.\n\t\tif (paired && !mcp.grants.some((g) => pairedGrants.has(g.grantId))) {\n\t\t\tsetPaired(false);\n\t\t}\n\t\tconst connected = mcp.state === \"connected\";\n\t\tappList.replaceChildren(\n\t\t\t...mcp.grants.map((grant) => {\n\t\t\t\tconst disconnect = button(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"Disconnect\",\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (!mcp.revoke(grant.grantId)) renderGrants();\n\t\t\t\t\t},\n\t\t\t\t\t\"tab-mcp-disconnect\",\n\t\t\t\t\t\"danger\",\n\t\t\t\t);\n\t\t\t\t// Only the relay can revoke, so only while connected.\n\t\t\t\tdisconnect.disabled = !connected;\n\t\t\t\treturn el(\n\t\t\t\t\tdoc,\n\t\t\t\t\t\"li\",\n\t\t\t\t\t{},\n\t\t\t\t\tel(doc, \"span\", {\n\t\t\t\t\t\tclassName: \"tab-mcp-app\",\n\t\t\t\t\t\ttext: `${clientLabel(grant.client)} connected `,\n\t\t\t\t\t}),\n\t\t\t\t\tdisconnect,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tappsNote.textContent = connected\n\t\t\t? \"\"\n\t\t\t: \"To disconnect an app, connect this page again first.\";\n\t\tappsNote.hidden = connected;\n\t\tapps.hidden = mcp.grants.length === 0;\n\t\tif (!confirmBox.hidden && !renderQuestion()) {\n\t\t\t// Nobody left to disconnect: no question needed.\n\t\t\tconfirmBox.hidden = true;\n\t\t\tfresh.focus();\n\t\t}\n\t};\n\tconst onDisconnected = (event: CustomEvent<DisconnectDetail>) => {\n\t\tif (event.detail.reason !== \"new_address\")\n\t\t\tstatus.textContent =\n\t\t\t\t\"Disconnected. AI apps can use this page again after you connect.\";\n\t\trenderSession(undefined);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\tconst onConnected = () => {\n\t\trenderSession(mcp.session);\n\t\trenderGrants();\n\t\trenderCode();\n\t};\n\n\t// The address was taken over: the notice says so instead of this dialog.\n\tconst onReplaced = () => dialog.close();\n\twatchReplaced(mcp, doc);\n\tmcp.addEventListener(\"pairingcode\", renderCode);\n\tmcp.addEventListener(\"grantschange\", renderGrants);\n\tmcp.addEventListener(\"connected\", onConnected);\n\tmcp.addEventListener(\"disconnected\", onDisconnected);\n\tmcp.addEventListener(\"replaced\", onReplaced);\n\tdoc.body.append(dialog);\n\tmcp.startPairing();\n\trenderGrants();\n\trenderCode();\n\trenderSession(mcp.session);\n\tconnecting.then(\n\t\t(session) => renderSession(session),\n\t\t(error: unknown) => {\n\t\t\tstatus.textContent = `Could not connect: ${error instanceof Error ? error.message : String(error)}`;\n\t\t},\n\t);\n\n\treturn new Promise((resolve) => {\n\t\tdialog.addEventListener(\n\t\t\t\"close\",\n\t\t\t() => {\n\t\t\t\tmcp.stopPairing();\n\t\t\t\tmcp.removeEventListener(\"pairingcode\", renderCode);\n\t\t\t\tmcp.removeEventListener(\"grantschange\", renderGrants);\n\t\t\t\tmcp.removeEventListener(\"connected\", onConnected);\n\t\t\t\tmcp.removeEventListener(\"disconnected\", onDisconnected);\n\t\t\t\tmcp.removeEventListener(\"replaced\", onReplaced);\n\t\t\t\tdialog.remove();\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t\tdialog.showModal();\n\t\t// Start at the address's Copy; until the address is there, at the\n\t\t// dialog itself (its title is read out), not at Close.\n\t\tif (!addressBox.hidden) copy.focus();\n\t\telse dialog.focus();\n\t});\n}\n"
7
+ ],
8
+ "mappings": "AAMO,MAAM,CAAc,CACjB,GAAS,IAAI,IAEtB,GAAG,CAAC,EAAiB,EAAuB,CAC3C,OAAO,KAAK,GAAO,IAAI,CAAO,GAAG,IAAI,CAAI,IAAM,GAGhD,GAAG,CAAC,EAAiB,EAAoB,CACxC,IAAM,EAAQ,KAAK,GAAO,IAAI,CAAO,GAAK,IAAI,IAC9C,EAAM,IAAI,CAAI,EACd,KAAK,GAAO,IAAI,EAAS,CAAK,EAI/B,UAAU,CAAC,EAAkC,CAC5C,IAAM,EAAO,IAAI,IAAI,CAAQ,EAC7B,QAAW,KAAW,KAAK,GAAO,KAAK,EACtC,GAAI,CAAC,EAAK,IAAI,CAAO,EAAG,KAAK,GAAO,OAAO,CAAO,EAKpD,SAAS,CAAC,EAA+B,CACxC,IAAM,EAAO,IAAI,IAAI,CAAK,EAC1B,QAAW,KAAS,KAAK,GAAO,OAAO,EACtC,QAAW,KAAQ,EAAO,GAAI,CAAC,EAAK,IAAI,CAAI,EAAG,EAAM,OAAO,CAAI,EAGnE,CCfA,IAAI,GAAU,EAEd,SAAS,CAAyC,CACjD,EACA,EACA,EAA4D,CAAC,KAC1D,EACwB,CAC3B,IAAM,EAAO,EAAI,cAAc,CAAG,EAClC,GAAI,EAAM,YAAc,OAAW,EAAK,UAAY,EAAM,UAC1D,GAAI,EAAM,KAAO,OAAW,EAAK,GAAK,EAAM,GAC5C,GAAI,EAAM,OAAS,OAAW,EAAK,YAAc,EAAM,KAEvD,OADA,EAAK,OAAO,GAAG,CAAQ,EAChB,EAQR,SAAS,CAAM,CACd,EACA,EACA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