feat: add pluggable Excel analyst report guard
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
This commit is contained in:
@@ -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/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user