Files
openclaw-zero-token/flows/types.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

57 lines
1.5 KiB
TypeScript

export type FlowDocsLink = {
path: string;
label?: string;
};
export type FlowContributionKind = "channel" | "core" | "provider" | "search";
export type FlowContributionSurface = "auth-choice" | "health" | "model-picker" | "setup";
export type FlowOptionGroup = {
id: string;
label: string;
hint?: string;
};
export type FlowOption<Value extends string = string> = {
value: Value;
label: string;
hint?: string;
group?: FlowOptionGroup;
docs?: FlowDocsLink;
};
export type FlowContribution<Value extends string = string> = {
id: string;
kind: FlowContributionKind;
surface: FlowContributionSurface;
option: FlowOption<Value>;
source?: string;
};
export function mergeFlowContributions<T extends FlowContribution>(params: {
primary: readonly T[];
fallbacks?: readonly T[];
}): T[] {
const contributionByValue = new Map<string, T>();
for (const contribution of params.primary) {
contributionByValue.set(contribution.option.value, contribution);
}
for (const contribution of params.fallbacks ?? []) {
if (!contributionByValue.has(contribution.option.value)) {
contributionByValue.set(contribution.option.value, contribution);
}
}
return [...contributionByValue.values()];
}
export function sortFlowContributionsByLabel<T extends FlowContribution>(
contributions: readonly T[],
): T[] {
return [...contributions].toSorted(
(left, right) =>
left.option.label.localeCompare(right.option.label) ||
left.option.value.localeCompare(right.option.value),
);
}