@eclipse-glsp/server-mcp 2.7.0-next.9
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/LICENSE +642 -0
- package/README.md +57 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +41 -0
- package/lib/index.js.map +1 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts +43 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js +96 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js.map +1 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts +43 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js +95 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +1 -0
- package/lib/prompts/index.d.ts +18 -0
- package/lib/prompts/index.d.ts.map +1 -0
- package/lib/prompts/index.js +34 -0
- package/lib/prompts/index.js.map +1 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts +81 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts.map +1 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.js +174 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.js.map +1 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts +52 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts.map +1 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js +96 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js.map +1 -0
- package/lib/resources/index.d.ts +20 -0
- package/lib/resources/index.d.ts.map +1 -0
- package/lib/resources/index.js +36 -0
- package/lib/resources/index.js.map +1 -0
- package/lib/resources/services/element-types-provider.d.ts +65 -0
- package/lib/resources/services/element-types-provider.d.ts.map +1 -0
- package/lib/resources/services/element-types-provider.js +81 -0
- package/lib/resources/services/element-types-provider.js.map +1 -0
- package/lib/resources/services/mcp-model-serializer.d.ts +78 -0
- package/lib/resources/services/mcp-model-serializer.d.ts.map +1 -0
- package/lib/resources/services/mcp-model-serializer.js +188 -0
- package/lib/resources/services/mcp-model-serializer.js.map +1 -0
- package/lib/server/glsp-mcp-server.d.ts +82 -0
- package/lib/server/glsp-mcp-server.d.ts.map +1 -0
- package/lib/server/glsp-mcp-server.js +140 -0
- package/lib/server/glsp-mcp-server.js.map +1 -0
- package/lib/server/index.d.ts +37 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +57 -0
- package/lib/server/index.js.map +1 -0
- package/lib/server/lru-event-store.d.ts +53 -0
- package/lib/server/lru-event-store.d.ts.map +1 -0
- package/lib/server/lru-event-store.js +100 -0
- package/lib/server/lru-event-store.js.map +1 -0
- package/lib/server/mcp-diagram-handler-dispatcher.d.ts +144 -0
- package/lib/server/mcp-diagram-handler-dispatcher.d.ts.map +1 -0
- package/lib/server/mcp-diagram-handler-dispatcher.js +382 -0
- package/lib/server/mcp-diagram-handler-dispatcher.js.map +1 -0
- package/lib/server/mcp-diagram-module.d.ts +123 -0
- package/lib/server/mcp-diagram-module.d.ts.map +1 -0
- package/lib/server/mcp-diagram-module.js +186 -0
- package/lib/server/mcp-diagram-module.js.map +1 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.d.ts +33 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.js +76 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.js.map +1 -0
- package/lib/server/mcp-diagram-resource-handler-registry.d.ts +35 -0
- package/lib/server/mcp-diagram-resource-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-resource-handler-registry.js +94 -0
- package/lib/server/mcp-diagram-resource-handler-registry.js.map +1 -0
- package/lib/server/mcp-diagram-tool-handler-registry.d.ts +57 -0
- package/lib/server/mcp-diagram-tool-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-tool-handler-registry.js +111 -0
- package/lib/server/mcp-diagram-tool-handler-registry.js.map +1 -0
- package/lib/server/mcp-handler-shared.d.ts +142 -0
- package/lib/server/mcp-handler-shared.d.ts.map +1 -0
- package/lib/server/mcp-handler-shared.js +199 -0
- package/lib/server/mcp-handler-shared.js.map +1 -0
- package/lib/server/mcp-http-transport.d.ts +93 -0
- package/lib/server/mcp-http-transport.d.ts.map +1 -0
- package/lib/server/mcp-http-transport.js +350 -0
- package/lib/server/mcp-http-transport.js.map +1 -0
- package/lib/server/mcp-id-alias-service.d.ts +70 -0
- package/lib/server/mcp-id-alias-service.d.ts.map +1 -0
- package/lib/server/mcp-id-alias-service.js +85 -0
- package/lib/server/mcp-id-alias-service.js.map +1 -0
- package/lib/server/mcp-input-schemas.d.ts +73 -0
- package/lib/server/mcp-input-schemas.d.ts.map +1 -0
- package/lib/server/mcp-input-schemas.js +67 -0
- package/lib/server/mcp-input-schemas.js.map +1 -0
- package/lib/server/mcp-label-provider.d.ts +45 -0
- package/lib/server/mcp-label-provider.d.ts.map +1 -0
- package/lib/server/mcp-label-provider.js +42 -0
- package/lib/server/mcp-label-provider.js.map +1 -0
- package/lib/server/mcp-log-level-registry.d.ts +54 -0
- package/lib/server/mcp-log-level-registry.d.ts.map +1 -0
- package/lib/server/mcp-log-level-registry.js +80 -0
- package/lib/server/mcp-log-level-registry.js.map +1 -0
- package/lib/server/mcp-logger.d.ts +59 -0
- package/lib/server/mcp-logger.d.ts.map +1 -0
- package/lib/server/mcp-logger.js +104 -0
- package/lib/server/mcp-logger.js.map +1 -0
- package/lib/server/mcp-mime-types.d.ts +28 -0
- package/lib/server/mcp-mime-types.d.ts.map +1 -0
- package/lib/server/mcp-mime-types.js +18 -0
- package/lib/server/mcp-mime-types.js.map +1 -0
- package/lib/server/mcp-options.d.ts +39 -0
- package/lib/server/mcp-options.d.ts.map +1 -0
- package/lib/server/mcp-options.js +53 -0
- package/lib/server/mcp-options.js.map +1 -0
- package/lib/server/mcp-progress-reporter.d.ts +48 -0
- package/lib/server/mcp-progress-reporter.d.ts.map +1 -0
- package/lib/server/mcp-progress-reporter.js +66 -0
- package/lib/server/mcp-progress-reporter.js.map +1 -0
- package/lib/server/mcp-prompt-handler.d.ts +120 -0
- package/lib/server/mcp-prompt-handler.d.ts.map +1 -0
- package/lib/server/mcp-prompt-handler.js +131 -0
- package/lib/server/mcp-prompt-handler.js.map +1 -0
- package/lib/server/mcp-request-context.d.ts +37 -0
- package/lib/server/mcp-request-context.d.ts.map +1 -0
- package/lib/server/mcp-request-context.js +37 -0
- package/lib/server/mcp-request-context.js.map +1 -0
- package/lib/server/mcp-resource-handler.d.ts +212 -0
- package/lib/server/mcp-resource-handler.d.ts.map +1 -0
- package/lib/server/mcp-resource-handler.js +298 -0
- package/lib/server/mcp-resource-handler.js.map +1 -0
- package/lib/server/mcp-server-launcher.d.ts +143 -0
- package/lib/server/mcp-server-launcher.d.ts.map +1 -0
- package/lib/server/mcp-server-launcher.js +355 -0
- package/lib/server/mcp-server-launcher.js.map +1 -0
- package/lib/server/mcp-server-module.d.ts +143 -0
- package/lib/server/mcp-server-module.d.ts.map +1 -0
- package/lib/server/mcp-server-module.js +249 -0
- package/lib/server/mcp-server-module.js.map +1 -0
- package/lib/server/mcp-session.d.ts +44 -0
- package/lib/server/mcp-session.d.ts.map +1 -0
- package/lib/server/mcp-session.js +18 -0
- package/lib/server/mcp-session.js.map +1 -0
- package/lib/server/mcp-tool-handler.d.ts +259 -0
- package/lib/server/mcp-tool-handler.d.ts.map +1 -0
- package/lib/server/mcp-tool-handler.js +355 -0
- package/lib/server/mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts +46 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.js +76 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts +112 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.js +190 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts +81 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.js +123 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts +52 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.js +73 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts +59 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.js +78 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts +97 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.js +155 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts +43 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js +68 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts +43 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js +71 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts +78 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.js +136 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts +92 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js +125 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts +102 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js +158 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts +45 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js +73 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts +55 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.js +91 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts +65 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.js +108 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts +60 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.js +103 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts +110 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.js +142 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts +45 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js +74 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts +66 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js +0 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js.map +1 -0
- package/lib/tools/index.d.ts +34 -0
- package/lib/tools/index.d.ts.map +1 -0
- package/lib/tools/index.js +50 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/util/index.d.ts +18 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +34 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/markdown-util.d.ts +20 -0
- package/lib/util/markdown-util.d.ts.map +1 -0
- package/lib/util/markdown-util.js +45 -0
- package/lib/util/markdown-util.js.map +1 -0
- package/lib/util/mcp-util.d.ts +22 -0
- package/lib/util/mcp-util.d.ts.map +1 -0
- package/lib/util/mcp-util.js +29 -0
- package/lib/util/mcp-util.js.map +1 -0
- package/package.json +63 -0
- package/src/index.ts +24 -0
- package/src/prompts/handlers/describe-diagram-mcp-prompt-handler.ts +89 -0
- package/src/prompts/handlers/suggest-improvements-mcp-prompt-handler.ts +86 -0
- package/src/prompts/index.ts +18 -0
- package/src/resources/handlers/diagram-png-mcp-resource-handler.ts +181 -0
- package/src/resources/handlers/diagram-svg-mcp-resource-handler.ts +89 -0
- package/src/resources/index.ts +20 -0
- package/src/resources/services/element-types-provider.ts +105 -0
- package/src/resources/services/mcp-model-serializer.ts +211 -0
- package/src/server/glsp-mcp-server.spec.ts +73 -0
- package/src/server/glsp-mcp-server.ts +196 -0
- package/src/server/index.ts +42 -0
- package/src/server/lru-event-store.spec.ts +121 -0
- package/src/server/lru-event-store.ts +112 -0
- package/src/server/mcp-diagram-handler-dispatcher.spec.ts +231 -0
- package/src/server/mcp-diagram-handler-dispatcher.ts +459 -0
- package/src/server/mcp-diagram-module.ts +248 -0
- package/src/server/mcp-diagram-prompt-handler-registry.ts +59 -0
- package/src/server/mcp-diagram-resource-handler-registry.ts +73 -0
- package/src/server/mcp-diagram-tool-handler-registry.ts +97 -0
- package/src/server/mcp-handler-shared.spec.ts +53 -0
- package/src/server/mcp-handler-shared.ts +247 -0
- package/src/server/mcp-http-transport-e2e.spec.ts +151 -0
- package/src/server/mcp-http-transport.spec.ts +385 -0
- package/src/server/mcp-http-transport.ts +368 -0
- package/src/server/mcp-id-alias-service.spec.ts +106 -0
- package/src/server/mcp-id-alias-service.ts +104 -0
- package/src/server/mcp-input-schemas.ts +82 -0
- package/src/server/mcp-label-provider.ts +52 -0
- package/src/server/mcp-log-level-registry.spec.ts +75 -0
- package/src/server/mcp-log-level-registry.ts +90 -0
- package/src/server/mcp-logger.spec.ts +227 -0
- package/src/server/mcp-logger.ts +91 -0
- package/src/server/mcp-mime-types.ts +31 -0
- package/src/server/mcp-options.ts +43 -0
- package/src/server/mcp-progress-reporter.spec.ts +93 -0
- package/src/server/mcp-progress-reporter.ts +67 -0
- package/src/server/mcp-prompt-handler.ts +157 -0
- package/src/server/mcp-request-context.ts +39 -0
- package/src/server/mcp-resource-handler.ts +389 -0
- package/src/server/mcp-server-launcher.spec.ts +173 -0
- package/src/server/mcp-server-launcher.ts +369 -0
- package/src/server/mcp-server-module.ts +287 -0
- package/src/server/mcp-session.ts +45 -0
- package/src/server/mcp-tool-handler.spec.ts +182 -0
- package/src/server/mcp-tool-handler.ts +431 -0
- package/src/server/raw-http.spec.ts +59 -0
- package/src/tools/handlers/count-elements-mcp-tool-handler.spec.ts +99 -0
- package/src/tools/handlers/count-elements-mcp-tool-handler.ts +66 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.spec.ts +196 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.ts +205 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.spec.ts +197 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.ts +131 -0
- package/src/tools/handlers/delete-elements-mcp-tool-handler.ts +73 -0
- package/src/tools/handlers/diagram-model-mcp-tool-handler.ts +66 -0
- package/src/tools/handlers/element-types-mcp-tool-handler.ts +151 -0
- package/src/tools/handlers/get-selection-mcp-tool-handler.ts +54 -0
- package/src/tools/handlers/layout-mcp-tool-handler.ts +56 -0
- package/src/tools/handlers/modify-edges-mcp-tool-handler.ts +148 -0
- package/src/tools/handlers/modify-nodes-mcp-tool-handler.ts +140 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.spec.ts +210 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.ts +161 -0
- package/src/tools/handlers/redo-mcp-tool-handler.ts +62 -0
- package/src/tools/handlers/save-model-mcp-tool-handler.ts +71 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.spec.ts +152 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.ts +97 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.spec.ts +118 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.ts +90 -0
- package/src/tools/handlers/set-view-mcp-tool-handler.ts +162 -0
- package/src/tools/handlers/undo-mcp-tool-handler.ts +61 -0
- package/src/tools/handlers/validate-diagram-mcp-tool-handler.ts +0 -0
- package/src/tools/index.ts +34 -0
- package/src/tools/tool-annotations.spec.ts +141 -0
- package/src/util/index.ts +18 -0
- package/src/util/markdown-util.ts +44 -0
- package/src/util/mcp-util.ts +25 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var ElementTypesMcpToolHandler_1;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.ElementTypesMcpToolHandler = exports.ElementTypesOutputSchema = exports.ElementTypeEntrySchema = exports.ElementTypesInputSchema = void 0;
|
|
29
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
30
|
+
const inversify_1 = require("inversify");
|
|
31
|
+
const z = require("zod/v4");
|
|
32
|
+
const server_2 = require("../../server");
|
|
33
|
+
const element_types_provider_1 = require("../../resources/services/element-types-provider");
|
|
34
|
+
exports.ElementTypesInputSchema = z.object({
|
|
35
|
+
sessionId: z.string().optional().describe('Open GLSP session id; diagram type is derived from it. Provide this OR `diagramType`.'),
|
|
36
|
+
diagramType: z.string().optional().describe('Diagram type to query. Provide this OR `sessionId`; useful when no session is open yet.')
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* `id` + `label` are required (the default registry-scrape provides both); `description` and
|
|
40
|
+
* `acceptsText` are optional adopter-richer fields. `.loose()` lets adopter providers attach
|
|
41
|
+
* arbitrary extra fields without us having to widen the schema each time.
|
|
42
|
+
*/
|
|
43
|
+
exports.ElementTypeEntrySchema = z
|
|
44
|
+
.object({
|
|
45
|
+
id: z.string().describe('Element type id used by `create-*` tools (e.g. `task:manual`).'),
|
|
46
|
+
label: z.string().describe('Human-readable display name for the element TYPE (e.g. `Manual Task`).'),
|
|
47
|
+
description: z.string().optional().describe('Adopter-supplied human-readable description.'),
|
|
48
|
+
acceptsText: z
|
|
49
|
+
.boolean()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Whether `create-*` / `modify-*` tools should pass a `text` arg for elements of this type. Absent ⇒ unknown.')
|
|
52
|
+
})
|
|
53
|
+
.loose();
|
|
54
|
+
exports.ElementTypesOutputSchema = z.object({
|
|
55
|
+
diagramType: z.string(),
|
|
56
|
+
nodeTypes: z.array(exports.ElementTypeEntrySchema),
|
|
57
|
+
edgeTypes: z.array(exports.ElementTypeEntrySchema)
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Server-scope so the LLM can discover types before opening a session. Lazy-harvests the
|
|
61
|
+
* per-diagram-type {@link ElementTypesProvider} via a temporary child container (same pattern
|
|
62
|
+
* as core's `DefaultGlobalActionProvider`) and caches the result for the server's lifetime —
|
|
63
|
+
* element-type sets are static at runtime, so we pay the harvest cost once per type.
|
|
64
|
+
*
|
|
65
|
+
* Adopters with statically-known type info bind their own {@link ElementTypesProvider} via
|
|
66
|
+
* `bindElementTypesProvider()`; the harvest picks it up without further overrides.
|
|
67
|
+
*/
|
|
68
|
+
let ElementTypesMcpToolHandler = ElementTypesMcpToolHandler_1 = class ElementTypesMcpToolHandler extends server_2.AbstractMcpToolHandler {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.name = ElementTypesMcpToolHandler_1.NAME;
|
|
72
|
+
this.title = 'Creatable Element Types';
|
|
73
|
+
this.description = 'List all element types (nodes and edges) that can be created for a specific diagram type. ' +
|
|
74
|
+
'Use this to discover valid `elementTypeId` values for the create-nodes / create-edges tools. ' +
|
|
75
|
+
'Pass `sessionId` for the diagram you are working in (recommended), or `diagramType` directly ' +
|
|
76
|
+
'when no session of that type is open yet (e.g. when creating a brand-new diagram).';
|
|
77
|
+
this.inputSchema = exports.ElementTypesInputSchema;
|
|
78
|
+
this.outputSchema = exports.ElementTypesOutputSchema;
|
|
79
|
+
this.cache = new Map();
|
|
80
|
+
}
|
|
81
|
+
createResult({ sessionId, diagramType }) {
|
|
82
|
+
const resolved = diagramType !== null && diagramType !== void 0 ? diagramType : this.resolveDiagramType(sessionId);
|
|
83
|
+
const { nodeTypes, edgeTypes } = this.getElementTypes(resolved);
|
|
84
|
+
return this.success(this.summarizeElementTypes(resolved, nodeTypes, edgeTypes), {
|
|
85
|
+
diagramType: resolved,
|
|
86
|
+
nodeTypes,
|
|
87
|
+
edgeTypes
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Builds the LLM-facing summary. Override to customize per-adopter wording. */
|
|
91
|
+
summarizeElementTypes(diagramType, nodeTypes, edgeTypes) {
|
|
92
|
+
return (`Diagram type '${diagramType}': ${nodeTypes.length} node type(s), ${edgeTypes.length} edge type(s); ` +
|
|
93
|
+
`full details in structuredContent.\n` +
|
|
94
|
+
`- Node types: ${nodeTypes.map(entry => entry.id).join(', ') || '(none)'}\n` +
|
|
95
|
+
`- Edge types: ${edgeTypes.map(entry => entry.id).join(', ') || '(none)'}`);
|
|
96
|
+
}
|
|
97
|
+
resolveDiagramType(sessionId) {
|
|
98
|
+
if (!sessionId) {
|
|
99
|
+
throw new server_2.McpToolError('Either `diagramType` or `sessionId` must be provided.');
|
|
100
|
+
}
|
|
101
|
+
const session = this.clientSessionManager.getSession(sessionId);
|
|
102
|
+
if (!session) {
|
|
103
|
+
throw new server_2.McpToolError(`Unknown sessionId: ${sessionId}`);
|
|
104
|
+
}
|
|
105
|
+
return session.diagramType;
|
|
106
|
+
}
|
|
107
|
+
getElementTypes(diagramType) {
|
|
108
|
+
let types = this.cache.get(diagramType);
|
|
109
|
+
if (!types) {
|
|
110
|
+
types = this.harvestElementTypes(diagramType);
|
|
111
|
+
this.cache.set(diagramType, types);
|
|
112
|
+
}
|
|
113
|
+
return types;
|
|
114
|
+
}
|
|
115
|
+
/** Runs session-open initializers on a throwaway container so registries (e.g. `OperationHandlerRegistry`) are populated for the provider to scrape. */
|
|
116
|
+
harvestElementTypes(diagramType) {
|
|
117
|
+
const modules = this.diagramModules.get(diagramType);
|
|
118
|
+
if (!modules) {
|
|
119
|
+
throw new server_2.McpToolError(`Unknown diagram type: ${diagramType}`);
|
|
120
|
+
}
|
|
121
|
+
const tempContainer = this.serverContainer.createChild();
|
|
122
|
+
try {
|
|
123
|
+
const placeholderSessionModule = (0, server_1.createClientSessionModule)({
|
|
124
|
+
clientId: 'mcp-element-types-temp',
|
|
125
|
+
glspClient: { process: () => { } },
|
|
126
|
+
clientActionKinds: []
|
|
127
|
+
});
|
|
128
|
+
tempContainer.load(...modules, placeholderSessionModule);
|
|
129
|
+
const initializers = tempContainer.getAll(server_1.ClientSessionInitializer);
|
|
130
|
+
initializers.forEach(initializer => initializer.initialize());
|
|
131
|
+
return tempContainer.get(element_types_provider_1.ElementTypesProvider).get();
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
tempContainer.unbindAll();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.ElementTypesMcpToolHandler = ElementTypesMcpToolHandler;
|
|
139
|
+
ElementTypesMcpToolHandler.NAME = 'element-types';
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, inversify_1.inject)(server_1.DiagramModules),
|
|
142
|
+
__metadata("design:type", Map)
|
|
143
|
+
], ElementTypesMcpToolHandler.prototype, "diagramModules", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, inversify_1.inject)(server_1.InjectionContainer),
|
|
146
|
+
__metadata("design:type", inversify_1.Container)
|
|
147
|
+
], ElementTypesMcpToolHandler.prototype, "serverContainer", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, inversify_1.inject)(server_1.ClientSessionManager),
|
|
150
|
+
__metadata("design:type", Object)
|
|
151
|
+
], ElementTypesMcpToolHandler.prototype, "clientSessionManager", void 0);
|
|
152
|
+
exports.ElementTypesMcpToolHandler = ElementTypesMcpToolHandler = ElementTypesMcpToolHandler_1 = __decorate([
|
|
153
|
+
(0, inversify_1.injectable)()
|
|
154
|
+
], ElementTypesMcpToolHandler);
|
|
155
|
+
//# sourceMappingURL=element-types-mcp-tool-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-types-mcp-tool-handler.js","sourceRoot":"","sources":["../../../src/tools/handlers/element-types-mcp-tool-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;AAElF,iDAM8B;AAC9B,yCAA2E;AAC3E,4BAA4B;AAC5B,yCAAmF;AACnF,4FAAqG;AAExF,QAAA,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,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B,+BAAI,GAAG,eAAe,AAAlB,CAAmB;AAJL;IAAjC,IAAA,kBAAM,EAAC,uBAAc,CAAC;8BAA2B,GAAG;kEAA4B;AAC3C;IAArC,IAAA,kBAAM,EAAC,2BAAkB,CAAC;8BAA4B,qBAAS;mEAAC;AACzB;IAAvC,IAAA,kBAAM,EAAC,6BAAoB,CAAC;;wEAAsD;qCAH1E,0BAA0B;IADtC,IAAA,sBAAU,GAAE;GACA,0BAA0B,CAmFtC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { ActionDispatcher } from '@eclipse-glsp/server';
|
|
17
|
+
import * as z from 'zod/v4';
|
|
18
|
+
import { AbstractMcpDiagramToolHandler, McpToolResult } from '../../server';
|
|
19
|
+
export declare const GetSelectionInputSchema: z.ZodObject<{
|
|
20
|
+
sessionId: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type GetSelectionInput = z.infer<typeof GetSelectionInputSchema>;
|
|
23
|
+
export declare const GetSelectionOutputSchema: z.ZodObject<{
|
|
24
|
+
selectedElementIds: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/** Round-trips a sprotty {@link GetSelectionAction} via `ActionDispatcher.requestUntil` and awaits the matching `SelectionResult`. */
|
|
27
|
+
export declare class GetSelectionMcpToolHandler extends AbstractMcpDiagramToolHandler<GetSelectionInput> {
|
|
28
|
+
/** Timeout (in ms) for awaiting the selection response from the client. Override via subclass + rebind. */
|
|
29
|
+
protected readonly timeoutMs: number;
|
|
30
|
+
static readonly NAME = "get-selection";
|
|
31
|
+
readonly name = "get-selection";
|
|
32
|
+
readonly title = "Get Selected Diagram Elements";
|
|
33
|
+
readonly description: string;
|
|
34
|
+
readonly inputSchema: z.ZodObject<{
|
|
35
|
+
sessionId: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
readonly outputSchema: z.ZodObject<{
|
|
38
|
+
selectedElementIds: z.ZodArray<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
protected actionDispatcher: ActionDispatcher;
|
|
41
|
+
protected createResult(_params: GetSelectionInput): Promise<McpToolResult>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=get-selection-mcp-tool-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-selection-mcp-tool-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/get-selection-mcp-tool-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAE5E,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAA+B,6BAA6B,EAAE,aAAa,EAAuB,MAAM,cAAc,CAAC;AAE9H,eAAO,MAAM,uBAAuB;;iBAA8B,CAAC;AACnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,wBAAwB;;iBAEnC,CAAC;AAEH,sIAAsI;AACtI,qBACa,0BAA2B,SAAQ,6BAA6B,CAAC,iBAAiB,CAAC;IAC5F,2GAA2G;IAC3G,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAQ;IAE5C,MAAM,CAAC,QAAQ,CAAC,IAAI,mBAAmB;IACvC,QAAQ,CAAC,IAAI,mBAAmC;IAChD,SAAkB,KAAK,mCAAmC;IAC1D,QAAQ,CAAC,WAAW,SAIkC;IACtD,QAAQ,CAAC,WAAW;;sBAA2B;IAC/C,SAAkB,YAAY;;sBAA4B;IAEhC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;cAEvD,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;CAMnF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var GetSelectionMcpToolHandler_1;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.GetSelectionMcpToolHandler = exports.GetSelectionOutputSchema = exports.GetSelectionInputSchema = void 0;
|
|
29
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
30
|
+
const inversify_1 = require("inversify");
|
|
31
|
+
const z = require("zod/v4");
|
|
32
|
+
const server_2 = require("../../server");
|
|
33
|
+
exports.GetSelectionInputSchema = server_2.McpDiagramScopedInputSchema;
|
|
34
|
+
exports.GetSelectionOutputSchema = z.object({
|
|
35
|
+
selectedElementIds: z.array(z.string()).describe('Aliased ids of the elements currently selected on the client.')
|
|
36
|
+
});
|
|
37
|
+
/** Round-trips a sprotty {@link GetSelectionAction} via `ActionDispatcher.requestUntil` and awaits the matching `SelectionResult`. */
|
|
38
|
+
let GetSelectionMcpToolHandler = GetSelectionMcpToolHandler_1 = class GetSelectionMcpToolHandler extends server_2.AbstractMcpDiagramToolHandler {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
/** Timeout (in ms) for awaiting the selection response from the client. Override via subclass + rebind. */
|
|
42
|
+
this.timeoutMs = 5000;
|
|
43
|
+
this.name = GetSelectionMcpToolHandler_1.NAME;
|
|
44
|
+
this.title = 'Get Selected Diagram Elements';
|
|
45
|
+
this.description = 'Get the element IDs of all elements currently selected in the user-facing diagram UI. ' +
|
|
46
|
+
'Use this only when the user explicitly references their selection ("the selected node", "what I have highlighted"); ' +
|
|
47
|
+
'do not call it speculatively. Pairs with `set-selection` for write-side selection control. ' +
|
|
48
|
+
'Returns an empty list when nothing is selected.';
|
|
49
|
+
this.inputSchema = exports.GetSelectionInputSchema;
|
|
50
|
+
this.outputSchema = exports.GetSelectionOutputSchema;
|
|
51
|
+
}
|
|
52
|
+
async createResult(_params) {
|
|
53
|
+
const response = await (0, server_2.requestActionOrFail)(this.actionDispatcher, server_1.GetSelectionAction.create(), this.timeoutMs, this.name);
|
|
54
|
+
const selectedElementIds = this.encodeIds(response.selectedElementsIDs);
|
|
55
|
+
const selectedIdsStr = selectedElementIds.map(id => `- ${id}`).join('\n');
|
|
56
|
+
return this.success(`Following element IDs are selected:\n${selectedIdsStr}`, { selectedElementIds });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.GetSelectionMcpToolHandler = GetSelectionMcpToolHandler;
|
|
60
|
+
GetSelectionMcpToolHandler.NAME = 'get-selection';
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, inversify_1.inject)(server_1.ActionDispatcher),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], GetSelectionMcpToolHandler.prototype, "actionDispatcher", void 0);
|
|
65
|
+
exports.GetSelectionMcpToolHandler = GetSelectionMcpToolHandler = GetSelectionMcpToolHandler_1 = __decorate([
|
|
66
|
+
(0, inversify_1.injectable)()
|
|
67
|
+
], GetSelectionMcpToolHandler);
|
|
68
|
+
//# sourceMappingURL=get-selection-mcp-tool-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-selection-mcp-tool-handler.js","sourceRoot":"","sources":["../../../src/tools/handlers/get-selection-mcp-tool-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;AAElF,iDAA4E;AAC5E,yCAA+C;AAC/C,4BAA4B;AAC5B,yCAA8H;AAEjH,QAAA,uBAAuB,GAAG,oCAA2B,CAAC;AAGtD,QAAA,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,kBAAkB,EAAE,CAAC,CAAC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+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { LayoutEngine } from '@eclipse-glsp/server';
|
|
17
|
+
import * as z from 'zod/v4';
|
|
18
|
+
import { McpToolResult, OperationMcpDiagramToolHandler } from '../../server';
|
|
19
|
+
export declare const LayoutInputSchema: z.ZodObject<{
|
|
20
|
+
sessionId: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type LayoutInput = z.infer<typeof LayoutInputSchema>;
|
|
23
|
+
export declare const LayoutOutputSchema: z.ZodObject<{
|
|
24
|
+
applied: z.ZodBoolean;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/** Not registered by default: requires an adopter-supplied `LayoutEngine` to bind, which only some GLSP servers ship. */
|
|
27
|
+
export declare class LayoutMcpToolHandler extends OperationMcpDiagramToolHandler<LayoutInput> {
|
|
28
|
+
static readonly NAME = "layout";
|
|
29
|
+
readonly name = "layout";
|
|
30
|
+
readonly title = "Auto-Layout Diagram";
|
|
31
|
+
readonly description: string;
|
|
32
|
+
readonly inputSchema: z.ZodObject<{
|
|
33
|
+
sessionId: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
readonly outputSchema: z.ZodObject<{
|
|
36
|
+
applied: z.ZodBoolean;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
protected layoutEngine?: LayoutEngine;
|
|
39
|
+
/** Skip-bind when no `LayoutEngine` is bound — every dispatch would otherwise no-op. */
|
|
40
|
+
canRegister(): boolean;
|
|
41
|
+
protected createResult(_params: LayoutInput): Promise<McpToolResult>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=layout-mcp-tool-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-mcp-tool-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/layout-mcp-tool-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAA+B,aAAa,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE1G,eAAO,MAAM,iBAAiB;;iBAA8B,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAEH,yHAAyH;AACzH,qBACa,oBAAqB,SAAQ,8BAA8B,CAAC,WAAW,CAAC;IACjF,MAAM,CAAC,QAAQ,CAAC,IAAI,YAAY;IAChC,QAAQ,CAAC,IAAI,YAA6B;IAC1C,SAAkB,KAAK,yBAAyB;IAChD,QAAQ,CAAC,WAAW,SAM+D;IACnF,QAAQ,CAAC,WAAW;;sBAAqB;IACzC,SAAkB,YAAY;;sBAAsB;IAElB,SAAS,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IAExE,wFAAwF;IAC/E,WAAW,IAAI,OAAO;cAIf,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAI7E"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var LayoutMcpToolHandler_1;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.LayoutMcpToolHandler = exports.LayoutOutputSchema = exports.LayoutInputSchema = void 0;
|
|
29
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
30
|
+
const inversify_1 = require("inversify");
|
|
31
|
+
const z = require("zod/v4");
|
|
32
|
+
const server_2 = require("../../server");
|
|
33
|
+
exports.LayoutInputSchema = server_2.McpDiagramScopedInputSchema;
|
|
34
|
+
exports.LayoutOutputSchema = z.object({
|
|
35
|
+
applied: z.boolean().describe('Always true on success — surfaced for parity with other operations.')
|
|
36
|
+
});
|
|
37
|
+
/** Not registered by default: requires an adopter-supplied `LayoutEngine` to bind, which only some GLSP servers ship. */
|
|
38
|
+
let LayoutMcpToolHandler = LayoutMcpToolHandler_1 = class LayoutMcpToolHandler extends server_2.OperationMcpDiagramToolHandler {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.name = LayoutMcpToolHandler_1.NAME;
|
|
42
|
+
this.title = 'Auto-Layout Diagram';
|
|
43
|
+
this.description = "Trigger automatic layout computation for the given session's diagram, repositioning all nodes and " +
|
|
44
|
+
'rerouting all edges according to the configured layout engine. ' +
|
|
45
|
+
'Use this only when the user explicitly asks for "automatic layout" or similar — it overwrites every ' +
|
|
46
|
+
'manual position in the diagram and is generally a destructive change for hand-tuned layouts. ' +
|
|
47
|
+
'For targeted positional edits prefer `modify-nodes` / `modify-edges`. ' +
|
|
48
|
+
'Adopters who do not bind a `LayoutEngine` will not see this tool registered.';
|
|
49
|
+
this.inputSchema = exports.LayoutInputSchema;
|
|
50
|
+
this.outputSchema = exports.LayoutOutputSchema;
|
|
51
|
+
}
|
|
52
|
+
/** Skip-bind when no `LayoutEngine` is bound — every dispatch would otherwise no-op. */
|
|
53
|
+
canRegister() {
|
|
54
|
+
return this.layoutEngine !== undefined;
|
|
55
|
+
}
|
|
56
|
+
async createResult(_params) {
|
|
57
|
+
await this.actionDispatcher.dispatch(server_1.LayoutOperation.create());
|
|
58
|
+
return this.success('Automatic layout applied', { applied: true });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.LayoutMcpToolHandler = LayoutMcpToolHandler;
|
|
62
|
+
LayoutMcpToolHandler.NAME = 'layout';
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, inversify_1.inject)(server_1.LayoutEngine),
|
|
65
|
+
(0, inversify_1.optional)(),
|
|
66
|
+
__metadata("design:type", Object)
|
|
67
|
+
], LayoutMcpToolHandler.prototype, "layoutEngine", void 0);
|
|
68
|
+
exports.LayoutMcpToolHandler = LayoutMcpToolHandler = LayoutMcpToolHandler_1 = __decorate([
|
|
69
|
+
(0, inversify_1.injectable)()
|
|
70
|
+
], LayoutMcpToolHandler);
|
|
71
|
+
//# sourceMappingURL=layout-mcp-tool-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-mcp-tool-handler.js","sourceRoot":"","sources":["../../../src/tools/handlers/layout-mcp-tool-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;AAElF,iDAAqE;AACrE,yCAAyD;AACzD,4BAA4B;AAC5B,yCAA0G;AAE7F,QAAA,iBAAiB,GAAG,oCAA2B,CAAC;AAGhD,QAAA,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,qEAAqE,CAAC;CACvG,CAAC,CAAC;AAEH,yHAAyH;AAElH,IAAM,oBAAoB,4BAA1B,MAAM,oBAAqB,SAAQ,uCAA2C;IAA9E;;QAEM,SAAI,GAAG,sBAAoB,CAAC,IAAI,CAAC;QACxB,UAAK,GAAG,qBAAqB,CAAC;QACvC,gBAAW,GAChB,oGAAoG;YACpG,iEAAiE;YACjE,sGAAsG;YACtG,+FAA+F;YAC/F,wEAAwE;YACxE,8EAA8E,CAAC;QAC1E,gBAAW,GAAG,yBAAiB,CAAC;QACvB,iBAAY,GAAG,0BAAkB,CAAC;IAaxD,CAAC;IATG,wFAAwF;IAC/E,WAAW;QAChB,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC;IAC3C,CAAC;IAES,KAAK,CAAC,YAAY,CAAC,OAAoB;QAC7C,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,wBAAe,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;;AAxBQ,oDAAoB;AACb,yBAAI,GAAG,QAAQ,AAAX,CAAY;AAaY;IAA3C,IAAA,kBAAM,EAAC,qBAAY,CAAC;IAAE,IAAA,oBAAQ,GAAE;;0DAAuC;+BAd/D,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAyBhC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import * as z from 'zod/v4';
|
|
17
|
+
import { McpToolResult, OperationMcpDiagramToolHandler } from '../../server';
|
|
18
|
+
/** Single edge-modification entry. Strict so an LLM-typoed field surfaces as a validation error instead of being silently dropped. */
|
|
19
|
+
export declare const ModifyEdgeSpecSchema: z.ZodObject<{
|
|
20
|
+
elementId: z.ZodString;
|
|
21
|
+
sourceElementId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
targetElementId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
routingPoints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
|
+
x: z.ZodNumber;
|
|
25
|
+
y: z.ZodNumber;
|
|
26
|
+
}, z.core.$strict>>>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
export declare const ModifyEdgesInputSchema: z.ZodObject<{
|
|
29
|
+
sessionId: z.ZodString;
|
|
30
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
31
|
+
elementId: z.ZodString;
|
|
32
|
+
sourceElementId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
targetElementId: z.ZodOptional<z.ZodString>;
|
|
34
|
+
routingPoints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
35
|
+
x: z.ZodNumber;
|
|
36
|
+
y: z.ZodNumber;
|
|
37
|
+
}, z.core.$strict>>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type ModifyEdgesInput = z.infer<typeof ModifyEdgesInputSchema>;
|
|
41
|
+
export declare const ModifyEdgesOutputSchema: z.ZodObject<{
|
|
42
|
+
modifiedEdges: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
elementTypeId: z.ZodString;
|
|
45
|
+
label: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
dispatchedCommands: z.ZodNumber;
|
|
48
|
+
errors: z.ZodArray<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare class ModifyEdgesMcpToolHandler extends OperationMcpDiagramToolHandler<ModifyEdgesInput> {
|
|
51
|
+
static readonly NAME = "modify-edges";
|
|
52
|
+
readonly name = "modify-edges";
|
|
53
|
+
readonly title = "Modify Diagram Edges";
|
|
54
|
+
readonly description: string;
|
|
55
|
+
readonly inputSchema: z.ZodObject<{
|
|
56
|
+
sessionId: z.ZodString;
|
|
57
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
58
|
+
elementId: z.ZodString;
|
|
59
|
+
sourceElementId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
targetElementId: z.ZodOptional<z.ZodString>;
|
|
61
|
+
routingPoints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
|
+
x: z.ZodNumber;
|
|
63
|
+
y: z.ZodNumber;
|
|
64
|
+
}, z.core.$strict>>>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
readonly outputSchema: z.ZodObject<{
|
|
68
|
+
modifiedEdges: z.ZodArray<z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
elementTypeId: z.ZodString;
|
|
71
|
+
label: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
dispatchedCommands: z.ZodNumber;
|
|
74
|
+
errors: z.ZodArray<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
protected createResult({ edges }: ModifyEdgesInput): Promise<McpToolResult>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=modify-edges-mcp-tool-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-edges-mcp-tool-handler.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/modify-edges-mcp-tool-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAIH,aAAa,EACb,8BAA8B,EAGjC,MAAM,cAAc,CAAC;AAGtB,sIAAsI;AACtI,eAAO,MAAM,oBAAoB;;;;;;;;kBAW/B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBAKjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,uBAAuB;;;;;;;;iBAIlC,CAAC;AAEH,qBACa,yBAA0B,SAAQ,8BAA8B,CAAC,gBAAgB,CAAC;IAC3F,MAAM,CAAC,QAAQ,CAAC,IAAI,kBAAkB;IACtC,QAAQ,CAAC,IAAI,kBAAkC;IAC/C,SAAkB,KAAK,0BAA0B;IACjD,QAAQ,CAAC,WAAW,SAM8C;IAClE,QAAQ,CAAC,WAAW;;;;;;;;;;;sBAA0B;IAC9C,SAAkB,YAAY;;;;;;;;sBAA2B;cAEzC,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CA0EpF"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var ModifyEdgesMcpToolHandler_1;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ModifyEdgesMcpToolHandler = exports.ModifyEdgesOutputSchema = exports.ModifyEdgesInputSchema = exports.ModifyEdgeSpecSchema = void 0;
|
|
26
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
27
|
+
const inversify_1 = require("inversify");
|
|
28
|
+
const z = require("zod/v4");
|
|
29
|
+
const server_2 = require("../../server");
|
|
30
|
+
const util_1 = require("../../util");
|
|
31
|
+
/** Single edge-modification entry. Strict so an LLM-typoed field surfaces as a validation error instead of being silently dropped. */
|
|
32
|
+
exports.ModifyEdgeSpecSchema = z.strictObject({
|
|
33
|
+
elementId: server_2.elementId,
|
|
34
|
+
sourceElementId: z.string().optional().describe('ID of the source element (must exist in the diagram)'),
|
|
35
|
+
targetElementId: z.string().optional().describe('ID of the target element (must exist in the diagram)'),
|
|
36
|
+
routingPoints: z
|
|
37
|
+
.array(server_2.position)
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Optional array of routing point coordinates that allow for a complex edge path. ' +
|
|
40
|
+
'Using an empty array removes all routing points.')
|
|
41
|
+
});
|
|
42
|
+
exports.ModifyEdgesInputSchema = server_2.McpDiagramScopedInputSchema.extend({
|
|
43
|
+
edges: z
|
|
44
|
+
.array(exports.ModifyEdgeSpecSchema)
|
|
45
|
+
.min(1)
|
|
46
|
+
.describe('Array of edge changes — each entry needs `elementId` plus the fields to update. Must include at least one change.')
|
|
47
|
+
});
|
|
48
|
+
exports.ModifyEdgesOutputSchema = z.object({
|
|
49
|
+
modifiedEdges: z.array(server_2.ElementIdentitySchema).describe('Identity of each edge whose change request was dispatched.'),
|
|
50
|
+
dispatchedCommands: z.number().int().describe('Number of underlying GLSP operations dispatched.'),
|
|
51
|
+
errors: z.array(z.string()).describe('Per-input failure messages; absent or empty when every input succeeded.')
|
|
52
|
+
});
|
|
53
|
+
let ModifyEdgesMcpToolHandler = ModifyEdgesMcpToolHandler_1 = class ModifyEdgesMcpToolHandler extends server_2.OperationMcpDiagramToolHandler {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this.name = ModifyEdgesMcpToolHandler_1.NAME;
|
|
57
|
+
this.title = 'Modify Diagram Edges';
|
|
58
|
+
this.description = 'Modify one or more existing edges by reconnecting their source/target endpoints or rewriting their routing points. ' +
|
|
59
|
+
'Reconnection (provide both `sourceElementId` and `targetElementId`) and routing-point edits are mutually exclusive ' +
|
|
60
|
+
'per change entry — a reconnect recomputes the path from scratch and ignores `routingPoints`. ' +
|
|
61
|
+
'Pass an empty `routingPoints` array to remove all routing points (snap to a straight line). ' +
|
|
62
|
+
'This operation modifies the diagram state and requires user approval. ' +
|
|
63
|
+
'For nodes (position/size/text), use `modify-nodes` instead.';
|
|
64
|
+
this.inputSchema = exports.ModifyEdgesInputSchema;
|
|
65
|
+
this.outputSchema = exports.ModifyEdgesOutputSchema;
|
|
66
|
+
}
|
|
67
|
+
async createResult({ edges }) {
|
|
68
|
+
const elements = this.lookupElements(edges, change => change.elementId);
|
|
69
|
+
// Type-validate so non-edge ids surface a clear error instead of "model element not found"
|
|
70
|
+
// from the dispatched operation handler. Aliases are sequential across all element kinds,
|
|
71
|
+
// so an LLM passing an arbitrary id may hit a node here.
|
|
72
|
+
const wrongType = elements
|
|
73
|
+
.filter(([, element]) => !(element instanceof server_1.GEdge))
|
|
74
|
+
.map(([change, element]) => `'${change.elementId}' (type '${element.type}')`);
|
|
75
|
+
if (wrongType.length) {
|
|
76
|
+
throw new server_2.McpToolError(`modify-edges accepts edges only — got: ${wrongType.join(', ')}. Use modify-nodes for nodes.`);
|
|
77
|
+
}
|
|
78
|
+
// Dispatch in parallel via `allSettled` so one failed edge surfaces in `errors`
|
|
79
|
+
// instead of rejecting the whole call and losing the other outcomes.
|
|
80
|
+
const dispatched = [];
|
|
81
|
+
const errors = [];
|
|
82
|
+
const modifiedRealIds = new Set();
|
|
83
|
+
elements.forEach(([change]) => {
|
|
84
|
+
const { routingPoints } = change;
|
|
85
|
+
const realId = this.aliasService.lookup(change.elementId);
|
|
86
|
+
const sourceElementId = change.sourceElementId ? this.aliasService.lookup(change.sourceElementId) : undefined;
|
|
87
|
+
const targetElementId = change.targetElementId ? this.aliasService.lookup(change.targetElementId) : undefined;
|
|
88
|
+
if ((sourceElementId && !targetElementId) || (!sourceElementId && targetElementId)) {
|
|
89
|
+
errors.push(`Both source and target ID are required for input: ${JSON.stringify(change)}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (sourceElementId && targetElementId) {
|
|
93
|
+
const source = this.modelState.index.find(sourceElementId);
|
|
94
|
+
if (!source) {
|
|
95
|
+
errors.push(`Source element not found: ${sourceElementId}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const target = this.modelState.index.find(targetElementId);
|
|
99
|
+
if (!target) {
|
|
100
|
+
errors.push(`Target element not found: ${targetElementId}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const operation = server_1.ReconnectEdgeOperation.create({ edgeElementId: realId, sourceElementId, targetElementId });
|
|
104
|
+
dispatched.push({ promise: this.actionDispatcher.dispatch(operation), realId, inputId: change.elementId });
|
|
105
|
+
modifiedRealIds.add(realId);
|
|
106
|
+
// Routing-point changes are skipped during a reconnect — the edge's path is recomputed from scratch.
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (routingPoints) {
|
|
110
|
+
const operation = server_1.ChangeRoutingPointsOperation.create([{ elementId: realId, newRoutingPoints: routingPoints }]);
|
|
111
|
+
dispatched.push({ promise: this.actionDispatcher.dispatch(operation), realId, inputId: change.elementId });
|
|
112
|
+
modifiedRealIds.add(realId);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const results = await Promise.allSettled(dispatched.map(entry => entry.promise));
|
|
116
|
+
results.forEach((result, i) => {
|
|
117
|
+
if (result.status === 'rejected') {
|
|
118
|
+
const { realId, inputId } = dispatched[i];
|
|
119
|
+
const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
|
|
120
|
+
errors.push(`Failed to modify edge '${inputId}': ${reason}`);
|
|
121
|
+
// The dispatch failed, so this id was *not* modified — drop it from the success list.
|
|
122
|
+
modifiedRealIds.delete(realId);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const modifiedEdges = [...modifiedRealIds]
|
|
126
|
+
.map(realId => this.describeElement(realId))
|
|
127
|
+
.filter((entry) => entry !== undefined);
|
|
128
|
+
return this.success(`Successfully modified ${edges.length - errors.length} edge(s) (in ${dispatched.length} commands)${(0, util_1.formatNoticeList)('errors', errors)}`, { modifiedEdges, dispatchedCommands: dispatched.length, errors });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
exports.ModifyEdgesMcpToolHandler = ModifyEdgesMcpToolHandler;
|
|
132
|
+
ModifyEdgesMcpToolHandler.NAME = 'modify-edges';
|
|
133
|
+
exports.ModifyEdgesMcpToolHandler = ModifyEdgesMcpToolHandler = ModifyEdgesMcpToolHandler_1 = __decorate([
|
|
134
|
+
(0, inversify_1.injectable)()
|
|
135
|
+
], ModifyEdgesMcpToolHandler);
|
|
136
|
+
//# sourceMappingURL=modify-edges-mcp-tool-handler.js.map
|