piper: pipe cleanup on early return, write error; misc error hygiene
piper_handler: close stdin/stdout pipes on Start() failure and on WriteString error instead of leaking fds. Propagate WriteString error. worker/client: log SetDeadline errors instead of discarding them. voice/session: pushAudio marshals params inline and returns the marshal error instead of swallowing it via mustParams (removed). tool/matcher: log ListTools errors instead of silently returning an empty allowlist that refuses every act. config: applyDefaults now sets RouterThreshold and ToolTimeout defaults so consumers self-contained defaults are belt-and-suspenders.
This commit is contained in:
@@ -69,7 +69,11 @@ func (s *Session) pushAudio(p AudioNudgePush) error {
|
||||
if s.closed || s.conn == nil {
|
||||
return fmt.Errorf("voice: session %d closed: %w", s.ID, ErrNoSession)
|
||||
}
|
||||
return writeFrame(s.conn, Push{Kind: PushKindAudioNudge, Params: mustParams(p)})
|
||||
params, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("voice: marshal push params: %w", err)
|
||||
}
|
||||
return writeFrame(s.conn, Push{Kind: PushKindAudioNudge, Params: params})
|
||||
}
|
||||
|
||||
func (s *Session) shutdown() {
|
||||
@@ -167,11 +171,3 @@ func (r *Sessions) PushToMostRecent(ctx context.Context, p AudioNudgePush) error
|
||||
return best.pushAudio(p)
|
||||
}
|
||||
|
||||
// helper that returns a fixed nil-error marshal so the push call site is short.
|
||||
func mustParams(v any) json.RawMessage {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
b, _ := jsonMarshal(v)
|
||||
return b
|
||||
}
|
||||
Reference in New Issue
Block a user