PageSourceSearch

https://cpk-research-canvas.vercel.app/_next/static/chunks/2668.a9d2dc8421381889.js

js cpk-research-canvas.vercel.app collected 2026-10-03 06:36:28 UTC 66,902 bytes, 39 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2668],{92668:(e,t,s)=>{s.d(t,{T1:()=>sv,aE:()=>tF,hJ:()=>s_});var o,i=s(26452),a=s(74265);let r="io.modelcontextprotocol/related-task",n=i.Ie(e=>null!==e&&("object"==typeof e||"function"==typeof e)),l=i.KC([i.Yj(),i.ai().int()]),d=i.Yj();i._H({ttl:i.ai().optional(),pollInterval:i.ai().optional()});let c=i.Ik({ttl:i.ai().optional()}),p=i.Ik({taskId:i.Yj()}),u=i._H({progressToken:l.optional(),[r]:p.optional()}),h=i.Ik({_meta:u.optional()}),m=h.extend({task:c.optional()}),g=i.Ik({method:i.Yj(),params:h.loose().optional()}),f=i.Ik({_meta:u.optional()}),_=i.Ik({method:i.Yj(),params:f.loose().optional()}),k=i._H({_meta:u.optional()}),b=i.KC([i.Yj(),i.ai().int()]),y=i.Ik({jsonrpc:i.eu("2.0"),id:b,...g.shape}).strict(),I=e=>y.safeParse(e).success,w=i.Ik({jsonrpc:i.eu("2.0"),..._.shape}).strict(),v=i.Ik({jsonrpc:i.eu("2.0"),id:b,result:k}).strict(),x=e=>v.safeParse(e).success;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(o||(o={}));let q=i.Ik({jsonrpc:i.eu("2.0"),id:b.optional(),error:i.Ik({code:i.ai().int(),message:i.Yj(),data:i.L5().optional()})}).strict(),C=i.KC([y,w,v,q]);i.KC([v,q]);let T=k.strict(),Y=f.extend({requestId:b.optional(),reason:i.Yj().optional()}),H=_.extend({method:i.eu("notifications/cancelled"),params:Y}),j=i.Ik({src:i.Yj(),mimeType:i.Yj().optional(),sizes:i.YO(i.Yj()).optional(),theme:i.k5(["light","dark"]).optional()}),S=i.Ik({icons:i.YO(j).optional()}),R=i.Ik({name:i.Yj(),title:i.Yj().optional()}),E=R.extend({...R.shape,...S.shape,version:i.Yj(),websiteUrl:i.Yj().optional(),description:i.Yj().optional()}),M=i.E$(i.Ik({applyDefaults:i.zM().optional()}),i.g1(i.Yj(),i.L5())),z=i.vk(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,i.E$(i.Ik({form:M.optional(),url:n.optional()}),i.g1(i.Yj(),i.L5()).optional())),P=i._H({list:n.optional(),cancel:n.optional(),requests:i._H({sampling:i._H({createMessage:n.optional()}).optional(),elicitation:i._H({create:n.optional()}).optional()}).optional()}),O=i._H({list:n.optional(),cancel:n.optional(),requests:i._H({tools:i._H({call:n.optional()}).optional()}).optional()}),N=i.Ik({experimental:i.g1(i.Yj(),n).optional(),sampling:i.Ik({context:n.optional(),tools:n.optional()}).optional(),elicitation:z.optional(),roots:i.Ik({listChanged:i.zM().optional()}).optional(),tasks:P.optional(),extensions:i.g1(i.Yj(),n).optional()}),L=h.extend({protocolVersion:i.Yj(),capabilities:N,clientInfo:E}),$=g.extend({method:i.eu("initialize"),params:L}),A=i.Ik({experimental:i.g1(i.Yj(),n).optional(),logging:n.optional(),completions:n.optional(),prompts:i.Ik({listChanged:i.zM().optional()}).optional(),resources:i.Ik({subscribe:i.zM().optional(),listChanged:i.zM().optional()}).optional(),tools:i.Ik({listChanged:i.zM().optional()}).optional(),tasks:O.optional(),extensions:i.g1(i.Yj(),n).optional()}),K=k.extend({protocolVersion:i.Yj(),capabilities:A,serverInfo:E,instructions:i.Yj().optional()}),U=_.extend({method:i.eu("notifications/initialized"),params:f.optional()}),D=g.extend({method:i.eu("ping"),params:h.optional()}),F=i.Ik({progress:i.ai(),total:i.lq(i.ai()),message:i.lq(i.Yj())}),V=i.Ik({...f.shape,...F.shape,progressToken:l}),Q=_.extend({method:i.eu("notifications/progress"),params:V}),B=h.extend({cursor:d.optional()}),W=g.extend({params:B.optional()}),J=k.extend({nextCursor:d.optional()}),Z=i.k5(["working","input_required","completed","failed","cancelled"]),X=i.Ik({taskId:i.Yj(),status:Z,ttl:i.KC([i.ai(),i.ch()]),createdAt:i.Yj(),lastUpdatedAt:i.Yj(),pollInterval:i.lq(i.ai()),statusMessage:i.lq(i.Yj())}),G=k.extend({task:X}),ee=f.merge(X),et=_.extend({method:i.eu("notifications/tasks/status"),params:ee}),es=g.extend({method:i.eu("tasks/get"),params:h.extend({taskId:i.Yj()})}),eo=k.merge(X),ei=g.extend({method:i.eu("tasks/result"),params:h.extend({taskId:i.Yj()})});k.loose();let ea=W.extend({method:i.eu("tasks/list")}),er=J.extend({tasks:i.YO(X)}),en=g.extend({method:i.eu("tasks/cancel"),params:h.extend({taskId:i.Yj()})}
1),el=k.merge(X),ed=i.Ik({uri:i.Yj(),mimeType:i.lq(i.Yj()),_meta:i.g1(i.Yj(),i.L5()).optional()}),ec=ed.extend({text:i.Yj()}),ep=i.Yj().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),eu=ed.extend({blob:ep}),eh=i.k5(["user","assistant"]),em=i.Ik({audience:i.YO(eh).optional(),priority:i.ai().min(0).max(1).optional(),lastModified:a.datetime({offset:!0}).optional()}),eg=i.Ik({...R.shape,...S.shape,uri:i.Yj(),description:i.lq(i.Yj()),mimeType:i.lq(i.Yj()),size:i.lq(i.ai()),annotations:em.optional(),_meta:i.lq(i._H({}))}),ef=i.Ik({...R.shape,...S.shape,uriTemplate:i.Yj(),description:i.lq(i.Yj()),mimeType:i.lq(i.Yj()),annotations:em.optional(),_meta:i.lq(i._H({}))}),e_=W.extend({method:i.eu("resources/list")}),ek=J.extend({resources:i.YO(eg)}),eb=W.extend({method:i.eu("resources/templates/list")}),ey=J.extend({resourceTemplates:i.YO(ef)}),eI=h.extend({uri:i.Yj()}),ew=g.extend({method:i.eu("resources/read"),params:eI}),ev=k.extend({contents:i.YO(i.KC([ec,eu]))}),ex=_.extend({method:i.eu("notifications/resources/list_changed"),params:f.optional()}),eq=g.extend({method:i.eu("resources/subscribe"),params:eI}),eC=g.extend({method:i.eu("resources/unsubscribe"),params:eI}),eT=f.extend({uri:i.Yj()}),eY=_.extend({method:i.eu("notifications/resources/updated"),params:eT}),eH=i.Ik({name:i.Yj(),description:i.lq(i.Yj()),required:i.lq(i.zM())}),ej=i.Ik({...R.shape,...S.shape,description:i.lq(i.Yj()),arguments:i.lq(i.YO(eH)),_meta:i.lq(i._H({}))}),eS=W.extend({method:i.eu("prompts/list")}),eR=J.extend({prompts:i.YO(ej)}),eE=h.extend({name:i.Yj(),arguments:i.g1(i.Yj(),i.Yj()).optional()}),eM=g.extend({method:i.eu("prompts/get"),params:eE}),ez=i.Ik({type:i.eu("text"),text:i.Yj(),annotations:em.optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),eP=i.Ik({type:i.eu("image"),data:ep,mimeType:i.Yj(),annotations:em.optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),eO=i.Ik({type:i.eu("audio"),data:ep,mimeType:i.Yj(),annotations:em.optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),eN=i.Ik({type:i.eu("tool_use"),name:i.Yj(),id:i.Yj(),input:i.g1(i.Yj(),i.L5()),_meta:i.g1(i.Yj(),i.L5()).optional()}),eL=i.Ik({type:i.eu("resource"),resource:i.KC([ec,eu]),annotations:em.optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),e$=eg.extend({type:i.eu("resource_link")}),eA=i.KC([ez,eP,eO,e$,eL]),eK=i.Ik({role:eh,content:eA}),eU=k.extend({description:i.Yj().optional(),messages:i.YO(eK)}),eD=_.extend({method:i.eu("notifications/prompts/list_changed"),params:f.optional()}),eF=i.Ik({title:i.Yj().optional(),readOnlyHint:i.zM().optional(),destructiveHint:i.zM().optional(),idempotentHint:i.zM().optional(),openWorldHint:i.zM().optional()}),eV=i.Ik({taskSupport:i.k5(["required","optional","forbidden"]).optional()}),eQ=i.Ik({...R.shape,...S.shape,description:i.Yj().optional(),inputSchema:i.Ik({type:i.eu("object"),properties:i.g1(i.Yj(),n).optional(),required:i.YO(i.Yj()).optional()}).catchall(i.L5()),outputSchema:i.Ik({type:i.eu("object"),properties:i.g1(i.Yj(),n).optional(),required:i.YO(i.Yj()).optional()}).catchall(i.L5()).optional(),annotations:eF.optional(),execution:eV.optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),eB=W.extend({method:i.eu("tools/list")}),eW=J.extend({tools:i.YO(eQ)}),eJ=k.extend({content:i.YO(eA).default([]),structuredContent:i.g1(i.Yj(),i.L5()).optional(),isError:i.zM().optional()});eJ.or(k.extend({toolResult:i.L5()}));let eZ=m.extend({name:i.Yj(),arguments:i.g1(i.Yj(),i.L5()).optional()}),eX=g.extend({method:i.eu("tools/call"),params:eZ}),eG=_.extend({method:i.eu("notifications/tools/list_changed"),params:f.optional()});i.Ik({autoRefresh:i.zM().default(!0),debounceMs:i.ai().int().nonnegative().default(300)});let e0=i.k5(["debug","info","notice","warning","error","critical","alert","emergency"]),e1=h.extend({level:e0}),e5=g.extend({method:i.eu("logging/setLevel"),params:e1}),e2=f.extend({level:e0,logger:i.Yj().optional(),data:i.L5()}),e3=_.extend({method:i.eu("notifications/message"),params:e2}),e6=i.Ik({name:i.Yj().optional()}),e7=i.Ik({hints:i.YO(e6).optional(),costPriority:i.ai().min(0).max(1).optional(),speedPriority:i.ai().min(0).max(1).optional(),intelligencePriority:i.ai().min(0).max(1).optional()}),e4=i.Ik({mode:i.k5(["auto","required","none"]).optional()}),e8=i.Ik({type:i.eu("tool_result"),toolUseId:i.Yj().describe("The unique identifier for the corresponding tool call."),content:i.YO(eA).default([]),structuredContent:i.Ik({}).loose().optional(),isError:i.zM().optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),e9=i.gM("type",[ez,eP,eO]),te=i.gM("type",[ez,eP,eO,eN,e8]),tt=i.Ik({role:eh,content:i.KC([te,i.YO(te)]),_meta:i.g1(i.Yj(),i.L5()).optional()}),ts=m.extend({messages:i.YO(tt),modelPreferences:e7.optional(),systemPrompt:i.Yj().optional(),includeContext:i.k5(["none","thisServer","allServers"]).optional(),temperature:i.ai().optional(),maxTokens:i.ai().int(),stopSequences:i.YO(i.Yj()).optional(),metadata:n.optional(),tools:i.YO(eQ).optional(),toolChoice:e4.optional()}),to=g.extend({method:i.eu("sampling/createMessage"),params:ts}),ti=k.extend({model:i.Yj(),stopReason:i.lq(i.k5(["endTurn","stopSequence","maxTokens"]).or(i.Yj())),role:eh,content:e9}),ta=k.extend({model:i.Yj(),stopReason:i.lq(i.k5(["endTurn","stopSequence","maxTokens","toolUse"]).or(i.Yj())),role:eh,content:i.KC([te,i.YO(te)])}),tr=i.Ik({type:i.eu("boolean"),title:i.Yj().optional(),description:i.Yj().optional(),default:i.zM().optional()}),tn=i.Ik({type:i.eu("string"),title:i.Yj().optional(),description:i.Yj().optional(),minLength:i.ai().optional(),maxLength:i.ai().optional(),format:i.k5(["email","uri","date","date-time"]).optional(),default:i.Yj().optional()}),tl=i.Ik({type:i.k5(["number","integer"]),title:i.Yj().optional(),description:i.Yj().optional(),minimum:i.ai().optional(),maximum:i.ai().optional(),default:i.ai().optional()}),td=i.Ik({type:i.eu("string"),title:i.Yj().optional(),description:i.Yj().optional(),enum:i.YO(i.Yj()),default:i.Yj().optional()}),tc=i.Ik({type:i.eu("string"),title:i.Yj().optional(),description:i.Yj().optional(),oneOf:i.YO(i.Ik({const:i.Yj(),title:i.Yj()})),default:i.Yj().optional()}),tp=i.Ik({type:i.eu("string"),title:i.Yj().optional(),description:i.Yj().optional(),enum:i.YO(i.Yj()),enumNames:i.YO(i.Yj()).optional(),default:i.Yj().optional()}),tu=i.KC([td,tc]),th=i.Ik({type:i.eu("array"),title:i.Yj().optional(),description:i.Yj().optional(),minItems:i.ai().optional(),maxItems:i.ai().optional(),items:i.Ik({type:i.eu("string"),enum:i.YO(i.Yj())}),default:i.YO(i.Yj()).optional()}),tm=i.Ik({type:i.eu("array"),title:i.Yj().optional(),description:i.Yj().optional(),minItems:i.ai().optional(),maxItems:i.ai().optional(),items:i.Ik({anyOf:i.YO(i.Ik({const:i.Yj(),title:i.Yj()}))}),default:i.YO(i.Yj()).optional()}),tg=i.KC([th,tm]),tf=i.KC([tp,tu,tg]),t_=i.KC([tf,tr,tn,tl]),tk=m.extend({mode:i.eu("form").optional(),message:i.Yj(),requestedSchema:i.Ik({type:i.eu("object"),properties:i.g1(i.Yj(),t_),required:i.YO(i.Yj()).optional()})}),tb=m.extend({mode:i.eu("url"),message:i.Yj(),elicitationId:i.Yj(),url:i.Yj().url()}),ty=i.KC([tk,tb]),tI=g.extend({method:i.eu("elicitation/create"),params:ty}),tw=f.extend({elicitationId:i.Yj()}),tv=_.extend({method:i.eu("notifications/elicitation/complete"),params:tw}),tx=k.extend({action:i.k5(["accept","decline","cancel"]),content:i.vk(e=>null===e?void 0:e,i.g1(i.Yj(),i.KC([i.Yj(),i.ai(),i.zM(),i.YO(i.Yj())])).optional())}),tq=i.Ik({type:i.eu("ref/resource"),uri:i.Yj()}),tC=i.Ik({type:i.eu("ref/prompt"),name:i.Yj()}),tT=h.extend({ref:i.KC([tC,tq]),argument:i.Ik({name:i.Yj(),value:i.Yj()}),context:i.Ik({arguments:i.g1(i.Yj(),i.Yj()).optional()}).optional()}),tY=g.extend({method:i.eu("completion/complete"),params:tT}),tH=k.extend({completion:i._H({values:i.YO(i.Yj()).max(100),total:i.lq(i.ai().int()),hasMore:i.lq(i.zM())})}),tj=i.Ik({uri:i.Yj().startsWith("file://"),name:i.Yj().optional(),_meta:i.g1(i.Yj(),i.L5()).optional()}),tS=g.extend({method:i.eu("roots/list"),params:h.optional()}),tR=k.extend({roots:i.YO(tj)}),tE=_.extend({method:i.eu("notifications/roots/list_changed"),params:f.optional()});i.KC([D,$,tY,e5,eM,eS,e_,eb,ew,eq,eC,eX,eB,es,ei,ea,en]),i.KC([H,Q,U,tE,et]),i.KC([T,ti,ta,tx,tR,eo,er,G]),i.KC([D,to,tI,tS,es,ei,ea,en]),i.KC([H,Q,e3,eY,ex,eG,eD,et,tv]),i.KC([T,K,tH,eU,eR,ek,ey,ev,eJ,eW,eo,er,G]);
1class tM extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,t,s){return e===o.UrlElicitationRequired&&s&&s.elicitations?new tz(s.elicitations,t):new tM(e,t,s)}}class tz extends tM{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(o.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}var tP=s(26950);function tO(e,t){return e._zod?tP.xL(e,t):e.safeParse(t)}function tN(e){return"completed"===e||"failed"===e||"cancelled"===e}function tL(e){let t=function(e){let t;if(e&&(t=e._zod?e._zod?.def?.shape:e.shape)){if("function"==typeof t)try{return t()}catch{return}return t}}(e),s=t?.method;if(!s)throw Error("Schema is missing a method literal");let o=function(e){if(e._zod){let t=e._zod?.def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let s=e.value;if(void 0!==s)return s}(s);if("string"!=typeof o)throw Error("Schema method literal must be a string");return o}function t$(e,t){let s=tO(e,t);if(!s.success)throw s.error;return s.data}s(3181);class tA{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(H,e=>{this._oncancel(e)}),this.setNotificationHandler(Q,e=>{this._onprogress(e)}),this.setRequestHandler(D,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(es,async(e,t)=>{let s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new tM(o.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ei,async(e,t)=>{let s=async()=>{let i=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(i,t.sessionId);){if("response"===e.type||"error"===e.type){let t=e.message,s=t.id,o=this._requestResolvers.get(s);if(o)this._requestResolvers.delete(s),o("response"===e.type?t:new tM(t.error.code,t.error.message,t.error.data));else{let t="response"===e.type?"Response":"Error";this._onerror(Error(`${t} handler missing for request ${s}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let a=await this._taskStore.getTask(i,t.sessionId);if(!a)throw new tM(o.InvalidParams,`Task not found: ${i}`);if(!tN(a.status))return await this._waitForTaskUpdate(i,t.signal),await s();if(tN(a.status)){let e=await this._taskStore.getTaskResult(i,t.sessionId);return this._clearTaskQueue(i),{...e,_meta:{...e._meta,[r]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(ea,async(e,t)=>{try{let{tasks:s,nextCursor:o}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:s,nextCursor:o,_meta:{}}}catch(e){throw new tM(o.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(en,async(e,t)=>{try{let s=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!s)throw new tM(o.InvalidParams,`Task not found: ${e.params.taskId}`);if(tN(s.status))throw new tM(o.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);let i=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!i)throw new tM(o.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...i}}catch(e){if(e instanceof tM)throw e;throw new tM(o.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;let t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,s,o,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),tM.fromError(o.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error("Already connected to a transport. C
1all close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let s=this.transport?.onerror;this._transport.onerror=e=>{s?.(e),this._onerror(e)};let o=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{if(o?.(e,t),x(e)||q.safeParse(e).success)this._onresponse(e);else if(I(e))this._onrequest(e,t);else w.safeParse(e).success?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;for(let e of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(e.timeoutId);for(let e of(this._timeoutInfo.clear(),this._requestHandlerAbortControllers.values()))e.abort();this._requestHandlerAbortControllers.clear();let t=tM.fromError(o.ConnectionClosed,"Connection closed");for(let s of(this._transport=void 0,this.onclose?.(),e.values())
1)s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let s,i=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,a=this._transport,n=e.params?._meta?.[r]?.taskId;if(void 0===i){let t={jsonrpc:"2.0",id:e.id,error:{code:o.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:t,timestamp:Date.now()},a?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):a?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let d=(s=e.params,m.safeParse(s).success)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,a?.sessionId):void 0,p={signal:l.signal,sessionId:a?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(l.signal.aborted)return;let s={relatedRequestId:e.id};n&&(s.relatedTask={taskId:n}),await this.notification(t,s)},sendRequest:async(t,s,i)=>{if(l.signal.aborted)throw new tM(o.ConnectionClosed,"Request was cancelled");let a={...i,relatedRequestId:e.id};n&&!a.relatedTask&&(a.relatedTask={taskId:n});let r=a.relatedTask?.taskId??n;return r&&c&&await c.updateTaskStatus(r,"input_required"),await this.request(t,s,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:n,taskStore:c,taskRequestedTtl:d?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{d&&this.assertTaskHandlerCapability(e.method)}).then(()=>i(e,p)).then(async t=>{if(l.signal.aborted)return;let s={result:t,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:s,timestamp:Date.now()},a?.sessionId):await a?.send(s)},async t=>{if(l.signal.aborted)return;let s={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:o.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:s,timestamp:Date.now()},a?.sessionId):await a?.send(s)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===l&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...s}=e.params,o=Number(t),i=this._progressHandlers.get(o);if(!i)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));let a=this._responseHandlers.get(o),r=this._timeoutInfo.get(o);if(r&&a&&r.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(e){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(e);return}i(s)}_onresponse(e){let t=Number(e.id),s=this._requestResolvers.get(t);if(s){this._requestResolvers.delete(t),s(x(e)?e:new tM(e.error.code,e.error.message,e.error.data));return}let o=this._responseHandlers.get(t);if(void 0===o)return void this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(x(e)&&e.result&&"object"==typeof e.result){let s=e.result;if(s.task&&"object"==typeof s.task){let e=s.task;"string"==typeof e.taskId&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),o(x(e)?e:tM.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async *requestStream(e,t,s){let i,{task:a}=s??{};if(!a){try{let o=await this.request(e,t,s);yield{type:"result",result:o}}catch(e){yield{type:"error",error:e instanceof tM?e:new tM(o.InternalError,String(e))}}return}try{let a=await this.request(e,G,s);if(a.task)i=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new tM(o.InternalError,"Task creation did not return a task");for(;;){let e=await this.getTask({taskId:i},s);if(yield{type:"taskStatus",task:e},tN(e.status)){if("completed"===e.status){let e=await this.getTaskResult({taskId:i},t,s);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new tM(o.InternalError,`Task ${i} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new tM(o.InternalError,`Task ${i} was cancelled`)});return}if("input_required"===e.status){let e=await this.getTaskResult({taskId:i},t,s);yield{type:"result",result:e};return}let a=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,a)),s?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof tM?e:new tM(o.InternalError,String(e))}}}request(e,t,s){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:n,task:l,relatedTask:d}=s??{};return new Promise((c,p)=>{let u=e=>{p(e)};if(!this._transport)return void u(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),l&&this.assertTaskCapability(e.method)}catch(e){u(e);return}s?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:h};s?.onprogress&&(this._progressHandlers.set(h,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),l&&(m.params={...m.params,task:l}),d&&(m.params={...m.params,_meta:{...m.params?._meta||{},[r]:d}});let g=e=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(e)}},{relatedRequestId:i,resumptionToken:a,onresumptiontoken:n}).catch(e=>
1this._onerror(Error(`Failed to send cancellation: ${e}`))),p(e instanceof tM?e:new tM(o.RequestTimeout,String(e)))};this._responseHandlers.set(h,e=>{if(!s?.signal?.aborted){if(e instanceof Error)return p(e);try{let s=tO(t,e.result);s.success?c(s.data):p(s.error)}catch(e){p(e)}}}),s?.signal?.addEventListener("abort",()=>{g(s?.signal?.reason)});let f=s?.timeout??6e4;this._setupTimeout(h,f,s?.maxTotalTimeout,()=>g(tM.fromError(o.RequestTimeout,"Request timed out",{timeout:f})),s?.resetTimeoutOnProgress??!1);let _=d?.taskId;if(_){let e=e=>{let t=this._responseHandlers.get(h);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,e),this._enqueueTaskMessage(_,{type:"request",message:m,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(h),p(e)})}else this._transport.send(m,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:n}).catch(e=>{this._cleanupTimeout(h),p(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},eo,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},er,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},el,t)}async notification(e,t){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(e.method);let s=t?.relatedTask?.taskId;if(s){let o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[r]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:o,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};t?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[r]:t.relatedTask}}}),this._transport?.send(s,t).catch(e=>this._onerror(e))});return}let o={...e,jsonrpc:"2.0"};t?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[r]:t.relatedTask}}}),await this._transport.send(o,t)}setRequestHandler(e,t){let s=tL(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(s,o)=>Promise.resolve(t(t$(e,s),o)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let s=tL(e);this._notificationHandlers.set(s,s=>Promise.resolve(t(t$(e,s))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,o)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){for(let s of(await this._taskMessageQueue.dequeueAll(e,t)))if("request"===s.type&&I(s.message)){let t=s.message.id,i=this._requestResolvers.get(t);i?(i(new tM(o.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(t)):this._onerror(Error(`Resolver missing for request ${t} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(s=t.pollInterval)}catch{}return new Promise((e,i)=>{if(t.aborted)return void i(new tM(o.InvalidRequest,"Request cancelled"));let a=setTimeout(e,s);t.addEventListener("abort",()=>{clearTimeout(a),i(new tM(o.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){let s=this._taskStore;if(!s)throw Error("No task store configured");return{createTask:async o=>{if(!e)throw Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let i=await s.getTask(e,t);if(!i)throw new tM(o.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(e,o,i)=>{await s.storeTaskResult(e,o,i,t);let a=await s.getTask(e,t);if(a){let t=et.parse({method:"notifications/tasks/status",params:a});await this.notification(t),tN(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>s.getTaskResult(e,t),updateTaskStatus:async(e,i,a)=>{let r=await s.getTask(e,t);if(!r)throw new tM(o.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(tN(r.status))throw new tM(o.InvalidParams,`Cannot update task "${e}" from terminal status "${r.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(e,i,a,t);let n=await s.getTask(e,t);if(n){let t=et.parse({method:"notifications/tasks/status",params:n});await this.notification(t),tN(n.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>s.listTasks(e,t)}}}function tK(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var tU=s(13452);"u">typeof require?require:"u">typeof Proxy&&new Proxy(function(e){if("u">typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},{get:(e,t)=>("u">typeof require?require:e)[t]});class tD extends tA{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let s=this.eventSchemas[e];if(!s)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let o=s.shape.method.value;this._registeredMethods.add(o);let i=t;super.setNotificationHandler(s,t=>{let s=t.params;for(let t of(this.onEventDispatch(e,s),i.onHandler?.(s),[...i.listeners]))t(s)})}return t}setEventHandler(e,t){let s=this._ensureEventSlot(e);s.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),s.onHandler=t}getEventHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let s=this._eventSlots.get(e);if(!s)return;let o=s.listeners.indexOf(t);-1!==o&&s.listeners.splice(o,1)}setRequestHandler=(e,t)=>{this._assertMethodNotRegistered(e,"setRequestHandler"),super.setRequestHandler(e,t)};
1setNotificationHandler=(e,t)=>{this._assertMethodNotRegistered(e,"setNotificationHandler"),super.setNotificationHandler(e,t)};warnIfRequestHandlerReplaced(e,t,s){t&&s&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(e,t)=>{let s=e.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(e,t)};_assertMethodNotRegistered(e,t){let s=e.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var tF="2026-01-26",tV=i.KC([i.eu("light"),i.eu("dark")]).describe("Color theme preference for the host environment."),tQ=i.KC([i.eu("inline"),i.eu("fullscreen"),i.eu("pip")]).describe("Display mode for UI presentation."),tB=i.KC([i.eu("--color-background-primary"),i.eu("--color-background-secondary"),i.eu("--color-background-tertiary"),i.eu("--color-background-inverse"),i.eu("--color-background-ghost"),i.eu("--color-background-info"),i.eu("--color-background-danger"),i.eu("--color-background-success"),i.eu("--color-background-warning"),i.eu("--color-background-disabled"),i.eu("--color-text-primary"),i.eu("--color-text-secondary"),i.eu("--color-text-tertiary"),i.eu("--color-text-inverse"),i.eu("--color-text-ghost"),i.eu("--color-text-info"),i.eu("--color-text-danger"),i.eu("--color-text-success"),i.eu("--color-text-warning"),i.eu("--color-text-disabled"),i.eu("--color-border-primary"),i.eu("--color-border-secondary"),i.eu("--color-border-tertiary"),i.eu("--color-border-inverse"),i.eu("--color-border-ghost"),i.eu("--color-border-info"),i.eu("--color-border-danger"),i.eu("--color-border-success"),i.eu("--color-border-warning"),i.eu("--color-border-disabled"),i.eu("--color-ring-primary"),i.eu("--color-ring-secondary"),i.eu("--color-ring-inverse"),i.eu("--color-ring-info"),i.eu("--color-ring-danger"),i.eu("--color-ring-success"),i.eu("--color-ring-warning"),i.eu("--font-sans"),i.eu("--font-mono"),i.eu("--font-weight-normal"),i.eu("--font-weight-medium"),i.eu("--font-weight-semibold"),i.eu("--font-weight-bold"),i.eu("--font-text-xs-size"),i.eu("--font-text-sm-size"),i.eu("--font-text-md-size"),i.eu("--font-text-lg-size"),i.eu("--font-heading-xs-size"),i.eu("--font-heading-sm-size"),i.eu("--font-heading-md-size"),i.eu("--font-heading-lg-size"),i.eu("--font-heading-xl-size"),i.eu("--font-heading-2xl-size"),i.eu("--font-heading-3xl-size"),i.eu("--font-text-xs-line-height"),i.eu("--font-text-sm-line-height"),i.eu("--font-text-md-line-height"),i.eu("--font-text-lg-line-height"),i.eu("--font-heading-xs-line-height"),i.eu("--font-heading-sm-line-height"),i.eu("--font-heading-md-line-height"),i.eu("--font-heading-lg-line-height"),i.eu("--font-heading-xl-line-height"),i.eu("--font-heading-2xl-line-height"),i.eu("--font-heading-3xl-line-height"),i.eu("--border-radius-xs"),i.eu("--border-radius-sm"),i.eu("--border-radius-md"),i.eu("--border-radius-lg"),i.eu("--border-radius-xl"),i.eu("--border-radius-full"),i.eu("--border-width-regular"),i.eu("--shadow-hairline"),i.eu("--shadow-sm"),i.eu("--shadow-md"),i.eu("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),tW=i.g1(tB.describe(`Style variables for theming MCP apps.
2
3Individual style keys are optional - hosts may provide any subset of these values.
4Values are strings containing CSS values (colors, sizes, font stacks, etc.).
5
6Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
7for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),i.KC([i.Yj(),i.Vx()]).describe(`Style variables for theming MCP apps.
8
9Individual style keys are optional - hosts may provide any subset of these values.
10Values are strings containing CSS values (colors, sizes, font stacks, etc.).
11
12Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
13for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
14
15Individual style keys are optional - hosts may provide any subset of these values.
16Values are strings containing CSS values (colors, sizes, font stacks, etc.).
17
18Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
19for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),tJ=i.Ik({method:i.eu("ui/open-link"),params:i.Ik({url:i.Yj().describe("URL to open in the host's browser")})}),tZ=i.Ik({isError:i.zM().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),tX=i.Ik({isError:i.zM().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),tG=i.Ik({isError:i.zM().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),t0=i.Ik({method:i.eu("ui/notifications/sandbox-proxy-ready"),params:i.Ik({})}),t1=i.Ik({connectDomains:i.YO(i.Yj()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
20
21- Maps to CSP \`connect-src\` directive
22- Empty or omitted → no network connections (secure default)`),resourceDomains:i.YO(i.Yj()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:i.YO(i.Yj()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-sr
22c` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:i.YO(i.Yj()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),t5=i.Ik({camera:i.Ik({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:i.Ik({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:i.Ik({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:i.Ik({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),t2=i.Ik({method:i.eu("ui/notifications/size-changed"),params:i.Ik({width:i.ai().optional().describe("New width in pixels."),height:i.ai().optional().describe("New height in pixels.")})}),t3=i.Ik({method:i.eu("ui/notifications/tool-input"),params:i.Ik({arguments:i.g1(i.Yj(),i.L5().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),t6=i.Ik({method:i.eu("ui/notifications/tool-input-partial"),params:i.Ik({arguments:i.g1(i.Yj(),i.L5().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),t7=i.Ik({method:i.eu("ui/notifications/tool-cancelled"),params:i.Ik({reason:i.Yj().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),t4=i.Ik({fonts:i.Yj().optional()}),t8=i.Ik({variables:tW.optional().describe("CSS variables for theming the app."),css:t4.optional().describe("CSS blocks that apps can inject.")}),t9=i.Ik({method:i.eu("ui/resource-teardown"),params:i.Ik({})}),se=i.g1(i.Yj(),i.L5()),st=i.Ik({text:i.Ik({}).optional().describe("Host supports text content blocks."),image:i.Ik({}).optional().describe("Host supports image content blocks."),audio:i.Ik({}).optional().describe("Host supports audio content blocks."),resource:i.Ik({}).optional().describe("Host supports resource content blocks."),resourceLink:i.Ik({}).optional().describe("Host supports resource link content blocks."),structuredContent:i.Ik({}).optional().describe("Host supports structured content.")}),ss=i.Ik({method:i.eu("ui/notifications/request-teardown"),params:i.Ik({}).optional()}),so=i.Ik({experimental:i.g1(i.Yj(),i.g1(i.Yj(),i.bz()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:i.Ik({}).optional().describe("Host supports opening external URLs."),downloadFile:i.Ik({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:i.Ik({listChanged:i.zM().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:i.Ik({listChanged:i.zM().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:i.Ik({}).optional().describe("Host accepts log messages."),sandbox:i.Ik({permissions:t5.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:t1.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:st.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:st.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:i.Ik({tools:i.Ik({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),si=i.Ik({experimental:i.g1(i.Yj(),i.g1(i.Yj(),i.bz()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:i.Ik({listChanged:i.zM().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:i.YO(tQ).optional().describe("Display modes the app supports.")}),sa=i.Ik({method:i.eu("ui/notifications/initialized"),params:i.Ik({}).optional()}),sr=(i.Ik({csp:t1.optional().describe("Content Security Policy configuration for UI resources."),permissions:t5.optional().describe("Sandbox permissions requested by the UI resource."),domain:i.Yj().optional().describe(`Dedicated origin for view sandbox.
23
24Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
25
26**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
27- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
28- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
29
30If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:i.zM().optional().describe(`Visual boundary preference - true if view prefers a visible border.
31
32Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
33
34- \`true\`: request visible border + background
35- \`false\`: request no visible border + background
36- omitted: host decides border`)}),i.Ik({method:i.eu("ui/request-display-mode"),params:i.Ik({mode:tQ.describe("The display mode being requested.")})})),sn=i.Ik({mode:tQ.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),sl=i.KC([i.eu("model"),i.eu("app")]).describe("Tool visibility scope - who can access the tool."),sd=(i.Ik({resourceUri:i.Yj().optional(),visibility:i.YO(sl).optional().describe(`Who can access this tool. Default: ["model", "app"]
37- "model": Tool visible to and callable by the agent
38- "app": Tool callable by the app from this server only`),csp:i.Zm().optional(),permissions:i.Zm().optional()}),i.Ik({mimeTypes:i.YO(i.Yj()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),i.Ik({method:i.eu("ui/download-file"),params:i.Ik({contents:i.YO(i.KC([eL,e$])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})})),sc=i.Ik({method:i.eu("ui/message"),params:i.Ik({role:i.eu("user").describe('Message role, currently only "user" is supported.'),content:i.YO(eA).describe("Message content blocks (text, image, etc.).")})}),sp=(i.Ik({method:i.eu("ui/notifications/sandbox-resource-ready"),params:i.Ik({html:i.Yj().describe("HTML content to load into the inner iframe."),sandbox:i.Yj().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:t1.optional().describe("CSP configuration from resource metadata."),permissions:t5.optional().describe("Sandbox permissions from resource metadata.")})}),i.Ik({method:i.eu("ui/notifications/tool-result"),params:eJ.describe("Standard MCP tool execution result.")})),su=i.Ik({toolInfo:i.Ik({id:b.optional().describe("JSON-RPC id of the tools/call request."),tool:eQ.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:tV.optional().describe("Current color theme preference."),styles:t8.optional().describe("Style configuration for theming the app."),displayMode:tQ.optional().describe("How the UI is currently displayed."),availableDisplayModes:i.YO(tQ).optional().describe("Display modes the host supports."),containerDimensions:i.KC([i.Ik({height:i.ai().describe("Fixed container height in pixels.")}),i.Ik({maxHeight:i.KC([i.ai(),i.Vx()]).optional().describe("Maximum container height in pixels.")})]).and(i.KC([i.Ik({width:i.ai().describe("Fixed container width in pixels.")}),i.Ik({maxWidth:i.KC([i.ai(),i.Vx()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
39container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:i.Yj().optional().describe("User's language and region preference in BCP 47 format."),timeZone:i.Yj().optional().describe("User's timezone in IANA format."),userAgent:i.Yj().optional().describe("Host application identifier."),platform:i.KC([i.eu("web"),i.eu("desktop"),i.eu("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:i.Ik({touch:i.zM().optional().describe("Whether the device supports touch input."),hover:i.zM().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:i.Ik({top:i.ai().describe("Top safe area inset in pixels."),right:i.ai().describe("Right safe area inset in pixels."),bottom:i.ai().describe("Bottom safe area inset in pixels."),left:i.ai().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),sh=i.Ik({method:i.eu("ui/notifications/host-context-changed"),params:su.describe("Partial context update containing only changed fields.")}),sm=i.Ik({method:i.eu("ui/update-model-context"),params:i.Ik({content:i.YO(eA).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:i.g1(i.Yj(),i.L5().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),sg=i.Ik({method:i.eu("ui/initialize"),params:i.Ik({appInfo:E.describe("App identification (name and version)."),appCapabilities:si.describe("Features and capabilities this app provides."),protocolVersion:i.Yj().describe("Protocol version this app supports.")})}),sf=i.Ik({protocolVersion:i.Yj().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:E.describe("Host application identification and version."),hostCapabilities:so.describe("Features and capabilities provided by the host."),hostContext:su.describe("Rich context about the host environment.")}).passthrough();class s_{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource)return void console.debug("Ignoring message from unknown source",e);let s=C.safeParse(e.data);s.success?(console.debug("Parsed message",s.data),this.onmessage?.(s.data)):e.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",s.error.message,e):(console.error("Failed to parse message",s.error.message,e),this.onerror?.(Error("Invalid JSON-RPC message received: "+s.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){"ui/notifications/tool-input-partial"!==e.method&&console.debug("Sending message",e),this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}
39var sk={target:"draft-2020-12"};async function sb(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](sk);if("zod"===o.vendor){let{z:o}=await s.e(7877).then(s.bind(s,57877));return o.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function sy(e,t,s=""){let o=await e["~standard"].validate(t);if(o.issues)throw Error(s+o.issues.map(e=>{let t=e.path?.map(e=>"object"==typeof e?e.key:e).join(".");return t?`${t}: ${e.message}`:e.message}).join("; "));return o.value}class sI extends tD{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:t3,toolinputpartial:t6,toolresult:sp,toolcancelled:t7,hostcontextchanged:sh};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!sI.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){"hostcontextchanged"===e&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},s={autoResize:!0}){super(s),this._appInfo=e,this._capabilities=t,this.options=s,s.allowUnsafeEval||tU.$W({jitless:!0}),this.setRequestHandler(D,e=>(console.log("Received ping:",e.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=function(e,t){let s={...e};for(let e in t){let o=t[e];if(void 0===o)continue;let i=s[e];tK(i)&&tK(o)?s[e]={...i,...o}:s[e]=o}return s}(this._capabilities,e)}registerTool(e,t,s){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let o=this,i=()=>{o._initializedSent&&o._capabilities.tools?.listChanged&&o.sendToolListChanged()},a=void 0!==t.inputSchema,r={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){o._registeredTools[e]===r&&(delete o._registeredTools[e],i())},handler:async(t,o)=>{let i;if(!r.enabled)throw Error(`Tool ${e} is disabled`);if(a){let a=r.inputSchema,n=a?await sy(a,t??{},`Invalid input for tool ${e}: `):t??{};i=await s(n,o)}else i=await s(o);return r.outputSchema&&!i.isError&&(i.structuredContent=await sy(r.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=r,this._capabilities.tools||this.transport||this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),r}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let s=this._registeredTools[e.name];if(!s)throw Error(`Tool ${e.name} not found`);return s.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let s={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await sb(t.inputSchema,"input"):{type:"object",properties:{}}};
39return t.outputSchema&&(s.outputSchema=await sb(t.outputSchema,"output")),t.annotations&&(s.annotations=t.annotations),t._meta&&(s._meta=t._meta),s}))}))}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(t9,(e,t)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(eX,(e,t)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(eB,(e,t)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if("sampling/createMessage"===e&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(e){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),"string"==typeof e)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},eJ,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},ev,t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},ek,t)}async createSamplingMessage(e,t){this._assertInitialized("createSamplingMessage");let s=e.tools?ta:ti;return await this.request({method:"sampling/createMessage",params:e},s,t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},tG,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},T,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},tZ,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},tX,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},sn,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,s=0,o=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let o=document.documentElement,i=o.style.height;o.style.height="max-content";let a=Math.ceil(o.getBoundingClientRect().height);o.style.height=i;let r=Math.ceil(window.innerWidth);(r!==t||a!==s)&&(t=r,s=a,this.sendSizeChanged({width:r,height:a}))}))};o();let i=new ResizeObserver(o);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new s_(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(e);try{let e=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:tF}},sf,t);if(void 0===e)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}}var sw=[tF];class sv extends tD{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(e,t)=>{this._baseReplaceRequestHandler(e,(e,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),t(e,s)))};eventSchemas={sizechange:t2,sandboxready:t0,initialized:sa,requestteardown:ss,loggingmessage:e3};constructor(e,t,s,o){super(o),this._client=e,this._hostInfo=t,this._capabilities=s,this.addEventListener("initialized",()=>{this._initializedReceived=!0}
39),this._hostContext=o?.hostContext||{},this.setRequestHandler(sg,e=>this._oninitialize(e)),this.setRequestHandler(D,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(sr,e=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(e){this.setEventHandler("sizechange",e)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(e){this.setEventHandler("sandboxready",e)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(e){this.setEventHandler("initialized",e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(sc,async(e,t)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(e.params,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(tJ,async(e,t)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(e.params,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(sd,async(e,t)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(e.params,t)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(e){this.setEventHandler("requestteardown",e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(sr,async(e,t)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(e.params,t)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(e){this.setEventHandler("loggingmessage",e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(sm,async(e,t)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(eX,async(e,t)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(to,async(t,s)=>e(t.params,s))}sendToolListChanged(e={}){return this.notification({method:"notifications/tools/list_changed",params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(e_,async(e,t)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(eb,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(ew,async(e,t)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:"notifications/resources/list_changed",params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(eS,async(e,t)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:"notifications/prompts/list_changed",params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(e){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return void 0!==this._appInfo&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:sw.includes(t)?t:tF,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},s=!1;for(let a of Object.keys(e)){var o,i;let r=this._hostContext[a],n=e[a];o=r,i=n,JSON.stringify(o)!==JSON.stringify(i)&&(t[a]=n,s=!0)}s&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:"ui/notifications/host-context-changed",params:e})}sendToolInput(e){return this.notification({method:"ui/notifications/tool-input",params:e})}sendToolInputPartial(e){return this.notification({method:"ui/notifications/tool-input-partial",params:e})}sendToolResult(e){return this.notification({method:"ui/notifications/tool-result",params:e})}sendToolCancelled(e){return this.notification({method:"ui/notifications/tool-cancelled",params:e})}sendSandboxResourceReady(e){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:e})}
39teardownResource(e,t){return this.request({method:"ui/resource-teardown",params:e},se,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:"tools/call",params:e},eJ,t)}listTools(e,t){return this.request({method:"tools/list",params:e},eW,t)}async connect(e){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error("Client server capabilities not available");e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:"tools/call",params:e},eJ,{signal:t.signal}),e.tools.listChanged)&&this._client.setNotificationHandler(eG,e=>this.sendToolListChanged(e.params)),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:"resources/list",params:e},ek,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:"resources/templates/list",params:e},ey,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:"resources/read",params:e},ev,{signal:t.signal}),e.resources.listChanged)&&this._client.setNotificationHandler(ex,e=>this.sendResourceListChanged(e.params)),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:"prompts/list",params:e},eR,{signal:t.signal}),e.prompts.listChanged)&&this._client.setNotificationHandler(eD,e=>this.sendPromptListChanged(e.params))}return super.connect(e)}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.