refactor(config): dedupe model api definitions

This commit is contained in:
Peter Steinberger
2026-02-26 20:00:11 +01:00
parent ac03803d12
commit 344f54b84d
3 changed files with 16 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import {
resolveAgentModelFallbackValues,
resolveAgentModelPrimaryValue,
} from "../config/model-input.js";
import type { ModelApi } from "../config/types.models.js";
import {
applyAuthProfileConfig,
applyLitellmProviderConfig,
@@ -45,7 +46,7 @@ import {
function createLegacyProviderConfig(params: {
providerId: string;
api: "anthropic-messages" | "openai-completions" | "openai-responses";
api: ModelApi;
modelId?: string;
modelName?: string;
baseUrl?: string;

View File

@@ -1,14 +1,17 @@
import type { SecretInput } from "./types.secrets.js";
export type ModelApi =
| "openai-completions"
| "openai-responses"
| "openai-codex-responses"
| "anthropic-messages"
| "google-generative-ai"
| "github-copilot"
| "bedrock-converse-stream"
| "ollama";
export const MODEL_APIS = [
"openai-completions",
"openai-responses",
"openai-codex-responses",
"anthropic-messages",
"google-generative-ai",
"github-copilot",
"bedrock-converse-stream",
"ollama",
] as const;
export type ModelApi = (typeof MODEL_APIS)[number];
export type ModelCompatConfig = {
supportsStore?: boolean;

View File

@@ -2,6 +2,7 @@ import path from "node:path";
import { z } from "zod";
import { isSafeExecutableValue } from "../infra/exec-safety.js";
import { isValidFileSecretRefId } from "../secrets/ref-contract.js";
import { MODEL_APIS } from "./types.models.js";
import { createAllowDenyChannelRulesSchema } from "./zod-schema.allowdeny.js";
import { sensitive } from "./zod-schema.sensitive.js";
@@ -179,16 +180,7 @@ export const SecretsConfigSchema = z
.strict()
.optional();
export const ModelApiSchema = z.union([
z.literal("openai-completions"),
z.literal("openai-responses"),
z.literal("openai-codex-responses"),
z.literal("anthropic-messages"),
z.literal("google-generative-ai"),
z.literal("github-copilot"),
z.literal("bedrock-converse-stream"),
z.literal("ollama"),
]);
export const ModelApiSchema = z.enum(MODEL_APIS);
export const ModelCompatSchema = z
.object({