feat(openclaw): add agents.defaults config support

- Add types for default model config (primary + fallbacks)
- Add types for model catalog/allowlist with aliases
- Extend OpenClawModelEntry with cost and contextWindow fields
- Add Tauri commands: get/set_openclaw_default_model, get/set_openclaw_model_catalog
- Create frontend API (src/lib/api/openclaw.ts)
- Add suggestedDefaults to provider presets with model metadata
- Add i18n translations (zh/en/ja) for openclawConfig.*
This commit is contained in:
Jason
2026-02-04 21:19:13 +08:00
parent 52db7941ea
commit 47f2c47a2f
9 changed files with 595 additions and 21 deletions
+59
View File
@@ -0,0 +1,59 @@
import { invoke } from "@tauri-apps/api/core";
import type {
OpenClawDefaultModel,
OpenClawModelCatalogEntry,
} from "@/types";
/**
* OpenClaw agents configuration API
*
* Manages agents.defaults configuration in ~/.openclaw/openclaw.json
*/
export const openclawApi = {
/**
* Get default model configuration (agents.defaults.model)
*/
async getDefaultModel(): Promise<OpenClawDefaultModel | null> {
return await invoke("get_openclaw_default_model");
},
/**
* Set default model configuration (agents.defaults.model)
*/
async setDefaultModel(model: OpenClawDefaultModel): Promise<void> {
return await invoke("set_openclaw_default_model", { model });
},
/**
* Get model catalog/allowlist (agents.defaults.models)
*/
async getModelCatalog(): Promise<Record<
string,
OpenClawModelCatalogEntry
> | null> {
return await invoke("get_openclaw_model_catalog");
},
/**
* Set model catalog/allowlist (agents.defaults.models)
*/
async setModelCatalog(
catalog: Record<string, OpenClawModelCatalogEntry>,
): Promise<void> {
return await invoke("set_openclaw_model_catalog", { catalog });
},
/**
* Import providers from live config (openclaw.json) to database
*/
async importProvidersFromLive(): Promise<number> {
return await invoke("import_openclaw_providers_from_live");
},
/**
* Get provider IDs that exist in live config (openclaw.json)
*/
async getLiveProviderIds(): Promise<string[]> {
return await invoke("get_openclaw_live_provider_ids");
},
};