Lines 1-25javascript
1async function It(n,t=0){let e=new TextEncoder().encode(n);if(!crypto.subtle)throw"Requires secure origin (localhost or https:)";let o=await crypto.subtle.digest("SHA-1",e),r=new Uint8Array(o),s=String.fromCodePoint(...r),a=btoa(s).replaceAll("+","-").replaceAll("/","_").replaceAll("=","");return t?a.substring(0,t):a}async function je(n,t=0){let e=new TextEncoder().encode(n);if(!crypto.subtle)throw"Requires secure origin (localhost or https:)";let o=await crypto.subtle.digest("SHA-1",e),s=Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join("");return t?s.substring(0,t):s} ...
2`))>=0;){let y=c.slice(0,p);c=c.slice(p+1),await i(y)}}return c+=l.decode(),await i(c),s}normalizeTargetParty(t){let e=String(t??"").trim();if(!e)throw"Daemon host is required";try{let o=e.includes("://")?new URL(e):new URL(`${globalThis.location.protocol}//${e}`);if(!o.host)throw"missing host";return o.host}catch{throw`Invalid daemon host: ${t}`}}#r(){if(!this.#t)throw"Browser app is not initialised";return this.#t}};function qe(n=void 0){let t=new M;return t.register("browser_daemon_identity",{type:"function",name:"browser_daemon_identity",execution:"client",description:"Get the active chat ...
3${btoa(String.fromCharCode(...new Uint8Array(e))).match(/.{1,64}/g)?.join(`
5-----END PUBLIC KEY-----`}async privatePem(){if(!this.#e)throw"Must generate keypair";let t=this.#e.privateKey,e=await crypto.subtle.exportKey("pkcs8",t);return`-----BEGIN PRIVATE KEY-----
CriticalCritical Secret
Package contains a critical-looking secret pattern.
dist/index.jsView on unpkg · L5 6${btoa(String.fromCharCode(...new Uint8Array(e))).match(/.{1,64}/g)?.join(`
8-----END PRIVATE KEY-----`}};async function Ze(){let n=await R.getInstance(),t=n.getPartyOrigin(),e=new URL(`${t}/catalog`);e.searchParams.append("alert","");let r=await(await fetch(e,{headers:{"X-Tabserver-Token":n.getTokenBase64(),Accept:"application/json"}})).json();if("error"in r)throw r.error;return r.ok.alert.find(i=>i.type=="LAUNCH"&&i.sourceUrl==new URL(n.getAppUrl()))||null}var ot=class{#t;#e;#n;#s;#o;#r;#l;async initWithKey(t,e,o,r){this.#e=e.startsWith("https:")?"https:":"http:",this.#n=t,this.#o=e,this.#t=o,this.#s=r,await this.#p()}async checkActivate(){if(!this.#r)throw"checkActi ...
10${n}`:t}function lt(n){return n!=null}var ee="2025-06-18",G={"Access-Control-Allow-Origin":"*"},ne="POST, GET",ut=class{#t;constructor(t){this.#t=t}listTools(){return this.#t.map(t=>({name:t.name,...t.title===void 0?{}:{title:t.title},description:t.description,inputSchema:t.inputSchema,...t.outputSchema===void 0?{}:{outputSchema:t.outputSchema},...t.annotations===void 0?{}:{annotations:t.annotations}}))}async callTool(t,e,o){let r=this.#t.find(s=>s.name===t);if(!r)throw new w(-32602,`Unknown tool: ${t}`);return await r.call(e,o)}},D=class{#t;#e;#n;constructor(t,e){this.#t=t,typeof e=="function ...
13`,{headers:{...G,"Content-Type":"text/event-stream","Cache-Control":"no-cache"}})}function pt(){return new Response(null,{status:405,headers:{...G,Allow:ne}})}function se(n){return typeof n=="string"||typeof n=="number"||n===null?n:null}var H="application/x-ndjson",F=class extends Array{#t;constructor(t){super(),this.#t=t}static get[Symbol.species](){return Array}push(...t){for(let e of t)this.#t?.(e);return super.push(...t)}};function Y(n,t){ie(n,t.reasoning),t.content?n.push({role:"assistant",content:t.content}):t.toolCalls?.length||n.push({role:"assistant",content:""})}function ie(n,t){for( ...
14${JSON.stringify(n.input,null,2)}`}function O(n,t,e,o,r=!1){o&&n.push({role:"tool-result",content:ae(t,e,r),...r?{error:!0}:{}})}function ae
15${t}`}function dt(n,t={}){let e=t.toolDetails??!0,o=t.clientToolNames,r=[];for(let s of n)if(s.role==="assistant"){if(Y(r,s),e)for(let i of s.toolCalls??[])r.push({role:"tool",content:
16`)),i=new F(a=>s({type:"event",event:a}));try{let a=await t(i);s({type:"done",...a.clientToolCalls?.length?{clientToolCalls:a.clientToolCalls}:{}})}catch(a){console.error(a),s({type:"error",message:String(a)})}finally{r.close()}}});return new Response(o,{status:200,headers:{"Content-Type":H,"Cache-Control":"no-cache","Access-Control-Allow-Origin":"*"}})}async askExpert(t,e){let o=e.trim();if(!o)throw"Question is required";let r=this.#N(void 0),s=C(t),i=await this.#R(r,{expert:!0},s),a=this.#i.temperature,l=t.headers.get(K),c=l?Pe(t,l):null;if(c)return await this.#T(t,r,s,c,i,a,o);let u=await t ...
17When answering expert MCP questions, prefer semantic and structured memory under root "${s}" when looking up remembered information.`:"",a=await this.#Z(t,o),l=await this.#et(t,o);return`${r}${i}${a}${l}`}async#Z(t,e){try{let o=await this.#b(t,e),r=z(),s=r?await this
19Semantic memory catalog is unavailable for this session.`}}async#tt(t,e,o,r){let s=await this.#I(t,{root:e,collections:r},o);return s.length?s:await this.#I(t,{collections:r},o)}async#I(t,e,o){let r=await this.#c(t,"/ai/memory/catalog",{kind:"semantic",...e.root?{root:e.root}:{},...e.collections?{collections:e.collections}:
21Structured memory catalog is unavailable for this session.`}}async#F(t,e,o){let r=await this.#c(t,"/ai/memory/catalog",{kind:"structured",...e.root?{root:e.root}:{},...e.collections?{collections:e.collections}:{}},o);return Array.isArray(r.resources)?r.resources:[]}#$(){return this.#i.systemPrompt??this.#e}#nt(){return
23${e??"default"}`}function Pe(n,t){try{let e=d.from(n);return e?`${e.getSub()}
25${t}`:null}catch{return null}}function xt(n,t){return`${n}
Long lines were clipped for display.