Files
X-Financial/web/src/composables/workbenchAiMode/workbenchIntentActionPolicy.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

const QUERY_CANDIDATE_ACTIONS = new Set(['delete', 'approve', 'reject', 'query'])
export function resolveWorkbenchIntentActionRoute(frame = null) {
if (!frame) {
return { nextStep: 'pass_through' }
}
if (frame.safetyLevel === 'blocked') {
return { nextStep: 'blocked', reason: '高风险批量动作需要先选择具体单据。' }
}
if (frame.action === 'ask_policy') {
return { nextStep: 'pass_through' }
}
if (frame.policyDecision === 'need_confirmation') {
return {
nextStep: 'open_context_confirm',
riskLevel: frame.riskLevel,
requiresSelection: Boolean(frame.requiresSelection),
requiresConfirmation: Boolean(frame.requiresConfirmation)
}
}
if (frame.policyDecision === 'query_candidates' && QUERY_CANDIDATE_ACTIONS.has(frame.action)) {
return {
nextStep: 'query_candidates',
queryPrompt: frame.normalizedQuery || '',
riskLevel: frame.riskLevel,
requiresSelection: Boolean(frame.requiresSelection),
requiresConfirmation: Boolean(frame.requiresConfirmation)
}
}
return { nextStep: 'pass_through' }
}