@tencent-ai/codebuddy-code 0.0.1-beta.17 → 0.0.1-beta.18
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/444.codebuddy.js +1 -1
- package/dist/726.codebuddy.js +1 -1
- package/dist/814.codebuddy.js +1 -1
- package/dist/889.codebuddy.js +1 -0
- package/dist/codebuddy.js +1 -1
- package/package.json +1 -1
- package/product.json +2 -2
- package/dist/453.codebuddy.js +0 -1
package/dist/444.codebuddy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=444,exports.ids=[444],exports.modules={84444:(e,t,r)=>{r.r(t),r.d(t,{Client:()=>Client});var s=r(99453);class Protocol{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(s.CancelledNotificationSchema,(e=>{const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)})),this.setNotificationHandler(s.ProgressNotificationSchema,(e=>{this._onprogress(e)})),this.setRequestHandler(s.PingRequestSchema,(e=>({})))}_setupTimeout(e,t,r,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new s.McpError(s.ErrorCode.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,r,o;this._transport=e;const i=null===(t=this.transport)||void 0===t?void 0:t.onclose;this._transport.onclose=()=>{null==i||i(),this._onclose()};const n=null===(r=this.transport)||void 0===r?void 0:r.onerror;this._transport.onerror=e=>{null==n||n(e),this._onerror(e)};const a=null===(o=this._transport)||void 0===o?void 0:o.onmessage;this._transport.onmessage=(e,t)=>{null==a||a(e,t),(0,s.isJSONRPCResponse)(e)||(0,s.isJSONRPCError)(e)?this._onresponse(e):(0,s.isJSONRPCRequest)(e)?this._onrequest(e,t):(0,s.isJSONRPCNotification)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);const r=new s.McpError(s.ErrorCode.ConnectionClosed,"Connection closed");for(const e of t.values())e(r)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const r=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==r&&Promise.resolve().then((()=>r(e))).catch((e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`))))}_onrequest(e,t){var r,o,i,n;const a=null!==(r=this._requestHandlers.get(e.method))&&void 0!==r?r:this.fallbackRequestHandler;if(void 0===a)return void(null===(o=this._transport)||void 0===o||o.send({jsonrpc:"2.0",id:e.id,error:{code:s.ErrorCode.MethodNotFound,message:"Method not found"}}).catch((e=>this._onerror(new Error(`Failed to send an error response: ${e}`)))));const l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);const u={signal:l.signal,sessionId:null===(i=this._transport)||void 0===i?void 0:i.sessionId,_meta:null===(n=e.params)||void 0===n?void 0:n._meta,sendNotification:t=>this.notification(t,{relatedRequestId:e.id}),sendRequest:(t,r,s)=>this.request(t,r,{...s,relatedRequestId:e.id}),authInfo:null==t?void 0:t.authInfo,requestId:e.id,requestInfo:null==t?void 0:t.requestInfo};Promise.resolve().then((()=>a(e,u))).then((t=>{var r;if(!l.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({result:t,jsonrpc:"2.0",id:e.id})}),(t=>{var r,o;if(!l.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:s.ErrorCode.InternalError,message:null!==(o=t.message)&&void 0!==o?o:"Internal error"}})})).catch((e=>this._onerror(new Error(`Failed to send response: ${e}`)))).finally((()=>{this._requestHandlerAbortControllers.delete(e.id)}))}_onprogress(e){const{progressToken:t,...r}=e.params,s=Number(t),o=this._progressHandlers.get(s);if(!o)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(s),n=this._timeoutInfo.get(s);if(n&&i&&n.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(e){return void i(e)}o(r)}_onresponse(e){const t=Number(e.id),r=this._responseHandlers.get(t);if(void 0!==r)if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),(0,s.isJSONRPCResponse)(e))r(e);else{r(new s.McpError(e.error.code,e.error.message,e.error.data))}else this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`))}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}request(e,t,r){const{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}=null!=r?r:{};return new Promise(((a,l)=>{var u,c,d,h,p,m;if(!this._transport)return void l(new Error("Not connected"));!0===(null===(u=this._options)||void 0===u?void 0:u.enforceStrictCapabilities)&&this.assertCapabilityForMethod(e.method),null===(c=null==r?void 0:r.signal)||void 0===c||c.throwIfAborted();const v=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:v};(null==r?void 0:r.onprogress)&&(this._progressHandlers.set(v,r.onprogress),_.params={...e.params,_meta:{...(null===(d=e.params)||void 0===d?void 0:d._meta)||{},progressToken:v}});const cancel=e=>{var t;this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(e)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}).catch((e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)))),l(e)};this._responseHandlers.set(v,(e=>{var s;if(!(null===(s=null==r?void 0:r.signal)||void 0===s?void 0:s.aborted)){if(e instanceof Error)return l(e);try{const r=t.parse(e.result);a(r)}catch(e){l(e)}}})),null===(h=null==r?void 0:r.signal)||void 0===h||h.addEventListener("abort",(()=>{var e;cancel(null===(e=null==r?void 0:r.signal)||void 0===e?void 0:e.reason)}));const f=null!==(p=null==r?void 0:r.timeout)&&void 0!==p?p:6e4;this._setupTimeout(v,f,null==r?void 0:r.maxTotalTimeout,(()=>cancel(new s.McpError(s.ErrorCode.RequestTimeout,"Request timed out",{timeout:f}))),null!==(m=null==r?void 0:r.resetTimeoutOnProgress)&&void 0!==m&&m),this._transport.send(_,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}).catch((e=>{this._cleanupTimeout(v),l(e)}))}))}async notification(e,t){var r,s;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);if((null!==(s=null===(r=this._options)||void 0===r?void 0:r.debouncedNotificationMethods)&&void 0!==s?s:[]).includes(e.method)&&!e.params&&!(null==t?void 0:t.relatedRequestId)){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then((()=>{var r;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;const s={...e,jsonrpc:"2.0"};null===(r=this._transport)||void 0===r||r.send(s,t).catch((e=>this._onerror(e)))}))}const o={...e,jsonrpc:"2.0"};await this._transport.send(o,t)}setRequestHandler(e,t){const r=e.shape.method.value;this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,((r,s)=>Promise.resolve(t(e.parse(r),s))))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,(r=>Promise.resolve(t(e.parse(r)))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}var o=r(82174);class Client extends Protocol{constructor(e,t){var r;super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=null!==(r=null==t?void 0:t.capabilities)&&void 0!==r?r:{},this._ajv=new o}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function mergeCapabilities(e,t){return Object.entries(t).reduce(((e,[t,r])=>(e[t]=r&&"object"==typeof r&&e[t]?{...e[t],...r}:r,e)),{...e})}(this._capabilities,e)}assertCapability(e,t){var r;if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const r=await this.request({method:"initialize",params:{protocolVersion:s.LATEST_PROTOCOL_VERSION,capabilities:this._capabilities,clientInfo:this._clientInfo}},s.InitializeResultSchema,t);if(void 0===r)throw new Error(`Server sent invalid initialize result: ${r}`);if(!s.SUPPORTED_PROTOCOL_VERSIONS.includes(r.protocolVersion))throw new Error(`Server's protocol version is not supported: ${r.protocolVersion}`);this._serverCapabilities=r.capabilities,this._serverVersion=r.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(r.protocolVersion),this._instructions=r.instructions,await this.notification({method:"notifications/initialized"})}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,r,s,o,i;switch(e){case"logging/setLevel":if(!(null===(t=this._serverCapabilities)||void 0===t?void 0:t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(null===(s=this._serverCapabilities)||void 0===s?void 0:s.resources))throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(null===(o=this._serverCapabilities)||void 0===o?void 0:o.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(null===(i=this._serverCapabilities)||void 0===i?void 0:i.completions))throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){var t;if("notifications/roots/list_changed"===e)if(!(null===(t=this._capabilities.roots)||void 0===t?void 0:t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:"ping"},s.EmptyResultSchema,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},s.CompleteResultSchema,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},s.EmptyResultSchema,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},s.GetPromptResultSchema,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},s.ListPromptsResultSchema,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},s.ListResourcesResultSchema,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},s.ListResourceTemplatesResultSchema,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},s.ReadResourceResultSchema,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},s.EmptyResultSchema,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},s.EmptyResultSchema,t)}async callTool(e,t=s.CallToolResultSchema,r){const o=await this.request({method:"tools/call",params:e},t,r),i=this.getToolOutputValidator(e.name);if(i){if(!o.structuredContent&&!o.isError)throw new s.McpError(s.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{if(!i(o.structuredContent))throw new s.McpError(s.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(i.errors)}`)}catch(e){if(e instanceof s.McpError)throw e;throw new s.McpError(s.ErrorCode.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return o}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const t of e)if(t.outputSchema)try{const e=this._ajv.compile(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}catch(e){}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},s.ListToolsResultSchema,t);return this.cacheToolOutputSchemas(r.tools),r}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}}};
|
|
1
|
+
"use strict";exports.id=444,exports.ids=[444],exports.modules={84444:(e,t,r)=>{r.r(t),r.d(t,{Client:()=>Client});var s=r(76889);class Protocol{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(s.CancelledNotificationSchema,(e=>{const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)})),this.setNotificationHandler(s.ProgressNotificationSchema,(e=>{this._onprogress(e)})),this.setRequestHandler(s.PingRequestSchema,(e=>({})))}_setupTimeout(e,t,r,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new s.McpError(s.ErrorCode.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,r,o;this._transport=e;const i=null===(t=this.transport)||void 0===t?void 0:t.onclose;this._transport.onclose=()=>{null==i||i(),this._onclose()};const n=null===(r=this.transport)||void 0===r?void 0:r.onerror;this._transport.onerror=e=>{null==n||n(e),this._onerror(e)};const a=null===(o=this._transport)||void 0===o?void 0:o.onmessage;this._transport.onmessage=(e,t)=>{null==a||a(e,t),(0,s.isJSONRPCResponse)(e)||(0,s.isJSONRPCError)(e)?this._onresponse(e):(0,s.isJSONRPCRequest)(e)?this._onrequest(e,t):(0,s.isJSONRPCNotification)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);const r=new s.McpError(s.ErrorCode.ConnectionClosed,"Connection closed");for(const e of t.values())e(r)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const r=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==r&&Promise.resolve().then((()=>r(e))).catch((e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`))))}_onrequest(e,t){var r,o,i,n;const a=null!==(r=this._requestHandlers.get(e.method))&&void 0!==r?r:this.fallbackRequestHandler;if(void 0===a)return void(null===(o=this._transport)||void 0===o||o.send({jsonrpc:"2.0",id:e.id,error:{code:s.ErrorCode.MethodNotFound,message:"Method not found"}}).catch((e=>this._onerror(new Error(`Failed to send an error response: ${e}`)))));const l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);const u={signal:l.signal,sessionId:null===(i=this._transport)||void 0===i?void 0:i.sessionId,_meta:null===(n=e.params)||void 0===n?void 0:n._meta,sendNotification:t=>this.notification(t,{relatedRequestId:e.id}),sendRequest:(t,r,s)=>this.request(t,r,{...s,relatedRequestId:e.id}),authInfo:null==t?void 0:t.authInfo,requestId:e.id,requestInfo:null==t?void 0:t.requestInfo};Promise.resolve().then((()=>a(e,u))).then((t=>{var r;if(!l.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({result:t,jsonrpc:"2.0",id:e.id})}),(t=>{var r,o;if(!l.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:s.ErrorCode.InternalError,message:null!==(o=t.message)&&void 0!==o?o:"Internal error"}})})).catch((e=>this._onerror(new Error(`Failed to send response: ${e}`)))).finally((()=>{this._requestHandlerAbortControllers.delete(e.id)}))}_onprogress(e){const{progressToken:t,...r}=e.params,s=Number(t),o=this._progressHandlers.get(s);if(!o)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(s),n=this._timeoutInfo.get(s);if(n&&i&&n.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(e){return void i(e)}o(r)}_onresponse(e){const t=Number(e.id),r=this._responseHandlers.get(t);if(void 0!==r)if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),(0,s.isJSONRPCResponse)(e))r(e);else{r(new s.McpError(e.error.code,e.error.message,e.error.data))}else this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`))}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}request(e,t,r){const{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}=null!=r?r:{};return new Promise(((a,l)=>{var u,c,d,h,p,m;if(!this._transport)return void l(new Error("Not connected"));!0===(null===(u=this._options)||void 0===u?void 0:u.enforceStrictCapabilities)&&this.assertCapabilityForMethod(e.method),null===(c=null==r?void 0:r.signal)||void 0===c||c.throwIfAborted();const v=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:v};(null==r?void 0:r.onprogress)&&(this._progressHandlers.set(v,r.onprogress),_.params={...e.params,_meta:{...(null===(d=e.params)||void 0===d?void 0:d._meta)||{},progressToken:v}});const cancel=e=>{var t;this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(e)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}).catch((e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)))),l(e)};this._responseHandlers.set(v,(e=>{var s;if(!(null===(s=null==r?void 0:r.signal)||void 0===s?void 0:s.aborted)){if(e instanceof Error)return l(e);try{const r=t.parse(e.result);a(r)}catch(e){l(e)}}})),null===(h=null==r?void 0:r.signal)||void 0===h||h.addEventListener("abort",(()=>{var e;cancel(null===(e=null==r?void 0:r.signal)||void 0===e?void 0:e.reason)}));const f=null!==(p=null==r?void 0:r.timeout)&&void 0!==p?p:6e4;this._setupTimeout(v,f,null==r?void 0:r.maxTotalTimeout,(()=>cancel(new s.McpError(s.ErrorCode.RequestTimeout,"Request timed out",{timeout:f}))),null!==(m=null==r?void 0:r.resetTimeoutOnProgress)&&void 0!==m&&m),this._transport.send(_,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:n}).catch((e=>{this._cleanupTimeout(v),l(e)}))}))}async notification(e,t){var r,s;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);if((null!==(s=null===(r=this._options)||void 0===r?void 0:r.debouncedNotificationMethods)&&void 0!==s?s:[]).includes(e.method)&&!e.params&&!(null==t?void 0:t.relatedRequestId)){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then((()=>{var r;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;const s={...e,jsonrpc:"2.0"};null===(r=this._transport)||void 0===r||r.send(s,t).catch((e=>this._onerror(e)))}))}const o={...e,jsonrpc:"2.0"};await this._transport.send(o,t)}setRequestHandler(e,t){const r=e.shape.method.value;this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,((r,s)=>Promise.resolve(t(e.parse(r),s))))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,(r=>Promise.resolve(t(e.parse(r)))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}var o=r(82174);class Client extends Protocol{constructor(e,t){var r;super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=null!==(r=null==t?void 0:t.capabilities)&&void 0!==r?r:{},this._ajv=new o}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function mergeCapabilities(e,t){return Object.entries(t).reduce(((e,[t,r])=>(e[t]=r&&"object"==typeof r&&e[t]?{...e[t],...r}:r,e)),{...e})}(this._capabilities,e)}assertCapability(e,t){var r;if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const r=await this.request({method:"initialize",params:{protocolVersion:s.LATEST_PROTOCOL_VERSION,capabilities:this._capabilities,clientInfo:this._clientInfo}},s.InitializeResultSchema,t);if(void 0===r)throw new Error(`Server sent invalid initialize result: ${r}`);if(!s.SUPPORTED_PROTOCOL_VERSIONS.includes(r.protocolVersion))throw new Error(`Server's protocol version is not supported: ${r.protocolVersion}`);this._serverCapabilities=r.capabilities,this._serverVersion=r.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(r.protocolVersion),this._instructions=r.instructions,await this.notification({method:"notifications/initialized"})}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,r,s,o,i;switch(e){case"logging/setLevel":if(!(null===(t=this._serverCapabilities)||void 0===t?void 0:t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(null===(s=this._serverCapabilities)||void 0===s?void 0:s.resources))throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(null===(o=this._serverCapabilities)||void 0===o?void 0:o.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(null===(i=this._serverCapabilities)||void 0===i?void 0:i.completions))throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){var t;if("notifications/roots/list_changed"===e)if(!(null===(t=this._capabilities.roots)||void 0===t?void 0:t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:"ping"},s.EmptyResultSchema,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},s.CompleteResultSchema,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},s.EmptyResultSchema,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},s.GetPromptResultSchema,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},s.ListPromptsResultSchema,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},s.ListResourcesResultSchema,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},s.ListResourceTemplatesResultSchema,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},s.ReadResourceResultSchema,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},s.EmptyResultSchema,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},s.EmptyResultSchema,t)}async callTool(e,t=s.CallToolResultSchema,r){const o=await this.request({method:"tools/call",params:e},t,r),i=this.getToolOutputValidator(e.name);if(i){if(!o.structuredContent&&!o.isError)throw new s.McpError(s.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{if(!i(o.structuredContent))throw new s.McpError(s.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(i.errors)}`)}catch(e){if(e instanceof s.McpError)throw e;throw new s.McpError(s.ErrorCode.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return o}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const t of e)if(t.outputSchema)try{const e=this._ajv.compile(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}catch(e){}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},s.ListToolsResultSchema,t);return this.cacheToolOutputSchemas(r.tools),r}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}}};
|
package/dist/726.codebuddy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=726,exports.ids=[726],exports.modules={51345:(r,e,t)=>{let o;async function random(r){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let t="";const n=await async function getRandomValues(r){return(await o).getRandomValues(new Uint8Array(r))}(r);for(let o=0;o<r;o++){t+=e[n[o]%66]}return t}async function generateChallenge(r){const e=await(await o).subtle.digest("SHA-256",(new TextEncoder).encode(r));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function pkceChallenge(r){if(r||(r=43),r<43||r>128)throw`Expected a length between 43 and 128. Received ${r}.`;const e=await async function generateVerifier(r){return await random(r)}(r);return{code_verifier:e,code_challenge:await generateChallenge(e)}}t.d(e,{D_:()=>UnauthorizedError,j2:()=>auth,cV:()=>extractResourceMetadataUrl}),o=globalThis.crypto?.webcrypto??globalThis.crypto??Promise.resolve().then(t.t.bind(t,77598,19)).then((r=>r.webcrypto));var n=t(13298),a=t(83478);const i=a.z.object({resource:a.z.string().url(),authorization_servers:a.z.array(a.z.string().url()).optional(),jwks_uri:a.z.string().url().optional(),scopes_supported:a.z.array(a.z.string()).optional(),bearer_methods_supported:a.z.array(a.z.string()).optional(),resource_signing_alg_values_supported:a.z.array(a.z.string()).optional(),resource_name:a.z.string().optional(),resource_documentation:a.z.string().optional(),resource_policy_uri:a.z.string().url().optional(),resource_tos_uri:a.z.string().url().optional(),tls_client_certificate_bound_access_tokens:a.z.boolean().optional(),authorization_details_types_supported:a.z.array(a.z.string()).optional(),dpop_signing_alg_values_supported:a.z.array(a.z.string()).optional(),dpop_bound_access_tokens_required:a.z.boolean().optional()}).passthrough(),s=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),registration_endpoint:a.z.string().optional(),scopes_supported:a.z.array(a.z.string()).optional(),response_types_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()).optional(),grant_types_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),service_documentation:a.z.string().optional(),revocation_endpoint:a.z.string().optional(),revocation_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),revocation_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),introspection_endpoint:a.z.string().optional(),introspection_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),introspection_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),code_challenge_methods_supported:a.z.array(a.z.string()).optional()}).passthrough(),c=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),userinfo_endpoint:a.z.string().optional(),jwks_uri:a.z.string(),registration_endpoint:a.z.string().optional(),scopes_supported:a.z.array(a.z.string()).optional(),response_types_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()).optional(),grant_types_supported:a.z.array(a.z.string()).optional(),acr_values_supported:a.z.array(a.z.string()).optional(),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),id_token_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),id_token_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),userinfo_signing_alg_values_supported:a.z.array(a.z.string()).optional(),userinfo_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),userinfo_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),request_object_signing_alg_values_supported:a.z.array(a.z.string()).optional(),request_object_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),request_object_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),display_values_supported:a.z.array(a.z.string()).optional(),claim_types_supported:a.z.array(a.z.string()).optional(),claims_supported:a.z.array(a.z.string()).optional(),service_documentation:a.z.string().optional(),claims_locales_supported:a.z.array(a.z.string()).optional(),ui_locales_supported:a.z.array(a.z.string()).optional(),claims_parameter_supported:a.z.boolean().optional(),request_parameter_supported:a.z.boolean().optional(),request_uri_parameter_supported:a.z.boolean().optional(),require_request_uri_registration:a.z.boolean().optional(),op_policy_uri:a.z.string().optional(),op_tos_uri:a.z.string().optional()}).passthrough().merge(s.pick({code_challenge_methods_supported:!0})),l=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number().optional(),scope:a.z.string().optional(),refresh_token:a.z.string().optional()}).strip(),p=a.z.object({error:a.z.string(),error_description:a.z.string().optional(),error_uri:a.z.string().optional()}),d=a.z.object({redirect_uris:a.z.array(a.z.string()).refine((r=>r.every((r=>URL.canParse(r)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:a.z.string().optional(),grant_types:a.z.array(a.z.string()).optional(),response_types:a.z.array(a.z.string()).optional(),client_name:a.z.string().optional(),client_uri:a.z.string().optional(),logo_uri:a.z.string().optional(),scope:a.z.string().optional(),contacts:a.z.array(a.z.string()).optional(),tos_uri:a.z.string().optional(),policy_uri:a.z.string().optional(),jwks_uri:a.z.string().optional(),jwks:a.z.any().optional(),software_id:a.z.string().optional(),software_version:a.z.string().optional(),software_statement:a.z.string().optional()}).strip(),u=a.z.object({client_id:a.z.string(),client_secret:a.z.string().optional(),client_id_issued_at:a.z.number().optional(),client_secret_expires_at:a.z.number().optional()}).strip(),_=d.merge(u);a.z.object({error:a.z.string(),error_description:a.z.string().optional()}).strip(),a.z.object({token:a.z.string(),token_type_hint:a.z.string().optional()}).strip();class OAuthError extends Error{constructor(r,e){super(r),this.errorUri=e,this.name=this.constructor.name}toResponseObject(){const r={error:this.errorCode,error_description:this.message};return this.errorUri&&(r.error_uri=this.errorUri),r}get errorCode(){return this.constructor.errorCode}}class InvalidRequestError extends OAuthError{}InvalidRequestError.errorCode="invalid_request";class InvalidClientError extends OAuthError{}InvalidClientError.errorCode="invalid_client";class InvalidGrantError extends OAuthError{}InvalidGrantError.errorCode="invalid_grant";class UnauthorizedClientError extends OAuthError{}UnauthorizedClientError.errorCode="unauthorized_client";class UnsupportedGrantTypeError extends OAuthError{}UnsupportedGrantTypeError.errorCode="unsupported_grant_type";class InvalidScopeError extends OAuthError{}InvalidScopeError.errorCode="invalid_scope";class AccessDeniedError extends OAuthError{}AccessDeniedError.errorCode="access_denied";class ServerError extends OAuthError{}ServerError.errorCode="server_error";class TemporarilyUnavailableError extends OAuthError{}TemporarilyUnavailableError.errorCode="temporarily_unavailable";class UnsupportedResponseTypeError extends OAuthError{}UnsupportedResponseTypeError.errorCode="unsupported_response_type";class UnsupportedTokenTypeError extends OAuthError{}UnsupportedTokenTypeError.errorCode="unsupported_token_type";class InvalidTokenError extends OAuthError{}InvalidTokenError.errorCode="invalid_token";class MethodNotAllowedError extends OAuthError{}MethodNotAllowedError.errorCode="method_not_allowed";class TooManyRequestsError extends OAuthError{}TooManyRequestsError.errorCode="too_many_requests";class InvalidClientMetadataError extends OAuthError{}InvalidClientMetadataError.errorCode="invalid_client_metadata";class InsufficientScopeError extends OAuthError{}InsufficientScopeError.errorCode="insufficient_scope";const h={[InvalidRequestError.errorCode]:InvalidRequestError,[InvalidClientError.errorCode]:InvalidClientError,[InvalidGrantError.errorCode]:InvalidGrantError,[UnauthorizedClientError.errorCode]:UnauthorizedClientError,[UnsupportedGrantTypeError.errorCode]:UnsupportedGrantTypeError,[InvalidScopeError.errorCode]:InvalidScopeError,[AccessDeniedError.errorCode]:AccessDeniedError,[ServerError.errorCode]:ServerError,[TemporarilyUnavailableError.errorCode]:TemporarilyUnavailableError,[UnsupportedResponseTypeError.errorCode]:UnsupportedResponseTypeError,[UnsupportedTokenTypeError.errorCode]:UnsupportedTokenTypeError,[InvalidTokenError.errorCode]:InvalidTokenError,[MethodNotAllowedError.errorCode]:MethodNotAllowedError,[TooManyRequestsError.errorCode]:TooManyRequestsError,[InvalidClientMetadataError.errorCode]:InvalidClientMetadataError,[InsufficientScopeError.errorCode]:InsufficientScopeError};class UnauthorizedError extends Error{constructor(r){super(null!=r?r:"Unauthorized")}}function selectClientAuthMethod(r,e){const t=void 0!==r.client_secret;return 0===e.length?t?"client_secret_post":"none":t&&e.includes("client_secret_basic")?"client_secret_basic":t&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":t?"client_secret_post":"none"}function applyClientAuthentication(r,e,t,o){const{client_id:n,client_secret:a}=e;switch(r){case"client_secret_basic":return void function applyBasicAuth(r,e,t){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${r}:${e}`);t.set("Authorization",`Basic ${o}`)}(n,a,t);case"client_secret_post":return void function applyPostAuth(r,e,t){t.set("client_id",r),e&&t.set("client_secret",e)}(n,a,o);case"none":return void function applyPublicAuth(r,e){e.set("client_id",r)}(n,o);default:throw new Error(`Unsupported client authentication method: ${r}`)}}async function parseErrorResponse(r){const e=r instanceof Response?r.status:void 0,t=r instanceof Response?await r.text():r;try{const r=p.parse(JSON.parse(t)),{error:e,error_description:o,error_uri:n}=r;return new(h[e]||ServerError)(o||"",n)}catch(r){return new ServerError(`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${r}. Raw body: ${t}`)}}async function auth(r,e){var t,o;try{return await authInternal(r,e)}catch(n){if(n instanceof InvalidClientError||n instanceof UnauthorizedClientError)return await(null===(t=r.invalidateCredentials)||void 0===t?void 0:t.call(r,"all")),await authInternal(r,e);if(n instanceof InvalidGrantError)return await(null===(o=r.invalidateCredentials)||void 0===o?void 0:o.call(r,"tokens")),await authInternal(r,e);throw n}}async function authInternal(r,{serverUrl:e,authorizationCode:t,scope:o,resourceMetadataUrl:a,fetchFn:p}){let d,u;try{d=await async function discoverOAuthProtectedResourceMetadata(r,e,t=fetch){const o=await discoverMetadataWithFallback(r,"oauth-protected-resource",t,{protocolVersion:null==e?void 0:e.protocolVersion,metadataUrl:null==e?void 0:e.resourceMetadataUrl});if(!o||404===o.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return i.parse(await o.json())}(e,{resourceMetadataUrl:a},p),d.authorization_servers&&d.authorization_servers.length>0&&(u=d.authorization_servers[0])}catch(r){}u||(u=e);const h=await async function selectResourceURL(r,e,t){const o=function resourceUrlFromServerUrl(r){const e="string"==typeof r?new URL(r):new URL(r.href);return e.hash="",e}(r);if(e.validateResourceURL)return await e.validateResourceURL(o,null==t?void 0:t.resource);if(!t)return;if(!function checkResourceAllowed({requestedResource:r,configuredResource:e}){const t="string"==typeof r?new URL(r):new URL(r.href),o="string"==typeof e?new URL(e):new URL(e.href);if(t.origin!==o.origin)return!1;if(t.pathname.length<o.pathname.length)return!1;const n=t.pathname.endsWith("/")?t.pathname:t.pathname+"/",a=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(a)}({requestedResource:o,configuredResource:t.resource}))throw new Error(`Protected resource ${t.resource} does not match expected ${o} (or origin)`);return new URL(t.resource)}(e,r,d),g=await async function discoverAuthorizationServerMetadata(r,{fetchFn:e=fetch,protocolVersion:t=n.LATEST_PROTOCOL_VERSION}={}){var o;const a={"MCP-Protocol-Version":t},i=function buildDiscoveryUrls(r){const e="string"==typeof r?new URL(r):r,t="/"!==e.pathname,o=[];if(!t)return o.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),o;let n=e.pathname;n.endsWith("/")&&(n=n.slice(0,-1));return o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,e.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,e.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,e.origin),type:"oidc"}),o}(r);for(const{url:r,type:t}of i){const n=await fetchWithCorsRetry(r,a,e);if(n){if(!n.ok){if(n.status>=400&&n.status<500)continue;throw new Error(`HTTP ${n.status} trying to load ${"oauth"===t?"OAuth":"OpenID provider"} metadata from ${r}`)}if("oauth"===t)return s.parse(await n.json());{const e=c.parse(await n.json());if(!(null===(o=e.code_challenge_methods_supported)||void 0===o?void 0:o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${r}: does not support S256 code challenge method required by MCP specification`);return e}}}return}(u,{fetchFn:p});let z=await Promise.resolve(r.clientInformation());if(!z){if(void 0!==t)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!r.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const e=await async function registerClient(r,{metadata:e,clientMetadata:t,fetchFn:o}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",r);const a=await(null!=o?o:fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw await parseErrorResponse(a);return _.parse(await a.json())}(u,{metadata:g,clientMetadata:r.clientMetadata});await r.saveClientInformation(e),z=e}if(void 0!==t){const e=await r.codeVerifier(),o=await async function exchangeAuthorization(r,{metadata:e,clientInformation:t,authorizationCode:o,codeVerifier:n,redirectUri:a,resource:i,addClientAuthentication:s,fetchFn:c}){var p;const d="authorization_code",u=(null==e?void 0:e.token_endpoint)?new URL(e.token_endpoint):new URL("/token",r);if((null==e?void 0:e.grant_types_supported)&&!e.grant_types_supported.includes(d))throw new Error(`Incompatible auth server: does not support grant type ${d}`);const _=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),h=new URLSearchParams({grant_type:d,code:o,code_verifier:n,redirect_uri:String(a)});if(s)s(_,h,r,e);else{applyClientAuthentication(selectClientAuthMethod(t,null!==(p=null==e?void 0:e.token_endpoint_auth_methods_supported)&&void 0!==p?p:[]),t,_,h)}i&&h.set("resource",i.href);const g=await(null!=c?c:fetch)(u,{method:"POST",headers:_,body:h});if(!g.ok)throw await parseErrorResponse(g);return l.parse(await g.json())}(u,{metadata:g,clientInformation:z,authorizationCode:t,codeVerifier:e,redirectUri:r.redirectUrl,resource:h,addClientAuthentication:r.addClientAuthentication,fetchFn:p});return await r.saveTokens(o),"AUTHORIZED"}const f=await r.tokens();if(null==f?void 0:f.refresh_token)try{const e=await async function refreshAuthorization(r,{metadata:e,clientInformation:t,refreshToken:o,resource:n,addClientAuthentication:a,fetchFn:i}){var s;const c="refresh_token";let p;if(e){if(p=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else p=new URL("/token",r);const d=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),u=new URLSearchParams({grant_type:c,refresh_token:o});if(a)a(d,u,r,e);else{applyClientAuthentication(selectClientAuthMethod(t,null!==(s=null==e?void 0:e.token_endpoint_auth_methods_supported)&&void 0!==s?s:[]),t,d,u)}n&&u.set("resource",n.href);const _=await(null!=i?i:fetch)(p,{method:"POST",headers:d,body:u});if(!_.ok)throw await parseErrorResponse(_);return l.parse({refresh_token:o,...await _.json()})}(u,{metadata:g,clientInformation:z,refreshToken:f.refresh_token,resource:h,addClientAuthentication:r.addClientAuthentication});return await r.saveTokens(e),"AUTHORIZED"}catch(r){if(r instanceof OAuthError&&!(r instanceof ServerError))throw r}const y=r.state?await r.state():void 0,{authorizationUrl:w,codeVerifier:v}=await async function startAuthorization(r,{metadata:e,clientInformation:t,redirectUrl:o,scope:n,state:a,resource:i}){const s="code",c="S256";let l;if(e){if(l=new URL(e.authorization_endpoint),!e.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!e.code_challenge_methods_supported||!e.code_challenge_methods_supported.includes(c))throw new Error(`Incompatible auth server: does not support code challenge method ${c}`)}else l=new URL("/authorize",r);const p=await pkceChallenge(),d=p.code_verifier,u=p.code_challenge;l.searchParams.set("response_type",s),l.searchParams.set("client_id",t.client_id),l.searchParams.set("code_challenge",u),l.searchParams.set("code_challenge_method",c),l.searchParams.set("redirect_uri",String(o)),a&&l.searchParams.set("state",a);n&&l.searchParams.set("scope",n);(null==n?void 0:n.includes("offline_access"))&&l.searchParams.append("prompt","consent");i&&l.searchParams.set("resource",i.href);return{authorizationUrl:l,codeVerifier:d}}(u,{metadata:g,clientInformation:z,state:y,redirectUrl:r.redirectUrl,scope:o||r.clientMetadata.scope,resource:h});return await r.saveCodeVerifier(v),await r.redirectToAuthorization(w),"REDIRECT"}function extractResourceMetadataUrl(r){const e=r.headers.get("WWW-Authenticate");if(!e)return;const[t,o]=e.split(" ");if("bearer"!==t.toLowerCase()||!o)return;const n=/resource_metadata="([^"]*)"/.exec(e);if(n)try{return new URL(n[1])}catch(r){return}}async function fetchWithCorsRetry(r,e,t=fetch){try{return await t(r,{headers:e})}catch(o){if(o instanceof TypeError)return e?fetchWithCorsRetry(r,void 0,t):void 0;throw o}}async function tryMetadataDiscovery(r,e,t=fetch){const o={"MCP-Protocol-Version":e};return await fetchWithCorsRetry(r,o,t)}async function discoverMetadataWithFallback(r,e,t,o){var a,i;const s=new URL(r),c=null!==(a=null==o?void 0:o.protocolVersion)&&void 0!==a?a:n.LATEST_PROTOCOL_VERSION;let l;if(null==o?void 0:o.metadataUrl)l=new URL(o.metadataUrl);else{const r=function buildWellKnownPath(r,e="",t={}){return e.endsWith("/")&&(e=e.slice(0,-1)),t.prependPathname?`${e}/.well-known/${r}`:`/.well-known/${r}${e}`}(e,s.pathname);l=new URL(r,null!==(i=null==o?void 0:o.metadataServerUrl)&&void 0!==i?i:s),l.search=s.search}let p=await tryMetadataDiscovery(l,c,t);if(!(null==o?void 0:o.metadataUrl)&&function shouldAttemptFallback(r,e){return!r||404===r.status&&"/"!==e}(p,s.pathname)){const r=new URL(`/.well-known/${e}`,s);p=await tryMetadataDiscovery(r,c,t)}return p}}};
|
|
1
|
+
"use strict";exports.id=726,exports.ids=[726],exports.modules={51345:(r,e,t)=>{let o;async function random(r){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let t="";const n=await async function getRandomValues(r){return(await o).getRandomValues(new Uint8Array(r))}(r);for(let o=0;o<r;o++){t+=e[n[o]%66]}return t}async function generateChallenge(r){const e=await(await o).subtle.digest("SHA-256",(new TextEncoder).encode(r));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function pkceChallenge(r){if(r||(r=43),r<43||r>128)throw`Expected a length between 43 and 128. Received ${r}.`;const e=await async function generateVerifier(r){return await random(r)}(r);return{code_verifier:e,code_challenge:await generateChallenge(e)}}t.d(e,{D_:()=>UnauthorizedError,j2:()=>auth,cV:()=>extractResourceMetadataUrl}),o=globalThis.crypto?.webcrypto??globalThis.crypto??Promise.resolve().then(t.t.bind(t,77598,19)).then((r=>r.webcrypto));var n=t(13298),a=t(7578);const i=a.z.object({resource:a.z.string().url(),authorization_servers:a.z.array(a.z.string().url()).optional(),jwks_uri:a.z.string().url().optional(),scopes_supported:a.z.array(a.z.string()).optional(),bearer_methods_supported:a.z.array(a.z.string()).optional(),resource_signing_alg_values_supported:a.z.array(a.z.string()).optional(),resource_name:a.z.string().optional(),resource_documentation:a.z.string().optional(),resource_policy_uri:a.z.string().url().optional(),resource_tos_uri:a.z.string().url().optional(),tls_client_certificate_bound_access_tokens:a.z.boolean().optional(),authorization_details_types_supported:a.z.array(a.z.string()).optional(),dpop_signing_alg_values_supported:a.z.array(a.z.string()).optional(),dpop_bound_access_tokens_required:a.z.boolean().optional()}).passthrough(),s=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),registration_endpoint:a.z.string().optional(),scopes_supported:a.z.array(a.z.string()).optional(),response_types_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()).optional(),grant_types_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),service_documentation:a.z.string().optional(),revocation_endpoint:a.z.string().optional(),revocation_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),revocation_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),introspection_endpoint:a.z.string().optional(),introspection_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),introspection_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),code_challenge_methods_supported:a.z.array(a.z.string()).optional()}).passthrough(),c=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),userinfo_endpoint:a.z.string().optional(),jwks_uri:a.z.string(),registration_endpoint:a.z.string().optional(),scopes_supported:a.z.array(a.z.string()).optional(),response_types_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()).optional(),grant_types_supported:a.z.array(a.z.string()).optional(),acr_values_supported:a.z.array(a.z.string()).optional(),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),id_token_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),id_token_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),userinfo_signing_alg_values_supported:a.z.array(a.z.string()).optional(),userinfo_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),userinfo_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),request_object_signing_alg_values_supported:a.z.array(a.z.string()).optional(),request_object_encryption_alg_values_supported:a.z.array(a.z.string()).optional(),request_object_encryption_enc_values_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_methods_supported:a.z.array(a.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string()).optional(),display_values_supported:a.z.array(a.z.string()).optional(),claim_types_supported:a.z.array(a.z.string()).optional(),claims_supported:a.z.array(a.z.string()).optional(),service_documentation:a.z.string().optional(),claims_locales_supported:a.z.array(a.z.string()).optional(),ui_locales_supported:a.z.array(a.z.string()).optional(),claims_parameter_supported:a.z.boolean().optional(),request_parameter_supported:a.z.boolean().optional(),request_uri_parameter_supported:a.z.boolean().optional(),require_request_uri_registration:a.z.boolean().optional(),op_policy_uri:a.z.string().optional(),op_tos_uri:a.z.string().optional()}).passthrough().merge(s.pick({code_challenge_methods_supported:!0})),l=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number().optional(),scope:a.z.string().optional(),refresh_token:a.z.string().optional()}).strip(),p=a.z.object({error:a.z.string(),error_description:a.z.string().optional(),error_uri:a.z.string().optional()}),d=a.z.object({redirect_uris:a.z.array(a.z.string()).refine((r=>r.every((r=>URL.canParse(r)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:a.z.string().optional(),grant_types:a.z.array(a.z.string()).optional(),response_types:a.z.array(a.z.string()).optional(),client_name:a.z.string().optional(),client_uri:a.z.string().optional(),logo_uri:a.z.string().optional(),scope:a.z.string().optional(),contacts:a.z.array(a.z.string()).optional(),tos_uri:a.z.string().optional(),policy_uri:a.z.string().optional(),jwks_uri:a.z.string().optional(),jwks:a.z.any().optional(),software_id:a.z.string().optional(),software_version:a.z.string().optional(),software_statement:a.z.string().optional()}).strip(),u=a.z.object({client_id:a.z.string(),client_secret:a.z.string().optional(),client_id_issued_at:a.z.number().optional(),client_secret_expires_at:a.z.number().optional()}).strip(),_=d.merge(u);a.z.object({error:a.z.string(),error_description:a.z.string().optional()}).strip(),a.z.object({token:a.z.string(),token_type_hint:a.z.string().optional()}).strip();class OAuthError extends Error{constructor(r,e){super(r),this.errorUri=e,this.name=this.constructor.name}toResponseObject(){const r={error:this.errorCode,error_description:this.message};return this.errorUri&&(r.error_uri=this.errorUri),r}get errorCode(){return this.constructor.errorCode}}class InvalidRequestError extends OAuthError{}InvalidRequestError.errorCode="invalid_request";class InvalidClientError extends OAuthError{}InvalidClientError.errorCode="invalid_client";class InvalidGrantError extends OAuthError{}InvalidGrantError.errorCode="invalid_grant";class UnauthorizedClientError extends OAuthError{}UnauthorizedClientError.errorCode="unauthorized_client";class UnsupportedGrantTypeError extends OAuthError{}UnsupportedGrantTypeError.errorCode="unsupported_grant_type";class InvalidScopeError extends OAuthError{}InvalidScopeError.errorCode="invalid_scope";class AccessDeniedError extends OAuthError{}AccessDeniedError.errorCode="access_denied";class ServerError extends OAuthError{}ServerError.errorCode="server_error";class TemporarilyUnavailableError extends OAuthError{}TemporarilyUnavailableError.errorCode="temporarily_unavailable";class UnsupportedResponseTypeError extends OAuthError{}UnsupportedResponseTypeError.errorCode="unsupported_response_type";class UnsupportedTokenTypeError extends OAuthError{}UnsupportedTokenTypeError.errorCode="unsupported_token_type";class InvalidTokenError extends OAuthError{}InvalidTokenError.errorCode="invalid_token";class MethodNotAllowedError extends OAuthError{}MethodNotAllowedError.errorCode="method_not_allowed";class TooManyRequestsError extends OAuthError{}TooManyRequestsError.errorCode="too_many_requests";class InvalidClientMetadataError extends OAuthError{}InvalidClientMetadataError.errorCode="invalid_client_metadata";class InsufficientScopeError extends OAuthError{}InsufficientScopeError.errorCode="insufficient_scope";const h={[InvalidRequestError.errorCode]:InvalidRequestError,[InvalidClientError.errorCode]:InvalidClientError,[InvalidGrantError.errorCode]:InvalidGrantError,[UnauthorizedClientError.errorCode]:UnauthorizedClientError,[UnsupportedGrantTypeError.errorCode]:UnsupportedGrantTypeError,[InvalidScopeError.errorCode]:InvalidScopeError,[AccessDeniedError.errorCode]:AccessDeniedError,[ServerError.errorCode]:ServerError,[TemporarilyUnavailableError.errorCode]:TemporarilyUnavailableError,[UnsupportedResponseTypeError.errorCode]:UnsupportedResponseTypeError,[UnsupportedTokenTypeError.errorCode]:UnsupportedTokenTypeError,[InvalidTokenError.errorCode]:InvalidTokenError,[MethodNotAllowedError.errorCode]:MethodNotAllowedError,[TooManyRequestsError.errorCode]:TooManyRequestsError,[InvalidClientMetadataError.errorCode]:InvalidClientMetadataError,[InsufficientScopeError.errorCode]:InsufficientScopeError};class UnauthorizedError extends Error{constructor(r){super(null!=r?r:"Unauthorized")}}function selectClientAuthMethod(r,e){const t=void 0!==r.client_secret;return 0===e.length?t?"client_secret_post":"none":t&&e.includes("client_secret_basic")?"client_secret_basic":t&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":t?"client_secret_post":"none"}function applyClientAuthentication(r,e,t,o){const{client_id:n,client_secret:a}=e;switch(r){case"client_secret_basic":return void function applyBasicAuth(r,e,t){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${r}:${e}`);t.set("Authorization",`Basic ${o}`)}(n,a,t);case"client_secret_post":return void function applyPostAuth(r,e,t){t.set("client_id",r),e&&t.set("client_secret",e)}(n,a,o);case"none":return void function applyPublicAuth(r,e){e.set("client_id",r)}(n,o);default:throw new Error(`Unsupported client authentication method: ${r}`)}}async function parseErrorResponse(r){const e=r instanceof Response?r.status:void 0,t=r instanceof Response?await r.text():r;try{const r=p.parse(JSON.parse(t)),{error:e,error_description:o,error_uri:n}=r;return new(h[e]||ServerError)(o||"",n)}catch(r){return new ServerError(`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${r}. Raw body: ${t}`)}}async function auth(r,e){var t,o;try{return await authInternal(r,e)}catch(n){if(n instanceof InvalidClientError||n instanceof UnauthorizedClientError)return await(null===(t=r.invalidateCredentials)||void 0===t?void 0:t.call(r,"all")),await authInternal(r,e);if(n instanceof InvalidGrantError)return await(null===(o=r.invalidateCredentials)||void 0===o?void 0:o.call(r,"tokens")),await authInternal(r,e);throw n}}async function authInternal(r,{serverUrl:e,authorizationCode:t,scope:o,resourceMetadataUrl:a,fetchFn:p}){let d,u;try{d=await async function discoverOAuthProtectedResourceMetadata(r,e,t=fetch){const o=await discoverMetadataWithFallback(r,"oauth-protected-resource",t,{protocolVersion:null==e?void 0:e.protocolVersion,metadataUrl:null==e?void 0:e.resourceMetadataUrl});if(!o||404===o.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return i.parse(await o.json())}(e,{resourceMetadataUrl:a},p),d.authorization_servers&&d.authorization_servers.length>0&&(u=d.authorization_servers[0])}catch(r){}u||(u=e);const h=await async function selectResourceURL(r,e,t){const o=function resourceUrlFromServerUrl(r){const e="string"==typeof r?new URL(r):new URL(r.href);return e.hash="",e}(r);if(e.validateResourceURL)return await e.validateResourceURL(o,null==t?void 0:t.resource);if(!t)return;if(!function checkResourceAllowed({requestedResource:r,configuredResource:e}){const t="string"==typeof r?new URL(r):new URL(r.href),o="string"==typeof e?new URL(e):new URL(e.href);if(t.origin!==o.origin)return!1;if(t.pathname.length<o.pathname.length)return!1;const n=t.pathname.endsWith("/")?t.pathname:t.pathname+"/",a=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(a)}({requestedResource:o,configuredResource:t.resource}))throw new Error(`Protected resource ${t.resource} does not match expected ${o} (or origin)`);return new URL(t.resource)}(e,r,d),g=await async function discoverAuthorizationServerMetadata(r,{fetchFn:e=fetch,protocolVersion:t=n.LATEST_PROTOCOL_VERSION}={}){var o;const a={"MCP-Protocol-Version":t},i=function buildDiscoveryUrls(r){const e="string"==typeof r?new URL(r):r,t="/"!==e.pathname,o=[];if(!t)return o.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),o;let n=e.pathname;n.endsWith("/")&&(n=n.slice(0,-1));return o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,e.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,e.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,e.origin),type:"oidc"}),o}(r);for(const{url:r,type:t}of i){const n=await fetchWithCorsRetry(r,a,e);if(n){if(!n.ok){if(n.status>=400&&n.status<500)continue;throw new Error(`HTTP ${n.status} trying to load ${"oauth"===t?"OAuth":"OpenID provider"} metadata from ${r}`)}if("oauth"===t)return s.parse(await n.json());{const e=c.parse(await n.json());if(!(null===(o=e.code_challenge_methods_supported)||void 0===o?void 0:o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${r}: does not support S256 code challenge method required by MCP specification`);return e}}}return}(u,{fetchFn:p});let z=await Promise.resolve(r.clientInformation());if(!z){if(void 0!==t)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!r.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const e=await async function registerClient(r,{metadata:e,clientMetadata:t,fetchFn:o}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",r);const a=await(null!=o?o:fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw await parseErrorResponse(a);return _.parse(await a.json())}(u,{metadata:g,clientMetadata:r.clientMetadata});await r.saveClientInformation(e),z=e}if(void 0!==t){const e=await r.codeVerifier(),o=await async function exchangeAuthorization(r,{metadata:e,clientInformation:t,authorizationCode:o,codeVerifier:n,redirectUri:a,resource:i,addClientAuthentication:s,fetchFn:c}){var p;const d="authorization_code",u=(null==e?void 0:e.token_endpoint)?new URL(e.token_endpoint):new URL("/token",r);if((null==e?void 0:e.grant_types_supported)&&!e.grant_types_supported.includes(d))throw new Error(`Incompatible auth server: does not support grant type ${d}`);const _=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),h=new URLSearchParams({grant_type:d,code:o,code_verifier:n,redirect_uri:String(a)});if(s)s(_,h,r,e);else{applyClientAuthentication(selectClientAuthMethod(t,null!==(p=null==e?void 0:e.token_endpoint_auth_methods_supported)&&void 0!==p?p:[]),t,_,h)}i&&h.set("resource",i.href);const g=await(null!=c?c:fetch)(u,{method:"POST",headers:_,body:h});if(!g.ok)throw await parseErrorResponse(g);return l.parse(await g.json())}(u,{metadata:g,clientInformation:z,authorizationCode:t,codeVerifier:e,redirectUri:r.redirectUrl,resource:h,addClientAuthentication:r.addClientAuthentication,fetchFn:p});return await r.saveTokens(o),"AUTHORIZED"}const f=await r.tokens();if(null==f?void 0:f.refresh_token)try{const e=await async function refreshAuthorization(r,{metadata:e,clientInformation:t,refreshToken:o,resource:n,addClientAuthentication:a,fetchFn:i}){var s;const c="refresh_token";let p;if(e){if(p=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else p=new URL("/token",r);const d=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),u=new URLSearchParams({grant_type:c,refresh_token:o});if(a)a(d,u,r,e);else{applyClientAuthentication(selectClientAuthMethod(t,null!==(s=null==e?void 0:e.token_endpoint_auth_methods_supported)&&void 0!==s?s:[]),t,d,u)}n&&u.set("resource",n.href);const _=await(null!=i?i:fetch)(p,{method:"POST",headers:d,body:u});if(!_.ok)throw await parseErrorResponse(_);return l.parse({refresh_token:o,...await _.json()})}(u,{metadata:g,clientInformation:z,refreshToken:f.refresh_token,resource:h,addClientAuthentication:r.addClientAuthentication});return await r.saveTokens(e),"AUTHORIZED"}catch(r){if(r instanceof OAuthError&&!(r instanceof ServerError))throw r}const y=r.state?await r.state():void 0,{authorizationUrl:w,codeVerifier:v}=await async function startAuthorization(r,{metadata:e,clientInformation:t,redirectUrl:o,scope:n,state:a,resource:i}){const s="code",c="S256";let l;if(e){if(l=new URL(e.authorization_endpoint),!e.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!e.code_challenge_methods_supported||!e.code_challenge_methods_supported.includes(c))throw new Error(`Incompatible auth server: does not support code challenge method ${c}`)}else l=new URL("/authorize",r);const p=await pkceChallenge(),d=p.code_verifier,u=p.code_challenge;l.searchParams.set("response_type",s),l.searchParams.set("client_id",t.client_id),l.searchParams.set("code_challenge",u),l.searchParams.set("code_challenge_method",c),l.searchParams.set("redirect_uri",String(o)),a&&l.searchParams.set("state",a);n&&l.searchParams.set("scope",n);(null==n?void 0:n.includes("offline_access"))&&l.searchParams.append("prompt","consent");i&&l.searchParams.set("resource",i.href);return{authorizationUrl:l,codeVerifier:d}}(u,{metadata:g,clientInformation:z,state:y,redirectUrl:r.redirectUrl,scope:o||r.clientMetadata.scope,resource:h});return await r.saveCodeVerifier(v),await r.redirectToAuthorization(w),"REDIRECT"}function extractResourceMetadataUrl(r){const e=r.headers.get("WWW-Authenticate");if(!e)return;const[t,o]=e.split(" ");if("bearer"!==t.toLowerCase()||!o)return;const n=/resource_metadata="([^"]*)"/.exec(e);if(n)try{return new URL(n[1])}catch(r){return}}async function fetchWithCorsRetry(r,e,t=fetch){try{return await t(r,{headers:e})}catch(o){if(o instanceof TypeError)return e?fetchWithCorsRetry(r,void 0,t):void 0;throw o}}async function tryMetadataDiscovery(r,e,t=fetch){const o={"MCP-Protocol-Version":e};return await fetchWithCorsRetry(r,o,t)}async function discoverMetadataWithFallback(r,e,t,o){var a,i;const s=new URL(r),c=null!==(a=null==o?void 0:o.protocolVersion)&&void 0!==a?a:n.LATEST_PROTOCOL_VERSION;let l;if(null==o?void 0:o.metadataUrl)l=new URL(o.metadataUrl);else{const r=function buildWellKnownPath(r,e="",t={}){return e.endsWith("/")&&(e=e.slice(0,-1)),t.prependPathname?`${e}/.well-known/${r}`:`/.well-known/${r}${e}`}(e,s.pathname);l=new URL(r,null!==(i=null==o?void 0:o.metadataServerUrl)&&void 0!==i?i:s),l.search=s.search}let p=await tryMetadataDiscovery(l,c,t);if(!(null==o?void 0:o.metadataUrl)&&function shouldAttemptFallback(r,e){return!r||404===r.status&&"/"!==e}(p,s.pathname)){const r=new URL(`/.well-known/${e}`,s);p=await tryMetadataDiscovery(r,c,t)}return p}}};
|
package/dist/814.codebuddy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
exports.id=814,exports.ids=[814],exports.modules={8147:(t,r,e)=>{"use strict";const s=e(16928),n=e(54080),o=e(50078),i=e(34489),c="win32"===process.platform,a=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function parseNonShell(t){if(!c)return t;const r=function detectShebang(t){t.file=n(t);const r=t.file&&i(t.file);return r?(t.args.unshift(t.file),t.command=r,n(t)):t.file}(t),e=!a.test(r);if(t.options.forceShell||e){const e=l.test(r);t.command=s.normalize(t.command),t.command=o.command(t.command),t.args=t.args.map((t=>o.argument(t,e)));const n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}t.exports=function parse(t,r,e){r&&!Array.isArray(r)&&(e=r,r=null);const s={command:t,args:r=r?r.slice(0):[],options:e=Object.assign({},e),file:void 0,original:{command:t,args:r}};return e.shell?s:parseNonShell(s)}},14155:(t,r,e)=>{t.exports=isexe,isexe.sync=function sync(t,r){return checkStat(s.statSync(t),r)};var s=e(79896);function isexe(t,r,e){s.stat(t,(function(t,s){e(t,!t&&checkStat(s,r))}))}function checkStat(t,r){return t.isFile()&&function checkMode(t,r){var e=t.mode,s=t.uid,n=t.gid,o=void 0!==r.uid?r.uid:process.getuid&&process.getuid(),i=void 0!==r.gid?r.gid:process.getgid&&process.getgid(),c=parseInt("100",8),a=parseInt("010",8),l=parseInt("001",8),u=c|a;return e&l||e&a&&n===i||e&c&&s===o||e&u&&0===o}(t,r)}},24326:(t,r,e)=>{const s="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,n=e(16928),o=s?";":":",i=e(79882),getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),getPathInfo=(t,r)=>{const e=r.colon||o,n=t.match(/\//)||s&&t.match(/\\/)?[""]:[...s?[process.cwd()]:[],...(r.path||process.env.PATH||"").split(e)],i=s?r.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",c=s?i.split(e):[""];return s&&-1!==t.indexOf(".")&&""!==c[0]&&c.unshift(""),{pathEnv:n,pathExt:c,pathExtExe:i}},which=(t,r,e)=>{"function"==typeof r&&(e=r,r={}),r||(r={});const{pathEnv:s,pathExt:o,pathExtExe:c}=getPathInfo(t,r),a=[],step=e=>new Promise(((o,i)=>{if(e===s.length)return r.all&&a.length?o(a):i(getNotFoundError(t));const c=s[e],l=/^".*"$/.test(c)?c.slice(1,-1):c,u=n.join(l,t),p=!l&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;o(subStep(p,e,0))})),subStep=(t,e,s)=>new Promise(((n,l)=>{if(s===o.length)return n(step(e+1));const u=o[s];i(t+u,{pathExt:c},((o,i)=>{if(!o&&i){if(!r.all)return n(t+u);a.push(t+u)}return n(subStep(t,e,s+1))}))}));return e?step(0).then((t=>e(null,t)),e):step(0)};t.exports=which,which.sync=(t,r)=>{r=r||{};const{pathEnv:e,pathExt:s,pathExtExe:o}=getPathInfo(t,r),c=[];for(let a=0;a<e.length;a++){const l=e[a],u=/^".*"$/.test(l)?l.slice(1,-1):l,p=n.join(u,t),d=!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p;for(let t=0;t<s.length;t++){const e=d+s[t];try{if(i.sync(e,{pathExt:o})){if(!r.all)return e;c.push(e)}}catch(t){}}}if(r.all&&c.length)return c;if(r.nothrow)return null;throw getNotFoundError(t)}},34489:(t,r,e)=>{"use strict";const s=e(79896),n=e(50230);t.exports=function readShebang(t){const r=Buffer.alloc(150);let e;try{e=s.openSync(t,"r"),s.readSync(e,r,0,150,0),s.closeSync(e)}catch(t){}return n(r.toString())}},47814:(t,r,e)=>{"use strict";e.r(r),e.d(r,{DEFAULT_INHERITED_ENV_VARS:()=>c,StdioClientTransport:()=>StdioClientTransport,getDefaultEnvironment:()=>getDefaultEnvironment});var s=e(91092),n=e(1708),o=e(57075),i=e(99453);class ReadBuffer{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;const t=this._buffer.indexOf("\n");if(-1===t)return null;const r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),function deserializeMessage(t){return i.JSONRPCMessageSchema.parse(JSON.parse(t))}(r)}clear(){this._buffer=void 0}}const c="win32"===n.platform?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function getDefaultEnvironment(){const t={};for(const r of c){const e=n.env[r];void 0!==e&&(e.startsWith("()")||(t[r]=e))}return t}class StdioClientTransport{constructor(t){this._abortController=new AbortController,this._readBuffer=new ReadBuffer,this._stderrStream=null,this._serverParams=t,"pipe"!==t.stderr&&"overlapped"!==t.stderr||(this._stderrStream=new o.PassThrough)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise(((t,r)=>{var e,o,i,c,a;this._process=s(this._serverParams.command,null!==(e=this._serverParams.args)&&void 0!==e?e:[],{env:{...getDefaultEnvironment(),...this._serverParams.env},stdio:["pipe","pipe",null!==(o=this._serverParams.stderr)&&void 0!==o?o:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:"win32"===n.platform&&"type"in n,cwd:this._serverParams.cwd}),this._process.on("error",(t=>{var e,s;"AbortError"!==t.name?(r(t),null===(s=this.onerror)||void 0===s||s.call(this,t)):null===(e=this.onclose)||void 0===e||e.call(this)})),this._process.on("spawn",(()=>{t()})),this._process.on("close",(t=>{var r;this._process=void 0,null===(r=this.onclose)||void 0===r||r.call(this)})),null===(i=this._process.stdin)||void 0===i||i.on("error",(t=>{var r;null===(r=this.onerror)||void 0===r||r.call(this,t)})),null===(c=this._process.stdout)||void 0===c||c.on("data",(t=>{this._readBuffer.append(t),this.processReadBuffer()})),null===(a=this._process.stdout)||void 0===a||a.on("error",(t=>{var r;null===(r=this.onerror)||void 0===r||r.call(this,t)})),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)}))}get stderr(){var t,r;return this._stderrStream?this._stderrStream:null!==(r=null===(t=this._process)||void 0===t?void 0:t.stderr)&&void 0!==r?r:null}get pid(){var t,r;return null!==(r=null===(t=this._process)||void 0===t?void 0:t.pid)&&void 0!==r?r:null}processReadBuffer(){for(var t,r;;)try{const r=this._readBuffer.readMessage();if(null===r)break;null===(t=this.onmessage)||void 0===t||t.call(this,r)}catch(t){null===(r=this.onerror)||void 0===r||r.call(this,t)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(t){return new Promise((r=>{var e;if(!(null===(e=this._process)||void 0===e?void 0:e.stdin))throw new Error("Not connected");const s=function serializeMessage(t){return JSON.stringify(t)+"\n"}(t);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)}))}}},50078:t=>{"use strict";const r=/([()\][%!^"`<>&|;, *?])/g;t.exports.command=function escapeCommand(t){return t=t.replace(r,"^$1")},t.exports.argument=function escapeArgument(t,e){return t=(t=`"${t=(t=(t=`${t}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1")}"`).replace(r,"^$1"),e&&(t=t.replace(r,"^$1")),t}},50230:(t,r,e)=>{"use strict";const s=e(85672);t.exports=(t="")=>{const r=t.match(s);if(!r)return null;const[e,n]=r[0].replace(/#! ?/,"").split(" "),o=e.split("/").pop();return"env"===o?n:n?`${o} ${n}`:o}},54080:(t,r,e)=>{"use strict";const s=e(16928),n=e(24326),o=e(58139);function resolveCommandAttempt(t,r){const e=t.options.env||process.env,i=process.cwd(),c=null!=t.options.cwd,a=c&&void 0!==process.chdir&&!process.chdir.disabled;if(a)try{process.chdir(t.options.cwd)}catch(t){}let l;try{l=n.sync(t.command,{path:e[o({env:e})],pathExt:r?s.delimiter:void 0})}catch(t){}finally{a&&process.chdir(i)}return l&&(l=s.resolve(c?t.options.cwd:"",l)),l}t.exports=function resolveCommand(t){return resolveCommandAttempt(t)||resolveCommandAttempt(t,!0)}},58139:t=>{"use strict";const pathKey=(t={})=>{const r=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(r).reverse().find((t=>"PATH"===t.toUpperCase()))||"Path"};t.exports=pathKey,t.exports.default=pathKey},66095:(t,r,e)=>{t.exports=isexe,isexe.sync=function sync(t,r){return checkStat(s.statSync(t),t,r)};var s=e(79896);function checkStat(t,r,e){return!(!t.isSymbolicLink()&&!t.isFile())&&function checkPathExt(t,r){var e=void 0!==r.pathExt?r.pathExt:process.env.PATHEXT;if(!e)return!0;if(-1!==(e=e.split(";")).indexOf(""))return!0;for(var s=0;s<e.length;s++){var n=e[s].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}(r,e)}function isexe(t,r,e){s.stat(t,(function(s,n){e(s,!s&&checkStat(n,t,r))}))}},79882:(t,r,e)=>{var s;e(79896);function isexe(t,r,e){if("function"==typeof r&&(e=r,r={}),!e){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise((function(e,s){isexe(t,r||{},(function(t,r){t?s(t):e(r)}))}))}s(t,r||{},(function(t,s){t&&("EACCES"===t.code||r&&r.ignoreErrors)&&(t=null,s=!1),e(t,s)}))}s="win32"===process.platform||global.TESTING_WINDOWS?e(66095):e(14155),t.exports=isexe,isexe.sync=function sync(t,r){try{return s.sync(t,r||{})}catch(t){if(r&&r.ignoreErrors||"EACCES"===t.code)return!1;throw t}}},85672:t=>{"use strict";t.exports=/^#!(.*)/},90995:t=>{"use strict";const r="win32"===process.platform;function notFoundError(t,r){return Object.assign(new Error(`${r} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${r} ${t.command}`,path:t.command,spawnargs:t.args})}function verifyENOENT(t,e){return r&&1===t&&!e.file?notFoundError(e.original,"spawn"):null}t.exports={hookChildProcess:function hookChildProcess(t,e){if(!r)return;const s=t.emit;t.emit=function(r,n){if("exit"===r){const r=verifyENOENT(n,e);if(r)return s.call(t,"error",r)}return s.apply(t,arguments)}},verifyENOENT,verifyENOENTSync:function verifyENOENTSync(t,e){return r&&1===t&&!e.file?notFoundError(e.original,"spawnSync"):null},notFoundError}},91092:(t,r,e)=>{"use strict";const s=e(35317),n=e(8147),o=e(90995);function spawn(t,r,e){const i=n(t,r,e),c=s.spawn(i.command,i.args,i.options);return o.hookChildProcess(c,i),c}t.exports=spawn,t.exports.spawn=spawn,t.exports.sync=function spawnSync(t,r,e){const i=n(t,r,e),c=s.spawnSync(i.command,i.args,i.options);return c.error=c.error||o.verifyENOENTSync(c.status,i),c},t.exports._parse=n,t.exports._enoent=o}};
|
|
1
|
+
exports.id=814,exports.ids=[814],exports.modules={8147:(t,r,e)=>{"use strict";const s=e(16928),n=e(54080),o=e(50078),i=e(34489),c="win32"===process.platform,a=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function parseNonShell(t){if(!c)return t;const r=function detectShebang(t){t.file=n(t);const r=t.file&&i(t.file);return r?(t.args.unshift(t.file),t.command=r,n(t)):t.file}(t),e=!a.test(r);if(t.options.forceShell||e){const e=l.test(r);t.command=s.normalize(t.command),t.command=o.command(t.command),t.args=t.args.map((t=>o.argument(t,e)));const n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}t.exports=function parse(t,r,e){r&&!Array.isArray(r)&&(e=r,r=null);const s={command:t,args:r=r?r.slice(0):[],options:e=Object.assign({},e),file:void 0,original:{command:t,args:r}};return e.shell?s:parseNonShell(s)}},14155:(t,r,e)=>{t.exports=isexe,isexe.sync=function sync(t,r){return checkStat(s.statSync(t),r)};var s=e(79896);function isexe(t,r,e){s.stat(t,(function(t,s){e(t,!t&&checkStat(s,r))}))}function checkStat(t,r){return t.isFile()&&function checkMode(t,r){var e=t.mode,s=t.uid,n=t.gid,o=void 0!==r.uid?r.uid:process.getuid&&process.getuid(),i=void 0!==r.gid?r.gid:process.getgid&&process.getgid(),c=parseInt("100",8),a=parseInt("010",8),l=parseInt("001",8),u=c|a;return e&l||e&a&&n===i||e&c&&s===o||e&u&&0===o}(t,r)}},24326:(t,r,e)=>{const s="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,n=e(16928),o=s?";":":",i=e(79882),getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),getPathInfo=(t,r)=>{const e=r.colon||o,n=t.match(/\//)||s&&t.match(/\\/)?[""]:[...s?[process.cwd()]:[],...(r.path||process.env.PATH||"").split(e)],i=s?r.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",c=s?i.split(e):[""];return s&&-1!==t.indexOf(".")&&""!==c[0]&&c.unshift(""),{pathEnv:n,pathExt:c,pathExtExe:i}},which=(t,r,e)=>{"function"==typeof r&&(e=r,r={}),r||(r={});const{pathEnv:s,pathExt:o,pathExtExe:c}=getPathInfo(t,r),a=[],step=e=>new Promise(((o,i)=>{if(e===s.length)return r.all&&a.length?o(a):i(getNotFoundError(t));const c=s[e],l=/^".*"$/.test(c)?c.slice(1,-1):c,u=n.join(l,t),p=!l&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;o(subStep(p,e,0))})),subStep=(t,e,s)=>new Promise(((n,l)=>{if(s===o.length)return n(step(e+1));const u=o[s];i(t+u,{pathExt:c},((o,i)=>{if(!o&&i){if(!r.all)return n(t+u);a.push(t+u)}return n(subStep(t,e,s+1))}))}));return e?step(0).then((t=>e(null,t)),e):step(0)};t.exports=which,which.sync=(t,r)=>{r=r||{};const{pathEnv:e,pathExt:s,pathExtExe:o}=getPathInfo(t,r),c=[];for(let a=0;a<e.length;a++){const l=e[a],u=/^".*"$/.test(l)?l.slice(1,-1):l,p=n.join(u,t),d=!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p;for(let t=0;t<s.length;t++){const e=d+s[t];try{if(i.sync(e,{pathExt:o})){if(!r.all)return e;c.push(e)}}catch(t){}}}if(r.all&&c.length)return c;if(r.nothrow)return null;throw getNotFoundError(t)}},34489:(t,r,e)=>{"use strict";const s=e(79896),n=e(50230);t.exports=function readShebang(t){const r=Buffer.alloc(150);let e;try{e=s.openSync(t,"r"),s.readSync(e,r,0,150,0),s.closeSync(e)}catch(t){}return n(r.toString())}},47814:(t,r,e)=>{"use strict";e.r(r),e.d(r,{DEFAULT_INHERITED_ENV_VARS:()=>c,StdioClientTransport:()=>StdioClientTransport,getDefaultEnvironment:()=>getDefaultEnvironment});var s=e(91092),n=e(1708),o=e(57075),i=e(76889);class ReadBuffer{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;const t=this._buffer.indexOf("\n");if(-1===t)return null;const r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),function deserializeMessage(t){return i.JSONRPCMessageSchema.parse(JSON.parse(t))}(r)}clear(){this._buffer=void 0}}const c="win32"===n.platform?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function getDefaultEnvironment(){const t={};for(const r of c){const e=n.env[r];void 0!==e&&(e.startsWith("()")||(t[r]=e))}return t}class StdioClientTransport{constructor(t){this._abortController=new AbortController,this._readBuffer=new ReadBuffer,this._stderrStream=null,this._serverParams=t,"pipe"!==t.stderr&&"overlapped"!==t.stderr||(this._stderrStream=new o.PassThrough)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise(((t,r)=>{var e,o,i,c,a;this._process=s(this._serverParams.command,null!==(e=this._serverParams.args)&&void 0!==e?e:[],{env:{...getDefaultEnvironment(),...this._serverParams.env},stdio:["pipe","pipe",null!==(o=this._serverParams.stderr)&&void 0!==o?o:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:"win32"===n.platform&&"type"in n,cwd:this._serverParams.cwd}),this._process.on("error",(t=>{var e,s;"AbortError"!==t.name?(r(t),null===(s=this.onerror)||void 0===s||s.call(this,t)):null===(e=this.onclose)||void 0===e||e.call(this)})),this._process.on("spawn",(()=>{t()})),this._process.on("close",(t=>{var r;this._process=void 0,null===(r=this.onclose)||void 0===r||r.call(this)})),null===(i=this._process.stdin)||void 0===i||i.on("error",(t=>{var r;null===(r=this.onerror)||void 0===r||r.call(this,t)})),null===(c=this._process.stdout)||void 0===c||c.on("data",(t=>{this._readBuffer.append(t),this.processReadBuffer()})),null===(a=this._process.stdout)||void 0===a||a.on("error",(t=>{var r;null===(r=this.onerror)||void 0===r||r.call(this,t)})),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)}))}get stderr(){var t,r;return this._stderrStream?this._stderrStream:null!==(r=null===(t=this._process)||void 0===t?void 0:t.stderr)&&void 0!==r?r:null}get pid(){var t,r;return null!==(r=null===(t=this._process)||void 0===t?void 0:t.pid)&&void 0!==r?r:null}processReadBuffer(){for(var t,r;;)try{const r=this._readBuffer.readMessage();if(null===r)break;null===(t=this.onmessage)||void 0===t||t.call(this,r)}catch(t){null===(r=this.onerror)||void 0===r||r.call(this,t)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(t){return new Promise((r=>{var e;if(!(null===(e=this._process)||void 0===e?void 0:e.stdin))throw new Error("Not connected");const s=function serializeMessage(t){return JSON.stringify(t)+"\n"}(t);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)}))}}},50078:t=>{"use strict";const r=/([()\][%!^"`<>&|;, *?])/g;t.exports.command=function escapeCommand(t){return t=t.replace(r,"^$1")},t.exports.argument=function escapeArgument(t,e){return t=(t=`"${t=(t=(t=`${t}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1")}"`).replace(r,"^$1"),e&&(t=t.replace(r,"^$1")),t}},50230:(t,r,e)=>{"use strict";const s=e(85672);t.exports=(t="")=>{const r=t.match(s);if(!r)return null;const[e,n]=r[0].replace(/#! ?/,"").split(" "),o=e.split("/").pop();return"env"===o?n:n?`${o} ${n}`:o}},54080:(t,r,e)=>{"use strict";const s=e(16928),n=e(24326),o=e(58139);function resolveCommandAttempt(t,r){const e=t.options.env||process.env,i=process.cwd(),c=null!=t.options.cwd,a=c&&void 0!==process.chdir&&!process.chdir.disabled;if(a)try{process.chdir(t.options.cwd)}catch(t){}let l;try{l=n.sync(t.command,{path:e[o({env:e})],pathExt:r?s.delimiter:void 0})}catch(t){}finally{a&&process.chdir(i)}return l&&(l=s.resolve(c?t.options.cwd:"",l)),l}t.exports=function resolveCommand(t){return resolveCommandAttempt(t)||resolveCommandAttempt(t,!0)}},58139:t=>{"use strict";const pathKey=(t={})=>{const r=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(r).reverse().find((t=>"PATH"===t.toUpperCase()))||"Path"};t.exports=pathKey,t.exports.default=pathKey},66095:(t,r,e)=>{t.exports=isexe,isexe.sync=function sync(t,r){return checkStat(s.statSync(t),t,r)};var s=e(79896);function checkStat(t,r,e){return!(!t.isSymbolicLink()&&!t.isFile())&&function checkPathExt(t,r){var e=void 0!==r.pathExt?r.pathExt:process.env.PATHEXT;if(!e)return!0;if(-1!==(e=e.split(";")).indexOf(""))return!0;for(var s=0;s<e.length;s++){var n=e[s].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}(r,e)}function isexe(t,r,e){s.stat(t,(function(s,n){e(s,!s&&checkStat(n,t,r))}))}},79882:(t,r,e)=>{var s;e(79896);function isexe(t,r,e){if("function"==typeof r&&(e=r,r={}),!e){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise((function(e,s){isexe(t,r||{},(function(t,r){t?s(t):e(r)}))}))}s(t,r||{},(function(t,s){t&&("EACCES"===t.code||r&&r.ignoreErrors)&&(t=null,s=!1),e(t,s)}))}s="win32"===process.platform||global.TESTING_WINDOWS?e(66095):e(14155),t.exports=isexe,isexe.sync=function sync(t,r){try{return s.sync(t,r||{})}catch(t){if(r&&r.ignoreErrors||"EACCES"===t.code)return!1;throw t}}},85672:t=>{"use strict";t.exports=/^#!(.*)/},90995:t=>{"use strict";const r="win32"===process.platform;function notFoundError(t,r){return Object.assign(new Error(`${r} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${r} ${t.command}`,path:t.command,spawnargs:t.args})}function verifyENOENT(t,e){return r&&1===t&&!e.file?notFoundError(e.original,"spawn"):null}t.exports={hookChildProcess:function hookChildProcess(t,e){if(!r)return;const s=t.emit;t.emit=function(r,n){if("exit"===r){const r=verifyENOENT(n,e);if(r)return s.call(t,"error",r)}return s.apply(t,arguments)}},verifyENOENT,verifyENOENTSync:function verifyENOENTSync(t,e){return r&&1===t&&!e.file?notFoundError(e.original,"spawnSync"):null},notFoundError}},91092:(t,r,e)=>{"use strict";const s=e(35317),n=e(8147),o=e(90995);function spawn(t,r,e){const i=n(t,r,e),c=s.spawn(i.command,i.args,i.options);return o.hookChildProcess(c,i),c}t.exports=spawn,t.exports.spawn=spawn,t.exports.sync=function spawnSync(t,r,e){const i=n(t,r,e),c=s.spawnSync(i.command,i.args,i.options);return c.error=c.error||o.verifyENOENTSync(c.status,i),c},t.exports._parse=n,t.exports._enoent=o}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.id=889,exports.ids=[889],exports.modules={76889:(e,t,o)=>{o.r(t),o.d(t,{AudioContentSchema:()=>se,BaseMetadataSchema:()=>y,BlobResourceContentsSchema:()=>A,BooleanSchemaSchema:()=>Ne,CallToolRequestSchema:()=>be,CallToolResultSchema:()=>de,CancelledNotificationSchema:()=>f,ClientCapabilitiesSchema:()=>q,ClientNotificationSchema:()=>Fe,ClientRequestSchema:()=>De,ClientResultSchema:()=>Ge,CompatibilityCallToolResultSchema:()=>Se,CompleteRequestSchema:()=>we,CompleteResultSchema:()=>Ae,ContentBlockSchema:()=>ze,CreateMessageRequestSchema:()=>Te,CreateMessageResultSchema:()=>qe,CursorSchema:()=>l,DEFAULT_NEGOTIATED_PROTOCOL_VERSION:()=>s,ElicitRequestSchema:()=>ve,ElicitResultSchema:()=>Ie,EmbeddedResourceSchema:()=>ie,EmptyResultSchema:()=>P,EnumSchemaSchema:()=>Oe,ErrorCode:()=>x,GetPromptRequestSchema:()=>oe,GetPromptResultSchema:()=>ce,ImageContentSchema:()=>ne,ImplementationSchema:()=>T,InitializeRequestSchema:()=>N,InitializeResultSchema:()=>L,InitializedNotificationSchema:()=>O,JSONRPCErrorSchema:()=>j,JSONRPCMessageSchema:()=>C,JSONRPCNotificationSchema:()=>b,JSONRPCRequestSchema:()=>S,JSONRPCResponseSchema:()=>R,JSONRPC_VERSION:()=>r,LATEST_PROTOCOL_VERSION:()=>n,ListPromptsRequestSchema:()=>ee,ListPromptsResultSchema:()=>te,ListResourceTemplatesRequestSchema:()=>D,ListResourceTemplatesResultSchema:()=>F,ListResourcesRequestSchema:()=>U,ListResourcesResultSchema:()=>B,ListRootsRequestSchema:()=>He,ListRootsResultSchema:()=>Ue,ListToolsRequestSchema:()=>ue,ListToolsResultSchema:()=>ge,LoggingLevelSchema:()=>xe,LoggingMessageNotificationSchema:()=>Ce,McpError:()=>McpError,ModelHintSchema:()=>Pe,ModelPreferencesSchema:()=>fe,NotificationSchema:()=>u,NumberSchemaSchema:()=>Le,PaginatedRequestSchema:()=>M,PaginatedResultSchema:()=>k,PingRequestSchema:()=>_,PrimitiveSchemaDefinitionSchema:()=>_e,ProgressNotificationSchema:()=>I,ProgressSchema:()=>v,ProgressTokenSchema:()=>z,PromptArgumentSchema:()=>Y,PromptListChangedNotificationSchema:()=>me,PromptMessageSchema:()=>le,PromptReferenceSchema:()=>Je,PromptSchema:()=>Z,ReadResourceRequestSchema:()=>G,ReadResourceResultSchema:()=>W,RequestIdSchema:()=>d,RequestSchema:()=>p,ResourceContentsSchema:()=>J,ResourceLinkSchema:()=>re,ResourceListChangedNotificationSchema:()=>$,ResourceReferenceSchema:()=>ke,ResourceSchema:()=>V,ResourceTemplateReferenceSchema:()=>Me,ResourceTemplateSchema:()=>H,ResourceUpdatedNotificationSchema:()=>X,ResultSchema:()=>g,RootSchema:()=>Ve,RootsListChangedNotificationSchema:()=>Be,SUPPORTED_PROTOCOL_VERSIONS:()=>i,SamplingMessageSchema:()=>ye,ServerCapabilitiesSchema:()=>E,ServerNotificationSchema:()=>$e,ServerRequestSchema:()=>We,ServerResultSchema:()=>Ke,SetLevelRequestSchema:()=>je,StringSchemaSchema:()=>Ee,SubscribeRequestSchema:()=>K,TextContentSchema:()=>ae,TextResourceContentsSchema:()=>w,ToolAnnotationsSchema:()=>pe,ToolListChangedNotificationSchema:()=>Re,ToolSchema:()=>he,UnsubscribeRequestSchema:()=>Q,isInitializeRequest:()=>isInitializeRequest,isInitializedNotification:()=>isInitializedNotification,isJSONRPCError:()=>isJSONRPCError,isJSONRPCNotification:()=>isJSONRPCNotification,isJSONRPCRequest:()=>isJSONRPCRequest,isJSONRPCResponse:()=>isJSONRPCResponse});var a=o(7578);const n="2025-06-18",s="2025-03-26",i=[n,"2025-03-26","2024-11-05","2024-10-07"],r="2.0",z=a.z.union([a.z.string(),a.z.number().int()]),l=a.z.string(),c=a.z.object({progressToken:a.z.optional(z)}).passthrough(),m=a.z.object({_meta:a.z.optional(c)}).passthrough(),p=a.z.object({method:a.z.string(),params:a.z.optional(m)}),h=a.z.object({_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),u=a.z.object({method:a.z.string(),params:a.z.optional(h)}),g=a.z.object({_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),d=a.z.union([a.z.string(),a.z.number().int()]),S=a.z.object({jsonrpc:a.z.literal(r),id:d}).merge(p).strict(),isJSONRPCRequest=e=>S.safeParse(e).success,b=a.z.object({jsonrpc:a.z.literal(r)}).merge(u).strict(),isJSONRPCNotification=e=>b.safeParse(e).success,R=a.z.object({jsonrpc:a.z.literal(r),id:d,result:g}).strict(),isJSONRPCResponse=e=>R.safeParse(e).success;var x;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(x||(x={}));const j=a.z.object({jsonrpc:a.z.literal(r),id:d,error:a.z.object({code:a.z.number().int(),message:a.z.string(),data:a.z.optional(a.z.unknown())})}).strict(),isJSONRPCError=e=>j.safeParse(e).success,C=a.z.union([S,b,R,j]),P=g.strict(),f=u.extend({method:a.z.literal("notifications/cancelled"),params:h.extend({requestId:d,reason:a.z.string().optional()})}),y=a.z.object({name:a.z.string(),title:a.z.optional(a.z.string())}).passthrough(),T=y.extend({version:a.z.string()}),q=a.z.object({experimental:a.z.optional(a.z.object({}).passthrough()),sampling:a.z.optional(a.z.object({}).passthrough()),elicitation:a.z.optional(a.z.object({}).passthrough()),roots:a.z.optional(a.z.object({listChanged:a.z.optional(a.z.boolean())}).passthrough())}).passthrough(),N=p.extend({method:a.z.literal("initialize"),params:m.extend({protocolVersion:a.z.string(),capabilities:q,clientInfo:T})}),isInitializeRequest=e=>N.safeParse(e).success,E=a.z.object({experimental:a.z.optional(a.z.object({}).passthrough()),logging:a.z.optional(a.z.object({}).passthrough()),completions:a.z.optional(a.z.object({}).passthrough()),prompts:a.z.optional(a.z.object({listChanged:a.z.optional(a.z.boolean())}).passthrough()),resources:a.z.optional(a.z.object({subscribe:a.z.optional(a.z.boolean()),listChanged:a.z.optional(a.z.boolean())}).passthrough()),tools:a.z.optional(a.z.object({listChanged:a.z.optional(a.z.boolean())}).passthrough())}).passthrough(),L=g.extend({protocolVersion:a.z.string(),capabilities:E,serverInfo:T,instructions:a.z.optional(a.z.string())}),O=u.extend({method:a.z.literal("notifications/initialized")}),isInitializedNotification=e=>O.safeParse(e).success,_=p.extend({method:a.z.literal("ping")}),v=a.z.object({progress:a.z.number(),total:a.z.optional(a.z.number()),message:a.z.optional(a.z.string())}).passthrough(),I=u.extend({method:a.z.literal("notifications/progress"),params:h.merge(v).extend({progressToken:z})}),M=p.extend({params:m.extend({cursor:a.z.optional(l)}).optional()}),k=g.extend({nextCursor:a.z.optional(l)}),J=a.z.object({uri:a.z.string(),mimeType:a.z.optional(a.z.string()),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),w=J.extend({text:a.z.string()}),A=J.extend({blob:a.z.string().base64()}),V=y.extend({uri:a.z.string(),description:a.z.optional(a.z.string()),mimeType:a.z.optional(a.z.string()),_meta:a.z.optional(a.z.object({}).passthrough())}),H=y.extend({uriTemplate:a.z.string(),description:a.z.optional(a.z.string()),mimeType:a.z.optional(a.z.string()),_meta:a.z.optional(a.z.object({}).passthrough())}),U=M.extend({method:a.z.literal("resources/list")}),B=k.extend({resources:a.z.array(V)}),D=M.extend({method:a.z.literal("resources/templates/list")}),F=k.extend({resourceTemplates:a.z.array(H)}),G=p.extend({method:a.z.literal("resources/read"),params:m.extend({uri:a.z.string()})}),W=g.extend({contents:a.z.array(a.z.union([w,A]))}),$=u.extend({method:a.z.literal("notifications/resources/list_changed")}),K=p.extend({method:a.z.literal("resources/subscribe"),params:m.extend({uri:a.z.string()})}),Q=p.extend({method:a.z.literal("resources/unsubscribe"),params:m.extend({uri:a.z.string()})}),X=u.extend({method:a.z.literal("notifications/resources/updated"),params:h.extend({uri:a.z.string()})}),Y=a.z.object({name:a.z.string(),description:a.z.optional(a.z.string()),required:a.z.optional(a.z.boolean())}).passthrough(),Z=y.extend({description:a.z.optional(a.z.string()),arguments:a.z.optional(a.z.array(Y)),_meta:a.z.optional(a.z.object({}).passthrough())}),ee=M.extend({method:a.z.literal("prompts/list")}),te=k.extend({prompts:a.z.array(Z)}),oe=p.extend({method:a.z.literal("prompts/get"),params:m.extend({name:a.z.string(),arguments:a.z.optional(a.z.record(a.z.string()))})}),ae=a.z.object({type:a.z.literal("text"),text:a.z.string(),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),ne=a.z.object({type:a.z.literal("image"),data:a.z.string().base64(),mimeType:a.z.string(),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),se=a.z.object({type:a.z.literal("audio"),data:a.z.string().base64(),mimeType:a.z.string(),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),ie=a.z.object({type:a.z.literal("resource"),resource:a.z.union([w,A]),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),re=V.extend({type:a.z.literal("resource_link")}),ze=a.z.union([ae,ne,se,re,ie]),le=a.z.object({role:a.z.enum(["user","assistant"]),content:ze}).passthrough(),ce=g.extend({description:a.z.optional(a.z.string()),messages:a.z.array(le)}),me=u.extend({method:a.z.literal("notifications/prompts/list_changed")}),pe=a.z.object({title:a.z.optional(a.z.string()),readOnlyHint:a.z.optional(a.z.boolean()),destructiveHint:a.z.optional(a.z.boolean()),idempotentHint:a.z.optional(a.z.boolean()),openWorldHint:a.z.optional(a.z.boolean())}).passthrough(),he=y.extend({description:a.z.optional(a.z.string()),inputSchema:a.z.object({type:a.z.literal("object"),properties:a.z.optional(a.z.object({}).passthrough()),required:a.z.optional(a.z.array(a.z.string()))}).passthrough(),outputSchema:a.z.optional(a.z.object({type:a.z.literal("object"),properties:a.z.optional(a.z.object({}).passthrough()),required:a.z.optional(a.z.array(a.z.string()))}).passthrough()),annotations:a.z.optional(pe),_meta:a.z.optional(a.z.object({}).passthrough())}),ue=M.extend({method:a.z.literal("tools/list")}),ge=k.extend({tools:a.z.array(he)}),de=g.extend({content:a.z.array(ze).default([]),structuredContent:a.z.object({}).passthrough().optional(),isError:a.z.optional(a.z.boolean())}),Se=de.or(g.extend({toolResult:a.z.unknown()})),be=p.extend({method:a.z.literal("tools/call"),params:m.extend({name:a.z.string(),arguments:a.z.optional(a.z.record(a.z.unknown()))})}),Re=u.extend({method:a.z.literal("notifications/tools/list_changed")}),xe=a.z.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),je=p.extend({method:a.z.literal("logging/setLevel"),params:m.extend({level:xe})}),Ce=u.extend({method:a.z.literal("notifications/message"),params:h.extend({level:xe,logger:a.z.optional(a.z.string()),data:a.z.unknown()})}),Pe=a.z.object({name:a.z.string().optional()}).passthrough(),fe=a.z.object({hints:a.z.optional(a.z.array(Pe)),costPriority:a.z.optional(a.z.number().min(0).max(1)),speedPriority:a.z.optional(a.z.number().min(0).max(1)),intelligencePriority:a.z.optional(a.z.number().min(0).max(1))}).passthrough(),ye=a.z.object({role:a.z.enum(["user","assistant"]),content:a.z.union([ae,ne,se])}).passthrough(),Te=p.extend({method:a.z.literal("sampling/createMessage"),params:m.extend({messages:a.z.array(ye),systemPrompt:a.z.optional(a.z.string()),includeContext:a.z.optional(a.z.enum(["none","thisServer","allServers"])),temperature:a.z.optional(a.z.number()),maxTokens:a.z.number().int(),stopSequences:a.z.optional(a.z.array(a.z.string())),metadata:a.z.optional(a.z.object({}).passthrough()),modelPreferences:a.z.optional(fe)})}),qe=g.extend({model:a.z.string(),stopReason:a.z.optional(a.z.enum(["endTurn","stopSequence","maxTokens"]).or(a.z.string())),role:a.z.enum(["user","assistant"]),content:a.z.discriminatedUnion("type",[ae,ne,se])}),Ne=a.z.object({type:a.z.literal("boolean"),title:a.z.optional(a.z.string()),description:a.z.optional(a.z.string()),default:a.z.optional(a.z.boolean())}).passthrough(),Ee=a.z.object({type:a.z.literal("string"),title:a.z.optional(a.z.string()),description:a.z.optional(a.z.string()),minLength:a.z.optional(a.z.number()),maxLength:a.z.optional(a.z.number()),format:a.z.optional(a.z.enum(["email","uri","date","date-time"]))}).passthrough(),Le=a.z.object({type:a.z.enum(["number","integer"]),title:a.z.optional(a.z.string()),description:a.z.optional(a.z.string()),minimum:a.z.optional(a.z.number()),maximum:a.z.optional(a.z.number())}).passthrough(),Oe=a.z.object({type:a.z.literal("string"),title:a.z.optional(a.z.string()),description:a.z.optional(a.z.string()),enum:a.z.array(a.z.string()),enumNames:a.z.optional(a.z.array(a.z.string()))}).passthrough(),_e=a.z.union([Ne,Ee,Le,Oe]),ve=p.extend({method:a.z.literal("elicitation/create"),params:m.extend({message:a.z.string(),requestedSchema:a.z.object({type:a.z.literal("object"),properties:a.z.record(a.z.string(),_e),required:a.z.optional(a.z.array(a.z.string()))}).passthrough()})}),Ie=g.extend({action:a.z.enum(["accept","decline","cancel"]),content:a.z.optional(a.z.record(a.z.string(),a.z.unknown()))}),Me=a.z.object({type:a.z.literal("ref/resource"),uri:a.z.string()}).passthrough(),ke=Me,Je=a.z.object({type:a.z.literal("ref/prompt"),name:a.z.string()}).passthrough(),we=p.extend({method:a.z.literal("completion/complete"),params:m.extend({ref:a.z.union([Je,Me]),argument:a.z.object({name:a.z.string(),value:a.z.string()}).passthrough(),context:a.z.optional(a.z.object({arguments:a.z.optional(a.z.record(a.z.string(),a.z.string()))}))})}),Ae=g.extend({completion:a.z.object({values:a.z.array(a.z.string()).max(100),total:a.z.optional(a.z.number().int()),hasMore:a.z.optional(a.z.boolean())}).passthrough()}),Ve=a.z.object({uri:a.z.string().startsWith("file://"),name:a.z.optional(a.z.string()),_meta:a.z.optional(a.z.object({}).passthrough())}).passthrough(),He=p.extend({method:a.z.literal("roots/list")}),Ue=g.extend({roots:a.z.array(Ve)}),Be=u.extend({method:a.z.literal("notifications/roots/list_changed")}),De=a.z.union([_,N,we,je,oe,ee,U,D,G,K,Q,be,ue]),Fe=a.z.union([f,I,O,Be]),Ge=a.z.union([P,qe,Ie,Ue]),We=a.z.union([_,Te,ve,He]),$e=a.z.union([f,I,Ce,X,$,Re,me]),Ke=a.z.union([P,L,Ae,ce,te,B,F,W,de,ge]);class McpError extends Error{constructor(e,t,o){super(`MCP error ${e}: ${t}`),this.code=e,this.data=o,this.name="McpError"}}}};
|