feat(02-02): add council orchestrator and result collector
- Implement executeCouncil with parallel member launch and partial-failure tolerance - Add result collection mapping and wire Athena exports with read-only athena tool restrictions
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import type { BackgroundTask, BackgroundTaskStatus } from "../../features/background-agent/types"
|
||||
import type { CouncilMemberConfig, CouncilMemberResponse, CouncilMemberStatus } from "./types"
|
||||
|
||||
export function collectCouncilResults(
|
||||
tasks: BackgroundTask[],
|
||||
members: CouncilMemberConfig[],
|
||||
startTimes: Map<string, number>
|
||||
): CouncilMemberResponse[] {
|
||||
return tasks.map((task, index) => {
|
||||
const member = members[index]
|
||||
const status = mapTaskStatus(task.status)
|
||||
const startTime = startTimes.get(task.id) ?? Date.now()
|
||||
const finishedAt = task.completedAt?.getTime() ?? Date.now()
|
||||
|
||||
return {
|
||||
member,
|
||||
status,
|
||||
response: status === "completed" ? task.result : undefined,
|
||||
error: status === "completed" ? undefined : (task.error ?? `Task status: ${task.status}`),
|
||||
taskId: task.id,
|
||||
durationMs: Math.max(0, finishedAt - startTime),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function mapTaskStatus(taskStatus: BackgroundTaskStatus): CouncilMemberStatus {
|
||||
if (taskStatus === "completed") {
|
||||
return "completed"
|
||||
}
|
||||
|
||||
if (taskStatus === "cancelled" || taskStatus === "interrupt") {
|
||||
return "timeout"
|
||||
}
|
||||
|
||||
return "error"
|
||||
}
|
||||
Reference in New Issue
Block a user