Files
agent-safe-middleware/config.yaml
T
starrrLight 8ad4b29e4c feat(附件): 增加请求级文本读取与上传代理
支持任意 POST 路径的 multipart 暂存、原始字节转发和 TXT、DOCX、DOC 文本提取;通过 host.files.read_text 提供请求内受限读取,禁止插件改写附件和上传正文。

增加附件数量、文本、解压、超时和读取次数限制,覆盖断开、异常及清理场景;补充依赖、LibreOffice 镜像安装和插件接口文档,不修改业务 Lua 插件。

验证:全量测试 128 通过、2 个既有失败、1 个跳过;既有失败为 test_example_redacts_cross_event_phone 和 test_network_example_uses_configuration_and_http_result,均缺少插件必填配置。Ruff 静态检查、改动文件格式检查、pip check 和差异检查通过;全仓格式检查保留两处既有问题。当前环境缺少 LibreOffice 和 Docker,真实 DOC 转换及镜像构建未验证。
2026-10-15 18:03:23 +08:00

71 lines
1.8 KiB
YAML

upstream: http://127.0.0.1:8000
listen_host: 0.0.0.0
listen_port: 8080
limits:
max_sessions: 4
hook_timeout_seconds: 5
upstream_timeout_seconds: 120
max_attachment_files: 8
max_attachment_fields: 128
max_attachment_text_bytes: 1048576
max_attachment_unpacked_bytes: 33554432
max_attachment_zip_entries: 2048
attachment_timeout_seconds: 10
max_attachment_reads: 64
llm:
- id: guard_model
type: guard
file: models/guard_model
load: {device: cuda}
limits:
max_input_tokens: 4096
max_new_tokens: 32
timeout_seconds: 30
queue_size: 8
plugins:
- id: network-review
file: plugins/network_review.lua
match:
paths: [/chat/stream]
network:
allow:
- domain: review.example.com # 本地联调改 mock-review.local
scheme: https
ports: [443]
timeout_seconds: 5
max_response_bytes: 1048576
config:
url: https://review.example.com/check # 本地联调改 http://mock-review.local:8001/check
fields: [messages]
headers: {x-api-key: "injected-by-admin"}
- id: response-guard
file: plugins/response_guard.lua
match:
paths: [/chat/stream]
llm: {allow: [guard_model]}
config:
model: guard_model # 必须与 llm 注册的 id 一致
content_path: content
- id: request-rewrite
file: plugins/request_rewrite.lua
match:
paths: [/chat/stream]
config:
prefix: "[checked] "
- id: stream-redact
file: plugins/stream_redact.lua
match:
paths: [/chat/stream]
config:
text_event: text_delta
content_path: content
terminal_error_events: [run_error]
control_event_names: [heartbeat, run_started, run_finished, run_error, run_completed]
max_buffer_bytes: 262144