patch({ priorityDemoteKeywords: value })} />
)}
+
+ {activeStrategy === 'singleSource' && (
+
+ patch({ singleSourceProtectionEnabled: checked })}
+ />
+ 本次调度只有一个可用源时,命中自动禁用、运行策略冷却或故障切换冷却动作都只记录保护事件,不修改平台或模型状态。
+
+ )}
@@ -554,6 +573,7 @@ function runnerPolicyToForm(policy: GatewayRunnerPolicy | null): RunnerPolicyFor
const failover = readObject(policy?.failoverPolicy);
const hardStop = readObject(policy?.hardStopPolicy);
const priorityDemote = readObject(policy?.priorityDemotePolicy);
+ const singleSource = readObject(policy?.singleSourcePolicy);
return {
name: policy?.name ?? '默认全局调度策略',
description: policy?.description ?? '控制多个候选平台之间的故障切换;模型运行策略只可覆盖 failoverPolicy,不能覆盖 hardStopPolicy。',
@@ -579,6 +599,7 @@ function runnerPolicyToForm(policy: GatewayRunnerPolicy | null): RunnerPolicyFor
priorityDemoteCodes: tagsFromValue(priorityDemote.codes ?? ['network', 'timeout', 'stream_read_error', 'rate_limit', 'server_error', 'overloaded']),
priorityDemoteStatusCodes: tagsFromValue(priorityDemote.statusCodes ?? [408, 429, 500, 502, 503, 504]),
priorityDemoteKeywords: tagsFromValue(priorityDemote.keywords ?? ['timeout', 'network', 'rate_limit', 'overloaded', 'temporarily_unavailable', 'server_error', '429', '5xx']),
+ singleSourceProtectionEnabled: readBool(singleSource.enabled, true),
metadataJson: JSON.stringify(policy?.metadata ?? {}, null, 2),
status: policy?.status ?? 'active',
};
@@ -617,6 +638,9 @@ function runnerFormToPayload(form: RunnerPolicyForm): GatewayRunnerPolicyUpsertR
statusCodes: parseNumberTags(form.priorityDemoteStatusCodes),
keywords: cleanTags(form.priorityDemoteKeywords),
},
+ singleSourcePolicy: {
+ enabled: form.singleSourceProtectionEnabled,
+ },
metadata: parseJson(form.metadataJson),
status: form.status.trim() || 'active',
};
diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts
index d85714b..7f2c2b8 100644
--- a/packages/contracts/src/index.ts
+++ b/packages/contracts/src/index.ts
@@ -282,6 +282,7 @@ export interface GatewayRunnerPolicy {
failoverPolicy?: Record;
hardStopPolicy?: Record;
priorityDemotePolicy?: Record;
+ singleSourcePolicy?: Record;
metadata?: Record;
status: 'active' | 'disabled' | string;
createdAt: string;
@@ -295,6 +296,7 @@ export interface GatewayRunnerPolicyUpsertRequest {
failoverPolicy?: Record;
hardStopPolicy?: Record;
priorityDemotePolicy?: Record;
+ singleSourcePolicy?: Record;
metadata?: Record;
status?: 'active' | 'disabled' | string;
}