forked from Rockachopa/Timmy-time-dashboard
feat(swarm): add in-process agent spawning with live auction bidding
- Add spawn_in_process_agent() to SwarmCoordinator: creates lightweight SwarmNode instances that share the coordinator's comms layer and AuctionManager, enabling synchronous bid submission - Fix post_task() to open the auction BEFORE announcing via comms so in-process agent callbacks can submit bids into an open auction - Fix run_auction_and_assign() to close an already-open auction instead of re-opening (which would discard bids) - Add POST /swarm/tasks/auction route for atomic task+auction flow - Add 7 integration tests (TDD) covering the full lifecycle: spawn → post → auction → assign → complete
This commit is contained in:
@@ -88,6 +88,21 @@ async def post_task(description: str = Form(...)):
|
||||
}
|
||||
|
||||
|
||||
@router.post("/tasks/auction")
|
||||
async def post_task_and_auction(description: str = Form(...)):
|
||||
"""Post a task and immediately run an auction to assign it."""
|
||||
task = coordinator.post_task(description)
|
||||
winner = await coordinator.run_auction_and_assign(task.id)
|
||||
updated = coordinator.get_task(task.id)
|
||||
return {
|
||||
"task_id": task.id,
|
||||
"description": task.description,
|
||||
"status": updated.status.value if updated else task.status.value,
|
||||
"assigned_agent": updated.assigned_agent if updated else None,
|
||||
"winning_bid": winner.bid_sats if winner else None,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/tasks/{task_id}")
|
||||
async def get_task(task_id: str):
|
||||
"""Get details for a specific task."""
|
||||
|
||||
Reference in New Issue
Block a user