This is what I know of the battle AI
I'm in no way familiar with scripts in TATW, but I had a look at the file config_ai_battle.xml and the only occurrence of the ai behaving differently under different difficulty settings is when deciding whether or not to retreat, (there's a counter for deciding when to retreat and on lower difficulties the ai retreats at a lower threshold). Everything else is the SAME across all difficulties, things like the distance at which an enemy army will engage you, or how the ai calculates whether or not it should attempt to fight your missile troops with its own are the SAME.
I remember seeing somewhere however that on different difficulties the attack values of your troops and the enemy troops are invisibly modified.
easy: +3 attack for your troops
medium: +0 for everyone
hard: +3 attack for enemy troops
very hard: +7 attack for enemy troops
now because the AI knows about these bonuses (it uses them in its calculations) it appears to behave differently on different difficulty settings as it perceives itself to be stronger.
for example, say on medium it thinks that
your forces are stronger and plays more defensively; on very hard it has +7 attack and so calculates
itself to be stronger than you and so behaves more aggressively.
As for campaign AI, I haven't got a clue!