mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 00:02:53 +00:00
refactor: share provider install choice fields
This commit is contained in:
@@ -47,6 +47,20 @@ type PreferredInstallSources = {
|
||||
installedPluginIds: ReadonlySet<string>;
|
||||
installsByPluginId: Map<string, PreferredInstallSource>;
|
||||
};
|
||||
type ProviderInstallCatalogChoiceFields = Pick<
|
||||
ProviderAuthChoiceMetadata,
|
||||
| "choiceHint"
|
||||
| "assistantPriority"
|
||||
| "assistantVisibility"
|
||||
| "groupId"
|
||||
| "groupLabel"
|
||||
| "groupHint"
|
||||
| "optionKey"
|
||||
| "cliFlag"
|
||||
| "cliOption"
|
||||
| "cliDescription"
|
||||
| "onboardingScopes"
|
||||
>;
|
||||
|
||||
const INSTALL_ORIGIN_PRIORITY: Readonly<Record<PluginOrigin, number>> = {
|
||||
config: 0,
|
||||
@@ -234,19 +248,19 @@ function resolveProviderIndexInstallCatalogEntries(params: {
|
||||
methodId: choice.method,
|
||||
choiceId: choice.choiceId,
|
||||
choiceLabel: choice.choiceLabel,
|
||||
...(choice.choiceHint ? { choiceHint: choice.choiceHint } : {}),
|
||||
...(choice.assistantPriority !== undefined
|
||||
? { assistantPriority: choice.assistantPriority }
|
||||
: {}),
|
||||
...(choice.assistantVisibility ? { assistantVisibility: choice.assistantVisibility } : {}),
|
||||
...(choice.groupId ? { groupId: choice.groupId } : {}),
|
||||
...(choice.groupLabel ? { groupLabel: choice.groupLabel } : {}),
|
||||
...(choice.groupHint ? { groupHint: choice.groupHint } : {}),
|
||||
...(choice.optionKey ? { optionKey: choice.optionKey } : {}),
|
||||
...(choice.cliFlag ? { cliFlag: choice.cliFlag } : {}),
|
||||
...(choice.cliOption ? { cliOption: choice.cliOption } : {}),
|
||||
...(choice.cliDescription ? { cliDescription: choice.cliDescription } : {}),
|
||||
...(choice.onboardingScopes ? { onboardingScopes: [...choice.onboardingScopes] } : {}),
|
||||
...resolveProviderInstallCatalogChoiceFields({
|
||||
choiceHint: choice.choiceHint,
|
||||
assistantPriority: choice.assistantPriority,
|
||||
assistantVisibility: choice.assistantVisibility,
|
||||
groupId: choice.groupId,
|
||||
groupLabel: choice.groupLabel,
|
||||
groupHint: choice.groupHint,
|
||||
optionKey: choice.optionKey,
|
||||
cliFlag: choice.cliFlag,
|
||||
cliOption: choice.cliOption,
|
||||
cliDescription: choice.cliDescription,
|
||||
onboardingScopes: choice.onboardingScopes ? [...choice.onboardingScopes] : undefined,
|
||||
}),
|
||||
label: provider.name,
|
||||
origin: "bundled",
|
||||
install,
|
||||
@@ -259,6 +273,26 @@ function resolveProviderIndexInstallCatalogEntries(params: {
|
||||
return entries;
|
||||
}
|
||||
|
||||
function resolveProviderInstallCatalogChoiceFields(
|
||||
choice: ProviderInstallCatalogChoiceFields,
|
||||
): Partial<ProviderInstallCatalogChoiceFields> {
|
||||
return {
|
||||
...(choice.choiceHint ? { choiceHint: choice.choiceHint } : {}),
|
||||
...(choice.assistantPriority !== undefined
|
||||
? { assistantPriority: choice.assistantPriority }
|
||||
: {}),
|
||||
...(choice.assistantVisibility ? { assistantVisibility: choice.assistantVisibility } : {}),
|
||||
...(choice.groupId ? { groupId: choice.groupId } : {}),
|
||||
...(choice.groupLabel ? { groupLabel: choice.groupLabel } : {}),
|
||||
...(choice.groupHint ? { groupHint: choice.groupHint } : {}),
|
||||
...(choice.optionKey ? { optionKey: choice.optionKey } : {}),
|
||||
...(choice.cliFlag ? { cliFlag: choice.cliFlag } : {}),
|
||||
...(choice.cliOption ? { cliOption: choice.cliOption } : {}),
|
||||
...(choice.cliDescription ? { cliDescription: choice.cliDescription } : {}),
|
||||
...(choice.onboardingScopes ? { onboardingScopes: choice.onboardingScopes } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function isProviderFlowScope(
|
||||
value: unknown,
|
||||
): value is "text-inference" | "image-generation" | "music-generation" {
|
||||
@@ -309,23 +343,19 @@ function resolveOfficialExternalProviderInstallCatalogEntries(params: {
|
||||
methodId,
|
||||
choiceId,
|
||||
choiceLabel,
|
||||
...(choice.choiceHint ? { choiceHint: choice.choiceHint } : {}),
|
||||
...(choice.assistantPriority !== undefined
|
||||
? { assistantPriority: choice.assistantPriority }
|
||||
: {}),
|
||||
...(choice.assistantVisibility
|
||||
? { assistantVisibility: choice.assistantVisibility }
|
||||
: {}),
|
||||
...(choice.groupId ? { groupId: choice.groupId } : {}),
|
||||
...(choice.groupLabel ? { groupLabel: choice.groupLabel } : {}),
|
||||
...(choice.groupHint ? { groupHint: choice.groupHint } : {}),
|
||||
...(choice.optionKey ? { optionKey: choice.optionKey } : {}),
|
||||
...(choice.cliFlag ? { cliFlag: choice.cliFlag } : {}),
|
||||
...(choice.cliOption ? { cliOption: choice.cliOption } : {}),
|
||||
...(choice.cliDescription ? { cliDescription: choice.cliDescription } : {}),
|
||||
...(normalizeProviderAuthChoiceScopes(choice.onboardingScopes)
|
||||
? { onboardingScopes: normalizeProviderAuthChoiceScopes(choice.onboardingScopes) }
|
||||
: {}),
|
||||
...resolveProviderInstallCatalogChoiceFields({
|
||||
choiceHint: choice.choiceHint,
|
||||
assistantPriority: choice.assistantPriority,
|
||||
assistantVisibility: choice.assistantVisibility,
|
||||
groupId: choice.groupId,
|
||||
groupLabel: choice.groupLabel,
|
||||
groupHint: choice.groupHint,
|
||||
optionKey: choice.optionKey,
|
||||
cliFlag: choice.cliFlag,
|
||||
cliOption: choice.cliOption,
|
||||
cliDescription: choice.cliDescription,
|
||||
onboardingScopes: normalizeProviderAuthChoiceScopes(choice.onboardingScopes),
|
||||
}),
|
||||
label,
|
||||
origin: "bundled",
|
||||
install,
|
||||
|
||||
Reference in New Issue
Block a user