There would be a version of adventure() that takes a third string argument, naming a function.
That function should have a signature like this:
string my_consult_function(int round, monster opponent, string pageText)
'round' starts at zero, and is incremented by one on each successive call to your function. It's not exactly the same as the combat round number, since there are actions that take no rounds (such as "steal" when that's unavailable or inappropriate), and actions that take more than one round (skill use with insufficient MP, thus requiring a restorative to be used first).
The normal consult-related functions could probably be used, but there's a better way - just return a string in the form of a CCS command. (Actually, I'm surprised that this isn't the way consult scripts worked from the beginning - seems like it would have been a lot easier to implement.) It will be executed, and then, assuming that the combat hasn't been finished or aborted, your function will be called again to produce the next action. Note that, unlike existing consult scripts, your script isn't being reloaded each time, so you've got continuity of global variables between each call.