mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 18:14:29 -07:00
fix(hooks): support 'ask' decision for BeforeTool hooks (#21146)
This commit is contained in:
committed by
GitHub
parent
d3766875f8
commit
d1dc4902fd
@@ -125,6 +125,7 @@ export class HookAggregator {
|
||||
const additionalContexts: string[] = [];
|
||||
|
||||
let hasBlockDecision = false;
|
||||
let hasAskDecision = false;
|
||||
let hasContinueFalse = false;
|
||||
|
||||
for (const output of outputs) {
|
||||
@@ -142,6 +143,12 @@ export class HookAggregator {
|
||||
if (tempOutput.isBlockingDecision()) {
|
||||
hasBlockDecision = true;
|
||||
merged.decision = output.decision;
|
||||
} else if (tempOutput.isAskDecision()) {
|
||||
hasAskDecision = true;
|
||||
// Ask decision is only set if no blocking decision was found so far
|
||||
if (!hasBlockDecision) {
|
||||
merged.decision = output.decision;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect messages
|
||||
@@ -180,8 +187,8 @@ export class HookAggregator {
|
||||
this.extractAdditionalContext(output, additionalContexts);
|
||||
}
|
||||
|
||||
// Set final decision if no blocking decision was found
|
||||
if (!hasBlockDecision && !hasContinueFalse) {
|
||||
// Set final decision if no blocking or ask decision was found
|
||||
if (!hasBlockDecision && !hasAskDecision && !hasContinueFalse) {
|
||||
merged.decision = 'allow';
|
||||
}
|
||||
|
||||
|
||||
@@ -197,12 +197,19 @@ export class DefaultHookOutput implements HookOutput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this output represents a blocking decision
|
||||
* Check if this output represents a blocking decision (block or deny)
|
||||
*/
|
||||
isBlockingDecision(): boolean {
|
||||
return this.decision === 'block' || this.decision === 'deny';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this output represents an 'ask' decision
|
||||
*/
|
||||
isAskDecision(): boolean {
|
||||
return this.decision === 'ask';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this output requests to stop execution
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user