fix: auto-detect file_permission for file-related tools in step_probe + always check cmd for allow
This commit is contained in:
@@ -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) {
|
||||
// File permission detection: check command content or explicit step_type
|
||||
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
|
||||
const btnIdx = resp.button_index ?? -1;
|
||||
if (btnIdx === 1) {
|
||||
pendingStepType = 'file_permission_conversation';
|
||||
}
|
||||
else if (btnIdx === 2) {
|
||||
pendingStepType = 'file_permission_deny';
|
||||
}
|
||||
else {
|
||||
pendingStepType = 'file_permission_once';
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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';
|
||||
logToFile(`[RESPONSE] file_permission detected from pending cmd, mapped to ${pendingStepType}`);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1687,7 +1687,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',
|
||||
});
|
||||
@@ -1742,7 +1742,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',
|
||||
});
|
||||
@@ -2070,22 +2070,19 @@ async function processResponseFile(filePath: string) {
|
||||
|| pending.source === 'dom_observer';
|
||||
pendingStepType = pending.step_type || '';
|
||||
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
|
||||
if (!pendingStepType && pending.command) {
|
||||
// File permission detection: check command content or explicit step_type
|
||||
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
|
||||
const btnIdx = resp.button_index ?? -1;
|
||||
if (btnIdx === 1) {
|
||||
pendingStepType = 'file_permission_conversation';
|
||||
} else if (btnIdx === 2) {
|
||||
pendingStepType = 'file_permission_deny';
|
||||
} else {
|
||||
pendingStepType = 'file_permission_once';
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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';
|
||||
logToFile(`[RESPONSE] file_permission detected from pending cmd, mapped to ${pendingStepType}`);
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
- 4차 수정: ApprovalRequest + 단일 봇 인스턴스 테스트 (15:21)
|
||||
- 5차 수정: 진단 로그 추가 — step_type 확인 (15:25)
|
||||
- 6차 수정: 기본 콜백 step_type 최종 테스트 (15:31)
|
||||
- 7차 수정: dirty doc 포커스 + Accept all 테스트 (15:35)
|
||||
|
||||
Reference in New Issue
Block a user