feat: 升级至 v0.3.16 — 工单修复 51 项 + 审查修复 30 项(安全加固/适配器/工具系统/数据层/前端)

This commit is contained in:
2026-07-22 10:31:13 +08:00
parent 516d8a728f
commit 2c2ca4a692
43 changed files with 1454 additions and 301 deletions
+12 -7
View File
@@ -59,7 +59,8 @@ export class MimoAdapter extends BaseAdapter {
async send(request: MetonaRequest): Promise<MetonaResponse> {
const body = this.toNativeRequest(request, false);
const response = await fetch(`${this.config.baseURL}/chat/completions`, {
// #24 修复: 使用 fetchWithTimeout 替代 getFetchSignal + fetch,确保 timer 清理
const response = await this.fetchWithTimeout(`${this.config.baseURL}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -67,8 +68,7 @@ export class MimoAdapter extends BaseAdapter {
...this.config.headers,
},
body: JSON.stringify(body),
signal: this.getFetchSignal(this.config.timeoutMs ?? 120_000),
});
}, this.config.timeoutMs ?? 120_000);
if (!response.ok) {
await this.throwHttpError(response, 'MiMo API error');
@@ -98,7 +98,8 @@ export class MimoAdapter extends BaseAdapter {
async *sendStream(request: MetonaRequest): AsyncIterable<MetonaStreamEvent> {
const body = this.toNativeRequest(request, true);
const response = await fetch(`${this.config.baseURL}/chat/completions`, {
// #24 修复: 使用 fetchWithTimeout 替代 getFetchSignal + fetch,确保 timer 清理
const response = await this.fetchWithTimeout(`${this.config.baseURL}/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -106,8 +107,7 @@ export class MimoAdapter extends BaseAdapter {
...this.config.headers,
},
body: JSON.stringify(body),
signal: this.getFetchSignal(this.config.timeoutMs ?? 300_000),
});
}, this.config.timeoutMs ?? 300_000);
if (!response.ok || !response.body) {
await this.throwHttpError(response, 'MiMo stream error');
@@ -194,7 +194,12 @@ export class MimoAdapter extends BaseAdapter {
model: this.config.defaultModel,
messages,
// MiMo 使用 max_completion_tokens(非 max_tokens
max_completion_tokens: request.params.maxTokens,
// #41 修复: thinking 模式下 max_completion_tokens 未配置时使用兜底默认值(32768)
// thinking 占用 token 配额,未配置时 API 默认值可能过小导致输出被截断
// thinkingEnabled !== false 包含 true 和 undefinedMiMo 默认 enabled)两种情况
// 审查修复: 兜底值从 63488 改为 32768,避免超出标准版上限导致 API 400
max_completion_tokens: request.params.maxTokens
?? (request.params.thinkingEnabled !== false ? 32768 : undefined),
stream,
};