mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 04:00:36 +00:00
implementation SessionStart and SessionEnd hook
This commit is contained in:
parent
7cde98e238
commit
f0cc28f80f
11 changed files with 2099 additions and 7 deletions
|
|
@ -14,6 +14,12 @@ import type { HookRegistryEntry } from './hookRegistry.js';
|
|||
import { createDebugLogger } from '../utils/debugLogger.js';
|
||||
import type { DefaultHookOutput } from './types.js';
|
||||
import { createHookOutput } from './types.js';
|
||||
import type {
|
||||
SessionStartSource,
|
||||
SessionEndReason,
|
||||
PermissionMode,
|
||||
AgentType,
|
||||
} from './types.js';
|
||||
|
||||
const debugLogger = createDebugLogger('TRUSTED_HOOKS');
|
||||
|
||||
|
|
@ -100,4 +106,30 @@ export class HookSystem {
|
|||
? createHookOutput('Stop', result.finalOutput)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
async fireSessionStartEvent(
|
||||
source: SessionStartSource,
|
||||
model: string,
|
||||
permissionMode?: PermissionMode,
|
||||
agentType?: AgentType,
|
||||
): Promise<DefaultHookOutput | undefined> {
|
||||
const result = await this.hookEventHandler.fireSessionStartEvent(
|
||||
source,
|
||||
model,
|
||||
permissionMode,
|
||||
agentType,
|
||||
);
|
||||
return result.finalOutput
|
||||
? createHookOutput('SessionStart', result.finalOutput)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
async fireSessionEndEvent(
|
||||
reason: SessionEndReason,
|
||||
): Promise<DefaultHookOutput | undefined> {
|
||||
const result = await this.hookEventHandler.fireSessionEndEvent(reason);
|
||||
return result.finalOutput
|
||||
? createHookOutput('SessionEnd', result.finalOutput)
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue