@eclipse-glsp-examples/workflow-server-bundled-web 2.8.0-next.6 → 2.8.0-next.7

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-next.6",
3
+ "version": "2.8.0-next.7",
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,q,G;try{let se=i.headers.get("accept");if(!(se!=null&&se.includes("application/json"))||!se.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 rt;try{Array.isArray(Ve)?rt=Ve.map(Ko=>tp.JSONRPCMessageSchema.parse(Ko)):rt=[tp.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 jt=rt.some(tp.isInitializeRequest);if(jt){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(rt.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(!jt){let Ko=this.validateSession(i);if(Ko)return Ko;let iu=this.validateProtocolVersion(i);if(iu)return iu}if(!rt.some(tp.isJSONRPCRequest)){for(let Ko of rt)(C=this.onmessage)==null||C.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te});return new Response(null,{status:202})}let ut=crypto.randomUUID(),Lt=rt.find(Ko=>(0,tp.isInitializeRequest)(Ko)),ar=Lt?Lt.params.protocolVersion:(I=i.headers.get("mcp-protocol-version"))!=null?I:tp.DEFAULT_NEGOTIATED_PROTOCOL_VERSION;if(this._enableJsonResponse)return new Promise(Ko=>{var iu;this._streamMapping.set(ut,{resolveJson:Ko,cleanup:n(()=>{this._streamMapping.delete(ut)},"cleanup")});for(let hd of rt)(0,tp.isJSONRPCRequest)(hd)&&this._requestToStreamMapping.set(hd.id,ut);for(let hd of rt)(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(ut)},"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 rt)(0,tp.isJSONRPCRequest)(Ko)&&(this._streamMapping.set(ut,{controller:Ei,encoder:lo,cleanup:n(()=>{this._streamMapping.delete(ut);try{Ei.close()}catch{}},"cleanup")}),this._requestToStreamMapping.set(Ko.id,ut));await this.writePrimingEvent(Ei,lo,ut,ar);for(let Ko of rt){let iu,hd;(0,tp.isJSONRPCRequest)(Ko)&&this._eventStore&&ar>="2025-11-25"&&(iu=n(()=>{this.closeSSEStream(Ko.id)},"closeSSEStream"),hd=n(()=>{this.closeStandaloneSSEStream()},"closeStandaloneSSEStream")),(q=this.onmessage)==null||q.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(se){return(G=this.onerror)==null||G.call(this,se),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(se)})}}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&&!tp.SUPPORTED_PROTOCOL_VERSIONS.includes(c))return(u=this.onerror)==null||u.call(this,new Error(`Bad Request: Unsupported protocol version: ${c} (supported versions: ${tp.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${c} (supported versions: ${tp.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,tp.isJSONRPCResultResponse)(i)||(0,tp.isJSONRPCErrorResponse)(i))&&(u=i.id),u===void 0){if((0,tp.isJSONRPCResultResponse)(i)||(0,tp.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,tp.isJSONRPCResultResponse)(i)||(0,tp.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(SYe,"WebStandardStreamableHTTPServerTransport");var _Ye=SYe;bye.WebStandardStreamableHTTPServerTransport=_Ye});var Kdn=Z((Upi,j2r)=>{j2r.exports={name:"@eclipse-glsp/server-mcp",version:"2.8.0-next.6",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 vye=Z(rb=>{"use strict";var P2r=rb&&rb.__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},I2r=rb&&rb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},EYe=rb&&rb.__param||function(s,i){return function(c,u){i(c,u,s)}};Object.defineProperty(rb,"__esModule",{value:!0});rb.DefaultGLSPMcpServer=rb.GLSPMcpServerFactory=rb.GLSPMcpServer=void 0;var T2r=Vr(),M2r=HQ(),OYe=kA(),mye=cn();rb.GLSPMcpServer=Symbol("GLSPMcpServer");var A2r=3e4,k2r=5e3;rb.GLSPMcpServerFactory=Symbol("GLSPMcpServerFactory");var GB,jYe=(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 OYe.McpError)||u.code!==OYe.ErrorCode.RequestTimeout)&&this.logger.debug("MCP keep-alive ping failed:",u)}),A2r);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"},OYe.EmptyResultSchema,{timeout:k2r})}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);rb.DefaultGLSPMcpServer=jYe;rb.DefaultGLSPMcpServer=jYe=P2r([(0,mye.injectable)(),EYe(0,(0,mye.unmanaged)()),EYe(1,(0,mye.unmanaged)()),EYe(2,(0,mye.unmanaged)()),I2r("design:paramtypes",[M2r.McpServer,Object,T2r.Logger])],jYe)});var yye=Z(wye=>{"use strict";Object.defineProperty(wye,"__esModule",{value:!0});wye.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 PYe=JQ;wye.LruEventStore=PYe});var _ye=Z(ib=>{"use strict";var VQ=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},IYe=ib&&ib.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ib,"__esModule",{value:!0});ib.McpDiagramPromptHandlerRegistryInitializer=ib.McpDiagramPromptHandlerRegistry=ib.McpDiagramPromptHandlerFactory=void 0;var $2r=Vr(),JB=cn(),C2r=iT();ib.McpDiagramPromptHandlerFactory=Symbol("McpDiagramPromptHandlerFactory");var ZB,KQ=(ZB=class extends $2r.Registry{registerHandler(i){return this.register(i.name,i)}},n(ZB,"McpDiagramPromptHandlerRegistry"),ZB);ib.McpDiagramPromptHandlerRegistry=KQ;ib.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);ib.McpDiagramPromptHandlerRegistryInitializer=KB;VQ([(0,JB.inject)(ib.McpDiagramPromptHandlerFactory),IYe("design:type",Function)],KB.prototype,"factory",void 0);VQ([(0,JB.inject)(C2r.McpDiagramPromptHandlerConstructor),(0,JB.optional)(),IYe("design:type",Array)],KB.prototype,"constructors",void 0);VQ([(0,JB.inject)(KQ),IYe("design:type",KQ)],KB.prototype,"registry",void 0);ib.McpDiagramPromptHandlerRegistryInitializer=KB=VQ([(0,JB.injectable)()],KB)});var wT=Z(Fp=>{"use strict";var vT=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=Wdn;var WQ=Vr(),R2r=HQ(),RO=cn(),TYe=Dd(),D2r=zD(),Vdn=nT();Fp.McpResourceHandler=Symbol("McpResourceHandler");var VB,YB=(VB=class{constructor(){this.requestContext=new Vdn.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 TYe.McpToolError)return{ok:!1,message:c.message};let u=(0,TYe.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 R2r.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);vT([(0,RO.inject)(Vdn.McpRequestContext),(0,RO.optional)(),QB("design:type",Object)],YB.prototype,"requestContext",void 0);vT([(0,RO.inject)(WQ.Logger),QB("design:type",WQ.Logger)],YB.prototype,"logger",void 0);YB=vT([(0,RO.injectable)()],YB);var WB,MYe=(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(Wdn(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=MYe;Fp.AbstractMcpResourceHandler=MYe=vT([(0,RO.injectable)()],MYe);var XB,E9=(XB=class extends YB{requestAction(i,c,u=this.name){return(0,TYe.requestActionOrFail)(this.actionDispatcher,i,c,u)}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;vT([(0,RO.inject)(WQ.ClientId),QB("design:type",String)],E9.prototype,"clientId",void 0);vT([(0,RO.inject)(WQ.ModelState),QB("design:type",Object)],E9.prototype,"modelState",void 0);vT([(0,RO.inject)(D2r.McpIdAliasService),QB("design:type",Object)],E9.prototype,"aliasService",void 0);vT([(0,RO.inject)(WQ.ActionDispatcher),QB("design:type",Object)],E9.prototype,"actionDispatcher",void 0);Fp.AbstractMcpDiagramResourceHandler=E9=vT([(0,RO.injectable)()],E9);function Wdn(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(Wdn,"toParams");Fp.McpDiagramResourceHandlerConstructor=Symbol("McpDiagramResourceHandlerConstructor")});var Sye=Z(ob=>{"use strict";var O9=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},QQ=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.McpDiagramResourceHandlerRegistryInitializer=ob.McpDiagramResourceHandlerRegistry=ob.McpDiagramResourceHandlerFactory=void 0;var XQ=Vr(),ZA=cn(),N2r=wT();ob.McpDiagramResourceHandlerFactory=Symbol("McpDiagramResourceHandlerFactory");var eF,YQ=(eF=class extends XQ.Registry{registerHandler(i){return this.register(i.name,i)}},n(eF,"McpDiagramResourceHandlerRegistry"),eF);ob.McpDiagramResourceHandlerRegistry=YQ;ob.McpDiagramResourceHandlerRegistry=YQ=O9([(0,ZA.injectable)()],YQ);var tF,HA=(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);ob.McpDiagramResourceHandlerRegistryInitializer=HA;O9([(0,ZA.inject)(ob.McpDiagramResourceHandlerFactory),QQ("design:type",Function)],HA.prototype,"factory",void 0);O9([(0,ZA.inject)(N2r.McpDiagramResourceHandlerConstructor),(0,ZA.optional)(),QQ("design:type",Array)],HA.prototype,"constructors",void 0);O9([(0,ZA.inject)(YQ),QQ("design:type",YQ)],HA.prototype,"registry",void 0);O9([(0,ZA.inject)(XQ.ClientId),QQ("design:type",String)],HA.prototype,"clientId",void 0);O9([(0,ZA.inject)(XQ.Logger),QQ("design:type",XQ.Logger)],HA.prototype,"logger",void 0);ob.McpDiagramResourceHandlerRegistryInitializer=HA=O9([(0,ZA.injectable)()],HA)});var Eye=Z(sb=>{"use strict";var j9=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},nee=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.McpDiagramToolHandlerRegistryInitializer=sb.McpDiagramToolHandlerRegistry=sb.McpDiagramToolHandlerFactory=void 0;var eee=Vr(),JA=cn(),q2r=Xu();sb.McpDiagramToolHandlerFactory=Symbol("McpDiagramToolHandlerFactory");var nF,tee=(nF=class extends eee.Registry{registerHandler(i){return this.register(i.name,i)}},n(nF,"McpDiagramToolHandlerRegistry"),nF);sb.McpDiagramToolHandlerRegistry=tee;sb.McpDiagramToolHandlerRegistry=tee=j9([(0,JA.injectable)()],tee);var rF,KA=(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);sb.McpDiagramToolHandlerRegistryInitializer=KA;j9([(0,JA.inject)(sb.McpDiagramToolHandlerFactory),nee("design:type",Function)],KA.prototype,"factory",void 0);j9([(0,JA.inject)(q2r.McpDiagramToolHandlerConstructor),(0,JA.optional)(),nee("design:type",Array)],KA.prototype,"constructors",void 0);j9([(0,JA.inject)(tee),nee("design:type",tee)],KA.prototype,"registry",void 0);j9([(0,JA.inject)(eee.ClientId),nee("design:type",String)],KA.prototype,"clientId",void 0);j9([(0,JA.inject)(eee.Logger),nee("design:type",eee.Logger)],KA.prototype,"logger",void 0);sb.McpDiagramToolHandlerRegistryInitializer=KA=j9([(0,JA.injectable)()],KA)});var Oye=Z(iS=>{"use strict";var oF=iS&&iS.__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=iS&&iS.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(iS,"__esModule",{value:!0});iS.DefaultMcpDiagramHandlerDispatcher=iS.McpDiagramHandlerDispatcher=void 0;var P9=Vr(),L2r=HQ(),WA=cn(),x2r=_ye(),Xdn=Sye(),z2r=Eye(),VA=Dd(),B2r=iT(),Qdn=nT(),Ydn=wT(),F2r=Xu();iS.McpDiagramHandlerDispatcher=Symbol("McpDiagramHandlerDispatcher");var iF,XA=(iF=class{constructor(){this.requestContext=new Qdn.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=AYe(b,F2r.McpDiagramToolHandlerConstructor),w=AYe(b,Ydn.McpDiagramResourceHandlerConstructor),T=AYe(b,B2r.McpDiagramPromptHandlerConstructor);b.unbindAll(),i.push({diagramType:u,toolConstructors:y,resourceConstructors:w,promptConstructors:T})}this.diagramCatalogs=i}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 L2r.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,VA.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 VA.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,Ydn.toParams)(u);return this.requireDiagramResourceHandler(i,f.sessionId).handleRead(c.toString(),f)}dispatchDiagramResourceAsTool(i,c){return(0,VA.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(z2r.McpDiagramToolHandlerRegistry).get(i);if(!b)throw new VA.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(Xdn.McpDiagramResourceHandlerRegistry).get(i);if(!b)throw new VA.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(Xdn.McpDiagramResourceHandlerRegistry).get(i)}requireDiagramPromptHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(x2r.McpDiagramPromptHandlerRegistry).get(i);if(!b)throw new VA.McpToolError(`No prompt handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireGlspSession(i){if(!i)throw new VA.McpMissingParamError("sessionId");let c=this.clientSessionManager.getSession(i);if(!c)throw new VA.McpSessionNotFoundError(i);return c}reset(){this.diagramCatalogs=[]}},n(iF,"DefaultMcpDiagramHandlerDispatcher"),iF);iS.DefaultMcpDiagramHandlerDispatcher=XA;oF([(0,WA.inject)(Qdn.McpRequestContext),(0,WA.optional)(),ree("design:type",Object)],XA.prototype,"requestContext",void 0);oF([(0,WA.inject)(P9.InjectionContainer),ree("design:type",WA.Container)],XA.prototype,"serverContainer",void 0);oF([(0,WA.inject)(P9.DiagramModules),ree("design:type",Map)],XA.prototype,"diagramModules",void 0);oF([(0,WA.inject)(P9.ClientSessionManager),ree("design:type",Object)],XA.prototype,"clientSessionManager",void 0);oF([(0,WA.inject)(P9.Logger),ree("design:type",P9.Logger)],XA.prototype,"logger",void 0);iS.DefaultMcpDiagramHandlerDispatcher=XA=oF([(0,WA.injectable)()],XA);function AYe(s,i){return s.isBound(i)?s.get(i):[]}n(AYe,"getConstructorList")});var iee=Z(DO=>{"use strict";var U2r=DO&&DO.__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},jye;Object.defineProperty(DO,"__esModule",{value:!0});DO.DefaultMcpLogLevelRegistry=DO.McpLogLevelRegistry=void 0;DO.passesLogThreshold=Z2r;var G2r=cn();DO.McpLogLevelRegistry=Symbol("McpLogLevelRegistry");var ehn={emergency:0,alert:1,critical:2,error:3,warning:4,notice:5,info:6,debug:7};function Z2r(s,i){return ehn[s]<=ehn[i]}n(Z2r,"passesLogThreshold");var YA,kYe=(YA=class{constructor(){this.levels=new Map}setLevel(i,c){this.levels.set(i,c)}getLevel(i){var c;return i===void 0?jye.DEFAULT_LEVEL:(c=this.levels.get(i))!=null?c:jye.DEFAULT_LEVEL}clear(i){this.levels.delete(i)}},n(YA,"DefaultMcpLogLevelRegistry"),jye=YA,YA.DEFAULT_LEVEL="debug",YA);DO.DefaultMcpLogLevelRegistry=kYe;DO.DefaultMcpLogLevelRegistry=kYe=jye=U2r([(0,G2r.injectable)()],kYe)});var Pye=Z(yT=>{"use strict";var H2r=yT&&yT.__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(yT,"__esModule",{value:!0});yT.McpServerDefaults=yT.McpServerOptions=void 0;var J2r=cn(),sF,$Ye=(sF=class{constructor(){this.values={}}},n(sF,"McpServerOptions"),sF);yT.McpServerOptions=$Ye;yT.McpServerOptions=$Ye=H2r([(0,J2r.injectable)()],$Ye);yT.McpServerDefaults=Symbol("McpServerDefaults")});var Tye=Z(mv=>{"use strict";var oS=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},qO=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=thn;var NO=Vr(),K2r=HQ(),V2r=Jdn(),Iye=kA(),xm=cn(),W2r=Kdn(),X2r=vye(),Y2r=yye(),Q2r=Oye(),eSr=iee(),CYe=Pye(),tSr=iT(),nSr=wT(),rSr=Xu();mv.SERVER_VERSION=W2r.version;function thn(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(thn,"pickInitOptions");var iSr=null,cF,bv=(cF=class{constructor(){this.toolHandlers=[],this.resourceHandlers=[],this.promptHandlers=[],this.toDispose=new NO.DisposableCollection,this.sessions=new Map,this.sessionServers=new Map,this.onSessionInitializedEmitter=new NO.Emitter,this.onSessionInitialized=this.onSessionInitializedEmitter.event,this.onSessionClosedEmitter=new NO.Emitter,this.onSessionClosed=this.onSessionClosedEmitter.event}async initializeServer(i,c,u){var G,se;let f=NO.McpInitializeParameters.getServerConfig(c);if(!f)return u;if(this.serverConfig)return this.serverUrl?NO.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,...thn(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 q=await this.bindTransport(I);return this.serverConfig=I,this.serverUrl=q.url,this.logger.info(`MCP server '${I.name}' is ready to accept new client requests on: ${(se=this.serverUrl)!=null?se:"(no network endpoint)"}`),q.url?NO.McpInitializeResult.attachServer(u,{name:I.name,url:q.url,headers:q.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,Iye.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(q){let G=q instanceof Error?q.message:String(q);return this.logger.error("Error handling MCP request:",q),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&&!Iye.SUPPORTED_PROTOCOL_VERSIONS.includes(u))return this.jsonRpcErrorResponse(400,-32e3,`Unsupported MCP-Protocol-Version: '${u}'. Supported versions: ${Iye.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 V2r.WebStandardStreamableHTTPServerTransport({sessionIdGenerator:n(()=>globalThis.crypto.randomUUID(),"sessionIdGenerator"),eventStore:new Y2r.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(NO.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(Iye.SetLevelRequestSchema,async u=>(this.logLevelRegistry.setLevel(c,u.params.level),{}))}createGlspMcpServer({name:i,options:c}){let u=c.dataMode==="resources",f=new K2r.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:iSr}),{status:i,headers:{"Content-Type":"application/json"}})}},n(cF,"AbstractMcpServerLauncher"),cF);mv.AbstractMcpServerLauncher=bv;oS([(0,xm.inject)(NO.Logger),qO("design:type",NO.Logger)],bv.prototype,"logger",void 0);oS([(0,xm.inject)(CYe.McpServerOptions),qO("design:type",CYe.McpServerOptions)],bv.prototype,"mcpOptions",void 0);oS([(0,xm.inject)(CYe.McpServerDefaults),qO("design:type",Object)],bv.prototype,"mcpDefaults",void 0);oS([(0,xm.inject)(X2r.GLSPMcpServerFactory),qO("design:type",Function)],bv.prototype,"glspMcpServerFactory",void 0);oS([(0,xm.inject)(Q2r.McpDiagramHandlerDispatcher),qO("design:type",Object)],bv.prototype,"dispatcher",void 0);oS([(0,xm.inject)(eSr.McpLogLevelRegistry),qO("design:type",Object)],bv.prototype,"logLevelRegistry",void 0);oS([(0,xm.inject)(NO.ClientSessionManager),qO("design:type",Object)],bv.prototype,"clientSessionManager",void 0);oS([(0,xm.multiInject)(rSr.McpToolHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"toolHandlers",void 0);oS([(0,xm.multiInject)(nSr.McpResourceHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"resourceHandlers",void 0);oS([(0,xm.multiInject)(tSr.McpPromptHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"promptHandlers",void 0);mv.AbstractMcpServerLauncher=bv=oS([(0,xm.injectable)()],bv)});var Aye=Z(_T=>{"use strict";var Mye=_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},RYe=_T&&_T.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(_T,"__esModule",{value:!0});_T.McpLogger=void 0;var nhn=Vr(),oee=cn(),rhn=iee(),ihn=nT(),aF,uF=(aF=class{constructor(){this.requestContext=new ihn.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,rhn.passesLogThreshold)(i,f)&&u.sendNotification({method:"notifications/message",params:{level:i,data:c}}).catch(()=>{})}},n(aF,"McpLogger"),aF);_T.McpLogger=uF;Mye([(0,oee.inject)(ihn.McpRequestContext),(0,oee.optional)(),RYe("design:type",Object)],uF.prototype,"requestContext",void 0);Mye([(0,oee.inject)(nhn.Logger),RYe("design:type",nhn.Logger)],uF.prototype,"glspLogger",void 0);Mye([(0,oee.inject)(rhn.McpLogLevelRegistry),RYe("design:type",Object)],uF.prototype,"levelRegistry",void 0);_T.McpLogger=uF=Mye([(0,oee.injectable)()],uF)});var see=Z(ST=>{"use strict";var ohn=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},oSr=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.McpProgressReporter=void 0;var DYe=cn(),shn=nT(),lF,kye=(lF=class{constructor(){this.requestContext=new shn.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);ST.McpProgressReporter=kye;ohn([(0,DYe.inject)(shn.McpRequestContext),(0,DYe.optional)(),oSr("design:type",Object)],kye.prototype,"requestContext",void 0);ST.McpProgressReporter=kye=ohn([(0,DYe.injectable)()],kye)});var LYe=Z(np=>{"use strict";var chn=np&&np.__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},sSr=np&&np.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},NYe;Object.defineProperty(np,"__esModule",{value:!0});np.SessionInfoMcpToolHandler=np.SessionInfoOutputSchema=np.SessionInfoRowSchema=np.SessionInfoInputSchema=void 0;var qYe=Vr(),ahn=cn(),LO=Vu(),cSr=Dd(),aSr=Xu();np.SessionInfoInputSchema=LO.object({sessionId:LO.string().optional().describe("Optional filter \u2014 returns only the matching session, or throws if unknown. Omit to list all sessions.")});np.SessionInfoRowSchema=LO.object({sessionId:LO.string(),diagramType:LO.string(),sourceUri:LO.string(),readOnly:LO.boolean(),dirty:LO.boolean().describe("True when the diagram has unsaved changes \u2014 call `save-model` to persist.")});np.SessionInfoOutputSchema=LO.object({sessions:LO.array(np.SessionInfoRowSchema)});var QA,$ye=(QA=class extends aSr.AbstractMcpToolHandler{constructor(){super(...arguments),this.name=NYe.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=np.SessionInfoInputSchema,this.outputSchema=np.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(qYe.ModelState),u=i.container.get(qYe.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,q,G;try{let se=i.headers.get("accept");if(!(se!=null&&se.includes("application/json"))||!se.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 rt;try{Array.isArray(Ve)?rt=Ve.map(Ko=>tp.JSONRPCMessageSchema.parse(Ko)):rt=[tp.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 jt=rt.some(tp.isInitializeRequest);if(jt){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(rt.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(!jt){let Ko=this.validateSession(i);if(Ko)return Ko;let iu=this.validateProtocolVersion(i);if(iu)return iu}if(!rt.some(tp.isJSONRPCRequest)){for(let Ko of rt)(C=this.onmessage)==null||C.call(this,Ko,{authInfo:c==null?void 0:c.authInfo,requestInfo:Te});return new Response(null,{status:202})}let ut=crypto.randomUUID(),Lt=rt.find(Ko=>(0,tp.isInitializeRequest)(Ko)),ar=Lt?Lt.params.protocolVersion:(I=i.headers.get("mcp-protocol-version"))!=null?I:tp.DEFAULT_NEGOTIATED_PROTOCOL_VERSION;if(this._enableJsonResponse)return new Promise(Ko=>{var iu;this._streamMapping.set(ut,{resolveJson:Ko,cleanup:n(()=>{this._streamMapping.delete(ut)},"cleanup")});for(let hd of rt)(0,tp.isJSONRPCRequest)(hd)&&this._requestToStreamMapping.set(hd.id,ut);for(let hd of rt)(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(ut)},"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 rt)(0,tp.isJSONRPCRequest)(Ko)&&(this._streamMapping.set(ut,{controller:Ei,encoder:lo,cleanup:n(()=>{this._streamMapping.delete(ut);try{Ei.close()}catch{}},"cleanup")}),this._requestToStreamMapping.set(Ko.id,ut));await this.writePrimingEvent(Ei,lo,ut,ar);for(let Ko of rt){let iu,hd;(0,tp.isJSONRPCRequest)(Ko)&&this._eventStore&&ar>="2025-11-25"&&(iu=n(()=>{this.closeSSEStream(Ko.id)},"closeSSEStream"),hd=n(()=>{this.closeStandaloneSSEStream()},"closeStandaloneSSEStream")),(q=this.onmessage)==null||q.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(se){return(G=this.onerror)==null||G.call(this,se),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(se)})}}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&&!tp.SUPPORTED_PROTOCOL_VERSIONS.includes(c))return(u=this.onerror)==null||u.call(this,new Error(`Bad Request: Unsupported protocol version: ${c} (supported versions: ${tp.SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${c} (supported versions: ${tp.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,tp.isJSONRPCResultResponse)(i)||(0,tp.isJSONRPCErrorResponse)(i))&&(u=i.id),u===void 0){if((0,tp.isJSONRPCResultResponse)(i)||(0,tp.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,tp.isJSONRPCResultResponse)(i)||(0,tp.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(SYe,"WebStandardStreamableHTTPServerTransport");var _Ye=SYe;bye.WebStandardStreamableHTTPServerTransport=_Ye});var Kdn=Z((Upi,j2r)=>{j2r.exports={name:"@eclipse-glsp/server-mcp",version:"2.8.0-next.7",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 vye=Z(rb=>{"use strict";var P2r=rb&&rb.__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},I2r=rb&&rb.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},EYe=rb&&rb.__param||function(s,i){return function(c,u){i(c,u,s)}};Object.defineProperty(rb,"__esModule",{value:!0});rb.DefaultGLSPMcpServer=rb.GLSPMcpServerFactory=rb.GLSPMcpServer=void 0;var T2r=Vr(),M2r=HQ(),OYe=kA(),mye=cn();rb.GLSPMcpServer=Symbol("GLSPMcpServer");var A2r=3e4,k2r=5e3;rb.GLSPMcpServerFactory=Symbol("GLSPMcpServerFactory");var GB,jYe=(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 OYe.McpError)||u.code!==OYe.ErrorCode.RequestTimeout)&&this.logger.debug("MCP keep-alive ping failed:",u)}),A2r);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"},OYe.EmptyResultSchema,{timeout:k2r})}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);rb.DefaultGLSPMcpServer=jYe;rb.DefaultGLSPMcpServer=jYe=P2r([(0,mye.injectable)(),EYe(0,(0,mye.unmanaged)()),EYe(1,(0,mye.unmanaged)()),EYe(2,(0,mye.unmanaged)()),I2r("design:paramtypes",[M2r.McpServer,Object,T2r.Logger])],jYe)});var yye=Z(wye=>{"use strict";Object.defineProperty(wye,"__esModule",{value:!0});wye.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 PYe=JQ;wye.LruEventStore=PYe});var _ye=Z(ib=>{"use strict";var VQ=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},IYe=ib&&ib.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(ib,"__esModule",{value:!0});ib.McpDiagramPromptHandlerRegistryInitializer=ib.McpDiagramPromptHandlerRegistry=ib.McpDiagramPromptHandlerFactory=void 0;var $2r=Vr(),JB=cn(),C2r=iT();ib.McpDiagramPromptHandlerFactory=Symbol("McpDiagramPromptHandlerFactory");var ZB,KQ=(ZB=class extends $2r.Registry{registerHandler(i){return this.register(i.name,i)}},n(ZB,"McpDiagramPromptHandlerRegistry"),ZB);ib.McpDiagramPromptHandlerRegistry=KQ;ib.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);ib.McpDiagramPromptHandlerRegistryInitializer=KB;VQ([(0,JB.inject)(ib.McpDiagramPromptHandlerFactory),IYe("design:type",Function)],KB.prototype,"factory",void 0);VQ([(0,JB.inject)(C2r.McpDiagramPromptHandlerConstructor),(0,JB.optional)(),IYe("design:type",Array)],KB.prototype,"constructors",void 0);VQ([(0,JB.inject)(KQ),IYe("design:type",KQ)],KB.prototype,"registry",void 0);ib.McpDiagramPromptHandlerRegistryInitializer=KB=VQ([(0,JB.injectable)()],KB)});var wT=Z(Fp=>{"use strict";var vT=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=Wdn;var WQ=Vr(),R2r=HQ(),RO=cn(),TYe=Dd(),D2r=zD(),Vdn=nT();Fp.McpResourceHandler=Symbol("McpResourceHandler");var VB,YB=(VB=class{constructor(){this.requestContext=new Vdn.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 TYe.McpToolError)return{ok:!1,message:c.message};let u=(0,TYe.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 R2r.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);vT([(0,RO.inject)(Vdn.McpRequestContext),(0,RO.optional)(),QB("design:type",Object)],YB.prototype,"requestContext",void 0);vT([(0,RO.inject)(WQ.Logger),QB("design:type",WQ.Logger)],YB.prototype,"logger",void 0);YB=vT([(0,RO.injectable)()],YB);var WB,MYe=(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(Wdn(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=MYe;Fp.AbstractMcpResourceHandler=MYe=vT([(0,RO.injectable)()],MYe);var XB,E9=(XB=class extends YB{requestAction(i,c,u=this.name){return(0,TYe.requestActionOrFail)(this.actionDispatcher,i,c,u)}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;vT([(0,RO.inject)(WQ.ClientId),QB("design:type",String)],E9.prototype,"clientId",void 0);vT([(0,RO.inject)(WQ.ModelState),QB("design:type",Object)],E9.prototype,"modelState",void 0);vT([(0,RO.inject)(D2r.McpIdAliasService),QB("design:type",Object)],E9.prototype,"aliasService",void 0);vT([(0,RO.inject)(WQ.ActionDispatcher),QB("design:type",Object)],E9.prototype,"actionDispatcher",void 0);Fp.AbstractMcpDiagramResourceHandler=E9=vT([(0,RO.injectable)()],E9);function Wdn(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(Wdn,"toParams");Fp.McpDiagramResourceHandlerConstructor=Symbol("McpDiagramResourceHandlerConstructor")});var Sye=Z(ob=>{"use strict";var O9=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},QQ=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.McpDiagramResourceHandlerRegistryInitializer=ob.McpDiagramResourceHandlerRegistry=ob.McpDiagramResourceHandlerFactory=void 0;var XQ=Vr(),ZA=cn(),N2r=wT();ob.McpDiagramResourceHandlerFactory=Symbol("McpDiagramResourceHandlerFactory");var eF,YQ=(eF=class extends XQ.Registry{registerHandler(i){return this.register(i.name,i)}},n(eF,"McpDiagramResourceHandlerRegistry"),eF);ob.McpDiagramResourceHandlerRegistry=YQ;ob.McpDiagramResourceHandlerRegistry=YQ=O9([(0,ZA.injectable)()],YQ);var tF,HA=(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);ob.McpDiagramResourceHandlerRegistryInitializer=HA;O9([(0,ZA.inject)(ob.McpDiagramResourceHandlerFactory),QQ("design:type",Function)],HA.prototype,"factory",void 0);O9([(0,ZA.inject)(N2r.McpDiagramResourceHandlerConstructor),(0,ZA.optional)(),QQ("design:type",Array)],HA.prototype,"constructors",void 0);O9([(0,ZA.inject)(YQ),QQ("design:type",YQ)],HA.prototype,"registry",void 0);O9([(0,ZA.inject)(XQ.ClientId),QQ("design:type",String)],HA.prototype,"clientId",void 0);O9([(0,ZA.inject)(XQ.Logger),QQ("design:type",XQ.Logger)],HA.prototype,"logger",void 0);ob.McpDiagramResourceHandlerRegistryInitializer=HA=O9([(0,ZA.injectable)()],HA)});var Eye=Z(sb=>{"use strict";var j9=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},nee=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.McpDiagramToolHandlerRegistryInitializer=sb.McpDiagramToolHandlerRegistry=sb.McpDiagramToolHandlerFactory=void 0;var eee=Vr(),JA=cn(),q2r=Xu();sb.McpDiagramToolHandlerFactory=Symbol("McpDiagramToolHandlerFactory");var nF,tee=(nF=class extends eee.Registry{registerHandler(i){return this.register(i.name,i)}},n(nF,"McpDiagramToolHandlerRegistry"),nF);sb.McpDiagramToolHandlerRegistry=tee;sb.McpDiagramToolHandlerRegistry=tee=j9([(0,JA.injectable)()],tee);var rF,KA=(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);sb.McpDiagramToolHandlerRegistryInitializer=KA;j9([(0,JA.inject)(sb.McpDiagramToolHandlerFactory),nee("design:type",Function)],KA.prototype,"factory",void 0);j9([(0,JA.inject)(q2r.McpDiagramToolHandlerConstructor),(0,JA.optional)(),nee("design:type",Array)],KA.prototype,"constructors",void 0);j9([(0,JA.inject)(tee),nee("design:type",tee)],KA.prototype,"registry",void 0);j9([(0,JA.inject)(eee.ClientId),nee("design:type",String)],KA.prototype,"clientId",void 0);j9([(0,JA.inject)(eee.Logger),nee("design:type",eee.Logger)],KA.prototype,"logger",void 0);sb.McpDiagramToolHandlerRegistryInitializer=KA=j9([(0,JA.injectable)()],KA)});var Oye=Z(iS=>{"use strict";var oF=iS&&iS.__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=iS&&iS.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(iS,"__esModule",{value:!0});iS.DefaultMcpDiagramHandlerDispatcher=iS.McpDiagramHandlerDispatcher=void 0;var P9=Vr(),L2r=HQ(),WA=cn(),x2r=_ye(),Xdn=Sye(),z2r=Eye(),VA=Dd(),B2r=iT(),Qdn=nT(),Ydn=wT(),F2r=Xu();iS.McpDiagramHandlerDispatcher=Symbol("McpDiagramHandlerDispatcher");var iF,XA=(iF=class{constructor(){this.requestContext=new Qdn.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=AYe(b,F2r.McpDiagramToolHandlerConstructor),w=AYe(b,Ydn.McpDiagramResourceHandlerConstructor),T=AYe(b,B2r.McpDiagramPromptHandlerConstructor);b.unbindAll(),i.push({diagramType:u,toolConstructors:y,resourceConstructors:w,promptConstructors:T})}this.diagramCatalogs=i}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 L2r.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,VA.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 VA.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,Ydn.toParams)(u);return this.requireDiagramResourceHandler(i,f.sessionId).handleRead(c.toString(),f)}dispatchDiagramResourceAsTool(i,c){return(0,VA.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(z2r.McpDiagramToolHandlerRegistry).get(i);if(!b)throw new VA.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(Xdn.McpDiagramResourceHandlerRegistry).get(i);if(!b)throw new VA.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(Xdn.McpDiagramResourceHandlerRegistry).get(i)}requireDiagramPromptHandler(i,c){let u=this.requireGlspSession(this.extractSessionId(c)),b=u.container.get(x2r.McpDiagramPromptHandlerRegistry).get(i);if(!b)throw new VA.McpToolError(`No prompt handler '${i}' registered for diagram type '${u.diagramType}'.`);return b}requireGlspSession(i){if(!i)throw new VA.McpMissingParamError("sessionId");let c=this.clientSessionManager.getSession(i);if(!c)throw new VA.McpSessionNotFoundError(i);return c}reset(){this.diagramCatalogs=[]}},n(iF,"DefaultMcpDiagramHandlerDispatcher"),iF);iS.DefaultMcpDiagramHandlerDispatcher=XA;oF([(0,WA.inject)(Qdn.McpRequestContext),(0,WA.optional)(),ree("design:type",Object)],XA.prototype,"requestContext",void 0);oF([(0,WA.inject)(P9.InjectionContainer),ree("design:type",WA.Container)],XA.prototype,"serverContainer",void 0);oF([(0,WA.inject)(P9.DiagramModules),ree("design:type",Map)],XA.prototype,"diagramModules",void 0);oF([(0,WA.inject)(P9.ClientSessionManager),ree("design:type",Object)],XA.prototype,"clientSessionManager",void 0);oF([(0,WA.inject)(P9.Logger),ree("design:type",P9.Logger)],XA.prototype,"logger",void 0);iS.DefaultMcpDiagramHandlerDispatcher=XA=oF([(0,WA.injectable)()],XA);function AYe(s,i){return s.isBound(i)?s.get(i):[]}n(AYe,"getConstructorList")});var iee=Z(DO=>{"use strict";var U2r=DO&&DO.__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},jye;Object.defineProperty(DO,"__esModule",{value:!0});DO.DefaultMcpLogLevelRegistry=DO.McpLogLevelRegistry=void 0;DO.passesLogThreshold=Z2r;var G2r=cn();DO.McpLogLevelRegistry=Symbol("McpLogLevelRegistry");var ehn={emergency:0,alert:1,critical:2,error:3,warning:4,notice:5,info:6,debug:7};function Z2r(s,i){return ehn[s]<=ehn[i]}n(Z2r,"passesLogThreshold");var YA,kYe=(YA=class{constructor(){this.levels=new Map}setLevel(i,c){this.levels.set(i,c)}getLevel(i){var c;return i===void 0?jye.DEFAULT_LEVEL:(c=this.levels.get(i))!=null?c:jye.DEFAULT_LEVEL}clear(i){this.levels.delete(i)}},n(YA,"DefaultMcpLogLevelRegistry"),jye=YA,YA.DEFAULT_LEVEL="debug",YA);DO.DefaultMcpLogLevelRegistry=kYe;DO.DefaultMcpLogLevelRegistry=kYe=jye=U2r([(0,G2r.injectable)()],kYe)});var Pye=Z(yT=>{"use strict";var H2r=yT&&yT.__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(yT,"__esModule",{value:!0});yT.McpServerDefaults=yT.McpServerOptions=void 0;var J2r=cn(),sF,$Ye=(sF=class{constructor(){this.values={}}},n(sF,"McpServerOptions"),sF);yT.McpServerOptions=$Ye;yT.McpServerOptions=$Ye=H2r([(0,J2r.injectable)()],$Ye);yT.McpServerDefaults=Symbol("McpServerDefaults")});var Tye=Z(mv=>{"use strict";var oS=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},qO=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=thn;var NO=Vr(),K2r=HQ(),V2r=Jdn(),Iye=kA(),xm=cn(),W2r=Kdn(),X2r=vye(),Y2r=yye(),Q2r=Oye(),eSr=iee(),CYe=Pye(),tSr=iT(),nSr=wT(),rSr=Xu();mv.SERVER_VERSION=W2r.version;function thn(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(thn,"pickInitOptions");var iSr=null,cF,bv=(cF=class{constructor(){this.toolHandlers=[],this.resourceHandlers=[],this.promptHandlers=[],this.toDispose=new NO.DisposableCollection,this.sessions=new Map,this.sessionServers=new Map,this.onSessionInitializedEmitter=new NO.Emitter,this.onSessionInitialized=this.onSessionInitializedEmitter.event,this.onSessionClosedEmitter=new NO.Emitter,this.onSessionClosed=this.onSessionClosedEmitter.event}async initializeServer(i,c,u){var G,se;let f=NO.McpInitializeParameters.getServerConfig(c);if(!f)return u;if(this.serverConfig)return this.serverUrl?NO.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,...thn(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 q=await this.bindTransport(I);return this.serverConfig=I,this.serverUrl=q.url,this.logger.info(`MCP server '${I.name}' is ready to accept new client requests on: ${(se=this.serverUrl)!=null?se:"(no network endpoint)"}`),q.url?NO.McpInitializeResult.attachServer(u,{name:I.name,url:q.url,headers:q.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,Iye.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(q){let G=q instanceof Error?q.message:String(q);return this.logger.error("Error handling MCP request:",q),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&&!Iye.SUPPORTED_PROTOCOL_VERSIONS.includes(u))return this.jsonRpcErrorResponse(400,-32e3,`Unsupported MCP-Protocol-Version: '${u}'. Supported versions: ${Iye.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 V2r.WebStandardStreamableHTTPServerTransport({sessionIdGenerator:n(()=>globalThis.crypto.randomUUID(),"sessionIdGenerator"),eventStore:new Y2r.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(NO.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(Iye.SetLevelRequestSchema,async u=>(this.logLevelRegistry.setLevel(c,u.params.level),{}))}createGlspMcpServer({name:i,options:c}){let u=c.dataMode==="resources",f=new K2r.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:iSr}),{status:i,headers:{"Content-Type":"application/json"}})}},n(cF,"AbstractMcpServerLauncher"),cF);mv.AbstractMcpServerLauncher=bv;oS([(0,xm.inject)(NO.Logger),qO("design:type",NO.Logger)],bv.prototype,"logger",void 0);oS([(0,xm.inject)(CYe.McpServerOptions),qO("design:type",CYe.McpServerOptions)],bv.prototype,"mcpOptions",void 0);oS([(0,xm.inject)(CYe.McpServerDefaults),qO("design:type",Object)],bv.prototype,"mcpDefaults",void 0);oS([(0,xm.inject)(X2r.GLSPMcpServerFactory),qO("design:type",Function)],bv.prototype,"glspMcpServerFactory",void 0);oS([(0,xm.inject)(Q2r.McpDiagramHandlerDispatcher),qO("design:type",Object)],bv.prototype,"dispatcher",void 0);oS([(0,xm.inject)(eSr.McpLogLevelRegistry),qO("design:type",Object)],bv.prototype,"logLevelRegistry",void 0);oS([(0,xm.inject)(NO.ClientSessionManager),qO("design:type",Object)],bv.prototype,"clientSessionManager",void 0);oS([(0,xm.multiInject)(rSr.McpToolHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"toolHandlers",void 0);oS([(0,xm.multiInject)(nSr.McpResourceHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"resourceHandlers",void 0);oS([(0,xm.multiInject)(tSr.McpPromptHandler),(0,xm.optional)(),qO("design:type",Array)],bv.prototype,"promptHandlers",void 0);mv.AbstractMcpServerLauncher=bv=oS([(0,xm.injectable)()],bv)});var Aye=Z(_T=>{"use strict";var Mye=_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},RYe=_T&&_T.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)};Object.defineProperty(_T,"__esModule",{value:!0});_T.McpLogger=void 0;var nhn=Vr(),oee=cn(),rhn=iee(),ihn=nT(),aF,uF=(aF=class{constructor(){this.requestContext=new ihn.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,rhn.passesLogThreshold)(i,f)&&u.sendNotification({method:"notifications/message",params:{level:i,data:c}}).catch(()=>{})}},n(aF,"McpLogger"),aF);_T.McpLogger=uF;Mye([(0,oee.inject)(ihn.McpRequestContext),(0,oee.optional)(),RYe("design:type",Object)],uF.prototype,"requestContext",void 0);Mye([(0,oee.inject)(nhn.Logger),RYe("design:type",nhn.Logger)],uF.prototype,"glspLogger",void 0);Mye([(0,oee.inject)(rhn.McpLogLevelRegistry),RYe("design:type",Object)],uF.prototype,"levelRegistry",void 0);_T.McpLogger=uF=Mye([(0,oee.injectable)()],uF)});var see=Z(ST=>{"use strict";var ohn=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},oSr=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.McpProgressReporter=void 0;var DYe=cn(),shn=nT(),lF,kye=(lF=class{constructor(){this.requestContext=new shn.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);ST.McpProgressReporter=kye;ohn([(0,DYe.inject)(shn.McpRequestContext),(0,DYe.optional)(),oSr("design:type",Object)],kye.prototype,"requestContext",void 0);ST.McpProgressReporter=kye=ohn([(0,DYe.injectable)()],kye)});var LYe=Z(np=>{"use strict";var chn=np&&np.__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},sSr=np&&np.__metadata||function(s,i){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,i)},NYe;Object.defineProperty(np,"__esModule",{value:!0});np.SessionInfoMcpToolHandler=np.SessionInfoOutputSchema=np.SessionInfoRowSchema=np.SessionInfoInputSchema=void 0;var qYe=Vr(),ahn=cn(),LO=Vu(),cSr=Dd(),aSr=Xu();np.SessionInfoInputSchema=LO.object({sessionId:LO.string().optional().describe("Optional filter \u2014 returns only the matching session, or throws if unknown. Omit to list all sessions.")});np.SessionInfoRowSchema=LO.object({sessionId:LO.string(),diagramType:LO.string(),sourceUri:LO.string(),readOnly:LO.boolean(),dirty:LO.boolean().describe("True when the diagram has unsaved changes \u2014 call `save-model` to persist.")});np.SessionInfoOutputSchema=LO.object({sessions:LO.array(np.SessionInfoRowSchema)});var QA,$ye=(QA=class extends aSr.AbstractMcpToolHandler{constructor(){super(...arguments),this.name=NYe.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=np.SessionInfoInputSchema,this.outputSchema=np.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(qYe.ModelState),u=i.container.get(qYe.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 cSr.McpToolError(`Unknown sessionId: ${i}`);return[c]}},n(QA,"SessionInfoMcpToolHandler"),NYe=QA,QA.NAME="session-info",QA);np.SessionInfoMcpToolHandler=$ye;chn([(0,ahn.inject)(qYe.ClientSessionManager),sSr("design:type",Object)],$ye.prototype,"clientSessionManager",void 0);np.SessionInfoMcpToolHandler=$ye=NYe=chn([(0,ahn.injectable)()],$ye)});var GYe=Z(sS=>{"use strict";Object.defineProperty(sS,"__esModule",{value:!0});sS.AbstractMcpServerModule=sS.McpHandlerMultiBinding=sS.DEFAULT_MCP_OPTIONS=sS.DEFAULT_AGENT_PERSONA=void 0;var zm=Vr(),uSr=rKe(),lSr=cKe(),xYe=Tye(),uhn=vye(),fSr=yye(),lhn=Oye(),fhn=iee(),dhn=Aye(),zYe=Pye(),hhn=see(),dSr=iT(),hSr=nT(),pSr=wT(),gSr=Xu(),bSr=ove(),mSr=LYe();sS.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