Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): say when a DOCX list is nested deeper than Word allows
marcotebe488539c3912
diff --git a/mcp-host/src/workflow/__tests__/internalTools.docx.test.ts b/mcp-host/src/workflow/__tests__/internalTools.docx.test.tsindex ad04be39f..2cf5283c5 100644--- a/mcp-host/src/workflow/__tests__/internalTools.docx.test.ts+++ b/mcp-host/src/workflow/__tests__/internalTools.docx.test.ts@@ -310,6 +310,21 @@ describe('generate_docx lists', () => {expect(levels(two)).toEqual([0, 1, 2, 3, 4])})+ it('sets items past the ninth level at the ninth, and says so once', async () => {+ const body = Array.from({ length: 11 }, (_, i) => `${' '.repeat(i)}- L${i + 1}`).join('\n')+ const r = await generate({ body: `${body}\n\n${body}` })+ expect(r.success, r.error).toBe(true)+ const xml = zipEntryText(r.artifact!.path, 'word/document.xml')+ expect(levels(xml).slice(0, 11)).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8])+ expect(r.content!.match(/nested more than 9 levels deep/g)).toHaveLength(1)+ })++ it('says nothing about depth for a list within nine levels', async () => {+ const body = Array.from({ length: 9 }, (_, i) => `${' '.repeat(i)}- L${i + 1}`).join('\n')+ const r = await generate({ body })+ expect(r.content ?? '').not.toContain('levels deep')+ })+it('defines nine levels for both list kinds', async () => {const r = await generate({ body: '- a\n\n1. b' })const numbering = zipEntryText(r.artifact!.path, 'word/numbering.xml')diff --git a/mcp-host/src/workflow/docxMarkdown.ts b/mcp-host/src/workflow/docxMarkdown.tsindex a5f384148..df5928f68 100644--- a/mcp-host/src/workflow/docxMarkdown.ts+++ b/mcp-host/src/workflow/docxMarkdown.ts@@ -38,6 +38,10 @@ function blankParagraph(): Paragraph {return new Paragraph({ children: [new TextRun({ text: '' })] })}+const TOO_DEEP =+ `A list nested more than ${DOCX_LIST_LEVELS} levels deep was set at level ` ++ `${DOCX_LIST_LEVELS} from there down; Word lists have ${DOCX_LIST_LEVELS} levels.`+interface ListFrame {indent: numberordered: boolean@@ -89,6 +93,8 @@ function parseList(lines: string[], start: number, ctx: DocxBodyContext, out: Paif (!frame || (frame.indent < indent && stack.length < DOCX_LIST_LEVELS)) {frame = { indent, ordered, ...ctx.numbering.begin(ordered, number ?? 1) }stack.push(frame)+ } else if (frame.indent < indent && !ctx.warnings.includes(TOO_DEEP)) {+ ctx.warnings.push(TOO_DEEP)}frame.last = number