pulse-coder-cli 0.0.1-alpha.10 → 0.0.1-alpha.11
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.cjs +28 -17
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -116,6 +116,17 @@ You are an interactive CLI tool that helps users with software engineering tasks
|
|
|
116
116
|
- Use Bash for terminal operations (git, bun, builds, tests, running scripts).
|
|
117
117
|
- Run tool calls in parallel when neither call needs the other\u2019s output; otherwise run sequentially.
|
|
118
118
|
|
|
119
|
+
## Execution discipline
|
|
120
|
+
- If the user gives a clear execution command (for example: "start", "run", "execute", "do it now", "\u5F00\u59CB\u6267\u884C", "\u76F4\u63A5\u6267\u884C"), execute the relevant tool calls immediately when safe and feasible.
|
|
121
|
+
- Do not reply with intent-only messages (for example: "I will do it", "starting now") when a tool call can be made right away.
|
|
122
|
+
- Do not claim completion unless tool execution has actually happened.
|
|
123
|
+
- If execution cannot proceed, state exactly what is blocked and ask one targeted question with a recommended default.
|
|
124
|
+
- Only ask before execution when one of these is true:
|
|
125
|
+
- A required value is missing and cannot be inferred safely.
|
|
126
|
+
- The action is destructive, irreversible, or changes production/security/billing posture.
|
|
127
|
+
- Credentials/authorization are required and unavailable.
|
|
128
|
+
- After each execution step, report factual outcomes (success/failure, key output, and next action).
|
|
129
|
+
|
|
119
130
|
## Git and workspace hygiene
|
|
120
131
|
- You may be in a dirty git worktree.
|
|
121
132
|
* NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.
|
|
@@ -367,45 +378,45 @@ ${r.comment}`:r.comment;}this.doc.range[2]=r.offset;break}default:this.errors.pu
|
|
|
367
378
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
368
379
|
`,r)+1;}yield*this.pop();break;default:yield*this.pop(),yield*this.step();}}*blockMap(t){let r=t.items[t.items.length-1];switch(this.type){case "newline":if(this.onKeyLine=false,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]});}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case "space":case "comment":if(r.value)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else {if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken);}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",o=[];if(n&&r.sep&&!r.value){let s=[];for(let l=0;l<r.sep.length;++l){let c=r.sep[l];switch(c.type){case "newline":s.push(l);break;case "space":break;case "comment":c.indent>t.indent&&(s.length=0);break;default:s.length=0;}}s.length>=2&&(o=r.sep.splice(s[1]));}switch(this.type){case "anchor":case "tag":n||r.value?(o.push(this.sourceToken),t.items.push({start:o}),this.onKeyLine=true):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case "explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=true):n||r.value?(o.push(this.sourceToken),t.items.push({start:o,explicitKey:true})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:true}]}),this.onKeyLine=true;return;case "map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ti(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Uz(r.key)&&!Ti(r.sep,"newline")){let s=Ka(r.start),l=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:l,sep:c}]});}else o.length>0?r.sep=r.sep.concat(o,this.sourceToken):r.sep.push(this.sourceToken);else if(Ti(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else {let s=Ka(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});}else r.sep?r.value||n?t.items.push({start:o,key:null,sep:[this.sourceToken]}):Ti(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=true;return;case "alias":case "scalar":case "single-quoted-scalar":case "double-quoted-scalar":{let s=this.flowScalar(this.type);n||r.value?(t.items.push({start:o,key:s,sep:[]}),this.onKeyLine=true):r.sep?this.stack.push(s):(Object.assign(r,{key:s,sep:[]}),this.onKeyLine=true);return}default:{let s=this.startBlockValue(t);if(s){if(s.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Ti(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step();}*blockSequence(t){let r=t.items[t.items.length-1];switch(this.type){case "newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]});}else r.start.push(this.sourceToken);return;case "space":case "comment":if(r.value)t.items.push({start:[this.sourceToken]});else {if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken);}return;case "anchor":case "tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case "seq-item-ind":if(this.indent!==t.indent)break;r.value||Ti(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step();}*flowCollection(t){let r=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case "comma":case "explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case "map-value-ind":!r||r.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case "space":case "comment":case "newline":case "anchor":case "tag":!r||r.value?t.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case "alias":case "scalar":case "single-quoted-scalar":case "double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?t.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case "flow-map-end":case "flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step());}else {let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Zf(i),o=Ka(n);Dz(t);let s=t.end.splice(1,t.end.length);s.push(this.sourceToken);let l={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:o,key:t,sep:s}]};this.onKeyLine=true,this.stack[this.stack.length-1]=l;}else yield*this.lineEnd(t);}}flowScalar(t){if(this.onNewLine){let r=this.source.indexOf(`
|
|
369
380
|
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
|
|
370
|
-
`,r)+1;}return {type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case "alias":case "scalar":case "single-quoted-scalar":case "double-quoted-scalar":return this.flowScalar(this.type);case "block-scalar-header":return {type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case "flow-map-start":case "flow-seq-start":return {type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case "seq-item-ind":return {type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case "explicit-key-ind":{this.onKeyLine=true;let r=Zf(t),i=Ka(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:true}]}}case "map-value-ind":{this.onKeyLine=true;let r=Zf(t),i=Ka(r);return {type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?false:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()));}*lineEnd(t){switch(this.type){case "comma":case "doc-start":case "doc-end":case "flow-seq-end":case "flow-map-end":case "map-value-ind":yield*this.pop(),yield*this.step();break;case "newline":this.onKeyLine=false;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop());}}};Lz.Parser=k0;});var Bz=M(Pc=>{var qz=d0(),FX=xc(),Oc=Tc(),ZX=cx(),VX=qe(),BX=S0(),Fz=T0();function Zz(e){let t=e.prettyErrors!==false;return {lineCounter:e.lineCounter||t&&new BX.LineCounter||null,prettyErrors:t}}function JX(e,t={}){let{lineCounter:r,prettyErrors:i}=Zz(t),n=new Fz.Parser(r?.addNewLine),o=new qz.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let l of s)l.errors.forEach(Oc.prettifyError(e,r)),l.warnings.forEach(Oc.prettifyError(e,r));return s.length>0?s:Object.assign([],{empty:true},o.streamInfo())}function Vz(e,t={}){let{lineCounter:r,prettyErrors:i}=Zz(t),n=new Fz.Parser(r?.addNewLine),o=new qz.Composer(t),s=null;for(let l of o.compose(n.parse(e),true,e.length))if(!s)s=l;else if(s.options.logLevel!=="silent"){s.errors.push(new Oc.YAMLParseError(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(s.errors.forEach(Oc.prettifyError(e,r)),s.warnings.forEach(Oc.prettifyError(e,r))),s}function WX(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=Vz(e,r);if(!n)return null;if(n.warnings.forEach(o=>ZX.warn(n.options.logLevel,o)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[];}return n.toJS(Object.assign({reviver:i},r))}function KX(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n};}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return VX.isDocument(e)&&!i?e.toString(r):new FX.Document(e,i,r).toString(r)}Pc.parse=WX;Pc.parseAllDocuments=JX;Pc.parseDocument=Vz;Pc.stringify=KX;});var Wz=M(Be=>{var HX=d0(),GX=xc(),YX=Bx(),I0=Tc(),XX=oc(),Ii=qe(),QX=wi(),eQ=yt(),tQ=Si(),rQ=ki(),nQ=qf(),iQ=w0(),oQ=S0(),aQ=T0(),Vf=Bz(),Jz=tc();Be.Composer=HX.Composer;Be.Document=GX.Document;Be.Schema=YX.Schema;Be.YAMLError=I0.YAMLError;Be.YAMLParseError=I0.YAMLParseError;Be.YAMLWarning=I0.YAMLWarning;Be.Alias=XX.Alias;Be.isAlias=Ii.isAlias;Be.isCollection=Ii.isCollection;Be.isDocument=Ii.isDocument;Be.isMap=Ii.isMap;Be.isNode=Ii.isNode;Be.isPair=Ii.isPair;Be.isScalar=Ii.isScalar;Be.isSeq=Ii.isSeq;Be.Pair=QX.Pair;Be.Scalar=eQ.Scalar;Be.YAMLMap=tQ.YAMLMap;Be.YAMLSeq=rQ.YAMLSeq;Be.CST=nQ;Be.Lexer=iQ.Lexer;Be.LineCounter=oQ.LineCounter;Be.Parser=aQ.Parser;Be.parse=Vf.parse;Be.parseAllDocuments=Vf.parseAllDocuments;Be.parseDocument=Vf.parseDocument;Be.stringify=Vf.stringify;Be.visit=Jz.visit;Be.visitAsync=Jz.visitAsync;});var Ac,E0=T(()=>{Bw();Jw();Ac=class{enginePlugins=new Map;userConfigPlugins=[];tools=new Map;runHooks=new Map;services=new Map;protocols=new Map;config=new Map;events=new events.EventEmitter;logger;constructor(t){this.logger=t??{debug:(r,i)=>console.debug(`[PluginManager] ${r}`,i),info:(r,i)=>console.info(`[PluginManager] ${r}`,i),warn:(r,i)=>console.warn(`[PluginManager] ${r}`,i),error:(r,i,n)=>console.error(`[PluginManager] ${r}`,i,n)};}async initialize(t={}){this.logger.info("Initializing plugin system...");try{await this.loadEnginePlugins(t.enginePlugins),await this.validateCoreCapabilities(),await this.loadUserConfigPlugins(t.userConfigPlugins),this.logger.info("Plugin system initialized successfully");}catch(r){throw this.logger.error("Failed to initialize plugin system",r),r}}async loadEnginePlugins(t={}){let r=[];if(t.plugins&&r.push(...t.plugins),t.scan!==false){let n=t.dirs||[".pulse-coder/engine-plugins",".coder/engine-plugins","~/.pulse-coder/engine-plugins","~/.coder/engine-plugins"];for(let o of n){let s=await this.scanEnginePlugins(o);r.push(...s);}}let i=this.sortPluginsByDependencies(r);for(let n of i)await this.initializeEnginePlugin(n);}async scanEnginePlugins(t){let r=[],i=this.resolvePath(t);try{let o=await ec("**/*.plugin.{js,ts}",{cwd:i,absolute:!0});for(let s of o)try{let l=await this.loadEnginePluginFile(s);r.push(l),this.logger.info(`Loaded engine plugin: ${l.name} from ${s}`);}catch(l){this.logger.error(`Failed to load engine plugin from ${s}`,l);}}catch{this.logger.debug(`Directory not found: ${i}`);}return r}async loadEnginePluginFile(t){let r=await import(t),i=r.default||r;if(!i.name||!i.initialize)throw new Error(`Invalid engine plugin: ${t}`);return i}async initializeEnginePlugin(t){try{if(t.dependencies){for(let i of t.dependencies)if(!this.enginePlugins.has(i))throw new Error(`Dependency not found: ${i} for plugin ${t.name}`)}let r={registerTool:(i,n)=>{this.tools.set(i,n);},registerTools:i=>{Object.entries(i).forEach(([n,o])=>{this.tools.set(n,o);});},getTool:i=>this.tools.get(i),getTools:()=>Object.fromEntries(this.tools),registerRunHook:(i,n)=>{this.runHooks.set(i,n);},getRunHook:i=>this.runHooks.get(i),registerProtocol:(i,n)=>{this.protocols.set(i,n);},getProtocol:i=>this.protocols.get(i),registerService:(i,n)=>{this.services.set(i,n);},getService:i=>this.services.get(i),getConfig:i=>this.config.get(i),setConfig:(i,n)=>this.config.set(i,n),events:this.events,logger:this.logger};t.beforeInitialize&&await t.beforeInitialize(r),await t.initialize(r),t.afterInitialize&&await t.afterInitialize(r),this.enginePlugins.set(t.name,t);}catch(r){throw new Error(`Failed to initialize engine plugin ${t.name}: ${r}`)}}async loadUserConfigPlugins(t={}){let r=[];if(t.configs&&r.push(...t.configs),t.scan!==false){let i=t.dirs||[".pulse-coder/config",".coder/config","~/.pulse-coder/config","~/.coder/config"];for(let n of i){let o=await this.scanUserConfigPlugins(n);r.push(...o);}}for(let i of r)await this.applyUserConfig(i);}async scanUserConfigPlugins(t){let r=[],i=this.resolvePath(t);try{let n=["config.{json,yaml,yml}","*.config.{json,yaml,yml}"];for(let o of n){let s=await ec(o,{cwd:i,absolute:!0});for(let l of s)try{let c=await this.loadUserConfigFile(l);r.push(c),this.logger.info(`Loaded user config: ${c.name||l}`);}catch(c){this.logger.error(`Failed to load user config from ${l}`,c);}}}catch{this.logger.debug(`Directory not found: ${i}`);}return r}async loadUserConfigFile(t){let r=await Dj.promises.readFile(t,"utf-8"),i=ss__namespace.default.extname(t),n;try{if(i===".json")n=JSON.parse(r);else if(i===".yaml"||i===".yml")n=(await Promise.resolve().then(()=>Oi(Wz(),1))).parse(r);else throw new Error(`Unsupported config format: ${i}`)}catch(s){throw new Error(`Failed to parse config file ${t}: ${s}`)}return n=new Wp().resolveObject(n),n}async applyUserConfig(t){try{if(t.tools)for(let[r,i]of Object.entries(t.tools))i.enabled!==!1&&this.logger.debug(`Configured tool: ${r}`);if(t.mcp?.servers)for(let r of t.mcp.servers)r.enabled!==!1&&this.logger.debug(`Configured MCP server: ${r.name}`);if(t.subAgents)for(let r of t.subAgents)r.enabled!==!1&&this.logger.debug(`Configured sub-agent: ${r.name}`);t.skills&&this.logger.debug("Configured skills scanning",t.skills),this.userConfigPlugins.push(t);}catch(r){this.logger.error("Failed to apply user config",r);}}async validateCoreCapabilities(){let t=[];for(let i of t)if(!i.aliases.some(o=>this.enginePlugins.has(o)))throw new Error(`Missing required capability "${i.name}". Expected one of: ${i.aliases.join(", ")}`);let r=[{name:"skills",aliases:["pulse-coder-engine/built-in-skills"]}];for(let i of r)i.aliases.some(o=>this.enginePlugins.has(o))||this.logger.warn(`Missing recommended capability "${i.name}". Expected one of: ${i.aliases.join(", ")}`);}sortPluginsByDependencies(t){let r=[],i=new Set,n=new Set,o=s=>{if(!i.has(s.name)){if(n.has(s.name))throw new Error(`Circular dependency detected: ${s.name}`);if(n.add(s.name),s.dependencies)for(let l of s.dependencies){let c=t.find(u=>u.name===l);c&&o(c);}n.delete(s.name),i.add(s.name),r.push(s);}};for(let s of t)o(s);return r}getTools(){return Object.fromEntries(this.tools)}getRunHooks(){return Array.from(this.runHooks.values())}getService(t){return this.services.get(t)}getProtocol(t){return this.protocols.get(t)}getStatus(){return {enginePlugins:Array.from(this.enginePlugins.keys()),userConfigPlugins:this.userConfigPlugins.map(t=>t.name||"unnamed"),tools:Array.from(this.tools.keys()),runHooks:Array.from(this.runHooks.keys()),services:Array.from(this.services.keys()),protocols:Array.from(this.protocols.keys())}}resolvePath(t){return t.startsWith("~/")?ss__namespace.default.join(process.env.HOME||process.env.USERPROFILE||"",t.slice(2)):ss__namespace.default.resolve(t)}};});async function cQ(e){return (await C0).getRandomValues(new Uint8Array(e))}async function uQ(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,i="";for(;i.length<e;){let n=await cQ(e-i.length);for(let o of n)o<r&&(i+=t[o%t.length]);}return i}async function dQ(e){return await uQ(e)}async function pQ(e){let t=await(await C0).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function O0(e){if(e||(e=43),e<43||e>128)throw `Expected a length between 43 and 128. Received ${e}.`;let t=await dQ(e),r=await pQ(t);return {code_verifier:t,code_challenge:r}}var C0,Kz=T(()=>{C0=globalThis.crypto?.webcrypto??globalThis.crypto??import('crypto').then(e=>e.webcrypto);});function HQ(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function GQ({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),i=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==i.origin||r.pathname.length<i.pathname.length)return false;let n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",o=i.pathname.endsWith("/")?i.pathname:i.pathname+"/";return n.startsWith(o)}function Hf(e){var t;let r=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!r)return;let[i,n]=r.split(" ");if(i.toLowerCase()!=="bearer"||!n)return;let o=/resource_metadata="([^"]*)"/,s=r.match(o);if(s)try{return new URL(s[1])}catch{return}}function YQ(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function N0(e,t,r=fetch){try{return await r(e,{headers:t})}catch(i){if(i instanceof TypeError)return t?N0(e,void 0,r):void 0;throw i}}async function e2(e,t,r=fetch){return await N0(e,{"MCP-Protocol-Version":t},r)}function XQ(e,t){return !e||e.status>=400&&e.status<500&&t!=="/"}async function QQ(e,t,r,i){var n,o;let s=new URL(e),l=(n=i?.protocolVersion)!=null?n:Ga,c;if(i?.metadataUrl)c=new URL(i.metadataUrl);else {let d=YQ(t,s.pathname);c=new URL(d,(o=i?.metadataServerUrl)!=null?o:s),c.search=s.search;}let u=await e2(c,l,r);if(!i?.metadataUrl&&XQ(u,s.pathname)){let d=new URL(`/.well-known/${t}`,s);u=await e2(d,l,r);}return u}async function eee(e,t,r=fetch){let i=await QQ(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!i||i.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!i.ok)throw new Error(`HTTP ${i.status} trying to load well-known OAuth protected resource metadata.`);return UQ.parse(await i.json())}function tee(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",i=[];if(!r)return i.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),i.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),i;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),i.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),i.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),i.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),i.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),i}async function ree(e,{fetchFn:t=fetch,protocolVersion:r=Ga}={}){var i;let n={"MCP-Protocol-Version":r},o=tee(e);for(let{url:s,type:l}of o){let c=await N0(s,n,t);if(c){if(!c.ok){if(c.status>=400&&c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${l==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}if(l==="oauth")return f2.parse(await c.json());{let u=qQ.parse(await c.json());if(!((i=u.code_challenge_methods_supported)!=null&&i.includes("S256")))throw new Error(`Incompatible OIDC provider at ${s}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function nee(e,{metadata:t,clientInformation:r,redirectUrl:i,scope:n,state:o,resource:s}){let l="code",c="S256",u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support response type ${l}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(c))throw new Error(`Incompatible auth server: does not support code challenge method ${c}`)}else u=new URL("/authorize",e);let d=await O0(),p=d.code_verifier,f=d.code_challenge;return u.searchParams.set("response_type",l),u.searchParams.set("client_id",r.client_id),u.searchParams.set("code_challenge",f),u.searchParams.set("code_challenge_method",c),u.searchParams.set("redirect_uri",String(i)),o&&u.searchParams.set("state",o),n&&u.searchParams.set("scope",n),n?.includes("offline_access")&&u.searchParams.append("prompt","consent"),s&&u.searchParams.set("resource",s.href),{authorizationUrl:u,codeVerifier:p}}function h2(e,t){let r=e.client_secret!==void 0;return t.length===0?r?"client_secret_post":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function g2(e,t,r,i){let{client_id:n,client_secret:o}=t;switch(e){case "client_secret_basic":iee(n,o,r);return;case "client_secret_post":oee(n,o,i);return;case "none":aee(n,i);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function iee(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let i=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${i}`);}function oee(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t);}function aee(e,t){t.set("client_id",e);}async function j0(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let i=VQ.parse(JSON.parse(r)),{error:n,error_description:o,error_uri:s}=i,l=KQ[n]||Ha;return new l({message:o||"",cause:s})}catch(i){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${i}. Raw body: ${r}`;return new Ha({message:n})}}async function see(e,{metadata:t,clientInformation:r,authorizationCode:i,codeVerifier:n,redirectUri:o,resource:s,addClientAuthentication:l,fetchFn:c}){var u;let d="authorization_code",p=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(d))throw new Error(`Incompatible auth server: does not support grant type ${d}`);let f=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),m=new URLSearchParams({grant_type:d,code:i,code_verifier:n,redirect_uri:String(o)});if(l)l(f,m,e,t);else {let h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],y=h2(r,h);g2(y,r,f,m);}s&&m.set("resource",s.href);let v=await(c??fetch)(p,{method:"POST",headers:f,body:m});if(!v.ok)throw await j0(v);return p2.parse(await v.json())}async function lee(e,{metadata:t,clientInformation:r,refreshToken:i,resource:n,addClientAuthentication:o,fetchFn:s}){var l;let c="refresh_token",u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else u=new URL("/token",e);let d=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),p=new URLSearchParams({grant_type:c,refresh_token:i});if(o)o(d,p,e,t);else {let m=(l=t?.token_endpoint_auth_methods_supported)!=null?l:[],v=h2(r,m);g2(v,r,d,p);}n&&p.set("resource",n.href);let f=await(s??fetch)(u,{method:"POST",headers:d,body:p});if(!f.ok)throw await j0(f);return p2.parse({refresh_token:i,...await f.json()})}async function cee(e,{metadata:t,clientMetadata:r,fetchFn:i}){let n;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint);}else n=new URL("/register",e);let o=await(i??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw await j0(o);return BQ.parse(await o.json())}async function Gf(e,t){var r,i;try{return await P0(e,t)}catch(n){if(n instanceof Bf||n instanceof Wf)return await((r=e.invalidateCredentials)==null?void 0:r.call(e,"all")),await P0(e,t);if(n instanceof Jf)return await((i=e.invalidateCredentials)==null?void 0:i.call(e,"tokens")),await P0(e,t);throw n}}async function uee(e,t,r){let i=HQ(e);if(t.validateResourceURL)return await t.validateResourceURL(i,r?.resource);if(r){if(!GQ({requestedResource:i,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${i} (or origin)`);return new URL(r.resource)}}async function P0(e,{serverUrl:t,authorizationCode:r,scope:i,resourceMetadataUrl:n,fetchFn:o}){let s,l;try{s=await eee(t,{resourceMetadataUrl:n},o),s.authorization_servers&&s.authorization_servers.length>0&&(l=s.authorization_servers[0]);}catch{}l||(l=t);let c=await uee(t,e,s),u=await ree(l,{fetchFn:o}),d=await Promise.resolve(e.clientInformation());if(!d){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let h=await cee(l,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:o});await e.saveClientInformation(h),d=h;}if(r!==void 0){let h=await e.codeVerifier(),y=await see(l,{metadata:u,clientInformation:d,authorizationCode:r,codeVerifier:h,redirectUri:e.redirectUrl,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:o});return await e.saveTokens(y),"AUTHORIZED"}let p=await e.tokens();if(p?.refresh_token)try{let h=await lee(l,{metadata:u,clientInformation:d,refreshToken:p.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:o});return await e.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof jc)||h instanceof Ha))throw h}let f=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:v}=await nee(l,{metadata:u,clientInformation:d,state:f,redirectUrl:e.redirectUrl,scope:i||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(m),"REDIRECT"}function fee(e){switch(e.type){case "sse":return new dee(e);case "http":return new pee(e);default:throw new Ze({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function mee(e){return "start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}function t2({output:e}){let t=e;return !("content"in t)||!Array.isArray(t.content)?{type:"json",value:t}:{type:"content",value:t.content.map(i=>i.type==="text"&&"text"in i?{type:"text",text:i.text}:i.type==="image"&&"data"in i&&"mimeType"in i?{type:"image-data",data:i.data,mediaType:i.mimeType}:{type:"text",text:JSON.stringify(i)})}}async function y2(e){let t=new gee(e);return await t.init(),t}var fQ,r2,mQ,Hz,Gz,Ze,Ga,hQ,gQ,yQ,Yf,qn,n2,i2,vQ,_Q,A0,bQ,wQ,o2,a2,xQ,SQ,s2,l2,c2,u2,kQ,TQ,IQ,$Q,EQ,CQ,OQ,PQ,AQ,NQ,Yz,jQ,Xf,RQ,MQ,zQ,DQ,Nc,d2,p2,mr,UQ,f2,LQ,qQ,FQ,ZQ,VQ,BQ,JQ,m2,WQ,Xz,Qz,jc,Ha,Bf,Jf,Wf,KQ,Kf,dee,pee,hee,gee,v2=T(()=>{et();Rt();et();le();le();Kz();le();Rt();et();fQ="AI_MCPClientError",r2=`vercel.ai.error.${fQ}`,mQ=Symbol.for(r2),Ze=class extends(Gz=Le,Hz=mQ,Gz){constructor({name:e="MCPClientError",message:t,cause:r,data:i,code:n}){super({name:e,message:t,cause:r}),this[Hz]=true,this.data=i,this.code=n;}static isInstance(e){return Le.hasMarker(e,r2)}},Ga="2025-06-18",hQ=[Ga,"2025-03-26","2024-11-05"],gQ=a.optional(a.record(a.string(),a.unknown())),yQ=a.looseObject({name:a.string(),version:a.string()}),Yf=a.looseObject({_meta:a.optional(a.object({}).loose())}),qn=Yf,n2=a.object({method:a.string(),params:a.optional(Yf)}),i2=a.object({applyDefaults:a.optional(a.boolean())}).loose(),vQ=a.looseObject({experimental:a.optional(a.object({}).loose()),logging:a.optional(a.object({}).loose()),prompts:a.optional(a.looseObject({listChanged:a.optional(a.boolean())})),resources:a.optional(a.looseObject({subscribe:a.optional(a.boolean()),listChanged:a.optional(a.boolean())})),tools:a.optional(a.looseObject({listChanged:a.optional(a.boolean())})),elicitation:a.optional(i2)}),a.object({elicitation:a.optional(i2)}).loose(),_Q=qn.extend({protocolVersion:a.string(),capabilities:vQ,serverInfo:yQ,instructions:a.optional(a.string())}),A0=qn.extend({nextCursor:a.optional(a.string())}),bQ=a.object({name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),inputSchema:a.object({type:a.literal("object"),properties:a.optional(a.object({}).loose())}).loose(),outputSchema:a.optional(a.object({}).loose()),annotations:a.optional(a.object({title:a.optional(a.string())}).loose()),_meta:gQ}).loose(),wQ=A0.extend({tools:a.array(bQ)}),o2=a.object({type:a.literal("text"),text:a.string()}).loose(),a2=a.object({type:a.literal("image"),data:a.base64(),mimeType:a.string()}).loose(),xQ=a.object({uri:a.string(),name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),mimeType:a.optional(a.string()),size:a.optional(a.number())}).loose(),SQ=A0.extend({resources:a.array(xQ)}),s2=a.object({uri:a.string(),name:a.optional(a.string()),title:a.optional(a.string()),mimeType:a.optional(a.string())}).loose(),l2=s2.extend({text:a.string()}),c2=s2.extend({blob:a.base64()}),u2=a.object({type:a.literal("resource"),resource:a.union([l2,c2])}).loose(),kQ=qn.extend({content:a.array(a.union([o2,a2,u2])),structuredContent:a.optional(a.unknown()),isError:a.boolean().default(false).optional()}).or(qn.extend({toolResult:a.unknown()})),TQ=a.object({uriTemplate:a.string(),name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),mimeType:a.optional(a.string())}).loose(),IQ=qn.extend({resourceTemplates:a.array(TQ)}),$Q=qn.extend({contents:a.array(a.union([l2,c2]))}),EQ=a.object({name:a.string(),description:a.optional(a.string()),required:a.optional(a.boolean())}).loose(),CQ=a.object({name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),arguments:a.optional(a.array(EQ))}).loose(),OQ=A0.extend({prompts:a.array(CQ)}),PQ=a.object({role:a.union([a.literal("user"),a.literal("assistant")]),content:a.union([o2,a2,u2])}).loose(),AQ=qn.extend({description:a.optional(a.string()),messages:a.array(PQ)}),NQ=Yf.extend({message:a.string(),requestedSchema:a.unknown()}),Yz=n2.extend({method:a.literal("elicitation/create"),params:NQ}),jQ=qn.extend({action:a.union([a.literal("accept"),a.literal("decline"),a.literal("cancel")]),content:a.optional(a.record(a.string(),a.unknown()))}),Xf="2.0",RQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()])}).merge(n2).strict(),MQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()]),result:qn}).strict(),zQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()]),error:a.object({code:a.number().int(),message:a.string(),data:a.optional(a.unknown())})}).strict(),DQ=a.object({jsonrpc:a.literal(Xf)}).merge(a.object({method:a.string(),params:a.optional(Yf)})).strict(),Nc=a.union([RQ,DQ,MQ,zQ]),d2=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",p2=a.object({access_token:a.string(),id_token:a.string().optional(),token_type:a.string(),expires_in:a.number().optional(),scope:a.string().optional(),refresh_token:a.string().optional()}).strip(),mr=a.string().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:a.ZodIssueCode.custom,message:"URL must be parseable",fatal:true}),a.NEVER}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),UQ=a.object({resource:a.string().url(),authorization_servers:a.array(mr).optional(),jwks_uri:a.string().url().optional(),scopes_supported:a.array(a.string()).optional(),bearer_methods_supported:a.array(a.string()).optional(),resource_signing_alg_values_supported:a.array(a.string()).optional(),resource_name:a.string().optional(),resource_documentation:a.string().optional(),resource_policy_uri:a.string().url().optional(),resource_tos_uri:a.string().url().optional(),tls_client_certificate_bound_access_tokens:a.boolean().optional(),authorization_details_types_supported:a.array(a.string()).optional(),dpop_signing_alg_values_supported:a.array(a.string()).optional(),dpop_bound_access_tokens_required:a.boolean().optional()}).passthrough(),f2=a.object({issuer:a.string(),authorization_endpoint:mr,token_endpoint:mr,registration_endpoint:mr.optional(),scopes_supported:a.array(a.string()).optional(),response_types_supported:a.array(a.string()),grant_types_supported:a.array(a.string()).optional(),code_challenge_methods_supported:a.array(a.string()),token_endpoint_auth_methods_supported:a.array(a.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.array(a.string()).optional()}).passthrough(),LQ=a.object({issuer:a.string(),authorization_endpoint:mr,token_endpoint:mr,userinfo_endpoint:mr.optional(),jwks_uri:mr,registration_endpoint:mr.optional(),scopes_supported:a.array(a.string()).optional(),response_types_supported:a.array(a.string()),grant_types_supported:a.array(a.string()).optional(),subject_types_supported:a.array(a.string()),id_token_signing_alg_values_supported:a.array(a.string()),claims_supported:a.array(a.string()).optional(),token_endpoint_auth_methods_supported:a.array(a.string()).optional()}).passthrough(),qQ=LQ.merge(f2.pick({code_challenge_methods_supported:true})),FQ=a.object({client_id:a.string(),client_secret:a.string().optional(),client_id_issued_at:a.number().optional(),client_secret_expires_at:a.number().optional()}).strip(),ZQ=a.object({redirect_uris:a.array(mr),token_endpoint_auth_method:a.string().optional(),grant_types:a.array(a.string()).optional(),response_types:a.array(a.string()).optional(),client_name:a.string().optional(),client_uri:mr.optional(),logo_uri:mr.optional(),scope:a.string().optional(),contacts:a.array(a.string()).optional(),tos_uri:mr.optional(),policy_uri:a.string().optional(),jwks_uri:mr.optional(),jwks:a.any().optional(),software_id:a.string().optional(),software_version:a.string().optional(),software_statement:a.string().optional()}).strip(),VQ=a.object({error:a.string(),error_description:a.string().optional(),error_uri:a.string().optional()}),BQ=ZQ.merge(FQ),JQ="AI_MCPClientOAuthError",m2=`vercel.ai.error.${JQ}`,WQ=Symbol.for(m2),jc=class extends(Qz=Le,Xz=WQ,Qz){constructor({name:e="MCPClientOAuthError",message:t,cause:r}){super({name:e,message:t,cause:r}),this[Xz]=true;}static isInstance(e){return Le.hasMarker(e,m2)}},Ha=class extends jc{};Ha.errorCode="server_error";Bf=class extends jc{};Bf.errorCode="invalid_client";Jf=class extends jc{};Jf.errorCode="invalid_grant";Wf=class extends jc{};Wf.errorCode="unauthorized_client";KQ={[Ha.errorCode]:Ha,[Bf.errorCode]:Bf,[Jf.errorCode]:Jf,[Wf.errorCode]:Wf};Kf=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError";}};dee=class{constructor({url:e,headers:t,authProvider:r}){this.connected=false,this.url=new URL(e),this.headers=t,this.authProvider=r;}async commonHeaders(e){let t={...this.headers,...e,"mcp-protocol-version":Ga};if(this.authProvider){let r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`);}return Xi(t,`ai-sdk/${d2}`,Nl())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;let r=async(i=false)=>{var n,o,s,l,c;try{let u=await this.commonHeaders({Accept:"text/event-stream"}),d=await fetch(this.url.href,{headers:u,signal:(n=this.abortController)==null?void 0:n.signal});if(d.status===401&&this.authProvider&&!i){this.resourceMetadataUrl=Hf(d);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let h=new Kf;return (o=this.onerror)==null||o.call(this,h),t(h)}}catch(v){return (s=this.onerror)==null||s.call(this,v),t(v)}return r(!0)}if(!d.ok||!d.body){let v=`MCP SSE Transport Error: ${d.status} ${d.statusText}`;d.status===405&&(v+=". This server does not support SSE transport. Try using `http` transport instead");let h=new Ze({message:v});return (l=this.onerror)==null||l.call(this,h),t(h)}let f=d.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader(),m=async()=>{var v,h,y;try{for(;;){let{done:w,value:S}=await f.read();if(w){if(this.connected)throw this.connected=!1,new Ze({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}let{event:_,data:x}=S;if(_==="endpoint"){if(this.endpoint=new URL(x,this.url),this.endpoint.origin!==this.url.origin)throw new Ze({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e();}else if(_==="message")try{let k=Nc.parse(JSON.parse(x));(v=this.onmessage)==null||v.call(this,k);}catch(k){let g=new Ze({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(h=this.onerror)==null||h.call(this,g);}}}catch(w){if(w instanceof Error&&w.name==="AbortError")return;(y=this.onerror)==null||y.call(this,w),t(w);}};this.sseConnection={close:()=>f.cancel()},m();}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(c=this.onerror)==null||c.call(this,u),t(u);}};r();})}async close(){var e,t,r;this.connected=false,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this);}async send(e){if(!this.endpoint||!this.connected)throw new Ze({message:"MCP SSE Transport Error: Not connected"});let t=this.endpoint,r=async(i=false)=>{var n,o,s,l,c;try{let d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(n=this.abortController)==null?void 0:n.signal},p=await fetch(t,d);if(p.status===401&&this.authProvider&&!i){this.resourceMetadataUrl=Hf(p);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let m=new Kf;(o=this.onerror)==null||o.call(this,m);return}}catch(f){(s=this.onerror)==null||s.call(this,f);return}return r(!0)}if(!p.ok){let f=await p.text().catch(()=>null),m=new Ze({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${p.status}): ${f}`});(l=this.onerror)==null||l.call(this,m);return}}catch(u){(c=this.onerror)==null||c.call(this,u);return}};await r();}},pee=class{constructor({url:e,headers:t,authProvider:r}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=r;}async commonHeaders(e){let t={...this.headers,...e,"mcp-protocol-version":Ga};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){let r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`);}return Xi(t,`ai-sdk/${d2}`,Nl())}async start(){if(this.abortController)throw new Ze({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse();}async close(){var e,t,r;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){let i=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:i,signal:this.abortController.signal}).catch(()=>{});}}catch{}(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this);}async send(e){let t=async(r=false)=>{var i,n,o,s,l,c,u;try{let p={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(i=this.abortController)==null?void 0:i.signal},f=await fetch(this.url,p),m=f.headers.get("mcp-session-id");if(m&&(this.sessionId=m),f.status===401&&this.authProvider&&!r){this.resourceMetadataUrl=Hf(f);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new Kf}catch(w){throw (n=this.onerror)==null||n.call(this,w),w}return t(!0)}if(f.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!f.ok){let w=await f.text().catch(()=>null),S=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${f.status}): ${w}`;f.status===404&&(S+=". This server does not support HTTP transport. Try using `sse` transport instead");let _=new Ze({message:S});throw (o=this.onerror)==null||o.call(this,_),_}if(!("id"in e))return;let h=f.headers.get("content-type")||"";if(h.includes("application/json")){let w=await f.json(),S=Array.isArray(w)?w.map(_=>Nc.parse(_)):[Nc.parse(w)];for(let _ of S)(s=this.onmessage)==null||s.call(this,_);return}if(h.includes("text/event-stream")){if(!f.body){let x=new Ze({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw (l=this.onerror)==null||l.call(this,x),x}let S=f.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader();(async()=>{var x,k,g;try{for(;;){let{done:$,value:C}=await S.read();if($)return;let{event:A,data:D}=C;if(A==="message")try{let oe=Nc.parse(JSON.parse(D));(x=this.onmessage)==null||x.call(this,oe);}catch(oe){let z=new Ze({message:"MCP HTTP Transport Error: Failed to parse message",cause:oe});(k=this.onerror)==null||k.call(this,z);}}}catch($){if($ instanceof Error&&$.name==="AbortError")return;(g=this.onerror)==null||g.call(this,$);}})();return}let y=new Ze({message:`MCP HTTP Transport Error: Unexpected content type: ${h}`});throw (c=this.onerror)==null||c.call(this,y),y}catch(d){throw (u=this.onerror)==null||u.call(this,d),d}};await t();}getNextReconnectionDelay(e){let{initialReconnectionDelay:t,reconnectionDelayGrowFactor:r,maxReconnectionDelay:i}=this.reconnectionOptions;return Math.min(t*Math.pow(r,e),i)}scheduleInboundSseReconnection(){var e;let{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new Ze({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}let r=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var i;(i=this.abortController)!=null&&i.signal.aborted||await this.openInboundSse(false,this.lastInboundEventId);},r);}async openInboundSse(e=false,t){var r,i,n,o,s,l;try{let c=await this.commonHeaders({Accept:"text/event-stream"});t&&(c["last-event-id"]=t);let u=await fetch(this.url.href,{method:"GET",headers:c,signal:(r=this.abortController)==null?void 0:r.signal}),d=u.headers.get("mcp-session-id");if(d&&(this.sessionId=d),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=Hf(u);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let h=new Kf;(i=this.onerror)==null||i.call(this,h);return}}catch(v){(n=this.onerror)==null||n.call(this,v);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){let v=new Ze({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(o=this.onerror)==null||o.call(this,v);return}let f=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader(),m=async()=>{var v,h,y,w;try{for(;;){let{done:S,value:_}=await f.read();if(S)return;let{event:x,data:k,id:g}=_;if(g&&(this.lastInboundEventId=g),x==="message")try{let $=Nc.parse(JSON.parse(k));(v=this.onmessage)==null||v.call(this,$);}catch($){let C=new Ze({message:"MCP HTTP Transport Error: Failed to parse message",cause:$});(h=this.onerror)==null||h.call(this,C);}}}catch(S){if(S instanceof Error&&S.name==="AbortError")return;(y=this.onerror)==null||y.call(this,S),(w=this.abortController)!=null&&w.signal.aborted||this.scheduleInboundSseReconnection();}};this.inboundSseConnection={close:()=>f.cancel()},this.inboundReconnectAttempts=0,m();}catch(c){if(c instanceof Error&&c.name==="AbortError")return;(s=this.onerror)==null||s.call(this,c),(l=this.abortController)!=null&&l.signal.aborted||this.scheduleInboundSseReconnection();}}};hee="1.0.0";gee=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:r=hee,onUncaughtError:i,capabilities:n}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=true,this.onUncaughtError=i,this.clientCapabilities=n??{},mee(e)?this.transport=e:this.transport=fee(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=o=>this.onError(o),this.transport.onmessage=o=>{if("method"in o){"id"in o?this.onRequestMessage(o):this.onError(new Ze({message:"Unsupported message type"}));return}this.onResponse(o);},this.clientInfo={name:t,version:r};}async init(){try{await this.transport.start(),this.isClosed=!1;let e=await this.request({request:{method:"initialize",params:{protocolVersion:Ga,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:_Q});if(e===void 0)throw new Ze({message:"Server sent invalid initialize result"});if(!hQ.includes(e.protocolVersion))throw new Ze({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose());}assertCapability(e){switch(e){case "initialize":break;case "tools/list":case "tools/call":if(!this.serverCapabilities.tools)throw new Ze({message:"Server does not support tools"});break;case "resources/list":case "resources/read":case "resources/templates/list":if(!this.serverCapabilities.resources)throw new Ze({message:"Server does not support resources"});break;case "prompts/list":case "prompts/get":if(!this.serverCapabilities.prompts)throw new Ze({message:"Server does not support prompts"});break;default:throw new Ze({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:r}){return new Promise((i,n)=>{if(this.isClosed)return n(new Ze({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);let o=r?.signal;o?.throwIfAborted();let s=this.requestMessageId++,l={...e,jsonrpc:"2.0",id:s},c=()=>{this.responseHandlers.delete(s);};this.responseHandlers.set(s,u=>{if(o?.aborted)return n(new Ze({message:"Request was aborted",cause:o.reason}));if(u instanceof Error)return n(u);try{let d=t.parse(u.result);i(d);}catch(d){let p=new Ze({message:"Failed to parse server response",cause:d});n(p);}}),this.transport.send(l).catch(u=>{c(),n(u);});})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:wQ,options:t})}catch(r){throw r}}async callTool({name:e,args:t,options:r}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:kQ,options:{signal:r?.abortSignal}})}catch(i){throw i}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:SQ,options:t})}catch(r){throw r}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:$Q,options:t})}catch(r){throw r}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:IQ,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:OQ,options:t})}catch(r){throw r}}async getPromptInternal({name:e,args:t,options:r}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:AQ,options:r})}catch(i){throw i}}async notification(e){let t={...e,jsonrpc:"2.0"};await this.transport.send(t);}async tools({schemas:e="automatic"}={}){var t,r;let i={};try{let n=await this.listTools();for(let{name:o,title:s,description:l,inputSchema:c,annotations:u,_meta:d}of n.tools){let p=s??u?.title;if(e!=="automatic"&&!(o in e))continue;let f=this,m=e!=="automatic"?(t=e[o])==null?void 0:t.outputSchema:void 0,v=async(y,w)=>{var S;(S=w?.abortSignal)==null||S.throwIfAborted();let _=await f.callTool({name:o,args:y,options:w});return m!=null?f.extractStructuredContent(_,m,o):_},h=e==="automatic"?dj({description:l,title:p,inputSchema:Ta({...c,properties:(r=c.properties)!=null?r:{},additionalProperties:!1}),execute:v,toModelOutput:t2}):{description:l,title:p,inputSchema:e[o].inputSchema,...m!=null?{outputSchema:m}:{},execute:v,toModelOutput:t2};i[o]={...h,_meta:d};}return i}catch(n){throw n}}async extractStructuredContent(e,t,r){if("structuredContent"in e&&e.structuredContent!=null){let i=await jl({value:e.structuredContent,schema:aw(t)});if(!i.success)throw new Ze({message:`Tool "${r}" returned structuredContent that does not match the expected outputSchema`,cause:i.error});return i.value}if("content"in e&&Array.isArray(e.content)){let i=e.content.find(n=>n.type==="text");if(i&&"text"in i){let n=await wp({text:i.text,schema:t});if(!n.success)throw new Ze({message:`Tool "${r}" returned content that does not match the expected outputSchema`,cause:n.error});return n.value}}throw new Ze({message:`Tool "${r}" did not return structuredContent or parseable text content`})}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}experimental_listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}experimental_getPrompt({name:e,arguments:t,options:r}){return this.getPromptInternal({name:e,args:t,options:r})}onElicitationRequest(e,t){if(e!==Yz)throw new Ze({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t;}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}let t=Yz.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{let r=await this.elicitationRequestHandler(t.data),i=jQ.parse(r);await this.transport.send({jsonrpc:"2.0",id:e.id,result:i});}catch(r){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Failed to handle elicitation request"}}),this.onError(r);}}catch(t){this.onError(t);}}onClose(){if(this.isClosed)return;this.isClosed=true;let e=new Ze({message:"Connection closed"});for(let t of this.responseHandlers.values())t(e);this.responseHandlers.clear();}onError(e){this.onUncaughtError&&this.onUncaughtError(e);}onResponse(e){let t=Number(e.id),r=this.responseHandlers.get(t);if(r===void 0)throw new Ze({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),r("result"in e?e:new Ze({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}));}};});async function vee(e){let t=ss__namespace.join(e,".pulse-coder","mcp.json"),r=ss__namespace.join(e,".coder","mcp.json"),i=Dj.existsSync(t)?t:r;if(!Dj.existsSync(i))return {servers:{}};try{let n=Dj.readFileSync(i,"utf-8"),o=JSON.parse(n);return !o.servers||typeof o.servers!="object"?(console.warn('[MCP] Invalid config: missing "servers" object'),{servers:{}}):{servers:o.servers}}catch(n){return console.warn(`[MCP] Failed to load config: ${n instanceof Error?n.message:"Unknown error"}`),{servers:{}}}}function _ee(e){return {type:"http",url:e.url}}var Qf,M0=T(()=>{v2();Qf={name:"pulse-coder-engine/built-in-mcp",version:"1.0.0",async initialize(e){let t=await vee(process.cwd()),r=Object.keys(t.servers).length;if(r===0){console.log("[MCP] No MCP servers configured");return}let i=0;for(let[n,o]of Object.entries(t.servers))try{if(!o.url){console.warn(`[MCP] Server "${n}" missing URL, skipping`);continue}let s=_ee(o),l=await y2({transport:s}),c=await l.tools(),u=Object.fromEntries(Object.entries(c).map(([d,p])=>[`mcp_${n}_${d}`,p]));e.registerTools(u),i++,console.log(`[MCP] Server "${n}" loaded (${Object.keys(c).length} tools)`),e.registerService(`mcp:${n}`,l);}catch(s){console.warn(`[MCP] Failed to load server "${n}": ${s instanceof Error?s.message:"Unknown error"}`);}i>0?console.log(`[MCP] Successfully loaded ${i}/${r} MCP servers`):console.warn("[MCP] No MCP servers were loaded successfully");}};});var Rc=M((A_e,w2)=>{var bee=Object.prototype.toString;w2.exports=function(t){if(t===void 0)return "undefined";if(t===null)return "null";var r=typeof t;if(r==="boolean")return "boolean";if(r==="string")return "string";if(r==="number")return "number";if(r==="symbol")return "symbol";if(r==="function")return Tee(t)?"generatorfunction":"function";if(wee(t))return "array";if(Eee(t))return "buffer";if($ee(t))return "arguments";if(See(t))return "date";if(xee(t))return "error";if(kee(t))return "regexp";switch(b2(t)){case "Symbol":return "symbol";case "Promise":return "promise";case "WeakMap":return "weakmap";case "WeakSet":return "weakset";case "Map":return "map";case "Set":return "set";case "Int8Array":return "int8array";case "Uint8Array":return "uint8array";case "Uint8ClampedArray":return "uint8clampedarray";case "Int16Array":return "int16array";case "Uint16Array":return "uint16array";case "Int32Array":return "int32array";case "Uint32Array":return "uint32array";case "Float32Array":return "float32array";case "Float64Array":return "float64array"}if(Iee(t))return "generator";switch(r=bee.call(t),r){case "[object Object]":return "object";case "[object Map Iterator]":return "mapiterator";case "[object Set Iterator]":return "setiterator";case "[object String Iterator]":return "stringiterator";case "[object Array Iterator]":return "arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function b2(e){return typeof e.constructor=="function"?e.constructor.name:null}function wee(e){return Array.isArray?Array.isArray(e):e instanceof Array}function xee(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function See(e){return e instanceof Date?true:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function kee(e){return e instanceof RegExp?true:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function Tee(e,t){return b2(e)==="GeneratorFunction"}function Iee(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function $ee(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return !0}catch(t){if(t.message.indexOf("callee")!==-1)return true}return false}function Eee(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):false}});var S2=M((N_e,x2)=>{x2.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t=="object"||typeof t=="function")};});var I2=M((j_e,T2)=>{var k2=S2();T2.exports=function(t){k2(t)||(t={});for(var r=arguments.length,i=1;i<r;i++){var n=arguments[i];k2(n)&&Cee(t,n);}return t};function Cee(e,t){for(var r in t)Oee(t,r)&&(e[r]=t[r]);}function Oee(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var C2=M((R_e,E2)=>{var Pee=Rc(),Aee=I2();E2.exports=function(e,t){typeof t=="function"&&(t={parse:t});var r=jee(e),i={section_delimiter:"---",parse:Mee},n=Aee({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),l=null,c=$2(),u=[],d=[];function p(w){r.content=w,l=[],u=[];}function f(w){d.length&&(c.key=Ree(d[0],o),c.content=w,n.parse(c,l),l.push(c),c=$2(),u=[],d=[]);}for(var m=0;m<s.length;m++){var v=s[m],h=d.length,y=v.trim();if(Nee(y,o)){if(y.length===3&&m!==0){if(h===0||h===2){u.push(v);continue}d.push(y),c.data=u.join(`
|
|
381
|
+
`,r)+1;}return {type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case "alias":case "scalar":case "single-quoted-scalar":case "double-quoted-scalar":return this.flowScalar(this.type);case "block-scalar-header":return {type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case "flow-map-start":case "flow-seq-start":return {type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case "seq-item-ind":return {type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case "explicit-key-ind":{this.onKeyLine=true;let r=Zf(t),i=Ka(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:true}]}}case "map-value-ind":{this.onKeyLine=true;let r=Zf(t),i=Ka(r);return {type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?false:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()));}*lineEnd(t){switch(this.type){case "comma":case "doc-start":case "doc-end":case "flow-seq-end":case "flow-map-end":case "map-value-ind":yield*this.pop(),yield*this.step();break;case "newline":this.onKeyLine=false;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop());}}};Lz.Parser=k0;});var Bz=M(Pc=>{var qz=d0(),FX=xc(),Oc=Tc(),ZX=cx(),VX=qe(),BX=S0(),Fz=T0();function Zz(e){let t=e.prettyErrors!==false;return {lineCounter:e.lineCounter||t&&new BX.LineCounter||null,prettyErrors:t}}function JX(e,t={}){let{lineCounter:r,prettyErrors:i}=Zz(t),n=new Fz.Parser(r?.addNewLine),o=new qz.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let l of s)l.errors.forEach(Oc.prettifyError(e,r)),l.warnings.forEach(Oc.prettifyError(e,r));return s.length>0?s:Object.assign([],{empty:true},o.streamInfo())}function Vz(e,t={}){let{lineCounter:r,prettyErrors:i}=Zz(t),n=new Fz.Parser(r?.addNewLine),o=new qz.Composer(t),s=null;for(let l of o.compose(n.parse(e),true,e.length))if(!s)s=l;else if(s.options.logLevel!=="silent"){s.errors.push(new Oc.YAMLParseError(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(s.errors.forEach(Oc.prettifyError(e,r)),s.warnings.forEach(Oc.prettifyError(e,r))),s}function WX(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=Vz(e,r);if(!n)return null;if(n.warnings.forEach(o=>ZX.warn(n.options.logLevel,o)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[];}return n.toJS(Object.assign({reviver:i},r))}function KX(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n};}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return VX.isDocument(e)&&!i?e.toString(r):new FX.Document(e,i,r).toString(r)}Pc.parse=WX;Pc.parseAllDocuments=JX;Pc.parseDocument=Vz;Pc.stringify=KX;});var Wz=M(Be=>{var HX=d0(),GX=xc(),YX=Bx(),I0=Tc(),XX=oc(),Ii=qe(),QX=wi(),eQ=yt(),tQ=Si(),rQ=ki(),nQ=qf(),iQ=w0(),oQ=S0(),aQ=T0(),Vf=Bz(),Jz=tc();Be.Composer=HX.Composer;Be.Document=GX.Document;Be.Schema=YX.Schema;Be.YAMLError=I0.YAMLError;Be.YAMLParseError=I0.YAMLParseError;Be.YAMLWarning=I0.YAMLWarning;Be.Alias=XX.Alias;Be.isAlias=Ii.isAlias;Be.isCollection=Ii.isCollection;Be.isDocument=Ii.isDocument;Be.isMap=Ii.isMap;Be.isNode=Ii.isNode;Be.isPair=Ii.isPair;Be.isScalar=Ii.isScalar;Be.isSeq=Ii.isSeq;Be.Pair=QX.Pair;Be.Scalar=eQ.Scalar;Be.YAMLMap=tQ.YAMLMap;Be.YAMLSeq=rQ.YAMLSeq;Be.CST=nQ;Be.Lexer=iQ.Lexer;Be.LineCounter=oQ.LineCounter;Be.Parser=aQ.Parser;Be.parse=Vf.parse;Be.parseAllDocuments=Vf.parseAllDocuments;Be.parseDocument=Vf.parseDocument;Be.stringify=Vf.stringify;Be.visit=Jz.visit;Be.visitAsync=Jz.visitAsync;});var Ac,E0=T(()=>{Bw();Jw();Ac=class{enginePlugins=new Map;userConfigPlugins=[];tools=new Map;runHooks=new Map;services=new Map;protocols=new Map;config=new Map;events=new events.EventEmitter;logger;constructor(t){this.logger=t??{debug:(r,i)=>console.debug(`[PluginManager] ${r}`,i),info:(r,i)=>console.info(`[PluginManager] ${r}`,i),warn:(r,i)=>console.warn(`[PluginManager] ${r}`,i),error:(r,i,n)=>console.error(`[PluginManager] ${r}`,i,n)};}async initialize(t={}){this.logger.info("Initializing plugin system...");try{await this.loadEnginePlugins(t.enginePlugins),await this.validateCoreCapabilities(),await this.loadUserConfigPlugins(t.userConfigPlugins),this.logger.info("Plugin system initialized successfully");}catch(r){throw this.logger.error("Failed to initialize plugin system",r),r}}async loadEnginePlugins(t={}){let r=[];if(t.plugins&&r.push(...t.plugins),t.scan!==false){let n=t.dirs||[".pulse-coder/engine-plugins",".coder/engine-plugins","~/.pulse-coder/engine-plugins","~/.coder/engine-plugins"];for(let o of n){let s=await this.scanEnginePlugins(o);r.push(...s);}}let i=this.sortPluginsByDependencies(r);for(let n of i)await this.initializeEnginePlugin(n);}async scanEnginePlugins(t){let r=[],i=this.resolvePath(t);try{let o=await ec("**/*.plugin.{js,ts}",{cwd:i,absolute:!0});for(let s of o)try{let l=await this.loadEnginePluginFile(s);r.push(l),this.logger.info(`Loaded engine plugin: ${l.name} from ${s}`);}catch(l){this.logger.error(`Failed to load engine plugin from ${s}`,l);}}catch{this.logger.debug(`Directory not found: ${i}`);}return r}async loadEnginePluginFile(t){let r=await import(t),i=r.default||r;if(!i.name||!i.initialize)throw new Error(`Invalid engine plugin: ${t}`);return i}async initializeEnginePlugin(t){try{if(t.dependencies){for(let i of t.dependencies)if(!this.enginePlugins.has(i))throw new Error(`Dependency not found: ${i} for plugin ${t.name}`)}let r={registerTool:(i,n)=>{this.tools.set(i,n);},registerTools:i=>{Object.entries(i).forEach(([n,o])=>{this.tools.set(n,o);});},getTool:i=>this.tools.get(i),getTools:()=>Object.fromEntries(this.tools),registerRunHook:(i,n)=>{this.runHooks.set(i,n);},getRunHook:i=>this.runHooks.get(i),registerProtocol:(i,n)=>{this.protocols.set(i,n);},getProtocol:i=>this.protocols.get(i),registerService:(i,n)=>{this.services.set(i,n);},getService:i=>this.services.get(i),getConfig:i=>this.config.get(i),setConfig:(i,n)=>this.config.set(i,n),events:this.events,logger:this.logger};t.beforeInitialize&&await t.beforeInitialize(r),await t.initialize(r),t.afterInitialize&&await t.afterInitialize(r),this.enginePlugins.set(t.name,t);}catch(r){throw new Error(`Failed to initialize engine plugin ${t.name}: ${r}`)}}async loadUserConfigPlugins(t={}){let r=[];if(t.configs&&r.push(...t.configs),t.scan!==false){let i=t.dirs||[".pulse-coder/config",".coder/config","~/.pulse-coder/config","~/.coder/config"];for(let n of i){let o=await this.scanUserConfigPlugins(n);r.push(...o);}}for(let i of r)await this.applyUserConfig(i);}async scanUserConfigPlugins(t){let r=[],i=this.resolvePath(t);try{let n=["config.{json,yaml,yml}","*.config.{json,yaml,yml}"];for(let o of n){let s=await ec(o,{cwd:i,absolute:!0});for(let l of s)try{let c=await this.loadUserConfigFile(l);r.push(c),this.logger.info(`Loaded user config: ${c.name||l}`);}catch(c){this.logger.error(`Failed to load user config from ${l}`,c);}}}catch{this.logger.debug(`Directory not found: ${i}`);}return r}async loadUserConfigFile(t){let r=await Dj.promises.readFile(t,"utf-8"),i=ss__namespace.default.extname(t),n;try{if(i===".json")n=JSON.parse(r);else if(i===".yaml"||i===".yml")n=(await Promise.resolve().then(()=>Oi(Wz(),1))).parse(r);else throw new Error(`Unsupported config format: ${i}`)}catch(s){throw new Error(`Failed to parse config file ${t}: ${s}`)}return n=new Wp().resolveObject(n),n}async applyUserConfig(t){try{if(t.tools)for(let[r,i]of Object.entries(t.tools))i.enabled!==!1&&this.logger.debug(`Configured tool: ${r}`);if(t.mcp?.servers)for(let r of t.mcp.servers)r.enabled!==!1&&this.logger.debug(`Configured MCP server: ${r.name}`);if(t.subAgents)for(let r of t.subAgents)r.enabled!==!1&&this.logger.debug(`Configured sub-agent: ${r.name}`);t.skills&&this.logger.debug("Configured skills scanning",t.skills),this.userConfigPlugins.push(t);}catch(r){this.logger.error("Failed to apply user config",r);}}async validateCoreCapabilities(){let t=[];for(let i of t)if(!i.aliases.some(o=>this.enginePlugins.has(o)))throw new Error(`Missing required capability "${i.name}". Expected one of: ${i.aliases.join(", ")}`);let r=[{name:"skills",aliases:["pulse-coder-engine/built-in-skills"]}];for(let i of r)i.aliases.some(o=>this.enginePlugins.has(o))||this.logger.warn(`Missing recommended capability "${i.name}". Expected one of: ${i.aliases.join(", ")}`);}sortPluginsByDependencies(t){let r=[],i=new Set,n=new Set,o=s=>{if(!i.has(s.name)){if(n.has(s.name))throw new Error(`Circular dependency detected: ${s.name}`);if(n.add(s.name),s.dependencies)for(let l of s.dependencies){let c=t.find(u=>u.name===l);c&&o(c);}n.delete(s.name),i.add(s.name),r.push(s);}};for(let s of t)o(s);return r}getTools(){return Object.fromEntries(this.tools)}getRunHooks(){return Array.from(this.runHooks.values())}getService(t){return this.services.get(t)}getProtocol(t){return this.protocols.get(t)}getStatus(){return {enginePlugins:Array.from(this.enginePlugins.keys()),userConfigPlugins:this.userConfigPlugins.map(t=>t.name||"unnamed"),tools:Array.from(this.tools.keys()),runHooks:Array.from(this.runHooks.keys()),services:Array.from(this.services.keys()),protocols:Array.from(this.protocols.keys())}}resolvePath(t){return t.startsWith("~/")?ss__namespace.default.join(process.env.HOME||process.env.USERPROFILE||"",t.slice(2)):ss__namespace.default.resolve(t)}};});async function cQ(e){return (await C0).getRandomValues(new Uint8Array(e))}async function uQ(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,i="";for(;i.length<e;){let n=await cQ(e-i.length);for(let o of n)o<r&&(i+=t[o%t.length]);}return i}async function dQ(e){return await uQ(e)}async function pQ(e){let t=await(await C0).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function O0(e){if(e||(e=43),e<43||e>128)throw `Expected a length between 43 and 128. Received ${e}.`;let t=await dQ(e),r=await pQ(t);return {code_verifier:t,code_challenge:r}}var C0,Kz=T(()=>{C0=globalThis.crypto?.webcrypto??globalThis.crypto??import('crypto').then(e=>e.webcrypto);});function HQ(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function GQ({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),i=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==i.origin||r.pathname.length<i.pathname.length)return false;let n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",o=i.pathname.endsWith("/")?i.pathname:i.pathname+"/";return n.startsWith(o)}function Hf(e){var t;let r=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!r)return;let[i,n]=r.split(" ");if(i.toLowerCase()!=="bearer"||!n)return;let o=/resource_metadata="([^"]*)"/,s=r.match(o);if(s)try{return new URL(s[1])}catch{return}}function YQ(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function N0(e,t,r=fetch){try{return await r(e,{headers:t})}catch(i){if(i instanceof TypeError)return t?N0(e,void 0,r):void 0;throw i}}async function eD(e,t,r=fetch){return await N0(e,{"MCP-Protocol-Version":t},r)}function XQ(e,t){return !e||e.status>=400&&e.status<500&&t!=="/"}async function QQ(e,t,r,i){var n,o;let s=new URL(e),l=(n=i?.protocolVersion)!=null?n:Ga,c;if(i?.metadataUrl)c=new URL(i.metadataUrl);else {let d=YQ(t,s.pathname);c=new URL(d,(o=i?.metadataServerUrl)!=null?o:s),c.search=s.search;}let u=await eD(c,l,r);if(!i?.metadataUrl&&XQ(u,s.pathname)){let d=new URL(`/.well-known/${t}`,s);u=await eD(d,l,r);}return u}async function eee(e,t,r=fetch){let i=await QQ(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!i||i.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!i.ok)throw new Error(`HTTP ${i.status} trying to load well-known OAuth protected resource metadata.`);return UQ.parse(await i.json())}function tee(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",i=[];if(!r)return i.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),i.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),i;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),i.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),i.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),i.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),i.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),i}async function ree(e,{fetchFn:t=fetch,protocolVersion:r=Ga}={}){var i;let n={"MCP-Protocol-Version":r},o=tee(e);for(let{url:s,type:l}of o){let c=await N0(s,n,t);if(c){if(!c.ok){if(c.status>=400&&c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${l==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}if(l==="oauth")return fD.parse(await c.json());{let u=qQ.parse(await c.json());if(!((i=u.code_challenge_methods_supported)!=null&&i.includes("S256")))throw new Error(`Incompatible OIDC provider at ${s}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function nee(e,{metadata:t,clientInformation:r,redirectUrl:i,scope:n,state:o,resource:s}){let l="code",c="S256",u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support response type ${l}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(c))throw new Error(`Incompatible auth server: does not support code challenge method ${c}`)}else u=new URL("/authorize",e);let d=await O0(),p=d.code_verifier,f=d.code_challenge;return u.searchParams.set("response_type",l),u.searchParams.set("client_id",r.client_id),u.searchParams.set("code_challenge",f),u.searchParams.set("code_challenge_method",c),u.searchParams.set("redirect_uri",String(i)),o&&u.searchParams.set("state",o),n&&u.searchParams.set("scope",n),n?.includes("offline_access")&&u.searchParams.append("prompt","consent"),s&&u.searchParams.set("resource",s.href),{authorizationUrl:u,codeVerifier:p}}function hD(e,t){let r=e.client_secret!==void 0;return t.length===0?r?"client_secret_post":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function gD(e,t,r,i){let{client_id:n,client_secret:o}=t;switch(e){case "client_secret_basic":iee(n,o,r);return;case "client_secret_post":oee(n,o,i);return;case "none":aee(n,i);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function iee(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let i=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${i}`);}function oee(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t);}function aee(e,t){t.set("client_id",e);}async function j0(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let i=VQ.parse(JSON.parse(r)),{error:n,error_description:o,error_uri:s}=i,l=KQ[n]||Ha;return new l({message:o||"",cause:s})}catch(i){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${i}. Raw body: ${r}`;return new Ha({message:n})}}async function see(e,{metadata:t,clientInformation:r,authorizationCode:i,codeVerifier:n,redirectUri:o,resource:s,addClientAuthentication:l,fetchFn:c}){var u;let d="authorization_code",p=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(d))throw new Error(`Incompatible auth server: does not support grant type ${d}`);let f=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),m=new URLSearchParams({grant_type:d,code:i,code_verifier:n,redirect_uri:String(o)});if(l)l(f,m,e,t);else {let h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],y=hD(r,h);gD(y,r,f,m);}s&&m.set("resource",s.href);let v=await(c??fetch)(p,{method:"POST",headers:f,body:m});if(!v.ok)throw await j0(v);return pD.parse(await v.json())}async function lee(e,{metadata:t,clientInformation:r,refreshToken:i,resource:n,addClientAuthentication:o,fetchFn:s}){var l;let c="refresh_token",u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else u=new URL("/token",e);let d=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),p=new URLSearchParams({grant_type:c,refresh_token:i});if(o)o(d,p,e,t);else {let m=(l=t?.token_endpoint_auth_methods_supported)!=null?l:[],v=hD(r,m);gD(v,r,d,p);}n&&p.set("resource",n.href);let f=await(s??fetch)(u,{method:"POST",headers:d,body:p});if(!f.ok)throw await j0(f);return pD.parse({refresh_token:i,...await f.json()})}async function cee(e,{metadata:t,clientMetadata:r,fetchFn:i}){let n;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint);}else n=new URL("/register",e);let o=await(i??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw await j0(o);return BQ.parse(await o.json())}async function Gf(e,t){var r,i;try{return await P0(e,t)}catch(n){if(n instanceof Bf||n instanceof Wf)return await((r=e.invalidateCredentials)==null?void 0:r.call(e,"all")),await P0(e,t);if(n instanceof Jf)return await((i=e.invalidateCredentials)==null?void 0:i.call(e,"tokens")),await P0(e,t);throw n}}async function uee(e,t,r){let i=HQ(e);if(t.validateResourceURL)return await t.validateResourceURL(i,r?.resource);if(r){if(!GQ({requestedResource:i,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${i} (or origin)`);return new URL(r.resource)}}async function P0(e,{serverUrl:t,authorizationCode:r,scope:i,resourceMetadataUrl:n,fetchFn:o}){let s,l;try{s=await eee(t,{resourceMetadataUrl:n},o),s.authorization_servers&&s.authorization_servers.length>0&&(l=s.authorization_servers[0]);}catch{}l||(l=t);let c=await uee(t,e,s),u=await ree(l,{fetchFn:o}),d=await Promise.resolve(e.clientInformation());if(!d){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let h=await cee(l,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:o});await e.saveClientInformation(h),d=h;}if(r!==void 0){let h=await e.codeVerifier(),y=await see(l,{metadata:u,clientInformation:d,authorizationCode:r,codeVerifier:h,redirectUri:e.redirectUrl,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:o});return await e.saveTokens(y),"AUTHORIZED"}let p=await e.tokens();if(p?.refresh_token)try{let h=await lee(l,{metadata:u,clientInformation:d,refreshToken:p.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:o});return await e.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof jc)||h instanceof Ha))throw h}let f=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:v}=await nee(l,{metadata:u,clientInformation:d,state:f,redirectUrl:e.redirectUrl,scope:i||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(m),"REDIRECT"}function fee(e){switch(e.type){case "sse":return new dee(e);case "http":return new pee(e);default:throw new Ze({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function mee(e){return "start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}function tD({output:e}){let t=e;return !("content"in t)||!Array.isArray(t.content)?{type:"json",value:t}:{type:"content",value:t.content.map(i=>i.type==="text"&&"text"in i?{type:"text",text:i.text}:i.type==="image"&&"data"in i&&"mimeType"in i?{type:"image-data",data:i.data,mediaType:i.mimeType}:{type:"text",text:JSON.stringify(i)})}}async function yD(e){let t=new gee(e);return await t.init(),t}var fQ,rD,mQ,Hz,Gz,Ze,Ga,hQ,gQ,yQ,Yf,qn,nD,iD,vQ,_Q,A0,bQ,wQ,oD,aD,xQ,SQ,sD,lD,cD,uD,kQ,TQ,IQ,$Q,EQ,CQ,OQ,PQ,AQ,NQ,Yz,jQ,Xf,RQ,MQ,zQ,DQ,Nc,dD,pD,mr,UQ,fD,LQ,qQ,FQ,ZQ,VQ,BQ,JQ,mD,WQ,Xz,Qz,jc,Ha,Bf,Jf,Wf,KQ,Kf,dee,pee,hee,gee,vD=T(()=>{et();Rt();et();le();le();Kz();le();Rt();et();fQ="AI_MCPClientError",rD=`vercel.ai.error.${fQ}`,mQ=Symbol.for(rD),Ze=class extends(Gz=Le,Hz=mQ,Gz){constructor({name:e="MCPClientError",message:t,cause:r,data:i,code:n}){super({name:e,message:t,cause:r}),this[Hz]=true,this.data=i,this.code=n;}static isInstance(e){return Le.hasMarker(e,rD)}},Ga="2025-06-18",hQ=[Ga,"2025-03-26","2024-11-05"],gQ=a.optional(a.record(a.string(),a.unknown())),yQ=a.looseObject({name:a.string(),version:a.string()}),Yf=a.looseObject({_meta:a.optional(a.object({}).loose())}),qn=Yf,nD=a.object({method:a.string(),params:a.optional(Yf)}),iD=a.object({applyDefaults:a.optional(a.boolean())}).loose(),vQ=a.looseObject({experimental:a.optional(a.object({}).loose()),logging:a.optional(a.object({}).loose()),prompts:a.optional(a.looseObject({listChanged:a.optional(a.boolean())})),resources:a.optional(a.looseObject({subscribe:a.optional(a.boolean()),listChanged:a.optional(a.boolean())})),tools:a.optional(a.looseObject({listChanged:a.optional(a.boolean())})),elicitation:a.optional(iD)}),a.object({elicitation:a.optional(iD)}).loose(),_Q=qn.extend({protocolVersion:a.string(),capabilities:vQ,serverInfo:yQ,instructions:a.optional(a.string())}),A0=qn.extend({nextCursor:a.optional(a.string())}),bQ=a.object({name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),inputSchema:a.object({type:a.literal("object"),properties:a.optional(a.object({}).loose())}).loose(),outputSchema:a.optional(a.object({}).loose()),annotations:a.optional(a.object({title:a.optional(a.string())}).loose()),_meta:gQ}).loose(),wQ=A0.extend({tools:a.array(bQ)}),oD=a.object({type:a.literal("text"),text:a.string()}).loose(),aD=a.object({type:a.literal("image"),data:a.base64(),mimeType:a.string()}).loose(),xQ=a.object({uri:a.string(),name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),mimeType:a.optional(a.string()),size:a.optional(a.number())}).loose(),SQ=A0.extend({resources:a.array(xQ)}),sD=a.object({uri:a.string(),name:a.optional(a.string()),title:a.optional(a.string()),mimeType:a.optional(a.string())}).loose(),lD=sD.extend({text:a.string()}),cD=sD.extend({blob:a.base64()}),uD=a.object({type:a.literal("resource"),resource:a.union([lD,cD])}).loose(),kQ=qn.extend({content:a.array(a.union([oD,aD,uD])),structuredContent:a.optional(a.unknown()),isError:a.boolean().default(false).optional()}).or(qn.extend({toolResult:a.unknown()})),TQ=a.object({uriTemplate:a.string(),name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),mimeType:a.optional(a.string())}).loose(),IQ=qn.extend({resourceTemplates:a.array(TQ)}),$Q=qn.extend({contents:a.array(a.union([lD,cD]))}),EQ=a.object({name:a.string(),description:a.optional(a.string()),required:a.optional(a.boolean())}).loose(),CQ=a.object({name:a.string(),title:a.optional(a.string()),description:a.optional(a.string()),arguments:a.optional(a.array(EQ))}).loose(),OQ=A0.extend({prompts:a.array(CQ)}),PQ=a.object({role:a.union([a.literal("user"),a.literal("assistant")]),content:a.union([oD,aD,uD])}).loose(),AQ=qn.extend({description:a.optional(a.string()),messages:a.array(PQ)}),NQ=Yf.extend({message:a.string(),requestedSchema:a.unknown()}),Yz=nD.extend({method:a.literal("elicitation/create"),params:NQ}),jQ=qn.extend({action:a.union([a.literal("accept"),a.literal("decline"),a.literal("cancel")]),content:a.optional(a.record(a.string(),a.unknown()))}),Xf="2.0",RQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()])}).merge(nD).strict(),MQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()]),result:qn}).strict(),zQ=a.object({jsonrpc:a.literal(Xf),id:a.union([a.string(),a.number().int()]),error:a.object({code:a.number().int(),message:a.string(),data:a.optional(a.unknown())})}).strict(),DQ=a.object({jsonrpc:a.literal(Xf)}).merge(a.object({method:a.string(),params:a.optional(Yf)})).strict(),Nc=a.union([RQ,DQ,MQ,zQ]),dD=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",pD=a.object({access_token:a.string(),id_token:a.string().optional(),token_type:a.string(),expires_in:a.number().optional(),scope:a.string().optional(),refresh_token:a.string().optional()}).strip(),mr=a.string().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:a.ZodIssueCode.custom,message:"URL must be parseable",fatal:true}),a.NEVER}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),UQ=a.object({resource:a.string().url(),authorization_servers:a.array(mr).optional(),jwks_uri:a.string().url().optional(),scopes_supported:a.array(a.string()).optional(),bearer_methods_supported:a.array(a.string()).optional(),resource_signing_alg_values_supported:a.array(a.string()).optional(),resource_name:a.string().optional(),resource_documentation:a.string().optional(),resource_policy_uri:a.string().url().optional(),resource_tos_uri:a.string().url().optional(),tls_client_certificate_bound_access_tokens:a.boolean().optional(),authorization_details_types_supported:a.array(a.string()).optional(),dpop_signing_alg_values_supported:a.array(a.string()).optional(),dpop_bound_access_tokens_required:a.boolean().optional()}).passthrough(),fD=a.object({issuer:a.string(),authorization_endpoint:mr,token_endpoint:mr,registration_endpoint:mr.optional(),scopes_supported:a.array(a.string()).optional(),response_types_supported:a.array(a.string()),grant_types_supported:a.array(a.string()).optional(),code_challenge_methods_supported:a.array(a.string()),token_endpoint_auth_methods_supported:a.array(a.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.array(a.string()).optional()}).passthrough(),LQ=a.object({issuer:a.string(),authorization_endpoint:mr,token_endpoint:mr,userinfo_endpoint:mr.optional(),jwks_uri:mr,registration_endpoint:mr.optional(),scopes_supported:a.array(a.string()).optional(),response_types_supported:a.array(a.string()),grant_types_supported:a.array(a.string()).optional(),subject_types_supported:a.array(a.string()),id_token_signing_alg_values_supported:a.array(a.string()),claims_supported:a.array(a.string()).optional(),token_endpoint_auth_methods_supported:a.array(a.string()).optional()}).passthrough(),qQ=LQ.merge(fD.pick({code_challenge_methods_supported:true})),FQ=a.object({client_id:a.string(),client_secret:a.string().optional(),client_id_issued_at:a.number().optional(),client_secret_expires_at:a.number().optional()}).strip(),ZQ=a.object({redirect_uris:a.array(mr),token_endpoint_auth_method:a.string().optional(),grant_types:a.array(a.string()).optional(),response_types:a.array(a.string()).optional(),client_name:a.string().optional(),client_uri:mr.optional(),logo_uri:mr.optional(),scope:a.string().optional(),contacts:a.array(a.string()).optional(),tos_uri:mr.optional(),policy_uri:a.string().optional(),jwks_uri:mr.optional(),jwks:a.any().optional(),software_id:a.string().optional(),software_version:a.string().optional(),software_statement:a.string().optional()}).strip(),VQ=a.object({error:a.string(),error_description:a.string().optional(),error_uri:a.string().optional()}),BQ=ZQ.merge(FQ),JQ="AI_MCPClientOAuthError",mD=`vercel.ai.error.${JQ}`,WQ=Symbol.for(mD),jc=class extends(Qz=Le,Xz=WQ,Qz){constructor({name:e="MCPClientOAuthError",message:t,cause:r}){super({name:e,message:t,cause:r}),this[Xz]=true;}static isInstance(e){return Le.hasMarker(e,mD)}},Ha=class extends jc{};Ha.errorCode="server_error";Bf=class extends jc{};Bf.errorCode="invalid_client";Jf=class extends jc{};Jf.errorCode="invalid_grant";Wf=class extends jc{};Wf.errorCode="unauthorized_client";KQ={[Ha.errorCode]:Ha,[Bf.errorCode]:Bf,[Jf.errorCode]:Jf,[Wf.errorCode]:Wf};Kf=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError";}};dee=class{constructor({url:e,headers:t,authProvider:r}){this.connected=false,this.url=new URL(e),this.headers=t,this.authProvider=r;}async commonHeaders(e){let t={...this.headers,...e,"mcp-protocol-version":Ga};if(this.authProvider){let r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`);}return Xi(t,`ai-sdk/${dD}`,Nl())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;let r=async(i=false)=>{var n,o,s,l,c;try{let u=await this.commonHeaders({Accept:"text/event-stream"}),d=await fetch(this.url.href,{headers:u,signal:(n=this.abortController)==null?void 0:n.signal});if(d.status===401&&this.authProvider&&!i){this.resourceMetadataUrl=Hf(d);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let h=new Kf;return (o=this.onerror)==null||o.call(this,h),t(h)}}catch(v){return (s=this.onerror)==null||s.call(this,v),t(v)}return r(!0)}if(!d.ok||!d.body){let v=`MCP SSE Transport Error: ${d.status} ${d.statusText}`;d.status===405&&(v+=". This server does not support SSE transport. Try using `http` transport instead");let h=new Ze({message:v});return (l=this.onerror)==null||l.call(this,h),t(h)}let f=d.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader(),m=async()=>{var v,h,y;try{for(;;){let{done:w,value:S}=await f.read();if(w){if(this.connected)throw this.connected=!1,new Ze({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}let{event:_,data:x}=S;if(_==="endpoint"){if(this.endpoint=new URL(x,this.url),this.endpoint.origin!==this.url.origin)throw new Ze({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e();}else if(_==="message")try{let k=Nc.parse(JSON.parse(x));(v=this.onmessage)==null||v.call(this,k);}catch(k){let g=new Ze({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(h=this.onerror)==null||h.call(this,g);}}}catch(w){if(w instanceof Error&&w.name==="AbortError")return;(y=this.onerror)==null||y.call(this,w),t(w);}};this.sseConnection={close:()=>f.cancel()},m();}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(c=this.onerror)==null||c.call(this,u),t(u);}};r();})}async close(){var e,t,r;this.connected=false,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this);}async send(e){if(!this.endpoint||!this.connected)throw new Ze({message:"MCP SSE Transport Error: Not connected"});let t=this.endpoint,r=async(i=false)=>{var n,o,s,l,c;try{let d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(n=this.abortController)==null?void 0:n.signal},p=await fetch(t,d);if(p.status===401&&this.authProvider&&!i){this.resourceMetadataUrl=Hf(p);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let m=new Kf;(o=this.onerror)==null||o.call(this,m);return}}catch(f){(s=this.onerror)==null||s.call(this,f);return}return r(!0)}if(!p.ok){let f=await p.text().catch(()=>null),m=new Ze({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${p.status}): ${f}`});(l=this.onerror)==null||l.call(this,m);return}}catch(u){(c=this.onerror)==null||c.call(this,u);return}};await r();}},pee=class{constructor({url:e,headers:t,authProvider:r}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=r;}async commonHeaders(e){let t={...this.headers,...e,"mcp-protocol-version":Ga};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){let r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`);}return Xi(t,`ai-sdk/${dD}`,Nl())}async start(){if(this.abortController)throw new Ze({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse();}async close(){var e,t,r;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){let i=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:i,signal:this.abortController.signal}).catch(()=>{});}}catch{}(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this);}async send(e){let t=async(r=false)=>{var i,n,o,s,l,c,u;try{let p={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(i=this.abortController)==null?void 0:i.signal},f=await fetch(this.url,p),m=f.headers.get("mcp-session-id");if(m&&(this.sessionId=m),f.status===401&&this.authProvider&&!r){this.resourceMetadataUrl=Hf(f);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new Kf}catch(w){throw (n=this.onerror)==null||n.call(this,w),w}return t(!0)}if(f.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!f.ok){let w=await f.text().catch(()=>null),S=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${f.status}): ${w}`;f.status===404&&(S+=". This server does not support HTTP transport. Try using `sse` transport instead");let _=new Ze({message:S});throw (o=this.onerror)==null||o.call(this,_),_}if(!("id"in e))return;let h=f.headers.get("content-type")||"";if(h.includes("application/json")){let w=await f.json(),S=Array.isArray(w)?w.map(_=>Nc.parse(_)):[Nc.parse(w)];for(let _ of S)(s=this.onmessage)==null||s.call(this,_);return}if(h.includes("text/event-stream")){if(!f.body){let x=new Ze({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw (l=this.onerror)==null||l.call(this,x),x}let S=f.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader();(async()=>{var x,k,g;try{for(;;){let{done:$,value:C}=await S.read();if($)return;let{event:A,data:D}=C;if(A==="message")try{let oe=Nc.parse(JSON.parse(D));(x=this.onmessage)==null||x.call(this,oe);}catch(oe){let z=new Ze({message:"MCP HTTP Transport Error: Failed to parse message",cause:oe});(k=this.onerror)==null||k.call(this,z);}}}catch($){if($ instanceof Error&&$.name==="AbortError")return;(g=this.onerror)==null||g.call(this,$);}})();return}let y=new Ze({message:`MCP HTTP Transport Error: Unexpected content type: ${h}`});throw (c=this.onerror)==null||c.call(this,y),y}catch(d){throw (u=this.onerror)==null||u.call(this,d),d}};await t();}getNextReconnectionDelay(e){let{initialReconnectionDelay:t,reconnectionDelayGrowFactor:r,maxReconnectionDelay:i}=this.reconnectionOptions;return Math.min(t*Math.pow(r,e),i)}scheduleInboundSseReconnection(){var e;let{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new Ze({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}let r=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var i;(i=this.abortController)!=null&&i.signal.aborted||await this.openInboundSse(false,this.lastInboundEventId);},r);}async openInboundSse(e=false,t){var r,i,n,o,s,l;try{let c=await this.commonHeaders({Accept:"text/event-stream"});t&&(c["last-event-id"]=t);let u=await fetch(this.url.href,{method:"GET",headers:c,signal:(r=this.abortController)==null?void 0:r.signal}),d=u.headers.get("mcp-session-id");if(d&&(this.sessionId=d),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=Hf(u);try{if(await Gf(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){let h=new Kf;(i=this.onerror)==null||i.call(this,h);return}}catch(v){(n=this.onerror)==null||n.call(this,v);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){let v=new Ze({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(o=this.onerror)==null||o.call(this,v);return}let f=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Cr).getReader(),m=async()=>{var v,h,y,w;try{for(;;){let{done:S,value:_}=await f.read();if(S)return;let{event:x,data:k,id:g}=_;if(g&&(this.lastInboundEventId=g),x==="message")try{let $=Nc.parse(JSON.parse(k));(v=this.onmessage)==null||v.call(this,$);}catch($){let C=new Ze({message:"MCP HTTP Transport Error: Failed to parse message",cause:$});(h=this.onerror)==null||h.call(this,C);}}}catch(S){if(S instanceof Error&&S.name==="AbortError")return;(y=this.onerror)==null||y.call(this,S),(w=this.abortController)!=null&&w.signal.aborted||this.scheduleInboundSseReconnection();}};this.inboundSseConnection={close:()=>f.cancel()},this.inboundReconnectAttempts=0,m();}catch(c){if(c instanceof Error&&c.name==="AbortError")return;(s=this.onerror)==null||s.call(this,c),(l=this.abortController)!=null&&l.signal.aborted||this.scheduleInboundSseReconnection();}}};hee="1.0.0";gee=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:r=hee,onUncaughtError:i,capabilities:n}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=true,this.onUncaughtError=i,this.clientCapabilities=n??{},mee(e)?this.transport=e:this.transport=fee(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=o=>this.onError(o),this.transport.onmessage=o=>{if("method"in o){"id"in o?this.onRequestMessage(o):this.onError(new Ze({message:"Unsupported message type"}));return}this.onResponse(o);},this.clientInfo={name:t,version:r};}async init(){try{await this.transport.start(),this.isClosed=!1;let e=await this.request({request:{method:"initialize",params:{protocolVersion:Ga,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:_Q});if(e===void 0)throw new Ze({message:"Server sent invalid initialize result"});if(!hQ.includes(e.protocolVersion))throw new Ze({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose());}assertCapability(e){switch(e){case "initialize":break;case "tools/list":case "tools/call":if(!this.serverCapabilities.tools)throw new Ze({message:"Server does not support tools"});break;case "resources/list":case "resources/read":case "resources/templates/list":if(!this.serverCapabilities.resources)throw new Ze({message:"Server does not support resources"});break;case "prompts/list":case "prompts/get":if(!this.serverCapabilities.prompts)throw new Ze({message:"Server does not support prompts"});break;default:throw new Ze({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:r}){return new Promise((i,n)=>{if(this.isClosed)return n(new Ze({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);let o=r?.signal;o?.throwIfAborted();let s=this.requestMessageId++,l={...e,jsonrpc:"2.0",id:s},c=()=>{this.responseHandlers.delete(s);};this.responseHandlers.set(s,u=>{if(o?.aborted)return n(new Ze({message:"Request was aborted",cause:o.reason}));if(u instanceof Error)return n(u);try{let d=t.parse(u.result);i(d);}catch(d){let p=new Ze({message:"Failed to parse server response",cause:d});n(p);}}),this.transport.send(l).catch(u=>{c(),n(u);});})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:wQ,options:t})}catch(r){throw r}}async callTool({name:e,args:t,options:r}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:kQ,options:{signal:r?.abortSignal}})}catch(i){throw i}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:SQ,options:t})}catch(r){throw r}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:$Q,options:t})}catch(r){throw r}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:IQ,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:OQ,options:t})}catch(r){throw r}}async getPromptInternal({name:e,args:t,options:r}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:AQ,options:r})}catch(i){throw i}}async notification(e){let t={...e,jsonrpc:"2.0"};await this.transport.send(t);}async tools({schemas:e="automatic"}={}){var t,r;let i={};try{let n=await this.listTools();for(let{name:o,title:s,description:l,inputSchema:c,annotations:u,_meta:d}of n.tools){let p=s??u?.title;if(e!=="automatic"&&!(o in e))continue;let f=this,m=e!=="automatic"?(t=e[o])==null?void 0:t.outputSchema:void 0,v=async(y,w)=>{var S;(S=w?.abortSignal)==null||S.throwIfAborted();let _=await f.callTool({name:o,args:y,options:w});return m!=null?f.extractStructuredContent(_,m,o):_},h=e==="automatic"?dj({description:l,title:p,inputSchema:Ta({...c,properties:(r=c.properties)!=null?r:{},additionalProperties:!1}),execute:v,toModelOutput:tD}):{description:l,title:p,inputSchema:e[o].inputSchema,...m!=null?{outputSchema:m}:{},execute:v,toModelOutput:tD};i[o]={...h,_meta:d};}return i}catch(n){throw n}}async extractStructuredContent(e,t,r){if("structuredContent"in e&&e.structuredContent!=null){let i=await jl({value:e.structuredContent,schema:aw(t)});if(!i.success)throw new Ze({message:`Tool "${r}" returned structuredContent that does not match the expected outputSchema`,cause:i.error});return i.value}if("content"in e&&Array.isArray(e.content)){let i=e.content.find(n=>n.type==="text");if(i&&"text"in i){let n=await wp({text:i.text,schema:t});if(!n.success)throw new Ze({message:`Tool "${r}" returned content that does not match the expected outputSchema`,cause:n.error});return n.value}}throw new Ze({message:`Tool "${r}" did not return structuredContent or parseable text content`})}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}experimental_listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}experimental_getPrompt({name:e,arguments:t,options:r}){return this.getPromptInternal({name:e,args:t,options:r})}onElicitationRequest(e,t){if(e!==Yz)throw new Ze({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t;}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}let t=Yz.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{let r=await this.elicitationRequestHandler(t.data),i=jQ.parse(r);await this.transport.send({jsonrpc:"2.0",id:e.id,result:i});}catch(r){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Failed to handle elicitation request"}}),this.onError(r);}}catch(t){this.onError(t);}}onClose(){if(this.isClosed)return;this.isClosed=true;let e=new Ze({message:"Connection closed"});for(let t of this.responseHandlers.values())t(e);this.responseHandlers.clear();}onError(e){this.onUncaughtError&&this.onUncaughtError(e);}onResponse(e){let t=Number(e.id),r=this.responseHandlers.get(t);if(r===void 0)throw new Ze({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),r("result"in e?e:new Ze({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}));}};});async function vee(e){let t=ss__namespace.join(e,".pulse-coder","mcp.json"),r=ss__namespace.join(e,".coder","mcp.json"),i=Dj.existsSync(t)?t:r;if(!Dj.existsSync(i))return {servers:{}};try{let n=Dj.readFileSync(i,"utf-8"),o=JSON.parse(n);return !o.servers||typeof o.servers!="object"?(console.warn('[MCP] Invalid config: missing "servers" object'),{servers:{}}):{servers:o.servers}}catch(n){return console.warn(`[MCP] Failed to load config: ${n instanceof Error?n.message:"Unknown error"}`),{servers:{}}}}function _ee(e){return {type:"http",url:e.url}}var Qf,M0=T(()=>{vD();Qf={name:"pulse-coder-engine/built-in-mcp",version:"1.0.0",async initialize(e){let t=await vee(process.cwd()),r=Object.keys(t.servers).length;if(r===0){console.log("[MCP] No MCP servers configured");return}let i=0;for(let[n,o]of Object.entries(t.servers))try{if(!o.url){console.warn(`[MCP] Server "${n}" missing URL, skipping`);continue}let s=_ee(o),l=await yD({transport:s}),c=await l.tools(),u=Object.fromEntries(Object.entries(c).map(([d,p])=>[`mcp_${n}_${d}`,p]));e.registerTools(u),i++,console.log(`[MCP] Server "${n}" loaded (${Object.keys(c).length} tools)`),e.registerService(`mcp:${n}`,l);}catch(s){console.warn(`[MCP] Failed to load server "${n}": ${s instanceof Error?s.message:"Unknown error"}`);}i>0?console.log(`[MCP] Successfully loaded ${i}/${r} MCP servers`):console.warn("[MCP] No MCP servers were loaded successfully");}};});var Rc=M((A_e,wD)=>{var bee=Object.prototype.toString;wD.exports=function(t){if(t===void 0)return "undefined";if(t===null)return "null";var r=typeof t;if(r==="boolean")return "boolean";if(r==="string")return "string";if(r==="number")return "number";if(r==="symbol")return "symbol";if(r==="function")return Tee(t)?"generatorfunction":"function";if(wee(t))return "array";if(Eee(t))return "buffer";if($ee(t))return "arguments";if(See(t))return "date";if(xee(t))return "error";if(kee(t))return "regexp";switch(bD(t)){case "Symbol":return "symbol";case "Promise":return "promise";case "WeakMap":return "weakmap";case "WeakSet":return "weakset";case "Map":return "map";case "Set":return "set";case "Int8Array":return "int8array";case "Uint8Array":return "uint8array";case "Uint8ClampedArray":return "uint8clampedarray";case "Int16Array":return "int16array";case "Uint16Array":return "uint16array";case "Int32Array":return "int32array";case "Uint32Array":return "uint32array";case "Float32Array":return "float32array";case "Float64Array":return "float64array"}if(Iee(t))return "generator";switch(r=bee.call(t),r){case "[object Object]":return "object";case "[object Map Iterator]":return "mapiterator";case "[object Set Iterator]":return "setiterator";case "[object String Iterator]":return "stringiterator";case "[object Array Iterator]":return "arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function bD(e){return typeof e.constructor=="function"?e.constructor.name:null}function wee(e){return Array.isArray?Array.isArray(e):e instanceof Array}function xee(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function See(e){return e instanceof Date?true:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function kee(e){return e instanceof RegExp?true:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function Tee(e,t){return bD(e)==="GeneratorFunction"}function Iee(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function $ee(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return !0}catch(t){if(t.message.indexOf("callee")!==-1)return true}return false}function Eee(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):false}});var SD=M((N_e,xD)=>{xD.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t=="object"||typeof t=="function")};});var ID=M((j_e,TD)=>{var kD=SD();TD.exports=function(t){kD(t)||(t={});for(var r=arguments.length,i=1;i<r;i++){var n=arguments[i];kD(n)&&Cee(t,n);}return t};function Cee(e,t){for(var r in t)Oee(t,r)&&(e[r]=t[r]);}function Oee(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var CD=M((R_e,ED)=>{var Pee=Rc(),Aee=ID();ED.exports=function(e,t){typeof t=="function"&&(t={parse:t});var r=jee(e),i={section_delimiter:"---",parse:Mee},n=Aee({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),l=null,c=$D(),u=[],d=[];function p(w){r.content=w,l=[],u=[];}function f(w){d.length&&(c.key=Ree(d[0],o),c.content=w,n.parse(c,l),l.push(c),c=$D(),u=[],d=[]);}for(var m=0;m<s.length;m++){var v=s[m],h=d.length,y=v.trim();if(Nee(y,o)){if(y.length===3&&m!==0){if(h===0||h===2){u.push(v);continue}d.push(y),c.data=u.join(`
|
|
371
382
|
`),u=[];continue}l===null&&p(u.join(`
|
|
372
383
|
`)),h===2&&f(u.join(`
|
|
373
384
|
`)),d.push(y);continue}u.push(v);}return l===null?p(u.join(`
|
|
374
385
|
`)):f(u.join(`
|
|
375
|
-
`)),r.sections=l,r};function Nee(e,t){return !(e.slice(0,t.length)!==t||e.charAt(t.length+1)===t.slice(-1))}function jee(e){if(Pee(e)!=="object"&&(e={content:e}),typeof e.content!="string"&&!zee(e.content))throw new TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function Ree(e,t){return e?e.slice(t.length).trim():""}function $
|
|
386
|
+
`)),r.sections=l,r};function Nee(e,t){return !(e.slice(0,t.length)!==t||e.charAt(t.length+1)===t.slice(-1))}function jee(e){if(Pee(e)!=="object"&&(e={content:e}),typeof e.content!="string"&&!zee(e.content))throw new TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function Ree(e,t){return e?e.slice(t.length).trim():""}function $D(){return {key:"",data:"",content:""}}function Mee(e){return e}function zee(e){return e&&e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):false}});var uo=M((M_e,co)=>{function OD(e){return typeof e>"u"||e===null}function Dee(e){return typeof e=="object"&&e!==null}function Uee(e){return Array.isArray(e)?e:OD(e)?[]:[e]}function Lee(e,t){var r,i,n,o;if(t)for(o=Object.keys(t),r=0,i=o.length;r<i;r+=1)n=o[r],e[n]=t[n];return e}function qee(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function Fee(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}co.exports.isNothing=OD;co.exports.isObject=Dee;co.exports.toArray=Uee;co.exports.repeat=qee;co.exports.isNegativeZero=Fee;co.exports.extend=Lee;});var Ya=M((z_e,PD)=>{function Mc(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||"";}Mc.prototype=Object.create(Error.prototype);Mc.prototype.constructor=Mc;Mc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};PD.exports=Mc;});var jD=M((D_e,ND)=>{var AD=uo();function z0(e,t,r,i,n){this.name=e,this.buffer=t,this.position=r,this.line=i,this.column=n;}z0.prototype.getSnippet=function(t,r){var i,n,o,s,l;if(!this.buffer)return null;for(t=t||4,r=r||75,i="",n=this.position;n>0&&`\0\r
|
|
376
387
|
\x85\u2028\u2029`.indexOf(this.buffer.charAt(n-1))===-1;)if(n-=1,this.position-n>r/2-1){i=" ... ",n+=5;break}for(o="",s=this.position;s<this.buffer.length&&`\0\r
|
|
377
|
-
\x85\u2028\u2029`.indexOf(this.buffer.charAt(s))===-1;)if(s+=1,s-this.position>r/2-1){o=" ... ",s-=5;break}return l=this.buffer.slice(n,s),
|
|
378
|
-
`+
|
|
379
|
-
`+r)),i};
|
|
380
|
-
\r`;function Pte(e){if(e===null)return false;var t,r,i=0,n=e.length,o=q0;for(r=0;r<n;r++)if(t=o.indexOf(e.charAt(r)),!(t>64)){if(t<0)return false;i+=6;}return i%8===0}function Ate(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=q0,s=0,l=[];for(t=0;t<n;t++)t%4===0&&t&&(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)),s=s<<6|o.indexOf(i.charAt(t));return r=n%4*6,r===0?(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)):r===18?(l.push(s>>10&255),l.push(s>>2&255)):r===12&&l.push(s>>4&255),fo?fo.from?fo.from(l):new fo(l):l}function Nte(e){var t="",r=0,i,n,o=e.length,s=q0;for(i=0;i<o;i++)i%3===0&&i&&(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]),r=(r<<8)+e[i];return n=o%3,n===0?(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]):n===2?(t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64]):n===1&&(t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64]),t}function jte(e){return fo&&fo.isBuffer(e)}
|
|
381
|
-
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function _re(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function
|
|
382
|
-
`,t-1));}function wre(e,t,r){var i,n,o,s,l,c,u,d,p=e.kind,f=e.result,m;if(m=e.input.charCodeAt(e.position),hr(m)||es(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(n=e.input.charCodeAt(e.position+1),hr(n)||r&&es(n)))return false;for(e.kind="scalar",e.result="",o=s=e.position,l=false;m!==0;){if(m===58){if(n=e.input.charCodeAt(e.position+1),hr(n)||r&&es(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),hr(i))break}else {if(e.position===e.lineStart&&am(e)||r&&es(m))break;if(vn(m))if(c=e.line,u=e.lineStart,d=e.lineIndent,vt(e,false,-1),e.lineIndent>=t){l=true,m=e.input.charCodeAt(e.position);continue}else {e.position=s,e.line=c,e.lineStart=u,e.lineIndent=d;break}}l&&($i(e,o,s,false),V0(e,e.line-c),o=s=e.position,l=false),ho(m)||(s=e.position+1),m=e.input.charCodeAt(++e.position);}return $i(e,o,s,false),e.result?true:(e.kind=p,e.result=f,false)}function xre(e,t){var r,i,n;if(r=e.input.charCodeAt(e.position),r!==39)return false;for(e.kind="scalar",e.result="",e.position++,i=n=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if($i(e,i,e.position,true),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,n=e.position;else return true;else vn(r)?($i(e,i,n,true),V0(e,vt(e,false,t)),i=n=e.position):e.position===e.lineStart&&am(e)?we(e,"unexpected end of the document within a single quoted scalar"):(e.position++,n=e.position);we(e,"unexpected end of the stream within a single quoted scalar");}function Sre(e,t){var r,i,n,o,s,l;if(l=e.input.charCodeAt(e.position),l!==34)return false;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return $i(e,r,e.position,true),e.position++,true;if(l===92){if($i(e,r,e.position,true),l=e.input.charCodeAt(++e.position),vn(l))vt(e,false,t);else if(l<256&&
|
|
388
|
+
\x85\u2028\u2029`.indexOf(this.buffer.charAt(s))===-1;)if(s+=1,s-this.position>r/2-1){o=" ... ",s-=5;break}return l=this.buffer.slice(n,s),AD.repeat(" ",t)+i+l+o+`
|
|
389
|
+
`+AD.repeat(" ",t+this.position-n+i.length)+"^"};z0.prototype.toString=function(t){var r,i="";return this.name&&(i+='in "'+this.name+'" '),i+="at line "+(this.line+1)+", column "+(this.column+1),t||(r=this.getSnippet(),r&&(i+=`:
|
|
390
|
+
`+r)),i};ND.exports=z0;});var kt=M((U_e,MD)=>{var RD=Ya(),Zee=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],Vee=["scalar","sequence","mapping"];function Bee(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r;});}),t}function Jee(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(Zee.indexOf(r)===-1)throw new RD('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return true},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=Bee(t.styleAliases||null),Vee.indexOf(this.kind)===-1)throw new RD('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}MD.exports=Jee;});var po=M((L_e,DD)=>{var zD=uo(),em=Ya(),Wee=kt();function D0(e,t,r){var i=[];return e.include.forEach(function(n){r=D0(n,t,r);}),e[t].forEach(function(n){r.forEach(function(o,s){o.tag===n.tag&&o.kind===n.kind&&i.push(s);}),r.push(n);}),r.filter(function(n,o){return i.indexOf(o)===-1})}function Kee(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function i(n){e[n.kind][n.tag]=e.fallback[n.tag]=n;}for(t=0,r=arguments.length;t<r;t+=1)arguments[t].forEach(i);return e}function Xa(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(t){if(t.loadKind&&t.loadKind!=="scalar")throw new em("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=D0(this,"implicit",[]),this.compiledExplicit=D0(this,"explicit",[]),this.compiledTypeMap=Kee(this.compiledImplicit,this.compiledExplicit);}Xa.DEFAULT=null;Xa.create=function(){var t,r;switch(arguments.length){case 1:t=Xa.DEFAULT,r=arguments[0];break;case 2:t=arguments[0],r=arguments[1];break;default:throw new em("Wrong number of arguments for Schema.create function")}if(t=zD.toArray(t),r=zD.toArray(r),!t.every(function(i){return i instanceof Xa}))throw new em("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(i){return i instanceof Wee}))throw new em("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new Xa({include:t,explicit:r})};DD.exports=Xa;});var LD=M((q_e,UD)=>{var Hee=kt();UD.exports=new Hee("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}});});var FD=M((F_e,qD)=>{var Gee=kt();qD.exports=new Gee("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}});});var VD=M((Z_e,ZD)=>{var Yee=kt();ZD.exports=new Yee("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}});});var tm=M((V_e,BD)=>{var Xee=po();BD.exports=new Xee({explicit:[LD(),FD(),VD()]});});var WD=M((B_e,JD)=>{var Qee=kt();function ete(e){if(e===null)return true;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function tte(){return null}function rte(e){return e===null}JD.exports=new Qee("tag:yaml.org,2002:null",{kind:"scalar",resolve:ete,construct:tte,predicate:rte,represent:{canonical:function(){return "~"},lowercase:function(){return "null"},uppercase:function(){return "NULL"},camelcase:function(){return "Null"}},defaultStyle:"lowercase"});});var HD=M((J_e,KD)=>{var nte=kt();function ite(e){if(e===null)return false;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function ote(e){return e==="true"||e==="True"||e==="TRUE"}function ate(e){return Object.prototype.toString.call(e)==="[object Boolean]"}KD.exports=new nte("tag:yaml.org,2002:bool",{kind:"scalar",resolve:ite,construct:ote,predicate:ate,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});});var YD=M((W_e,GD)=>{var ste=uo(),lte=kt();function cte(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function ute(e){return 48<=e&&e<=55}function dte(e){return 48<=e&&e<=57}function pte(e){if(e===null)return false;var t=e.length,r=0,i=false,n;if(!t)return false;if(n=e[r],(n==="-"||n==="+")&&(n=e[++r]),n==="0"){if(r+1===t)return true;if(n=e[++r],n==="b"){for(r++;r<t;r++)if(n=e[r],n!=="_"){if(n!=="0"&&n!=="1")return false;i=true;}return i&&n!=="_"}if(n==="x"){for(r++;r<t;r++)if(n=e[r],n!=="_"){if(!cte(e.charCodeAt(r)))return false;i=true;}return i&&n!=="_"}for(;r<t;r++)if(n=e[r],n!=="_"){if(!ute(e.charCodeAt(r)))return false;i=true;}return i&&n!=="_"}if(n==="_")return false;for(;r<t;r++)if(n=e[r],n!=="_"){if(n===":")break;if(!dte(e.charCodeAt(r)))return false;i=true;}return !i||n==="_"?false:n!==":"?true:/^(:[0-5]?[0-9])+$/.test(e.slice(r))}function fte(e){var t=e,r=1,i,n,o=[];return t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),i=t[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),t=t.slice(1),i=t[0]),t==="0"?0:i==="0"?t[1]==="b"?r*parseInt(t.slice(2),2):t[1]==="x"?r*parseInt(t,16):r*parseInt(t,8):t.indexOf(":")!==-1?(t.split(":").forEach(function(s){o.unshift(parseInt(s,10));}),t=0,n=1,o.forEach(function(s){t+=s*n,n*=60;}),r*t):r*parseInt(t,10)}function mte(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!ste.isNegativeZero(e)}GD.exports=new lte("tag:yaml.org,2002:int",{kind:"scalar",resolve:pte,construct:fte,predicate:mte,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}});});var e2=M((K_e,QD)=>{var XD=uo(),hte=kt(),gte=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function yte(e){return !(e===null||!gte.test(e)||e[e.length-1]==="_")}function vte(e){var t,r,i,n;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,n=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(o){n.unshift(parseFloat(o,10));}),t=0,i=1,n.forEach(function(o){t+=o*i,i*=60;}),r*t):r*parseFloat(t,10)}var _te=/^[-+]?[0-9]+e/;function bte(e,t){var r;if(isNaN(e))switch(t){case "lowercase":return ".nan";case "uppercase":return ".NAN";case "camelcase":return ".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case "lowercase":return ".inf";case "uppercase":return ".INF";case "camelcase":return ".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case "lowercase":return "-.inf";case "uppercase":return "-.INF";case "camelcase":return "-.Inf"}else if(XD.isNegativeZero(e))return "-0.0";return r=e.toString(10),_te.test(r)?r.replace("e",".e"):r}function wte(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||XD.isNegativeZero(e))}QD.exports=new hte("tag:yaml.org,2002:float",{kind:"scalar",resolve:yte,construct:vte,predicate:wte,represent:bte,defaultStyle:"lowercase"});});var U0=M((H_e,t2)=>{var xte=po();t2.exports=new xte({include:[tm()],implicit:[WD(),HD(),YD(),e2()]});});var L0=M((G_e,r2)=>{var Ste=po();r2.exports=new Ste({include:[U0()]});});var a2=M((Y_e,o2)=>{var kte=kt(),n2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),i2=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Tte(e){return e===null?false:n2.exec(e)!==null||i2.exec(e)!==null}function Ite(e){var t,r,i,n,o,s,l,c=0,u=null,d,p,f;if(t=n2.exec(e),t===null&&(t=i2.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],i=+t[2]-1,n=+t[3],!t[4])return new Date(Date.UTC(r,i,n));if(o=+t[4],s=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c;}return t[9]&&(d=+t[10],p=+(t[11]||0),u=(d*60+p)*6e4,t[9]==="-"&&(u=-u)),f=new Date(Date.UTC(r,i,n,o,s,l,c)),u&&f.setTime(f.getTime()-u),f}function $te(e){return e.toISOString()}o2.exports=new kte("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Tte,construct:Ite,instanceOf:Date,represent:$te});});var l2=M((X_e,s2)=>{var Ete=kt();function Cte(e){return e==="<<"||e===null}s2.exports=new Ete("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Cte});});var d2=M((Q_e,u2)=>{var fo;try{c2=dt,fo=c2("buffer").Buffer;}catch{}var c2,Ote=kt(),q0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
391
|
+
\r`;function Pte(e){if(e===null)return false;var t,r,i=0,n=e.length,o=q0;for(r=0;r<n;r++)if(t=o.indexOf(e.charAt(r)),!(t>64)){if(t<0)return false;i+=6;}return i%8===0}function Ate(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=q0,s=0,l=[];for(t=0;t<n;t++)t%4===0&&t&&(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)),s=s<<6|o.indexOf(i.charAt(t));return r=n%4*6,r===0?(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)):r===18?(l.push(s>>10&255),l.push(s>>2&255)):r===12&&l.push(s>>4&255),fo?fo.from?fo.from(l):new fo(l):l}function Nte(e){var t="",r=0,i,n,o=e.length,s=q0;for(i=0;i<o;i++)i%3===0&&i&&(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]),r=(r<<8)+e[i];return n=o%3,n===0?(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]):n===2?(t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64]):n===1&&(t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64]),t}function jte(e){return fo&&fo.isBuffer(e)}u2.exports=new Ote("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Pte,construct:Ate,predicate:jte,represent:Nte});});var f2=M((tbe,p2)=>{var Rte=kt(),Mte=Object.prototype.hasOwnProperty,zte=Object.prototype.toString;function Dte(e){if(e===null)return true;var t=[],r,i,n,o,s,l=e;for(r=0,i=l.length;r<i;r+=1){if(n=l[r],s=false,zte.call(n)!=="[object Object]")return false;for(o in n)if(Mte.call(n,o))if(!s)s=true;else return false;if(!s)return false;if(t.indexOf(o)===-1)t.push(o);else return false}return true}function Ute(e){return e!==null?e:[]}p2.exports=new Rte("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Dte,construct:Ute});});var h2=M((rbe,m2)=>{var Lte=kt(),qte=Object.prototype.toString;function Fte(e){if(e===null)return true;var t,r,i,n,o,s=e;for(o=new Array(s.length),t=0,r=s.length;t<r;t+=1){if(i=s[t],qte.call(i)!=="[object Object]"||(n=Object.keys(i),n.length!==1))return false;o[t]=[n[0],i[n[0]]];}return true}function Zte(e){if(e===null)return [];var t,r,i,n,o,s=e;for(o=new Array(s.length),t=0,r=s.length;t<r;t+=1)i=s[t],n=Object.keys(i),o[t]=[n[0],i[n[0]]];return o}m2.exports=new Lte("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Fte,construct:Zte});});var y2=M((nbe,g2)=>{var Vte=kt(),Bte=Object.prototype.hasOwnProperty;function Jte(e){if(e===null)return true;var t,r=e;for(t in r)if(Bte.call(r,t)&&r[t]!==null)return false;return true}function Wte(e){return e!==null?e:{}}g2.exports=new Vte("tag:yaml.org,2002:set",{kind:"mapping",resolve:Jte,construct:Wte});});var Qa=M((ibe,v2)=>{var Kte=po();v2.exports=new Kte({include:[L0()],implicit:[a2(),l2()],explicit:[d2(),f2(),h2(),y2()]});});var b2=M((obe,_2)=>{var Hte=kt();function Gte(){return true}function Yte(){}function Xte(){return ""}function Qte(e){return typeof e>"u"}_2.exports=new Hte("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:Gte,construct:Yte,predicate:Qte,represent:Xte});});var x2=M((abe,w2)=>{var ere=kt();function tre(e){if(e===null||e.length===0)return false;var t=e,r=/\/([gim]*)$/.exec(e),i="";return !(t[0]==="/"&&(r&&(i=r[1]),i.length>3||t[t.length-i.length-1]!=="/"))}function rre(e){var t=e,r=/\/([gim]*)$/.exec(e),i="";return t[0]==="/"&&(r&&(i=r[1]),t=t.slice(1,t.length-i.length-1)),new RegExp(t,i)}function nre(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function ire(e){return Object.prototype.toString.call(e)==="[object RegExp]"}w2.exports=new ere("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:tre,construct:rre,predicate:ire,represent:nre});});var T2=M((sbe,k2)=>{var rm;try{S2=dt,rm=S2("esprima");}catch{typeof window<"u"&&(rm=window.esprima);}var S2,ore=kt();function are(e){if(e===null)return false;try{var t="("+e+")",r=rm.parse(t,{range:!0});return !(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")}catch{return false}}function sre(e){var t="("+e+")",r=rm.parse(t,{range:true}),i=[],n;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return r.body[0].expression.params.forEach(function(o){i.push(o.name);}),n=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement"?new Function(i,t.slice(n[0]+1,n[1]-1)):new Function(i,"return "+t.slice(n[0],n[1]))}function lre(e){return e.toString()}function cre(e){return Object.prototype.toString.call(e)==="[object Function]"}k2.exports=new ore("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:are,construct:sre,predicate:cre,represent:lre});});var zc=M((cbe,$2)=>{var I2=po();$2.exports=I2.DEFAULT=new I2({include:[Qa()],explicit:[b2(),x2(),T2()]});});var W2=M((ube,Dc)=>{var Fn=uo(),j2=Ya(),ure=jD(),R2=Qa(),dre=zc(),Ei=Object.prototype.hasOwnProperty,nm=1,M2=2,z2=3,im=4,F0=1,pre=2,E2=3,fre=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,mre=/[\x85\u2028\u2029]/,hre=/[,\[\]\{\}]/,D2=/^(?:!|!!|![a-z\-]+!)$/i,U2=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function C2(e){return Object.prototype.toString.call(e)}function vn(e){return e===10||e===13}function ho(e){return e===9||e===32}function hr(e){return e===9||e===32||e===10||e===13}function es(e){return e===44||e===91||e===93||e===123||e===125}function gre(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function yre(e){return e===120?2:e===117?4:e===85?8:0}function vre(e){return 48<=e&&e<=57?e-48:-1}function O2(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
392
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function _re(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function L2(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{configurable:true,enumerable:true,writable:true,value:r}):e[t]=r;}var q2=new Array(256),F2=new Array(256);for(mo=0;mo<256;mo++)q2[mo]=O2(mo)?1:0,F2[mo]=O2(mo);var mo;function bre(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||dre,this.onWarning=t.onWarning||null,this.legacy=t.legacy||false,this.json=t.json||false,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[];}function Z2(e,t){return new j2(t,new ure(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function we(e,t){throw Z2(e,t)}function om(e,t){e.onWarning&&e.onWarning.call(null,Z2(e,t));}var P2={YAML:function(t,r,i){var n,o,s;t.version!==null&&we(t,"duplication of %YAML directive"),i.length!==1&&we(t,"YAML directive accepts exactly one argument"),n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),n===null&&we(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),s=parseInt(n[2],10),o!==1&&we(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&om(t,"unsupported YAML version of the document");},TAG:function(t,r,i){var n,o;i.length!==2&&we(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],D2.test(n)||we(t,"ill-formed tag handle (first argument) of the TAG directive"),Ei.call(t.tagMap,n)&&we(t,'there is a previously declared suffix for "'+n+'" tag handle'),U2.test(o)||we(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[n]=o;}};function $i(e,t,r,i){var n,o,s,l;if(t<r){if(l=e.input.slice(t,r),i)for(n=0,o=l.length;n<o;n+=1)s=l.charCodeAt(n),s===9||32<=s&&s<=1114111||we(e,"expected valid JSON character");else fre.test(l)&&we(e,"the stream contains non-printable characters");e.result+=l;}}function A2(e,t,r,i){var n,o,s,l;for(Fn.isObject(r)||we(e,"cannot merge mappings; the provided source object is unacceptable"),n=Object.keys(r),s=0,l=n.length;s<l;s+=1)o=n[s],Ei.call(t,o)||(L2(t,o,r[o]),i[o]=true);}function ts(e,t,r,i,n,o,s,l){var c,u;if(Array.isArray(n))for(n=Array.prototype.slice.call(n),c=0,u=n.length;c<u;c+=1)Array.isArray(n[c])&&we(e,"nested arrays are not supported inside keys"),typeof n=="object"&&C2(n[c])==="[object Object]"&&(n[c]="[object Object]");if(typeof n=="object"&&C2(n)==="[object Object]"&&(n="[object Object]"),n=String(n),t===null&&(t={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(c=0,u=o.length;c<u;c+=1)A2(e,t,o[c],r);else A2(e,t,o,r);else !e.json&&!Ei.call(r,n)&&Ei.call(t,n)&&(e.line=s||e.line,e.position=l||e.position,we(e,"duplicated mapping key")),L2(t,n,o),delete r[n];return t}function Z0(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):we(e,"a line break is expected"),e.line+=1,e.lineStart=e.position;}function vt(e,t,r){for(var i=0,n=e.input.charCodeAt(e.position);n!==0;){for(;ho(n);)n=e.input.charCodeAt(++e.position);if(t&&n===35)do n=e.input.charCodeAt(++e.position);while(n!==10&&n!==13&&n!==0);if(vn(n))for(Z0(e),n=e.input.charCodeAt(e.position),i++,e.lineIndent=0;n===32;)e.lineIndent++,n=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&om(e,"deficient indentation"),i}function am(e){var t=e.position,r;return r=e.input.charCodeAt(t),!!((r===45||r===46)&&r===e.input.charCodeAt(t+1)&&r===e.input.charCodeAt(t+2)&&(t+=3,r=e.input.charCodeAt(t),r===0||hr(r)))}function V0(e,t){t===1?e.result+=" ":t>1&&(e.result+=Fn.repeat(`
|
|
393
|
+
`,t-1));}function wre(e,t,r){var i,n,o,s,l,c,u,d,p=e.kind,f=e.result,m;if(m=e.input.charCodeAt(e.position),hr(m)||es(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(n=e.input.charCodeAt(e.position+1),hr(n)||r&&es(n)))return false;for(e.kind="scalar",e.result="",o=s=e.position,l=false;m!==0;){if(m===58){if(n=e.input.charCodeAt(e.position+1),hr(n)||r&&es(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),hr(i))break}else {if(e.position===e.lineStart&&am(e)||r&&es(m))break;if(vn(m))if(c=e.line,u=e.lineStart,d=e.lineIndent,vt(e,false,-1),e.lineIndent>=t){l=true,m=e.input.charCodeAt(e.position);continue}else {e.position=s,e.line=c,e.lineStart=u,e.lineIndent=d;break}}l&&($i(e,o,s,false),V0(e,e.line-c),o=s=e.position,l=false),ho(m)||(s=e.position+1),m=e.input.charCodeAt(++e.position);}return $i(e,o,s,false),e.result?true:(e.kind=p,e.result=f,false)}function xre(e,t){var r,i,n;if(r=e.input.charCodeAt(e.position),r!==39)return false;for(e.kind="scalar",e.result="",e.position++,i=n=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if($i(e,i,e.position,true),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,n=e.position;else return true;else vn(r)?($i(e,i,n,true),V0(e,vt(e,false,t)),i=n=e.position):e.position===e.lineStart&&am(e)?we(e,"unexpected end of the document within a single quoted scalar"):(e.position++,n=e.position);we(e,"unexpected end of the stream within a single quoted scalar");}function Sre(e,t){var r,i,n,o,s,l;if(l=e.input.charCodeAt(e.position),l!==34)return false;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return $i(e,r,e.position,true),e.position++,true;if(l===92){if($i(e,r,e.position,true),l=e.input.charCodeAt(++e.position),vn(l))vt(e,false,t);else if(l<256&&q2[l])e.result+=F2[l],e.position++;else if((s=yre(l))>0){for(n=s,o=0;n>0;n--)l=e.input.charCodeAt(++e.position),(s=gre(l))>=0?o=(o<<4)+s:we(e,"expected hexadecimal character");e.result+=_re(o),e.position++;}else we(e,"unknown escape sequence");r=i=e.position;}else vn(l)?($i(e,r,i,true),V0(e,vt(e,false,t)),r=i=e.position):e.position===e.lineStart&&am(e)?we(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position);}we(e,"unexpected end of the stream within a double quoted scalar");}function kre(e,t){var r=true,i,n=e.tag,o,s=e.anchor,l,c,u,d,p,f={},m,v,h,y;if(y=e.input.charCodeAt(e.position),y===91)c=93,p=false,o=[];else if(y===123)c=125,p=true,o={};else return false;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),y=e.input.charCodeAt(++e.position);y!==0;){if(vt(e,true,t),y=e.input.charCodeAt(e.position),y===c)return e.position++,e.tag=n,e.anchor=s,e.kind=p?"mapping":"sequence",e.result=o,true;r||we(e,"missed comma between flow collection entries"),v=m=h=null,u=d=false,y===63&&(l=e.input.charCodeAt(e.position+1),hr(l)&&(u=d=true,e.position++,vt(e,true,t))),i=e.line,rs(e,t,nm,false,true),v=e.tag,m=e.result,vt(e,true,t),y=e.input.charCodeAt(e.position),(d||e.line===i)&&y===58&&(u=true,y=e.input.charCodeAt(++e.position),vt(e,true,t),rs(e,t,nm,false,true),h=e.result),p?ts(e,o,f,v,m,h):u?o.push(ts(e,null,f,v,m,h)):o.push(m),vt(e,true,t),y=e.input.charCodeAt(e.position),y===44?(r=true,y=e.input.charCodeAt(++e.position)):r=false;}we(e,"unexpected end of the stream within a flow collection");}function Tre(e,t){var r,i,n=F0,o=false,s=false,l=t,c=0,u=false,d,p;if(p=e.input.charCodeAt(e.position),p===124)i=false;else if(p===62)i=true;else return false;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)F0===n?n=p===43?E2:pre:we(e,"repeat of a chomping mode identifier");else if((d=vre(p))>=0)d===0?we(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?we(e,"repeat of an indentation width identifier"):(l=t+d-1,s=true);else break;if(ho(p)){do p=e.input.charCodeAt(++e.position);while(ho(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!vn(p)&&p!==0)}for(;p!==0;){for(Z0(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!s||e.lineIndent<l)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>l&&(l=e.lineIndent),vn(p)){c++;continue}if(e.lineIndent<l){n===E2?e.result+=Fn.repeat(`
|
|
383
394
|
`,o?1+c:c):n===F0&&o&&(e.result+=`
|
|
384
395
|
`);break}for(i?ho(p)?(u=true,e.result+=Fn.repeat(`
|
|
385
396
|
`,o?1+c:c)):u?(u=false,e.result+=Fn.repeat(`
|
|
386
397
|
`,c+1)):c===0?o&&(e.result+=" "):e.result+=Fn.repeat(`
|
|
387
398
|
`,c):e.result+=Fn.repeat(`
|
|
388
|
-
`,o?1+c:c),o=true,s=true,c=0,r=e.position;!vn(p)&&p!==0;)p=e.input.charCodeAt(++e.position);$i(e,r,e.position,false);}return true}function
|
|
389
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new bre(e,t),i=e.indexOf("\0");for(i!==-1&&(r.position=i,we(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)Ore(r);return r.documents}function
|
|
399
|
+
`,o?1+c:c),o=true,s=true,c=0,r=e.position;!vn(p)&&p!==0;)p=e.input.charCodeAt(++e.position);$i(e,r,e.position,false);}return true}function N2(e,t){var r,i=e.tag,n=e.anchor,o=[],s,l=false,c;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),c=e.input.charCodeAt(e.position);c!==0&&!(c!==45||(s=e.input.charCodeAt(e.position+1),!hr(s)));){if(l=true,e.position++,vt(e,true,-1)&&e.lineIndent<=t){o.push(null),c=e.input.charCodeAt(e.position);continue}if(r=e.line,rs(e,t,z2,false,true),o.push(e.result),vt(e,true,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&c!==0)we(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=i,e.anchor=n,e.kind="sequence",e.result=o,true):false}function Ire(e,t,r){var i,n,o,s,l=e.tag,c=e.anchor,u={},d={},p=null,f=null,m=null,v=false,h=false,y;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),y=e.input.charCodeAt(e.position);y!==0;){if(i=e.input.charCodeAt(e.position+1),o=e.line,s=e.position,(y===63||y===58)&&hr(i))y===63?(v&&(ts(e,u,d,p,f,null),p=f=m=null),h=true,v=true,n=true):v?(v=false,n=true):we(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,y=i;else if(rs(e,r,M2,false,true))if(e.line===o){for(y=e.input.charCodeAt(e.position);ho(y);)y=e.input.charCodeAt(++e.position);if(y===58)y=e.input.charCodeAt(++e.position),hr(y)||we(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(ts(e,u,d,p,f,null),p=f=m=null),h=true,v=false,n=false,p=e.tag,f=e.result;else if(h)we(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=l,e.anchor=c,true}else if(h)we(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=l,e.anchor=c,true;else break;if((e.line===o||e.lineIndent>t)&&(rs(e,t,im,true,n)&&(v?f=e.result:m=e.result),v||(ts(e,u,d,p,f,m,o,s),p=f=m=null),vt(e,true,-1),y=e.input.charCodeAt(e.position)),e.lineIndent>t&&y!==0)we(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&ts(e,u,d,p,f,null),h&&(e.tag=l,e.anchor=c,e.kind="mapping",e.result=u),h}function $re(e){var t,r=false,i=false,n,o,s;if(s=e.input.charCodeAt(e.position),s!==33)return false;if(e.tag!==null&&we(e,"duplication of a tag property"),s=e.input.charCodeAt(++e.position),s===60?(r=true,s=e.input.charCodeAt(++e.position)):s===33?(i=true,n="!!",s=e.input.charCodeAt(++e.position)):n="!",t=e.position,r){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);e.position<e.length?(o=e.input.slice(t,e.position),s=e.input.charCodeAt(++e.position)):we(e,"unexpected end of the stream within a verbatim tag");}else {for(;s!==0&&!hr(s);)s===33&&(i?we(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),D2.test(n)||we(e,"named tag handle cannot contain such characters"),i=true,t=e.position+1)),s=e.input.charCodeAt(++e.position);o=e.input.slice(t,e.position),hre.test(o)&&we(e,"tag suffix cannot contain flow indicator characters");}return o&&!U2.test(o)&&we(e,"tag name cannot contain such characters: "+o),r?e.tag=o:Ei.call(e.tagMap,n)?e.tag=e.tagMap[n]+o:n==="!"?e.tag="!"+o:n==="!!"?e.tag="tag:yaml.org,2002:"+o:we(e,'undeclared tag handle "'+n+'"'),true}function Ere(e){var t,r;if(r=e.input.charCodeAt(e.position),r!==38)return false;for(e.anchor!==null&&we(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!hr(r)&&!es(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&we(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),true}function Cre(e){var t,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return false;for(i=e.input.charCodeAt(++e.position),t=e.position;i!==0&&!hr(i)&&!es(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&we(e,"name of an alias node must contain at least one character"),r=e.input.slice(t,e.position),Ei.call(e.anchorMap,r)||we(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],vt(e,true,-1),true}function rs(e,t,r,i,n){var o,s,l,c=1,u=false,d=false,p,f,m,v,h;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=s=l=im===r||z2===r,i&&vt(e,true,-1)&&(u=true,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;$re(e)||Ere(e);)vt(e,true,-1)?(u=true,l=o,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=false;if(l&&(l=u||n),(c===1||im===r)&&(nm===r||M2===r?v=t:v=t+1,h=e.position-e.lineStart,c===1?l&&(N2(e,h)||Ire(e,h,v))||kre(e,v)?d=true:(s&&Tre(e,v)||xre(e,v)||Sre(e,v)?d=true:Cre(e)?(d=true,(e.tag!==null||e.anchor!==null)&&we(e,"alias node should not have any properties")):wre(e,v,nm===r)&&(d=true,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(d=l&&N2(e,h))),e.tag!==null&&e.tag!=="!")if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&we(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,f=e.implicitTypes.length;p<f;p+=1)if(m=e.implicitTypes[p],m.resolve(e.result)){e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else Ei.call(e.typeMap[e.kind||"fallback"],e.tag)?(m=e.typeMap[e.kind||"fallback"][e.tag],e.result!==null&&m.kind!==e.kind&&we(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+m.kind+'", not "'+e.kind+'"'),m.resolve(e.result)?(e.result=m.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):we(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):we(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function Ore(e){var t=e.position,r,i,n,o=false,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(s=e.input.charCodeAt(e.position))!==0&&(vt(e,true,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(o=true,s=e.input.charCodeAt(++e.position),r=e.position;s!==0&&!hr(s);)s=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),n=[],i.length<1&&we(e,"directive name must not be less than one character in length");s!==0;){for(;ho(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!vn(s));break}if(vn(s))break;for(r=e.position;s!==0&&!hr(s);)s=e.input.charCodeAt(++e.position);n.push(e.input.slice(r,e.position));}s!==0&&Z0(e),Ei.call(P2,i)?P2[i](e,i,n):om(e,'unknown document directive "'+i+'"');}if(vt(e,true,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,vt(e,true,-1)):o&&we(e,"directives end mark is expected"),rs(e,e.lineIndent-1,im,false,true),vt(e,true,-1),e.checkLineBreaks&&mre.test(e.input.slice(t,e.position))&&om(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&am(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,vt(e,true,-1));return}if(e.position<e.length-1)we(e,"end of the stream or a document separator is expected");else return}function V2(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
400
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new bre(e,t),i=e.indexOf("\0");for(i!==-1&&(r.position=i,we(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)Ore(r);return r.documents}function B2(e,t,r){t!==null&&typeof t=="object"&&typeof r>"u"&&(r=t,t=null);var i=V2(e,r);if(typeof t!="function")return i;for(var n=0,o=i.length;n<o;n+=1)t(i[n]);}function J2(e,t){var r=V2(e,t);if(r.length!==0){if(r.length===1)return r[0];throw new j2("expected a single document in the stream, but found more")}}function Pre(e,t,r){return typeof t=="object"&&t!==null&&typeof r>"u"&&(r=t,t=null),B2(e,t,Fn.extend({schema:R2},r))}function Are(e,t){return J2(e,Fn.extend({schema:R2},t))}Dc.exports.loadAll=B2;Dc.exports.load=J2;Dc.exports.safeLoadAll=Pre;Dc.exports.safeLoad=Are;});var gU=M((dbe,K0)=>{var Lc=uo(),qc=Ya(),Nre=zc(),jre=Qa(),tU=Object.prototype.toString,rU=Object.prototype.hasOwnProperty,Rre=9,Uc=10,Mre=13,zre=32,Dre=33,Ure=34,nU=35,Lre=37,qre=38,Fre=39,Zre=42,iU=44,Vre=45,oU=58,Bre=61,Jre=62,Wre=63,Kre=64,aU=91,sU=93,Hre=96,lU=123,Gre=124,cU=125,Wt={};Wt[0]="\\0";Wt[7]="\\a";Wt[8]="\\b";Wt[9]="\\t";Wt[10]="\\n";Wt[11]="\\v";Wt[12]="\\f";Wt[13]="\\r";Wt[27]="\\e";Wt[34]='\\"';Wt[92]="\\\\";Wt[133]="\\N";Wt[160]="\\_";Wt[8232]="\\L";Wt[8233]="\\P";var Yre=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function Xre(e,t){var r,i,n,o,s,l,c;if(t===null)return {};for(r={},i=Object.keys(t),n=0,o=i.length;n<o;n+=1)s=i[n],l=String(t[s]),s.slice(0,2)==="!!"&&(s="tag:yaml.org,2002:"+s.slice(2)),c=e.compiledTypeMap.fallback[s],c&&rU.call(c.styleAliases,l)&&(l=c.styleAliases[l]),r[s]=l;return r}function K2(e){var t,r,i;if(t=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new qc("code point within a string may not be greater than 0xFFFFFFFF");return "\\"+r+Lc.repeat("0",i-t.length)+t}function Qre(e){this.schema=e.schema||Nre,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||false,this.skipInvalid=e.skipInvalid||false,this.flowLevel=Lc.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Xre(this.schema,e.styles||null),this.sortKeys=e.sortKeys||false,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||false,this.noCompatMode=e.noCompatMode||false,this.condenseFlow=e.condenseFlow||false,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null;}function H2(e,t){for(var r=Lc.repeat(" ",t),i=0,n=-1,o="",s,l=e.length;i<l;)n=e.indexOf(`
|
|
390
401
|
`,i),n===-1?(s=e.slice(i),i=l):(s=e.slice(i,n+1),i=n+1),s.length&&s!==`
|
|
391
402
|
`&&(o+=r),o+=s;return o}function B0(e,t){return `
|
|
392
|
-
`+Lc.repeat(" ",e.indent*t)}function ene(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return true;return false}function W0(e){return e===zre||e===Rre}function ns(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==65279||65536<=e&&e<=1114111}function tne(e){return ns(e)&&!W0(e)&&e!==65279&&e!==Mre&&e!==Uc}function
|
|
403
|
+
`+Lc.repeat(" ",e.indent*t)}function ene(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return true;return false}function W0(e){return e===zre||e===Rre}function ns(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==65279||65536<=e&&e<=1114111}function tne(e){return ns(e)&&!W0(e)&&e!==65279&&e!==Mre&&e!==Uc}function G2(e,t){return ns(e)&&e!==65279&&e!==iU&&e!==aU&&e!==sU&&e!==lU&&e!==cU&&e!==oU&&(e!==nU||t&&tne(t))}function rne(e){return ns(e)&&e!==65279&&!W0(e)&&e!==Vre&&e!==Wre&&e!==oU&&e!==iU&&e!==aU&&e!==sU&&e!==lU&&e!==cU&&e!==nU&&e!==qre&&e!==Zre&&e!==Dre&&e!==Gre&&e!==Bre&&e!==Jre&&e!==Fre&&e!==Ure&&e!==Lre&&e!==Kre&&e!==Hre}function uU(e){var t=/^\n* /;return t.test(e)}var dU=1,pU=2,fU=3,mU=4,sm=5;function nne(e,t,r,i,n){var o,s,l,c=false,u=false,d=i!==-1,p=-1,f=rne(e.charCodeAt(0))&&!W0(e.charCodeAt(e.length-1));if(t)for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),!ns(s))return sm;l=o>0?e.charCodeAt(o-1):null,f=f&&G2(s,l);}else {for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),s===Uc)c=true,d&&(u=u||o-p-1>i&&e[p+1]!==" ",p=o);else if(!ns(s))return sm;l=o>0?e.charCodeAt(o-1):null,f=f&&G2(s,l);}u=u||d&&o-p-1>i&&e[p+1]!==" ";}return !c&&!u?f&&!n(e)?dU:pU:r>9&&uU(e)?sm:u?mU:fU}function ine(e,t,r,i){e.dump=(function(){if(t.length===0)return "''";if(!e.noCompatMode&&Yre.indexOf(t)!==-1)return "'"+t+"'";var n=e.indent*Math.max(1,r),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-n),s=i||e.flowLevel>-1&&r>=e.flowLevel;function l(c){return ene(e,c)}switch(nne(t,s,e.indent,o,l)){case dU:return t;case pU:return "'"+t.replace(/'/g,"''")+"'";case fU:return "|"+Y2(t,e.indent)+X2(H2(t,n));case mU:return ">"+Y2(t,e.indent)+X2(H2(one(t,o),n));case sm:return '"'+ane(t)+'"';default:throw new qc("impossible error: invalid scalar style")}})();}function Y2(e,t){var r=uU(e)?String(t):"",i=e[e.length-1]===`
|
|
393
404
|
`,n=i&&(e[e.length-2]===`
|
|
394
405
|
`||e===`
|
|
395
406
|
`),o=n?"+":i?"":"-";return r+o+`
|
|
396
|
-
`}function
|
|
407
|
+
`}function X2(e){return e[e.length-1]===`
|
|
397
408
|
`?e.slice(0,-1):e}function one(e,t){for(var r=/(\n+)([^\n]*)/g,i=(function(){var u=e.indexOf(`
|
|
398
|
-
`);return u=u!==-1?u:e.length,r.lastIndex=u,
|
|
409
|
+
`);return u=u!==-1?u:e.length,r.lastIndex=u,Q2(e.slice(0,u),t)})(),n=e[0]===`
|
|
399
410
|
`||e[0]===" ",o,s;s=r.exec(e);){var l=s[1],c=s[2];o=c[0]===" ",i+=l+(!n&&!o&&c!==""?`
|
|
400
|
-
`:"")+
|
|
411
|
+
`:"")+Q2(c,t),n=o;}return i}function Q2(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,n=0,o,s=0,l=0,c="";i=r.exec(e);)l=i.index,l-n>t&&(o=s>n?s:l,c+=`
|
|
401
412
|
`+e.slice(n,o),n=o+1),s=l;return c+=`
|
|
402
413
|
`,e.length-n>t&&s>n?c+=e.slice(n,s)+`
|
|
403
|
-
`+e.slice(s+1):c+=e.slice(n),c.slice(1)}function ane(e){for(var t="",r,i,n,o=0;o<e.length;o++){if(r=e.charCodeAt(o),r>=55296&&r<=56319&&(i=e.charCodeAt(o+1),i>=56320&&i<=57343)){t+=
|
|
404
|
-
`:""}function pne(e,t){return hU(e,Lc.extend({schema:jre},t))}K0.exports.dump=hU;K0.exports.safeDump=pne;});var vU=M((pbe,ct)=>{var lm=
|
|
414
|
+
`+e.slice(s+1):c+=e.slice(n),c.slice(1)}function ane(e){for(var t="",r,i,n,o=0;o<e.length;o++){if(r=e.charCodeAt(o),r>=55296&&r<=56319&&(i=e.charCodeAt(o+1),i>=56320&&i<=57343)){t+=K2((r-55296)*1024+i-56320+65536),o++;continue}n=Wt[r],t+=!n&&ns(r)?e[o]:n||K2(r);}return t}function sne(e,t,r){var i="",n=e.tag,o,s;for(o=0,s=r.length;o<s;o+=1)go(e,t,r[o],false,false)&&(o!==0&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=n,e.dump="["+i+"]";}function lne(e,t,r,i){var n="",o=e.tag,s,l;for(s=0,l=r.length;s<l;s+=1)go(e,t+1,r[s],true,true)&&((!i||s!==0)&&(n+=B0(e,t)),e.dump&&Uc===e.dump.charCodeAt(0)?n+="-":n+="- ",n+=e.dump);e.tag=o,e.dump=n||"[]";}function cne(e,t,r){var i="",n=e.tag,o=Object.keys(r),s,l,c,u,d;for(s=0,l=o.length;s<l;s+=1)d="",s!==0&&(d+=", "),e.condenseFlow&&(d+='"'),c=o[s],u=r[c],go(e,t,c,false,false)&&(e.dump.length>1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),go(e,t,u,false,false)&&(d+=e.dump,i+=d));e.tag=n,e.dump="{"+i+"}";}function une(e,t,r,i){var n="",o=e.tag,s=Object.keys(r),l,c,u,d,p,f;if(e.sortKeys===true)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new qc("sortKeys must be a boolean or a function");for(l=0,c=s.length;l<c;l+=1)f="",(!i||l!==0)&&(f+=B0(e,t)),u=s[l],d=r[u],go(e,t+1,u,true,true,true)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&Uc===e.dump.charCodeAt(0)?f+="?":f+="? "),f+=e.dump,p&&(f+=B0(e,t)),go(e,t+1,d,true,p)&&(e.dump&&Uc===e.dump.charCodeAt(0)?f+=":":f+=": ",f+=e.dump,n+=f));e.tag=o,e.dump=n||"{}";}function eU(e,t,r){var i,n,o,s,l,c;for(n=r?e.explicitTypes:e.implicitTypes,o=0,s=n.length;o<s;o+=1)if(l=n[o],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(e.tag=r?l.tag:"?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,tU.call(l.represent)==="[object Function]")i=l.represent(t,c);else if(rU.call(l.represent,c))i=l.represent[c](t,c);else throw new qc("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i;}return true}return false}function go(e,t,r,i,n,o){e.tag=null,e.dump=r,eU(e,r,false)||eU(e,r,true);var s=tU.call(e.dump);i&&(i=e.flowLevel<0||e.flowLevel>t);var l=s==="[object Object]"||s==="[object Array]",c,u;if(l&&(c=e.duplicates.indexOf(r),u=c!==-1),(e.tag!==null&&e.tag!=="?"||u||e.indent!==2&&t>0)&&(n=false),u&&e.usedDuplicates[c])e.dump="*ref_"+c;else {if(l&&u&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=true),s==="[object Object]")i&&Object.keys(e.dump).length!==0?(une(e,t,e.dump,n),u&&(e.dump="&ref_"+c+e.dump)):(cne(e,t,e.dump),u&&(e.dump="&ref_"+c+" "+e.dump));else if(s==="[object Array]"){var d=e.noArrayIndent&&t>0?t-1:t;i&&e.dump.length!==0?(lne(e,d,e.dump,n),u&&(e.dump="&ref_"+c+e.dump)):(sne(e,d,e.dump),u&&(e.dump="&ref_"+c+" "+e.dump));}else if(s==="[object String]")e.tag!=="?"&&ine(e,e.dump,t,o);else {if(e.skipInvalid)return false;throw new qc("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump);}return true}function dne(e,t){var r=[],i=[],n,o;for(J0(e,r,i),n=0,o=i.length;n<o;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=new Array(o);}function J0(e,t,r){var i,n,o;if(e!==null&&typeof e=="object")if(n=t.indexOf(e),n!==-1)r.indexOf(n)===-1&&r.push(n);else if(t.push(e),Array.isArray(e))for(n=0,o=e.length;n<o;n+=1)J0(e[n],t,r);else for(i=Object.keys(e),n=0,o=i.length;n<o;n+=1)J0(e[i[n]],t,r);}function hU(e,t){t=t||{};var r=new Qre(t);return r.noRefs||dne(e,r),go(r,0,e,true,true)?r.dump+`
|
|
415
|
+
`:""}function pne(e,t){return hU(e,Lc.extend({schema:jre},t))}K0.exports.dump=hU;K0.exports.safeDump=pne;});var vU=M((pbe,ct)=>{var lm=W2(),yU=gU();function cm(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}ct.exports.Type=kt();ct.exports.Schema=po();ct.exports.FAILSAFE_SCHEMA=tm();ct.exports.JSON_SCHEMA=U0();ct.exports.CORE_SCHEMA=L0();ct.exports.DEFAULT_SAFE_SCHEMA=Qa();ct.exports.DEFAULT_FULL_SCHEMA=zc();ct.exports.load=lm.load;ct.exports.loadAll=lm.loadAll;ct.exports.safeLoad=lm.safeLoad;ct.exports.safeLoadAll=lm.safeLoadAll;ct.exports.dump=yU.dump;ct.exports.safeDump=yU.safeDump;ct.exports.YAMLException=Ya();ct.exports.MINIMAL_SCHEMA=tm();ct.exports.SAFE_SCHEMA=Qa();ct.exports.DEFAULT_SCHEMA=zc();ct.exports.scan=cm("scan");ct.exports.parse=cm("parse");ct.exports.compose=cm("compose");ct.exports.addConstructor=cm("addConstructor");});var bU=M((fbe,_U)=>{var fne=vU();_U.exports=fne;});var H0=M((exports$1,module)=>{var yaml=bU(),engines=module.exports;engines.yaml={parse:yaml.safeLoad.bind(yaml),stringify:yaml.safeDump.bind(yaml)};engines.json={parse:JSON.parse.bind(JSON),stringify:function(e,t){let r=Object.assign({replacer:null,space:2},t);return JSON.stringify(e,r.replacer,r.space)}};engines.javascript={parse:function parse(str,options,wrap){try{return wrap!==!1&&(str=`(function() {
|
|
405
416
|
return `+str.trim()+`;
|
|
406
417
|
}());`),eval(str)||{}}catch(e){if(wrap!==false&&/(unexpected|identifier)/i.test(e.message))return parse(str,options,false);throw new SyntaxError(e)}},stringify:function(){throw new Error("stringifying JavaScript is not supported")}};});var xU=M((mbe,wU)=>{wU.exports=function(e){return typeof e=="string"&&e.charAt(0)==="\uFEFF"?e.slice(1):e};});var um=M(Zn=>{var SU=xU(),kU=Rc();Zn.define=function(e,t,r){Reflect.defineProperty(e,t,{enumerable:false,configurable:true,writable:true,value:r});};Zn.isBuffer=function(e){return kU(e)==="buffer"};Zn.isObject=function(e){return kU(e)==="object"};Zn.toBuffer=function(e){return typeof e=="string"?Buffer.from(e):e};Zn.toString=function(e){if(Zn.isBuffer(e))return SU(String(e));if(typeof e!="string")throw new TypeError("expected input to be a string or buffer");return SU(e)};Zn.arrayify=function(e){return e?Array.isArray(e)?e:[e]:[]};Zn.startsWith=function(e,t,r){return typeof r!="number"&&(r=t.length),e.slice(0,r)===t};});var Fc=M((gbe,TU)=>{var mne=H0(),hne=um();TU.exports=function(e){let t=Object.assign({},e);return t.delimiters=hne.arrayify(t.delims||t.delimiters||"---"),t.delimiters.length===1&&t.delimiters.push(t.delimiters[0]),t.language=(t.language||t.lang||"yaml").toLowerCase(),t.engines=Object.assign({},mne,t.parsers,t.engines),t};});var G0=M((ybe,IU)=>{IU.exports=function(e,t){let r=t.engines[e]||t.engines[gne(e)];if(typeof r>"u")throw new Error('gray-matter engine "'+e+'" is not registered');return typeof r=="function"&&(r={parse:r}),r};function gne(e){switch(e.toLowerCase()){case "js":case "javascript":return "javascript";case "coffee":case "coffeescript":case "cson":return "coffee";case "yaml":case "yml":return "yaml";default:return e}}});var Y0=M((vbe,$U)=>{var yne=Rc(),vne=G0(),_ne=Fc();$U.exports=function(e,t,r){if(t==null&&r==null)switch(yne(e)){case "object":t=e.data,r={};break;case "string":return e;default:throw new TypeError("expected file to be a string or object")}let i=e.content,n=_ne(r);if(t==null){if(!n.data)return e;t=n.data;}let o=e.language||n.language,s=vne(o,n);if(typeof s.stringify!="function")throw new TypeError('expected "'+o+'.stringify" to be a function');t=Object.assign({},e.data,t);let l=n.delimiters[0],c=n.delimiters[1],u=s.stringify(t,r).trim(),d="";return u!=="{}"&&(d=is(l)+is(u)+is(c)),typeof e.excerpt=="string"&&e.excerpt!==""&&i.indexOf(e.excerpt.trim())===-1&&(d+=is(e.excerpt)+is(c)),d+is(i)};function is(e){return e.slice(-1)!==`
|
|
407
418
|
`?e+`
|
|
408
|
-
`:e}});var CU=M((_be,EU)=>{var bne=Fc();EU.exports=function(e,t){let r=bne(t);if(e.data==null&&(e.data={}),typeof r.excerpt=="function")return r.excerpt(e,r);let i=e.data.excerpt_separator||r.excerpt_separator;if(i==null&&(r.excerpt===false||r.excerpt==null))return e;let n=typeof r.excerpt=="string"?r.excerpt:i||r.delimiters[0],o=e.content.indexOf(n);return o!==-1&&(e.excerpt=e.content.slice(0,o)),e};});var AU=M((bbe,PU)=>{var OU=Rc(),wne=Y0(),os=um();PU.exports=function(e){return OU(e)!=="object"&&(e={content:e}),OU(e.data)!=="object"&&(e.data={}),e.contents&&e.content==null&&(e.content=e.contents),os.define(e,"orig",os.toBuffer(e.content)),os.define(e,"language",e.language||""),os.define(e,"matter",e.matter||""),os.define(e,"stringify",function(t,r){return r&&r.language&&(e.language=r.language),wne(e,t,r)}),e.content=os.toString(e.content),e.isEmpty=false,e.excerpt="",e};});var jU=M((wbe,NU)=>{var xne=G0(),Sne=Fc();NU.exports=function(e,t,r){let i=Sne(r),n=xne(e,i);if(typeof n.parse!="function")throw new TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)};});var DU=M((xbe,zU)=>{var kne=dt("fs"),Tne=
|
|
419
|
+
`:e}});var CU=M((_be,EU)=>{var bne=Fc();EU.exports=function(e,t){let r=bne(t);if(e.data==null&&(e.data={}),typeof r.excerpt=="function")return r.excerpt(e,r);let i=e.data.excerpt_separator||r.excerpt_separator;if(i==null&&(r.excerpt===false||r.excerpt==null))return e;let n=typeof r.excerpt=="string"?r.excerpt:i||r.delimiters[0],o=e.content.indexOf(n);return o!==-1&&(e.excerpt=e.content.slice(0,o)),e};});var AU=M((bbe,PU)=>{var OU=Rc(),wne=Y0(),os=um();PU.exports=function(e){return OU(e)!=="object"&&(e={content:e}),OU(e.data)!=="object"&&(e.data={}),e.contents&&e.content==null&&(e.content=e.contents),os.define(e,"orig",os.toBuffer(e.content)),os.define(e,"language",e.language||""),os.define(e,"matter",e.matter||""),os.define(e,"stringify",function(t,r){return r&&r.language&&(e.language=r.language),wne(e,t,r)}),e.content=os.toString(e.content),e.isEmpty=false,e.excerpt="",e};});var jU=M((wbe,NU)=>{var xne=G0(),Sne=Fc();NU.exports=function(e,t,r){let i=Sne(r),n=xne(e,i);if(typeof n.parse!="function")throw new TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)};});var DU=M((xbe,zU)=>{var kne=dt("fs"),Tne=CD(),X0=Fc(),Ine=Y0(),RU=CU(),$ne=H0(),Ene=AU(),Cne=jU(),MU=um();function or(e,t){if(e==="")return {data:{},content:e,excerpt:"",orig:e};let r=Ene(e),i=or.cache[r.content];if(!t){if(i)return r=Object.assign({},i),r.orig=i.orig,r;or.cache[r.content]=r;}return One(r,t)}function One(e,t){let r=X0(t),i=r.delimiters[0],n=`
|
|
409
420
|
`+r.delimiters[1],o=e.content;r.language&&(e.language=r.language);let s=i.length;if(!MU.startsWith(o,i,s))return RU(e,r),e;if(o.charAt(s)===i.slice(-1))return e;o=o.slice(s);let l=o.length,c=or.language(o,r);c.name&&(e.language=c.name,o=o.slice(c.raw.length));let u=o.indexOf(n);return u===-1&&(u=l),e.matter=o.slice(0,u),e.matter.replace(/^\s*#[^\n]+/gm,"").trim()===""?(e.isEmpty=true,e.empty=e.content,e.data={}):e.data=Cne(e.language,e.matter,r),u===l?e.content="":(e.content=o.slice(u+n.length),e.content[0]==="\r"&&(e.content=e.content.slice(1)),e.content[0]===`
|
|
410
421
|
`&&(e.content=e.content.slice(1))),RU(e,r),(r.sections===true||typeof r.section=="function")&&Tne(e,r.section),e}or.engines=$ne;or.stringify=function(e,t,r){return typeof e=="string"&&(e=or(e,r)),Ine(e,t,r)};or.read=function(e,t){let r=kne.readFileSync(e,"utf8"),i=or(r,t);return i.path=e,i};or.test=function(e,t){return MU.startsWith(e,X0(t).delimiters[0])};or.language=function(e,t){let i=X0(t).delimiters[0];or.test(e)&&(e=e.slice(i.length));let n=e.slice(0,e.search(/\r?\n/));return {raw:n,name:n?n.trim():""}};or.cache={};or.clearCache=function(){or.cache={};};zU.exports=or;});function Nne(e){return {name:"skill",description:(r=>["If query matches an available skill's description or instruction [use skill], use the skill tool to get detailed instructions.","Load a skill to get detailed instructions for a specific task.","Skills provide specialized knowledge and step-by-step guidance.","Use this when a task matches an available skill's description.","Only the skills listed here are available:","[!important] You should follow the skill's step-by-step guidance. If the skill is not complete, ask the user for more information.","<available_skills>",...r.flatMap(i=>[" <skill>",` <name>${i.name}</name>`,` <description>${i.description}</description>`," </skill>"]),"</available_skills>"].join(" "))(e),inputSchema:Ane,execute:async({name:r})=>{let i=e.find(n=>n.name===r);if(!i)throw new Error(`Skill ${r} not found`);return i}}}var LU,Zc,Ane,dm,Q0=T(()=>{Bw();LU=Oi(DU(),1);dr();Zc=class{skills=new Map;initialized=false;async initialize(t){if(this.initialized){console.warn("SkillRegistry already initialized");return}console.log("Scanning built-in skills...");let r=await this.scanSkills(t);this.skills.clear();for(let i of r)this.skills.set(i.name,i);this.initialized=true,console.log(`Loaded ${this.skills.size} built-in skill(s)`);}async scanSkills(t){let r=[],i=[{base:t,pattern:".pulse-coder/skills/**/SKILL.md"},{base:t,pattern:".coder/skills/**/SKILL.md"},{base:t,pattern:".claude/skills/**/SKILL.md"},{base:os.homedir(),pattern:".pulse-coder/skills/**/SKILL.md"},{base:os.homedir(),pattern:".coder/skills/**/SKILL.md"}];for(let{base:n,pattern:o}of i)try{let s=Bp(o,{cwd:n,absolute:!0});for(let l of s)try{let c=this.parseSkillFile(l);c&&r.push(c);}catch(c){console.warn(`Failed to parse skill file ${l}:`,c);}}catch(s){console.debug(`Skip scanning ${o} in ${n}:`,s);}return r}parseSkillFile(t){try{let r=Dj.readFileSync(t,"utf-8"),{data:i,content:n}=(0,LU.default)(r);return !i.name||!i.description?(console.warn(`Skill file ${t} missing required fields (name or description)`),null):{name:i.name,description:i.description,location:t,content:n,metadata:i}}catch(r){return console.warn(`Failed to read skill file ${t}:`,r),null}}getAll(){return Array.from(this.skills.values())}get(t){return this.skills.get(t)}has(t){return this.skills.has(t)}search(t){let r=t.toLowerCase();return this.getAll().filter(i=>i.name.toLowerCase().includes(r)||i.description.toLowerCase().includes(r))}},Ane=a.object({name:a.string().describe("The name of the skill to execute")});dm={name:"pulse-coder-engine/built-in-skills",version:"1.0.0",async initialize(e){let t=new Zc;await t.initialize(process.cwd());let r=t.getAll();if(r.length===0){console.log("[Skills] No skills found");return}let i=Nne(r);e.registerTool("skill",i),e.registerService("skillRegistry",t),console.log(`[Skills] Registered ${r.length} skill(s)`);}};});function Une(e,t){if(!t.trim())return e??{append:""};if(!e)return {append:t};if(typeof e=="string")return `${e}
|
|
411
422
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulse-coder-cli",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.11",
|
|
4
4
|
"description": "CLI interface for Pulse Coder",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
|
-
"dependencies": {
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"pulse-sandbox": "0.0.1-alpha.3",
|
|
15
|
+
"pulse-coder-engine": "0.0.1-alpha.10"
|
|
16
|
+
},
|
|
14
17
|
"devDependencies": {
|
|
15
18
|
"typescript": "^5.0.0",
|
|
16
19
|
"tsup": "^8.0.0",
|