Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(host): exercise real attachment page wrappers
Alfredo Lopezdb798b1830bc
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 3d9a15dd4..d74aa345a 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.487",+ "version": "0.1.488","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.487",+ "version": "0.1.488","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex edc364693..cef9cdc9c 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.487",+ "version": "0.1.488","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/agent/__tests__/attachmentRead.approvalBudget.test.ts b/mcp-host/src/agent/__tests__/attachmentRead.approvalBudget.test.tsindex 3eef43873..61b23673e 100644--- a/mcp-host/src/agent/__tests__/attachmentRead.approvalBudget.test.ts+++ b/mcp-host/src/agent/__tests__/attachmentRead.approvalBudget.test.ts@@ -97,10 +97,10 @@ async function fixture(readInitially = true) {usage,finish_reason: FinishReason.ToolUse,tool_calls: [- ...((!resumed && readInitially) || requestReadAfterResume+ ...(readInitially || requestReadAfterResume? [{- id: resumed ? 'read-after' : 'read-first',+ id: 'read-first',name: 'clerum__attachment_read',arguments: { attachmentId: 'public-file' },},diff --git a/mcp-host/src/core/extensions/__tests__/prePrune.attachmentPageCollapse.test.ts b/mcp-host/src/core/extensions/__tests__/prePrune.attachmentPageCollapse.test.tsindex ab524cff0..9924015dd 100644--- a/mcp-host/src/core/extensions/__tests__/prePrune.attachmentPageCollapse.test.ts+++ b/mcp-host/src/core/extensions/__tests__/prePrune.attachmentPageCollapse.test.ts@@ -9,6 +9,7 @@*/import { describe, expect, it } from 'vitest'import { validateToolLinkages } from '../../orchestration/toolUseLoop'+import { BasicSafety } from '../../safety/safety'import type { ChatMessage } from '../../types'import {DEFAULT_PRE_PRUNE_OPTIONS,@@ -20,6 +21,7 @@ import * as prePruneModule from '../prePrune'const PAGE_TEXT = 'confidential page body '.repeat(200)const FILENAME = 'strategy-2027.md'+const safety = new BasicSafety()function userMsg(content: string): ChatMessage {return { role: 'user', content }@@ -46,7 +48,8 @@ function nativePage(overrides: Record<string, unknown> = {}): string {}function wrapped(content: string, toolName = 'clerum__attachment_read'): string {- return `<tool_output name="${toolName}" sanitized="true">\n${content}\n</tool_output>`+ // Exercise the exact pure wrapper used to measure and emit real tool output.+ return safety.previewOutputForLlm(toolName, content)}function stubMarker(): string {@@ -108,7 +111,7 @@ describe('C17 collapseEarlierAttachmentPages — direct pass', () => {const out = prePruneModule.collapseEarlierAttachmentPages(messages)expect(- out[2].content.startsWith('<tool_output name="clerum__attachment_read" sanitized="true">')+ out[2].content.startsWith('<tool_output name="clerum__attachment_read" sanitized="false">')).toBe(true)expect(out[2].content.endsWith('</tool_output>')).toBe(true)const inner = out[2].content.split('\n')[1]!@@ -142,6 +145,31 @@ describe('C17 collapseEarlierAttachmentPages — direct pass', () => {expect(() => validateToolLinkages(out)).not.toThrow()})+ it('keeps continuation metadata after a second pressured pre-prune of a real wrapper', () => {+ const messages = conversation()+ messages[2] = attachmentToolResult(+ 'tc_old',+ wrapped(+ nativePage({+ limit: 'page_budget',+ nextOffset: 65536,+ })+ )+ )++ const first = prePrune(messages, OPTIONS, PRESSURE_ON)+ const second = prePrune(first.messages, OPTIONS, PRESSURE_ON)+ expect(first.passesApplied).toContain('attachment_page_collapse')+ expect(second.messages[2]).toBe(first.messages[2])+ expect(second.messages[2].content.endsWith('</tool_output>')).toBe(true)+ const stub = JSON.parse(second.messages[2].content.split('\n')[1]!)+ expect(stub.byteRange).toEqual({ offset: 0, length: 65536 })+ expect(stub.limit).toBe('page_budget')+ expect(stub.nextOffset).toBe(65536)+ expect(stub.text).toBe(stubMarker())+ expect(() => validateToolLinkages(second.messages)).not.toThrow()+ })+it('does not start another turn when a tool supplies a synthetic image user message', () => {const messages = conversation()messages.push({ role: 'user', content: 'tool-supplied image', imageOrigin: 'tool_result' })