@vivix-labs/studio-chat-mcp 0.1.3 → 0.1.4
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/chat-ui/index.html +1 -1
- package/dist/server.js +11 -5
- package/package.json +8 -8
- package/skills/vivix-studio-chat/SKILL.md +6 -4
- package/README.md +0 -120
package/dist/chat-ui/index.html
CHANGED
|
@@ -148,7 +148,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
148
148
|
- "model": Tool visible to and callable by the agent
|
|
149
149
|
- "app": Tool callable by the app from this server only`),csp:f.never().optional(),permissions:f.never().optional()}),uU=f.object({mimeTypes:f.array(f.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),lU=f.object({method:f.literal("ui/download-file"),params:f.object({contents:f.array(f.union([En,Cn])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),dU=f.object({method:f.literal("ui/message"),params:f.object({role:f.literal("user").describe('Message role, currently only "user" is supported.'),content:f.array(Wt).describe("Message content blocks (text, image, etc.).")})}),mU=f.object({method:f.literal("ui/notifications/sandbox-resource-ready"),params:f.object({html:f.string().describe("HTML content to load into the inner iframe."),sandbox:f.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Yv.optional().describe("CSP configuration from resource metadata."),permissions:Xv.optional().describe("Sandbox permissions from resource metadata.")})}),WE=f.object({method:f.literal("ui/notifications/tool-result"),params:Vr.describe("Standard MCP tool execution result.")}),xz=f.object({toolInfo:f.object({id:Rt.optional().describe("JSON-RPC id of the tools/call request."),tool:Lr.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:OE.optional().describe("Current color theme preference."),styles:ZE.optional().describe("Style configuration for theming the app."),displayMode:qc.optional().describe("How the UI is currently displayed."),availableDisplayModes:f.array(qc).optional().describe("Display modes the host supports."),containerDimensions:f.union([f.object({height:f.number().describe("Fixed container height in pixels.")}),f.object({maxHeight:f.union([f.number(),f.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(f.union([f.object({width:f.number().describe("Fixed container width in pixels.")}),f.object({maxWidth:f.union([f.number(),f.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
150
150
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:f.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:f.string().optional().describe("User's timezone in IANA format."),userAgent:f.string().optional().describe("Host application identifier."),platform:f.union([f.literal("web"),f.literal("desktop"),f.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:f.object({touch:f.boolean().optional().describe("Whether the device supports touch input."),hover:f.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:f.object({top:f.number().describe("Top safe area inset in pixels."),right:f.number().describe("Right safe area inset in pixels."),bottom:f.number().describe("Bottom safe area inset in pixels."),left:f.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),YE=f.object({method:f.literal("ui/notifications/host-context-changed"),params:xz.describe("Partial context update containing only changed fields.")}),pU=f.object({method:f.literal("ui/update-model-context"),params:f.object({content:f.array(Wt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:f.record(f.string(),f.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),fU=f.object({method:f.literal("ui/initialize"),params:f.object({appInfo:Kt.describe("App identification (name and version)."),appCapabilities:BE.describe("Features and capabilities this app provides."),protocolVersion:f.string().describe("Protocol version this app supports.")})}),XE=f.object({protocolVersion:f.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Kt.describe("Host application identification and version."),hostCapabilities:JE.describe("Features and capabilities provided by the host."),hostContext:xz.describe("Rich context about the host environment.")}).passthrough(),QE={target:"draft-2020-12"};async function kz(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](QE);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 Iz(e,t,n=""){let o=await e["~standard"].validate(t);if(o.issues){let r=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(n+r)}return o.value}function eC(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Wd=class e extends Dc{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Kv;_methods=new Gv;setRequestHandler=(...t)=>{let[n,...o]=zz("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=zz("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...o)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() 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(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:ME,toolinputpartial:qE,toolresult:WE,toolcancelled:LE,hostcontextchanged:YE};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" 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(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},o=>{let r=o;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,o){n&&o&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},o={autoResize:!0}){super(o),this._appInfo=t,this._appCapabilities=n,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval&&f.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=eC(this._appCapabilities,t)}registerTool(t,n,o){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(c){Object.assign(this,c),i()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],i())},handler:async(c,u)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let d;if(a){let m=s.inputSchema,p=m?await Iz(m,c??{},`Invalid input for tool ${t}: `):c??{};d=await o(p,u)}else d=await o(u);return s.outputSchema&&!d.isError&&(d.structuredContent=await Iz(s.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let o=this._registeredTools[t.name];if(!o)throw Error(`Tool ${t.name} not found`);return o.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let i={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await kz(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await kz(r.outputSchema,"output")),r.annotations&&(i.annotations=r.annotations),r._meta&&(i._meta=r._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:FE.shape.params,result:HE},(n,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,o)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},DE,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Mr,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},AE,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},UE,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},KE,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,o=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let c=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let u=Math.ceil(window.innerWidth);(u!==n||c!==o)&&(n=u,o=c,this.sendSizeChanged({width:u,height:c}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Wv(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:EE}},XE,n);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var e_="studio.chat.component.v1";function pe(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Xd(e){return{content:e.content,structuredContent:pe(e.structuredContent)?e.structuredContent:void 0,_meta:e._meta,isError:e.isError===!0}}function Rz(e){let t=e.content;if(e.isError||e.structuredContent||e._meta?.["studio/view"]||t?.length!==1)return e;let n=t[0]?.text;if(t[0]?.type!=="text"||!n?.startsWith('{"content":')||!n.includes('"studio/view"'))return e;try{let o=JSON.parse(n);if(pe(o)&&Array.isArray(o.content)&&pe(o.structuredContent)&&pe(o._meta)){let r=o._meta["studio/view"];if(pe(r)&&pe(r.ui)){let i={content:o.content,structuredContent:o.structuredContent,_meta:{"studio/view":{...r,ui:{format:r.ui.format,sha256:r.ui.sha256}}}};if(t_(i))return i}}}catch{}return{isError:!0,content:[{type:"text",text:"The saved Studio card could not be read."}]}}function Pz(e){let t=e.structuredContent,n=t&&{...t,bindings:t.bindings??gr(e).bindings};if(!(!n||n.protocolVersion!==1||!pe(n.bindings)||Object.entries(n.bindings).some(([o,r])=>!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(o)||typeof r!="string"||!r)||typeof n.component!="string"||!/^[a-zA-Z0-9._/-]+@[1-9]\d*$/.test(n.component)||typeof n.projectId!="string"||!n.projectId||n.scope!==void 0&&(!pe(n.scope)||!["user","project"].includes(String(n.scope.kind))||n.scope.id!==n.projectId||n.scope.kind==="user"&&n.scope.id!=="user")||!pe(n.target)||typeof n.target.instanceId!="string"||!n.target.instanceId||typeof n.target.operationId!="string"||!n.target.operationId))return{component:n.component,bindings:n.bindings,projectId:n.projectId,...n.scope!==void 0&&{scope:n.scope},target:{instanceId:n.target.instanceId,operationId:n.target.operationId}}}function Qv(e,t){return pe(e)&&Object.keys(e).length===Object.keys(t).length&&Object.entries(t).every(([n,o])=>e[n]===o)}function gr(e){let t=e._meta?.["studio/view"];return pe(t)?t:{}}function Tz(e,t,n){let o=gr(e),r=new URL(t);if(r.protocol!=="https:"||r.username||r.password||!Array.isArray(o.mediaOrigins)||!o.mediaOrigins.includes(r.origin))throw Error("This media source is not available for download.");let i=a=>Array.isArray(a)?a.some(i):pe(a)?Object.entries(a).some(([s,c])=>(s==="src"||s==="downloadUrl")&&c===t||i(c)):!1;if(!i(o.props))throw Error("This media is not part of the current card.");return{type:"resource_link",uri:t,name:n.replace(/[\\/:*?"<>|\x00-\x1f]/g,"_").slice(0,200)||"Media"}}function t_(e){let t=gr(e),n=Pz(e),o=t.ui;if(!(!n||t.protocolVersion!==1||t.component!==n.component||!Qv(t.bindings,n.bindings)||t.projectId!==n.projectId||n.scope!==void 0&&(!pe(t.scope)||t.scope.kind!==n.scope.kind||t.scope.id!==n.scope.id)||!pe(t.target)||t.target.instanceId!==n.target.instanceId||t.target.operationId!==n.target.operationId||!pe(t.props)||!pe(o)||o.format!=="iife"||o.javascript!==void 0&&(typeof o.javascript!="string"||!o.javascript.trim())||typeof o.sha256!="string"||!/^[a-f0-9]{64}$/.test(o.sha256)))return{id:n.component,...typeof o.javascript=="string"&&{javascript:o.javascript},sha256:o.sha256}}async function r_(e){if(!e.javascript)return!1;let t=new TextEncoder().encode(e.javascript),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")===e.sha256}function Ez(e,t){let n=e.scope??{kind:"project",id:e.projectId};return"studio://chat-bundles/"+[n.kind,n.id,e.target.instanceId,e.target.operationId,t].map(encodeURIComponent).join("/")}function po(e){return(e.content??[]).filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
151
|
-
`)}function Qd(e){let{ui:t,...n}=gr(e);return{text:po(e),structuredContent:e.structuredContent,view:n,isError:e.isError===!0}}function n_(e,t){return!e||typeof e!="object"?!1:pe(e)&&["audio","video"].includes(String(e.kind))&&e.path===t?!0:Object.values(e).some(n=>n_(n,t))}var Yd=class{constructor(t,n){this.callTool=t;this.sendMessage=n}callTool;sendMessage;result={};identity;pending=!1;lastRequest;receive(t){let n=Pz(t);if(this.identity){let o=t.structuredContent??{};if(o.scope!==void 0){let s=this.identity.scope??{kind:"project",id:this.identity.projectId};if(!pe(o.scope)||o.scope.kind!==s.kind||o.scope.id!==s.id)throw new Error("The reply changed the card scope. Reopen the original card.")}for(let s of["projectId","component"])if(o[s]!==void 0&&o[s]!==this.identity[s])throw new Error("The reply belongs to another card. Reopen the original card.");if(o.target!==void 0&&(!pe(o.target)||o.target.instanceId!==this.identity.target.instanceId||o.target.operationId!==this.identity.target.operationId))throw new Error("The reply changed the source operation. Reopen the original card.");if(o.bindings!==void 0&&!Qv(o.bindings,this.identity.bindings)||n!==void 0&&!Qv(n.bindings,this.identity.bindings))throw new Error("The reply changed the action bindings. Reopen the original card.");let r=this.result,{error:i,...a}=r.structuredContent??{};this.result={...r,...t,isError:t.isError===!0,structuredContent:{...a,...o},_meta:{...r._meta,...t._meta,"studio/view":{...gr(r),...gr(t)}}}}else this.result=t,this.identity=n}async action(t,n={},o={}){if(!this.identity)throw new Error("Reopen the operation before using this card.");if(this.pending)throw new Error("Wait for the current card action to finish.");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t))throw new Error("Invalid card action.");if(!Object.hasOwn(this.identity.bindings,t))throw new Error("This card does not declare that action.");if(Object.keys(o).some(i=>!["requestKey","approval"].includes(i)))throw new Error("Invalid card invocation options.");let r={...this.identity.scope?.kind==="user"?{scope:this.identity.scope}:{projectId:this.identity.projectId},target:this.identity.target,binding:this.identity.bindings[t],action:t,input:n,requestKey:o.requestKey??`card:${crypto.randomUUID()}`,...o.approval===void 0?{}:{approval:o.approval}};this.lastRequest=r,this.pending=!0;try{let i=await this.callTool({name:"studio_card_action",arguments:r}),a=i._meta?.["studio/message"],{["studio/message"]:s,...c}=i._meta??{},u={...i,_meta:c};if(this.receive(u),a!==void 0&&!i.isError){if(!pe(a)||typeof a.intent!="string"||!a.intent.trim()||!pe(a.data))throw Error("The adapter returned an invalid prepared message. Your draft is retained.");let d=this.sendMessage?await this.sendMessage(r.requestKey,{intent:a.intent,data:a.data}):{status:"failed",message:"This chat client does not support follow-up messages. Your draft is retained."},m=d.status==="sent",p={...u,content:[{type:"text",text:m?"Sent to this conversation. Business changes are not yet confirmed.":d.message}],isError:!m,structuredContent:{...u.structuredContent,...m?{}:{error:{code:d.status==="unknown"?"PROMPT_MESSAGE_UNKNOWN":"PROMPT_MESSAGE_FAILED"}}}};return this.receive(p),p}return u}finally{this.pending=!1}}};function Cz(e,t){let n=t.mediaOrigins??[];if(!Array.isArray(n)||n.some(i=>{if(typeof i!="string")return!0;try{let a=new URL(i);return a.protocol!=="https:"||a.origin!==i||a.hostname.includes("*")||/["';]/.test(i)}catch{return!0}}))throw new Error("The card declared invalid HTTPS media origins.");let o=["data:","blob:",...[...new Set(n)].sort()].join(" ");return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; font-src data:; img-src ${o}; media-src ${o}; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'`}"><meta name="referrer" content="no-referrer"><meta name="color-scheme" content="light dark"><div id="root"></div><script>${e.replace(/<\/script/gi,"<\\/script")}<\/script>`}function Oz(){let e="studio.chat.component.v1",t=new Map,n,o=0,r=!1,i=c=>parent.postMessage({channel:e,...c},"*"),a=(c,u={},d={})=>new Promise((m,p)=>{let h=String(++o);t.set(h,{resolve:m,reject:p}),i({type:"action",id:h,action:c,input:u,options:d})}),s=c=>({data:c.view.props,projectId:c.view.projectId,target:c.view.target,action:a,...r&&{download:u=>new Promise((d,m)=>{let p=String(++o);t.set(p,{resolve:()=>d(),reject:m}),i({type:"download",id:p,uri:u.uri,name:u.name})})},readMedia:u=>new Promise((d,m)=>{let p=String(++o);t.set(p,{resolve:d,reject:m}),i({type:"read-media",id:p,input:u})})});window.addEventListener("message",c=>{if(c.source!==parent||c.data?.channel!==e)return;let u=c.data;try{if(u.type==="initialize"&&!n){r=u.downloadsAvailable===!0;let d=document.createElement("script");d.textContent=u.javascript,document.head.append(d);let m=globalThis,p=m.StudioComponent??m.StudioChatCard;if(typeof p?.mount!="function")throw new Error("The registered card has no mount export.");if(n=p.mount(document.querySelector("#root"),s(u.result)),!n||typeof n.update!="function"||typeof n.dispose!="function")throw new Error("The registered card returned an invalid mount.")}else u.type==="result"&&n?n.update(s(u.result)):u.type==="action-result"||u.type==="download-result"?(t.get(u.id)?.resolve(u.result),t.delete(u.id)):u.type==="media-result"?(t.get(u.id)?.resolve(u.value),t.delete(u.id)):u.type==="media-error"?(t.get(u.id)?.reject(new Error(u.message)),t.delete(u.id)):(u.type==="action-error"||u.type==="download-error")&&(t.get(u.id)?.reject(Object.assign(new Error(u.error.message),u.error)),t.delete(u.id))}catch(d){i({type:"component-error",message:d instanceof Error?d.message:"Card failed."})}}),window.addEventListener("error",()=>i({type:"component-error",message:"The registered card could not render."})),window.addEventListener("unhandledrejection",()=>i({type:"component-error",message:"The registered card could not update."})),document.addEventListener("securitypolicyviolation",c=>{if(!["media-src","img-src"].includes(c.effectiveDirective))return;let u="the media source";try{u=new URL(c.blockedURI).origin}catch{}i({type:"component-error",message:`This chat blocked ${u} (${c.effectiveDirective}). Refreshing the URL alone will not change its resource policy.`})}),new ResizeObserver(()=>{i({type:"resize",height:document.documentElement.scrollHeight})}).observe(document.body),window.addEventListener("pagehide",()=>n?.dispose()),i({type:"ready"})}var bt=new Wd({name:"Vivix Studio card",version:"1.0.0"},{},{strict:!0}),tC=new ou(bt),yt=new Yd(async e=>Xd(await bt.callServerTool(e)),(e,t)=>tC.send(e,t)),jz=document.querySelector("#summary"),fo=document.querySelector("#status"),rC=document.querySelector("#card"),$e,Lc,em,Nz,Xt=!1,vr,Az,i_=0;function Hr(e){$e?.contentWindow?.postMessage({channel:e_,...e},"*")}function Vc(e){let t=e instanceof Error?e.message:"Studio could not update this card.",n=yt.lastRequest?.requestKey??Az;fo.textContent=`${t}${n?`
|
|
151
|
+
`)}function Qd(e){let{ui:t,...n}=gr(e);return{text:po(e),structuredContent:e.structuredContent,view:n,isError:e.isError===!0}}function n_(e,t){return!e||typeof e!="object"?!1:pe(e)&&["image","audio","video"].includes(String(e.kind))&&e.path===t?!0:Object.values(e).some(n=>n_(n,t))}var Yd=class{constructor(t,n){this.callTool=t;this.sendMessage=n}callTool;sendMessage;result={};identity;pending=!1;lastRequest;receive(t){let n=Pz(t);if(this.identity){let o=t.structuredContent??{};if(o.scope!==void 0){let s=this.identity.scope??{kind:"project",id:this.identity.projectId};if(!pe(o.scope)||o.scope.kind!==s.kind||o.scope.id!==s.id)throw new Error("The reply changed the card scope. Reopen the original card.")}for(let s of["projectId","component"])if(o[s]!==void 0&&o[s]!==this.identity[s])throw new Error("The reply belongs to another card. Reopen the original card.");if(o.target!==void 0&&(!pe(o.target)||o.target.instanceId!==this.identity.target.instanceId||o.target.operationId!==this.identity.target.operationId))throw new Error("The reply changed the source operation. Reopen the original card.");if(o.bindings!==void 0&&!Qv(o.bindings,this.identity.bindings)||n!==void 0&&!Qv(n.bindings,this.identity.bindings))throw new Error("The reply changed the action bindings. Reopen the original card.");let r=this.result,{error:i,...a}=r.structuredContent??{};this.result={...r,...t,isError:t.isError===!0,structuredContent:{...a,...o},_meta:{...r._meta,...t._meta,"studio/view":{...gr(r),...gr(t)}}}}else this.result=t,this.identity=n}async action(t,n={},o={}){if(!this.identity)throw new Error("Reopen the operation before using this card.");if(this.pending)throw new Error("Wait for the current card action to finish.");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t))throw new Error("Invalid card action.");if(!Object.hasOwn(this.identity.bindings,t))throw new Error("This card does not declare that action.");if(Object.keys(o).some(i=>!["requestKey","approval"].includes(i)))throw new Error("Invalid card invocation options.");let r={...this.identity.scope?.kind==="user"?{scope:this.identity.scope}:{projectId:this.identity.projectId},target:this.identity.target,binding:this.identity.bindings[t],action:t,input:n,requestKey:o.requestKey??`card:${crypto.randomUUID()}`,...o.approval===void 0?{}:{approval:o.approval}};this.lastRequest=r,this.pending=!0;try{let i=await this.callTool({name:"studio_card_action",arguments:r}),a=i._meta?.["studio/message"],{["studio/message"]:s,...c}=i._meta??{},u={...i,_meta:c};if(this.receive(u),a!==void 0&&!i.isError){if(!pe(a)||typeof a.intent!="string"||!a.intent.trim()||!pe(a.data))throw Error("The adapter returned an invalid prepared message. Your draft is retained.");let d=this.sendMessage?await this.sendMessage(r.requestKey,{intent:a.intent,data:a.data}):{status:"failed",message:"This chat client does not support follow-up messages. Your draft is retained."},m=d.status==="sent",p={...u,content:[{type:"text",text:m?"Sent to this conversation. Business changes are not yet confirmed.":d.message}],isError:!m,structuredContent:{...u.structuredContent,...m?{}:{error:{code:d.status==="unknown"?"PROMPT_MESSAGE_UNKNOWN":"PROMPT_MESSAGE_FAILED"}}}};return this.receive(p),p}return u}finally{this.pending=!1}}};function Cz(e,t){let n=t.mediaOrigins??[];if(!Array.isArray(n)||n.some(i=>{if(typeof i!="string")return!0;try{let a=new URL(i);return a.protocol!=="https:"||a.origin!==i||a.hostname.includes("*")||/["';]/.test(i)}catch{return!0}}))throw new Error("The card declared invalid HTTPS media origins.");let o=["data:","blob:",...[...new Set(n)].sort()].join(" ");return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; font-src data:; img-src ${o}; media-src ${o}; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'`}"><meta name="referrer" content="no-referrer"><meta name="color-scheme" content="light dark"><div id="root"></div><script>${e.replace(/<\/script/gi,"<\\/script")}<\/script>`}function Oz(){let e="studio.chat.component.v1",t=new Map,n,o=0,r=!1,i=c=>parent.postMessage({channel:e,...c},"*"),a=(c,u={},d={})=>new Promise((m,p)=>{let h=String(++o);t.set(h,{resolve:m,reject:p}),i({type:"action",id:h,action:c,input:u,options:d})}),s=c=>({data:c.view.props,projectId:c.view.projectId,target:c.view.target,action:a,...r&&{download:u=>new Promise((d,m)=>{let p=String(++o);t.set(p,{resolve:()=>d(),reject:m}),i({type:"download",id:p,uri:u.uri,name:u.name})})},readMedia:u=>new Promise((d,m)=>{let p=String(++o);t.set(p,{resolve:d,reject:m}),i({type:"read-media",id:p,input:u})})});window.addEventListener("message",c=>{if(c.source!==parent||c.data?.channel!==e)return;let u=c.data;try{if(u.type==="initialize"&&!n){r=u.downloadsAvailable===!0;let d=document.createElement("script");d.textContent=u.javascript,document.head.append(d);let m=globalThis,p=m.StudioComponent??m.StudioChatCard;if(typeof p?.mount!="function")throw new Error("The registered card has no mount export.");if(n=p.mount(document.querySelector("#root"),s(u.result)),!n||typeof n.update!="function"||typeof n.dispose!="function")throw new Error("The registered card returned an invalid mount.")}else u.type==="result"&&n?n.update(s(u.result)):u.type==="action-result"||u.type==="download-result"?(t.get(u.id)?.resolve(u.result),t.delete(u.id)):u.type==="media-result"?(t.get(u.id)?.resolve(u.value),t.delete(u.id)):u.type==="media-error"?(t.get(u.id)?.reject(new Error(u.message)),t.delete(u.id)):(u.type==="action-error"||u.type==="download-error")&&(t.get(u.id)?.reject(Object.assign(new Error(u.error.message),u.error)),t.delete(u.id))}catch(d){i({type:"component-error",message:d instanceof Error?d.message:"Card failed."})}}),window.addEventListener("error",()=>i({type:"component-error",message:"The registered card could not render."})),window.addEventListener("unhandledrejection",()=>i({type:"component-error",message:"The registered card could not update."})),document.addEventListener("securitypolicyviolation",c=>{if(!["media-src","img-src"].includes(c.effectiveDirective))return;let u="the media source";try{u=new URL(c.blockedURI).origin}catch{}i({type:"component-error",message:`This chat blocked ${u} (${c.effectiveDirective}). Refreshing the URL alone will not change its resource policy.`})}),new ResizeObserver(()=>{i({type:"resize",height:document.documentElement.scrollHeight})}).observe(document.body),window.addEventListener("pagehide",()=>n?.dispose()),i({type:"ready"})}var bt=new Wd({name:"Vivix Studio card",version:"1.0.0"},{},{strict:!0}),tC=new ou(bt),yt=new Yd(async e=>Xd(await bt.callServerTool(e)),(e,t)=>tC.send(e,t)),jz=document.querySelector("#summary"),fo=document.querySelector("#status"),rC=document.querySelector("#card"),$e,Lc,em,Nz,Xt=!1,vr,Az,i_=0;function Hr(e){$e?.contentWindow?.postMessage({channel:e_,...e},"*")}function Vc(e){let t=e instanceof Error?e.message:"Studio could not update this card.",n=yt.lastRequest?.requestKey??Az;fo.textContent=`${t}${n?`
|
|
152
152
|
Request key: ${String(n)}`:""}`}async function Uz(){let e=++i_,t=yt.result;jz.textContent=po(t)||"Studio card",fo.textContent=t.isError?po(t)||"Studio rejected the card action.":"";let n=t_(t);if(!yt.identity||!n){vr&&clearTimeout(vr),$e?.remove(),$e=void 0,Lc=void 0,em=void 0,Xt=!1,t.isError||(fo.textContent="The registered card could not load. Reopen the original operation.");return}let o=Cz(`(${Oz.toString()})();`,gr(t));if($e&&em===n.sha256&&Nz===o){Xt&&Hr({type:"result",result:Qd(t)});return}let r=n.javascript;try{if(!r||!await r_(n)){let i=Ez(yt.identity,n.sha256),s=(await bt.readServerResource({uri:i})).contents.find(c=>c.uri===i&&c.mimeType==="text/javascript");if(!s||!("text"in s)||!await r_({...n,javascript:s.text}))throw new Error("Card script does not match its saved digest.");r=s.text}}catch{if(e!==i_)return;fo.textContent="The original Studio card script could not be loaded or verified. Reopen the card.",$e?.remove(),$e=void 0,Lc=void 0,em=void 0,Xt=!1;return}e===i_&&(vr&&clearTimeout(vr),$e?.remove(),Xt=!1,Lc=r,em=n.sha256,Nz=o,$e=document.createElement("iframe"),$e.id="component",$e.title="Studio card",$e.setAttribute("sandbox","allow-scripts"),$e.setAttribute("referrerpolicy","no-referrer"),$e.srcdoc=o,rC.replaceChildren($e),vr=setTimeout(()=>{Xt||(fo.textContent="The card did not initialize. Reopen the original operation.")},1e4))}async function nC(e,t,n,o){try{let i=await yt.action(e,t,n);await Uz(),o&&Hr({type:"action-result",id:o,result:Qd(i)})}catch(r){Vc(r),o&&Hr({type:"action-error",id:o,error:{code:"CARD_ACTION_FAILED",message:r instanceof Error?r.message:"Card action failed.",requestKey:yt.lastRequest?.requestKey}})}}async function iC(e,t,n){try{let o=Tz(yt.result,e,t);if(!bt.getHostCapabilities()?.downloadFile)throw Error("Downloads are unavailable in this chat.");if((await bt.downloadFile({contents:[o]})).isError)throw Error("The download was declined by this chat.");Hr({type:"download-result",id:n})}catch(o){Hr({type:"download-error",id:n,error:{message:o instanceof Error?o.message:"Download failed."}})}}window.addEventListener("message",e=>{if(!$e||e.source!==$e.contentWindow||!pe(e.data))return;let t=e.data;if(t.channel===e_)if(t.type==="ready")Xt=!0,vr&&clearTimeout(vr),fo.textContent=yt.result.isError?po(yt.result):"",Lc&&Hr({type:"initialize",javascript:Lc,result:Qd(yt.result),downloadsAvailable:!!bt.getHostCapabilities()?.downloadFile});else if(t.type==="component-error"&&typeof t.message=="string")Vc(new Error(t.message));else if(Xt&&t.type==="resize"&&typeof t.height=="number"&&Number.isFinite(t.height))$e.style.height=`${Math.max(120,Math.min(2e3,t.height))}px`;else if(Xt&&t.type==="download"&&typeof t.id=="string"&&t.id.length>0&&typeof t.uri=="string"&&typeof t.name=="string")iC(t.uri,t.name,t.id);else if(Xt&&t.type==="read-media"&&typeof t.id=="string"&&pe(t.input)){let n=$e,o=t.input;(async()=>{try{if(typeof o.path!="string"||!n_(gr(yt.result).props,o.path))throw Error("This media path does not belong to the original card.");let r=await bt.callServerTool({name:"read_local_media",arguments:o});if(r.isError)throw Error(po(Xd(r))||"Local media could not be read.");let i=r._meta?.["studio/media"];if(!pe(i))throw Error("The local media reply is incomplete.");$e===n&&Hr({type:"media-result",id:t.id,value:i})}catch(r){$e===n&&Hr({type:"media-error",id:t.id,message:r instanceof Error?r.message:"Local media could not be read."})}})()}else Xt&&t.type==="action"&&typeof t.id=="string"&&t.id.length>0&&typeof t.action=="string"&&(t.input===void 0||pe(t.input))&&(t.options===void 0||pe(t.options))&&nC(t.action,t.input??{},t.options??{},t.id)});bt.ontoolinput=({arguments:e})=>{Az=typeof e?.requestKey=="string"?e.requestKey:void 0};bt.ontoolresult=async e=>{try{yt.receive(Rz(Xd(e))),await Uz()}catch(t){Vc(t)}};bt.ontoolcancelled=()=>{Vc(new Error("The tool was cancelled. Recover with the original request to check whether it was accepted."))};bt.onteardown=async()=>(vr&&clearTimeout(vr),$e?.remove(),{});bt.connect().catch(e=>{jz.textContent="Studio could not connect to this chat.",Vc(e)});})();
|
|
153
153
|
/*! Bundled license information:
|
|
154
154
|
|
package/dist/server.js
CHANGED
|
@@ -29429,7 +29429,7 @@ data:
|
|
|
29429
29429
|
// package.json
|
|
29430
29430
|
var package_default = {
|
|
29431
29431
|
name: "@vivix-labs/studio-chat-mcp",
|
|
29432
|
-
version: "0.1.
|
|
29432
|
+
version: "0.1.4",
|
|
29433
29433
|
type: "module",
|
|
29434
29434
|
engines: {
|
|
29435
29435
|
node: ">=22.12.0"
|
|
@@ -38163,6 +38163,10 @@ var localMediaInput = external_exports.object({
|
|
|
38163
38163
|
expected: snapshot.optional()
|
|
38164
38164
|
}).strict();
|
|
38165
38165
|
var mimeTypes = {
|
|
38166
|
+
".png": "image/png",
|
|
38167
|
+
".jpg": "image/jpeg",
|
|
38168
|
+
".jpeg": "image/jpeg",
|
|
38169
|
+
".webp": "image/webp",
|
|
38166
38170
|
".mp4": "video/mp4",
|
|
38167
38171
|
".m4v": "video/mp4",
|
|
38168
38172
|
".mov": "video/quicktime",
|
|
@@ -38179,7 +38183,7 @@ var mimeTypes = {
|
|
|
38179
38183
|
async function readLocalMedia(raw) {
|
|
38180
38184
|
const input2 = localMediaInput.parse(raw);
|
|
38181
38185
|
const mimeType = mimeTypes[extname(input2.path).toLowerCase()];
|
|
38182
|
-
if (!mimeType) throw Error("Choose a supported local audio or video file.");
|
|
38186
|
+
if (!mimeType) throw Error("Choose a supported local image, audio or video file.");
|
|
38183
38187
|
const file2 = await open2(input2.path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
38184
38188
|
try {
|
|
38185
38189
|
const before = await file2.stat();
|
|
@@ -38458,13 +38462,15 @@ async function resolveChatMedia(host, scope, ref, fileId) {
|
|
|
38458
38462
|
}
|
|
38459
38463
|
|
|
38460
38464
|
// src/chat-server.ts
|
|
38461
|
-
var chatResourceUri = "ui://studio/chat/
|
|
38465
|
+
var chatResourceUri = "ui://studio/chat/v8.html";
|
|
38462
38466
|
var historicalChatResourceUris = [
|
|
38463
38467
|
"ui://studio/chat/v1.html",
|
|
38464
38468
|
"ui://studio/chat/v2.html",
|
|
38465
38469
|
"ui://studio/chat/v3.html",
|
|
38466
38470
|
"ui://studio/chat/v4.html",
|
|
38467
|
-
"ui://studio/chat/v5.html"
|
|
38471
|
+
"ui://studio/chat/v5.html",
|
|
38472
|
+
"ui://studio/chat/v6.html",
|
|
38473
|
+
"ui://studio/chat/v7.html"
|
|
38468
38474
|
];
|
|
38469
38475
|
var chatMimeType = "text/html;profile=mcp-app";
|
|
38470
38476
|
var defaultResourceDomains = ["https://static.vivi-x.ai"];
|
|
@@ -38521,7 +38527,7 @@ function createChatServer(options2) {
|
|
|
38521
38527
|
"read_local_media",
|
|
38522
38528
|
{
|
|
38523
38529
|
title: "Read local media bytes",
|
|
38524
|
-
description: "Read a bounded chunk of a local audio
|
|
38530
|
+
description: "Read a bounded chunk of a local image, audio or video path supplied to this card. Bytes are private App metadata, not model context. Does not upload or import files.",
|
|
38525
38531
|
inputSchema: localMediaInput,
|
|
38526
38532
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
38527
38533
|
_meta: { ui: { visibility: ["app"] } }
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivix-labs/studio-chat-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.12.0"
|
|
7
7
|
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsx scripts/build-chat-mcp.ts build",
|
|
10
|
+
"package": "tsx scripts/build-chat-mcp.ts package",
|
|
11
|
+
"check": "tsc --noEmit",
|
|
12
|
+
"test": "tsx --test tests/*.test.ts chat-ui/*.test.ts"
|
|
13
|
+
},
|
|
8
14
|
"devDependencies": {
|
|
9
15
|
"@modelcontextprotocol/client": "2.4.0",
|
|
10
16
|
"@modelcontextprotocol/core": "2.4.0",
|
|
@@ -40,11 +46,5 @@
|
|
|
40
46
|
"access": "public",
|
|
41
47
|
"registry": "https://registry.npmjs.org/",
|
|
42
48
|
"tag": "beta"
|
|
43
|
-
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsx scripts/build-chat-mcp.ts build",
|
|
46
|
-
"package": "tsx scripts/build-chat-mcp.ts package",
|
|
47
|
-
"check": "tsc --noEmit",
|
|
48
|
-
"test": "tsx --test tests/*.test.ts chat-ui/*.test.ts"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
@@ -47,10 +47,12 @@ readable URL does not prove the native host permits it. Report a URL-safety
|
|
|
47
47
|
rejection separately from expiry or decoding; do not proxy, rehost or disable
|
|
48
48
|
checks to evade that rejection. A changed UI resource must be tested in a
|
|
49
49
|
connection that actually loads the new resource version.
|
|
50
|
-
Use existing valid URLs directly. For
|
|
51
|
-
MCP Host, supply its absolute `path` instead of
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Use existing valid URLs directly. For PNG/JPEG/WebP images, audio, or video
|
|
51
|
+
already available on the local MCP Host, supply its absolute `path` instead of
|
|
52
|
+
`src` when the component's schema supports it; use exactly one of the two.
|
|
53
|
+
Video `poster` strings still require HTTPS. The card reads `path + offset`
|
|
54
|
+
through the App-only `read_local_media` channel and loads the complete file
|
|
55
|
+
before display or playback. It needs no preview ID,
|
|
54
56
|
import or public URL. A remote MCP Host cannot read a path on the user's computer.
|
|
55
57
|
This whole-file preview does not provide progressive long-video playback.
|
|
56
58
|
|
package/README.md
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# Studio Chat MCP adapter
|
|
2
|
-
|
|
3
|
-
Studio loads this user-scoped server plugin into its Host process. The plugin owns MCP tools, chat declarations, card action routing, projection and the bundled MCP Apps page. Codex connects to the plugin's authenticated Streamable HTTP route.
|
|
4
|
-
|
|
5
|
-
## Install and enable
|
|
6
|
-
|
|
7
|
-
The public Studio suite installer installs this Host plugin and its card provider, enables them in user scope, and adds their authenticated HTTP connection to the private Codex configuration. Restart the Codex chat to discover the new connection. Existing MCP entries and personal Skills are preserved.
|
|
8
|
-
|
|
9
|
-
Use the paired Studio CLI with SDK API 0.2.6, Node.js 22.12+ and pnpm 10.33.0. Build a standard Studio plugin directory from this repository.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
pnpm --filter @vivix-labs/studio-chat-mcp package "$PWD/artifacts/studio-chat-host"
|
|
13
|
-
vivix-studio plugin install "$PWD/artifacts/studio-chat-host/studio-chat-mcp"
|
|
14
|
-
vivix-studio plugin enable @vivix-labs/studio-chat-mcp --scope user --instance studio-chat --trust --allow-access host.operations
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Open a project and enable its business plugins normally. Discover their ready operations with `vivix-studio plugin describe`. Use ordinary `plugin call <adapter-instance> run --scope user --input <file> --json` or the MCP tools to open a card. The adapter also registers an `action` operation for subsequent clicks.
|
|
18
|
-
|
|
19
|
-
The package exports its chat protocol types from `@vivix-labs/studio-chat-mcp/shared`. Chat components import these types from the adapter package. The CLI SDK does not export chat types.
|
|
20
|
-
|
|
21
|
-
## Connect an MCP client
|
|
22
|
-
|
|
23
|
-
Read the installed adapter's connection with an empty input JSON file.
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
printf '{}\n' > connection-input.json
|
|
27
|
-
vivix-studio plugin call studio-chat connection --scope user --input connection-input.json --json
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The private result contains `url`, `headers.Authorization` and the adapter's `pid`. Configure the MCP client with that URL and header. For Codex, the corresponding configuration has this shape.
|
|
31
|
-
|
|
32
|
-
```toml
|
|
33
|
-
[mcp_servers.vivix-studio-chat]
|
|
34
|
-
url = "http://127.0.0.1:<host-port>/v1/user/http/studio-chat/mcp"
|
|
35
|
-
|
|
36
|
-
[mcp_servers.vivix-studio-chat.http_headers]
|
|
37
|
-
Authorization = "Bearer <route-credential>"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Keep the credential in the client's private configuration. It authorizes this exact plugin route. The Host derives it from the profile's existing persistent browser key. The saved Host port and route credential survive Host restarts. CLI bearer credentials continue rotating at startup. Start the Host through the Studio CLI before reconnecting a stopped Host.
|
|
41
|
-
|
|
42
|
-
The plugin requires Studio plugin API 0.2.6. It exposes discovery and media reads on the same connection as `run_studio_action`, the app-only `studio_card_action`, and `ui://studio/chat/v6.html`. Its connection PID equals the Studio Host PID. Disabling the plugin removes the route through the normal plugin lifecycle. The current bundled MCP dependency requires an explicit Host restart for code upgrades when the generic reloader reports `restart_required`.
|
|
43
|
-
|
|
44
|
-
## Discover and read through one connection
|
|
45
|
-
|
|
46
|
-
`list_chat_capabilities({})` defaults to `{kind:"user",id:"user"}` and returns ready reusable components, declared chat operations and read-only media queries with their actual `scope` and `target`. Component entries come from the enabled provider's existing `components.list`; the adapter does not keep a second component registry. Generic interactions need a user-scoped component provider and do not create a business project.
|
|
47
|
-
|
|
48
|
-
Pass the returned route to `describe_chat_capability({scope,target,componentId?})`. A component description contains its props, result, selected render input and examples, with local schema references intact. For saved project operations, use the selected project's explicit scope. The Host still enforces grants, readiness, bindings and receipts. Legacy `projectId` input remains supported; supplying both it and `scope` is rejected.
|
|
49
|
-
|
|
50
|
-
`query_studio_media({scope,target,input})` invokes only a discovered media query with read effects and no confirmation. Read its input schema first. Returned records, task output refs and file selections provide the immutable `ref: {storeId,objectId,versionId}` for `resolve_chat_media({scope,ref,fileId?})`.
|
|
51
|
-
|
|
52
|
-
The resolver delegates `{ref,fileId?,access:"https"}` to the existing backend file-access operation. The file service checks the selected bytes, follows a matching saved origin, reuses a usable stored HTTPS URL, or asks the original API provider for a fresh read ticket by its persisted remote ID and original task identity. Ordinary local reads keep their existing behavior. An unmatched local file is an explicit error; resolving never uploads, generates or substitutes another version. The MCP response contains the fixed ref, file ID, MIME type, HTTPS URL and optional expiry, without the Host path.
|
|
53
|
-
|
|
54
|
-
Tool `content` is a short readable receipt. `structuredContent` contains model-readable creative data and routing. Signed action bindings, the script digest and prepared messages travel in `_meta` for the App. The page loads the registered script through a read-only MCP resource and verifies it against the saved digest before mounting the card. The page also accepts legacy replies whose public data contains bindings. A tool return proves neither that a client displayed the card nor that a click delivered a continuation; those require separate UI evidence.
|
|
55
|
-
|
|
56
|
-
The adapter's `resourceDomains` configuration declares canonical HTTPS origins for media and other resources. Its default is the Official media CDN, `https://static.vivi-x.ai`. Declare any additional verified source origins explicitly in this adapter's configuration. Discovery returns the active `resourceDomains`; a readable URL alone does not establish that a native host permits the iframe to load it. The component's own `mediaOrigins` further restricts each card. Do not use URL proxies, rehosting or disabled checks to evade a host URL-safety rejection.
|
|
57
|
-
|
|
58
|
-
- [Installation-to-card acceptance](acceptance/README.md)
|
|
59
|
-
- [Card page and sandbox](chat-ui/README.md)
|
|
60
|
-
|
|
61
|
-
## Discover native action targets
|
|
62
|
-
|
|
63
|
-
Search `list_chat_capabilities({scope,kind:"nativeOperation",query,offset,limit})`.
|
|
64
|
-
The default limit is 20, the maximum is 100, and nextOffset identifies the next page.
|
|
65
|
-
Describe the returned target with kind=nativeOperation to read input/output schemas,
|
|
66
|
-
effects, confirm and contract. This includes operations without a chat declaration.
|
|
67
|
-
Discovery reads metadata without invoking business operations; default component
|
|
68
|
-
discovery does not expand into the whole native catalog.
|
|
69
|
-
|
|
70
|
-
An installed source may provide `dynamicActions(context)`. It resolves native
|
|
71
|
-
bindings from initial input or authenticated binding context. The adapter admits
|
|
72
|
-
those exact same-scope targets through host.operations, signs them with the source
|
|
73
|
-
and retains invokeBound recovery. The resolver is installed server code; browser
|
|
74
|
-
input never supplies a destination or callback. Static dependency rules are unchanged.
|
|
75
|
-
|
|
76
|
-
## Declare a chat operation
|
|
77
|
-
|
|
78
|
-
The App-only `read_local_media` tool reads a supplied absolute audio/video `path`
|
|
79
|
-
and byte `offset` directly on the local Host. Each response contains at most
|
|
80
|
-
256 KiB in `_meta["studio/media"]`; binary data does not enter public tool output.
|
|
81
|
-
The component receives an optional `readMedia` callback through the sandbox bridge,
|
|
82
|
-
which accepts only paths declared by the original card projection. Later reads
|
|
83
|
-
carry the initial file identity/size/mtime and reject changes. No preview registry,
|
|
84
|
-
public media endpoint, import or CLI SDK change is involved. Existing HTTPS media
|
|
85
|
-
and action dispatch keep their current routes. Use a matching component package
|
|
86
|
-
and adapter; local paths require the Host to share the caller's filesystem.
|
|
87
|
-
|
|
88
|
-
A business plugin publishes `extensions: { chat: { component, projectResult, actions } }`
|
|
89
|
-
on its operation and registers the component in the manifest's `components` field.
|
|
90
|
-
The adapter routes `(action, input)` to the declared destination. Business plugins
|
|
91
|
-
own object identity, validation, input mapping, and writes. See the
|
|
92
|
-
[component contract](chat-ui/README.md) for Props and Host receipt recovery.
|
|
93
|
-
|
|
94
|
-
Card projectors may return optional server-only `bindingContext` JSON. The adapter
|
|
95
|
-
puts it inside the existing signed Host operation bindings, strips the top-level
|
|
96
|
-
field from the public projection, and supplies the authenticated snapshot as
|
|
97
|
-
`ChatActionContext.bindingContext` and `ChatProjectionContext.bindingContext`.
|
|
98
|
-
Browser action input never supplies that context. Updated projections can replace
|
|
99
|
-
it; unchanged legacy cards omit it and keep context-free bindings. The Host keeps
|
|
100
|
-
its existing size limit, scope/caller authentication, generation validation and
|
|
101
|
-
receipt-before-preparation replay. Context is signed for integrity, not encrypted;
|
|
102
|
-
do not put secrets in it.
|
|
103
|
-
|
|
104
|
-
## Send a follow-up message
|
|
105
|
-
|
|
106
|
-
A declared action can provide `prepareMessage(request, context)` instead of a
|
|
107
|
-
target. The adapter authenticates the original source binding and passes its
|
|
108
|
-
server-owned context to this callback. The callback returns `{intent, data}` with
|
|
109
|
-
a nonempty intent and JSON object data. This read-only path invokes no business
|
|
110
|
-
operation and creates no business receipt.
|
|
111
|
-
|
|
112
|
-
The outer MCP App sends the prepared content through the current client's
|
|
113
|
-
`sendMessage` API. The sandbox receives the result status, never the prepared
|
|
114
|
-
message metadata. Client confirmation means the message was sent, while business
|
|
115
|
-
changes require the subsequent conversation turn and persisted readback.
|
|
116
|
-
|
|
117
|
-
Unsupported or rejected sends retain the draft. Unknown sends retain their
|
|
118
|
-
original request identity and are not automatically resent. The component's
|
|
119
|
-
prompt and target actions remain exclusive per button. No context-update API or
|
|
120
|
-
widget-state write substitutes for message delivery.
|