Skip to content

Conversation

@Pasu4
Copy link
Member

@Pasu4 Pasu4 commented Nov 25, 2025

How the API works

The activation function returns a NeuroPilotAPIWrapper object. It has a single method (for now), registerCompanion, which allows a companion extension to register itself. registerCompanion generates a token for the companion and returns the actual ExtensionAPI object. The token is contained in the private _token property, 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.

@KTrain5169
Copy link
Member

Yeah, no, that CI status checks out considering I've been losing my mind over an issue with tsc

@Pasu4 Pasu4 requested a review from KTrain5169 November 27, 2025 12:15
@Pasu4 Pasu4 marked this pull request as ready for review November 27, 2025 12:16
@KTrain5169
Copy link
Member

Reviewing this in the browser is super inconvenient, I will submit a review once I get back home.

@KTrain5169 KTrain5169 added the meta Doesn't involve the main source code and doesn't concern the end user label Nov 28, 2025
// /** 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;
Copy link
Member

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.

Copy link
Member Author

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:

  • connected can be got with getConnectionStatus().
  • url would always be as configured in the settings. I assume the | null part of the type means that it would be null if not connected, which can be determined with getConnectionStatus().
  • Any error during connection would be logged to the output channel.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.
Copy link
Member

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)?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Doesn't involve the main source code and doesn't concern the end user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants