fix: ulid API + tolerate missing tmux + dispatch-first endpoint
- coordinator: use `ulid.new().str` (ulid-py 1.x API), not `ULID()` - coordinator._submit: swallow tmux errors so game logic continues - app: split first-prompt dispatch into POST /api/dispatch-first - start.sh: POST /api/dispatch-first ~12s after tmux create - test_coordinator: isolate GAMES_DIR via tmp_path
This commit is contained in:
+11
-3
@@ -120,11 +120,19 @@ def build_app(state: state_mod.AppState) -> FastAPI:
|
||||
@app.post("/api/new-game")
|
||||
async def new_game_post() -> dict[str, Any]:
|
||||
await start_new_game(state)
|
||||
runtime = getattr(state, "runtime", None)
|
||||
if runtime and runtime.get("coord"):
|
||||
await runtime["coord"].dispatch_first_prompt()
|
||||
return state.game.get_state() # type: ignore[union-attr]
|
||||
|
||||
@app.post("/api/dispatch-first")
|
||||
async def dispatch_first() -> dict[str, Any]:
|
||||
runtime = getattr(state, "runtime", None)
|
||||
if not runtime or not runtime.get("coord"):
|
||||
return {"ok": False, "reason": "coordinator_not_running"}
|
||||
try:
|
||||
await runtime["coord"].dispatch_first_prompt()
|
||||
return {"ok": True}
|
||||
except Exception as e:
|
||||
return {"ok": False, "reason": "dispatch_failed", "detail": str(e)}
|
||||
|
||||
@app.get("/api/agent-binding/{side}")
|
||||
async def agent_binding(side: str) -> dict[str, Any]:
|
||||
s = Side.from_str(side)
|
||||
|
||||
Reference in New Issue
Block a user