+
    lHàj—   ã                  óì   € R t ^ RIHt ^ RIt^ RIt^ RIHtHtHtH	t	 ]P                  ! R]P                  4      t]P                  ! R4      t^
tR R ltR R	 ltR
 R ltR R lt^tR R ltR R ltR# )zldelegate_task input validation: tasks=[...] / legacy goal normalisation, per-task output schemas and images.)ÚannotationsN)ÚAnyÚDictÚListÚOptionalz^(todo|task\s*\d+)$z[<[A-Za-z][A-Za-z0-9]*(?:[ _-][A-Za-z0-9]+)+>|\{[A-Za-z][A-Za-z0-9]*(?:[ _-][A-Za-z0-9]+)+\}c               ó    € V ^8„  d   QhRRRR/# )é   Útasksr   Úreturnú4tuple[Optional[list[dict[str, Any]]], Optional[str]]© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/tools/delegate_tool_tasks.pyÚ__annotate__r      s   € ÷ ñ ¨3ð Ð3gñ ó    c                óf  € \        V \        4      '       g   R# V P                  4       pV'       g   R#  \        P                  ! V4      p\        T\        4      '       g   RR\        T4      P                   R23# TR3#   \        P
                   d   pRRTP                   R23u Rp?# Rp?ii ; i)zp``(parsed_list, None)`` for a JSON-array string, ``(None, error)`` for a bad string, ``(None, None)`` otherwise.Nz`tasks must be a JSON array of task objects; received a string that could not be parsed as JSON (z).z3tasks must be a JSON array of task objects; parsed z	 instead.©NN)Nz7Provide either 'goal' (single task) or 'tasks' (batch).)
Ú
isinstanceÚstrÚstripÚjsonÚloadsÚJSONDecodeErrorÚmsgÚlistÚtypeÚ__name__)r	   ÚrawÚparsedÚexcs   &   r   Ú_recover_tasks_from_json_stringr       sÀ   € ä�eœS×!Ò!ØÐØ
�+‰+‹-€CßØNÐNðDÜ—’˜C“ˆô �fœd×#Ò#ØÐJÌ4ÐPVË<×K`ÑK`ÐJaÐajÐkÐkÐkØ�4ˆ<Ðøô	 ×Ñô DØÐwÐx{×xÑxð  xAð  ACð  Dð  Dõ  	DûðDús   ´A? Á?B0ÂB+Â%B0Â+B0c               ó    € V ^8„  d   QhRRRR/# )r   Ú	task_listúlist[dict[str, Any]]r
   zOptional[str]r   )r   s   "r   r   r   $   s   € ÷ ñ Ð%9ð ¸mñ r   c                ó  € \        V 4       Fñ  w  r\        VP                  RR4      4      P                  4       p\        P                  RP                  VP                  4       P                  4       4      4      '       d   RV RV: R2u # \        P                  V4      pV'       d   RV RVP                  ^ 4      : R2u # \        V4      \        8  g   KÎ  \        V 4      ^8¼  g   Kà  RV R	V: R
\         R2u # 	  R# )u"  Batch-only quality gate beyond per-task goal presence; actionable error or None. No minimum count: a one-entry
array is the canonical single-task shape (legacy top-level `goal` is wrapped into one). Duplicate goals are
deliberately NOT rejected â€” identical-goal fan-outs (best-of-N / ensemble sampling) are legitimate and blocking
them broke real workflows. The too-short check applies only to multi-task fan-outs (terse goals there are
usually unexpanded templates); a SINGLE task legitimately uses short goals ("Fix the tests").

See #81141.
ÚgoalÚ Ú úTask z has a placeholder goal (za). Replace it with a specific, self-contained description of what the subagent should accomplish.z. goal contains an unexpanded template marker (ud   ). Substitute the real value before calling delegate_task â€” subagents cannot resolve placeholders.z goal is too short (z5). Write a specific, self-contained goal of at least z5 characters so the subagent knows exactly what to do.N)Ú	enumerater   Úgetr   Ú_PLACEHOLDER_GOAL_REÚmatchÚjoinÚlowerÚsplitÚ_TEMPLATE_MARKER_REÚsearchÚgroupÚlenÚ_MIN_BATCH_GOAL_LEN)r"   ÚiÚtaskr%   Úmarkers   &    r   Ú_validate_batch_tasksr8   $   s  € ô ˜YÖ'‰ˆÜ�4—8‘8˜F BÓ'Ó(×.Ñ.Ó0ˆÜ×%Ñ% c§h¡h¨t¯z©z«|×/AÑ/AÓ/CÓ&D×EÒEà˜�sÐ3°D±8ð <fð fòô %×+Ñ+¨DÓ1ˆßà˜�sð Ø—L‘L “OÑ&ð 'SðSòô
 ˆt‹9Ô*Ö*¬s°9«~ÀÖ/Bà˜�sÐ.¨t©hð 73Ü3FÐ2Gð H&ð&òñ (ñ( r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Útop_roler   Úmax_childrenÚintr
   r   r   )r   s   "r   r   r   C   s)   € ÷ &Eñ &EØ36ð&EØFIð&Eà9ñ&Er   c                ó  € \        V4      w  rgV'       d   RV3# Ve   Tp\        V\        4      '       d   V'       g   RpV'       d>   \        V\        4      '       d(   \        V4      V8”  d   RR\        V4       RV R23# TpMOV '       dF   \        V \        4      '       d0   V P                  4       '       d   RV RVRV/.pVe   W8^ ,          R&   MR# \        V4       Fk  w  rš\        V
\        4      '       g!   RR	V	 R
\        V
4      P                   R23u # V
P                  RR4      P                  4       '       d   Kc  RR	V	 R23u # 	  \        V\        4      '       d   \        V4      MRpV'       d   RV3# VR3# )za``(task_list, None)`` from ``tasks=[...]`` or the legacy single ``goal``, else ``(None, error)``.NzToo many tasks: z* provided, but max_concurrent_children is z‡. Either reduce the task count, split into multiple delegate_task calls, or increase delegation.max_concurrent_children in config.yaml.r%   ÚcontextÚroleÚoutput_schemar(   z must be an object, got Ú.r&   z is missing a 'goal'.)Nuƒ   No tasks provided. Pass tasks=[{goal: '...', context: '...'}, ...] â€” one entry per subagent (a single task is a one-entry array).)r    r   r   r3   r   r   r)   Údictr   r   r*   r8   )r%   r>   r	   r@   r:   r;   Úrecovered_tasksÚtasks_errorr"   r5   r6   Úbatch_errors   &&&&&&      r   Ú_normalize_task_listrF   C   s„  € ô $CÀ5Ó#IÑ €OßØ�[Ð Ð ØÒ"Øˆä�%œ×Ò§uØˆç”˜E¤4×(Ò(Üˆu‹:˜Ô$ØØ"¤3 u£: ,Ð.XÐYeÐXfð gEð Fðð ð
 ‰	ß	”*˜T¤3×'Ò'¨D¯J©J¯LªLØ˜d I¨w¸ÀÐIÐJˆ	ØÒ$Ø,9�a�L˜Ñ)øð
ð 	
ô
 ˜YÖ'‰ˆÜ˜$¤×%Ò%Ø˜5  Ð#;¼DÀ»J×<OÑ<OÐ;PÐPQÐRÐRÒRØ�x‰x˜ Ó#×)Ñ)×+Ô+Ø˜5  Ð#8Ð9Ð9Ò9ñ	 (ô 7AÀÌ×6MÒ6MÔ'¨	Ô2ÐSW€Kß"-ˆD�+ÐÐD°I¸tÐ3DÐDr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r"   r#   r@   zOptional[dict[str, Any]]r
   z4tuple[list[Optional[dict[str, Any]]], Optional[str]]r   )r   s   "r   r   r   k   s$   € ÷ ñ Ø#ðØ4Lðà9ñr   c                óö   € ^ RI Hp . p\        V 4       F_  w  rEVP                  R4      pVf   \	        V 4      ^8X  d   Ve   TpV! V4      w  rxV'       d   . RV RV 23u # VP                  V4       Ka  	  VR3# )z±Per-task coerced output schemas. A malformed output_schema fails the whole call before any child spawns;
schema-less tasks resolve to None and take no new code paths downstream.)Úcoerce_output_schemar@   Nr(   z output_schema invalid: )Útools.delegation_output_schemarI   r)   r*   r3   Úappend)	r"   r@   rI   Útask_schemasr5   r6   Ú
raw_schemaÚcoerced_schemaÚ
schema_errs	   &&       r   Ú_coerce_task_schemasrP   k   s‹   € õ
 DØ35€LÜ˜YÖ'‰ˆØ—X‘X˜oÓ.ˆ
ØÒ¤# i£.°AÔ"5¸-Ò:SØ&ˆJÙ%9¸*Ó%EÑ"ˆßØ˜˜q˜cÐ!9¸*¸ÐFÐFÒFØ×Ñ˜NÖ+ñ (ð ˜ÐÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r6   rB   r5   r<   r
   z)tuple[Optional[list[str]], Optional[str]]r   )r   s   "r   r   r      s"   € ÷ #ñ # ð #¨#ð #Ð2[ñ #r   c                óØ  € V P                  R4      pVf   R	# \        V\        4      '       d   V.p\        V\        4      '       g	   RRV R23# . pV FX  p\        V\        4      '       d   VP	                  4       '       g   RRV R23u # VP                  VP	                  4       4       KZ  	  \        V4      \        8”  d   RRV R\        V4       R\         R23# T;'       g    RR3# )
zÖ``(cleaned_list_or_None, None)`` for a task's optional ``images`` (local paths, http(s) or data: URLs), else
``(None, error)``. A bare string is wrapped into a one-entry list (small models emit scalars for arrays).ÚimagesNr(   z? 'images' must be an array of local file paths or http(s) URLs.zO 'images' entries must be non-empty strings (local file paths or http(s) URLs).z has z images; the per-task limit is z5. Trim to the images the child actually needs to see.r   )r*   r   r   r   r   rK   r3   Ú_MAX_TASK_IMAGES)r6   r5   r   ÚcleanedÚitems   &&   r   Ú_normalize_task_imagesrW      sö   € ð �(‰(�8Ó
€CØ
‚{ØÐÜ�#”s×ÒØˆeˆÜ�cœ4× Ò Ø�u˜Q˜CÐ^Ð_Ð_Ð_Ø€GÛˆÜ˜$¤×$Ò$¨D¯J©J¯LªLØ˜5  Ð#rÐsÐsÒsØ�‰�t—z‘z“|Ö$ñ ô ˆ7ƒ|Ô&Ô&ØØ�A�3�eœC ›L˜>Ð)HÔIYÐHZð [Bð Bð
ð 	
ð �OˆO�t˜dÐ"Ð"r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r"   r#   rS   zOptional[list[str]]r
   z/tuple[list[Optional[list[str]]], Optional[str]]r   )r   s   "r   r   r   •   s$   € ÷ ñ Ø#ðØ-@ðà4ñr   c                óì   € . p\        V 4       F`  w  r4VP                  R4      f   \        V 4      ^8X  d   Ve	   / VCRV/Cp\        WC4      w  rVV'       d   . V3u # VP	                  V4       Kb  	  VR3# )zµPer-task validated image lists; a malformed list fails the whole call before any child spawns. The legacy
top-level ``images`` applies to a single task only, like ``output_schema``.rS   N)r)   r*   r3   rW   rK   )r"   rS   Útask_imagesr5   r6   rU   Úerrs   &&     r   Ú_coerce_task_imagesr\   •   s}   € ð
 .0€KÜ˜YÖ'‰ˆØ�8‰8�HÓÒ%¬#¨i«.¸AÔ*=À&ÒBTØ-�dÐ-˜H fÑ-ˆDÜ-¨dÓ6‰ˆßØ�s�7ŠNØ×Ñ˜7Ö#ñ (ð ˜ÐÐr   )Ú__doc__Ú
__future__r   r   ÚreÚtypingr   r   r   r   ÚcompileÚ
IGNORECASEr+   r0   r4   r    r8   rF   rP   rT   rW   r\   r   r   r   Ú<module>rc      sq   ðÙ rå "ã Û 	ß ,Ó ,ð —z’zÐ"8¸"¿-¹-ÓHÐ Ø—j’jØbóÐ ð Ð õõõ>&EõPð$ Ð õ#÷,r   