Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/minimax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const API_PROVIDER_ID = "minimax";
const PORTAL_PROVIDER_ID = "minimax-portal";
const PROVIDER_LABEL = "MiniMax";
const DEFAULT_MODEL = MINIMAX_DEFAULT_MODEL_ID;
const DEFAULT_BASE_URL_CN = "https://api.minimaxi.com/anthropic";
const DEFAULT_BASE_URL_GLOBAL = "https://api.minimax.io/anthropic";
const DEFAULT_BASE_URL_CN = "https://api.minimaxi.com/anthropic/v1";
const DEFAULT_BASE_URL_GLOBAL = "https://api.minimax.io/anthropic/v1";

function getDefaultBaseUrl(region: MiniMaxRegion): string {
return region === "cn" ? DEFAULT_BASE_URL_CN : DEFAULT_BASE_URL_GLOBAL;
Expand Down
23 changes: 11 additions & 12 deletions extensions/minimax/model-definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,36 @@ import {
} from "./model-definitions.js";

describe("minimax model definitions", () => {
it("uses M2.7 as default hosted model", () => {
expect(MINIMAX_HOSTED_MODEL_ID).toBe("MiniMax-M2.7");
it("uses M3 as default hosted model", () => {
expect(MINIMAX_HOSTED_MODEL_ID).toBe("MiniMax-M3");
});

it("uses the higher upstream MiniMax context and token defaults", () => {
expect(DEFAULT_MINIMAX_CONTEXT_WINDOW).toBe(204800);
it("uses the upstream MiniMax M3 context and cost defaults", () => {
expect(DEFAULT_MINIMAX_CONTEXT_WINDOW).toBe(1000000);
expect(DEFAULT_MINIMAX_MAX_TOKENS).toBe(131072);
expect(MINIMAX_API_COST).toEqual({
input: 0.3,
output: 1.2,
cacheRead: 0.06,
cacheWrite: 0.375,
input: 0.6,
output: 2.4,
cacheRead: 0.12,
});
});

it("builds catalog model with name and reasoning from catalog", () => {
const model = buildMinimaxModelDefinition({
id: "MiniMax-M2.7",
id: "MiniMax-M3",
cost: MINIMAX_API_COST,
contextWindow: DEFAULT_MINIMAX_CONTEXT_WINDOW,
maxTokens: DEFAULT_MINIMAX_MAX_TOKENS,
});
expect(model).toMatchObject({
id: "MiniMax-M2.7",
name: "MiniMax M2.7",
id: "MiniMax-M3",
name: "MiniMax M3",
reasoning: true,
});
});

it("builds API model definition with standard cost", () => {
const model = buildMinimaxApiModelDefinition("MiniMax-M2.7");
const model = buildMinimaxApiModelDefinition("MiniMax-M3");
expect(model.cost).toEqual(MINIMAX_API_COST);
expect(model.contextWindow).toBe(DEFAULT_MINIMAX_CONTEXT_WINDOW);
expect(model.maxTokens).toBe(DEFAULT_MINIMAX_MAX_TOKENS);
Expand Down
13 changes: 6 additions & 7 deletions extensions/minimax/model-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-s
import { MINIMAX_DEFAULT_MODEL_ID, MINIMAX_TEXT_MODEL_CATALOG } from "./provider-models.js";

export const DEFAULT_MINIMAX_BASE_URL = "https://api.minimax.io/v1";
export const MINIMAX_API_BASE_URL = "https://api.minimax.io/anthropic";
export const MINIMAX_CN_API_BASE_URL = "https://api.minimaxi.com/anthropic";
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -C3

Repository: 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 2

Repository: 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 3

Repository: 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 2

Repository: 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.ts

Repository: 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`.

};
export const MINIMAX_HOSTED_COST = {
input: 0,
Expand Down
16 changes: 8 additions & 8 deletions extensions/minimax/onboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ describe("minimax onboard", () => {
it("adds minimax provider with correct settings", () => {
const cfg = applyMinimaxApiConfig({});
expect(cfg.models?.providers?.minimax).toMatchObject({
baseUrl: "https://api.minimax.io/anthropic",
baseUrl: "https://api.minimax.io/anthropic/v1",
api: "anthropic-messages",
authHeader: true,
});
});

it("keeps reasoning enabled for MiniMax-M2.7", () => {
const cfg = applyMinimaxApiConfig({}, "MiniMax-M2.7");
it("keeps reasoning enabled for MiniMax-M3", () => {
const cfg = applyMinimaxApiConfig({}, "MiniMax-M3");
expect(cfg.models?.providers?.minimax?.models[0]?.reasoning).toBe(true);
});

Expand All @@ -31,17 +31,17 @@ describe("minimax onboard", () => {
agents: {
defaults: {
models: {
"minimax/MiniMax-M2.7": {
"minimax/MiniMax-M3": {
alias: "MiniMax",
params: { custom: "value" },
},
},
},
},
},
"MiniMax-M2.7",
"MiniMax-M3",
);
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]).toMatchObject({
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M3"]).toMatchObject({
alias: "Minimax",
params: { custom: "value" },
});
Expand All @@ -54,13 +54,13 @@ describe("minimax onboard", () => {
api: "openai-completions",
}),
);
expect(cfg.models?.providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic");
expect(cfg.models?.providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic/v1");
expect(cfg.models?.providers?.minimax?.api).toBe("anthropic-messages");
expect(cfg.models?.providers?.minimax?.authHeader).toBe(true);
expect(cfg.models?.providers?.minimax?.apiKey).toBe("old-key");
expect(cfg.models?.providers?.minimax?.models.map((m) => m.id)).toEqual([
"old-model",
"MiniMax-M2.7",
"MiniMax-M3",
]);
});

Expand Down
8 changes: 4 additions & 4 deletions extensions/minimax/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function applyMinimaxApiConfigWithBaseUrl(

export function applyMinimaxApiProviderConfig(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -72,7 +72,7 @@ export function applyMinimaxApiProviderConfig(

export function applyMinimaxApiConfig(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -83,7 +83,7 @@ export function applyMinimaxApiConfig(

export function applyMinimaxApiProviderConfigCn(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -94,7 +94,7 @@ export function applyMinimaxApiProviderConfigCn(

export function applyMinimaxApiConfigCn(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand Down
11 changes: 5 additions & 6 deletions extensions/minimax/provider-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {
MINIMAX_TEXT_MODEL_ORDER,
} from "./provider-models.js";

const MINIMAX_PORTAL_BASE_URL = "https://api.minimax.io/anthropic";
const MINIMAX_DEFAULT_CONTEXT_WINDOW = 204800;
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,
};

function buildMinimaxModel(params: {
Expand Down
11 changes: 8 additions & 3 deletions extensions/minimax/provider-models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { matchesExactOrPrefix } from "openclaw/plugin-sdk/provider-model-shared";

export const MINIMAX_DEFAULT_MODEL_ID = "MiniMax-M2.7";
export const MINIMAX_DEFAULT_MODEL_ID = "MiniMax-M3";
export const MINIMAX_DEFAULT_MODEL_REF = `minimax/${MINIMAX_DEFAULT_MODEL_ID}`;

export const MINIMAX_TEXT_MODEL_ORDER = ["MiniMax-M2.7", "MiniMax-M2.7-highspeed"] as const;
export const MINIMAX_TEXT_MODEL_ORDER = [
"MiniMax-M3",
"MiniMax-M2.7",
"MiniMax-M2.7-highspeed",
] as const;

export const MINIMAX_TEXT_MODEL_CATALOG = {
"MiniMax-M3": { name: "MiniMax M3", reasoning: true },
"MiniMax-M2.7": { name: "MiniMax M2.7", reasoning: true },
"MiniMax-M2.7-highspeed": { name: "MiniMax M2.7 Highspeed", reasoning: true },
} as const;
Expand All @@ -14,7 +19,7 @@ export const MINIMAX_TEXT_MODEL_REFS = MINIMAX_TEXT_MODEL_ORDER.map(
(modelId) => `minimax/${modelId}`,
);

const MINIMAX_MODERN_MODEL_MATCHERS = ["minimax-m2.7"] as const;
const MINIMAX_MODERN_MODEL_MATCHERS = ["minimax-m3", "minimax-m2.7"] as const;

export function isMiniMaxModernModelId(modelId: string): boolean {
return matchesExactOrPrefix(modelId, MINIMAX_MODERN_MODEL_MATCHERS);
Expand Down
4 changes: 2 additions & 2 deletions minimax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const API_PROVIDER_ID = "minimax";
const PORTAL_PROVIDER_ID = "minimax-portal";
const PROVIDER_LABEL = "MiniMax";
const DEFAULT_MODEL = MINIMAX_DEFAULT_MODEL_ID;
const DEFAULT_BASE_URL_CN = "https://api.minimaxi.com/anthropic";
const DEFAULT_BASE_URL_GLOBAL = "https://api.minimax.io/anthropic";
const DEFAULT_BASE_URL_CN = "https://api.minimaxi.com/anthropic/v1";
const DEFAULT_BASE_URL_GLOBAL = "https://api.minimax.io/anthropic/v1";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.ts

Repository: 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.ts

Repository: 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.ts

Repository: 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.


function getDefaultBaseUrl(region: MiniMaxRegion): string {
return region === "cn" ? DEFAULT_BASE_URL_CN : DEFAULT_BASE_URL_GLOBAL;
Expand Down
23 changes: 11 additions & 12 deletions minimax/model-definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,36 @@ import {
} from "./model-definitions.js";

describe("minimax model definitions", () => {
it("uses M2.7 as default hosted model", () => {
expect(MINIMAX_HOSTED_MODEL_ID).toBe("MiniMax-M2.7");
it("uses M3 as default hosted model", () => {
expect(MINIMAX_HOSTED_MODEL_ID).toBe("MiniMax-M3");
});

it("uses the higher upstream MiniMax context and token defaults", () => {
expect(DEFAULT_MINIMAX_CONTEXT_WINDOW).toBe(204800);
it("uses the upstream MiniMax M3 context and cost defaults", () => {
expect(DEFAULT_MINIMAX_CONTEXT_WINDOW).toBe(1000000);
expect(DEFAULT_MINIMAX_MAX_TOKENS).toBe(131072);
expect(MINIMAX_API_COST).toEqual({
input: 0.3,
output: 1.2,
cacheRead: 0.06,
cacheWrite: 0.375,
input: 0.6,
output: 2.4,
cacheRead: 0.12,
});
});

it("builds catalog model with name and reasoning from catalog", () => {
const model = buildMinimaxModelDefinition({
id: "MiniMax-M2.7",
id: "MiniMax-M3",
cost: MINIMAX_API_COST,
contextWindow: DEFAULT_MINIMAX_CONTEXT_WINDOW,
maxTokens: DEFAULT_MINIMAX_MAX_TOKENS,
});
expect(model).toMatchObject({
id: "MiniMax-M2.7",
name: "MiniMax M2.7",
id: "MiniMax-M3",
name: "MiniMax M3",
reasoning: true,
});
});

it("builds API model definition with standard cost", () => {
const model = buildMinimaxApiModelDefinition("MiniMax-M2.7");
const model = buildMinimaxApiModelDefinition("MiniMax-M3");
expect(model.cost).toEqual(MINIMAX_API_COST);
expect(model.contextWindow).toBe(DEFAULT_MINIMAX_CONTEXT_WINDOW);
expect(model.maxTokens).toBe(DEFAULT_MINIMAX_MAX_TOKENS);
Expand Down
13 changes: 6 additions & 7 deletions minimax/model-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-s
import { MINIMAX_DEFAULT_MODEL_ID, MINIMAX_TEXT_MODEL_CATALOG } from "./provider-models.js";

export const DEFAULT_MINIMAX_BASE_URL = "https://api.minimax.io/v1";
export const MINIMAX_API_BASE_URL = "https://api.minimax.io/anthropic";
export const MINIMAX_CN_API_BASE_URL = "https://api.minimaxi.com/anthropic";
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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 expanded

Repository: 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

buildMinimaxApiModelDefinitionprovider-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.

};
export const MINIMAX_HOSTED_COST = {
input: 0,
Expand Down
16 changes: 8 additions & 8 deletions minimax/onboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ describe("minimax onboard", () => {
it("adds minimax provider with correct settings", () => {
const cfg = applyMinimaxApiConfig({});
expect(cfg.models?.providers?.minimax).toMatchObject({
baseUrl: "https://api.minimax.io/anthropic",
baseUrl: "https://api.minimax.io/anthropic/v1",
api: "anthropic-messages",
authHeader: true,
});
});

it("keeps reasoning enabled for MiniMax-M2.7", () => {
const cfg = applyMinimaxApiConfig({}, "MiniMax-M2.7");
it("keeps reasoning enabled for MiniMax-M3", () => {
const cfg = applyMinimaxApiConfig({}, "MiniMax-M3");
expect(cfg.models?.providers?.minimax?.models[0]?.reasoning).toBe(true);
});

Expand All @@ -31,17 +31,17 @@ describe("minimax onboard", () => {
agents: {
defaults: {
models: {
"minimax/MiniMax-M2.7": {
"minimax/MiniMax-M3": {
alias: "MiniMax",
params: { custom: "value" },
},
},
},
},
},
"MiniMax-M2.7",
"MiniMax-M3",
);
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M2.7"]).toMatchObject({
expect(cfg.agents?.defaults?.models?.["minimax/MiniMax-M3"]).toMatchObject({
alias: "Minimax",
params: { custom: "value" },
});
Expand All @@ -54,13 +54,13 @@ describe("minimax onboard", () => {
api: "openai-completions",
}),
);
expect(cfg.models?.providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic");
expect(cfg.models?.providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic/v1");
expect(cfg.models?.providers?.minimax?.api).toBe("anthropic-messages");
expect(cfg.models?.providers?.minimax?.authHeader).toBe(true);
expect(cfg.models?.providers?.minimax?.apiKey).toBe("old-key");
expect(cfg.models?.providers?.minimax?.models.map((m) => m.id)).toEqual([
"old-model",
"MiniMax-M2.7",
"MiniMax-M3",
]);
});

Expand Down
8 changes: 4 additions & 4 deletions minimax/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function applyMinimaxApiConfigWithBaseUrl(

export function applyMinimaxApiProviderConfig(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -72,7 +72,7 @@ export function applyMinimaxApiProviderConfig(

export function applyMinimaxApiConfig(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -83,7 +83,7 @@ export function applyMinimaxApiConfig(

export function applyMinimaxApiProviderConfigCn(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand All @@ -94,7 +94,7 @@ export function applyMinimaxApiProviderConfigCn(

export function applyMinimaxApiConfigCn(
cfg: OpenClawConfig,
modelId: string = "MiniMax-M2.7",
modelId: string = "MiniMax-M3",
): OpenClawConfig {
return applyMinimaxApiConfigWithBaseUrl(cfg, {
providerId: "minimax",
Expand Down
Loading
Loading