minimal-agent 0.18.20 → 0.18.22

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.
Files changed (188) hide show
  1. package/README.md +16 -3
  2. package/package.json +1 -1
  3. package/plugins/cron-runner/README.md +23 -0
  4. package/plugins/cron-runner/commands/cron.md +7 -1
  5. package/plugins/cron-runner/plugin.js +9 -2
  6. package/plugins/cron-runner/plugin.ts +10 -2
  7. package/plugins/cron-runner/src/commands.js +112 -25
  8. package/plugins/cron-runner/src/commands.ts +154 -33
  9. package/plugins/cron-runner/src/contract.js +70 -0
  10. package/plugins/cron-runner/src/contract.ts +70 -0
  11. package/plugins/cron-runner/src/requests.js +22 -13
  12. package/plugins/cron-runner/src/requests.ts +34 -14
  13. package/plugins/cron-runner/src/runs.js +63 -10
  14. package/plugins/cron-runner/src/runs.ts +107 -15
  15. package/plugins/cron-runner/src/scheduler.js +188 -76
  16. package/plugins/cron-runner/src/scheduler.ts +277 -94
  17. package/plugins/cron-runner/src/schema.js +52 -17
  18. package/plugins/cron-runner/src/schema.ts +73 -22
  19. package/plugins/cron-runner/src/service.js +29 -8
  20. package/plugins/cron-runner/src/service.ts +71 -18
  21. package/plugins/cron-runner/src/store.js +92 -30
  22. package/plugins/cron-runner/src/store.ts +156 -53
  23. package/plugins/cron-runner/src/transaction.js +24 -0
  24. package/plugins/cron-runner/src/transaction.ts +36 -0
  25. package/plugins/cron-runner/src/types.ts +30 -4
  26. package/plugins/cron-runner/test/lifecycle.test.ts +419 -0
  27. package/plugins/cron-runner/test/plugin-integration.test.ts +3 -2
  28. package/plugins/cron-runner/test/reliability.test.ts +2 -2
  29. package/plugins/cron-runner/test/store-and-scheduler.test.ts +9 -7
  30. package/plugins/workflow-runner/plugin.js +1 -0
  31. package/plugins/workflow-runner/plugin.ts +1 -0
  32. package/plugins/workflow-runner/src/index.js +1 -0
  33. package/plugins/workflow-runner/src/index.ts +2 -0
  34. package/plugins/workflow-runner/src/runner.js +6 -1
  35. package/plugins/workflow-runner/src/runner.ts +5 -1
  36. package/plugins/workflow-runner/src/types.ts +1 -0
  37. package/plugins/workflow-runner/test/api.test.ts +1 -0
  38. package/plugins/workflow-runner/test/apiCapabilities.test.ts +4 -0
  39. package/plugins/workflow-runner/test/apiConcurrencyGate.test.ts +1 -0
  40. package/plugins/workflow-runner/test/childWorkflow.test.ts +19 -0
  41. package/plugins/workflow-runner/test/embeddedExecution.test.ts +23 -3
  42. package/src/advisor/README.md +17 -6
  43. package/src/advisor/advisorNudge.js +23 -3
  44. package/src/advisor/advisorNudge.ts +20 -3
  45. package/src/advisor/deliveryReview.js +9 -2
  46. package/src/advisor/deliveryReview.ts +10 -2
  47. package/src/cli/args.js +1 -0
  48. package/src/cli/args.ts +1 -0
  49. package/src/cli/headlessTurn.js +143 -0
  50. package/src/cli/headlessTurn.ts +187 -0
  51. package/src/cli/lifecycle.js +52 -0
  52. package/src/cli/lifecycle.ts +59 -0
  53. package/src/cli/print.js +91 -240
  54. package/src/cli/print.ts +99 -301
  55. package/src/cli/quickModelSetup.js +3 -0
  56. package/src/cli/quickModelSetup.tsx +3 -0
  57. package/src/cli/streamJson.js +244 -334
  58. package/src/cli/streamJson.ts +248 -416
  59. package/src/cli/wizards/contextAdvisorWizard.js +0 -7
  60. package/src/cli/wizards/contextAdvisorWizard.tsx +0 -11
  61. package/src/cli/wizards/providerPresets.js +25 -14
  62. package/src/cli/wizards/providerPresets.ts +25 -14
  63. package/src/cli/wizards/providerWizard.js +29 -11
  64. package/src/cli/wizards/providerWizard.tsx +29 -11
  65. package/src/config/configDefaults.js +2 -2
  66. package/src/config/configDefaults.ts +2 -2
  67. package/src/config/configDiagnostics.js +7 -3
  68. package/src/config/configDiagnostics.ts +6 -3
  69. package/src/config/configFile.ts +1 -1
  70. package/src/context/compact.js +40 -10
  71. package/src/context/compact.ts +51 -12
  72. package/src/context/compactResources.js +39 -0
  73. package/src/context/compactResources.ts +35 -0
  74. package/src/context/manualCompact.js +20 -0
  75. package/src/context/manualCompact.ts +28 -0
  76. package/src/llm/client.js +4 -0
  77. package/src/llm/client.ts +4 -0
  78. package/src/llm/messageProvenance.js +1 -1
  79. package/src/llm/messageProvenance.ts +1 -1
  80. package/src/loop/README.md +4 -2
  81. package/src/loop/deliveryIntent.js +3 -2
  82. package/src/loop/deliveryIntent.ts +4 -2
  83. package/src/loop/messages.js +1 -0
  84. package/src/loop/messages.ts +1 -0
  85. package/src/loop/options.ts +2 -0
  86. package/src/loop.js +10 -2
  87. package/src/loop.ts +9 -2
  88. package/src/main.js +40 -45
  89. package/src/main.tsx +33 -52
  90. package/src/plugin-sdk.js +1 -1
  91. package/src/plugin-sdk.ts +1 -1
  92. package/src/plugins/artifactDelivery.js +76 -0
  93. package/src/plugins/artifactDelivery.ts +76 -0
  94. package/src/plugins/pluginApi.ts +4 -0
  95. package/src/plugins/pluginRunner.js +2 -0
  96. package/src/plugins/pluginRunner.ts +3 -0
  97. package/src/prompts/delegation.js +2 -2
  98. package/src/prompts/delegation.ts +2 -2
  99. package/src/prompts/policyRegistry.js +7 -5
  100. package/src/prompts/policyRegistry.ts +7 -5
  101. package/src/prompts/promptAssembly.js +2 -2
  102. package/src/prompts/promptAssembly.ts +2 -2
  103. package/src/runtime/requestIntent.js +86 -0
  104. package/src/runtime/requestIntent.ts +66 -0
  105. package/src/runtime/systemEvents.js +10 -1
  106. package/src/runtime/systemEvents.ts +9 -1
  107. package/src/session/commandTranscript.js +76 -0
  108. package/src/session/commandTranscript.ts +77 -0
  109. package/src/session/executionOutcome.js +25 -0
  110. package/src/session/executionOutcome.ts +34 -0
  111. package/src/session/runAgentTurn.js +8 -1
  112. package/src/session/runAgentTurn.ts +10 -1
  113. package/src/session/runTurn.js +40 -15
  114. package/src/session/runTurn.ts +38 -12
  115. package/src/session/sessionState.js +7 -2
  116. package/src/session/sessionState.ts +7 -2
  117. package/src/team/onlineToolContract.js +1 -0
  118. package/src/team/onlineToolContract.ts +1 -0
  119. package/src/tools/advisor/advisor.js +73 -30
  120. package/src/tools/advisor/advisor.ts +73 -33
  121. package/src/tools/advisor/advisorCoordination.js +44 -0
  122. package/src/tools/advisor/advisorCoordination.ts +45 -0
  123. package/src/tools/advisor/advisorDescription.js +1 -1
  124. package/src/tools/advisor/advisorDescription.ts +1 -1
  125. package/src/tools/agent/README.md +2 -0
  126. package/src/tools/agent/agent.js +7 -3
  127. package/src/tools/agent/agent.ts +7 -3
  128. package/src/tools/agent/agentHandoff.js +2 -1
  129. package/src/tools/agent/agentHandoff.ts +2 -1
  130. package/src/tools/agent/agentTaskService.js +26 -5
  131. package/src/tools/agent/agentTaskService.ts +25 -5
  132. package/src/tools/agent/agentTypes.js +2 -2
  133. package/src/tools/agent/agentTypes.ts +2 -2
  134. package/src/tools/agent/baselineAttach.js +14 -7
  135. package/src/tools/agent/baselineAttach.ts +14 -7
  136. package/src/tools/applypatch/applyPatch.js +39 -13
  137. package/src/tools/applypatch/applyPatch.ts +35 -15
  138. package/src/tools/bash/bash.js +3 -0
  139. package/src/tools/bash/bash.ts +3 -0
  140. package/src/tools/capabilities.js +1 -0
  141. package/src/tools/capabilities.ts +1 -0
  142. package/src/tools/download/download.js +147 -11
  143. package/src/tools/download/download.ts +193 -17
  144. package/src/tools/edit/edit.js +4 -4
  145. package/src/tools/edit/edit.ts +4 -4
  146. package/src/tools/edit/multi-edit.js +2 -2
  147. package/src/tools/edit/multi-edit.ts +2 -2
  148. package/src/tools/index.js +2 -0
  149. package/src/tools/index.ts +2 -0
  150. package/src/tools/powershell/powershell.js +2 -0
  151. package/src/tools/powershell/powershell.ts +2 -0
  152. package/src/tools/schedule/schedule.js +184 -0
  153. package/src/tools/schedule/schedule.ts +214 -0
  154. package/src/tools/shared/fileUtils.js +16 -6
  155. package/src/tools/shared/fileUtils.ts +15 -6
  156. package/src/tools/tasks/backgroundTaskService.js +108 -12
  157. package/src/tools/tasks/backgroundTaskService.ts +106 -14
  158. package/src/tools/tasks/taskOutput.js +15 -5
  159. package/src/tools/tasks/taskOutput.ts +13 -5
  160. package/src/tools/tasks/taskStop.js +2 -2
  161. package/src/tools/tasks/taskStop.ts +2 -2
  162. package/src/tools/toolPromptGuides.js +4 -3
  163. package/src/tools/toolPromptGuides.ts +4 -3
  164. package/src/tools/webfetch/webfetch.js +1 -1
  165. package/src/tools/webfetch/webfetch.ts +1 -1
  166. package/src/types.ts +6 -0
  167. package/src/ui/App.js +3 -1
  168. package/src/ui/App.tsx +2 -0
  169. package/src/ui/InputBox.js +2 -2
  170. package/src/ui/InputBox.tsx +2 -2
  171. package/src/ui/LiveArea.js +6 -1
  172. package/src/ui/LiveArea.tsx +6 -1
  173. package/src/ui/MessageList.js +2 -0
  174. package/src/ui/MessageList.tsx +2 -0
  175. package/src/ui/README.md +8 -2
  176. package/src/ui/activityPresentation.js +23 -3
  177. package/src/ui/activityPresentation.ts +22 -3
  178. package/src/ui/backgroundWake.js +20 -4
  179. package/src/ui/backgroundWake.ts +19 -4
  180. package/src/ui/commandTranscript.js +2 -69
  181. package/src/ui/commandTranscript.ts +2 -71
  182. package/src/ui/hooks/useBackgroundAgents.js +33 -0
  183. package/src/ui/hooks/useBackgroundAgents.ts +36 -0
  184. package/src/ui/hooks/useChat.js +46 -25
  185. package/src/ui/hooks/useChat.ts +36 -23
  186. package/src/web/protocol.ts +5 -2
  187. package/src/cli/wizards/advisorWizard.js +0 -152
  188. package/src/cli/wizards/advisorWizard.tsx +0 -203
@@ -53,12 +53,6 @@ export function ContextAdvisorWizard({ compactRatio, advisor, models, onDone, on
53
53
  default: advisor?.enforcement ?? 'remind',
54
54
  hint: 'remind=只提醒 · followup=实质回答未复核时再发一次请求,让模型自己补问顾问(弱基座模型用)',
55
55
  },
56
- {
57
- key: 'inputTokenBudget',
58
- label: '顾问输入 Token 预算',
59
- type: 'text',
60
- default: String(advisor?.inputTokenBudget ?? DEFAULT_ADVISOR_CONFIG.inputTokenBudget),
61
- },
62
56
  {
63
57
  key: 'timeoutSeconds',
64
58
  label: '最长等待(秒)',
@@ -77,7 +71,6 @@ export function ContextAdvisorWizard({ compactRatio, advisor, models, onDone, on
77
71
  mode: values.mode === 'manual' ? 'manual' : 'auto',
78
72
  enforcement: values.enforcement === 'followup' ? 'followup' : 'remind',
79
73
  modelId,
80
- inputTokenBudget: normalizeLimited(numberValue(values.inputTokenBudget, DEFAULT_ADVISOR_CONFIG.inputTokenBudget), CONFIG_LIMITS.advisorInputTokenBudget, DEFAULT_ADVISOR_CONFIG.inputTokenBudget),
81
74
  timeoutMs: normalizeLimited(numberValue(values.timeoutSeconds, DEFAULT_ADVISOR_CONFIG.timeoutMs / 1000) * 1000, CONFIG_LIMITS.advisorTimeoutMs, DEFAULT_ADVISOR_CONFIG.timeoutMs),
82
75
  }
83
76
  : { clear: true },
@@ -77,12 +77,6 @@ export function ContextAdvisorWizard({
77
77
  default: advisor?.enforcement ?? 'remind',
78
78
  hint: 'remind=只提醒 · followup=实质回答未复核时再发一次请求,让模型自己补问顾问(弱基座模型用)',
79
79
  },
80
- {
81
- key: 'inputTokenBudget',
82
- label: '顾问输入 Token 预算',
83
- type: 'text',
84
- default: String(advisor?.inputTokenBudget ?? DEFAULT_ADVISOR_CONFIG.inputTokenBudget),
85
- },
86
80
  {
87
81
  key: 'timeoutSeconds',
88
82
  label: '最长等待(秒)',
@@ -106,11 +100,6 @@ export function ContextAdvisorWizard({
106
100
  mode: values.mode === 'manual' ? 'manual' : 'auto',
107
101
  enforcement: values.enforcement === 'followup' ? 'followup' : 'remind',
108
102
  modelId,
109
- inputTokenBudget: normalizeLimited(
110
- numberValue(values.inputTokenBudget, DEFAULT_ADVISOR_CONFIG.inputTokenBudget),
111
- CONFIG_LIMITS.advisorInputTokenBudget,
112
- DEFAULT_ADVISOR_CONFIG.inputTokenBudget,
113
- ),
114
103
  timeoutMs: normalizeLimited(
115
104
  numberValue(values.timeoutSeconds, DEFAULT_ADVISOR_CONFIG.timeoutMs / 1000) * 1000,
116
105
  CONFIG_LIMITS.advisorTimeoutMs,
@@ -27,30 +27,38 @@ export const PRESETS = [
27
27
  // model 字段大小写严格匹配('glm-5.3' 而非 'GLM-5.3')。
28
28
  // ⚠️ 必须是 /api/coding/v3/(Coding Plan 折扣路由),不是 /api/v3/
29
29
  // (官网原价路由)——控制台原文明确警告后者「会产生额外费用」。
30
- // 2026-09 按控制台最新模型列表刷新(原列表含已下线的 doubao-seed-2.0-pro/
31
- // doubao-seed-code/glm-5.1/minimax-latest/deepseek-v3.2/kimi-k2.6)。
30
+ // 2026-11-20 按官方快速开始刷新;Auto 只能在控制台设置,ID 使用 ark-code-latest。
32
31
  name: 'volces',
33
32
  label: '火山方舟 Coding Plan (ARK)',
34
33
  baseURL: 'https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions',
35
34
  models: [
36
- 'auto',
35
+ 'ark-code-latest',
37
36
  'doubao-seed-evolving',
38
- 'doubao-seed-2.1-turbo',
39
- 'doubao-seed-2.0-lite',
37
+ 'doubao-seed-2.1-pro',
38
+ 'doubao-seed-2.1-lite',
39
+ 'doubao-seed-2.0-mini',
40
40
  'glm-5.3-flash',
41
41
  'glm-5.3',
42
42
  'deepseek-v4-pro',
43
43
  'deepseek-v4-flash',
44
- 'kimi-k2.7-code',
45
- 'minimax-m3',
44
+ 'deepseek-v4.1-flash',
45
+ 'deepseek-v4.1-flash-economy',
46
+ 'kimi-k2.8-preview',
47
+ 'kimi-k3',
48
+ 'kimi-k3.1-pro',
46
49
  ],
47
50
  contextWindow: 204_800,
48
51
  modelContextWindows: {
49
- // 控制台标注「支持 1M 超长上下文」的三个。
52
+ // 使用保守的 1M 值(官方不同工具示例分别使用 1024000/1048576)。
50
53
  'doubao-seed-evolving': 1_000_000,
51
54
  'glm-5.3': 1_000_000,
52
55
  'deepseek-v4-pro': 1_000_000,
53
- 'kimi-k2.7-code': 512_000,
56
+ 'deepseek-v4-flash': 1_000_000,
57
+ 'deepseek-v4.1-flash': 1_000_000,
58
+ 'deepseek-v4.1-flash-economy': 1_000_000,
59
+ 'glm-5.3-flash': 1_000_000,
60
+ 'kimi-k2.8-preview': 1_000_000,
61
+ 'kimi-k3.1-pro': 1_000_000,
54
62
  },
55
63
  },
56
64
  {
@@ -78,7 +86,7 @@ export const PRESETS = [
78
86
  name: 'openai-responses',
79
87
  label: 'OpenAI(Responses API,推荐)',
80
88
  baseURL: 'https://api.openai.com/v1/responses',
81
- models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
89
+ models: ['gpt-6.2-sol', 'gpt-6.2-astra', 'gpt-6.1-terra', 'gpt-6-luna'],
82
90
  contextWindow: 1_050_000,
83
91
  apiFormat: 'openai-responses',
84
92
  supportsReasoningEffort: true,
@@ -89,7 +97,8 @@ export const PRESETS = [
89
97
  name: 'openai',
90
98
  label: 'OpenAI(Chat Completions)',
91
99
  baseURL: 'https://api.openai.com/v1/chat/completions',
92
- models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
100
+ // 6.2 的工具调用要求 Responses,不放进 Chat Completions Agent 预设。
101
+ models: ['gpt-6.1-terra', 'gpt-6.1-sol'],
93
102
  contextWindow: 1_050_000,
94
103
  supportsReasoningEffort: true,
95
104
  },
@@ -97,12 +106,14 @@ export const PRESETS = [
97
106
  name: 'openrouter',
98
107
  label: 'OpenRouter',
99
108
  baseURL: 'https://openrouter.ai/api/v1/chat/completions',
100
- // 2026-10 取自 OpenRouter /api/v1/models 的最新条目(均约 1M 上下文)。
109
+ // 2026-11-20 核对 OpenRouter /api/v1/models;聚合服务的工具协议以其目录为准。
101
110
  models: [
102
- 'openai/gpt-6.1-terra',
111
+ 'openai/gpt-6.2-sol',
112
+ 'openai/gpt-6.2-astra',
113
+ 'anthropic/claude-fable-5.2',
103
114
  'anthropic/claude-sonnet-5.5',
104
115
  'anthropic/claude-opus-5.5',
105
- 'google/gemini-3.8-flash',
116
+ 'google/gemini-4-neon',
106
117
  'moonshotai/kimi-k3.1-pro',
107
118
  'deepseek/deepseek-v4.1-flash',
108
119
  'minimax/minimax-m3.1-flash',
@@ -56,30 +56,38 @@ export const PRESETS: ProviderPreset[] = [
56
56
  // model 字段大小写严格匹配('glm-5.3' 而非 'GLM-5.3')。
57
57
  // ⚠️ 必须是 /api/coding/v3/(Coding Plan 折扣路由),不是 /api/v3/
58
58
  // (官网原价路由)——控制台原文明确警告后者「会产生额外费用」。
59
- // 2026-09 按控制台最新模型列表刷新(原列表含已下线的 doubao-seed-2.0-pro/
60
- // doubao-seed-code/glm-5.1/minimax-latest/deepseek-v3.2/kimi-k2.6)。
59
+ // 2026-11-20 按官方快速开始刷新;Auto 只能在控制台设置,ID 使用 ark-code-latest。
61
60
  name: 'volces',
62
61
  label: '火山方舟 Coding Plan (ARK)',
63
62
  baseURL: 'https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions',
64
63
  models: [
65
- 'auto',
64
+ 'ark-code-latest',
66
65
  'doubao-seed-evolving',
67
- 'doubao-seed-2.1-turbo',
68
- 'doubao-seed-2.0-lite',
66
+ 'doubao-seed-2.1-pro',
67
+ 'doubao-seed-2.1-lite',
68
+ 'doubao-seed-2.0-mini',
69
69
  'glm-5.3-flash',
70
70
  'glm-5.3',
71
71
  'deepseek-v4-pro',
72
72
  'deepseek-v4-flash',
73
- 'kimi-k2.7-code',
74
- 'minimax-m3',
73
+ 'deepseek-v4.1-flash',
74
+ 'deepseek-v4.1-flash-economy',
75
+ 'kimi-k2.8-preview',
76
+ 'kimi-k3',
77
+ 'kimi-k3.1-pro',
75
78
  ],
76
79
  contextWindow: 204_800,
77
80
  modelContextWindows: {
78
- // 控制台标注「支持 1M 超长上下文」的三个。
81
+ // 使用保守的 1M 值(官方不同工具示例分别使用 1024000/1048576)。
79
82
  'doubao-seed-evolving': 1_000_000,
80
83
  'glm-5.3': 1_000_000,
81
84
  'deepseek-v4-pro': 1_000_000,
82
- 'kimi-k2.7-code': 512_000,
85
+ 'deepseek-v4-flash': 1_000_000,
86
+ 'deepseek-v4.1-flash': 1_000_000,
87
+ 'deepseek-v4.1-flash-economy': 1_000_000,
88
+ 'glm-5.3-flash': 1_000_000,
89
+ 'kimi-k2.8-preview': 1_000_000,
90
+ 'kimi-k3.1-pro': 1_000_000,
83
91
  },
84
92
  },
85
93
  {
@@ -107,7 +115,7 @@ export const PRESETS: ProviderPreset[] = [
107
115
  name: 'openai-responses',
108
116
  label: 'OpenAI(Responses API,推荐)',
109
117
  baseURL: 'https://api.openai.com/v1/responses',
110
- models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
118
+ models: ['gpt-6.2-sol', 'gpt-6.2-astra', 'gpt-6.1-terra', 'gpt-6-luna'],
111
119
  contextWindow: 1_050_000,
112
120
  apiFormat: 'openai-responses',
113
121
  supportsReasoningEffort: true,
@@ -118,7 +126,8 @@ export const PRESETS: ProviderPreset[] = [
118
126
  name: 'openai',
119
127
  label: 'OpenAI(Chat Completions)',
120
128
  baseURL: 'https://api.openai.com/v1/chat/completions',
121
- models: ['gpt-6.1-terra', 'gpt-6.1-terra-pro', 'gpt-6.1-sol', 'gpt-6.1-sol-pro'],
129
+ // 6.2 的工具调用要求 Responses,不放进 Chat Completions Agent 预设。
130
+ models: ['gpt-6.1-terra', 'gpt-6.1-sol'],
122
131
  contextWindow: 1_050_000,
123
132
  supportsReasoningEffort: true,
124
133
  },
@@ -126,12 +135,14 @@ export const PRESETS: ProviderPreset[] = [
126
135
  name: 'openrouter',
127
136
  label: 'OpenRouter',
128
137
  baseURL: 'https://openrouter.ai/api/v1/chat/completions',
129
- // 2026-10 取自 OpenRouter /api/v1/models 的最新条目(均约 1M 上下文)。
138
+ // 2026-11-20 核对 OpenRouter /api/v1/models;聚合服务的工具协议以其目录为准。
130
139
  models: [
131
- 'openai/gpt-6.1-terra',
140
+ 'openai/gpt-6.2-sol',
141
+ 'openai/gpt-6.2-astra',
142
+ 'anthropic/claude-fable-5.2',
132
143
  'anthropic/claude-sonnet-5.5',
133
144
  'anthropic/claude-opus-5.5',
134
- 'google/gemini-3.8-flash',
145
+ 'google/gemini-4-neon',
135
146
  'moonshotai/kimi-k3.1-pro',
136
147
  'deepseek/deepseek-v4.1-flash',
137
148
  'minimax/minimax-m3.1-flash',
@@ -11,18 +11,23 @@ const numberValue = (value, fallback) => {
11
11
  const parsed = Number(String(value ?? '').trim());
12
12
  return Number.isFinite(parsed) ? parsed : fallback;
13
13
  };
14
- export function ProviderWizard({ existing, setAsBase = true, quick = false, onDone, onCancel, }) {
14
+ export function ProviderWizard({ existing: original, setAsBase = true, quick = false, onDone, onCancel, }) {
15
+ const initialPresetIndex = original
16
+ ? PRESETS.findIndex(item => item.baseURL === original.baseURL)
17
+ : -1;
15
18
  const [phase, setPhase] = useState('preset');
16
19
  const [advanced, setAdvanced] = useState(false);
17
20
  const [presetIndex, setPresetIndex] = useState(() => {
18
- if (existing) {
19
- const byUrl = PRESETS.findIndex((item) => item.baseURL === existing.baseURL);
21
+ if (original) {
22
+ const byUrl = PRESETS.findIndex((item) => item.baseURL === original.baseURL);
20
23
  if (byUrl >= 0)
21
24
  return byUrl;
22
25
  }
23
- return findPresetIndex(existing?.displayName);
26
+ return findPresetIndex(original?.displayName);
24
27
  });
25
28
  const preset = PRESETS[presetIndex];
29
+ // A provider switch must not send the old provider's credential to a new host.
30
+ const existing = presetIndex === (initialPresetIndex >= 0 ? initialPresetIndex : findPresetIndex(original?.displayName)) ? original : undefined;
26
31
  useInput((input, key) => {
27
32
  if (phase === 'quick-choice') {
28
33
  if (key.escape)
@@ -55,7 +60,7 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
55
60
  // 协议:选了具体服务商就跟服务商走(编辑时换服务商可以顺带换协议);
56
61
  // 「自定义」没有预设,沿用已有模型自己的协议,新建时在完整设置里让用户选。
57
62
  const presetFormat = preset.name === 'custom' ? existing?.apiFormat : (preset.apiFormat ?? 'openai');
58
- const askFormat = preset.name === 'custom' && (!quick || advanced);
63
+ const askFormat = preset.name === 'custom';
59
64
  const knownFormat = presetFormat ?? 'openai';
60
65
  // 推理强度是 OpenAI 系模型最常调的一项:快速配置也要问,不藏进高级里。
61
66
  const showEffort = knownFormat !== 'anthropic' &&
@@ -122,7 +127,9 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
122
127
  key: 'contextWindow',
123
128
  label: '上下文窗口(Token)',
124
129
  type: 'text',
125
- default: String(defaultContext),
130
+ default: existing ? String(defaultContext) : '',
131
+ optional: true,
132
+ hint: '留空按最终填写的模型 ID 使用预设窗口;自定义模型请确认服务商实际限制。',
126
133
  }, {
127
134
  key: 'maxTokens',
128
135
  label: '单次输出上限(留空使用推荐值)',
@@ -156,9 +163,18 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
156
163
  const model = String(values.model ?? '').trim();
157
164
  if (!baseURL || !apiKey || !model)
158
165
  throw new Error('Base URL、API Key 和模型 ID 均不能为空');
166
+ if (original && apiKey === original.apiKey && new URL(baseURL).origin !== new URL(original.baseURL).origin)
167
+ throw new Error('端点已换到其他服务商,请显式填写新服务商的 API Key,不能复用旧凭据');
168
+ for (const key of ['contextWindow', 'maxTokens']) {
169
+ const raw = String(values[key] ?? '').trim();
170
+ if (raw && (!Number.isSafeInteger(Number(raw)) || Number(raw) <= 0))
171
+ throw new Error(`${key} 必须是正整数,或留空使用推荐值`);
172
+ }
159
173
  const contextWindow = normalizeLimited(quick && !advanced
160
174
  ? resolveContextWindow(preset, model)
161
- : numberValue(values.contextWindow, defaultContext), CONFIG_LIMITS.modelContextWindow, defaultContext);
175
+ : String(values.contextWindow ?? '').trim()
176
+ ? numberValue(values.contextWindow, defaultContext)
177
+ : resolveContextWindow(preset, model), CONFIG_LIMITS.modelContextWindow, defaultContext);
162
178
  const rawMax = quick && !advanced ? '' : String(values.maxTokens ?? '').trim();
163
179
  const maxTokens = rawMax
164
180
  ? normalizeLimited(numberValue(rawMax, defaultMaxTokens(contextWindow)), CONFIG_LIMITS.modelMaxTokens, defaultMaxTokens(contextWindow))
@@ -166,6 +182,8 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
166
182
  const apiFormat = askFormat
167
183
  ? (API_FORMAT_CHOICES.find((item) => item === values.apiFormat) ?? knownFormat)
168
184
  : knownFormat;
185
+ if (new URL(baseURL).hostname === 'api.openai.com' && model.startsWith('gpt-6.2') && apiFormat !== 'openai-responses')
186
+ throw new Error('OpenAI 6.2 的工具调用需要 Responses API,请选择 Responses 预设和 /v1/responses 端点');
169
187
  const reasoningEffort = showEffort
170
188
  ? reasoningEffortFromChoice(values.reasoningEffort)
171
189
  : existing?.reasoningEffort;
@@ -178,7 +196,7 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
178
196
  apiKey,
179
197
  model,
180
198
  contextWindow,
181
- ...(maxTokens ? { maxTokens } : {}),
199
+ maxTokens: maxTokens ?? defaultMaxTokens(contextWindow),
182
200
  supportsVision: existing?.supportsVision !== false,
183
201
  ...(reasoningEffort ? { reasoningEffort } : {}),
184
202
  reasoning: quick && !advanced
@@ -193,11 +211,11 @@ export function ProviderWizard({ existing, setAsBase = true, quick = false, onDo
193
211
  const diagnostic = await testModelConnection(draft);
194
212
  if (!diagnostic.ok)
195
213
  throw new Error(diagnostic.message);
196
- if (existing) {
214
+ if (original) {
197
215
  await configService.savePatch({
198
216
  // null = 清除之前设的强度(选了「不设置」);不带这个字段则保留旧值。
199
- models: [{ op: 'update', id: existing.id, patch: { ...draft, reasoningEffort: reasoningEffort ?? null } }],
200
- ...(setAsBase ? { baseModelId: existing.id } : {}),
217
+ models: [{ op: 'update', id: original.id, patch: { ...draft, reasoningEffort: reasoningEffort ?? null } }],
218
+ ...(setAsBase ? { baseModelId: original.id } : {}),
201
219
  });
202
220
  }
203
221
  else {
@@ -47,26 +47,31 @@ const numberValue = (value: unknown, fallback: number) => {
47
47
  };
48
48
 
49
49
  export function ProviderWizard({
50
- existing,
50
+ existing: original,
51
51
  setAsBase = true,
52
52
  quick = false,
53
53
  onDone,
54
54
  onCancel,
55
55
  }: Props): JSX.Element {
56
+ const initialPresetIndex = original
57
+ ? PRESETS.findIndex(item => item.baseURL === original.baseURL)
58
+ : -1;
56
59
  const [phase, setPhase] = useState<'preset' | 'quick-choice' | 'fields'>(
57
60
  'preset',
58
61
  );
59
62
  const [advanced, setAdvanced] = useState(false);
60
63
  const [presetIndex, setPresetIndex] = useState(() => {
61
- if (existing) {
64
+ if (original) {
62
65
  const byUrl = PRESETS.findIndex(
63
- (item) => item.baseURL === existing.baseURL,
66
+ (item) => item.baseURL === original.baseURL,
64
67
  );
65
68
  if (byUrl >= 0) return byUrl;
66
69
  }
67
- return findPresetIndex(existing?.displayName);
70
+ return findPresetIndex(original?.displayName);
68
71
  });
69
72
  const preset = PRESETS[presetIndex]!;
73
+ // A provider switch must not send the old provider's credential to a new host.
74
+ const existing = presetIndex === (initialPresetIndex >= 0 ? initialPresetIndex : findPresetIndex(original?.displayName)) ? original : undefined;
70
75
 
71
76
  useInput((input, key) => {
72
77
  if (phase === 'quick-choice') {
@@ -133,7 +138,7 @@ export function ProviderWizard({
133
138
  // 「自定义」没有预设,沿用已有模型自己的协议,新建时在完整设置里让用户选。
134
139
  const presetFormat: ApiFormat | undefined =
135
140
  preset.name === 'custom' ? existing?.apiFormat : (preset.apiFormat ?? 'openai');
136
- const askFormat = preset.name === 'custom' && (!quick || advanced);
141
+ const askFormat = preset.name === 'custom';
137
142
  const knownFormat: ApiFormat = presetFormat ?? 'openai';
138
143
  // 推理强度是 OpenAI 系模型最常调的一项:快速配置也要问,不藏进高级里。
139
144
  const showEffort =
@@ -206,7 +211,9 @@ export function ProviderWizard({
206
211
  key: 'contextWindow',
207
212
  label: '上下文窗口(Token)',
208
213
  type: 'text',
209
- default: String(defaultContext),
214
+ default: existing ? String(defaultContext) : '',
215
+ optional: true,
216
+ hint: '留空按最终填写的模型 ID 使用预设窗口;自定义模型请确认服务商实际限制。',
210
217
  },
211
218
  {
212
219
  key: 'maxTokens',
@@ -252,10 +259,19 @@ export function ProviderWizard({
252
259
  const model = String(values.model ?? '').trim();
253
260
  if (!baseURL || !apiKey || !model)
254
261
  throw new Error('Base URL、API Key 和模型 ID 均不能为空');
262
+ if (original && apiKey === original.apiKey && new URL(baseURL).origin !== new URL(original.baseURL).origin)
263
+ throw new Error('端点已换到其他服务商,请显式填写新服务商的 API Key,不能复用旧凭据');
264
+ for (const key of ['contextWindow', 'maxTokens']) {
265
+ const raw = String(values[key] ?? '').trim();
266
+ if (raw && (!Number.isSafeInteger(Number(raw)) || Number(raw) <= 0))
267
+ throw new Error(`${key} 必须是正整数,或留空使用推荐值`);
268
+ }
255
269
  const contextWindow = normalizeLimited(
256
270
  quick && !advanced
257
271
  ? resolveContextWindow(preset, model)
258
- : numberValue(values.contextWindow, defaultContext),
272
+ : String(values.contextWindow ?? '').trim()
273
+ ? numberValue(values.contextWindow, defaultContext)
274
+ : resolveContextWindow(preset, model),
259
275
  CONFIG_LIMITS.modelContextWindow,
260
276
  defaultContext,
261
277
  );
@@ -271,6 +287,8 @@ export function ProviderWizard({
271
287
  const apiFormat: ApiFormat = askFormat
272
288
  ? (API_FORMAT_CHOICES.find((item) => item === values.apiFormat) ?? knownFormat)
273
289
  : knownFormat;
290
+ if (new URL(baseURL).hostname === 'api.openai.com' && model.startsWith('gpt-6.2') && apiFormat !== 'openai-responses')
291
+ throw new Error('OpenAI 6.2 的工具调用需要 Responses API,请选择 Responses 预设和 /v1/responses 端点');
274
292
  const reasoningEffort = showEffort
275
293
  ? reasoningEffortFromChoice(values.reasoningEffort)
276
294
  : existing?.reasoningEffort;
@@ -284,7 +302,7 @@ export function ProviderWizard({
284
302
  apiKey,
285
303
  model,
286
304
  contextWindow,
287
- ...(maxTokens ? { maxTokens } : {}),
305
+ maxTokens: maxTokens ?? defaultMaxTokens(contextWindow),
288
306
  supportsVision: existing?.supportsVision !== false,
289
307
  ...(reasoningEffort ? { reasoningEffort } : {}),
290
308
  reasoning:
@@ -300,11 +318,11 @@ export function ProviderWizard({
300
318
  };
301
319
  const diagnostic = await testModelConnection(draft);
302
320
  if (!diagnostic.ok) throw new Error(diagnostic.message);
303
- if (existing) {
321
+ if (original) {
304
322
  await configService.savePatch({
305
323
  // null = 清除之前设的强度(选了「不设置」);不带这个字段则保留旧值。
306
- models: [{ op: 'update', id: existing.id, patch: { ...draft, reasoningEffort: reasoningEffort ?? null } }],
307
- ...(setAsBase ? { baseModelId: existing.id } : {}),
324
+ models: [{ op: 'update', id: original.id, patch: { ...draft, reasoningEffort: reasoningEffort ?? null } }],
325
+ ...(setAsBase ? { baseModelId: original.id } : {}),
308
326
  });
309
327
  } else {
310
328
  const before = new Set(
@@ -49,8 +49,8 @@ export const DEFAULT_COMPUTER_USE_CONFIG = {
49
49
  * 任何 advisor 默认值变更只能改这里,否则就是 numericLimits.ts 注释预言的
50
50
  *「用户改不回值」事故类型(同 DEFAULT_SUBAGENTS_CONFIG / DEFAULT_BROWSER_CONFIG 范式)。
51
51
  *
52
- * inputTokenBudget:默认使用配置允许的最大值,实际按顾问模型窗口扣除输出
53
- * 与协议余量。能力优先,不因默认 256K 配额提前省略材料;显式配置仍生效。
52
+ * inputTokenBudget:仅保留旧配置往返兼容;运行时忽略此字段。
53
+ * 顾问容量由选定模型的 contextWindow/maxTokens 决定。
54
54
  *
55
55
  * timeoutMs:120s 是 2026-08 的新默认值,从 180s 压到 120s 的理由:
56
56
  * 180s 在快模型上等太久(用户实际配置中已主动压到 90s 撞墙过),
@@ -60,8 +60,8 @@ export const DEFAULT_COMPUTER_USE_CONFIG: ComputerUseConfig = {
60
60
  * 任何 advisor 默认值变更只能改这里,否则就是 numericLimits.ts 注释预言的
61
61
  *「用户改不回值」事故类型(同 DEFAULT_SUBAGENTS_CONFIG / DEFAULT_BROWSER_CONFIG 范式)。
62
62
  *
63
- * inputTokenBudget:默认使用配置允许的最大值,实际按顾问模型窗口扣除输出
64
- * 与协议余量。能力优先,不因默认 256K 配额提前省略材料;显式配置仍生效。
63
+ * inputTokenBudget:仅保留旧配置往返兼容;运行时忽略此字段。
64
+ * 顾问容量由选定模型的 contextWindow/maxTokens 决定。
65
65
  *
66
66
  * timeoutMs:120s 是 2026-08 的新默认值,从 180s 压到 120s 的理由:
67
67
  * 180s 在快模型上等太久(用户实际配置中已主动压到 90s 撞墙过),
@@ -1,3 +1,4 @@
1
+ import { completeGenerationTerminal } from '../harness/generationReceipt.js';
1
2
  import { configService } from './configService.js';
2
3
  function providerFromModel(model) {
3
4
  return {
@@ -27,6 +28,7 @@ export async function testModelConnection(model, timeoutMs = 45_000) {
27
28
  try {
28
29
  const { chat } = await import('../llm/client.js');
29
30
  let received = false;
31
+ let completed = false;
30
32
  for await (const event of chat({
31
33
  provider: providerFromModel(model),
32
34
  messages: [{ role: 'user', content: '请只回复 OK' }],
@@ -35,18 +37,20 @@ export async function testModelConnection(model, timeoutMs = 45_000) {
35
37
  })) {
36
38
  if (event.type === 'text_delta' && event.delta.trim())
37
39
  received = true;
40
+ if (event.type === 'done')
41
+ completed = completeGenerationTerminal(event.stopReason, false);
38
42
  }
39
- return received
43
+ return received && completed
40
44
  ? { ok: true, code: 'ok', message: '连接正常' }
41
45
  : {
42
46
  ok: false,
43
47
  code: 'invalid-response',
44
- message: '服务已响应,但没有返回文本',
48
+ message: '服务已响应,但没有返回完整文本和正常结束回执',
45
49
  };
46
50
  }
47
51
  catch (error) {
48
52
  if (error.name === 'AbortError')
49
- return { ok: false, code: 'timeout', message: '连接超时(45 秒无响应)' };
53
+ return { ok: false, code: 'timeout', message: `连接测试超过 ${timeoutMs / 1000} 秒,未能完成` };
50
54
  const detail = error.message || String(error);
51
55
  return {
52
56
  ok: false,
@@ -1,4 +1,5 @@
1
1
  import type { LocalProvider } from '../types.js';
2
+ import { completeGenerationTerminal } from '../harness/generationReceipt.js';
2
3
  import type { ModelConfig } from './configFile.js';
3
4
  import { type ConfigService, configService } from './configService.js';
4
5
 
@@ -74,6 +75,7 @@ export async function testModelConnection(
74
75
  try {
75
76
  const { chat } = await import('../llm/client.js');
76
77
  let received = false;
78
+ let completed = false;
77
79
  for await (const event of chat({
78
80
  provider: providerFromModel(model),
79
81
  messages: [{ role: 'user', content: '请只回复 OK' }],
@@ -81,17 +83,18 @@ export async function testModelConnection(
81
83
  signal: controller.signal,
82
84
  })) {
83
85
  if (event.type === 'text_delta' && event.delta.trim()) received = true;
86
+ if (event.type === 'done') completed = completeGenerationTerminal(event.stopReason, false);
84
87
  }
85
- return received
88
+ return received && completed
86
89
  ? { ok: true, code: 'ok', message: '连接正常' }
87
90
  : {
88
91
  ok: false,
89
92
  code: 'invalid-response',
90
- message: '服务已响应,但没有返回文本',
93
+ message: '服务已响应,但没有返回完整文本和正常结束回执',
91
94
  };
92
95
  } catch (error) {
93
96
  if ((error as Error).name === 'AbortError')
94
- return { ok: false, code: 'timeout', message: '连接超时(45 秒无响应)' };
97
+ return { ok: false, code: 'timeout', message: `连接测试超过 ${timeoutMs / 1000} 秒,未能完成` };
95
98
  const detail = (error as Error).message || String(error);
96
99
  return {
97
100
  ok: false,
@@ -77,7 +77,7 @@ export interface AdvisorConfig {
77
77
  /** 引用 models[].id;null = 未选。顾问不再自带一整套独立 provider 字段。 */
78
78
  modelId: string | null;
79
79
  contextPolicy: 'full-relevant';
80
- /** 顾问单次输入预算。独立于模型声明的上下文窗口,避免百万窗口吞入整段历史。 */
80
+ /** @deprecated 仅兼容旧配置/客户端往返;顾问运行时忽略,容量由模型窗口决定。 */
81
81
  inputTokenBudget: number;
82
82
  timeoutMs: number;
83
83
  }