//#region src/domains/run/agents/tools/tool-utils.ts
function getRelationshipIdForTool(ctx, toolName, toolType) {
	if (toolType === "mcp") return (ctx.config.tools?.find((tool) => {
		if (tool.config?.type !== "mcp") return false;
		if (tool.availableTools?.some((available) => available.name === toolName)) return true;
		if (tool.config.mcp.activeTools?.includes(toolName)) return true;
		return tool.name === toolName;
	}))?.relationshipId;
	if (toolType === "tool") return ctx.functionToolRelationshipIdByName.get(toolName);
	if (toolType === "delegation") return ctx.config.delegateRelations.find((relation) => `delegate_to_${relation.config.id.toLowerCase().replace(/\s+/g, "_")}` === toolName)?.config.relationId;
	if (toolType === "transfer") return ctx.config.transferRelations.find((relation) => `transfer_to_${relation.id.toLowerCase().replace(/\s+/g, "_")}` === toolName)?.relationId;
}

//#endregion
export { getRelationshipIdForTool };