Merge 75b164e5cd into 09be5d45d5
This commit is contained in:
commit
f6aa344a18
@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
Status: stable.
|
Status: stable.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
- Model Providers: add Amazon Nova as a provider with OpenAI-compatible chat completion API.
|
||||||
- Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope.
|
- Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope.
|
||||||
- Onboarding: strengthen security warning copy for beta + access control expectations.
|
- Onboarding: strengthen security warning copy for beta + access control expectations.
|
||||||
- Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub.
|
- Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub.
|
||||||
|
|||||||
@ -41,6 +41,7 @@ See [Venice AI](/providers/venice).
|
|||||||
- [Moonshot AI (Kimi + Kimi Code)](/providers/moonshot)
|
- [Moonshot AI (Kimi + Kimi Code)](/providers/moonshot)
|
||||||
- [OpenCode Zen](/providers/opencode)
|
- [OpenCode Zen](/providers/opencode)
|
||||||
- [Amazon Bedrock](/bedrock)
|
- [Amazon Bedrock](/bedrock)
|
||||||
|
- [Amazon Nova](/providers/nova)
|
||||||
- [Z.AI](/providers/zai)
|
- [Z.AI](/providers/zai)
|
||||||
- [Xiaomi](/providers/xiaomi)
|
- [Xiaomi](/providers/xiaomi)
|
||||||
- [GLM models](/providers/glm)
|
- [GLM models](/providers/glm)
|
||||||
|
|||||||
51
docs/providers/nova.md
Normal file
51
docs/providers/nova.md
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
summary: "Use Amazon Nova with Moltbot"
|
||||||
|
read_when:
|
||||||
|
- You want to use Amazon Nova models in Moltbot
|
||||||
|
- You need to configure Nova via API key
|
||||||
|
---
|
||||||
|
# Amazon Nova
|
||||||
|
|
||||||
|
Amazon Nova provides multimodal AI models via an OpenAI-compatible chat completion API. Moltbot supports Nova via API key authentication.
|
||||||
|
|
||||||
|
## Available Models
|
||||||
|
|
||||||
|
- **Nova 2 Lite** (`nova-2-lite-v1`) - Fast multimodal model, 64K context
|
||||||
|
- **Nova 2 Pro** (`nova-2-pro-v1`) - Advanced multimodal model, 64K context
|
||||||
|
|
||||||
|
## CLI setup
|
||||||
|
|
||||||
|
To configure Nova with an API key:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
moltbot onboard --auth-choice nova-api-key
|
||||||
|
# or non-interactive
|
||||||
|
moltbot onboard --nova-api-key "$NOVA_API_KEY"
|
||||||
|
```
|
||||||
|
|
||||||
|
Get your API key at: https://nova.amazon.com/dev/api
|
||||||
|
|
||||||
|
## Config snippet
|
||||||
|
|
||||||
|
```json5
|
||||||
|
{
|
||||||
|
env: { NOVA_API_KEY: "..." },
|
||||||
|
agents: { defaults: { model: { primary: "nova/nova-2-lite-v1" } } },
|
||||||
|
models: {
|
||||||
|
providers: {
|
||||||
|
nova: {
|
||||||
|
baseUrl: "https://api.nova.amazon.com/v1",
|
||||||
|
api: "openai-completions",
|
||||||
|
apiKey: "${NOVA_API_KEY}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Nova models are available under the `nova/` provider prefix.
|
||||||
|
- The default model is `nova/nova-2-lite-v1`.
|
||||||
|
- Nova uses OpenAI-compatible chat completion endpoints.
|
||||||
|
- Nova 2 Lite supports both text and image inputs.
|
||||||
@ -279,6 +279,7 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null {
|
|||||||
openrouter: "OPENROUTER_API_KEY",
|
openrouter: "OPENROUTER_API_KEY",
|
||||||
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
||||||
moonshot: "MOONSHOT_API_KEY",
|
moonshot: "MOONSHOT_API_KEY",
|
||||||
|
nova: "NOVA_API_KEY",
|
||||||
"kimi-code": "KIMICODE_API_KEY",
|
"kimi-code": "KIMICODE_API_KEY",
|
||||||
minimax: "MINIMAX_API_KEY",
|
minimax: "MINIMAX_API_KEY",
|
||||||
xiaomi: "XIAOMI_API_KEY",
|
xiaomi: "XIAOMI_API_KEY",
|
||||||
|
|||||||
@ -64,6 +64,18 @@ const KIMI_CODE_DEFAULT_COST = {
|
|||||||
cacheWrite: 0,
|
cacheWrite: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NOVA_BASE_URL = "https://api.nova.amazon.com/v1";
|
||||||
|
const NOVA_DEFAULT_MODEL_ID = "nova-2-lite-v1";
|
||||||
|
const NOVA_PRO_MODEL_ID = "nova-2-pro-v1";
|
||||||
|
const NOVA_DEFAULT_CONTEXT_WINDOW = 64000;
|
||||||
|
const NOVA_DEFAULT_MAX_TOKENS = 10000;
|
||||||
|
const NOVA_DEFAULT_COST = {
|
||||||
|
input: 0,
|
||||||
|
output: 0,
|
||||||
|
cacheRead: 0,
|
||||||
|
cacheWrite: 0,
|
||||||
|
};
|
||||||
|
|
||||||
const QWEN_PORTAL_BASE_URL = "https://portal.qwen.ai/v1";
|
const QWEN_PORTAL_BASE_URL = "https://portal.qwen.ai/v1";
|
||||||
const QWEN_PORTAL_OAUTH_PLACEHOLDER = "qwen-oauth";
|
const QWEN_PORTAL_OAUTH_PLACEHOLDER = "qwen-oauth";
|
||||||
const QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW = 128000;
|
const QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW = 128000;
|
||||||
@ -379,6 +391,33 @@ async function buildVeniceProvider(): Promise<ProviderConfig> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildNovaProvider(): ProviderConfig {
|
||||||
|
return {
|
||||||
|
baseUrl: NOVA_BASE_URL,
|
||||||
|
api: "openai-completions",
|
||||||
|
models: [
|
||||||
|
{
|
||||||
|
id: NOVA_DEFAULT_MODEL_ID,
|
||||||
|
name: "Nova 2 Lite",
|
||||||
|
reasoning: false,
|
||||||
|
input: ["text", "image"],
|
||||||
|
cost: NOVA_DEFAULT_COST,
|
||||||
|
contextWindow: NOVA_DEFAULT_CONTEXT_WINDOW,
|
||||||
|
maxTokens: NOVA_DEFAULT_MAX_TOKENS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: NOVA_PRO_MODEL_ID,
|
||||||
|
name: "Nova 2 Pro",
|
||||||
|
reasoning: false,
|
||||||
|
input: ["text", "image"],
|
||||||
|
cost: NOVA_DEFAULT_COST,
|
||||||
|
contextWindow: NOVA_DEFAULT_CONTEXT_WINDOW,
|
||||||
|
maxTokens: NOVA_DEFAULT_MAX_TOKENS,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function buildOllamaProvider(): Promise<ProviderConfig> {
|
async function buildOllamaProvider(): Promise<ProviderConfig> {
|
||||||
const models = await discoverOllamaModels();
|
const models = await discoverOllamaModels();
|
||||||
return {
|
return {
|
||||||
@ -431,6 +470,13 @@ export async function resolveImplicitProviders(params: {
|
|||||||
providers.venice = { ...(await buildVeniceProvider()), apiKey: veniceKey };
|
providers.venice = { ...(await buildVeniceProvider()), apiKey: veniceKey };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const novaKey =
|
||||||
|
resolveEnvApiKeyVarName("nova") ??
|
||||||
|
resolveApiKeyFromProfiles({ provider: "nova", store: authStore });
|
||||||
|
if (novaKey) {
|
||||||
|
providers.nova = { ...buildNovaProvider(), apiKey: novaKey };
|
||||||
|
}
|
||||||
|
|
||||||
const qwenProfiles = listProfilesForProvider(authStore, "qwen-portal");
|
const qwenProfiles = listProfilesForProvider(authStore, "qwen-portal");
|
||||||
if (qwenProfiles.length > 0) {
|
if (qwenProfiles.length > 0) {
|
||||||
providers["qwen-portal"] = {
|
providers["qwen-portal"] = {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ export function registerOnboardCommand(program: Command) {
|
|||||||
.option("--mode <mode>", "Wizard mode: local|remote")
|
.option("--mode <mode>", "Wizard mode: local|remote")
|
||||||
.option(
|
.option(
|
||||||
"--auth-choice <choice>",
|
"--auth-choice <choice>",
|
||||||
"Auth: setup-token|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|kimi-code-api-key|synthetic-api-key|venice-api-key|gemini-api-key|zai-api-key|xiaomi-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip",
|
"Auth: setup-token|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|nova-api-key|kimi-code-api-key|synthetic-api-key|venice-api-key|gemini-api-key|zai-api-key|xiaomi-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip",
|
||||||
)
|
)
|
||||||
.option(
|
.option(
|
||||||
"--token-provider <id>",
|
"--token-provider <id>",
|
||||||
@ -69,6 +69,7 @@ export function registerOnboardCommand(program: Command) {
|
|||||||
.option("--openrouter-api-key <key>", "OpenRouter API key")
|
.option("--openrouter-api-key <key>", "OpenRouter API key")
|
||||||
.option("--ai-gateway-api-key <key>", "Vercel AI Gateway API key")
|
.option("--ai-gateway-api-key <key>", "Vercel AI Gateway API key")
|
||||||
.option("--moonshot-api-key <key>", "Moonshot API key")
|
.option("--moonshot-api-key <key>", "Moonshot API key")
|
||||||
|
.option("--nova-api-key <key>", "Amazon Nova API key")
|
||||||
.option("--kimi-code-api-key <key>", "Kimi Code API key")
|
.option("--kimi-code-api-key <key>", "Kimi Code API key")
|
||||||
.option("--gemini-api-key <key>", "Gemini API key")
|
.option("--gemini-api-key <key>", "Gemini API key")
|
||||||
.option("--zai-api-key <key>", "Z.AI API key")
|
.option("--zai-api-key <key>", "Z.AI API key")
|
||||||
@ -120,6 +121,7 @@ export function registerOnboardCommand(program: Command) {
|
|||||||
openrouterApiKey: opts.openrouterApiKey as string | undefined,
|
openrouterApiKey: opts.openrouterApiKey as string | undefined,
|
||||||
aiGatewayApiKey: opts.aiGatewayApiKey as string | undefined,
|
aiGatewayApiKey: opts.aiGatewayApiKey as string | undefined,
|
||||||
moonshotApiKey: opts.moonshotApiKey as string | undefined,
|
moonshotApiKey: opts.moonshotApiKey as string | undefined,
|
||||||
|
novaApiKey: opts.novaApiKey as string | undefined,
|
||||||
kimiCodeApiKey: opts.kimiCodeApiKey as string | undefined,
|
kimiCodeApiKey: opts.kimiCodeApiKey as string | undefined,
|
||||||
geminiApiKey: opts.geminiApiKey as string | undefined,
|
geminiApiKey: opts.geminiApiKey as string | undefined,
|
||||||
zaiApiKey: opts.zaiApiKey as string | undefined,
|
zaiApiKey: opts.zaiApiKey as string | undefined,
|
||||||
|
|||||||
@ -15,6 +15,7 @@ export type AuthChoiceGroupId =
|
|||||||
| "openrouter"
|
| "openrouter"
|
||||||
| "ai-gateway"
|
| "ai-gateway"
|
||||||
| "moonshot"
|
| "moonshot"
|
||||||
|
| "nova"
|
||||||
| "zai"
|
| "zai"
|
||||||
| "xiaomi"
|
| "xiaomi"
|
||||||
| "opencode-zen"
|
| "opencode-zen"
|
||||||
@ -102,6 +103,12 @@ const AUTH_CHOICE_GROUP_DEFS: {
|
|||||||
hint: "Kimi K2 + Kimi Code",
|
hint: "Kimi K2 + Kimi Code",
|
||||||
choices: ["moonshot-api-key", "kimi-code-api-key"],
|
choices: ["moonshot-api-key", "kimi-code-api-key"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: "nova",
|
||||||
|
label: "Amazon Nova",
|
||||||
|
hint: "API key",
|
||||||
|
choices: ["nova-api-key"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: "zai",
|
value: "zai",
|
||||||
label: "Z.AI (GLM 4.7)",
|
label: "Z.AI (GLM 4.7)",
|
||||||
@ -147,6 +154,11 @@ export function buildAuthChoiceOptions(params: {
|
|||||||
label: "Vercel AI Gateway API key",
|
label: "Vercel AI Gateway API key",
|
||||||
});
|
});
|
||||||
options.push({ value: "moonshot-api-key", label: "Moonshot AI API key" });
|
options.push({ value: "moonshot-api-key", label: "Moonshot AI API key" });
|
||||||
|
options.push({
|
||||||
|
value: "nova-api-key",
|
||||||
|
label: "Amazon Nova API key",
|
||||||
|
hint: "Nova chat completion API",
|
||||||
|
});
|
||||||
options.push({ value: "kimi-code-api-key", label: "Kimi Code API key" });
|
options.push({ value: "kimi-code-api-key", label: "Kimi Code API key" });
|
||||||
options.push({ value: "synthetic-api-key", label: "Synthetic API key" });
|
options.push({ value: "synthetic-api-key", label: "Synthetic API key" });
|
||||||
options.push({
|
options.push({
|
||||||
|
|||||||
@ -17,6 +17,8 @@ import {
|
|||||||
applyKimiCodeProviderConfig,
|
applyKimiCodeProviderConfig,
|
||||||
applyMoonshotConfig,
|
applyMoonshotConfig,
|
||||||
applyMoonshotProviderConfig,
|
applyMoonshotProviderConfig,
|
||||||
|
applyNovaConfig,
|
||||||
|
applyNovaProviderConfig,
|
||||||
applyOpencodeZenConfig,
|
applyOpencodeZenConfig,
|
||||||
applyOpencodeZenProviderConfig,
|
applyOpencodeZenProviderConfig,
|
||||||
applyOpenrouterConfig,
|
applyOpenrouterConfig,
|
||||||
@ -32,6 +34,7 @@ import {
|
|||||||
applyZaiConfig,
|
applyZaiConfig,
|
||||||
KIMI_CODE_MODEL_REF,
|
KIMI_CODE_MODEL_REF,
|
||||||
MOONSHOT_DEFAULT_MODEL_REF,
|
MOONSHOT_DEFAULT_MODEL_REF,
|
||||||
|
NOVA_DEFAULT_MODEL_REF,
|
||||||
OPENROUTER_DEFAULT_MODEL_REF,
|
OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
SYNTHETIC_DEFAULT_MODEL_REF,
|
SYNTHETIC_DEFAULT_MODEL_REF,
|
||||||
VENICE_DEFAULT_MODEL_REF,
|
VENICE_DEFAULT_MODEL_REF,
|
||||||
@ -40,6 +43,7 @@ import {
|
|||||||
setGeminiApiKey,
|
setGeminiApiKey,
|
||||||
setKimiCodeApiKey,
|
setKimiCodeApiKey,
|
||||||
setMoonshotApiKey,
|
setMoonshotApiKey,
|
||||||
|
setNovaApiKey,
|
||||||
setOpencodeZenApiKey,
|
setOpencodeZenApiKey,
|
||||||
setOpenrouterApiKey,
|
setOpenrouterApiKey,
|
||||||
setSyntheticApiKey,
|
setSyntheticApiKey,
|
||||||
@ -77,6 +81,8 @@ export async function applyAuthChoiceApiProviders(
|
|||||||
authChoice = "ai-gateway-api-key";
|
authChoice = "ai-gateway-api-key";
|
||||||
} else if (params.opts.tokenProvider === "moonshot") {
|
} else if (params.opts.tokenProvider === "moonshot") {
|
||||||
authChoice = "moonshot-api-key";
|
authChoice = "moonshot-api-key";
|
||||||
|
} else if (params.opts.tokenProvider === "nova") {
|
||||||
|
authChoice = "nova-api-key";
|
||||||
} else if (params.opts.tokenProvider === "kimi-code") {
|
} else if (params.opts.tokenProvider === "kimi-code") {
|
||||||
authChoice = "kimi-code-api-key";
|
authChoice = "kimi-code-api-key";
|
||||||
} else if (params.opts.tokenProvider === "google") {
|
} else if (params.opts.tokenProvider === "google") {
|
||||||
@ -271,6 +277,62 @@ export async function applyAuthChoiceApiProviders(
|
|||||||
return { config: nextConfig, agentModelOverride };
|
return { config: nextConfig, agentModelOverride };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (authChoice === "nova-api-key") {
|
||||||
|
let hasCredential = false;
|
||||||
|
|
||||||
|
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "nova") {
|
||||||
|
await setNovaApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
||||||
|
hasCredential = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasCredential) {
|
||||||
|
await params.prompter.note(
|
||||||
|
[
|
||||||
|
"Amazon Nova provides multimodal AI models via chat completion API.",
|
||||||
|
"Get your API key at: https://nova.amazon.com/dev/api",
|
||||||
|
].join("\n"),
|
||||||
|
"Amazon Nova",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const envKey = resolveEnvApiKey("nova");
|
||||||
|
if (envKey) {
|
||||||
|
const useExisting = await params.prompter.confirm({
|
||||||
|
message: `Use existing NOVA_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
||||||
|
initialValue: true,
|
||||||
|
});
|
||||||
|
if (useExisting) {
|
||||||
|
await setNovaApiKey(envKey.apiKey, params.agentDir);
|
||||||
|
hasCredential = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasCredential) {
|
||||||
|
const key = await params.prompter.text({
|
||||||
|
message: "Enter Amazon Nova API key",
|
||||||
|
validate: validateApiKeyInput,
|
||||||
|
});
|
||||||
|
await setNovaApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
||||||
|
}
|
||||||
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||||
|
profileId: "nova:default",
|
||||||
|
provider: "nova",
|
||||||
|
mode: "api_key",
|
||||||
|
});
|
||||||
|
{
|
||||||
|
const applied = await applyDefaultModelChoice({
|
||||||
|
config: nextConfig,
|
||||||
|
setDefaultModel: params.setDefaultModel,
|
||||||
|
defaultModel: NOVA_DEFAULT_MODEL_REF,
|
||||||
|
applyDefaultConfig: applyNovaConfig,
|
||||||
|
applyProviderConfig: applyNovaProviderConfig,
|
||||||
|
noteAgentModel,
|
||||||
|
prompter: params.prompter,
|
||||||
|
});
|
||||||
|
nextConfig = applied.config;
|
||||||
|
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
||||||
|
}
|
||||||
|
return { config: nextConfig, agentModelOverride };
|
||||||
|
}
|
||||||
|
|
||||||
if (authChoice === "kimi-code-api-key") {
|
if (authChoice === "kimi-code-api-key") {
|
||||||
let hasCredential = false;
|
let hasCredential = false;
|
||||||
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "kimi-code") {
|
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "kimi-code") {
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const PREFERRED_PROVIDER_BY_AUTH_CHOICE: Partial<Record<AuthChoice, string>> = {
|
|||||||
"openrouter-api-key": "openrouter",
|
"openrouter-api-key": "openrouter",
|
||||||
"ai-gateway-api-key": "vercel-ai-gateway",
|
"ai-gateway-api-key": "vercel-ai-gateway",
|
||||||
"moonshot-api-key": "moonshot",
|
"moonshot-api-key": "moonshot",
|
||||||
|
"nova-api-key": "nova",
|
||||||
"kimi-code-api-key": "kimi-code",
|
"kimi-code-api-key": "kimi-code",
|
||||||
"gemini-api-key": "google",
|
"gemini-api-key": "google",
|
||||||
"google-antigravity": "google-antigravity",
|
"google-antigravity": "google-antigravity",
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
} from "../agents/venice-models.js";
|
} from "../agents/venice-models.js";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import {
|
import {
|
||||||
|
NOVA_DEFAULT_MODEL_REF,
|
||||||
OPENROUTER_DEFAULT_MODEL_REF,
|
OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
|
VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
|
||||||
XIAOMI_DEFAULT_MODEL_REF,
|
XIAOMI_DEFAULT_MODEL_REF,
|
||||||
@ -21,12 +22,15 @@ import {
|
|||||||
import {
|
import {
|
||||||
buildKimiCodeModelDefinition,
|
buildKimiCodeModelDefinition,
|
||||||
buildMoonshotModelDefinition,
|
buildMoonshotModelDefinition,
|
||||||
|
buildNovaModelDefinition,
|
||||||
KIMI_CODE_BASE_URL,
|
KIMI_CODE_BASE_URL,
|
||||||
KIMI_CODE_MODEL_ID,
|
KIMI_CODE_MODEL_ID,
|
||||||
KIMI_CODE_MODEL_REF,
|
KIMI_CODE_MODEL_REF,
|
||||||
MOONSHOT_BASE_URL,
|
MOONSHOT_BASE_URL,
|
||||||
MOONSHOT_DEFAULT_MODEL_ID,
|
MOONSHOT_DEFAULT_MODEL_ID,
|
||||||
MOONSHOT_DEFAULT_MODEL_REF,
|
MOONSHOT_DEFAULT_MODEL_REF,
|
||||||
|
NOVA_BASE_URL,
|
||||||
|
NOVA_DEFAULT_MODEL_ID,
|
||||||
} from "./onboard-auth.models.js";
|
} from "./onboard-auth.models.js";
|
||||||
|
|
||||||
export function applyZaiConfig(cfg: OpenClawConfig): OpenClawConfig {
|
export function applyZaiConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
@ -204,6 +208,71 @@ export function applyMoonshotConfig(cfg: OpenClawConfig): OpenClawConfig {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function applyNovaProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
|
const models = { ...cfg.agents?.defaults?.models };
|
||||||
|
models[NOVA_DEFAULT_MODEL_REF] = {
|
||||||
|
...models[NOVA_DEFAULT_MODEL_REF],
|
||||||
|
alias: models[NOVA_DEFAULT_MODEL_REF]?.alias ?? "Nova 2 Lite",
|
||||||
|
};
|
||||||
|
|
||||||
|
const providers = { ...cfg.models?.providers };
|
||||||
|
const existingProvider = providers.nova;
|
||||||
|
const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : [];
|
||||||
|
const defaultModel = buildNovaModelDefinition();
|
||||||
|
const hasDefaultModel = existingModels.some((model) => model.id === NOVA_DEFAULT_MODEL_ID);
|
||||||
|
const mergedModels = hasDefaultModel ? existingModels : [...existingModels, defaultModel];
|
||||||
|
const { apiKey: existingApiKey, ...existingProviderRest } = (existingProvider ?? {}) as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
> as { apiKey?: string };
|
||||||
|
const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined;
|
||||||
|
const normalizedApiKey = resolvedApiKey?.trim();
|
||||||
|
providers.nova = {
|
||||||
|
...existingProviderRest,
|
||||||
|
baseUrl: NOVA_BASE_URL,
|
||||||
|
api: "openai-completions",
|
||||||
|
...(normalizedApiKey ? { apiKey: normalizedApiKey } : {}),
|
||||||
|
models: mergedModels.length > 0 ? mergedModels : [defaultModel],
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...cfg,
|
||||||
|
agents: {
|
||||||
|
...cfg.agents,
|
||||||
|
defaults: {
|
||||||
|
...cfg.agents?.defaults,
|
||||||
|
models,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
models: {
|
||||||
|
mode: cfg.models?.mode ?? "merge",
|
||||||
|
providers,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyNovaConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
|
const next = applyNovaProviderConfig(cfg);
|
||||||
|
const existingModel = next.agents?.defaults?.model;
|
||||||
|
return {
|
||||||
|
...next,
|
||||||
|
agents: {
|
||||||
|
...next.agents,
|
||||||
|
defaults: {
|
||||||
|
...next.agents?.defaults,
|
||||||
|
model: {
|
||||||
|
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
|
||||||
|
? {
|
||||||
|
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||||
|
}
|
||||||
|
: undefined),
|
||||||
|
primary: NOVA_DEFAULT_MODEL_REF,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function applyKimiCodeProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
export function applyKimiCodeProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
const models = { ...cfg.agents?.defaults?.models };
|
const models = { ...cfg.agents?.defaults?.models };
|
||||||
models[KIMI_CODE_MODEL_REF] = {
|
models[KIMI_CODE_MODEL_REF] = {
|
||||||
|
|||||||
@ -73,6 +73,19 @@ export async function setMoonshotApiKey(key: string, agentDir?: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setNovaApiKey(key: string, agentDir?: string) {
|
||||||
|
// Write to resolved agent dir so gateway finds credentials on startup.
|
||||||
|
upsertAuthProfile({
|
||||||
|
profileId: "nova:default",
|
||||||
|
credential: {
|
||||||
|
type: "api_key",
|
||||||
|
provider: "nova",
|
||||||
|
key,
|
||||||
|
},
|
||||||
|
agentDir: resolveAuthAgentDir(agentDir),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function setKimiCodeApiKey(key: string, agentDir?: string) {
|
export async function setKimiCodeApiKey(key: string, agentDir?: string) {
|
||||||
// Write to resolved agent dir so gateway finds credentials on startup.
|
// Write to resolved agent dir so gateway finds credentials on startup.
|
||||||
upsertAuthProfile({
|
upsertAuthProfile({
|
||||||
@ -116,6 +129,7 @@ export const ZAI_DEFAULT_MODEL_REF = "zai/glm-4.7";
|
|||||||
export const XIAOMI_DEFAULT_MODEL_REF = "xiaomi/mimo-v2-flash";
|
export const XIAOMI_DEFAULT_MODEL_REF = "xiaomi/mimo-v2-flash";
|
||||||
export const OPENROUTER_DEFAULT_MODEL_REF = "openrouter/auto";
|
export const OPENROUTER_DEFAULT_MODEL_REF = "openrouter/auto";
|
||||||
export const VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF = "vercel-ai-gateway/anthropic/claude-opus-4.5";
|
export const VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF = "vercel-ai-gateway/anthropic/claude-opus-4.5";
|
||||||
|
export const NOVA_DEFAULT_MODEL_REF = "nova/nova-2-lite-v1";
|
||||||
|
|
||||||
export async function setZaiApiKey(key: string, agentDir?: string) {
|
export async function setZaiApiKey(key: string, agentDir?: string) {
|
||||||
// Write to resolved agent dir so gateway finds credentials on startup.
|
// Write to resolved agent dir so gateway finds credentials on startup.
|
||||||
|
|||||||
@ -20,6 +20,20 @@ export const KIMI_CODE_MAX_TOKENS = 32768;
|
|||||||
export const KIMI_CODE_HEADERS = { "User-Agent": "KimiCLI/0.77" } as const;
|
export const KIMI_CODE_HEADERS = { "User-Agent": "KimiCLI/0.77" } as const;
|
||||||
export const KIMI_CODE_COMPAT = { supportsDeveloperRole: false } as const;
|
export const KIMI_CODE_COMPAT = { supportsDeveloperRole: false } as const;
|
||||||
|
|
||||||
|
export const NOVA_BASE_URL = "https://api.nova.amazon.com/v1";
|
||||||
|
export const NOVA_DEFAULT_MODEL_ID = "nova-2-lite-v1";
|
||||||
|
export const NOVA_PRO_MODEL_ID = "nova-2-pro-v1";
|
||||||
|
export const NOVA_DEFAULT_MODEL_REF = `nova/${NOVA_DEFAULT_MODEL_ID}`;
|
||||||
|
export const NOVA_DEFAULT_CONTEXT_WINDOW = 64000;
|
||||||
|
export const NOVA_DEFAULT_MAX_TOKENS = 10000;
|
||||||
|
|
||||||
|
const NOVA_MODEL_CATALOG = {
|
||||||
|
"nova-2-lite-v1": { name: "Nova 2 Lite" },
|
||||||
|
"nova-2-pro-v1": { name: "Nova 2 Pro" },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type NovaCatalogId = keyof typeof NOVA_MODEL_CATALOG;
|
||||||
|
|
||||||
// Pricing: MiniMax doesn't publish public rates. Override in models.json for accurate costs.
|
// Pricing: MiniMax doesn't publish public rates. Override in models.json for accurate costs.
|
||||||
export const MINIMAX_API_COST = {
|
export const MINIMAX_API_COST = {
|
||||||
input: 15,
|
input: 15,
|
||||||
@ -52,6 +66,13 @@ export const KIMI_CODE_DEFAULT_COST = {
|
|||||||
cacheWrite: 0,
|
cacheWrite: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const NOVA_DEFAULT_COST = {
|
||||||
|
input: 0,
|
||||||
|
output: 0,
|
||||||
|
cacheRead: 0,
|
||||||
|
cacheWrite: 0,
|
||||||
|
};
|
||||||
|
|
||||||
const MINIMAX_MODEL_CATALOG = {
|
const MINIMAX_MODEL_CATALOG = {
|
||||||
"MiniMax-M2.1": { name: "MiniMax M2.1", reasoning: false },
|
"MiniMax-M2.1": { name: "MiniMax M2.1", reasoning: false },
|
||||||
"MiniMax-M2.1-lightning": {
|
"MiniMax-M2.1-lightning": {
|
||||||
@ -116,3 +137,20 @@ export function buildKimiCodeModelDefinition(): ModelDefinitionConfig {
|
|||||||
compat: KIMI_CODE_COMPAT,
|
compat: KIMI_CODE_COMPAT,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildNovaModelDefinition(
|
||||||
|
modelId: string = NOVA_DEFAULT_MODEL_ID,
|
||||||
|
): ModelDefinitionConfig {
|
||||||
|
const catalog = NOVA_MODEL_CATALOG[modelId as NovaCatalogId];
|
||||||
|
return {
|
||||||
|
id: modelId,
|
||||||
|
name: catalog?.name ?? "Nova 2 Lite",
|
||||||
|
reasoning: false,
|
||||||
|
input: ["text", "image"],
|
||||||
|
cost: NOVA_DEFAULT_COST,
|
||||||
|
contextWindow: NOVA_DEFAULT_CONTEXT_WINDOW,
|
||||||
|
maxTokens: NOVA_DEFAULT_MAX_TOKENS,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const NOVA_MODEL_IDS = Object.keys(NOVA_MODEL_CATALOG) as NovaCatalogId[];
|
||||||
|
|||||||
@ -9,6 +9,8 @@ export {
|
|||||||
applyKimiCodeProviderConfig,
|
applyKimiCodeProviderConfig,
|
||||||
applyMoonshotConfig,
|
applyMoonshotConfig,
|
||||||
applyMoonshotProviderConfig,
|
applyMoonshotProviderConfig,
|
||||||
|
applyNovaConfig,
|
||||||
|
applyNovaProviderConfig,
|
||||||
applyOpenrouterConfig,
|
applyOpenrouterConfig,
|
||||||
applyOpenrouterProviderConfig,
|
applyOpenrouterProviderConfig,
|
||||||
applySyntheticConfig,
|
applySyntheticConfig,
|
||||||
@ -35,12 +37,14 @@ export {
|
|||||||
applyOpencodeZenProviderConfig,
|
applyOpencodeZenProviderConfig,
|
||||||
} from "./onboard-auth.config-opencode.js";
|
} from "./onboard-auth.config-opencode.js";
|
||||||
export {
|
export {
|
||||||
|
NOVA_DEFAULT_MODEL_REF,
|
||||||
OPENROUTER_DEFAULT_MODEL_REF,
|
OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
setAnthropicApiKey,
|
setAnthropicApiKey,
|
||||||
setGeminiApiKey,
|
setGeminiApiKey,
|
||||||
setKimiCodeApiKey,
|
setKimiCodeApiKey,
|
||||||
setMinimaxApiKey,
|
setMinimaxApiKey,
|
||||||
setMoonshotApiKey,
|
setMoonshotApiKey,
|
||||||
|
setNovaApiKey,
|
||||||
setOpencodeZenApiKey,
|
setOpencodeZenApiKey,
|
||||||
setOpenrouterApiKey,
|
setOpenrouterApiKey,
|
||||||
setSyntheticApiKey,
|
setSyntheticApiKey,
|
||||||
@ -58,6 +62,7 @@ export {
|
|||||||
buildMinimaxApiModelDefinition,
|
buildMinimaxApiModelDefinition,
|
||||||
buildMinimaxModelDefinition,
|
buildMinimaxModelDefinition,
|
||||||
buildMoonshotModelDefinition,
|
buildMoonshotModelDefinition,
|
||||||
|
buildNovaModelDefinition,
|
||||||
DEFAULT_MINIMAX_BASE_URL,
|
DEFAULT_MINIMAX_BASE_URL,
|
||||||
KIMI_CODE_BASE_URL,
|
KIMI_CODE_BASE_URL,
|
||||||
KIMI_CODE_MODEL_ID,
|
KIMI_CODE_MODEL_ID,
|
||||||
@ -68,4 +73,6 @@ export {
|
|||||||
MOONSHOT_BASE_URL,
|
MOONSHOT_BASE_URL,
|
||||||
MOONSHOT_DEFAULT_MODEL_ID,
|
MOONSHOT_DEFAULT_MODEL_ID,
|
||||||
MOONSHOT_DEFAULT_MODEL_REF,
|
MOONSHOT_DEFAULT_MODEL_REF,
|
||||||
|
NOVA_BASE_URL,
|
||||||
|
NOVA_DEFAULT_MODEL_ID,
|
||||||
} from "./onboard-auth.models.js";
|
} from "./onboard-auth.models.js";
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import {
|
|||||||
applyMinimaxApiConfig,
|
applyMinimaxApiConfig,
|
||||||
applyMinimaxConfig,
|
applyMinimaxConfig,
|
||||||
applyMoonshotConfig,
|
applyMoonshotConfig,
|
||||||
|
applyNovaConfig,
|
||||||
applyOpencodeZenConfig,
|
applyOpencodeZenConfig,
|
||||||
applyOpenrouterConfig,
|
applyOpenrouterConfig,
|
||||||
applySyntheticConfig,
|
applySyntheticConfig,
|
||||||
@ -24,6 +25,7 @@ import {
|
|||||||
setKimiCodeApiKey,
|
setKimiCodeApiKey,
|
||||||
setMinimaxApiKey,
|
setMinimaxApiKey,
|
||||||
setMoonshotApiKey,
|
setMoonshotApiKey,
|
||||||
|
setNovaApiKey,
|
||||||
setOpencodeZenApiKey,
|
setOpencodeZenApiKey,
|
||||||
setOpenrouterApiKey,
|
setOpenrouterApiKey,
|
||||||
setSyntheticApiKey,
|
setSyntheticApiKey,
|
||||||
@ -273,6 +275,25 @@ export async function applyNonInteractiveAuthChoice(params: {
|
|||||||
return applyMoonshotConfig(nextConfig);
|
return applyMoonshotConfig(nextConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (authChoice === "nova-api-key") {
|
||||||
|
const resolved = await resolveNonInteractiveApiKey({
|
||||||
|
provider: "nova",
|
||||||
|
cfg: baseConfig,
|
||||||
|
flagValue: opts.novaApiKey,
|
||||||
|
flagName: "--nova-api-key",
|
||||||
|
envVar: "NOVA_API_KEY",
|
||||||
|
runtime,
|
||||||
|
});
|
||||||
|
if (!resolved) return null;
|
||||||
|
if (resolved.source !== "profile") await setNovaApiKey(resolved.key);
|
||||||
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||||
|
profileId: "nova:default",
|
||||||
|
provider: "nova",
|
||||||
|
mode: "api_key",
|
||||||
|
});
|
||||||
|
return applyNovaConfig(nextConfig);
|
||||||
|
}
|
||||||
|
|
||||||
if (authChoice === "kimi-code-api-key") {
|
if (authChoice === "kimi-code-api-key") {
|
||||||
const resolved = await resolveNonInteractiveApiKey({
|
const resolved = await resolveNonInteractiveApiKey({
|
||||||
provider: "kimi-code",
|
provider: "kimi-code",
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export type AuthChoice =
|
|||||||
| "openrouter-api-key"
|
| "openrouter-api-key"
|
||||||
| "ai-gateway-api-key"
|
| "ai-gateway-api-key"
|
||||||
| "moonshot-api-key"
|
| "moonshot-api-key"
|
||||||
|
| "nova-api-key"
|
||||||
| "kimi-code-api-key"
|
| "kimi-code-api-key"
|
||||||
| "synthetic-api-key"
|
| "synthetic-api-key"
|
||||||
| "venice-api-key"
|
| "venice-api-key"
|
||||||
@ -65,6 +66,7 @@ export type OnboardOptions = {
|
|||||||
openrouterApiKey?: string;
|
openrouterApiKey?: string;
|
||||||
aiGatewayApiKey?: string;
|
aiGatewayApiKey?: string;
|
||||||
moonshotApiKey?: string;
|
moonshotApiKey?: string;
|
||||||
|
novaApiKey?: string;
|
||||||
kimiCodeApiKey?: string;
|
kimiCodeApiKey?: string;
|
||||||
geminiApiKey?: string;
|
geminiApiKey?: string;
|
||||||
zaiApiKey?: string;
|
zaiApiKey?: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user