This commit is contained in:
Ian Gulliver
2026-10-16 09:51:32 -07:00
parent 59c2b2cb9c
commit 48ef2d6bb5
12 changed files with 343 additions and 192 deletions
+23
View File
@@ -1223,6 +1223,29 @@ func (s *Store) SessionStarted(ctx context.Context, sessionID string) (bool, err
return started, err
}
type Turn struct {
Actor string
At time.Time
}
func (s *Store) RunningTurn(ctx context.Context, taskID string) (Turn, bool, error) {
t := Turn{}
at := ""
err := s.db.QueryRowContext(ctx, `
SELECT e.actor, e.created_at FROM events e JOIN agent_sessions s ON s.id = e.agent_session_id
WHERE e.task_id = ? AND e.kind = 'user.message' AND s.role = ? AND s.state = ?
ORDER BY e.seq DESC LIMIT 1
`, taskID, string(api.Implementer), string(api.AgentSessionStateRunning)).Scan(&t.Actor, &at)
if errors.Is(err, sql.ErrNoRows) {
return t, false, nil
}
if err != nil {
return t, false, err
}
t.At, err = parseTime(at)
return t, err == nil, err
}
func (s *Store) SetVendorSessionID(ctx context.Context, id, vendorSessionID string) error {
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
res, err := tx.ExecContext(ctx, `UPDATE agent_sessions SET vendor_session_id = ? WHERE id = ?`, vendorSessionID, id)