fix: 校正实时探针可选工具事件合同
This commit is contained in:
@@ -206,6 +206,10 @@ export interface HwlabRuntimeWebProbeRealtimeFanoutProfileSpec {
|
||||
agentrun: readonly string[];
|
||||
hwlab: readonly string[];
|
||||
}>;
|
||||
readonly conditionalEventTypePairs: Readonly<Record<string, Readonly<{
|
||||
agentrun: string;
|
||||
hwlab: string;
|
||||
}>>>;
|
||||
}
|
||||
|
||||
export interface HwlabRuntimeWebProbeAuthLoginSpec {
|
||||
@@ -1514,6 +1518,24 @@ function webProbeRealtimeFanoutProfileConfig(value: unknown, path: string): Hwla
|
||||
const hwlabEventTypes = nonEmptyStringArrayField(requiredEventTypes, "hwlab", `${path}.requiredEventTypes`);
|
||||
if (new Set(agentrunEventTypes).size !== agentrunEventTypes.length) throw new Error(`${path}.requiredEventTypes.agentrun must not contain duplicates`);
|
||||
if (new Set(hwlabEventTypes).size !== hwlabEventTypes.length) throw new Error(`${path}.requiredEventTypes.hwlab must not contain duplicates`);
|
||||
const conditionalEventTypePairsRaw = asRecord(raw.conditionalEventTypePairs, `${path}.conditionalEventTypePairs`);
|
||||
if (Object.keys(conditionalEventTypePairsRaw).length === 0) throw new Error(`${path}.conditionalEventTypePairs must contain at least one pair`);
|
||||
const conditionalEventTypePairs = Object.fromEntries(Object.entries(conditionalEventTypePairsRaw).map(([id, value]) => {
|
||||
if (!/^[a-z][a-z0-9-]*$/u.test(id)) throw new Error(`${path}.conditionalEventTypePairs.${id} must use a stable lowercase id`);
|
||||
const pairPath = `${path}.conditionalEventTypePairs.${id}`;
|
||||
const pair = asRecord(value, pairPath);
|
||||
const unknownFields = Object.keys(pair).filter((field) => field !== "agentrun" && field !== "hwlab");
|
||||
if (unknownFields.length > 0) throw new Error(`${pairPath}.${unknownFields[0]} is not allowed`);
|
||||
const agentrun = stringField(pair, "agentrun", pairPath);
|
||||
const hwlab = stringField(pair, "hwlab", pairPath);
|
||||
if (agentrunEventTypes.includes(agentrun)) throw new Error(`${pairPath}.agentrun duplicates a required event type`);
|
||||
if (hwlabEventTypes.includes(hwlab)) throw new Error(`${pairPath}.hwlab duplicates a required event type`);
|
||||
return [id, { agentrun, hwlab }];
|
||||
}));
|
||||
const conditionalAgentrunTypes = Object.values(conditionalEventTypePairs).map((pair) => pair.agentrun);
|
||||
const conditionalHwlabTypes = Object.values(conditionalEventTypePairs).map((pair) => pair.hwlab);
|
||||
if (new Set(conditionalAgentrunTypes).size !== conditionalAgentrunTypes.length) throw new Error(`${path}.conditionalEventTypePairs agentrun types must not contain duplicates`);
|
||||
if (new Set(conditionalHwlabTypes).size !== conditionalHwlabTypes.length) throw new Error(`${path}.conditionalEventTypePairs hwlab types must not contain duplicates`);
|
||||
return {
|
||||
subscriberCount: 2,
|
||||
debugStreams: debugStreams as ("stdio" | "agentrun" | "hwlab")[],
|
||||
@@ -1535,6 +1557,7 @@ function webProbeRealtimeFanoutProfileConfig(value: unknown, path: string): Hwla
|
||||
agentrun: agentrunEventTypes,
|
||||
hwlab: hwlabEventTypes,
|
||||
},
|
||||
conditionalEventTypePairs,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user