feat: add human detection scoring and webhook notifications

Implement phase 2.1 (human detection) and 2.2 (notifications):

- Detection scorer computes 0.0-1.0 human likelihood from keystroke
  timing variance, special key usage, typing speed, command diversity,
  and session duration
- Webhook notifier sends JSON POST to configured endpoints with
  deduplication, custom headers, and event filtering
- RecordingChannel gains an event callback for feeding keystrokes
  to the scorer without coupling shell and detection packages
- Server wires scorer into session lifecycle with periodic updates
  and threshold-based notification triggers
- Web UI shows human score in session tables with highlighting
- New config sections: [detection] and [[notify.webhooks]]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 21:28:11 +01:00
parent 96c8476f77
commit 0ad6f4cb6a
13 changed files with 1060 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ package web
import (
"embed"
"fmt"
"html/template"
"time"
)
@@ -26,6 +27,18 @@ func loadTemplates() (*template.Template, error) {
}
return *t
},
"derefFloat": func(f *float64) float64 {
if f == nil {
return 0
}
return *f
},
"formatScore": func(f *float64) string {
if f == nil {
return "-"
}
return fmt.Sprintf("%.0f%%", *f*100)
},
}
return template.New("").Funcs(funcMap).ParseFS(templateFS,