MCPcopy Create free account
hub / github.com/diillson/chatcli / executeHook

Method executeHook

cli/hooks/manager.go:165–177  ·  view source on GitHub ↗

executeHook runs a single hook and returns the result.

(ctx context.Context, hook HookConfig, event HookEvent)

Source from the content-addressed store, hash-verified

163
164// executeHook runs a single hook and returns the result.
165func (m *Manager) executeHook(ctx context.Context, hook HookConfig, event HookEvent) *HookResult {
166 timeout := time.Duration(hook.GetTimeout()) * time.Millisecond
167
168 switch hook.Type {
169 case HookTypeCommand:
170 return m.executeCommandHook(ctx, hook, event, timeout)
171 case HookTypeHTTP:
172 return m.executeHTTPHook(ctx, hook, event, timeout)
173 default:
174 m.logger.Warn("Unknown hook type", zap.String("type", string(hook.Type)), zap.String("name", hook.Name))
175 return &HookResult{ExitCode: -1, Error: "unknown hook type"}
176 }
177}
178
179// executeCommandHook runs a shell command hook.
180// The event JSON is passed via stdin. Exit code 0 = allow, 2 = block.

Callers 1

FireMethod · 0.95

Implementers 2

MockTokenManagerllm/token/mock_token_manager.go
TokenManagerllm/token/token_manager.go

Calls 5

executeCommandHookMethod · 0.95
executeHTTPHookMethod · 0.95
GetTimeoutMethod · 0.80
WarnMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected