mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 16:56:16 +08:00
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:
@@ -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");
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user