fix: route file_permission scope by cmd (once=1, conversation=2)
This commit is contained in:
@@ -1987,11 +1987,16 @@ async function processResponseFile(filePath) {
|
|||||||
|| pending.source === 'dom_observer';
|
|| pending.source === 'dom_observer';
|
||||||
pendingStepType = pending.step_type || '';
|
pendingStepType = pending.step_type || '';
|
||||||
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
|
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
|
||||||
// Infer step_type from cmd if not explicitly set
|
|
||||||
if (!pendingStepType && pending.command) {
|
if (!pendingStepType && pending.command) {
|
||||||
const cmd = (pending.command || '').toLowerCase();
|
const cmd = (pending.command || '').toLowerCase();
|
||||||
if (cmd.includes('allow once') || cmd.includes('allow this conversation')) {
|
if (cmd.includes('allow this conversation')) {
|
||||||
pendingStepType = 'file_permission';
|
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 } };
|
interactionPayload = { runExtensionCode: { confirm: true } };
|
||||||
}
|
}
|
||||||
else if (typeLower.includes('file_permission')) {
|
else if (typeLower.includes('file_permission')) {
|
||||||
// FilePermissionInteraction: allow=true, scope=ONCE(1) or CONVERSATION(2)
|
// FilePermissionInteraction: allow=true, scope depends on cmd
|
||||||
interactionPayload = { filePermission: { allow: true, scope: 1 } }; // PERMISSION_SCOPE_ONCE
|
// 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')) {
|
else if (typeLower.includes('elicitation')) {
|
||||||
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1943,11 +1943,14 @@ async function processResponseFile(filePath: string) {
|
|||||||
|| pending.source === 'dom_observer';
|
|| pending.source === 'dom_observer';
|
||||||
pendingStepType = pending.step_type || '';
|
pendingStepType = pending.step_type || '';
|
||||||
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
|
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
|
||||||
// Infer step_type from cmd if not explicitly set
|
|
||||||
if (!pendingStepType && pending.command) {
|
if (!pendingStepType && pending.command) {
|
||||||
const cmd = (pending.command || '').toLowerCase();
|
const cmd = (pending.command || '').toLowerCase();
|
||||||
if (cmd.includes('allow once') || cmd.includes('allow this conversation')) {
|
if (cmd.includes('allow this conversation')) {
|
||||||
pendingStepType = 'file_permission';
|
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 { }
|
} catch { }
|
||||||
@@ -2252,8 +2255,10 @@ async function tryApprovalStrategies(approved: boolean, sessionId: string, stepT
|
|||||||
} else if (typeLower.includes('invoke_subagent') || typeLower.includes('extension_code')) {
|
} else if (typeLower.includes('invoke_subagent') || typeLower.includes('extension_code')) {
|
||||||
interactionPayload = { runExtensionCode: { confirm: true } };
|
interactionPayload = { runExtensionCode: { confirm: true } };
|
||||||
} else if (typeLower.includes('file_permission')) {
|
} else if (typeLower.includes('file_permission')) {
|
||||||
// FilePermissionInteraction: allow=true, scope=ONCE(1) or CONVERSATION(2)
|
// FilePermissionInteraction: allow=true, scope depends on cmd
|
||||||
interactionPayload = { filePermission: { allow: true, scope: 1 } }; // PERMISSION_SCOPE_ONCE
|
// 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')) {
|
} else if (typeLower.includes('elicitation')) {
|
||||||
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user