Do you mean the program is executing wait instruction? If this is the case, you can get the state until you use script to set some signal, such as register etc. to indicate the state. If you mean the program finishing state, you can get from port 30001/30002 or dashboard with is_ProgramRunning.
There isn’t a direct way for access this state since from the point view of robot, it is executing the program normally. So a workaround could be you set a register before and after a wait instruction and monitor the register via 30004 or modbus.
If your program is written in Polyscope it will include label messages for every line in the program. These can be read out from the Primary Client Interface Datastream on port 30001, in the LabelMessage message type. You could monitor the last line to be executed and whether it was a wait or not.
Not an ideal solution as it’s quite troublesome and won’t work if you’ve written your program directly in URScript. You may be able to create your own custom label messages in that case, although this is something I haven’t tried.