OpenRecoveryScript is an open scripting engine that any recovery and any app can use to as an API between app and recovery.  This engine allows an app to tell a recovery to install zips, perform backups, etc.  Below is documentation of the API:

Script file needs to be: /cache/recovery/openrecoveryscript

Each line represents a different command. Commands are executed in order, top to bottom. If an error occurs, the script will stop executing. Commands must be lower case. If a parameter is needed, the parameter will follow the command with a space. You have the following commands and parameters to work with:

install /sdcard/path/ (note, if you don't supply a leading slash, TWRP will use "relative paths" instead of absolute paths which is handy on dual storage devices and devices where the path to storage in the ROM isn't the same as the path in recovery -- relative paths available in TWRP 2.2 and later only)
wipe cache
backup SDCR123BAEOM foldername
-S = System
-D = Data
-C = Cache
-R = Recovery
-1 = special partition 1
-2 = special partition 2
-3 = special partition 3
-B = Boot
-A = Android secure
-E = SD-Ext
-O = use compression
-M = do not create MD5
-foldername is optional and is just the final folder in the full TWRP path
restore foldername SDCR123BAEM
-foldername is fully qualified with /sdcard/TWRP etc.
-partitions are optional, if nothing is set, then all partitions will be restored
-setting a flag for a partition that doesn't exist in the backup will not throw an error
-flags are the same as backup, there is no O for compression in restore
mount path
unmount path
set variable value
-use this to change variables that are in the TWRP settings file
mkdir /folder1/folder2/folder3
-fully recursive, will create all folders needed in the full path
cmd command line command with any parameters
print whatever you want to have displayed (added in TWRP 2.2 and later)

Here are some examples:
install /sdcard/
wipe data
wipe cache
wipe dalvik
backup SDBOM (will backup system, data, and boot and use compression and skip MD5 generation)
backup SDBOM myrom (backups the same as above in a folder called myrom)
restore /sdcard/TWRP/BACKUPS/*serialno*/myrom (would restore all partitions found in myrom)
restore /sdcard/TWRP/BACKUPS/*serialno*/myrom DM (would restore only the data partition in myrom and skip MD5 checking)
mount system
unmount system
set tw_signed_zip_verify 0 (would turn off zip verification)
set tw_time_zone CST6;CDT (would set the time zone to central time)
mkdir /sdcard/folder1/folder2 (would potentially create 2 folders on your sdcard if they don't already exist)
cmd chmod 755 /system/bin/htcdumlock (obviously you need to have system mounted for this to work)
cmd htcdumlock restore (this would restore the original boot if the user is using htcdumlock)

The version for CWMR follows the above, but some options are not available in CWMR:
You must specify something as an option for backup, but whatever is specified is ignored. CWMR doesn't support backing up individual partitions. Something like:
backup E
backup E backupname
Note that CWMR does support restoring individual partitions, though not all partitions are supported. Special partitions are not supported and android_secure and recovery are not supported.
The set command is not supported.
mkdir is not directly supported. You can create directories using the command line: cmd mkdir