Config: add MiniMax direct API authentication option
Makes apiKey optional in ModelProviderConfig so MiniMax can use auth profiles or environment variables (MINIMAX_API_KEY) instead of requiring explicit config. Changes: - src/config/types.ts: apiKey changed from required to optional - src/config/zod-schema.ts: use z.string().min(1).optional() for validation - src/commands/configure.ts: add minimax-api auth choice in wizard - src/commands/onboard-auth.ts: MiniMax provider omits apiKey (uses env/auth) - patches/@mariozechner__pi-ai@0.42.1.patch: map minimax → MINIMAX_API_KEY Auth Resolution Order (unchanged): 1. Auth profiles (highest priority) 2. Environment variables (MINIMAX_API_KEY, etc.) 3. Custom provider apiKey from models.json (lowest priority)
This commit is contained in:
36
AGENTS.md
36
AGENTS.md
@@ -115,3 +115,39 @@ EOF
|
||||
```
|
||||
|
||||
This is a Claude Code quirk, not a clawdbot bug.
|
||||
|
||||
---
|
||||
|
||||
## PR & Code Review Checklist
|
||||
|
||||
Before creating PRs or presenting code for review (especially to senior engineers):
|
||||
|
||||
### 1. Verify Code Quality
|
||||
- [ ] Run `pnpm lint` - no errors
|
||||
- [ ] Run `pnpm build` - TypeScript compiles
|
||||
- [ ] Run related tests - all pass
|
||||
|
||||
### 2. Review Diff Purity
|
||||
- [ ] Diff is minimal and focused on the feature
|
||||
- [ ] No unrelated changes bundled in
|
||||
- [ ] Patch files: **append** changes, don't replace entire files
|
||||
|
||||
### 3. Self-Critique Questions
|
||||
- Is the auth resolution chain correct?
|
||||
- Are type changes safe and backwards compatible?
|
||||
- Would this pass review by John Carmack? (clarity > cleverness)
|
||||
|
||||
### 4. Fork Workflow (when applicable)
|
||||
```bash
|
||||
# Push to fork
|
||||
git remote add fork https://github.com/USERNAME/clawdbot
|
||||
git push fork branch-name
|
||||
|
||||
# Create PR from fork
|
||||
gh pr create --head USERNAME:branch-name --base main
|
||||
```
|
||||
|
||||
### 5. Git Diff Interpretation
|
||||
- `-` lines = content being **removed**
|
||||
- `+` lines = content being **added**
|
||||
- Verify you understand what the diff actually shows
|
||||
|
||||
@@ -55,3 +55,16 @@ index 20fb0a22aaa28f7ff7c2f44a8b628fa1d9d7d936..0bf46bfb4a6fac5a0304652e42566b2c
|
||||
const reasoningItem = JSON.parse(block.thinkingSignature);
|
||||
output.push(reasoningItem);
|
||||
}
|
||||
|
||||
diff --git a/dist/stream.js b/dist/stream.js
|
||||
index 0000000..2222222 100644
|
||||
--- a/dist/stream.js
|
||||
+++ b/dist/stream.js
|
||||
@@ -43,6 +43,7 @@ export function getEnvApiKey(provider) {
|
||||
xai: "XAI_API_KEY",
|
||||
openrouter: "OPENROUTER_API_KEY",
|
||||
zai: "ZAI_API_KEY",
|
||||
+ minimax: "MINIMAX_API_KEY",
|
||||
mistral: "MISTRAL_API_KEY",
|
||||
};
|
||||
const envVar = envMap[provider];
|
||||
|
||||
@@ -70,6 +70,7 @@ import { healthCommand } from "./health.js";
|
||||
import { formatHealthCheckFailure } from "./health-format.js";
|
||||
import {
|
||||
applyAuthProfileConfig,
|
||||
applyMinimaxApiConfig,
|
||||
applyMinimaxConfig,
|
||||
applyMinimaxHostedConfig,
|
||||
applyOpencodeZenConfig,
|
||||
@@ -369,6 +370,7 @@ async function promptAuthConfig(
|
||||
| "gemini-api-key"
|
||||
| "apiKey"
|
||||
| "minimax-cloud"
|
||||
| "minimax-api"
|
||||
| "minimax"
|
||||
| "opencode-zen"
|
||||
| "skip";
|
||||
@@ -788,6 +790,21 @@ async function promptAuthConfig(
|
||||
next = applyMinimaxHostedConfig(next);
|
||||
} else if (authChoice === "minimax") {
|
||||
next = applyMinimaxConfig(next);
|
||||
} else if (authChoice === "minimax-api") {
|
||||
const key = guardCancel(
|
||||
await text({
|
||||
message: "Enter MiniMax API key",
|
||||
validate: (value) => (value?.trim() ? undefined : "Required"),
|
||||
}),
|
||||
runtime,
|
||||
);
|
||||
await setMinimaxApiKey(String(key).trim());
|
||||
next = applyAuthProfileConfig(next, {
|
||||
profileId: "minimax:default",
|
||||
provider: "minimax",
|
||||
mode: "api_key",
|
||||
});
|
||||
next = applyMinimaxApiConfig(next);
|
||||
} else if (authChoice === "opencode-zen") {
|
||||
note(
|
||||
[
|
||||
|
||||
@@ -336,7 +336,7 @@ export function applyMinimaxApiProviderConfig(
|
||||
const providers = { ...cfg.models?.providers };
|
||||
providers.minimax = {
|
||||
baseUrl: MINIMAX_API_BASE_URL,
|
||||
apiKey: "", // Resolved via MINIMAX_API_KEY env var or auth profile
|
||||
// apiKey omitted: resolved via MINIMAX_API_KEY env var or auth profile by default.
|
||||
api: "anthropic-messages",
|
||||
models: [buildMinimaxApiModelDefinition(modelId)],
|
||||
};
|
||||
|
||||
@@ -1201,7 +1201,7 @@ export type ModelDefinitionConfig = {
|
||||
|
||||
export type ModelProviderConfig = {
|
||||
baseUrl: string;
|
||||
apiKey: string;
|
||||
apiKey?: string;
|
||||
api?: ModelApi;
|
||||
headers?: Record<string, string>;
|
||||
authHeader?: boolean;
|
||||
|
||||
@@ -40,7 +40,7 @@ const ModelDefinitionSchema = z.object({
|
||||
|
||||
const ModelProviderSchema = z.object({
|
||||
baseUrl: z.string().min(1),
|
||||
apiKey: z.string().min(1),
|
||||
apiKey: z.string().min(1).optional(),
|
||||
api: ModelApiSchema.optional(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
authHeader: z.boolean().optional(),
|
||||
|
||||
Reference in New Issue
Block a user