MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / findAvailableTask

Function findAvailableTask

src/utils/swarm/inProcessRunner.ts:604–614  ·  view source on GitHub ↗

* Find an available task from the team's task list. * A task is available if it's pending, has no owner, and is not blocked.

(tasks: Task[])

Source from the content-addressed store, hash-verified

602 * A task is available if it's pending, has no owner, and is not blocked.
603 */
604function findAvailableTask(tasks: Task[]): Task | undefined {
605 const unresolvedTaskIds = new Set(
606 tasks.filter(t => t.status !== 'completed').map(t => t.id),
607 )
608
609 return tasks.find(task => {
610 if (task.status !== 'pending') return false
611 if (task.owner) return false
612 return task.blockedBy.every(id => !unresolvedTaskIds.has(id))
613 })
614}
615
616/**
617 * Format a task as a prompt for the teammate to work on.

Callers 1

tryClaimNextTaskFunction · 0.70

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected