Throw FileRestrictionErrors sooner

This commit is contained in:
Matt Rubens
2025-01-26 02:43:40 -05:00
parent 813c607440
commit 5d20477785
4 changed files with 113 additions and 36 deletions

View File

@@ -1144,25 +1144,22 @@ export class Cline {
await this.browserSession.closeBrowser()
}
// Only validate complete tool uses
if (!block.partial) {
const { mode } = (await this.providerRef.deref()?.getState()) ?? {}
const { customModes } = (await this.providerRef.deref()?.getState()) ?? {}
try {
validateToolUse(
block.name as ToolName,
mode ?? defaultModeSlug,
customModes ?? [],
{
apply_diff: this.diffEnabled,
},
block.params,
)
} catch (error) {
this.consecutiveMistakeCount++
pushToolResult(formatResponse.toolError(error.message))
break
}
// Validate tool use before execution
const { mode, customModes } = (await this.providerRef.deref()?.getState()) ?? {}
try {
validateToolUse(
block.name as ToolName,
mode ?? defaultModeSlug,
customModes ?? [],
{
apply_diff: this.diffEnabled,
},
block.params,
)
} catch (error) {
this.consecutiveMistakeCount++
pushToolResult(formatResponse.toolError(error.message))
break
}
switch (block.name) {