How to do a cascading series of events to open an application with specific information?

The layout I'm looking at: • A daemon which queries various things, and at times decides it's time to log in (or log back in) • An application that handles the logging in, configuration, etc., which registers a custom url scheme • A LaunchAgent which would get an XPC (or just mach message, I suppose) from the daemon, and sends an open-url request for the custom url scheme, eg x-kithrup:login?reason=ihateyou

All of that is pretty straightforward to me! But... on a mac, can I tell who sent the request? That is, can my application see that it was my LaunchAgent that made the open-url request? On iOS, it looks like I can, as the UIApplicationDelegate has a method that passes in a sourceApplication. But the NSAppleEventDescriptors confused me a lot.

Yes, it turns out I can, by using event.attributeDescriptor(forKeyword: keyword) on the NSAppleEventDescriptor, which gives me an audit_token_t, from which I can at least sometimes get security (eg SecCode). Answer from @eskimo via TSI, which was SO WORTH IT.

How to do a cascading series of events to open an application with specific information?
 
 
Q