refactor: 重构 Kiro flow 配置与运行链路
This commit is contained in:
+163
-87
@@ -5,12 +5,11 @@
|
||||
const flowRegistryApi = rootScope.MultiPageFlowRegistry || {};
|
||||
const settingsSchemaApi = rootScope.MultiPageSettingsSchema || {};
|
||||
const DEFAULT_FLOW_ID = flowRegistryApi.DEFAULT_FLOW_ID || 'openai';
|
||||
const DEFAULT_PANEL_MODE = flowRegistryApi.DEFAULT_OPENAI_SOURCE_ID || 'cpa';
|
||||
const LEGACY_OPENAI_FLOW_ALIAS = String(flowRegistryApi.LEGACY_OPENAI_FLOW_ALIAS || 'codex').trim().toLowerCase();
|
||||
const DEFAULT_OPENAI_INTEGRATION_TARGET_ID = flowRegistryApi.DEFAULT_OPENAI_INTEGRATION_TARGET_ID || 'cpa';
|
||||
const SIGNUP_METHOD_EMAIL = 'email';
|
||||
const SIGNUP_METHOD_PHONE = 'phone';
|
||||
const VALID_PANEL_MODES = Array.isArray(flowRegistryApi.OPENAI_SOURCE_IDS)
|
||||
? flowRegistryApi.OPENAI_SOURCE_IDS.slice()
|
||||
const VALID_OPENAI_INTEGRATION_TARGET_IDS = Array.isArray(flowRegistryApi.OPENAI_INTEGRATION_TARGET_IDS)
|
||||
? flowRegistryApi.OPENAI_INTEGRATION_TARGET_IDS.slice()
|
||||
: ['cpa', 'sub2api', 'codex2api'];
|
||||
const REGISTERED_FLOW_IDS = Array.isArray(flowRegistryApi.getRegisteredFlowIds?.())
|
||||
? flowRegistryApi.getRegisteredFlowIds().map((flowId) => String(flowId || '').trim().toLowerCase()).filter(Boolean)
|
||||
@@ -23,7 +22,7 @@
|
||||
supportsPhoneVerificationSettings: false,
|
||||
supportsPlusMode: false,
|
||||
supportsContributionMode: false,
|
||||
supportsPlatformBinding: [],
|
||||
supportedIntegrationTargets: [],
|
||||
supportsLuckmail: false,
|
||||
supportsOauthTimeoutBudget: false,
|
||||
canSwitchFlow: true,
|
||||
@@ -48,7 +47,7 @@
|
||||
)
|
||||
);
|
||||
|
||||
const DEFAULT_PANEL_CAPABILITIES = Object.freeze({
|
||||
const DEFAULT_INTEGRATION_TARGET_CAPABILITIES = Object.freeze({
|
||||
supportsPhoneSignup: true,
|
||||
requiresPhoneSignupWarning: false,
|
||||
});
|
||||
@@ -61,9 +60,11 @@
|
||||
'plusModeEnabled',
|
||||
'signupMethod',
|
||||
'kiroSourceId',
|
||||
'openaiIntegrationTargetId',
|
||||
'kiroIntegrationTargetId',
|
||||
]);
|
||||
|
||||
const PANEL_CAPABILITIES = Object.freeze({
|
||||
const OPENAI_INTEGRATION_TARGET_CAPABILITIES = Object.freeze({
|
||||
cpa: Object.freeze({
|
||||
supportsPhoneSignup: true,
|
||||
requiresPhoneSignupWarning: true,
|
||||
@@ -88,30 +89,26 @@
|
||||
|
||||
function normalizeCapabilityFlowId(value = '', fallback = DEFAULT_FLOW_ID) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === LEGACY_OPENAI_FLOW_ALIAS) {
|
||||
return DEFAULT_FLOW_ID;
|
||||
}
|
||||
if (normalized) {
|
||||
return normalized;
|
||||
}
|
||||
const normalizedFallback = String(fallback || '').trim().toLowerCase();
|
||||
if (normalizedFallback === LEGACY_OPENAI_FLOW_ALIAS) {
|
||||
return DEFAULT_FLOW_ID;
|
||||
}
|
||||
return normalizedFallback || DEFAULT_FLOW_ID;
|
||||
return normalizeFlowId(fallback, DEFAULT_FLOW_ID);
|
||||
}
|
||||
|
||||
function isRegisteredFlowId(flowId = '') {
|
||||
return REGISTERED_FLOW_ID_SET.has(normalizeCapabilityFlowId(flowId, ''));
|
||||
const normalized = String(flowId || '').trim().toLowerCase();
|
||||
return Boolean(normalized) && REGISTERED_FLOW_ID_SET.has(normalized);
|
||||
}
|
||||
|
||||
function normalizePanelMode(value = '', fallback = DEFAULT_PANEL_MODE) {
|
||||
function normalizeOpenAiIntegrationTargetId(value = '', fallback = DEFAULT_OPENAI_INTEGRATION_TARGET_ID) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (VALID_PANEL_MODES.includes(normalized)) {
|
||||
if (VALID_OPENAI_INTEGRATION_TARGET_IDS.includes(normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
const fallbackValue = String(fallback || '').trim().toLowerCase();
|
||||
return VALID_PANEL_MODES.includes(fallbackValue) ? fallbackValue : DEFAULT_PANEL_MODE;
|
||||
return VALID_OPENAI_INTEGRATION_TARGET_IDS.includes(fallbackValue)
|
||||
? fallbackValue
|
||||
: DEFAULT_OPENAI_INTEGRATION_TARGET_ID;
|
||||
}
|
||||
|
||||
function normalizeSignupMethod(value = '') {
|
||||
@@ -120,41 +117,50 @@
|
||||
: SIGNUP_METHOD_EMAIL;
|
||||
}
|
||||
|
||||
function normalizePanelModeList(values = []) {
|
||||
function normalizeOpenAiIntegrationTargetList(values = []) {
|
||||
if (!Array.isArray(values)) {
|
||||
return [];
|
||||
}
|
||||
const seen = new Set();
|
||||
const normalized = [];
|
||||
values.forEach((value) => {
|
||||
const mode = normalizePanelMode(value, '');
|
||||
if (!mode || seen.has(mode)) {
|
||||
const integrationTargetId = normalizeOpenAiIntegrationTargetId(value, '');
|
||||
if (!integrationTargetId || seen.has(integrationTargetId)) {
|
||||
return;
|
||||
}
|
||||
seen.add(mode);
|
||||
normalized.push(mode);
|
||||
seen.add(integrationTargetId);
|
||||
normalized.push(integrationTargetId);
|
||||
});
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function getPanelModeLabel(panelMode = '') {
|
||||
const normalized = normalizePanelMode(panelMode);
|
||||
function getIntegrationTargetLabel(flowId = DEFAULT_FLOW_ID, integrationTargetId = '') {
|
||||
if (
|
||||
isRegisteredFlowId(flowId)
|
||||
&& typeof flowRegistryApi.getIntegrationTargetLabel === 'function'
|
||||
) {
|
||||
return flowRegistryApi.getIntegrationTargetLabel(flowId, integrationTargetId);
|
||||
}
|
||||
const normalized = String(integrationTargetId || '').trim().toLowerCase();
|
||||
if (normalized === 'sub2api') {
|
||||
return 'SUB2API';
|
||||
}
|
||||
if (normalized === 'codex2api') {
|
||||
return 'Codex2API';
|
||||
}
|
||||
return 'CPA';
|
||||
if (normalized === 'cpa') {
|
||||
return 'CPA';
|
||||
}
|
||||
return normalized || String(integrationTargetId || '').trim();
|
||||
}
|
||||
|
||||
function createFlowCapabilityRegistry(deps = {}) {
|
||||
const {
|
||||
defaultFlowCapabilities = DEFAULT_FLOW_CAPABILITIES,
|
||||
defaultFlowId = DEFAULT_FLOW_ID,
|
||||
defaultPanelCapabilities = DEFAULT_PANEL_CAPABILITIES,
|
||||
defaultIntegrationTargetCapabilities = DEFAULT_INTEGRATION_TARGET_CAPABILITIES,
|
||||
flowCapabilities = FLOW_CAPABILITIES,
|
||||
panelCapabilities = PANEL_CAPABILITIES,
|
||||
integrationTargetCapabilities = OPENAI_INTEGRATION_TARGET_CAPABILITIES,
|
||||
} = deps;
|
||||
const settingsSchema = settingsSchemaApi.createSettingsSchema
|
||||
? settingsSchemaApi.createSettingsSchema({
|
||||
@@ -165,21 +171,72 @@
|
||||
function getFlowCapabilities(flowId) {
|
||||
const normalizedFlowId = normalizeCapabilityFlowId(flowId, defaultFlowId);
|
||||
const entry = flowCapabilities[normalizedFlowId] || null;
|
||||
const supportedIntegrationTargets = normalizedFlowId === 'openai'
|
||||
? normalizeOpenAiIntegrationTargetList(
|
||||
entry?.supportedIntegrationTargets || defaultFlowCapabilities.supportedIntegrationTargets
|
||||
)
|
||||
: (Array.isArray(entry?.supportedIntegrationTargets)
|
||||
? entry.supportedIntegrationTargets.map((value) => String(value || '').trim().toLowerCase()).filter(Boolean)
|
||||
: []);
|
||||
return {
|
||||
...defaultFlowCapabilities,
|
||||
...(entry || {}),
|
||||
supportsPlatformBinding: normalizePanelModeList(entry?.supportsPlatformBinding || defaultFlowCapabilities.supportsPlatformBinding),
|
||||
supportedIntegrationTargets,
|
||||
};
|
||||
}
|
||||
|
||||
function getPanelCapabilities(panelMode) {
|
||||
const normalizedPanelMode = normalizePanelMode(panelMode);
|
||||
function getOpenAiIntegrationTargetCapabilities(integrationTargetId) {
|
||||
const normalizedIntegrationTargetId = normalizeOpenAiIntegrationTargetId(integrationTargetId);
|
||||
return {
|
||||
...defaultPanelCapabilities,
|
||||
...(panelCapabilities[normalizedPanelMode] || {}),
|
||||
...defaultIntegrationTargetCapabilities,
|
||||
...(integrationTargetCapabilities[normalizedIntegrationTargetId] || {}),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeRequestedIntegrationTargetId(activeFlowId, state = {}, options = {}) {
|
||||
if (activeFlowId === 'openai') {
|
||||
return normalizeOpenAiIntegrationTargetId(
|
||||
options?.integrationTargetId
|
||||
?? options?.panelMode
|
||||
?? state?.openaiIntegrationTargetId
|
||||
?? state?.panelMode,
|
||||
DEFAULT_OPENAI_INTEGRATION_TARGET_ID
|
||||
);
|
||||
}
|
||||
|
||||
const rawIntegrationTargetId = activeFlowId === 'kiro'
|
||||
? (
|
||||
options?.integrationTargetId
|
||||
?? state?.kiroIntegrationTargetId
|
||||
?? state?.kiroSourceId
|
||||
?? flowRegistryApi.getDefaultIntegrationTargetId?.(activeFlowId)
|
||||
?? ''
|
||||
)
|
||||
: (
|
||||
options?.integrationTargetId
|
||||
?? state?.integrationTargetId
|
||||
?? state?.openaiIntegrationTargetId
|
||||
?? state?.panelMode
|
||||
?? state?.kiroIntegrationTargetId
|
||||
?? state?.kiroSourceId
|
||||
?? flowRegistryApi.getDefaultIntegrationTargetId?.(activeFlowId)
|
||||
?? ''
|
||||
);
|
||||
|
||||
if (
|
||||
isRegisteredFlowId(activeFlowId)
|
||||
&& typeof flowRegistryApi.normalizeIntegrationTargetId === 'function'
|
||||
) {
|
||||
return flowRegistryApi.normalizeIntegrationTargetId(
|
||||
activeFlowId,
|
||||
rawIntegrationTargetId,
|
||||
flowRegistryApi.getDefaultIntegrationTargetId?.(activeFlowId)
|
||||
);
|
||||
}
|
||||
|
||||
return String(rawIntegrationTargetId || '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function normalizeChangedKeys(values = []) {
|
||||
const list = Array.isArray(values) ? values : [];
|
||||
const seen = new Set();
|
||||
@@ -195,28 +252,33 @@
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function resolveEffectiveSourceId(activeFlowId, state = {}, requestedPanelMode = DEFAULT_PANEL_MODE) {
|
||||
function resolveEffectiveIntegrationTargetId(activeFlowId, state = {}, requestedIntegrationTargetId = DEFAULT_OPENAI_INTEGRATION_TARGET_ID) {
|
||||
if (!isRegisteredFlowId(activeFlowId)) {
|
||||
return normalizePanelMode(state?.panelMode || requestedPanelMode, requestedPanelMode || DEFAULT_PANEL_MODE);
|
||||
return normalizeRequestedIntegrationTargetId(activeFlowId, state, {
|
||||
integrationTargetId: requestedIntegrationTargetId,
|
||||
});
|
||||
}
|
||||
if (settingsSchema?.getSelectedSourceId) {
|
||||
const sourceFromSchema = settingsSchema.getSelectedSourceId({
|
||||
if (settingsSchema?.getSelectedIntegrationTargetId) {
|
||||
const integrationTargetId = settingsSchema.getSelectedIntegrationTargetId({
|
||||
...state,
|
||||
activeFlowId,
|
||||
}, activeFlowId);
|
||||
if (sourceFromSchema) {
|
||||
return sourceFromSchema;
|
||||
if (integrationTargetId) {
|
||||
return integrationTargetId;
|
||||
}
|
||||
}
|
||||
if (typeof flowRegistryApi.normalizeSourceId === 'function') {
|
||||
if (activeFlowId === 'openai') {
|
||||
return flowRegistryApi.normalizeSourceId('openai', state?.panelMode || requestedPanelMode, DEFAULT_PANEL_MODE);
|
||||
}
|
||||
return flowRegistryApi.normalizeSourceId(activeFlowId, state?.kiroSourceId || '', flowRegistryApi.getDefaultSourceId?.(activeFlowId));
|
||||
if (typeof flowRegistryApi.normalizeIntegrationTargetId === 'function') {
|
||||
return flowRegistryApi.normalizeIntegrationTargetId(
|
||||
activeFlowId,
|
||||
activeFlowId === 'openai'
|
||||
? (state?.openaiIntegrationTargetId || state?.panelMode || requestedIntegrationTargetId)
|
||||
: (state?.kiroIntegrationTargetId || state?.kiroSourceId || requestedIntegrationTargetId),
|
||||
flowRegistryApi.getDefaultIntegrationTargetId?.(activeFlowId)
|
||||
);
|
||||
}
|
||||
return activeFlowId === 'openai'
|
||||
? normalizePanelMode(state?.panelMode || requestedPanelMode)
|
||||
: '';
|
||||
? normalizeOpenAiIntegrationTargetId(requestedIntegrationTargetId)
|
||||
: String(requestedIntegrationTargetId || '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function resolveSidepanelCapabilities(options = {}) {
|
||||
@@ -226,19 +288,25 @@
|
||||
defaultFlowId
|
||||
);
|
||||
const flowState = getFlowCapabilities(activeFlowId);
|
||||
const requestedPanelMode = normalizePanelMode(
|
||||
options?.panelMode ?? state?.panelMode,
|
||||
DEFAULT_PANEL_MODE
|
||||
const requestedIntegrationTargetId = normalizeRequestedIntegrationTargetId(
|
||||
activeFlowId,
|
||||
state,
|
||||
options
|
||||
);
|
||||
const supportedPanelModes = normalizePanelModeList(flowState.supportsPlatformBinding);
|
||||
const panelModeSupported = supportedPanelModes.length === 0
|
||||
const supportedIntegrationTargets = activeFlowId === 'openai'
|
||||
? normalizeOpenAiIntegrationTargetList(flowState.supportedIntegrationTargets)
|
||||
: (Array.isArray(flowState.supportedIntegrationTargets)
|
||||
? flowState.supportedIntegrationTargets.slice()
|
||||
: []);
|
||||
const integrationTargetSupported = supportedIntegrationTargets.length === 0
|
||||
? true
|
||||
: supportedPanelModes.includes(requestedPanelMode);
|
||||
const effectivePanelMode = panelModeSupported
|
||||
? requestedPanelMode
|
||||
: (supportedPanelModes[0] || requestedPanelMode);
|
||||
const panelState = getPanelCapabilities(effectivePanelMode);
|
||||
const effectiveSourceId = resolveEffectiveSourceId(activeFlowId, state, effectivePanelMode);
|
||||
: supportedIntegrationTargets.includes(requestedIntegrationTargetId);
|
||||
const effectiveIntegrationTargetId = integrationTargetSupported
|
||||
? requestedIntegrationTargetId
|
||||
: (supportedIntegrationTargets[0] || requestedIntegrationTargetId);
|
||||
const integrationTargetState = activeFlowId === 'openai'
|
||||
? getOpenAiIntegrationTargetCapabilities(effectiveIntegrationTargetId)
|
||||
: defaultIntegrationTargetCapabilities;
|
||||
const runtimeLocks = {
|
||||
autoRunLocked: Boolean(options?.autoRunLocked ?? state?.autoRunLocked),
|
||||
contributionMode: activeFlowId === 'openai' && flowState.supportsContributionMode && Boolean(state?.contributionMode),
|
||||
@@ -252,7 +320,7 @@
|
||||
}
|
||||
const canSelectPhoneSignup = activeFlowId === 'openai'
|
||||
&& Boolean(flowState.supportsPhoneSignup)
|
||||
&& Boolean(panelState.supportsPhoneSignup)
|
||||
&& Boolean(integrationTargetState.supportsPhoneSignup)
|
||||
&& runtimeLocks.phoneVerificationEnabled
|
||||
&& !runtimeLocks.plusModeEnabled
|
||||
&& !runtimeLocks.contributionMode;
|
||||
@@ -272,7 +340,7 @@
|
||||
: effectiveSignupMethods[0]);
|
||||
const visibleGroupIds = typeof flowRegistryApi.getVisibleGroupIds === 'function'
|
||||
&& isRegisteredFlowId(activeFlowId)
|
||||
? flowRegistryApi.getVisibleGroupIds(activeFlowId, effectiveSourceId)
|
||||
? flowRegistryApi.getVisibleGroupIds(activeFlowId, effectiveIntegrationTargetId)
|
||||
: [];
|
||||
|
||||
return {
|
||||
@@ -283,33 +351,38 @@
|
||||
canShowPlusSettings: activeFlowId === 'openai' && Boolean(flowState.supportsPlusMode),
|
||||
canSwitchFlow: Boolean(flowState.canSwitchFlow),
|
||||
canUsePhoneSignup: canSelectPhoneSignup,
|
||||
canUseSelectedPanelMode: panelModeSupported,
|
||||
effectivePanelMode,
|
||||
canUseSelectedPanelMode: integrationTargetSupported,
|
||||
effectiveIntegrationTargetId,
|
||||
effectivePanelMode: effectiveIntegrationTargetId,
|
||||
effectiveSignupMethod,
|
||||
effectiveSignupMethods,
|
||||
effectiveSourceId,
|
||||
effectiveSourceId: effectiveIntegrationTargetId,
|
||||
flowCapabilities: flowState,
|
||||
panelCapabilities: panelState,
|
||||
panelMode: effectivePanelMode,
|
||||
requestedPanelMode,
|
||||
integrationTargetCapabilities: integrationTargetState,
|
||||
panelCapabilities: integrationTargetState,
|
||||
panelMode: effectiveIntegrationTargetId,
|
||||
requestedIntegrationTargetId,
|
||||
requestedPanelMode: requestedIntegrationTargetId,
|
||||
requestedSignupMethod,
|
||||
runtimeLocks,
|
||||
shouldWarnCpaPhoneSignup: effectiveSignupMethod === SIGNUP_METHOD_PHONE
|
||||
&& Boolean(panelState.requiresPhoneSignupWarning),
|
||||
&& Boolean(integrationTargetState.requiresPhoneSignupWarning),
|
||||
stepDefinitionOptions: {
|
||||
activeFlowId,
|
||||
panelMode: effectivePanelMode,
|
||||
integrationTargetId: effectiveIntegrationTargetId,
|
||||
panelMode: effectiveIntegrationTargetId,
|
||||
plusModeEnabled: runtimeLocks.plusModeEnabled,
|
||||
signupMethod: effectiveSignupMethod,
|
||||
},
|
||||
supportedPanelModes,
|
||||
supportedIntegrationTargets,
|
||||
supportedPanelModes: supportedIntegrationTargets,
|
||||
visibleGroupIds,
|
||||
};
|
||||
}
|
||||
|
||||
function buildPhoneSignupValidationError(capabilityState = {}) {
|
||||
const flowState = capabilityState.flowCapabilities || {};
|
||||
const panelState = capabilityState.panelCapabilities || {};
|
||||
const integrationTargetState = capabilityState.integrationTargetCapabilities || {};
|
||||
const runtimeLocks = capabilityState.runtimeLocks || {};
|
||||
|
||||
if (!flowState.supportsPhoneSignup) {
|
||||
@@ -318,10 +391,10 @@
|
||||
message: '当前 flow 不支持手机号注册。',
|
||||
};
|
||||
}
|
||||
if (!panelState.supportsPhoneSignup) {
|
||||
if (!integrationTargetState.supportsPhoneSignup) {
|
||||
return {
|
||||
code: 'phone_signup_panel_unsupported',
|
||||
message: `当前来源 ${getPanelModeLabel(capabilityState.requestedPanelMode)} 不支持手机号注册。`,
|
||||
message: `当前来源 ${getIntegrationTargetLabel(capabilityState.activeFlowId, capabilityState.requestedIntegrationTargetId)} 不支持手机号注册。`,
|
||||
};
|
||||
}
|
||||
if (!runtimeLocks.phoneVerificationEnabled) {
|
||||
@@ -354,13 +427,13 @@
|
||||
const errors = [];
|
||||
|
||||
if (
|
||||
Array.isArray(capabilityState.supportedPanelModes)
|
||||
&& capabilityState.supportedPanelModes.length > 0
|
||||
Array.isArray(capabilityState.supportedIntegrationTargets)
|
||||
&& capabilityState.supportedIntegrationTargets.length > 0
|
||||
&& capabilityState.canUseSelectedPanelMode === false
|
||||
) {
|
||||
errors.push({
|
||||
code: 'panel_mode_unsupported',
|
||||
message: `当前 flow 不支持 ${getPanelModeLabel(capabilityState.requestedPanelMode)} 来源。`,
|
||||
message: `当前 flow 不支持 ${getIntegrationTargetLabel(capabilityState.activeFlowId, capabilityState.requestedIntegrationTargetId)} 来源。`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -408,15 +481,18 @@
|
||||
const shouldReconcileSignupMethod = MODE_SWITCH_RELEVANT_KEYS.some((key) => changedKeySet.has(key));
|
||||
|
||||
if (
|
||||
changedKeySet.has('panelMode')
|
||||
&& Array.isArray(capabilityState.supportedPanelModes)
|
||||
&& capabilityState.supportedPanelModes.length > 0
|
||||
(changedKeySet.has('panelMode') || changedKeySet.has('openaiIntegrationTargetId') || changedKeySet.has('kiroIntegrationTargetId'))
|
||||
&& Array.isArray(capabilityState.supportedIntegrationTargets)
|
||||
&& capabilityState.supportedIntegrationTargets.length > 0
|
||||
&& capabilityState.canUseSelectedPanelMode === false
|
||||
) {
|
||||
normalizedUpdates.panelMode = capabilityState.effectivePanelMode;
|
||||
normalizedUpdates.panelMode = capabilityState.effectiveIntegrationTargetId;
|
||||
normalizedUpdates.openaiIntegrationTargetId = capabilityState.effectiveIntegrationTargetId;
|
||||
normalizedUpdates.kiroIntegrationTargetId = capabilityState.effectiveIntegrationTargetId;
|
||||
normalizedUpdates.kiroSourceId = capabilityState.effectiveIntegrationTargetId;
|
||||
errors.push({
|
||||
code: 'panel_mode_unsupported',
|
||||
message: `当前 flow 不支持 ${getPanelModeLabel(capabilityState.requestedPanelMode)} 来源。`,
|
||||
message: `当前 flow 不支持 ${getIntegrationTargetLabel(capabilityState.activeFlowId, capabilityState.requestedIntegrationTargetId)} 来源。`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -480,9 +556,9 @@
|
||||
return {
|
||||
canUsePhoneSignup,
|
||||
getFlowCapabilities,
|
||||
getPanelCapabilities,
|
||||
getOpenAiIntegrationTargetCapabilities,
|
||||
normalizeFlowId,
|
||||
normalizePanelMode,
|
||||
normalizeOpenAiIntegrationTargetId,
|
||||
normalizeSignupMethod,
|
||||
resolveSidepanelCapabilities,
|
||||
resolveSignupMethod,
|
||||
@@ -495,15 +571,15 @@
|
||||
createFlowCapabilityRegistry,
|
||||
DEFAULT_FLOW_CAPABILITIES,
|
||||
DEFAULT_FLOW_ID,
|
||||
DEFAULT_PANEL_CAPABILITIES,
|
||||
DEFAULT_PANEL_MODE,
|
||||
DEFAULT_INTEGRATION_TARGET_CAPABILITIES,
|
||||
DEFAULT_OPENAI_INTEGRATION_TARGET_ID,
|
||||
FLOW_CAPABILITIES,
|
||||
PANEL_CAPABILITIES,
|
||||
OPENAI_INTEGRATION_TARGET_CAPABILITIES,
|
||||
SIGNUP_METHOD_EMAIL,
|
||||
SIGNUP_METHOD_PHONE,
|
||||
VALID_PANEL_MODES,
|
||||
VALID_OPENAI_INTEGRATION_TARGET_IDS,
|
||||
normalizeFlowId,
|
||||
normalizePanelMode,
|
||||
normalizeOpenAiIntegrationTargetId,
|
||||
normalizeSignupMethod,
|
||||
};
|
||||
});
|
||||
|
||||
+105
-81
@@ -2,11 +2,11 @@
|
||||
root.MultiPageFlowRegistry = factory();
|
||||
})(typeof self !== 'undefined' ? self : globalThis, function createFlowRegistryModule() {
|
||||
const DEFAULT_FLOW_ID = 'openai';
|
||||
const LEGACY_OPENAI_FLOW_ALIAS = 'codex';
|
||||
const DEFAULT_OPENAI_SOURCE_ID = 'cpa';
|
||||
const DEFAULT_KIRO_SOURCE_ID = 'kiro-rs';
|
||||
const DEFAULT_OPENAI_INTEGRATION_TARGET_ID = 'cpa';
|
||||
const DEFAULT_KIRO_INTEGRATION_TARGET_ID = 'kiro-rs';
|
||||
const DEFAULT_KIRO_PUBLICATION_TARGET_ID = 'kiro-rs';
|
||||
const DEFAULT_KIRO_RS_URL = 'https://kiro.leftcode.xyz/admin';
|
||||
const OPENAI_SOURCE_IDS = Object.freeze(['cpa', 'sub2api', 'codex2api']);
|
||||
const OPENAI_INTEGRATION_TARGET_IDS = Object.freeze(['cpa', 'sub2api', 'codex2api']);
|
||||
const SHARED_SERVICE_IDS = Object.freeze(['account', 'email', 'proxy']);
|
||||
|
||||
const DEFAULT_FLOW_CAPABILITIES = Object.freeze({
|
||||
@@ -15,7 +15,7 @@
|
||||
supportsPhoneVerificationSettings: false,
|
||||
supportsPlusMode: false,
|
||||
supportsContributionMode: false,
|
||||
supportsPlatformBinding: [],
|
||||
supportedIntegrationTargets: [],
|
||||
supportsLuckmail: false,
|
||||
supportsOauthTimeoutBudget: false,
|
||||
canSwitchFlow: true,
|
||||
@@ -44,7 +44,7 @@
|
||||
supportsPhoneVerificationSettings: true,
|
||||
supportsPlusMode: true,
|
||||
supportsContributionMode: true,
|
||||
supportsPlatformBinding: [...OPENAI_SOURCE_IDS],
|
||||
supportedIntegrationTargets: [...OPENAI_INTEGRATION_TARGET_IDS],
|
||||
supportsLuckmail: true,
|
||||
supportsOauthTimeoutBudget: true,
|
||||
stepDefinitionMode: 'openai-dynamic',
|
||||
@@ -55,24 +55,21 @@
|
||||
'openai-oauth',
|
||||
'openai-step6',
|
||||
],
|
||||
sources: {
|
||||
integrationTargets: {
|
||||
cpa: {
|
||||
id: 'cpa',
|
||||
label: 'CPA 面板',
|
||||
legacyPanelMode: 'cpa',
|
||||
groups: ['openai-source-cpa'],
|
||||
groups: ['openai-target-cpa'],
|
||||
},
|
||||
sub2api: {
|
||||
id: 'sub2api',
|
||||
label: 'SUB2API',
|
||||
legacyPanelMode: 'sub2api',
|
||||
groups: ['openai-source-sub2api'],
|
||||
groups: ['openai-target-sub2api'],
|
||||
},
|
||||
codex2api: {
|
||||
id: 'codex2api',
|
||||
label: 'Codex2API',
|
||||
legacyPanelMode: 'codex2api',
|
||||
groups: ['openai-source-codex2api'],
|
||||
groups: ['openai-target-codex2api'],
|
||||
},
|
||||
},
|
||||
runtimeSources: {
|
||||
@@ -206,16 +203,23 @@
|
||||
services: ['account', 'email', 'proxy'],
|
||||
capabilities: {
|
||||
...DEFAULT_FLOW_CAPABILITIES,
|
||||
supportedIntegrationTargets: [DEFAULT_KIRO_INTEGRATION_TARGET_ID],
|
||||
stepDefinitionMode: 'kiro-device-auth',
|
||||
},
|
||||
baseGroups: [
|
||||
'kiro-runtime-status',
|
||||
],
|
||||
sources: {
|
||||
integrationTargets: {
|
||||
'kiro-rs': {
|
||||
id: 'kiro-rs',
|
||||
label: 'kiro.rs',
|
||||
groups: ['kiro-target-kiro-rs'],
|
||||
},
|
||||
},
|
||||
publicationTargets: {
|
||||
'kiro-rs': {
|
||||
id: 'kiro-rs',
|
||||
label: 'kiro.rs',
|
||||
groups: ['kiro-source-kiro-rs'],
|
||||
},
|
||||
},
|
||||
runtimeSources: {
|
||||
@@ -280,13 +284,13 @@
|
||||
label: 'IP 代理',
|
||||
sectionIds: ['ip-proxy-section'],
|
||||
},
|
||||
'openai-source-cpa': {
|
||||
id: 'openai-source-cpa',
|
||||
'openai-target-cpa': {
|
||||
id: 'openai-target-cpa',
|
||||
label: 'CPA 来源',
|
||||
rowIds: ['row-vps-url', 'row-vps-password', 'row-local-cpa-step9-mode'],
|
||||
},
|
||||
'openai-source-sub2api': {
|
||||
id: 'openai-source-sub2api',
|
||||
'openai-target-sub2api': {
|
||||
id: 'openai-target-sub2api',
|
||||
label: 'SUB2API 来源',
|
||||
rowIds: [
|
||||
'row-sub2api-url',
|
||||
@@ -297,17 +301,15 @@
|
||||
'row-sub2api-default-proxy',
|
||||
],
|
||||
},
|
||||
'openai-source-codex2api': {
|
||||
id: 'openai-source-codex2api',
|
||||
'openai-target-codex2api': {
|
||||
id: 'openai-target-codex2api',
|
||||
label: 'Codex2API 来源',
|
||||
rowIds: ['row-codex2api-url', 'row-codex2api-admin-key'],
|
||||
},
|
||||
'openai-plus': {
|
||||
id: 'openai-plus',
|
||||
label: 'Plus',
|
||||
rowIds: [
|
||||
'row-plus-mode',
|
||||
],
|
||||
rowIds: ['row-plus-mode'],
|
||||
},
|
||||
'openai-phone': {
|
||||
id: 'openai-phone',
|
||||
@@ -325,8 +327,8 @@
|
||||
label: '第六步',
|
||||
rowIds: ['row-step6-cookie-settings'],
|
||||
},
|
||||
'kiro-source-kiro-rs': {
|
||||
id: 'kiro-source-kiro-rs',
|
||||
'kiro-target-kiro-rs': {
|
||||
id: 'kiro-target-kiro-rs',
|
||||
label: 'kiro.rs 配置',
|
||||
rowIds: ['row-kiro-rs-url', 'row-kiro-rs-key'],
|
||||
},
|
||||
@@ -339,16 +341,10 @@
|
||||
|
||||
function normalizeFlowId(value = '', fallback = DEFAULT_FLOW_ID) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === LEGACY_OPENAI_FLOW_ALIAS) {
|
||||
return DEFAULT_FLOW_ID;
|
||||
}
|
||||
if (normalized && Object.prototype.hasOwnProperty.call(FLOW_DEFINITIONS, normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
const fallbackValue = String(fallback || '').trim().toLowerCase();
|
||||
if (fallbackValue === LEGACY_OPENAI_FLOW_ALIAS) {
|
||||
return DEFAULT_FLOW_ID;
|
||||
}
|
||||
return Object.prototype.hasOwnProperty.call(FLOW_DEFINITIONS, fallbackValue)
|
||||
? fallbackValue
|
||||
: DEFAULT_FLOW_ID;
|
||||
@@ -359,73 +355,92 @@
|
||||
}
|
||||
|
||||
function getFlowDefinition(flowId) {
|
||||
const normalizedFlowId = normalizeFlowId(flowId);
|
||||
return FLOW_DEFINITIONS[normalizedFlowId] || FLOW_DEFINITIONS[DEFAULT_FLOW_ID];
|
||||
return FLOW_DEFINITIONS[normalizeFlowId(flowId)] || FLOW_DEFINITIONS[DEFAULT_FLOW_ID];
|
||||
}
|
||||
|
||||
function getFlowLabel(flowId) {
|
||||
return getFlowDefinition(flowId)?.label || normalizeFlowId(flowId);
|
||||
}
|
||||
|
||||
function getDefaultSourceId(flowId) {
|
||||
function getDefaultIntegrationTargetId(flowId) {
|
||||
return normalizeFlowId(flowId) === 'kiro'
|
||||
? DEFAULT_KIRO_SOURCE_ID
|
||||
: DEFAULT_OPENAI_SOURCE_ID;
|
||||
? DEFAULT_KIRO_INTEGRATION_TARGET_ID
|
||||
: DEFAULT_OPENAI_INTEGRATION_TARGET_ID;
|
||||
}
|
||||
|
||||
function normalizeOpenAiSourceId(value = '', fallback = DEFAULT_OPENAI_SOURCE_ID) {
|
||||
function normalizeOpenAiIntegrationTargetId(value = '', fallback = DEFAULT_OPENAI_INTEGRATION_TARGET_ID) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (OPENAI_SOURCE_IDS.includes(normalized)) {
|
||||
if (OPENAI_INTEGRATION_TARGET_IDS.includes(normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
const fallbackValue = String(fallback || '').trim().toLowerCase();
|
||||
return OPENAI_SOURCE_IDS.includes(fallbackValue) ? fallbackValue : DEFAULT_OPENAI_SOURCE_ID;
|
||||
return OPENAI_INTEGRATION_TARGET_IDS.includes(fallbackValue)
|
||||
? fallbackValue
|
||||
: DEFAULT_OPENAI_INTEGRATION_TARGET_ID;
|
||||
}
|
||||
|
||||
function normalizeKiroSourceId(value = '', fallback = DEFAULT_KIRO_SOURCE_ID) {
|
||||
function normalizeKiroIntegrationTargetId(value = '', fallback = DEFAULT_KIRO_INTEGRATION_TARGET_ID) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === DEFAULT_KIRO_SOURCE_ID) {
|
||||
if (normalized === DEFAULT_KIRO_INTEGRATION_TARGET_ID) {
|
||||
return normalized;
|
||||
}
|
||||
const fallbackValue = String(fallback || '').trim().toLowerCase();
|
||||
return fallbackValue === DEFAULT_KIRO_SOURCE_ID ? fallbackValue : DEFAULT_KIRO_SOURCE_ID;
|
||||
return fallbackValue === DEFAULT_KIRO_INTEGRATION_TARGET_ID
|
||||
? fallbackValue
|
||||
: DEFAULT_KIRO_INTEGRATION_TARGET_ID;
|
||||
}
|
||||
|
||||
function normalizeSourceId(flowId, sourceId = '', fallback = undefined) {
|
||||
function normalizeIntegrationTargetId(flowId, integrationTargetId = '', fallback = undefined) {
|
||||
const normalizedFlowId = normalizeFlowId(flowId);
|
||||
if (normalizedFlowId === 'kiro') {
|
||||
return normalizeKiroSourceId(sourceId, fallback || DEFAULT_KIRO_SOURCE_ID);
|
||||
return normalizeKiroIntegrationTargetId(
|
||||
integrationTargetId,
|
||||
fallback || DEFAULT_KIRO_INTEGRATION_TARGET_ID
|
||||
);
|
||||
}
|
||||
return normalizeOpenAiSourceId(sourceId, fallback || DEFAULT_OPENAI_SOURCE_ID);
|
||||
return normalizeOpenAiIntegrationTargetId(
|
||||
integrationTargetId,
|
||||
fallback || DEFAULT_OPENAI_INTEGRATION_TARGET_ID
|
||||
);
|
||||
}
|
||||
|
||||
function getSourceDefinitions(flowId) {
|
||||
return getFlowDefinition(flowId)?.sources || {};
|
||||
function getIntegrationTargetDefinitions(flowId) {
|
||||
return getFlowDefinition(flowId)?.integrationTargets || {};
|
||||
}
|
||||
|
||||
function getSourceDefinition(flowId, sourceId) {
|
||||
function getIntegrationTargetDefinition(flowId, integrationTargetId) {
|
||||
const normalizedFlowId = normalizeFlowId(flowId);
|
||||
const normalizedSourceId = normalizeSourceId(normalizedFlowId, sourceId, getDefaultSourceId(normalizedFlowId));
|
||||
return getSourceDefinitions(normalizedFlowId)[normalizedSourceId] || null;
|
||||
const normalizedIntegrationTargetId = normalizeIntegrationTargetId(
|
||||
normalizedFlowId,
|
||||
integrationTargetId,
|
||||
getDefaultIntegrationTargetId(normalizedFlowId)
|
||||
);
|
||||
return getIntegrationTargetDefinitions(normalizedFlowId)[normalizedIntegrationTargetId] || null;
|
||||
}
|
||||
|
||||
function getSourceOptions(flowId) {
|
||||
return Object.values(getSourceDefinitions(flowId));
|
||||
function getIntegrationTargetOptions(flowId) {
|
||||
return Object.values(getIntegrationTargetDefinitions(flowId));
|
||||
}
|
||||
|
||||
function getSourceLabel(flowId, sourceId) {
|
||||
return getSourceDefinition(flowId, sourceId)?.label || normalizeSourceId(flowId, sourceId);
|
||||
function getIntegrationTargetLabel(flowId, integrationTargetId) {
|
||||
return getIntegrationTargetDefinition(flowId, integrationTargetId)?.label
|
||||
|| normalizeIntegrationTargetId(flowId, integrationTargetId);
|
||||
}
|
||||
|
||||
function mapPanelModeToSourceId(panelMode = '', fallback = DEFAULT_OPENAI_SOURCE_ID) {
|
||||
return normalizeOpenAiSourceId(panelMode, fallback);
|
||||
function getPublicationTargetDefinitions(flowId) {
|
||||
return getFlowDefinition(flowId)?.publicationTargets || {};
|
||||
}
|
||||
|
||||
function mapSourceIdToPanelMode(flowId, sourceId = '', fallback = DEFAULT_OPENAI_SOURCE_ID) {
|
||||
if (normalizeFlowId(flowId) !== DEFAULT_FLOW_ID) {
|
||||
return normalizeOpenAiSourceId(fallback, DEFAULT_OPENAI_SOURCE_ID);
|
||||
}
|
||||
return normalizeOpenAiSourceId(sourceId, fallback || DEFAULT_OPENAI_SOURCE_ID);
|
||||
function getPublicationTargetDefinition(flowId, publicationTargetId) {
|
||||
const normalizedFlowId = normalizeFlowId(flowId);
|
||||
const normalizedPublicationTargetId = String(
|
||||
publicationTargetId || (
|
||||
normalizedFlowId === 'kiro'
|
||||
? DEFAULT_KIRO_PUBLICATION_TARGET_ID
|
||||
: ''
|
||||
)
|
||||
).trim().toLowerCase();
|
||||
return getPublicationTargetDefinitions(normalizedFlowId)[normalizedPublicationTargetId] || null;
|
||||
}
|
||||
|
||||
function getFlowCapabilities(flowId) {
|
||||
@@ -435,18 +450,27 @@
|
||||
};
|
||||
}
|
||||
|
||||
function getVisibleGroupIds(flowId, sourceId, options = {}) {
|
||||
function getVisibleGroupIds(flowId, integrationTargetId, options = {}) {
|
||||
const normalizedFlowId = normalizeFlowId(flowId);
|
||||
const flowDefinition = getFlowDefinition(normalizedFlowId);
|
||||
const normalizedSourceId = normalizeSourceId(normalizedFlowId, sourceId, getDefaultSourceId(normalizedFlowId));
|
||||
const sourceDefinition = getSourceDefinition(normalizedFlowId, normalizedSourceId);
|
||||
const normalizedIntegrationTargetId = normalizeIntegrationTargetId(
|
||||
normalizedFlowId,
|
||||
integrationTargetId,
|
||||
getDefaultIntegrationTargetId(normalizedFlowId)
|
||||
);
|
||||
const integrationTargetDefinition = getIntegrationTargetDefinition(
|
||||
normalizedFlowId,
|
||||
normalizedIntegrationTargetId
|
||||
);
|
||||
const includeSharedServices = options?.includeSharedServices !== false;
|
||||
const serviceGroups = includeSharedServices
|
||||
? (Array.isArray(flowDefinition?.services) ? flowDefinition.services.map((serviceId) => `service-${serviceId}`) : [])
|
||||
? (Array.isArray(flowDefinition?.services)
|
||||
? flowDefinition.services.map((serviceId) => `service-${serviceId}`)
|
||||
: [])
|
||||
: [];
|
||||
return Array.from(new Set([
|
||||
...(Array.isArray(flowDefinition?.baseGroups) ? flowDefinition.baseGroups : []),
|
||||
...(Array.isArray(sourceDefinition?.groups) ? sourceDefinition.groups : []),
|
||||
...(Array.isArray(integrationTargetDefinition?.groups) ? integrationTargetDefinition.groups : []),
|
||||
...serviceGroups,
|
||||
]));
|
||||
}
|
||||
@@ -479,33 +503,33 @@
|
||||
return {
|
||||
DEFAULT_FLOW_CAPABILITIES,
|
||||
DEFAULT_FLOW_ID,
|
||||
DEFAULT_KIRO_INTEGRATION_TARGET_ID,
|
||||
DEFAULT_KIRO_PUBLICATION_TARGET_ID,
|
||||
DEFAULT_KIRO_RS_URL,
|
||||
DEFAULT_KIRO_SOURCE_ID,
|
||||
DEFAULT_OPENAI_SOURCE_ID,
|
||||
DEFAULT_OPENAI_INTEGRATION_TARGET_ID,
|
||||
FLOW_DEFINITIONS,
|
||||
LEGACY_OPENAI_FLOW_ALIAS,
|
||||
OPENAI_SOURCE_IDS,
|
||||
OPENAI_INTEGRATION_TARGET_IDS,
|
||||
SETTINGS_GROUP_DEFINITIONS,
|
||||
SHARED_SERVICE_IDS,
|
||||
getDefaultSourceId,
|
||||
getDefaultIntegrationTargetId,
|
||||
getDriverDefinitions,
|
||||
getFlowCapabilities,
|
||||
getFlowDefinition,
|
||||
getFlowLabel,
|
||||
getIntegrationTargetDefinition,
|
||||
getIntegrationTargetDefinitions,
|
||||
getIntegrationTargetLabel,
|
||||
getIntegrationTargetOptions,
|
||||
getPublicationTargetDefinition,
|
||||
getPublicationTargetDefinitions,
|
||||
getRegisteredFlowIds,
|
||||
getRuntimeSourceDefinitions,
|
||||
getSettingsGroupDefinition,
|
||||
getSettingsGroupDefinitions,
|
||||
getSourceDefinition,
|
||||
getSourceDefinitions,
|
||||
getSourceLabel,
|
||||
getSourceOptions,
|
||||
getVisibleGroupIds,
|
||||
mapPanelModeToSourceId,
|
||||
mapSourceIdToPanelMode,
|
||||
normalizeFlowId,
|
||||
normalizeKiroSourceId,
|
||||
normalizeOpenAiSourceId,
|
||||
normalizeSourceId,
|
||||
normalizeIntegrationTargetId,
|
||||
normalizeKiroIntegrationTargetId,
|
||||
normalizeOpenAiIntegrationTargetId,
|
||||
};
|
||||
});
|
||||
|
||||
+233
-188
@@ -32,9 +32,11 @@
|
||||
function createSettingsSchema(deps = {}) {
|
||||
const rootScope = typeof self !== 'undefined' ? self : globalThis;
|
||||
const flowRegistry = deps.flowRegistry || rootScope.MultiPageFlowRegistry || {};
|
||||
const defaultFlowId = String(deps.defaultFlowId || flowRegistry.DEFAULT_FLOW_ID || 'openai').trim().toLowerCase() || 'openai';
|
||||
const defaultOpenAiSourceId = flowRegistry.DEFAULT_OPENAI_SOURCE_ID || 'cpa';
|
||||
const defaultKiroSourceId = flowRegistry.DEFAULT_KIRO_SOURCE_ID || 'kiro-rs';
|
||||
const defaultFlowId = String(
|
||||
deps.defaultFlowId || flowRegistry.DEFAULT_FLOW_ID || 'openai'
|
||||
).trim().toLowerCase() || 'openai';
|
||||
const defaultOpenAiIntegrationTargetId = flowRegistry.DEFAULT_OPENAI_INTEGRATION_TARGET_ID || 'cpa';
|
||||
const defaultKiroIntegrationTargetId = flowRegistry.DEFAULT_KIRO_INTEGRATION_TARGET_ID || 'kiro-rs';
|
||||
const defaultKiroRsUrl = flowRegistry.DEFAULT_KIRO_RS_URL || 'https://kiro.leftcode.xyz/admin';
|
||||
const normalizeFlowId = typeof flowRegistry.normalizeFlowId === 'function'
|
||||
? flowRegistry.normalizeFlowId
|
||||
@@ -42,19 +44,13 @@
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
return normalized || String(fallback || '').trim().toLowerCase() || defaultFlowId;
|
||||
});
|
||||
const normalizeSourceId = typeof flowRegistry.normalizeSourceId === 'function'
|
||||
? flowRegistry.normalizeSourceId
|
||||
: ((flowId, value = '', fallback = '') => String(value || fallback || '').trim().toLowerCase());
|
||||
const mapSourceIdToPanelMode = typeof flowRegistry.mapSourceIdToPanelMode === 'function'
|
||||
? flowRegistry.mapSourceIdToPanelMode
|
||||
: ((_flowId, sourceId = '', fallback = defaultOpenAiSourceId) => String(sourceId || fallback || defaultOpenAiSourceId).trim().toLowerCase());
|
||||
const mapPanelModeToSourceId = typeof flowRegistry.mapPanelModeToSourceId === 'function'
|
||||
? flowRegistry.mapPanelModeToSourceId
|
||||
: ((panelMode = '', fallback = defaultOpenAiSourceId) => String(panelMode || fallback || defaultOpenAiSourceId).trim().toLowerCase());
|
||||
const normalizeIntegrationTargetId = typeof flowRegistry.normalizeIntegrationTargetId === 'function'
|
||||
? flowRegistry.normalizeIntegrationTargetId
|
||||
: ((_flowId, value = '', fallback = '') => String(value || fallback || '').trim().toLowerCase());
|
||||
|
||||
function buildDefaultSettingsState() {
|
||||
return {
|
||||
schemaVersion: 3,
|
||||
schemaVersion: 4,
|
||||
activeFlowId: defaultFlowId,
|
||||
services: {
|
||||
account: {
|
||||
@@ -71,27 +67,25 @@
|
||||
},
|
||||
flows: {
|
||||
openai: {
|
||||
source: {
|
||||
selected: defaultOpenAiSourceId,
|
||||
entries: {
|
||||
cpa: {
|
||||
vpsUrl: '',
|
||||
vpsPassword: '',
|
||||
localCpaStep9Mode: 'submit',
|
||||
},
|
||||
sub2api: {
|
||||
sub2apiUrl: '',
|
||||
sub2apiEmail: '',
|
||||
sub2apiPassword: '',
|
||||
sub2apiGroupName: 'codex',
|
||||
sub2apiGroupNames: ['codex', 'openai-plus'],
|
||||
sub2apiAccountPriority: 1,
|
||||
sub2apiDefaultProxyName: '',
|
||||
},
|
||||
codex2api: {
|
||||
codex2apiUrl: '',
|
||||
codex2apiAdminKey: '',
|
||||
},
|
||||
integrationTargetId: defaultOpenAiIntegrationTargetId,
|
||||
integrationTargets: {
|
||||
cpa: {
|
||||
vpsUrl: '',
|
||||
vpsPassword: '',
|
||||
localCpaStep9Mode: 'submit',
|
||||
},
|
||||
sub2api: {
|
||||
sub2apiUrl: '',
|
||||
sub2apiEmail: '',
|
||||
sub2apiPassword: '',
|
||||
sub2apiGroupName: 'codex',
|
||||
sub2apiGroupNames: ['codex', 'openai-plus'],
|
||||
sub2apiAccountPriority: 1,
|
||||
sub2apiDefaultProxyName: '',
|
||||
},
|
||||
codex2api: {
|
||||
codex2apiUrl: '',
|
||||
codex2apiAdminKey: '',
|
||||
},
|
||||
},
|
||||
signup: {
|
||||
@@ -112,21 +106,13 @@
|
||||
},
|
||||
},
|
||||
kiro: {
|
||||
source: {
|
||||
selected: defaultKiroSourceId,
|
||||
entries: {
|
||||
'kiro-rs': {
|
||||
kiroRsUrl: defaultKiroRsUrl,
|
||||
kiroRsKey: '',
|
||||
},
|
||||
integrationTargetId: defaultKiroIntegrationTargetId,
|
||||
integrationTargets: {
|
||||
'kiro-rs': {
|
||||
baseUrl: defaultKiroRsUrl,
|
||||
apiKey: '',
|
||||
},
|
||||
},
|
||||
options: {
|
||||
kiroRsPriority: 0,
|
||||
kiroRsEndpoint: '',
|
||||
kiroRsAuthRegion: '',
|
||||
kiroRsApiRegion: '',
|
||||
},
|
||||
autoRun: {
|
||||
stepExecutionRange: {
|
||||
enabled: false,
|
||||
@@ -139,7 +125,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
function getSourceValue(settingsState, pathGetter, fallback = {}) {
|
||||
function getIntegrationTargetValue(settingsState, pathGetter, fallback = {}) {
|
||||
return cloneValue(pathGetter(isPlainObject(settingsState) ? settingsState : {}) || fallback);
|
||||
}
|
||||
|
||||
@@ -155,20 +141,21 @@
|
||||
?? defaults.activeFlowId,
|
||||
defaults.activeFlowId
|
||||
);
|
||||
const openaiSelectedSource = normalizeSourceId(
|
||||
const openaiIntegrationTargetId = normalizeIntegrationTargetId(
|
||||
'openai',
|
||||
nested?.flows?.openai?.source?.selected
|
||||
nested?.flows?.openai?.integrationTargetId
|
||||
?? input?.openaiIntegrationTargetId
|
||||
?? input?.panelMode
|
||||
?? input?.openaiSourceId
|
||||
?? defaults.flows.openai.source.selected,
|
||||
defaults.flows.openai.source.selected
|
||||
?? defaults.flows.openai.integrationTargetId,
|
||||
defaults.flows.openai.integrationTargetId
|
||||
);
|
||||
const kiroSelectedSource = normalizeSourceId(
|
||||
const kiroIntegrationTargetId = normalizeIntegrationTargetId(
|
||||
'kiro',
|
||||
nested?.flows?.kiro?.source?.selected
|
||||
nested?.flows?.kiro?.integrationTargetId
|
||||
?? input?.kiroIntegrationTargetId
|
||||
?? input?.kiroSourceId
|
||||
?? defaults.flows.kiro.source.selected,
|
||||
defaults.flows.kiro.source.selected
|
||||
?? defaults.flows.kiro.integrationTargetId,
|
||||
defaults.flows.kiro.integrationTargetId
|
||||
);
|
||||
const stepExecutionRangeByFlow = isPlainObject(input?.stepExecutionRangeByFlow)
|
||||
? input.stepExecutionRangeByFlow
|
||||
@@ -206,58 +193,115 @@
|
||||
customPassword: String(
|
||||
input?.customPassword
|
||||
?? nested?.services?.account?.customPassword
|
||||
?? nested?.flows?.openai?.account?.customPassword
|
||||
?? defaults.services.account.customPassword
|
||||
).trim(),
|
||||
},
|
||||
},
|
||||
flows: {
|
||||
openai: {
|
||||
source: {
|
||||
selected: openaiSelectedSource,
|
||||
entries: {
|
||||
cpa: {
|
||||
...defaults.flows.openai.source.entries.cpa,
|
||||
...getSourceValue(nested, (state) => state.flows?.openai?.source?.entries?.cpa),
|
||||
vpsUrl: String(input?.vpsUrl ?? nested?.flows?.openai?.source?.entries?.cpa?.vpsUrl ?? '').trim(),
|
||||
vpsPassword: String(input?.vpsPassword ?? nested?.flows?.openai?.source?.entries?.cpa?.vpsPassword ?? ''),
|
||||
localCpaStep9Mode: String(
|
||||
input?.localCpaStep9Mode
|
||||
?? nested?.flows?.openai?.source?.entries?.cpa?.localCpaStep9Mode
|
||||
?? defaults.flows.openai.source.entries.cpa.localCpaStep9Mode
|
||||
).trim() || defaults.flows.openai.source.entries.cpa.localCpaStep9Mode,
|
||||
},
|
||||
sub2api: {
|
||||
...defaults.flows.openai.source.entries.sub2api,
|
||||
...getSourceValue(nested, (state) => state.flows?.openai?.source?.entries?.sub2api),
|
||||
sub2apiUrl: String(input?.sub2apiUrl ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiUrl ?? '').trim(),
|
||||
sub2apiEmail: String(input?.sub2apiEmail ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiEmail ?? '').trim(),
|
||||
sub2apiPassword: String(input?.sub2apiPassword ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiPassword ?? ''),
|
||||
sub2apiGroupName: String(input?.sub2apiGroupName ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiGroupName ?? defaults.flows.openai.source.entries.sub2api.sub2apiGroupName).trim() || defaults.flows.openai.source.entries.sub2api.sub2apiGroupName,
|
||||
sub2apiGroupNames: Array.isArray(input?.sub2apiGroupNames)
|
||||
? input.sub2apiGroupNames.map((entry) => String(entry || '').trim()).filter(Boolean)
|
||||
: (Array.isArray(nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiGroupNames)
|
||||
? nested.flows.openai.source.entries.sub2api.sub2apiGroupNames.map((entry) => String(entry || '').trim()).filter(Boolean)
|
||||
: [...defaults.flows.openai.source.entries.sub2api.sub2apiGroupNames]),
|
||||
sub2apiAccountPriority: Math.max(1, Number(input?.sub2apiAccountPriority ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiAccountPriority ?? defaults.flows.openai.source.entries.sub2api.sub2apiAccountPriority) || defaults.flows.openai.source.entries.sub2api.sub2apiAccountPriority),
|
||||
sub2apiDefaultProxyName: String(input?.sub2apiDefaultProxyName ?? nested?.flows?.openai?.source?.entries?.sub2api?.sub2apiDefaultProxyName ?? '').trim(),
|
||||
},
|
||||
codex2api: {
|
||||
...defaults.flows.openai.source.entries.codex2api,
|
||||
...getSourceValue(nested, (state) => state.flows?.openai?.source?.entries?.codex2api),
|
||||
codex2apiUrl: String(input?.codex2apiUrl ?? nested?.flows?.openai?.source?.entries?.codex2api?.codex2apiUrl ?? '').trim(),
|
||||
codex2apiAdminKey: String(input?.codex2apiAdminKey ?? nested?.flows?.openai?.source?.entries?.codex2api?.codex2apiAdminKey ?? '').trim(),
|
||||
},
|
||||
integrationTargetId: openaiIntegrationTargetId,
|
||||
integrationTargets: {
|
||||
cpa: {
|
||||
...defaults.flows.openai.integrationTargets.cpa,
|
||||
...getIntegrationTargetValue(nested, (state) => state.flows?.openai?.integrationTargets?.cpa),
|
||||
vpsUrl: String(
|
||||
input?.vpsUrl
|
||||
?? nested?.flows?.openai?.integrationTargets?.cpa?.vpsUrl
|
||||
?? ''
|
||||
).trim(),
|
||||
vpsPassword: String(
|
||||
input?.vpsPassword
|
||||
?? nested?.flows?.openai?.integrationTargets?.cpa?.vpsPassword
|
||||
?? ''
|
||||
),
|
||||
localCpaStep9Mode: String(
|
||||
input?.localCpaStep9Mode
|
||||
?? nested?.flows?.openai?.integrationTargets?.cpa?.localCpaStep9Mode
|
||||
?? defaults.flows.openai.integrationTargets.cpa.localCpaStep9Mode
|
||||
).trim() || defaults.flows.openai.integrationTargets.cpa.localCpaStep9Mode,
|
||||
},
|
||||
sub2api: {
|
||||
...defaults.flows.openai.integrationTargets.sub2api,
|
||||
...getIntegrationTargetValue(nested, (state) => state.flows?.openai?.integrationTargets?.sub2api),
|
||||
sub2apiUrl: String(
|
||||
input?.sub2apiUrl
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiUrl
|
||||
?? ''
|
||||
).trim(),
|
||||
sub2apiEmail: String(
|
||||
input?.sub2apiEmail
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiEmail
|
||||
?? ''
|
||||
).trim(),
|
||||
sub2apiPassword: String(
|
||||
input?.sub2apiPassword
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiPassword
|
||||
?? ''
|
||||
),
|
||||
sub2apiGroupName: String(
|
||||
input?.sub2apiGroupName
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiGroupName
|
||||
?? defaults.flows.openai.integrationTargets.sub2api.sub2apiGroupName
|
||||
).trim() || defaults.flows.openai.integrationTargets.sub2api.sub2apiGroupName,
|
||||
sub2apiGroupNames: Array.isArray(input?.sub2apiGroupNames)
|
||||
? input.sub2apiGroupNames.map((entry) => String(entry || '').trim()).filter(Boolean)
|
||||
: (Array.isArray(nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiGroupNames)
|
||||
? nested.flows.openai.integrationTargets.sub2api.sub2apiGroupNames.map((entry) => String(entry || '').trim()).filter(Boolean)
|
||||
: [...defaults.flows.openai.integrationTargets.sub2api.sub2apiGroupNames]),
|
||||
sub2apiAccountPriority: Math.max(1, Number(
|
||||
input?.sub2apiAccountPriority
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiAccountPriority
|
||||
?? defaults.flows.openai.integrationTargets.sub2api.sub2apiAccountPriority
|
||||
) || defaults.flows.openai.integrationTargets.sub2api.sub2apiAccountPriority),
|
||||
sub2apiDefaultProxyName: String(
|
||||
input?.sub2apiDefaultProxyName
|
||||
?? nested?.flows?.openai?.integrationTargets?.sub2api?.sub2apiDefaultProxyName
|
||||
?? ''
|
||||
).trim(),
|
||||
},
|
||||
codex2api: {
|
||||
...defaults.flows.openai.integrationTargets.codex2api,
|
||||
...getIntegrationTargetValue(nested, (state) => state.flows?.openai?.integrationTargets?.codex2api),
|
||||
codex2apiUrl: String(
|
||||
input?.codex2apiUrl
|
||||
?? nested?.flows?.openai?.integrationTargets?.codex2api?.codex2apiUrl
|
||||
?? ''
|
||||
).trim(),
|
||||
codex2apiAdminKey: String(
|
||||
input?.codex2apiAdminKey
|
||||
?? nested?.flows?.openai?.integrationTargets?.codex2api?.codex2apiAdminKey
|
||||
?? ''
|
||||
).trim(),
|
||||
},
|
||||
},
|
||||
signup: {
|
||||
signupMethod: String(input?.signupMethod ?? nested?.flows?.openai?.signup?.signupMethod ?? defaults.flows.openai.signup.signupMethod).trim().toLowerCase() === 'phone' ? 'phone' : 'email',
|
||||
phoneVerificationEnabled: Boolean(input?.phoneVerificationEnabled ?? nested?.flows?.openai?.signup?.phoneVerificationEnabled ?? defaults.flows.openai.signup.phoneVerificationEnabled),
|
||||
phoneSignupReloginAfterBindEmailEnabled: Boolean(input?.phoneSignupReloginAfterBindEmailEnabled ?? nested?.flows?.openai?.signup?.phoneSignupReloginAfterBindEmailEnabled ?? defaults.flows.openai.signup.phoneSignupReloginAfterBindEmailEnabled),
|
||||
signupMethod: String(
|
||||
input?.signupMethod
|
||||
?? nested?.flows?.openai?.signup?.signupMethod
|
||||
?? defaults.flows.openai.signup.signupMethod
|
||||
).trim().toLowerCase() === 'phone' ? 'phone' : 'email',
|
||||
phoneVerificationEnabled: Boolean(
|
||||
input?.phoneVerificationEnabled
|
||||
?? nested?.flows?.openai?.signup?.phoneVerificationEnabled
|
||||
?? defaults.flows.openai.signup.phoneVerificationEnabled
|
||||
),
|
||||
phoneSignupReloginAfterBindEmailEnabled: Boolean(
|
||||
input?.phoneSignupReloginAfterBindEmailEnabled
|
||||
?? nested?.flows?.openai?.signup?.phoneSignupReloginAfterBindEmailEnabled
|
||||
?? defaults.flows.openai.signup.phoneSignupReloginAfterBindEmailEnabled
|
||||
),
|
||||
},
|
||||
plus: {
|
||||
plusModeEnabled: Boolean(input?.plusModeEnabled ?? nested?.flows?.openai?.plus?.plusModeEnabled ?? defaults.flows.openai.plus.plusModeEnabled),
|
||||
plusPaymentMethod: String(input?.plusPaymentMethod ?? nested?.flows?.openai?.plus?.plusPaymentMethod ?? defaults.flows.openai.plus.plusPaymentMethod).trim() || defaults.flows.openai.plus.plusPaymentMethod,
|
||||
plusModeEnabled: Boolean(
|
||||
input?.plusModeEnabled
|
||||
?? nested?.flows?.openai?.plus?.plusModeEnabled
|
||||
?? defaults.flows.openai.plus.plusModeEnabled
|
||||
),
|
||||
plusPaymentMethod: String(
|
||||
input?.plusPaymentMethod
|
||||
?? nested?.flows?.openai?.plus?.plusPaymentMethod
|
||||
?? defaults.flows.openai.plus.plusPaymentMethod
|
||||
).trim() || defaults.flows.openai.plus.plusPaymentMethod,
|
||||
},
|
||||
autoRun: {
|
||||
stepExecutionRange: normalizeStepExecutionRangeEntry(
|
||||
@@ -269,47 +313,25 @@
|
||||
},
|
||||
},
|
||||
kiro: {
|
||||
source: {
|
||||
selected: kiroSelectedSource,
|
||||
entries: {
|
||||
'kiro-rs': {
|
||||
...defaults.flows.kiro.source.entries['kiro-rs'],
|
||||
...getSourceValue(nested, (state) => state.flows?.kiro?.source?.entries?.['kiro-rs']),
|
||||
kiroRsUrl: String(
|
||||
input?.kiroRsUrl
|
||||
?? nested?.flows?.kiro?.source?.entries?.['kiro-rs']?.kiroRsUrl
|
||||
?? defaults.flows.kiro.source.entries['kiro-rs'].kiroRsUrl
|
||||
).trim() || defaults.flows.kiro.source.entries['kiro-rs'].kiroRsUrl,
|
||||
kiroRsKey: String(
|
||||
input?.kiroRsKey
|
||||
?? nested?.flows?.kiro?.source?.entries?.['kiro-rs']?.kiroRsKey
|
||||
?? defaults.flows.kiro.source.entries['kiro-rs'].kiroRsKey
|
||||
),
|
||||
},
|
||||
integrationTargetId: kiroIntegrationTargetId,
|
||||
integrationTargets: {
|
||||
'kiro-rs': {
|
||||
...defaults.flows.kiro.integrationTargets['kiro-rs'],
|
||||
...getIntegrationTargetValue(nested, (state) => state.flows?.kiro?.integrationTargets?.['kiro-rs']),
|
||||
baseUrl: String(
|
||||
input?.kiroRsUrl
|
||||
?? input?.kiroRsBaseUrl
|
||||
?? nested?.flows?.kiro?.integrationTargets?.['kiro-rs']?.baseUrl
|
||||
?? defaults.flows.kiro.integrationTargets['kiro-rs'].baseUrl
|
||||
).trim() || defaults.flows.kiro.integrationTargets['kiro-rs'].baseUrl,
|
||||
apiKey: String(
|
||||
input?.kiroRsKey
|
||||
?? input?.kiroRsApiKey
|
||||
?? nested?.flows?.kiro?.integrationTargets?.['kiro-rs']?.apiKey
|
||||
?? defaults.flows.kiro.integrationTargets['kiro-rs'].apiKey
|
||||
),
|
||||
},
|
||||
},
|
||||
options: {
|
||||
kiroRsPriority: Number(
|
||||
input?.kiroRsPriority
|
||||
?? nested?.flows?.kiro?.options?.kiroRsPriority
|
||||
?? defaults.flows.kiro.options.kiroRsPriority
|
||||
) || 0,
|
||||
kiroRsEndpoint: String(
|
||||
input?.kiroRsEndpoint
|
||||
?? nested?.flows?.kiro?.options?.kiroRsEndpoint
|
||||
?? defaults.flows.kiro.options.kiroRsEndpoint
|
||||
).trim(),
|
||||
kiroRsAuthRegion: String(
|
||||
input?.kiroRsAuthRegion
|
||||
?? nested?.flows?.kiro?.options?.kiroRsAuthRegion
|
||||
?? defaults.flows.kiro.options.kiroRsAuthRegion
|
||||
).trim(),
|
||||
kiroRsApiRegion: String(
|
||||
input?.kiroRsApiRegion
|
||||
?? nested?.flows?.kiro?.options?.kiroRsApiRegion
|
||||
?? defaults.flows.kiro.options.kiroRsApiRegion
|
||||
).trim(),
|
||||
},
|
||||
autoRun: {
|
||||
stepExecutionRange: normalizeStepExecutionRangeEntry(
|
||||
nested?.flows?.kiro?.autoRun?.stepExecutionRange
|
||||
@@ -323,6 +345,53 @@
|
||||
};
|
||||
}
|
||||
|
||||
function mergeSettingsState(baseValue = {}, patchValue = {}) {
|
||||
const baseSettingsState = normalizeSettingsState(baseValue);
|
||||
const patchSettingsState = normalizeSettingsState({
|
||||
settingsState: patchValue,
|
||||
activeFlowId: patchValue?.activeFlowId ?? baseSettingsState.activeFlowId,
|
||||
});
|
||||
|
||||
function mergeRecursive(baseNode, patchNode) {
|
||||
if (Array.isArray(patchNode)) {
|
||||
return patchNode.map((entry) => cloneValue(entry));
|
||||
}
|
||||
if (!isPlainObject(patchNode)) {
|
||||
return patchNode === undefined ? cloneValue(baseNode) : patchNode;
|
||||
}
|
||||
const next = {
|
||||
...cloneValue(isPlainObject(baseNode) ? baseNode : {}),
|
||||
};
|
||||
Object.entries(patchNode).forEach(([key, value]) => {
|
||||
next[key] = mergeRecursive(baseNode?.[key], value);
|
||||
});
|
||||
return next;
|
||||
}
|
||||
|
||||
return normalizeSettingsState({
|
||||
settingsState: mergeRecursive(baseSettingsState, patchSettingsState),
|
||||
});
|
||||
}
|
||||
|
||||
function getFlowSettings(settingsState = {}, flowId) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
const normalizedFlowId = normalizeFlowId(flowId, normalizedState.activeFlowId);
|
||||
return cloneValue(normalizedState?.flows?.[normalizedFlowId] || {});
|
||||
}
|
||||
|
||||
function getSelectedIntegrationTargetId(settingsState = {}, flowId) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
const normalizedFlowId = normalizeFlowId(flowId, normalizedState.activeFlowId);
|
||||
const flowSettings = normalizedState?.flows?.[normalizedFlowId] || {};
|
||||
return normalizeIntegrationTargetId(
|
||||
normalizedFlowId,
|
||||
flowSettings?.integrationTargetId,
|
||||
normalizedFlowId === 'kiro'
|
||||
? defaultKiroIntegrationTargetId
|
||||
: defaultOpenAiIntegrationTargetId
|
||||
);
|
||||
}
|
||||
|
||||
function buildStepExecutionRangeByFlow(settingsState = {}) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
return {
|
||||
@@ -337,23 +406,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
function getFlowSettings(settingsState = {}, flowId) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
const normalizedFlowId = normalizeFlowId(flowId, normalizedState.activeFlowId);
|
||||
return cloneValue(normalizedState?.flows?.[normalizedFlowId] || {});
|
||||
}
|
||||
|
||||
function getSelectedSourceId(settingsState = {}, flowId) {
|
||||
const flowSettings = getFlowSettings(settingsState, flowId);
|
||||
const normalizedFlowId = normalizeFlowId(flowId, normalizeSettingsState(settingsState).activeFlowId);
|
||||
return normalizeSourceId(
|
||||
normalizedFlowId,
|
||||
flowSettings?.source?.selected,
|
||||
normalizedFlowId === 'kiro' ? defaultKiroSourceId : defaultOpenAiSourceId
|
||||
);
|
||||
}
|
||||
|
||||
function buildLegacySettingsPayload(settingsState = {}, baseInput = {}) {
|
||||
function buildSettingsView(settingsState = {}, baseInput = {}) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
const next = {
|
||||
...(isPlainObject(baseInput) ? cloneValue(baseInput) : {}),
|
||||
@@ -361,20 +414,22 @@
|
||||
const openaiState = normalizedState.flows.openai;
|
||||
const kiroState = normalizedState.flows.kiro;
|
||||
next.activeFlowId = normalizedState.activeFlowId;
|
||||
next.panelMode = mapSourceIdToPanelMode('openai', openaiState.source.selected, defaultOpenAiSourceId);
|
||||
next.kiroSourceId = getSelectedSourceId(normalizedState, 'kiro');
|
||||
next.vpsUrl = openaiState.source.entries.cpa.vpsUrl;
|
||||
next.vpsPassword = openaiState.source.entries.cpa.vpsPassword;
|
||||
next.localCpaStep9Mode = openaiState.source.entries.cpa.localCpaStep9Mode;
|
||||
next.sub2apiUrl = openaiState.source.entries.sub2api.sub2apiUrl;
|
||||
next.sub2apiEmail = openaiState.source.entries.sub2api.sub2apiEmail;
|
||||
next.sub2apiPassword = openaiState.source.entries.sub2api.sub2apiPassword;
|
||||
next.sub2apiGroupName = openaiState.source.entries.sub2api.sub2apiGroupName;
|
||||
next.sub2apiGroupNames = cloneValue(openaiState.source.entries.sub2api.sub2apiGroupNames);
|
||||
next.sub2apiAccountPriority = openaiState.source.entries.sub2api.sub2apiAccountPriority;
|
||||
next.sub2apiDefaultProxyName = openaiState.source.entries.sub2api.sub2apiDefaultProxyName;
|
||||
next.codex2apiUrl = openaiState.source.entries.codex2api.codex2apiUrl;
|
||||
next.codex2apiAdminKey = openaiState.source.entries.codex2api.codex2apiAdminKey;
|
||||
next.openaiIntegrationTargetId = getSelectedIntegrationTargetId(normalizedState, 'openai');
|
||||
next.kiroIntegrationTargetId = getSelectedIntegrationTargetId(normalizedState, 'kiro');
|
||||
next.panelMode = next.openaiIntegrationTargetId;
|
||||
next.kiroSourceId = next.kiroIntegrationTargetId;
|
||||
next.vpsUrl = openaiState.integrationTargets.cpa.vpsUrl;
|
||||
next.vpsPassword = openaiState.integrationTargets.cpa.vpsPassword;
|
||||
next.localCpaStep9Mode = openaiState.integrationTargets.cpa.localCpaStep9Mode;
|
||||
next.sub2apiUrl = openaiState.integrationTargets.sub2api.sub2apiUrl;
|
||||
next.sub2apiEmail = openaiState.integrationTargets.sub2api.sub2apiEmail;
|
||||
next.sub2apiPassword = openaiState.integrationTargets.sub2api.sub2apiPassword;
|
||||
next.sub2apiGroupName = openaiState.integrationTargets.sub2api.sub2apiGroupName;
|
||||
next.sub2apiGroupNames = cloneValue(openaiState.integrationTargets.sub2api.sub2apiGroupNames);
|
||||
next.sub2apiAccountPriority = openaiState.integrationTargets.sub2api.sub2apiAccountPriority;
|
||||
next.sub2apiDefaultProxyName = openaiState.integrationTargets.sub2api.sub2apiDefaultProxyName;
|
||||
next.codex2apiUrl = openaiState.integrationTargets.codex2api.codex2apiUrl;
|
||||
next.codex2apiAdminKey = openaiState.integrationTargets.codex2api.codex2apiAdminKey;
|
||||
next.customPassword = normalizedState.services.account.customPassword;
|
||||
next.signupMethod = openaiState.signup.signupMethod;
|
||||
next.phoneVerificationEnabled = openaiState.signup.phoneVerificationEnabled;
|
||||
@@ -385,13 +440,8 @@
|
||||
next.ipProxyEnabled = normalizedState.services.proxy.enabled;
|
||||
next.ipProxyService = normalizedState.services.proxy.provider;
|
||||
next.ipProxyMode = normalizedState.services.proxy.mode;
|
||||
next.kiroRsUrl = kiroState.source.entries['kiro-rs'].kiroRsUrl;
|
||||
next.kiroRsKey = kiroState.source.entries['kiro-rs'].kiroRsKey;
|
||||
next.kiroRsPriority = kiroState.options.kiroRsPriority;
|
||||
next.kiroRsEndpoint = kiroState.options.kiroRsEndpoint;
|
||||
next.kiroRsAuthRegion = kiroState.options.kiroRsAuthRegion;
|
||||
next.kiroRsApiRegion = kiroState.options.kiroRsApiRegion;
|
||||
delete next.kiroRegion;
|
||||
next.kiroRsUrl = kiroState.integrationTargets['kiro-rs'].baseUrl;
|
||||
next.kiroRsKey = kiroState.integrationTargets['kiro-rs'].apiKey;
|
||||
next.stepExecutionRangeByFlow = buildStepExecutionRangeByFlow(normalizedState);
|
||||
next.settingsSchemaVersion = normalizedState.schemaVersion;
|
||||
next.settingsState = cloneValue(normalizedState);
|
||||
@@ -401,34 +451,29 @@
|
||||
function getFlowInputState(settingsState = {}, flowId) {
|
||||
const normalizedState = normalizeSettingsState(settingsState);
|
||||
const normalizedFlowId = normalizeFlowId(flowId, normalizedState.activeFlowId);
|
||||
const integrationTargetId = getSelectedIntegrationTargetId(normalizedState, normalizedFlowId);
|
||||
if (normalizedFlowId === 'kiro') {
|
||||
return {
|
||||
activeFlowId: normalizedFlowId,
|
||||
sourceId: getSelectedSourceId(normalizedState, 'kiro'),
|
||||
kiroRsUrl: normalizedState.flows.kiro.source.entries['kiro-rs'].kiroRsUrl,
|
||||
kiroRsKey: normalizedState.flows.kiro.source.entries['kiro-rs'].kiroRsKey,
|
||||
integrationTargetId,
|
||||
kiroRsUrl: normalizedState.flows.kiro.integrationTargets['kiro-rs'].baseUrl,
|
||||
kiroRsKey: normalizedState.flows.kiro.integrationTargets['kiro-rs'].apiKey,
|
||||
};
|
||||
}
|
||||
return {
|
||||
activeFlowId: normalizedFlowId,
|
||||
sourceId: getSelectedSourceId(normalizedState, 'openai'),
|
||||
panelMode: mapSourceIdToPanelMode('openai', normalizedState.flows.openai.source.selected, defaultOpenAiSourceId),
|
||||
integrationTargetId,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeFlatInput(input = {}) {
|
||||
const state = normalizeSettingsState(input);
|
||||
return buildLegacySettingsPayload(state, input);
|
||||
}
|
||||
|
||||
return {
|
||||
buildDefaultSettingsState,
|
||||
buildLegacySettingsPayload,
|
||||
buildSettingsView,
|
||||
buildStepExecutionRangeByFlow,
|
||||
getFlowInputState,
|
||||
getFlowSettings,
|
||||
getSelectedSourceId,
|
||||
normalizeFlatInput,
|
||||
getSelectedIntegrationTargetId,
|
||||
mergeSettingsState,
|
||||
normalizeSettingsState,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user