mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-04 17:04:04 -07:00
Clean up dead code (#17443)
This commit is contained in:
committed by
GitHub
parent
84e882770b
commit
80e1fa198f
@@ -7,12 +7,8 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import type { PolicyEngine } from '../policy/policy-engine.js';
|
||||
import { PolicyDecision, getHookSource } from '../policy/types.js';
|
||||
import {
|
||||
MessageBusType,
|
||||
type Message,
|
||||
type HookPolicyDecision,
|
||||
} from './types.js';
|
||||
import { PolicyDecision } from '../policy/types.js';
|
||||
import { MessageBusType, type Message } from './types.js';
|
||||
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
@@ -89,39 +85,6 @@ export class MessageBus extends EventEmitter {
|
||||
default:
|
||||
throw new Error(`Unknown policy decision: ${decision}`);
|
||||
}
|
||||
} else if (message.type === MessageBusType.HOOK_EXECUTION_REQUEST) {
|
||||
// Handle hook execution requests through policy evaluation
|
||||
const hookRequest = message;
|
||||
const decision = await this.policyEngine.checkHook(hookRequest);
|
||||
|
||||
// Map decision to allow/deny for observability (ASK_USER treated as deny for hooks)
|
||||
const effectiveDecision =
|
||||
decision === PolicyDecision.ALLOW ? 'allow' : 'deny';
|
||||
|
||||
// Emit policy decision for observability
|
||||
this.emitMessage({
|
||||
type: MessageBusType.HOOK_POLICY_DECISION,
|
||||
eventName: hookRequest.eventName,
|
||||
hookSource: getHookSource(hookRequest.input),
|
||||
decision: effectiveDecision,
|
||||
reason:
|
||||
decision !== PolicyDecision.ALLOW
|
||||
? 'Hook execution denied by policy'
|
||||
: undefined,
|
||||
} as HookPolicyDecision);
|
||||
|
||||
// If allowed, emit the request for hook system to handle
|
||||
if (decision === PolicyDecision.ALLOW) {
|
||||
this.emitMessage(message);
|
||||
} else {
|
||||
// If denied or ASK_USER, emit error response (hooks don't support interactive confirmation)
|
||||
this.emitMessage({
|
||||
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
||||
correlationId: hookRequest.correlationId,
|
||||
success: false,
|
||||
error: new Error('Hook execution denied by policy'),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// For all other message types, just emit them
|
||||
this.emitMessage(message);
|
||||
|
||||
Reference in New Issue
Block a user