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

@@ -1987,11 +1987,16 @@ async function processResponseFile(filePath) {
|| 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
}
}
}
@@ -2311,8 +2316,10 @@ async function tryApprovalStrategies(approved, sessionId, stepType = '', stepInd
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)

File diff suppressed because one or more lines are too long