test(events): prefer runtime hook observation

Use RuntimeEventObserver for the normal in-process hook observer path and make the process-hook helper assert hook.runtime_event notifications.

Validation: go test ./pkg/agent; make lint
This commit is contained in:
Hoshina
2026-04-26 16:28:41 +08:00
parent dc80e8f5f2
commit 6e8a81bfbf
3 changed files with 14 additions and 19 deletions
+1 -4
View File
@@ -356,14 +356,11 @@ func runProcessHookHelper() error {
}
if msg.ID == 0 {
if (msg.Method == "hook.event" || msg.Method == "hook.runtime_event") && eventLog != "" {
if msg.Method == "hook.runtime_event" && eventLog != "" {
var evt map[string]any
if err := json.Unmarshal(msg.Params, &evt); err == nil {
if kind, ok := evt["kind"].(string); ok {
_ = os.WriteFile(eventLog, []byte(kind+"\n"), 0o644)
} else if rawKind, ok := evt["Kind"].(float64); ok {
kind := EventKind(rawKind)
_ = os.WriteFile(eventLog, []byte(kind.String()+"\n"), 0o644)
}
}
}