fix: route file_permission scope by cmd (once=1, conversation=2)

This commit is contained in:
2026-03-10 11:20:55 +09:00
parent c612c37105
commit c9b4fd4722
3 changed files with 23 additions and 11 deletions

View File

@@ -1943,11 +1943,14 @@ async function processResponseFile(filePath: string) {
|| pending.source === 'dom_observer';
pendingStepType = pending.step_type || '';
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
// Infer step_type from cmd if not explicitly set
if (!pendingStepType && pending.command) {
const cmd = (pending.command || '').toLowerCase();
if (cmd.includes('allow once') || cmd.includes('allow this conversation')) {
pendingStepType = 'file_permission';
if (cmd.includes('allow this conversation')) {
pendingStepType = 'file_permission_conversation';
} else if (cmd.includes('allow once')) {
pendingStepType = 'file_permission_once';
} else if (cmd.includes('allow')) {
pendingStepType = 'file_permission_once'; // default to once
}
}
} catch { }
@@ -2252,8 +2255,10 @@ async function tryApprovalStrategies(approved: boolean, sessionId: string, stepT
} else if (typeLower.includes('invoke_subagent') || typeLower.includes('extension_code')) {
interactionPayload = { runExtensionCode: { confirm: true } };
} else if (typeLower.includes('file_permission')) {
// FilePermissionInteraction: allow=true, scope=ONCE(1) or CONVERSATION(2)
interactionPayload = { filePermission: { allow: true, scope: 1 } }; // PERMISSION_SCOPE_ONCE
// FilePermissionInteraction: allow=true, scope depends on cmd
// file_permission_once → 1, file_permission_conversation → 2
const scope = typeLower.includes('conversation') ? 2 : 1;
interactionPayload = { filePermission: { allow: true, scope } };
} else if (typeLower.includes('elicitation')) {
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
} else {