- Jev (TypeSafe, direct) triages mode and task type with confidence - Its call stands at >= 70% on both and no split; otherwise the LLM Sentry decides (unsure, split needs subtasks, or Jev down) - Jev flights obey the same budget, flock cap, timeout and log - Tests for every path; flight log is nil-safe - start.command reads TYPESAFE_API_KEY and threshold from .env Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UQnSw4RRWp8uqpj3nsnnXF
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// Event is one line in the flight log: every triage, flight and verdict.
|
|
type Event struct {
|
|
Time time.Time `json:"ts"`
|
|
Kind string `json:"kind"`
|
|
Requester string `json:"requester,omitempty"`
|
|
Item string `json:"item,omitempty"`
|
|
Crow string `json:"crow,omitempty"`
|
|
Mode string `json:"mode,omitempty"`
|
|
TaskType string `json:"task_type,omitempty"`
|
|
Model string `json:"model,omitempty"` // which model actually answered (routers vary)
|
|
Tokens int `json:"tokens,omitempty"`
|
|
Ms int64 `json:"ms,omitempty"`
|
|
Verdict string `json:"verdict,omitempty"`
|
|
Output string `json:"output,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
Note string `json:"note,omitempty"`
|
|
}
|
|
|
|
type FlightLog struct {
|
|
mu sync.Mutex
|
|
f *os.File
|
|
}
|
|
|
|
func OpenFlightLog(path string) (*FlightLog, error) {
|
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
return nil, err
|
|
}
|
|
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &FlightLog{f: f}, nil
|
|
}
|
|
|
|
func (l *FlightLog) Write(e Event) {
|
|
if l == nil {
|
|
return // no log configured (tests, embedded use)
|
|
}
|
|
l.mu.Lock()
|
|
defer l.mu.Unlock()
|
|
e.Time = time.Now()
|
|
b, _ := json.Marshal(e)
|
|
l.f.Write(append(b, '\n'))
|
|
}
|
|
|
|
func (l *FlightLog) Close() error { return l.f.Close() }
|