+
    „°ñj×V  ã                   ól  € R t ^ RIt^ RIHtHt ^ RIHt RtRtRt	Rt
 ! R R	4      tR
 R lt]! 0 R.m4      t]! 0 R/m4      t]! 0 R0m4      tR R ltR tR R ltRtR R ltR R ltR R ltR R ltR R ltR1R R lltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR2R( R) llt R* R+ lt!R, R- lt"R# )3zp
Job utilities for the /api/jobs endpoint.
Provides normalization and helper functions for job status tracking.
N)ÚCallableÚOptional)Ú
prune_dictÚrunningÚpendingÚterminalÚunknownc                   ó<   € ] tR t^tRtRtRtRtRtRt	]]]]]	.t
RtR# )	Ú	JobStatuszJob status constants.r   Úin_progressÚ	completedÚfailedÚ	cancelled© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚPENDINGÚIN_PROGRESSÚ	COMPLETEDÚFAILEDÚ	CANCELLEDÚALLÚ__static_attributes__r   ó    Ú8C:\Ai_Coding\apps\studio\ComfyUI\comfy_execution\jobs.pyr
   r
      s.   † ÙØ€GØ€KØ€IØ€FØ€Ià�K ¨F°IÐ
>„Cr   r
   c                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)Ústr)Úformats   "r   Ú__annotate__r#   "   s   € ÷ ñ œcñ r   c                óÒ   € \        V \        4      '       g"   \        R\        V 4      P                   24      h\        \
        P                  ! V 4      4      V 8w  d   \        R4      hV # )uÚ  Validate a client-supplied job (prompt) id.

Job ids must be UUIDs in the canonical lowercase hyphenated form. The id
is stored and compared verbatim everywhere downstream â€” history keys,
websocket events, and /interrupt matching â€” so accepting another spelling
would silently rewrite the client's id and then miss every exact-match
lookup. Rejecting loudly beats that.

Returns the id unchanged. Raises ValueError when the value is not a
string in canonical UUID form.
zjob id must be a string, got z<job id must be a UUID in canonical lowercase hyphenated form)Ú
isinstancer!   Ú
ValueErrorÚtyper   ÚuuidÚUUID©Úvalues   &r   Úvalidate_job_idr,   "   sV   € ô �eœS×!Ò!ÜÐ8¼¸e»×9MÑ9MÐ8NÐOÓPÐPÜ
Œ4�9Š9�UÓÓ Ô%ÜÐWÓXÐXØ€Lr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úfilenamer    )r!   Úbool)r"   s   "r   r#   r#   ?   s   € ÷ Bñ Bœsð B¤tñ Br   c                 ó¨   a€ V P                  4       o\        ;QJ d#    V3R  l\         4       F  '       g   K   R# 	  R# ! V3R  l\         4       4      # )c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5i©N©Úendswith)Ú.0ÚextÚlowers   & €r   Ú	<genexpr>Ú#has_3d_extension.<locals>.<genexpr>A   s   øé € ÐAÑ.@ sˆu�~‰~˜c×"Ð"Ó.@ùó   ƒ!TF)r7   ÚanyÚTHREE_D_EXTENSIONS)r.   r7   s   &@r   Úhas_3d_extensionr=   ?   s:   ø€ Ø�N‰NÓ€Eß‹3ÔAÕ.@ÓA�3Œ3ÐAŠ3ÐAˆ3ÔAÕ.@ÓAÓAÐAr   c                ó¨   € V f   R# \        V \        4      '       d   \        V 4      '       d   RV RRRRRR/# R# \        V \        4      '       d   V # R# )	zµNormalize a single output list item for the jobs API.

Returns the normalized item, or None to exclude it.
String items with 3D extensions become {filename, type, subfolder} dicts.
Nr.   r'   ÚoutputÚ	subfolderÚ Ú	mediaTypeÚ3d)r%   r!   r=   Údict)Úitems   &r   Únormalize_output_itemrF   D   sT   € ð ‚|ÙÜ�$œ×ÒÜ˜D×!Ò!Ø  f¨h¸ÀRÈÐVZÐ[Ð[ÙÜ�$œ×ÒØˆÙr   c                ó0   € V ^8„  d   QhR\         R\         /# ©r   Úoutputsr    )rD   )r"   s   "r   r#   r#   U   s   € ÷ ñ œtð ¬ñ r   c                óf  € / pV P                  4        Fš  w  r#\        V\        4      '       g   W1V&   K!  / pVP                  4        F_  w  rVVR8X  g   \        V\        4      '       g   WdV&   K(  . pV F+  pVf   K	  \	        V4      p	TP                  V	e   T	MT4       K-  	  WtV&   Ka  	  WAV&   Kœ  	  V# )z¿Normalize raw node outputs for the jobs API.

Transforms string 3D filenames into file output dicts and removes
None items. All other items (non-3D strings, dicts, etc.) are
preserved as-is.
Úanimated)Úitemsr%   rD   ÚlistrF   Úappend)
rI   Ú
normalizedÚnode_idÚnode_outputsÚnormalized_nodeÚ
media_typerL   Únormalized_itemsrE   Únorms
   &         r   Únormalize_outputsrV   U   sÁ   € ð €JØ!(§¡¦ÑˆÜ˜,¬×-Ò-Ø".�wÑÙØˆØ!-×!3Ñ!3Ö!5ÑˆJØ˜ZÔ'¬z¸%Ä×/FÒ/FØ.3 
Ñ+ÙØ!ÐÛ�Ø’<ÙÜ,¨TÓ2�Ø ×'Ñ'°Ò0@©ÀdÖKñ	 ð
 +;˜JÓ'ñ "6ð .�7Óñ! "1ð" Ðr   i   c                ó0   € V ^8„  d   QhR\         R\        /# )r   r+   r    )r!   rD   )r"   s   "r   r#   r#   t   s   € ÷ ñ ¤ð ¬ñ r   c                óL   € \        V 4      \        8:  d   RV /# RV R\         RR/# )zwCreate a text preview dict with optional truncation.

Returns:
    dict with 'content' and optionally 'truncated' flag
ÚcontentNÚ	truncatedT)ÚlenÚTEXT_PREVIEW_MAX_LENGTHr*   s   &r   Ú_create_text_previewr]   t   s9   € ô ˆ5ƒzÔ,Ô,Ø˜5Ð!Ð!à�5Ð1Ô1Ð2Ø�Tðð r   c                ó~   € V ^8„  d   QhR\         R\        \        \        ,          \        \        ,          3,          /# )r   Ú
extra_datar    )rD   Útupler   Úintr!   )r"   s   "r   r#   r#   ‚   s,   € ÷ 	$ñ 	$¤dð 	$¬u´X¼cµ]ÄHÌSÅMÐ5QÕ/Rñ 	$r   c                ó�   € V P                  R4      pV P                  R/ 4      pVP                  R/ 4      P                  R4      pW3# )zeExtract create_time and workflow_id from extra_data.

Returns:
    tuple: (create_time, workflow_id)
Úcreate_timeÚextra_pnginfoÚworkflowÚid©Úget)r_   rc   rd   Úworkflow_ids   &   r   Ú_extract_job_metadatarj   ‚   sH   € ð —.‘. Ó/€KØ—N‘N ?°BÓ7€MØ×#Ñ# J°Ó3×7Ñ7¸Ó=€KØÐ#Ð#r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# ©r   rS   rE   r    ©r!   rD   r/   )r"   s   "r   r#   r#   Ž   s!   € ÷ ñ œsð ¬$ð ´4ñ r   c                ó  a€ V \         9   d   R# VP                  RR4      pV'       d1   VP                  R4      '       g   VP                  R4      '       d   R# VP                  RR4      P                  4       o\        ;QJ d#    V3R l\
         4       F  '       g   K   RM	  RM! V3R l\
         4       4      '       d   R# \        ;QJ d#    V3R	 l\         4       F  '       g   K   RM	  RM! V3R	 l\         4       4      '       d   R# R# )
a–  
Check if an output item is previewable.
Matches frontend logic in ComfyUI_frontend/src/stores/queueStore.ts
Maintains backwards compatibility with existing logic.

Priority:
1. media_type is 'images', 'video', 'audio', '3d', or 'text'
2. format field starts with 'video/' or 'audio/'
3. filename has a 3D extension (.obj, .fbx, .gltf, .glb, .usdz)
4. filename has a text extension (.txt, .md, .json, ...)
Tr"   rA   zvideo/zaudio/r.   c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir2   r3   ©r5   r6   r.   s   & €r   r8   Ú!is_previewable.<locals>.<genexpr>¥   s!   øé € Ð
@Ñ-? cˆ8×Ñ˜S×!Ð!Ó-?ùr:   Fc              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir2   r3   rp   s   & €r   r8   rq   §   s   øé € Ð
=©_ cˆ8×Ñ˜S×!Ð!«_ùr:   )ÚPREVIEWABLE_MEDIA_TYPESrh   Ú
startswithr7   r;   r<   ÚTEXT_EXTENSIONS)rS   rE   Úfmtr.   s   && @r   Úis_previewablerw   Ž   s­   ø€ ð Ô,Ô,Ùð �(‰(�8˜RÓ
 €Cß
�—‘˜x×(Ò(¨C¯N©N¸8×,DÒ,DÙð �x‰x˜
 BÓ'×-Ñ-Ó/€Hß
ƒsÔ
@Õ-?Ó
@‡s‡s‚sÔ
@Õ-?Ó
@×@Ò@Ùß
ƒsÔ
=­_Ó
=‡s‡s‚sÔ
=­_Ó
=×=Ò=Ùár   c                ó<   € V ^8„  d   QhR\         R\        R\        /# rl   rm   )r"   s   "r   r#   r#   ­   s&   € ÷ 
Bñ 
B¤ð 
B¬4ð 
B´Dñ 
Br   c                óÚ   a€ V R8X  d   R# VP                  RR4      P                  4       o\        ;QJ d#    V3R l\         4       F  '       g   K   R# 	  R# ! V3R l\         4       4      # )zÈ
Check if a previewable output item is textual rather than visual media.

Saved text files (SaveText's .txt/.md/.json) are real outputs but must not
outrank visual media when picking the job preview.
ÚtextTr.   rA   c              3   óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir2   r3   rp   s   & €r   r8   Ú"is_text_preview.<locals>.<genexpr>·   s   øé € ÐA±¨#ˆx× Ñ  ×%Ð%³ùr:   F)rh   r7   r;   ru   )rS   rE   r.   s   &&@r   Úis_text_previewr}   ­   sR   ø€ ð �VÔÙØ�x‰x˜
 BÓ'×-Ñ-Ó/€Hß‹3ÔAµÓA�3Œ3ÐAŠ3ÐAˆ3ÔAµÓAÓAÐAr   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   rE   Ústatusr    )r`   r!   rD   )r"   s   "r   r#   r#   º   s!   € ÷ ñ œuð ¬cð ´dñ r   c                óZ   € V w  r#rEp\        V4      w  rg\        RVRVRVRVR^ R^ RV/4      # )znConvert queue item tuple to unified job dict.

Expects item with sensitive data already removed (5 elements).
rf   r   Úpriorityrc   Úoutputs_countÚpreviewable_outputs_countri   )rj   r   )rE   r   r�   Ú	prompt_idÚ_r_   rc   ri   s   &&      r   Únormalize_queue_itemr†   º   sR   € ð
 -1Ñ)€H˜¨Ü4°ZÓ@Ñ€KäØˆiØ�&Ø�HØ�{Ø˜Ø# QØ�{ðó ð r   c                óH   € V ^8„  d   QhR\         R\        R\        R\        /# )r   r„   Úhistory_itemÚinclude_outputsr    rm   )r"   s   "r   r#   r#   Í   s0   € ÷ Añ A¤cð A¼ð AÔPTð AÔaeñ Ar   c                óî  € VR,          pVw  rErgp\        V4      w  r‰VP                  R/ 4      p
V
'       d   V
P                  R4      MRpVP                  R/ 4      p\        V4      w  rÞ\        V4      pRpRpRpRpV
'       dÀ   V
P                  R. 4      pV F§  p\	        V\
        \        34      '       g   K!  \        V4      ^8¼  g   K3  V^ ,          V^,          pp\	        V\        4      '       g   K]  VR8X  d   VP                  R	4      pKw  VR9   g   K€  VP                  R	4      pVR
8X  d   TpKœ  VR8X  g   K¥  RpK©  	  VR8X  d   \        P                  pM@VR8X  d*   V'       d   \        P                  M\        P                  pM\        P                  p\        RV RVRVRVRVRVR
VRVRVRVRV	/4      pV'       d2   \        V4      VR&   V
VR&   VP                  R/ 4      VR&   RVRV/VR&   V# )z�Convert history item dict to unified job dict.

History items have sensitive data already removed (prompt tuple has 5 elements).
Úpromptr   Ú
status_strNrI   FÚmessagesÚexecution_startÚ	timestampÚexecution_errorÚexecution_interruptedTÚsuccessÚerrorrf   r�   rc   Úexecution_start_timeÚexecution_end_timer‚   rƒ   Úpreview_outputri   Úexecution_statusÚmetaÚexecution_metar_   re   )Úexecution_successr�   r‘   )rj   rh   Úget_outputs_summaryÚcount_previewable_outputsr%   rM   r`   r[   rD   r
   r   r   r   r   rV   )r„   rˆ   r‰   Úprompt_tupler�   r…   r‹   r_   rc   ri   Ústatus_inforŒ   rI   r‚   r–   rƒ   r�   r”   r•   Úwas_interruptedr�   ÚentryÚ
event_nameÚ
event_datar   Újobs   &&&                       r   Únormalize_history_itemr¤   Í   s  € ð
   Õ)€LØ)5Ñ&€H� QÜ4°ZÓ@Ñ€Kà×"Ñ" 8¨RÓ0€Kß2=�—‘ Ô.À4€Jà×Ñ˜y¨"Ó-€GÜ$7¸Ó$@Ñ!€MÜ 9¸'Ó BÐà€OØÐØÐØ€OßØ—?‘? :¨rÓ2ˆÛˆEÜ˜%¤$¬ ×/Ô/´C¸³JÀ!¶OØ).¨q­°5¸µ8˜J�
Ü˜j¬$×/Ô/Ø!Ð%6Ô6Ø/9¯~©~¸kÓ/JÒ,Ø#Ð'hÖhØ-7¯^©^¸KÓ-HÐ*Ø%Ð):Ô:Ø.8šOØ'Ð+BÖBØ.2šOñ ð �YÔÜ×$Ñ$‰Ø	�wÔ	ß(7”×$Ò$¼Y×=MÑ=M‰ä×$Ñ$ˆä
ØˆiØ�&Ø�HØ�{ØÐ 4ØÐ0Ø˜?Ø˜Ø#Ð%>Ø˜.Ø�{ðó €C÷ Ü*¨7Ó3ˆˆI‰Ø"-ˆÐÑØ ,× 0Ñ 0°¸Ó <ˆÐÑà�fØ˜*ð
ˆˆJ‰ð
 €Jr   c                óh   € V ^8„  d   QhR\         R\        \        \        \         ,          3,          /# rH   )rD   r`   ra   r   )r"   s   "r   r#   r#     s0   € ÷ L\ñ L\¤ð L\¬%´´X¼dµ^Ð0CÕ*Dñ L\r   c                ó0  € ^ pRpRpRpRpV P                  4        EFW  w  rg\        V\        4      '       g   K  VP                  4        EF$  w  r‰VR8X  g   \        V	\        4      '       g   K%  V	 Fù  p
\        V
\        4      '       go   \	        V
4      pVf^   VR8X  dU   VfQ   \        V
\
        4      '       d   V
'       d
   V
^ ,          MRpM\        V
4      p\        V4      p/ VCRVRV/CpVf   TpK…  Tp
V^,          pVe   K–  \        WŠ4      '       g   K©  / V
CRV/CpRV
9  d   WŽR&   \        WŠ4      '       d   Vf   TpKÕ  K×  V
P                  R4      R8X  d   TpKñ  Ve   K÷  TpKû  	  EK'  	  EKZ  	  Y;'       g    T;'       g    T;'       g    T3# )	aº  
Count outputs and find preview in a single pass.
Returns (outputs_count, preview_output).

Preview priority (matching frontend):
1. type="output" visual media (saved images/video/audio/3d)
2. any other previewable visual media (e.g. temp/preview images)
3. saved text file (e.g. SaveText's .txt/.md/.json)
4. raw text (only when the job produced nothing else previewable)

Text is kept in its own slots so node/execution order can't let a text
output mask a visual one (e.g. a text node that runs before an image).

Text content entries (strings under 'text') are preview-only metadata,
matching the frontend's METADATA_KEYS: they can serve as the fallback
preview but are not counted as outputs.
NrK   rz   rA   ÚnodeIdrB   r'   r?   )rL   r%   rD   rM   rF   r`   r!   r]   rw   r}   rh   )rI   Úcountr–   Úfallback_previewÚtext_file_fallbackÚtext_fallbackrP   rQ   rS   rL   rE   rO   Ú
text_valueÚtext_previewÚenricheds   &              r   r›   r›     s±  € ð$ €EØ€NØÐØÐØ€Mà!(§¡§ÑˆÜ˜,¬×-Ò-ÙØ!-×!3Ñ!3×!5ÑˆJà˜ZÔ'¬z¸%Ä×/FÒ/FÙã�Ü! $¬×-Ò-ä!6°tÓ!<�JØ!Ò)à%¨Ô/Ø-Ò5Ü#-¨d´E×#:Ò#:ß<@°°a¶Àb¡Jä14°T³ JÜ/CÀJÓ/O ð,"Ø&2ð,"à$,¨gØ$/°ñ," ð
 $1Ò#8Ø4< MÙ à%�Dà˜•
�à!Ò-Ùä! *×3Ô3ð Øð à  'ñ �Hð #¨$Ô.Ø0: Ñ-Ü& z×8Ò8Ø-Ò5Ø19Ò.ñ 6àŸ™ &Ó)¨XÔ5Ø)1šØ)Ô1Ø+3Ò(ôU ô "6ñ "1ðh ×[Ð[Ð$4×[Ð[Ð8J×[Ð[ÈmÐ[Ð[r   c                ó0   € V ^8„  d   QhR\         R\        /# rH   )rD   ra   )r"   s   "r   r#   r#   `  s   € ÷ ñ ¤tð ´ñ r   c                óp  € ^ pV P                  4        FŸ  p\        V\        4      '       g   K  VP                  4        Fp  w  r4VR8X  g   \        V\        4      '       g   K$  V FF  p\        V\        4      '       g   \        V4      pVf   K*  \        W54      '       g   K=  V^,          pKH  	  Kr  	  K¡  	  V# )aÉ  
Count only outputs that would actually render in the expanded asset view,
i.e. items is_previewable() accepts (image/video/audio/3D/text). Kept
separate from get_outputs_summary()'s outputs_count, which counts every
output item regardless of media type, so a job with a non-previewable
saved file alongside real media (e.g. SaveLatent's .latent output next to
a SaveImage output) doesn't inflate the Media Assets badge beyond what
the expanded view shows.
rK   )Úvaluesr%   rD   rL   rM   rF   rw   )rI   r¨   rQ   rS   rL   rE   s   &     r   rœ   rœ   `  s›   € ð €EØŸ™Ö(ˆÜ˜,¬×-Ò-ÙØ!-×!3Ñ!3Ö!5ÑˆJØ˜ZÔ'¬z¸%Ä×/FÒ/FÙÛ�Ü! $¬×-Ò-Ü0°Ó6�DØ’|Ù Ü! *×3Ô3Ø˜Q•J’Eó ó "6ñ )ð €Lr   c          	      ót   € V ^8„  d   QhR\         \        ,          R\        R\        R\         \        ,          /# )r   ÚjobsÚsort_byÚ
sort_orderr    )rM   rD   r!   )r"   s   "r   r#   r#   {  s0   € ÷ ;ñ ;œœT�
ð ;¬Sð ;¼cð ;ÄdÌ4Åjñ ;r   c                óB   € VR8H  pVR8X  d   R pMR p\        WVR7      # )z,Sort jobs list by specified field and order.ÚdescÚexecution_durationc                 ó~   € V P                  R ^ 4      pV P                  R^ 4      pV'       d   V'       d	   W!,
          # ^ # )r”   r•   rg   )r£   ÚstartÚends   &  r   Úget_sort_keyÚ#apply_sorting.<locals>.get_sort_key€  s5   € Ø—G‘GÐ2°AÓ6ˆEØ—'‘'Ð.°Ó2ˆCß"%¯%�3•;Ð6°QÐ6r   c                 ó&   € V P                  R ^ 4      # )rc   rg   )r£   s   &r   r¼   r½   …  s   € Ø—7‘7˜=¨!Ó,Ð,r   )ÚkeyÚreverse)Úsorted)r³   r´   rµ   rÀ   r¼   s   &&&  r   Úapply_sortingrÂ   {  s.   € à˜VÑ#€GàÐ&Ô&ó	7ò
	-ô �$°'Ô:Ð:r   c                ój   € V ^8„  d   QhR\         R\        R\        R\        R\        \        ,          /# ©r   r„   r   ÚqueuedÚhistoryr    )r!   rM   rD   r   )r"   s   "r   r#   r#   ‹  s4   € ÷ ñ ”sð ¤Tð ´4ð Ä$ð Ì8ÔTXÍ>ñ r   c                ó  € W9   d   \        WV ,          RR7      # V F-  pV^,          V 8X  g   K  \        V\        P                  4      u # 	  V F-  pV^,          V 8X  g   K  \        V\        P                  4      u # 	  R# )a5  
Get a single job by prompt_id from history or queue.

Args:
    prompt_id: The prompt ID to look up
    running: List of currently running queue items
    queued: List of pending queue items
    history: Dict of history items keyed by prompt_id

Returns:
    Job dict with full details, or None if not found
T)r‰   N)r¤   r†   r
   r   r   ©r„   r   rÅ   rÆ   rE   s   &&&& r   Úget_jobrÉ   ‹  sv   € ð ÔÜ% i¸Õ1CÐUYÔZÐZãˆØ��7�iÖÜ'¨¬i×.CÑ.CÓDÒDñ ó ˆØ��7�iÖÜ'¨¬i×.?Ñ.?Ó@Ò@ñ ñ r   c                óŒ   € V ^8„  d   QhR\         \        ,          R\         R\         R\        R\        \        \        3,          /# )r   Ú
prompt_idsr   rÅ   rÆ   r    )rM   r!   rD   ra   )r"   s   "r   r#   r#   ¦  sF   € ÷ ñ Ü”S•	ðäðô ðô ð	ô
 
Œ#Œsˆ(…^ñr   c                óN  € . VOVO Uu/ uF  qD^,          V^,          bK  	  ppVP                  4        F  w  rgVR,          ^,          WV&   K  	  / pV  FI  pVP                  V4      ;'       g    / P                  R4      p	\        V	\        4      '       g   KE  W˜V&   KK  	  V# u upi )a²  
Get the creation time (ms since epoch) of each given job that is still known.

A job is known while it is queued, running or in history.

Args:
    prompt_ids: The prompt IDs to look up
    running: List of currently running queue items
    queued: List of pending queue items
    history: Dict of history items keyed by prompt_id

Returns:
    Dict of creation times keyed by prompt_id; jobs the server no longer knows are left out
r‹   rc   )rL   rh   r%   ra   )
rË   r   rÅ   rÆ   rE   Úextra_data_by_promptr„   rˆ   Úcreate_timesrc   s
   &&&&      r   Úget_job_create_timesrÏ   ¦  s®   € ð( :M¸7Ð9LÀVÑ9LÓMÑ9L° �G T¨!¥WÒ,Ñ9LÐÐMØ#*§=¡=¦?Ñˆ	Ø*6°xÕ*@ÀÕ*CÐÓ'ñ $3ð €LÛˆ	Ø+×/Ñ/°	Ó:×@Ð@¸b×EÑEÀmÓTˆÜ�k¤3×'Ô'Ø&1˜Ó#ñ  ð Ðùò Ns   ‰B"c                ó   € V ^8„  d   QhR\         R\         R\        R\        \         \        ,          ,          R\        \        ,          R\        R\        R\        \        ,          R	\        R
\
        \         \        ,          \        3,          /
# )r   r   rÅ   rÆ   Ústatus_filterri   r´   rµ   ÚlimitÚoffsetr    )rM   rD   r   r!   ra   r`   )r"   s   "r   r#   r#   Æ  sŠ   € ÷ =ñ =Üð=äð=ô ð=ô œD¤�IÕ&ð	=ô
 œ#•ð=ô ð=ô ð=ô ”C�=ð=ô ð=ô Œ4”�:”sˆ?Õñ=r   c	                ó@  € . p	Vf   \         P                  p\         P                  V9   d3   V  F,  p
V	P                  \	        V
\         P                  4      4       K.  	  \         P
                  V9   d3   V F,  p
V	P                  \	        V
\         P
                  4      4       K.  	  \         P                  \         P                  \         P                  0pV\        V4      ,          pV'       dN   VP                  4        F9  w  rÞ\        WÞ4      pVP                  R4      V9   g   K(  V	P                  V4       K;  	  V'       d*   V	 Uu. uF  pVP                  R4      V8X  g   K  VNK  	  p	p\        W•V4      p	\        V	4      pV^ 8”  d   W˜R p	Ve   V	RV p	V	V3# u upi )a-  
Get all jobs (running, pending, completed) with filtering and sorting.

Args:
    running: List of currently running queue items
    queued: List of pending queue items
    history: Dict of history items keyed by prompt_id
    status_filter: List of statuses to include (from JobStatus.ALL)
    workflow_id: Filter by workflow ID
    sort_by: Field to sort by ('created_at', 'execution_duration')
    sort_order: 'asc' or 'desc'
    limit: Maximum number of items to return
    offset: Number of items to skip

Returns:
    tuple: (jobs_list, total_count)
Nr   ri   )r
   r   r   rN   r†   r   r   r   r   ÚsetrL   r¤   rh   rÂ   r[   )r   rÅ   rÆ   rÑ   ri   r´   rµ   rÒ   rÓ   r³   rE   Úhistory_statusesÚrequested_history_statusesr„   rˆ   r£   ÚjÚtotal_counts   &&&&&&&&&         r   Úget_all_jobsrÚ   Æ  s_  € ð8 €DàÒÜ!Ÿ™ˆä×Ñ Ô-ÛˆDØ�K‰KÔ,¨T´9×3HÑ3HÓIÖJñ ô ×Ñ˜MÔ)ÛˆDØ�K‰KÔ,¨T´9×3DÑ3DÓEÖFñ ô "×+Ñ+¬Y×-=Ñ-=¼y×?RÑ?RÐSÐØ!1´C¸Ó4FÕ!FÐß!Ø'.§}¡}¦Ñ#ˆIÜ(¨ÓAˆCØ�w‰w�xÓ Ð$>Ö>Ø—‘˜CÖ ñ (7÷
 ÙÓG™4�a 1§5¡5¨Ó#7¸;Ñ#F—�™4ˆÐGä˜¨
Ó3€Dä�d“)€Kà�„zØ�Gˆ}ˆØÒØ�F�Uˆ|ˆà�+ÐÐùò Hs   ÅFÅ$Fc          
      óT   € V ^8„  d   QhR\         R\        R\        R\        R\         /# rÄ   )r!   rM   rD   )r"   s   "r   r#   r#     s1   € ÷ ñ ¤sð ´Tð Ä4ð ÔRVð Ô[^ñ r   c                ó¢   € V F  pV^,          V 8X  g   K  \         u # 	  V F  pV^,          V 8X  g   K  \        u # 	  W9   d   \        # \        # )a.  Classify a job id for cancellation.

Returns one of CANCEL_RUNNING, CANCEL_PENDING, CANCEL_TERMINAL, CANCEL_UNKNOWN.

Queue items are tuples whose second element (index 1) is the prompt_id.
History is a dict keyed by prompt_id, so a job present there has already
finished and cancelling it is a no-op.
)ÚCANCEL_RUNNINGÚCANCEL_PENDINGÚCANCEL_TERMINALÚCANCEL_UNKNOWNrÈ   s   &&&& r   Úclassify_job_for_cancelrá     sR   € ó ˆØ��7�iÖÜ!Ò!ñ ó ˆØ��7�iÖÜ!Ò!ñ ð ÔÜÐÜÐr   c                ó´   € V ^8„  d   QhR\         R\        R\        R\        R\        \         .\        3,          R\        \         .\        3,          R\         /# )r   r„   r   rÅ   rÆ   Ú	interruptÚdequeuer    )r!   rM   rD   r   r/   )r"   s   "r   r#   r#     sd   € ÷ -ñ -Üð-äð-ô ð-ô ð	-ô
 œ˜œt˜Õ$ð-ô ”s�eœT�kÕ"ð-ô 	ñ-r   c                óÚ   € \        WW#4      pV\        8X  d   V! V 4      '       d   \        # \        # V\        8X  d/   V! V 4      '       d   \        # V! V 4      '       d   \        # \        # V# )uŠ  Cancel a single job by id, regardless of state.

Maps the cancel onto the runtime's existing mechanics:
  - a running job is interrupted via ``interrupt``
  - a pending job is removed from the queue via ``dequeue``
  - a job that already finished (terminal) is a no-op
  - an unknown id is a no-op (callers that need fail-fast behaviour should
    validate ids up front with ``classify_job_for_cancel``)

Both ``interrupt`` and ``dequeue`` take the prompt id and return whether
they acted on a job that was *actually* in that state, so the value returned
here reflects what truly happened rather than the (possibly stale)
classification. This matters around the narrow TOCTOU windows where a job
changes state between the caller's snapshot and the action:

  - a job classified RUNNING may have finished before ``interrupt`` fires:
    ``interrupt`` returns False and this returns CANCEL_UNKNOWN (no-op).
  - a job classified PENDING may have started executing before ``dequeue``
    fires: ``dequeue`` returns False, ``interrupt`` then catches the now-
    running job and this returns CANCEL_RUNNING. If it had simply finished
    instead, both return False and this returns CANCEL_UNKNOWN.

``interrupt`` must be atomic â€” interrupt the job only if it is still the one
running â€” so a cancel can never land on an unrelated prompt that started in
the meantime (see ``execution.PromptQueue.interrupt_if_running``).
)rá   rÝ   rà   rÞ   )r„   r   rÅ   rÆ   rã   rä   Úclassifications   &&&&&& r   Ú
cancel_jobrç     sd   € ôD -¨YÀÓQ€NØœÔ'Ù!*¨9×!5Ò!5Œ~ÐI¼>ÐIØœÔ'Ù�9×ÒÜ!Ð!ñ "+¨9×!5Ò!5Œ~ÐI¼>ÐIàÐr   >   rC   rz   ÚaudioÚvideoÚimages>   ú.fbxú.glbú.objú.gltfú.usdz>   ú.mdú.txtú.json)F)NNÚ
created_atr·   Né    )#r   r(   Útypingr   r   Úcomfy_api.internalr   rÝ   rÞ   rß   rà   r
   r,   Ú	frozensetrs   r<   ru   r=   rF   rV   r\   r]   rj   rw   r}   r†   r¤   r›   rœ   rÂ   rÉ   rÏ   rÚ   rá   rç   r   r   r   Ú<module>rø      sÉ   ðñó
 ß %å )ð €Ø€Ø€Ø€÷?ñ ?õñ( $Ò$NÓOÐ ñ ÒIÓJÐ ñ Ò4Ó5€õBò
õ"ð8 Ð õõ	$õõ>
Bõ÷&AõHL\õ^õ6;õ õ6÷@=õ@÷(-r   