MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / FqY

Function FqY

package/cli.js:3749–3749  ·  view source on GitHub ↗
(q,K,_,z)

Source from the content-addressed store, hash-verified

3747**IMPORTANT**: TeamDelete will fail if the team still has active members. Gracefully terminate teammates first, then call TeamDelete after all teammates have shut down.
3748
3749Use this when all teammates have finished their work and you want to clean up the team resources. The team name is automatically determined from the current session's team context.
3750`.trim()}function NMK(q){return"cleanup team: current"}function yMK(q,K,{verbose:_}){let z=typeof q==="string"?r8(q):q;if("success"in z&&"team_name"in z&&"message"in z)return null;return null}var EMK=y(()=>{l8()});var LMK={};T8(LMK,{TeamDeleteTool:()=>hqY});var RqY,hqY;var RMK=y(()=>{x7();k8();Bq();i$();l8();RD();Le6();gj();EMK();RqY=B6(()=>L.strictObject({})),hqY=sq({name:Mw6,searchHint:"disband a swarm team and clean up",maxResultSizeChars:1e5,shouldDefer:!0,userFacingName(){return""},get inputSchema(){return RqY()},isEnabled(){return nq()},async description(){return"Clean up team and task directories when the swarm is complete"},async prompt(){return VMK()},mapToolResultToToolResultBlockParam(q,K){return{tool_use_id:K,type:"tool_result",content:[{type:"text",text:g6(q)}]}},async call(q,K){let{setAppState:_,getAppState:z}=K,$=z().teamContext?.teamName;if($){let A=mH($);if(A){let w=A.members.filter((j)=>j.name!==wz).filter((j)=>j.isActive!==!1);if(w.length>0){let j=w.map((H)=>H.name).join(", ");return{data:{success:!1,message:`Cannot cleanup team with ${w.length} active member(s): ${j}. Use requestShutdown to gracefully terminate teammates first.`,team_name:$}}}}await Ab8($),si1($),i7K(),S1K(),d("tengu_team_deleted",{team_name:$})}return _((A)=>({...A,teamContext:void 0,inbox:{messages:[]}})),{data:{success:!0,message:$?`Cleaned up directories and worktrees for team "${$}"`:"No team name found, nothing to clean up",team_name:$}}},renderToolUseMessage:NMK,renderToolResultMessage:yMK})});import{chmod as SqY,mkdir as CqY,readdir as bqY,readFile as xqY,unlink as SMK,writeFile as CMK}from"fs/promises";import{join as um8}from"path";function A67(){return um8(c1(),"sessions")}function IqY(){return}async function bMK(){if(NP()!=null)return!1;let q=IqY()??"interactive",K=A67(),_=um8(K,`${process.pid}.json`);pq(async()=>{try{await SMK(_)}catch{}});try{return await CqY(K,{recursive:!0,mode:448}),await SqY(K,448),await CMK(_,g6({pid:process.pid,sessionId:N8(),cwd:r1(),startedAt:Date.now(),kind:q,entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT,...{},...{}})),Bn8((z)=>{O67({sessionId:z})}),!0}catch(z){return N(`[concurrentSessions] register failed: ${d6(z)}`),!1}}async function O67(q){let K=um8(A67(),`${process.pid}.json`);try{let _=r8(await xqY(K,"utf8"));await CMK(K,g6({..._,...q}))}catch(_){N(`[concurrentSessions] updatePidFile failed: ${d6(_)}`)}}async function cQ(q){if(!q)return;await O67({name:q})}async function mm8(q){await O67({bridgeSessionId:q})}async function pm8(){let q=A67(),K;try{K=await bqY(q)}catch(z){if(!e3(z))N(`[concurrentSessions] readdir failed: ${d6(z)}`);return 0}let _=0;for(let z of K){if(!/^\d+\.json$/.test(z))continue;let Y=parseInt(z.slice(0,-5),10);if(Y===process.pid){_++;continue}if(QG6(Y))_++;else if(Z1()!=="wsl")SMK(um8(q,z)).catch(()=>{})}return _}var lQ=y(()=>{v8();c9();_8();m8();y8();u$6();vK();l8();AY()});function w67(q){xMK=q,mm8(mqY()??null).catch(()=>{})}function uqY(){return xMK}function mqY(){let q=uqY();return q?FC(q.bridgeSessionId):void 0}var xMK=null;var j67=y(()=>{lQ()});import{randomBytes as pqY}from"crypto";function gqY(){let q=pqY(8),K="s";for(let _=0;_<8;_++)K+=IMK[q[_]%IMK.length];return K}function FqY(q,K,_,z){let Y=gqY();zH6(Y,c0(pO(Y)));let $=z??P3(),A=pq(async()=>{K((j)=>{let{[Y]:H,...J}=j.tasks;return{...j,tasks:J}})}),O=_??BqY,w={...C0(Y,"local_agent",q),type:"local_agent",status:"running",agentId:Y,prompt:q,selectedAgent:O,agentType:"main-session",abortController:$,unregisterCleanup:A,retrieved:!1,lastReportedToolCount:0,lastReportedTokenCount:0,isBackgrounded:!0,pendingMessages:[],retain:!1,diskLoaded:!1};return N(`[LocalMainSessionTask] Registering task ${Y} with description: ${q}`),H0(w,K),K((j)=>{let H=Y in j.tasks;return N(`[LocalMainSessionTask] After registration, task ${Y} exists in state: ${H}`),j}),{taskId:Y,abortSignal:$.signal}}function uMK(q,K,_){let z=!0,Y;if(A3(q,_,($)=>{if($.status!=="running")return $;return z=$.isBackgrounded??!0,Y=$.toolUseId,$.unregisterCleanup?.(),{...$,status:K?"completed":"failed",endTime:Date.now(),messages:$.messages?.length?[$.messages.at(-1)]:void 0}}),Zw(q),z)UqY(q,"Background session",K?"completed":"failed",_,Y);else A3(q,_,($)=>({...$,notified:!0})),ZN(q,K?"completed":"failed",{toolUseId:Y,summary:"Background session"})}function UqY(q,K,_,z,Y){let $=!1;if(A3(q,z,(H)=>{if(H.notified)return H;return $=!0,{...H,notified:!0}}),!$)return;let A=_==="completed"?`Background session "${K}" completed`:`Background session "${K}" failed`,O=Y?`
3751<${gT}>${Y}</${gT}>`:"",w=sz(q),j=`<${XA}>
3752<${jP}>${q}</${jP}>${O}

Callers 1

mMKFunction · 0.85

Calls 10

gqYFunction · 0.85
zH6Function · 0.85
c0Function · 0.85
pOFunction · 0.85
P3Function · 0.85
pqFunction · 0.85
C0Function · 0.85
NFunction · 0.85
H0Function · 0.85
KFunction · 0.70

Tested by

no test coverage detected