chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -5,10 +5,7 @@ import {
|
||||
SYNTHETIC_MODEL_CATALOG,
|
||||
} from "../agents/synthetic-models.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import {
|
||||
OPENROUTER_DEFAULT_MODEL_REF,
|
||||
ZAI_DEFAULT_MODEL_REF,
|
||||
} from "./onboard-auth.credentials.js";
|
||||
import { OPENROUTER_DEFAULT_MODEL_REF, ZAI_DEFAULT_MODEL_REF } from "./onboard-auth.credentials.js";
|
||||
import {
|
||||
buildMoonshotModelDefinition,
|
||||
MOONSHOT_BASE_URL,
|
||||
@@ -32,11 +29,9 @@ export function applyZaiConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
...cfg.agents?.defaults,
|
||||
models,
|
||||
model: {
|
||||
...(existingModel &&
|
||||
"fallbacks" in (existingModel as Record<string, unknown>)
|
||||
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
|
||||
? {
|
||||
fallbacks: (existingModel as { fallbacks?: string[] })
|
||||
.fallbacks,
|
||||
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||
}
|
||||
: undefined),
|
||||
primary: ZAI_DEFAULT_MODEL_REF,
|
||||
@@ -46,9 +41,7 @@ export function applyZaiConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export function applyOpenrouterProviderConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
): ClawdbotConfig {
|
||||
export function applyOpenrouterProviderConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
const models = { ...cfg.agents?.defaults?.models };
|
||||
models[OPENROUTER_DEFAULT_MODEL_REF] = {
|
||||
...models[OPENROUTER_DEFAULT_MODEL_REF],
|
||||
@@ -77,11 +70,9 @@ export function applyOpenrouterConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
defaults: {
|
||||
...next.agents?.defaults,
|
||||
model: {
|
||||
...(existingModel &&
|
||||
"fallbacks" in (existingModel as Record<string, unknown>)
|
||||
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
|
||||
? {
|
||||
fallbacks: (existingModel as { fallbacks?: string[] })
|
||||
.fallbacks,
|
||||
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||
}
|
||||
: undefined),
|
||||
primary: OPENROUTER_DEFAULT_MODEL_REF,
|
||||
@@ -91,9 +82,7 @@ export function applyOpenrouterConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export function applyMoonshotProviderConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
): ClawdbotConfig {
|
||||
export function applyMoonshotProviderConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
const models = { ...cfg.agents?.defaults?.models };
|
||||
models[MOONSHOT_DEFAULT_MODEL_REF] = {
|
||||
...models[MOONSHOT_DEFAULT_MODEL_REF],
|
||||
@@ -102,20 +91,15 @@ export function applyMoonshotProviderConfig(
|
||||
|
||||
const providers = { ...cfg.models?.providers };
|
||||
const existingProvider = providers.moonshot;
|
||||
const existingModels = Array.isArray(existingProvider?.models)
|
||||
? existingProvider.models
|
||||
: [];
|
||||
const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : [];
|
||||
const defaultModel = buildMoonshotModelDefinition();
|
||||
const hasDefaultModel = existingModels.some(
|
||||
(model) => model.id === MOONSHOT_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 hasDefaultModel = existingModels.some((model) => model.id === MOONSHOT_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.moonshot = {
|
||||
...existingProviderRest,
|
||||
@@ -151,11 +135,9 @@ export function applyMoonshotConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
defaults: {
|
||||
...next.agents?.defaults,
|
||||
model: {
|
||||
...(existingModel &&
|
||||
"fallbacks" in (existingModel as Record<string, unknown>)
|
||||
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
|
||||
? {
|
||||
fallbacks: (existingModel as { fallbacks?: string[] })
|
||||
.fallbacks,
|
||||
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||
}
|
||||
: undefined),
|
||||
primary: MOONSHOT_DEFAULT_MODEL_REF,
|
||||
@@ -165,9 +147,7 @@ export function applyMoonshotConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export function applySyntheticProviderConfig(
|
||||
cfg: ClawdbotConfig,
|
||||
): ClawdbotConfig {
|
||||
export function applySyntheticProviderConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
const models = { ...cfg.agents?.defaults?.models };
|
||||
models[SYNTHETIC_DEFAULT_MODEL_REF] = {
|
||||
...models[SYNTHETIC_DEFAULT_MODEL_REF],
|
||||
@@ -176,22 +156,19 @@ export function applySyntheticProviderConfig(
|
||||
|
||||
const providers = { ...cfg.models?.providers };
|
||||
const existingProvider = providers.synthetic;
|
||||
const existingModels = Array.isArray(existingProvider?.models)
|
||||
? existingProvider.models
|
||||
: [];
|
||||
const syntheticModels = SYNTHETIC_MODEL_CATALOG.map(
|
||||
buildSyntheticModelDefinition,
|
||||
);
|
||||
const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : [];
|
||||
const syntheticModels = SYNTHETIC_MODEL_CATALOG.map(buildSyntheticModelDefinition);
|
||||
const mergedModels = [
|
||||
...existingModels,
|
||||
...syntheticModels.filter(
|
||||
(model) => !existingModels.some((existing) => existing.id === model.id),
|
||||
),
|
||||
];
|
||||
const { apiKey: existingApiKey, ...existingProviderRest } =
|
||||
(existingProvider ?? {}) as Record<string, unknown> as { apiKey?: string };
|
||||
const resolvedApiKey =
|
||||
typeof existingApiKey === "string" ? existingApiKey : undefined;
|
||||
const { apiKey: existingApiKey, ...existingProviderRest } = (existingProvider ?? {}) as Record<
|
||||
string,
|
||||
unknown
|
||||
> as { apiKey?: string };
|
||||
const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined;
|
||||
const normalizedApiKey = resolvedApiKey?.trim();
|
||||
providers.synthetic = {
|
||||
...existingProviderRest,
|
||||
@@ -227,11 +204,9 @@ export function applySyntheticConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||
defaults: {
|
||||
...next.agents?.defaults,
|
||||
model: {
|
||||
...(existingModel &&
|
||||
"fallbacks" in (existingModel as Record<string, unknown>)
|
||||
...(existingModel && "fallbacks" in (existingModel as Record<string, unknown>)
|
||||
? {
|
||||
fallbacks: (existingModel as { fallbacks?: string[] })
|
||||
.fallbacks,
|
||||
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||
}
|
||||
: undefined),
|
||||
primary: SYNTHETIC_DEFAULT_MODEL_REF,
|
||||
@@ -268,9 +243,7 @@ export function applyAuthProfileConfig(
|
||||
existingProviderOrder && preferProfileFirst
|
||||
? [
|
||||
params.profileId,
|
||||
...existingProviderOrder.filter(
|
||||
(profileId) => profileId !== params.profileId,
|
||||
),
|
||||
...existingProviderOrder.filter((profileId) => profileId !== params.profileId),
|
||||
]
|
||||
: existingProviderOrder;
|
||||
const order =
|
||||
|
||||
Reference in New Issue
Block a user