+
    i                         ^ RI t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^R	IHt R
 R lt]! R.4      ]! ].4      R 4       4       tR# )    N)Path)AnyDict)settingsstatus)api_viewpermission_classes)IsAuthenticated)Response)run_lk_agentc                $    V ^8  d   QhR\         /# )   return)str)formats   "@E:\live-kit-agent\livekit_voicebot\backend\apps\livekit\views.py__annotate__r      s     # ## #    c                  .   \         P                  ! R 4      p V '       d9   \        V 4      P                  4       '       d   \        V 4      P                  4       # \	        \
        RR4      pV'       d&   \        \        V4      P                  R,          4      # R# )LIVEKIT_AGENT_WORKDIRBASE_DIRNagent_runtimezbackend/agent_runtime)osgetenvr   stripgetattrr   r   parent)env_dirbase_dirs     r   _default_workdirr!      sg    ii/0G3w<%%''7|!!##xT2H4>((?:;;"r   POSTc                l   \        V P                  \        4      '       d   V P                  M/ p\        VP	                  R4      ;'       g    R4      P                  4       P                  4       pVR9  d   \        RR/\        P                  R7      # \        VP	                  R4      ;'       g    \        4       4      P                  4       pV'       g   \        RR/\        P                  R7      # \        V4      pVP                  4       '       g!   \        RRV 2/\        P                  R7      # VP	                  R	4      e)   \        VP	                  R	4      4      P                  4       MR
;'       g    R
pVP	                  R4      e)   \        VP	                  R4      4      P                  4       MR
;'       g    R
pVP	                  R4      e)   \        VP	                  R4      4      P                  4       MR
;'       g    R
pVP	                  R4      e)   \        VP	                  R4      4      P                  4       MR
;'       g    R
p\        VP	                  RR4      4      p	VP	                  RR4      p
 \        V
4      p
\        ^
\!        V
R4      4      p
VP	                  R4      pVe4   \        V\        4      '       g   \        RR/\        P                  R7      # \'        VVVVVVVV	V
R7	      pVP	                  R4      fJ   R\        VP	                  RR4      4      P                  4       9   d   \        V\        P(                  R7      # \        YP	                  R4      '       d   \        P*                  R7      # \        P,                  R7      #   \"        \$        3 d    Rp
 ELi ; i)a  
Deploy a LiveKit Cloud agent by shelling out to the LiveKit CLI (`lk`).

This endpoint is optional and will return 501 unless `lk` is installed on the server.

Body:
  - action: "create" | "deploy" (default "deploy")
  - workdir: directory containing agent Dockerfile + livekit.toml (optional)
  - region: optional LiveKit Cloud region
  - config: optional livekit.toml path (default handled by lk)
  - agent_id: optional agent id (for deploy/update)
  - secrets: { KEY: VALUE } optional environment secrets to inject
  - secrets_file: path to secrets file (server-side path) optional
  - timeout_s: int (default 900)
  - silent: bool (default true)
actiondeploymessagez)Invalid action. Use 'create' or 'deploy'.r   workdirzworkdir is required.zworkdir does not exist: regionNconfigagent_idsecrets_filesilentT	timeout_si  i  secretsz,secrets must be an object/dict of KEY: VALUE)r(   r)   r*   r.   r+   r,   r-   	exit_codelk ok)creater%   )
isinstancedatadictr   getr   lowerr   r   HTTP_400_BAD_REQUESTr!   r   existsboolintmaxmin	TypeError
ValueErrorr   HTTP_501_NOT_IMPLEMENTEDHTTP_200_OKHTTP_502_BAD_GATEWAY)requestr5   r$   r'   workdir_pathr(   r)   r*   r+   r,   r-   r.   payloads   &            r   deploy_agentrG      s   & &gllD997<<rD(#//x0668>>@F))CD..
 	

 $((9%;;)9);<BBDG./..
 	

 =L  27)<=..
 	

 26(1C1Oc$((8$%++-UYbb^bF15(1C1Oc$((8$%++-UYbb^bF59XXj5I5UDHHZ()//1[_hhdhH=AXXn=U=aC01779gkttptL$((8T*+Fc*I	N	C	401	 hhy!G:gt#<#<FG..
 	

 +!
G {{;'DCIr8R4S4Y4Y4[,[(G(GHHG++d:K:KF$6$6mmQWQlQlmm1 z" 	s   =!N N32N3)r   pathlibr   typingr   r   django.confr   rest_frameworkr   rest_framework.decoratorsr	   r
   rest_framework.permissionsr   rest_framework.responser   clir   r!   rG    r   r   <module>rQ      sT    	     ! B 6 , # 
6(_%&Hn ' Hnr   