@ractive-ch/tab-mcp-client 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cdn/tab-mcp-client.min.js +3 -3
- package/cdn/tab-mcp-client.min.js.map +2 -2
- package/index.js +3 -3
- package/index.js.map +2 -2
- package/package.json +1 -1
- package/version.d.ts +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Or without a bundler, from a CDN as an ES module:
|
|
|
19
19
|
|
|
20
20
|
```html
|
|
21
21
|
<script type="module">
|
|
22
|
-
import { TabMcp } from "https://cdn.jsdelivr.net/npm/@ractive-ch/tab-mcp-client@0.1.0-alpha.
|
|
22
|
+
import { TabMcp } from "https://cdn.jsdelivr.net/npm/@ractive-ch/tab-mcp-client@0.1.0-alpha.1/cdn/tab-mcp-client.min.js";
|
|
23
23
|
</script>
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var w,g,f,p=(e,t)=>{for(var[n,o,r]of w||[])for(var i=[e],a=globalThis,s=a.document,c,h,u,d,l;h=i.pop();)if(!g[h]&&(u=o[h])){g[h]=1;for(d=1;d<u.length;d++)i.push(r[u[d]]);if(!t&&h!==e&&(c=s&&s.head)){if(f===void 0)f=(d=s.querySelector("meta[property=csp-nonce]"))&&(d.nonce||d.getAttribute("nonce"))||"";if(l=s.createElement("link"),l.rel="modulepreload",l.crossOrigin="",f)l.nonce=f;l.href=new a.URL(u[0],n),c.appendChild(l)}}},C=(e,t,n,o)=>{for(var r={},i=0;i<t.length;i++)r[t[i]]=n[i];(w||=[]).push([e,r,t]),g||={},p(t[o],1)};C(import.meta.url,["
|
|
2
|
-
var O=/^[A-Za-z0-9_.-]{1,128}$/;function m(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function T(e,t=0){if(t>64||typeof e!=="object"||e===null)return!1;if(!Array.isArray(e)&&"x-mcp-header"in e)return!0;return Object.values(e).some((n)=>T(n,t+1))}function R(e,t){let n=e;for(let o of t.split("/").slice(1)){let r=decodeURIComponent(o).replaceAll("~1","/").replaceAll("~0","~");if(typeof n!=="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function A(e){let t=new Set,n=[],o=[],r=(i,a)=>{if(a>64||typeof i!=="object"||i===null)return;if(!Array.isArray(i)){let s=i;if(typeof s.$anchor==="string")t.add(s.$anchor);if(typeof s.$ref==="string")n.push(s.$ref);if(typeof s.pattern==="string")o.push(s.pattern);let c=s.patternProperties;if(typeof c==="object"&&c!==null)o.push(...Object.keys(c))}for(let s of Object.values(i))r(s,a+1)};r(e,0);for(let i of o)try{new RegExp(i,"u")}catch{return`pattern ${JSON.stringify(i)} is not a valid regular expression`}for(let i of n){if(!i.startsWith("#"))return`$ref ${JSON.stringify(i)} points outside the schema`;let a=i.slice(1);if(!(a===""||(a.startsWith("/")?R(e,a)!==void 0:t.has(a))))return`$ref ${JSON.stringify(i)} does not resolve`}return}function M(e){if(!m(e))throw TypeError("registerTool: the tool must be an object");let{name:t,title:n,description:o,inputSchema:r,execute:i,annotations:a}=e;if(typeof t!=="string"||!O.test(t))throw TypeError(`registerTool: the name must be 1–128 characters of A–Z, a–z, 0–9, "_", "-" or "." (got ${JSON.stringify(t)})`);if(typeof o!=="string"||o.trim()==="")throw TypeError(`registerTool: tool ${t} needs a description`);if(n!==void 0&&typeof n!=="string")throw TypeError(`registerTool: the title of ${t} must be a string`);if(typeof i!=="function")throw TypeError(`registerTool: tool ${t} needs an execute function`);let s=r??{type:"object"};if(!m(s)||s.type!=="object")throw TypeError(`registerTool: the inputSchema of ${t} must be a JSON Schema object with "type": "object"`);if(T(s))throw TypeError(`registerTool: ${t} uses x-mcp-header, which tab-mcp does not support`);let c=A(s);if(c!==void 0)throw TypeError(`registerTool: the inputSchema of ${t}: ${c}`);let h;try{h=JSON.parse(JSON.stringify(s))}catch{throw TypeError(`registerTool: the inputSchema of ${t} must be JSON`)}if(a!==void 0&&!m(a))throw TypeError(`registerTool: the annotations of ${t} must be an object`);let u={};for(let[d,l]of Object.entries(a??{}))if(typeof l==="boolean")u[d]=l;return{name:t,title:n,description:o,inputSchema:h,annotations:u,execute:i}}class y{#e=new Map;#o=new Set;register(e,t={}){let n=M(e),{signal:o}=t;if(o?.aborted)return;if(this.#e.has(n.name))throw new DOMException(`registerTool: a tool named ${n.name} is already registered`,"InvalidStateError");this.#e.set(n.name,n),o?.addEventListener("abort",()=>{if(this.#e.get(n.name)===n)this.#e.delete(n.name),this.#r()},{once:!0}),this.#r()}get(e){return this.#e.get(e)}list(){return[...this.#e.values()]}onChange(e){return this.#o.add(e),()=>this.#o.delete(e)}#r(){for(let e of[...this.#o])e()}}var L=/^[A-Za-z0-9_-]{43}$/;function I(e){return btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function x(){return I(crypto.getRandomValues(new Uint8Array(32)))}function P(e){return typeof e==="string"&&L.test(e)}function k(){try{return globalThis.localStorage??null}catch{return null}}class v{#e;#o;#r;constructor(e,t){this.#e=e===void 0?k():e,this.#o=t}get(){let e=null;try{e=this.#e?.getItem(this.#o)??null}catch{}if(P(e))return this.#r=e,e;return this.#r??this.rotate()}rotate(){let e=x();this.#r=e;try{this.#e?.setItem(this.#o,e)}catch{}return e}}var S="@ractive-ch/tab-mcp-client",b="0.1.0-alpha.
|
|
1
|
+
var w,g,f,p=(e,t)=>{for(var[n,o,r]of w||[])for(var i=[e],a=globalThis,s=a.document,c,h,u,d,l;h=i.pop();)if(!g[h]&&(u=o[h])){g[h]=1;for(d=1;d<u.length;d++)i.push(r[u[d]]);if(!t&&h!==e&&(c=s&&s.head)){if(f===void 0)f=(d=s.querySelector("meta[property=csp-nonce]"))&&(d.nonce||d.getAttribute("nonce"))||"";if(l=s.createElement("link"),l.rel="modulepreload",l.crossOrigin="",f)l.nonce=f;l.href=new a.URL(u[0],n),c.appendChild(l)}}},C=(e,t,n,o)=>{for(var r={},i=0;i<t.length;i++)r[t[i]]=n[i];(w||=[]).push([e,r,t]),g||={},p(t[o],1)};C(import.meta.url,["gg1g51nf","cfq1n4kh","aac2cw9f"],[["./tab-mcp-client.min.js"],["./connection-cfq1n4kh.min.js"],["./ui-aac2cw9f.min.js"]],0);
|
|
2
|
+
var O=/^[A-Za-z0-9_.-]{1,128}$/;function m(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function T(e,t=0){if(t>64||typeof e!=="object"||e===null)return!1;if(!Array.isArray(e)&&"x-mcp-header"in e)return!0;return Object.values(e).some((n)=>T(n,t+1))}function R(e,t){let n=e;for(let o of t.split("/").slice(1)){let r=decodeURIComponent(o).replaceAll("~1","/").replaceAll("~0","~");if(typeof n!=="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function A(e){let t=new Set,n=[],o=[],r=(i,a)=>{if(a>64||typeof i!=="object"||i===null)return;if(!Array.isArray(i)){let s=i;if(typeof s.$anchor==="string")t.add(s.$anchor);if(typeof s.$ref==="string")n.push(s.$ref);if(typeof s.pattern==="string")o.push(s.pattern);let c=s.patternProperties;if(typeof c==="object"&&c!==null)o.push(...Object.keys(c))}for(let s of Object.values(i))r(s,a+1)};r(e,0);for(let i of o)try{new RegExp(i,"u")}catch{return`pattern ${JSON.stringify(i)} is not a valid regular expression`}for(let i of n){if(!i.startsWith("#"))return`$ref ${JSON.stringify(i)} points outside the schema`;let a=i.slice(1);if(!(a===""||(a.startsWith("/")?R(e,a)!==void 0:t.has(a))))return`$ref ${JSON.stringify(i)} does not resolve`}return}function M(e){if(!m(e))throw TypeError("registerTool: the tool must be an object");let{name:t,title:n,description:o,inputSchema:r,execute:i,annotations:a}=e;if(typeof t!=="string"||!O.test(t))throw TypeError(`registerTool: the name must be 1–128 characters of A–Z, a–z, 0–9, "_", "-" or "." (got ${JSON.stringify(t)})`);if(typeof o!=="string"||o.trim()==="")throw TypeError(`registerTool: tool ${t} needs a description`);if(n!==void 0&&typeof n!=="string")throw TypeError(`registerTool: the title of ${t} must be a string`);if(typeof i!=="function")throw TypeError(`registerTool: tool ${t} needs an execute function`);let s=r??{type:"object"};if(!m(s)||s.type!=="object")throw TypeError(`registerTool: the inputSchema of ${t} must be a JSON Schema object with "type": "object"`);if(T(s))throw TypeError(`registerTool: ${t} uses x-mcp-header, which tab-mcp does not support`);let c=A(s);if(c!==void 0)throw TypeError(`registerTool: the inputSchema of ${t}: ${c}`);let h;try{h=JSON.parse(JSON.stringify(s))}catch{throw TypeError(`registerTool: the inputSchema of ${t} must be JSON`)}if(a!==void 0&&!m(a))throw TypeError(`registerTool: the annotations of ${t} must be an object`);let u={};for(let[d,l]of Object.entries(a??{}))if(typeof l==="boolean")u[d]=l;return{name:t,title:n,description:o,inputSchema:h,annotations:u,execute:i}}class y{#e=new Map;#o=new Set;register(e,t={}){let n=M(e),{signal:o}=t;if(o?.aborted)return;if(this.#e.has(n.name))throw new DOMException(`registerTool: a tool named ${n.name} is already registered`,"InvalidStateError");this.#e.set(n.name,n),o?.addEventListener("abort",()=>{if(this.#e.get(n.name)===n)this.#e.delete(n.name),this.#r()},{once:!0}),this.#r()}get(e){return this.#e.get(e)}list(){return[...this.#e.values()]}onChange(e){return this.#o.add(e),()=>this.#o.delete(e)}#r(){for(let e of[...this.#o])e()}}var L=/^[A-Za-z0-9_-]{43}$/;function I(e){return btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function x(){return I(crypto.getRandomValues(new Uint8Array(32)))}function P(e){return typeof e==="string"&&L.test(e)}function k(){try{return globalThis.localStorage??null}catch{return null}}class v{#e;#o;#r;constructor(e,t){this.#e=e===void 0?k():e,this.#o=t}get(){let e=null;try{e=this.#e?.getItem(this.#o)??null}catch{}if(P(e))return this.#r=e,e;return this.#r??this.rotate()}rotate(){let e=x();this.#r=e;try{this.#e?.setItem(this.#o,e)}catch{}return e}}var S="@ractive-ch/tab-mcp-client",b="0.1.0-alpha.1";var N=new Set(["localhost","127.0.0.1","[::1]"]);function j(e){let t;try{t=new URL(e)}catch{throw TypeError(`TabMcp: relay is not a URL: ${e}`)}let n=t.protocol==="https:"||t.protocol==="wss:";if(!n&&t.protocol!=="http:"&&t.protocol!=="ws:")throw TypeError(`TabMcp: relay must be an https: or wss: URL: ${e}`);if(!n&&!N.has(t.hostname))throw TypeError(`TabMcp: relay must use https: or wss: (http: only for localhost): ${e}`);let o=`${n?"https:":"http:"}//${t.host}`,r=t.pathname.replace(/\/+$/,"");return t.protocol=n?"wss:":"ws:",t.pathname=r.endsWith("/tab")?r:`${r}/tab`,t.search="",t.hash="",{url:t.href,origin:o}}function D(e){try{return new URL(e).host}catch{return""}}function J(e){let t={sessionId:e.sessionId,address:e.address,origin:e.origin,expiresAt:e.expiresAt,limits:e.limits};if(e.appName!==void 0)t.appName=e.appName;return t}class E extends EventTarget{#e=new y;#o;#r;#u;#y;#v;#f;#t="disconnected";#s;#d=[];#c=!1;#p;#n;#a;#g=0;constructor(e){super();let{url:t,origin:n}=j(e.relay),{server:o,appName:r}=e;if(typeof o?.name!=="string"||typeof o.version!=="string")throw TypeError("TabMcp: server needs a name and a version");if(r!==void 0&&(typeof r!=="string"||r.length>64))throw TypeError("TabMcp: appName must be a string of at most 64 characters");this.#v=t,this.#o={...o},this.#r=r,this.#u=e.onConfirm,this.#y=e.confirmDelayMs,this.#f=new v(e.storage,e.storageKey??`tab-mcp:secret:${n}`),this.#e.onChange(()=>this.#i("toolschange",{tools:this.tools}))}registerTool(e,t={}){try{this.#e.register(e,t)}catch(n){return Promise.reject(n)}return Promise.resolve()}get tools(){return this.#e.list().map((e)=>e.name)}get state(){return this.#t}get session(){return this.#s}get address(){return this.#s?.address}get appName(){return this.#s?.appName??this.#r}get grants(){return this.#d}get pairing(){return this.#c}get pairingCode(){return this.#p}connect(e={}){if(this.#t==="connected"&&this.#s!==void 0)return Promise.resolve(this.#s);if(this.#a!==void 0)return this.#a;let t=globalThis.navigator?.userActivation;if(e.resume!==!0&&t!==void 0&&!t.isActive)return Promise.reject(new DOMException("connect() must be called from a user action, such as a click","NotAllowedError"));this.#l("connecting");let n=this.#w(this.#g);return this.#a=n,n.then(()=>{if(this.#a===n)this.#a=void 0},()=>{if(this.#a!==n)return;this.#a=void 0,this.#n=void 0,this.#l("disconnected")}),n}async#w(e){let{openConnection:t}=await (p("cfq1n4kh"),import("./connection-cfq1n4kh.min.js"));if(e!==this.#g)throw new DOMException("The connection was cancelled","AbortError");let n={},o=t(this.#S(n),this.#v,this.#f.get());return n.connection=o,this.#n=o,o.ready}disconnect(){this.#b("user")}newAddress(){let e=this.#t!=="disconnected";if(this.#t==="connected")this.#n?.send({type:"grants.revokeAll"});return this.#b("new_address"),this.#f.rotate(),e?this.connect():Promise.resolve(void 0)}#b(e){this.#g++;let t=this.#n,n=this.#t==="connected";if(this.#n=void 0,this.#a=void 0,t?.close(e),this.#t==="disconnected")return;if(this.#s=void 0,this.#h(void 0),this.#l("disconnected"),n)this.#i("disconnected",{reason:e,code:1000})}startPairing(){if(this.#c)return;if(this.#c=!0,this.#t==="connected")this.#n?.send({type:"pairing.start"})}stopPairing(){if(!this.#c)return;if(this.#c=!1,this.#t==="connected")this.#n?.send({type:"pairing.stop"});this.#h(void 0)}revoke(e){if(this.#t!=="connected")return!1;return this.#n?.send({type:"grant.revoke",grantId:e})===!0}async showConnectDialog(e={}){let t=this.connect();t.catch(()=>{});let{showConnectDialog:n}=await (p("aac2cw9f"),import("./ui-aac2cw9f.min.js"));await n(this,t,e.document??globalThis.document)}addEventListener(e,t,n){super.addEventListener(e,t,n)}removeEventListener(e,t,n){super.removeEventListener(e,t,n)}#i(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}#l(e){if(this.#t===e)return;this.#t=e,this.#i("statechange",{state:e})}#h(e){if(this.#p===void 0&&e===void 0)return;this.#p=e,this.#i("pairingcode",e??null)}#m(e){this.#d=e,this.#i("grantschange",{grants:e})}#T(e){if(this.#u!==void 0){let o=this.#u;return Promise.resolve().then(()=>o(e)).then((r)=>r===!0)}let t=globalThis.document;if(t===void 0)return Promise.resolve(!1);let n=this.#y;return (p("aac2cw9f"),import("./ui-aac2cw9f.min.js")).then((o)=>o.confirmDialog(e,t,n===void 0?{}:{allowDelayMs:n}))}#S(e){let t=()=>e.connection!==void 0&&this.#n===e.connection;return{registry:this.#e,server:this.#o,appName:this.#r,library:{name:S,version:b},confirm:(n)=>this.#T(n),clientFor:(n)=>{let o=this.#d.find((i)=>i.grantId===n.grantId),r={grantId:n.grantId,id:n.clientId,host:D(n.clientId)};if(o!==void 0)r.name=o.client.name;return r},sessionStarted:(n)=>{let o=J(n);if(!t())return o;if(this.#s=o,this.#l("connected"),this.#m([...n.grants]),this.#c)this.#n?.send({type:"pairing.start"});return this.#i("connected",o),o},pairingCode:(n)=>{if(t()&&this.#c)this.#h(n)},grantAdded:(n)=>{if(!t())return;this.#m([...this.#d.filter((o)=>o.grantId!==n.grantId),n])},grantRemoved:(n)=>{if(!t())return;this.#m(this.#d.filter((o)=>o.grantId!==n))},replaced:()=>{if(t())this.#i("replaced",null)},error:(n)=>{if(t())this.#i("error",{error:n})},closed:(n,o)=>{if(!t())return;this.#n=void 0,this.#s=void 0,this.#h(void 0),this.#l("disconnected"),this.#i("disconnected",{reason:n,code:o})}}}}export{E as TabMcp,b as VERSION};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=231785A2307BA20E64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=tab-mcp-client.min.js.map
|
|
@@ -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 */\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\nexport class ToolRegistry {\n\treadonly #tools = new Map<string, RegisteredTool>();\n\treadonly #listeners = new Set<() => void>();\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.#tools.set(registered.name, registered);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tif (this.#tools.get(registered.name) === registered) {\n\t\t\t\t\tthis.#tools.delete(registered.name);\n\t\t\t\t\tthis.#changed();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\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#memory: string | undefined;\n\n\tconstructor(storage: SecretStorage | null | undefined, key: string) {\n\t\tthis.#storage = storage === undefined ? defaultStorage() : storage;\n\t\tthis.#key = key;\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} 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\ttry {\n\t\t\tthis.#storage?.setItem(this.#key, secret);\n\t\t} catch {\n\t\t\t// quota or blocked: the secret lives as long as the page\n\t\t}\n\t\treturn secret;\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.1.0-alpha.
|
|
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.1.0-alpha.1\";\n",
|
|
8
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\tPairingCode,\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/** `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\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 #relayUrl: string;\n\treadonly #secrets: SecretStore;\n\t#state: ConnectionState = \"disconnected\";\n\t#session: SessionInfo | undefined;\n\t#grants: Grant[] = [];\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\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 (\n\t\t\tappName !== undefined &&\n\t\t\t(typeof appName !== \"string\" || appName.length > 64)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"TabMcp: appName must be a string of at most 64 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 = options.confirmDelayMs;\n\t\tthis.#secrets = new SecretStore(\n\t\t\toptions.storage,\n\t\t\toptions.storageKey ?? `tab-mcp:secret:${origin}`,\n\t\t);\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. */\n\tget grants(): readonly Grant[] {\n\t\treturn this.#grants;\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 * Never reconnects by itself.\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) return this.#connecting;\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\tthis.#setState(\"connecting\");\n\t\tconst connecting = this.#open(this.#generation);\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): Promise<SessionInfo> {\n\t\tconst { openConnection } = await import(\"./connection.ts\");\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\tthis.#relayUrl,\n\t\t\tthis.#secrets.get(),\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. Call it from a user action.\n\t */\n\tnewAddress(): Promise<SessionInfo | undefined> {\n\t\tconst wasOn = this.#state !== \"disconnected\";\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\treturn wasOn ? this.connect() : 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.#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.#setState(\"disconnected\");\n\t\tif (wasConnected) this.#emit(\"disconnected\", { reason, code: 1000 });\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 tool\" dialog; connects first if needed\n\t * (call it from a click). Resolves when the dialog closes. Pages with their\n\t * own UI use the events and methods instead.\n\t */\n\tasync showConnectDialog(\n\t\toptions: { document?: Document } = {},\n\t): 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(\n\t\t\tthis,\n\t\t\tconnecting,\n\t\t\toptions.document ?? globalThis.document,\n\t\t);\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#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: Grant[]): void {\n\t\tthis.#grants = grants;\n\t\tthis.#emit(\"grantschange\", { 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\tconst doc = globalThis.document as Document | undefined;\n\t\tif (doc === undefined) return Promise.resolve(false); // nobody to ask: decline\n\t\tconst delay = this.#confirmDelayMs;\n\t\treturn import(\"./ui.ts\").then((ui) =>\n\t\t\tui.confirmDialog(\n\t\t\t\trequest,\n\t\t\t\tdoc,\n\t\t\t\tdelay === undefined ? {} : { allowDelayMs: delay },\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\treturn {\n\t\t\tregistry: this.#registry,\n\t\t\tserver: this.#server,\n\t\t\tappName: this.#appName,\n\t\t\tlibrary: { name: LIBRARY_NAME, version: VERSION },\n\t\t\tconfirm: (request) => this.#confirm(request),\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.#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\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\treplaced: () => {\n\t\t\t\tif (current()) this.#emit(\"replaced\", null);\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\tthis.#connection = undefined;\n\t\t\t\tthis.#session = undefined;\n\t\t\t\tthis.#setPairingCode(undefined);\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t\tthis.#emit(\"disconnected\", { reason, code });\n\t\t\t},\n\t\t};\n\t}\n}\n"
|
|
9
9
|
],
|
|
10
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,EAAQ,MAAM,GAAG,EAAE,MAAM,CAAC,EAAG,CAC9C,IAAM,EAAM,mBAAmB,CAAG,EAChC,WAAW,KAAM,GAAG,EACpB,WAAW,KAAM,GAAG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,IAAa,KAAK,CAAE,KAAM,eAAgB,CAAC,EAEnE,OADA,KAAK,GAAM,YAAa,CAAO,EACxB,GAER,YAAa,CAAC,IAAS,CACtB,GAAI,EAAQ,GAAK,KAAK,GAAU,KAAK,GAAgB,CAAI,GAE1D,WAAY,CAAC,IAAU,CACtB,GAAI,CAAC,EAAQ,EAAG,OAChB,KAAK,GAAW,CACf,GAAG,KAAK,GAAQ,OAAO,CAAC,IAAM,EAAE,UAAY,EAAM,OAAO,EACzD,CACD,CAAC,GAEF,aAAc,CAAC,IAAY,CAC1B,GAAI,CAAC,EAAQ,EAAG,OAChB,KAAK,GAAW,KAAK,GAAQ,OAAO,CAAC,IAAM,EAAE,UAAY,CAAO,CAAC,GAElE,SAAU,IAAM,CACf,GAAI,EAAQ,EAAG,KAAK,GAAM,WAAY,IAAI,GAE3C,MAAO,CAAC,IAAU,CACjB,GAAI,EAAQ,EAAG,KAAK,GAAM,QAAS,CAAE,OAAM,CAAC,GAE7C,OAAQ,CAAC,EAA0B,IAAiB,CACnD,GAAI,CAAC,EAAQ,EAAG,OAChB,KAAK,GAAc,OACnB,KAAK,GAAW,OAChB,KAAK,GAAgB,MAAS,EAC9B,KAAK,GAAU,cAAc,EAC7B,KAAK,GAAM,eAAgB,CAAE,SAAQ,MAAK,CAAC,EAE7C,EAEF",
|
|
11
|
-
"debugId": "
|
|
11
|
+
"debugId": "231785A2307BA20E64756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __chunks = (base, ids, nodes, entry) => {
|
|
|
28
28
|
__chunkSeen ||= {};
|
|
29
29
|
__preload(ids[entry], 1);
|
|
30
30
|
};
|
|
31
|
-
__chunks(import.meta.url,["
|
|
31
|
+
__chunks(import.meta.url,["tzd7tzfz","1gf7vqz2","168746sb"],[["./index.js"],["./connection-1gf7vqz2.js"],["./ui-168746sb.js"]],0);
|
|
32
32
|
|
|
33
33
|
// src/registry.ts
|
|
34
34
|
var NAME = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
@@ -230,7 +230,7 @@ class SecretStore {
|
|
|
230
230
|
|
|
231
231
|
// src/version.ts
|
|
232
232
|
var LIBRARY_NAME = "@ractive-ch/tab-mcp-client";
|
|
233
|
-
var VERSION = "0.1.0-alpha.
|
|
233
|
+
var VERSION = "0.1.0-alpha.1";
|
|
234
234
|
|
|
235
235
|
// src/tab-mcp.ts
|
|
236
236
|
var LOOPBACK = new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -539,5 +539,5 @@ export {
|
|
|
539
539
|
VERSION
|
|
540
540
|
};
|
|
541
541
|
|
|
542
|
-
//# debugId=
|
|
542
|
+
//# debugId=B477DA9C3F7079C964756E2164756E21
|
|
543
543
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -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 */\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\nexport class ToolRegistry {\n\treadonly #tools = new Map<string, RegisteredTool>();\n\treadonly #listeners = new Set<() => void>();\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.#tools.set(registered.name, registered);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tif (this.#tools.get(registered.name) === registered) {\n\t\t\t\t\tthis.#tools.delete(registered.name);\n\t\t\t\t\tthis.#changed();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\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#memory: string | undefined;\n\n\tconstructor(storage: SecretStorage | null | undefined, key: string) {\n\t\tthis.#storage = storage === undefined ? defaultStorage() : storage;\n\t\tthis.#key = key;\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} 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\ttry {\n\t\t\tthis.#storage?.setItem(this.#key, secret);\n\t\t} catch {\n\t\t\t// quota or blocked: the secret lives as long as the page\n\t\t}\n\t\treturn secret;\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.1.0-alpha.
|
|
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.1.0-alpha.1\";\n",
|
|
8
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\tPairingCode,\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/** `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\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 #relayUrl: string;\n\treadonly #secrets: SecretStore;\n\t#state: ConnectionState = \"disconnected\";\n\t#session: SessionInfo | undefined;\n\t#grants: Grant[] = [];\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\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 (\n\t\t\tappName !== undefined &&\n\t\t\t(typeof appName !== \"string\" || appName.length > 64)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"TabMcp: appName must be a string of at most 64 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 = options.confirmDelayMs;\n\t\tthis.#secrets = new SecretStore(\n\t\t\toptions.storage,\n\t\t\toptions.storageKey ?? `tab-mcp:secret:${origin}`,\n\t\t);\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. */\n\tget grants(): readonly Grant[] {\n\t\treturn this.#grants;\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 * Never reconnects by itself.\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) return this.#connecting;\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\tthis.#setState(\"connecting\");\n\t\tconst connecting = this.#open(this.#generation);\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): Promise<SessionInfo> {\n\t\tconst { openConnection } = await import(\"./connection.ts\");\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\tthis.#relayUrl,\n\t\t\tthis.#secrets.get(),\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. Call it from a user action.\n\t */\n\tnewAddress(): Promise<SessionInfo | undefined> {\n\t\tconst wasOn = this.#state !== \"disconnected\";\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\treturn wasOn ? this.connect() : 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.#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.#setState(\"disconnected\");\n\t\tif (wasConnected) this.#emit(\"disconnected\", { reason, code: 1000 });\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 tool\" dialog; connects first if needed\n\t * (call it from a click). Resolves when the dialog closes. Pages with their\n\t * own UI use the events and methods instead.\n\t */\n\tasync showConnectDialog(\n\t\toptions: { document?: Document } = {},\n\t): 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(\n\t\t\tthis,\n\t\t\tconnecting,\n\t\t\toptions.document ?? globalThis.document,\n\t\t);\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#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: Grant[]): void {\n\t\tthis.#grants = grants;\n\t\tthis.#emit(\"grantschange\", { 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\tconst doc = globalThis.document as Document | undefined;\n\t\tif (doc === undefined) return Promise.resolve(false); // nobody to ask: decline\n\t\tconst delay = this.#confirmDelayMs;\n\t\treturn import(\"./ui.ts\").then((ui) =>\n\t\t\tui.confirmDialog(\n\t\t\t\trequest,\n\t\t\t\tdoc,\n\t\t\t\tdelay === undefined ? {} : { allowDelayMs: delay },\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\treturn {\n\t\t\tregistry: this.#registry,\n\t\t\tserver: this.#server,\n\t\t\tappName: this.#appName,\n\t\t\tlibrary: { name: LIBRARY_NAME, version: VERSION },\n\t\t\tconfirm: (request) => this.#confirm(request),\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.#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\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\treplaced: () => {\n\t\t\t\tif (current()) this.#emit(\"replaced\", null);\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\tthis.#connection = undefined;\n\t\t\t\tthis.#session = undefined;\n\t\t\t\tthis.#setPairingCode(undefined);\n\t\t\t\tthis.#setState(\"disconnected\");\n\t\t\t\tthis.#emit(\"disconnected\", { reason, code });\n\t\t\t},\n\t\t};\n\t}\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAM,OAAO;AAYb,SAAS,aAAa,CAAC,GAA0C;AAAA,EAChE,OAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAAA;AAI/D,SAAS,aAAa,CAAC,QAAiB,QAAQ,GAAY;AAAA,EAC3D,IAAI,QAAQ,MAAM,OAAO,WAAW,YAAY,WAAW;AAAA,IAAM,OAAO;AAAA,EACxE,IAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,kBAAkB;AAAA,IAAQ,OAAO;AAAA,EAC/D,OAAO,OAAO,OAAO,MAAM,EAAE,KAAK,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC;AAAA;AAIrE,SAAS,cAAc,CAAC,MAAe,SAA0B;AAAA,EAChE,IAAI,OAAgB;AAAA,EACpB,WAAW,OAAO,QAAQ,MAAM,GAAG,EAAE,MAAM,CAAC,GAAG;AAAA,IAC9C,MAAM,MAAM,mBAAmB,GAAG,EAChC,WAAW,MAAM,GAAG,EACpB,WAAW,MAAM,GAAG;AAAA,IACtB,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,OAAO,OAAO,MAAM,GAAG;AAAA,MACxE;AAAA,IACD,OAAQ,KAAiC;AAAA,EAC1C;AAAA,EACA,OAAO;AAAA;AAQR,SAAS,aAAa,CAAC,MAAmC;AAAA,EACzD,MAAM,UAAU,IAAI;AAAA,EACpB,MAAM,OAAiB,CAAC;AAAA,EACxB,MAAM,WAAqB,CAAC;AAAA,EAC5B,MAAM,OAAO,CAAC,MA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