focus
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user