Repository navigation
feat(utility): create an utility for the ai assistant COMPASS-11269 - #8636
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The extracted runner calls an unsupported createServer() method that prevents MCP startup, while overlapping tool calls can invoke or disconnect the wrong provider through shared connection state.
4 open issues
What changed in this PR
Adds utility-process infrastructure for Compass’s AI assistant database tools, separating tool execution from renderer-side communication.
Changes:
- Introduces a tools host, request/response messaging, cancellation, and BSON-aware connection parameter transfer.
- Registers the assistant utility and adjusts utility bundling to share dependencies.
- Adds tests for messaging, tool hosting, serialization, and port lifecycle behavior.
| File | Description |
|---|---|
packages/compass/webpack.config.js |
Shares utility dependencies and disables utility coverage instrumentation. |
packages/compass/src/utilities/ai-assistant/index.spec.mts |
Tests utility logging, requests, and port closure. |
packages/compass/src/utilities/ai-assistant/index.mts |
Creates a tools host for each renderer port. |
packages/compass/src/main/application.ts |
Registers the AI assistant utility. |
packages/compass-utils/src/utility-process.ts |
Starts renderer-side utility ports. |
packages/compass-utils/src/utility-process.spec.ts |
Tests port transfer and startup. |
packages/compass-generative-ai/src/tools/infrastructure/tools-host.ts |
Hosts database tools and manages connections. |
packages/compass-generative-ai/src/tools/infrastructure/tools-host.spec.ts |
Tests tool listing, configuration, failures, and shutdown. |
packages/compass-generative-ai/src/tools/infrastructure/server.ts |
Dispatches requests and propagates cancellation. |
packages/compass-generative-ai/src/tools/infrastructure/rpc-client.ts |
Tracks requests, responses, and cancellation. |
packages/compass-generative-ai/src/tools/infrastructure/rpc-client.spec.ts |
Tests messaging and lifecycle behavior. |
packages/compass-generative-ai/src/tools/infrastructure/noop-metrics.ts |
Provides a no-op metrics implementation. |
packages/compass-generative-ai/src/tools/infrastructure/messages.ts |
Defines the tools messaging protocol. |
packages/compass-generative-ai/src/tools/infrastructure/in-memory-runner.ts |
Adds an in-memory MCP server runner. |
packages/compass-generative-ai/src/tools/infrastructure/connect-params.ts |
Restores BSON prototypes after port transfer. |
packages/compass-generative-ai/src/tools/infrastructure/connect-params.spec.ts |
Tests connection parameter serialization. |
packages/compass-generative-ai/package.json |
Exports the utility host and makes BSON a runtime dependency. |
package-lock.json |
Reflects the BSON dependency classification. |
Review effort: Balanced
386dbdd to
313b59b
Compare
b037746 to
14b5c88
Compare
| * Renderer-side client. `port` is the end of the channel returned by | ||
| * `openUtilityPort`. | ||
| */ | ||
| export function createRuntimeClient(port: MessagePort): { |
There was a problem hiding this comment.
Just a note for anyone else looking here: Edjan and I discussed how we're going to need to repeat this pattern for the other services too, particularly data service, it should be easy when I work on data-service to make one sharable implementation that just extends this a bit for AbortSignal support etc. (actually just saw this does support signal so maybe it'll just be extraction to a shared package!)
| for (const entryValue of Array.isArray(value) | ||
| ? value | ||
| : Object.values(value)) { | ||
| collectBsonValues(entryValue, found, seen); |
There was a problem hiding this comment.
Another thing for us to move somewhere shared later, we have the same logic in the shell parsing package, fine to have here for now


Description
Keeping up the work for using electron utilities, I'm creating an utility for the AI Assistant. There's a stacked PR actually making use of this utility.
I had some issues with the size of the bundled app. That's because of some imports which duplicate some code, so I tried to optimize the bundle as much as I could
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes