fireHook dispatches a hook event and returns the result.
(ctx context.Context, agentName string, event hooks.EventType, input *hooks.Input)
| 750 | |
| 751 | // fireHook dispatches a hook event and returns the result. |
| 752 | func (rt *wasmRuntime) fireHook(ctx context.Context, agentName string, event hooks.EventType, input *hooks.Input) *hooks.Result { |
| 753 | exec, ok := rt.hookExec[agentName] |
| 754 | if !ok || exec == nil { |
| 755 | return nil |
| 756 | } |
| 757 | if !exec.Has(event) { |
| 758 | return nil |
| 759 | } |
| 760 | |
| 761 | result, err := exec.Dispatch(ctx, event, input) |
| 762 | if err != nil { |
| 763 | slog.WarnContext(ctx, "Hook dispatch failed", "event", event, "agent", agentName, "error", err) |
| 764 | return nil |
| 765 | } |
| 766 | return result |
| 767 | } |
| 768 | |
| 769 | // emitEvent sends a typed event to the JS onEvent callback. |
| 770 | func (rt *wasmRuntime) emitEvent(event map[string]any) { |
no test coverage detected