修复 smoke 全部过时用例并顺带修两处真 bug:messages 路由丢失 attachments(纯附件消息被 400、【系统通知】不再拼入),api_key/password 脱敏正则误伤空串值("" 变 ***");smoke 适配新建即 held 预留语义与平台名/模型id 唯一键;process.exit 改 exitCode 防跳过 finally 残留 mock/server 占端口;测试配置隔离 data_root;68/68 全过

This commit is contained in:
2026-09-06 08:21:49 +08:00
parent 548ce651f6
commit 120726b7fe
4 changed files with 31 additions and 20 deletions
+3 -2
View File
@@ -46,8 +46,9 @@ function maskKey(k) {
// 逐行掩码配置原文里的 api_key 值(设置页原文编辑器展示用)。
// 行格式如 ` api_key: sk-xxx` / ` api_key: "sk-xxx"` / ` - api_key: sk-xxx`(platforms.keys 列表项写法)。
// 值用 (.*) 而非 (.+?):允许空串(`api_key: ""`),否则引号可选组回退会把 `""` 误捕成值 `"` 而被掩码成 `***"`。
// 记录每行是否掩码,便于 restore 时按顺序还原未改动项。
const API_KEY_LINE = /^(\s*(?:-\s+)?api_key:\s*)(["']?)(.+?)\2\s*$/;
const API_KEY_LINE = /^(\s*(?:-\s+)?api_key:\s*)(["']?)(.*)\2\s*$/;
function maskApiKeys(text) {
if (!text) return text;
return text.split('\n').map(function (line) {
@@ -79,7 +80,7 @@ function restoreApiKeys(submitted, orig) {
// password 脱敏(思路同 api_key):auth.users 密码在原文编辑器里统一显示 ******。
// 行格式如 ` password: "xxx"` / ` password: xxx`(auth.users 列表项写法)。
const PASSWORD_LINE = /^(\s*(?:-\s+)?password:\s*)(["']?)(.+?)\2\s*$/;
const PASSWORD_LINE = /^(\s*(?:-\s+)?password:\s*)(["']?)(.*)\2\s*$/;
const PASSWORD_MASK = '******';
function maskPassword(p) { return p ? PASSWORD_MASK : ''; }
function maskPasswords(text) {
+7 -3
View File
@@ -37,12 +37,16 @@ function composeWithAttachments(content, attachments) {
router.post('/:id/messages', wrap((req, res) => {
const content = String((req.body && req.body.content) || '').trim();
if (!content) return res.status(400).json({ error: 'content 不能为空' });
// 附件告知:正文前拼【系统通知】行(见 composeWithAttachments 注释);纯附件消息(无正文)也合法。
const attachments = Array.isArray(req.body && req.body.attachments) && (req.body.attachments || []).length
? req.body.attachments : null;
const full = composeWithAttachments(content, attachments);
if (!full) return res.status(400).json({ error: 'content 与 attachments 不能同时为空' });
// deepThink:是否启用模型该「深度思考」参数(thinking_params 合并进上游请求体)
const deepThink = !!(req.body && req.body.deepThink);
const r = engine.postUserMessage(req.params.id, content, { deepThink });
const r = engine.postUserMessage(req.params.id, full, { deepThink });
log.info('msg', (req.user || '-') + ' ' + req.params.id + ' 用户消息(' + (r && r.delivered || '?') + '):' +
content.slice(0, 60).replace(/\s+/g, ' '));
full.slice(0, 60).replace(/\s+/g, ' '));
res.json(r);
}));