feat: Add DefaultEmbeddingFunction for local vector embeddings

- Added @chroma-core/default-embed dependency for local embeddings
- Updated ChromaSync to use DefaultEmbeddingFunction with collections
- Added isServerReachable() async method for reliable server detection
- Fixed start() to detect and reuse existing Chroma servers
- Updated build script to externalize native ONNX binaries
- Added runtime dependency to plugin/package.json

The embedding function uses all-MiniLM-L6-v2 model locally via ONNX,
eliminating need for external embedding API calls.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
bigphoot
2026-01-23 23:28:38 -08:00
committed by bigphoot
parent 70d6ac9daf
commit 2c304eafad
5 changed files with 62 additions and 9 deletions
+40 -1
View File
@@ -48,6 +48,7 @@ export class ChromaServerManager {
/**
* Start the Chroma HTTP server
* Spawns `npx chroma run` as a background process
* If a server is already running (from previous worker), reuses it
*/
async start(): Promise<void> {
if (this.ready || this.starting) {
@@ -57,6 +58,24 @@ export class ChromaServerManager {
});
return;
}
// Check if a server is already running (from previous worker or manual start)
try {
const response = await fetch(
`http://${this.config.host}:${this.config.port}/api/v2/heartbeat`
);
if (response.ok) {
logger.info('CHROMA_SERVER', 'Existing server detected, reusing', {
host: this.config.host,
port: this.config.port
});
this.ready = true;
return;
}
} catch {
// No server running, proceed to start one
}
this.starting = true;
// Cross-platform: use npx.cmd on Windows
@@ -159,9 +178,29 @@ export class ChromaServerManager {
/**
* Check if the server is running and ready
* Returns true if we manage the process OR if a server is responding
*/
isRunning(): boolean {
return this.ready && this.serverProcess !== null;
return this.ready;
}
/**
* Async check if server is running by pinging heartbeat
* Use this when you need to verify server is actually reachable
*/
async isServerReachable(): Promise<boolean> {
try {
const response = await fetch(
`http://${this.config.host}:${this.config.port}/api/v2/heartbeat`
);
if (response.ok) {
this.ready = true;
return true;
}
} catch {
// Server not reachable
}
return false;
}
/**