minimal-agent 0.18.14 → 0.18.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/cli/wizards/providerPresets.js +30 -19
- package/src/cli/wizards/providerPresets.ts +30 -19
- package/src/config/reasoningEffort.js +3 -3
- package/src/config/reasoningEffort.ts +3 -3
- package/src/llm/client.js +2 -2
- package/src/llm/client.ts +1 -1
- package/src/llm/providers/anthropicFormat.js +3 -1
- package/src/llm/providers/anthropicFormat.ts +4 -1
- package/src/llm/providers/responsesFormat.js +3 -1
- package/src/llm/providers/responsesFormat.ts +3 -1
- package/src/runtime/commandCatalog.js +1 -0
- package/src/runtime/commandCatalog.ts +9 -0
- package/src/types.ts +1 -1
- package/src/ui/App.js +20 -1
- package/src/ui/App.tsx +25 -1
- package/src/ui/effortCommand.js +19 -0
- package/src/ui/effortCommand.ts +36 -0
- package/src/web/protocol.ts +1 -1
package/README.md
CHANGED
|
@@ -65,9 +65,9 @@ minimal-agent # 首次运行进入配置菜单(逐项配置,
|
|
|
65
65
|
必需三项 + 可选项:
|
|
66
66
|
|
|
67
67
|
```env
|
|
68
|
-
MINIMAL_AGENT_BASE_URL=https://api.minimax.
|
|
68
|
+
MINIMAL_AGENT_BASE_URL=https://api.minimax.cn/v1 # 必需:API 地址
|
|
69
69
|
MINIMAL_AGENT_API_KEY=your-api-key # 必需:API key
|
|
70
|
-
MINIMAL_AGENT_MODEL=MiniMax-
|
|
70
|
+
MINIMAL_AGENT_MODEL=MiniMax-M3.1-Flash # 必需:模型名
|
|
71
71
|
MINIMAL_AGENT_PROVIDER=minimax # 可选:友好名,默认 "env"
|
|
72
72
|
MINIMAL_AGENT_CONTEXT_WINDOW=204800 # 可选:上下文窗口,默认 128000
|
|
73
73
|
TAVILY_API_KEY= # 可选:WebSearch 工具用(https://tavily.com)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minimal-agent",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.15",
|
|
4
4
|
"description": "Bun-first 的本地 Agent 内核,支持工具、插件、工作流、上下文压缩、长期记忆与 OpenAI 兼容接口;Tauri 桌面宿主和 Node.js npm 发布可复用同一内核",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Bill Wang <leiwang0359@gmail.com>",
|
|
@@ -15,9 +15,12 @@ export const PRESETS = [
|
|
|
15
15
|
{
|
|
16
16
|
name: 'minimax',
|
|
17
17
|
label: 'MiniMax (海螺)',
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// 2026-10 按官方文档刷新:M3.1-Flash 是最新 M 系列(1M 上下文,effort 可调,省略时默认 max;
|
|
19
|
+
// 不支持关闭思考,effort:'none' 会 400);M2.x/M1/abab 已从文档下线。
|
|
20
|
+
baseURL: 'https://api.minimax.cn/v1/chat/completions',
|
|
21
|
+
models: ['MiniMax-M3.1-Flash', 'MiniMax-M3'],
|
|
22
|
+
contextWindow: 1_000_000,
|
|
23
|
+
supportsReasoningEffort: true,
|
|
21
24
|
},
|
|
22
25
|
{
|
|
23
26
|
// 火山方舟 ARK Coding Plan —— 一个 endpoint 后挂多个 model id,
|
|
@@ -53,9 +56,12 @@ export const PRESETS = [
|
|
|
53
56
|
{
|
|
54
57
|
name: 'deepseek',
|
|
55
58
|
label: 'DeepSeek',
|
|
59
|
+
// 2026-10:官方只列 deepseek-flash(V4.1-Flash)与 deepseek-v4-pro,两者 1M 上下文并认 reasoning_effort;
|
|
60
|
+
// deepseek-chat/deepseek-reasoner 旧名已不在文档里。
|
|
56
61
|
baseURL: 'https://api.deepseek.com/v1/chat/completions',
|
|
57
|
-
models: ['deepseek-
|
|
58
|
-
contextWindow:
|
|
62
|
+
models: ['deepseek-flash', 'deepseek-v4-pro'],
|
|
63
|
+
contextWindow: 1_000_000,
|
|
64
|
+
supportsReasoningEffort: true,
|
|
59
65
|
},
|
|
60
66
|
{
|
|
61
67
|
// OpenAI 当前主推的 Responses API(POST /v1/responses)。模型与推理强度都在请求体里,
|
|
@@ -63,8 +69,8 @@ export const PRESETS = [
|
|
|
63
69
|
name: 'openai-responses',
|
|
64
70
|
label: 'OpenAI(Responses API,推荐)',
|
|
65
71
|
baseURL: 'https://api.openai.com/v1/responses',
|
|
66
|
-
models: ['gpt-6.1-terra', 'gpt-
|
|
67
|
-
contextWindow:
|
|
72
|
+
models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
|
|
73
|
+
contextWindow: 1_050_000,
|
|
68
74
|
apiFormat: 'openai-responses',
|
|
69
75
|
supportsReasoningEffort: true,
|
|
70
76
|
reasoningEffort: 'medium',
|
|
@@ -74,34 +80,39 @@ export const PRESETS = [
|
|
|
74
80
|
name: 'openai',
|
|
75
81
|
label: 'OpenAI(Chat Completions)',
|
|
76
82
|
baseURL: 'https://api.openai.com/v1/chat/completions',
|
|
77
|
-
models: ['gpt-
|
|
78
|
-
contextWindow:
|
|
83
|
+
models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
|
|
84
|
+
contextWindow: 1_050_000,
|
|
79
85
|
supportsReasoningEffort: true,
|
|
80
86
|
},
|
|
81
87
|
{
|
|
82
88
|
name: 'openrouter',
|
|
83
89
|
label: 'OpenRouter',
|
|
84
90
|
baseURL: 'https://openrouter.ai/api/v1/chat/completions',
|
|
91
|
+
// 2026-10 取自 OpenRouter /api/v1/models 的最新条目(均约 1M 上下文)。
|
|
85
92
|
models: [
|
|
86
|
-
'openai/gpt-
|
|
87
|
-
'
|
|
88
|
-
'anthropic/claude-
|
|
89
|
-
'google/gemini-
|
|
93
|
+
'openai/gpt-6.1-terra',
|
|
94
|
+
'anthropic/claude-sonnet-5.5',
|
|
95
|
+
'anthropic/claude-opus-5.5',
|
|
96
|
+
'google/gemini-3.8-flash',
|
|
97
|
+
'moonshotai/kimi-k3.1-pro',
|
|
98
|
+
'deepseek/deepseek-v4.1-flash',
|
|
99
|
+
'minimax/minimax-m3.1-flash',
|
|
90
100
|
],
|
|
91
|
-
contextWindow:
|
|
101
|
+
contextWindow: 1_000_000,
|
|
92
102
|
reasoning: true,
|
|
93
103
|
},
|
|
94
104
|
{
|
|
95
105
|
name: 'moonshot',
|
|
96
106
|
label: 'Moonshot (Kimi)',
|
|
97
107
|
baseURL: 'https://api.moonshot.cn/v1/chat/completions',
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
// 2026-10:K3.1 Pro 是旗舰(1M 上下文,顶层 reasoning_effort 认 low/high/max,默认 max);
|
|
109
|
+
// moonshot-v1-* 旧型号已移除。
|
|
110
|
+
models: ['kimi-k3.1-pro', 'kimi-k3.1-pro-highspeed', 'kimi-k3', 'kimi-k2.7-code'],
|
|
111
|
+
contextWindow: 1_000_000,
|
|
100
112
|
promptCacheMode: 'session-key',
|
|
113
|
+
supportsReasoningEffort: true,
|
|
101
114
|
modelContextWindows: {
|
|
102
|
-
'
|
|
103
|
-
'moonshot-v1-32k': 32_000,
|
|
104
|
-
'moonshot-v1-128k': 128_000,
|
|
115
|
+
'kimi-k2.7-code': 262_144,
|
|
105
116
|
},
|
|
106
117
|
},
|
|
107
118
|
{
|
|
@@ -44,9 +44,12 @@ export const PRESETS: ProviderPreset[] = [
|
|
|
44
44
|
{
|
|
45
45
|
name: 'minimax',
|
|
46
46
|
label: 'MiniMax (海螺)',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
// 2026-10 按官方文档刷新:M3.1-Flash 是最新 M 系列(1M 上下文,effort 可调,省略时默认 max;
|
|
48
|
+
// 不支持关闭思考,effort:'none' 会 400);M2.x/M1/abab 已从文档下线。
|
|
49
|
+
baseURL: 'https://api.minimax.cn/v1/chat/completions',
|
|
50
|
+
models: ['MiniMax-M3.1-Flash', 'MiniMax-M3'],
|
|
51
|
+
contextWindow: 1_000_000,
|
|
52
|
+
supportsReasoningEffort: true,
|
|
50
53
|
},
|
|
51
54
|
{
|
|
52
55
|
// 火山方舟 ARK Coding Plan —— 一个 endpoint 后挂多个 model id,
|
|
@@ -82,9 +85,12 @@ export const PRESETS: ProviderPreset[] = [
|
|
|
82
85
|
{
|
|
83
86
|
name: 'deepseek',
|
|
84
87
|
label: 'DeepSeek',
|
|
88
|
+
// 2026-10:官方只列 deepseek-flash(V4.1-Flash)与 deepseek-v4-pro,两者 1M 上下文并认 reasoning_effort;
|
|
89
|
+
// deepseek-chat/deepseek-reasoner 旧名已不在文档里。
|
|
85
90
|
baseURL: 'https://api.deepseek.com/v1/chat/completions',
|
|
86
|
-
models: ['deepseek-
|
|
87
|
-
contextWindow:
|
|
91
|
+
models: ['deepseek-flash', 'deepseek-v4-pro'],
|
|
92
|
+
contextWindow: 1_000_000,
|
|
93
|
+
supportsReasoningEffort: true,
|
|
88
94
|
},
|
|
89
95
|
{
|
|
90
96
|
// OpenAI 当前主推的 Responses API(POST /v1/responses)。模型与推理强度都在请求体里,
|
|
@@ -92,8 +98,8 @@ export const PRESETS: ProviderPreset[] = [
|
|
|
92
98
|
name: 'openai-responses',
|
|
93
99
|
label: 'OpenAI(Responses API,推荐)',
|
|
94
100
|
baseURL: 'https://api.openai.com/v1/responses',
|
|
95
|
-
models: ['gpt-6.1-terra', 'gpt-
|
|
96
|
-
contextWindow:
|
|
101
|
+
models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
|
|
102
|
+
contextWindow: 1_050_000,
|
|
97
103
|
apiFormat: 'openai-responses',
|
|
98
104
|
supportsReasoningEffort: true,
|
|
99
105
|
reasoningEffort: 'medium',
|
|
@@ -103,34 +109,39 @@ export const PRESETS: ProviderPreset[] = [
|
|
|
103
109
|
name: 'openai',
|
|
104
110
|
label: 'OpenAI(Chat Completions)',
|
|
105
111
|
baseURL: 'https://api.openai.com/v1/chat/completions',
|
|
106
|
-
models: ['gpt-
|
|
107
|
-
contextWindow:
|
|
112
|
+
models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
|
|
113
|
+
contextWindow: 1_050_000,
|
|
108
114
|
supportsReasoningEffort: true,
|
|
109
115
|
},
|
|
110
116
|
{
|
|
111
117
|
name: 'openrouter',
|
|
112
118
|
label: 'OpenRouter',
|
|
113
119
|
baseURL: 'https://openrouter.ai/api/v1/chat/completions',
|
|
120
|
+
// 2026-10 取自 OpenRouter /api/v1/models 的最新条目(均约 1M 上下文)。
|
|
114
121
|
models: [
|
|
115
|
-
'openai/gpt-
|
|
116
|
-
'
|
|
117
|
-
'anthropic/claude-
|
|
118
|
-
'google/gemini-
|
|
122
|
+
'openai/gpt-6.1-terra',
|
|
123
|
+
'anthropic/claude-sonnet-5.5',
|
|
124
|
+
'anthropic/claude-opus-5.5',
|
|
125
|
+
'google/gemini-3.8-flash',
|
|
126
|
+
'moonshotai/kimi-k3.1-pro',
|
|
127
|
+
'deepseek/deepseek-v4.1-flash',
|
|
128
|
+
'minimax/minimax-m3.1-flash',
|
|
119
129
|
],
|
|
120
|
-
contextWindow:
|
|
130
|
+
contextWindow: 1_000_000,
|
|
121
131
|
reasoning: true,
|
|
122
132
|
},
|
|
123
133
|
{
|
|
124
134
|
name: 'moonshot',
|
|
125
135
|
label: 'Moonshot (Kimi)',
|
|
126
136
|
baseURL: 'https://api.moonshot.cn/v1/chat/completions',
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
// 2026-10:K3.1 Pro 是旗舰(1M 上下文,顶层 reasoning_effort 认 low/high/max,默认 max);
|
|
138
|
+
// moonshot-v1-* 旧型号已移除。
|
|
139
|
+
models: ['kimi-k3.1-pro', 'kimi-k3.1-pro-highspeed', 'kimi-k3', 'kimi-k2.7-code'],
|
|
140
|
+
contextWindow: 1_000_000,
|
|
129
141
|
promptCacheMode: 'session-key',
|
|
142
|
+
supportsReasoningEffort: true,
|
|
130
143
|
modelContextWindows: {
|
|
131
|
-
'
|
|
132
|
-
'moonshot-v1-32k': 32_000,
|
|
133
|
-
'moonshot-v1-128k': 128_000,
|
|
144
|
+
'kimi-k2.7-code': 262_144,
|
|
134
145
|
},
|
|
135
146
|
},
|
|
136
147
|
{
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* 独立成文件是因为 Desktop 的浏览器端经 `minimal-agent/provider-presets` 引用它:
|
|
5
5
|
* 放在 configFile.ts 里会把 node:fs 等整串依赖拖进前端包。
|
|
6
6
|
*
|
|
7
|
-
* 不同模型认的档位不同(有的没有 none/minimal,有的才有 xhigh
|
|
8
|
-
*
|
|
7
|
+
* 不同模型认的档位不同(有的没有 none/minimal,有的才有 xhigh/max;MiniMax M3.1 只认
|
|
8
|
+
* low~max 且不允许 none,Kimi K3.1 只认 low/high/max),所以这里只收「各家文档出现过的全部取值」,具体某个模型接不接受由服务端裁决:被拒绝时 client.ts 会去掉
|
|
9
9
|
* 该参数重发一次并告警,而不是让整个对话 400。
|
|
10
10
|
*/
|
|
11
|
-
export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh'];
|
|
11
|
+
export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
12
12
|
export function normalizeReasoningEffort(value) {
|
|
13
13
|
return typeof value === 'string' && REASONING_EFFORTS.includes(value)
|
|
14
14
|
? value
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* 独立成文件是因为 Desktop 的浏览器端经 `minimal-agent/provider-presets` 引用它:
|
|
5
5
|
* 放在 configFile.ts 里会把 node:fs 等整串依赖拖进前端包。
|
|
6
6
|
*
|
|
7
|
-
* 不同模型认的档位不同(有的没有 none/minimal,有的才有 xhigh
|
|
8
|
-
*
|
|
7
|
+
* 不同模型认的档位不同(有的没有 none/minimal,有的才有 xhigh/max;MiniMax M3.1 只认
|
|
8
|
+
* low~max 且不允许 none,Kimi K3.1 只认 low/high/max),所以这里只收「各家文档出现过的全部取值」,具体某个模型接不接受由服务端裁决:被拒绝时 client.ts 会去掉
|
|
9
9
|
* 该参数重发一次并告警,而不是让整个对话 400。
|
|
10
10
|
*/
|
|
11
|
-
export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh'] as const;
|
|
11
|
+
export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'] as const;
|
|
12
12
|
export type ReasoningEffort = (typeof REASONING_EFFORTS)[number];
|
|
13
13
|
|
|
14
14
|
export function normalizeReasoningEffort(value: unknown): ReasoningEffort | undefined {
|
package/src/llm/client.js
CHANGED
|
@@ -310,8 +310,7 @@ async function* streamLocal(args) {
|
|
|
310
310
|
provider.maxTokens > 0 &&
|
|
311
311
|
!maxTokensUnsupported.has(rfKey);
|
|
312
312
|
let imagesStripped = false;
|
|
313
|
-
let wantReasoningEffort =
|
|
314
|
-
!!provider.reasoningEffort &&
|
|
313
|
+
let wantReasoningEffort = !!provider.reasoningEffort &&
|
|
315
314
|
!reasoningEffortUnsupported.has(rfKey);
|
|
316
315
|
let wantPromptCacheKey = format !== 'anthropic' &&
|
|
317
316
|
provider.promptCache?.mode === 'session-key' &&
|
|
@@ -341,6 +340,7 @@ async function* streamLocal(args) {
|
|
|
341
340
|
provider,
|
|
342
341
|
cleanedMessages,
|
|
343
342
|
tools,
|
|
343
|
+
withReasoningEffort: wantReasoningEffort,
|
|
344
344
|
...(cacheEdits ? { cacheEdits } : {}),
|
|
345
345
|
})
|
|
346
346
|
: format === 'openai-responses'
|
package/src/llm/client.ts
CHANGED
|
@@ -434,7 +434,6 @@ async function* streamLocal(args: {
|
|
|
434
434
|
!maxTokensUnsupported.has(rfKey);
|
|
435
435
|
let imagesStripped = false;
|
|
436
436
|
let wantReasoningEffort =
|
|
437
|
-
format !== 'anthropic' &&
|
|
438
437
|
!!provider.reasoningEffort &&
|
|
439
438
|
!reasoningEffortUnsupported.has(rfKey);
|
|
440
439
|
let wantPromptCacheKey =
|
|
@@ -471,6 +470,7 @@ async function* streamLocal(args: {
|
|
|
471
470
|
provider,
|
|
472
471
|
cleanedMessages,
|
|
473
472
|
tools,
|
|
473
|
+
withReasoningEffort: wantReasoningEffort,
|
|
474
474
|
...(cacheEdits ? { cacheEdits } : {}),
|
|
475
475
|
})
|
|
476
476
|
: format === 'openai-responses'
|
|
@@ -140,7 +140,7 @@ export function buildAnthropicUrl(provider) {
|
|
|
140
140
|
return url;
|
|
141
141
|
}
|
|
142
142
|
export function buildAnthropicRequest(args) {
|
|
143
|
-
const { provider, cleanedMessages, tools, cacheEdits } = args;
|
|
143
|
+
const { provider, cleanedMessages, tools, cacheEdits, withReasoningEffort } = args;
|
|
144
144
|
const { system, messages } = toAnthropicMessages(cleanedMessages);
|
|
145
145
|
const anthropicTools = toAnthropicTools(tools);
|
|
146
146
|
if (cacheEdits)
|
|
@@ -158,6 +158,8 @@ export function buildAnthropicRequest(args) {
|
|
|
158
158
|
// tools: [] 会被部分 provider 拒绝或产生意外行为——空数组直接不发这个字段。
|
|
159
159
|
if (anthropicTools.length > 0)
|
|
160
160
|
body.tools = anthropicTools;
|
|
161
|
+
if (withReasoningEffort && provider.reasoningEffort)
|
|
162
|
+
body.output_config = { effort: provider.reasoningEffort };
|
|
161
163
|
return {
|
|
162
164
|
url: buildAnthropicUrl(provider),
|
|
163
165
|
headers: {
|
|
@@ -160,10 +160,12 @@ export interface AnthropicRequestArgs {
|
|
|
160
160
|
* 传入即进入协议组装:pinned 重发 + pendingNew 发送并 pin + cache_reference 标注。
|
|
161
161
|
*/
|
|
162
162
|
cacheEdits?: CacheEditsState;
|
|
163
|
+
/** 发送 provider.reasoningEffort(Anthropic 兼容端点认 output_config.effort;被拒绝过的由 client.ts 关掉)。 */
|
|
164
|
+
withReasoningEffort?: boolean;
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
export function buildAnthropicRequest(args: AnthropicRequestArgs): { url: string; headers: Record<string, string>; body: string } {
|
|
166
|
-
const { provider, cleanedMessages, tools, cacheEdits } = args;
|
|
168
|
+
const { provider, cleanedMessages, tools, cacheEdits, withReasoningEffort } = args;
|
|
167
169
|
const { system, messages } = toAnthropicMessages(cleanedMessages);
|
|
168
170
|
const anthropicTools = toAnthropicTools(tools);
|
|
169
171
|
if (cacheEdits) applyCacheEdits(messages, cacheEdits);
|
|
@@ -179,6 +181,7 @@ export function buildAnthropicRequest(args: AnthropicRequestArgs): { url: string
|
|
|
179
181
|
};
|
|
180
182
|
// tools: [] 会被部分 provider 拒绝或产生意外行为——空数组直接不发这个字段。
|
|
181
183
|
if (anthropicTools.length > 0) body.tools = anthropicTools;
|
|
184
|
+
if (withReasoningEffort && provider.reasoningEffort) body.output_config = { effort: provider.reasoningEffort };
|
|
182
185
|
return {
|
|
183
186
|
url: buildAnthropicUrl(provider),
|
|
184
187
|
headers: {
|
|
@@ -142,9 +142,11 @@ export function isReasoningEffortRejected(status, errText) {
|
|
|
142
142
|
if (status !== 400 && status !== 422)
|
|
143
143
|
return false;
|
|
144
144
|
const text = errText.toLowerCase();
|
|
145
|
-
|
|
145
|
+
// MiniMax 对 effort:'none' 回 `requires adaptive thinking`;Anthropic 兼容端点的字段叫 output_config.effort。
|
|
146
|
+
if (!text.includes('reasoning') && !text.includes('effort') && !text.includes('adaptive thinking'))
|
|
146
147
|
return false;
|
|
147
148
|
return (text.includes('not support') ||
|
|
149
|
+
text.includes('requires') ||
|
|
148
150
|
text.includes('unsupported') ||
|
|
149
151
|
text.includes('invalid') ||
|
|
150
152
|
text.includes('not valid') ||
|
|
@@ -171,9 +171,11 @@ export function buildResponsesRequest(args: ResponsesRequestArgs): {
|
|
|
171
171
|
export function isReasoningEffortRejected(status: number, errText: string): boolean {
|
|
172
172
|
if (status !== 400 && status !== 422) return false;
|
|
173
173
|
const text = errText.toLowerCase();
|
|
174
|
-
|
|
174
|
+
// MiniMax 对 effort:'none' 回 `requires adaptive thinking`;Anthropic 兼容端点的字段叫 output_config.effort。
|
|
175
|
+
if (!text.includes('reasoning') && !text.includes('effort') && !text.includes('adaptive thinking')) return false;
|
|
175
176
|
return (
|
|
176
177
|
text.includes('not support') ||
|
|
178
|
+
text.includes('requires') ||
|
|
177
179
|
text.includes('unsupported') ||
|
|
178
180
|
text.includes('invalid') ||
|
|
179
181
|
text.includes('not valid') ||
|
|
@@ -34,6 +34,7 @@ export function descriptor(id, slash, title, description, category, requiresWork
|
|
|
34
34
|
const TERMINAL = [
|
|
35
35
|
descriptor('workspaces', '/workspaces', '工作目录', '选择或切换工作目录', 'context', false),
|
|
36
36
|
descriptor('model', '/model', '选择模型', '选择本机或已授权在线模型', 'system', false, '[模型 ID]'),
|
|
37
|
+
descriptor('effort', '/effort', '思考强度', '切换当前会话的推理强度(low/medium/high/xhigh/max,auto 沿用模型默认)', 'system', false, '[档位|auto]'),
|
|
37
38
|
descriptor('login', '/login', '登录', '打开浏览器登录账号', 'system', false),
|
|
38
39
|
descriptor('logout', '/logout', '退出登录', '退出账号并回退本机模型', 'system', false),
|
|
39
40
|
descriptor('login-status', '/login status', '账号状态', '查看账号连接状态', 'system', false),
|
|
@@ -180,6 +180,15 @@ const TERMINAL: CommandDescriptor[] = [
|
|
|
180
180
|
false,
|
|
181
181
|
'[模型 ID]',
|
|
182
182
|
),
|
|
183
|
+
descriptor(
|
|
184
|
+
'effort',
|
|
185
|
+
'/effort',
|
|
186
|
+
'思考强度',
|
|
187
|
+
'切换当前会话的推理强度(low/medium/high/xhigh/max,auto 沿用模型默认)',
|
|
188
|
+
'system',
|
|
189
|
+
false,
|
|
190
|
+
'[档位|auto]',
|
|
191
|
+
),
|
|
183
192
|
descriptor('login', '/login', '登录', '打开浏览器登录账号', 'system', false),
|
|
184
193
|
descriptor(
|
|
185
194
|
'logout',
|
package/src/types.ts
CHANGED
|
@@ -835,7 +835,7 @@ interface ProviderCommon {
|
|
|
835
835
|
* `reasoning_effort`(OpenRouter 发 `reasoning.effort`)。缺省不发送,沿用服务端默认。
|
|
836
836
|
* 模型不认该档位时 client.ts 去掉参数重发一次,不让对话 400。
|
|
837
837
|
*/
|
|
838
|
-
reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
838
|
+
reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
839
839
|
promptCache?: PromptCacheConfig;
|
|
840
840
|
|
|
841
841
|
/**
|
package/src/ui/App.js
CHANGED
|
@@ -33,6 +33,7 @@ import { InputBox } from './InputBox.js';
|
|
|
33
33
|
import { LiveArea } from './LiveArea.js';
|
|
34
34
|
import { MessageList } from './MessageList.js';
|
|
35
35
|
import { ModelPicker } from './ModelPicker.js';
|
|
36
|
+
import { effortChoicesText, parseEffortCommand } from './effortCommand.js';
|
|
36
37
|
import { QueuedMessagesBanner } from './QueuedMessagesBanner.js';
|
|
37
38
|
import { SessionPicker } from './SessionPicker.js';
|
|
38
39
|
import { StatusLine } from './StatusLine.js';
|
|
@@ -803,6 +804,24 @@ export function App({ provider, initialHistory }) {
|
|
|
803
804
|
return;
|
|
804
805
|
}
|
|
805
806
|
}
|
|
807
|
+
// /effort [档位|auto] —— 只改当前 Session 的推理强度(不写回配置,与 /model 同语义)。
|
|
808
|
+
const effortCommand = parseEffortCommand(trimmed);
|
|
809
|
+
if (effortCommand.matched) {
|
|
810
|
+
const current = chat.getCurrentProvider();
|
|
811
|
+
if (effortCommand.action === 'show') {
|
|
812
|
+
chat.ephemeralLine(`[/effort] 当前 ${current.model} 的推理强度:${current.reasoningEffort ?? '未设置(服务端默认)'}\n` +
|
|
813
|
+
` 用法:/effort <${effortChoicesText()}>;各模型接受的档位不同,不被接受时会自动去掉该参数并告警。`);
|
|
814
|
+
}
|
|
815
|
+
else if (effortCommand.action === 'invalid') {
|
|
816
|
+
chat.ephemeralLine(`[/effort] 不认识 "${effortCommand.input}",可选:${effortChoicesText()}`);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
const { reasoningEffort: _previous, ...rest } = current;
|
|
820
|
+
chat.setProvider(effortCommand.effort ? { ...rest, reasoningEffort: effortCommand.effort } : rest);
|
|
821
|
+
chat.ephemeralLine(`[/effort] 当前 Session 的推理强度已设为 ${effortCommand.effort ?? '未设置(服务端默认)'},下一轮对话生效。`);
|
|
822
|
+
}
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
806
825
|
const modelArgMatch = /^\/model(?:\s+(.+))?$/.exec(trimmed);
|
|
807
826
|
if (modelArgMatch) {
|
|
808
827
|
const arg = modelArgMatch[1]?.trim();
|
|
@@ -979,7 +998,7 @@ export function App({ provider, initialHistory }) {
|
|
|
979
998
|
if (!drafts.current.has(draftKey))
|
|
980
999
|
drafts.current.set(draftKey, { current: { text: '', cursor: 0 } });
|
|
981
1000
|
const advisorLabel = !advisorStatus.configured ? '未配置' : !advisorStatus.enabled ? '已关闭' : advisorStatus.mode === 'manual' ? '仅手动' : '自动启用';
|
|
982
|
-
const bannerText = `minimal-agent · ${currentProvider.name}/${currentProvider.model} · /model 切模型 · /computer 控制桌面 · /copy 复制回复 · /paste-image 添加图片 · /new 清空 · /compact 压缩 · Ctrl+C 中断`;
|
|
1001
|
+
const bannerText = `minimal-agent · ${currentProvider.name}/${currentProvider.model} · /model 切模型 · /effort 思考强度 · /computer 控制桌面 · /copy 复制回复 · /paste-image 添加图片 · /new 清空 · /compact 压缩 · Ctrl+C 中断`;
|
|
983
1002
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: chat.history, compactGeneration: chat.compactGeneration, bannerText: `${bannerText} · 顾问:${advisorLabel}(/advisor status)`, terminalRows: terminalRows }), _jsxs(Box, { flexDirection: "column", width: Math.max(1, terminalCols - 1), children: [!configMenuOpen && !baseModelPicker && !advisorModelPicker && !workspacePicker && !sessionPicker && !chat.pendingAsk && _jsx(LiveArea, { progressStage: chat.progressStage, reasoningPreview: chat.reasoningPreview, streamingText: chat.streamingText, runningTools: chat.runningTools, pluginProgress: chat.pluginProgress, transientError: chat.transientError, progressNotice: chat.progressNotice, terminalCols: terminalCols, terminalRows: terminalRows, reservedRows: chromeRows + 3 }), _jsxs(Box, { flexDirection: "column", ref: chromeRef, children: [_jsx(QueuedMessagesBanner, { items: chat.queuedItems }), chat.pendingComputerIntervention && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.warning, paddingX: 1, marginBottom: 1, children: [_jsxs(Text, { color: theme.warning, children: ["\u9700\u8981\u4EBA\u5DE5\u64CD\u4F5C\uFF1A", chat.pendingComputerIntervention.sanitizedSummary] }), _jsx(Text, { dimColor: true, children: "\u8BF7\u76F4\u63A5\u5728\u76EE\u6807\u5E94\u7528\u4E2D\u5904\u7406\uFF1B\u654F\u611F\u5185\u5BB9\u4E0D\u4F1A\u8FDB\u5165\u7EC8\u7AEF\u6216\u6A21\u578B\u3002\u5B8C\u6210\u540E\u8F93\u5165 /computer resume\uFF0C\u53D6\u6D88\u8F93\u5165 /computer cancel\u3002" })] })), chat.error && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: theme.error, wrap: "truncate-end", children: ["\u26A0 ", terminalText(chat.error)] }) })), chat.interrupted && (_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: theme.warning, children: "\u26A1 \u64CD\u4F5C\u88AB\u7528\u6237\u4E2D\u65AD\uFF0C\u7B49\u5F85\u65B0\u7684\u4EFB\u52A1\u8F93\u5165..." }), _jsxs(Text, { dimColor: true, children: [' ', "\u8C03\u6574\u4E0A\u4E00\u6B21\u8BA1\u5212\uFF1A\u76F4\u63A5\u8BF4\u8C03\u6574\u5185\u5BB9 / \u91CD\u65B0\u8DD1 /workflow plan \u76EE\u6807 / \u65B0\u4EFB\u52A1\u76F4\u63A5\u8BF4"] })] })), configMenuOpen ? (_jsx(ConfigMenu, { mode: "reconfigure", onDone: () => setConfigMenuOpen(false) })) : baseModelPicker ? (_jsx(ModelPicker, { models: baseModelPicker.models, currentModelId: baseModelPicker.currentId, title: "\u9009\u62E9\u57FA\u5EA7\u6A21\u578B", onSelect: handleBaseModelSelect, onCancel: () => setBaseModelPicker(null) })) : advisorModelPicker ? (_jsx(ModelPicker, { models: advisorModelPicker.models, currentModelId: advisorModelPicker.currentId, title: "\u9009\u62E9\u987E\u95EE\u6A21\u578B", nullOptionLabel: "\u25CB \u4E0D\u4F7F\u7528\u987E\u95EE\u6A21\u578B", onSelect: handleAdvisorModelSelect, onCancel: () => setAdvisorModelPicker(null) })) : workspacePicker ? (_jsx(WorkspacePicker, { workspaces: workspacePicker, currentPath: getWorkingDir(), currentSessionId: chat.activeSessionId, onSelect: handleWorkspaceSelect, onCancel: () => setWorkspacePicker(null) })) : sessionPicker ? (_jsx(SessionPicker, { sessions: sessionPicker, activeSessionId: chat.activeSessionId, onSelect: handleSessionSelect, onCreate: handleSessionCreate, onCancel: () => setSessionPicker(null) })) : chat.pendingAsk ? (_jsx(AskQuestion, { questions: chat.pendingAsk, source: chat.pendingAskSource, queuedCount: chat.pendingAskQueueCount, onAnswer: chat.answerAsk, onCancel: chat.cancelAsk })) : (
|
|
984
1003
|
/* handleSubmit 包装做 slash 命令拦截,非命令透传 chat.submit */
|
|
985
1004
|
_jsx(InputBox, { draft: drafts.current.get(draftKey), onHeight: setInputRows, onSubmit: handleSubmit, disabled: chat.isLoading && !chat.pendingComputerIntervention, onAbort: chat.abort, onClear: handleClear, onCompact: chat.compactNow, onWorkspaces: openWorkspacePicker }, draftKey)), _jsx(StatusLine, { provider: currentProvider, history: chat.history, pluginProgress: chat.pluginProgress, contextUsage: chat.contextUsage })] })] })] }));
|
package/src/ui/App.tsx
CHANGED
|
@@ -56,6 +56,7 @@ import { InputBox } from './InputBox.js';
|
|
|
56
56
|
import { LiveArea } from './LiveArea.js';
|
|
57
57
|
import { MessageList } from './MessageList.js';
|
|
58
58
|
import { ModelPicker } from './ModelPicker.js';
|
|
59
|
+
import { effortChoicesText, parseEffortCommand } from './effortCommand.js';
|
|
59
60
|
import type { PickerModel } from './ModelPicker.js';
|
|
60
61
|
import { QueuedMessagesBanner } from './QueuedMessagesBanner.js';
|
|
61
62
|
import { SessionPicker } from './SessionPicker.js';
|
|
@@ -1013,6 +1014,29 @@ export function App({ provider, initialHistory }: Props): JSX.Element {
|
|
|
1013
1014
|
}
|
|
1014
1015
|
}
|
|
1015
1016
|
|
|
1017
|
+
// /effort [档位|auto] —— 只改当前 Session 的推理强度(不写回配置,与 /model 同语义)。
|
|
1018
|
+
const effortCommand = parseEffortCommand(trimmed);
|
|
1019
|
+
if (effortCommand.matched) {
|
|
1020
|
+
const current = chat.getCurrentProvider();
|
|
1021
|
+
if (effortCommand.action === 'show') {
|
|
1022
|
+
chat.ephemeralLine(
|
|
1023
|
+
`[/effort] 当前 ${current.model} 的推理强度:${current.reasoningEffort ?? '未设置(服务端默认)'}\n` +
|
|
1024
|
+
` 用法:/effort <${effortChoicesText()}>;各模型接受的档位不同,不被接受时会自动去掉该参数并告警。`,
|
|
1025
|
+
);
|
|
1026
|
+
} else if (effortCommand.action === 'invalid') {
|
|
1027
|
+
chat.ephemeralLine(`[/effort] 不认识 "${effortCommand.input}",可选:${effortChoicesText()}`);
|
|
1028
|
+
} else {
|
|
1029
|
+
const { reasoningEffort: _previous, ...rest } = current;
|
|
1030
|
+
chat.setProvider(
|
|
1031
|
+
effortCommand.effort ? { ...rest, reasoningEffort: effortCommand.effort } : rest,
|
|
1032
|
+
);
|
|
1033
|
+
chat.ephemeralLine(
|
|
1034
|
+
`[/effort] 当前 Session 的推理强度已设为 ${effortCommand.effort ?? '未设置(服务端默认)'},下一轮对话生效。`,
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1016
1040
|
const modelArgMatch = /^\/model(?:\s+(.+))?$/.exec(trimmed);
|
|
1017
1041
|
if (modelArgMatch) {
|
|
1018
1042
|
const arg = modelArgMatch[1]?.trim();
|
|
@@ -1232,7 +1256,7 @@ export function App({ provider, initialHistory }: Props): JSX.Element {
|
|
|
1232
1256
|
const draftKey = `${getWorkingDir()}\0${chat.activeSessionId}`;
|
|
1233
1257
|
if (!drafts.current.has(draftKey)) drafts.current.set(draftKey, { current: { text: '', cursor: 0 } });
|
|
1234
1258
|
const advisorLabel = !advisorStatus.configured ? '未配置' : !advisorStatus.enabled ? '已关闭' : advisorStatus.mode === 'manual' ? '仅手动' : '自动启用';
|
|
1235
|
-
const bannerText = `minimal-agent · ${currentProvider.name}/${currentProvider.model} · /model 切模型 · /computer 控制桌面 · /copy 复制回复 · /paste-image 添加图片 · /new 清空 · /compact 压缩 · Ctrl+C 中断`;
|
|
1259
|
+
const bannerText = `minimal-agent · ${currentProvider.name}/${currentProvider.model} · /model 切模型 · /effort 思考强度 · /computer 控制桌面 · /copy 复制回复 · /paste-image 添加图片 · /new 清空 · /compact 压缩 · Ctrl+C 中断`;
|
|
1236
1260
|
|
|
1237
1261
|
return (
|
|
1238
1262
|
<Box flexDirection="column">
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { REASONING_EFFORTS } from '../config/reasoningEffort.js';
|
|
2
|
+
const CLEAR_WORDS = new Set(['auto', 'default', 'unset', 'reset']);
|
|
3
|
+
export function parseEffortCommand(input) {
|
|
4
|
+
const match = /^\/effort(?:\s+(\S+))?\s*$/i.exec(input.trim());
|
|
5
|
+
if (!match)
|
|
6
|
+
return { matched: false };
|
|
7
|
+
const arg = match[1]?.toLowerCase();
|
|
8
|
+
if (!arg)
|
|
9
|
+
return { matched: true, action: 'show' };
|
|
10
|
+
if (CLEAR_WORDS.has(arg))
|
|
11
|
+
return { matched: true, action: 'set', effort: null };
|
|
12
|
+
if (REASONING_EFFORTS.includes(arg)) {
|
|
13
|
+
return { matched: true, action: 'set', effort: arg };
|
|
14
|
+
}
|
|
15
|
+
return { matched: true, action: 'invalid', input: arg };
|
|
16
|
+
}
|
|
17
|
+
export function effortChoicesText() {
|
|
18
|
+
return `${REASONING_EFFORTS.join(' / ')} / auto`;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { REASONING_EFFORTS, type ReasoningEffort } from '../config/reasoningEffort.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `/effort [档位|auto]` 的纯解析(可单测)。只改当前 Session 的运行时 provider,
|
|
5
|
+
* 与 `/model` 同语义:不写回 config.json,进程重启后恢复配置里的值。
|
|
6
|
+
*
|
|
7
|
+
* - `/effort` → 显示当前档位与可选项
|
|
8
|
+
* - `/effort high` → 切到该档位
|
|
9
|
+
* - `/effort auto` → 不再发送该参数,沿用服务端对该模型的默认强度(也认 default / unset / off 以外的别名见下)
|
|
10
|
+
*
|
|
11
|
+
* 档位取值是各家文档出现过的并集,具体某个模型接不接受由服务端裁决:被拒绝时 client.ts
|
|
12
|
+
* 会去掉参数重发并告警,所以这里不替用户猜"这个模型支持哪几档"。
|
|
13
|
+
*/
|
|
14
|
+
export type EffortCommand =
|
|
15
|
+
| { matched: false }
|
|
16
|
+
| { matched: true; action: 'show' }
|
|
17
|
+
| { matched: true; action: 'set'; effort: ReasoningEffort | null }
|
|
18
|
+
| { matched: true; action: 'invalid'; input: string };
|
|
19
|
+
|
|
20
|
+
const CLEAR_WORDS = new Set(['auto', 'default', 'unset', 'reset']);
|
|
21
|
+
|
|
22
|
+
export function parseEffortCommand(input: string): EffortCommand {
|
|
23
|
+
const match = /^\/effort(?:\s+(\S+))?\s*$/i.exec(input.trim());
|
|
24
|
+
if (!match) return { matched: false };
|
|
25
|
+
const arg = match[1]?.toLowerCase();
|
|
26
|
+
if (!arg) return { matched: true, action: 'show' };
|
|
27
|
+
if (CLEAR_WORDS.has(arg)) return { matched: true, action: 'set', effort: null };
|
|
28
|
+
if ((REASONING_EFFORTS as readonly string[]).includes(arg)) {
|
|
29
|
+
return { matched: true, action: 'set', effort: arg as ReasoningEffort };
|
|
30
|
+
}
|
|
31
|
+
return { matched: true, action: 'invalid', input: arg };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function effortChoicesText(): string {
|
|
35
|
+
return `${REASONING_EFFORTS.join(' / ')} / auto`;
|
|
36
|
+
}
|
package/src/web/protocol.ts
CHANGED
|
@@ -298,7 +298,7 @@ export interface SkillInfo {
|
|
|
298
298
|
export type ApiFormat = 'openai' | 'openai-responses' | 'anthropic';
|
|
299
299
|
|
|
300
300
|
/** 推理强度;缺省 = 不发送,沿用服务端对该模型的默认强度。 */
|
|
301
|
-
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
301
|
+
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
302
302
|
|
|
303
303
|
/** 模型列表的一个条目(脱敏视图——apiKey 只给 configured 布尔位,不下发原文)。 */
|
|
304
304
|
export interface ModelView {
|