MCPcopy Index your code
hub / github.com/Noumena-Network/code / killWorkflowTask

Function killWorkflowTask

src/tasks/LocalWorkflowTask/LocalWorkflowTask.tsx:438–480  ·  view source on GitHub ↗
(
  taskId: string,
  setAppState: SetAppState,
)

Source from the content-addressed store, hash-verified

436}
437
438export async function killWorkflowTask(
439 taskId: string,
440 setAppState: SetAppState,
441): Promise<void> {
442 let shouldNotify = false
443
444 updateWorkflowTask(taskId, setAppState, task => {
445 if (task.status !== 'running') {
446 return task
447 }
448
449 shouldNotify = true
450 task.abortController?.abort()
451 for (const controller of Object.values(task.agentControllers ?? {})) {
452 controller.abort()
453 }
454
455 const agents = task.agents.map(agent =>
456 agent.status === 'completed' || agent.status === 'failed'
457 ? agent
458 : {
459 ...agent,
460 status: 'killed',
461 endTime: agent.endTime ?? Date.now(),
462 },
463 )
464
465 return {
466 ...task,
467 ...countAgents(agents),
468 status: 'killed',
469 endTime: Date.now(),
470 agents,
471 abortController: undefined,
472 agentControllers: {},
473 }
474 })
475
476 if (shouldNotify) {
477 enqueueWorkflowNotification(taskId, setAppState, 'killed')
478 void evictTaskOutput(taskId)
479 }
480}
481
482export async function skipWorkflowAgent(
483 taskId: string,

Callers 4

handleKeyDownFunction · 0.85
BackgroundTasksDialogFunction · 0.85
killFunction · 0.85

Calls 4

updateWorkflowTaskFunction · 0.85
countAgentsFunction · 0.85
evictTaskOutputFunction · 0.85

Tested by

no test coverage detected