fix: auto-detect file_permission for file-related tools in step_probe + always check cmd for allow

This commit is contained in:
2026-03-10 15:50:01 +09:00
parent 4dcb78c1ce
commit d1586c5e97
4 changed files with 32 additions and 36 deletions

View File

@@ -1716,7 +1716,7 @@ function setupMonitor() {
conversation_id: activeSessionId,
command,
description: `Step #${actualIndex} (${(oStep.type || '').replace('CORTEX_STEP_TYPE_', '')})`,
step_type: toolName,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search'].includes(toolName) ? 'file_permission' : toolName,
step_index: actualIndex,
source: 'step_probe_offset',
});
@@ -1772,7 +1772,7 @@ function setupMonitor() {
conversation_id: activeSessionId,
command,
description,
step_type: toolName,
step_type: ['view_file', 'list_dir', 'find_by_name', 'read_file', 'grep_search'].includes(toolName) ? 'file_permission' : toolName,
step_index: si,
source: 'step_probe',
});
@@ -2115,23 +2115,21 @@ async function processResponseFile(filePath) {
|| pending.source === 'dom_observer';
pendingStepType = pending.step_type || '';
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
if (!pendingStepType && pending.command) {
const cmd = (pending.command || '').toLowerCase();
if (cmd.includes('allow') || cmd.includes('파일 접근') || pending.step_type === 'file_permission') {
// Map button_index → scope: 0=Once, 1=Conversation, 2=Deny
const btnIdx = resp.button_index ?? -1;
if (btnIdx === 1) {
pendingStepType = 'file_permission_conversation';
}
else {
pendingStepType = 'file_permission_once';
}
}
}
// Also handle when step_type was explicitly set
if (pendingStepType === 'file_permission') {
// File permission detection: check command content or explicit step_type
const cmd = (pending.command || '').toLowerCase();
if (pendingStepType === 'file_permission' || cmd.includes('allow') || cmd.includes('파일 접근')) {
// Map button_index → scope: 0=Once, 1=Conversation, 2=Deny
const btnIdx = resp.button_index ?? -1;
pendingStepType = btnIdx === 1 ? 'file_permission_conversation' : 'file_permission_once';
if (btnIdx === 1) {
pendingStepType = 'file_permission_conversation';
}
else if (btnIdx === 2) {
pendingStepType = 'file_permission_deny';
}
else {
pendingStepType = 'file_permission_once';
}
logToFile(`[RESPONSE] file_permission detected from pending cmd, mapped to ${pendingStepType}`);
}
}
catch { }

File diff suppressed because one or more lines are too long