import { LAB_REPRESENTATIVE_AGENT } from "../../agents/identity.js";
import { findTeamMemberBySession } from "./contract.js";
import { loadTeamRuntime } from "./store.js";
export async function resolveTeamActor(store, runId, input) {
    const runtime = await loadTeamRuntime(store, runId);
    const fallback = input.fallbackAgent;
    if (fallback && fallback !== store.config.default_run_agent && runtime?.members.some((member) => member.name === fallback)) {
        return fallback;
    }
    const member = findTeamMemberBySession(runtime, input.sessionId);
    return String(member?.name ?? input.fallbackAgent ?? store.config.default_run_agent ?? LAB_REPRESENTATIVE_AGENT);
}
//# sourceMappingURL=actor.js.map