@mcp-com-ai/plugin-sdk 1.0.1-beta.260914 → 1.0.2-beta.260914
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/README.md +1 -1
- package/dist/index.js +2 -2
- package/dist/types.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Deploying & Registering MCP Servers
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
# HAPI plugin SDK 
|
|
33
33
|
|
|
34
34
|
`@mcp-com-ai/plugin-sdk` is the contract that lets HAPI plugins work with the
|
|
35
35
|
`hapi` command. It is for plugin authors, not for people simply serving an API
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var k="1.0.2-beta.260914";var P=Number(k.split(".")[0]);function V(e){return e}function N(e){if(!e.name)throw Error("HAPI plugin missing required `name`");if(!e.version)throw Error(`HAPI plugin '${e.name}' missing required \`version\``);if(!e.compatibility?.cliApiVersion)throw Error(`HAPI plugin '${e.name}' must declare compatibility.cliApiVersion (current: '${P}')`);if(!Array.isArray(e.commands))throw Error(`HAPI plugin '${e.name}' must declare a commands[] array`);let n=new Set;for(let t of e.serveProviders??[]){if(!t.id||!t.kind||!t.rootField||!t.description)throw Error(`HAPI plugin '${e.name}' has an invalid serve provider declaration`);if(typeof t.serve!=="function")throw Error(`HAPI plugin '${e.name}' serve provider '${t.id}' must declare serve()`);if(n.has(t.id))throw Error(`HAPI plugin '${e.name}' declares duplicate serve provider '${t.id}'`);n.add(t.id)}return e}function L(e,n=[],t={}){let a=t.allowUnknown??!0,i=[],r=[],o={},l=[];for(let s of n)if(s.env&&process.env[s.env]!==void 0)o[s.name]=w(process.env[s.env],s);else if(s.default!==void 0)o[s.name]=s.default;let u=new Map,I=new Map;for(let s of n)if(u.set(s.name,s),s.alias)I.set(s.alias,s);let c=0;while(c<e.length){let s=e[c];if(s==="--"){r.push(...e.slice(c+1));break}if(s.startsWith("--")){let p=s.slice(2),m=p.indexOf("="),d=m>=0?p.slice(0,m):p,f=m>=0?p.slice(m+1):void 0,g=d.startsWith("no-"),h=g?d.slice(3):d,C=u.get(h)??u.get(R(h));if(!C){if(!a)throw Error(`Unknown option: --${d}`);if(l.push(d),f!==void 0)o[v(d)]=f,c++;else if(g)o[v(h)]=!1,c++;else{let x=e[c+1];if(x!==void 0&&!String(x).startsWith("-"))o[v(d)]=x,c+=2;else o[v(d)]=!0,c++}continue}if(C.type==="boolean"){o[C.name]=g?!1:f?A(f):!0,c++;continue}let b=f;if(b===void 0)b=e[c+1],c+=b!==void 0&&!String(b).startsWith("-")?2:1;else c++;if(C.type==="array"){let x=o[C.name]??[];o[C.name]=[...x,...String(b??"").split(",").map((H)=>H.trim()).filter(Boolean)]}else o[C.name]=w(b,C);continue}if(s.startsWith("-")&&s.length>1){let p=s.slice(1),m=p.indexOf("="),d=m>=0?p.slice(0,m):p,f=m>=0?p.slice(m+1):void 0,g=I.get(d);if(!g){if(!a)throw Error(`Unknown option: -${d}`);i.push(s),c++;continue}if(g.type==="boolean"){o[g.name]=f?A(f):!0,c++;continue}let h=f;if(h===void 0)h=e[c+1],c+=h!==void 0&&!String(h).startsWith("-")?2:1;else c++;o[g.name]=w(h,g);continue}i.push(s),c++}return{positionals:i,options:o,rest:r,unknownOptions:l}}function w(e,n){if(e===void 0)return e;switch(n.type){case"number":{let t=Number(e);return Number.isFinite(t)?t:e}case"boolean":return A(e);case"array":return String(e).split(",").map((t)=>t.trim()).filter(Boolean);default:return String(e)}}function A(e){if(typeof e==="boolean")return e;let n=String(e).toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}function R(e){return e.replace(/-([a-z0-9])/g,(n,t)=>t.toUpperCase())}function v(e){return R(e)}function _(e,n,t=[]){let a=t.length?`${t.join(" ")} `:"",i=(r)=>n.stdout.write(r);if(i(`
|
|
3
3
|
${a}${e.name} \u2014 ${e.description}
|
|
4
4
|
`),e.arguments?.length){i(`
|
|
5
5
|
Arguments:
|
|
@@ -13,4 +13,4 @@ Subcommands:
|
|
|
13
13
|
`)}}if(e.longHelp)i(`
|
|
14
14
|
${e.longHelp}
|
|
15
15
|
`);i(`
|
|
16
|
-
`)}var
|
|
16
|
+
`)}var j=Object.freeze({maxBytes:5242880,timeoutMs:1e4,maxRedirects:5});function D(e){if(e.protocol!=="http:"&&e.protocol!=="https:")throw Error(`Remote documents cannot resolve ${e.protocol} sources`)}function W(e){try{let n=e instanceof URL?new URL(e.href):new URL(e);if(n.username="",n.password="",n.search)n.search="?redacted";return n.href}catch{return String(e)}}var q=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/,E=/^(<=|>=|<|>|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z.-]+)?)$/;function M(e,n){let t=y(e);if(!t||!O(n))return!1;if(n.startsWith("^")){let i=y(n.slice(1));return i!==void 0&&S(t,i)>=0&&S(t,T(i))<0}let a=n.trim().split(/\s+/).filter(Boolean);return a.length>0&&a.every((i)=>{let r=i.match(E);if(!r)return!1;let o=r[2];if(!o)return!1;let l=y(o);if(!l)return!1;let u=S(t,l);switch(r[1]??"="){case"=":return u===0;case">":return u>0;case">=":return u>=0;case"<":return u<0;case"<=":return u<=0;default:return!1}})}function O(e){if(e.startsWith("^"))return y(e.slice(1))!==void 0;let n=e.trim().split(/\s+/).filter(Boolean);return n.length>0&&n.every((t)=>{let i=t.match(E)?.[2];return i!==void 0&&y(i)!==void 0})}function y(e){let n=e.match(q);if(!n)return;return{major:Number(n[1]),minor:Number(n[2]),patch:Number(n[3]),prerelease:n[4]?.split(".")??[]}}function T(e){if(e.major>0)return{major:e.major+1,minor:0,patch:0,prerelease:["0"]};if(e.minor>0)return{major:0,minor:e.minor+1,patch:0,prerelease:["0"]};return{major:0,minor:0,patch:e.patch+1,prerelease:["0"]}}function S(e,n){for(let a of["major","minor","patch"])if(e[a]!==n[a])return e[a]<n[a]?-1:1;if(e.prerelease.length===0||n.prerelease.length===0){if(e.prerelease.length===n.prerelease.length)return 0;return e.prerelease.length===0?1:-1}let t=Math.max(e.prerelease.length,n.prerelease.length);for(let a=0;a<t;a++){let i=e.prerelease[a],r=n.prerelease[a];if(i===void 0)return-1;if(r===void 0)return 1;if(i===r)continue;let o=/^\d+$/.test(i),l=/^\d+$/.test(r);if(o&&l)return Number(i)<Number(r)?-1:1;if(o!==l)return o?-1:1;return i<r?-1:1}return 0}export{j as DEFAULT_DOCUMENT_SOURCE_POLICY,P as HAPI_CLI_API_VERSION,D as assertRemoteDocumentUrl,V as defineCommand,N as definePlugin,O as isSupportedVersionRange,L as parseArgs,W as redactDocumentUrl,_ as renderCommandHelp,M as satisfiesVersionRange};
|
package/dist/types.d.ts
CHANGED
|
@@ -90,6 +90,15 @@ export interface CliInvocation {
|
|
|
90
90
|
positionals: string[];
|
|
91
91
|
options: Record<string, unknown>;
|
|
92
92
|
rest: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Flags on argv that didn't match any declared CliOption (by name or its
|
|
95
|
+
* kebab/camel variant), e.g. from a typo like --project-name instead of
|
|
96
|
+
* --project. Still parsed into `options` under a best-guess key (so
|
|
97
|
+
* intentional passthrough, like wrangler --var forwarding, keeps working),
|
|
98
|
+
* but callers should warn on these — a silently-ignored typo'd flag is
|
|
99
|
+
* much harder to notice than a merely-unused one.
|
|
100
|
+
*/
|
|
101
|
+
unknownOptions?: string[];
|
|
93
102
|
}
|
|
94
103
|
/** A parsed source passed from the CLI to a document-specific serve provider. */
|
|
95
104
|
export interface DocumentSourceEnvelope {
|
|
@@ -120,6 +129,8 @@ export interface ServeProvider {
|
|
|
120
129
|
rootField: string;
|
|
121
130
|
description: string;
|
|
122
131
|
options?: readonly CliOption[];
|
|
132
|
+
/** Optional long-form help appended below the generic `hapi serve --help` block. */
|
|
133
|
+
longHelp?: string;
|
|
123
134
|
/** Permit legacy identifiers that do not resolve to a document, e.g. an OpenAPI project name. */
|
|
124
135
|
legacyFallback?: boolean;
|
|
125
136
|
serve: (request: ServeProviderRequest, context: CliContext) => Promise<number | void> | number | void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-com-ai/plugin-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-beta.260914",
|
|
4
4
|
"description": "The shared plugin contract for the HAPI CLI. Consumed by the core CLI, first-party plugins, and third-party extensions.",
|
|
5
5
|
"license": "LRL-CL",
|
|
6
6
|
"type": "module",
|