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

File diff suppressed because one or more lines are too long

View File

@@ -1687,7 +1687,7 @@ function setupMonitor() {
conversation_id: activeSessionId, conversation_id: activeSessionId,
command, command,
description: `Step #${actualIndex} (${(oStep.type || '').replace('CORTEX_STEP_TYPE_', '')})`, 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, step_index: actualIndex,
source: 'step_probe_offset', source: 'step_probe_offset',
}); });
@@ -1742,7 +1742,7 @@ function setupMonitor() {
conversation_id: activeSessionId, conversation_id: activeSessionId,
command, command,
description, 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, step_index: si,
source: 'step_probe', source: 'step_probe',
}); });
@@ -2070,22 +2070,19 @@ 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;
if (!pendingStepType && pending.command) { // File permission detection: check command content or explicit step_type
const cmd = (pending.command || '').toLowerCase(); const cmd = (pending.command || '').toLowerCase();
if (cmd.includes('allow') || cmd.includes('파일 접근') || pending.step_type === 'file_permission') { if (pendingStepType === 'file_permission' || cmd.includes('allow') || cmd.includes('파일 접근')) {
// Map button_index → scope: 0=Once, 1=Conversation, 2=Deny // Map button_index → scope: 0=Once, 1=Conversation, 2=Deny
const btnIdx = resp.button_index ?? -1; const btnIdx = resp.button_index ?? -1;
if (btnIdx === 1) { if (btnIdx === 1) {
pendingStepType = 'file_permission_conversation'; pendingStepType = 'file_permission_conversation';
} else if (btnIdx === 2) {
pendingStepType = 'file_permission_deny';
} else { } else {
pendingStepType = 'file_permission_once'; pendingStepType = 'file_permission_once';
} }
} logToFile(`[RESPONSE] file_permission detected from pending cmd, mapped to ${pendingStepType}`);
}
// Also handle when step_type was explicitly set
if (pendingStepType === 'file_permission') {
const btnIdx = resp.button_index ?? -1;
pendingStepType = btnIdx === 1 ? 'file_permission_conversation' : 'file_permission_once';
} }
} catch { } } catch { }
} }

View File

@@ -9,3 +9,4 @@
- 4차 수정: ApprovalRequest + 단일 봇 인스턴스 테스트 (15:21) - 4차 수정: ApprovalRequest + 단일 봇 인스턴스 테스트 (15:21)
- 5차 수정: 진단 로그 추가 — step_type 확인 (15:25) - 5차 수정: 진단 로그 추가 — step_type 확인 (15:25)
- 6차 수정: 기본 콜백 step_type 최종 테스트 (15:31) - 6차 수정: 기본 콜백 step_type 최종 테스트 (15:31)
- 7차 수정: dirty doc 포커스 + Accept all 테스트 (15:35)