Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): omit workspace entries that resolve to conversation-store files
Alfredo Lopez87864057e827
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 0eb4da2c9..3adbfcc75 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.568",+ "version": "0.1.569","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.568",+ "version": "0.1.569","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 9f86d9703..4442919a4 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.568",+ "version": "0.1.569","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/workspace/__tests__/conversationStoreFiles.test.ts b/mcp-host/src/workspace/__tests__/conversationStoreFiles.test.tsindex 0f88ef5a1..1dc79534a 100644--- a/mcp-host/src/workspace/__tests__/conversationStoreFiles.test.ts+++ b/mcp-host/src/workspace/__tests__/conversationStoreFiles.test.ts@@ -85,7 +85,12 @@ describe('conversation-store files are not agent-accessible', () => {const names = (await workspace.list()).map(e => e.name)// Witness: the listing has the ordinary files.expect(names).toEqual(expect.arrayContaining(['mystate.db.txt', 'notes.md']))- for (const p of STORE_FILES) expect(names).not.toContain(p)+ for (const p of PROTECTED) expect(names).not.toContain(p)++ const all = await workspace.listAll()+ // Witness: the recursive listing has the ordinary files.+ expect(all).toEqual(expect.arrayContaining(['mystate.db.txt', 'notes.md']))+ for (const p of PROTECTED) expect(all).not.toContain(p)const hits = (await workspace.search('needle')).map(r => r.path)// Witness: the same query finds the ordinary note.diff --git a/mcp-host/src/workspace/service.ts b/mcp-host/src/workspace/service.tsindex 399391df3..5c0401990 100644--- a/mcp-host/src/workspace/service.ts+++ b/mcp-host/src/workspace/service.ts@@ -306,6 +306,7 @@ export class WorkspaceService implements Workspace {return []}+ const realWorkspaceRoot = await fs.realpath(this.workspacePath)const results: WorkspaceEntry[] = []for (const entry of entries) {if (isProtectedWorkspacePath(entry.name)) continue@@ -313,6 +314,10 @@ export class WorkspaceService implements Workspace {if (!directory && this.options?.excludeDirs?.includes(entry.name)) continueconst entryPath = path.join(directory, entry.name).replace(/^\//, '')const absPath = path.join(resolved, entry.name)+ // A symlink with a harmless name can resolve to store data; the listing+ // omits it as read and write already deny it. A dangling link reaches no+ // file and stays listed.+ if (await this.resolvesToProtectedPath(absPath, realWorkspaceRoot)) continuelet size: number | undefinedlet modifiedAt: string | undefinedtry {@@ -333,6 +338,20 @@ export class WorkspaceService implements Workspace {return results}+ private async resolvesToProtectedPath(+ absPath: string,+ realWorkspaceRoot: string+ ): Promise<boolean> {+ let realPath: string+ try {+ realPath = await fs.realpath(absPath)+ } catch (err) {+ if ((err as NodeJS.ErrnoException).code === 'ENOENT') return false+ throw err+ }+ return isProtectedRealPath(realPath, realWorkspaceRoot)+ }+async listAll(): Promise<string[]> {const { searchWorkspace: collect } = await import('./search')// Reuse the internal file collector by doing a dummy search with empty result