@mag.ni/process 1.0.0
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 +21 -0
- package/README.md +122 -0
- package/dist/auth.d.ts +50 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +421 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +208 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +701 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agents.d.ts +39 -0
- package/dist/tools/agents.d.ts.map +1 -0
- package/dist/tools/agents.js +141 -0
- package/dist/tools/agents.js.map +1 -0
- package/dist/tools/design.d.ts +175 -0
- package/dist/tools/design.d.ts.map +1 -0
- package/dist/tools/design.js +1172 -0
- package/dist/tools/design.js.map +1 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +131 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/session.d.ts +77 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +285 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/work.d.ts +99 -0
- package/dist/tools/work.d.ts.map +1 -0
- package/dist/tools/work.js +702 -0
- package/dist/tools/work.js.map +1 -0
- package/dist/types.d.ts +264 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,1172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Processes - Design Tools
|
|
3
|
+
* Tools for creating and modifying diagrams in design mode
|
|
4
|
+
*/
|
|
5
|
+
const designModeState = {
|
|
6
|
+
isDesignMode: false,
|
|
7
|
+
activeDiagramId: null,
|
|
8
|
+
};
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Tool Definitions
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Tool: enter_design_mode
|
|
14
|
+
* Switch to design mode to create and modify diagrams
|
|
15
|
+
*/
|
|
16
|
+
export const enterDesignModeTool = {
|
|
17
|
+
name: "enter_design_mode",
|
|
18
|
+
description: "Enter design mode to create and modify diagrams. In design mode, you can create diagrams, add nodes, connect them with arrows, and configure workflow logic. Call exit_design_mode when finished designing.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
diagramId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Optional diagram ID to start editing. If not provided, use list_diagrams or create_diagram to get started.",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: [],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Tool: exit_design_mode
|
|
32
|
+
* Exit design mode and return to work mode
|
|
33
|
+
*/
|
|
34
|
+
export const exitDesignModeTool = {
|
|
35
|
+
name: "exit_design_mode",
|
|
36
|
+
description: "Exit design mode and return to work mode. Any unsaved changes should be committed before exiting.",
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {},
|
|
40
|
+
required: [],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Tool: list_diagrams
|
|
45
|
+
* List all available diagrams
|
|
46
|
+
*/
|
|
47
|
+
export const listDiagramsTool = {
|
|
48
|
+
name: "list_diagrams",
|
|
49
|
+
description: "List all available diagrams with optional filtering. Returns diagram metadata including ID, title, token, type, and node/arrow counts.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
search: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Search term to filter diagrams by title or token",
|
|
56
|
+
},
|
|
57
|
+
diagramType: {
|
|
58
|
+
type: "string",
|
|
59
|
+
enum: ["all", "process", "activity", "dependency"],
|
|
60
|
+
description: "Filter by diagram type. Defaults to 'all'.",
|
|
61
|
+
},
|
|
62
|
+
sortBy: {
|
|
63
|
+
type: "string",
|
|
64
|
+
enum: ["updatedAt", "createdAt", "title"],
|
|
65
|
+
description: "Sort field. Defaults to 'updatedAt'.",
|
|
66
|
+
},
|
|
67
|
+
sortOrder: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["asc", "desc"],
|
|
70
|
+
description: "Sort order. Defaults to 'desc'.",
|
|
71
|
+
},
|
|
72
|
+
topLevelOnly: {
|
|
73
|
+
type: "boolean",
|
|
74
|
+
description: "If true, only return top-level diagrams (not sub-diagrams). Defaults to false.",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: [],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Tool: get_diagram
|
|
82
|
+
* Get a diagram's full details for editing
|
|
83
|
+
*/
|
|
84
|
+
export const getDiagramTool = {
|
|
85
|
+
name: "get_diagram",
|
|
86
|
+
description: "Get a diagram's full details including all nodes and arrows. Use this to load a diagram for editing in design mode.",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
diagramId: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "ID of the diagram to retrieve",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
required: ["diagramId"],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Tool: create_diagram
|
|
100
|
+
* Create a new diagram
|
|
101
|
+
*/
|
|
102
|
+
export const createDiagramTool = {
|
|
103
|
+
name: "create_diagram",
|
|
104
|
+
description: "Create a new diagram. Returns the created diagram with its ID. You can then add nodes and arrows to it.",
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
title: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Title of the diagram (e.g., 'Customer Onboarding Process')",
|
|
111
|
+
},
|
|
112
|
+
token: {
|
|
113
|
+
type: "string",
|
|
114
|
+
description: "Unique token/slug for the diagram (e.g., 'customer-onboarding'). Must be unique across all diagrams.",
|
|
115
|
+
},
|
|
116
|
+
diagramType: {
|
|
117
|
+
type: "string",
|
|
118
|
+
enum: ["process", "activity", "dependency"],
|
|
119
|
+
description: "Type of diagram. Defaults to 'process'.",
|
|
120
|
+
},
|
|
121
|
+
mode: {
|
|
122
|
+
type: "string",
|
|
123
|
+
enum: ["reactive", "proactive"],
|
|
124
|
+
description: "Workflow mode. 'reactive' waits for user actions, 'proactive' advances automatically. Defaults to 'reactive'.",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
required: ["title", "token"],
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Tool: update_diagram
|
|
132
|
+
* Update diagram properties
|
|
133
|
+
*/
|
|
134
|
+
export const updateDiagramTool = {
|
|
135
|
+
name: "update_diagram",
|
|
136
|
+
description: "Update a diagram's properties such as title, token, type, or mode. Does not modify nodes or arrows - use create_node, update_node, create_arrow, delete_arrow for that.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
diagramId: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "ID of the diagram to update",
|
|
143
|
+
},
|
|
144
|
+
title: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "New title for the diagram",
|
|
147
|
+
},
|
|
148
|
+
token: {
|
|
149
|
+
type: "string",
|
|
150
|
+
description: "New token for the diagram (must be unique)",
|
|
151
|
+
},
|
|
152
|
+
diagramType: {
|
|
153
|
+
type: "string",
|
|
154
|
+
enum: ["process", "activity", "dependency"],
|
|
155
|
+
description: "New diagram type",
|
|
156
|
+
},
|
|
157
|
+
mode: {
|
|
158
|
+
type: "string",
|
|
159
|
+
enum: ["reactive", "proactive"],
|
|
160
|
+
description: "New workflow mode",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
required: ["diagramId"],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Tool: create_node
|
|
168
|
+
* Add a node to a diagram
|
|
169
|
+
*/
|
|
170
|
+
export const createNodeTool = {
|
|
171
|
+
name: "create_node",
|
|
172
|
+
description: "Add a new node to a diagram. Nodes represent steps in the workflow. Position nodes carefully - use coordinates based on existing nodes for proper layout.",
|
|
173
|
+
inputSchema: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
diagramId: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description: "ID of the diagram to add the node to",
|
|
179
|
+
},
|
|
180
|
+
label: {
|
|
181
|
+
type: "string",
|
|
182
|
+
description: "Label/title for the node (e.g., 'Review Application', 'Send Email')",
|
|
183
|
+
},
|
|
184
|
+
x: {
|
|
185
|
+
type: "number",
|
|
186
|
+
description: "X coordinate for the node position (horizontal). Typical spacing is 200-300 units between nodes.",
|
|
187
|
+
},
|
|
188
|
+
y: {
|
|
189
|
+
type: "number",
|
|
190
|
+
description: "Y coordinate for the node position (vertical). Typical spacing is 150-200 units between rows.",
|
|
191
|
+
},
|
|
192
|
+
shape: {
|
|
193
|
+
type: "string",
|
|
194
|
+
enum: ["roundedRect", "diamond", "ellipse", "rect"],
|
|
195
|
+
description: "Node shape. Use 'roundedRect' for tasks, 'diamond' for decisions, 'ellipse' for start/end. Defaults to 'roundedRect'.",
|
|
196
|
+
},
|
|
197
|
+
isStart: {
|
|
198
|
+
type: "boolean",
|
|
199
|
+
description: "Mark as the start node. Only one node per diagram should be the start.",
|
|
200
|
+
},
|
|
201
|
+
isEnd: {
|
|
202
|
+
type: "boolean",
|
|
203
|
+
description: "Mark as an end node. A diagram can have multiple end nodes.",
|
|
204
|
+
},
|
|
205
|
+
description: {
|
|
206
|
+
type: "string",
|
|
207
|
+
description: "Detailed description or instructions for this step",
|
|
208
|
+
},
|
|
209
|
+
waitForAll: {
|
|
210
|
+
type: "boolean",
|
|
211
|
+
description: "If true, all parallel branches must arrive at this node before any can proceed (merge point).",
|
|
212
|
+
},
|
|
213
|
+
childDiagramId: {
|
|
214
|
+
type: "string",
|
|
215
|
+
description: "Link to a sub-diagram. When workflow reaches this node, it will enter the child diagram.",
|
|
216
|
+
},
|
|
217
|
+
assignedUserId: {
|
|
218
|
+
type: "string",
|
|
219
|
+
description: "User ID to auto-assign instances when they reach this node.",
|
|
220
|
+
},
|
|
221
|
+
width: {
|
|
222
|
+
type: "number",
|
|
223
|
+
description: "Node width. Defaults to 150.",
|
|
224
|
+
},
|
|
225
|
+
height: {
|
|
226
|
+
type: "number",
|
|
227
|
+
description: "Node height. Defaults to 60.",
|
|
228
|
+
},
|
|
229
|
+
fillColor: {
|
|
230
|
+
type: "string",
|
|
231
|
+
description: "Background color (hex). Defaults to '#ffffff'.",
|
|
232
|
+
},
|
|
233
|
+
borderColor: {
|
|
234
|
+
type: "string",
|
|
235
|
+
description: "Border color (hex). Defaults to '#000000'.",
|
|
236
|
+
},
|
|
237
|
+
textColor: {
|
|
238
|
+
type: "string",
|
|
239
|
+
description: "Text color (hex). Defaults to '#000000'.",
|
|
240
|
+
},
|
|
241
|
+
durationValue: {
|
|
242
|
+
type: "number",
|
|
243
|
+
description: "Expected duration value for this step (for planning).",
|
|
244
|
+
},
|
|
245
|
+
durationUnit: {
|
|
246
|
+
type: "string",
|
|
247
|
+
enum: ["minutes", "hours", "days", "weeks", "months"],
|
|
248
|
+
description: "Duration unit.",
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
required: ["diagramId", "label", "x", "y"],
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Tool: update_node
|
|
256
|
+
* Update an existing node's properties
|
|
257
|
+
*/
|
|
258
|
+
export const updateNodeTool = {
|
|
259
|
+
name: "update_node",
|
|
260
|
+
description: "Update an existing node's properties. You can change any node property including position, label, shape, and workflow behavior settings.",
|
|
261
|
+
inputSchema: {
|
|
262
|
+
type: "object",
|
|
263
|
+
properties: {
|
|
264
|
+
diagramId: {
|
|
265
|
+
type: "string",
|
|
266
|
+
description: "ID of the diagram containing the node",
|
|
267
|
+
},
|
|
268
|
+
nodeId: {
|
|
269
|
+
type: "string",
|
|
270
|
+
description: "ID of the node to update",
|
|
271
|
+
},
|
|
272
|
+
label: {
|
|
273
|
+
type: "string",
|
|
274
|
+
description: "New label for the node",
|
|
275
|
+
},
|
|
276
|
+
x: {
|
|
277
|
+
type: "number",
|
|
278
|
+
description: "New X coordinate",
|
|
279
|
+
},
|
|
280
|
+
y: {
|
|
281
|
+
type: "number",
|
|
282
|
+
description: "New Y coordinate",
|
|
283
|
+
},
|
|
284
|
+
shape: {
|
|
285
|
+
type: "string",
|
|
286
|
+
enum: ["roundedRect", "diamond", "ellipse", "rect"],
|
|
287
|
+
description: "New shape",
|
|
288
|
+
},
|
|
289
|
+
isStart: {
|
|
290
|
+
type: "boolean",
|
|
291
|
+
description: "Set or unset as start node",
|
|
292
|
+
},
|
|
293
|
+
isEnd: {
|
|
294
|
+
type: "boolean",
|
|
295
|
+
description: "Set or unset as end node",
|
|
296
|
+
},
|
|
297
|
+
description: {
|
|
298
|
+
type: "string",
|
|
299
|
+
description: "New description",
|
|
300
|
+
},
|
|
301
|
+
waitForAll: {
|
|
302
|
+
type: "boolean",
|
|
303
|
+
description: "Enable/disable wait-for-all merge behavior",
|
|
304
|
+
},
|
|
305
|
+
childDiagramId: {
|
|
306
|
+
type: "string",
|
|
307
|
+
description: "Link to a child diagram (or null to unlink)",
|
|
308
|
+
},
|
|
309
|
+
assignedUserId: {
|
|
310
|
+
type: "string",
|
|
311
|
+
description: "User to auto-assign (or null to remove assignment)",
|
|
312
|
+
},
|
|
313
|
+
width: {
|
|
314
|
+
type: "number",
|
|
315
|
+
description: "New width",
|
|
316
|
+
},
|
|
317
|
+
height: {
|
|
318
|
+
type: "number",
|
|
319
|
+
description: "New height",
|
|
320
|
+
},
|
|
321
|
+
fillColor: {
|
|
322
|
+
type: "string",
|
|
323
|
+
description: "New background color",
|
|
324
|
+
},
|
|
325
|
+
borderColor: {
|
|
326
|
+
type: "string",
|
|
327
|
+
description: "New border color",
|
|
328
|
+
},
|
|
329
|
+
textColor: {
|
|
330
|
+
type: "string",
|
|
331
|
+
description: "New text color",
|
|
332
|
+
},
|
|
333
|
+
durationValue: {
|
|
334
|
+
type: "number",
|
|
335
|
+
description: "New duration value",
|
|
336
|
+
},
|
|
337
|
+
durationUnit: {
|
|
338
|
+
type: "string",
|
|
339
|
+
enum: ["minutes", "hours", "days", "weeks", "months"],
|
|
340
|
+
description: "New duration unit",
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
required: ["diagramId", "nodeId"],
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Tool: delete_node
|
|
348
|
+
* Remove a node from a diagram
|
|
349
|
+
*/
|
|
350
|
+
export const deleteNodeTool = {
|
|
351
|
+
name: "delete_node",
|
|
352
|
+
description: "Remove a node from a diagram. This will also remove any arrows connected to this node. Use with caution.",
|
|
353
|
+
inputSchema: {
|
|
354
|
+
type: "object",
|
|
355
|
+
properties: {
|
|
356
|
+
diagramId: {
|
|
357
|
+
type: "string",
|
|
358
|
+
description: "ID of the diagram containing the node",
|
|
359
|
+
},
|
|
360
|
+
nodeId: {
|
|
361
|
+
type: "string",
|
|
362
|
+
description: "ID of the node to delete",
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
required: ["diagramId", "nodeId"],
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Tool: create_arrow
|
|
370
|
+
* Connect two nodes with an arrow
|
|
371
|
+
*/
|
|
372
|
+
export const createArrowTool = {
|
|
373
|
+
name: "create_arrow",
|
|
374
|
+
description: "Connect two nodes with an arrow. Arrows define the workflow transitions between nodes. For decision nodes, create multiple arrows with different labels for each path.",
|
|
375
|
+
inputSchema: {
|
|
376
|
+
type: "object",
|
|
377
|
+
properties: {
|
|
378
|
+
diagramId: {
|
|
379
|
+
type: "string",
|
|
380
|
+
description: "ID of the diagram",
|
|
381
|
+
},
|
|
382
|
+
from: {
|
|
383
|
+
type: "string",
|
|
384
|
+
description: "ID of the source node (where the arrow starts)",
|
|
385
|
+
},
|
|
386
|
+
to: {
|
|
387
|
+
type: "string",
|
|
388
|
+
description: "ID of the target node (where the arrow points)",
|
|
389
|
+
},
|
|
390
|
+
label: {
|
|
391
|
+
type: "string",
|
|
392
|
+
description: "Label for the arrow (e.g., 'Yes', 'No', 'Approve', 'Reject'). Important for decision nodes.",
|
|
393
|
+
},
|
|
394
|
+
fromPoint: {
|
|
395
|
+
type: "string",
|
|
396
|
+
enum: ["top", "right", "bottom", "left"],
|
|
397
|
+
description: "Connection point on the source node. Defaults to 'right'.",
|
|
398
|
+
},
|
|
399
|
+
toPoint: {
|
|
400
|
+
type: "string",
|
|
401
|
+
enum: ["top", "right", "bottom", "left"],
|
|
402
|
+
description: "Connection point on the target node. Defaults to 'left'.",
|
|
403
|
+
},
|
|
404
|
+
delay: {
|
|
405
|
+
type: "string",
|
|
406
|
+
description: "Time delay before transition (e.g., '+3d' for 3 days, '+24h' for 24 hours, '+30m' for 30 minutes).",
|
|
407
|
+
},
|
|
408
|
+
color: {
|
|
409
|
+
type: "string",
|
|
410
|
+
description: "Arrow color (hex). Defaults to '#000000'.",
|
|
411
|
+
},
|
|
412
|
+
thickness: {
|
|
413
|
+
type: "number",
|
|
414
|
+
description: "Line thickness. Defaults to 2.",
|
|
415
|
+
},
|
|
416
|
+
lineStyle: {
|
|
417
|
+
type: "string",
|
|
418
|
+
enum: ["solid", "dashed", "dotted"],
|
|
419
|
+
description: "Line style. Defaults to 'solid'.",
|
|
420
|
+
},
|
|
421
|
+
routing: {
|
|
422
|
+
type: "string",
|
|
423
|
+
enum: ["straight", "orthogonal", "curved"],
|
|
424
|
+
description: "Arrow routing style. Defaults to 'straight'.",
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
required: ["diagramId", "from", "to"],
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Tool: update_arrow
|
|
432
|
+
* Update an existing arrow's properties
|
|
433
|
+
*/
|
|
434
|
+
export const updateArrowTool = {
|
|
435
|
+
name: "update_arrow",
|
|
436
|
+
description: "Update an existing arrow's properties such as label, connection points, delay, or styling.",
|
|
437
|
+
inputSchema: {
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: {
|
|
440
|
+
diagramId: {
|
|
441
|
+
type: "string",
|
|
442
|
+
description: "ID of the diagram containing the arrow",
|
|
443
|
+
},
|
|
444
|
+
arrowId: {
|
|
445
|
+
type: "string",
|
|
446
|
+
description: "ID of the arrow to update",
|
|
447
|
+
},
|
|
448
|
+
label: {
|
|
449
|
+
type: "string",
|
|
450
|
+
description: "New label for the arrow",
|
|
451
|
+
},
|
|
452
|
+
fromPoint: {
|
|
453
|
+
type: "string",
|
|
454
|
+
enum: ["top", "right", "bottom", "left"],
|
|
455
|
+
description: "New connection point on the source node",
|
|
456
|
+
},
|
|
457
|
+
toPoint: {
|
|
458
|
+
type: "string",
|
|
459
|
+
enum: ["top", "right", "bottom", "left"],
|
|
460
|
+
description: "New connection point on the target node",
|
|
461
|
+
},
|
|
462
|
+
delay: {
|
|
463
|
+
type: "string",
|
|
464
|
+
description: "New time delay (e.g., '+3d', '+24h', '+30m', or null to remove)",
|
|
465
|
+
},
|
|
466
|
+
color: {
|
|
467
|
+
type: "string",
|
|
468
|
+
description: "New arrow color (hex)",
|
|
469
|
+
},
|
|
470
|
+
thickness: {
|
|
471
|
+
type: "number",
|
|
472
|
+
description: "New line thickness",
|
|
473
|
+
},
|
|
474
|
+
lineStyle: {
|
|
475
|
+
type: "string",
|
|
476
|
+
enum: ["solid", "dashed", "dotted"],
|
|
477
|
+
description: "New line style",
|
|
478
|
+
},
|
|
479
|
+
routing: {
|
|
480
|
+
type: "string",
|
|
481
|
+
enum: ["straight", "orthogonal", "curved"],
|
|
482
|
+
description: "New routing style",
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
required: ["diagramId", "arrowId"],
|
|
486
|
+
},
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* Tool: delete_arrow
|
|
490
|
+
* Remove an arrow from a diagram
|
|
491
|
+
*/
|
|
492
|
+
export const deleteArrowTool = {
|
|
493
|
+
name: "delete_arrow",
|
|
494
|
+
description: "Remove an arrow from a diagram. This disconnects two nodes without affecting the nodes themselves.",
|
|
495
|
+
inputSchema: {
|
|
496
|
+
type: "object",
|
|
497
|
+
properties: {
|
|
498
|
+
diagramId: {
|
|
499
|
+
type: "string",
|
|
500
|
+
description: "ID of the diagram containing the arrow",
|
|
501
|
+
},
|
|
502
|
+
arrowId: {
|
|
503
|
+
type: "string",
|
|
504
|
+
description: "ID of the arrow to delete",
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
required: ["diagramId", "arrowId"],
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Tool: delete_diagram
|
|
512
|
+
* Delete a diagram
|
|
513
|
+
*/
|
|
514
|
+
export const deleteDiagramTool = {
|
|
515
|
+
name: "delete_diagram",
|
|
516
|
+
description: "Delete a diagram (soft delete). If the diagram has active workflow instances, you must confirm the deletion.",
|
|
517
|
+
inputSchema: {
|
|
518
|
+
type: "object",
|
|
519
|
+
properties: {
|
|
520
|
+
diagramId: {
|
|
521
|
+
type: "string",
|
|
522
|
+
description: "ID of the diagram to delete",
|
|
523
|
+
},
|
|
524
|
+
confirm: {
|
|
525
|
+
type: "boolean",
|
|
526
|
+
description: "Set to true to confirm deletion when there are active instances",
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
required: ["diagramId"],
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Tool: duplicate_diagram
|
|
534
|
+
* Create a copy of an existing diagram
|
|
535
|
+
*/
|
|
536
|
+
export const duplicateDiagramTool = {
|
|
537
|
+
name: "duplicate_diagram",
|
|
538
|
+
description: "Create a copy of an existing diagram with all its nodes and arrows. The copy will have a new ID and a modified title/token.",
|
|
539
|
+
inputSchema: {
|
|
540
|
+
type: "object",
|
|
541
|
+
properties: {
|
|
542
|
+
diagramId: {
|
|
543
|
+
type: "string",
|
|
544
|
+
description: "ID of the diagram to duplicate",
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
required: ["diagramId"],
|
|
548
|
+
},
|
|
549
|
+
};
|
|
550
|
+
// =============================================================================
|
|
551
|
+
// Tool Handlers
|
|
552
|
+
// =============================================================================
|
|
553
|
+
/**
|
|
554
|
+
* Handler for enter_design_mode tool
|
|
555
|
+
*/
|
|
556
|
+
export async function handleEnterDesignMode(client, params) {
|
|
557
|
+
designModeState.isDesignMode = true;
|
|
558
|
+
designModeState.activeDiagramId = params.diagramId?.trim() || null;
|
|
559
|
+
const response = {
|
|
560
|
+
success: true,
|
|
561
|
+
message: "Entered design mode",
|
|
562
|
+
designMode: true,
|
|
563
|
+
activeDiagramId: designModeState.activeDiagramId,
|
|
564
|
+
};
|
|
565
|
+
if (designModeState.activeDiagramId) {
|
|
566
|
+
try {
|
|
567
|
+
const diagram = await client.getDiagram(designModeState.activeDiagramId);
|
|
568
|
+
response.diagram = {
|
|
569
|
+
id: diagram.id,
|
|
570
|
+
name: diagram.name,
|
|
571
|
+
nodeCount: diagram.nodes?.length || 0,
|
|
572
|
+
edgeCount: diagram.edges?.length || 0,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
catch {
|
|
576
|
+
response.warning = "Could not load diagram. Use get_diagram to load it.";
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
response.hint = "Use list_diagrams to see available diagrams or create_diagram to create a new one.";
|
|
581
|
+
}
|
|
582
|
+
return JSON.stringify(response, null, 2);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Handler for exit_design_mode tool
|
|
586
|
+
*/
|
|
587
|
+
export async function handleExitDesignMode() {
|
|
588
|
+
const wasInDesignMode = designModeState.isDesignMode;
|
|
589
|
+
const previousDiagramId = designModeState.activeDiagramId;
|
|
590
|
+
designModeState.isDesignMode = false;
|
|
591
|
+
designModeState.activeDiagramId = null;
|
|
592
|
+
return JSON.stringify({
|
|
593
|
+
success: true,
|
|
594
|
+
message: wasInDesignMode ? "Exited design mode" : "Was not in design mode",
|
|
595
|
+
designMode: false,
|
|
596
|
+
previousActiveDiagramId: previousDiagramId,
|
|
597
|
+
}, null, 2);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Handler for list_diagrams tool
|
|
601
|
+
*/
|
|
602
|
+
export async function handleListDiagrams(client, params) {
|
|
603
|
+
const diagrams = await client.listDiagrams({
|
|
604
|
+
search: params.search,
|
|
605
|
+
diagramType: params.diagramType,
|
|
606
|
+
sortBy: params.sortBy,
|
|
607
|
+
sortOrder: params.sortOrder,
|
|
608
|
+
topLevelOnly: params.topLevelOnly,
|
|
609
|
+
});
|
|
610
|
+
if (diagrams.length === 0) {
|
|
611
|
+
return JSON.stringify({
|
|
612
|
+
success: true,
|
|
613
|
+
message: "No diagrams found",
|
|
614
|
+
diagrams: [],
|
|
615
|
+
filter: {
|
|
616
|
+
search: params.search || null,
|
|
617
|
+
diagramType: params.diagramType || "all",
|
|
618
|
+
topLevelOnly: params.topLevelOnly || false,
|
|
619
|
+
},
|
|
620
|
+
}, null, 2);
|
|
621
|
+
}
|
|
622
|
+
const formattedDiagrams = diagrams.map((d) => ({
|
|
623
|
+
id: d.id,
|
|
624
|
+
title: d.title,
|
|
625
|
+
token: d.token,
|
|
626
|
+
diagramType: d.diagramType,
|
|
627
|
+
mode: d.mode,
|
|
628
|
+
nodeCount: d.nodeCount,
|
|
629
|
+
arrowCount: d.arrowCount,
|
|
630
|
+
updatedAt: d.updatedAt,
|
|
631
|
+
}));
|
|
632
|
+
return JSON.stringify({
|
|
633
|
+
success: true,
|
|
634
|
+
message: `Found ${diagrams.length} diagram(s)`,
|
|
635
|
+
diagrams: formattedDiagrams,
|
|
636
|
+
filter: {
|
|
637
|
+
search: params.search || null,
|
|
638
|
+
diagramType: params.diagramType || "all",
|
|
639
|
+
topLevelOnly: params.topLevelOnly || false,
|
|
640
|
+
},
|
|
641
|
+
}, null, 2);
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Handler for get_diagram tool (design mode version with full details)
|
|
645
|
+
*/
|
|
646
|
+
export async function handleGetDiagramForDesign(client, params) {
|
|
647
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
648
|
+
return JSON.stringify({
|
|
649
|
+
success: false,
|
|
650
|
+
error: "diagramId is required",
|
|
651
|
+
}, null, 2);
|
|
652
|
+
}
|
|
653
|
+
const diagram = await client.getDiagramRaw(params.diagramId.trim());
|
|
654
|
+
// Update active diagram in design mode
|
|
655
|
+
if (designModeState.isDesignMode) {
|
|
656
|
+
designModeState.activeDiagramId = params.diagramId.trim();
|
|
657
|
+
}
|
|
658
|
+
const nodes = diagram.nodes || [];
|
|
659
|
+
const arrows = diagram.arrows || [];
|
|
660
|
+
return JSON.stringify({
|
|
661
|
+
success: true,
|
|
662
|
+
diagram: {
|
|
663
|
+
id: diagram.id,
|
|
664
|
+
title: diagram.title,
|
|
665
|
+
token: diagram.token,
|
|
666
|
+
diagramType: diagram.diagramType,
|
|
667
|
+
mode: diagram.mode,
|
|
668
|
+
version: diagram.version,
|
|
669
|
+
createdAt: diagram.createdAt,
|
|
670
|
+
updatedAt: diagram.updatedAt,
|
|
671
|
+
},
|
|
672
|
+
nodes: nodes.map((n) => ({
|
|
673
|
+
id: n.id,
|
|
674
|
+
label: n.label,
|
|
675
|
+
x: n.x,
|
|
676
|
+
y: n.y,
|
|
677
|
+
width: n.width,
|
|
678
|
+
height: n.height,
|
|
679
|
+
shape: n.shape,
|
|
680
|
+
isStart: n.isStart,
|
|
681
|
+
isEnd: n.isEnd,
|
|
682
|
+
description: n.description,
|
|
683
|
+
waitForAll: n.waitForAll,
|
|
684
|
+
childDiagramId: n.childDiagramId,
|
|
685
|
+
childDiagramTitle: n.childDiagramTitle,
|
|
686
|
+
assignedUserId: n.assignedUserId,
|
|
687
|
+
assignedUserName: n.assignedUserName,
|
|
688
|
+
fillColor: n.fillColor,
|
|
689
|
+
borderColor: n.borderColor,
|
|
690
|
+
textColor: n.textColor,
|
|
691
|
+
durationValue: n.durationValue,
|
|
692
|
+
durationUnit: n.durationUnit,
|
|
693
|
+
})),
|
|
694
|
+
arrows: arrows.map((a) => ({
|
|
695
|
+
id: a.id,
|
|
696
|
+
from: a.from,
|
|
697
|
+
to: a.to,
|
|
698
|
+
label: a.label,
|
|
699
|
+
fromPoint: a.fromPoint,
|
|
700
|
+
toPoint: a.toPoint,
|
|
701
|
+
delay: a.delay,
|
|
702
|
+
color: a.color,
|
|
703
|
+
thickness: a.thickness,
|
|
704
|
+
lineStyle: a.lineStyle,
|
|
705
|
+
routing: a.routing,
|
|
706
|
+
})),
|
|
707
|
+
summary: {
|
|
708
|
+
nodeCount: nodes.length,
|
|
709
|
+
arrowCount: arrows.length,
|
|
710
|
+
hasStartNode: nodes.some((n) => n.isStart),
|
|
711
|
+
hasEndNode: nodes.some((n) => n.isEnd),
|
|
712
|
+
startNodeId: nodes.find((n) => n.isStart)?.id || null,
|
|
713
|
+
endNodeIds: nodes.filter((n) => n.isEnd).map((n) => n.id),
|
|
714
|
+
},
|
|
715
|
+
}, null, 2);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Handler for create_diagram tool
|
|
719
|
+
*/
|
|
720
|
+
export async function handleCreateDiagram(client, params) {
|
|
721
|
+
if (!params.title || params.title.trim().length === 0) {
|
|
722
|
+
return JSON.stringify({
|
|
723
|
+
success: false,
|
|
724
|
+
error: "title is required",
|
|
725
|
+
}, null, 2);
|
|
726
|
+
}
|
|
727
|
+
if (!params.token || params.token.trim().length === 0) {
|
|
728
|
+
return JSON.stringify({
|
|
729
|
+
success: false,
|
|
730
|
+
error: "token is required",
|
|
731
|
+
}, null, 2);
|
|
732
|
+
}
|
|
733
|
+
const diagram = await client.createDiagram({
|
|
734
|
+
title: params.title.trim(),
|
|
735
|
+
token: params.token.trim(),
|
|
736
|
+
diagramType: params.diagramType || "process",
|
|
737
|
+
mode: params.mode || "reactive",
|
|
738
|
+
});
|
|
739
|
+
// Set as active diagram if in design mode
|
|
740
|
+
if (designModeState.isDesignMode) {
|
|
741
|
+
designModeState.activeDiagramId = diagram.id;
|
|
742
|
+
}
|
|
743
|
+
return JSON.stringify({
|
|
744
|
+
success: true,
|
|
745
|
+
message: `Diagram '${diagram.title}' created successfully`,
|
|
746
|
+
diagram: {
|
|
747
|
+
id: diagram.id,
|
|
748
|
+
title: diagram.title,
|
|
749
|
+
token: diagram.token,
|
|
750
|
+
diagramType: diagram.diagramType,
|
|
751
|
+
mode: diagram.mode,
|
|
752
|
+
},
|
|
753
|
+
hint: "Use create_node to add nodes to this diagram. Start with a node marked as isStart: true.",
|
|
754
|
+
}, null, 2);
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Handler for update_diagram tool
|
|
758
|
+
*/
|
|
759
|
+
export async function handleUpdateDiagram(client, params) {
|
|
760
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
761
|
+
return JSON.stringify({
|
|
762
|
+
success: false,
|
|
763
|
+
error: "diagramId is required",
|
|
764
|
+
}, null, 2);
|
|
765
|
+
}
|
|
766
|
+
const updateData = {};
|
|
767
|
+
if (params.title !== undefined)
|
|
768
|
+
updateData.title = params.title;
|
|
769
|
+
if (params.token !== undefined)
|
|
770
|
+
updateData.token = params.token;
|
|
771
|
+
if (params.diagramType !== undefined)
|
|
772
|
+
updateData.diagramType = params.diagramType;
|
|
773
|
+
if (params.mode !== undefined)
|
|
774
|
+
updateData.mode = params.mode;
|
|
775
|
+
if (Object.keys(updateData).length === 0) {
|
|
776
|
+
return JSON.stringify({
|
|
777
|
+
success: false,
|
|
778
|
+
error: "At least one property to update is required (title, token, diagramType, or mode)",
|
|
779
|
+
}, null, 2);
|
|
780
|
+
}
|
|
781
|
+
const diagram = await client.updateDiagram(params.diagramId.trim(), updateData);
|
|
782
|
+
return JSON.stringify({
|
|
783
|
+
success: true,
|
|
784
|
+
message: "Diagram updated successfully",
|
|
785
|
+
diagram: {
|
|
786
|
+
id: diagram.id,
|
|
787
|
+
title: diagram.title,
|
|
788
|
+
token: diagram.token,
|
|
789
|
+
diagramType: diagram.diagramType,
|
|
790
|
+
mode: diagram.mode,
|
|
791
|
+
},
|
|
792
|
+
}, null, 2);
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Handler for create_node tool
|
|
796
|
+
*/
|
|
797
|
+
export async function handleCreateNode(client, params) {
|
|
798
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
799
|
+
return JSON.stringify({
|
|
800
|
+
success: false,
|
|
801
|
+
error: "diagramId is required",
|
|
802
|
+
}, null, 2);
|
|
803
|
+
}
|
|
804
|
+
if (!params.label || params.label.trim().length === 0) {
|
|
805
|
+
return JSON.stringify({
|
|
806
|
+
success: false,
|
|
807
|
+
error: "label is required",
|
|
808
|
+
}, null, 2);
|
|
809
|
+
}
|
|
810
|
+
if (params.x === undefined || params.y === undefined) {
|
|
811
|
+
return JSON.stringify({
|
|
812
|
+
success: false,
|
|
813
|
+
error: "x and y coordinates are required",
|
|
814
|
+
}, null, 2);
|
|
815
|
+
}
|
|
816
|
+
// Generate a unique node ID
|
|
817
|
+
const nodeId = `node-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
818
|
+
const nodeData = {
|
|
819
|
+
id: nodeId,
|
|
820
|
+
label: params.label.trim(),
|
|
821
|
+
x: params.x,
|
|
822
|
+
y: params.y,
|
|
823
|
+
width: params.width || 150,
|
|
824
|
+
height: params.height || 60,
|
|
825
|
+
shape: params.shape || "roundedRect",
|
|
826
|
+
fillColor: params.fillColor || "#ffffff",
|
|
827
|
+
borderColor: params.borderColor || "#000000",
|
|
828
|
+
textColor: params.textColor || "#000000",
|
|
829
|
+
lineStyle: "solid",
|
|
830
|
+
status: "none",
|
|
831
|
+
};
|
|
832
|
+
if (params.isStart !== undefined)
|
|
833
|
+
nodeData.isStart = params.isStart;
|
|
834
|
+
if (params.isEnd !== undefined)
|
|
835
|
+
nodeData.isEnd = params.isEnd;
|
|
836
|
+
if (params.description !== undefined)
|
|
837
|
+
nodeData.description = params.description;
|
|
838
|
+
if (params.waitForAll !== undefined)
|
|
839
|
+
nodeData.waitForAll = params.waitForAll;
|
|
840
|
+
if (params.childDiagramId !== undefined)
|
|
841
|
+
nodeData.childDiagramId = params.childDiagramId;
|
|
842
|
+
if (params.assignedUserId !== undefined)
|
|
843
|
+
nodeData.assignedUserId = params.assignedUserId;
|
|
844
|
+
if (params.durationValue !== undefined)
|
|
845
|
+
nodeData.durationValue = params.durationValue;
|
|
846
|
+
if (params.durationUnit !== undefined)
|
|
847
|
+
nodeData.durationUnit = params.durationUnit;
|
|
848
|
+
const result = await client.addNode(params.diagramId.trim(), nodeData);
|
|
849
|
+
return JSON.stringify({
|
|
850
|
+
success: true,
|
|
851
|
+
message: `Node '${params.label}' created successfully`,
|
|
852
|
+
node: {
|
|
853
|
+
id: result.id || nodeId,
|
|
854
|
+
label: params.label,
|
|
855
|
+
x: params.x,
|
|
856
|
+
y: params.y,
|
|
857
|
+
shape: nodeData.shape,
|
|
858
|
+
isStart: nodeData.isStart,
|
|
859
|
+
isEnd: nodeData.isEnd,
|
|
860
|
+
},
|
|
861
|
+
hint: params.isStart
|
|
862
|
+
? "Start node created. Add more nodes and connect them with create_arrow."
|
|
863
|
+
: "Node created. Use create_arrow to connect this node to others.",
|
|
864
|
+
}, null, 2);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Handler for update_node tool
|
|
868
|
+
*/
|
|
869
|
+
export async function handleUpdateNode(client, params) {
|
|
870
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
871
|
+
return JSON.stringify({
|
|
872
|
+
success: false,
|
|
873
|
+
error: "diagramId is required",
|
|
874
|
+
}, null, 2);
|
|
875
|
+
}
|
|
876
|
+
if (!params.nodeId || params.nodeId.trim().length === 0) {
|
|
877
|
+
return JSON.stringify({
|
|
878
|
+
success: false,
|
|
879
|
+
error: "nodeId is required",
|
|
880
|
+
}, null, 2);
|
|
881
|
+
}
|
|
882
|
+
const updateData = {};
|
|
883
|
+
if (params.label !== undefined)
|
|
884
|
+
updateData.label = params.label;
|
|
885
|
+
if (params.x !== undefined)
|
|
886
|
+
updateData.x = params.x;
|
|
887
|
+
if (params.y !== undefined)
|
|
888
|
+
updateData.y = params.y;
|
|
889
|
+
if (params.width !== undefined)
|
|
890
|
+
updateData.width = params.width;
|
|
891
|
+
if (params.height !== undefined)
|
|
892
|
+
updateData.height = params.height;
|
|
893
|
+
if (params.shape !== undefined)
|
|
894
|
+
updateData.shape = params.shape;
|
|
895
|
+
if (params.isStart !== undefined)
|
|
896
|
+
updateData.isStart = params.isStart;
|
|
897
|
+
if (params.isEnd !== undefined)
|
|
898
|
+
updateData.isEnd = params.isEnd;
|
|
899
|
+
if (params.description !== undefined)
|
|
900
|
+
updateData.description = params.description;
|
|
901
|
+
if (params.waitForAll !== undefined)
|
|
902
|
+
updateData.waitForAll = params.waitForAll;
|
|
903
|
+
if (params.childDiagramId !== undefined)
|
|
904
|
+
updateData.childDiagramId = params.childDiagramId;
|
|
905
|
+
if (params.assignedUserId !== undefined)
|
|
906
|
+
updateData.assignedUserId = params.assignedUserId;
|
|
907
|
+
if (params.fillColor !== undefined)
|
|
908
|
+
updateData.fillColor = params.fillColor;
|
|
909
|
+
if (params.borderColor !== undefined)
|
|
910
|
+
updateData.borderColor = params.borderColor;
|
|
911
|
+
if (params.textColor !== undefined)
|
|
912
|
+
updateData.textColor = params.textColor;
|
|
913
|
+
if (params.durationValue !== undefined)
|
|
914
|
+
updateData.durationValue = params.durationValue;
|
|
915
|
+
if (params.durationUnit !== undefined)
|
|
916
|
+
updateData.durationUnit = params.durationUnit;
|
|
917
|
+
if (Object.keys(updateData).length === 0) {
|
|
918
|
+
return JSON.stringify({
|
|
919
|
+
success: false,
|
|
920
|
+
error: "At least one property to update is required",
|
|
921
|
+
}, null, 2);
|
|
922
|
+
}
|
|
923
|
+
await client.updateNode(params.diagramId.trim(), params.nodeId.trim(), updateData);
|
|
924
|
+
return JSON.stringify({
|
|
925
|
+
success: true,
|
|
926
|
+
message: `Node '${params.nodeId}' updated successfully`,
|
|
927
|
+
nodeId: params.nodeId,
|
|
928
|
+
updatedProperties: Object.keys(updateData),
|
|
929
|
+
}, null, 2);
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Handler for delete_node tool
|
|
933
|
+
*/
|
|
934
|
+
export async function handleDeleteNode(client, params) {
|
|
935
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
936
|
+
return JSON.stringify({
|
|
937
|
+
success: false,
|
|
938
|
+
error: "diagramId is required",
|
|
939
|
+
}, null, 2);
|
|
940
|
+
}
|
|
941
|
+
if (!params.nodeId || params.nodeId.trim().length === 0) {
|
|
942
|
+
return JSON.stringify({
|
|
943
|
+
success: false,
|
|
944
|
+
error: "nodeId is required",
|
|
945
|
+
}, null, 2);
|
|
946
|
+
}
|
|
947
|
+
const result = await client.deleteNode(params.diagramId.trim(), params.nodeId.trim());
|
|
948
|
+
return JSON.stringify({
|
|
949
|
+
success: true,
|
|
950
|
+
message: `Node '${params.nodeId}' deleted successfully`,
|
|
951
|
+
nodeId: params.nodeId,
|
|
952
|
+
removedArrowCount: result.removedArrowCount || 0,
|
|
953
|
+
}, null, 2);
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Handler for create_arrow tool
|
|
957
|
+
*/
|
|
958
|
+
export async function handleCreateArrow(client, params) {
|
|
959
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
960
|
+
return JSON.stringify({
|
|
961
|
+
success: false,
|
|
962
|
+
error: "diagramId is required",
|
|
963
|
+
}, null, 2);
|
|
964
|
+
}
|
|
965
|
+
if (!params.from || params.from.trim().length === 0) {
|
|
966
|
+
return JSON.stringify({
|
|
967
|
+
success: false,
|
|
968
|
+
error: "from (source node ID) is required",
|
|
969
|
+
}, null, 2);
|
|
970
|
+
}
|
|
971
|
+
if (!params.to || params.to.trim().length === 0) {
|
|
972
|
+
return JSON.stringify({
|
|
973
|
+
success: false,
|
|
974
|
+
error: "to (target node ID) is required",
|
|
975
|
+
}, null, 2);
|
|
976
|
+
}
|
|
977
|
+
// Generate a unique arrow ID
|
|
978
|
+
const arrowId = `arrow-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
979
|
+
const arrowData = {
|
|
980
|
+
id: arrowId,
|
|
981
|
+
from: params.from.trim(),
|
|
982
|
+
to: params.to.trim(),
|
|
983
|
+
fromPoint: params.fromPoint || "right",
|
|
984
|
+
toPoint: params.toPoint || "left",
|
|
985
|
+
color: params.color || "#000000",
|
|
986
|
+
thickness: params.thickness || 2,
|
|
987
|
+
lineStyle: params.lineStyle || "solid",
|
|
988
|
+
routing: params.routing || "straight",
|
|
989
|
+
arrowHead: "default",
|
|
990
|
+
};
|
|
991
|
+
if (params.label !== undefined)
|
|
992
|
+
arrowData.label = params.label;
|
|
993
|
+
if (params.delay !== undefined)
|
|
994
|
+
arrowData.delay = params.delay;
|
|
995
|
+
const result = await client.addArrow(params.diagramId.trim(), arrowData);
|
|
996
|
+
return JSON.stringify({
|
|
997
|
+
success: true,
|
|
998
|
+
message: `Arrow created from '${params.from}' to '${params.to}'`,
|
|
999
|
+
arrow: {
|
|
1000
|
+
id: result.id || arrowId,
|
|
1001
|
+
from: params.from,
|
|
1002
|
+
to: params.to,
|
|
1003
|
+
label: params.label || null,
|
|
1004
|
+
delay: params.delay || null,
|
|
1005
|
+
},
|
|
1006
|
+
}, null, 2);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Handler for update_arrow tool
|
|
1010
|
+
*/
|
|
1011
|
+
export async function handleUpdateArrow(client, params) {
|
|
1012
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
1013
|
+
return JSON.stringify({
|
|
1014
|
+
success: false,
|
|
1015
|
+
error: "diagramId is required",
|
|
1016
|
+
}, null, 2);
|
|
1017
|
+
}
|
|
1018
|
+
if (!params.arrowId || params.arrowId.trim().length === 0) {
|
|
1019
|
+
return JSON.stringify({
|
|
1020
|
+
success: false,
|
|
1021
|
+
error: "arrowId is required",
|
|
1022
|
+
}, null, 2);
|
|
1023
|
+
}
|
|
1024
|
+
const updateData = {};
|
|
1025
|
+
if (params.label !== undefined)
|
|
1026
|
+
updateData.label = params.label;
|
|
1027
|
+
if (params.fromPoint !== undefined)
|
|
1028
|
+
updateData.fromPoint = params.fromPoint;
|
|
1029
|
+
if (params.toPoint !== undefined)
|
|
1030
|
+
updateData.toPoint = params.toPoint;
|
|
1031
|
+
if (params.delay !== undefined)
|
|
1032
|
+
updateData.delay = params.delay;
|
|
1033
|
+
if (params.color !== undefined)
|
|
1034
|
+
updateData.color = params.color;
|
|
1035
|
+
if (params.thickness !== undefined)
|
|
1036
|
+
updateData.thickness = params.thickness;
|
|
1037
|
+
if (params.lineStyle !== undefined)
|
|
1038
|
+
updateData.lineStyle = params.lineStyle;
|
|
1039
|
+
if (params.routing !== undefined)
|
|
1040
|
+
updateData.routing = params.routing;
|
|
1041
|
+
if (Object.keys(updateData).length === 0) {
|
|
1042
|
+
return JSON.stringify({
|
|
1043
|
+
success: false,
|
|
1044
|
+
error: "At least one property to update is required",
|
|
1045
|
+
}, null, 2);
|
|
1046
|
+
}
|
|
1047
|
+
await client.updateArrow(params.diagramId.trim(), params.arrowId.trim(), updateData);
|
|
1048
|
+
return JSON.stringify({
|
|
1049
|
+
success: true,
|
|
1050
|
+
message: `Arrow '${params.arrowId}' updated successfully`,
|
|
1051
|
+
arrowId: params.arrowId,
|
|
1052
|
+
updatedProperties: Object.keys(updateData),
|
|
1053
|
+
}, null, 2);
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Handler for delete_arrow tool
|
|
1057
|
+
*/
|
|
1058
|
+
export async function handleDeleteArrow(client, params) {
|
|
1059
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
1060
|
+
return JSON.stringify({
|
|
1061
|
+
success: false,
|
|
1062
|
+
error: "diagramId is required",
|
|
1063
|
+
}, null, 2);
|
|
1064
|
+
}
|
|
1065
|
+
if (!params.arrowId || params.arrowId.trim().length === 0) {
|
|
1066
|
+
return JSON.stringify({
|
|
1067
|
+
success: false,
|
|
1068
|
+
error: "arrowId is required",
|
|
1069
|
+
}, null, 2);
|
|
1070
|
+
}
|
|
1071
|
+
await client.deleteArrow(params.diagramId.trim(), params.arrowId.trim());
|
|
1072
|
+
return JSON.stringify({
|
|
1073
|
+
success: true,
|
|
1074
|
+
message: `Arrow '${params.arrowId}' deleted successfully`,
|
|
1075
|
+
arrowId: params.arrowId,
|
|
1076
|
+
}, null, 2);
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Handler for delete_diagram tool
|
|
1080
|
+
*/
|
|
1081
|
+
export async function handleDeleteDiagram(client, params) {
|
|
1082
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
1083
|
+
return JSON.stringify({
|
|
1084
|
+
success: false,
|
|
1085
|
+
error: "diagramId is required",
|
|
1086
|
+
}, null, 2);
|
|
1087
|
+
}
|
|
1088
|
+
const result = await client.deleteDiagram(params.diagramId.trim(), params.confirm || false);
|
|
1089
|
+
if (result.requiresConfirmation) {
|
|
1090
|
+
return JSON.stringify({
|
|
1091
|
+
success: false,
|
|
1092
|
+
requiresConfirmation: true,
|
|
1093
|
+
message: result.message,
|
|
1094
|
+
activeInstanceCount: result.count,
|
|
1095
|
+
hint: "Call delete_diagram again with confirm: true to proceed with deletion.",
|
|
1096
|
+
}, null, 2);
|
|
1097
|
+
}
|
|
1098
|
+
// Clear active diagram if it was deleted
|
|
1099
|
+
if (designModeState.activeDiagramId === params.diagramId.trim()) {
|
|
1100
|
+
designModeState.activeDiagramId = null;
|
|
1101
|
+
}
|
|
1102
|
+
return JSON.stringify({
|
|
1103
|
+
success: true,
|
|
1104
|
+
message: `Diagram '${params.diagramId}' deleted successfully`,
|
|
1105
|
+
diagramId: params.diagramId,
|
|
1106
|
+
}, null, 2);
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Handler for duplicate_diagram tool
|
|
1110
|
+
*/
|
|
1111
|
+
export async function handleDuplicateDiagram(client, params) {
|
|
1112
|
+
if (!params.diagramId || params.diagramId.trim().length === 0) {
|
|
1113
|
+
return JSON.stringify({
|
|
1114
|
+
success: false,
|
|
1115
|
+
error: "diagramId is required",
|
|
1116
|
+
}, null, 2);
|
|
1117
|
+
}
|
|
1118
|
+
const diagram = await client.duplicateDiagram(params.diagramId.trim());
|
|
1119
|
+
return JSON.stringify({
|
|
1120
|
+
success: true,
|
|
1121
|
+
message: `Diagram duplicated successfully`,
|
|
1122
|
+
originalId: params.diagramId,
|
|
1123
|
+
newDiagram: {
|
|
1124
|
+
id: diagram.id,
|
|
1125
|
+
title: diagram.title,
|
|
1126
|
+
token: diagram.token,
|
|
1127
|
+
diagramType: diagram.diagramType,
|
|
1128
|
+
},
|
|
1129
|
+
hint: "Use get_diagram with the new ID to view and edit the duplicated diagram.",
|
|
1130
|
+
}, null, 2);
|
|
1131
|
+
}
|
|
1132
|
+
// =============================================================================
|
|
1133
|
+
// Design Mode State Accessors
|
|
1134
|
+
// =============================================================================
|
|
1135
|
+
/**
|
|
1136
|
+
* Check if currently in design mode
|
|
1137
|
+
*/
|
|
1138
|
+
export function isInDesignMode() {
|
|
1139
|
+
return designModeState.isDesignMode;
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Get the active diagram ID in design mode
|
|
1143
|
+
*/
|
|
1144
|
+
export function getActiveDiagramId() {
|
|
1145
|
+
return designModeState.activeDiagramId;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Get the full design mode state
|
|
1149
|
+
*/
|
|
1150
|
+
export function getDesignModeState() {
|
|
1151
|
+
return { ...designModeState };
|
|
1152
|
+
}
|
|
1153
|
+
// =============================================================================
|
|
1154
|
+
// Exports
|
|
1155
|
+
// =============================================================================
|
|
1156
|
+
export const designTools = [
|
|
1157
|
+
enterDesignModeTool,
|
|
1158
|
+
exitDesignModeTool,
|
|
1159
|
+
listDiagramsTool,
|
|
1160
|
+
getDiagramTool,
|
|
1161
|
+
createDiagramTool,
|
|
1162
|
+
updateDiagramTool,
|
|
1163
|
+
createNodeTool,
|
|
1164
|
+
updateNodeTool,
|
|
1165
|
+
deleteNodeTool,
|
|
1166
|
+
createArrowTool,
|
|
1167
|
+
updateArrowTool,
|
|
1168
|
+
deleteArrowTool,
|
|
1169
|
+
deleteDiagramTool,
|
|
1170
|
+
duplicateDiagramTool,
|
|
1171
|
+
];
|
|
1172
|
+
//# sourceMappingURL=design.js.map
|