Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): read a deck's palette and aspect ratio without regard to case
marcoteb948453522123
diff --git a/mcp-host/src/workflow/__tests__/internalTools.pptx.contract.test.ts b/mcp-host/src/workflow/__tests__/internalTools.pptx.contract.test.tsindex 58667c15b..60d725d65 100644--- a/mcp-host/src/workflow/__tests__/internalTools.pptx.contract.test.ts+++ b/mcp-host/src/workflow/__tests__/internalTools.pptx.contract.test.ts@@ -333,6 +333,35 @@ describe('clerum__generate_pptx — execute() answers malformed input by field',expect(result.error).toMatch(/slides\[0\]\.kpis\[0\]\.value/)})+ it('reads palette and aspectRatio without regard to case, as the other generators do', async () => {+ const result = await generatePptx(+ {+ filename: 'c.pptx',+ palette: 'Corporate',+ aspectRatio: '16X9',+ slides: [{ layout: 'section', title: 'x' }],+ },+ outputDir+ )+ expect(result.success, result.error).toBe(true)+ expect(result.content).not.toContain('is not one of')+ const file = path.join(outputDir, 'c.pptx')+ expect(zipEntryText(file, 'ppt/presentation.xml')).toContain('cx="9144000" cy="5143500"')+ // The corporate palette's primary color, not the default's.+ expect(slideXml(file, 1).toUpperCase()).toContain('1E3A8A')+ })++ it('names an unknown palette and uses the default', async () => {+ const result = await generatePptx(+ { filename: 'n.pptx', palette: 'neon', slides: [{ layout: 'section', title: 'x' }] },+ outputDir+ )+ expect(result.success, result.error).toBe(true)+ expect(result.content).toContain(+ 'palette "neon" is not one of default, corporate, warm, alert; "default" was used.'+ )+ })+it('refuses an unknown layout with the list of layouts instead of printing it on a slide', async () => {const result = await generatePptx({ filename: 'u.pptx', slides: [{ layout: 'bullets', title: 'x', bullets: ['a'] }] },diff --git a/mcp-host/src/workflow/pptxDeck.ts b/mcp-host/src/workflow/pptxDeck.tsindex e152ce6ef..f680578e7 100644--- a/mcp-host/src/workflow/pptxDeck.ts+++ b/mcp-host/src/workflow/pptxDeck.ts@@ -7,7 +7,7 @@* values shrink to fit their boxes, and pictures keep their proportions.*/import { documentEastAsianScript } from './docxScript'-import { own } from './ownEntry'+import { choose } from './ownEntry'import { type DrawContext, hex } from './pptxDraw'import {PptxInputError,@@ -29,23 +29,6 @@ import { keepZipTextWhole } from './zipText'const PptxGenJS = require('pptxgenjs')-function pick<T>(- table: Record<string, T>,- value: unknown,- fallback: string,- field: string,- warnings: string[]-): T {- if (value === undefined || value === null || value === '') return table[fallback]- const entry = typeof value === 'string' ? own(table, value) : undefined- if (entry) return entry- warnings.push(- `${field} ${JSON.stringify(value)} is not one of ${Object.keys(table).join(', ')}; ` +- `"${fallback}" was used.`- )- return table[fallback]-}-/** The slides `args` describe, from a template's data or from slides[]. */function readDeck(args: Record<string, unknown>, ctx: ReadContext): PptxSlide[] {const template = args.template ?? 'custom'@@ -91,8 +74,12 @@ export async function buildPptxDeck(): Promise<{ buffer: Buffer; slides: number }> {const ctx: ReadContext = { outputDir, warnings }const specs = readDeck(args, ctx)- const palette = pick(PPTX_PALETTES, args.palette, 'default', 'palette', warnings)- const aspect = pick(PPTX_ASPECT_RATIOS, args.aspectRatio, 'wide', 'aspectRatio', warnings)+ const palette =+ PPTX_PALETTES[choose(args.palette, Object.keys(PPTX_PALETTES), 'default', 'palette', warnings)]+ const aspect =+ PPTX_ASPECT_RATIOS[+ choose(args.aspectRatio, Object.keys(PPTX_ASPECT_RATIOS), 'wide', 'aspectRatio', warnings)+ ]if (args.branding !== undefined && args.branding !== null && !isRecord(args.branding)) {throw new PptxInputError('branding must be an object with companyName, logoPath and footerText.'