Add MiniMax M3 provider defaults#273
Conversation
Reason: add target provider/model to existing provider registry. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📝 WalkthroughWalkthrough将 minimax 与 extensions/minimax 两套代码中的 MiniMax API 基础地址追加 Changesminimax 目录变更
extensions/minimax 目录变更
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
minimax/provider-models.ts (1)
3-22: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win更新 Minimax 默认模型对应的测试断言
MINIMAX_DEFAULT_MODEL_ID已切到"MiniMax-M3",src/commands/onboard-auth.test.ts:420-435里这条合并测试仍断言最后一个模型是"MiniMax-M2.7";把它改成"MiniMax-M3",否则这条测试会和默认配置不一致。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@minimax/provider-models.ts` around lines 3 - 22, The Minimax default model has changed to MiniMax-M3, so the onboarding auth test in onboard-auth.test.ts still asserting MiniMax-M2.7 is now out of sync. Update the affected test expectation to match MINIMAX_DEFAULT_MODEL_ID and the default model selection logic used by the Minimax provider model constants, so the merged-model assertion reflects MiniMax-M3.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@extensions/minimax/model-definitions.ts`:
- Around line 5-15: `MINIMAX_API_COST` in
`MINIMAX_API_BASE_URL`/`MINIMAX_API_COST` definitions is missing the
`cacheWrite` entry, which makes it incompatible with places expecting a full
`ModelDefinitionConfig["cost"]`. Add the missing `cacheWrite` field to
`MINIMAX_API_COST` alongside `input`, `output`, and `cacheRead`, keeping the
existing naming and structure in `model-definitions.ts`.
In `@minimax/index.ts`:
- Around line 32-33: The MiniMax default base URL has changed, so the onboard
auth test is still asserting the old value. Update the `applyMinimaxApiConfig`
expectation in `src/commands/onboard-auth.test.ts` to match the new
`DEFAULT_BASE_URL_GLOBAL` value used by `minimax/index.ts`, so the baseUrl
assertion checks `https://api.minimax.io/anthropic/v1` instead of the outdated
URL.
In `@minimax/model-definitions.ts`:
- Around line 5-15: `MINIMAX_API_COST` is missing the `cacheWrite` field, which
is used by `buildMinimaxApiModelDefinition`, `provider-catalog.ts`, and
`estimateUsageCost` when computing usage cost. Update the `MINIMAX_API_COST`
object in `model-definitions` to include `cacheWrite` with a default value of 0
so cost estimation remains valid and does not produce undefined/NaN results.
In `@minimax/provider-catalog.ts`:
- Around line 11-17: The Minimax config behavior has changed, but the onboarding
auth test still asserts the old values. Update the assertions in
onboard-auth.test.ts to match applyMinimaxApiConfig and the Minimax provider
behavior now using https://api.minimax.io/anthropic/v1 and the new model value
instead of the old baseUrl and "MiniMax-M2.7". Keep the test expectations
aligned with the relevant Minimax symbols so the suite reflects the current
provider catalog behavior.
---
Outside diff comments:
In `@minimax/provider-models.ts`:
- Around line 3-22: The Minimax default model has changed to MiniMax-M3, so the
onboarding auth test in onboard-auth.test.ts still asserting MiniMax-M2.7 is now
out of sync. Update the affected test expectation to match
MINIMAX_DEFAULT_MODEL_ID and the default model selection logic used by the
Minimax provider model constants, so the merged-model assertion reflects
MiniMax-M3.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 62a82df7-d54a-46ff-bcbb-9141744b37cb
📒 Files selected for processing (14)
extensions/minimax/index.tsextensions/minimax/model-definitions.test.tsextensions/minimax/model-definitions.tsextensions/minimax/onboard.test.tsextensions/minimax/onboard.tsextensions/minimax/provider-catalog.tsextensions/minimax/provider-models.tsminimax/index.tsminimax/model-definitions.test.tsminimax/model-definitions.tsminimax/onboard.test.tsminimax/onboard.tsminimax/provider-catalog.tsminimax/provider-models.ts
| export const MINIMAX_API_BASE_URL = "https://api.minimax.io/anthropic/v1"; | ||
| export const MINIMAX_CN_API_BASE_URL = "https://api.minimaxi.com/anthropic/v1"; | ||
| export const MINIMAX_HOSTED_MODEL_ID = MINIMAX_DEFAULT_MODEL_ID; | ||
| export const MINIMAX_HOSTED_MODEL_REF = `minimax/${MINIMAX_HOSTED_MODEL_ID}`; | ||
| export const DEFAULT_MINIMAX_CONTEXT_WINDOW = 204800; | ||
| export const DEFAULT_MINIMAX_CONTEXT_WINDOW = 1000000; | ||
| export const DEFAULT_MINIMAX_MAX_TOKENS = 131072; | ||
|
|
||
| export const MINIMAX_API_COST = { | ||
| input: 0.3, | ||
| output: 1.2, | ||
| cacheRead: 0.06, | ||
| cacheWrite: 0.375, | ||
| input: 0.6, | ||
| output: 2.4, | ||
| cacheRead: 0.12, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 查找 MINIMAX_API_COST 的类型定义,确认 cacheWrite 是否为可选字段
rg -n "cacheWrite" extensions/minimax/ --type=ts -C3
rg -n "interface.*cost\|type.*cost\|cacheWrite\?:" extensions/minimax/ src/ --type=ts -C3Repository: linuxhsj/openclaw-zero-token
Length of output: 1497
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant source file and shared type definitions for cost typing.
sed -n '1,120p' extensions/minimax/model-definitions.ts
printf '\n--- SEARCH ModelDefinitionConfig / cost typing ---\n'
rg -n "type ModelDefinitionConfig|interface ModelDefinitionConfig|cost:" src extensions -g '*.ts' -C 3
printf '\n--- SEARCH cost references in minimax ---\n'
rg -n "MINIMAX_API_COST|MINIMAX_.*COST|cacheWrite" extensions/minimax -g '*.ts' -C 2Repository: linuxhsj/openclaw-zero-token
Length of output: 50385
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- extensions/minimax/model-definitions.ts ---'
sed -n '1,120p' extensions/minimax/model-definitions.ts
printf '\n%s\n' '--- cost type definitions ---'
rg -n "type ModelDefinitionConfig|interface ModelDefinitionConfig|cost\s*:\s*\{" src extensions -g '*.ts' -C 3 | sed -n '1,220p'
printf '\n%s\n' '--- direct MINIMAX_API_COST usages ---'
rg -n "MINIMAX_API_COST" extensions src -g '*.ts' -C 3Repository: linuxhsj/openclaw-zero-token
Length of output: 23693
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the shared ModelDefinitionConfig type and the cost shape.
rg -n "export (type|interface) ModelDefinitionConfig|cost\s*[:?]" src extensions packages openclaw -g '*.ts' -C 4
printf '\n--- provider-model-shared files ---\n'
fd -a "provider-model-shared" . -t f
printf '\n--- files that define cacheWrite in model cost types ---\n'
rg -n "cacheWrite.*\?" src extensions packages openclaw -g '*.ts' -C 2Repository: linuxhsj/openclaw-zero-token
Length of output: 50385
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the shared model-definition type file, then inspect the cost shape directly.
fd -a "provider-model-shared*.ts" src extensions packages openclaw -t f
printf '\n--- possible matches for ModelDefinitionConfig ---\n'
rg -n "export (type|interface) ModelDefinitionConfig|type ModelDefinitionConfig|interface ModelDefinitionConfig" src extensions packages openclaw -g '*.ts' -C 4 | sed -n '1,200p'
printf '\n--- cacheWrite optional/required in shared types ---\n'
rg -n "cacheWrite\??:" src extensions packages openclaw -g '*.ts' -C 4 | sed -n '1,220p'Repository: linuxhsj/openclaw-zero-token
Length of output: 1273
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- src/config/types.models.ts (ModelDefinitionConfig) ---'
sed -n '1,180p' src/config/types.models.ts
printf '\n%s\n' '--- src/plugin-sdk/provider-model-shared.ts ---'
sed -n '1,220p' src/plugin-sdk/provider-model-shared.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 4117
补回 cacheWrite 字段 extensions/minimax/model-definitions.ts:12-15 里的 MINIMAX_API_COST 少了 cacheWrite,但它会被传给要求完整 ModelDefinitionConfig["cost"] 的位置,当前会产生类型不匹配。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@extensions/minimax/model-definitions.ts` around lines 5 - 15,
`MINIMAX_API_COST` in `MINIMAX_API_BASE_URL`/`MINIMAX_API_COST` definitions is
missing the `cacheWrite` entry, which makes it incompatible with places
expecting a full `ModelDefinitionConfig["cost"]`. Add the missing `cacheWrite`
field to `MINIMAX_API_COST` alongside `input`, `output`, and `cacheRead`,
keeping the existing naming and structure in `model-definitions.ts`.
| const DEFAULT_BASE_URL_CN = "https://api.minimaxi.com/anthropic/v1"; | ||
| const DEFAULT_BASE_URL_GLOBAL = "https://api.minimax.io/anthropic/v1"; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 检查下游测试文件中是否仍有旧的 baseUrl 断言
rg -n 'api\.minimax\.io/anthropic"' src/commands/onboard-auth.test.ts
# 检查下游测试文件中是否仍有旧的 MiniMax-M2.7 默认模型断言
rg -n 'MiniMax-M2\.7' src/commands/onboard-auth.test.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 888
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) 定位实现与测试,确认 baseUrl 的实际生成逻辑和相关断言
rg -n 'DEFAULT_BASE_URL_(CN|GLOBAL)|applyMinimaxApiConfig|baseUrl' minimax/index.ts src/commands/onboard-auth.test.ts
# 2) 只读取相关小片段,避免整文件过大输出
sed -n '1,120p' minimax/index.ts
printf '\n--- onboard-auth.test.ts excerpt ---\n'
sed -n '370,440p' src/commands/onboard-auth.test.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 10325
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 找出 applyMinimaxApiConfig 的实现和它默认写入 baseUrl 的位置
rg -n 'function applyMinimaxApiConfig|export .*applyMinimaxApiConfig|baseUrl: .*anthropic|DEFAULT_BASE_URL_GLOBAL|DEFAULT_BASE_URL_CN' -S .
# 只读相关实现片段
printf '\n--- plugin-sdk/minimax.js / onboard.ts candidates ---\n'
fd -a 'minimax.*' .
fd -a 'onboard.*' .Repository: linuxhsj/openclaw-zero-token
Length of output: 22472
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 读取 applyMinimaxApiConfig 的实现,确认它是否使用了新的 /v1 默认值
sed -n '1,180p' minimax/onboard.ts
printf '\n--- src/commands/onboard-auth.test.ts excerpt ---\n'
sed -n '380,435p' src/commands/onboard-auth.test.ts
printf '\n--- extensions/minimax/onboard.test.ts excerpt ---\n'
sed -n '1,120p' extensions/minimax/onboard.test.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 9171
同步更新 src/commands/onboard-auth.test.ts 的 MiniMax baseUrl 断言
applyMinimaxApiConfig({}) 现在写入的是 https://api.minimax.io/anthropic/v1,但这里仍在断言旧值 https://api.minimax.io/anthropic,会导致这条测试失败。把断言改成新默认值即可。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@minimax/index.ts` around lines 32 - 33, The MiniMax default base URL has
changed, so the onboard auth test is still asserting the old value. Update the
`applyMinimaxApiConfig` expectation in `src/commands/onboard-auth.test.ts` to
match the new `DEFAULT_BASE_URL_GLOBAL` value used by `minimax/index.ts`, so the
baseUrl assertion checks `https://api.minimax.io/anthropic/v1` instead of the
outdated URL.
| export const MINIMAX_API_BASE_URL = "https://api.minimax.io/anthropic/v1"; | ||
| export const MINIMAX_CN_API_BASE_URL = "https://api.minimaxi.com/anthropic/v1"; | ||
| export const MINIMAX_HOSTED_MODEL_ID = MINIMAX_DEFAULT_MODEL_ID; | ||
| export const MINIMAX_HOSTED_MODEL_REF = `minimax/${MINIMAX_HOSTED_MODEL_ID}`; | ||
| export const DEFAULT_MINIMAX_CONTEXT_WINDOW = 204800; | ||
| export const DEFAULT_MINIMAX_CONTEXT_WINDOW = 1000000; | ||
| export const DEFAULT_MINIMAX_MAX_TOKENS = 131072; | ||
|
|
||
| export const MINIMAX_API_COST = { | ||
| input: 0.3, | ||
| output: 1.2, | ||
| cacheRead: 0.06, | ||
| cacheWrite: 0.375, | ||
| input: 0.6, | ||
| output: 2.4, | ||
| cacheRead: 0.12, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 搜索下游代码中对 MINIMAX_API_COST.cacheWrite 的引用
rg -n 'cacheWrite' minimax/ src/ --type=ts -g '!**/*.test.ts' -g '!**/node_modules/**'
# 搜索 MINIMAX_API_COST 的所有使用点
rg -n 'MINIMAX_API_COST' minimax/ src/ --type=ts -g '!**/node_modules/**'Repository: linuxhsj/openclaw-zero-token
Length of output: 32636
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## minimax/model-definitions.ts\n'
cat -n minimax/model-definitions.ts | sed -n '1,120p'
printf '\n## minimax/provider-catalog.ts\n'
cat -n minimax/provider-catalog.ts | sed -n '1,120p'
printf '\n## minimax/api.ts\n'
cat -n minimax/api.ts | sed -n '1,120p'
printf '\n## minimax/model-definitions.test.ts\n'
cat -n minimax/model-definitions.test.ts | sed -n '1,120p'
printf '\n## minimax files outline\n'
ast-grep outline minimax/model-definitions.ts --view expanded
ast-grep outline minimax/provider-catalog.ts --view expandedRepository: linuxhsj/openclaw-zero-token
Length of output: 9212
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## ModelDefinitionConfig / cost types\n'
rg -n 'interface ModelDefinitionConfig|type ModelDefinitionConfig|cost:' src minimax -g '!**/*.test.ts' -g '!**/node_modules/**'
printf '\n## config defaults / merge logic around cost\n'
rg -n 'DEFAULT_MODEL_COST|cacheWrite.*cost|raw\.cost|cost\.cacheWrite|merge.*cost' src minimax -g '!**/*.test.ts' -g '!**/node_modules/**'
printf '\n## minimax-specific cost references\n'
rg -n 'MINIMAX_API_COST|MINIMAX_HOSTED_COST|MINIMAX_LM_STUDIO_COST|cacheWrite' minimax -g '!**/*.test.ts' -g '!**/node_modules/**'Repository: linuxhsj/openclaw-zero-token
Length of output: 23160
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## src/config/types.models.ts\n'
cat -n src/config/types.models.ts | sed -n '58,90p'
printf '\n## src/config/defaults.ts\n'
cat -n src/config/defaults.ts | sed -n '30,90p'
printf '\n--\n'
cat -n src/config/defaults.ts | sed -n '260,285p'
printf '\n## src/utils/usage-format.ts\n'
cat -n src/utils/usage-format.ts | sed -n '235,265p'
printf '\n## minimax/model-definitions.ts references\n'
rg -n 'MINIMAX_API_COST|MINIMAX_HOSTED_COST|MINIMAX_LM_STUDIO_COST' minimax src -g '!**/*.test.ts' -g '!**/node_modules/**'Repository: linuxhsj/openclaw-zero-token
Length of output: 6265
补上 MINIMAX_API_COST.cacheWrite
buildMinimaxApiModelDefinition 和 provider-catalog.ts 都直接复用这个成本对象,而 estimateUsageCost 会读取 cost.cacheWrite 参与计算。这里缺少字段会让 Minimax API 的成本估算变成 undefined/NaN;直接补 cacheWrite: 0 即可。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@minimax/model-definitions.ts` around lines 5 - 15, `MINIMAX_API_COST` is
missing the `cacheWrite` field, which is used by
`buildMinimaxApiModelDefinition`, `provider-catalog.ts`, and `estimateUsageCost`
when computing usage cost. Update the `MINIMAX_API_COST` object in
`model-definitions` to include `cacheWrite` with a default value of 0 so cost
estimation remains valid and does not produce undefined/NaN results.
| const MINIMAX_PORTAL_BASE_URL = "https://api.minimax.io/anthropic/v1"; | ||
| const MINIMAX_DEFAULT_CONTEXT_WINDOW = 1000000; | ||
| const MINIMAX_DEFAULT_MAX_TOKENS = 131072; | ||
| const MINIMAX_API_COST = { | ||
| input: 0.3, | ||
| output: 1.2, | ||
| cacheRead: 0.06, | ||
| cacheWrite: 0.375, | ||
| input: 0.6, | ||
| output: 2.4, | ||
| cacheRead: 0.12, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 验证下游测试中的断言是否已更新
rg -n 'api\.minimax\.io/anthropic"' src/commands/onboard-auth.test.ts
rg -n 'MiniMax-M2\.7' src/commands/onboard-auth.test.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 888
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '380,440p' src/commands/onboard-auth.test.ts
printf '\n---\n'
sed -n '1,120p' minimax/provider-catalog.tsRepository: linuxhsj/openclaw-zero-token
Length of output: 3805
同步 src/commands/onboard-auth.test.ts 中的 Minimax 断言
applyMinimaxApiConfig 现在返回 https://api.minimax.io/anthropic/v1,但 src/commands/onboard-auth.test.ts 里仍有旧的 baseUrl 和 "MiniMax-M2.7" 断言;这些用例需要一起改成新行为,否则测试会继续失败。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@minimax/provider-catalog.ts` around lines 11 - 17, The Minimax config
behavior has changed, but the onboarding auth test still asserts the old values.
Update the assertions in onboard-auth.test.ts to match applyMinimaxApiConfig and
the Minimax provider behavior now using https://api.minimax.io/anthropic/v1 and
the new model value instead of the old baseUrl and "MiniMax-M2.7". Keep the test
expectations aligned with the relevant Minimax symbols so the suite reflects the
current provider catalog behavior.
Reason: add target provider/model to existing provider registry
Summary
Test plan
git diff --checkpnpm install --frozen-lockfile(failed: environment has Node v20.20.2 but package requires >=22.12.0, then disk filled during install with ENOSPC)pnpm exec vitest run minimax/model-definitions.test.ts minimax/onboard.test.ts extensions/minimax/model-definitions.test.ts extensions/minimax/onboard.test.ts(not run successfully: vitest unavailable because install failed)🤖 Generated with Claude Code
Summary by CodeRabbit
新功能
Bug 修复