@joai/warps-mcp 1.0.0-beta.27 → 1.0.0-beta.29

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/index.d.cts CHANGED
@@ -61,7 +61,7 @@ declare const buildZodInputSchema: (inputs: WarpActionInput[], config: WarpClien
61
61
  declare const convertActionToTool: (warp: Warp, action: WarpTransferAction | WarpContractAction | WarpCollectAction | WarpQueryAction, description: string | undefined, primaryActionInputs: WarpActionInput[] | undefined, resource: WarpMcpResource | null, config: WarpClientConfig) => WarpMcpTool;
62
62
  declare const convertMcpActionToTool: (warp: Warp, action: WarpMcpAction, description: string | undefined, primaryActionInputs: WarpActionInput[] | undefined, resource: WarpMcpResource | null, config: WarpClientConfig) => WarpMcpTool;
63
63
 
64
- declare const createAppResource: (warp: Warp, appUrl: string, config: WarpClientConfig) => Promise<WarpMcpResource | null>;
64
+ declare const createAppResource: (warp: Warp, componentPath: string, config: WarpClientConfig) => Promise<WarpMcpResource | null>;
65
65
 
66
66
  declare const convertWarpToMcpCapabilities: (warp: Warp, config: WarpClientConfig) => Promise<WarpMcpCapabilities>;
67
67
  declare const convertWarpsToMcpCapabilities: (warps: Warp[], config: WarpClientConfig) => Promise<WarpMcpCapabilities[]>;
package/dist/index.d.ts CHANGED
@@ -61,7 +61,7 @@ declare const buildZodInputSchema: (inputs: WarpActionInput[], config: WarpClien
61
61
  declare const convertActionToTool: (warp: Warp, action: WarpTransferAction | WarpContractAction | WarpCollectAction | WarpQueryAction, description: string | undefined, primaryActionInputs: WarpActionInput[] | undefined, resource: WarpMcpResource | null, config: WarpClientConfig) => WarpMcpTool;
62
62
  declare const convertMcpActionToTool: (warp: Warp, action: WarpMcpAction, description: string | undefined, primaryActionInputs: WarpActionInput[] | undefined, resource: WarpMcpResource | null, config: WarpClientConfig) => WarpMcpTool;
63
63
 
64
- declare const createAppResource: (warp: Warp, appUrl: string, config: WarpClientConfig) => Promise<WarpMcpResource | null>;
64
+ declare const createAppResource: (warp: Warp, componentPath: string, config: WarpClientConfig) => Promise<WarpMcpResource | null>;
65
65
 
66
66
  declare const convertWarpToMcpCapabilities: (warp: Warp, config: WarpClientConfig) => Promise<WarpMcpCapabilities>;
67
67
  declare const convertWarpsToMcpCapabilities: (warps: Warp[], config: WarpClientConfig) => Promise<WarpMcpCapabilities[]>;
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";var h=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},L=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J(e))!U.call(t,o)&&o!==r&&h(t,o,{get:()=>e[o],enumerable:!(n=q(e,o))||n.enumerable});return t};var F=t=>L(h({},"__esModule",{value:!0}),t);var it={};D(it,{WarpMcp:()=>z,buildZodInputSchema:()=>M,convertActionToTool:()=>b,convertMcpActionToTool:()=>C,convertMcpArgsToWarpInputs:()=>A,convertMcpToolToWarp:()=>R,convertPromptActionToPrompt:()=>S,convertWarpToMcpCapabilities:()=>$,convertWarpsToMcpCapabilities:()=>X,createAppResource:()=>P,createMcpServerFromWarps:()=>ot,extractTextOrUndefined:()=>u,interpolatePromptWithArgs:()=>v});module.exports=F(it);var T=require("@joai/warps"),A=(t,e)=>{let{action:r}=(0,T.getWarpPrimaryAction)(t);if(!r.inputs)return[];let n=new T.WarpSerializer;return r.inputs.map(o=>{let i=o.as||o.name,a=e[i]??o.default??null;return a===null&&o.type==="bool"?n.nativeToString(o.type,!1):n.nativeToString(o.type,a)})};var f=require("@joai/warps");var W=require("@joai/warps"),m=require("zod");var V=t=>{if(t){if(Array.isArray(t))return t;if(typeof t=="object")return Object.keys(t)}},I=t=>(t.includes(":")?t.split(":").slice(1).join(":"):t).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,e=>e.includes("_")?"_":e).replace(/_+/g,"_"),H=(t,e)=>{let r,n=t.type.toLowerCase();n==="string"||n==="address"||n==="hex"?r=m.z.string():n==="number"||n==="uint8"||n==="uint16"||n==="uint32"||n==="uint64"||n==="uint128"||n==="uint256"?r=m.z.number():n==="bool"||n==="boolean"?r=m.z.boolean():n==="biguint"?r=m.z.string():r=m.z.string(),typeof t.min=="number"&&r instanceof m.z.ZodNumber&&(r=r.min(t.min)),typeof t.max=="number"&&r instanceof m.z.ZodNumber&&(r=r.max(t.max)),t.pattern&&r instanceof m.z.ZodString&&(r=r.regex(new RegExp(t.pattern)));let o=V(t.options);if(o&&o.length>0){if(r instanceof m.z.ZodString)r=m.z.enum(o);else if(r instanceof m.z.ZodNumber){let l=o.map(s=>Number(s)).filter(s=>!isNaN(s));l.length>0&&(r=r.refine(s=>l.includes(s),{message:`Value must be one of: ${l.join(", ")}`}))}}let i=[],a=u(t.description,e);a&&i.push(a),t.bot&&i.push(t.bot),i.push(`Type: ${t.type}`),i.push(t.required?"Required":"Optional"),o&&o.length>0&&i.push(`Options: ${o.join(", ")}`);let c=u(t.patternDescription,e);c&&i.push(c);let p=i.join(". ");return p&&(r=r.describe(p)),t.required!==!0&&(r=r.optional()),r},M=(t,e)=>{let r={};for(let n of t){if(n.source==="hidden"||n.source!=="field")continue;let o=n.as||n.name;r[o]=H(n,e)}return W.WarpLogger.info("[MCP] buildZodInputSchema - inputs:",t.length,"shape keys:",Object.keys(r)),Object.keys(r).length>0?r:void 0},b=(t,e,r,n,o,i)=>{let a=n||e.inputs||[],c=M(a,i),p=I(t.name);W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${p}, inputsToUse: ${a.length}, inputSchema keys:`,c?Object.keys(c):"undefined");let l={name:p,description:r,inputSchema:c,meta:k(t,o,i)};return W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${p}, meta:`,JSON.stringify(l.meta,null,2)),l},C=(t,e,r,n,o,i)=>{let a=n||e.inputs||[],c=M(a,i),p=e.destination.tool,l=I(p),s={name:l,description:r,inputSchema:c,meta:k(t,o,i)};return W.WarpLogger.info(`[MCP] convertMcpActionToTool - tool: ${l}, meta:`,JSON.stringify(s.meta,null,2)),s},k=(t,e,r)=>{let n={"openai/widgetAccessible":!0};if(e&&(n["openai/outputTemplate"]=e.uri),t.messages){let o=u(t.messages.invoking,r),i=u(t.messages.invoked,r);o&&(n["openai/toolInvocation/invoking"]=o),i&&(n["openai/toolInvocation/invoked"]=i)}return n};var x=require("@joai/warps");var Q=async t=>{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to download app from ${t}: HTTP ${e.status} ${e.statusText}`);return e.text()},_=(t,e)=>{if(e.startsWith("http://")||e.startsWith("https://"))return e;let r=new URL(t);return new URL(e,r).href},B=async(t,e)=>{let r=/<link[^>]+rel=["']stylesheet["'][^>]+href=["']([^"']+)["'][^>]*>/gi,n=/<script[^>]+src=["']([^"']+)["'][^>]*><\/script>/gi,o=[],i;for(;(i=r.exec(t))!==null;){let p=i[0],l=_(e,i[1]);o.push(fetch(l).then(s=>s.ok?s.text():"").then(s=>({match:p,content:s?`<style>${s}</style>`:""})).catch(()=>({match:p,content:""})))}for(;(i=n.exec(t))!==null;){let p=i[0],l=_(e,i[1]);o.push(fetch(l).then(s=>s.ok?s.text():"").then(s=>({match:p,content:s?`<script>${s}</script>`:""})).catch(()=>({match:p,content:""})))}if(o.length===0)return t;let a=await Promise.all(o),c=t;for(let{match:p,content:l}of a)c=c.replace(p,l||"");return c},G=t=>{let e=t;return e=e.replace(/<html[^>]*>/gi,"").replace(/<\/html>/gi,""),e=e.replace(/<head[^>]*>/gi,"").replace(/<\/head>/gi,""),e=e.replace(/<body[^>]*>/gi,"").replace(/<\/body>/gi,""),e.trim()},K=(t,e)=>{let r=`<script type="application/json" id="warp-app-data">${JSON.stringify(e)}</script>`,n=G(t);return`${r}
2
- ${n}`},P=async(t,e,r)=>{if(!t.meta?.identifier)return null;try{let n=await Q(e);n=await B(n,e);let o={warp:{name:t.name,title:u(t.title,r),description:u(t.description,r)}};return{name:t.name,uri:`ui://widget/${t.meta.identifier}`,description:`ChatGPT app for ${t.name}`,mimeType:"text/html+skybridge",content:K(n,o)}}catch(n){let o=n instanceof Error?n.message:String(n),i=n instanceof Error?n.stack:void 0;return x.WarpLogger.error(`[MCP] Failed to create app resource for warp "${t.name}" (url: ${e}):`,o),i&&x.WarpLogger.error("[MCP] Error stack:",i),null}};var $=async(t,e)=>{let r=null,n=null,o=null;if(t.ui&&t.ui!=="table"&&(n=await P(t,t.ui,e)),t.actions.length===0)return{tool:null,resource:n,prompt:null};try{let{action:i}=(0,f.getWarpPrimaryAction)(t),a=u(t.description,e)||u(i.description,e);if(i.type==="prompt")o=S(t,i,a,e);else if(i.type==="mcp"){let c=i;c.destination&&(r=C(t,c,a,i.inputs,n,e))}else r=b(t,i,a,i.inputs,n,e)}catch{return{tool:null,resource:n,prompt:null}}return{tool:r,resource:n,prompt:o}},X=async(t,e)=>Promise.all(t.map(r=>$(r,e))),Y=(t,e)=>e==="date-time"||e==="date"||t==="string"?"string":t==="number"||t==="integer"?"uint256":t==="boolean"?"bool":"string",R=async(t,e,r,n)=>{let o=[];if(e.inputSchema?.properties){let c=e.inputSchema.properties,p=e.inputSchema.required||[];Object.entries(c).forEach(([l,s])=>{let d=p.includes(l),g=Y(s.type||"string",s.format),y={name:l,label:typeof s.title=="string"?{en:s.title}:s.title||{en:l},description:s.description?{en:s.description.trim()}:null,type:g,position:`payload:${l}`,source:"field",required:d,...s.default!==void 0&&typeof s.default=="string"||typeof s.default=="number"||typeof s.default=="boolean"?{default:s.default}:{}};o.push(y)})}let i={};e.outputSchema?.properties&&Object.keys(e.outputSchema.properties).forEach(c=>{i[c]=`out.${c}`});let a={type:"mcp",label:{en:e.name},description:e.description?{en:e.description.trim()}:null,destination:{url:r,tool:e.name,headers:n},inputs:o};return await new f.WarpBuilder(t).setName(e.name||"unnamed_tool").setTitle({en:e.name||"Unnamed Tool"}).setDescription(e.description?{en:e.description.trim()}:null).addAction(a).setOutput(Object.keys(i).length>0?i:null).build(!1)},u=(t,e)=>t&&(0,f.resolveWarpText)(t,e)||void 0;var v=(t,e)=>{let r=t;for(let[n,o]of Object.entries(e)){let i=new RegExp(`\\{\\{\\s*${n}\\s*\\}\\}`,"g");r=r.replace(i,o??"")}return r},tt=t=>(t.includes(":")?t.split(":").slice(1).join(":"):t).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,e=>e.includes("_")?"_":e).replace(/_+/g,"_"),et=(t,e)=>{let r=[];for(let n of t){if(n.source==="hidden"||n.source!=="field")continue;let o=n.as||n.name,i=u(n.description,e);r.push({name:o,description:i,required:n.required===!0})}return r},S=(t,e,r,n)=>{let o=tt(t.name),i=e.inputs||[],a=et(i,n);return{name:o,description:r,arguments:a.length>0?a:void 0,prompt:e.prompt}};var w=require("@modelcontextprotocol/sdk/server/mcp.js"),j=require("@modelcontextprotocol/sdk/server/zod-compat.js"),Z=require("zod");var rt=t=>{if(t)return typeof t=="object"&&"_zod"in t?t._zod:typeof t=="object"&&!Array.isArray(t)&&(0,j.normalizeObjectSchema)(t)||t},nt=t=>{if(!t.arguments||t.arguments.length===0)return;let e={};for(let r of t.arguments){let n=Z.z.string();r.description&&(n=n.describe(r.description)),r.required||(n=n.optional()),e[r.name]=n}return e},ot=(t,e,r,n)=>{let o=new w.McpServer({name:t.name,version:t.version||"1.0.0"}),i=t.executor||n;for(let a=0;a<r.length;a++){let{tool:c,resource:p,prompt:l}=r[a],s=e[a];if(c){let d=rt(c.inputSchema),g={description:c.description||"",inputSchema:d,...c.meta&&{_meta:c.meta}};o.registerTool(c.name,g,async y=>{if(i){let E=A(s,y||{});return await i(s,E)}return{content:[{type:"text",text:`Tool ${c.name} executed successfully`}]}})}if(p&&o.registerResource(p.name||p.uri,p.uri,{description:p.description,mimeType:p.mimeType},async()=>{let d={uri:p.uri,text:p.content||"",mimeType:p.mimeType};return p.meta&&(d._meta=p.meta),{contents:[d]}}),l){let d=nt(l);o.registerPrompt(l.name,{description:l.description||"",argsSchema:d},g=>({messages:[{role:"user",content:{type:"text",text:v(l.prompt,g)}}]}))}}return o};var O=require("@modelcontextprotocol/sdk/client/index.js"),N=require("@modelcontextprotocol/sdk/client/streamableHttp.js");var z=class{constructor(e){this.config=e}async getWarpsFromTools(e,r){let n=new N.StreamableHTTPClientTransport(new URL(e),{requestInit:{headers:r||{}}}),o=new O.Client({name:"warps-mcp-client",version:"1.0.0"},{capabilities:{}});try{await o.connect(n);let i=await o.listTools();return await o.close(),await Promise.all(i.tools.map(a=>R(this.config,a,e,r)))}catch(i){throw await o.close().catch(()=>{}),i}}};0&&(module.exports={WarpMcp,buildZodInputSchema,convertActionToTool,convertMcpActionToTool,convertMcpArgsToWarpInputs,convertMcpToolToWarp,convertPromptActionToPrompt,convertWarpToMcpCapabilities,convertWarpsToMcpCapabilities,createAppResource,createMcpServerFromWarps,extractTextOrUndefined,interpolatePromptWithArgs});
1
+ "use strict";var A=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var r in t)A(e,r,{get:t[r],enumerable:!0})},D=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q(t))!J.call(e,o)&&o!==r&&A(e,o,{get:()=>t[o],enumerable:!(n=E(t,o))||n.enumerable});return e};var L=e=>D(A({},"__esModule",{value:!0}),e);var te={};U(te,{WarpMcp:()=>v,buildZodInputSchema:()=>M,convertActionToTool:()=>C,convertMcpActionToTool:()=>b,convertMcpArgsToWarpInputs:()=>h,convertMcpToolToWarp:()=>S,convertPromptActionToPrompt:()=>R,convertWarpToMcpCapabilities:()=>k,convertWarpsToMcpCapabilities:()=>Q,createAppResource:()=>P,createMcpServerFromWarps:()=>ee,extractTextOrUndefined:()=>m,interpolatePromptWithArgs:()=>z});module.exports=L(te);var T=require("@joai/warps"),h=(e,t)=>{let{action:r}=(0,T.getWarpPrimaryAction)(e);if(!r.inputs)return[];let n=new T.WarpSerializer;return r.inputs.map(o=>{let i=o.as||o.name,s=t[i]??o.default??null;return s===null&&o.type==="bool"?n.nativeToString(o.type,!1):n.nativeToString(o.type,s)})};var d=require("@joai/warps");var W=require("@joai/warps"),l=require("zod");var F=e=>{if(e){if(Array.isArray(e))return e;if(typeof e=="object")return Object.keys(e)}},I=e=>(e.includes(":")?e.split(":").slice(1).join(":"):e).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,t=>t.includes("_")?"_":t).replace(/_+/g,"_"),V=(e,t)=>{let r,n=e.type.toLowerCase();n==="string"||n==="address"||n==="hex"?r=l.z.string():n==="number"||n==="uint8"||n==="uint16"||n==="uint32"||n==="uint64"||n==="uint128"||n==="uint256"?r=l.z.number():n==="bool"||n==="boolean"?r=l.z.boolean():n==="biguint"?r=l.z.string():r=l.z.string(),typeof e.min=="number"&&r instanceof l.z.ZodNumber&&(r=r.min(e.min)),typeof e.max=="number"&&r instanceof l.z.ZodNumber&&(r=r.max(e.max)),e.pattern&&r instanceof l.z.ZodString&&(r=r.regex(new RegExp(e.pattern)));let o=F(e.options);if(o&&o.length>0){if(r instanceof l.z.ZodString)r=l.z.enum(o);else if(r instanceof l.z.ZodNumber){let u=o.map(a=>Number(a)).filter(a=>!isNaN(a));u.length>0&&(r=r.refine(a=>u.includes(a),{message:`Value must be one of: ${u.join(", ")}`}))}}let i=[],s=m(e.description,t);s&&i.push(s),e.bot&&i.push(e.bot),i.push(`Type: ${e.type}`),i.push(e.required?"Required":"Optional"),o&&o.length>0&&i.push(`Options: ${o.join(", ")}`);let p=m(e.patternDescription,t);p&&i.push(p);let c=i.join(". ");return c&&(r=r.describe(c)),e.required!==!0&&(r=r.optional()),r},M=(e,t)=>{let r={};for(let n of e){if(n.source==="hidden"||n.source!=="field")continue;let o=n.as||n.name;r[o]=V(n,t)}return W.WarpLogger.info("[MCP] buildZodInputSchema - inputs:",e.length,"shape keys:",Object.keys(r)),Object.keys(r).length>0?r:void 0},C=(e,t,r,n,o,i)=>{let s=n||t.inputs||[],p=M(s,i),c=I(e.name);W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${c}, inputsToUse: ${s.length}, inputSchema keys:`,p?Object.keys(p):"undefined");let u={name:c,description:r,inputSchema:p,meta:_(e,o,i)};return W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${c}, meta:`,JSON.stringify(u.meta,null,2)),u},b=(e,t,r,n,o,i)=>{let s=n||t.inputs||[],p=M(s,i),c=t.destination.tool,u=I(c),a={name:u,description:r,inputSchema:p,meta:_(e,o,i)};return W.WarpLogger.info(`[MCP] convertMcpActionToTool - tool: ${u}, meta:`,JSON.stringify(a.meta,null,2)),a},_=(e,t,r)=>{let n={"openai/widgetAccessible":!0};if(t&&(n["openai/outputTemplate"]=t.uri),e.messages){let o=m(e.messages.invoking,r),i=m(e.messages.invoked,r);o&&(n["openai/toolInvocation/invoking"]=o),i&&(n["openai/toolInvocation/invoked"]=i)}return n};var x=require("@joai/warps"),H=async e=>{if(e.startsWith("http://")||e.startsWith("https://")){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to download component from ${e}: HTTP ${t.status} ${t.statusText}`);return t.text()}throw new Error(`Unsupported component path: ${e}`)},P=async(e,t,r)=>{if(!e.meta?.identifier)return null;try{let n=await H(t);return{name:e.name,uri:`ui://widget/${e.meta.identifier}`,description:`ChatGPT app for ${e.name}`,mimeType:"text/html+skybridge",content:n}}catch(n){let o=n instanceof Error?n.message:String(n),i=n instanceof Error?n.stack:void 0;return x.WarpLogger.error(`[MCP] Failed to create app resource for warp "${e.name}" (path: ${t}):`,o),i&&x.WarpLogger.error("[MCP] Error stack:",i),null}};var k=async(e,t)=>{let r=null,n=null,o=null;if(e.ui&&e.ui!=="table"&&(n=await P(e,e.ui,t)),e.actions.length===0)return{tool:null,resource:n,prompt:null};try{let{action:i}=(0,d.getWarpPrimaryAction)(e),s=m(e.description,t)||m(i.description,t);if(i.type==="prompt")o=R(e,i,s,t);else if(i.type==="mcp"){let p=i;p.destination&&(r=b(e,p,s,i.inputs,n,t))}else r=C(e,i,s,i.inputs,n,t)}catch{return{tool:null,resource:n,prompt:null}}return{tool:r,resource:n,prompt:o}},Q=async(e,t)=>Promise.all(e.map(r=>k(r,t))),B=(e,t)=>t==="date-time"||t==="date"||e==="string"?"string":e==="number"||e==="integer"?"uint256":e==="boolean"?"bool":"string",S=async(e,t,r,n)=>{let o=[];if(t.inputSchema?.properties){let p=t.inputSchema.properties,c=t.inputSchema.required||[];Object.entries(p).forEach(([u,a])=>{let f=c.includes(u),g=B(a.type||"string",a.format),y={name:u,label:typeof a.title=="string"?{en:a.title}:a.title||{en:u},description:a.description?{en:a.description.trim()}:null,type:g,position:`payload:${u}`,source:"field",required:f,...a.default!==void 0&&typeof a.default=="string"||typeof a.default=="number"||typeof a.default=="boolean"?{default:a.default}:{}};o.push(y)})}let i={};t.outputSchema?.properties&&Object.keys(t.outputSchema.properties).forEach(p=>{i[p]=`out.${p}`});let s={type:"mcp",label:{en:t.name},description:t.description?{en:t.description.trim()}:null,destination:{url:r,tool:t.name,headers:n},inputs:o};return await new d.WarpBuilder(e).setName(t.name||"unnamed_tool").setTitle({en:t.name||"Unnamed Tool"}).setDescription(t.description?{en:t.description.trim()}:null).addAction(s).setOutput(Object.keys(i).length>0?i:null).build(!1)},m=(e,t)=>e&&(0,d.resolveWarpText)(e,t)||void 0;var z=(e,t)=>{let r=e;for(let[n,o]of Object.entries(t)){let i=new RegExp(`\\{\\{\\s*${n}\\s*\\}\\}`,"g");r=r.replace(i,o??"")}return r},G=e=>(e.includes(":")?e.split(":").slice(1).join(":"):e).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,t=>t.includes("_")?"_":t).replace(/_+/g,"_"),K=(e,t)=>{let r=[];for(let n of e){if(n.source==="hidden"||n.source!=="field")continue;let o=n.as||n.name,i=m(n.description,t);r.push({name:o,description:i,required:n.required===!0})}return r},R=(e,t,r,n)=>{let o=G(e.name),i=t.inputs||[],s=K(i,n);return{name:o,description:r,arguments:s.length>0?s:void 0,prompt:t.prompt}};var Z=require("@modelcontextprotocol/sdk/server/mcp.js"),$=require("@modelcontextprotocol/sdk/server/zod-compat.js"),w=require("zod");var X=e=>{if(e)return typeof e=="object"&&"_zod"in e?e._zod:typeof e=="object"&&!Array.isArray(e)&&(0,$.normalizeObjectSchema)(e)||e},Y=e=>{if(!e.arguments||e.arguments.length===0)return;let t={};for(let r of e.arguments){let n=w.z.string();r.description&&(n=n.describe(r.description)),r.required||(n=n.optional()),t[r.name]=n}return t},ee=(e,t,r,n)=>{let o=new Z.McpServer({name:e.name,version:e.version||"1.0.0"}),i=e.executor||n;for(let s=0;s<r.length;s++){let{tool:p,resource:c,prompt:u}=r[s],a=t[s];if(p){let f=X(p.inputSchema),g={description:p.description||"",inputSchema:f,...p.meta&&{_meta:p.meta}};o.registerTool(p.name,g,async y=>{if(i){let N=h(a,y||{});return await i(a,N)}return{content:[{type:"text",text:`Tool ${p.name} executed successfully`}]}})}if(c&&o.registerResource(c.name||c.uri,c.uri,{description:c.description,mimeType:c.mimeType},async()=>{let f={uri:c.uri,text:c.content||"",mimeType:c.mimeType};return c.meta&&(f._meta=c.meta),{contents:[f]}}),u){let f=Y(u);o.registerPrompt(u.name,{description:u.description||"",argsSchema:f},g=>({messages:[{role:"user",content:{type:"text",text:z(u.prompt,g)}}]}))}}return o};var j=require("@modelcontextprotocol/sdk/client/index.js"),O=require("@modelcontextprotocol/sdk/client/streamableHttp.js");var v=class{constructor(t){this.config=t}async getWarpsFromTools(t,r){let n=new O.StreamableHTTPClientTransport(new URL(t),{requestInit:{headers:r||{}}}),o=new j.Client({name:"warps-mcp-client",version:"1.0.0"},{capabilities:{}});try{await o.connect(n);let i=await o.listTools();return await o.close(),await Promise.all(i.tools.map(s=>S(this.config,s,t,r)))}catch(i){throw await o.close().catch(()=>{}),i}}};0&&(module.exports={WarpMcp,buildZodInputSchema,convertActionToTool,convertMcpActionToTool,convertMcpArgsToWarpInputs,convertMcpToolToWarp,convertPromptActionToPrompt,convertWarpToMcpCapabilities,convertWarpsToMcpCapabilities,createAppResource,createMcpServerFromWarps,extractTextOrUndefined,interpolatePromptWithArgs});
package/dist/index.mjs CHANGED
@@ -1,2 +1 @@
1
- import{getWarpPrimaryAction as k,WarpSerializer as _}from"@joai/warps";var y=(t,e)=>{let{action:r}=k(t);if(!r.inputs)return[];let n=new _;return r.inputs.map(i=>{let o=i.as||i.name,a=e[o]??i.default??null;return a===null&&i.type==="bool"?n.nativeToString(i.type,!1):n.nativeToString(i.type,a)})};import{WarpBuilder as E,getWarpPrimaryAction as q,resolveWarpText as J}from"@joai/warps";import{WarpLogger as W}from"@joai/warps";import{z as m}from"zod";var $=t=>{if(t){if(Array.isArray(t))return t;if(typeof t=="object")return Object.keys(t)}},T=t=>(t.includes(":")?t.split(":").slice(1).join(":"):t).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,e=>e.includes("_")?"_":e).replace(/_+/g,"_"),w=(t,e)=>{let r,n=t.type.toLowerCase();n==="string"||n==="address"||n==="hex"?r=m.string():n==="number"||n==="uint8"||n==="uint16"||n==="uint32"||n==="uint64"||n==="uint128"||n==="uint256"?r=m.number():n==="bool"||n==="boolean"?r=m.boolean():n==="biguint"?r=m.string():r=m.string(),typeof t.min=="number"&&r instanceof m.ZodNumber&&(r=r.min(t.min)),typeof t.max=="number"&&r instanceof m.ZodNumber&&(r=r.max(t.max)),t.pattern&&r instanceof m.ZodString&&(r=r.regex(new RegExp(t.pattern)));let i=$(t.options);if(i&&i.length>0){if(r instanceof m.ZodString)r=m.enum(i);else if(r instanceof m.ZodNumber){let l=i.map(s=>Number(s)).filter(s=>!isNaN(s));l.length>0&&(r=r.refine(s=>l.includes(s),{message:`Value must be one of: ${l.join(", ")}`}))}}let o=[],a=u(t.description,e);a&&o.push(a),t.bot&&o.push(t.bot),o.push(`Type: ${t.type}`),o.push(t.required?"Required":"Optional"),i&&i.length>0&&o.push(`Options: ${i.join(", ")}`);let c=u(t.patternDescription,e);c&&o.push(c);let p=o.join(". ");return p&&(r=r.describe(p)),t.required!==!0&&(r=r.optional()),r},h=(t,e)=>{let r={};for(let n of t){if(n.source==="hidden"||n.source!=="field")continue;let i=n.as||n.name;r[i]=w(n,e)}return W.info("[MCP] buildZodInputSchema - inputs:",t.length,"shape keys:",Object.keys(r)),Object.keys(r).length>0?r:void 0},A=(t,e,r,n,i,o)=>{let a=n||e.inputs||[],c=h(a,o),p=T(t.name);W.info(`[MCP] convertActionToTool - tool: ${p}, inputsToUse: ${a.length}, inputSchema keys:`,c?Object.keys(c):"undefined");let l={name:p,description:r,inputSchema:c,meta:b(t,i,o)};return W.info(`[MCP] convertActionToTool - tool: ${p}, meta:`,JSON.stringify(l.meta,null,2)),l},M=(t,e,r,n,i,o)=>{let a=n||e.inputs||[],c=h(a,o),p=e.destination.tool,l=T(p),s={name:l,description:r,inputSchema:c,meta:b(t,i,o)};return W.info(`[MCP] convertMcpActionToTool - tool: ${l}, meta:`,JSON.stringify(s.meta,null,2)),s},b=(t,e,r)=>{let n={"openai/widgetAccessible":!0};if(e&&(n["openai/outputTemplate"]=e.uri),t.messages){let i=u(t.messages.invoking,r),o=u(t.messages.invoked,r);i&&(n["openai/toolInvocation/invoking"]=i),o&&(n["openai/toolInvocation/invoked"]=o)}return n};import{WarpLogger as C}from"@joai/warps";var j=async t=>{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to download app from ${t}: HTTP ${e.status} ${e.statusText}`);return e.text()},x=(t,e)=>{if(e.startsWith("http://")||e.startsWith("https://"))return e;let r=new URL(t);return new URL(e,r).href},Z=async(t,e)=>{let r=/<link[^>]+rel=["']stylesheet["'][^>]+href=["']([^"']+)["'][^>]*>/gi,n=/<script[^>]+src=["']([^"']+)["'][^>]*><\/script>/gi,i=[],o;for(;(o=r.exec(t))!==null;){let p=o[0],l=x(e,o[1]);i.push(fetch(l).then(s=>s.ok?s.text():"").then(s=>({match:p,content:s?`<style>${s}</style>`:""})).catch(()=>({match:p,content:""})))}for(;(o=n.exec(t))!==null;){let p=o[0],l=x(e,o[1]);i.push(fetch(l).then(s=>s.ok?s.text():"").then(s=>({match:p,content:s?`<script>${s}</script>`:""})).catch(()=>({match:p,content:""})))}if(i.length===0)return t;let a=await Promise.all(i),c=t;for(let{match:p,content:l}of a)c=c.replace(p,l||"");return c},O=t=>{let e=t;return e=e.replace(/<html[^>]*>/gi,"").replace(/<\/html>/gi,""),e=e.replace(/<head[^>]*>/gi,"").replace(/<\/head>/gi,""),e=e.replace(/<body[^>]*>/gi,"").replace(/<\/body>/gi,""),e.trim()},N=(t,e)=>{let r=`<script type="application/json" id="warp-app-data">${JSON.stringify(e)}</script>`,n=O(t);return`${r}
2
- ${n}`},P=async(t,e,r)=>{if(!t.meta?.identifier)return null;try{let n=await j(e);n=await Z(n,e);let i={warp:{name:t.name,title:u(t.title,r),description:u(t.description,r)}};return{name:t.name,uri:`ui://widget/${t.meta.identifier}`,description:`ChatGPT app for ${t.name}`,mimeType:"text/html+skybridge",content:N(n,i)}}catch(n){let i=n instanceof Error?n.message:String(n),o=n instanceof Error?n.stack:void 0;return C.error(`[MCP] Failed to create app resource for warp "${t.name}" (url: ${e}):`,i),o&&C.error("[MCP] Error stack:",o),null}};var U=async(t,e)=>{let r=null,n=null,i=null;if(t.ui&&t.ui!=="table"&&(n=await P(t,t.ui,e)),t.actions.length===0)return{tool:null,resource:n,prompt:null};try{let{action:o}=q(t),a=u(t.description,e)||u(o.description,e);if(o.type==="prompt")i=S(t,o,a,e);else if(o.type==="mcp"){let c=o;c.destination&&(r=M(t,c,a,o.inputs,n,e))}else r=A(t,o,a,o.inputs,n,e)}catch{return{tool:null,resource:n,prompt:null}}return{tool:r,resource:n,prompt:i}},$t=async(t,e)=>Promise.all(t.map(r=>U(r,e))),D=(t,e)=>e==="date-time"||e==="date"||t==="string"?"string":t==="number"||t==="integer"?"uint256":t==="boolean"?"bool":"string",R=async(t,e,r,n)=>{let i=[];if(e.inputSchema?.properties){let c=e.inputSchema.properties,p=e.inputSchema.required||[];Object.entries(c).forEach(([l,s])=>{let d=p.includes(l),f=D(s.type||"string",s.format),g={name:l,label:typeof s.title=="string"?{en:s.title}:s.title||{en:l},description:s.description?{en:s.description.trim()}:null,type:f,position:`payload:${l}`,source:"field",required:d,...s.default!==void 0&&typeof s.default=="string"||typeof s.default=="number"||typeof s.default=="boolean"?{default:s.default}:{}};i.push(g)})}let o={};e.outputSchema?.properties&&Object.keys(e.outputSchema.properties).forEach(c=>{o[c]=`out.${c}`});let a={type:"mcp",label:{en:e.name},description:e.description?{en:e.description.trim()}:null,destination:{url:r,tool:e.name,headers:n},inputs:i};return await new E(t).setName(e.name||"unnamed_tool").setTitle({en:e.name||"Unnamed Tool"}).setDescription(e.description?{en:e.description.trim()}:null).addAction(a).setOutput(Object.keys(o).length>0?o:null).build(!1)},u=(t,e)=>t&&J(t,e)||void 0;var v=(t,e)=>{let r=t;for(let[n,i]of Object.entries(e)){let o=new RegExp(`\\{\\{\\s*${n}\\s*\\}\\}`,"g");r=r.replace(o,i??"")}return r},L=t=>(t.includes(":")?t.split(":").slice(1).join(":"):t).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,e=>e.includes("_")?"_":e).replace(/_+/g,"_"),F=(t,e)=>{let r=[];for(let n of t){if(n.source==="hidden"||n.source!=="field")continue;let i=n.as||n.name,o=u(n.description,e);r.push({name:i,description:o,required:n.required===!0})}return r},S=(t,e,r,n)=>{let i=L(t.name),o=e.inputs||[],a=F(o,n);return{name:i,description:r,arguments:a.length>0?a:void 0,prompt:e.prompt}};import{McpServer as V}from"@modelcontextprotocol/sdk/server/mcp.js";import{normalizeObjectSchema as H}from"@modelcontextprotocol/sdk/server/zod-compat.js";import{z as Q}from"zod";var B=t=>{if(t)return typeof t=="object"&&"_zod"in t?t._zod:typeof t=="object"&&!Array.isArray(t)&&H(t)||t},G=t=>{if(!t.arguments||t.arguments.length===0)return;let e={};for(let r of t.arguments){let n=Q.string();r.description&&(n=n.describe(r.description)),r.required||(n=n.optional()),e[r.name]=n}return e},Ut=(t,e,r,n)=>{let i=new V({name:t.name,version:t.version||"1.0.0"}),o=t.executor||n;for(let a=0;a<r.length;a++){let{tool:c,resource:p,prompt:l}=r[a],s=e[a];if(c){let d=B(c.inputSchema),f={description:c.description||"",inputSchema:d,...c.meta&&{_meta:c.meta}};i.registerTool(c.name,f,async g=>{if(o){let I=y(s,g||{});return await o(s,I)}return{content:[{type:"text",text:`Tool ${c.name} executed successfully`}]}})}if(p&&i.registerResource(p.name||p.uri,p.uri,{description:p.description,mimeType:p.mimeType},async()=>{let d={uri:p.uri,text:p.content||"",mimeType:p.mimeType};return p.meta&&(d._meta=p.meta),{contents:[d]}}),l){let d=G(l);i.registerPrompt(l.name,{description:l.description||"",argsSchema:d},f=>({messages:[{role:"user",content:{type:"text",text:v(l.prompt,f)}}]}))}}return i};import{Client as K}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as X}from"@modelcontextprotocol/sdk/client/streamableHttp.js";var z=class{constructor(e){this.config=e}async getWarpsFromTools(e,r){let n=new X(new URL(e),{requestInit:{headers:r||{}}}),i=new K({name:"warps-mcp-client",version:"1.0.0"},{capabilities:{}});try{await i.connect(n);let o=await i.listTools();return await i.close(),await Promise.all(o.tools.map(a=>R(this.config,a,e,r)))}catch(o){throw await i.close().catch(()=>{}),o}}};export{z as WarpMcp,h as buildZodInputSchema,A as convertActionToTool,M as convertMcpActionToTool,y as convertMcpArgsToWarpInputs,R as convertMcpToolToWarp,S as convertPromptActionToPrompt,U as convertWarpToMcpCapabilities,$t as convertWarpsToMcpCapabilities,P as createAppResource,Ut as createMcpServerFromWarps,u as extractTextOrUndefined,v as interpolatePromptWithArgs};
1
+ import{getWarpPrimaryAction as I,WarpSerializer as _}from"@joai/warps";var y=(e,t)=>{let{action:r}=I(e);if(!r.inputs)return[];let n=new _;return r.inputs.map(i=>{let o=i.as||i.name,s=t[o]??i.default??null;return s===null&&i.type==="bool"?n.nativeToString(i.type,!1):n.nativeToString(i.type,s)})};import{WarpBuilder as w,getWarpPrimaryAction as j,resolveWarpText as O}from"@joai/warps";import{WarpLogger as W}from"@joai/warps";import{z as l}from"zod";var k=e=>{if(e){if(Array.isArray(e))return e;if(typeof e=="object")return Object.keys(e)}},T=e=>(e.includes(":")?e.split(":").slice(1).join(":"):e).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,t=>t.includes("_")?"_":t).replace(/_+/g,"_"),Z=(e,t)=>{let r,n=e.type.toLowerCase();n==="string"||n==="address"||n==="hex"?r=l.string():n==="number"||n==="uint8"||n==="uint16"||n==="uint32"||n==="uint64"||n==="uint128"||n==="uint256"?r=l.number():n==="bool"||n==="boolean"?r=l.boolean():n==="biguint"?r=l.string():r=l.string(),typeof e.min=="number"&&r instanceof l.ZodNumber&&(r=r.min(e.min)),typeof e.max=="number"&&r instanceof l.ZodNumber&&(r=r.max(e.max)),e.pattern&&r instanceof l.ZodString&&(r=r.regex(new RegExp(e.pattern)));let i=k(e.options);if(i&&i.length>0){if(r instanceof l.ZodString)r=l.enum(i);else if(r instanceof l.ZodNumber){let u=i.map(a=>Number(a)).filter(a=>!isNaN(a));u.length>0&&(r=r.refine(a=>u.includes(a),{message:`Value must be one of: ${u.join(", ")}`}))}}let o=[],s=m(e.description,t);s&&o.push(s),e.bot&&o.push(e.bot),o.push(`Type: ${e.type}`),o.push(e.required?"Required":"Optional"),i&&i.length>0&&o.push(`Options: ${i.join(", ")}`);let p=m(e.patternDescription,t);p&&o.push(p);let c=o.join(". ");return c&&(r=r.describe(c)),e.required!==!0&&(r=r.optional()),r},A=(e,t)=>{let r={};for(let n of e){if(n.source==="hidden"||n.source!=="field")continue;let i=n.as||n.name;r[i]=Z(n,t)}return W.info("[MCP] buildZodInputSchema - inputs:",e.length,"shape keys:",Object.keys(r)),Object.keys(r).length>0?r:void 0},h=(e,t,r,n,i,o)=>{let s=n||t.inputs||[],p=A(s,o),c=T(e.name);W.info(`[MCP] convertActionToTool - tool: ${c}, inputsToUse: ${s.length}, inputSchema keys:`,p?Object.keys(p):"undefined");let u={name:c,description:r,inputSchema:p,meta:C(e,i,o)};return W.info(`[MCP] convertActionToTool - tool: ${c}, meta:`,JSON.stringify(u.meta,null,2)),u},M=(e,t,r,n,i,o)=>{let s=n||t.inputs||[],p=A(s,o),c=t.destination.tool,u=T(c),a={name:u,description:r,inputSchema:p,meta:C(e,i,o)};return W.info(`[MCP] convertMcpActionToTool - tool: ${u}, meta:`,JSON.stringify(a.meta,null,2)),a},C=(e,t,r)=>{let n={"openai/widgetAccessible":!0};if(t&&(n["openai/outputTemplate"]=t.uri),e.messages){let i=m(e.messages.invoking,r),o=m(e.messages.invoked,r);i&&(n["openai/toolInvocation/invoking"]=i),o&&(n["openai/toolInvocation/invoked"]=o)}return n};import{WarpLogger as b}from"@joai/warps";var $=async e=>{if(e.startsWith("http://")||e.startsWith("https://")){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to download component from ${e}: HTTP ${t.status} ${t.statusText}`);return t.text()}throw new Error(`Unsupported component path: ${e}`)},x=async(e,t,r)=>{if(!e.meta?.identifier)return null;try{let n=await $(t);return{name:e.name,uri:`ui://widget/${e.meta.identifier}`,description:`ChatGPT app for ${e.name}`,mimeType:"text/html+skybridge",content:n}}catch(n){let i=n instanceof Error?n.message:String(n),o=n instanceof Error?n.stack:void 0;return b.error(`[MCP] Failed to create app resource for warp "${e.name}" (path: ${t}):`,i),o&&b.error("[MCP] Error stack:",o),null}};var N=async(e,t)=>{let r=null,n=null,i=null;if(e.ui&&e.ui!=="table"&&(n=await x(e,e.ui,t)),e.actions.length===0)return{tool:null,resource:n,prompt:null};try{let{action:o}=j(e),s=m(e.description,t)||m(o.description,t);if(o.type==="prompt")i=S(e,o,s,t);else if(o.type==="mcp"){let p=o;p.destination&&(r=M(e,p,s,o.inputs,n,t))}else r=h(e,o,s,o.inputs,n,t)}catch{return{tool:null,resource:n,prompt:null}}return{tool:r,resource:n,prompt:i}},ze=async(e,t)=>Promise.all(e.map(r=>N(r,t))),E=(e,t)=>t==="date-time"||t==="date"||e==="string"?"string":e==="number"||e==="integer"?"uint256":e==="boolean"?"bool":"string",P=async(e,t,r,n)=>{let i=[];if(t.inputSchema?.properties){let p=t.inputSchema.properties,c=t.inputSchema.required||[];Object.entries(p).forEach(([u,a])=>{let f=c.includes(u),d=E(a.type||"string",a.format),g={name:u,label:typeof a.title=="string"?{en:a.title}:a.title||{en:u},description:a.description?{en:a.description.trim()}:null,type:d,position:`payload:${u}`,source:"field",required:f,...a.default!==void 0&&typeof a.default=="string"||typeof a.default=="number"||typeof a.default=="boolean"?{default:a.default}:{}};i.push(g)})}let o={};t.outputSchema?.properties&&Object.keys(t.outputSchema.properties).forEach(p=>{o[p]=`out.${p}`});let s={type:"mcp",label:{en:t.name},description:t.description?{en:t.description.trim()}:null,destination:{url:r,tool:t.name,headers:n},inputs:i};return await new w(e).setName(t.name||"unnamed_tool").setTitle({en:t.name||"Unnamed Tool"}).setDescription(t.description?{en:t.description.trim()}:null).addAction(s).setOutput(Object.keys(o).length>0?o:null).build(!1)},m=(e,t)=>e&&O(e,t)||void 0;var R=(e,t)=>{let r=e;for(let[n,i]of Object.entries(t)){let o=new RegExp(`\\{\\{\\s*${n}\\s*\\}\\}`,"g");r=r.replace(o,i??"")}return r},q=e=>(e.includes(":")?e.split(":").slice(1).join(":"):e).trim().toLowerCase().replace(/\s+/g,"_").replace(/:/g,"_").replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,"").replace(/[_-]+/g,t=>t.includes("_")?"_":t).replace(/_+/g,"_"),J=(e,t)=>{let r=[];for(let n of e){if(n.source==="hidden"||n.source!=="field")continue;let i=n.as||n.name,o=m(n.description,t);r.push({name:i,description:o,required:n.required===!0})}return r},S=(e,t,r,n)=>{let i=q(e.name),o=t.inputs||[],s=J(o,n);return{name:i,description:r,arguments:s.length>0?s:void 0,prompt:t.prompt}};import{McpServer as U}from"@modelcontextprotocol/sdk/server/mcp.js";import{normalizeObjectSchema as D}from"@modelcontextprotocol/sdk/server/zod-compat.js";import{z as L}from"zod";var F=e=>{if(e)return typeof e=="object"&&"_zod"in e?e._zod:typeof e=="object"&&!Array.isArray(e)&&D(e)||e},V=e=>{if(!e.arguments||e.arguments.length===0)return;let t={};for(let r of e.arguments){let n=L.string();r.description&&(n=n.describe(r.description)),r.required||(n=n.optional()),t[r.name]=n}return t},Oe=(e,t,r,n)=>{let i=new U({name:e.name,version:e.version||"1.0.0"}),o=e.executor||n;for(let s=0;s<r.length;s++){let{tool:p,resource:c,prompt:u}=r[s],a=t[s];if(p){let f=F(p.inputSchema),d={description:p.description||"",inputSchema:f,...p.meta&&{_meta:p.meta}};i.registerTool(p.name,d,async g=>{if(o){let v=y(a,g||{});return await o(a,v)}return{content:[{type:"text",text:`Tool ${p.name} executed successfully`}]}})}if(c&&i.registerResource(c.name||c.uri,c.uri,{description:c.description,mimeType:c.mimeType},async()=>{let f={uri:c.uri,text:c.content||"",mimeType:c.mimeType};return c.meta&&(f._meta=c.meta),{contents:[f]}}),u){let f=V(u);i.registerPrompt(u.name,{description:u.description||"",argsSchema:f},d=>({messages:[{role:"user",content:{type:"text",text:R(u.prompt,d)}}]}))}}return i};import{Client as H}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as Q}from"@modelcontextprotocol/sdk/client/streamableHttp.js";var z=class{constructor(t){this.config=t}async getWarpsFromTools(t,r){let n=new Q(new URL(t),{requestInit:{headers:r||{}}}),i=new H({name:"warps-mcp-client",version:"1.0.0"},{capabilities:{}});try{await i.connect(n);let o=await i.listTools();return await i.close(),await Promise.all(o.tools.map(s=>P(this.config,s,t,r)))}catch(o){throw await i.close().catch(()=>{}),o}}};export{z as WarpMcp,A as buildZodInputSchema,h as convertActionToTool,M as convertMcpActionToTool,y as convertMcpArgsToWarpInputs,P as convertMcpToolToWarp,S as convertPromptActionToPrompt,N as convertWarpToMcpCapabilities,ze as convertWarpsToMcpCapabilities,x as createAppResource,Oe as createMcpServerFromWarps,m as extractTextOrUndefined,R as interpolatePromptWithArgs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/warps-mcp",
3
- "version": "1.0.0-beta.27",
3
+ "version": "1.0.0-beta.29",
4
4
  "description": "MCP adapter for Warps SDK",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",