ue-mcp-tripo 0.2.1 → 0.2.2
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/dist/ui/settings.html +1 -1
- package/package.json +1 -1
package/dist/ui/settings.html
CHANGED
|
@@ -174,7 +174,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
174
174
|
- omitted: host decides border`)}),Fb=u.object({method:u.literal("ui/request-display-mode"),params:u.object({mode:Gt.describe("The display mode being requested.")})}),cb=u.object({mode:Gt.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),mb=u.union([u.literal("model"),u.literal("app")]).describe("Tool visibility scope - who can access the tool."),Wb=u.object({resourceUri:u.string().optional(),visibility:u.array(mb).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
175
175
|
- "model": Tool visible to and callable by the agent
|
|
176
176
|
- "app": Tool callable by the app from this server only`),csp:u.never().optional(),permissions:u.never().optional()}),Kb=u.object({mimeTypes:u.array(u.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Vb=u.object({method:u.literal("ui/download-file"),params:u.object({contents:u.array(u.union([tp,ip])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Bb=u.object({method:u.literal("ui/message"),params:u.object({role:u.literal("user").describe('Message role, currently only "user" is supported.'),content:u.array(ln).describe("Message content blocks (text, image, etc.).")})}),Gb=u.object({method:u.literal("ui/notifications/sandbox-resource-ready"),params:u.object({html:u.string().describe("HTML content to load into the inner iframe."),sandbox:u.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:vl.optional().describe("CSP configuration from resource metadata."),permissions:hl.optional().describe("Sandbox permissions from resource metadata.")})}),pb=u.object({method:u.literal("ui/notifications/tool-result"),params:qr.describe("Standard MCP tool execution result.")}),up=u.object({toolInfo:u.object({id:nn.optional().describe("JSON-RPC id of the tools/call request."),tool:gl.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:X$.optional().describe("Current color theme preference."),styles:sb.optional().describe("Style configuration for theming the app."),displayMode:Gt.optional().describe("How the UI is currently displayed."),availableDisplayModes:u.array(Gt).optional().describe("Display modes the host supports."),containerDimensions:u.union([u.object({height:u.number().describe("Fixed container height in pixels.")}),u.object({maxHeight:u.union([u.number(),u.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(u.union([u.object({width:u.number().describe("Fixed container width in pixels.")}),u.object({maxWidth:u.union([u.number(),u.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
177
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:u.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:u.string().optional().describe("User's timezone in IANA format."),userAgent:u.string().optional().describe("Host application identifier."),platform:u.union([u.literal("web"),u.literal("desktop"),u.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:u.object({touch:u.boolean().optional().describe("Whether the device supports touch input."),hover:u.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:u.object({top:u.number().describe("Top safe area inset in pixels."),right:u.number().describe("Right safe area inset in pixels."),bottom:u.number().describe("Bottom safe area inset in pixels."),left:u.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fb=u.object({method:u.literal("ui/notifications/host-context-changed"),params:up.describe("Partial context update containing only changed fields.")}),Xb=u.object({method:u.literal("ui/update-model-context"),params:u.object({content:u.array(ln).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:u.record(u.string(),u.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Yb=u.object({method:u.literal("ui/initialize"),params:u.object({appInfo:Mr.describe("App identification (name and version)."),appCapabilities:db.describe("Features and capabilities this app provides."),protocolVersion:u.string().describe("Protocol version this app supports.")})}),gb=u.object({protocolVersion:u.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Mr.describe("Host application identification and version."),hostCapabilities:lb.describe("Features and capabilities provided by the host."),hostContext:up.describe("Rich context about the host environment.")}).passthrough(),vb={target:"draft-2020-12"};async function Bl(e,i){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[i](vb);if(n.vendor==="zod"){let{z:a}=await Promise.resolve().then(()=>(Rr(),qm));return a.toJSONSchema(e,{io:i})}throw Error(`Schema (vendor: ${n.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 Gl(e,i,n=""){let a=await e["~standard"].validate(i);if(a.issues){let t=a.issues.map(r=>{let o=r.path?.map(s=>typeof s=="object"?s.key:s).join(".");return o?`${o}: ${r.message}`:r.message}).join("; ");throw Error(n+t)}return a.value}Rr();function lp(e){let i=document.documentElement;i.setAttribute("data-theme",e),i.style.colorScheme=e}function dp(e,i=document.documentElement){for(let[n,a]of Object.entries(e))a!==void 0&&i.style.setProperty(n,a)}function cp(e){if(document.getElementById("__mcp-host-fonts"))return;let i=document.createElement("style");i.id="__mcp-host-fonts",i.textContent=e,document.head.appendChild(i)}var Cn=class Cn extends ta{constructor(n,a={},t={autoResize:!0}){super(t);D(this,"_appInfo");D(this,"_capabilities");D(this,"options");D(this,"_hostCapabilities");D(this,"_hostInfo");D(this,"_hostContext");D(this,"_registeredTools",{});D(this,"_initializedSent",!1);D(this,"eventSchemas",{toolinput:nb,toolinputpartial:rb,toolresult:pb,toolcancelled:ab,hostcontextchanged:fb});D(this,"_everHadListener",new Set);D(this,"_toolHandlersInitialized",!1);D(this,"_onteardown");D(this,"_oncalltool");D(this,"_onlisttools");D(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=a,this.options=t,t.allowUnsafeEval||u.config({jitless:!0}),this.setRequestHandler(Lr,r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}_assertInitialized(n){if(this._initializedSent)return;let a=`[ext-apps] App.${n}() 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(a);console.warn(`${a}. This will throw in a future release.`)}_assertHandlerTiming(n){if(!Cn.ONE_SHOT_EVENTS.has(n)||this._everHadListener.has(n)||(this._everHadListener.add(n),!this._initializedSent))return;let a=`[ext-apps] "${String(n)}" 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(a);console.warn(a)}setEventHandler(n,a){a&&this._assertHandlerTiming(n),super.setEventHandler(n,a)}addEventListener(n,a){this._assertHandlerTiming(n),super.addEventListener(n,a)}onEventDispatch(n,a){n==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...a})}registerCapabilities(n){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=V$(this._capabilities,n)}registerTool(n,a,t){if(this._registeredTools[n])throw Error(`Tool ${n} is already registered`);let r=this,o=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},s=a.inputSchema!==void 0,l={title:a.title,description:a.description,inputSchema:a.inputSchema,outputSchema:a.outputSchema,annotations:a.annotations,_meta:a._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(d){Object.assign(this,d),o()},remove(){r._registeredTools[n]===l&&(delete r._registeredTools[n],o())},handler:async(d,c)=>{if(!l.enabled)throw Error(`Tool ${n} is disabled`);let f;if(s){let g=l.inputSchema,_=g?await Gl(g,d??{},`Invalid input for tool ${n}: `):d??{};f=await t(_,c)}else f=await t(c);return l.outputSchema&&!f.isError&&(f.structuredContent=await Gl(l.outputSchema,f.structuredContent,`Invalid output for tool ${n}: `)),f}};return this._registeredTools[n]=l,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),l}ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(n,a)=>{let t=this._registeredTools[n.name];if(!t)throw Error(`Tool ${n.name} not found`);return t.handler(n.arguments,a)},this.onlisttools=async(n,a)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([t,r])=>r.enabled).map(async([t,r])=>{let o={name:t,title:r.title,description:r.description,inputSchema:r.inputSchema?await Bl(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(o.outputSchema=await Bl(r.outputSchema,"output")),r.annotations&&(o.annotations=r.annotations),r._meta&&(o._meta=r._meta),o}))}))}async sendToolListChanged(n={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:n})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(n){this.setEventHandler("toolinput",n)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(n){this.setEventHandler("toolinputpartial",n)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(n){this.setEventHandler("toolresult",n)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(n){this.setEventHandler("toolcancelled",n)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(n){this.setEventHandler("hostcontextchanged",n)}get onteardown(){return this._onteardown}set onteardown(n){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,n),this._onteardown=n,this.replaceRequestHandler(ub,(a,t)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(a.params,t)})}get oncalltool(){return this._oncalltool}set oncalltool(n){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,n),this._oncalltool=n,this.replaceRequestHandler(rp,(a,t)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(a.params,t)})}get onlisttools(){return this._onlisttools}set onlisttools(n){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,n),this._onlisttools=n,this.replaceRequestHandler(np,(a,t)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(a.params,t)})}assertCapabilityForMethod(n){switch(n){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${n})`);break}}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,a){if(this._assertInitialized("callServerTool"),typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},qr,{onprogress:()=>{},resetTimeoutOnProgress:!0,...a})}async readServerResource(n,a){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:n},ep,a)}async listServerResources(n,a){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:n},Qm,a)}async createSamplingMessage(n,a){this._assertInitialized("createSamplingMessage");let t=n.tools?sp:op;return await this.request({method:"sampling/createMessage",params:n},t,a)}sendMessage(n,a){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:n},ib,a)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,a){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:n},el,a)}openLink(n,a){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:n},eb,a)}downloadFile(n,a){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:n},tb,a)}requestTeardown(n={}){return this.notification({method:"ui/notifications/request-teardown",params:n})}requestDisplayMode(n,a){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:n},cb,a)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,a=0,t=0,r=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let s=document.documentElement,l=s.style.height;s.style.height="max-content";let d=Math.ceil(s.getBoundingClientRect().height);s.style.height=l;let c=Math.ceil(window.innerWidth);(c!==a||d!==t)&&(a=c,t=d,this.sendSizeChanged({width:c,height:d}))}))};r();let o=new ResizeObserver(r);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(n=new ia(window.parent,window.parent),a){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(n);try{let t=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:B$}},gb,a);if(t===void 0)throw Error(`Server sent invalid initialize result: ${t}`);this._hostCapabilities=t.hostCapabilities,this._hostInfo=t.hostInfo,this._hostContext=t.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(t){throw this.close(),t}}};D(Cn,"ONE_SHOT_EVENTS",new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]));var Rn=Cn;var hb="https://developers.tripo3d.ai/en/keys",$b="https://developers.tripo3d.com/zh/keys",K=e=>document.getElementById(e),Se=new Rn({name:"Tripo settings",version:"0.2.1"},{});async function dn(e,i={}){let n=await Se.callServerTool({name:e,arguments:i}),a=(n.content??[]).find(t=>t.type==="text")?.text??"";if(n.isError)throw new Error(a.replace(/^Error \[[A-Z_]+\]:\s*/,"")||"The call failed.");try{return JSON.parse(a)}catch{throw new Error(a||"The call returned nothing.")}}function Ee(e){for(let i of["save","clear","signin","region"])K(i).disabled=e;e||(K("clear").disabled=!$l||$l.key.source!=="store")}function he(e){let i=K("error");i.textContent=e??"",i.hidden=!e}var $l=null;function _l(e){$l=e;let i=K("account");if(e.signedIn){let n=[e.account??"Signed in"];e.region&&n.push(e.region==="cn"?"China mainland":"International"),typeof e.balance=="number"&&n.push(`${e.balance.toLocaleString()} credits`),i.textContent=n.join(" \xB7 "),i.dataset.state="ok"}else i.textContent="Not signed in. Save an API key or sign in with Tripo.",i.dataset.state="off";K("keystate").textContent=e.key.source==="env"?"Set by the TRIPO_API_KEY environment variable, which takes precedence over a saved key.":e.key.source==="store"?"A key is saved.":"No key is saved.",K("clear").disabled=e.key.source!=="store"}async function bl(){he(null);try{_l(await dn("auth_status"))}catch(e){he(e.message)}}async function bb(e){e.preventDefault();let i=K("apikey"),n=i.value.trim();if(!n){he("Enter an API key first.");return}Ee(!0),he(null);try{_l(await dn("set_key",{apiKey:n})),i.value=""}catch(a){he(a.message)}finally{Ee(!1)}}async function _b(){Ee(!0),he(null);try{_l(await dn("clear_key"))}catch(e){he(e.message)}finally{Ee(!1)}}var At=null;function mp(){At&&clearTimeout(At),At=null}async function yb(){mp(),Ee(!0),he(null);let e=K("region").value;try{let i=await dn("login_start",{region:e});if(!i.url){K("device").hidden=!0,await bl(),Ee(!1);return}K("code").textContent=i.code??"",K("open").onclick=()=>void Se.openLink({url:i.url}),K("device").hidden=!1,K("pollstate").textContent="Waiting for you to approve the code in your browser.",Se.openLink({url:i.url});let n=async()=>{let a;try{a=await dn("login_poll")}catch(t){a={state:"error",message:t.message}}if(a.state==="pending"){At=setTimeout(()=>void n(),i.pollAfterMs||5e3);return}At=null,Ee(!1),a.state==="done"?(K("device").hidden=!0,await bl()):(K("pollstate").textContent=a.state==="expired"?"The code expired. Sign in again for a new one.":"",a.state==="error"&&he(a.message??"Sign-in failed."))};At=setTimeout(()=>void n(),i.pollAfterMs||5e3)}catch(i){he(i.message),Ee(!1)}}function pp(e){e&&(e.theme&&lp(e.theme),e.styles?.variables&&dp(e.styles.variables),e.styles?.css?.fonts&&cp(e.styles.css.fonts))}Se.onhostcontextchanged=e=>pp({...Se.getHostContext(),...e});Se.onteardown=async()=>(mp(),{});K("keyform").addEventListener("submit",e=>void bb(e));K("clear").addEventListener("click",()=>void _b());K("signin").addEventListener("click",()=>void yb());K("getkey").addEventListener("click",e=>{e.preventDefault(),Se.openLink({url:K("region").value==="cn"?$b:hb})});Se.connect().then(()=>{pp(Se.getHostContext()),bl()}).catch(e=>he(`Could not reach the host: ${e.message}`));})();
|
|
177
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:u.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:u.string().optional().describe("User's timezone in IANA format."),userAgent:u.string().optional().describe("Host application identifier."),platform:u.union([u.literal("web"),u.literal("desktop"),u.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:u.object({touch:u.boolean().optional().describe("Whether the device supports touch input."),hover:u.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:u.object({top:u.number().describe("Top safe area inset in pixels."),right:u.number().describe("Right safe area inset in pixels."),bottom:u.number().describe("Bottom safe area inset in pixels."),left:u.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fb=u.object({method:u.literal("ui/notifications/host-context-changed"),params:up.describe("Partial context update containing only changed fields.")}),Xb=u.object({method:u.literal("ui/update-model-context"),params:u.object({content:u.array(ln).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:u.record(u.string(),u.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Yb=u.object({method:u.literal("ui/initialize"),params:u.object({appInfo:Mr.describe("App identification (name and version)."),appCapabilities:db.describe("Features and capabilities this app provides."),protocolVersion:u.string().describe("Protocol version this app supports.")})}),gb=u.object({protocolVersion:u.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Mr.describe("Host application identification and version."),hostCapabilities:lb.describe("Features and capabilities provided by the host."),hostContext:up.describe("Rich context about the host environment.")}).passthrough(),vb={target:"draft-2020-12"};async function Bl(e,i){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[i](vb);if(n.vendor==="zod"){let{z:a}=await Promise.resolve().then(()=>(Rr(),qm));return a.toJSONSchema(e,{io:i})}throw Error(`Schema (vendor: ${n.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 Gl(e,i,n=""){let a=await e["~standard"].validate(i);if(a.issues){let t=a.issues.map(r=>{let o=r.path?.map(s=>typeof s=="object"?s.key:s).join(".");return o?`${o}: ${r.message}`:r.message}).join("; ");throw Error(n+t)}return a.value}Rr();function lp(e){let i=document.documentElement;i.setAttribute("data-theme",e),i.style.colorScheme=e}function dp(e,i=document.documentElement){for(let[n,a]of Object.entries(e))a!==void 0&&i.style.setProperty(n,a)}function cp(e){if(document.getElementById("__mcp-host-fonts"))return;let i=document.createElement("style");i.id="__mcp-host-fonts",i.textContent=e,document.head.appendChild(i)}var Cn=class Cn extends ta{constructor(n,a={},t={autoResize:!0}){super(t);D(this,"_appInfo");D(this,"_capabilities");D(this,"options");D(this,"_hostCapabilities");D(this,"_hostInfo");D(this,"_hostContext");D(this,"_registeredTools",{});D(this,"_initializedSent",!1);D(this,"eventSchemas",{toolinput:nb,toolinputpartial:rb,toolresult:pb,toolcancelled:ab,hostcontextchanged:fb});D(this,"_everHadListener",new Set);D(this,"_toolHandlersInitialized",!1);D(this,"_onteardown");D(this,"_oncalltool");D(this,"_onlisttools");D(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=a,this.options=t,t.allowUnsafeEval||u.config({jitless:!0}),this.setRequestHandler(Lr,r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}_assertInitialized(n){if(this._initializedSent)return;let a=`[ext-apps] App.${n}() 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(a);console.warn(`${a}. This will throw in a future release.`)}_assertHandlerTiming(n){if(!Cn.ONE_SHOT_EVENTS.has(n)||this._everHadListener.has(n)||(this._everHadListener.add(n),!this._initializedSent))return;let a=`[ext-apps] "${String(n)}" 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(a);console.warn(a)}setEventHandler(n,a){a&&this._assertHandlerTiming(n),super.setEventHandler(n,a)}addEventListener(n,a){this._assertHandlerTiming(n),super.addEventListener(n,a)}onEventDispatch(n,a){n==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...a})}registerCapabilities(n){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=V$(this._capabilities,n)}registerTool(n,a,t){if(this._registeredTools[n])throw Error(`Tool ${n} is already registered`);let r=this,o=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},s=a.inputSchema!==void 0,l={title:a.title,description:a.description,inputSchema:a.inputSchema,outputSchema:a.outputSchema,annotations:a.annotations,_meta:a._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(d){Object.assign(this,d),o()},remove(){r._registeredTools[n]===l&&(delete r._registeredTools[n],o())},handler:async(d,c)=>{if(!l.enabled)throw Error(`Tool ${n} is disabled`);let f;if(s){let g=l.inputSchema,_=g?await Gl(g,d??{},`Invalid input for tool ${n}: `):d??{};f=await t(_,c)}else f=await t(c);return l.outputSchema&&!f.isError&&(f.structuredContent=await Gl(l.outputSchema,f.structuredContent,`Invalid output for tool ${n}: `)),f}};return this._registeredTools[n]=l,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),l}ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(n,a)=>{let t=this._registeredTools[n.name];if(!t)throw Error(`Tool ${n.name} not found`);return t.handler(n.arguments,a)},this.onlisttools=async(n,a)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([t,r])=>r.enabled).map(async([t,r])=>{let o={name:t,title:r.title,description:r.description,inputSchema:r.inputSchema?await Bl(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(o.outputSchema=await Bl(r.outputSchema,"output")),r.annotations&&(o.annotations=r.annotations),r._meta&&(o._meta=r._meta),o}))}))}async sendToolListChanged(n={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:n})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(n){this.setEventHandler("toolinput",n)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(n){this.setEventHandler("toolinputpartial",n)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(n){this.setEventHandler("toolresult",n)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(n){this.setEventHandler("toolcancelled",n)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(n){this.setEventHandler("hostcontextchanged",n)}get onteardown(){return this._onteardown}set onteardown(n){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,n),this._onteardown=n,this.replaceRequestHandler(ub,(a,t)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(a.params,t)})}get oncalltool(){return this._oncalltool}set oncalltool(n){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,n),this._oncalltool=n,this.replaceRequestHandler(rp,(a,t)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(a.params,t)})}get onlisttools(){return this._onlisttools}set onlisttools(n){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,n),this._onlisttools=n,this.replaceRequestHandler(np,(a,t)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(a.params,t)})}assertCapabilityForMethod(n){switch(n){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${n})`);break}}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,a){if(this._assertInitialized("callServerTool"),typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},qr,{onprogress:()=>{},resetTimeoutOnProgress:!0,...a})}async readServerResource(n,a){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:n},ep,a)}async listServerResources(n,a){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:n},Qm,a)}async createSamplingMessage(n,a){this._assertInitialized("createSamplingMessage");let t=n.tools?sp:op;return await this.request({method:"sampling/createMessage",params:n},t,a)}sendMessage(n,a){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:n},ib,a)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,a){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:n},el,a)}openLink(n,a){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:n},eb,a)}downloadFile(n,a){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:n},tb,a)}requestTeardown(n={}){return this.notification({method:"ui/notifications/request-teardown",params:n})}requestDisplayMode(n,a){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:n},cb,a)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,a=0,t=0,r=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let s=document.documentElement,l=s.style.height;s.style.height="max-content";let d=Math.ceil(s.getBoundingClientRect().height);s.style.height=l;let c=Math.ceil(window.innerWidth);(c!==a||d!==t)&&(a=c,t=d,this.sendSizeChanged({width:c,height:d}))}))};r();let o=new ResizeObserver(r);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(n=new ia(window.parent,window.parent),a){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(n);try{let t=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:B$}},gb,a);if(t===void 0)throw Error(`Server sent invalid initialize result: ${t}`);this._hostCapabilities=t.hostCapabilities,this._hostInfo=t.hostInfo,this._hostContext=t.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(t){throw this.close(),t}}};D(Cn,"ONE_SHOT_EVENTS",new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]));var Rn=Cn;var hb="https://developers.tripo3d.ai/en/keys",$b="https://developers.tripo3d.com/zh/keys",K=e=>document.getElementById(e),Se=new Rn({name:"Tripo settings",version:"0.2.2"},{});async function dn(e,i={}){let n=await Se.callServerTool({name:`tripo_${e}`,arguments:i}),a=(n.content??[]).find(t=>t.type==="text")?.text??"";if(n.isError)throw new Error(a.replace(/^Error \[[A-Z_]+\]:\s*/,"")||"The call failed.");try{return JSON.parse(a)}catch{throw new Error(a||"The call returned nothing.")}}function Ee(e){for(let i of["save","clear","signin","region"])K(i).disabled=e;e||(K("clear").disabled=!$l||$l.key.source!=="store")}function he(e){let i=K("error");i.textContent=e??"",i.hidden=!e}var $l=null;function _l(e){$l=e;let i=K("account");if(e.signedIn){let n=[e.account??"Signed in"];e.region&&n.push(e.region==="cn"?"China mainland":"International"),typeof e.balance=="number"&&n.push(`${e.balance.toLocaleString()} credits`),i.textContent=n.join(" \xB7 "),i.dataset.state="ok"}else i.textContent="Not signed in. Save an API key or sign in with Tripo.",i.dataset.state="off";K("keystate").textContent=e.key.source==="env"?"Set by the TRIPO_API_KEY environment variable, which takes precedence over a saved key.":e.key.source==="store"?"A key is saved.":"No key is saved.",K("clear").disabled=e.key.source!=="store"}async function bl(){he(null);try{_l(await dn("auth_status"))}catch(e){he(e.message)}}async function bb(e){e.preventDefault();let i=K("apikey"),n=i.value.trim();if(!n){he("Enter an API key first.");return}Ee(!0),he(null);try{_l(await dn("set_key",{apiKey:n})),i.value=""}catch(a){he(a.message)}finally{Ee(!1)}}async function _b(){Ee(!0),he(null);try{_l(await dn("clear_key"))}catch(e){he(e.message)}finally{Ee(!1)}}var At=null;function mp(){At&&clearTimeout(At),At=null}async function yb(){mp(),Ee(!0),he(null);let e=K("region").value;try{let i=await dn("login_start",{region:e});if(!i.url){K("device").hidden=!0,await bl(),Ee(!1);return}K("code").textContent=i.code??"",K("open").onclick=()=>void Se.openLink({url:i.url}),K("device").hidden=!1,K("pollstate").textContent="Waiting for you to approve the code in your browser.",Se.openLink({url:i.url});let n=async()=>{let a;try{a=await dn("login_poll")}catch(t){a={state:"error",message:t.message}}if(a.state==="pending"){At=setTimeout(()=>void n(),i.pollAfterMs||5e3);return}At=null,Ee(!1),a.state==="done"?(K("device").hidden=!0,await bl()):(K("pollstate").textContent=a.state==="expired"?"The code expired. Sign in again for a new one.":"",a.state==="error"&&he(a.message??"Sign-in failed."))};At=setTimeout(()=>void n(),i.pollAfterMs||5e3)}catch(i){he(i.message),Ee(!1)}}function pp(e){e&&(e.theme&&lp(e.theme),e.styles?.variables&&dp(e.styles.variables),e.styles?.css?.fonts&&cp(e.styles.css.fonts))}Se.onhostcontextchanged=e=>pp({...Se.getHostContext(),...e});Se.onteardown=async()=>(mp(),{});K("keyform").addEventListener("submit",e=>void bb(e));K("clear").addEventListener("click",()=>void _b());K("signin").addEventListener("click",()=>void yb());K("getkey").addEventListener("click",e=>{e.preventDefault(),Se.openLink({url:K("region").value==="cn"?$b:hb})});Se.connect().then(()=>{pp(Se.getHostContext()),bl()}).catch(e=>he(`Could not reach the host: ${e.message}`));})();
|
|
178
178
|
</script>
|
|
179
179
|
</body>
|
|
180
180
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ue-mcp-tripo",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Tripo plugin for ue-mcp. Runs Tripo's own CLI to turn a prompt or image into a rigged, textured Unreal Engine 5 character imported through ue-mcp core, and exposes every other CLI command through a passthrough.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|