Compare commits
2 Commits
563fbadd5a
...
75a3482a9c
| Author | SHA1 | Date | |
|---|---|---|---|
| 75a3482a9c | |||
| df592723b7 |
@@ -1627,7 +1627,7 @@ function setupMonitor() {
|
|||||||
try {
|
try {
|
||||||
const args = JSON.parse(toolCall.argumentsJson);
|
const args = JSON.parse(toolCall.argumentsJson);
|
||||||
if (args.CommandLine)
|
if (args.CommandLine)
|
||||||
command = `${toolName}: ${args.CommandLine.substring(0, 150)}`;
|
command = `${toolName}: ${args.CommandLine.substring(0, 1500)}`;
|
||||||
else if (args.TargetFile)
|
else if (args.TargetFile)
|
||||||
command = `${toolName}: ${args.TargetFile.split(/[\\/]/).pop()}`;
|
command = `${toolName}: ${args.TargetFile.split(/[\\/]/).pop()}`;
|
||||||
else
|
else
|
||||||
@@ -1846,7 +1846,7 @@ function setupMonitor() {
|
|||||||
for (let ri = steps.length - 1; ri >= 0; ri--) {
|
for (let ri = steps.length - 1; ri >= 0; ri--) {
|
||||||
const s = steps[ri];
|
const s = steps[ri];
|
||||||
const sType = s?.type || '';
|
const sType = s?.type || '';
|
||||||
if (sType.includes('PLANNER_RESPONSE') || sType.includes('MESSAGE')) {
|
if (sType.includes('PLANNER_RESPONSE') && !sType.includes('EPHEMERAL')) {
|
||||||
let textContent = '';
|
let textContent = '';
|
||||||
// Extract from plannerResponse field
|
// Extract from plannerResponse field
|
||||||
const pr = s?.plannerResponse;
|
const pr = s?.plannerResponse;
|
||||||
@@ -1983,6 +1983,13 @@ 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) {
|
||||||
|
const cmd = (pending.command || '').toLowerCase();
|
||||||
|
if (cmd.includes('allow once') || cmd.includes('allow this conversation')) {
|
||||||
|
pendingStepType = 'file_permission';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
@@ -1992,8 +1999,10 @@ async function processResponseFile(filePath) {
|
|||||||
// Step probe/stall: try RPC → VS Code commands → log results
|
// Step probe/stall: try RPC → VS Code commands → log results
|
||||||
const approved = resp.approved;
|
const approved = resp.approved;
|
||||||
if (isDomObserver) {
|
if (isDomObserver) {
|
||||||
// DOM observer path: renderer polls /response/:rid and clicks directly
|
// DOM observer path: ALSO try RPC strategies (renderer click is unreliable)
|
||||||
logToFile(`[RESPONSE] renderer-handled approval (rid=${resp.request_id})`);
|
logToFile(`[RESPONSE] dom_observer → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
|
||||||
|
const strategyResult = await tryApprovalStrategies(approved, activeSessionId, pendingStepType, pendingStepIndex);
|
||||||
|
logToFile(`[RESPONSE] dom strategy result: ${strategyResult}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Step probe path: run ALL approval strategies
|
// Step probe path: run ALL approval strategies
|
||||||
@@ -2286,6 +2295,13 @@ async function tryApprovalStrategies(approved, sessionId, stepType = '', stepInd
|
|||||||
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')) {
|
||||||
|
// FilePermissionInteraction: allow=true, scope=ONCE(1) or CONVERSATION(2)
|
||||||
|
interactionPayload = { filePermission: { allow: true, scope: 1 } }; // PERMISSION_SCOPE_ONCE
|
||||||
|
}
|
||||||
|
else if (typeLower.includes('elicitation')) {
|
||||||
|
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Default: try run_command (most common)
|
// Default: try run_command (most common)
|
||||||
interactionPayload = { runCommand: { confirm: true } };
|
interactionPayload = { runCommand: { confirm: true } };
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1604,7 +1604,7 @@ function setupMonitor() {
|
|||||||
if (toolCall?.argumentsJson) {
|
if (toolCall?.argumentsJson) {
|
||||||
try {
|
try {
|
||||||
const args = JSON.parse(toolCall.argumentsJson);
|
const args = JSON.parse(toolCall.argumentsJson);
|
||||||
if (args.CommandLine) command = `${toolName}: ${args.CommandLine.substring(0, 150)}`;
|
if (args.CommandLine) command = `${toolName}: ${args.CommandLine.substring(0, 1500)}`;
|
||||||
else if (args.TargetFile) command = `${toolName}: ${args.TargetFile.split(/[\\/]/).pop()}`;
|
else if (args.TargetFile) command = `${toolName}: ${args.TargetFile.split(/[\\/]/).pop()}`;
|
||||||
else command = `${toolName}: ${Object.keys(args).join(', ')}`;
|
else command = `${toolName}: ${Object.keys(args).join(', ')}`;
|
||||||
} catch { command = toolName; }
|
} catch { command = toolName; }
|
||||||
@@ -1812,7 +1812,7 @@ function setupMonitor() {
|
|||||||
for (let ri = steps.length - 1; ri >= 0; ri--) {
|
for (let ri = steps.length - 1; ri >= 0; ri--) {
|
||||||
const s = steps[ri];
|
const s = steps[ri];
|
||||||
const sType = s?.type || '';
|
const sType = s?.type || '';
|
||||||
if (sType.includes('PLANNER_RESPONSE') || sType.includes('MESSAGE')) {
|
if (sType.includes('PLANNER_RESPONSE') && !sType.includes('EPHEMERAL')) {
|
||||||
let textContent = '';
|
let textContent = '';
|
||||||
// Extract from plannerResponse field
|
// Extract from plannerResponse field
|
||||||
const pr = s?.plannerResponse;
|
const pr = s?.plannerResponse;
|
||||||
@@ -1939,6 +1939,13 @@ 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) {
|
||||||
|
const cmd = (pending.command || '').toLowerCase();
|
||||||
|
if (cmd.includes('allow once') || cmd.includes('allow this conversation')) {
|
||||||
|
pendingStepType = 'file_permission';
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1950,8 +1957,10 @@ async function processResponseFile(filePath: string) {
|
|||||||
const approved = resp.approved;
|
const approved = resp.approved;
|
||||||
|
|
||||||
if (isDomObserver) {
|
if (isDomObserver) {
|
||||||
// DOM observer path: renderer polls /response/:rid and clicks directly
|
// DOM observer path: ALSO try RPC strategies (renderer click is unreliable)
|
||||||
logToFile(`[RESPONSE] renderer-handled approval (rid=${resp.request_id})`);
|
logToFile(`[RESPONSE] dom_observer → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
|
||||||
|
const strategyResult = await tryApprovalStrategies(approved, activeSessionId, pendingStepType, pendingStepIndex);
|
||||||
|
logToFile(`[RESPONSE] dom strategy result: ${strategyResult}`);
|
||||||
} else {
|
} else {
|
||||||
// Step probe path: run ALL approval strategies
|
// Step probe path: run ALL approval strategies
|
||||||
logToFile(`[RESPONSE] step_probe → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
|
logToFile(`[RESPONSE] step_probe → tryApprovalStrategies(${approved}, ${activeSessionId.substring(0, 8)}, type=${pendingStepType}, step=${pendingStepIndex})`);
|
||||||
@@ -2226,6 +2235,11 @@ async function tryApprovalStrategies(approved: boolean, sessionId: string, stepT
|
|||||||
interactionPayload = { mcpTool: { confirm: true } }; // guess
|
interactionPayload = { mcpTool: { confirm: true } }; // guess
|
||||||
} 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')) {
|
||||||
|
// FilePermissionInteraction: allow=true, scope=ONCE(1) or CONVERSATION(2)
|
||||||
|
interactionPayload = { filePermission: { allow: true, scope: 1 } }; // PERMISSION_SCOPE_ONCE
|
||||||
|
} else if (typeLower.includes('elicitation')) {
|
||||||
|
interactionPayload = { elicitation: {} }; // ElicitationInteraction (TBD)
|
||||||
} else {
|
} else {
|
||||||
// Default: try run_command (most common)
|
// Default: try run_command (most common)
|
||||||
interactionPayload = { runCommand: { confirm: true } };
|
interactionPayload = { runCommand: { confirm: true } };
|
||||||
|
|||||||
Reference in New Issue
Block a user