import{aga as q,kga as U}from"./cli-0.5.3-7wdgps7z.mjs";import{Wma as L,Xma as X}from"./cli-0.5.3-0df3r78b.mjs";import{AsyncLocalStorage as F}from"async_hooks";function G(){return O.getStore()}function Y(z,B){return O.run(z,B)}function Z(){return O.getStore()!==void 0}function $(z){return{...z,isInProcess:!0}}var O;var Q=X(()=>{O=new F});var y={};L(y,{waitForTeammatesToBecomeIdle:()=>l,setDynamicTeamContext:()=>b,runWithTeammateContext:()=>Y,isTeammate:()=>u,isTeamLead:()=>S,isPlanModeRequired:()=>w,isInProcessTeammate:()=>Z,hasWorkingInProcessTeammates:()=>I,hasActiveInProcessTeammates:()=>P,getTeammateContext:()=>G,getTeammateColor:()=>f,getTeamName:()=>h,getParentSessionId:()=>_,getDynamicTeamContext:()=>v,getAgentName:()=>A,getAgentId:()=>E,createTeammateContext:()=>$,clearDynamicTeamContext:()=>j});function _(){let z=G();if(z)return z.parentSessionId;return D?.parentSessionId}function b(z){D=z}function j(){D=null}function v(){return D}function E(){let z=G();if(z)return z.agentId;return D?.agentId}function A(){let z=G();if(z)return z.agentName;return D?.agentName}function h(z){let B=G();if(B)return B.teamName;if(D?.teamName)return D.teamName;return z?.teamName}function u(){if(G())return!0;return!!(D?.agentId&&D?.teamName)}function f(){let z=G();if(z)return z.color;return D?.color}function w(){let z=G();if(z)return z.planModeRequired;if(D!==null)return D.planModeRequired;return q(process.env.CLAUDE_CODE_PLAN_MODE_REQUIRED)}function S(z){if(!z?.leadAgentId)return!1;let B=E(),H=z.leadAgentId;if(B===H)return!0;if(!B)return!0;return!1}function P(z){for(let B of Object.values(z.tasks))if(B.type==="in_process_teammate"&&B.status==="running")return!0;return!1}function I(z){for(let B of Object.values(z.tasks))if(B.type==="in_process_teammate"&&B.status==="running"&&!B.isIdle)return!0;return!1}function l(z,B){let H=[];for(let[M,J]of Object.entries(B.tasks))if(J.type==="in_process_teammate"&&J.status==="running"&&!J.isIdle)H.push(M);if(H.length===0)return Promise.resolve();return new Promise((M)=>{let J=H.length,R=()=>{if(J--,J===0)M()};z((V)=>{let N={...V.tasks};for(let W of H){let K=N[W];if(K&&K.type==="in_process_teammate")if(K.isIdle)R();else N[W]={...K,onIdleCallbacks:[...K.onIdleCallbacks??[],R]}}return{...V,tasks:N}})})}var D=null;var g=X(()=>{Q();U();Q()});
export{G as _R,Y as $R,Z as aS,$ as bS,Q as cS,_ as dS,v as eS,E as fS,A as gS,h as hS,u as iS,f as jS,w as kS,S as lS,P as mS,I as nS,l as oS,y as pS,g as qS};
