Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): treat a dashboard column type the same on every path
marcoteb32a4acafe293
diff --git a/mcp-host/src/workflow/__tests__/internalTools.dashboard.contract.test.ts b/mcp-host/src/workflow/__tests__/internalTools.dashboard.contract.test.tsindex 003348555..150c1e666 100644--- a/mcp-host/src/workflow/__tests__/internalTools.dashboard.contract.test.ts+++ b/mcp-host/src/workflow/__tests__/internalTools.dashboard.contract.test.ts@@ -394,3 +394,46 @@ describe('dashboard schema survives Gemini', () => {expect(empty).toEqual([])})})++describe('dashboard table column types', () => {+ const args = {+ filename: 'types.html',+ data: {+ title: 'T',+ tables: [+ {+ headers: ['Item', 'Amount', 'Severity'],+ rows: [['a', '$5', 'high']],+ columnTypes: { Amount: 'currency', Severity: 'severity' },+ },+ ],+ },+ }++ it('shows a column of an unknown type as plain text, with a note, on the chat path', async () => {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'clerum-coltypes-'))+ try {+ const tool = INTERNAL_TOOLS.find(t => t.name === 'clerum__generate_dashboard')!+ const result = await tool.execute(args, dir)+ expect(result.success, result.error).toBe(true)+ expect(result.content).toContain('columnTypes["Amount"] "currency" is not a column type')+ const html = fs.readFileSync(result.artifact!.path, 'utf8')+ expect(html).toContain('severity-badge')+ } finally {+ fs.rmSync(dir, { recursive: true, force: true })+ }+ })++ it('accepts the same call on the workflow path, where the schema is enforced', async () => {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'clerum-coltypes-'))+ try {+ const { result } = await workflowRouter(dir).callTool(+ 'clerum__generate_dashboard',+ structuredClone(args)+ )+ expect(result.isError, JSON.stringify(result.content)).toBeFalsy()+ } finally {+ fs.rmSync(dir, { recursive: true, force: true })+ }+ })+})diff --git a/mcp-host/src/workflow/dashboardRender.ts b/mcp-host/src/workflow/dashboardRender.tsindex 7d440c254..2f8e1180b 100644--- a/mcp-host/src/workflow/dashboardRender.ts+++ b/mcp-host/src/workflow/dashboardRender.ts@@ -992,6 +992,7 @@ function renderChartCards(charts: unknown, where: string, ctx: DashRender, title}const BADGE_COLUMN_TYPES = new Set(['severity', 'priority', 'status'])+const COLUMN_TYPES = new Set(['plain', ...BADGE_COLUMN_TYPES])function dashSeverityClass(value: unknown): string {const v = String(value ?? '')@@ -1023,6 +1024,14 @@ function renderTableHtml(t: unknown, where: string, ctx: DashRender, title?: strthrow new Error(`${where}.headers must be a non-empty array of column names.`)}const colTypes = isDashRecord(table.columnTypes) ? table.columnTypes : {}+ for (const [column, type] of Object.entries(colTypes)) {+ if (!COLUMN_TYPES.has(String(type))) {+ ctx.warnings.push(+ `${where}.columnTypes[${JSON.stringify(column)}] ${JSON.stringify(type)} is not a column ` ++ 'type (plain, severity, priority, status), so that column shows as plain text.'+ )+ }+ }const headerNames = headers.map(headerText)const headerHtml = headerNames.map(h => `<th>${softBreaks(escapeHtml(h))}</th>`).join('')const rows = fitRowsToHeaders(@@ -1036,7 +1045,7 @@ function renderTableHtml(t: unknown, where: string, ctx: DashRender, title?: str.map(row => {const cells = row.map((cell, c) => {- const colType = colTypes[c] ?? colTypes[headerNames[c]]+ const colType = own(colTypes, String(c)) ?? own(colTypes, headerNames[c])if (cell !== null && typeof cell === 'object') structured++const text = tableCellText(cell)const cls = BADGE_COLUMN_TYPES.has(String(colType)) ? dashSeverityClass(text) : ''diff --git a/mcp-host/src/workflow/internalTools.ts b/mcp-host/src/workflow/internalTools.tsindex e5c738dbf..df47fb05a 100644--- a/mcp-host/src/workflow/internalTools.ts+++ b/mcp-host/src/workflow/internalTools.ts@@ -1047,17 +1047,15 @@ const DASH_TABLE_SCHEMA = {// one example key. additionalProperties, which Gemini's SDK drops, keeps// the other keys valid and marks the object as a map.properties: {- '0': {- type: 'string',- enum: ['plain', 'severity', 'priority', 'status'],- description: 'Column 0.',- },+ '0': { type: 'string', description: 'Column 0: plain, severity, priority or status.' },},- additionalProperties: { type: 'string', enum: ['plain', 'severity', 'priority', 'status'] },+ // A plain string, not an enum: an unknown type shows the column as plain+ // text with a note, the same on every path, as it did before types were listed.+ additionalProperties: { type: 'string' },description:- 'Badge columns: header or 0-based index to a type, e.g. {"Status": "severity"}. ' +- 'Values such as critical, high, medium, low, info, p0-p2, healthy, degraded, down ' +- 'then show as colored badges.',+ 'Badge columns: header or 0-based index to plain, severity, priority or status, e.g. ' ++ '{"Status": "severity"}. Values such as critical, high, medium, low, info, p0-p2, ' ++ 'healthy, degraded, down then show as colored badges.',},},}