feat(providers): add Bailian Coding Plan provider with editable base URL (#467)

This commit is contained in:
diegosouzapw
2026-03-19 02:25:29 -03:00
parent a09b298127
commit 246fd05fae
13 changed files with 1195 additions and 10 deletions

View File

@@ -33,6 +33,7 @@ export const API_ENDPOINTS = {
export const PROVIDER_ENDPOINTS = {
openrouter: "https://openrouter.ai/api/v1/chat/completions",
glm: "https://api.z.ai/api/anthropic/v1/messages",
"bailian-coding-plan": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages",
kimi: "https://api.moonshot.ai/v1/chat/completions",
"kimi-coding": "https://api.kimi.com/coding/v1/messages",
"kimi-coding-apikey": "https://api.kimi.com/coding/v1/messages",

View File

@@ -74,6 +74,15 @@ export const APIKEY_PROVIDERS = {
textIcon: "GL",
website: "https://open.bigmodel.cn",
},
"bailian-coding-plan": {
id: "bailian-coding-plan",
alias: "bcp",
name: "Alibaba Coding Plan",
icon: "code",
color: "#FF6A00",
textIcon: "BCP",
website: "https://www.alibabacloud.com/help/en/model-studio/coding-plan",
},
kimi: {
id: "kimi",
alias: "kimi",

View File

@@ -1,5 +1,14 @@
import { z } from "zod";
function isHttpUrl(value: string): boolean {
try {
const parsed = new URL(value);
return parsed.protocol === "http:" || parsed.protocol === "https:";
} catch {
return false;
}
}
// Re-export validation helpers from dedicated module to avoid webpack barrel-file
// optimization bug that truncates exports from large files.
export { validateBody, isValidationFailure } from "./helpers";
@@ -15,6 +24,21 @@ export const createProviderSchema = z.object({
globalPriority: z.number().int().min(1).max(100).nullable().optional(),
defaultModel: z.string().max(200).nullable().optional(),
testStatus: z.string().max(50).optional(),
providerSpecificData: z
.record(z.string(), z.unknown())
.optional()
.superRefine((data, ctx) => {
if (!data) return;
const baseUrl = data.baseUrl;
if (baseUrl === undefined) return;
if (typeof baseUrl !== "string" || !isHttpUrl(baseUrl)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "providerSpecificData.baseUrl must be a valid http(s) URL",
path: ["baseUrl"],
});
}
}),
});
// ──── API Key Schemas ────
@@ -945,7 +969,21 @@ export const updateProviderConnectionSchema = z
healthCheckInterval: z.coerce.number().int().min(0).optional(),
group: z.union([z.string().max(100), z.null()]).optional(),
// Partial patch of per-connection provider-specific settings (e.g. quota toggles)
providerSpecificData: z.record(z.string(), z.unknown()).optional(),
providerSpecificData: z
.record(z.string(), z.unknown())
.optional()
.superRefine((data, ctx) => {
if (!data) return;
const baseUrl = data.baseUrl;
if (baseUrl === undefined) return;
if (typeof baseUrl !== "string" || !isHttpUrl(baseUrl)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "providerSpecificData.baseUrl must be a valid http(s) URL",
path: ["baseUrl"],
});
}
}),
})
.superRefine((value, ctx) => {
if (Object.keys(value).length === 0) {