MCPcopy Create free account
hub / github.com/Noumena-Network/code / kill

Function kill

src/tasks/RemoteAgentTask/RemoteAgentTask.tsx:814–850  ·  view source on GitHub ↗
(taskId, setAppState)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected