-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access window.ai from inside another extension #47
Comments
Are you injecting your script before the document load event? What happens if you wait for load and then try? Also, what happens if you use “npm i window.ai” and then await getWindowAI ? |
You will need to inject your CS inside the mainworld to be able to consume this API as-is. The default world content script (CS) lives in does not share the same window context as the main world (where window.ai exposes the API). One way we can do is to add a secondary interface via externallyConnectable, so that other extension can call window.ai directly via extension messaging instead of having to pipe message from main -> their extension. This will also allow other extension to not be rely on the main world (which is only exposed when user visit a site). Another way is to have window.ai be a central model config store (like a password manager). Since extension communication are not real time (or at least I don't recall there was an API for that :d...). Then, other extension can ask for the auth data from window.ai, and use a window.ai's client package that implement the API interface in their own extension, invoking the model however they like. |
@JeroenvdV It sounds like making the extension externally connectable is the best path so far to making this easy, but in the meantime you can make a main world script. (e.g. With Plasmo:
Will close this for now but feel free to reopen if this doesn't work. |
@alexanderatallah by realtime I mean like the port API - I shoulda say -"long-lived" comms :d |
Reopening this to mark a task for improving support for connecting from other extensions |
I will take a look at this tomorrow! I would love to see to some sort of Plasmo template that makes it easy to get started with window.ai in a chrome extension! |
I'm working on a browser extension myself that could I would like to use window.ai as a backend. Unlike in a page, my injected js code currently can't access window.ai (in Chrome), because it remains undefined. Is there a way to access the API from an extension or what would be needed to enable that?
The text was updated successfully, but these errors were encountered: