Files
agent-safe-middleware/plugins/file_read_log.lua
T
starrrLight 016c43f13e feat(插件): 读取附件正文并保留日志文本
新增附件读取测试插件并配置上传路径,记录文件名、提取状态及正文。所有插件日志保留参数和级别,按字节限制截断并转义换行,补充运行时和附件集成测试。
2026-10-16 14:38:03 +08:00

20 lines
652 B
Lua

-- 上传附件读取测试:通过 host.files 读取提取正文,不改写请求或文件。
-- 场景运行器追加 --verbose 即可显示 INFO 日志。
local plugin = {}
function plugin.on_request(ctx, request)
if request.kind ~= "multipart" then return {action = "pass"} end
for _, file in ipairs(request.files or {}) do
local text = host.files.read_text(file.id)
host.log.info(host.json.encode({
name = file.name,
extraction_status = file.extraction_status,
text_bytes = file.text_bytes,
text = text,
}))
end
return {action = "pass"}
end
return plugin