@vfarcic/dot-ai 0.178.0 → 0.180.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/dist/core/generic-session-manager.d.ts +5 -0
- package/dist/core/generic-session-manager.d.ts.map +1 -1
- package/dist/core/generic-session-manager.js +8 -1
- package/dist/core/mermaid-tools.d.ts +27 -0
- package/dist/core/mermaid-tools.d.ts.map +1 -0
- package/dist/core/mermaid-tools.js +115 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +14 -13
- package/dist/core/visualization.d.ts +77 -0
- package/dist/core/visualization.d.ts.map +1 -0
- package/dist/core/visualization.js +80 -0
- package/dist/interfaces/rest-api.d.ts +19 -2
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +120 -47
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +93 -23
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-analysis.js +5 -0
- package/dist/tools/operate.d.ts +4 -1
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +9 -1
- package/dist/tools/organizational-data.d.ts +1 -1
- package/dist/tools/query.d.ts +2 -1
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +4 -15
- package/dist/tools/recommend.d.ts +22 -0
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +41 -16
- package/dist/tools/remediate.d.ts +3 -1
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +31 -12
- package/dist/tools/version.d.ts +16 -0
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +55 -29
- package/package.json +2 -1
- package/prompts/visualize.md +86 -0
- package/scripts/dot-ai.nu +43 -5
- package/prompts/visualize-query.md +0 -113
|
@@ -61,6 +61,11 @@ export declare class GenericSessionManager<T = any> {
|
|
|
61
61
|
clearAllSessions(): void;
|
|
62
62
|
/**
|
|
63
63
|
* Save session to file
|
|
64
|
+
*
|
|
65
|
+
* Note: Uses a custom replacer to convert undefined values to null.
|
|
66
|
+
* This is critical because JSON.stringify drops undefined values entirely,
|
|
67
|
+
* which would cause data loss in toolCallsExecuted arrays where tool
|
|
68
|
+
* outputs may have undefined fields. (PRD #320 Milestone 2.5)
|
|
64
69
|
*/
|
|
65
70
|
private saveSession;
|
|
66
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-session-manager.d.ts","sourceRoot":"","sources":["../../src/core/generic-session-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CACT;AAED;;GAEG;AACH,qBAAa,qBAAqB,CAAC,CAAC,GAAG,GAAG;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAE7B;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAW1B;;;OAGG;IACH,aAAa,CAAC,WAAW,GAAE,CAAW,GAAG,cAAc,CAAC,CAAC,CAAC;IAgB1D;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAgBvD;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAc/E;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAcvE;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAgBzC;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;IAgBxB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAiBxB
|
|
1
|
+
{"version":3,"file":"generic-session-manager.d.ts","sourceRoot":"","sources":["../../src/core/generic-session-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CACT;AAED;;GAEG;AACH,qBAAa,qBAAqB,CAAC,CAAC,GAAG,GAAG;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAE7B;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAW1B;;;OAGG;IACH,aAAa,CAAC,WAAW,GAAE,CAAW,GAAG,cAAc,CAAC,CAAC,CAAC;IAgB1D;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAgBvD;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAc/E;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI;IAcvE;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAgBzC;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;IAgBxB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAiBxB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -183,10 +183,17 @@ class GenericSessionManager {
|
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Save session to file
|
|
186
|
+
*
|
|
187
|
+
* Note: Uses a custom replacer to convert undefined values to null.
|
|
188
|
+
* This is critical because JSON.stringify drops undefined values entirely,
|
|
189
|
+
* which would cause data loss in toolCallsExecuted arrays where tool
|
|
190
|
+
* outputs may have undefined fields. (PRD #320 Milestone 2.5)
|
|
186
191
|
*/
|
|
187
192
|
saveSession(session) {
|
|
188
193
|
const sessionFile = path.join(this.sessionsPath, `${session.sessionId}.json`);
|
|
189
|
-
|
|
194
|
+
// Convert undefined to null to preserve structure during JSON serialization
|
|
195
|
+
const replacer = (_key, value) => value === undefined ? null : value;
|
|
196
|
+
fs.writeFileSync(sessionFile, JSON.stringify(session, replacer, 2), 'utf8');
|
|
190
197
|
}
|
|
191
198
|
}
|
|
192
199
|
exports.GenericSessionManager = GenericSessionManager;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid Validation Tools for AI-Powered Visualization
|
|
3
|
+
*
|
|
4
|
+
* Provides Mermaid diagram validation tools for the visualization AI.
|
|
5
|
+
* Allows AI to validate diagrams before returning them to the user.
|
|
6
|
+
*
|
|
7
|
+
* PRD #320: Milestone 2.6 - Mermaid Diagram Validation
|
|
8
|
+
*/
|
|
9
|
+
import { AITool } from './ai-provider.interface';
|
|
10
|
+
/**
|
|
11
|
+
* Tool: validate_mermaid
|
|
12
|
+
* Validates Mermaid diagram syntax and returns errors if any
|
|
13
|
+
*/
|
|
14
|
+
export declare const VALIDATE_MERMAID_TOOL: AITool;
|
|
15
|
+
/**
|
|
16
|
+
* All mermaid tools for visualization
|
|
17
|
+
*/
|
|
18
|
+
export declare const MERMAID_TOOLS: AITool[];
|
|
19
|
+
/**
|
|
20
|
+
* Execute Mermaid-related tools
|
|
21
|
+
*
|
|
22
|
+
* @param toolName - Name of the tool to execute
|
|
23
|
+
* @param input - Tool input parameters
|
|
24
|
+
* @returns Tool execution result
|
|
25
|
+
*/
|
|
26
|
+
export declare function executeMermaidTools(toolName: string, input: any): Promise<any>;
|
|
27
|
+
//# sourceMappingURL=mermaid-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-tools.d.ts","sourceRoot":"","sources":["../../src/core/mermaid-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAWjD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MA0BnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,EAEjC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,GACT,OAAO,CAAC,GAAG,CAAC,CAoDd"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mermaid Validation Tools for AI-Powered Visualization
|
|
4
|
+
*
|
|
5
|
+
* Provides Mermaid diagram validation tools for the visualization AI.
|
|
6
|
+
* Allows AI to validate diagrams before returning them to the user.
|
|
7
|
+
*
|
|
8
|
+
* PRD #320: Milestone 2.6 - Mermaid Diagram Validation
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.MERMAID_TOOLS = exports.VALIDATE_MERMAID_TOOL = void 0;
|
|
15
|
+
exports.executeMermaidTools = executeMermaidTools;
|
|
16
|
+
const mermaid_1 = __importDefault(require("mermaid"));
|
|
17
|
+
// Initialize mermaid with strict validation
|
|
18
|
+
mermaid_1.default.initialize({
|
|
19
|
+
securityLevel: 'strict',
|
|
20
|
+
startOnLoad: false,
|
|
21
|
+
// Disable rendering, we only want parsing/validation
|
|
22
|
+
suppressErrorRendering: true
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Tool: validate_mermaid
|
|
26
|
+
* Validates Mermaid diagram syntax and returns errors if any
|
|
27
|
+
*/
|
|
28
|
+
exports.VALIDATE_MERMAID_TOOL = {
|
|
29
|
+
name: 'validate_mermaid',
|
|
30
|
+
description: `Validates Mermaid diagram syntax. Use this tool to check if a Mermaid diagram has correct syntax BEFORE including it in visualizations.
|
|
31
|
+
|
|
32
|
+
IMPORTANT: Always validate all Mermaid diagrams before returning them. If validation fails, fix the error and validate again.
|
|
33
|
+
|
|
34
|
+
Common Mermaid syntax errors to watch for:
|
|
35
|
+
- "classDist" should be "classDef" (class definition)
|
|
36
|
+
- Missing quotes around labels with special characters
|
|
37
|
+
- Invalid node/edge syntax
|
|
38
|
+
- Unbalanced brackets or parentheses
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
- valid: boolean - true if diagram is valid
|
|
42
|
+
- error: string | null - error message if invalid, null if valid
|
|
43
|
+
- parseError: object | null - detailed parse error info if available`,
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
diagram: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'The Mermaid diagram code to validate (without the ```mermaid code fence)'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
required: ['diagram']
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* All mermaid tools for visualization
|
|
57
|
+
*/
|
|
58
|
+
exports.MERMAID_TOOLS = [
|
|
59
|
+
exports.VALIDATE_MERMAID_TOOL
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Execute Mermaid-related tools
|
|
63
|
+
*
|
|
64
|
+
* @param toolName - Name of the tool to execute
|
|
65
|
+
* @param input - Tool input parameters
|
|
66
|
+
* @returns Tool execution result
|
|
67
|
+
*/
|
|
68
|
+
async function executeMermaidTools(toolName, input) {
|
|
69
|
+
if (toolName !== 'validate_mermaid') {
|
|
70
|
+
return {
|
|
71
|
+
success: false,
|
|
72
|
+
error: `Unknown mermaid tool: ${toolName}`,
|
|
73
|
+
message: `Tool '${toolName}' is not a mermaid tool`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const { diagram } = input;
|
|
77
|
+
if (!diagram || typeof diagram !== 'string') {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
valid: false,
|
|
81
|
+
error: 'Missing or invalid diagram parameter. Provide the Mermaid diagram code as a string.'
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
// Use mermaid.parse() to validate syntax without rendering
|
|
86
|
+
// This returns true if valid, or throws an error if invalid
|
|
87
|
+
await mermaid_1.default.parse(diagram);
|
|
88
|
+
return {
|
|
89
|
+
success: true,
|
|
90
|
+
valid: true,
|
|
91
|
+
error: null,
|
|
92
|
+
parseError: null,
|
|
93
|
+
message: 'Diagram syntax is valid'
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// Extract useful error information
|
|
98
|
+
const errorMessage = error.message || String(error);
|
|
99
|
+
// Check if it's a parser error with detailed info
|
|
100
|
+
const parseError = error.hash ? {
|
|
101
|
+
text: error.hash.text,
|
|
102
|
+
token: error.hash.token,
|
|
103
|
+
line: error.hash.line,
|
|
104
|
+
loc: error.hash.loc,
|
|
105
|
+
expected: error.hash.expected
|
|
106
|
+
} : null;
|
|
107
|
+
return {
|
|
108
|
+
success: true, // Tool executed successfully, but diagram is invalid
|
|
109
|
+
valid: false,
|
|
110
|
+
error: errorMessage,
|
|
111
|
+
parseError,
|
|
112
|
+
message: `Diagram validation failed: ${errorMessage}`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AAiBlC,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAM;gBAEf,MAAM,EAAE,gBAAgB;IAWpC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,eAAe;IAsFvB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,iBAAiB;IAyBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IAoJtB;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vercel-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/vercel-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AAiBlC,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,aAAa,CAAM;gBAEf,MAAM,EAAE,gBAAgB;IAWpC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,eAAe;IAsFvB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,OAAO;IAIxB,OAAO,CAAC,iBAAiB;IAyBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IAoJtB;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAiW/D"}
|
|
@@ -278,6 +278,9 @@ class VercelProvider {
|
|
|
278
278
|
const operation = config.operation || 'tool-loop';
|
|
279
279
|
// Convert AITool[] to Vercel AI SDK tool format
|
|
280
280
|
const tools = {};
|
|
281
|
+
// PRD #320: Capture tool calls during execution (not reconstruction from steps)
|
|
282
|
+
// This ensures toolCallsExecuted has actual data for visualization
|
|
283
|
+
const toolCallsExecuted = [];
|
|
281
284
|
for (let i = 0; i < config.tools.length; i++) {
|
|
282
285
|
const aiTool = config.tools[i];
|
|
283
286
|
const isLastTool = i === config.tools.length - 1;
|
|
@@ -285,7 +288,15 @@ class VercelProvider {
|
|
|
285
288
|
description: aiTool.description,
|
|
286
289
|
inputSchema: (0, ai_1.jsonSchema)(aiTool.inputSchema),
|
|
287
290
|
execute: async (input) => {
|
|
288
|
-
|
|
291
|
+
// Execute and capture result
|
|
292
|
+
const output = await config.toolExecutor(aiTool.name, input);
|
|
293
|
+
// Capture for toolCallsExecuted array
|
|
294
|
+
toolCallsExecuted.push({
|
|
295
|
+
tool: aiTool.name,
|
|
296
|
+
input,
|
|
297
|
+
output,
|
|
298
|
+
});
|
|
299
|
+
return output;
|
|
289
300
|
},
|
|
290
301
|
});
|
|
291
302
|
// Add cache control ONLY to last tool for Anthropic (max 4 cache breakpoints)
|
|
@@ -448,18 +459,8 @@ class VercelProvider {
|
|
|
448
459
|
};
|
|
449
460
|
debugFiles = this.logDebugIfEnabled(`${operation}-raw`, finalPrompt, rawAiResponse);
|
|
450
461
|
}
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
for (const step of result.steps || []) {
|
|
454
|
-
for (const toolCall of step.toolCalls || []) {
|
|
455
|
-
const toolResult = step.toolResults?.find((tr) => tr.toolCallId === toolCall.toolCallId);
|
|
456
|
-
toolCallsExecuted.push({
|
|
457
|
-
tool: toolCall.toolName,
|
|
458
|
-
input: toolCall.args,
|
|
459
|
-
output: toolResult?.result,
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
462
|
+
// PRD #320: toolCallsExecuted is now captured during execution (see tool wrapper above)
|
|
463
|
+
// This replaces the old reconstruction from result.steps which lost input/output data
|
|
463
464
|
// Normalize token metrics across providers
|
|
464
465
|
// NOTE: Vercel AI SDK had token reporting bugs that were fixed in PR #8945 (merged Sept 26, 2025)
|
|
465
466
|
// - GitHub Issue #8349: cache tokens only reflected last step, not summed across all steps
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Visualization Utilities (PRD #320)
|
|
3
|
+
*
|
|
4
|
+
* Common utilities for visualization support across all MCP tools.
|
|
5
|
+
* Provides session metadata interfaces, URL generation, and prompt selection.
|
|
6
|
+
*/
|
|
7
|
+
import { VisualizationType } from '../interfaces/rest-api';
|
|
8
|
+
/**
|
|
9
|
+
* Cached visualization structure stored in sessions
|
|
10
|
+
* PRD #320: Added toolsUsed for test validation of mermaid validation
|
|
11
|
+
*/
|
|
12
|
+
export interface CachedVisualization {
|
|
13
|
+
title: string;
|
|
14
|
+
visualizations: Array<{
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
type: VisualizationType;
|
|
18
|
+
content: any;
|
|
19
|
+
}>;
|
|
20
|
+
insights: string[];
|
|
21
|
+
toolsUsed?: string[];
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Base interface for visualization session data
|
|
26
|
+
* All tools should include these fields for visualization support
|
|
27
|
+
*/
|
|
28
|
+
export interface BaseVisualizationData {
|
|
29
|
+
/** Tool that created this session: 'query' | 'recommend' | 'remediate' | etc. */
|
|
30
|
+
toolName: string;
|
|
31
|
+
/** Optional stage for multi-stage tools (e.g., 'recommend', 'generateManifests') */
|
|
32
|
+
stage?: string;
|
|
33
|
+
/** Cached visualization to avoid re-generation */
|
|
34
|
+
cachedVisualization?: CachedVisualization;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Supported tool names for visualization
|
|
38
|
+
*/
|
|
39
|
+
export type VisualizationToolName = 'query' | 'recommend' | 'remediate' | 'operate' | 'version' | 'projectSetup';
|
|
40
|
+
/**
|
|
41
|
+
* Get the prompt file name for visualization
|
|
42
|
+
* All tools use the unified visualize.md template (PRD #320)
|
|
43
|
+
*
|
|
44
|
+
* @param toolName - Name of the tool (unused, kept for API compatibility)
|
|
45
|
+
* @returns Prompt file name (without .md extension)
|
|
46
|
+
*/
|
|
47
|
+
export declare function getPromptForTool(_toolName: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get visualization URL if WEB_UI_BASE_URL is configured
|
|
50
|
+
* Feature toggle - only returns URL when env var is set
|
|
51
|
+
*
|
|
52
|
+
* @param sessionIds - Single session ID or array of session IDs to include in URL
|
|
53
|
+
* @returns Visualization URL or undefined if not configured
|
|
54
|
+
*/
|
|
55
|
+
export declare function getVisualizationUrl(sessionIds: string | string[]): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Extract the session prefix from a session ID
|
|
58
|
+
* Session IDs are formatted: {prefix}-{timestamp}-{uuid}
|
|
59
|
+
*
|
|
60
|
+
* @param sessionId - Full session ID (e.g., 'qry-1704067200000-a1b2c3d4')
|
|
61
|
+
* @returns Session prefix (e.g., 'qry')
|
|
62
|
+
*/
|
|
63
|
+
export declare function extractPrefixFromSessionId(sessionId: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Session prefixes used by each tool
|
|
66
|
+
* Useful for documentation and validation
|
|
67
|
+
*/
|
|
68
|
+
export declare const TOOL_SESSION_PREFIXES: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Get the tool name from a session prefix
|
|
71
|
+
* Reverse lookup from prefix to tool name
|
|
72
|
+
*
|
|
73
|
+
* @param prefix - Session prefix (e.g., 'qry')
|
|
74
|
+
* @returns Tool name or undefined if not recognized
|
|
75
|
+
*/
|
|
76
|
+
export declare function getToolNameFromPrefix(prefix: string): string | undefined;
|
|
77
|
+
//# sourceMappingURL=visualization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualization.d.ts","sourceRoot":"","sources":["../../src/core/visualization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,KAAK,CAAC;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,iBAAiB,CAAC;QACxB,OAAO,EAAE,GAAG,CAAC;KACd,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,cAAc,CAAC;AAEnB;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAUrF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOxD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOxE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared Visualization Utilities (PRD #320)
|
|
4
|
+
*
|
|
5
|
+
* Common utilities for visualization support across all MCP tools.
|
|
6
|
+
* Provides session metadata interfaces, URL generation, and prompt selection.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TOOL_SESSION_PREFIXES = void 0;
|
|
10
|
+
exports.getPromptForTool = getPromptForTool;
|
|
11
|
+
exports.getVisualizationUrl = getVisualizationUrl;
|
|
12
|
+
exports.extractPrefixFromSessionId = extractPrefixFromSessionId;
|
|
13
|
+
exports.getToolNameFromPrefix = getToolNameFromPrefix;
|
|
14
|
+
/**
|
|
15
|
+
* Get the prompt file name for visualization
|
|
16
|
+
* All tools use the unified visualize.md template (PRD #320)
|
|
17
|
+
*
|
|
18
|
+
* @param toolName - Name of the tool (unused, kept for API compatibility)
|
|
19
|
+
* @returns Prompt file name (without .md extension)
|
|
20
|
+
*/
|
|
21
|
+
function getPromptForTool(_toolName) {
|
|
22
|
+
return 'visualize';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get visualization URL if WEB_UI_BASE_URL is configured
|
|
26
|
+
* Feature toggle - only returns URL when env var is set
|
|
27
|
+
*
|
|
28
|
+
* @param sessionIds - Single session ID or array of session IDs to include in URL
|
|
29
|
+
* @returns Visualization URL or undefined if not configured
|
|
30
|
+
*/
|
|
31
|
+
function getVisualizationUrl(sessionIds) {
|
|
32
|
+
const baseUrl = process.env.WEB_UI_BASE_URL;
|
|
33
|
+
if (!baseUrl) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
// Remove trailing slash if present, then append /v/{sessionId(s)}
|
|
37
|
+
const normalizedBaseUrl = baseUrl.replace(/\/$/, '');
|
|
38
|
+
// Join multiple session IDs with + separator
|
|
39
|
+
const sessionPath = Array.isArray(sessionIds) ? sessionIds.join('+') : sessionIds;
|
|
40
|
+
return `${normalizedBaseUrl}/v/${sessionPath}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extract the session prefix from a session ID
|
|
44
|
+
* Session IDs are formatted: {prefix}-{timestamp}-{uuid}
|
|
45
|
+
*
|
|
46
|
+
* @param sessionId - Full session ID (e.g., 'qry-1704067200000-a1b2c3d4')
|
|
47
|
+
* @returns Session prefix (e.g., 'qry')
|
|
48
|
+
*/
|
|
49
|
+
function extractPrefixFromSessionId(sessionId) {
|
|
50
|
+
const parts = sessionId.split('-');
|
|
51
|
+
// Return first part as prefix, default to 'qry' if invalid
|
|
52
|
+
return parts[0] || 'qry';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Session prefixes used by each tool
|
|
56
|
+
* Useful for documentation and validation
|
|
57
|
+
*/
|
|
58
|
+
exports.TOOL_SESSION_PREFIXES = {
|
|
59
|
+
query: 'qry',
|
|
60
|
+
recommend: 'sol', // "solution" - recommend tool provides solutions
|
|
61
|
+
remediate: 'rem',
|
|
62
|
+
operate: 'opr',
|
|
63
|
+
version: 'ver',
|
|
64
|
+
projectSetup: 'prj',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get the tool name from a session prefix
|
|
68
|
+
* Reverse lookup from prefix to tool name
|
|
69
|
+
*
|
|
70
|
+
* @param prefix - Session prefix (e.g., 'qry')
|
|
71
|
+
* @returns Tool name or undefined if not recognized
|
|
72
|
+
*/
|
|
73
|
+
function getToolNameFromPrefix(prefix) {
|
|
74
|
+
for (const [tool, toolPrefix] of Object.entries(exports.TOOL_SESSION_PREFIXES)) {
|
|
75
|
+
if (toolPrefix === prefix) {
|
|
76
|
+
return tool;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
@@ -59,8 +59,22 @@ export interface ToolDiscoveryResponse extends RestApiResponse {
|
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Visualization types supported by the API
|
|
62
|
+
* PRD #320: Added 'diff' type for before/after comparisons
|
|
62
63
|
*/
|
|
63
|
-
export type VisualizationType = 'mermaid' | 'cards' | 'code' | 'table';
|
|
64
|
+
export type VisualizationType = 'mermaid' | 'cards' | 'code' | 'table' | 'diff';
|
|
65
|
+
/**
|
|
66
|
+
* Diff visualization content (PRD #320)
|
|
67
|
+
*/
|
|
68
|
+
export interface DiffVisualizationContent {
|
|
69
|
+
before: {
|
|
70
|
+
language: string;
|
|
71
|
+
code: string;
|
|
72
|
+
};
|
|
73
|
+
after: {
|
|
74
|
+
language: string;
|
|
75
|
+
code: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
64
78
|
/**
|
|
65
79
|
* Individual visualization item
|
|
66
80
|
*/
|
|
@@ -79,15 +93,17 @@ export interface Visualization {
|
|
|
79
93
|
title: string;
|
|
80
94
|
description?: string;
|
|
81
95
|
tags?: string[];
|
|
82
|
-
}
|
|
96
|
+
}> | DiffVisualizationContent;
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Visualization endpoint response format
|
|
100
|
+
* PRD #320: Added toolsUsed for test validation of mermaid validation
|
|
86
101
|
*/
|
|
87
102
|
export interface VisualizationResponse {
|
|
88
103
|
title: string;
|
|
89
104
|
visualizations: Visualization[];
|
|
90
105
|
insights: string[];
|
|
106
|
+
toolsUsed?: string[];
|
|
91
107
|
}
|
|
92
108
|
/**
|
|
93
109
|
* REST API router configuration
|
|
@@ -144,6 +160,7 @@ export declare class RestApiRouter {
|
|
|
144
160
|
/**
|
|
145
161
|
* Handle visualization requests (PRD #317)
|
|
146
162
|
* Returns structured visualization data for a query session
|
|
163
|
+
* PRD #320: Supports ?reload=true to regenerate visualization from current session data
|
|
147
164
|
*/
|
|
148
165
|
private handleVisualize;
|
|
149
166
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../../src/interfaces/rest-api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAyBtC;;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