Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/workflow-standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"compile": "tsc -b",
"dev": "yarn ts-node ./scripts/start.ts --dev",
"dev:browser": "yarn ts-node ./scripts/start.ts --dev --browser",
"dev:mcp": "yarn ts-node ./scripts/start.ts --dev --mcp",
"lint": "eslint ./src",
"start": "yarn ts-node ./scripts/start.ts",
"start:browser": "yarn ts-node ./scripts/start.ts --browser",
"start:mcp": "yarn ts-node ./scripts/start.ts --mcp",
"start:server": "yarn ts-node ./scripts/start-node-server.ts",
"watch": "tsc -w"
},
Expand Down
3 changes: 2 additions & 1 deletion examples/workflow-standalone/scripts/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { downloadServerBundle, resolveVersion, SERVER_DIR_PATH } from './downloa

const isBrowser = process.argv.includes('--browser');
const isDev = process.argv.includes('--dev');
const isMcp = process.argv.includes('--mcp');
const noOpen = process.argv.includes('--no-open');

const externalServerIndex = process.argv.indexOf('--external-server');
Expand Down Expand Up @@ -64,7 +65,7 @@ async function run(): Promise<void> {
await downloadServerBundle({ ...bundle, version: resolveVersion() });
}

const webpackCmd = `webpack serve${isBrowser ? ' --env mode=browser' : ''}${noOpen ? ' --no-open' : ''}`;
const webpackCmd = `webpack serve${isBrowser ? ' --env mode=browser' : ''}${isMcp ? ' --env mcp' : ''}${noOpen ? ' --no-open' : ''}`;
const commands: { command: string; name: string }[] = [];
const prefixColors: string[] = [];

Expand Down
5 changes: 2 additions & 3 deletions examples/workflow-standalone/src/common/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import {
import { Container } from 'inversify';
import '../../css/diagram.css';
import { standaloneTaskEditorModule } from './features/direct-task-editing/standalone-task-editor-module';
import { getParameters } from './url-parameters';
import { hasParameter } from './url-parameters';
export default function createContainer(options: IDiagramOptions): Container {
const parameters = getParameters();
if (parameters.readonly) {
if (hasParameter('readonly')) {
options.editMode = EditMode.READONLY;
}
const container = createWorkflowDiagramContainer(
Expand Down
21 changes: 2 additions & 19 deletions examples/workflow-standalone/src/common/url-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

export function getParameters(): Record<string, string> {
let search = window.location.search.substring(1);
const result: Record<string, string> = {};
while (search.length > 0) {
const nextParamIndex = search.indexOf('&');
let param: string;
if (nextParamIndex < 0) {
param = search;
search = '';
} else {
param = search.substring(0, nextParamIndex);
search = search.substring(nextParamIndex + 1);
}
const valueIndex = param.indexOf('=');
if (valueIndex > 0 && valueIndex < param.length - 1) {
result[param.substring(0, valueIndex)] = decodeURIComponent(param.substring(valueIndex + 1));
}
}
return result;
export function hasParameter(name: string): boolean {
return new URLSearchParams(window.location.search).has(name);
}
25 changes: 15 additions & 10 deletions examples/workflow-standalone/src/node/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { Container } from 'inversify';
import { MessageConnection } from 'vscode-jsonrpc';
import createContainer from '../common/di.config';
import { hasParameter } from '../common/url-parameters';
const host = GLSP_SERVER_HOST;
const port = GLSP_SERVER_PORT;
const id = 'workflow';
Expand All @@ -50,17 +51,21 @@ async function initialize(connectionProvider: MessageConnection, isReconnecting
container = createContainer({ clientId, diagramType, glspClientProvider: async () => glspClient, sourceUri: examplePath });
const actionDispatcher = container.get(GLSPActionDispatcher);
const diagramLoader = container.get(DiagramLoader);
await diagramLoader.load<McpInitializeParameters>({
requestModelOptions: { isReconnecting },
initializeParameters: { mcpServer: { name: 'glsp-workflow', port: Number(GLSP_MCP_SERVER_PORT) } }
});
const mcpEnabled = hasParameter('mcp');

// Surface the MCP server URL announced by the GLSP server for dev visibility.
const mcpServer = McpInitializeResult.getServer(glspClient.initializeResult);
if (mcpServer && !isReconnecting) {
const message = `MCP server '${mcpServer.name}' available at ${mcpServer.url}`;
console.info(`[GLSP-MCP] ${message}`);
actionDispatcher.dispatch(ShowToastMessageAction.createWithTimeout({ message, timeout: 10_000 }));
if (mcpEnabled) {
await diagramLoader.load<McpInitializeParameters>({
requestModelOptions: { isReconnecting },
initializeParameters: { mcpServer: { name: 'glsp-workflow', port: Number(GLSP_MCP_SERVER_PORT) } }
});
const mcpServer = McpInitializeResult.getServer(glspClient.initializeResult);
if (mcpServer && !isReconnecting) {
const message = `MCP server '${mcpServer.name}' available at ${mcpServer.url}`;
console.info(`[GLSP-MCP] ${message}`);
actionDispatcher.dispatch(ShowToastMessageAction.createWithTimeout({ message, timeout: 10_000 }));
}
} else {
await diagramLoader.load({ requestModelOptions: { isReconnecting } });
}

if (isReconnecting) {
Expand Down
3 changes: 2 additions & 1 deletion examples/workflow-standalone/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var CircularDependencyPlugin = require('circular-dependency-plugin');
*/
module.exports = (env = {}) => {
const isBrowser = env.mode === 'browser';
const isMcp = Boolean(env.mcp);

const plugins = [
new CircularDependencyPlugin({
Expand Down Expand Up @@ -109,7 +110,7 @@ module.exports = (env = {}) => {
static: devServerStatic,
compress: true,
port: parseInt(process.env.CLIENT_PORT || (isBrowser ? '8083' : '8082')),
open: '/diagram.html'
open: isMcp ? '/diagram.html?mcp' : '/diagram.html'
}
};
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"compile": "tsc -b",
"dev": "yarn standalone dev",
"dev:browser": "yarn standalone dev:browser",
"dev:mcp": "yarn standalone dev:mcp",
"fix:all": "yarn lint:fix && yarn format && yarn headers:fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
Expand All @@ -29,6 +30,7 @@
"standalone": "yarn --cwd ./examples/workflow-standalone",
"start": "yarn standalone start",
"start:browser": "yarn standalone start:browser",
"start:mcp": "yarn standalone start:mcp",
"start:exampleServer": "yarn standalone start:server",
"test": "lerna run test --no-bail",
"test:ci": "lerna run test:ci --no-bail",
Expand Down
Loading