MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / kill

Function kill

source code/tasks/RemoteAgentTask/RemoteAgentTask.tsx:813–849  ·  view source on GitHub ↗
(taskId, setAppState)

Source from the content-addressed store, hash-verified

811 name: 'RemoteAgentTask',
812 type: 'remote_agent',
813 async kill(taskId, setAppState) {
814 let toolUseId: string | undefined;
815 let description: string | undefined;
816 let sessionId: string | undefined;
817 let killed = false;
818 updateTaskState<RemoteAgentTaskState>(taskId, setAppState, task => {
819 if (task.status !== 'running') {
820 return task;
821 }
822 toolUseId = task.toolUseId;
823 description = task.description;
824 sessionId = task.sessionId;
825 killed = true;
826 return {
827 ...task,
828 status: 'killed',
829 notified: true,
830 endTime: Date.now()
831 };
832 });
833
834 // Close the task_started bookend for SDK consumers. The poll loop's
835 // early-return when status!=='running' won't emit a notification.
836 if (killed) {
837 emitTaskTerminatedSdk(taskId, 'stopped', {
838 toolUseId,
839 summary: description
840 });
841 // Archive the remote session so it stops consuming cloud resources.
842 if (sessionId) {
843 void archiveRemoteSession(sessionId).catch(e => logForDebugging(`RemoteAgentTask archive failed: ${String(e)}`));
844 }
845 }
846 void evictTaskOutput(taskId);
847 void removeRemoteAgentMetadata(taskId);
848 logForDebugging(`RemoteAgentTask ${taskId} killed, archiving session ${sessionId ?? 'unknown'}`);
849 }
850};
851
852/**

Callers

nothing calls this directly

Calls 6

emitTaskTerminatedSdkFunction · 0.85
archiveRemoteSessionFunction · 0.85
logForDebuggingFunction · 0.85
evictTaskOutputFunction · 0.85
updateTaskStateFunction · 0.50

Tested by

no test coverage detected