
    !\i_                         d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ  e       Z G d	 d
e      Zej%                  d       edd       eddd       ee
      fdee   dedefd       Zy)zAgent run API endpoints    )	APIRouterDependsQuery)Session)Optional)get_db)AgentRunRepository)	BaseModel)datetimec                       e Zd ZU eed<   eed<   eed<   eed<   ee   ed<   ee   ed<   eed<   eed<   eed	<    G d
 d      Zy)RunResponseid
agent_namestatus
started_atfinished_aterrormatches_processedrecords_createdrecords_updatedc                       e Zd ZdZy)RunResponse.ConfigTN)__name__
__module____qualname__from_attributes     /app/app/api/runs.pyConfigr      s    r   r    N)	r   r   r   int__annotations__strr   r   r    r   r   r   r   r      sH    GOK(##C= r   r   z/runsNzFilter by agent name)description2      i  )geler   limitdbc                 H  K   t        |      }|j                  | |      }|D cg c]p  }t        |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  	      r c}S c c}w w)zGet agent run history)r   r)   )	r   r   r   r   r   r   r   r   r   )r	   
get_recentr   r   r   r   r   r   r   r   r   r   )r   r)   r*   run_reporunsrs         r   get_runsr0      s      ""%H*EBD 
 ! 44<<xx<<MMgg--))))
 
 
 
s   #B"A5BB")__doc__fastapir   r   r   sqlalchemy.ormr   typingr   app.core.db.databaser   -app.core.db.repositories.agent_run_repositoryr	   pydanticr
   r   routerr   getr#   r!   r0   r   r   r   <module>r:      s     - - "  ' L  	)  G %d8N OraC(&/ 	 r   