mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
implement PreTooUse PostToolUse PostToolUseFailure and test
This commit is contained in:
parent
f0cc28f80f
commit
a5212123dc
12 changed files with 1539 additions and 79 deletions
|
|
@ -757,6 +757,43 @@ export class Config {
|
|||
(input['last_assistant_message'] as string) || '',
|
||||
);
|
||||
break;
|
||||
case 'PreToolUse': {
|
||||
const { PermissionMode: PM } = await import(
|
||||
'../hooks/types.js'
|
||||
);
|
||||
result = await hookSystem.firePreToolUseEvent(
|
||||
(input['tool_name'] as string) || '',
|
||||
(input['tool_input'] as Record<string, unknown>) || {},
|
||||
(input['tool_use_id'] as string) || '',
|
||||
(input['permission_mode'] as
|
||||
| import('../hooks/types.js').PermissionMode
|
||||
| undefined) ?? PM.Default,
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'PostToolUse':
|
||||
result = await hookSystem.firePostToolUseEvent(
|
||||
(input['tool_name'] as string) || '',
|
||||
(input['tool_input'] as Record<string, unknown>) || {},
|
||||
(input['tool_response'] as Record<string, unknown>) || {},
|
||||
(input['tool_use_id'] as string) || '',
|
||||
(input[
|
||||
'permission_mode'
|
||||
] as import('../hooks/types.js').PermissionMode) || 'default',
|
||||
);
|
||||
break;
|
||||
case 'PostToolUseFailure':
|
||||
result = await hookSystem.firePostToolUseFailureEvent(
|
||||
(input['tool_use_id'] as string) || '',
|
||||
(input['tool_name'] as string) || '',
|
||||
(input['tool_input'] as Record<string, unknown>) || {},
|
||||
(input['error'] as string) || '',
|
||||
input['is_interrupt'] as boolean | undefined,
|
||||
(input[
|
||||
'permission_mode'
|
||||
] as import('../hooks/types.js').PermissionMode) || 'default',
|
||||
);
|
||||
break;
|
||||
default:
|
||||
this.debugLogger.warn(
|
||||
`Unknown hook event: ${request.eventName}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue