feat: 将 ofcx-go backend 收敛为 dsflash-go

This commit is contained in:
Codex
2026-06-08 01:38:50 +08:00
parent eef59c74ee
commit 41886aef80
14 changed files with 115 additions and 36 deletions
+38
View File
@@ -137,6 +137,39 @@ ON CONFLICT (profile) DO UPDATE SET
updated_at = EXCLUDED.updated_at;
`;
const dsflashGoBackendProfileMigrationSql = `
UPDATE agentrun_runs SET backend_profile = 'dsflash-go' WHERE backend_profile = 'ofcx-go';
UPDATE agentrun_sessions SET backend_profile = 'dsflash-go' WHERE backend_profile = 'ofcx-go';
UPDATE agentrun_runners SET backend_profile = 'dsflash-go' WHERE backend_profile = 'ofcx-go';
UPDATE agentrun_queue_tasks SET backend_profile = 'dsflash-go' WHERE backend_profile = 'ofcx-go';
UPDATE agentrun_runs
SET execution_policy = replace(replace(replace(execution_policy::text,
'"profile": "ofcx-go"',
'"profile": "dsflash-go"'),
'agentrun-v01-provider-ofcx-go',
'agentrun-v01-provider-dsflash-go'),
'/home/agentrun/.codex-ofcx-go',
'/home/agentrun/.codex-dsflash-go')::jsonb
WHERE execution_policy::text LIKE '%ofcx-go%';
UPDATE agentrun_queue_tasks
SET execution_policy = replace(replace(replace(execution_policy::text,
'"profile": "ofcx-go"',
'"profile": "dsflash-go"'),
'agentrun-v01-provider-ofcx-go',
'agentrun-v01-provider-dsflash-go'),
'/home/agentrun/.codex-ofcx-go',
'/home/agentrun/.codex-dsflash-go')::jsonb
WHERE execution_policy IS NOT NULL AND execution_policy::text LIKE '%ofcx-go%';
DELETE FROM agentrun_backends WHERE profile = 'ofcx-go';
INSERT INTO agentrun_backends (profile, capabilities, capacity, health, updated_at)
VALUES ${backendCapabilitiesSqlValues(["dsflash-go"])}
ON CONFLICT (profile) DO UPDATE SET
capabilities = EXCLUDED.capabilities,
capacity = EXCLUDED.capacity,
health = EXCLUDED.health,
updated_at = EXCLUDED.updated_at;
`;
const sessionControlMigrationSql = `
ALTER TABLE agentrun_sessions ADD COLUMN IF NOT EXISTS version bigint NOT NULL DEFAULT 1;
ALTER TABLE agentrun_sessions ADD COLUMN IF NOT EXISTS execution_state text NOT NULL DEFAULT 'idle';
@@ -322,6 +355,11 @@ const postgresMigrations: MigrationDefinition[] = [
checksum: checksumSql(sessionStateStorageMigrationSql),
sql: sessionStateStorageMigrationSql,
},
{
id: "008_v01_dsflash_go_backend_profile",
checksum: checksumSql(dsflashGoBackendProfileMigrationSql),
sql: dsflashGoBackendProfileMigrationSql,
},
];
export function postgresMigrationContract(): JsonRecord {
+19 -11
View File
@@ -122,7 +122,7 @@ export async function setProviderProfileConfig(profileValue: string, body: unkno
configHashSuffix: shortHash(configToml),
updatedAt: objectPath(applied, ["metadata", "annotations", `${credentialAnnotationPrefix}-updated-at`]) ?? new Date().toISOString(),
delegatedBy,
requiresExternalBridgeUpdate: profile === "deepseek",
requiresExternalBridgeUpdate: profile === "deepseek" || profile === "dsflash-go",
configTomlPrinted: false,
credentialValuesPrinted: false,
valuesPrinted: false,
@@ -180,7 +180,7 @@ export async function setProviderProfileCredential(profileValue: string, body: u
updatedAt: objectPath(applied, ["metadata", "annotations", `${credentialAnnotationPrefix}-updated-at`]) ?? new Date().toISOString(),
configSummary: rendered.config.configSummary,
delegatedBy,
requiresExternalBridgeUpdate: profile === "deepseek",
requiresExternalBridgeUpdate: profile === "deepseek" || profile === "dsflash-go",
valuesPrinted: false,
pollCommands: {
show: `./scripts/agentrun provider-profiles show ${profile}`,
@@ -297,14 +297,15 @@ function authPayload(apiKey: string): JsonRecord {
}
function renderConfigToml(config: ProfileConfig): string {
const { contextWindow, autoCompactTokenLimit } = contextWindowSettings(config.model);
return [
`model_provider = ${tomlString(config.providerName)}`,
`model = ${tomlString(config.model)}`,
`review_model = ${tomlString(config.model)}`,
"disable_response_storage = true",
"network_access = \"enabled\"",
"model_context_window = 128000",
"model_auto_compact_token_limit = 110000",
`model_context_window = ${contextWindow}`,
`model_auto_compact_token_limit = ${autoCompactTokenLimit}`,
"approvals_reviewer = \"user\"",
"",
`[model_providers.${config.providerName}]`,
@@ -368,8 +369,8 @@ async function existingConfigToml(profile: BackendProfile, options: ProviderProf
function existingConfigAllowed(profile: BackendProfile, configToml: string): boolean {
if (configToml.trim().length === 0) return false;
if (profile === "deepseek" && configToml.includes("hyueapi.com")) return false;
if (profile === "deepseek" && !configToml.includes("hwlab-deepseek-proxy.hwlab-v02.svc.cluster.local")) return false;
if ((profile === "deepseek" || profile === "dsflash-go") && configToml.includes("hyueapi.com")) return false;
if ((profile === "deepseek" || profile === "dsflash-go") && !configToml.includes("hwlab-deepseek-proxy.hwlab-v02.svc.cluster.local")) return false;
return true;
}
@@ -414,7 +415,7 @@ function defaultConfig(profile: BackendProfile): ProfileConfig {
displayName: "OpenAI",
};
}
if (profile === "ofcx-go") {
if (profile === "dsflash-go") {
return {
model: "deepseek-v4-flash",
providerName: "opencode",
@@ -451,14 +452,21 @@ function validateBaseUrl(profile: BackendProfile, value: string): void {
} catch {
throw new AgentRunError("schema-invalid", "config.baseUrl must be a valid URL", { httpStatus: 400 });
}
if (profile === "deepseek" && url.hostname === "hyueapi.com") {
throw new AgentRunError("tenant-policy-denied", "deepseek profile must use HWLAB Moon Bridge, not hyueapi.com", { httpStatus: 403 });
if ((profile === "deepseek" || profile === "dsflash-go") && url.hostname === "hyueapi.com") {
throw new AgentRunError("tenant-policy-denied", `${profile} profile must use HWLAB Moon Bridge, not hyueapi.com`, { httpStatus: 403 });
}
if (profile === "deepseek" && url.hostname !== "hwlab-deepseek-proxy.hwlab-v02.svc.cluster.local") {
throw new AgentRunError("tenant-policy-denied", "deepseek profile baseUrl must point to HWLAB v0.2 Moon Bridge", { httpStatus: 403 });
if ((profile === "deepseek" || profile === "dsflash-go") && url.hostname !== "hwlab-deepseek-proxy.hwlab-v02.svc.cluster.local") {
throw new AgentRunError("tenant-policy-denied", `${profile} profile baseUrl must point to HWLAB v0.2 Moon Bridge`, { httpStatus: 403 });
}
}
function contextWindowSettings(model: string): { contextWindow: number; autoCompactTokenLimit: number } {
if (model === "deepseek-v4-pro" || model === "deepseek-v4-flash") {
return { contextWindow: 1_000_000, autoCompactTokenLimit: 900_000 };
}
return { contextWindow: 200_000, autoCompactTokenLimit: 180_000 };
}
function validationExecutionPolicy(profile: BackendProfile, namespace: string): ExecutionPolicy {
const spec = requiredSpec(profile);
return {