feat: add minimax m3 backend profile
This commit is contained in:
+16
-3
@@ -11,6 +11,7 @@ export interface SelfTestContext {
|
||||
tmp: string;
|
||||
codexHome: string;
|
||||
deepseekHome: string;
|
||||
minimaxM3Home: string;
|
||||
workspace: string;
|
||||
fakeCodexPath: string;
|
||||
fakeCodexCommand: string;
|
||||
@@ -25,20 +26,24 @@ export interface SelfTestResult {
|
||||
|
||||
export type SelfTestCase = (context: SelfTestContext) => Promise<SelfTestResult> | SelfTestResult;
|
||||
|
||||
type SelfTestRunContext = Pick<SelfTestContext, "workspace" | "codexHome"> & Partial<Pick<SelfTestContext, "deepseekHome">> & { backendProfile?: BackendProfile; includeOnlyProfile?: BackendProfile; toolCredentials?: JsonRecord[] };
|
||||
type SelfTestRunContext = Pick<SelfTestContext, "workspace" | "codexHome"> & Partial<Pick<SelfTestContext, "deepseekHome" | "minimaxM3Home">> & { backendProfile?: BackendProfile; includeOnlyProfile?: BackendProfile; toolCredentials?: JsonRecord[] };
|
||||
|
||||
export async function createSelfTestContext(root: string): Promise<SelfTestContext> {
|
||||
const tmp = await mkdtemp(path.join(os.tmpdir(), "agentrun-selftest-"));
|
||||
const codexHome = path.join(tmp, "codex-home");
|
||||
const deepseekHome = path.join(tmp, "deepseek-home");
|
||||
const minimaxM3Home = path.join(tmp, "minimax-m3-home");
|
||||
const workspace = path.join(tmp, "workspace");
|
||||
await mkdir(codexHome, { recursive: true });
|
||||
await mkdir(deepseekHome, { recursive: true });
|
||||
await mkdir(minimaxM3Home, { recursive: true });
|
||||
await mkdir(workspace, { recursive: true });
|
||||
await writeFile(path.join(codexHome, "auth.json"), JSON.stringify({ token: "test-token-material" }));
|
||||
await writeFile(path.join(codexHome, "config.toml"), "model = \"gpt-test\"\n");
|
||||
await writeFile(path.join(deepseekHome, "auth.json"), JSON.stringify({ token: "test-token-material-deepseek" }));
|
||||
await writeFile(path.join(deepseekHome, "config.toml"), "model = \"deepseek-test\"\n");
|
||||
await writeFile(path.join(minimaxM3Home, "auth.json"), JSON.stringify({ token: "test-token-material-minimax-m3" }));
|
||||
await writeFile(path.join(minimaxM3Home, "config.toml"), "model = \"MiniMax-M3\"\nmodel_provider = \"minimax\"\n[model_providers.minimax]\nname = \"MiniMax\"\nbase_url = \"https://api.minimaxi.com/v1\"\nenv_key = \"MINIMAX_API_KEY\"\nwire_api = \"chat\"\n");
|
||||
await writeFile(path.join(workspace, "README.md"), "self-test workspace\n");
|
||||
const fakeCodexPath = path.join(root, "src/selftest/fake-codex-app-server.ts");
|
||||
return {
|
||||
@@ -46,6 +51,7 @@ export async function createSelfTestContext(root: string): Promise<SelfTestConte
|
||||
tmp,
|
||||
codexHome,
|
||||
deepseekHome,
|
||||
minimaxM3Home,
|
||||
workspace,
|
||||
fakeCodexPath,
|
||||
fakeCodexCommand: process.env.AGENTRUN_SELFTEST_CODEX_COMMAND ?? defaultFakeCommand(),
|
||||
@@ -81,14 +87,14 @@ function toolCredentialScope(context: { toolCredentials?: JsonRecord[] }): JsonR
|
||||
return context.toolCredentials ? { toolCredentials: context.toolCredentials } : {};
|
||||
}
|
||||
|
||||
function providerCredentials(context: Pick<SelfTestContext, "codexHome"> & Partial<Pick<SelfTestContext, "deepseekHome">> & { includeOnlyProfile?: BackendProfile }, backendProfile: BackendProfile): JsonRecord[] {
|
||||
function providerCredentials(context: Pick<SelfTestContext, "codexHome"> & Partial<Pick<SelfTestContext, "deepseekHome" | "minimaxM3Home">> & { includeOnlyProfile?: BackendProfile }, backendProfile: BackendProfile): JsonRecord[] {
|
||||
const profiles: BackendProfile[] = context.includeOnlyProfile ? [context.includeOnlyProfile] : [backendProfile];
|
||||
return profiles.map((profile) => ({
|
||||
profile,
|
||||
secretRef: {
|
||||
name: backendProfileSpec(profile)?.defaultSecretName ?? `agentrun-v01-provider-${profile}`,
|
||||
keys: ["auth.json", "config.toml"],
|
||||
mountPath: profile === "deepseek" ? context.deepseekHome ?? context.codexHome : context.codexHome,
|
||||
mountPath: profileSecretHome(context, profile),
|
||||
},
|
||||
}));
|
||||
}
|
||||
@@ -97,9 +103,16 @@ export function assertNoSecretLeak(value: unknown): void {
|
||||
const text = JSON.stringify(value);
|
||||
assert.equal(text.includes("test-token-material"), false);
|
||||
assert.equal(text.includes("test-token-material-deepseek"), false);
|
||||
assert.equal(text.includes("test-token-material-minimax-m3"), false);
|
||||
assert.equal(text.includes("Bearer test-token"), false);
|
||||
}
|
||||
|
||||
export function profileSecretHome(context: Pick<SelfTestContext, "codexHome"> & Partial<Pick<SelfTestContext, "deepseekHome" | "minimaxM3Home">>, profile: BackendProfile): string {
|
||||
if (profile === "deepseek") return context.deepseekHome ?? context.codexHome;
|
||||
if (profile === "minimax-m3") return context.minimaxM3Home ?? context.codexHome;
|
||||
return context.codexHome;
|
||||
}
|
||||
|
||||
function defaultFakeCommand(): string {
|
||||
return process.versions.bun ? process.execPath : "npx";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user