@eclipse-glsp-examples/workflow-server-bundled-web 2.8.0 → 2.9.0-next.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-glsp-examples/workflow-server-bundled-web",
3
- "version": "2.8.0",
3
+ "version": "2.9.0-next.1",
4
4
  "description": "GLSP web server for the workflow example (bundled)",
5
5
  "keywords": [
6
6
  "eclipse",
@@ -179,7 +179,7 @@ data:
179
179
  `;return f&&(y+=`id: ${f}
180
180
  `),y+=`data: ${JSON.stringify(u)}
181
181
 
182
- `,i.enqueue(c.encode(y)),!0}catch(y){return(b=this.onerror)==null||b.call(this,y),!1}}handleUnsupportedRequest(){var i;return(i=this.onerror)==null||i.call(this,new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(i,c){var u,f,b,y,w,T,A,C,I,R,G;try{let oe=i.headers.get("accept");if(!(oe!=null&&oe.includes("application/json"))||!oe.includes("text/event-stream"))return(u=this.onerror)==null||u.call(this,new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let le=i.headers.get("content-type");if(!le||!le.includes("application/json"))return(f=this.onerror)==null||f.call(this,new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let Te={headers:Object.fromEntries(i.headers.entries()),url:new URL(i.url)},Ve;if((c==null?void 0:c.parsedBody)!==void 0)Ve=c.parsedBody;else try{Ve=await i.json()}catch{return(b=this.onerror)==null||b.call(this,new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let ot;try{Array.isArray(Ve)?ot=Ve.map(Ko=>np.JSONRPCMessageSchema.parse(Ko)):ot=[np.JSONRPCMessageSchema.parse(Ve)]}catch{return(y=this.onerror)==null||y.call(this,new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let wt=ot.some(np.isInitializeRequest);if(wt){if(this._initialized&&this.sessionId!==void 0)return(w=this.onerror)==null||w.call(this,new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(ot.length>1)return(T=this.onerror)==null||T.call(this,new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=(A=this.sessionIdGenerator)==null?void 0:A.call(this),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!wt){let Ko=this.validateSession(i);if(Ko)return Ko;let iu=this.validateProtocolVersion(i);if(iu)return iu}if(!ot.some(np.isJSONRPCRequest)){for(let Ko of ot)(C=this.onmessage)==null||C.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te});return new Response(null,{status:202})}let tt=crypto.randomUUID(),yt=ot.find(Ko=>(0,np.isInitializeRequest)(Ko)),ar=yt?yt.params.protocolVersion:(I=i.headers.get("mcp-protocol-version"))!=null?I:np.DEFAULT_NEGOTIATED_PROTOCOL_VERSION;if(this._enableJsonResponse)return new Promise(Ko=>{var iu;this._streamMapping.set(tt,{resolveJson:Ko,cleanup:n(()=>{this._streamMapping.delete(tt)},"cleanup")});for(let hd of ot)(0,np.isJSONRPCRequest)(hd)&&this._requestToStreamMapping.set(hd.id,tt);for(let hd of ot)(iu=this.onmessage)==null||iu.call(this,hd,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te})});let lo=new TextEncoder,Ei,Oc=new ReadableStream({start:n(Ko=>{Ei=Ko},"start"),cancel:n(()=>{this._streamMapping.delete(tt)},"cancel")}),Qc={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(Qc["mcp-session-id"]=this.sessionId);for(let Ko of ot)(0,np.isJSONRPCRequest)(Ko)&&(this._streamMapping.set(tt,{controller:Ei,encoder:lo,cleanup:n(()=>{this._streamMapping.delete(tt);try{Ei.close()}catch{}},"cleanup")}),this._requestToStreamMapping.set(Ko.id,tt));await this.writePrimingEvent(Ei,lo,tt,ar);for(let Ko of ot){let iu,hd;(0,np.isJSONRPCRequest)(Ko)&&this._eventStore&&ar>="2025-11-25"&&(iu=n(()=>{this.closeSSEStream(Ko.id)},"closeSSEStream"),hd=n(()=>{this.closeStandaloneSSEStream()},"closeStandaloneSSEStream")),(R=this.onmessage)==null||R.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te,closeSSEStream:iu,closeStandaloneSSEStream:hd})}return new Response(Oc,{status:200,headers:Qc})}catch(oe){return(G=this.onerror)==null||G.call(this,oe),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(oe)})}}async handleDeleteRequest(i){var f;let c=this.validateSession(i);if(c)return c;let u=this.validateProtocolVersion(i);return u||(await Promise.resolve((f=this._onsessionclosed)==null?void 0:f.call(this,this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(i){var u,f,b;if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return(u=this.onerror)==null||u.call(this,new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let c=i.headers.get("mcp-session-id");if(!c)return(f=this.onerror)==null||f.call(this,new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(c!==this.sessionId)return(b=this.onerror)==null||b.call(this,new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(i){var u;let c=i.headers.get("mcp-protocol-version");if(c!==null&&!np.SUPPORTED_PROTOCOL_VERSIONS.includes(c))return(u=this.onerror)==null||u.call(this,new Error(`Bad Request: Unsupported protocol version: ${c} (supported versions: ${np.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${c} (supported versions: ${np.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)}async close(){var i;this._streamMapping.forEach(({cleanup:c})=>{c()}),this._streamMapping.clear(),this._requestResponseMap.clear(),(i=this.onclose)==null||i.call(this)}closeSSEStream(i){let c=this._requestToStreamMapping.get(i);if(!c)return;let u=this._streamMapping.get(c);u&&u.cleanup()}closeStandaloneSSEStream(){let i=this._streamMapping.get(this._standaloneSseStreamId);i&&i.cleanup()}async send(i,c){let u=c==null?void 0:c.relatedRequestId;if(((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i))&&(u=i.id),u===void 0){if((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let y;this._eventStore&&(y=await this._eventStore.storeEvent(this._standaloneSseStreamId,i));let w=this._streamMapping.get(this._standaloneSseStreamId);if(w===void 0)return;w.controller&&w.encoder&&this.writeSSEEvent(w.controller,w.encoder,i,y);return}let f=this._requestToStreamMapping.get(u);if(!f)throw new Error(`No connection established for request ID: ${String(u)}`);let b=this._streamMapping.get(f);if(!this._enableJsonResponse&&(b!=null&&b.controller)&&(b!=null&&b.encoder)){let y;this._eventStore&&(y=await this._eventStore.storeEvent(f,i)),this.writeSSEEvent(b.controller,b.encoder,i,y)}if((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i)){this._requestResponseMap.set(u,i);let y=Array.from(this._requestToStreamMapping.entries()).filter(([T,A])=>A===f).map(([T])=>T);if(y.every(T=>this._requestResponseMap.has(T))){if(!b)throw new Error(`No connection established for request ID: ${String(u)}`);if(this._enableJsonResponse&&b.resolveJson){let T={"Content-Type":"application/json"};this.sessionId!==void 0&&(T["mcp-session-id"]=this.sessionId);let A=y.map(C=>this._requestResponseMap.get(C));A.length===1?b.resolveJson(new Response(JSON.stringify(A[0]),{status:200,headers:T})):b.resolveJson(new Response(JSON.stringify(A),{status:200,headers:T}))}else b.cleanup();for(let T of y)this._requestResponseMap.delete(T),this._requestToStreamMapping.delete(T)}}}};n(EYe,"WebStandardStreamableHTTPServerTransport");var SYe=EYe;vye.WebStandardStreamableHTTPServerTransport=SYe});var Vdn=Z((Gpi,T2r)=>{T2r.exports={name:"@eclipse-glsp/server-mcp",version:"2.8.0",description:"Model Context Protocol (MCP) server for the GLSP TypeScript server \u2014 runs on Node, browser, and Fetch-API runtimes",keywords:["eclipse","graphics","diagram","modeling","visualization","glsp","diagram editor","mcp"],homepage:"https://www.eclipse.org/glsp/",bugs:"https://github.com/eclipse-glsp/glsp/issues",repository:{type:"git",url:"https://github.com/eclipse-glsp/glsp-server-node.git"},license:"(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",author:{name:"Eclipse GLSP"},contributors:[{name:"Eclipse GLSP Project",email:"glsp-dev@eclipse.org",url:"https://projects.eclipse.org/projects/ecd.glsp"}],main:"lib/node/index",browser:{"lib/node/index":"./lib/browser/index"},types:"lib/common/index",files:["lib","src","node.js","node.d.ts","browser.js","browser.d.ts","common.js","common.d.ts","!**/*.spec.ts","!**/*.spec.tsx","!**/test/**"],scripts:{build:"tsc -b",clean:"rimraf lib *.tsbuildinfo coverage","generate:index":"glsp generateIndex src/browser src/common src/node -f -s",lint:"eslint --ext .ts,.tsx ./src",prepublishOnly:"pnpm build"},dependencies:{"@eclipse-glsp/server":"workspace:*","@hono/node-server":"^1.19.9","@modelcontextprotocol/sdk":"^1.29.0",zod:"^4.0.0"},peerDependencies:{inversify:"^6.1.3","reflect-metadata":"^0.2.2"},publishConfig:{access:"public"}}});var yye=Z(ib=>{"use strict";var M2r=ib&&ib.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},A2r=ib&&ib.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},OYe=ib&&ib.__param||function(s,i){return function(c,u){i(c,u,s)}};Object.defineProperty(ib,"__esModule",{value:!0});ib.DefaultGLSPMcpServer=ib.GLSPMcpServerFactory=ib.GLSPMcpServer=void 0;var k2r=Vr(),$2r=HQ(),jYe=CA(),wye=cn();ib.GLSPMcpServer=Symbol("GLSPMcpServer");var C2r=3e4,R2r=5e3;ib.GLSPMcpServerFactory=Symbol("GLSPMcpServerFactory");var GB,PYe=(GB=class{constructor(i,c,u){this.mcpServer=i,this.options=c,this.logger=u,this.tools=new Map,this.resources=new Map,this.prompts=new Map;let{tools:f,resources:b,prompts:y}=this;this.registerTool=new Proxy(i.registerTool.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&f.set(A[0],C),C}}),this.registerResource=new Proxy(i.registerResource.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&b.set(A[0],C),C}}),this.registerPrompt=new Proxy(i.registerPrompt.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&y.set(A[0],C),C}})}sendLoggingMessage(...i){return this.mcpServer.sendLoggingMessage(...i)}async connect(...i){await this.mcpServer.connect(...i),this.keepAliveTimer=setInterval(()=>this.ping().catch(u=>{(!(u instanceof jYe.McpError)||u.code!==jYe.ErrorCode.RequestTimeout)&&this.logger.debug("MCP keep-alive ping failed:",u)}),C2r);let c=this.keepAliveTimer.unref;typeof c=="function"&&c.call(this.keepAliveTimer)}isConnected(){return this.mcpServer.isConnected()}async ping(){await this.mcpServer.server.request({method:"ping"},jYe.EmptyResultSchema,{timeout:R2r})}listTools(){return[...this.tools.values()]}hasTool(i){return this.tools.has(i)}listResources(){return[...this.resources.values()]}listPrompts(){return[...this.prompts.values()]}getRawServer(){return this.mcpServer}dispose(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0),this.mcpServer.close()}},n(GB,"DefaultGLSPMcpServer"),GB);ib.DefaultGLSPMcpServer=PYe;ib.DefaultGLSPMcpServer=PYe=M2r([(0,wye.injectable)(),OYe(0,(0,wye.unmanaged)()),OYe(1,(0,wye.unmanaged)()),OYe(2,(0,wye.unmanaged)()),A2r("design:paramtypes",[$2r.McpServer,Object,k2r.Logger])],PYe)});var Sye=Z(_ye=>{"use strict";Object.defineProperty(_ye,"__esModule",{value:!0});_ye.LruEventStore=void 0;var JQ=class JQ{constructor(i=JQ.DEFAULT_LIMIT,c){if(this.events=new Map,i<1)throw new Error(`LruEventStore limit must be >= 1, got ${i}`);this.limit=i,this.logger=c}get size(){return this.events.size}async storeEvent(i,c){let u=`${i}_${Date.now()}_${Math.random().toString(36).substring(2,10)}`;if(this.events.set(u,{streamId:i,message:c}),this.events.size>this.limit){let f=this.events.keys().next().value;f!==void 0&&this.events.delete(f)}return u}async replayEventsAfter(i,{send:c}){var b;if(!i)return"";if(!this.events.has(i))return(b=this.logger)==null||b.warn(`[LruEventStore] Replay miss for last-event-id '${i}'. Cap is ${this.limit}; consider increasing \`eventStoreLimit\` if this fires under normal load.`),"";let u=i.split("_")[0];if(!u)return"";let f=!1;for(let[y,{streamId:w,message:T}]of this.events)if(w===u){if(y===i){f=!0;continue}f&&await c(y,T)}return u}};n(JQ,"LruEventStore"),JQ.DEFAULT_LIMIT=1e4;var IYe=JQ;_ye.LruEventStore=IYe});var Eye=Z(ob=>{"use strict";var VQ=ob&&ob.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},TYe=ob&&ob.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ob,"__esModule",{value:!0});ob.McpDiagramPromptHandlerRegistryInitializer=ob.McpDiagramPromptHandlerRegistry=ob.McpDiagramPromptHandlerFactory=void 0;var D2r=Vr(),JB=cn(),N2r=oT();ob.McpDiagramPromptHandlerFactory=Symbol("McpDiagramPromptHandlerFactory");var ZB,KQ=(ZB=class extends D2r.Registry{registerHandler(i){return this.register(i.name,i)}},n(ZB,"McpDiagramPromptHandlerRegistry"),ZB);ob.McpDiagramPromptHandlerRegistry=KQ;ob.McpDiagramPromptHandlerRegistry=KQ=VQ([(0,JB.injectable)()],KQ);var HB,KB=(HB=class{constructor(){this.constructors=[]}initialize(i){for(let c of this.constructors)try{this.registry.registerHandler(this.factory(c))}catch(u){throw new Error(`Failed to instantiate MCP diagram prompt handler '${c.name}': ${u.message}. Check your DiagramModule bindings.`)}}},n(HB,"McpDiagramPromptHandlerRegistryInitializer"),HB);ob.McpDiagramPromptHandlerRegistryInitializer=KB;VQ([(0,JB.inject)(ob.McpDiagramPromptHandlerFactory),TYe("design:type",Function)],KB.prototype,"factory",void 0);VQ([(0,JB.inject)(N2r.McpDiagramPromptHandlerConstructor),(0,JB.optional)(),TYe("design:type",Array)],KB.prototype,"constructors",void 0);VQ([(0,JB.inject)(KQ),TYe("design:type",KQ)],KB.prototype,"registry",void 0);ob.McpDiagramPromptHandlerRegistryInitializer=KB=VQ([(0,JB.injectable)()],KB)});var yT=Z(Fp=>{"use strict";var wT=Fp&&Fp.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},QB=Fp&&Fp.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(Fp,"__esModule",{value:!0});Fp.McpDiagramResourceHandlerConstructor=Fp.AbstractMcpDiagramResourceHandler=Fp.AbstractMcpResourceHandler=Fp.McpResourceHandler=void 0;Fp.toParams=Xdn;var WQ=Vr(),q2r=HQ(),DO=cn(),MYe=Dd(),L2r=zD(),Wdn=rT();Fp.McpResourceHandler=Symbol("McpResourceHandler");var VB,YB=(VB=class{constructor(){this.requestContext=new Wdn.NoopMcpRequestContext}toAnnotations(){if(!(this.audience===void 0&&this.priority===void 0&&this.lastModified===void 0))return{...this.audience!==void 0?{audience:this.audience}:{},...this.priority!==void 0?{priority:this.priority}:{},...this.lastModified!==void 0?{lastModified:this.lastModified}:{}}}uriTemplate(){return typeof this.uri=="string"?this.uri:this.uri.template}expandUriTemplate(i){return this.uriTemplate().replace(/\{(\w+)\}/g,(c,u)=>{let f=i[u];return f===void 0?c:encodeURIComponent(f)})}async execute(i){try{return{ok:!0,body:await i()}}catch(c){if(c instanceof MYe.McpToolError)return{ok:!1,message:c.message};let u=(0,MYe.extractErrorMessage)(c);return this.logger.error(`Unexpected error in resource '${this.name}': ${u}`,c),{ok:!1,message:u}}}toResourceResult(i,c){return c.ok?{contents:["text"in c.body?{uri:i,mimeType:this.mimeType,text:c.body.text}:{uri:i,mimeType:this.mimeType,blob:c.body.blob}],isError:!1}:{contents:[{uri:i,mimeType:"text/plain",text:c.message}],isError:!0}}toToolResult(i){if(!i.ok)return{isError:!0,content:[{type:"text",text:i.message}]};let c=i.body.structured,u="text"in i.body?{isError:!1,content:[{type:"text",text:i.body.text}]}:{isError:!1,content:[{type:"image",data:i.body.blob,mimeType:this.mimeType}]};return c?{...u,structuredContent:c}:u}buildResourceTemplate(i){var c;return new q2r.ResourceTemplate(i,{list:this.list?async u=>this.requestContext.run(u,()=>this.list()):void 0,complete:(c=this.complete)==null?void 0:c.call(this)})}},n(VB,"BaseMcpResourceHandler"),VB);wT([(0,DO.inject)(Wdn.McpRequestContext),(0,DO.optional)(),QB("design:type",Object)],YB.prototype,"requestContext",void 0);wT([(0,DO.inject)(WQ.Logger),QB("design:type",WQ.Logger)],YB.prototype,"logger",void 0);YB=wT([(0,DO.injectable)()],YB);var WB,AYe=(WB=class extends YB{registerResource(i){let c=this.toAnnotations(),u={title:this.title,description:this.description,mimeType:this.mimeType,...c?{annotations:c}:{}};if(typeof this.uri=="string"){let f=this.uri;i.registerResource(this.name,f,u,async(b,y)=>this.requestContext.run(y,async()=>this.toResourceResult(f,await this.execute(()=>this.createResult({})))))}else i.registerResource(this.name,this.buildResourceTemplate(this.uri.template),u,async(f,b,y)=>this.requestContext.run(y,async()=>this.toResourceResult(f.toString(),await this.execute(()=>this.createResult(Xdn(b))))))}registerToolAlternative(i){this.toolAlternativeInputSchema&&this.doRegisterToolAlternative(i)}doRegisterToolAlternative(i){let c=this.toolAlternativeInputSchema;i.registerTool(this.name,{title:this.title,description:this.description,inputSchema:c.strict(),outputSchema:this.toolAlternativeOutputSchema},async(u,f)=>this.requestContext.run(f,async()=>this.toToolResult(await this.execute(()=>this.createResult(u)))))}},n(WB,"AbstractMcpResourceHandler"),WB);Fp.AbstractMcpResourceHandler=AYe;Fp.AbstractMcpResourceHandler=AYe=wT([(0,DO.injectable)()],AYe);var XB,E9=(XB=class extends YB{requestAction(i,c,u=this.name){return(0,MYe.requestActionOrFail)(this.actionDispatcher,i,c,u)}isSupportedByDiagramType(){return!0}canRegister(){return!0}list(){return{resources:[this.toListingEntry()]}}complete(){return this.uriTemplate().includes("{sessionId}")?{sessionId:n(async()=>[this.clientId],"sessionId")}:{}}toListingEntry(){var c;let i=this.toAnnotations();return{uri:this.expandUriTemplate({sessionId:this.clientId}),name:`${(c=this.title)!=null?c:this.name}: ${this.clientId}`,description:this.description,mimeType:this.mimeType,...i?{annotations:i}:{}}}async handleRead(i,c){return this.toResourceResult(i,await this.execute(()=>this.createResult(c)))}async handleAsTool(i){return this.toToolResult(await this.execute(()=>this.createResult(i)))}glspSessionScopedComplete(){var b,y;let i=(y=(b=this.complete)==null?void 0:b.call(this))!=null?y:{},c=this.clientId,u=typeof this.uri=="object"&&this.uri.template.includes("{sessionId}"),f={};for(let[w,T]of Object.entries(i))f[w]=w==="sessionId"||!u?T:async(A,C)=>{var I;return((I=C==null?void 0:C.arguments)==null?void 0:I.sessionId)===c?T(A,C):[]};return f}},n(XB,"AbstractMcpDiagramResourceHandler"),XB);Fp.AbstractMcpDiagramResourceHandler=E9;wT([(0,DO.inject)(WQ.ClientId),QB("design:type",String)],E9.prototype,"clientId",void 0);wT([(0,DO.inject)(WQ.ModelState),QB("design:type",Object)],E9.prototype,"modelState",void 0);wT([(0,DO.inject)(L2r.McpIdAliasService),QB("design:type",Object)],E9.prototype,"aliasService",void 0);wT([(0,DO.inject)(WQ.ActionDispatcher),QB("design:type",Object)],E9.prototype,"actionDispatcher",void 0);Fp.AbstractMcpDiagramResourceHandler=E9=wT([(0,DO.injectable)()],E9);function Xdn(s){var c;let i={};for(let[u,f]of Object.entries(s))i[u]=Array.isArray(f)?(c=f[0])!=null?c:"":f;return i}n(Xdn,"toParams");Fp.McpDiagramResourceHandlerConstructor=Symbol("McpDiagramResourceHandlerConstructor")});var Oye=Z(sb=>{"use strict";var O9=sb&&sb.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},QQ=sb&&sb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(sb,"__esModule",{value:!0});sb.McpDiagramResourceHandlerRegistryInitializer=sb.McpDiagramResourceHandlerRegistry=sb.McpDiagramResourceHandlerFactory=void 0;var XQ=Vr(),JA=cn(),x2r=yT();sb.McpDiagramResourceHandlerFactory=Symbol("McpDiagramResourceHandlerFactory");var eF,YQ=(eF=class extends XQ.Registry{registerHandler(i){return this.register(i.name,i)}},n(eF,"McpDiagramResourceHandlerRegistry"),eF);sb.McpDiagramResourceHandlerRegistry=YQ;sb.McpDiagramResourceHandlerRegistry=YQ=O9([(0,JA.injectable)()],YQ);var tF,KA=(tF=class{constructor(){this.constructors=[]}initialize(i){let c=this.clientId===XQ.TEMPORARY_CLIENT_ID;for(let u of this.constructors){let f;try{f=this.factory(u)}catch(b){throw new Error(`Failed to instantiate MCP diagram resource handler '${u.name}': ${b.message}. Check your DiagramModule bindings.`)}if(!f.canRegister()){c||this.logger.debug(`Skipping MCP diagram resource handler '${f.name}': canRegister() returned false.`);continue}this.registry.registerHandler(f)}}},n(tF,"McpDiagramResourceHandlerRegistryInitializer"),tF);sb.McpDiagramResourceHandlerRegistryInitializer=KA;O9([(0,JA.inject)(sb.McpDiagramResourceHandlerFactory),QQ("design:type",Function)],KA.prototype,"factory",void 0);O9([(0,JA.inject)(x2r.McpDiagramResourceHandlerConstructor),(0,JA.optional)(),QQ("design:type",Array)],KA.prototype,"constructors",void 0);O9([(0,JA.inject)(YQ),QQ("design:type",YQ)],KA.prototype,"registry",void 0);O9([(0,JA.inject)(XQ.ClientId),QQ("design:type",String)],KA.prototype,"clientId",void 0);O9([(0,JA.inject)(XQ.Logger),QQ("design:type",XQ.Logger)],KA.prototype,"logger",void 0);sb.McpDiagramResourceHandlerRegistryInitializer=KA=O9([(0,JA.injectable)()],KA)});var jye=Z(cb=>{"use strict";var j9=cb&&cb.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},nee=cb&&cb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(cb,"__esModule",{value:!0});cb.McpDiagramToolHandlerRegistryInitializer=cb.McpDiagramToolHandlerRegistry=cb.McpDiagramToolHandlerFactory=void 0;var eee=Vr(),VA=cn(),z2r=Xu();cb.McpDiagramToolHandlerFactory=Symbol("McpDiagramToolHandlerFactory");var nF,tee=(nF=class extends eee.Registry{registerHandler(i){return this.register(i.name,i)}},n(nF,"McpDiagramToolHandlerRegistry"),nF);cb.McpDiagramToolHandlerRegistry=tee;cb.McpDiagramToolHandlerRegistry=tee=j9([(0,VA.injectable)()],tee);var rF,WA=(rF=class{constructor(){this.constructors=[]}initialize(i){let c=this.clientId===eee.TEMPORARY_CLIENT_ID;for(let u of this.constructors){let f;try{f=this.factory(u)}catch(b){throw new Error(`Failed to instantiate MCP diagram tool handler '${u.name}': ${b.message}. Check your DiagramModule bindings.`)}if(!f.canRegister()){c||this.logger.debug(`Skipping MCP diagram tool handler '${f.name}': canRegister() returned false.`);continue}this.registry.registerHandler(f)}}},n(rF,"McpDiagramToolHandlerRegistryInitializer"),rF);cb.McpDiagramToolHandlerRegistryInitializer=WA;j9([(0,VA.inject)(cb.McpDiagramToolHandlerFactory),nee("design:type",Function)],WA.prototype,"factory",void 0);j9([(0,VA.inject)(z2r.McpDiagramToolHandlerConstructor),(0,VA.optional)(),nee("design:type",Array)],WA.prototype,"constructors",void 0);j9([(0,VA.inject)(tee),nee("design:type",tee)],WA.prototype,"registry",void 0);j9([(0,VA.inject)(eee.ClientId),nee("design:type",String)],WA.prototype,"clientId",void 0);j9([(0,VA.inject)(eee.Logger),nee("design:type",eee.Logger)],WA.prototype,"logger",void 0);cb.McpDiagramToolHandlerRegistryInitializer=WA=j9([(0,VA.injectable)()],WA)});var Pye=Z(oS=>{"use strict";var oF=oS&&oS.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},ree=oS&&oS.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(oS,"__esModule",{value:!0});oS.DefaultMcpDiagramHandlerDispatcher=oS.McpDiagramHandlerDispatcher=void 0;var P9=Vr(),B2r=HQ(),YA=cn(),F2r=Eye(),Ydn=Oye(),U2r=jye(),XA=Dd(),G2r=oT(),ehn=rT(),kYe=yT(),Qdn=Xu();oS.McpDiagramHandlerDispatcher=Symbol("McpDiagramHandlerDispatcher");var iF,QA=(iF=class{constructor(){this.requestContext=new ehn.NoopMcpRequestContext,this.diagramCatalogs=[]}harvest(){if(this.diagramCatalogs.length>0)return;let i=[],c=(0,P9.createClientSessionModule)({clientId:P9.TEMPORARY_CLIENT_ID,glspClient:{process:n(()=>{},"process")},clientActionKinds:[]});for(let[u,f]of this.diagramModules){let b=this.serverContainer.createChild();b.load(...f,c);let y=this.filterSupported(b,$Ye(b,Qdn.McpDiagramToolHandlerConstructor),u,Qdn.BaseMcpDiagramToolHandler.prototype.isSupportedByDiagramType),w=this.filterSupported(b,$Ye(b,kYe.McpDiagramResourceHandlerConstructor),u,kYe.AbstractMcpDiagramResourceHandler.prototype.isSupportedByDiagramType),T=$Ye(b,G2r.McpDiagramPromptHandlerConstructor);b.unbindAll(),i.push({diagramType:u,toolConstructors:y,resourceConstructors:w,promptConstructors:T})}this.diagramCatalogs=i}filterSupported(i,c,u,f){return c.filter(b=>{let y=b.prototype.isSupportedByDiagramType;if(typeof y!="function"||y===f)return!0;try{return i.resolve(b).isSupportedByDiagramType()?!0:(this.logger.debug(`Diagram type '${u}' does not support MCP handler '${b.name}'; not registering.`),!1)}catch(w){return this.logger.debug(`Could not probe MCP handler '${b.name}' for diagram type '${u}'; registering.`,w),!0}})}hasDiagramTools(){return this.diagramCatalogs.some(i=>i.toolConstructors.length>0)}hasDiagramResources(){return this.diagramCatalogs.some(i=>i.resourceConstructors.length>0)}hasDiagramPrompts(){return this.diagramCatalogs.some(i=>i.promptConstructors.length>0)}registerAll(i,c){this.registerDiagramScopeTools(i),this.registerDiagramScopeResources(i,c),this.registerDiagramScopePrompts(i)}registerDiagramScopeTools(i){var u,f;let c=new Map;for(let b of this.diagramCatalogs)for(let y of b.toolConstructors){let w=new y,T={description:w.description,inputKeys:Object.keys((f=(u=w.inputSchema)==null?void 0:u.shape)!=null?f:{}).sort().join(","),diagramType:b.diagramType},A=c.get(w.name);if(A){(A.description!==T.description||A.inputKeys!==T.inputKeys)&&this.logger.warn(`Diagram-scope tool '${w.name}' is registered by multiple diagram types with diverging schemas: first registered by '${A.diagramType}', shadowed registration from '${b.diagramType}' is silently dropped. Either align schemas (description + inputSchema.shape keys must match) or pick distinct tool names.`);continue}c.set(w.name,T),i.registerTool(w.name,w.toRegistrationConfig(),(C,I)=>this.requestContext.run(I,()=>this.dispatchDiagramTool(w.name,C)))}}registerDiagramScopeResources(i,c){let u=new Set;for(let f of this.diagramCatalogs)for(let b of f.resourceConstructors){let y=new b;u.has(y.name)||(u.add(y.name),c?this.registerOneDiagramResource(i,y):y.toolAlternativeInputSchema&&this.registerOneDiagramResourceAsTool(i,y))}}registerOneDiagramResource(i,c){let u=c.name,f=c.toAnnotations(),b={title:c.title,description:c.description,mimeType:c.mimeType,...f?{annotations:f}:{}};if(typeof c.uri=="string"){let y=c.uri;i.registerResource(u,y,b,(w,T)=>this.requestContext.run(T,()=>this.dispatchStaticDiagramRead(u,y)))}else{let y=this.buildAggregatingResourceTemplate(c.uri.template,u);i.registerResource(u,y,b,(w,T,A)=>this.requestContext.run(A,()=>this.dispatchTemplatedDiagramRead(u,w,T)))}}registerOneDiagramResourceAsTool(i,c){let u=c.name,f=c.toolAlternativeInputSchema;i.registerTool(u,{title:c.title,description:c.description,inputSchema:f.strict(),outputSchema:c.toolAlternativeOutputSchema},(b,y)=>this.requestContext.run(y,()=>this.dispatchDiagramResourceAsTool(u,b)))}registerDiagramScopePrompts(i){let c=new Set;for(let u of this.diagramCatalogs)for(let f of u.promptConstructors){let b=new f;c.has(b.name)||(c.add(b.name),i.registerPrompt(b.name,b.toRegistrationConfig(),(y,w)=>this.requestContext.run(w,()=>this.dispatchDiagramPrompt(b.name,y))))}}buildAggregatingResourceTemplate(i,c){return new B2r.ResourceTemplate(i,{list:n(u=>this.requestContext.run(u,()=>this.aggregateList(c)),"list"),complete:this.buildAggregatedCompleters(c)})}async aggregateList(i){var f;let c=[],u=new Set;for(let b of this.clientSessionManager.getSessions().map(y=>y.id)){let y=this.findDiagramResourceHandler(i,b),w=await((f=y==null?void 0:y.list)==null?void 0:f.call(y));if(w)for(let T of w.resources)u.has(T.uri)||(u.add(T.uri),c.push(T))}return{resources:c}}buildAggregatedCompleters(i){let c=this.collectCompleterVariableNames(i),u={};for(let f of c)u[f]=async(b,y)=>{let w=new Set;for(let T of this.clientSessionManager.getSessions().map(A=>A.id)){let A=this.findDiagramResourceHandler(i,T);if(!A)continue;let I=A.glspSessionScopedComplete()[f];if(!I)continue;(await I(b,y)).forEach(G=>w.add(G))}return[...w]};return u}collectCompleterVariableNames(i){var u,f;let c=new Set;for(let b of this.diagramCatalogs)for(let y of b.resourceConstructors){let w=new y;w.name===i&&Object.keys((f=(u=w.complete)==null?void 0:u.call(w))!=null?f:{}).forEach(T=>c.add(T))}return c}dispatchDiagramTool(i,c){return(0,XA.runWithToolErrorEnvelope)(async()=>this.requireDiagramToolHandler(i,c).handle(c))}dispatchStaticDiagramRead(i,c){var b;let u=(b=this.clientSessionManager.getSessions()[0])==null?void 0:b.id;if(!u)throw new XA.McpToolError(`No open GLSP session can serve resource '${i}'.`);return this.requireDiagramResourceHandler(i,u).handleRead(c,{sessionId:u})}dispatchTemplatedDiagramRead(i,c,u){let f=(0,kYe.toParams)(u);return this.requireDiagramResourceHandler(i,f.sessionId).handleRead(c.toString(),f)}dispatchDiagramResourceAsTool(i,c){return(0,XA.runWithToolErrorEnvelope)(async()=>this.requireDiagramResourceHandler(i,this.extractSessionId(c)).handleAsTool(c))}dispatchDiagramPrompt(i,c){return this.requireDiagramPromptHandler(i,c).handle(c)}extractSessionId(i){return i.sessionId}requireDiagramToolHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(U2r.McpDiagramToolHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No tool handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireDiagramResourceHandler(i,c){let u=this.requireGlspSession(c),b=u.container.get(Ydn.McpDiagramResourceHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No resource handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}findDiagramResourceHandler(i,c){let u=this.clientSessionManager.getSession(c);if(u)return u.container.get(Ydn.McpDiagramResourceHandlerRegistry).get(i)}requireDiagramPromptHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(F2r.McpDiagramPromptHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No prompt handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireGlspSession(i){if(!i)throw new XA.McpMissingParamError("sessionId");let c=this.clientSessionManager.getSession(i);if(!c)throw new XA.McpSessionNotFoundError(i);return c}reset(){this.diagramCatalogs=[]}},n(iF,"DefaultMcpDiagramHandlerDispatcher"),iF);oS.DefaultMcpDiagramHandlerDispatcher=QA;oF([(0,YA.inject)(ehn.McpRequestContext),(0,YA.optional)(),ree("design:type",Object)],QA.prototype,"requestContext",void 0);oF([(0,YA.inject)(P9.InjectionContainer),ree("design:type",YA.Container)],QA.prototype,"serverContainer",void 0);oF([(0,YA.inject)(P9.DiagramModules),ree("design:type",Map)],QA.prototype,"diagramModules",void 0);oF([(0,YA.inject)(P9.ClientSessionManager),ree("design:type",Object)],QA.prototype,"clientSessionManager",void 0);oF([(0,YA.inject)(P9.Logger),ree("design:type",P9.Logger)],QA.prototype,"logger",void 0);oS.DefaultMcpDiagramHandlerDispatcher=QA=oF([(0,YA.injectable)()],QA);function $Ye(s,i){return s.isBound(i)?s.get(i):[]}n($Ye,"getConstructorList")});var iee=Z(NO=>{"use strict";var Z2r=NO&&NO.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},Iye;Object.defineProperty(NO,"__esModule",{value:!0});NO.DefaultMcpLogLevelRegistry=NO.McpLogLevelRegistry=void 0;NO.passesLogThreshold=J2r;var H2r=cn();NO.McpLogLevelRegistry=Symbol("McpLogLevelRegistry");var thn={emergency:0,alert:1,critical:2,error:3,warning:4,notice:5,info:6,debug:7};function J2r(s,i){return thn[s]<=thn[i]}n(J2r,"passesLogThreshold");var ek,CYe=(ek=class{constructor(){this.levels=new Map}setLevel(i,c){this.levels.set(i,c)}getLevel(i){var c;return i===void 0?Iye.DEFAULT_LEVEL:(c=this.levels.get(i))!=null?c:Iye.DEFAULT_LEVEL}clear(i){this.levels.delete(i)}},n(ek,"DefaultMcpLogLevelRegistry"),Iye=ek,ek.DEFAULT_LEVEL="debug",ek);NO.DefaultMcpLogLevelRegistry=CYe;NO.DefaultMcpLogLevelRegistry=CYe=Iye=Z2r([(0,H2r.injectable)()],CYe)});var Tye=Z(_T=>{"use strict";var K2r=_T&&_T.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b};Object.defineProperty(_T,"__esModule",{value:!0});_T.McpServerDefaults=_T.McpServerOptions=void 0;var V2r=cn(),sF,RYe=(sF=class{constructor(){this.values={}}},n(sF,"McpServerOptions"),sF);_T.McpServerOptions=RYe;_T.McpServerOptions=RYe=K2r([(0,V2r.injectable)()],RYe);_T.McpServerDefaults=Symbol("McpServerDefaults")});var Aye=Z(mv=>{"use strict";var sS=mv&&mv.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},LO=mv&&mv.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(mv,"__esModule",{value:!0});mv.AbstractMcpServerLauncher=mv.SERVER_VERSION=void 0;mv.pickInitOptions=nhn;var qO=Vr(),W2r=HQ(),X2r=Kdn(),Mye=CA(),zm=cn(),Y2r=Vdn(),Q2r=yye(),eSr=Sye(),tSr=Pye(),nSr=iee(),DYe=Tye(),rSr=oT(),iSr=yT(),oSr=Xu();mv.SERVER_VERSION=Y2r.version;function nhn(s){let{dataMode:i,agentPersona:c,eventStoreLimit:u}=s,f={};return i!==void 0&&(f.dataMode=i),c!==void 0&&(f.agentPersona=c),u!==void 0&&(f.eventStoreLimit=u),f}n(nhn,"pickInitOptions");var sSr=null,cF,bv=(cF=class{constructor(){this.toolHandlers=[],this.resourceHandlers=[],this.promptHandlers=[],this.toDispose=new qO.DisposableCollection,this.sessions=new Map,this.sessionServers=new Map,this.onSessionInitializedEmitter=new qO.Emitter,this.onSessionInitialized=this.onSessionInitializedEmitter.event,this.onSessionClosedEmitter=new qO.Emitter,this.onSessionClosed=this.onSessionClosedEmitter.event}async initializeServer(i,c,u){var G,oe;let f=qO.McpInitializeParameters.getServerConfig(c);if(!f)return u;if(this.serverConfig)return this.serverUrl?qO.McpInitializeResult.attachServer(u,{name:this.serverConfig.name,url:this.serverUrl}):u;let{port:b=0,route:y="/mcp",name:w="glsp",options:T={}}=f,A={...this.mcpDefaults,...nhn(T)};this.mcpOptions.values=A;let C=(G=A.host)!=null?G:"127.0.0.1",I={port:b,host:C,route:y,name:w,options:A};this.dispatcher.harvest(),this.installResourceListChangedNotifier();let R=await this.bindTransport(I);return this.serverConfig=I,this.serverUrl=R.url,this.logger.info(`MCP server '${I.name}' is ready to accept new client requests on: ${(oe=this.serverUrl)!=null?oe:"(no network endpoint)"}`),R.url?qO.McpInitializeResult.attachServer(u,{name:I.name,url:R.url,headers:R.headers}):u}serverShutDown(i){this.dispose()}dispose(){let i=Array.from(this.sessions.values()).map(c=>c.close().catch(u=>this.logger.warn(`Error closing MCP session ${c.sessionId}: ${u}`)));this.sessions.clear(),this.sessionServers.forEach(c=>c.dispose()),this.sessionServers.clear(),Promise.allSettled(i).then(()=>{this.toDispose.dispose(),this.toDispose.clear()}),this.serverUrl=void 0,this.serverConfig=void 0,this.dispatcher.reset()}async handleRequest(i,c){var C,I;let u=new URL(i.url),f=(I=(C=this.serverConfig)==null?void 0:C.route)!=null?I:"/mcp";if(u.pathname!==f)return new Response("Not Found",{status:404});if(i.method!=="POST"&&i.method!=="GET"&&i.method!=="DELETE")return new Response("Method Not Allowed",{status:405,headers:{Allow:"POST, GET, DELETE"}});let b=this.validateHostHeader(i);if(b)return b;let y;i.method==="POST"&&(y=await i.clone().json().catch(()=>{}));let w=i.method==="POST"&&(0,Mye.isInitializeRequest)(y),T=this.validateProtocolVersionHeader(i,w);if(T)return T;let A=this.resolveTransport(i,w);if(A instanceof Response)return A;try{return await A.handleRequest(i,{parsedBody:y,authInfo:c==null?void 0:c.authInfo})}catch(R){let G=R instanceof Error?R.message:String(R);return this.logger.error("Error handling MCP request:",R),this.jsonRpcErrorResponse(500,-32603,`Internal server error: ${G}`)}}getRequestHandler(){return(i,c)=>this.handleRequest(i,c)}resolveTransport(i,c){var b;let u=(b=i.headers.get("mcp-session-id"))!=null?b:void 0;if(c&&!u)return this.createTransport();if(!u)return this.jsonRpcErrorResponse(400,-32e3,"Bad Request: No valid session ID provided");let f=this.sessions.get(u);return f||this.jsonRpcErrorResponse(404,-32001,"Session not found")}validateProtocolVersionHeader(i,c){var f;if(c)return;let u=(f=i.headers.get("mcp-protocol-version"))!=null?f:void 0;if(u!==void 0&&!Mye.SUPPORTED_PROTOCOL_VERSIONS.includes(u))return this.jsonRpcErrorResponse(400,-32e3,`Unsupported MCP-Protocol-Version: '${u}'. Supported versions: ${Mye.SUPPORTED_PROTOCOL_VERSIONS.join(", ")}.`)}validateHostHeader(i){let c=this.mcpOptions.values.allowedHosts;if(!c||c.length===0)return;let u=i.headers.get("host");if(!u)return this.jsonRpcErrorResponse(403,-32e3,"Missing Host header");let f;try{f=new URL(`http://${u}`).hostname}catch{return this.jsonRpcErrorResponse(403,-32e3,`Invalid Host header: ${u}`)}if(!c.includes(f))return this.jsonRpcErrorResponse(403,-32e3,`Invalid Host: ${f}`)}createTransport(){var u;let i=this.mcpOptions.values.allowedOrigins,c=new X2r.WebStandardStreamableHTTPServerTransport({sessionIdGenerator:n(()=>globalThis.crypto.randomUUID(),"sessionIdGenerator"),eventStore:new eSr.LruEventStore(this.mcpOptions.values.eventStoreLimit,this.logger),allowedOrigins:i,enableDnsRebindingProtection:((u=i==null?void 0:i.length)!=null?u:0)>0,onsessioninitialized:n(f=>{this.logger.info(`MCP session initialized with ID: ${f}`),this.sessions.set(f,c),this.serverConfig&&this.attachServerToSession(c,this.serverConfig),this.onSessionInitializedEmitter.fire(c)},"onsessioninitialized"),onsessionclosed:n(f=>this.closeSession(f),"onsessionclosed")});return c.onclose=()=>this.closeSession(c.sessionId),c.onerror=f=>{var b;return this.logger.error(`MCP transport error (session ${(b=c.sessionId)!=null?b:"<pre-init>"}):`,f)},c}attachServerToSession(i,c){let u=i.sessionId;if(!u)return;let f=this.createGlspMcpServer(c);this.sessionServers.set(u,f),this.registerLogLevelHandler(f,u),f.connect(i)}closeSession(i){if(!i)return;let c=this.sessions.delete(i),u=this.sessionServers.get(i);u&&(this.sessionServers.delete(i),this.logLevelRegistry.clear(i),u.dispose()),c&&(this.logger.info(`MCP session closed: ${i}`),this.onSessionClosedEmitter.fire(i))}installResourceListChangedNotifier(){if(!this.dispatcher.hasDiagramResources())return;let i={sessionCreated:n(()=>this.broadcastResourceListChanged(),"sessionCreated"),sessionDisposed:n(()=>this.broadcastResourceListChanged(),"sessionDisposed")};this.clientSessionManager.addListener(i),this.toDispose.push(qO.Disposable.create(()=>this.clientSessionManager.removeListener(i)))}broadcastResourceListChanged(){for(let i of this.sessionServers.values())i.getRawServer().server.sendResourceListChanged().catch(c=>this.logger.debug("sendResourceListChanged failed:",c))}registerLogLevelHandler(i,c){i.getRawServer().server.setRequestHandler(Mye.SetLevelRequestSchema,async u=>(this.logLevelRegistry.setLevel(c,u.params.level),{}))}createGlspMcpServer({name:i,options:c}){let u=c.dataMode==="resources",f=new W2r.McpServer({name:i,version:mv.SERVER_VERSION},{capabilities:this.buildCapabilities(u),instructions:c.agentPersona}),b=this.glspMcpServerFactory(f,c);return this.registerHandlers(b,u),b}buildCapabilities(i){let c=this.toolHandlers.length>0,u=this.promptHandlers.length>0,f=this.resourceHandlers.length>0,b=this.dispatcher.hasDiagramTools(),y=this.dispatcher.hasDiagramPrompts(),w=this.dispatcher.hasDiagramResources(),T=f||w;return{logging:{},...c||b||!i&&T?{tools:{listChanged:!1}}:{},...i&&T?{resources:{listChanged:w}}:{},...u||y?{prompts:{listChanged:!1}}:{}}}registerHandlers(i,c){this.toolHandlers.forEach(u=>u.registerTool(i)),this.promptHandlers.forEach(u=>u.registerPrompt(i)),c?this.resourceHandlers.forEach(u=>u.registerResource(i)):this.resourceHandlers.forEach(u=>{var f;return(f=u.registerToolAlternative)==null?void 0:f.call(u,i)}),this.dispatcher.registerAll(i,c),this.validatePromptToolReferences(i)}validatePromptToolReferences(i){for(let c of this.promptHandlers){let u=c.referencedToolNames().filter(f=>!i.hasTool(f));u.length>0&&this.logger.warn(`Prompt '${c.name}' references unbound tool(s): ${u.join(", ")}. The prompt will still register but its text points at tools the LLM cannot invoke.`)}}jsonRpcErrorResponse(i,c,u){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:c,message:u},id:sSr}),{status:i,headers:{"Content-Type":"application/json"}})}},n(cF,"AbstractMcpServerLauncher"),cF);mv.AbstractMcpServerLauncher=bv;sS([(0,zm.inject)(qO.Logger),LO("design:type",qO.Logger)],bv.prototype,"logger",void 0);sS([(0,zm.inject)(DYe.McpServerOptions),LO("design:type",DYe.McpServerOptions)],bv.prototype,"mcpOptions",void 0);sS([(0,zm.inject)(DYe.McpServerDefaults),LO("design:type",Object)],bv.prototype,"mcpDefaults",void 0);sS([(0,zm.inject)(Q2r.GLSPMcpServerFactory),LO("design:type",Function)],bv.prototype,"glspMcpServerFactory",void 0);sS([(0,zm.inject)(tSr.McpDiagramHandlerDispatcher),LO("design:type",Object)],bv.prototype,"dispatcher",void 0);sS([(0,zm.inject)(nSr.McpLogLevelRegistry),LO("design:type",Object)],bv.prototype,"logLevelRegistry",void 0);sS([(0,zm.inject)(qO.ClientSessionManager),LO("design:type",Object)],bv.prototype,"clientSessionManager",void 0);sS([(0,zm.multiInject)(oSr.McpToolHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"toolHandlers",void 0);sS([(0,zm.multiInject)(iSr.McpResourceHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"resourceHandlers",void 0);sS([(0,zm.multiInject)(rSr.McpPromptHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"promptHandlers",void 0);mv.AbstractMcpServerLauncher=bv=sS([(0,zm.injectable)()],bv)});var $ye=Z(ST=>{"use strict";var kye=ST&&ST.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},NYe=ST&&ST.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ST,"__esModule",{value:!0});ST.McpLogger=void 0;var rhn=Vr(),oee=cn(),ihn=iee(),ohn=rT(),aF,uF=(aF=class{constructor(){this.requestContext=new ohn.NoopMcpRequestContext}info(i,...c){this.glspLogger.info(i,...c),this.notify("info",i)}warn(i,...c){this.glspLogger.warn(i,...c),this.notify("warning",i)}error(i,...c){this.glspLogger.error(i,...c),this.notify("error",i)}debug(i,...c){this.glspLogger.debug(i,...c),this.notify("debug",i)}notify(i,c){let u=this.requestContext.getStore();if(!u)return;let f=this.levelRegistry.getLevel(u.sessionId);(0,ihn.passesLogThreshold)(i,f)&&u.sendNotification({method:"notifications/message",params:{level:i,data:c}}).catch(()=>{})}},n(aF,"McpLogger"),aF);ST.McpLogger=uF;kye([(0,oee.inject)(ohn.McpRequestContext),(0,oee.optional)(),NYe("design:type",Object)],uF.prototype,"requestContext",void 0);kye([(0,oee.inject)(rhn.Logger),NYe("design:type",rhn.Logger)],uF.prototype,"glspLogger",void 0);kye([(0,oee.inject)(ihn.McpLogLevelRegistry),NYe("design:type",Object)],uF.prototype,"levelRegistry",void 0);ST.McpLogger=uF=kye([(0,oee.injectable)()],uF)});var see=Z(ET=>{"use strict";var shn=ET&&ET.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},cSr=ET&&ET.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ET,"__esModule",{value:!0});ET.McpProgressReporter=void 0;var qYe=cn(),chn=rT(),lF,Cye=(lF=class{constructor(){this.requestContext=new chn.NoopMcpRequestContext}async emit(i){var f;let c=this.requestContext.getStore(),u=(f=c==null?void 0:c._meta)==null?void 0:f.progressToken;if(!(c===void 0||u===void 0))try{await c.sendNotification({method:"notifications/progress",params:{progressToken:u,...i}})}catch{}}},n(lF,"McpProgressReporter"),lF);ET.McpProgressReporter=Cye;shn([(0,qYe.inject)(chn.McpRequestContext),(0,qYe.optional)(),cSr("design:type",Object)],Cye.prototype,"requestContext",void 0);ET.McpProgressReporter=Cye=shn([(0,qYe.injectable)()],Cye)});var zYe=Z(rp=>{"use strict";var ahn=rp&&rp.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},aSr=rp&&rp.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},LYe;Object.defineProperty(rp,"__esModule",{value:!0});rp.SessionInfoMcpToolHandler=rp.SessionInfoOutputSchema=rp.SessionInfoRowSchema=rp.SessionInfoInputSchema=void 0;var xYe=Vr(),uhn=cn(),xO=Vu(),uSr=Dd(),lSr=Xu();rp.SessionInfoInputSchema=xO.object({sessionId:xO.string().optional().describe("Optional filter \u2014 returns only the matching session, or throws if unknown. Omit to list all sessions.")});rp.SessionInfoRowSchema=xO.object({sessionId:xO.string(),diagramType:xO.string(),sourceUri:xO.string(),readOnly:xO.boolean(),dirty:xO.boolean().describe("True when the diagram has unsaved changes \u2014 call `save-model` to persist.")});rp.SessionInfoOutputSchema=xO.object({sessions:xO.array(rp.SessionInfoRowSchema)});var tk,Rye=(tk=class extends lSr.AbstractMcpToolHandler{constructor(){super(...arguments),this.name=LYe.NAME,this.title="GLSP Session Info",this.description="Report info on the active GLSP client sessions: session id, diagram type, source uri, and read-only status. Pass `sessionId` to retrieve a single session's entry; omit it to list every active session. Useful as a discovery tool \u2014 most other diagram-scoped tools take the `sessionId` returned here.",this.inputSchema=rp.SessionInfoInputSchema,this.outputSchema=rp.SessionInfoOutputSchema}createResult({sessionId:i}){let u=(i!==void 0?this.singleSession(i):this.clientSessionManager.getSessions()).map(f=>this.buildSessionRow(f));return this.success(this.summarizeSessions(u),{sessions:u})}buildSessionRow(i){var f;let c=i.container.get(xYe.ModelState),u=i.container.get(xYe.CommandStack);return{sessionId:i.id,diagramType:i.diagramType,sourceUri:(f=c.sourceUri)!=null?f:"",readOnly:c.isReadonly,dirty:u.isDirty}}summarizeSessions(i){if(i.length===0)return"No active sessions.";let c=i.map(u=>{let f=[u.readOnly?"read-only":void 0,u.dirty?"dirty":void 0].filter(Boolean),b=f.length>0?`, ${f.join(", ")}`:"";return`- ${u.sessionId} (${u.diagramType}${b})`});return`${i.length} session(s); full details in structuredContent.
182
+ `,i.enqueue(c.encode(y)),!0}catch(y){return(b=this.onerror)==null||b.call(this,y),!1}}handleUnsupportedRequest(){var i;return(i=this.onerror)==null||i.call(this,new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(i,c){var u,f,b,y,w,T,A,C,I,R,G;try{let oe=i.headers.get("accept");if(!(oe!=null&&oe.includes("application/json"))||!oe.includes("text/event-stream"))return(u=this.onerror)==null||u.call(this,new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let le=i.headers.get("content-type");if(!le||!le.includes("application/json"))return(f=this.onerror)==null||f.call(this,new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let Te={headers:Object.fromEntries(i.headers.entries()),url:new URL(i.url)},Ve;if((c==null?void 0:c.parsedBody)!==void 0)Ve=c.parsedBody;else try{Ve=await i.json()}catch{return(b=this.onerror)==null||b.call(this,new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let ot;try{Array.isArray(Ve)?ot=Ve.map(Ko=>np.JSONRPCMessageSchema.parse(Ko)):ot=[np.JSONRPCMessageSchema.parse(Ve)]}catch{return(y=this.onerror)==null||y.call(this,new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let wt=ot.some(np.isInitializeRequest);if(wt){if(this._initialized&&this.sessionId!==void 0)return(w=this.onerror)==null||w.call(this,new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(ot.length>1)return(T=this.onerror)==null||T.call(this,new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=(A=this.sessionIdGenerator)==null?void 0:A.call(this),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!wt){let Ko=this.validateSession(i);if(Ko)return Ko;let iu=this.validateProtocolVersion(i);if(iu)return iu}if(!ot.some(np.isJSONRPCRequest)){for(let Ko of ot)(C=this.onmessage)==null||C.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te});return new Response(null,{status:202})}let tt=crypto.randomUUID(),yt=ot.find(Ko=>(0,np.isInitializeRequest)(Ko)),ar=yt?yt.params.protocolVersion:(I=i.headers.get("mcp-protocol-version"))!=null?I:np.DEFAULT_NEGOTIATED_PROTOCOL_VERSION;if(this._enableJsonResponse)return new Promise(Ko=>{var iu;this._streamMapping.set(tt,{resolveJson:Ko,cleanup:n(()=>{this._streamMapping.delete(tt)},"cleanup")});for(let hd of ot)(0,np.isJSONRPCRequest)(hd)&&this._requestToStreamMapping.set(hd.id,tt);for(let hd of ot)(iu=this.onmessage)==null||iu.call(this,hd,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te})});let lo=new TextEncoder,Ei,Oc=new ReadableStream({start:n(Ko=>{Ei=Ko},"start"),cancel:n(()=>{this._streamMapping.delete(tt)},"cancel")}),Qc={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(Qc["mcp-session-id"]=this.sessionId);for(let Ko of ot)(0,np.isJSONRPCRequest)(Ko)&&(this._streamMapping.set(tt,{controller:Ei,encoder:lo,cleanup:n(()=>{this._streamMapping.delete(tt);try{Ei.close()}catch{}},"cleanup")}),this._requestToStreamMapping.set(Ko.id,tt));await this.writePrimingEvent(Ei,lo,tt,ar);for(let Ko of ot){let iu,hd;(0,np.isJSONRPCRequest)(Ko)&&this._eventStore&&ar>="2025-11-25"&&(iu=n(()=>{this.closeSSEStream(Ko.id)},"closeSSEStream"),hd=n(()=>{this.closeStandaloneSSEStream()},"closeStandaloneSSEStream")),(R=this.onmessage)==null||R.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te,closeSSEStream:iu,closeStandaloneSSEStream:hd})}return new Response(Oc,{status:200,headers:Qc})}catch(oe){return(G=this.onerror)==null||G.call(this,oe),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(oe)})}}async handleDeleteRequest(i){var f;let c=this.validateSession(i);if(c)return c;let u=this.validateProtocolVersion(i);return u||(await Promise.resolve((f=this._onsessionclosed)==null?void 0:f.call(this,this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(i){var u,f,b;if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return(u=this.onerror)==null||u.call(this,new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let c=i.headers.get("mcp-session-id");if(!c)return(f=this.onerror)==null||f.call(this,new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(c!==this.sessionId)return(b=this.onerror)==null||b.call(this,new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(i){var u;let c=i.headers.get("mcp-protocol-version");if(c!==null&&!np.SUPPORTED_PROTOCOL_VERSIONS.includes(c))return(u=this.onerror)==null||u.call(this,new Error(`Bad Request: Unsupported protocol version: ${c} (supported versions: ${np.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${c} (supported versions: ${np.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)}async close(){var i;this._streamMapping.forEach(({cleanup:c})=>{c()}),this._streamMapping.clear(),this._requestResponseMap.clear(),(i=this.onclose)==null||i.call(this)}closeSSEStream(i){let c=this._requestToStreamMapping.get(i);if(!c)return;let u=this._streamMapping.get(c);u&&u.cleanup()}closeStandaloneSSEStream(){let i=this._streamMapping.get(this._standaloneSseStreamId);i&&i.cleanup()}async send(i,c){let u=c==null?void 0:c.relatedRequestId;if(((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i))&&(u=i.id),u===void 0){if((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let y;this._eventStore&&(y=await this._eventStore.storeEvent(this._standaloneSseStreamId,i));let w=this._streamMapping.get(this._standaloneSseStreamId);if(w===void 0)return;w.controller&&w.encoder&&this.writeSSEEvent(w.controller,w.encoder,i,y);return}let f=this._requestToStreamMapping.get(u);if(!f)throw new Error(`No connection established for request ID: ${String(u)}`);let b=this._streamMapping.get(f);if(!this._enableJsonResponse&&(b!=null&&b.controller)&&(b!=null&&b.encoder)){let y;this._eventStore&&(y=await this._eventStore.storeEvent(f,i)),this.writeSSEEvent(b.controller,b.encoder,i,y)}if((0,np.isJSONRPCResultResponse)(i)||(0,np.isJSONRPCErrorResponse)(i)){this._requestResponseMap.set(u,i);let y=Array.from(this._requestToStreamMapping.entries()).filter(([T,A])=>A===f).map(([T])=>T);if(y.every(T=>this._requestResponseMap.has(T))){if(!b)throw new Error(`No connection established for request ID: ${String(u)}`);if(this._enableJsonResponse&&b.resolveJson){let T={"Content-Type":"application/json"};this.sessionId!==void 0&&(T["mcp-session-id"]=this.sessionId);let A=y.map(C=>this._requestResponseMap.get(C));A.length===1?b.resolveJson(new Response(JSON.stringify(A[0]),{status:200,headers:T})):b.resolveJson(new Response(JSON.stringify(A),{status:200,headers:T}))}else b.cleanup();for(let T of y)this._requestResponseMap.delete(T),this._requestToStreamMapping.delete(T)}}}};n(EYe,"WebStandardStreamableHTTPServerTransport");var SYe=EYe;vye.WebStandardStreamableHTTPServerTransport=SYe});var Vdn=Z((Gpi,T2r)=>{T2r.exports={name:"@eclipse-glsp/server-mcp",version:"2.9.0-next.1",description:"Model Context Protocol (MCP) server for the GLSP TypeScript server \u2014 runs on Node, browser, and Fetch-API runtimes",keywords:["eclipse","graphics","diagram","modeling","visualization","glsp","diagram editor","mcp"],homepage:"https://www.eclipse.org/glsp/",bugs:"https://github.com/eclipse-glsp/glsp/issues",repository:{type:"git",url:"https://github.com/eclipse-glsp/glsp-server-node.git"},license:"(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",author:{name:"Eclipse GLSP"},contributors:[{name:"Eclipse GLSP Project",email:"glsp-dev@eclipse.org",url:"https://projects.eclipse.org/projects/ecd.glsp"}],main:"lib/node/index",browser:{"lib/node/index":"./lib/browser/index"},types:"lib/common/index",files:["lib","src","node.js","node.d.ts","browser.js","browser.d.ts","common.js","common.d.ts","!**/*.spec.ts","!**/*.spec.tsx","!**/test/**"],scripts:{build:"tsc -b",clean:"rimraf lib *.tsbuildinfo coverage","generate:index":"glsp generateIndex src/browser src/common src/node -f -s",lint:"eslint --ext .ts,.tsx ./src",prepublishOnly:"pnpm build"},dependencies:{"@eclipse-glsp/server":"workspace:*","@hono/node-server":"^1.19.9","@modelcontextprotocol/sdk":"^1.29.0",zod:"^4.0.0"},peerDependencies:{inversify:"^6.1.3","reflect-metadata":"^0.2.2"},publishConfig:{access:"public"}}});var yye=Z(ib=>{"use strict";var M2r=ib&&ib.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},A2r=ib&&ib.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},OYe=ib&&ib.__param||function(s,i){return function(c,u){i(c,u,s)}};Object.defineProperty(ib,"__esModule",{value:!0});ib.DefaultGLSPMcpServer=ib.GLSPMcpServerFactory=ib.GLSPMcpServer=void 0;var k2r=Vr(),$2r=HQ(),jYe=CA(),wye=cn();ib.GLSPMcpServer=Symbol("GLSPMcpServer");var C2r=3e4,R2r=5e3;ib.GLSPMcpServerFactory=Symbol("GLSPMcpServerFactory");var GB,PYe=(GB=class{constructor(i,c,u){this.mcpServer=i,this.options=c,this.logger=u,this.tools=new Map,this.resources=new Map,this.prompts=new Map;let{tools:f,resources:b,prompts:y}=this;this.registerTool=new Proxy(i.registerTool.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&f.set(A[0],C),C}}),this.registerResource=new Proxy(i.registerResource.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&b.set(A[0],C),C}}),this.registerPrompt=new Proxy(i.registerPrompt.bind(i),{apply(w,T,A){let C=Reflect.apply(w,T,A);return typeof A[0]=="string"&&y.set(A[0],C),C}})}sendLoggingMessage(...i){return this.mcpServer.sendLoggingMessage(...i)}async connect(...i){await this.mcpServer.connect(...i),this.keepAliveTimer=setInterval(()=>this.ping().catch(u=>{(!(u instanceof jYe.McpError)||u.code!==jYe.ErrorCode.RequestTimeout)&&this.logger.debug("MCP keep-alive ping failed:",u)}),C2r);let c=this.keepAliveTimer.unref;typeof c=="function"&&c.call(this.keepAliveTimer)}isConnected(){return this.mcpServer.isConnected()}async ping(){await this.mcpServer.server.request({method:"ping"},jYe.EmptyResultSchema,{timeout:R2r})}listTools(){return[...this.tools.values()]}hasTool(i){return this.tools.has(i)}listResources(){return[...this.resources.values()]}listPrompts(){return[...this.prompts.values()]}getRawServer(){return this.mcpServer}dispose(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=void 0),this.mcpServer.close()}},n(GB,"DefaultGLSPMcpServer"),GB);ib.DefaultGLSPMcpServer=PYe;ib.DefaultGLSPMcpServer=PYe=M2r([(0,wye.injectable)(),OYe(0,(0,wye.unmanaged)()),OYe(1,(0,wye.unmanaged)()),OYe(2,(0,wye.unmanaged)()),A2r("design:paramtypes",[$2r.McpServer,Object,k2r.Logger])],PYe)});var Sye=Z(_ye=>{"use strict";Object.defineProperty(_ye,"__esModule",{value:!0});_ye.LruEventStore=void 0;var JQ=class JQ{constructor(i=JQ.DEFAULT_LIMIT,c){if(this.events=new Map,i<1)throw new Error(`LruEventStore limit must be >= 1, got ${i}`);this.limit=i,this.logger=c}get size(){return this.events.size}async storeEvent(i,c){let u=`${i}_${Date.now()}_${Math.random().toString(36).substring(2,10)}`;if(this.events.set(u,{streamId:i,message:c}),this.events.size>this.limit){let f=this.events.keys().next().value;f!==void 0&&this.events.delete(f)}return u}async replayEventsAfter(i,{send:c}){var b;if(!i)return"";if(!this.events.has(i))return(b=this.logger)==null||b.warn(`[LruEventStore] Replay miss for last-event-id '${i}'. Cap is ${this.limit}; consider increasing \`eventStoreLimit\` if this fires under normal load.`),"";let u=i.split("_")[0];if(!u)return"";let f=!1;for(let[y,{streamId:w,message:T}]of this.events)if(w===u){if(y===i){f=!0;continue}f&&await c(y,T)}return u}};n(JQ,"LruEventStore"),JQ.DEFAULT_LIMIT=1e4;var IYe=JQ;_ye.LruEventStore=IYe});var Eye=Z(ob=>{"use strict";var VQ=ob&&ob.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},TYe=ob&&ob.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ob,"__esModule",{value:!0});ob.McpDiagramPromptHandlerRegistryInitializer=ob.McpDiagramPromptHandlerRegistry=ob.McpDiagramPromptHandlerFactory=void 0;var D2r=Vr(),JB=cn(),N2r=oT();ob.McpDiagramPromptHandlerFactory=Symbol("McpDiagramPromptHandlerFactory");var ZB,KQ=(ZB=class extends D2r.Registry{registerHandler(i){return this.register(i.name,i)}},n(ZB,"McpDiagramPromptHandlerRegistry"),ZB);ob.McpDiagramPromptHandlerRegistry=KQ;ob.McpDiagramPromptHandlerRegistry=KQ=VQ([(0,JB.injectable)()],KQ);var HB,KB=(HB=class{constructor(){this.constructors=[]}initialize(i){for(let c of this.constructors)try{this.registry.registerHandler(this.factory(c))}catch(u){throw new Error(`Failed to instantiate MCP diagram prompt handler '${c.name}': ${u.message}. Check your DiagramModule bindings.`)}}},n(HB,"McpDiagramPromptHandlerRegistryInitializer"),HB);ob.McpDiagramPromptHandlerRegistryInitializer=KB;VQ([(0,JB.inject)(ob.McpDiagramPromptHandlerFactory),TYe("design:type",Function)],KB.prototype,"factory",void 0);VQ([(0,JB.inject)(N2r.McpDiagramPromptHandlerConstructor),(0,JB.optional)(),TYe("design:type",Array)],KB.prototype,"constructors",void 0);VQ([(0,JB.inject)(KQ),TYe("design:type",KQ)],KB.prototype,"registry",void 0);ob.McpDiagramPromptHandlerRegistryInitializer=KB=VQ([(0,JB.injectable)()],KB)});var yT=Z(Fp=>{"use strict";var wT=Fp&&Fp.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},QB=Fp&&Fp.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(Fp,"__esModule",{value:!0});Fp.McpDiagramResourceHandlerConstructor=Fp.AbstractMcpDiagramResourceHandler=Fp.AbstractMcpResourceHandler=Fp.McpResourceHandler=void 0;Fp.toParams=Xdn;var WQ=Vr(),q2r=HQ(),DO=cn(),MYe=Dd(),L2r=zD(),Wdn=rT();Fp.McpResourceHandler=Symbol("McpResourceHandler");var VB,YB=(VB=class{constructor(){this.requestContext=new Wdn.NoopMcpRequestContext}toAnnotations(){if(!(this.audience===void 0&&this.priority===void 0&&this.lastModified===void 0))return{...this.audience!==void 0?{audience:this.audience}:{},...this.priority!==void 0?{priority:this.priority}:{},...this.lastModified!==void 0?{lastModified:this.lastModified}:{}}}uriTemplate(){return typeof this.uri=="string"?this.uri:this.uri.template}expandUriTemplate(i){return this.uriTemplate().replace(/\{(\w+)\}/g,(c,u)=>{let f=i[u];return f===void 0?c:encodeURIComponent(f)})}async execute(i){try{return{ok:!0,body:await i()}}catch(c){if(c instanceof MYe.McpToolError)return{ok:!1,message:c.message};let u=(0,MYe.extractErrorMessage)(c);return this.logger.error(`Unexpected error in resource '${this.name}': ${u}`,c),{ok:!1,message:u}}}toResourceResult(i,c){return c.ok?{contents:["text"in c.body?{uri:i,mimeType:this.mimeType,text:c.body.text}:{uri:i,mimeType:this.mimeType,blob:c.body.blob}],isError:!1}:{contents:[{uri:i,mimeType:"text/plain",text:c.message}],isError:!0}}toToolResult(i){if(!i.ok)return{isError:!0,content:[{type:"text",text:i.message}]};let c=i.body.structured,u="text"in i.body?{isError:!1,content:[{type:"text",text:i.body.text}]}:{isError:!1,content:[{type:"image",data:i.body.blob,mimeType:this.mimeType}]};return c?{...u,structuredContent:c}:u}buildResourceTemplate(i){var c;return new q2r.ResourceTemplate(i,{list:this.list?async u=>this.requestContext.run(u,()=>this.list()):void 0,complete:(c=this.complete)==null?void 0:c.call(this)})}},n(VB,"BaseMcpResourceHandler"),VB);wT([(0,DO.inject)(Wdn.McpRequestContext),(0,DO.optional)(),QB("design:type",Object)],YB.prototype,"requestContext",void 0);wT([(0,DO.inject)(WQ.Logger),QB("design:type",WQ.Logger)],YB.prototype,"logger",void 0);YB=wT([(0,DO.injectable)()],YB);var WB,AYe=(WB=class extends YB{registerResource(i){let c=this.toAnnotations(),u={title:this.title,description:this.description,mimeType:this.mimeType,...c?{annotations:c}:{}};if(typeof this.uri=="string"){let f=this.uri;i.registerResource(this.name,f,u,async(b,y)=>this.requestContext.run(y,async()=>this.toResourceResult(f,await this.execute(()=>this.createResult({})))))}else i.registerResource(this.name,this.buildResourceTemplate(this.uri.template),u,async(f,b,y)=>this.requestContext.run(y,async()=>this.toResourceResult(f.toString(),await this.execute(()=>this.createResult(Xdn(b))))))}registerToolAlternative(i){this.toolAlternativeInputSchema&&this.doRegisterToolAlternative(i)}doRegisterToolAlternative(i){let c=this.toolAlternativeInputSchema;i.registerTool(this.name,{title:this.title,description:this.description,inputSchema:c.strict(),outputSchema:this.toolAlternativeOutputSchema},async(u,f)=>this.requestContext.run(f,async()=>this.toToolResult(await this.execute(()=>this.createResult(u)))))}},n(WB,"AbstractMcpResourceHandler"),WB);Fp.AbstractMcpResourceHandler=AYe;Fp.AbstractMcpResourceHandler=AYe=wT([(0,DO.injectable)()],AYe);var XB,E9=(XB=class extends YB{requestAction(i,c,u=this.name){return(0,MYe.requestActionOrFail)(this.actionDispatcher,i,c,u)}isSupportedByDiagramType(){return!0}canRegister(){return!0}list(){return{resources:[this.toListingEntry()]}}complete(){return this.uriTemplate().includes("{sessionId}")?{sessionId:n(async()=>[this.clientId],"sessionId")}:{}}toListingEntry(){var c;let i=this.toAnnotations();return{uri:this.expandUriTemplate({sessionId:this.clientId}),name:`${(c=this.title)!=null?c:this.name}: ${this.clientId}`,description:this.description,mimeType:this.mimeType,...i?{annotations:i}:{}}}async handleRead(i,c){return this.toResourceResult(i,await this.execute(()=>this.createResult(c)))}async handleAsTool(i){return this.toToolResult(await this.execute(()=>this.createResult(i)))}glspSessionScopedComplete(){var b,y;let i=(y=(b=this.complete)==null?void 0:b.call(this))!=null?y:{},c=this.clientId,u=typeof this.uri=="object"&&this.uri.template.includes("{sessionId}"),f={};for(let[w,T]of Object.entries(i))f[w]=w==="sessionId"||!u?T:async(A,C)=>{var I;return((I=C==null?void 0:C.arguments)==null?void 0:I.sessionId)===c?T(A,C):[]};return f}},n(XB,"AbstractMcpDiagramResourceHandler"),XB);Fp.AbstractMcpDiagramResourceHandler=E9;wT([(0,DO.inject)(WQ.ClientId),QB("design:type",String)],E9.prototype,"clientId",void 0);wT([(0,DO.inject)(WQ.ModelState),QB("design:type",Object)],E9.prototype,"modelState",void 0);wT([(0,DO.inject)(L2r.McpIdAliasService),QB("design:type",Object)],E9.prototype,"aliasService",void 0);wT([(0,DO.inject)(WQ.ActionDispatcher),QB("design:type",Object)],E9.prototype,"actionDispatcher",void 0);Fp.AbstractMcpDiagramResourceHandler=E9=wT([(0,DO.injectable)()],E9);function Xdn(s){var c;let i={};for(let[u,f]of Object.entries(s))i[u]=Array.isArray(f)?(c=f[0])!=null?c:"":f;return i}n(Xdn,"toParams");Fp.McpDiagramResourceHandlerConstructor=Symbol("McpDiagramResourceHandlerConstructor")});var Oye=Z(sb=>{"use strict";var O9=sb&&sb.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},QQ=sb&&sb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(sb,"__esModule",{value:!0});sb.McpDiagramResourceHandlerRegistryInitializer=sb.McpDiagramResourceHandlerRegistry=sb.McpDiagramResourceHandlerFactory=void 0;var XQ=Vr(),JA=cn(),x2r=yT();sb.McpDiagramResourceHandlerFactory=Symbol("McpDiagramResourceHandlerFactory");var eF,YQ=(eF=class extends XQ.Registry{registerHandler(i){return this.register(i.name,i)}},n(eF,"McpDiagramResourceHandlerRegistry"),eF);sb.McpDiagramResourceHandlerRegistry=YQ;sb.McpDiagramResourceHandlerRegistry=YQ=O9([(0,JA.injectable)()],YQ);var tF,KA=(tF=class{constructor(){this.constructors=[]}initialize(i){let c=this.clientId===XQ.TEMPORARY_CLIENT_ID;for(let u of this.constructors){let f;try{f=this.factory(u)}catch(b){throw new Error(`Failed to instantiate MCP diagram resource handler '${u.name}': ${b.message}. Check your DiagramModule bindings.`)}if(!f.canRegister()){c||this.logger.debug(`Skipping MCP diagram resource handler '${f.name}': canRegister() returned false.`);continue}this.registry.registerHandler(f)}}},n(tF,"McpDiagramResourceHandlerRegistryInitializer"),tF);sb.McpDiagramResourceHandlerRegistryInitializer=KA;O9([(0,JA.inject)(sb.McpDiagramResourceHandlerFactory),QQ("design:type",Function)],KA.prototype,"factory",void 0);O9([(0,JA.inject)(x2r.McpDiagramResourceHandlerConstructor),(0,JA.optional)(),QQ("design:type",Array)],KA.prototype,"constructors",void 0);O9([(0,JA.inject)(YQ),QQ("design:type",YQ)],KA.prototype,"registry",void 0);O9([(0,JA.inject)(XQ.ClientId),QQ("design:type",String)],KA.prototype,"clientId",void 0);O9([(0,JA.inject)(XQ.Logger),QQ("design:type",XQ.Logger)],KA.prototype,"logger",void 0);sb.McpDiagramResourceHandlerRegistryInitializer=KA=O9([(0,JA.injectable)()],KA)});var jye=Z(cb=>{"use strict";var j9=cb&&cb.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},nee=cb&&cb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(cb,"__esModule",{value:!0});cb.McpDiagramToolHandlerRegistryInitializer=cb.McpDiagramToolHandlerRegistry=cb.McpDiagramToolHandlerFactory=void 0;var eee=Vr(),VA=cn(),z2r=Xu();cb.McpDiagramToolHandlerFactory=Symbol("McpDiagramToolHandlerFactory");var nF,tee=(nF=class extends eee.Registry{registerHandler(i){return this.register(i.name,i)}},n(nF,"McpDiagramToolHandlerRegistry"),nF);cb.McpDiagramToolHandlerRegistry=tee;cb.McpDiagramToolHandlerRegistry=tee=j9([(0,VA.injectable)()],tee);var rF,WA=(rF=class{constructor(){this.constructors=[]}initialize(i){let c=this.clientId===eee.TEMPORARY_CLIENT_ID;for(let u of this.constructors){let f;try{f=this.factory(u)}catch(b){throw new Error(`Failed to instantiate MCP diagram tool handler '${u.name}': ${b.message}. Check your DiagramModule bindings.`)}if(!f.canRegister()){c||this.logger.debug(`Skipping MCP diagram tool handler '${f.name}': canRegister() returned false.`);continue}this.registry.registerHandler(f)}}},n(rF,"McpDiagramToolHandlerRegistryInitializer"),rF);cb.McpDiagramToolHandlerRegistryInitializer=WA;j9([(0,VA.inject)(cb.McpDiagramToolHandlerFactory),nee("design:type",Function)],WA.prototype,"factory",void 0);j9([(0,VA.inject)(z2r.McpDiagramToolHandlerConstructor),(0,VA.optional)(),nee("design:type",Array)],WA.prototype,"constructors",void 0);j9([(0,VA.inject)(tee),nee("design:type",tee)],WA.prototype,"registry",void 0);j9([(0,VA.inject)(eee.ClientId),nee("design:type",String)],WA.prototype,"clientId",void 0);j9([(0,VA.inject)(eee.Logger),nee("design:type",eee.Logger)],WA.prototype,"logger",void 0);cb.McpDiagramToolHandlerRegistryInitializer=WA=j9([(0,VA.injectable)()],WA)});var Pye=Z(oS=>{"use strict";var oF=oS&&oS.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},ree=oS&&oS.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(oS,"__esModule",{value:!0});oS.DefaultMcpDiagramHandlerDispatcher=oS.McpDiagramHandlerDispatcher=void 0;var P9=Vr(),B2r=HQ(),YA=cn(),F2r=Eye(),Ydn=Oye(),U2r=jye(),XA=Dd(),G2r=oT(),ehn=rT(),kYe=yT(),Qdn=Xu();oS.McpDiagramHandlerDispatcher=Symbol("McpDiagramHandlerDispatcher");var iF,QA=(iF=class{constructor(){this.requestContext=new ehn.NoopMcpRequestContext,this.diagramCatalogs=[]}harvest(){if(this.diagramCatalogs.length>0)return;let i=[],c=(0,P9.createClientSessionModule)({clientId:P9.TEMPORARY_CLIENT_ID,glspClient:{process:n(()=>{},"process")},clientActionKinds:[]});for(let[u,f]of this.diagramModules){let b=this.serverContainer.createChild();b.load(...f,c);let y=this.filterSupported(b,$Ye(b,Qdn.McpDiagramToolHandlerConstructor),u,Qdn.BaseMcpDiagramToolHandler.prototype.isSupportedByDiagramType),w=this.filterSupported(b,$Ye(b,kYe.McpDiagramResourceHandlerConstructor),u,kYe.AbstractMcpDiagramResourceHandler.prototype.isSupportedByDiagramType),T=$Ye(b,G2r.McpDiagramPromptHandlerConstructor);b.unbindAll(),i.push({diagramType:u,toolConstructors:y,resourceConstructors:w,promptConstructors:T})}this.diagramCatalogs=i}filterSupported(i,c,u,f){return c.filter(b=>{let y=b.prototype.isSupportedByDiagramType;if(typeof y!="function"||y===f)return!0;try{return i.resolve(b).isSupportedByDiagramType()?!0:(this.logger.debug(`Diagram type '${u}' does not support MCP handler '${b.name}'; not registering.`),!1)}catch(w){return this.logger.debug(`Could not probe MCP handler '${b.name}' for diagram type '${u}'; registering.`,w),!0}})}hasDiagramTools(){return this.diagramCatalogs.some(i=>i.toolConstructors.length>0)}hasDiagramResources(){return this.diagramCatalogs.some(i=>i.resourceConstructors.length>0)}hasDiagramPrompts(){return this.diagramCatalogs.some(i=>i.promptConstructors.length>0)}registerAll(i,c){this.registerDiagramScopeTools(i),this.registerDiagramScopeResources(i,c),this.registerDiagramScopePrompts(i)}registerDiagramScopeTools(i){var u,f;let c=new Map;for(let b of this.diagramCatalogs)for(let y of b.toolConstructors){let w=new y,T={description:w.description,inputKeys:Object.keys((f=(u=w.inputSchema)==null?void 0:u.shape)!=null?f:{}).sort().join(","),diagramType:b.diagramType},A=c.get(w.name);if(A){(A.description!==T.description||A.inputKeys!==T.inputKeys)&&this.logger.warn(`Diagram-scope tool '${w.name}' is registered by multiple diagram types with diverging schemas: first registered by '${A.diagramType}', shadowed registration from '${b.diagramType}' is silently dropped. Either align schemas (description + inputSchema.shape keys must match) or pick distinct tool names.`);continue}c.set(w.name,T),i.registerTool(w.name,w.toRegistrationConfig(),(C,I)=>this.requestContext.run(I,()=>this.dispatchDiagramTool(w.name,C)))}}registerDiagramScopeResources(i,c){let u=new Set;for(let f of this.diagramCatalogs)for(let b of f.resourceConstructors){let y=new b;u.has(y.name)||(u.add(y.name),c?this.registerOneDiagramResource(i,y):y.toolAlternativeInputSchema&&this.registerOneDiagramResourceAsTool(i,y))}}registerOneDiagramResource(i,c){let u=c.name,f=c.toAnnotations(),b={title:c.title,description:c.description,mimeType:c.mimeType,...f?{annotations:f}:{}};if(typeof c.uri=="string"){let y=c.uri;i.registerResource(u,y,b,(w,T)=>this.requestContext.run(T,()=>this.dispatchStaticDiagramRead(u,y)))}else{let y=this.buildAggregatingResourceTemplate(c.uri.template,u);i.registerResource(u,y,b,(w,T,A)=>this.requestContext.run(A,()=>this.dispatchTemplatedDiagramRead(u,w,T)))}}registerOneDiagramResourceAsTool(i,c){let u=c.name,f=c.toolAlternativeInputSchema;i.registerTool(u,{title:c.title,description:c.description,inputSchema:f.strict(),outputSchema:c.toolAlternativeOutputSchema},(b,y)=>this.requestContext.run(y,()=>this.dispatchDiagramResourceAsTool(u,b)))}registerDiagramScopePrompts(i){let c=new Set;for(let u of this.diagramCatalogs)for(let f of u.promptConstructors){let b=new f;c.has(b.name)||(c.add(b.name),i.registerPrompt(b.name,b.toRegistrationConfig(),(y,w)=>this.requestContext.run(w,()=>this.dispatchDiagramPrompt(b.name,y))))}}buildAggregatingResourceTemplate(i,c){return new B2r.ResourceTemplate(i,{list:n(u=>this.requestContext.run(u,()=>this.aggregateList(c)),"list"),complete:this.buildAggregatedCompleters(c)})}async aggregateList(i){var f;let c=[],u=new Set;for(let b of this.clientSessionManager.getSessions().map(y=>y.id)){let y=this.findDiagramResourceHandler(i,b),w=await((f=y==null?void 0:y.list)==null?void 0:f.call(y));if(w)for(let T of w.resources)u.has(T.uri)||(u.add(T.uri),c.push(T))}return{resources:c}}buildAggregatedCompleters(i){let c=this.collectCompleterVariableNames(i),u={};for(let f of c)u[f]=async(b,y)=>{let w=new Set;for(let T of this.clientSessionManager.getSessions().map(A=>A.id)){let A=this.findDiagramResourceHandler(i,T);if(!A)continue;let I=A.glspSessionScopedComplete()[f];if(!I)continue;(await I(b,y)).forEach(G=>w.add(G))}return[...w]};return u}collectCompleterVariableNames(i){var u,f;let c=new Set;for(let b of this.diagramCatalogs)for(let y of b.resourceConstructors){let w=new y;w.name===i&&Object.keys((f=(u=w.complete)==null?void 0:u.call(w))!=null?f:{}).forEach(T=>c.add(T))}return c}dispatchDiagramTool(i,c){return(0,XA.runWithToolErrorEnvelope)(async()=>this.requireDiagramToolHandler(i,c).handle(c))}dispatchStaticDiagramRead(i,c){var b;let u=(b=this.clientSessionManager.getSessions()[0])==null?void 0:b.id;if(!u)throw new XA.McpToolError(`No open GLSP session can serve resource '${i}'.`);return this.requireDiagramResourceHandler(i,u).handleRead(c,{sessionId:u})}dispatchTemplatedDiagramRead(i,c,u){let f=(0,kYe.toParams)(u);return this.requireDiagramResourceHandler(i,f.sessionId).handleRead(c.toString(),f)}dispatchDiagramResourceAsTool(i,c){return(0,XA.runWithToolErrorEnvelope)(async()=>this.requireDiagramResourceHandler(i,this.extractSessionId(c)).handleAsTool(c))}dispatchDiagramPrompt(i,c){return this.requireDiagramPromptHandler(i,c).handle(c)}extractSessionId(i){return i.sessionId}requireDiagramToolHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(U2r.McpDiagramToolHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No tool handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireDiagramResourceHandler(i,c){let u=this.requireGlspSession(c),b=u.container.get(Ydn.McpDiagramResourceHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No resource handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}findDiagramResourceHandler(i,c){let u=this.clientSessionManager.getSession(c);if(u)return u.container.get(Ydn.McpDiagramResourceHandlerRegistry).get(i)}requireDiagramPromptHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(F2r.McpDiagramPromptHandlerRegistry).get(i);if(!b)throw new XA.McpToolError(`No prompt handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireGlspSession(i){if(!i)throw new XA.McpMissingParamError("sessionId");let c=this.clientSessionManager.getSession(i);if(!c)throw new XA.McpSessionNotFoundError(i);return c}reset(){this.diagramCatalogs=[]}},n(iF,"DefaultMcpDiagramHandlerDispatcher"),iF);oS.DefaultMcpDiagramHandlerDispatcher=QA;oF([(0,YA.inject)(ehn.McpRequestContext),(0,YA.optional)(),ree("design:type",Object)],QA.prototype,"requestContext",void 0);oF([(0,YA.inject)(P9.InjectionContainer),ree("design:type",YA.Container)],QA.prototype,"serverContainer",void 0);oF([(0,YA.inject)(P9.DiagramModules),ree("design:type",Map)],QA.prototype,"diagramModules",void 0);oF([(0,YA.inject)(P9.ClientSessionManager),ree("design:type",Object)],QA.prototype,"clientSessionManager",void 0);oF([(0,YA.inject)(P9.Logger),ree("design:type",P9.Logger)],QA.prototype,"logger",void 0);oS.DefaultMcpDiagramHandlerDispatcher=QA=oF([(0,YA.injectable)()],QA);function $Ye(s,i){return s.isBound(i)?s.get(i):[]}n($Ye,"getConstructorList")});var iee=Z(NO=>{"use strict";var Z2r=NO&&NO.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},Iye;Object.defineProperty(NO,"__esModule",{value:!0});NO.DefaultMcpLogLevelRegistry=NO.McpLogLevelRegistry=void 0;NO.passesLogThreshold=J2r;var H2r=cn();NO.McpLogLevelRegistry=Symbol("McpLogLevelRegistry");var thn={emergency:0,alert:1,critical:2,error:3,warning:4,notice:5,info:6,debug:7};function J2r(s,i){return thn[s]<=thn[i]}n(J2r,"passesLogThreshold");var ek,CYe=(ek=class{constructor(){this.levels=new Map}setLevel(i,c){this.levels.set(i,c)}getLevel(i){var c;return i===void 0?Iye.DEFAULT_LEVEL:(c=this.levels.get(i))!=null?c:Iye.DEFAULT_LEVEL}clear(i){this.levels.delete(i)}},n(ek,"DefaultMcpLogLevelRegistry"),Iye=ek,ek.DEFAULT_LEVEL="debug",ek);NO.DefaultMcpLogLevelRegistry=CYe;NO.DefaultMcpLogLevelRegistry=CYe=Iye=Z2r([(0,H2r.injectable)()],CYe)});var Tye=Z(_T=>{"use strict";var K2r=_T&&_T.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b};Object.defineProperty(_T,"__esModule",{value:!0});_T.McpServerDefaults=_T.McpServerOptions=void 0;var V2r=cn(),sF,RYe=(sF=class{constructor(){this.values={}}},n(sF,"McpServerOptions"),sF);_T.McpServerOptions=RYe;_T.McpServerOptions=RYe=K2r([(0,V2r.injectable)()],RYe);_T.McpServerDefaults=Symbol("McpServerDefaults")});var Aye=Z(mv=>{"use strict";var sS=mv&&mv.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},LO=mv&&mv.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(mv,"__esModule",{value:!0});mv.AbstractMcpServerLauncher=mv.SERVER_VERSION=void 0;mv.pickInitOptions=nhn;var qO=Vr(),W2r=HQ(),X2r=Kdn(),Mye=CA(),zm=cn(),Y2r=Vdn(),Q2r=yye(),eSr=Sye(),tSr=Pye(),nSr=iee(),DYe=Tye(),rSr=oT(),iSr=yT(),oSr=Xu();mv.SERVER_VERSION=Y2r.version;function nhn(s){let{dataMode:i,agentPersona:c,eventStoreLimit:u}=s,f={};return i!==void 0&&(f.dataMode=i),c!==void 0&&(f.agentPersona=c),u!==void 0&&(f.eventStoreLimit=u),f}n(nhn,"pickInitOptions");var sSr=null,cF,bv=(cF=class{constructor(){this.toolHandlers=[],this.resourceHandlers=[],this.promptHandlers=[],this.toDispose=new qO.DisposableCollection,this.sessions=new Map,this.sessionServers=new Map,this.onSessionInitializedEmitter=new qO.Emitter,this.onSessionInitialized=this.onSessionInitializedEmitter.event,this.onSessionClosedEmitter=new qO.Emitter,this.onSessionClosed=this.onSessionClosedEmitter.event}async initializeServer(i,c,u){var G,oe;let f=qO.McpInitializeParameters.getServerConfig(c);if(!f)return u;if(this.serverConfig)return this.serverUrl?qO.McpInitializeResult.attachServer(u,{name:this.serverConfig.name,url:this.serverUrl}):u;let{port:b=0,route:y="/mcp",name:w="glsp",options:T={}}=f,A={...this.mcpDefaults,...nhn(T)};this.mcpOptions.values=A;let C=(G=A.host)!=null?G:"127.0.0.1",I={port:b,host:C,route:y,name:w,options:A};this.dispatcher.harvest(),this.installResourceListChangedNotifier();let R=await this.bindTransport(I);return this.serverConfig=I,this.serverUrl=R.url,this.logger.info(`MCP server '${I.name}' is ready to accept new client requests on: ${(oe=this.serverUrl)!=null?oe:"(no network endpoint)"}`),R.url?qO.McpInitializeResult.attachServer(u,{name:I.name,url:R.url,headers:R.headers}):u}serverShutDown(i){this.dispose()}dispose(){let i=Array.from(this.sessions.values()).map(c=>c.close().catch(u=>this.logger.warn(`Error closing MCP session ${c.sessionId}: ${u}`)));this.sessions.clear(),this.sessionServers.forEach(c=>c.dispose()),this.sessionServers.clear(),Promise.allSettled(i).then(()=>{this.toDispose.dispose(),this.toDispose.clear()}),this.serverUrl=void 0,this.serverConfig=void 0,this.dispatcher.reset()}async handleRequest(i,c){var C,I;let u=new URL(i.url),f=(I=(C=this.serverConfig)==null?void 0:C.route)!=null?I:"/mcp";if(u.pathname!==f)return new Response("Not Found",{status:404});if(i.method!=="POST"&&i.method!=="GET"&&i.method!=="DELETE")return new Response("Method Not Allowed",{status:405,headers:{Allow:"POST, GET, DELETE"}});let b=this.validateHostHeader(i);if(b)return b;let y;i.method==="POST"&&(y=await i.clone().json().catch(()=>{}));let w=i.method==="POST"&&(0,Mye.isInitializeRequest)(y),T=this.validateProtocolVersionHeader(i,w);if(T)return T;let A=this.resolveTransport(i,w);if(A instanceof Response)return A;try{return await A.handleRequest(i,{parsedBody:y,authInfo:c==null?void 0:c.authInfo})}catch(R){let G=R instanceof Error?R.message:String(R);return this.logger.error("Error handling MCP request:",R),this.jsonRpcErrorResponse(500,-32603,`Internal server error: ${G}`)}}getRequestHandler(){return(i,c)=>this.handleRequest(i,c)}resolveTransport(i,c){var b;let u=(b=i.headers.get("mcp-session-id"))!=null?b:void 0;if(c&&!u)return this.createTransport();if(!u)return this.jsonRpcErrorResponse(400,-32e3,"Bad Request: No valid session ID provided");let f=this.sessions.get(u);return f||this.jsonRpcErrorResponse(404,-32001,"Session not found")}validateProtocolVersionHeader(i,c){var f;if(c)return;let u=(f=i.headers.get("mcp-protocol-version"))!=null?f:void 0;if(u!==void 0&&!Mye.SUPPORTED_PROTOCOL_VERSIONS.includes(u))return this.jsonRpcErrorResponse(400,-32e3,`Unsupported MCP-Protocol-Version: '${u}'. Supported versions: ${Mye.SUPPORTED_PROTOCOL_VERSIONS.join(", ")}.`)}validateHostHeader(i){let c=this.mcpOptions.values.allowedHosts;if(!c||c.length===0)return;let u=i.headers.get("host");if(!u)return this.jsonRpcErrorResponse(403,-32e3,"Missing Host header");let f;try{f=new URL(`http://${u}`).hostname}catch{return this.jsonRpcErrorResponse(403,-32e3,`Invalid Host header: ${u}`)}if(!c.includes(f))return this.jsonRpcErrorResponse(403,-32e3,`Invalid Host: ${f}`)}createTransport(){var u;let i=this.mcpOptions.values.allowedOrigins,c=new X2r.WebStandardStreamableHTTPServerTransport({sessionIdGenerator:n(()=>globalThis.crypto.randomUUID(),"sessionIdGenerator"),eventStore:new eSr.LruEventStore(this.mcpOptions.values.eventStoreLimit,this.logger),allowedOrigins:i,enableDnsRebindingProtection:((u=i==null?void 0:i.length)!=null?u:0)>0,onsessioninitialized:n(f=>{this.logger.info(`MCP session initialized with ID: ${f}`),this.sessions.set(f,c),this.serverConfig&&this.attachServerToSession(c,this.serverConfig),this.onSessionInitializedEmitter.fire(c)},"onsessioninitialized"),onsessionclosed:n(f=>this.closeSession(f),"onsessionclosed")});return c.onclose=()=>this.closeSession(c.sessionId),c.onerror=f=>{var b;return this.logger.error(`MCP transport error (session ${(b=c.sessionId)!=null?b:"<pre-init>"}):`,f)},c}attachServerToSession(i,c){let u=i.sessionId;if(!u)return;let f=this.createGlspMcpServer(c);this.sessionServers.set(u,f),this.registerLogLevelHandler(f,u),f.connect(i)}closeSession(i){if(!i)return;let c=this.sessions.delete(i),u=this.sessionServers.get(i);u&&(this.sessionServers.delete(i),this.logLevelRegistry.clear(i),u.dispose()),c&&(this.logger.info(`MCP session closed: ${i}`),this.onSessionClosedEmitter.fire(i))}installResourceListChangedNotifier(){if(!this.dispatcher.hasDiagramResources())return;let i={sessionCreated:n(()=>this.broadcastResourceListChanged(),"sessionCreated"),sessionDisposed:n(()=>this.broadcastResourceListChanged(),"sessionDisposed")};this.clientSessionManager.addListener(i),this.toDispose.push(qO.Disposable.create(()=>this.clientSessionManager.removeListener(i)))}broadcastResourceListChanged(){for(let i of this.sessionServers.values())i.getRawServer().server.sendResourceListChanged().catch(c=>this.logger.debug("sendResourceListChanged failed:",c))}registerLogLevelHandler(i,c){i.getRawServer().server.setRequestHandler(Mye.SetLevelRequestSchema,async u=>(this.logLevelRegistry.setLevel(c,u.params.level),{}))}createGlspMcpServer({name:i,options:c}){let u=c.dataMode==="resources",f=new W2r.McpServer({name:i,version:mv.SERVER_VERSION},{capabilities:this.buildCapabilities(u),instructions:c.agentPersona}),b=this.glspMcpServerFactory(f,c);return this.registerHandlers(b,u),b}buildCapabilities(i){let c=this.toolHandlers.length>0,u=this.promptHandlers.length>0,f=this.resourceHandlers.length>0,b=this.dispatcher.hasDiagramTools(),y=this.dispatcher.hasDiagramPrompts(),w=this.dispatcher.hasDiagramResources(),T=f||w;return{logging:{},...c||b||!i&&T?{tools:{listChanged:!1}}:{},...i&&T?{resources:{listChanged:w}}:{},...u||y?{prompts:{listChanged:!1}}:{}}}registerHandlers(i,c){this.toolHandlers.forEach(u=>u.registerTool(i)),this.promptHandlers.forEach(u=>u.registerPrompt(i)),c?this.resourceHandlers.forEach(u=>u.registerResource(i)):this.resourceHandlers.forEach(u=>{var f;return(f=u.registerToolAlternative)==null?void 0:f.call(u,i)}),this.dispatcher.registerAll(i,c),this.validatePromptToolReferences(i)}validatePromptToolReferences(i){for(let c of this.promptHandlers){let u=c.referencedToolNames().filter(f=>!i.hasTool(f));u.length>0&&this.logger.warn(`Prompt '${c.name}' references unbound tool(s): ${u.join(", ")}. The prompt will still register but its text points at tools the LLM cannot invoke.`)}}jsonRpcErrorResponse(i,c,u){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:c,message:u},id:sSr}),{status:i,headers:{"Content-Type":"application/json"}})}},n(cF,"AbstractMcpServerLauncher"),cF);mv.AbstractMcpServerLauncher=bv;sS([(0,zm.inject)(qO.Logger),LO("design:type",qO.Logger)],bv.prototype,"logger",void 0);sS([(0,zm.inject)(DYe.McpServerOptions),LO("design:type",DYe.McpServerOptions)],bv.prototype,"mcpOptions",void 0);sS([(0,zm.inject)(DYe.McpServerDefaults),LO("design:type",Object)],bv.prototype,"mcpDefaults",void 0);sS([(0,zm.inject)(Q2r.GLSPMcpServerFactory),LO("design:type",Function)],bv.prototype,"glspMcpServerFactory",void 0);sS([(0,zm.inject)(tSr.McpDiagramHandlerDispatcher),LO("design:type",Object)],bv.prototype,"dispatcher",void 0);sS([(0,zm.inject)(nSr.McpLogLevelRegistry),LO("design:type",Object)],bv.prototype,"logLevelRegistry",void 0);sS([(0,zm.inject)(qO.ClientSessionManager),LO("design:type",Object)],bv.prototype,"clientSessionManager",void 0);sS([(0,zm.multiInject)(oSr.McpToolHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"toolHandlers",void 0);sS([(0,zm.multiInject)(iSr.McpResourceHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"resourceHandlers",void 0);sS([(0,zm.multiInject)(rSr.McpPromptHandler),(0,zm.optional)(),LO("design:type",Array)],bv.prototype,"promptHandlers",void 0);mv.AbstractMcpServerLauncher=bv=sS([(0,zm.injectable)()],bv)});var $ye=Z(ST=>{"use strict";var kye=ST&&ST.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},NYe=ST&&ST.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ST,"__esModule",{value:!0});ST.McpLogger=void 0;var rhn=Vr(),oee=cn(),ihn=iee(),ohn=rT(),aF,uF=(aF=class{constructor(){this.requestContext=new ohn.NoopMcpRequestContext}info(i,...c){this.glspLogger.info(i,...c),this.notify("info",i)}warn(i,...c){this.glspLogger.warn(i,...c),this.notify("warning",i)}error(i,...c){this.glspLogger.error(i,...c),this.notify("error",i)}debug(i,...c){this.glspLogger.debug(i,...c),this.notify("debug",i)}notify(i,c){let u=this.requestContext.getStore();if(!u)return;let f=this.levelRegistry.getLevel(u.sessionId);(0,ihn.passesLogThreshold)(i,f)&&u.sendNotification({method:"notifications/message",params:{level:i,data:c}}).catch(()=>{})}},n(aF,"McpLogger"),aF);ST.McpLogger=uF;kye([(0,oee.inject)(ohn.McpRequestContext),(0,oee.optional)(),NYe("design:type",Object)],uF.prototype,"requestContext",void 0);kye([(0,oee.inject)(rhn.Logger),NYe("design:type",rhn.Logger)],uF.prototype,"glspLogger",void 0);kye([(0,oee.inject)(ihn.McpLogLevelRegistry),NYe("design:type",Object)],uF.prototype,"levelRegistry",void 0);ST.McpLogger=uF=kye([(0,oee.injectable)()],uF)});var see=Z(ET=>{"use strict";var shn=ET&&ET.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},cSr=ET&&ET.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ET,"__esModule",{value:!0});ET.McpProgressReporter=void 0;var qYe=cn(),chn=rT(),lF,Cye=(lF=class{constructor(){this.requestContext=new chn.NoopMcpRequestContext}async emit(i){var f;let c=this.requestContext.getStore(),u=(f=c==null?void 0:c._meta)==null?void 0:f.progressToken;if(!(c===void 0||u===void 0))try{await c.sendNotification({method:"notifications/progress",params:{progressToken:u,...i}})}catch{}}},n(lF,"McpProgressReporter"),lF);ET.McpProgressReporter=Cye;shn([(0,qYe.inject)(chn.McpRequestContext),(0,qYe.optional)(),cSr("design:type",Object)],Cye.prototype,"requestContext",void 0);ET.McpProgressReporter=Cye=shn([(0,qYe.injectable)()],Cye)});var zYe=Z(rp=>{"use strict";var ahn=rp&&rp.__decorate||function(s,i,c,u){var f=arguments.length,b=f<3?i:u===null?u=Object.getOwnPropertyDescriptor(i,c):u,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(s,i,c,u);else for(var w=s.length-1;w>=0;w--)(y=s[w])&&(b=(f<3?y(b):f>3?y(i,c,b):y(i,c))||b);return f>3&&b&&Object.defineProperty(i,c,b),b},aSr=rp&&rp.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},LYe;Object.defineProperty(rp,"__esModule",{value:!0});rp.SessionInfoMcpToolHandler=rp.SessionInfoOutputSchema=rp.SessionInfoRowSchema=rp.SessionInfoInputSchema=void 0;var xYe=Vr(),uhn=cn(),xO=Vu(),uSr=Dd(),lSr=Xu();rp.SessionInfoInputSchema=xO.object({sessionId:xO.string().optional().describe("Optional filter \u2014 returns only the matching session, or throws if unknown. Omit to list all sessions.")});rp.SessionInfoRowSchema=xO.object({sessionId:xO.string(),diagramType:xO.string(),sourceUri:xO.string(),readOnly:xO.boolean(),dirty:xO.boolean().describe("True when the diagram has unsaved changes \u2014 call `save-model` to persist.")});rp.SessionInfoOutputSchema=xO.object({sessions:xO.array(rp.SessionInfoRowSchema)});var tk,Rye=(tk=class extends lSr.AbstractMcpToolHandler{constructor(){super(...arguments),this.name=LYe.NAME,this.title="GLSP Session Info",this.description="Report info on the active GLSP client sessions: session id, diagram type, source uri, and read-only status. Pass `sessionId` to retrieve a single session's entry; omit it to list every active session. Useful as a discovery tool \u2014 most other diagram-scoped tools take the `sessionId` returned here.",this.inputSchema=rp.SessionInfoInputSchema,this.outputSchema=rp.SessionInfoOutputSchema}createResult({sessionId:i}){let u=(i!==void 0?this.singleSession(i):this.clientSessionManager.getSessions()).map(f=>this.buildSessionRow(f));return this.success(this.summarizeSessions(u),{sessions:u})}buildSessionRow(i){var f;let c=i.container.get(xYe.ModelState),u=i.container.get(xYe.CommandStack);return{sessionId:i.id,diagramType:i.diagramType,sourceUri:(f=c.sourceUri)!=null?f:"",readOnly:c.isReadonly,dirty:u.isDirty}}summarizeSessions(i){if(i.length===0)return"No active sessions.";let c=i.map(u=>{let f=[u.readOnly?"read-only":void 0,u.dirty?"dirty":void 0].filter(Boolean),b=f.length>0?`, ${f.join(", ")}`:"";return`- ${u.sessionId} (${u.diagramType}${b})`});return`${i.length} session(s); full details in structuredContent.
183
183
  ${c.join(`
184
184
  `)}`}singleSession(i){let c=this.clientSessionManager.getSession(i);if(!c)throw new uSr.McpToolError(`Unknown sessionId: ${i}`);return[c]}},n(tk,"SessionInfoMcpToolHandler"),LYe=tk,tk.NAME="session-info",tk);rp.SessionInfoMcpToolHandler=Rye;ahn([(0,uhn.inject)(xYe.ClientSessionManager),aSr("design:type",Object)],Rye.prototype,"clientSessionManager",void 0);rp.SessionInfoMcpToolHandler=Rye=LYe=ahn([(0,uhn.injectable)()],Rye)});var HYe=Z(cS=>{"use strict";Object.defineProperty(cS,"__esModule",{value:!0});cS.AbstractMcpServerModule=cS.McpHandlerMultiBinding=cS.DEFAULT_MCP_OPTIONS=cS.DEFAULT_AGENT_PERSONA=void 0;var Bm=Vr(),fSr=iKe(),dSr=aKe(),BYe=Aye(),lhn=yye(),hSr=Sye(),fhn=Pye(),dhn=iee(),hhn=$ye(),FYe=Tye(),phn=see(),pSr=oT(),gSr=rT(),bSr=yT(),mSr=Xu(),vSr=cve(),wSr=zYe();cS.DEFAULT_AGENT_PERSONA=`
185
185
  You are the GLSP Modeling Agent. Your primary goal is to assist in the creation and modification of graphical models using the