@joai/warps-mcp 1.0.0-beta.27 → 1.0.0-beta.28
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
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,
|
|
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,
|
|
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,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
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 re={};U(re,{WarpMcp:()=>z,buildZodInputSchema:()=>M,convertActionToTool:()=>C,convertMcpActionToTool:()=>b,convertMcpArgsToWarpInputs:()=>h,convertMcpToolToWarp:()=>S,convertPromptActionToPrompt:()=>R,convertWarpToMcpCapabilities:()=>k,convertWarpsToMcpCapabilities:()=>B,createAppResource:()=>P,createMcpServerFromWarps:()=>te,extractTextOrUndefined:()=>m,interpolatePromptWithArgs:()=>v});module.exports=L(re);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 f=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(c=>Number(c)).filter(c=>!isNaN(c));u.length>0&&(r=r.refine(c=>u.includes(c),{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 a=i.join(". ");return a&&(r=r.describe(a)),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),a=I(e.name);W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${a}, inputsToUse: ${s.length}, inputSchema keys:`,p?Object.keys(p):"undefined");let u={name:a,description:r,inputSchema:p,meta:_(e,o,i)};return W.WarpLogger.info(`[MCP] convertActionToTool - tool: ${a}, meta:`,JSON.stringify(u.meta,null,2)),u},b=(e,t,r,n,o,i)=>{let s=n||t.inputs||[],p=M(s,i),a=t.destination.tool,u=I(a),c={name:u,description:r,inputSchema:p,meta:_(e,o,i)};return W.WarpLogger.info(`[MCP] convertMcpActionToTool - tool: ${u}, meta:`,JSON.stringify(c.meta,null,2)),c},_=(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}`)},Q=e=>{let t=['<div id="root"></div>'];return t.push(`<script type="module">${e}</script>`),t.join(`
|
|
2
|
+
`).trim()},P=async(e,t,r)=>{if(!e.meta?.identifier)return null;try{let n=await H(t),o;return t.endsWith(".html")?o=n:o=Q(n),{name:e.name,uri:`ui://widget/${e.meta.identifier}`,description:`ChatGPT app for ${e.name}`,mimeType:"text/html+skybridge",content: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 "${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,f.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}},B=async(e,t)=>Promise.all(e.map(r=>k(r,t))),G=(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,a=t.inputSchema.required||[];Object.entries(p).forEach(([u,c])=>{let d=a.includes(u),g=G(c.type||"string",c.format),y={name:u,label:typeof c.title=="string"?{en:c.title}:c.title||{en:u},description:c.description?{en:c.description.trim()}:null,type:g,position:`payload:${u}`,source:"field",required:d,...c.default!==void 0&&typeof c.default=="string"||typeof c.default=="number"||typeof c.default=="boolean"?{default:c.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 f.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,f.resolveWarpText)(e,t)||void 0;var v=(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},K=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,"_"),X=(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=K(e.name),i=t.inputs||[],s=X(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 Y=e=>{if(e)return typeof e=="object"&&"_zod"in e?e._zod:typeof e=="object"&&!Array.isArray(e)&&(0,$.normalizeObjectSchema)(e)||e},ee=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},te=(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:a,prompt:u}=r[s],c=t[s];if(p){let d=Y(p.inputSchema),g={description:p.description||"",inputSchema:d,...p.meta&&{_meta:p.meta}};o.registerTool(p.name,g,async y=>{if(i){let N=h(c,y||{});return await i(c,N)}return{content:[{type:"text",text:`Tool ${p.name} executed successfully`}]}})}if(a&&o.registerResource(a.name||a.uri,a.uri,{description:a.description,mimeType:a.mimeType},async()=>{let d={uri:a.uri,text:a.content||"",mimeType:a.mimeType};return a.meta&&(d._meta=a.meta),{contents:[d]}}),u){let d=ee(u);o.registerPrompt(u.name,{description:u.description||"",argsSchema:d},g=>({messages:[{role:"user",content:{type:"text",text:v(u.prompt,g)}}]}))}}return o};var j=require("@modelcontextprotocol/sdk/client/index.js"),O=require("@modelcontextprotocol/sdk/client/streamableHttp.js");var z=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,2 @@
|
|
|
1
|
-
import{getWarpPrimaryAction as
|
|
2
|
-
|
|
1
|
+
import{getWarpPrimaryAction as I,WarpSerializer as _}from"@joai/warps";var y=(e,t)=>{let{action:n}=I(e);if(!n.inputs)return[];let r=new _;return n.inputs.map(o=>{let i=o.as||o.name,s=t[i]??o.default??null;return s===null&&o.type==="bool"?r.nativeToString(o.type,!1):r.nativeToString(o.type,s)})};import{WarpBuilder as j,getWarpPrimaryAction as O,resolveWarpText as N}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 n,r=e.type.toLowerCase();r==="string"||r==="address"||r==="hex"?n=l.string():r==="number"||r==="uint8"||r==="uint16"||r==="uint32"||r==="uint64"||r==="uint128"||r==="uint256"?n=l.number():r==="bool"||r==="boolean"?n=l.boolean():r==="biguint"?n=l.string():n=l.string(),typeof e.min=="number"&&n instanceof l.ZodNumber&&(n=n.min(e.min)),typeof e.max=="number"&&n instanceof l.ZodNumber&&(n=n.max(e.max)),e.pattern&&n instanceof l.ZodString&&(n=n.regex(new RegExp(e.pattern)));let o=k(e.options);if(o&&o.length>0){if(n instanceof l.ZodString)n=l.enum(o);else if(n instanceof l.ZodNumber){let u=o.map(c=>Number(c)).filter(c=>!isNaN(c));u.length>0&&(n=n.refine(c=>u.includes(c),{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 a=i.join(". ");return a&&(n=n.describe(a)),e.required!==!0&&(n=n.optional()),n},A=(e,t)=>{let n={};for(let r of e){if(r.source==="hidden"||r.source!=="field")continue;let o=r.as||r.name;n[o]=Z(r,t)}return W.info("[MCP] buildZodInputSchema - inputs:",e.length,"shape keys:",Object.keys(n)),Object.keys(n).length>0?n:void 0},h=(e,t,n,r,o,i)=>{let s=r||t.inputs||[],p=A(s,i),a=T(e.name);W.info(`[MCP] convertActionToTool - tool: ${a}, inputsToUse: ${s.length}, inputSchema keys:`,p?Object.keys(p):"undefined");let u={name:a,description:n,inputSchema:p,meta:C(e,o,i)};return W.info(`[MCP] convertActionToTool - tool: ${a}, meta:`,JSON.stringify(u.meta,null,2)),u},M=(e,t,n,r,o,i)=>{let s=r||t.inputs||[],p=A(s,i),a=t.destination.tool,u=T(a),c={name:u,description:n,inputSchema:p,meta:C(e,o,i)};return W.info(`[MCP] convertMcpActionToTool - tool: ${u}, meta:`,JSON.stringify(c.meta,null,2)),c},C=(e,t,n)=>{let r={"openai/widgetAccessible":!0};if(t&&(r["openai/outputTemplate"]=t.uri),e.messages){let o=m(e.messages.invoking,n),i=m(e.messages.invoked,n);o&&(r["openai/toolInvocation/invoking"]=o),i&&(r["openai/toolInvocation/invoked"]=i)}return r};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}`)},w=e=>{let t=['<div id="root"></div>'];return t.push(`<script type="module">${e}</script>`),t.join(`
|
|
2
|
+
`).trim()},x=async(e,t,n)=>{if(!e.meta?.identifier)return null;try{let r=await $(t),o;return t.endsWith(".html")?o=r:o=w(r),{name:e.name,uri:`ui://widget/${e.meta.identifier}`,description:`ChatGPT app for ${e.name}`,mimeType:"text/html+skybridge",content:o}}catch(r){let o=r instanceof Error?r.message:String(r),i=r instanceof Error?r.stack:void 0;return b.error(`[MCP] Failed to create app resource for warp "${e.name}" (path: ${t}):`,o),i&&b.error("[MCP] Error stack:",i),null}};var E=async(e,t)=>{let n=null,r=null,o=null;if(e.ui&&e.ui!=="table"&&(r=await x(e,e.ui,t)),e.actions.length===0)return{tool:null,resource:r,prompt:null};try{let{action:i}=O(e),s=m(e.description,t)||m(i.description,t);if(i.type==="prompt")o=S(e,i,s,t);else if(i.type==="mcp"){let p=i;p.destination&&(n=M(e,p,s,i.inputs,r,t))}else n=h(e,i,s,i.inputs,r,t)}catch{return{tool:null,resource:r,prompt:null}}return{tool:n,resource:r,prompt:o}},ze=async(e,t)=>Promise.all(e.map(n=>E(n,t))),q=(e,t)=>t==="date-time"||t==="date"||e==="string"?"string":e==="number"||e==="integer"?"uint256":e==="boolean"?"bool":"string",P=async(e,t,n,r)=>{let o=[];if(t.inputSchema?.properties){let p=t.inputSchema.properties,a=t.inputSchema.required||[];Object.entries(p).forEach(([u,c])=>{let d=a.includes(u),f=q(c.type||"string",c.format),g={name:u,label:typeof c.title=="string"?{en:c.title}:c.title||{en:u},description:c.description?{en:c.description.trim()}:null,type:f,position:`payload:${u}`,source:"field",required:d,...c.default!==void 0&&typeof c.default=="string"||typeof c.default=="number"||typeof c.default=="boolean"?{default:c.default}:{}};o.push(g)})}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:n,tool:t.name,headers:r},inputs:o};return await new j(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&&N(e,t)||void 0;var R=(e,t)=>{let n=e;for(let[r,o]of Object.entries(t)){let i=new RegExp(`\\{\\{\\s*${r}\\s*\\}\\}`,"g");n=n.replace(i,o??"")}return n},J=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,"_"),U=(e,t)=>{let n=[];for(let r of e){if(r.source==="hidden"||r.source!=="field")continue;let o=r.as||r.name,i=m(r.description,t);n.push({name:o,description:i,required:r.required===!0})}return n},S=(e,t,n,r)=>{let o=J(e.name),i=t.inputs||[],s=U(i,r);return{name:o,description:n,arguments:s.length>0?s:void 0,prompt:t.prompt}};import{McpServer as D}from"@modelcontextprotocol/sdk/server/mcp.js";import{normalizeObjectSchema as L}from"@modelcontextprotocol/sdk/server/zod-compat.js";import{z as F}from"zod";var V=e=>{if(e)return typeof e=="object"&&"_zod"in e?e._zod:typeof e=="object"&&!Array.isArray(e)&&L(e)||e},H=e=>{if(!e.arguments||e.arguments.length===0)return;let t={};for(let n of e.arguments){let r=F.string();n.description&&(r=r.describe(n.description)),n.required||(r=r.optional()),t[n.name]=r}return t},Ne=(e,t,n,r)=>{let o=new D({name:e.name,version:e.version||"1.0.0"}),i=e.executor||r;for(let s=0;s<n.length;s++){let{tool:p,resource:a,prompt:u}=n[s],c=t[s];if(p){let d=V(p.inputSchema),f={description:p.description||"",inputSchema:d,...p.meta&&{_meta:p.meta}};o.registerTool(p.name,f,async g=>{if(i){let z=y(c,g||{});return await i(c,z)}return{content:[{type:"text",text:`Tool ${p.name} executed successfully`}]}})}if(a&&o.registerResource(a.name||a.uri,a.uri,{description:a.description,mimeType:a.mimeType},async()=>{let d={uri:a.uri,text:a.content||"",mimeType:a.mimeType};return a.meta&&(d._meta=a.meta),{contents:[d]}}),u){let d=H(u);o.registerPrompt(u.name,{description:u.description||"",argsSchema:d},f=>({messages:[{role:"user",content:{type:"text",text:R(u.prompt,f)}}]}))}}return o};import{Client as Q}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as B}from"@modelcontextprotocol/sdk/client/streamableHttp.js";var v=class{constructor(t){this.config=t}async getWarpsFromTools(t,n){let r=new B(new URL(t),{requestInit:{headers:n||{}}}),o=new Q({name:"warps-mcp-client",version:"1.0.0"},{capabilities:{}});try{await o.connect(r);let i=await o.listTools();return await o.close(),await Promise.all(i.tools.map(s=>P(this.config,s,t,n)))}catch(i){throw await o.close().catch(()=>{}),i}}};export{v as WarpMcp,A as buildZodInputSchema,h as convertActionToTool,M as convertMcpActionToTool,y as convertMcpArgsToWarpInputs,P as convertMcpToolToWarp,S as convertPromptActionToPrompt,E as convertWarpToMcpCapabilities,ze as convertWarpsToMcpCapabilities,x as createAppResource,Ne as createMcpServerFromWarps,m as extractTextOrUndefined,R as interpolatePromptWithArgs};
|