Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(mcp-host): build the attachment tests' chat registry in one place

marcoteb0dc25531682a
diff --git a/mcp-host/src/core/tools/__tests__/generatedArtifactAttachments.test.ts b/mcp-host/src/core/tools/__tests__/generatedArtifactAttachments.test.ts
index 68af9482f..4c2f98326 100644
--- a/mcp-host/src/core/tools/__tests__/generatedArtifactAttachments.test.ts
+++ b/mcp-host/src/core/tools/__tests__/generatedArtifactAttachments.test.ts
@@ -8,7 +8,6 @@ import { zipEntries } from '../../../workflow/__tests__/support/zipEntries'
import { INTERNAL_TOOLS } from '../../../workflow/internalTools'
import type { ArtifactMetadata } from '../../../workflow/types'
import { CALLER_OUTPUTS_DIR } from '../../../workspace/callerOutputs'
-import type { NativeToolConfig } from '../../interfaces'
import type { Attachment } from '../../types'
import {
INTERNAL_GENERATED_ARTIFACT_LANE,
@@ -82,6 +81,35 @@ describe('generated internal artifact attachments', () => {
fs.mkdirSync(callerRoot, { recursive: true })
})
+ /** A chat registry generating for the test caller, with `secretEntriesProvider`'s protected values. */
+ function chatRegistry(secretEntriesProvider?: () => Array<{ name: string; value: string }>) {
+ return new NativeToolRegistry(
+ {
+ workspacePath: outputDir,
+ shellTimeout: 5000,
+ toolTimeout: 60000,
+ toolProgressInterval: 30000,
+ httpAllowlist: [],
+ envAllowlist: ['PATH'],
+ memoryMaxSize: 1048576,
+ },
+ 'conv-1',
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ null,
+ { maxBytes: 52_428_800, secretEntriesProvider },
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ callerRoot
+ )
+ }
+
/** A file the chat generators wrote for the test caller. */
function generated(name: string): string {
return path.join(callerRoot, CALLER_OUTPUTS_DIR, name)
@@ -349,34 +377,7 @@ describe('generated internal artifact attachments', () => {
['a markdown link holding a reference', 'probe-[red&#97;ction](https://a.example)-value'],
['an image', 'probe-![redaction](missing.png)-value'],
])('does not attach a PDF that prints a secret split by %s', async (_label, body) => {
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => [{ name: 'PROBE_VALUE', value: 'probe-redaction-value' }],
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry(() => [{ name: 'PROBE_VALUE', value: 'probe-redaction-value' }])
const pdf = registry.get('clerum__generate_pdf')!
const leaked = await pdf.execute({ filename: 'split.pdf', body })
expect(leaked.is_error).toBe(false)
@@ -387,34 +388,7 @@ describe('generated internal artifact attachments', () => {
it('does not attach a document whose arguments hold a secret with a quote or a backslash', async () => {
const secret = 'probe"redac\\tion-value'
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => [{ name: 'PROBE_VALUE', value: secret }],
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry(() => [{ name: 'PROBE_VALUE', value: secret }])
const pdf = registry.get('clerum__generate_pdf')!
const leaked = await pdf.execute({ filename: 'quoted.pdf', body: `value: ${secret}` })
expect(leaked.is_error).toBe(false)
@@ -425,34 +399,7 @@ describe('generated internal artifact attachments', () => {
})
it('does not attach a DOCX whose table cell prints a secret a link splits', async () => {
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => [{ name: 'PROBE_VALUE', value: 'probe-redaction-value' }],
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry(() => [{ name: 'PROBE_VALUE', value: 'probe-redaction-value' }])
const docx = registry.get('clerum__generate_docx')!
const cell = 'probe-[redaction](https://a.example)-value'
const leaked = await docx.execute({
@@ -478,34 +425,7 @@ describe('generated internal artifact attachments', () => {
const protectedValue = 'probe-redaction-value'
function xlsxTool() {
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => [{ name: 'PROBE_VALUE', value: protectedValue }],
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry(() => [{ name: 'PROBE_VALUE', value: protectedValue }])
return registry.get('clerum__generate_xlsx')!
}
@@ -548,34 +468,7 @@ describe('generated internal artifact attachments', () => {
const protectedValue = '3141592653'
function tool(name: string) {
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => [{ name: 'PROBE_VALUE', value: protectedValue }],
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry(() => [{ name: 'PROBE_VALUE', value: protectedValue }])
return registry.get(name)!
}
@@ -643,33 +536,8 @@ describe('generated internal artifact attachments', () => {
describe('what a delivered file shows that its arguments never spelled', () => {
function toolWith(name: string, secrets: string[]) {
- const registry = new NativeToolRegistry(
- {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- },
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- {
- maxBytes: 52_428_800,
- secretEntriesProvider: () => secrets.map((value, i) => ({ name: `PROBE_${i}`, value })),
- },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
+ const registry = chatRegistry(() =>
+ secrets.map((value, i) => ({ name: `PROBE_${i}`, value }))
)
return registry.get(name)!
}
@@ -922,32 +790,7 @@ describe('generated internal artifact attachments', () => {
)
it('native internal tools return generated artifact attachments through the adapter', async () => {
- const config: NativeToolConfig = {
- workspacePath: outputDir,
- shellTimeout: 5000,
- toolTimeout: 60000,
- toolProgressInterval: 30000,
- httpAllowlist: [],
- envAllowlist: ['PATH'],
- memoryMaxSize: 1048576,
- }
- const registry = new NativeToolRegistry(
- config,
- 'conv-1',
- undefined,
- undefined,
- undefined,
- undefined,
- null,
- { maxBytes: 52_428_800 },
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- callerRoot
- )
+ const registry = chatRegistry()
const result = await registry.get('clerum__generate_markdown')!.execute({
filename: 'native-report.md',