Is it possible to make a CLI for your browser extention?

I am thinking about suggesting a feature to a browser extension about adding a CLI to improve things like workflows and all of that, I would also like to develop a browser extension at some point and I use nix/nixos and I would need some way to easily interact with my extension, among other things, I heard nativeMessaging could be a way to interact with it, but it feels a bit janky. How would I go about implementing a CLI for a browser extension? What about the inbuilt browser terminal? It should be possible there.