export function getLinkedAgentId(task) {
    if (!task)
        return null;
    const assignedAgentId = task.assignedAgentId?.trim();
    if (assignedAgentId) {
        return assignedAgentId;
    }
    if (task.resultData) {
        try {
            const parsed = JSON.parse(task.resultData);
            const id = parsed?.agentId ??
                parsed?.agent_id ??
                parsed?.agent?.id;
            if (typeof id === "string" && id.trim()) {
                return id.trim();
            }
        }
        catch {
            // Ignore non-JSON payloads in resultData.
        }
    }
    return null;
}
//# sourceMappingURL=taskAgentLink.js.map