-
Notifications
You must be signed in to change notification settings - Fork 10
API Proposal #187
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
base: feat/api
Are you sure you want to change the base?
API Proposal #187
Conversation
|
Yeah, no, that CI status checks out considering I've been losing my mind over an issue with tsc |
|
Reviewing this in the browser is super inconvenient, I will submit a review once I get back home. |
| // /** Whether or not NeuroPilot is connected to the Neuro API. */ | ||
| // readonly connected: Omit<ConnectionTypes, ConnectionTypes.Failed>; | ||
| // /** Current connection info, assuming {@link APIWrapper.connected} returns {@link ConnectionTypes.Connected} */ | ||
| // readonly connectionInfo: ConnectionStatus | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection info was in case of debugging purposes, tbh idrc if we need it or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all its properties can be obtained in other ways:
connectedcan be got withgetConnectionStatus().urlwould always be as configured in the settings. I assume the| nullpart of the type means that it would benullif not connected, which can be determined withgetConnectionStatus().- Any
errorduring connection would be logged to the output channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. That being said, do we need to expose the URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can query that from the settings, but I'll test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you definitely can ig
| * Deactivate the companion extension. | ||
| * Removes and unregisters all actions registered by this extension. | ||
| * After deactivation, the API methods will no longer work. | ||
| * @param message The message to display on deactivation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would be a message that would be sent to Neuro on deactivation (alongside our own deactivation notice)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about this, it would probably make more sense to not provide a message here, since the companion can just send context to Neuro via sendContext(...), or display a vscode notification without relying on our API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it's convenient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to just not have a .ts file in here and instead just have a .d.ts file instead? publishing .ts files have some jank to them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not possible because the enum has values defined, which either tsc or esbuild doesn't like. We could maybe try using a .js file instead if that's better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esbuild seems to like it now, wasnt complaining when I was trying
How the API works
The activation function returns a
NeuroPilotAPIWrapperobject. It has a single method (for now),registerCompanion, which allows a companion extension to register itself.registerCompaniongenerates a token for the companion and returns the actualExtensionAPIobject. The token is contained in the private_tokenproperty, and is used to validate "companion permissions" and filter actions in the registry. Currently, all companion permissions are always considered on, because no way to change them is implemented yet.I commented out some of the API functions which I deem unnecessary, but I am open to discussion on why they are necessary.
Safety
The API does not expose access to the action registry directly, so the filter cannot be circumvented. With knowledge about the implementation details, it is possible to extract the token from the API, but the token is not very useful by itself.