import { LAB_REPRESENTATIVE_AGENT } from "../../agents/identity.js";
export function threadIdForTeamMember(member) {
    return String(member.thread_id ?? member.name);
}
export function agentThreadInputFromTeamMember(runId, member, config) {
    const threadId = threadIdForTeamMember(member);
    const spawnPolicy = member.spawn_policy ?? config.virtual_member_defaults.default_spawn_policy;
    return {
        thread_id: threadId,
        run_id: runId,
        agent_name: threadId,
        role: member.role,
        role_label: member.role_label,
        capability_profile: member.capability_profile ? String(member.capability_profile) : undefined,
        parent_thread_id: member.parent_thread_id ?? (member.role === "lead" ? undefined : LAB_REPRESENTATIVE_AGENT),
        opencode_session_id: member.session_id,
        background_id: member.background_id,
        agent_call_id: member.agent_call_id,
        prompt_ref: member.prompt_ref,
        tool_manifest_ref: member.tool_manifest_ref,
        memory_ref: member.memory_ref,
        status: agentThreadStatusFromMemberStatus(member.status),
        allowed_tools: member.tool_policy?.allowed_tools ?? [],
        denied_tools: member.tool_policy?.denied_tools ?? [],
        allowed_skills: member.skill_policy?.allowed_skills ?? [],
        denied_skills: member.skill_policy?.denied_skills ?? [],
        allowed_mcps: member.mcp_policy?.allowed_mcps ?? [],
        denied_mcps: member.mcp_policy?.denied_mcps ?? [],
        helper_limits: {
            max_depth: spawnPolicy.allowed ? Math.max(0, spawnPolicy.max_depth) : 0,
            max_parallel_helpers: spawnPolicy.allowed ? config.agent_threads.max_parallel_helpers_per_thread : 0,
        },
        helper_counts: member.helper_counts ?? { running: 0, completed: 0, failed: 0 },
        read_paths: member.read_paths ?? [],
        write_paths: member.write_paths ?? [],
        created_at: member.joined_at,
        updated_at: member.last_seen_at ?? member.joined_at,
    };
}
export function agentThreadStatusFromMemberStatus(status) {
    switch (status) {
        case "queued":
        case "launching":
        case "running":
            return "launching";
        case "active":
            return "active";
        case "idle":
            return "idle";
        case "waiting_on_mailbox":
            return "waiting_on_mailbox";
        case "blocked":
            return "blocked";
        case "completed":
        case "done":
            return "completed";
        case "failed":
            return "failed";
        case "cancelled":
            return "cancelled";
        default:
            return "created";
    }
}
//# sourceMappingURL=projection.js.map