@arabold/docs-mcp-server 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/migrations/015-add-progress-pages-indexed.sql +10 -0
- package/db/migrations/016-add-content-url-to-pages.sql +14 -0
- package/dist/assets/index-CHvUVvbT.js +70 -0
- package/dist/assets/index-CHvUVvbT.js.map +1 -0
- package/dist/index.html +1 -1
- package/dist/index.js +1 -1
- package/dist/{main-BDg2etpq.js → main-BjEbd9LZ.js} +11060 -9728
- package/dist/main-BjEbd9LZ.js.map +1 -0
- package/dist/{utils-DizElQoU.js → utils-BP4qIXx8.js} +1 -1
- package/dist/{utils-DCwrdF5w.js → utils-uCqhR-rj.js} +814 -759
- package/dist/utils-uCqhR-rj.js.map +1 -0
- package/package.json +2 -2
- package/public/assets/index-CHvUVvbT.js +70 -0
- package/public/assets/index-CHvUVvbT.js.map +1 -0
- package/public/index.html +1 -1
- package/dist/assets/index-Jf4IQnpW.js +0 -70
- package/dist/assets/index-Jf4IQnpW.js.map +0 -1
- package/dist/main-BDg2etpq.js.map +0 -1
- package/dist/utils-DCwrdF5w.js.map +0 -1
- package/public/assets/index-Jf4IQnpW.js +0 -70
- package/public/assets/index-Jf4IQnpW.js.map +0 -1
|
@@ -10,858 +10,913 @@ import EventEmitter from "node:events";
|
|
|
10
10
|
import { chromium } from "playwright";
|
|
11
11
|
import { execSync } from "node:child_process";
|
|
12
12
|
import { createInterface } from "node:readline";
|
|
13
|
-
//#region src/
|
|
14
|
-
var projectRoot = null;
|
|
13
|
+
//#region src/store/embeddings/EmbeddingConfig.ts
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Shared embedding model configuration service.
|
|
16
|
+
* Provides synchronous parsing of embedding model configuration and known dimensions lookup.
|
|
17
|
+
* Eliminates code duplication between DocumentStore and telemetry systems.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* All model lookups are case-insensitive to handle variations in model name capitalization.
|
|
20
|
+
* Uses class-based approach to avoid mutable global state and improve testability.
|
|
21
21
|
*/
|
|
22
|
-
function getProjectRoot() {
|
|
23
|
-
if (projectRoot) return projectRoot;
|
|
24
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
25
|
-
let currentDir = path.dirname(currentFilePath);
|
|
26
|
-
while (true) {
|
|
27
|
-
const packageJsonPath = path.join(currentDir, "package.json");
|
|
28
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
29
|
-
projectRoot = currentDir;
|
|
30
|
-
return currentDir;
|
|
31
|
-
}
|
|
32
|
-
const parentDir = path.dirname(currentDir);
|
|
33
|
-
if (parentDir === currentDir) throw new Error("Could not find project root containing package.json.");
|
|
34
|
-
currentDir = parentDir;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
22
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* 2. Legacy .store directory in project root (if exists)
|
|
41
|
-
* 3. Standard system data directory using env-paths
|
|
23
|
+
* The complete set of provider prefixes recognized in a model specification.
|
|
24
|
+
* Anything else before the first colon is part of the model name itself.
|
|
42
25
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const projectRoot = getProjectRoot();
|
|
51
|
-
const oldDbDir = path.join(projectRoot, ".store");
|
|
52
|
-
const oldDbPath = path.join(oldDbDir, "documents.db");
|
|
53
|
-
if (fs.existsSync(oldDbPath)) dbDir = oldDbDir;
|
|
54
|
-
else dbDir = envPaths("docs-mcp-server", { suffix: "" }).data;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
fs.mkdirSync(dbDir, { recursive: true });
|
|
58
|
-
} catch (error) {
|
|
59
|
-
logger.warn(`⚠️ Failed to create database directory ${dbDir}: ${error}`);
|
|
60
|
-
}
|
|
61
|
-
return dbDir;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/telemetry/TelemetryConfig.ts
|
|
65
|
-
/**
|
|
66
|
-
* Telemetry configuration management for enabling/disabling analytics collection.
|
|
67
|
-
* Handles CLI flags, environment variables, and default settings.
|
|
68
|
-
*/
|
|
69
|
-
var TelemetryConfig = class TelemetryConfig {
|
|
70
|
-
static instance;
|
|
71
|
-
enabled = true;
|
|
72
|
-
constructor() {}
|
|
73
|
-
isEnabled() {
|
|
74
|
-
return this.enabled;
|
|
75
|
-
}
|
|
76
|
-
setEnabled(enabled) {
|
|
77
|
-
this.enabled = enabled;
|
|
78
|
-
}
|
|
79
|
-
static getInstance() {
|
|
80
|
-
if (!TelemetryConfig.instance) TelemetryConfig.instance = new TelemetryConfig();
|
|
81
|
-
return TelemetryConfig.instance;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Generate or retrieve a persistent installation identifier.
|
|
86
|
-
* Creates a UUID and stores it in a file in the user data directory.
|
|
87
|
-
* Supports custom store path override for Docker deployments.
|
|
88
|
-
* This ensures truly unique identification that persists across runs.
|
|
89
|
-
*/
|
|
90
|
-
function generateInstallationId(storePath) {
|
|
91
|
-
try {
|
|
92
|
-
const dataDir = resolveStorePath(storePath);
|
|
93
|
-
const installationIdPath = path.join(dataDir, "installation.id");
|
|
94
|
-
if (fs.existsSync(installationIdPath)) {
|
|
95
|
-
const existingId = fs.readFileSync(installationIdPath, "utf8").trim();
|
|
96
|
-
if (existingId) return existingId;
|
|
97
|
-
}
|
|
98
|
-
const newId = randomUUID();
|
|
99
|
-
fs.mkdirSync(dataDir, { recursive: true });
|
|
100
|
-
fs.writeFileSync(installationIdPath, newId, "utf8");
|
|
101
|
-
return newId;
|
|
102
|
-
} catch {
|
|
103
|
-
return randomUUID();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Check if telemetry should be enabled based on environment and CLI flags.
|
|
108
|
-
*/
|
|
109
|
-
function shouldEnableTelemetry() {
|
|
110
|
-
return TelemetryConfig.getInstance().isEnabled();
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/events/types.ts
|
|
114
|
-
/**
|
|
115
|
-
* Event type enum used by the EventBusService.
|
|
116
|
-
* These are the internal event identifiers.
|
|
117
|
-
*/
|
|
118
|
-
var EventType = /* @__PURE__ */ function(EventType) {
|
|
119
|
-
EventType["JOB_STATUS_CHANGE"] = "JOB_STATUS_CHANGE";
|
|
120
|
-
EventType["JOB_PROGRESS"] = "JOB_PROGRESS";
|
|
121
|
-
EventType["LIBRARY_CHANGE"] = "LIBRARY_CHANGE";
|
|
122
|
-
EventType["JOB_LIST_CHANGE"] = "JOB_LIST_CHANGE";
|
|
123
|
-
return EventType;
|
|
124
|
-
}({});
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/pipeline/types.ts
|
|
127
|
-
/**
|
|
128
|
-
* Represents the possible states of a pipeline job.
|
|
129
|
-
*/
|
|
130
|
-
var PipelineJobStatus = /* @__PURE__ */ function(PipelineJobStatus) {
|
|
131
|
-
PipelineJobStatus["QUEUED"] = "queued";
|
|
132
|
-
PipelineJobStatus["RUNNING"] = "running";
|
|
133
|
-
PipelineJobStatus["COMPLETED"] = "completed";
|
|
134
|
-
PipelineJobStatus["FAILED"] = "failed";
|
|
135
|
-
PipelineJobStatus["CANCELLING"] = "cancelling";
|
|
136
|
-
PipelineJobStatus["CANCELLED"] = "cancelled";
|
|
137
|
-
return PipelineJobStatus;
|
|
138
|
-
}({});
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/telemetry/postHogClient.ts
|
|
141
|
-
/**
|
|
142
|
-
* PostHog client wrapper for telemetry events.
|
|
143
|
-
* Handles PostHog SDK integration and event capture with privacy-first configuration.
|
|
144
|
-
* Automatically converts camelCase property names to snake_case for PostHog compatibility.
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* Convert camelCase string to snake_case
|
|
148
|
-
* Specifically designed for PostHog property name conversion
|
|
149
|
-
*/
|
|
150
|
-
function camelToSnakeCase(str) {
|
|
151
|
-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Recursively convert object keys from camelCase to snake_case
|
|
155
|
-
* Handles nested objects and arrays while preserving values
|
|
26
|
+
* This list is normative rather than descriptive: it decides which prefixes claim
|
|
27
|
+
* the provider slot, so adding an entry changes how existing specifications parse.
|
|
28
|
+
* A model literally named `<new-provider>:<tag>` served by an OpenAI-compatible
|
|
29
|
+
* endpoint would start resolving to the new provider, breaking that configuration
|
|
30
|
+
* on upgrade. Call provider additions out in the release notes.
|
|
31
|
+
*
|
|
32
|
+
* `EmbeddingProvider` is derived from this array so the two cannot drift apart.
|
|
156
33
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
34
|
+
var SUPPORTED_PROVIDERS = [
|
|
35
|
+
"openai",
|
|
36
|
+
"vertex",
|
|
37
|
+
"gemini",
|
|
38
|
+
"aws",
|
|
39
|
+
"microsoft"
|
|
40
|
+
];
|
|
167
41
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
42
|
+
* Split a model specification into its provider prefix and model name.
|
|
43
|
+
*
|
|
44
|
+
* Only a prefix that names a supported provider is treated as a provider, matched
|
|
45
|
+
* case-insensitively and resolved to its canonical lowercase form. Every other
|
|
46
|
+
* specification is an OpenAI-compatible model name, which keeps names that carry a
|
|
47
|
+
* tag or quantization suffix intact (e.g. "nomic-embed-text:latest" or
|
|
48
|
+
* "second-state/jina-embeddings-v3-GGUF:Q4_K_M").
|
|
49
|
+
*
|
|
50
|
+
* @param spec The full model specification.
|
|
51
|
+
* @returns The resolved provider and model name.
|
|
170
52
|
*/
|
|
171
|
-
function
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
result.$app_version = properties.appVersion;
|
|
183
|
-
delete result.appVersion;
|
|
184
|
-
}
|
|
185
|
-
return result;
|
|
53
|
+
function splitModelSpec(spec) {
|
|
54
|
+
const colonIndex = spec.indexOf(":");
|
|
55
|
+
const prefix = spec.substring(0, colonIndex).toLowerCase();
|
|
56
|
+
const provider = colonIndex === -1 ? void 0 : SUPPORTED_PROVIDERS.find((name) => name === prefix);
|
|
57
|
+
return provider ? {
|
|
58
|
+
provider,
|
|
59
|
+
model: spec.substring(colonIndex + 1)
|
|
60
|
+
} : {
|
|
61
|
+
provider: "openai",
|
|
62
|
+
model: spec
|
|
63
|
+
};
|
|
186
64
|
}
|
|
187
65
|
/**
|
|
188
|
-
*
|
|
66
|
+
* Embedding configuration manager that handles model parsing and dimension caching.
|
|
67
|
+
* Encapsulates state to avoid global variable issues and improve testability.
|
|
189
68
|
*/
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
enabled;
|
|
193
|
-
static CONFIG = {
|
|
194
|
-
host: "https://app.posthog.com",
|
|
195
|
-
flushAt: 20,
|
|
196
|
-
flushInterval: 1e4,
|
|
197
|
-
disableGeoip: true,
|
|
198
|
-
disableSessionRecording: true,
|
|
199
|
-
disableSurveys: true,
|
|
200
|
-
persistence: "memory"
|
|
201
|
-
};
|
|
202
|
-
constructor(enabled) {
|
|
203
|
-
this.enabled = enabled;
|
|
204
|
-
if (!this.enabled) return;
|
|
205
|
-
try {
|
|
206
|
-
this.client = new PostHog("phc_g7pXZZdUiAQXdnwUANjloQWMvO0amEDTBaeDSWgXgrQ", {
|
|
207
|
-
host: PostHogClient.CONFIG.host,
|
|
208
|
-
flushAt: PostHogClient.CONFIG.flushAt,
|
|
209
|
-
flushInterval: PostHogClient.CONFIG.flushInterval,
|
|
210
|
-
disableGeoip: PostHogClient.CONFIG.disableGeoip
|
|
211
|
-
});
|
|
212
|
-
logger.debug("PostHog client initialized");
|
|
213
|
-
} catch (error) {
|
|
214
|
-
logger.debug(`PostHog initialization failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
215
|
-
this.enabled = false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
69
|
+
var EmbeddingConfig = class EmbeddingConfig {
|
|
70
|
+
static instance = null;
|
|
218
71
|
/**
|
|
219
|
-
*
|
|
72
|
+
* Get the singleton instance of EmbeddingConfig.
|
|
73
|
+
* Creates the instance if it doesn't exist.
|
|
220
74
|
*/
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
const snakeCaseProperties = convertPropertiesToSnakeCase(addPostHogStandardProperties(properties));
|
|
225
|
-
this.client.capture({
|
|
226
|
-
distinctId,
|
|
227
|
-
event,
|
|
228
|
-
properties: snakeCaseProperties
|
|
229
|
-
});
|
|
230
|
-
logger.debug(`PostHog event captured: ${event}`);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
logger.debug(`PostHog capture error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
233
|
-
}
|
|
75
|
+
static getInstance() {
|
|
76
|
+
if (EmbeddingConfig.instance === null) EmbeddingConfig.instance = new EmbeddingConfig();
|
|
77
|
+
return EmbeddingConfig.instance;
|
|
234
78
|
}
|
|
235
79
|
/**
|
|
236
|
-
*
|
|
80
|
+
* Reset the singleton instance (useful for testing).
|
|
237
81
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
const snakeCaseProperties = convertPropertiesToSnakeCase(addPostHogStandardProperties(properties || {}));
|
|
242
|
-
this.client.captureException({
|
|
243
|
-
error,
|
|
244
|
-
distinctId,
|
|
245
|
-
properties: snakeCaseProperties
|
|
246
|
-
});
|
|
247
|
-
logger.debug(`PostHog exception captured: ${error.constructor.name}`);
|
|
248
|
-
} catch (captureError) {
|
|
249
|
-
logger.debug(`PostHog captureException error: ${captureError instanceof Error ? captureError.message : "Unknown error"}`);
|
|
250
|
-
}
|
|
82
|
+
static resetInstance() {
|
|
83
|
+
EmbeddingConfig.instance = null;
|
|
251
84
|
}
|
|
252
85
|
/**
|
|
253
|
-
*
|
|
86
|
+
* Known dimensions for common embedding models.
|
|
87
|
+
* This avoids expensive API calls for dimension detection in telemetry.
|
|
88
|
+
*
|
|
89
|
+
* Note: The "openai" provider also supports OpenAI-compatible APIs like:
|
|
90
|
+
* - Ollama (local models)
|
|
91
|
+
* - LMStudio (local models)
|
|
92
|
+
* - Any service implementing OpenAI's embedding API
|
|
254
93
|
*/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
94
|
+
knownModelDimensions = {
|
|
95
|
+
"text-embedding-3-small": 1536,
|
|
96
|
+
"text-embedding-3-large": 3072,
|
|
97
|
+
"text-embedding-ada-002": 1536,
|
|
98
|
+
"text-embedding-004": 768,
|
|
99
|
+
"text-embedding-005": 768,
|
|
100
|
+
"textembedding-gecko@003": 768,
|
|
101
|
+
"textembedding-gecko@002": 768,
|
|
102
|
+
"textembedding-gecko@001": 768,
|
|
103
|
+
"text-embedding-preview-0409": 768,
|
|
104
|
+
"embedding-001": 768,
|
|
105
|
+
"gemini-embedding-2-preview": 3072,
|
|
106
|
+
"amazon.titan-embed-text-v1": 1536,
|
|
107
|
+
"amazon.titan-embed-text-v2:0": 1024,
|
|
108
|
+
"amazon.titan-embed-image-v1": 1024,
|
|
109
|
+
"cohere.embed-english-v3": 1024,
|
|
110
|
+
"cohere.embed-multilingual-v3": 1024,
|
|
111
|
+
"Cohere/Cohere-embed-v4.0": 1536,
|
|
112
|
+
"embed-v4.0": 1536,
|
|
113
|
+
"intfloat/multilingual-e5-large": 1024,
|
|
114
|
+
"multilingual-e5-large": 1024,
|
|
115
|
+
"text-embedding-multilingual-e5-large": 1024,
|
|
116
|
+
"sentence-transformers/all-MiniLM-L6-v2": 384,
|
|
117
|
+
"gemini-embedding-001": 3072,
|
|
118
|
+
"Qwen/Qwen3-Embedding-8B": 4096,
|
|
119
|
+
"Qwen/Qwen3-Embedding-4B": 2560,
|
|
120
|
+
"Qwen/Qwen3-Embedding-0.6B": 1024,
|
|
121
|
+
"Linq-AI-Research/Linq-Embed-Mistral": 4096,
|
|
122
|
+
"Alibaba-NLP/gte-Qwen2-7B-instruct": 3584,
|
|
123
|
+
"intfloat/multilingual-e5-large-instruct": 1024,
|
|
124
|
+
"Salesforce/SFR-Embedding-Mistral": 4096,
|
|
125
|
+
"text-multilingual-embedding-002": 768,
|
|
126
|
+
"GritLM/GritLM-7B": 4096,
|
|
127
|
+
"GritLM/GritLM-8x7B": 4096,
|
|
128
|
+
"intfloat/e5-mistral-7b-instruct": 4096,
|
|
129
|
+
"Cohere/Cohere-embed-multilingual-v3.0": 1024,
|
|
130
|
+
"Alibaba-NLP/gte-Qwen2-1.5B-instruct": 8960,
|
|
131
|
+
"Lajavaness/bilingual-embedding-large": 1024,
|
|
132
|
+
"Salesforce/SFR-Embedding-2_R": 4096,
|
|
133
|
+
"NovaSearch/stella_en_1.5B_v5": 8960,
|
|
134
|
+
"NovaSearch/jasper_en_vision_language_v1": 8960,
|
|
135
|
+
"nvidia/NV-Embed-v2": 4096,
|
|
136
|
+
"OrdalieTech/Solon-embeddings-large-0.1": 1024,
|
|
137
|
+
"BAAI/bge-m3": 1024,
|
|
138
|
+
"HIT-TMG/KaLM-embedding-multilingual-mini-v1": 896,
|
|
139
|
+
"jinaai/jina-embeddings-v3": 1024,
|
|
140
|
+
"Alibaba-NLP/gte-multilingual-base": 768,
|
|
141
|
+
"Lajavaness/bilingual-embedding-base": 768,
|
|
142
|
+
"HIT-TMG/KaLM-embedding-multilingual-mini-instruct-v1": 896,
|
|
143
|
+
"nvidia/NV-Embed-v1": 4096,
|
|
144
|
+
"Cohere/Cohere-embed-multilingual-light-v3.0": 384,
|
|
145
|
+
"manu/bge-m3-custom-fr": 1024,
|
|
146
|
+
"Lajavaness/bilingual-embedding-small": 384,
|
|
147
|
+
"Snowflake/snowflake-arctic-embed-l-v2.0": 1024,
|
|
148
|
+
"intfloat/multilingual-e5-base": 768,
|
|
149
|
+
"voyage-3-lite": 512,
|
|
150
|
+
"voyage-3": 1024,
|
|
151
|
+
"voyage-3-large": 1024,
|
|
152
|
+
"voyage-3.5": 1024,
|
|
153
|
+
"voyage-4": 1024,
|
|
154
|
+
"voyage-4-large": 1024,
|
|
155
|
+
"voyage-4-lite": 1024,
|
|
156
|
+
"voyage-code-3": 1024,
|
|
157
|
+
"intfloat/multilingual-e5-small": 384,
|
|
158
|
+
"Alibaba-NLP/gte-Qwen1.5-7B-instruct": 4096,
|
|
159
|
+
"Snowflake/snowflake-arctic-embed-m-v2.0": 768,
|
|
160
|
+
"deepvk/USER-bge-m3": 1024,
|
|
161
|
+
"Cohere/Cohere-embed-english-v3.0": 1024,
|
|
162
|
+
"Omartificial-Intelligence-Space/Arabic-labse-Matryoshka": 768,
|
|
163
|
+
"ibm-granite/granite-embedding-278m-multilingual": 768,
|
|
164
|
+
"NovaSearch/stella_en_400M_v5": 4096,
|
|
165
|
+
"omarelshehy/arabic-english-sts-matryoshka": 1024,
|
|
166
|
+
"sentence-transformers/paraphrase-multilingual-mpnet-base-v2": 768,
|
|
167
|
+
"Omartificial-Intelligence-Space/Arabic-all-nli-triplet-Matryoshka": 768,
|
|
168
|
+
"Haon-Chen/speed-embedding-7b-instruct": 4096,
|
|
169
|
+
"sentence-transformers/LaBSE": 768,
|
|
170
|
+
"WhereIsAI/UAE-Large-V1": 1024,
|
|
171
|
+
"ibm-granite/granite-embedding-107m-multilingual": 384,
|
|
172
|
+
"mixedbread-ai/mxbai-embed-large-v1": 1024,
|
|
173
|
+
"intfloat/e5-large-v2": 1024,
|
|
174
|
+
"avsolatorio/GIST-large-Embedding-v0": 1024,
|
|
175
|
+
"sdadas/mmlw-e5-large": 1024,
|
|
176
|
+
"nomic-ai/nomic-embed-text-v1": 768,
|
|
177
|
+
"nomic-embed-text-v1": 768,
|
|
178
|
+
"nomic-ai/nomic-embed-text-v1-ablated": 768,
|
|
179
|
+
"nomic-ai/nomic-embed-text-v2-moe": 768,
|
|
180
|
+
"nomic-ai/modernbert-embed-base": 768,
|
|
181
|
+
"nomic-ai/nomic-embed-code": 3584,
|
|
182
|
+
"intfloat/e5-base-v2": 768,
|
|
183
|
+
"BAAI/bge-large-en-v1.5": 1024,
|
|
184
|
+
"intfloat/e5-large": 1024,
|
|
185
|
+
"Omartificial-Intelligence-Space/Arabic-MiniLM-L12-v2-all-nli-triplet": 384,
|
|
186
|
+
"Cohere/Cohere-embed-english-light-v3.0": 384,
|
|
187
|
+
"sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2": 768,
|
|
188
|
+
"Gameselo/STS-multilingual-mpnet-base-v2": 768,
|
|
189
|
+
"thenlper/gte-large": 1024,
|
|
190
|
+
"avsolatorio/GIST-Embedding-v0": 768,
|
|
191
|
+
"nomic-ai/nomic-embed-text-v1-unsupervised": 768,
|
|
192
|
+
"infgrad/stella-base-en-v2": 768,
|
|
193
|
+
"avsolatorio/NoInstruct-small-Embedding-v0": 384,
|
|
194
|
+
"dwzhu/e5-base-4k": 768,
|
|
195
|
+
"sdadas/mmlw-e5-base": 768,
|
|
196
|
+
"voyage-multilingual-2": 1024,
|
|
197
|
+
"McGill-NLP/LLM2Vec-Mistral-7B-Instruct-v2-mntp-supervised": 4096,
|
|
198
|
+
"BAAI/bge-base-en-v1.5": 768,
|
|
199
|
+
"avsolatorio/GIST-small-Embedding-v0": 384,
|
|
200
|
+
"sdadas/mmlw-roberta-large": 1024,
|
|
201
|
+
"nomic-ai/nomic-embed-text-v1.5": 768,
|
|
202
|
+
"nomic-embed-text-v1.5": 768,
|
|
203
|
+
"text-embedding-nomic-embed-text-v1.5": 768,
|
|
204
|
+
"minishlab/potion-multilingual-128M": 256,
|
|
205
|
+
"shibing624/text2vec-base-multilingual": 384,
|
|
206
|
+
"thenlper/gte-base": 768,
|
|
207
|
+
"intfloat/e5-small-v2": 384,
|
|
208
|
+
"intfloat/e5-base": 768,
|
|
209
|
+
"sentence-transformers/static-similarity-mrl-multilingual-v1": 1024,
|
|
210
|
+
"manu/sentence_croissant_alpha_v0.3": 2048,
|
|
211
|
+
"BAAI/bge-small-en-v1.5": 512,
|
|
212
|
+
"thenlper/gte-small": 384,
|
|
213
|
+
"sdadas/mmlw-e5-small": 384,
|
|
214
|
+
"manu/sentence_croissant_alpha_v0.4": 2048,
|
|
215
|
+
"manu/sentence_croissant_alpha_v0.2": 2048,
|
|
216
|
+
"abhinand/MedEmbed-small-v0.1": 384,
|
|
217
|
+
"ibm-granite/granite-embedding-125m-english": 768,
|
|
218
|
+
"intfloat/e5-small": 384,
|
|
219
|
+
"voyage-large-2-instruct": 1024,
|
|
220
|
+
"sdadas/mmlw-roberta-base": 768,
|
|
221
|
+
"Snowflake/snowflake-arctic-embed-l": 1024,
|
|
222
|
+
"Mihaiii/Ivysaur": 384,
|
|
223
|
+
"Snowflake/snowflake-arctic-embed-m-long": 768,
|
|
224
|
+
"bigscience/sgpt-bloom-7b1-msmarco": 4096,
|
|
225
|
+
"avsolatorio/GIST-all-MiniLM-L6-v2": 384,
|
|
226
|
+
"sergeyzh/LaBSE-ru-turbo": 768,
|
|
227
|
+
"sentence-transformers/all-mpnet-base-v2": 768,
|
|
228
|
+
"Snowflake/snowflake-arctic-embed-m": 768,
|
|
229
|
+
"Snowflake/snowflake-arctic-embed-s": 384,
|
|
230
|
+
"sentence-transformers/all-MiniLM-L12-v2": 384,
|
|
231
|
+
"Mihaiii/gte-micro-v4": 384,
|
|
232
|
+
"Snowflake/snowflake-arctic-embed-m-v1.5": 768,
|
|
233
|
+
"cointegrated/LaBSE-en-ru": 768,
|
|
234
|
+
"Mihaiii/Bulbasaur": 384,
|
|
235
|
+
"ibm-granite/granite-embedding-30m-english": 384,
|
|
236
|
+
"deepfile/embedder-100p": 768,
|
|
237
|
+
"Jaume/gemma-2b-embeddings": 2048,
|
|
238
|
+
"OrlikB/KartonBERT-USE-base-v1": 768,
|
|
239
|
+
"izhx/udever-bloom-7b1": 4096,
|
|
240
|
+
"izhx/udever-bloom-1b1": 1024,
|
|
241
|
+
"brahmairesearch/slx-v0.1": 384,
|
|
242
|
+
"Mihaiii/Wartortle": 384,
|
|
243
|
+
"izhx/udever-bloom-3b": 2048,
|
|
244
|
+
"deepvk/USER-base": 768,
|
|
245
|
+
"ai-forever/ru-en-RoSBERTa": 1024,
|
|
246
|
+
"McGill-NLP/LLM2Vec-Mistral-7B-Instruct-v2-mntp-unsup-simcse": 4096,
|
|
247
|
+
"Mihaiii/Venusaur": 384,
|
|
248
|
+
"Snowflake/snowflake-arctic-embed-xs": 384,
|
|
249
|
+
"jinaai/jina-embedding-b-en-v1": 768,
|
|
250
|
+
"Mihaiii/gte-micro": 384,
|
|
251
|
+
"aari1995/German_Semantic_STS_V2": 1024,
|
|
252
|
+
"Mihaiii/Squirtle": 384,
|
|
253
|
+
"OrlikB/st-polish-kartonberta-base-alpha-v1": 768,
|
|
254
|
+
"sergeyzh/rubert-tiny-turbo": 312,
|
|
255
|
+
"minishlab/potion-base-8M": 256,
|
|
256
|
+
"minishlab/M2V_base_glove_subword": 256,
|
|
257
|
+
"jinaai/jina-embedding-s-en-v1": 512,
|
|
258
|
+
"minishlab/potion-base-4M": 128,
|
|
259
|
+
"minishlab/M2V_base_output": 256,
|
|
260
|
+
"DeepPavlov/rubert-base-cased-sentence": 768,
|
|
261
|
+
"jinaai/jina-embeddings-v2-small-en": 512,
|
|
262
|
+
"cointegrated/rubert-tiny2": 312,
|
|
263
|
+
"minishlab/M2V_base_glove": 256,
|
|
264
|
+
"cointegrated/rubert-tiny": 312,
|
|
265
|
+
"silma-ai/silma-embeddding-matryoshka-v0.1": 768,
|
|
266
|
+
"DeepPavlov/rubert-base-cased": 768,
|
|
267
|
+
"Omartificial-Intelligence-Space/Arabic-mpnet-base-all-nli-triplet": 768,
|
|
268
|
+
"izhx/udever-bloom-560m": 1024,
|
|
269
|
+
"minishlab/potion-base-2M": 64,
|
|
270
|
+
"DeepPavlov/distilrubert-small-cased-conversational": 768,
|
|
271
|
+
"consciousAI/cai-lunaris-text-embeddings": 1024,
|
|
272
|
+
"deepvk/deberta-v1-base": 768,
|
|
273
|
+
"Omartificial-Intelligence-Space/Arabert-all-nli-triplet-Matryoshka": 768,
|
|
274
|
+
"Omartificial-Intelligence-Space/Marbert-all-nli-triplet-Matryoshka": 768,
|
|
275
|
+
"ai-forever/sbert_large_mt_nlu_ru": 1024,
|
|
276
|
+
"ai-forever/sbert_large_nlu_ru": 1024,
|
|
277
|
+
"malenia1/ternary-weight-embedding": 1024,
|
|
278
|
+
"jinaai/jina-embeddings-v2-base-en": 768,
|
|
279
|
+
"VPLabs/SearchMap_Preview": 4096,
|
|
280
|
+
"Hum-Works/lodestone-base-4096-v1": 768,
|
|
281
|
+
"jinaai/jina-embeddings-v4": 2048
|
|
282
|
+
};
|
|
283
|
+
runtimeDetectedDimensionModels = /* @__PURE__ */ new Set([
|
|
284
|
+
"novasearch/stella_en_1.5b_v5",
|
|
285
|
+
"stella_en_1.5b_v5",
|
|
286
|
+
"novasearch/stella_en_400m_v5",
|
|
287
|
+
"dunzhang/stella_en_400m_v5",
|
|
288
|
+
"stella_en_400m_v5",
|
|
289
|
+
"novasearch/jasper_en_vision_language_v1",
|
|
290
|
+
"jasper_en_vision_language_v1"
|
|
291
|
+
]);
|
|
292
|
+
/**
|
|
293
|
+
* Lowercase lookup map for case-insensitive model dimension queries.
|
|
294
|
+
* Built lazily from knownModelDimensions to ensure consistency.
|
|
265
295
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
296
|
+
modelLookup;
|
|
297
|
+
constructor() {
|
|
298
|
+
this.modelLookup = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const [model, dimensions] of Object.entries(this.knownModelDimensions)) this.modelLookup.set(model.toLowerCase(), dimensions);
|
|
268
300
|
}
|
|
269
|
-
};
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/telemetry/telemetry.ts
|
|
272
|
-
/**
|
|
273
|
-
* Telemtry wrapper for privacy-first telemetry using PostHog.
|
|
274
|
-
* Provides global context and automatic data sanitization.
|
|
275
|
-
*
|
|
276
|
-
* Architecture:
|
|
277
|
-
* - PostHogClient: Handles PostHog SDK integration and event capture
|
|
278
|
-
* - Telemtry: High-level coordinator providing public API with global context
|
|
279
|
-
*/
|
|
280
|
-
/**
|
|
281
|
-
* Event types for structured telemetry tracking
|
|
282
|
-
*/
|
|
283
|
-
var TelemetryEvent = /* @__PURE__ */ function(TelemetryEvent) {
|
|
284
|
-
TelemetryEvent["APP_STARTED"] = "app_started";
|
|
285
|
-
TelemetryEvent["APP_SHUTDOWN"] = "app_shutdown";
|
|
286
|
-
TelemetryEvent["CLI_COMMAND"] = "cli_command";
|
|
287
|
-
TelemetryEvent["TOOL_USED"] = "tool_used";
|
|
288
|
-
TelemetryEvent["PIPELINE_JOB_STARTED"] = "pipeline_job_started";
|
|
289
|
-
TelemetryEvent["PIPELINE_JOB_COMPLETED"] = "pipeline_job_completed";
|
|
290
|
-
TelemetryEvent["PIPELINE_JOB_FAILED"] = "pipeline_job_failed";
|
|
291
|
-
return TelemetryEvent;
|
|
292
|
-
}({});
|
|
293
|
-
/**
|
|
294
|
-
* Main telemetry class providing privacy-first telemetry
|
|
295
|
-
*/
|
|
296
|
-
var Telemetry = class Telemetry {
|
|
297
|
-
postHogClient;
|
|
298
|
-
enabled;
|
|
299
|
-
distinctId;
|
|
300
|
-
globalContext = {};
|
|
301
301
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
302
|
+
* Build the lookup keys to try for a model name, most specific first:
|
|
303
|
+
* the name itself, then with the namespace dropped, the tag dropped, and both.
|
|
304
|
+
*
|
|
305
|
+
* Dropping a trailing tag lets a quantized or tagged variant reuse the base
|
|
306
|
+
* model's dimensions (e.g. "nomic-ai/nomic-embed-text-v2-moe:latest"), which
|
|
307
|
+
* quantization does not change. Exact matches are tried first, so names whose
|
|
308
|
+
* own identifier contains a colon (e.g. "amazon.titan-embed-text-v2:0") still
|
|
309
|
+
* resolve to their own entry.
|
|
304
310
|
*/
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
dimensionLookupKeys(normalized) {
|
|
312
|
+
const slashIndex = normalized.lastIndexOf("/");
|
|
313
|
+
const withoutNamespace = slashIndex > -1 ? normalized.substring(slashIndex + 1) : void 0;
|
|
314
|
+
const bases = withoutNamespace ? [normalized, withoutNamespace] : [normalized];
|
|
315
|
+
const withoutTag = (key) => {
|
|
316
|
+
const colonIndex = key.lastIndexOf(":");
|
|
317
|
+
return colonIndex > 0 ? [key.substring(0, colonIndex)] : [];
|
|
318
|
+
};
|
|
319
|
+
return [...bases, ...bases.flatMap(withoutTag)];
|
|
320
|
+
}
|
|
321
|
+
findKnownDimension(model) {
|
|
322
|
+
for (const key of this.dimensionLookupKeys(model.toLowerCase())) {
|
|
323
|
+
if (this.runtimeDetectedDimensionModels.has(key)) return null;
|
|
324
|
+
const dimensions = this.modelLookup?.get(key);
|
|
325
|
+
if (dimensions !== void 0) return dimensions;
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
313
328
|
}
|
|
314
329
|
/**
|
|
315
|
-
*
|
|
330
|
+
* Parse embedding model configuration from a provided model specification.
|
|
331
|
+
* This is a synchronous operation that extracts provider, model, and known dimensions.
|
|
332
|
+
*
|
|
333
|
+
* Supports various providers:
|
|
334
|
+
* - openai: OpenAI models and OpenAI-compatible APIs (Ollama, LMStudio, etc.)
|
|
335
|
+
* - vertex: Google Cloud Vertex AI
|
|
336
|
+
* - gemini: Google Generative AI
|
|
337
|
+
* - aws: AWS Bedrock models
|
|
338
|
+
* - microsoft: Azure OpenAI
|
|
339
|
+
*
|
|
340
|
+
* @param modelSpec Model specification (e.g., "openai:text-embedding-3-small"), defaults to "text-embedding-3-small"
|
|
341
|
+
* @returns Parsed embedding model configuration
|
|
316
342
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
343
|
+
parse(modelSpec) {
|
|
344
|
+
const spec = normalizeEnvValue(modelSpec || "text-embedding-3-small");
|
|
345
|
+
const { provider, model } = splitModelSpec(spec);
|
|
346
|
+
return {
|
|
347
|
+
provider,
|
|
348
|
+
model,
|
|
349
|
+
dimensions: this.findKnownDimension(model),
|
|
350
|
+
modelSpec: spec
|
|
351
|
+
};
|
|
321
352
|
}
|
|
322
353
|
/**
|
|
323
|
-
*
|
|
354
|
+
* Get the known dimensions for a specific model.
|
|
355
|
+
* Returns null if the model dimensions are not known.
|
|
356
|
+
* Uses case-insensitive lookup.
|
|
357
|
+
*
|
|
358
|
+
* @param model The model name (e.g., "text-embedding-3-small")
|
|
359
|
+
* @returns Known dimensions or null
|
|
324
360
|
*/
|
|
325
|
-
|
|
326
|
-
this.
|
|
361
|
+
getKnownDimensions(model) {
|
|
362
|
+
return this.findKnownDimension(model);
|
|
327
363
|
}
|
|
328
364
|
/**
|
|
329
|
-
*
|
|
365
|
+
* Add or update known dimensions for a model.
|
|
366
|
+
* This can be used to cache discovered dimensions.
|
|
367
|
+
* Stores both original case and lowercase for consistent lookup.
|
|
368
|
+
*
|
|
369
|
+
* @param model The model name
|
|
370
|
+
* @param dimensions The dimensions to cache
|
|
330
371
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
track(event, properties = {}) {
|
|
335
|
-
if (!this.enabled) return;
|
|
336
|
-
const enrichedProperties = {
|
|
337
|
-
...this.globalContext,
|
|
338
|
-
...properties,
|
|
339
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
340
|
-
};
|
|
341
|
-
logger.debug(`Tracking event: ${event}`);
|
|
342
|
-
this.postHogClient.capture(this.distinctId, event, enrichedProperties);
|
|
372
|
+
setKnownDimensions(model, dimensions) {
|
|
373
|
+
this.knownModelDimensions[model] = dimensions;
|
|
374
|
+
if (this.modelLookup) this.modelLookup.set(model.toLowerCase(), dimensions);
|
|
343
375
|
}
|
|
344
376
|
/**
|
|
345
|
-
*
|
|
377
|
+
* Static method to parse embedding model configuration using the singleton instance.
|
|
378
|
+
* This maintains backward compatibility while using the class-based approach.
|
|
346
379
|
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const enrichedProperties = {
|
|
350
|
-
...this.globalContext,
|
|
351
|
-
...properties,
|
|
352
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
353
|
-
};
|
|
354
|
-
logger.debug(`Capturing exception: ${error instanceof Error ? error.message : String(error)}`);
|
|
355
|
-
this.postHogClient.captureException(this.distinctId, error instanceof Error ? error : new Error(String(error)), enrichedProperties);
|
|
380
|
+
static parseEmbeddingConfig(modelSpec) {
|
|
381
|
+
return EmbeddingConfig.getInstance().parse(modelSpec);
|
|
356
382
|
}
|
|
357
383
|
/**
|
|
358
|
-
*
|
|
384
|
+
* Static method to get known model dimensions using the singleton instance.
|
|
385
|
+
* This maintains backward compatibility while using the class-based approach.
|
|
359
386
|
*/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
await this.postHogClient.shutdown();
|
|
387
|
+
static getKnownModelDimensions(model) {
|
|
388
|
+
return EmbeddingConfig.getInstance().getKnownDimensions(model);
|
|
363
389
|
}
|
|
364
390
|
/**
|
|
365
|
-
*
|
|
391
|
+
* Static method to set known model dimensions using the singleton instance.
|
|
392
|
+
* This maintains backward compatibility while using the class-based approach.
|
|
366
393
|
*/
|
|
394
|
+
static setKnownModelDimensions(model, dimensions) {
|
|
395
|
+
EmbeddingConfig.getInstance().setKnownDimensions(model, dimensions);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/utils/paths.ts
|
|
400
|
+
var projectRoot = null;
|
|
401
|
+
/**
|
|
402
|
+
* Finds the project root directory by searching upwards from the current file
|
|
403
|
+
* for a directory containing 'package.json'. Caches the result.
|
|
404
|
+
*
|
|
405
|
+
* @returns {string} The absolute path to the project root.
|
|
406
|
+
* @throws {Error} If package.json cannot be found.
|
|
407
|
+
*/
|
|
408
|
+
function getProjectRoot() {
|
|
409
|
+
if (projectRoot) return projectRoot;
|
|
410
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
411
|
+
let currentDir = path.dirname(currentFilePath);
|
|
412
|
+
while (true) {
|
|
413
|
+
const packageJsonPath = path.join(currentDir, "package.json");
|
|
414
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
415
|
+
projectRoot = currentDir;
|
|
416
|
+
return currentDir;
|
|
417
|
+
}
|
|
418
|
+
const parentDir = path.dirname(currentDir);
|
|
419
|
+
if (parentDir === currentDir) throw new Error("Could not find project root containing package.json.");
|
|
420
|
+
currentDir = parentDir;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Resolves the data storage path using the following priority:
|
|
425
|
+
* 1. Provided storePath parameter
|
|
426
|
+
* 2. Legacy .store directory in project root (if exists)
|
|
427
|
+
* 3. Standard system data directory using env-paths
|
|
428
|
+
*
|
|
429
|
+
* @param storePath Optional custom storage path
|
|
430
|
+
* @returns Resolved absolute path for data storage
|
|
431
|
+
*/
|
|
432
|
+
function resolveStorePath(storePath) {
|
|
433
|
+
let dbDir;
|
|
434
|
+
if (storePath) dbDir = path.resolve(storePath);
|
|
435
|
+
else {
|
|
436
|
+
const projectRoot = getProjectRoot();
|
|
437
|
+
const oldDbDir = path.join(projectRoot, ".store");
|
|
438
|
+
const oldDbPath = path.join(oldDbDir, "documents.db");
|
|
439
|
+
if (fs.existsSync(oldDbPath)) dbDir = oldDbDir;
|
|
440
|
+
else dbDir = envPaths("docs-mcp-server", { suffix: "" }).data;
|
|
441
|
+
}
|
|
442
|
+
try {
|
|
443
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
444
|
+
} catch (error) {
|
|
445
|
+
logger.warn(`⚠️ Failed to create database directory ${dbDir}: ${error}`);
|
|
446
|
+
}
|
|
447
|
+
return dbDir;
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/telemetry/TelemetryConfig.ts
|
|
451
|
+
/**
|
|
452
|
+
* Telemetry configuration management for enabling/disabling analytics collection.
|
|
453
|
+
* Handles CLI flags, environment variables, and default settings.
|
|
454
|
+
*/
|
|
455
|
+
var TelemetryConfig = class TelemetryConfig {
|
|
456
|
+
static instance;
|
|
457
|
+
enabled = true;
|
|
458
|
+
constructor() {}
|
|
367
459
|
isEnabled() {
|
|
368
460
|
return this.enabled;
|
|
369
461
|
}
|
|
462
|
+
setEnabled(enabled) {
|
|
463
|
+
this.enabled = enabled;
|
|
464
|
+
}
|
|
465
|
+
static getInstance() {
|
|
466
|
+
if (!TelemetryConfig.instance) TelemetryConfig.instance = new TelemetryConfig();
|
|
467
|
+
return TelemetryConfig.instance;
|
|
468
|
+
}
|
|
370
469
|
};
|
|
371
470
|
/**
|
|
372
|
-
*
|
|
471
|
+
* Generate or retrieve a persistent installation identifier.
|
|
472
|
+
* Creates a UUID and stores it in a file in the user data directory.
|
|
473
|
+
* Supports custom store path override for Docker deployments.
|
|
474
|
+
* This ensures truly unique identification that persists across runs.
|
|
475
|
+
*/
|
|
476
|
+
function generateInstallationId(storePath) {
|
|
477
|
+
try {
|
|
478
|
+
const dataDir = resolveStorePath(storePath);
|
|
479
|
+
const installationIdPath = path.join(dataDir, "installation.id");
|
|
480
|
+
if (fs.existsSync(installationIdPath)) {
|
|
481
|
+
const existingId = fs.readFileSync(installationIdPath, "utf8").trim();
|
|
482
|
+
if (existingId) return existingId;
|
|
483
|
+
}
|
|
484
|
+
const newId = randomUUID();
|
|
485
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
486
|
+
fs.writeFileSync(installationIdPath, newId, "utf8");
|
|
487
|
+
return newId;
|
|
488
|
+
} catch {
|
|
489
|
+
return randomUUID();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Check if telemetry should be enabled based on environment and CLI flags.
|
|
494
|
+
*/
|
|
495
|
+
function shouldEnableTelemetry() {
|
|
496
|
+
return TelemetryConfig.getInstance().isEnabled();
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/events/types.ts
|
|
500
|
+
/**
|
|
501
|
+
* Event type enum used by the EventBusService.
|
|
502
|
+
* These are the internal event identifiers.
|
|
503
|
+
*/
|
|
504
|
+
var EventType = /* @__PURE__ */ function(EventType) {
|
|
505
|
+
EventType["JOB_STATUS_CHANGE"] = "JOB_STATUS_CHANGE";
|
|
506
|
+
EventType["JOB_PROGRESS"] = "JOB_PROGRESS";
|
|
507
|
+
EventType["LIBRARY_CHANGE"] = "LIBRARY_CHANGE";
|
|
508
|
+
EventType["JOB_LIST_CHANGE"] = "JOB_LIST_CHANGE";
|
|
509
|
+
return EventType;
|
|
510
|
+
}({});
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/pipeline/types.ts
|
|
513
|
+
/**
|
|
514
|
+
* Represents the possible states of a pipeline job.
|
|
515
|
+
*/
|
|
516
|
+
var PipelineJobStatus = /* @__PURE__ */ function(PipelineJobStatus) {
|
|
517
|
+
PipelineJobStatus["QUEUED"] = "queued";
|
|
518
|
+
PipelineJobStatus["RUNNING"] = "running";
|
|
519
|
+
PipelineJobStatus["COMPLETED"] = "completed";
|
|
520
|
+
PipelineJobStatus["FAILED"] = "failed";
|
|
521
|
+
PipelineJobStatus["CANCELLING"] = "cancelling";
|
|
522
|
+
PipelineJobStatus["CANCELLED"] = "cancelled";
|
|
523
|
+
return PipelineJobStatus;
|
|
524
|
+
}({});
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/telemetry/postHogClient.ts
|
|
527
|
+
/**
|
|
528
|
+
* PostHog client wrapper for telemetry events.
|
|
529
|
+
* Handles PostHog SDK integration and event capture with privacy-first configuration.
|
|
530
|
+
* Automatically converts camelCase property names to snake_case for PostHog compatibility.
|
|
373
531
|
*/
|
|
374
|
-
var telemetryInstance = null;
|
|
375
532
|
/**
|
|
376
|
-
*
|
|
533
|
+
* Convert camelCase string to snake_case
|
|
534
|
+
* Specifically designed for PostHog property name conversion
|
|
377
535
|
*/
|
|
378
|
-
function
|
|
379
|
-
|
|
380
|
-
return telemetryInstance;
|
|
536
|
+
function camelToSnakeCase(str) {
|
|
537
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
381
538
|
}
|
|
382
539
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
540
|
+
* Recursively convert object keys from camelCase to snake_case
|
|
541
|
+
* Handles nested objects and arrays while preserving values
|
|
385
542
|
*/
|
|
386
|
-
function
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const value = instance[prop];
|
|
394
|
-
if (typeof value === "function") return value.bind(instance);
|
|
395
|
-
return value;
|
|
396
|
-
} });
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/telemetry/TelemetryService.ts
|
|
399
|
-
var TelemetryService = class {
|
|
400
|
-
eventBus;
|
|
401
|
-
unsubscribers = [];
|
|
402
|
-
constructor(eventBus) {
|
|
403
|
-
this.eventBus = eventBus;
|
|
404
|
-
this.setupEventListeners();
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Sets up event listeners for pipeline events.
|
|
408
|
-
*/
|
|
409
|
-
setupEventListeners() {
|
|
410
|
-
const unsubStatusChange = this.eventBus.on(EventType.JOB_STATUS_CHANGE, this.handleJobStatusChange.bind(this));
|
|
411
|
-
const unsubProgress = this.eventBus.on(EventType.JOB_PROGRESS, this.handleJobProgress.bind(this));
|
|
412
|
-
this.unsubscribers.push(unsubStatusChange, unsubProgress);
|
|
413
|
-
logger.debug("TelemetryService initialized and listening to events");
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Handles job status change events and tracks them to analytics.
|
|
417
|
-
* Only tracks events for meaningful state transitions: started, completed, and failed.
|
|
418
|
-
*/
|
|
419
|
-
handleJobStatusChange(job) {
|
|
420
|
-
const duration = job.startedAt ? Date.now() - job.startedAt.getTime() : null;
|
|
421
|
-
const queueWaitTime = job.startedAt && job.createdAt ? job.startedAt.getTime() - job.createdAt.getTime() : null;
|
|
422
|
-
switch (job.status) {
|
|
423
|
-
case PipelineJobStatus.RUNNING:
|
|
424
|
-
telemetry.track(TelemetryEvent.PIPELINE_JOB_STARTED, {
|
|
425
|
-
jobId: job.id,
|
|
426
|
-
library: job.library,
|
|
427
|
-
hasVersion: !!job.version,
|
|
428
|
-
maxPagesConfigured: job.progressMaxPages || 0,
|
|
429
|
-
queueWaitTimeMs: queueWaitTime
|
|
430
|
-
});
|
|
431
|
-
break;
|
|
432
|
-
case PipelineJobStatus.COMPLETED:
|
|
433
|
-
telemetry.track(TelemetryEvent.PIPELINE_JOB_COMPLETED, {
|
|
434
|
-
jobId: job.id,
|
|
435
|
-
library: job.library,
|
|
436
|
-
durationMs: duration,
|
|
437
|
-
pagesProcessed: job.progressPages || 0,
|
|
438
|
-
maxPagesConfigured: job.progressMaxPages || 0,
|
|
439
|
-
hasVersion: !!job.version,
|
|
440
|
-
throughputPagesPerSecond: duration && job.progressPages ? Math.round(job.progressPages / duration * 1e3) : 0
|
|
441
|
-
});
|
|
442
|
-
break;
|
|
443
|
-
case PipelineJobStatus.FAILED:
|
|
444
|
-
telemetry.track(TelemetryEvent.PIPELINE_JOB_FAILED, {
|
|
445
|
-
jobId: job.id,
|
|
446
|
-
library: job.library,
|
|
447
|
-
durationMs: duration,
|
|
448
|
-
pagesProcessed: job.progressPages || 0,
|
|
449
|
-
maxPagesConfigured: job.progressMaxPages || 0,
|
|
450
|
-
hasVersion: !!job.version,
|
|
451
|
-
hasError: !!job.error,
|
|
452
|
-
errorMessage: job.error?.message
|
|
453
|
-
});
|
|
454
|
-
break;
|
|
455
|
-
default: break;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Handles job progress events. Currently a no-op but can be extended
|
|
460
|
-
* for progress-specific telemetry tracking.
|
|
461
|
-
*/
|
|
462
|
-
handleJobProgress(_event) {}
|
|
463
|
-
/**
|
|
464
|
-
* Cleans up event listeners.
|
|
465
|
-
*/
|
|
466
|
-
shutdown() {
|
|
467
|
-
for (const unsubscribe of this.unsubscribers) unsubscribe();
|
|
468
|
-
this.unsubscribers = [];
|
|
469
|
-
logger.debug("TelemetryService shut down");
|
|
543
|
+
function convertPropertiesToSnakeCase(obj) {
|
|
544
|
+
const result = {};
|
|
545
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
546
|
+
const snakeKey = camelToSnakeCase(key);
|
|
547
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) result[snakeKey] = convertPropertiesToSnakeCase(value);
|
|
548
|
+
else if (Array.isArray(value)) result[snakeKey] = value.map((item) => item && typeof item === "object" && !(item instanceof Date) ? convertPropertiesToSnakeCase(item) : item);
|
|
549
|
+
else result[snakeKey] = value;
|
|
470
550
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
//#region src/events/EventBusService.ts
|
|
474
|
-
/**
|
|
475
|
-
* Central event bus service for application-wide event distribution.
|
|
476
|
-
*
|
|
477
|
-
* This service provides a pub/sub mechanism that can be used by any service
|
|
478
|
-
* to emit and listen for events. Events emitted here can be:
|
|
479
|
-
* - Consumed locally by in-process subscribers
|
|
480
|
-
* - Broadcast to remote processes via tRPC subscriptions
|
|
481
|
-
* - Forwarded to SSE clients via the web service
|
|
482
|
-
*
|
|
483
|
-
* This decouples event producers (like DocumentManagementService) from
|
|
484
|
-
* consumers (like the Web UI), enabling a clean, scalable architecture.
|
|
485
|
-
*/
|
|
551
|
+
return result;
|
|
552
|
+
}
|
|
486
553
|
/**
|
|
487
|
-
*
|
|
554
|
+
* Add PostHog standard properties and remove duplicates
|
|
555
|
+
* Maps our properties to PostHog's expected property names
|
|
488
556
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Emit an event to all subscribers.
|
|
497
|
-
*/
|
|
498
|
-
emit(eventType, payload) {
|
|
499
|
-
logger.debug(`Event emitted: ${eventType}`);
|
|
500
|
-
this.emitter.emit(eventType, payload);
|
|
557
|
+
function addPostHogStandardProperties(properties) {
|
|
558
|
+
const result = { ...properties };
|
|
559
|
+
if (properties.sessionId) {
|
|
560
|
+
result.$session_id = properties.sessionId;
|
|
561
|
+
delete result.sessionId;
|
|
501
562
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
*/
|
|
506
|
-
on(eventType, listener) {
|
|
507
|
-
this.emitter.on(eventType, listener);
|
|
508
|
-
return () => this.emitter.off(eventType, listener);
|
|
563
|
+
if (properties.startTime) {
|
|
564
|
+
result.$start_timestamp = properties.startTime.toISOString();
|
|
565
|
+
delete result.startTime;
|
|
509
566
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
once(eventType, listener) {
|
|
514
|
-
this.emitter.once(eventType, listener);
|
|
567
|
+
if (properties.appVersion) {
|
|
568
|
+
result.$app_version = properties.appVersion;
|
|
569
|
+
delete result.appVersion;
|
|
515
570
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
571
|
+
return result;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* PostHog client wrapper for telemetry events
|
|
575
|
+
*/
|
|
576
|
+
var PostHogClient = class PostHogClient {
|
|
577
|
+
client;
|
|
578
|
+
enabled;
|
|
579
|
+
static CONFIG = {
|
|
580
|
+
host: "https://app.posthog.com",
|
|
581
|
+
flushAt: 20,
|
|
582
|
+
flushInterval: 1e4,
|
|
583
|
+
disableGeoip: true,
|
|
584
|
+
disableSessionRecording: true,
|
|
585
|
+
disableSurveys: true,
|
|
586
|
+
persistence: "memory"
|
|
587
|
+
};
|
|
588
|
+
constructor(enabled) {
|
|
589
|
+
this.enabled = enabled;
|
|
590
|
+
if (!this.enabled) return;
|
|
591
|
+
try {
|
|
592
|
+
this.client = new PostHog("phc_g7pXZZdUiAQXdnwUANjloQWMvO0amEDTBaeDSWgXgrQ", {
|
|
593
|
+
host: PostHogClient.CONFIG.host,
|
|
594
|
+
flushAt: PostHogClient.CONFIG.flushAt,
|
|
595
|
+
flushInterval: PostHogClient.CONFIG.flushInterval,
|
|
596
|
+
disableGeoip: PostHogClient.CONFIG.disableGeoip
|
|
597
|
+
});
|
|
598
|
+
logger.debug("PostHog client initialized");
|
|
599
|
+
} catch (error) {
|
|
600
|
+
logger.debug(`PostHog initialization failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
601
|
+
this.enabled = false;
|
|
602
|
+
}
|
|
521
603
|
}
|
|
522
604
|
/**
|
|
523
|
-
*
|
|
605
|
+
* Send event to PostHog
|
|
524
606
|
*/
|
|
525
|
-
|
|
526
|
-
if (
|
|
527
|
-
|
|
607
|
+
capture(distinctId, event, properties) {
|
|
608
|
+
if (!this.enabled || !this.client) return;
|
|
609
|
+
try {
|
|
610
|
+
const snakeCaseProperties = convertPropertiesToSnakeCase(addPostHogStandardProperties(properties));
|
|
611
|
+
this.client.capture({
|
|
612
|
+
distinctId,
|
|
613
|
+
event,
|
|
614
|
+
properties: snakeCaseProperties
|
|
615
|
+
});
|
|
616
|
+
logger.debug(`PostHog event captured: ${event}`);
|
|
617
|
+
} catch (error) {
|
|
618
|
+
logger.debug(`PostHog capture error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
619
|
+
}
|
|
528
620
|
}
|
|
529
621
|
/**
|
|
530
|
-
*
|
|
622
|
+
* Capture exception using PostHog's native error tracking
|
|
531
623
|
*/
|
|
532
|
-
|
|
533
|
-
|
|
624
|
+
captureException(distinctId, error, properties) {
|
|
625
|
+
if (!this.enabled || !this.client) return;
|
|
626
|
+
try {
|
|
627
|
+
const snakeCaseProperties = convertPropertiesToSnakeCase(addPostHogStandardProperties(properties || {}));
|
|
628
|
+
this.client.captureException({
|
|
629
|
+
error,
|
|
630
|
+
distinctId,
|
|
631
|
+
properties: snakeCaseProperties
|
|
632
|
+
});
|
|
633
|
+
logger.debug(`PostHog exception captured: ${error.constructor.name}`);
|
|
634
|
+
} catch (captureError) {
|
|
635
|
+
logger.debug(`PostHog captureException error: ${captureError instanceof Error ? captureError.message : "Unknown error"}`);
|
|
636
|
+
}
|
|
534
637
|
}
|
|
535
|
-
};
|
|
536
|
-
//#endregion
|
|
537
|
-
//#region src/store/embeddings/EmbeddingConfig.ts
|
|
538
|
-
/**
|
|
539
|
-
* Embedding configuration manager that handles model parsing and dimension caching.
|
|
540
|
-
* Encapsulates state to avoid global variable issues and improve testability.
|
|
541
|
-
*/
|
|
542
|
-
var EmbeddingConfig = class EmbeddingConfig {
|
|
543
|
-
static instance = null;
|
|
544
638
|
/**
|
|
545
|
-
*
|
|
546
|
-
* Creates the instance if it doesn't exist.
|
|
639
|
+
* Graceful shutdown with event flushing
|
|
547
640
|
*/
|
|
548
|
-
|
|
549
|
-
if (
|
|
550
|
-
|
|
641
|
+
async shutdown() {
|
|
642
|
+
if (this.client) try {
|
|
643
|
+
await this.client.shutdown();
|
|
644
|
+
logger.debug("PostHog client shutdown complete");
|
|
645
|
+
} catch (error) {
|
|
646
|
+
logger.debug(`PostHog shutdown error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
647
|
+
}
|
|
551
648
|
}
|
|
552
649
|
/**
|
|
553
|
-
*
|
|
650
|
+
* Check if client is enabled and ready
|
|
554
651
|
*/
|
|
555
|
-
|
|
556
|
-
|
|
652
|
+
isEnabled() {
|
|
653
|
+
return this.enabled && !!this.client;
|
|
557
654
|
}
|
|
655
|
+
};
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/telemetry/telemetry.ts
|
|
658
|
+
/**
|
|
659
|
+
* Telemtry wrapper for privacy-first telemetry using PostHog.
|
|
660
|
+
* Provides global context and automatic data sanitization.
|
|
661
|
+
*
|
|
662
|
+
* Architecture:
|
|
663
|
+
* - PostHogClient: Handles PostHog SDK integration and event capture
|
|
664
|
+
* - Telemtry: High-level coordinator providing public API with global context
|
|
665
|
+
*/
|
|
666
|
+
/**
|
|
667
|
+
* Event types for structured telemetry tracking
|
|
668
|
+
*/
|
|
669
|
+
var TelemetryEvent = /* @__PURE__ */ function(TelemetryEvent) {
|
|
670
|
+
TelemetryEvent["APP_STARTED"] = "app_started";
|
|
671
|
+
TelemetryEvent["APP_SHUTDOWN"] = "app_shutdown";
|
|
672
|
+
TelemetryEvent["CLI_COMMAND"] = "cli_command";
|
|
673
|
+
TelemetryEvent["TOOL_USED"] = "tool_used";
|
|
674
|
+
TelemetryEvent["PIPELINE_JOB_STARTED"] = "pipeline_job_started";
|
|
675
|
+
TelemetryEvent["PIPELINE_JOB_COMPLETED"] = "pipeline_job_completed";
|
|
676
|
+
TelemetryEvent["PIPELINE_JOB_FAILED"] = "pipeline_job_failed";
|
|
677
|
+
return TelemetryEvent;
|
|
678
|
+
}({});
|
|
679
|
+
/**
|
|
680
|
+
* Main telemetry class providing privacy-first telemetry
|
|
681
|
+
*/
|
|
682
|
+
var Telemetry = class Telemetry {
|
|
683
|
+
postHogClient;
|
|
684
|
+
enabled;
|
|
685
|
+
distinctId;
|
|
686
|
+
globalContext = {};
|
|
558
687
|
/**
|
|
559
|
-
*
|
|
560
|
-
* This
|
|
561
|
-
*
|
|
562
|
-
* Note: The "openai" provider also supports OpenAI-compatible APIs like:
|
|
563
|
-
* - Ollama (local models)
|
|
564
|
-
* - LMStudio (local models)
|
|
565
|
-
* - Any service implementing OpenAI's embedding API
|
|
688
|
+
* Create a new Telemetry instance with proper initialization
|
|
689
|
+
* This is the recommended way to create Telemetry instances
|
|
566
690
|
*/
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
"
|
|
572
|
-
"
|
|
573
|
-
"
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
"text-embedding-preview-0409": 768,
|
|
577
|
-
"embedding-001": 768,
|
|
578
|
-
"gemini-embedding-2-preview": 3072,
|
|
579
|
-
"amazon.titan-embed-text-v1": 1536,
|
|
580
|
-
"amazon.titan-embed-text-v2:0": 1024,
|
|
581
|
-
"amazon.titan-embed-image-v1": 1024,
|
|
582
|
-
"cohere.embed-english-v3": 1024,
|
|
583
|
-
"cohere.embed-multilingual-v3": 1024,
|
|
584
|
-
"Cohere/Cohere-embed-v4.0": 1536,
|
|
585
|
-
"embed-v4.0": 1536,
|
|
586
|
-
"intfloat/multilingual-e5-large": 1024,
|
|
587
|
-
"multilingual-e5-large": 1024,
|
|
588
|
-
"text-embedding-multilingual-e5-large": 1024,
|
|
589
|
-
"sentence-transformers/all-MiniLM-L6-v2": 384,
|
|
590
|
-
"gemini-embedding-001": 3072,
|
|
591
|
-
"Qwen/Qwen3-Embedding-8B": 4096,
|
|
592
|
-
"Qwen/Qwen3-Embedding-4B": 2560,
|
|
593
|
-
"Qwen/Qwen3-Embedding-0.6B": 1024,
|
|
594
|
-
"Linq-AI-Research/Linq-Embed-Mistral": 4096,
|
|
595
|
-
"Alibaba-NLP/gte-Qwen2-7B-instruct": 3584,
|
|
596
|
-
"intfloat/multilingual-e5-large-instruct": 1024,
|
|
597
|
-
"Salesforce/SFR-Embedding-Mistral": 4096,
|
|
598
|
-
"text-multilingual-embedding-002": 768,
|
|
599
|
-
"GritLM/GritLM-7B": 4096,
|
|
600
|
-
"GritLM/GritLM-8x7B": 4096,
|
|
601
|
-
"intfloat/e5-mistral-7b-instruct": 4096,
|
|
602
|
-
"Cohere/Cohere-embed-multilingual-v3.0": 1024,
|
|
603
|
-
"Alibaba-NLP/gte-Qwen2-1.5B-instruct": 8960,
|
|
604
|
-
"Lajavaness/bilingual-embedding-large": 1024,
|
|
605
|
-
"Salesforce/SFR-Embedding-2_R": 4096,
|
|
606
|
-
"NovaSearch/stella_en_1.5B_v5": 8960,
|
|
607
|
-
"NovaSearch/jasper_en_vision_language_v1": 8960,
|
|
608
|
-
"nvidia/NV-Embed-v2": 4096,
|
|
609
|
-
"OrdalieTech/Solon-embeddings-large-0.1": 1024,
|
|
610
|
-
"BAAI/bge-m3": 1024,
|
|
611
|
-
"HIT-TMG/KaLM-embedding-multilingual-mini-v1": 896,
|
|
612
|
-
"jinaai/jina-embeddings-v3": 1024,
|
|
613
|
-
"Alibaba-NLP/gte-multilingual-base": 768,
|
|
614
|
-
"Lajavaness/bilingual-embedding-base": 768,
|
|
615
|
-
"HIT-TMG/KaLM-embedding-multilingual-mini-instruct-v1": 896,
|
|
616
|
-
"nvidia/NV-Embed-v1": 4096,
|
|
617
|
-
"Cohere/Cohere-embed-multilingual-light-v3.0": 384,
|
|
618
|
-
"manu/bge-m3-custom-fr": 1024,
|
|
619
|
-
"Lajavaness/bilingual-embedding-small": 384,
|
|
620
|
-
"Snowflake/snowflake-arctic-embed-l-v2.0": 1024,
|
|
621
|
-
"intfloat/multilingual-e5-base": 768,
|
|
622
|
-
"voyage-3-lite": 512,
|
|
623
|
-
"voyage-3": 1024,
|
|
624
|
-
"voyage-3-large": 1024,
|
|
625
|
-
"voyage-3.5": 1024,
|
|
626
|
-
"voyage-4": 1024,
|
|
627
|
-
"voyage-4-large": 1024,
|
|
628
|
-
"voyage-4-lite": 1024,
|
|
629
|
-
"voyage-code-3": 1024,
|
|
630
|
-
"intfloat/multilingual-e5-small": 384,
|
|
631
|
-
"Alibaba-NLP/gte-Qwen1.5-7B-instruct": 4096,
|
|
632
|
-
"Snowflake/snowflake-arctic-embed-m-v2.0": 768,
|
|
633
|
-
"deepvk/USER-bge-m3": 1024,
|
|
634
|
-
"Cohere/Cohere-embed-english-v3.0": 1024,
|
|
635
|
-
"Omartificial-Intelligence-Space/Arabic-labse-Matryoshka": 768,
|
|
636
|
-
"ibm-granite/granite-embedding-278m-multilingual": 768,
|
|
637
|
-
"NovaSearch/stella_en_400M_v5": 4096,
|
|
638
|
-
"omarelshehy/arabic-english-sts-matryoshka": 1024,
|
|
639
|
-
"sentence-transformers/paraphrase-multilingual-mpnet-base-v2": 768,
|
|
640
|
-
"Omartificial-Intelligence-Space/Arabic-all-nli-triplet-Matryoshka": 768,
|
|
641
|
-
"Haon-Chen/speed-embedding-7b-instruct": 4096,
|
|
642
|
-
"sentence-transformers/LaBSE": 768,
|
|
643
|
-
"WhereIsAI/UAE-Large-V1": 1024,
|
|
644
|
-
"ibm-granite/granite-embedding-107m-multilingual": 384,
|
|
645
|
-
"mixedbread-ai/mxbai-embed-large-v1": 1024,
|
|
646
|
-
"intfloat/e5-large-v2": 1024,
|
|
647
|
-
"avsolatorio/GIST-large-Embedding-v0": 1024,
|
|
648
|
-
"sdadas/mmlw-e5-large": 1024,
|
|
649
|
-
"nomic-ai/nomic-embed-text-v1": 768,
|
|
650
|
-
"nomic-embed-text-v1": 768,
|
|
651
|
-
"nomic-ai/nomic-embed-text-v1-ablated": 768,
|
|
652
|
-
"nomic-ai/nomic-embed-text-v2-moe": 768,
|
|
653
|
-
"nomic-ai/modernbert-embed-base": 768,
|
|
654
|
-
"nomic-ai/nomic-embed-code": 3584,
|
|
655
|
-
"intfloat/e5-base-v2": 768,
|
|
656
|
-
"BAAI/bge-large-en-v1.5": 1024,
|
|
657
|
-
"intfloat/e5-large": 1024,
|
|
658
|
-
"Omartificial-Intelligence-Space/Arabic-MiniLM-L12-v2-all-nli-triplet": 384,
|
|
659
|
-
"Cohere/Cohere-embed-english-light-v3.0": 384,
|
|
660
|
-
"sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2": 768,
|
|
661
|
-
"Gameselo/STS-multilingual-mpnet-base-v2": 768,
|
|
662
|
-
"thenlper/gte-large": 1024,
|
|
663
|
-
"avsolatorio/GIST-Embedding-v0": 768,
|
|
664
|
-
"nomic-ai/nomic-embed-text-v1-unsupervised": 768,
|
|
665
|
-
"infgrad/stella-base-en-v2": 768,
|
|
666
|
-
"avsolatorio/NoInstruct-small-Embedding-v0": 384,
|
|
667
|
-
"dwzhu/e5-base-4k": 768,
|
|
668
|
-
"sdadas/mmlw-e5-base": 768,
|
|
669
|
-
"voyage-multilingual-2": 1024,
|
|
670
|
-
"McGill-NLP/LLM2Vec-Mistral-7B-Instruct-v2-mntp-supervised": 4096,
|
|
671
|
-
"BAAI/bge-base-en-v1.5": 768,
|
|
672
|
-
"avsolatorio/GIST-small-Embedding-v0": 384,
|
|
673
|
-
"sdadas/mmlw-roberta-large": 1024,
|
|
674
|
-
"nomic-ai/nomic-embed-text-v1.5": 768,
|
|
675
|
-
"nomic-embed-text-v1.5": 768,
|
|
676
|
-
"text-embedding-nomic-embed-text-v1.5": 768,
|
|
677
|
-
"minishlab/potion-multilingual-128M": 256,
|
|
678
|
-
"shibing624/text2vec-base-multilingual": 384,
|
|
679
|
-
"thenlper/gte-base": 768,
|
|
680
|
-
"intfloat/e5-small-v2": 384,
|
|
681
|
-
"intfloat/e5-base": 768,
|
|
682
|
-
"sentence-transformers/static-similarity-mrl-multilingual-v1": 1024,
|
|
683
|
-
"manu/sentence_croissant_alpha_v0.3": 2048,
|
|
684
|
-
"BAAI/bge-small-en-v1.5": 512,
|
|
685
|
-
"thenlper/gte-small": 384,
|
|
686
|
-
"sdadas/mmlw-e5-small": 384,
|
|
687
|
-
"manu/sentence_croissant_alpha_v0.4": 2048,
|
|
688
|
-
"manu/sentence_croissant_alpha_v0.2": 2048,
|
|
689
|
-
"abhinand/MedEmbed-small-v0.1": 384,
|
|
690
|
-
"ibm-granite/granite-embedding-125m-english": 768,
|
|
691
|
-
"intfloat/e5-small": 384,
|
|
692
|
-
"voyage-large-2-instruct": 1024,
|
|
693
|
-
"sdadas/mmlw-roberta-base": 768,
|
|
694
|
-
"Snowflake/snowflake-arctic-embed-l": 1024,
|
|
695
|
-
"Mihaiii/Ivysaur": 384,
|
|
696
|
-
"Snowflake/snowflake-arctic-embed-m-long": 768,
|
|
697
|
-
"bigscience/sgpt-bloom-7b1-msmarco": 4096,
|
|
698
|
-
"avsolatorio/GIST-all-MiniLM-L6-v2": 384,
|
|
699
|
-
"sergeyzh/LaBSE-ru-turbo": 768,
|
|
700
|
-
"sentence-transformers/all-mpnet-base-v2": 768,
|
|
701
|
-
"Snowflake/snowflake-arctic-embed-m": 768,
|
|
702
|
-
"Snowflake/snowflake-arctic-embed-s": 384,
|
|
703
|
-
"sentence-transformers/all-MiniLM-L12-v2": 384,
|
|
704
|
-
"Mihaiii/gte-micro-v4": 384,
|
|
705
|
-
"Snowflake/snowflake-arctic-embed-m-v1.5": 768,
|
|
706
|
-
"cointegrated/LaBSE-en-ru": 768,
|
|
707
|
-
"Mihaiii/Bulbasaur": 384,
|
|
708
|
-
"ibm-granite/granite-embedding-30m-english": 384,
|
|
709
|
-
"deepfile/embedder-100p": 768,
|
|
710
|
-
"Jaume/gemma-2b-embeddings": 2048,
|
|
711
|
-
"OrlikB/KartonBERT-USE-base-v1": 768,
|
|
712
|
-
"izhx/udever-bloom-7b1": 4096,
|
|
713
|
-
"izhx/udever-bloom-1b1": 1024,
|
|
714
|
-
"brahmairesearch/slx-v0.1": 384,
|
|
715
|
-
"Mihaiii/Wartortle": 384,
|
|
716
|
-
"izhx/udever-bloom-3b": 2048,
|
|
717
|
-
"deepvk/USER-base": 768,
|
|
718
|
-
"ai-forever/ru-en-RoSBERTa": 1024,
|
|
719
|
-
"McGill-NLP/LLM2Vec-Mistral-7B-Instruct-v2-mntp-unsup-simcse": 4096,
|
|
720
|
-
"Mihaiii/Venusaur": 384,
|
|
721
|
-
"Snowflake/snowflake-arctic-embed-xs": 384,
|
|
722
|
-
"jinaai/jina-embedding-b-en-v1": 768,
|
|
723
|
-
"Mihaiii/gte-micro": 384,
|
|
724
|
-
"aari1995/German_Semantic_STS_V2": 1024,
|
|
725
|
-
"Mihaiii/Squirtle": 384,
|
|
726
|
-
"OrlikB/st-polish-kartonberta-base-alpha-v1": 768,
|
|
727
|
-
"sergeyzh/rubert-tiny-turbo": 312,
|
|
728
|
-
"minishlab/potion-base-8M": 256,
|
|
729
|
-
"minishlab/M2V_base_glove_subword": 256,
|
|
730
|
-
"jinaai/jina-embedding-s-en-v1": 512,
|
|
731
|
-
"minishlab/potion-base-4M": 128,
|
|
732
|
-
"minishlab/M2V_base_output": 256,
|
|
733
|
-
"DeepPavlov/rubert-base-cased-sentence": 768,
|
|
734
|
-
"jinaai/jina-embeddings-v2-small-en": 512,
|
|
735
|
-
"cointegrated/rubert-tiny2": 312,
|
|
736
|
-
"minishlab/M2V_base_glove": 256,
|
|
737
|
-
"cointegrated/rubert-tiny": 312,
|
|
738
|
-
"silma-ai/silma-embeddding-matryoshka-v0.1": 768,
|
|
739
|
-
"DeepPavlov/rubert-base-cased": 768,
|
|
740
|
-
"Omartificial-Intelligence-Space/Arabic-mpnet-base-all-nli-triplet": 768,
|
|
741
|
-
"izhx/udever-bloom-560m": 1024,
|
|
742
|
-
"minishlab/potion-base-2M": 64,
|
|
743
|
-
"DeepPavlov/distilrubert-small-cased-conversational": 768,
|
|
744
|
-
"consciousAI/cai-lunaris-text-embeddings": 1024,
|
|
745
|
-
"deepvk/deberta-v1-base": 768,
|
|
746
|
-
"Omartificial-Intelligence-Space/Arabert-all-nli-triplet-Matryoshka": 768,
|
|
747
|
-
"Omartificial-Intelligence-Space/Marbert-all-nli-triplet-Matryoshka": 768,
|
|
748
|
-
"ai-forever/sbert_large_mt_nlu_ru": 1024,
|
|
749
|
-
"ai-forever/sbert_large_nlu_ru": 1024,
|
|
750
|
-
"malenia1/ternary-weight-embedding": 1024,
|
|
751
|
-
"jinaai/jina-embeddings-v2-base-en": 768,
|
|
752
|
-
"VPLabs/SearchMap_Preview": 4096,
|
|
753
|
-
"Hum-Works/lodestone-base-4096-v1": 768,
|
|
754
|
-
"jinaai/jina-embeddings-v4": 2048
|
|
755
|
-
};
|
|
756
|
-
runtimeDetectedDimensionModels = /* @__PURE__ */ new Set([
|
|
757
|
-
"novasearch/stella_en_1.5b_v5",
|
|
758
|
-
"stella_en_1.5b_v5",
|
|
759
|
-
"novasearch/stella_en_400m_v5",
|
|
760
|
-
"dunzhang/stella_en_400m_v5",
|
|
761
|
-
"stella_en_400m_v5",
|
|
762
|
-
"novasearch/jasper_en_vision_language_v1",
|
|
763
|
-
"jasper_en_vision_language_v1"
|
|
764
|
-
]);
|
|
691
|
+
static create() {
|
|
692
|
+
const config = TelemetryConfig.getInstance();
|
|
693
|
+
const shouldEnable = config.isEnabled() && true;
|
|
694
|
+
const telemetry = new Telemetry(shouldEnable);
|
|
695
|
+
if (telemetry.isEnabled()) logger.debug("Telemetry enabled");
|
|
696
|
+
else if (!config.isEnabled()) logger.debug("Telemetry disabled (user preference)");
|
|
697
|
+
else logger.debug("Telemetry disabled");
|
|
698
|
+
return telemetry;
|
|
699
|
+
}
|
|
765
700
|
/**
|
|
766
|
-
*
|
|
767
|
-
* Built lazily from knownModelDimensions to ensure consistency.
|
|
701
|
+
* Private constructor - use Telemetry.create() instead
|
|
768
702
|
*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
this.
|
|
772
|
-
|
|
703
|
+
constructor(enabled = true) {
|
|
704
|
+
this.enabled = enabled;
|
|
705
|
+
this.distinctId = generateInstallationId();
|
|
706
|
+
this.postHogClient = new PostHogClient(this.enabled);
|
|
773
707
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
const slashIndex = normalized.lastIndexOf("/");
|
|
780
|
-
if (slashIndex !== -1) {
|
|
781
|
-
const suffix = normalized.substring(slashIndex + 1);
|
|
782
|
-
if (this.runtimeDetectedDimensionModels.has(suffix)) return null;
|
|
783
|
-
return this.modelLookup?.get(suffix) ?? null;
|
|
784
|
-
}
|
|
785
|
-
return null;
|
|
708
|
+
/**
|
|
709
|
+
* Set global application context that will be included in all events
|
|
710
|
+
*/
|
|
711
|
+
setGlobalContext(context) {
|
|
712
|
+
this.globalContext = { ...context };
|
|
786
713
|
}
|
|
787
714
|
/**
|
|
788
|
-
*
|
|
789
|
-
* This is a synchronous operation that extracts provider, model, and known dimensions.
|
|
790
|
-
*
|
|
791
|
-
* Supports various providers:
|
|
792
|
-
* - openai: OpenAI models and OpenAI-compatible APIs (Ollama, LMStudio, etc.)
|
|
793
|
-
* - vertex: Google Cloud Vertex AI
|
|
794
|
-
* - gemini: Google Generative AI
|
|
795
|
-
* - aws: AWS Bedrock models
|
|
796
|
-
* - microsoft: Azure OpenAI
|
|
797
|
-
* - sagemaker: AWS SageMaker hosted models
|
|
798
|
-
*
|
|
799
|
-
* @param modelSpec Model specification (e.g., "openai:text-embedding-3-small"), defaults to "text-embedding-3-small"
|
|
800
|
-
* @returns Parsed embedding model configuration
|
|
715
|
+
* Get current global context
|
|
801
716
|
*/
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
provider = spec.substring(0, colonIndex);
|
|
812
|
-
model = spec.substring(colonIndex + 1);
|
|
813
|
-
}
|
|
814
|
-
const dimensions = this.findKnownDimension(model);
|
|
815
|
-
return {
|
|
816
|
-
provider,
|
|
817
|
-
model,
|
|
818
|
-
dimensions,
|
|
819
|
-
modelSpec: spec
|
|
717
|
+
getGlobalContext() {
|
|
718
|
+
return { ...this.globalContext };
|
|
719
|
+
}
|
|
720
|
+
track(event, properties = {}) {
|
|
721
|
+
if (!this.enabled) return;
|
|
722
|
+
const enrichedProperties = {
|
|
723
|
+
...this.globalContext,
|
|
724
|
+
...properties,
|
|
725
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
820
726
|
};
|
|
727
|
+
logger.debug(`Tracking event: ${event}`);
|
|
728
|
+
this.postHogClient.capture(this.distinctId, event, enrichedProperties);
|
|
821
729
|
}
|
|
822
730
|
/**
|
|
823
|
-
*
|
|
824
|
-
* Returns null if the model dimensions are not known.
|
|
825
|
-
* Uses case-insensitive lookup.
|
|
826
|
-
*
|
|
827
|
-
* @param model The model name (e.g., "text-embedding-3-small")
|
|
828
|
-
* @returns Known dimensions or null
|
|
731
|
+
* Capture exception using PostHog's native error tracking with global context
|
|
829
732
|
*/
|
|
830
|
-
|
|
831
|
-
|
|
733
|
+
captureException(error, properties = {}) {
|
|
734
|
+
if (!this.enabled) return;
|
|
735
|
+
const enrichedProperties = {
|
|
736
|
+
...this.globalContext,
|
|
737
|
+
...properties,
|
|
738
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
739
|
+
};
|
|
740
|
+
logger.debug(`Capturing exception: ${error instanceof Error ? error.message : String(error)}`);
|
|
741
|
+
this.postHogClient.captureException(this.distinctId, error instanceof Error ? error : new Error(String(error)), enrichedProperties);
|
|
832
742
|
}
|
|
833
743
|
/**
|
|
834
|
-
*
|
|
835
|
-
* This can be used to cache discovered dimensions.
|
|
836
|
-
* Stores both original case and lowercase for consistent lookup.
|
|
837
|
-
*
|
|
838
|
-
* @param model The model name
|
|
839
|
-
* @param dimensions The dimensions to cache
|
|
744
|
+
* Graceful shutdown with event flushing
|
|
840
745
|
*/
|
|
841
|
-
|
|
842
|
-
this.
|
|
843
|
-
|
|
746
|
+
async shutdown() {
|
|
747
|
+
if (!this.enabled) return;
|
|
748
|
+
await this.postHogClient.shutdown();
|
|
844
749
|
}
|
|
845
750
|
/**
|
|
846
|
-
*
|
|
847
|
-
* This maintains backward compatibility while using the class-based approach.
|
|
751
|
+
* Check if telemetry is enabled
|
|
848
752
|
*/
|
|
849
|
-
|
|
850
|
-
return
|
|
753
|
+
isEnabled() {
|
|
754
|
+
return this.enabled;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* Global telemetry instance - initialized lazily
|
|
759
|
+
*/
|
|
760
|
+
var telemetryInstance = null;
|
|
761
|
+
/**
|
|
762
|
+
* Get the global telemetry instance, initializing it if needed
|
|
763
|
+
*/
|
|
764
|
+
function getTelemetryInstance() {
|
|
765
|
+
if (!telemetryInstance) telemetryInstance = Telemetry.create();
|
|
766
|
+
return telemetryInstance;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Initialize telemetry system with proper configuration.
|
|
770
|
+
* This should be called once at application startup.
|
|
771
|
+
*/
|
|
772
|
+
function initTelemetry(options) {
|
|
773
|
+
TelemetryConfig.getInstance().setEnabled(options.enabled);
|
|
774
|
+
generateInstallationId(options.storePath);
|
|
775
|
+
telemetryInstance = Telemetry.create();
|
|
776
|
+
}
|
|
777
|
+
var telemetry = new Proxy({}, { get(_target, prop) {
|
|
778
|
+
const instance = getTelemetryInstance();
|
|
779
|
+
const value = instance[prop];
|
|
780
|
+
if (typeof value === "function") return value.bind(instance);
|
|
781
|
+
return value;
|
|
782
|
+
} });
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/telemetry/TelemetryService.ts
|
|
785
|
+
var TelemetryService = class {
|
|
786
|
+
eventBus;
|
|
787
|
+
unsubscribers = [];
|
|
788
|
+
constructor(eventBus) {
|
|
789
|
+
this.eventBus = eventBus;
|
|
790
|
+
this.setupEventListeners();
|
|
851
791
|
}
|
|
852
792
|
/**
|
|
853
|
-
*
|
|
854
|
-
* This maintains backward compatibility while using the class-based approach.
|
|
793
|
+
* Sets up event listeners for pipeline events.
|
|
855
794
|
*/
|
|
856
|
-
|
|
857
|
-
|
|
795
|
+
setupEventListeners() {
|
|
796
|
+
const unsubStatusChange = this.eventBus.on(EventType.JOB_STATUS_CHANGE, this.handleJobStatusChange.bind(this));
|
|
797
|
+
const unsubProgress = this.eventBus.on(EventType.JOB_PROGRESS, this.handleJobProgress.bind(this));
|
|
798
|
+
this.unsubscribers.push(unsubStatusChange, unsubProgress);
|
|
799
|
+
logger.debug("TelemetryService initialized and listening to events");
|
|
858
800
|
}
|
|
859
801
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
802
|
+
* Handles job status change events and tracks them to analytics.
|
|
803
|
+
* Only tracks events for meaningful state transitions: started, completed, and failed.
|
|
862
804
|
*/
|
|
863
|
-
|
|
864
|
-
|
|
805
|
+
handleJobStatusChange(job) {
|
|
806
|
+
const duration = job.startedAt ? Date.now() - job.startedAt.getTime() : null;
|
|
807
|
+
const queueWaitTime = job.startedAt && job.createdAt ? job.startedAt.getTime() - job.createdAt.getTime() : null;
|
|
808
|
+
switch (job.status) {
|
|
809
|
+
case PipelineJobStatus.RUNNING:
|
|
810
|
+
telemetry.track(TelemetryEvent.PIPELINE_JOB_STARTED, {
|
|
811
|
+
jobId: job.id,
|
|
812
|
+
library: job.library,
|
|
813
|
+
hasVersion: !!job.version,
|
|
814
|
+
maxPagesConfigured: job.scraperOptions?.maxPages ?? null,
|
|
815
|
+
queueWaitTimeMs: queueWaitTime
|
|
816
|
+
});
|
|
817
|
+
break;
|
|
818
|
+
case PipelineJobStatus.COMPLETED:
|
|
819
|
+
telemetry.track(TelemetryEvent.PIPELINE_JOB_COMPLETED, {
|
|
820
|
+
jobId: job.id,
|
|
821
|
+
library: job.library,
|
|
822
|
+
durationMs: duration,
|
|
823
|
+
pagesProcessed: job.progressPages || 0,
|
|
824
|
+
maxPagesConfigured: job.scraperOptions?.maxPages ?? null,
|
|
825
|
+
hasVersion: !!job.version,
|
|
826
|
+
throughputPagesPerSecond: duration && job.progressPages ? Math.round(job.progressPages / duration * 1e3) : 0
|
|
827
|
+
});
|
|
828
|
+
break;
|
|
829
|
+
case PipelineJobStatus.FAILED:
|
|
830
|
+
telemetry.track(TelemetryEvent.PIPELINE_JOB_FAILED, {
|
|
831
|
+
jobId: job.id,
|
|
832
|
+
library: job.library,
|
|
833
|
+
durationMs: duration,
|
|
834
|
+
pagesProcessed: job.progressPages || 0,
|
|
835
|
+
maxPagesConfigured: job.scraperOptions?.maxPages ?? null,
|
|
836
|
+
hasVersion: !!job.version,
|
|
837
|
+
hasError: !!job.error,
|
|
838
|
+
errorMessage: job.error?.message
|
|
839
|
+
});
|
|
840
|
+
break;
|
|
841
|
+
default: break;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Handles job progress events. Currently a no-op but can be extended
|
|
846
|
+
* for progress-specific telemetry tracking.
|
|
847
|
+
*/
|
|
848
|
+
handleJobProgress(_event) {}
|
|
849
|
+
/**
|
|
850
|
+
* Cleans up event listeners.
|
|
851
|
+
*/
|
|
852
|
+
shutdown() {
|
|
853
|
+
for (const unsubscribe of this.unsubscribers) unsubscribe();
|
|
854
|
+
this.unsubscribers = [];
|
|
855
|
+
logger.debug("TelemetryService shut down");
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/events/EventBusService.ts
|
|
860
|
+
/**
|
|
861
|
+
* Central event bus service for application-wide event distribution.
|
|
862
|
+
*
|
|
863
|
+
* This service provides a pub/sub mechanism that can be used by any service
|
|
864
|
+
* to emit and listen for events. Events emitted here can be:
|
|
865
|
+
* - Consumed locally by in-process subscribers
|
|
866
|
+
* - Broadcast to remote processes via tRPC subscriptions
|
|
867
|
+
* - Forwarded to SSE clients via the web service
|
|
868
|
+
*
|
|
869
|
+
* This decouples event producers (like DocumentManagementService) from
|
|
870
|
+
* consumers (like the Web UI), enabling a clean, scalable architecture.
|
|
871
|
+
*/
|
|
872
|
+
/**
|
|
873
|
+
* Central event bus for application-wide events.
|
|
874
|
+
*/
|
|
875
|
+
var EventBusService = class {
|
|
876
|
+
emitter;
|
|
877
|
+
constructor() {
|
|
878
|
+
this.emitter = new EventEmitter();
|
|
879
|
+
this.emitter.setMaxListeners(100);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Emit an event to all subscribers.
|
|
883
|
+
*/
|
|
884
|
+
emit(eventType, payload) {
|
|
885
|
+
logger.debug(`Event emitted: ${eventType}`);
|
|
886
|
+
this.emitter.emit(eventType, payload);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Subscribe to events of a specific type.
|
|
890
|
+
* Returns an unsubscribe function.
|
|
891
|
+
*/
|
|
892
|
+
on(eventType, listener) {
|
|
893
|
+
this.emitter.on(eventType, listener);
|
|
894
|
+
return () => this.emitter.off(eventType, listener);
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Subscribe to events once (auto-unsubscribes after first event).
|
|
898
|
+
*/
|
|
899
|
+
once(eventType, listener) {
|
|
900
|
+
this.emitter.once(eventType, listener);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Remove a specific listener.
|
|
904
|
+
*/
|
|
905
|
+
off(eventType, listener) {
|
|
906
|
+
this.emitter.off(eventType, listener);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Remove all listeners for a specific event type, or all listeners if no type specified.
|
|
910
|
+
*/
|
|
911
|
+
removeAllListeners(eventType) {
|
|
912
|
+
if (eventType === void 0) this.emitter.removeAllListeners();
|
|
913
|
+
else this.emitter.removeAllListeners(eventType);
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Get the count of listeners for a specific event type.
|
|
917
|
+
*/
|
|
918
|
+
listenerCount(eventType) {
|
|
919
|
+
return this.emitter.listenerCount(eventType);
|
|
865
920
|
}
|
|
866
921
|
};
|
|
867
922
|
//#endregion
|
|
@@ -1098,6 +1153,6 @@ async function handleEmbeddingModelChange(error, service) {
|
|
|
1098
1153
|
await service.resolveModelChange();
|
|
1099
1154
|
}
|
|
1100
1155
|
//#endregion
|
|
1101
|
-
export {
|
|
1156
|
+
export { shouldEnableTelemetry as C, SUPPORTED_PROVIDERS as D, EmbeddingConfig as E, splitModelSpec as O, EventType as S, resolveStorePath as T, TelemetryService as _, getGlobalOptions as a, telemetry as b, parseHeaders as c, validateAuthConfig as d, validateHost as f, EventBusService as g, warnHttpUsage as h, getEventBus as i, resolveEmbeddingContext as l, validateResumeFlag as m, createEventServices as n, handleEmbeddingModelChange as o, validatePort as p, ensurePlaywrightBrowsersInstalled as r, parseAuthConfig as s, createAppServerConfig as t, resolveProtocol as u, TelemetryEvent as v, getProjectRoot as w, PipelineJobStatus as x, initTelemetry as y };
|
|
1102
1157
|
|
|
1103
|
-
//# sourceMappingURL=utils-
|
|
1158
|
+
//# sourceMappingURL=utils-uCqhR-rj.js.map
|