@kernel.chat/kbot 3.9.0 → 3.11.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.
Files changed (49) hide show
  1. package/dist/a2a-client.d.ts +162 -0
  2. package/dist/a2a-client.d.ts.map +1 -0
  3. package/dist/a2a-client.js +376 -0
  4. package/dist/a2a-client.js.map +1 -0
  5. package/dist/agent.d.ts.map +1 -1
  6. package/dist/agent.js +96 -5
  7. package/dist/agent.js.map +1 -1
  8. package/dist/cli.js +295 -3
  9. package/dist/cli.js.map +1 -1
  10. package/dist/mcp-apps.d.ts +90 -0
  11. package/dist/mcp-apps.d.ts.map +1 -0
  12. package/dist/mcp-apps.js +497 -0
  13. package/dist/mcp-apps.js.map +1 -0
  14. package/dist/memory-synthesis.d.ts +67 -0
  15. package/dist/memory-synthesis.d.ts.map +1 -0
  16. package/dist/memory-synthesis.js +557 -0
  17. package/dist/memory-synthesis.js.map +1 -0
  18. package/dist/prompt-evolution.d.ts +92 -0
  19. package/dist/prompt-evolution.d.ts.map +1 -0
  20. package/dist/prompt-evolution.js +371 -0
  21. package/dist/prompt-evolution.js.map +1 -0
  22. package/dist/reflection.d.ts +33 -0
  23. package/dist/reflection.d.ts.map +1 -0
  24. package/dist/reflection.js +368 -0
  25. package/dist/reflection.js.map +1 -0
  26. package/dist/serve.d.ts.map +1 -1
  27. package/dist/serve.js +56 -6
  28. package/dist/serve.js.map +1 -1
  29. package/dist/skill-library.d.ts +60 -0
  30. package/dist/skill-library.d.ts.map +1 -0
  31. package/dist/skill-library.js +475 -0
  32. package/dist/skill-library.js.map +1 -0
  33. package/dist/spec.d.ts +23 -0
  34. package/dist/spec.d.ts.map +1 -0
  35. package/dist/spec.js +177 -0
  36. package/dist/spec.js.map +1 -0
  37. package/dist/tool-pipeline.d.ts +7 -0
  38. package/dist/tool-pipeline.d.ts.map +1 -1
  39. package/dist/tool-pipeline.js +32 -0
  40. package/dist/tool-pipeline.js.map +1 -1
  41. package/dist/tools/index.d.ts +1 -1
  42. package/dist/tools/index.d.ts.map +1 -1
  43. package/dist/tools/index.js +2 -1
  44. package/dist/tools/index.js.map +1 -1
  45. package/dist/tree-planner.d.ts +63 -0
  46. package/dist/tree-planner.d.ts.map +1 -0
  47. package/dist/tree-planner.js +818 -0
  48. package/dist/tree-planner.js.map +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ export interface McpAppResult {
2
+ /** Standard text result (for non-visual contexts) */
3
+ text: string;
4
+ /** Interactive HTML/JS content */
5
+ html?: string;
6
+ /** App title for the window/tab */
7
+ title?: string;
8
+ /** Preferred width in pixels */
9
+ width?: number;
10
+ /** Preferred height in pixels */
11
+ height?: number;
12
+ }
13
+ export interface McpAppConfig {
14
+ /** How to render HTML: 'browser' opens in default browser, 'inline' returns for embedding, 'disabled' skips */
15
+ renderMode: 'browser' | 'inline' | 'disabled';
16
+ /** Max HTML size to render in bytes (default 1MB) */
17
+ maxHtmlSize: number;
18
+ /** Whether to sandbox iframes when rendering inline (default true) */
19
+ sandbox: boolean;
20
+ }
21
+ /** Registry entry for tools that support MCP Apps output */
22
+ interface McpAppToolEntry {
23
+ name: string;
24
+ description: string;
25
+ supportsApp: true;
26
+ }
27
+ /**
28
+ * Determine whether a tool result contains MCP App HTML content.
29
+ * Checks for the presence of a non-empty `html` field.
30
+ */
31
+ export declare function isMcpAppResult(result: unknown): result is McpAppResult;
32
+ /**
33
+ * Check if a plain text tool result contains embedded MCP App markers.
34
+ * Tools that return a JSON-encoded McpAppResult as their text output
35
+ * use the marker `<!--mcp-app-->` at the start of the html field.
36
+ */
37
+ export declare function extractMcpAppFromText(text: string): McpAppResult | null;
38
+ /**
39
+ * Load MCP Apps config from ~/.kbot/config.json, falling back to defaults.
40
+ */
41
+ export declare function getAppConfig(): McpAppConfig;
42
+ /**
43
+ * Render an MCP App result based on the config mode.
44
+ *
45
+ * - **browser**: Writes HTML to a temp file and opens it with the system browser.
46
+ * - **inline**: Returns the HTML string wrapped with sandbox attributes for iframe embedding.
47
+ * - **disabled**: Returns just the text, ignoring the HTML.
48
+ *
49
+ * Returns the text portion of the result (always), plus the rendered HTML path/content.
50
+ */
51
+ export declare function renderMcpApp(result: McpAppResult, config?: McpAppConfig): Promise<{
52
+ text: string;
53
+ rendered?: string;
54
+ path?: string;
55
+ }>;
56
+ /**
57
+ * Create an MCP App result object. Use this in tool implementations
58
+ * to return interactive HTML alongside a text summary.
59
+ *
60
+ * @param title - Title for the app window/tab
61
+ * @param html - Interactive HTML/JS content
62
+ * @param options - Optional text summary, width, height
63
+ */
64
+ export declare function createMcpApp(title: string, html: string, options?: {
65
+ text?: string;
66
+ width?: number;
67
+ height?: number;
68
+ }): McpAppResult;
69
+ /**
70
+ * Mark a tool as MCP App-capable in the registry.
71
+ */
72
+ export declare function registerAppCapableTool(name: string, description: string): void;
73
+ /**
74
+ * Check if a tool is registered as MCP App-capable.
75
+ */
76
+ export declare function isAppCapableTool(name: string): boolean;
77
+ /**
78
+ * List all MCP App-capable tools.
79
+ */
80
+ export declare function listAppCapableTools(): McpAppToolEntry[];
81
+ /**
82
+ * Register the built-in tools that return MCP Apps:
83
+ * - render_chart: Chart.js-based charts
84
+ * - render_table: Interactive sortable tables
85
+ * - render_diff: Side-by-side diff viewer
86
+ * - render_diagram: Mermaid diagram renderer
87
+ */
88
+ export declare function registerMcpAppTools(): void;
89
+ export {};
90
+ //# sourceMappingURL=mcp-apps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-apps.d.ts","sourceRoot":"","sources":["../src/mcp-apps.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC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OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,eAAe,EAAE,CAEvD;AAID;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAgQ1C"}
@@ -0,0 +1,497 @@
1
+ // kbot MCP Apps — Interactive HTML/JS UI components in tool results
2
+ //
3
+ // MCP Apps (shipped Jan 2026 by Anthropic) extend MCP tools to return HTML
4
+ // content that renders as interactive UI. The tool result includes an `html`
5
+ // field alongside the regular `text` field.
6
+ //
7
+ // In terminal mode: opens HTML in default browser via temp file.
8
+ // In serve mode: returns HTML inline for the web client to render in iframe.
9
+ //
10
+ // Usage:
11
+ // import { isMcpAppResult, renderMcpApp, createMcpApp } from './mcp-apps.js'
12
+ //
13
+ // const result = await executeSomeTool(args)
14
+ // if (isMcpAppResult(result)) {
15
+ // await renderMcpApp(result, getAppConfig())
16
+ // }
17
+ import { writeFileSync, mkdirSync, readFileSync, existsSync } from 'node:fs';
18
+ import { join } from 'node:path';
19
+ import { tmpdir, homedir, platform } from 'node:os';
20
+ import { execSync } from 'node:child_process';
21
+ import { registerTool } from './tools/index.js';
22
+ // ── State ──
23
+ const appCapableTools = new Map();
24
+ // ── Type Guard ──
25
+ /**
26
+ * Determine whether a tool result contains MCP App HTML content.
27
+ * Checks for the presence of a non-empty `html` field.
28
+ */
29
+ export function isMcpAppResult(result) {
30
+ if (typeof result !== 'object' || result === null)
31
+ return false;
32
+ const r = result;
33
+ return typeof r.text === 'string' && typeof r.html === 'string' && r.html.length > 0;
34
+ }
35
+ /**
36
+ * Check if a plain text tool result contains embedded MCP App markers.
37
+ * Tools that return a JSON-encoded McpAppResult as their text output
38
+ * use the marker `<!--mcp-app-->` at the start of the html field.
39
+ */
40
+ export function extractMcpAppFromText(text) {
41
+ // Try JSON parse if it looks like JSON
42
+ if (text.startsWith('{') && text.includes('"html"')) {
43
+ try {
44
+ const parsed = JSON.parse(text);
45
+ if (isMcpAppResult(parsed))
46
+ return parsed;
47
+ }
48
+ catch { /* not JSON */ }
49
+ }
50
+ return null;
51
+ }
52
+ // ── Config ──
53
+ const DEFAULT_CONFIG = {
54
+ renderMode: 'browser',
55
+ maxHtmlSize: 1_048_576, // 1MB
56
+ sandbox: true,
57
+ };
58
+ /**
59
+ * Load MCP Apps config from ~/.kbot/config.json, falling back to defaults.
60
+ */
61
+ export function getAppConfig() {
62
+ try {
63
+ const configPath = join(homedir(), '.kbot', 'config.json');
64
+ if (!existsSync(configPath))
65
+ return { ...DEFAULT_CONFIG };
66
+ const raw = readFileSync(configPath, 'utf-8');
67
+ const config = JSON.parse(raw);
68
+ const apps = config.mcpApps ?? config.mcp_apps ?? {};
69
+ return {
70
+ renderMode: apps.renderMode ?? apps.render_mode ?? DEFAULT_CONFIG.renderMode,
71
+ maxHtmlSize: apps.maxHtmlSize ?? apps.max_html_size ?? DEFAULT_CONFIG.maxHtmlSize,
72
+ sandbox: apps.sandbox ?? DEFAULT_CONFIG.sandbox,
73
+ };
74
+ }
75
+ catch {
76
+ return { ...DEFAULT_CONFIG };
77
+ }
78
+ }
79
+ // ── Rendering ──
80
+ /**
81
+ * Render an MCP App result based on the config mode.
82
+ *
83
+ * - **browser**: Writes HTML to a temp file and opens it with the system browser.
84
+ * - **inline**: Returns the HTML string wrapped with sandbox attributes for iframe embedding.
85
+ * - **disabled**: Returns just the text, ignoring the HTML.
86
+ *
87
+ * Returns the text portion of the result (always), plus the rendered HTML path/content.
88
+ */
89
+ export async function renderMcpApp(result, config) {
90
+ const cfg = config ?? getAppConfig();
91
+ // Enforce size limit
92
+ if (result.html && result.html.length > cfg.maxHtmlSize) {
93
+ return {
94
+ text: result.text,
95
+ rendered: `[MCP App HTML too large: ${(result.html.length / 1024).toFixed(0)}KB exceeds ${(cfg.maxHtmlSize / 1024).toFixed(0)}KB limit]`,
96
+ };
97
+ }
98
+ if (cfg.renderMode === 'disabled' || !result.html) {
99
+ return { text: result.text };
100
+ }
101
+ if (cfg.renderMode === 'browser') {
102
+ return renderInBrowser(result);
103
+ }
104
+ // inline mode
105
+ return renderInline(result, cfg);
106
+ }
107
+ /**
108
+ * Write HTML to a temp file and open in the default browser.
109
+ */
110
+ function renderInBrowser(result) {
111
+ const dir = join(tmpdir(), 'kbot-apps');
112
+ mkdirSync(dir, { recursive: true });
113
+ const slug = (result.title ?? 'app').replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();
114
+ const filename = `${slug}-${Date.now()}.html`;
115
+ const filepath = join(dir, filename);
116
+ // Wrap in a full HTML document if the content doesn't already have <html>
117
+ const html = result.html;
118
+ const fullHtml = html.trimStart().startsWith('<!') || html.trimStart().startsWith('<html')
119
+ ? html
120
+ : wrapHtmlDocument(html, result.title ?? 'kbot App', result.width, result.height);
121
+ writeFileSync(filepath, fullHtml, 'utf-8');
122
+ // Open in default browser
123
+ try {
124
+ const os = platform();
125
+ if (os === 'darwin') {
126
+ execSync(`open "${filepath}"`, { stdio: 'ignore' });
127
+ }
128
+ else if (os === 'win32') {
129
+ execSync(`start "" "${filepath}"`, { stdio: 'ignore' });
130
+ }
131
+ else {
132
+ // Linux / others
133
+ execSync(`xdg-open "${filepath}"`, { stdio: 'ignore' });
134
+ }
135
+ }
136
+ catch {
137
+ // If open fails, still return the path so the user can open manually
138
+ }
139
+ return { text: result.text, path: filepath };
140
+ }
141
+ /**
142
+ * Return HTML with sandbox attributes for inline iframe embedding (serve mode).
143
+ */
144
+ function renderInline(result, config) {
145
+ const html = result.html;
146
+ const sandboxAttrs = config.sandbox
147
+ ? 'sandbox="allow-scripts allow-same-origin"'
148
+ : '';
149
+ const width = result.width ?? 800;
150
+ const height = result.height ?? 600;
151
+ const iframe = `<div class="mcp-app" data-title="${escapeAttr(result.title ?? 'App')}">` +
152
+ `<iframe srcdoc="${escapeAttr(html)}" ${sandboxAttrs} ` +
153
+ `style="width:${width}px;max-width:100%;height:${height}px;border:1px solid #333;border-radius:8px;" ` +
154
+ `loading="lazy"></iframe>` +
155
+ `</div>`;
156
+ return { text: result.text, rendered: iframe };
157
+ }
158
+ // ── Helpers ──
159
+ function escapeAttr(s) {
160
+ return s.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
161
+ }
162
+ function wrapHtmlDocument(body, title, width, height) {
163
+ return `<!DOCTYPE html>
164
+ <html lang="en">
165
+ <head>
166
+ <meta charset="UTF-8">
167
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
168
+ <title>${title}</title>
169
+ <style>
170
+ *, *::before, *::after { box-sizing: border-box; }
171
+ body {
172
+ margin: 0;
173
+ padding: 20px;
174
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
175
+ background: #1a1a2e;
176
+ color: #e0e0e0;
177
+ ${width ? `max-width: ${width}px;` : ''}
178
+ ${height ? `min-height: ${height}px;` : ''}
179
+ }
180
+ a { color: #a78bfa; }
181
+ table { border-collapse: collapse; width: 100%; }
182
+ th, td { border: 1px solid #333; padding: 8px 12px; text-align: left; }
183
+ th { background: #2a2a3e; color: #c4b5fd; }
184
+ tr:nth-child(even) { background: #1e1e32; }
185
+ pre, code { background: #2a2a3e; border-radius: 4px; padding: 2px 6px; font-family: 'Courier Prime', monospace; }
186
+ pre { padding: 16px; overflow-x: auto; }
187
+ .chart-container { position: relative; width: 100%; max-width: 800px; margin: 0 auto; }
188
+ </style>
189
+ </head>
190
+ <body>
191
+ ${body}
192
+ </body>
193
+ </html>`;
194
+ }
195
+ // ── Tool Creation Helper ──
196
+ /**
197
+ * Create an MCP App result object. Use this in tool implementations
198
+ * to return interactive HTML alongside a text summary.
199
+ *
200
+ * @param title - Title for the app window/tab
201
+ * @param html - Interactive HTML/JS content
202
+ * @param options - Optional text summary, width, height
203
+ */
204
+ export function createMcpApp(title, html, options) {
205
+ return {
206
+ text: options?.text ?? `[MCP App: ${title}]`,
207
+ html,
208
+ title,
209
+ width: options?.width,
210
+ height: options?.height,
211
+ };
212
+ }
213
+ // ── App-capable Tool Registry ──
214
+ /**
215
+ * Mark a tool as MCP App-capable in the registry.
216
+ */
217
+ export function registerAppCapableTool(name, description) {
218
+ appCapableTools.set(name, { name, description, supportsApp: true });
219
+ }
220
+ /**
221
+ * Check if a tool is registered as MCP App-capable.
222
+ */
223
+ export function isAppCapableTool(name) {
224
+ return appCapableTools.has(name);
225
+ }
226
+ /**
227
+ * List all MCP App-capable tools.
228
+ */
229
+ export function listAppCapableTools() {
230
+ return Array.from(appCapableTools.values());
231
+ }
232
+ // ── Built-in MCP App Tools ──
233
+ /**
234
+ * Register the built-in tools that return MCP Apps:
235
+ * - render_chart: Chart.js-based charts
236
+ * - render_table: Interactive sortable tables
237
+ * - render_diff: Side-by-side diff viewer
238
+ * - render_diagram: Mermaid diagram renderer
239
+ */
240
+ export function registerMcpAppTools() {
241
+ // ── render_chart ──
242
+ registerTool({
243
+ name: 'render_chart',
244
+ description: 'Render an interactive chart using Chart.js. Returns an MCP App with HTML that can be viewed in a browser. Supports bar, line, pie, doughnut, radar, scatter chart types.',
245
+ parameters: {
246
+ type: { type: 'string', description: 'Chart type: bar, line, pie, doughnut, radar, scatter', required: true },
247
+ title: { type: 'string', description: 'Chart title', required: false },
248
+ labels: { type: 'array', description: 'X-axis labels or category names', required: true, items: { type: 'string' } },
249
+ datasets: { type: 'array', description: 'Array of dataset objects: { label, data: number[], backgroundColor?, borderColor? }', required: true, items: { type: 'object' } },
250
+ },
251
+ tier: 'free',
252
+ async execute(args) {
253
+ const type = String(args.type || 'bar');
254
+ const title = String(args.title || 'Chart');
255
+ const labels = args.labels ?? [];
256
+ const datasets = args.datasets ?? [];
257
+ const chartConfig = JSON.stringify({
258
+ type,
259
+ data: {
260
+ labels,
261
+ datasets: datasets.map((ds, i) => ({
262
+ label: ds.label ?? `Dataset ${i + 1}`,
263
+ data: ds.data,
264
+ backgroundColor: ds.backgroundColor ?? CHART_COLORS[i % CHART_COLORS.length] + '80',
265
+ borderColor: ds.borderColor ?? CHART_COLORS[i % CHART_COLORS.length],
266
+ borderWidth: 2,
267
+ })),
268
+ },
269
+ options: {
270
+ responsive: true,
271
+ plugins: {
272
+ title: { display: true, text: title, color: '#e0e0e0', font: { size: 16 } },
273
+ legend: { labels: { color: '#c0c0c0' } },
274
+ },
275
+ scales: ['pie', 'doughnut', 'radar'].includes(type) ? {} : {
276
+ x: { ticks: { color: '#a0a0a0' }, grid: { color: '#333' } },
277
+ y: { ticks: { color: '#a0a0a0' }, grid: { color: '#333' } },
278
+ },
279
+ },
280
+ });
281
+ const html = `
282
+ <div class="chart-container">
283
+ <canvas id="chart"></canvas>
284
+ </div>
285
+ <script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
286
+ <script>
287
+ new Chart(document.getElementById('chart'), ${chartConfig});
288
+ </script>`;
289
+ const app = createMcpApp(title, html, {
290
+ text: `Chart: ${title} (${type}) — ${labels.length} labels, ${datasets.length} datasets`,
291
+ width: 800,
292
+ height: 500,
293
+ });
294
+ return JSON.stringify(app);
295
+ },
296
+ });
297
+ registerAppCapableTool('render_chart', 'Render Chart.js charts as interactive HTML');
298
+ // ── render_table ──
299
+ registerTool({
300
+ name: 'render_table',
301
+ description: 'Render an interactive sortable HTML table. Click column headers to sort. Returns an MCP App with HTML viewable in a browser.',
302
+ parameters: {
303
+ title: { type: 'string', description: 'Table title', required: false },
304
+ columns: { type: 'array', description: 'Column header names', required: true, items: { type: 'string' } },
305
+ rows: { type: 'array', description: 'Array of row arrays, each containing cell values', required: true, items: { type: 'array' } },
306
+ },
307
+ tier: 'free',
308
+ async execute(args) {
309
+ const title = String(args.title || 'Data Table');
310
+ const columns = args.columns ?? [];
311
+ const rows = args.rows ?? [];
312
+ const headerCells = columns.map((col, i) => `<th onclick="sortTable(${i})" style="cursor:pointer">${escapeHtml(String(col))} <span class="sort-arrow">▸</span></th>`).join('');
313
+ const bodyRows = rows.map(row => `<tr>${row.map(cell => `<td>${escapeHtml(String(cell ?? ''))}</td>`).join('')}</tr>`).join('\n');
314
+ const html = `
315
+ <h2 style="color:#c4b5fd;margin-bottom:16px">${escapeHtml(title)}</h2>
316
+ <input type="text" id="filter" placeholder="Filter rows..." style="
317
+ width:100%;padding:8px 12px;margin-bottom:12px;background:#2a2a3e;color:#e0e0e0;
318
+ border:1px solid #444;border-radius:6px;font-size:14px;outline:none;
319
+ " oninput="filterTable()">
320
+ <table id="data-table">
321
+ <thead><tr>${headerCells}</tr></thead>
322
+ <tbody>${bodyRows}</tbody>
323
+ </table>
324
+ <p style="color:#888;font-size:12px;margin-top:8px">${rows.length} rows · Click headers to sort · Type to filter</p>
325
+ <script>
326
+ let sortDir = {};
327
+ function sortTable(col) {
328
+ const tbody = document.querySelector('#data-table tbody');
329
+ const rows = Array.from(tbody.querySelectorAll('tr'));
330
+ sortDir[col] = !sortDir[col];
331
+ rows.sort((a, b) => {
332
+ const aVal = a.cells[col]?.textContent ?? '';
333
+ const bVal = b.cells[col]?.textContent ?? '';
334
+ const aNum = parseFloat(aVal), bNum = parseFloat(bVal);
335
+ const cmp = (!isNaN(aNum) && !isNaN(bNum)) ? aNum - bNum : aVal.localeCompare(bVal);
336
+ return sortDir[col] ? cmp : -cmp;
337
+ });
338
+ rows.forEach(r => tbody.appendChild(r));
339
+ }
340
+ function filterTable() {
341
+ const q = document.getElementById('filter').value.toLowerCase();
342
+ document.querySelectorAll('#data-table tbody tr').forEach(row => {
343
+ row.style.display = row.textContent.toLowerCase().includes(q) ? '' : 'none';
344
+ });
345
+ }
346
+ </script>`;
347
+ const app = createMcpApp(title, html, {
348
+ text: `Table: ${title} — ${columns.length} columns, ${rows.length} rows`,
349
+ width: 900,
350
+ height: Math.min(800, 200 + rows.length * 35),
351
+ });
352
+ return JSON.stringify(app);
353
+ },
354
+ });
355
+ registerAppCapableTool('render_table', 'Render interactive sortable HTML tables');
356
+ // ── render_diff ──
357
+ registerTool({
358
+ name: 'render_diff',
359
+ description: 'Render a side-by-side diff of two text strings. Highlights additions, deletions, and changes. Returns an MCP App with HTML viewable in a browser.',
360
+ parameters: {
361
+ left: { type: 'string', description: 'Left/original text content', required: true },
362
+ right: { type: 'string', description: 'Right/modified text content', required: true },
363
+ left_title: { type: 'string', description: 'Title for left panel (e.g., "Original")', required: false },
364
+ right_title: { type: 'string', description: 'Title for right panel (e.g., "Modified")', required: false },
365
+ },
366
+ tier: 'free',
367
+ async execute(args) {
368
+ const left = String(args.left ?? '');
369
+ const right = String(args.right ?? '');
370
+ const leftTitle = String(args.left_title ?? 'Original');
371
+ const rightTitle = String(args.right_title ?? 'Modified');
372
+ const leftLines = left.split('\n');
373
+ const rightLines = right.split('\n');
374
+ const maxLines = Math.max(leftLines.length, rightLines.length);
375
+ let leftHtml = '';
376
+ let rightHtml = '';
377
+ for (let i = 0; i < maxLines; i++) {
378
+ const l = leftLines[i] ?? '';
379
+ const r = rightLines[i] ?? '';
380
+ const lineNum = i + 1;
381
+ if (l === r) {
382
+ leftHtml += `<div class="line"><span class="ln">${lineNum}</span>${escapeHtml(l)}</div>`;
383
+ rightHtml += `<div class="line"><span class="ln">${lineNum}</span>${escapeHtml(r)}</div>`;
384
+ }
385
+ else if (i >= leftLines.length) {
386
+ leftHtml += `<div class="line empty"><span class="ln"></span></div>`;
387
+ rightHtml += `<div class="line added"><span class="ln">${lineNum}</span>${escapeHtml(r)}</div>`;
388
+ }
389
+ else if (i >= rightLines.length) {
390
+ leftHtml += `<div class="line removed"><span class="ln">${lineNum}</span>${escapeHtml(l)}</div>`;
391
+ rightHtml += `<div class="line empty"><span class="ln"></span></div>`;
392
+ }
393
+ else {
394
+ leftHtml += `<div class="line removed"><span class="ln">${lineNum}</span>${escapeHtml(l)}</div>`;
395
+ rightHtml += `<div class="line added"><span class="ln">${lineNum}</span>${escapeHtml(r)}</div>`;
396
+ }
397
+ }
398
+ const html = `
399
+ <style>
400
+ .diff-container { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; font-family: 'Courier Prime', monospace; font-size: 13px; }
401
+ .diff-panel { overflow-x: auto; }
402
+ .diff-header { padding: 8px 12px; background: #2a2a3e; color: #c4b5fd; font-weight: bold; border-radius: 6px 6px 0 0; }
403
+ .line { padding: 1px 12px; white-space: pre; min-height: 20px; line-height: 20px; }
404
+ .ln { display: inline-block; width: 40px; color: #555; text-align: right; margin-right: 12px; user-select: none; }
405
+ .added { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
406
+ .removed { background: rgba(248, 113, 113, 0.15); color: #f87171; }
407
+ .empty { background: rgba(100, 100, 100, 0.1); }
408
+ </style>
409
+ <div class="diff-container">
410
+ <div class="diff-panel">
411
+ <div class="diff-header">${escapeHtml(leftTitle)}</div>
412
+ ${leftHtml}
413
+ </div>
414
+ <div class="diff-panel">
415
+ <div class="diff-header">${escapeHtml(rightTitle)}</div>
416
+ ${rightHtml}
417
+ </div>
418
+ </div>
419
+ <p style="color:#888;font-size:12px;margin-top:8px">
420
+ ${leftLines.length} lines vs ${rightLines.length} lines
421
+ </p>`;
422
+ const app = createMcpApp(`Diff: ${leftTitle} vs ${rightTitle}`, html, {
423
+ text: `Diff: ${leftTitle} (${leftLines.length} lines) vs ${rightTitle} (${rightLines.length} lines)`,
424
+ width: 1000,
425
+ height: Math.min(800, 100 + maxLines * 22),
426
+ });
427
+ return JSON.stringify(app);
428
+ },
429
+ });
430
+ registerAppCapableTool('render_diff', 'Render side-by-side diff viewer as HTML');
431
+ // ── render_diagram ──
432
+ registerTool({
433
+ name: 'render_diagram',
434
+ description: 'Render a Mermaid diagram as interactive HTML. Supports flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, pie charts, and more. Returns an MCP App with HTML viewable in a browser.',
435
+ parameters: {
436
+ markup: { type: 'string', description: 'Mermaid diagram markup (e.g., "graph TD; A-->B; B-->C;")', required: true },
437
+ title: { type: 'string', description: 'Diagram title', required: false },
438
+ },
439
+ tier: 'free',
440
+ async execute(args) {
441
+ const markup = String(args.markup ?? '');
442
+ const title = String(args.title || 'Diagram');
443
+ const html = `
444
+ <h2 style="color:#c4b5fd;margin-bottom:16px">${escapeHtml(title)}</h2>
445
+ <div class="mermaid" id="diagram">
446
+ ${escapeHtml(markup)}
447
+ </div>
448
+ <details style="margin-top:16px">
449
+ <summary style="color:#888;cursor:pointer">View source markup</summary>
450
+ <pre style="margin-top:8px">${escapeHtml(markup)}</pre>
451
+ </details>
452
+ <script type="module">
453
+ import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
454
+ mermaid.initialize({
455
+ startOnLoad: true,
456
+ theme: 'dark',
457
+ themeVariables: {
458
+ primaryColor: '#6B5B95',
459
+ primaryTextColor: '#e0e0e0',
460
+ primaryBorderColor: '#7C6CB0',
461
+ lineColor: '#888',
462
+ secondaryColor: '#2a2a3e',
463
+ tertiaryColor: '#1a1a2e',
464
+ }
465
+ });
466
+ </script>`;
467
+ const app = createMcpApp(title, html, {
468
+ text: `Diagram: ${title} — Mermaid markup (${markup.length} chars)`,
469
+ width: 900,
470
+ height: 600,
471
+ });
472
+ return JSON.stringify(app);
473
+ },
474
+ });
475
+ registerAppCapableTool('render_diagram', 'Render Mermaid diagrams as interactive HTML');
476
+ }
477
+ // ── Internal Utilities ──
478
+ function escapeHtml(s) {
479
+ return s
480
+ .replace(/&/g, '&amp;')
481
+ .replace(/</g, '&lt;')
482
+ .replace(/>/g, '&gt;')
483
+ .replace(/"/g, '&quot;');
484
+ }
485
+ const CHART_COLORS = [
486
+ '#a78bfa', // violet
487
+ '#4ade80', // green
488
+ '#f87171', // red
489
+ '#fbbf24', // amber
490
+ '#67e8f9', // cyan
491
+ '#fb923c', // orange
492
+ '#f472b6', // pink
493
+ '#60a5fa', // blue
494
+ '#a3e635', // lime
495
+ '#e879f9', // fuchsia
496
+ ];
497
+ //# sourceMappingURL=mcp-apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-apps.js","sourceRoot":"","sources":["../src/mcp-apps.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,4CAA4C;A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