feat: add pluggable Excel analyst report guard
Memind CI / Test, build, and release guards (push) Has been cancelled

This commit is contained in:
john
2026-07-17 11:52:21 +08:00
parent 75b32d959c
commit 0c1c0c3b48
20 changed files with 2099 additions and 8 deletions
+38
View File
@@ -1,5 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import ExcelJS from 'exceljs';
import {
buildAttachmentPayload,
extractFileAttachmentsFromMessage,
@@ -54,3 +55,40 @@ test('buildAttachmentPayload injects extracted attachment text for agent executi
assert.match(text, /oa\/note\.txt/);
assert.equal(payload.userMessage.metadata.displayText, '请分析这份表格');
});
test('buildAttachmentPayload tells the agent to prefer dedicated tools for xlsx', async () => {
const workbook = new ExcelJS.Workbook();
workbook.addWorksheet('销售').addRow(['地区', '销售额']);
const xlsxBuffer = Buffer.from(await workbook.xlsx.writeBuffer());
const payload = await buildAttachmentPayload({
userId: 'user-1',
userMessage: {
metadata: {
displayText: '分析一下',
fileAttachments: [
{
assetId: 'asset-xlsx',
filename: 'sales.xlsx',
downloadUrl: '/api/mindspace/v1/assets/asset-xlsx/download',
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
},
],
},
content: [{ type: 'text', text: '分析一下' }],
},
fetchImpl: async () => {
throw new Error('use local asset');
},
localFetchAsset: async () => ({
buffer: xlsxBuffer,
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
}),
});
const text = payload.userMessage.content[0].text;
assert.match(text, /Excel 分析提示/);
assert.match(text, /excel_inspect \/ excel_analyze \/ excel_chart/);
assert.match(text, /excel_report/);
assert.match(text, /禁止用 write_file \/ edit_file 手工抄写数字/);
assert.match(text, /工作区路径: oa\/sales\.xlsx/);
});