callman-mcp 0.4.0 → 0.5.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/CHANGELOG.md +37 -27
- package/README.md +33 -11
- package/dist/client/api.d.ts +83 -15
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +106 -21
- package/dist/client/api.js.map +1 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +46 -11
- package/dist/client/errors.js.map +1 -1
- package/dist/client/types.d.ts +231 -14
- package/dist/client/types.d.ts.map +1 -1
- package/dist/domain/diagram/build.d.ts +17 -17
- package/dist/domain/diagram/build.d.ts.map +1 -1
- package/dist/domain/diagram/build.js +3 -3
- package/dist/domain/diagram/build.js.map +1 -1
- package/dist/domain/diagram/layout.d.ts +1 -3
- package/dist/domain/diagram/layout.d.ts.map +1 -1
- package/dist/domain/diagram/layout.js +3 -9
- package/dist/domain/diagram/layout.js.map +1 -1
- package/dist/domain/diagram/patch.d.ts +22 -723
- package/dist/domain/diagram/patch.d.ts.map +1 -1
- package/dist/domain/diagram/patch.js +0 -53
- package/dist/domain/diagram/patch.js.map +1 -1
- package/dist/domain/diagram/summarize.d.ts +0 -1
- package/dist/domain/diagram/summarize.d.ts.map +1 -1
- package/dist/domain/diagram/summarize.js +0 -1
- package/dist/domain/diagram/summarize.js.map +1 -1
- package/dist/domain/uiTest/compose.d.ts +55 -0
- package/dist/domain/uiTest/compose.d.ts.map +1 -0
- package/dist/domain/uiTest/compose.js +228 -0
- package/dist/domain/uiTest/compose.js.map +1 -0
- package/dist/domain/uiTest/summarize.d.ts +273 -0
- package/dist/domain/uiTest/summarize.d.ts.map +1 -0
- package/dist/domain/uiTest/summarize.js +145 -0
- package/dist/domain/uiTest/summarize.js.map +1 -0
- package/dist/lib/truncate.d.ts +1 -1
- package/dist/lib/truncate.d.ts.map +1 -1
- package/dist/lib/truncate.js.map +1 -1
- package/dist/resources/docs/diagramSchema.d.ts +1 -1
- package/dist/resources/docs/diagramSchema.d.ts.map +1 -1
- package/dist/resources/docs/diagramSchema.js +1 -33
- package/dist/resources/docs/diagramSchema.js.map +1 -1
- package/dist/resources/docs/overview.d.ts +1 -1
- package/dist/resources/docs/overview.d.ts.map +1 -1
- package/dist/resources/docs/overview.js +13 -7
- package/dist/resources/docs/overview.js.map +1 -1
- package/dist/resources/docs/uiTests.d.ts +2 -0
- package/dist/resources/docs/uiTests.d.ts.map +1 -0
- package/dist/resources/docs/uiTests.js +101 -0
- package/dist/resources/docs/uiTests.js.map +1 -0
- package/dist/resources/generated/aiPacks.d.ts +1 -1
- package/dist/resources/generated/aiPacks.js +2 -2
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +13 -2
- package/dist/resources/index.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/catalog.d.ts +1 -1
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +31 -5
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/diagrams.d.ts.map +1 -1
- package/dist/tools/diagrams.js +42 -328
- package/dist/tools/diagrams.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lookups.d.ts +19 -5
- package/dist/tools/lookups.d.ts.map +1 -1
- package/dist/tools/lookups.js +77 -41
- package/dist/tools/lookups.js.map +1 -1
- package/dist/tools/shared.d.ts +5 -0
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +10 -0
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/uiTestAdmin.d.ts +4 -0
- package/dist/tools/uiTestAdmin.d.ts.map +1 -0
- package/dist/tools/uiTestAdmin.js +509 -0
- package/dist/tools/uiTestAdmin.js.map +1 -0
- package/dist/tools/uiTestRuns.d.ts +24 -0
- package/dist/tools/uiTestRuns.d.ts.map +1 -0
- package/dist/tools/uiTestRuns.js +367 -0
- package/dist/tools/uiTestRuns.js.map +1 -0
- package/dist/tools/uiTestShared.d.ts +236 -0
- package/dist/tools/uiTestShared.d.ts.map +1 -0
- package/dist/tools/uiTestShared.js +187 -0
- package/dist/tools/uiTestShared.js.map +1 -0
- package/dist/tools/uiTests.d.ts +4 -0
- package/dist/tools/uiTests.d.ts.map +1 -0
- package/dist/tools/uiTests.js +572 -0
- package/dist/tools/uiTests.js.map +1 -0
- package/dist-cjs/client/api.js +106 -21
- package/dist-cjs/client/errors.js +46 -11
- package/dist-cjs/domain/diagram/build.js +3 -3
- package/dist-cjs/domain/diagram/layout.js +3 -10
- package/dist-cjs/domain/diagram/patch.js +1 -54
- package/dist-cjs/domain/diagram/summarize.js +0 -1
- package/dist-cjs/domain/uiTest/compose.js +242 -0
- package/dist-cjs/domain/uiTest/summarize.js +155 -0
- package/dist-cjs/resources/docs/diagramSchema.js +1 -33
- package/dist-cjs/resources/docs/overview.js +13 -7
- package/dist-cjs/resources/docs/uiTests.js +103 -0
- package/dist-cjs/resources/generated/aiPacks.js +2 -2
- package/dist-cjs/resources/index.js +11 -0
- package/dist-cjs/server.js +2 -2
- package/dist-cjs/tools/catalog.js +31 -5
- package/dist-cjs/tools/diagrams.js +37 -323
- package/dist-cjs/tools/index.js +6 -0
- package/dist-cjs/tools/lookups.js +83 -46
- package/dist-cjs/tools/shared.js +12 -1
- package/dist-cjs/tools/uiTestAdmin.js +512 -0
- package/dist-cjs/tools/uiTestRuns.js +372 -0
- package/dist-cjs/tools/uiTestShared.js +202 -0
- package/dist-cjs/tools/uiTests.js +575 -0
- package/package.json +3 -3
|
@@ -16,7 +16,7 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
const directionArg = zod_1.z.enum(["DOWN", "RIGHT", "UP", "LEFT"]).optional().describe("Layout flow direction (default DOWN)");
|
|
17
17
|
const sourceArg = zod_1.z
|
|
18
18
|
.object({
|
|
19
|
-
format: zod_1.z.enum(["mermaid", "bpmn"
|
|
19
|
+
format: zod_1.z.enum(["mermaid", "bpmn"]).describe('"mermaid": Mermaid text; "bpmn": a BPMN 2.0 XML file'),
|
|
20
20
|
text: zod_1.z
|
|
21
21
|
.string()
|
|
22
22
|
.min(1)
|
|
@@ -25,7 +25,7 @@ const sourceArg = zod_1.z
|
|
|
25
25
|
})
|
|
26
26
|
.strict()
|
|
27
27
|
.optional()
|
|
28
|
-
.describe("Create the diagram from Mermaid text
|
|
28
|
+
.describe("Create the diagram from Mermaid text or BPMN 2.0 XML instead of nodes/edges");
|
|
29
29
|
// A BPMN diagram keeps its truth in BPMN 2.0 XML: the model is derived from it.
|
|
30
30
|
const bpmnSource = (text) => ({ format: "bpmn", text, diagramType: "bpmn", grammar: callman_core_1.BPMN_GRAMMAR_VERSION });
|
|
31
31
|
// Typed bpmn.* nodes → a BPMN diagram: the model becomes XML, the XML becomes
|
|
@@ -36,83 +36,6 @@ const bpmnDocumentFromModel = (model, unpositionedNodeIds, base) => {
|
|
|
36
36
|
const document = (0, callman_core_1.applyDiagramOps)({ ...base, nodes: [], edges: [], source: undefined }, [{ op: "setSource", source: bpmnSource(xml), resync: true }], { now: now() }).doc;
|
|
37
37
|
return { document, layoutNote: unpositionedNodeIds.length > 0 ? `Written as BPMN 2.0 XML; ${unpositionedNodeIds.length} node(s) placed left to right after their predecessors.` : "Written as BPMN 2.0 XML with the positions given." };
|
|
38
38
|
};
|
|
39
|
-
// A database diagram keeps its truth in the JSON database model.
|
|
40
|
-
const databaseSource = (text) => ({ format: "database", text, diagramType: "database", grammar: callman_core_1.DATABASE_GRAMMAR_VERSION, valid: true });
|
|
41
|
-
const DATABASE_DIALECTS = ["postgres", "mysql", "mssql", "oracle", "mongo", "generic"];
|
|
42
|
-
const toolErrorFromDatabaseEdit = (error) => {
|
|
43
|
-
if (error instanceof callman_core_1.DatabaseEditError)
|
|
44
|
-
throw new errors_js_1.ToolInputError(error.code, error.message);
|
|
45
|
-
throw error;
|
|
46
|
-
};
|
|
47
|
-
// A database model → a database diagram: the model becomes the source, the
|
|
48
|
-
// tables are derived from it and laid out (unrelated tables packed in rows).
|
|
49
|
-
const databaseDocumentFromModel = async (model, base, keepPositions = false) => {
|
|
50
|
-
const applied = (0, callman_core_1.applyDiagramOps)({ ...base, ...(keepPositions ? {} : { nodes: [], edges: [] }), source: undefined }, [{ op: "setSource", source: databaseSource((0, callman_core_1.serializeDatabaseModel)(model)), resync: true }], { now: now() });
|
|
51
|
-
let document = applied.doc;
|
|
52
|
-
if (keepPositions) {
|
|
53
|
-
const fresh = applied.added.nodes.filter((id) => document.nodes.some((node) => node.id === id));
|
|
54
|
-
if (fresh.length > 0)
|
|
55
|
-
document = (0, layout_js_1.placeDatabaseNodes)(document, fresh);
|
|
56
|
-
return { document, layoutNote: fresh.length > 0 ? `${fresh.length} new table(s) placed to the right of the existing ones.` : "Positions kept." };
|
|
57
|
-
}
|
|
58
|
-
if (document.nodes.length === 0)
|
|
59
|
-
return { document, layoutNote: "An empty database diagram." };
|
|
60
|
-
const laid = await (0, layout_js_1.layoutDocument)(document, { request: callman_core_1.DATABASE_LAYOUT_REQUEST });
|
|
61
|
-
return { document: laid.document, layoutNote: laid.warning ?? `${document.nodes.length} table(s) laid out with ${laid.engine} (relationships left to right).` };
|
|
62
|
-
};
|
|
63
|
-
// Tables + relationships as the create tool takes them → a model.
|
|
64
|
-
const databaseModelFromInput = (tables, relationships, dialect) => {
|
|
65
|
-
const edits = [
|
|
66
|
-
...tables.map((table) => ({ kind: "addTable", table: { ...table, ...(table.columns ? { columns: table.columns.map((column) => ({ ...column, defaultValue: column.defaultValue ?? undefined, comment: column.comment ?? undefined })) } : {}) } })),
|
|
67
|
-
...relationships.map((relationship) => ({
|
|
68
|
-
kind: "addRelationship",
|
|
69
|
-
...(relationship.id ? { id: relationship.id } : {}),
|
|
70
|
-
source: relationship.source,
|
|
71
|
-
target: relationship.target,
|
|
72
|
-
...(relationship.cardinality ? { cardinality: relationship.cardinality } : {}),
|
|
73
|
-
...(relationship.kind ? { relationshipKind: relationship.kind } : {}),
|
|
74
|
-
...(relationship.name ? { name: relationship.name } : {}),
|
|
75
|
-
...(relationship.label ? { label: relationship.label } : {}),
|
|
76
|
-
})),
|
|
77
|
-
];
|
|
78
|
-
try {
|
|
79
|
-
return (0, callman_core_1.applyDatabaseEdits)((0, callman_core_1.emptyDatabaseModel)(dialect), edits).model;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
return toolErrorFromDatabaseEdit(error);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
// A database connection by id or name, in one workspace or across all.
|
|
86
|
-
const findDatabaseConnection = async (ctx, workspace, ref) => {
|
|
87
|
-
const wanted = ref.trim().toLowerCase();
|
|
88
|
-
const workspaces = await (0, lookups_js_1.workspacesForListing)(ctx, workspace);
|
|
89
|
-
const matches = [];
|
|
90
|
-
for (const ws of workspaces) {
|
|
91
|
-
for (const connection of await ctx.api.listConnections(ws.id, "database")) {
|
|
92
|
-
if (connection.id === ref.trim() || connection.name.trim().toLowerCase() === wanted)
|
|
93
|
-
matches.push({ ws, connection });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (matches.length === 0)
|
|
97
|
-
throw new errors_js_1.ToolInputError("CONNECTION_NOT_FOUND", `No database connection "${ref}"${workspace ? ` in workspace ${workspace}` : " in your workspaces"}. list_connections shows them (type: database).`);
|
|
98
|
-
const exact = matches.filter((match) => match.connection.id === ref.trim());
|
|
99
|
-
if (exact.length === 1)
|
|
100
|
-
return exact[0];
|
|
101
|
-
if (matches.length > 1) {
|
|
102
|
-
throw new errors_js_1.ToolInputError("AMBIGUOUS_CONNECTION", `"${ref}" matches ${matches.length} database connections; pass its id or a \`workspace\`.`, {
|
|
103
|
-
candidates: matches.map((match) => ({ id: match.connection.id, name: match.connection.name, workspace: (0, lookups_js_1.workspaceTag)(match.ws) })),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return matches[0];
|
|
107
|
-
};
|
|
108
|
-
const schemaQuery = (options) => ({
|
|
109
|
-
...(options.schemas && options.schemas.length > 0 ? { schemas: options.schemas.join(",") } : {}),
|
|
110
|
-
...(options.tables && options.tables.length > 0 ? { tables: options.tables.join(",") } : {}),
|
|
111
|
-
...(options.includeViews !== undefined ? { includeViews: String(options.includeViews) } : {}),
|
|
112
|
-
...(options.objectsOnly ? { objectsOnly: "true" } : {}),
|
|
113
|
-
...(options.maxTables !== undefined ? { maxTables: options.maxTables } : {}),
|
|
114
|
-
});
|
|
115
|
-
const PROVIDER_LABEL = { postgresql: "PostgreSQL", mysql: "MySQL", mssql: "SQL Server", oracle: "Oracle", mongodb: "MongoDB" };
|
|
116
39
|
// Every document entering a tool goes through the shared gate (legacy fields
|
|
117
40
|
// stripped, ids deduped, parents healed) — the same one the studio applies.
|
|
118
41
|
const loadDocument = (diagram) => {
|
|
@@ -135,21 +58,6 @@ const assertEditableStructure = (doc) => {
|
|
|
135
58
|
// nodes/edges (positions come from layout); anything else is kept as
|
|
136
59
|
// source only (the desktop previews it, tools read it back).
|
|
137
60
|
const documentFromSource = async (title, text, existing, direction, format = "mermaid") => {
|
|
138
|
-
if (format === "database") {
|
|
139
|
-
const parsed = (0, callman_core_1.parseDatabaseModel)(text);
|
|
140
|
-
if (!parsed.ok)
|
|
141
|
-
throw new errors_js_1.ToolInputError("DIAGRAM_SOURCE_INVALID", "The text is not a readable database model.", { errors: parsed.errors.slice(0, 20) });
|
|
142
|
-
const base = existing ?? (0, callman_core_1.createEmptyDocument)(title);
|
|
143
|
-
const keep = Boolean(existing && existing.source?.format === "database");
|
|
144
|
-
let built;
|
|
145
|
-
try {
|
|
146
|
-
built = await databaseDocumentFromModel(parsed.model, keep ? existing : { ...base, nodes: [], edges: [] }, keep);
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
return (0, build_js_1.toToolError)(error);
|
|
150
|
-
}
|
|
151
|
-
return { document: built.document, layoutNote: built.layoutNote, warnings: parsed.warnings };
|
|
152
|
-
}
|
|
153
61
|
if (format === "bpmn") {
|
|
154
62
|
if (!(0, callman_core_1.looksLikeBpmn)(text))
|
|
155
63
|
throw new errors_js_1.ToolInputError("DIAGRAM_SOURCE_INVALID", "The text is not a BPMN 2.0 document (no <definitions> root).");
|
|
@@ -219,59 +127,39 @@ const isConflict = (error) => error instanceof errors_js_1.CallmanApiError && er
|
|
|
219
127
|
const registerDiagramTools = (server, ctx) => {
|
|
220
128
|
server.registerTool("list_diagrams", {
|
|
221
129
|
title: "List diagrams",
|
|
222
|
-
description: "List your system-design diagrams and the ones shared with you (owner, node/edge counts, whether you can edit)
|
|
223
|
-
inputSchema: {
|
|
224
|
-
query: zod_1.z.string().max(200).optional(),
|
|
225
|
-
folder: zod_1.z.string().max(300).optional().describe('Only the diagrams in this folder of your library (id, name or path such as "Architecture/Payments"); "/" = the top level only'),
|
|
226
|
-
...shared_js_1.cursorArgs,
|
|
227
|
-
},
|
|
130
|
+
description: "List your system-design diagrams and the ones shared with you (owner, node/edge counts, whether you can edit). Diagrams belong to users and are shared into workspaces — not workspace-scoped.",
|
|
131
|
+
inputSchema: { query: zod_1.z.string().max(200).optional(), ...shared_js_1.cursorArgs },
|
|
228
132
|
annotations: shared_js_1.READ,
|
|
229
|
-
}, (0, shared_js_1.guarded)(async ({ query,
|
|
230
|
-
const
|
|
133
|
+
}, (0, shared_js_1.guarded)(async ({ query, cursor, limit }) => {
|
|
134
|
+
const all = await (0, lookups_js_1.loadDiagrams)(ctx);
|
|
231
135
|
const needle = query?.trim().toLowerCase();
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
return false;
|
|
236
|
-
if (scope === undefined)
|
|
237
|
-
return true;
|
|
238
|
-
return (diagram.folderId ?? null) === (scope.item?.id ?? null);
|
|
239
|
-
});
|
|
240
|
-
const page = (0, pagination_js_1.sliceWithCursor)(filtered, cursor, limit, `${needle ?? ""}|${scope?.item?.id ?? (scope ? "/" : "")}`);
|
|
241
|
-
return (0, shared_js_1.ok)({
|
|
242
|
-
diagrams: page.items.map((diagram) => ({ ...(0, summarize_js_1.diagramListView)(diagram), folder: (0, lookups_js_1.diagramFolderPath)(rows, diagram.folderId) })),
|
|
243
|
-
folders: rows.map((row) => ({ id: row.id, name: row.name, parentId: row.parentId, path: row.path })),
|
|
244
|
-
total: page.total,
|
|
245
|
-
nextCursor: page.nextCursor,
|
|
246
|
-
...(scope?.item && scope.annotation ? { resolved: [(0, resolve_js_1.resolvedSummary)(folder, scope)] } : {}),
|
|
247
|
-
});
|
|
136
|
+
const filtered = needle ? all.filter((diagram) => diagram.name.toLowerCase().includes(needle)) : all;
|
|
137
|
+
const page = (0, pagination_js_1.sliceWithCursor)(filtered, cursor, limit, needle ?? "");
|
|
138
|
+
return (0, shared_js_1.ok)({ diagrams: page.items.map(summarize_js_1.diagramListView), total: page.total, nextCursor: page.nextCursor });
|
|
248
139
|
}));
|
|
249
140
|
server.registerTool("get_diagram", {
|
|
250
141
|
title: "Get a diagram",
|
|
251
|
-
description: "Read a diagram: `summary` (counts, owner, sharing), `graph` (default — nodes with type/label/parent/style and edges with semantic/color/routing/sides, in the same shape the write tools accept: enough to describe, restyle or edit it), `mermaid` (the diagram rendered as Mermaid flowchart text), `source` (the Mermaid text
|
|
252
|
-
inputSchema: { diagram: (0, shared_js_1.refArg)("Diagram"), view: zod_1.z.enum(["summary", "graph", "mermaid", "source", "
|
|
142
|
+
description: "Read a diagram: `summary` (counts, owner, sharing), `graph` (default — nodes with type/label/parent/style and edges with semantic/color/routing/sides, in the same shape the write tools accept: enough to describe, restyle or edit it), `mermaid` (the diagram rendered as Mermaid flowchart text), `source` (the Mermaid text or BPMN 2.0 XML a source-backed diagram keeps) or `full` (the complete stored DiagramDocument with positions, sizes and routes, up to 512 KB).",
|
|
143
|
+
inputSchema: { diagram: (0, shared_js_1.refArg)("Diagram"), view: zod_1.z.enum(["summary", "graph", "mermaid", "source", "full"]).default("graph") },
|
|
253
144
|
annotations: shared_js_1.READ,
|
|
254
145
|
}, (0, shared_js_1.guarded)(async ({ diagram, view }) => {
|
|
255
146
|
const resolved = await (0, lookups_js_1.resolveDiagram)(ctx, diagram);
|
|
256
147
|
const doc = loadDocument(resolved.item);
|
|
257
148
|
const summary = (0, summarize_js_1.diagramListView)(resolved.item);
|
|
258
|
-
const summaryWithFolder = { ...summary, folder: (0, lookups_js_1.diagramFolderPath)(await (0, lookups_js_1.diagramFolderRows)(ctx), resolved.item.folderId) };
|
|
259
149
|
const body = view === "summary"
|
|
260
|
-
?
|
|
150
|
+
? summary
|
|
261
151
|
: view === "graph"
|
|
262
152
|
? { ...summary, ...(0, summarize_js_1.diagramGraphView)(doc) }
|
|
263
153
|
: view === "mermaid"
|
|
264
154
|
? { ...summary, ...(0, summarize_js_1.diagramMermaidView)(doc) }
|
|
265
155
|
: view === "source"
|
|
266
156
|
? { ...summary, ...(0, summarize_js_1.diagramSourceView)(doc) }
|
|
267
|
-
:
|
|
268
|
-
? { ...summary, schema: (0, callman_core_1.databaseSchemaView)(doc) }
|
|
269
|
-
: { ...summary, ...(0, summarize_js_1.diagramFullView)(doc) };
|
|
157
|
+
: { ...summary, ...(0, summarize_js_1.diagramFullView)(doc) };
|
|
270
158
|
return (0, shared_js_1.ok)({ diagram: body, ...(resolved.annotation ? { resolved: [(0, resolve_js_1.resolvedSummary)(diagram, resolved)] } : {}) });
|
|
271
159
|
}));
|
|
272
160
|
server.registerTool("create_diagram", {
|
|
273
|
-
title: "Create a system-design
|
|
274
|
-
description: "Create a diagram from typed nodes and edges — or from Mermaid text / BPMN 2.0 XML
|
|
161
|
+
title: "Create a system-design diagram",
|
|
162
|
+
description: "Create a diagram from typed nodes and edges — or from Mermaid text / BPMN 2.0 XML (`source`). A BPMN process (`kind: \"bpmn\"`, or nodes typed bpmn.*) is stored as BPMN 2.0 XML the desktop opens in its BPMN editor. Node `type` must come from callman://diagram/components (e.g. net.service, net.api-gateway, db.postgres, mq.kafka, aws.lambda, flow.process); unknown types are rejected with suggestions unless strictTypes: false. Group nodes inside a container node — frame, pool.horizontal or pool.vertical — with `parent`. Style nodes with `style` (fill / stroke / textColor as CSS colors, strokeWidth, dashed, radius, bold, fontSize, opacity…) and edges with `semantic` (sync default, async, fallback, bus), an optional `color`, `routing` and fixed `sourceSide`/`targetSide`. Layout is automatic when nodes have no positions. Read callman://docs/diagram-schema for every field. Keep it readable: 8–25 nodes, short labels.",
|
|
275
163
|
inputSchema: {
|
|
276
164
|
name: zod_1.z.string().min(1).max(200).describe("Diagram name (library entry)"),
|
|
277
165
|
title: build_js_1.diagramInputSchema.shape.title.optional().describe("Diagram title (defaults to the name)"),
|
|
@@ -279,73 +167,28 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
279
167
|
edges: build_js_1.diagramInputSchema.shape.edges.optional(),
|
|
280
168
|
canvas: build_js_1.diagramInputSchema.shape.canvas,
|
|
281
169
|
source: sourceArg,
|
|
282
|
-
kind: zod_1.z.enum(["canvas", "bpmn"
|
|
283
|
-
tables: zod_1.z.array(patch_js_1.dbTableInputSchema).max(500).optional().describe("Database diagram: the tables (name, schema?, kind?, columns with dataType / primaryKey / nullable / unique / defaultValue / comment)"),
|
|
284
|
-
relationships: zod_1.z.array(patch_js_1.dbRelationshipInputSchema).max(2000).optional().describe('Database diagram: relationships between the tables — source is the child (foreign-key) side as "table.column", target the parent; cardinality source:target (default N:1)'),
|
|
285
|
-
dialect: zod_1.z.enum(DATABASE_DIALECTS).optional().describe("Database diagram: which database the types are written for"),
|
|
286
|
-
fromConnection: zod_1.z
|
|
287
|
-
.object({
|
|
288
|
-
connection: zod_1.z.string().min(1).max(200).describe("A database connection by id or name (list_connections, type: database)"),
|
|
289
|
-
schemas: zod_1.z.array(zod_1.z.string().min(1).max(120)).max(50).optional().describe("Schemas to read (default: every user schema; MySQL: the connection's database; Oracle: the current schema)"),
|
|
290
|
-
tables: zod_1.z.array(zod_1.z.string().min(1).max(240)).max(2000).optional().describe('Only these tables ("schema.table" or "table"); default: all'),
|
|
291
|
-
includeViews: zod_1.z.boolean().optional(),
|
|
292
|
-
})
|
|
293
|
-
.strict()
|
|
294
|
-
.optional()
|
|
295
|
-
.describe("Database diagram: read a real database's schema through one of the workspace's connections and draw it — tables, columns, keys and the relationships the database declares"),
|
|
296
|
-
workspace: shared_js_1.workspaceArg,
|
|
297
|
-
folder: zod_1.z.string().max(300).optional().describe('File it in a folder of your library (id, name or path such as "Architecture/Payments"; create one with create_diagram_folder). Default: the top level'),
|
|
170
|
+
kind: zod_1.z.enum(["canvas", "bpmn"]).optional().describe('"bpmn": model a business process — nodes use bpmn.* types and the diagram is stored as BPMN 2.0 XML (default: canvas; inferred as bpmn when every node type starts with "bpmn.")'),
|
|
298
171
|
autoLayout: zod_1.z.boolean().optional().describe("Force layout even when positions were given"),
|
|
299
172
|
direction: directionArg,
|
|
300
173
|
strictTypes: zod_1.z.boolean().optional(),
|
|
301
174
|
dryRun: shared_js_1.dryRunArg,
|
|
302
175
|
},
|
|
303
176
|
annotations: shared_js_1.WRITE,
|
|
304
|
-
}, (0, shared_js_1.guarded)(async ({ name, title, nodes, edges, canvas, source, kind,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (
|
|
308
|
-
throw new errors_js_1.ToolInputError("
|
|
309
|
-
if (inputs.length > 1)
|
|
310
|
-
throw new errors_js_1.ToolInputError("CONFLICTING_INPUT", `Pass one of nodes, source, tables or fromConnection — not ${inputs.join(" + ")}.`);
|
|
311
|
-
if (relationships && !tables)
|
|
312
|
-
throw new errors_js_1.ToolInputError("CONFLICTING_INPUT", "relationships go with tables.");
|
|
177
|
+
}, (0, shared_js_1.guarded)(async ({ name, title, nodes, edges, canvas, source, kind, autoLayout, direction, strictTypes, dryRun }) => {
|
|
178
|
+
if (!nodes && !source)
|
|
179
|
+
throw new errors_js_1.ToolInputError("NOTHING_TO_CREATE", "Pass nodes (+ edges) or source { format: \"mermaid\" | \"bpmn\", text }.");
|
|
180
|
+
if (nodes && source)
|
|
181
|
+
throw new errors_js_1.ToolInputError("CONFLICTING_INPUT", "Pass either nodes or source, not both.");
|
|
313
182
|
let document;
|
|
314
183
|
let layoutNote;
|
|
315
184
|
let warnings = [];
|
|
316
185
|
const bpmnKind = kind === "bpmn" || (kind === undefined && Boolean(nodes && nodes.length > 0 && nodes.every((node) => node.type.startsWith("bpmn."))));
|
|
317
|
-
const databaseKind = kind === "database" || Boolean(tables) || Boolean(fromConnection) || (kind === undefined && Boolean(nodes && nodes.length > 0 && nodes.every((node) => (0, callman_core_1.isDatabaseType)(node.type))));
|
|
318
|
-
let connectionNote = {};
|
|
319
186
|
if (source) {
|
|
320
187
|
const fromSource = await documentFromSource(title ?? name, source.text, null, direction, source.format);
|
|
321
188
|
document = canvas ? { ...fromSource.document, canvas: { ...fromSource.document.canvas, ...canvas } } : fromSource.document;
|
|
322
189
|
layoutNote = fromSource.layoutNote;
|
|
323
190
|
warnings = fromSource.warnings;
|
|
324
191
|
}
|
|
325
|
-
else if (fromConnection) {
|
|
326
|
-
const found = await findDatabaseConnection(ctx, workspace, fromConnection.connection);
|
|
327
|
-
const schema = await ctx.api.getConnectionSchema(found.ws.id, found.connection.id, schemaQuery(fromConnection));
|
|
328
|
-
const model = (0, callman_core_1.databaseModelFromSchema)(schema, { connection: { connectionId: found.connection.id, name: found.connection.name, provider: found.connection.provider } });
|
|
329
|
-
const built = await databaseDocumentFromModel(model, (0, callman_core_1.createEmptyDocument)(title ?? name));
|
|
330
|
-
document = built.document;
|
|
331
|
-
layoutNote = built.layoutNote;
|
|
332
|
-
warnings = [...schema.warnings, ...(schema.truncated ? ["The database has more tables than the cap; the list was cut."] : [])];
|
|
333
|
-
connectionNote = { connection: { id: found.connection.id, name: found.connection.name, provider: PROVIDER_LABEL[found.connection.provider] ?? found.connection.provider, workspace: (0, lookups_js_1.workspaceTag)(found.ws) }, tables: model.entities.length, relationships: model.relationships.length };
|
|
334
|
-
}
|
|
335
|
-
else if (tables) {
|
|
336
|
-
const model = databaseModelFromInput(tables, relationships ?? [], dialect);
|
|
337
|
-
const built = await databaseDocumentFromModel(model, (0, callman_core_1.createEmptyDocument)(title ?? name));
|
|
338
|
-
document = built.document;
|
|
339
|
-
layoutNote = built.layoutNote;
|
|
340
|
-
}
|
|
341
|
-
else if (databaseKind) {
|
|
342
|
-
const built = (0, build_js_1.buildDiagramDocument)({ title: title ?? name, nodes: nodes ?? [], edges: edges ?? [], canvas }, { strictTypes, kind: "database" });
|
|
343
|
-
const model = (0, callman_core_1.databaseModelFromDocument)({ ...built.document, source: undefined }, dialect);
|
|
344
|
-
const database = await databaseDocumentFromModel(model, (0, callman_core_1.createEmptyDocument)(title ?? name));
|
|
345
|
-
document = database.document;
|
|
346
|
-
layoutNote = database.layoutNote;
|
|
347
|
-
warnings = built.warnings;
|
|
348
|
-
}
|
|
349
192
|
else if (bpmnKind) {
|
|
350
193
|
const built = (0, build_js_1.buildDiagramDocument)({ title: title ?? name, nodes: nodes ?? [], edges: edges ?? [], canvas }, { strictTypes, kind: "bpmn" });
|
|
351
194
|
const bpmn = bpmnDocumentFromModel(built.document, built.unpositionedNodeIds, (0, callman_core_1.createEmptyDocument)(title ?? name));
|
|
@@ -363,26 +206,21 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
363
206
|
layoutNote = laid.warning ?? `Laid out with ${laid.engine}.`;
|
|
364
207
|
}
|
|
365
208
|
}
|
|
366
|
-
if (document.source?.format === "database" && canvas && !source)
|
|
367
|
-
document = { ...document, canvas: { ...document.canvas, ...canvas } };
|
|
368
|
-
const view = document.source?.format === "database" ? { ...(0, summarize_js_1.diagramGraphView)(document), schema: (0, callman_core_1.databaseSchemaView)(document) } : (0, summarize_js_1.diagramGraphView)(document);
|
|
369
209
|
if (dryRun) {
|
|
370
|
-
return (0, shared_js_1.ok)({ dryRun: true, diagram: { name,
|
|
210
|
+
return (0, shared_js_1.ok)({ dryRun: true, diagram: { name, ...(0, summarize_js_1.diagramGraphView)(document) }, warnings, ...(layoutNote ? { layout: layoutNote } : {}) });
|
|
371
211
|
}
|
|
372
|
-
const created = await ctx.api.createDiagram({ name: name.trim(), document
|
|
212
|
+
const created = await ctx.api.createDiagram({ name: name.trim(), document });
|
|
373
213
|
ctx.invalidate("diagrams");
|
|
374
214
|
return (0, shared_js_1.ok)({
|
|
375
|
-
diagram: { ...(0, summarize_js_1.diagramListView)(created),
|
|
215
|
+
diagram: { ...(0, summarize_js_1.diagramListView)(created), ...(0, summarize_js_1.diagramGraphView)(document) },
|
|
376
216
|
warnings,
|
|
377
|
-
...connectionNote,
|
|
378
217
|
...(layoutNote ? { layout: layoutNote } : {}),
|
|
379
|
-
|
|
380
|
-
note: `Saved${targetFolder ? ` in ${targetFolder.item.path}` : ""}. Open it in the desktop app (Diagrams → Refresh). Edit with patch_diagram; share with share_diagram.`,
|
|
218
|
+
note: "Saved. Open it in the desktop app (Diagrams → Refresh). Edit with patch_diagram; share with share_diagram.",
|
|
381
219
|
});
|
|
382
220
|
}));
|
|
383
221
|
server.registerTool("update_diagram", {
|
|
384
222
|
title: "Replace a diagram's content",
|
|
385
|
-
description: "Replace a diagram's whole document (nodes + edges, same fields as create_diagram), replace or attach its Mermaid text
|
|
223
|
+
description: "Replace a diagram's whole document (nodes + edges, same fields as create_diagram), replace or attach its Mermaid text or BPMN 2.0 XML `source`, and/or rename it, retitle it or change its canvas — keeping its identity and sharing. Passing nodes replaces ALL nodes and edges (omitted edges are removed). Passing `source` re-derives nodes and edges from the text (existing ones keep their place; new ones are placed). For small edits — including restyling — prefer patch_diagram.",
|
|
386
224
|
inputSchema: {
|
|
387
225
|
diagram: (0, shared_js_1.refArg)("Diagram"),
|
|
388
226
|
name: zod_1.z.string().min(1).max(200).optional(),
|
|
@@ -391,19 +229,17 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
391
229
|
edges: build_js_1.diagramInputSchema.shape.edges.optional(),
|
|
392
230
|
canvas: build_js_1.diagramInputSchema.shape.canvas,
|
|
393
231
|
source: sourceArg,
|
|
394
|
-
folder: zod_1.z.string().max(300).nullable().optional().describe('Move the diagram into this folder of your library (id, name or path); null = the top level'),
|
|
395
232
|
autoLayout: zod_1.z.boolean().optional(),
|
|
396
233
|
direction: directionArg,
|
|
397
234
|
strictTypes: zod_1.z.boolean().optional(),
|
|
398
235
|
},
|
|
399
236
|
annotations: shared_js_1.IDEMPOTENT_WRITE,
|
|
400
|
-
}, (0, shared_js_1.guarded)(async ({ diagram, name, title, nodes, edges, canvas, source,
|
|
401
|
-
if (name === undefined && nodes === undefined && title === undefined && canvas === undefined && source === undefined
|
|
402
|
-
throw new errors_js_1.ToolInputError("NOTHING_TO_UPDATE", "Pass name, title, canvas, source
|
|
237
|
+
}, (0, shared_js_1.guarded)(async ({ diagram, name, title, nodes, edges, canvas, source, autoLayout, direction, strictTypes }) => {
|
|
238
|
+
if (name === undefined && nodes === undefined && title === undefined && canvas === undefined && source === undefined) {
|
|
239
|
+
throw new errors_js_1.ToolInputError("NOTHING_TO_UPDATE", "Pass name, title, canvas, source and/or nodes (+ edges).");
|
|
403
240
|
}
|
|
404
241
|
if (nodes && source)
|
|
405
242
|
throw new errors_js_1.ToolInputError("CONFLICTING_INPUT", "Pass either nodes or source, not both.");
|
|
406
|
-
const targetFolder = folder ? await (0, lookups_js_1.resolveDiagramFolder)(ctx, folder) : null;
|
|
407
243
|
const resolved = await (0, lookups_js_1.resolveDiagram)(ctx, diagram);
|
|
408
244
|
if (!resolved.item.canEdit)
|
|
409
245
|
throw new errors_js_1.ToolInputError("DIAGRAM_READ_ONLY", "You have read-only access to this diagram.");
|
|
@@ -411,19 +247,7 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
411
247
|
let document;
|
|
412
248
|
let layoutNote;
|
|
413
249
|
let warnings = [];
|
|
414
|
-
if (nodes && existing.source?.format === "
|
|
415
|
-
// A database diagram stays one: the tables given become the new model.
|
|
416
|
-
const built = (0, build_js_1.buildDiagramDocument)({ title: title ?? existing.meta.title, nodes, edges: edges ?? [], canvas: canvas ?? existing.canvas }, { strictTypes, existingId: existing.id, createdAt: existing.meta.createdAt, kind: "database" });
|
|
417
|
-
const previous = (0, callman_core_1.parseDatabaseModel)(existing.source.text).model;
|
|
418
|
-
const model = (0, callman_core_1.databaseModelFromDocument)({ ...built.document, source: undefined }, previous.dialect);
|
|
419
|
-
if (previous.connection)
|
|
420
|
-
model.connection = previous.connection;
|
|
421
|
-
const database = await databaseDocumentFromModel(model, existing, true);
|
|
422
|
-
document = database.document;
|
|
423
|
-
layoutNote = database.layoutNote;
|
|
424
|
-
warnings = [...built.warnings, "The database model was rewritten from the tables given; tables not in the input are gone. Prefer patch_diagram (addTable, addColumn, addRelationship …) for edits."];
|
|
425
|
-
}
|
|
426
|
-
else if (nodes && existing.source?.format === "bpmn") {
|
|
250
|
+
if (nodes && existing.source?.format === "bpmn") {
|
|
427
251
|
// A BPMN diagram stays BPMN: the new model is written as fresh XML.
|
|
428
252
|
const built = (0, build_js_1.buildDiagramDocument)({ title: title ?? existing.meta.title, nodes, edges: edges ?? [], canvas: canvas ?? existing.canvas }, { strictTypes, existingId: existing.id, createdAt: existing.meta.createdAt, kind: "bpmn" });
|
|
429
253
|
const bpmn = bpmnDocumentFromModel(built.document, built.unpositionedNodeIds, existing);
|
|
@@ -440,7 +264,7 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
440
264
|
warnings.push(`edges was omitted, so the ${existing.edges.length} existing edge(s) were removed. Pass edges to keep connections, or use patch_diagram for partial edits.`);
|
|
441
265
|
}
|
|
442
266
|
if (existing.source)
|
|
443
|
-
warnings.push(
|
|
267
|
+
warnings.push("The diagram's Mermaid source was detached: nodes and edges were replaced from the input.");
|
|
444
268
|
if (autoLayout || built.unpositionedNodeIds.length > 0) {
|
|
445
269
|
const laid = await (0, layout_js_1.layoutDocument)(document, { direction });
|
|
446
270
|
document = laid.document;
|
|
@@ -470,20 +294,13 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
470
294
|
const updated = await ctx.api.updateDiagram(resolved.item.id, {
|
|
471
295
|
...(name !== undefined ? { name: name.trim() } : {}),
|
|
472
296
|
...(document ? { document, ...(typeof existing.meta.revision === "number" ? { baseRevision: existing.meta.revision } : {}) } : {}),
|
|
473
|
-
...(folder !== undefined ? { folderId: targetFolder?.item.id ?? null } : {}),
|
|
474
297
|
});
|
|
475
298
|
ctx.invalidate("diagrams");
|
|
476
|
-
|
|
477
|
-
return (0, shared_js_1.ok)({
|
|
478
|
-
diagram: { ...(0, summarize_js_1.diagramListView)(updated), folder: (0, lookups_js_1.diagramFolderPath)(rows, updated.folderId), ...(0, summarize_js_1.diagramGraphView)(document ?? existing) },
|
|
479
|
-
warnings,
|
|
480
|
-
...(layoutNote ? { layout: layoutNote } : {}),
|
|
481
|
-
resolved: [(0, resolve_js_1.resolvedSummary)(diagram, resolved), ...(targetFolder?.annotation ? [(0, resolve_js_1.resolvedSummary)(folder, targetFolder)] : [])],
|
|
482
|
-
});
|
|
299
|
+
return (0, shared_js_1.ok)({ diagram: { ...(0, summarize_js_1.diagramListView)(updated), ...(0, summarize_js_1.diagramGraphView)(document ?? existing) }, warnings, ...(layoutNote ? { layout: layoutNote } : {}), resolved: [(0, resolve_js_1.resolvedSummary)(diagram, resolved)] });
|
|
483
300
|
}));
|
|
484
301
|
server.registerTool("patch_diagram", {
|
|
485
302
|
title: "Edit a diagram incrementally",
|
|
486
|
-
description: "Apply operations to a diagram without resending it: addNode, updateNode, removeNode (drops its edges, lifts its children out), addEdge, updateEdge, removeEdge, setTitle, moveNode, reparent, setEdgeRoute (routing, fixed sides, bends), reorder (stacking), setCanvas, group (wrap nodes in a container), ungroup, relayout (a hint: new | all).
|
|
303
|
+
description: "Apply operations to a diagram without resending it: addNode, updateNode, removeNode (drops its edges, lifts its children out), addEdge, updateEdge, removeEdge, setTitle, moveNode, reparent, setEdgeRoute (routing, fixed sides, bends), reorder (stacking), setCanvas, group (wrap nodes in a container), ungroup, relayout (a hint: new | all). updateNode `changes` MERGE: style and data keys you pass change, a key set to null is removed. updateEdge can change semantic, color, label, arrows, sides and ends. Moving a node re-routes its edges. `relayout`: none | new (place only new nodes, default) | all (re-run automatic layout). Call get_diagram (view: graph) first to see node ids and current styles. Ops are documented in callman://docs/diagram-schema.",
|
|
487
304
|
inputSchema: {
|
|
488
305
|
diagram: (0, shared_js_1.refArg)("Diagram"),
|
|
489
306
|
ops: zod_1.z.array(patch_js_1.diagramPatchOpSchema).min(1).max(200),
|
|
@@ -507,21 +324,15 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
507
324
|
const wantsAll = relayout === "all" || patched.relayout?.scope === "all";
|
|
508
325
|
const layoutDirection = direction ?? patched.relayout?.direction;
|
|
509
326
|
const bpmn = document.source?.format === "bpmn";
|
|
510
|
-
const database = document.source?.format === "database";
|
|
511
327
|
if (wantsAll) {
|
|
512
|
-
// A process reads left to right; the BPMN XML follows the moves.
|
|
513
|
-
|
|
514
|
-
const laid = await (0, layout_js_1.layoutDocument)(document, { direction: layoutDirection ?? (bpmn || database ? "RIGHT" : undefined), ...(database ? { request: callman_core_1.DATABASE_LAYOUT_REQUEST } : {}) });
|
|
328
|
+
// A process reads left to right; the BPMN XML follows the moves.
|
|
329
|
+
const laid = await (0, layout_js_1.layoutDocument)(document, { direction: layoutDirection ?? (bpmn ? "RIGHT" : undefined) });
|
|
515
330
|
document = laid.document;
|
|
516
331
|
layoutNote = laid.warning ?? `Laid out with ${laid.engine}.`;
|
|
517
332
|
}
|
|
518
333
|
else if (relayout === "new" && patched.addedNodeIds.length > 0) {
|
|
519
334
|
const ids = patched.addedNodeIds.filter((id) => document.nodes.some((node) => node.id === id));
|
|
520
|
-
if (
|
|
521
|
-
document = (0, layout_js_1.placeDatabaseNodes)(document, ids);
|
|
522
|
-
layoutNote = `Placed ${ids.length} new table(s) to the right of the existing ones.`;
|
|
523
|
-
}
|
|
524
|
-
else if (bpmn) {
|
|
335
|
+
if (bpmn) {
|
|
525
336
|
document = (0, callman_core_1.applyDiagramOps)(document, (0, callman_core_1.placeBpmnNodesOps)(document, ids), { now: now() }).doc;
|
|
526
337
|
layoutNote = `Placed ${ids.length} new node(s) after their predecessors.`;
|
|
527
338
|
}
|
|
@@ -550,7 +361,7 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
550
361
|
ctx.invalidate("diagrams");
|
|
551
362
|
const { updated, document, patched, layoutNote } = outcome;
|
|
552
363
|
return (0, shared_js_1.ok)({
|
|
553
|
-
diagram: { ...(0, summarize_js_1.diagramListView)(updated), ...(0, summarize_js_1.diagramGraphView)(document)
|
|
364
|
+
diagram: { ...(0, summarize_js_1.diagramListView)(updated), ...(0, summarize_js_1.diagramGraphView)(document) },
|
|
554
365
|
applied: ops.length,
|
|
555
366
|
added: patched.addedNodeIds,
|
|
556
367
|
removedNodes: patched.removedNodeIds,
|
|
@@ -562,103 +373,6 @@ const registerDiagramTools = (server, ctx) => {
|
|
|
562
373
|
resolved: [(0, resolve_js_1.resolvedSummary)(diagram, resolved)],
|
|
563
374
|
});
|
|
564
375
|
}));
|
|
565
|
-
server.registerTool("introspect_database", {
|
|
566
|
-
title: "Read a database's schema through a connection",
|
|
567
|
-
description: "Read the database behind one of the workspace's database connections (list_connections, type: database): schemas, tables and views (MongoDB: collections with fields inferred from a sample), columns with types, nullability, defaults and comments, primary and unique keys, foreign keys with referential actions, indexes. Metadata only — never credentials, never data. Use `objectsOnly` to list names first, then read the tables you need; `create_diagram` with `fromConnection` draws the result as a Database Diagram in one step. Runs on the Callman backend, which must be able to reach the database.",
|
|
568
|
-
inputSchema: {
|
|
569
|
-
connection: zod_1.z.string().min(1).max(200).describe("Connection id or name"),
|
|
570
|
-
workspace: shared_js_1.workspaceArg,
|
|
571
|
-
schemas: zod_1.z.array(zod_1.z.string().min(1).max(120)).max(50).optional(),
|
|
572
|
-
tables: zod_1.z.array(zod_1.z.string().min(1).max(240)).max(2000).optional().describe('"schema.table" or "table"'),
|
|
573
|
-
includeViews: zod_1.z.boolean().optional(),
|
|
574
|
-
objectsOnly: zod_1.z.boolean().optional().describe("Names only (no columns / keys) — for a first look at a large database"),
|
|
575
|
-
maxTables: zod_1.z.number().int().min(1).max(20000).optional(),
|
|
576
|
-
},
|
|
577
|
-
annotations: shared_js_1.READ,
|
|
578
|
-
}, (0, shared_js_1.guarded)(async ({ connection, workspace, schemas, tables, includeViews, objectsOnly, maxTables }) => {
|
|
579
|
-
const found = await findDatabaseConnection(ctx, workspace, connection);
|
|
580
|
-
const schema = await ctx.api.getConnectionSchema(found.ws.id, found.connection.id, schemaQuery({ schemas, tables, includeViews, objectsOnly, maxTables }));
|
|
581
|
-
return (0, shared_js_1.ok)({
|
|
582
|
-
connection: { id: found.connection.id, name: found.connection.name, provider: PROVIDER_LABEL[found.connection.provider] ?? found.connection.provider, workspace: (0, lookups_js_1.workspaceTag)(found.ws) },
|
|
583
|
-
schema,
|
|
584
|
-
...(schema.truncated ? { note: "The database has more tables than the cap; pass schemas/tables to narrow the read or raise maxTables." } : {}),
|
|
585
|
-
});
|
|
586
|
-
}));
|
|
587
|
-
// ── library folders (private to the token's owner) ──────────────────
|
|
588
|
-
const folderView = (row) => ({ id: row.id, name: row.name, parentId: row.parentId, path: row.path });
|
|
589
|
-
server.registerTool("create_diagram_folder", {
|
|
590
|
-
title: "Create a diagram folder",
|
|
591
|
-
description: "Create a folder in your diagram library, optionally inside a parent folder (id, name or path). Folders are yours alone (nobody else sees them; a diagram you share shows at the top level for others), nest up to 8 levels, and sibling names are unique — an existing folder with that name is returned instead of a duplicate. File diagrams with create_diagram / update_diagram `folder`.",
|
|
592
|
-
inputSchema: {
|
|
593
|
-
name: zod_1.z.string().min(1).max(120),
|
|
594
|
-
parent: zod_1.z.string().max(300).optional().describe("Parent folder id, name or path; omit for the top level"),
|
|
595
|
-
},
|
|
596
|
-
annotations: shared_js_1.WRITE,
|
|
597
|
-
}, (0, shared_js_1.guarded)(async ({ name, parent }) => {
|
|
598
|
-
const parentFolder = parent ? await (0, lookups_js_1.resolveDiagramFolder)(ctx, parent) : null;
|
|
599
|
-
const rows = await (0, lookups_js_1.diagramFolderRows)(ctx);
|
|
600
|
-
const trimmed = name.trim();
|
|
601
|
-
const sibling = rows.find((row) => row.parentId === (parentFolder?.item.id ?? null) && (0, ids_js_1.normalizeName)(row.name) === (0, ids_js_1.normalizeName)(trimmed));
|
|
602
|
-
if (sibling) {
|
|
603
|
-
return (0, shared_js_1.ok)({ folder: folderView(sibling), existed: true, note: "A folder with that name already exists there — returned instead of creating a duplicate." });
|
|
604
|
-
}
|
|
605
|
-
const created = await ctx.api.createDiagramFolder({ name: trimmed, parentId: parentFolder?.item.id ?? null });
|
|
606
|
-
ctx.invalidate("diagram-folders");
|
|
607
|
-
const path = parentFolder ? `${parentFolder.item.path}/${created.name}` : created.name;
|
|
608
|
-
return (0, shared_js_1.ok)({
|
|
609
|
-
folder: { id: created.id, name: created.name, parentId: created.parentId, path },
|
|
610
|
-
...(parentFolder?.annotation ? { resolved: [(0, resolve_js_1.resolvedSummary)(parent, parentFolder)] } : {}),
|
|
611
|
-
});
|
|
612
|
-
}));
|
|
613
|
-
server.registerTool("update_diagram_folder", {
|
|
614
|
-
title: "Rename or move a diagram folder",
|
|
615
|
-
description: "Rename a folder of your diagram library and/or move it under another folder (parent: null = the top level). A folder cannot be moved into itself or one of its subfolders.",
|
|
616
|
-
inputSchema: {
|
|
617
|
-
folder: (0, shared_js_1.refArg)("Diagram folder", "(or path)"),
|
|
618
|
-
name: zod_1.z.string().min(1).max(120).optional(),
|
|
619
|
-
parent: zod_1.z.string().max(300).nullable().optional().describe("New parent folder (id, name or path); null = the top level"),
|
|
620
|
-
},
|
|
621
|
-
annotations: shared_js_1.IDEMPOTENT_WRITE,
|
|
622
|
-
}, (0, shared_js_1.guarded)(async ({ folder, name, parent }) => {
|
|
623
|
-
if (name === undefined && parent === undefined)
|
|
624
|
-
throw new errors_js_1.ToolInputError("NOTHING_TO_UPDATE", "Pass name and/or parent.");
|
|
625
|
-
const target = await (0, lookups_js_1.resolveDiagramFolder)(ctx, folder);
|
|
626
|
-
const parentFolder = parent ? await (0, lookups_js_1.resolveDiagramFolder)(ctx, parent) : null;
|
|
627
|
-
if (parentFolder && (parentFolder.item.id === target.item.id || parentFolder.item.path.startsWith(`${target.item.path}/`))) {
|
|
628
|
-
throw new errors_js_1.ToolInputError("FOLDER_CYCLE", "A folder cannot be moved into itself or one of its subfolders.");
|
|
629
|
-
}
|
|
630
|
-
const updated = await ctx.api.updateDiagramFolder(target.item.id, {
|
|
631
|
-
...(name !== undefined ? { name: name.trim() } : {}),
|
|
632
|
-
...(parent !== undefined ? { parentId: parentFolder?.item.id ?? null } : {}),
|
|
633
|
-
});
|
|
634
|
-
ctx.invalidate("diagram-folders");
|
|
635
|
-
const rows = await (0, lookups_js_1.diagramFolderRows)(ctx);
|
|
636
|
-
const row = rows.find((entry) => entry.id === updated.id);
|
|
637
|
-
return (0, shared_js_1.ok)({
|
|
638
|
-
folder: row ? folderView(row) : { id: updated.id, name: updated.name, parentId: updated.parentId, path: updated.name },
|
|
639
|
-
resolved: [(0, resolve_js_1.resolvedSummary)(folder, target), ...(parentFolder?.annotation ? [(0, resolve_js_1.resolvedSummary)(parent, parentFolder)] : [])],
|
|
640
|
-
});
|
|
641
|
-
}));
|
|
642
|
-
server.registerTool("delete_diagram_folder", {
|
|
643
|
-
title: "Delete a diagram folder",
|
|
644
|
-
description: "Delete a folder of your diagram library and its subfolders. No diagram is deleted: everything inside moves to the deleted folder's parent. Confirm with the user first.",
|
|
645
|
-
inputSchema: { folder: (0, shared_js_1.refArg)("Diagram folder", "(or path)"), confirm: shared_js_1.confirmArg },
|
|
646
|
-
annotations: shared_js_1.DESTRUCTIVE,
|
|
647
|
-
}, (0, shared_js_1.guarded)(async ({ folder, confirm }) => {
|
|
648
|
-
(0, shared_js_1.requireConfirm)(confirm, "a diagram folder");
|
|
649
|
-
const target = await (0, lookups_js_1.resolveDiagramFolder)(ctx, folder, { exact: true });
|
|
650
|
-
const result = await ctx.api.deleteDiagramFolder(target.item.id);
|
|
651
|
-
ctx.invalidate("diagram-folders");
|
|
652
|
-
ctx.invalidate("diagrams");
|
|
653
|
-
const rows = await (0, lookups_js_1.diagramFolderRows)(ctx);
|
|
654
|
-
return (0, shared_js_1.ok)({
|
|
655
|
-
deleted: folderView(target.item),
|
|
656
|
-
deletedFolderCount: result.deletedFolderIds.length,
|
|
657
|
-
movedDiagramCount: result.movedDiagramCount,
|
|
658
|
-
movedTo: (0, lookups_js_1.diagramFolderPath)(rows, result.movedToFolderId) ?? "the top level",
|
|
659
|
-
resolved: [(0, resolve_js_1.resolvedSummary)(folder, target)],
|
|
660
|
-
});
|
|
661
|
-
}));
|
|
662
376
|
server.registerTool("delete_diagram", {
|
|
663
377
|
title: "Delete a diagram",
|
|
664
378
|
description: "Delete a diagram you own. Permanent — confirm with the user first.",
|
package/dist-cjs/tools/index.js
CHANGED
|
@@ -11,6 +11,9 @@ const meta_js_1 = require("./meta.js");
|
|
|
11
11
|
const requests_js_1 = require("./requests.js");
|
|
12
12
|
const run_js_1 = require("./run.js");
|
|
13
13
|
const scenarios_js_1 = require("./scenarios.js");
|
|
14
|
+
const uiTestAdmin_js_1 = require("./uiTestAdmin.js");
|
|
15
|
+
const uiTestRuns_js_1 = require("./uiTestRuns.js");
|
|
16
|
+
const uiTests_js_1 = require("./uiTests.js");
|
|
14
17
|
const workspaces_js_1 = require("./workspaces.js");
|
|
15
18
|
var catalog_js_1 = require("./catalog.js");
|
|
16
19
|
Object.defineProperty(exports, "TOOL_CATALOG", { enumerable: true, get: function () { return catalog_js_1.TOOL_CATALOG; } });
|
|
@@ -43,6 +46,9 @@ const registerAllTools = (host, ctx) => {
|
|
|
43
46
|
(0, import_js_1.registerImportTools)(server, ctx);
|
|
44
47
|
(0, environments_js_1.registerEnvironmentTools)(server, ctx);
|
|
45
48
|
(0, scenarios_js_1.registerScenarioTools)(server, ctx);
|
|
49
|
+
(0, uiTests_js_1.registerUiTestTools)(server, ctx);
|
|
50
|
+
(0, uiTestRuns_js_1.registerUiTestRunTools)(server, ctx);
|
|
51
|
+
(0, uiTestAdmin_js_1.registerUiTestAdminTools)(server, ctx);
|
|
46
52
|
(0, diagrams_js_1.registerDiagramTools)(server, ctx);
|
|
47
53
|
if (ctx.config.allowLocalRun)
|
|
48
54
|
(0, run_js_1.registerRunTools)(server, ctx);
|