mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-28 15:01:14 -07:00
feat(core): Fully migrate packages/core to AgentLoopContext. (#22115)
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type { Config } from '../config/config.js';
|
||||
import type { HookPlanner, HookEventContext } from './hookPlanner.js';
|
||||
import type { HookRunner } from './hookRunner.js';
|
||||
import type { HookAggregator, AggregatedHookResult } from './hookAggregator.js';
|
||||
@@ -40,12 +39,13 @@ import { logHookCall } from '../telemetry/loggers.js';
|
||||
import { HookCallEvent } from '../telemetry/types.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import { coreEvents } from '../utils/events.js';
|
||||
import type { AgentLoopContext } from '../config/agent-loop-context.js';
|
||||
|
||||
/**
|
||||
* Hook event bus that coordinates hook execution across the system
|
||||
*/
|
||||
export class HookEventHandler {
|
||||
private readonly config: Config;
|
||||
private readonly context: AgentLoopContext;
|
||||
private readonly hookPlanner: HookPlanner;
|
||||
private readonly hookRunner: HookRunner;
|
||||
private readonly hookAggregator: HookAggregator;
|
||||
@@ -58,12 +58,12 @@ export class HookEventHandler {
|
||||
private readonly reportedFailures = new WeakMap<object, Set<string>>();
|
||||
|
||||
constructor(
|
||||
config: Config,
|
||||
context: AgentLoopContext,
|
||||
hookPlanner: HookPlanner,
|
||||
hookRunner: HookRunner,
|
||||
hookAggregator: HookAggregator,
|
||||
) {
|
||||
this.config = config;
|
||||
this.context = context;
|
||||
this.hookPlanner = hookPlanner;
|
||||
this.hookRunner = hookRunner;
|
||||
this.hookAggregator = hookAggregator;
|
||||
@@ -370,15 +370,14 @@ export class HookEventHandler {
|
||||
private createBaseInput(eventName: HookEventName): HookInput {
|
||||
// Get the transcript path from the ChatRecordingService if available
|
||||
const transcriptPath =
|
||||
this.config
|
||||
.getGeminiClient()
|
||||
this.context.geminiClient
|
||||
?.getChatRecordingService()
|
||||
?.getConversationFilePath() ?? '';
|
||||
|
||||
return {
|
||||
session_id: this.config.getSessionId(),
|
||||
session_id: this.context.config.getSessionId(),
|
||||
transcript_path: transcriptPath,
|
||||
cwd: this.config.getWorkingDir(),
|
||||
cwd: this.context.config.getWorkingDir(),
|
||||
hook_event_name: eventName,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
@@ -457,7 +456,7 @@ export class HookEventHandler {
|
||||
result.error?.message,
|
||||
);
|
||||
|
||||
logHookCall(this.config, hookCallEvent);
|
||||
logHookCall(this.context.config, hookCallEvent);
|
||||
}
|
||||
|
||||
// Log individual errors
|
||||
|
||||
Reference in New Issue
Block a user