@swifty.js/swifty 0.0.14 → 0.0.16

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.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __swiftyCreateRequire } from "node:module";
3
+ const require = __swiftyCreateRequire(import.meta.url);
4
+ import{I as y,M as u,O as T,S as f}from"./chunk-RTOI4JAC.js";import{b as g}from"./chunk-E55KH72M.js";var S=y({module:"mcp"}),p="mcp__",m="__";function a(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function _(e){return p+a(e)+m}function h(e,r){return _(e)+a(r)}var C=class{name;description;category="command";deferred=!0;mcpServerName;client;originalName;inputSchema;constructor(r,t,n){this.name=h(t,n.name),this.description=n.description,this.originalName=n.name,this.client=r,this.inputSchema=n.inputSchema,this.mcpServerName=t}mcpInputSchema(){return this.inputSchema??{}}setDeferLoading(r){this.deferred=r}schema(){return{name:this.name,description:this.description,input_schema:this.inputSchema}}async execute(r,t){try{let{output:n,isError:s}=await this.client.callTool(this.originalName,t);return{output:n,isError:s}}catch(n){return S.error({err:n},"mcp operation failed"),{output:`MCP tool error: ${T(n)}`,isError:!0}}}};function x(e,r){if(r==="string"&&typeof e=="number"&&Number.isFinite(e))return String(e);if((r==="integer"||r==="number")&&typeof e=="string"){let t=e.trim();if(t===""||!(r==="integer"?/^[+-]?\d+$/:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/).test(t))return e;let s=r==="integer"?Number.parseInt(t,10):Number.parseFloat(t);return Number.isNaN(s)?e:s}if(r==="boolean"&&typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}return e}function d(e,r){if(typeof r!="object"||r===null)return e;let t=u(r),n=f(t,"type","");if(n==="object"&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=u(t.properties??{}),o={};for(let[i,c]of Object.entries(e))o[i]=i in s?d(c,s[i]):c;return o}if(n==="array"){let s=t.items??{},o=e;if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let i=Object.values(o);i.length===1&&Array.isArray(i[0])&&(o=i[0])}else typeof o=="string"&&(o=o.split(",").map(i=>i.trim()).filter(i=>i!==""));return Array.isArray(o)?o.map(i=>d(i,s)):o}return n!==""?x(e,n):e}function O(e,r){if(r.startsWith(p)){let t=r.slice(p.length),n=t.indexOf(m);if(n>=0)return a(t.slice(0,n))+m+a(t.slice(n+m.length))}return a(e)+m+a(r)}function M(e){return"mcpInputSchema"in e&&typeof e.mcpInputSchema=="function"}var b=class{constructor(r){this.registry=r}registry;name=g;description="Invoke a tool on a connected MCP server. Call ToolSearch first to load the tool's schema, then pass its arguments here exactly as that schema requires, using the same JSON types.";category="command";deferred=!1;schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{server:{type:"string",description:"MCP server name, e.g. 'linear'."},tool:{type:"string",description:"Full tool name as returned by ToolSearch, e.g. 'mcp__linear__create_issue'."},arguments:{type:"object",description:"The target tool's arguments. Must match that tool's input_schema exactly, including JSON types: bare numbers for integer fields, bare true/false for boolean fields, quoted strings for string fields, and plain JSON arrays for array fields."}},required:["server","tool","arguments"]}}}resolve(r,t){let n=this.registry.get(t)??this.registry.get(h(r,t));if(n)return n;let s=m+a(t),o=this.registry.listTools().filter(i=>i.name.startsWith(p)&&i.name.endsWith(s));return o.length===1?o[0]:void 0}availableNames(){return this.registry.listTools().filter(r=>r.name.startsWith(p)).map(r=>r.name).sort()}async execute(r,t){let n=f(t,"server",""),s=f(t,"tool","");if(s==="")return{output:"McpCall requires a 'tool' name",isError:!0};let o=this.resolve(n,s);if(!o){let c=this.availableNames(),l=c.length>0?c.join(", "):"(none connected)";return{output:`Unknown MCP tool '${s}' on server '${n}'. Available tools: ${l}`,isError:!0}}let i={};if(typeof t.arguments=="object"&&t.arguments!==null&&!Array.isArray(t.arguments)&&(i=u(t.arguments)),M(o)){let c=o.mcpInputSchema();if(Object.keys(c).length>0){let l=d(i,c);typeof l=="object"&&l!==null&&!Array.isArray(l)&&(i=u(l))}}return o.execute(r,i)}};export{p as a,C as b,O as c,M as d,b as e};
package/dist/glob.wasm CHANGED
Binary file