@vohongtho.infotech/code-intel 0.3.0 → 0.3.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/dist/index.js CHANGED
@@ -1,18 +1,14 @@
1
1
  import { createRequire } from 'module';
2
2
  import { fileURLToPath } from 'url';
3
- import * as path27 from 'path';
4
- import path27__default from 'path';
5
- import * as fs19 from 'fs';
6
- import fs19__default, { existsSync } from 'fs';
3
+ import path26 from 'path';
4
+ import fs18, { existsSync } from 'fs';
7
5
  import { Parser, Language, Query } from 'web-tree-sitter';
8
- import { trace, context, SpanStatusCode, diag, baggageEntryMetadataFromString } from '@opentelemetry/api';
9
- import { inspect } from 'util';
10
- import * as zlib from 'zlib';
11
- import { Readable } from 'stream';
12
6
  import { NodeSDK } from '@opentelemetry/sdk-node';
13
7
  import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
8
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
14
9
  import { resourceFromAttributes } from '@opentelemetry/resources';
15
10
  import { SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
11
+ import { trace, context, SpanStatusCode } from '@opentelemetry/api';
16
12
  import winston from 'winston';
17
13
  import DailyRotateFile from 'winston-daily-rotate-file';
18
14
  import os12 from 'os';
@@ -117,11 +113,11 @@ var init_shared = __esm({
117
113
  }
118
114
  });
119
115
  function findBundledWasmDir() {
120
- const fileDir = path27__default.dirname(fileURLToPath(import.meta.url));
116
+ const fileDir = path26.dirname(fileURLToPath(import.meta.url));
121
117
  const candidates = [
122
- path27__default.join(fileDir, "wasm"),
118
+ path26.join(fileDir, "wasm"),
123
119
  // dist/index.js → dist/wasm/
124
- path27__default.join(fileDir, "../wasm")
120
+ path26.join(fileDir, "../wasm")
125
121
  // dist/cli/main.js → dist/wasm/
126
122
  ];
127
123
  for (const candidate of candidates) {
@@ -162,7 +158,7 @@ function wasmPath(lang) {
162
158
  }
163
159
  const bundled = BUNDLED_WASM_MAP[lang];
164
160
  if (bundled) {
165
- const bundledPath = path27__default.join(_bundledWasmDir, bundled);
161
+ const bundledPath = path26.join(_bundledWasmDir, bundled);
166
162
  if (existsSync(bundledPath)) return bundledPath;
167
163
  }
168
164
  return null;
@@ -175,14 +171,14 @@ async function initParser() {
175
171
  }
176
172
  async function getLanguage(lang) {
177
173
  if (languageCache.has(lang)) return languageCache.get(lang);
178
- const path29 = wasmPath(lang);
179
- if (!path29) {
174
+ const path28 = wasmPath(lang);
175
+ if (!path28) {
180
176
  languageCache.set(lang, null);
181
177
  return null;
182
178
  }
183
179
  try {
184
180
  await initParser();
185
- const language = await Language.load(path29);
181
+ const language = await Language.load(path28);
186
182
  languageCache.set(lang, language);
187
183
  return language;
188
184
  } catch {
@@ -886,1227 +882,6 @@ var init_swift = __esm({
886
882
  }
887
883
  });
888
884
 
889
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
890
- var OTLPExporterBase;
891
- var init_OTLPExporterBase = __esm({
892
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js"() {
893
- OTLPExporterBase = class {
894
- _delegate;
895
- constructor(delegate) {
896
- this._delegate = delegate;
897
- }
898
- /**
899
- * Export items.
900
- * @param items
901
- * @param resultCallback
902
- */
903
- export(items, resultCallback) {
904
- this._delegate.export(items, resultCallback);
905
- }
906
- forceFlush() {
907
- return this._delegate.forceFlush();
908
- }
909
- shutdown() {
910
- return this._delegate.shutdown();
911
- }
912
- };
913
- }
914
- });
915
-
916
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
917
- var OTLPExporterError;
918
- var init_types = __esm({
919
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js"() {
920
- OTLPExporterError = class extends Error {
921
- code;
922
- name = "OTLPExporterError";
923
- data;
924
- constructor(message, code, data) {
925
- super(message);
926
- this.data = data;
927
- this.code = code;
928
- }
929
- };
930
- }
931
- });
932
-
933
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
934
- function validateTimeoutMillis(timeoutMillis) {
935
- if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
936
- return timeoutMillis;
937
- }
938
- throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
939
- }
940
- function wrapStaticHeadersInFunction(headers) {
941
- if (headers == null) {
942
- return void 0;
943
- }
944
- return async () => headers;
945
- }
946
- function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
947
- return {
948
- timeoutMillis: validateTimeoutMillis(userProvidedConfiguration.timeoutMillis ?? fallbackConfiguration.timeoutMillis ?? defaultConfiguration.timeoutMillis),
949
- concurrencyLimit: userProvidedConfiguration.concurrencyLimit ?? fallbackConfiguration.concurrencyLimit ?? defaultConfiguration.concurrencyLimit,
950
- compression: userProvidedConfiguration.compression ?? fallbackConfiguration.compression ?? defaultConfiguration.compression
951
- };
952
- }
953
- function getSharedConfigurationDefaults() {
954
- return {
955
- timeoutMillis: 1e4,
956
- concurrencyLimit: 30,
957
- compression: "none"
958
- };
959
- }
960
- var init_shared_configuration = __esm({
961
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js"() {
962
- }
963
- });
964
-
965
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
966
- function createBoundedQueueExportPromiseHandler(options) {
967
- return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
968
- }
969
- var BoundedQueueExportPromiseHandler;
970
- var init_bounded_queue_export_promise_handler = __esm({
971
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js"() {
972
- BoundedQueueExportPromiseHandler = class {
973
- _concurrencyLimit;
974
- _sendingPromises = [];
975
- /**
976
- * @param concurrencyLimit maximum promises allowed in a queue at the same time.
977
- */
978
- constructor(concurrencyLimit) {
979
- this._concurrencyLimit = concurrencyLimit;
980
- }
981
- pushPromise(promise) {
982
- if (this.hasReachedLimit()) {
983
- throw new Error("Concurrency Limit reached");
984
- }
985
- this._sendingPromises.push(promise);
986
- const popPromise = () => {
987
- const index = this._sendingPromises.indexOf(promise);
988
- void this._sendingPromises.splice(index, 1);
989
- };
990
- promise.then(popPromise, popPromise);
991
- }
992
- hasReachedLimit() {
993
- return this._sendingPromises.length >= this._concurrencyLimit;
994
- }
995
- async awaitAll() {
996
- await Promise.all(this._sendingPromises);
997
- }
998
- };
999
- }
1000
- });
1001
-
1002
- // ../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js
1003
- var BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_ITEMS_SEPARATOR;
1004
- var init_constants = __esm({
1005
- "../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js"() {
1006
- BAGGAGE_KEY_PAIR_SEPARATOR = "=";
1007
- BAGGAGE_PROPERTIES_SEPARATOR = ";";
1008
- BAGGAGE_ITEMS_SEPARATOR = ",";
1009
- }
1010
- });
1011
- function parsePairKeyValue(entry) {
1012
- if (!entry)
1013
- return;
1014
- const metadataSeparatorIndex = entry.indexOf(BAGGAGE_PROPERTIES_SEPARATOR);
1015
- const keyPairPart = metadataSeparatorIndex === -1 ? entry : entry.substring(0, metadataSeparatorIndex);
1016
- const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
1017
- if (separatorIndex <= 0)
1018
- return;
1019
- const rawKey = keyPairPart.substring(0, separatorIndex).trim();
1020
- const rawValue = keyPairPart.substring(separatorIndex + 1).trim();
1021
- if (!rawKey || !rawValue)
1022
- return;
1023
- let key;
1024
- let value;
1025
- try {
1026
- key = decodeURIComponent(rawKey);
1027
- value = decodeURIComponent(rawValue);
1028
- } catch {
1029
- return;
1030
- }
1031
- let metadata;
1032
- if (metadataSeparatorIndex !== -1 && metadataSeparatorIndex < entry.length - 1) {
1033
- const metadataString = entry.substring(metadataSeparatorIndex + 1);
1034
- metadata = baggageEntryMetadataFromString(metadataString);
1035
- }
1036
- return { key, value, metadata };
1037
- }
1038
- function parseKeyPairsIntoRecord(value) {
1039
- const result = {};
1040
- if (typeof value === "string" && value.length > 0) {
1041
- value.split(BAGGAGE_ITEMS_SEPARATOR).forEach((entry) => {
1042
- const keyPair = parsePairKeyValue(entry);
1043
- if (keyPair !== void 0 && keyPair.value.length > 0) {
1044
- result[keyPair.key] = keyPair.value;
1045
- }
1046
- });
1047
- }
1048
- return result;
1049
- }
1050
- var init_utils = __esm({
1051
- "../../node_modules/@opentelemetry/core/build/esm/baggage/utils.js"() {
1052
- init_constants();
1053
- }
1054
- });
1055
- function getNumberFromEnv(key) {
1056
- const raw = process.env[key];
1057
- if (raw == null || raw.trim() === "") {
1058
- return void 0;
1059
- }
1060
- const value = Number(raw);
1061
- if (isNaN(value)) {
1062
- diag.warn(`Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`);
1063
- return void 0;
1064
- }
1065
- return value;
1066
- }
1067
- function getStringFromEnv(key) {
1068
- const raw = process.env[key];
1069
- if (raw == null || raw.trim() === "") {
1070
- return void 0;
1071
- }
1072
- return raw;
1073
- }
1074
- var init_environment = __esm({
1075
- "../../node_modules/@opentelemetry/core/build/esm/platform/node/environment.js"() {
1076
- }
1077
- });
1078
-
1079
- // ../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js
1080
- var init_node = __esm({
1081
- "../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js"() {
1082
- init_environment();
1083
- }
1084
- });
1085
-
1086
- // ../../node_modules/@opentelemetry/core/build/esm/platform/index.js
1087
- var init_platform = __esm({
1088
- "../../node_modules/@opentelemetry/core/build/esm/platform/index.js"() {
1089
- init_node();
1090
- }
1091
- });
1092
-
1093
- // ../../node_modules/@opentelemetry/core/build/esm/common/time.js
1094
- function hrTimeToNanoseconds(time) {
1095
- return time[0] * SECOND_TO_NANOSECONDS + time[1];
1096
- }
1097
- var NANOSECOND_DIGITS, SECOND_TO_NANOSECONDS;
1098
- var init_time = __esm({
1099
- "../../node_modules/@opentelemetry/core/build/esm/common/time.js"() {
1100
- NANOSECOND_DIGITS = 9;
1101
- SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
1102
- }
1103
- });
1104
-
1105
- // ../../node_modules/@opentelemetry/core/build/esm/ExportResult.js
1106
- var ExportResultCode;
1107
- var init_ExportResult = __esm({
1108
- "../../node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
1109
- (function(ExportResultCode2) {
1110
- ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
1111
- ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
1112
- })(ExportResultCode || (ExportResultCode = {}));
1113
- }
1114
- });
1115
-
1116
- // ../../node_modules/@opentelemetry/core/build/esm/index.js
1117
- var init_esm = __esm({
1118
- "../../node_modules/@opentelemetry/core/build/esm/index.js"() {
1119
- init_time();
1120
- init_ExportResult();
1121
- init_utils();
1122
- init_platform();
1123
- }
1124
- });
1125
- function isPartialSuccessResponse(response) {
1126
- return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
1127
- }
1128
- function createLoggingPartialSuccessResponseHandler() {
1129
- return {
1130
- handleResponse(response) {
1131
- if (response == null || !isPartialSuccessResponse(response) || response.partialSuccess == null || Object.keys(response.partialSuccess).length === 0) {
1132
- return;
1133
- }
1134
- diag.warn("Received Partial Success response:", JSON.stringify(response.partialSuccess));
1135
- }
1136
- };
1137
- }
1138
- var init_logging_response_handler = __esm({
1139
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js"() {
1140
- }
1141
- });
1142
- function createOtlpExportDelegate(components, settings) {
1143
- return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
1144
- }
1145
- var OTLPExportDelegate;
1146
- var init_otlp_export_delegate = __esm({
1147
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js"() {
1148
- init_esm();
1149
- init_types();
1150
- init_logging_response_handler();
1151
- OTLPExportDelegate = class {
1152
- _diagLogger;
1153
- _transport;
1154
- _serializer;
1155
- _responseHandler;
1156
- _promiseQueue;
1157
- _timeout;
1158
- constructor(transport, serializer, responseHandler, promiseQueue, timeout) {
1159
- this._transport = transport;
1160
- this._serializer = serializer;
1161
- this._responseHandler = responseHandler;
1162
- this._promiseQueue = promiseQueue;
1163
- this._timeout = timeout;
1164
- this._diagLogger = diag.createComponentLogger({
1165
- namespace: "OTLPExportDelegate"
1166
- });
1167
- }
1168
- export(internalRepresentation, resultCallback) {
1169
- this._diagLogger.debug("items to be sent", internalRepresentation);
1170
- if (this._promiseQueue.hasReachedLimit()) {
1171
- resultCallback({
1172
- code: ExportResultCode.FAILED,
1173
- error: new Error("Concurrent export limit reached")
1174
- });
1175
- return;
1176
- }
1177
- const serializedRequest = this._serializer.serializeRequest(internalRepresentation);
1178
- if (serializedRequest == null) {
1179
- resultCallback({
1180
- code: ExportResultCode.FAILED,
1181
- error: new Error("Nothing to send")
1182
- });
1183
- return;
1184
- }
1185
- this._promiseQueue.pushPromise(this._transport.send(serializedRequest, this._timeout).then((response) => {
1186
- if (response.status === "success") {
1187
- if (response.data != null) {
1188
- try {
1189
- this._responseHandler.handleResponse(this._serializer.deserializeResponse(response.data));
1190
- } catch (e) {
1191
- this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?", e, response.data);
1192
- }
1193
- }
1194
- resultCallback({
1195
- code: ExportResultCode.SUCCESS
1196
- });
1197
- return;
1198
- } else if (response.status === "failure" && response.error) {
1199
- resultCallback({
1200
- code: ExportResultCode.FAILED,
1201
- error: response.error
1202
- });
1203
- return;
1204
- } else if (response.status === "retryable") {
1205
- resultCallback({
1206
- code: ExportResultCode.FAILED,
1207
- error: response.error ?? new OTLPExporterError("Export failed with retryable status")
1208
- });
1209
- } else {
1210
- resultCallback({
1211
- code: ExportResultCode.FAILED,
1212
- error: new OTLPExporterError("Export failed with unknown error")
1213
- });
1214
- }
1215
- }, (reason) => resultCallback({
1216
- code: ExportResultCode.FAILED,
1217
- error: reason
1218
- })));
1219
- }
1220
- forceFlush() {
1221
- return this._promiseQueue.awaitAll();
1222
- }
1223
- async shutdown() {
1224
- this._diagLogger.debug("shutdown started");
1225
- await this.forceFlush();
1226
- this._transport.shutdown();
1227
- }
1228
- };
1229
- }
1230
- });
1231
-
1232
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
1233
- var init_esm2 = __esm({
1234
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js"() {
1235
- init_OTLPExporterBase();
1236
- }
1237
- });
1238
-
1239
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
1240
- function createResource(resource, encoder) {
1241
- const result = {
1242
- attributes: toAttributes(resource.attributes, encoder),
1243
- droppedAttributesCount: 0
1244
- };
1245
- const schemaUrl = resource.schemaUrl;
1246
- if (schemaUrl && schemaUrl !== "")
1247
- result.schemaUrl = schemaUrl;
1248
- return result;
1249
- }
1250
- function createInstrumentationScope(scope) {
1251
- return {
1252
- name: scope.name,
1253
- version: scope.version
1254
- };
1255
- }
1256
- function toAttributes(attributes, encoder) {
1257
- return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key], encoder));
1258
- }
1259
- function toKeyValue(key, value, encoder) {
1260
- return {
1261
- key,
1262
- value: toAnyValue(value, encoder)
1263
- };
1264
- }
1265
- function toAnyValue(value, encoder) {
1266
- const t = typeof value;
1267
- if (t === "string")
1268
- return { stringValue: value };
1269
- if (t === "number") {
1270
- if (!Number.isInteger(value))
1271
- return { doubleValue: value };
1272
- return { intValue: value };
1273
- }
1274
- if (t === "boolean")
1275
- return { boolValue: value };
1276
- if (value instanceof Uint8Array)
1277
- return { bytesValue: encoder.encodeUint8Array(value) };
1278
- if (Array.isArray(value)) {
1279
- const values = new Array(value.length);
1280
- for (let i = 0; i < value.length; i++) {
1281
- values[i] = toAnyValue(value[i], encoder);
1282
- }
1283
- return { arrayValue: { values } };
1284
- }
1285
- if (t === "object" && value != null) {
1286
- const keys = Object.keys(value);
1287
- const values = new Array(keys.length);
1288
- for (let i = 0; i < keys.length; i++) {
1289
- values[i] = {
1290
- key: keys[i],
1291
- value: toAnyValue(value[keys[i]], encoder)
1292
- };
1293
- }
1294
- return { kvlistValue: { values } };
1295
- }
1296
- return {};
1297
- }
1298
- var init_internal = __esm({
1299
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js"() {
1300
- }
1301
- });
1302
-
1303
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
1304
- function hrTimeToNanos(hrTime2) {
1305
- const NANOSECONDS = BigInt(1e9);
1306
- return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
1307
- }
1308
- function encodeAsString(hrTime2) {
1309
- const nanos = hrTimeToNanos(hrTime2);
1310
- return nanos.toString();
1311
- }
1312
- function identity(value) {
1313
- return value;
1314
- }
1315
- var encodeTimestamp, JSON_ENCODER;
1316
- var init_utils2 = __esm({
1317
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js"() {
1318
- init_esm();
1319
- encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds;
1320
- JSON_ENCODER = {
1321
- encodeHrTime: encodeTimestamp,
1322
- encodeSpanContext: identity,
1323
- encodeOptionalSpanContext: identity,
1324
- encodeUint8Array: (bytes) => {
1325
- if (typeof Buffer !== "undefined") {
1326
- return Buffer.from(bytes).toString("base64");
1327
- }
1328
- const chars = new Array(bytes.length);
1329
- for (let i = 0; i < bytes.length; i++) {
1330
- chars[i] = String.fromCharCode(bytes[i]);
1331
- }
1332
- return btoa(chars.join(""));
1333
- }
1334
- };
1335
- }
1336
- });
1337
-
1338
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
1339
- function buildSpanFlagsFrom(traceFlags, isRemote) {
1340
- let flags = traceFlags & 255 | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK;
1341
- if (isRemote) {
1342
- flags |= SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
1343
- }
1344
- return flags;
1345
- }
1346
- function sdkSpanToOtlpSpan(span, encoder) {
1347
- const ctx = span.spanContext();
1348
- const status = span.status;
1349
- const parentSpanId = span.parentSpanContext?.spanId ? encoder.encodeSpanContext(span.parentSpanContext?.spanId) : void 0;
1350
- return {
1351
- traceId: encoder.encodeSpanContext(ctx.traceId),
1352
- spanId: encoder.encodeSpanContext(ctx.spanId),
1353
- parentSpanId,
1354
- traceState: ctx.traceState?.serialize(),
1355
- name: span.name,
1356
- // Span kind is offset by 1 because the API does not define a value for unset
1357
- kind: span.kind == null ? 0 : span.kind + 1,
1358
- startTimeUnixNano: encoder.encodeHrTime(span.startTime),
1359
- endTimeUnixNano: encoder.encodeHrTime(span.endTime),
1360
- attributes: toAttributes(span.attributes, encoder),
1361
- droppedAttributesCount: span.droppedAttributesCount,
1362
- events: span.events.map((event) => toOtlpSpanEvent(event, encoder)),
1363
- droppedEventsCount: span.droppedEventsCount,
1364
- status: {
1365
- // API and proto enums share the same values
1366
- code: status.code,
1367
- message: status.message
1368
- },
1369
- links: span.links.map((link) => toOtlpLink(link, encoder)),
1370
- droppedLinksCount: span.droppedLinksCount,
1371
- flags: buildSpanFlagsFrom(ctx.traceFlags, span.parentSpanContext?.isRemote)
1372
- };
1373
- }
1374
- function toOtlpLink(link, encoder) {
1375
- return {
1376
- attributes: link.attributes ? toAttributes(link.attributes, encoder) : [],
1377
- spanId: encoder.encodeSpanContext(link.context.spanId),
1378
- traceId: encoder.encodeSpanContext(link.context.traceId),
1379
- traceState: link.context.traceState?.serialize(),
1380
- droppedAttributesCount: link.droppedAttributesCount || 0,
1381
- flags: buildSpanFlagsFrom(link.context.traceFlags, link.context.isRemote)
1382
- };
1383
- }
1384
- function toOtlpSpanEvent(timedEvent, encoder) {
1385
- return {
1386
- attributes: timedEvent.attributes ? toAttributes(timedEvent.attributes, encoder) : [],
1387
- name: timedEvent.name,
1388
- timeUnixNano: encoder.encodeHrTime(timedEvent.time),
1389
- droppedAttributesCount: timedEvent.droppedAttributesCount || 0
1390
- };
1391
- }
1392
- function createExportTraceServiceRequest(spans, encoder) {
1393
- return {
1394
- resourceSpans: spanRecordsToResourceSpans(spans, encoder)
1395
- };
1396
- }
1397
- function createResourceMap(readableSpans) {
1398
- const resourceMap = /* @__PURE__ */ new Map();
1399
- for (const record of readableSpans) {
1400
- let ilsMap = resourceMap.get(record.resource);
1401
- if (!ilsMap) {
1402
- ilsMap = /* @__PURE__ */ new Map();
1403
- resourceMap.set(record.resource, ilsMap);
1404
- }
1405
- const instrumentationScopeKey = `${record.instrumentationScope.name}@${record.instrumentationScope.version || ""}:${record.instrumentationScope.schemaUrl || ""}`;
1406
- let records = ilsMap.get(instrumentationScopeKey);
1407
- if (!records) {
1408
- records = [];
1409
- ilsMap.set(instrumentationScopeKey, records);
1410
- }
1411
- records.push(record);
1412
- }
1413
- return resourceMap;
1414
- }
1415
- function spanRecordsToResourceSpans(readableSpans, encoder) {
1416
- const resourceMap = createResourceMap(readableSpans);
1417
- const out = [];
1418
- const entryIterator = resourceMap.entries();
1419
- let entry = entryIterator.next();
1420
- while (!entry.done) {
1421
- const [resource, ilmMap] = entry.value;
1422
- const scopeResourceSpans = [];
1423
- const ilmIterator = ilmMap.values();
1424
- let ilmEntry = ilmIterator.next();
1425
- while (!ilmEntry.done) {
1426
- const scopeSpans = ilmEntry.value;
1427
- if (scopeSpans.length > 0) {
1428
- const spans = scopeSpans.map((readableSpan) => sdkSpanToOtlpSpan(readableSpan, encoder));
1429
- scopeResourceSpans.push({
1430
- scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
1431
- spans,
1432
- schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl
1433
- });
1434
- }
1435
- ilmEntry = ilmIterator.next();
1436
- }
1437
- const processedResource = createResource(resource, encoder);
1438
- const transformedSpans = {
1439
- resource: processedResource,
1440
- scopeSpans: scopeResourceSpans,
1441
- schemaUrl: processedResource.schemaUrl
1442
- };
1443
- out.push(transformedSpans);
1444
- entry = entryIterator.next();
1445
- }
1446
- return out;
1447
- }
1448
- var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK, SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
1449
- var init_internal2 = __esm({
1450
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js"() {
1451
- init_internal();
1452
- SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
1453
- SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
1454
- }
1455
- });
1456
- var JsonTraceSerializer;
1457
- var init_trace = __esm({
1458
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js"() {
1459
- init_internal2();
1460
- init_utils2();
1461
- JsonTraceSerializer = {
1462
- serializeRequest: (arg) => {
1463
- const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
1464
- const encoder = new TextEncoder();
1465
- return encoder.encode(JSON.stringify(request));
1466
- },
1467
- deserializeResponse: (arg) => {
1468
- if (arg.length === 0) {
1469
- return {};
1470
- }
1471
- const decoder = new TextDecoder();
1472
- try {
1473
- return JSON.parse(decoder.decode(arg));
1474
- } catch (err) {
1475
- diag.warn(`Failed to parse trace export response: ${err.message}. Returning empty response`);
1476
- return {};
1477
- }
1478
- }
1479
- };
1480
- }
1481
- });
1482
-
1483
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
1484
- var init_json = __esm({
1485
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js"() {
1486
- init_trace();
1487
- }
1488
- });
1489
-
1490
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
1491
- var init_esm3 = __esm({
1492
- "../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js"() {
1493
- init_json();
1494
- }
1495
- });
1496
- function validateAndNormalizeHeaders(partialHeaders) {
1497
- const headers = {};
1498
- Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {
1499
- if (typeof value !== "undefined") {
1500
- headers[key] = String(value);
1501
- } else {
1502
- diag.warn(`Header "${key}" has invalid value (${value}) and will be ignored`);
1503
- }
1504
- });
1505
- return headers;
1506
- }
1507
- var init_util = __esm({
1508
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js"() {
1509
- }
1510
- });
1511
-
1512
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
1513
- function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
1514
- return async () => {
1515
- const requiredHeaders = {
1516
- ...await defaultHeaders()
1517
- };
1518
- const headers = {};
1519
- if (fallbackHeaders != null) {
1520
- Object.assign(headers, await fallbackHeaders());
1521
- }
1522
- if (userProvidedHeaders != null) {
1523
- Object.assign(headers, validateAndNormalizeHeaders(await userProvidedHeaders()));
1524
- }
1525
- return Object.assign(headers, requiredHeaders);
1526
- };
1527
- }
1528
- function validateUserProvidedUrl(url) {
1529
- if (url == null) {
1530
- return void 0;
1531
- }
1532
- try {
1533
- const base = globalThis.location?.href;
1534
- return new URL(url, base).href;
1535
- } catch {
1536
- throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
1537
- }
1538
- }
1539
- function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
1540
- return {
1541
- ...mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
1542
- headers: mergeHeaders(userProvidedConfiguration.headers, fallbackConfiguration.headers, defaultConfiguration.headers),
1543
- url: validateUserProvidedUrl(userProvidedConfiguration.url) ?? fallbackConfiguration.url ?? defaultConfiguration.url
1544
- };
1545
- }
1546
- function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
1547
- return {
1548
- ...getSharedConfigurationDefaults(),
1549
- headers: async () => requiredHeaders,
1550
- url: "http://localhost:4318/" + signalResourcePath
1551
- };
1552
- }
1553
- var init_otlp_http_configuration = __esm({
1554
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js"() {
1555
- init_shared_configuration();
1556
- init_util();
1557
- }
1558
- });
1559
-
1560
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js
1561
- function httpAgentFactoryFromOptions(options) {
1562
- return async (protocol) => {
1563
- const isInsecure = protocol === "http:";
1564
- const module = isInsecure ? import('http') : import('https');
1565
- const { Agent } = await module;
1566
- if (isInsecure) {
1567
- const { ca, cert, key, ...insecureOptions } = options;
1568
- return new Agent(insecureOptions);
1569
- }
1570
- return new Agent(options);
1571
- };
1572
- }
1573
- function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
1574
- return {
1575
- ...mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
1576
- agentFactory: userProvidedConfiguration.agentFactory ?? fallbackConfiguration.agentFactory ?? defaultConfiguration.agentFactory,
1577
- userAgent: userProvidedConfiguration.userAgent
1578
- };
1579
- }
1580
- function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
1581
- return {
1582
- ...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),
1583
- agentFactory: httpAgentFactoryFromOptions({ keepAlive: true })
1584
- };
1585
- }
1586
- var init_otlp_node_http_configuration = __esm({
1587
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js"() {
1588
- init_otlp_http_configuration();
1589
- }
1590
- });
1591
-
1592
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
1593
- function isExportHTTPErrorRetryable(statusCode) {
1594
- return statusCode === 429 || statusCode === 502 || statusCode === 503 || statusCode === 504;
1595
- }
1596
- function parseRetryAfterToMills(retryAfter) {
1597
- if (retryAfter == null) {
1598
- return void 0;
1599
- }
1600
- const seconds = Number.parseInt(retryAfter, 10);
1601
- if (Number.isInteger(seconds)) {
1602
- return seconds > 0 ? seconds * 1e3 : -1;
1603
- }
1604
- const delay = new Date(retryAfter).getTime() - Date.now();
1605
- if (delay >= 0) {
1606
- return delay;
1607
- }
1608
- return 0;
1609
- }
1610
- var init_is_export_retryable = __esm({
1611
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js"() {
1612
- }
1613
- });
1614
-
1615
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
1616
- var VERSION;
1617
- var init_version = __esm({
1618
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js"() {
1619
- VERSION = "0.215.0";
1620
- }
1621
- });
1622
- function sendWithHttp(request, url, headers, compression, userAgent, agent, data, timeoutMillis) {
1623
- return new Promise((resolve2) => {
1624
- const parsedUrl = new URL(url);
1625
- if (userAgent) {
1626
- headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
1627
- } else {
1628
- headers["User-Agent"] = DEFAULT_USER_AGENT;
1629
- }
1630
- const options = {
1631
- hostname: parsedUrl.hostname,
1632
- port: parsedUrl.port,
1633
- path: parsedUrl.pathname,
1634
- method: "POST",
1635
- headers,
1636
- agent
1637
- };
1638
- const req = request(options, (res) => {
1639
- const responseData = [];
1640
- let responseSize = 0;
1641
- res.on("data", (chunk) => {
1642
- responseSize += chunk.length;
1643
- if (responseSize > MAX_RESPONSE_BODY_SIZE) {
1644
- const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
1645
- resolve2({ status: "failure", error: sizeError });
1646
- res.destroy();
1647
- return;
1648
- }
1649
- responseData.push(chunk);
1650
- });
1651
- res.on("end", () => {
1652
- if (res.statusCode && res.statusCode <= 299) {
1653
- resolve2({
1654
- status: "success",
1655
- data: Buffer.concat(responseData)
1656
- });
1657
- } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
1658
- resolve2({
1659
- status: "retryable",
1660
- retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
1661
- });
1662
- } else {
1663
- const error = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
1664
- resolve2({
1665
- status: "failure",
1666
- error
1667
- });
1668
- }
1669
- });
1670
- res.on("error", (error) => {
1671
- if (res.statusCode && res.statusCode <= 299) {
1672
- resolve2({
1673
- status: "success"
1674
- });
1675
- } else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
1676
- resolve2({
1677
- status: "retryable",
1678
- error,
1679
- retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
1680
- });
1681
- } else {
1682
- resolve2({
1683
- status: "failure",
1684
- error
1685
- });
1686
- }
1687
- });
1688
- });
1689
- req.setTimeout(timeoutMillis, () => {
1690
- req.destroy();
1691
- resolve2({
1692
- status: "retryable",
1693
- error: new Error("Request timed out")
1694
- });
1695
- });
1696
- req.on("error", (error) => {
1697
- if (isHttpTransportNetworkErrorRetryable(error)) {
1698
- resolve2({
1699
- status: "retryable",
1700
- error
1701
- });
1702
- } else {
1703
- resolve2({
1704
- status: "failure",
1705
- error
1706
- });
1707
- }
1708
- });
1709
- compressAndSend(req, compression, data, (error) => {
1710
- resolve2({
1711
- status: "failure",
1712
- error
1713
- });
1714
- });
1715
- });
1716
- }
1717
- function compressAndSend(req, compression, data, onError) {
1718
- let dataStream = readableFromUint8Array(data);
1719
- if (compression === "gzip") {
1720
- req.setHeader("Content-Encoding", "gzip");
1721
- dataStream = dataStream.on("error", onError).pipe(zlib.createGzip()).on("error", onError);
1722
- }
1723
- dataStream.pipe(req).on("error", onError);
1724
- }
1725
- function readableFromUint8Array(buff) {
1726
- const readable = new Readable();
1727
- readable.push(buff);
1728
- readable.push(null);
1729
- return readable;
1730
- }
1731
- function isHttpTransportNetworkErrorRetryable(error) {
1732
- const RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
1733
- "ECONNRESET",
1734
- "ECONNREFUSED",
1735
- "EPIPE",
1736
- "ETIMEDOUT",
1737
- "EAI_AGAIN",
1738
- "ENOTFOUND",
1739
- "ENETUNREACH",
1740
- "EHOSTUNREACH"
1741
- ]);
1742
- if ("code" in error && typeof error.code === "string") {
1743
- return RETRYABLE_NETWORK_ERROR_CODES.has(error.code);
1744
- }
1745
- return false;
1746
- }
1747
- var DEFAULT_USER_AGENT, MAX_RESPONSE_BODY_SIZE;
1748
- var init_http_transport_utils = __esm({
1749
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js"() {
1750
- init_is_export_retryable();
1751
- init_types();
1752
- init_version();
1753
- DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;
1754
- MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
1755
- }
1756
- });
1757
-
1758
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
1759
- async function requestFunctionFactory(protocol) {
1760
- const module = protocol === "http:" ? import('http') : import('https');
1761
- const { request } = await module;
1762
- return request;
1763
- }
1764
- function createHttpExporterTransport(parameters) {
1765
- return new HttpExporterTransport(parameters);
1766
- }
1767
- var HttpExporterTransport;
1768
- var init_http_exporter_transport = __esm({
1769
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js"() {
1770
- init_http_transport_utils();
1771
- HttpExporterTransport = class {
1772
- _utils = null;
1773
- _parameters;
1774
- constructor(parameters) {
1775
- this._parameters = parameters;
1776
- }
1777
- async send(data, timeoutMillis) {
1778
- const { agent, request } = await this._loadUtils();
1779
- const headers = await this._parameters.headers();
1780
- return sendWithHttp(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, timeoutMillis);
1781
- }
1782
- shutdown() {
1783
- }
1784
- async _loadUtils() {
1785
- let utils = this._utils;
1786
- if (utils === null) {
1787
- const protocol = new URL(this._parameters.url).protocol;
1788
- const [agent, request] = await Promise.all([
1789
- this._parameters.agentFactory(protocol),
1790
- requestFunctionFactory(protocol)
1791
- ]);
1792
- utils = this._utils = { agent, request };
1793
- }
1794
- return utils;
1795
- }
1796
- };
1797
- }
1798
- });
1799
- function getJitter() {
1800
- return Math.random() * (2 * JITTER) - JITTER;
1801
- }
1802
- function createRetryingTransport(options) {
1803
- return new RetryingTransport(options.transport);
1804
- }
1805
- var MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_MULTIPLIER, JITTER, RetryingTransport;
1806
- var init_retrying_transport = __esm({
1807
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js"() {
1808
- MAX_ATTEMPTS = 5;
1809
- INITIAL_BACKOFF = 1e3;
1810
- MAX_BACKOFF = 5e3;
1811
- BACKOFF_MULTIPLIER = 1.5;
1812
- JITTER = 0.2;
1813
- RetryingTransport = class {
1814
- _transport;
1815
- constructor(transport) {
1816
- this._transport = transport;
1817
- }
1818
- retry(data, timeoutMillis, inMillis) {
1819
- return new Promise((resolve2, reject) => {
1820
- setTimeout(() => {
1821
- this._transport.send(data, timeoutMillis).then(resolve2, reject);
1822
- }, inMillis);
1823
- });
1824
- }
1825
- async send(data, timeoutMillis) {
1826
- let attempts = MAX_ATTEMPTS;
1827
- let nextBackoff = INITIAL_BACKOFF;
1828
- const deadline = Date.now() + timeoutMillis;
1829
- let result = await this._transport.send(data, timeoutMillis);
1830
- while (result.status === "retryable" && attempts > 0) {
1831
- attempts--;
1832
- const backoff = Math.max(Math.min(nextBackoff * (1 + getJitter()), MAX_BACKOFF), 0);
1833
- nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;
1834
- const retryInMillis = result.retryInMillis ?? backoff;
1835
- const remainingTimeoutMillis = deadline - Date.now();
1836
- if (retryInMillis > remainingTimeoutMillis) {
1837
- diag.info(`Export retry time ${Math.round(retryInMillis)}ms exceeds remaining timeout ${Math.round(remainingTimeoutMillis)}ms, not retrying further.`);
1838
- return result;
1839
- }
1840
- diag.verbose(`Scheduling export retry in ${Math.round(retryInMillis)}ms`);
1841
- result = await this.retry(data, remainingTimeoutMillis, retryInMillis);
1842
- }
1843
- if (result.status === "success") {
1844
- diag.verbose(`Export succeeded after ${MAX_ATTEMPTS - attempts} retry attempts.`);
1845
- } else if (result.status === "retryable") {
1846
- diag.info(`Export failed after maximum retry attempts (${MAX_ATTEMPTS}).`);
1847
- } else {
1848
- diag.info(`Export failed with non-retryable error: ${result.error}`);
1849
- }
1850
- return result;
1851
- }
1852
- shutdown() {
1853
- return this._transport.shutdown();
1854
- }
1855
- };
1856
- }
1857
- });
1858
-
1859
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
1860
- function createOtlpHttpExportDelegate(options, serializer) {
1861
- return createOtlpExportDelegate({
1862
- transport: createRetryingTransport({
1863
- transport: createHttpExporterTransport(options)
1864
- }),
1865
- serializer,
1866
- promiseHandler: createBoundedQueueExportPromiseHandler(options)
1867
- }, { timeout: options.timeoutMillis });
1868
- }
1869
- var init_otlp_http_export_delegate = __esm({
1870
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js"() {
1871
- init_otlp_export_delegate();
1872
- init_http_exporter_transport();
1873
- init_bounded_queue_export_promise_handler();
1874
- init_retrying_transport();
1875
- }
1876
- });
1877
- function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
1878
- const envTimeout = getNumberFromEnv(timeoutEnvVar);
1879
- if (envTimeout != null) {
1880
- if (Number.isFinite(envTimeout) && envTimeout > 0) {
1881
- return envTimeout;
1882
- }
1883
- diag.warn(`Configuration: ${timeoutEnvVar} is invalid, expected number greater than 0 (actual: ${envTimeout})`);
1884
- }
1885
- return void 0;
1886
- }
1887
- function getTimeoutFromEnv(signalIdentifier) {
1888
- const specificTimeout = parseAndValidateTimeoutFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_TIMEOUT`);
1889
- const nonSpecificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_TIMEOUT");
1890
- return specificTimeout ?? nonSpecificTimeout;
1891
- }
1892
- function parseAndValidateCompressionFromEnv(compressionEnvVar) {
1893
- const compression = getStringFromEnv(compressionEnvVar)?.trim();
1894
- if (compression == null || compression === "none" || compression === "gzip") {
1895
- return compression;
1896
- }
1897
- diag.warn(`Configuration: ${compressionEnvVar} is invalid, expected 'none' or 'gzip' (actual: '${compression}')`);
1898
- return void 0;
1899
- }
1900
- function getCompressionFromEnv(signalIdentifier) {
1901
- const specificCompression = parseAndValidateCompressionFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_COMPRESSION`);
1902
- const nonSpecificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_COMPRESSION");
1903
- return specificCompression ?? nonSpecificCompression;
1904
- }
1905
- function getSharedConfigurationFromEnvironment(signalIdentifier) {
1906
- return {
1907
- timeoutMillis: getTimeoutFromEnv(signalIdentifier),
1908
- compression: getCompressionFromEnv(signalIdentifier)
1909
- };
1910
- }
1911
- var init_shared_env_configuration = __esm({
1912
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js"() {
1913
- init_esm();
1914
- }
1915
- });
1916
- function getStaticHeadersFromEnv(signalIdentifier) {
1917
- const signalSpecificRawHeaders = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
1918
- const nonSignalSpecificRawHeaders = getStringFromEnv("OTEL_EXPORTER_OTLP_HEADERS");
1919
- const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
1920
- const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
1921
- if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
1922
- return void 0;
1923
- }
1924
- return Object.assign({}, parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), parseKeyPairsIntoRecord(signalSpecificRawHeaders));
1925
- }
1926
- function appendRootPathToUrlIfNeeded(url) {
1927
- try {
1928
- const parsedUrl = new URL(url);
1929
- return parsedUrl.toString();
1930
- } catch {
1931
- diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
1932
- return void 0;
1933
- }
1934
- }
1935
- function appendResourcePathToUrl(url, path29) {
1936
- try {
1937
- new URL(url);
1938
- } catch {
1939
- diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
1940
- return void 0;
1941
- }
1942
- if (!url.endsWith("/")) {
1943
- url = url + "/";
1944
- }
1945
- url += path29;
1946
- try {
1947
- new URL(url);
1948
- } catch {
1949
- diag.warn(`Configuration: Provided URL appended with '${path29}' is not a valid URL, using 'undefined' instead of '${url}'`);
1950
- return void 0;
1951
- }
1952
- return url;
1953
- }
1954
- function getNonSpecificUrlFromEnv(signalResourcePath) {
1955
- const envUrl = getStringFromEnv("OTEL_EXPORTER_OTLP_ENDPOINT");
1956
- if (envUrl === void 0) {
1957
- return void 0;
1958
- }
1959
- return appendResourcePathToUrl(envUrl, signalResourcePath);
1960
- }
1961
- function getSpecificUrlFromEnv(signalIdentifier) {
1962
- const envUrl = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`);
1963
- if (envUrl === void 0) {
1964
- return void 0;
1965
- }
1966
- return appendRootPathToUrlIfNeeded(envUrl);
1967
- }
1968
- function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
1969
- const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);
1970
- const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);
1971
- const filePath = signalSpecificPath ?? nonSignalSpecificPath;
1972
- if (filePath != null) {
1973
- try {
1974
- return fs19.readFileSync(path27.resolve(process.cwd(), filePath));
1975
- } catch {
1976
- diag.warn(warningMessage);
1977
- return void 0;
1978
- }
1979
- } else {
1980
- return void 0;
1981
- }
1982
- }
1983
- function getClientCertificateFromEnv(signalIdentifier) {
1984
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE", "Failed to read client certificate chain file");
1985
- }
1986
- function getClientKeyFromEnv(signalIdentifier) {
1987
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, "OTEL_EXPORTER_OTLP_CLIENT_KEY", "Failed to read client certificate private key file");
1988
- }
1989
- function getRootCertificateFromEnv(signalIdentifier) {
1990
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CERTIFICATE", "Failed to read root certificate file");
1991
- }
1992
- function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
1993
- return {
1994
- ...getSharedConfigurationFromEnvironment(signalIdentifier),
1995
- url: getSpecificUrlFromEnv(signalIdentifier) ?? getNonSpecificUrlFromEnv(signalResourcePath),
1996
- headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier)),
1997
- agentFactory: httpAgentFactoryFromOptions({
1998
- keepAlive: true,
1999
- ca: getRootCertificateFromEnv(signalIdentifier),
2000
- cert: getClientCertificateFromEnv(signalIdentifier),
2001
- key: getClientKeyFromEnv(signalIdentifier)
2002
- })
2003
- };
2004
- }
2005
- var init_otlp_node_http_env_configuration = __esm({
2006
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-env-configuration.js"() {
2007
- init_esm();
2008
- init_shared_env_configuration();
2009
- init_shared_configuration();
2010
- init_otlp_node_http_configuration();
2011
- }
2012
- });
2013
-
2014
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js
2015
- function convertLegacyHeaders(config) {
2016
- if (typeof config.headers === "function") {
2017
- return config.headers;
2018
- }
2019
- return wrapStaticHeadersInFunction(config.headers);
2020
- }
2021
- var init_convert_legacy_http_options = __esm({
2022
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js"() {
2023
- init_shared_configuration();
2024
- }
2025
- });
2026
- function convertLegacyAgentOptions(config) {
2027
- if (typeof config.httpAgentOptions === "function") {
2028
- return config.httpAgentOptions;
2029
- }
2030
- let legacy = config.httpAgentOptions;
2031
- if (config.keepAlive != null) {
2032
- legacy = { keepAlive: config.keepAlive, ...legacy };
2033
- }
2034
- if (legacy != null) {
2035
- return httpAgentFactoryFromOptions(legacy);
2036
- } else {
2037
- return void 0;
2038
- }
2039
- }
2040
- function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
2041
- if (config.metadata) {
2042
- diag.warn("Metadata cannot be set when using http");
2043
- }
2044
- return mergeOtlpNodeHttpConfigurationWithDefaults({
2045
- url: config.url,
2046
- headers: convertLegacyHeaders(config),
2047
- concurrencyLimit: config.concurrencyLimit,
2048
- timeoutMillis: config.timeoutMillis,
2049
- compression: config.compression,
2050
- agentFactory: convertLegacyAgentOptions(config),
2051
- userAgent: config.userAgent
2052
- }, getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
2053
- }
2054
- var init_convert_legacy_node_http_options = __esm({
2055
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js"() {
2056
- init_otlp_node_http_configuration();
2057
- init_index_node_http();
2058
- init_otlp_node_http_env_configuration();
2059
- init_convert_legacy_http_options();
2060
- }
2061
- });
2062
-
2063
- // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
2064
- var init_index_node_http = __esm({
2065
- "../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js"() {
2066
- init_otlp_node_http_configuration();
2067
- init_otlp_http_export_delegate();
2068
- init_convert_legacy_node_http_options();
2069
- }
2070
- });
2071
-
2072
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
2073
- var OTLPTraceExporter;
2074
- var init_OTLPTraceExporter = __esm({
2075
- "../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js"() {
2076
- init_esm2();
2077
- init_esm3();
2078
- init_index_node_http();
2079
- OTLPTraceExporter = class extends OTLPExporterBase {
2080
- constructor(config = {}) {
2081
- super(createOtlpHttpExportDelegate(convertLegacyHttpOptions(config, "TRACES", "v1/traces", {
2082
- "Content-Type": "application/json"
2083
- }), JsonTraceSerializer));
2084
- }
2085
- };
2086
- }
2087
- });
2088
-
2089
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
2090
- var init_node2 = __esm({
2091
- "../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js"() {
2092
- init_OTLPTraceExporter();
2093
- }
2094
- });
2095
-
2096
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
2097
- var init_platform2 = __esm({
2098
- "../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js"() {
2099
- init_node2();
2100
- }
2101
- });
2102
-
2103
- // ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
2104
- var init_esm4 = __esm({
2105
- "../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js"() {
2106
- init_platform2();
2107
- }
2108
- });
2109
-
2110
885
  // src/observability/tracing.ts
2111
886
  var tracing_exports = {};
2112
887
  __export(tracing_exports, {
@@ -2190,7 +965,6 @@ function getActiveTraceContext() {
2190
965
  var _sdk, TRACER_NAME, BLOCKED_ATTR_KEYS;
2191
966
  var init_tracing = __esm({
2192
967
  "src/observability/tracing.ts"() {
2193
- init_esm4();
2194
968
  _sdk = null;
2195
969
  TRACER_NAME = "code-intel";
2196
970
  BLOCKED_ATTR_KEYS = /secret|password|token|key|auth|credential/i;
@@ -2375,7 +1149,7 @@ var init_logger = __esm({
2375
1149
  };
2376
1150
  }
2377
1151
  /** Global log directory: ~/.code-intel/logs */
2378
- static LOG_DIR = path27__default.join(os12.homedir(), ".code-intel", "logs");
1152
+ static LOG_DIR = path26.join(os12.homedir(), ".code-intel", "logs");
2379
1153
  static getLogger() {
2380
1154
  if (!_Logger.instance) {
2381
1155
  const isProduction = process.env.NODE_ENV === "production";
@@ -2384,12 +1158,12 @@ var init_logger = __esm({
2384
1158
  transports.push(new winston.transports.Console());
2385
1159
  if (!isProduction) {
2386
1160
  try {
2387
- if (!fs19__default.existsSync(_Logger.LOG_DIR)) {
2388
- fs19__default.mkdirSync(_Logger.LOG_DIR, { recursive: true });
1161
+ if (!fs18.existsSync(_Logger.LOG_DIR)) {
1162
+ fs18.mkdirSync(_Logger.LOG_DIR, { recursive: true });
2389
1163
  }
2390
1164
  transports.push(
2391
1165
  new DailyRotateFile({
2392
- filename: path27__default.join(_Logger.LOG_DIR, "%DATE%-code-intel.log"),
1166
+ filename: path26.join(_Logger.LOG_DIR, "%DATE%-code-intel.log"),
2393
1167
  datePattern: "YYYY-MM-DD",
2394
1168
  maxSize: "20m",
2395
1169
  maxFiles: "14d"
@@ -3174,7 +1948,7 @@ var init_parse_phase = __esm({
3174
1948
  const batch = filePaths.slice(i, i + CONCURRENCY);
3175
1949
  await Promise.all(batch.map(async (filePath) => {
3176
1950
  try {
3177
- const source = await fs19__default.promises.readFile(filePath, "utf-8");
1951
+ const source = await fs18.promises.readFile(filePath, "utf-8");
3178
1952
  context2.fileCache.set(filePath, source);
3179
1953
  } catch {
3180
1954
  }
@@ -3187,14 +1961,14 @@ var init_parse_phase = __esm({
3187
1961
  const lang = detectLanguage(filePath);
3188
1962
  if (!lang) {
3189
1963
  if (context2.verbose) {
3190
- const relativePath2 = path27__default.relative(context2.workspaceRoot, filePath);
1964
+ const relativePath2 = path26.relative(context2.workspaceRoot, filePath);
3191
1965
  logger_default.info(` [parse] skipped (no parser): ${relativePath2}`);
3192
1966
  }
3193
1967
  continue;
3194
1968
  }
3195
1969
  const source = context2.fileCache.get(filePath);
3196
1970
  if (!source) continue;
3197
- const relativePath = path27__default.relative(context2.workspaceRoot, filePath);
1971
+ const relativePath = path26.relative(context2.workspaceRoot, filePath);
3198
1972
  const fileNodeId = generateNodeId("file", relativePath, relativePath);
3199
1973
  const fileNode = context2.graph.getNode(fileNodeId);
3200
1974
  if (fileNode) {
@@ -3434,11 +2208,11 @@ var init_resolve_phase = __esm({
3434
2208
  let heritageEdges = 0;
3435
2209
  const fileIndex = /* @__PURE__ */ new Map();
3436
2210
  for (const fp of filePaths) {
3437
- const rel = path27__default.relative(workspaceRoot, fp);
2211
+ const rel = path26.relative(workspaceRoot, fp);
3438
2212
  fileIndex.set(rel, fp);
3439
2213
  const noExt = rel.replace(/\.\w+$/, "");
3440
2214
  if (!fileIndex.has(noExt)) fileIndex.set(noExt, fp);
3441
- const base = path27__default.basename(rel, path27__default.extname(rel));
2215
+ const base = path26.basename(rel, path26.extname(rel));
3442
2216
  if (!fileIndex.has(base)) fileIndex.set(base, fp);
3443
2217
  }
3444
2218
  const symbolIndex = /* @__PURE__ */ new Map();
@@ -3469,7 +2243,7 @@ var init_resolve_phase = __esm({
3469
2243
  for (const filePath of filePaths) {
3470
2244
  const lang = detectLanguage(filePath);
3471
2245
  if (!lang) continue;
3472
- const relativePath = path27__default.relative(workspaceRoot, filePath);
2246
+ const relativePath = path26.relative(workspaceRoot, filePath);
3473
2247
  const fileNodeId = generateNodeId("file", relativePath, relativePath);
3474
2248
  const source = fileCache.get(filePath);
3475
2249
  if (!source) continue;
@@ -3482,13 +2256,13 @@ var init_resolve_phase = __esm({
3482
2256
  let resolvedRelPath = null;
3483
2257
  if (cleaned.startsWith(".")) {
3484
2258
  const cleanedNoJs = cleaned.replace(/\.(js|jsx)$/, "");
3485
- const fromDir = path27__default.dirname(relativePath);
2259
+ const fromDir = path26.dirname(relativePath);
3486
2260
  for (const ext of ["", ".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".go", "/index.ts", "/index.js"]) {
3487
- const candidate = path27__default.join(fromDir, cleanedNoJs + ext);
3488
- const normalized = path27__default.normalize(candidate);
2261
+ const candidate = path26.join(fromDir, cleanedNoJs + ext);
2262
+ const normalized = path26.normalize(candidate);
3489
2263
  if (fileIndex.has(normalized)) {
3490
2264
  const absPath = fileIndex.get(normalized);
3491
- resolvedRelPath = path27__default.relative(workspaceRoot, absPath);
2265
+ resolvedRelPath = path26.relative(workspaceRoot, absPath);
3492
2266
  break;
3493
2267
  }
3494
2268
  }
@@ -3668,27 +2442,27 @@ __export(group_registry_exports, {
3668
2442
  saveSyncResult: () => saveSyncResult
3669
2443
  });
3670
2444
  function groupFile(name) {
3671
- return path27__default.join(GROUPS_DIR, `${name}.json`);
2445
+ return path26.join(GROUPS_DIR, `${name}.json`);
3672
2446
  }
3673
2447
  function loadGroup(name) {
3674
2448
  try {
3675
- return JSON.parse(fs19__default.readFileSync(groupFile(name), "utf-8"));
2449
+ return JSON.parse(fs18.readFileSync(groupFile(name), "utf-8"));
3676
2450
  } catch {
3677
2451
  return null;
3678
2452
  }
3679
2453
  }
3680
2454
  function saveGroup(group) {
3681
- fs19__default.mkdirSync(GROUPS_DIR, { recursive: true });
3682
- fs19__default.writeFileSync(groupFile(group.name), JSON.stringify(group, null, 2) + "\n");
2455
+ fs18.mkdirSync(GROUPS_DIR, { recursive: true });
2456
+ fs18.writeFileSync(groupFile(group.name), JSON.stringify(group, null, 2) + "\n");
3683
2457
  }
3684
2458
  function listGroups() {
3685
2459
  const groups = [];
3686
2460
  try {
3687
- for (const file of fs19__default.readdirSync(GROUPS_DIR)) {
2461
+ for (const file of fs18.readdirSync(GROUPS_DIR)) {
3688
2462
  if (!file.endsWith(".json") || file.endsWith(".sync.json")) continue;
3689
2463
  try {
3690
2464
  const g = JSON.parse(
3691
- fs19__default.readFileSync(path27__default.join(GROUPS_DIR, file), "utf-8")
2465
+ fs18.readFileSync(path26.join(GROUPS_DIR, file), "utf-8")
3692
2466
  );
3693
2467
  groups.push(g);
3694
2468
  } catch {
@@ -3700,16 +2474,16 @@ function listGroups() {
3700
2474
  }
3701
2475
  function deleteGroup(name) {
3702
2476
  try {
3703
- fs19__default.unlinkSync(groupFile(name));
2477
+ fs18.unlinkSync(groupFile(name));
3704
2478
  } catch {
3705
2479
  }
3706
2480
  try {
3707
- fs19__default.unlinkSync(path27__default.join(GROUPS_DIR, `${name}.sync.json`));
2481
+ fs18.unlinkSync(path26.join(GROUPS_DIR, `${name}.sync.json`));
3708
2482
  } catch {
3709
2483
  }
3710
2484
  }
3711
2485
  function groupExists(name) {
3712
- return fs19__default.existsSync(groupFile(name));
2486
+ return fs18.existsSync(groupFile(name));
3713
2487
  }
3714
2488
  function addMember(groupName, member) {
3715
2489
  const group = loadGroup(groupName);
@@ -3735,16 +2509,16 @@ function removeMember(groupName, groupPath) {
3735
2509
  return group;
3736
2510
  }
3737
2511
  function saveSyncResult(result) {
3738
- fs19__default.mkdirSync(GROUPS_DIR, { recursive: true });
3739
- fs19__default.writeFileSync(
3740
- path27__default.join(GROUPS_DIR, `${result.groupName}.sync.json`),
2512
+ fs18.mkdirSync(GROUPS_DIR, { recursive: true });
2513
+ fs18.writeFileSync(
2514
+ path26.join(GROUPS_DIR, `${result.groupName}.sync.json`),
3741
2515
  JSON.stringify(result, null, 2) + "\n"
3742
2516
  );
3743
2517
  }
3744
2518
  function loadSyncResult(groupName) {
3745
2519
  try {
3746
2520
  return JSON.parse(
3747
- fs19__default.readFileSync(path27__default.join(GROUPS_DIR, `${groupName}.sync.json`), "utf-8")
2521
+ fs18.readFileSync(path26.join(GROUPS_DIR, `${groupName}.sync.json`), "utf-8")
3748
2522
  );
3749
2523
  } catch {
3750
2524
  return null;
@@ -3753,7 +2527,7 @@ function loadSyncResult(groupName) {
3753
2527
  var GROUPS_DIR;
3754
2528
  var init_group_registry = __esm({
3755
2529
  "src/multi-repo/group-registry.ts"() {
3756
- GROUPS_DIR = path27__default.join(os12.homedir(), ".code-intel", "groups");
2530
+ GROUPS_DIR = path26.join(os12.homedir(), ".code-intel", "groups");
3757
2531
  }
3758
2532
  });
3759
2533
 
@@ -3938,7 +2712,7 @@ init_shared();
3938
2712
  init_shared();
3939
2713
  init_typescript();
3940
2714
  function resolveRelative(rawPath, fromFile, workspace) {
3941
- const fromDir = path27__default.dirname(fromFile);
2715
+ const fromDir = path26.dirname(fromFile);
3942
2716
  const cleaned = rawPath.replace(/['"]/g, "");
3943
2717
  const extensions = [".ts", ".tsx", ".js", ".jsx", "/index.ts", "/index.js"];
3944
2718
  const resolved = workspace.resolve(fromDir, cleaned);
@@ -3990,7 +2764,7 @@ var pythonModule = {
3990
2764
  resolveImport(rawPath, fromFile, workspace) {
3991
2765
  const cleaned = rawPath.replace(/['"]/g, "");
3992
2766
  const parts = cleaned.split(".");
3993
- const fromDir = path27__default.dirname(fromFile);
2767
+ const fromDir = path26.dirname(fromFile);
3994
2768
  const relPath = parts.join("/");
3995
2769
  for (const suffix of ["/__init__.py", ".py"]) {
3996
2770
  const r = workspace.resolve(fromDir, relPath + suffix);
@@ -4069,7 +2843,7 @@ var cModule = {
4069
2843
  inheritanceStrategy: "none",
4070
2844
  resolveImport(rawPath, fromFile, workspace) {
4071
2845
  const cleaned = rawPath.replace(/[<>"']/g, "");
4072
- const fromDir = path27__default.dirname(fromFile);
2846
+ const fromDir = path26.dirname(fromFile);
4073
2847
  return workspace.resolve(fromDir, cleaned);
4074
2848
  },
4075
2849
  isExported(_node) {
@@ -4092,7 +2866,7 @@ var cppModule = {
4092
2866
  inheritanceStrategy: "depth-first",
4093
2867
  resolveImport(rawPath, fromFile, workspace) {
4094
2868
  const cleaned = rawPath.replace(/[<>"']/g, "");
4095
- const fromDir = path27__default.dirname(fromFile);
2869
+ const fromDir = path26.dirname(fromFile);
4096
2870
  return workspace.resolve(fromDir, cleaned);
4097
2871
  },
4098
2872
  isExported(_node) {
@@ -4254,7 +3028,7 @@ var dartModule = {
4254
3028
  const pkg = cleaned.replace("package:", "");
4255
3029
  return workspace.findByPackage(pkg);
4256
3030
  }
4257
- const fromDir = path27__default.dirname(fromFile);
3031
+ const fromDir = path26.dirname(fromFile);
4258
3032
  return workspace.resolve(fromDir, cleaned);
4259
3033
  },
4260
3034
  isExported(node) {
@@ -4609,25 +3383,25 @@ function validateDAG(phases) {
4609
3383
  const visiting = /* @__PURE__ */ new Set();
4610
3384
  const visited = /* @__PURE__ */ new Set();
4611
3385
  const phaseMap = new Map(phases.map((p) => [p.name, p]));
4612
- function dfs(name, path29) {
3386
+ function dfs(name, path28) {
4613
3387
  if (visiting.has(name)) {
4614
- const cycleStart = path29.indexOf(name);
4615
- const cycle = path29.slice(cycleStart).concat(name);
3388
+ const cycleStart = path28.indexOf(name);
3389
+ const cycle = path28.slice(cycleStart).concat(name);
4616
3390
  errors.push({ type: "cycle", message: `Cycle detected: ${cycle.join(" \u2192 ")}` });
4617
3391
  return true;
4618
3392
  }
4619
3393
  if (visited.has(name)) return false;
4620
3394
  visiting.add(name);
4621
- path29.push(name);
3395
+ path28.push(name);
4622
3396
  const phase = phaseMap.get(name);
4623
3397
  if (phase) {
4624
3398
  for (const dep of phase.dependencies) {
4625
- if (dfs(dep, path29)) return true;
3399
+ if (dfs(dep, path28)) return true;
4626
3400
  }
4627
3401
  }
4628
3402
  visiting.delete(name);
4629
3403
  visited.add(name);
4630
- path29.pop();
3404
+ path28.pop();
4631
3405
  return false;
4632
3406
  }
4633
3407
  for (const phase of phases) {
@@ -4840,7 +3614,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
4840
3614
  ]);
4841
3615
  function loadIgnorePatterns(workspaceRoot) {
4842
3616
  try {
4843
- const raw = fs19__default.readFileSync(path27__default.join(workspaceRoot, ".codeintelignore"), "utf-8");
3617
+ const raw = fs18.readFileSync(path26.join(workspaceRoot, ".codeintelignore"), "utf-8");
4844
3618
  const extras = /* @__PURE__ */ new Set();
4845
3619
  for (const line of raw.split("\n")) {
4846
3620
  const trimmed = line.trim();
@@ -4864,7 +3638,7 @@ var scanPhase = {
4864
3638
  function walk(dir) {
4865
3639
  let entries;
4866
3640
  try {
4867
- entries = fs19__default.readdirSync(dir, { withFileTypes: true });
3641
+ entries = fs18.readdirSync(dir, { withFileTypes: true });
4868
3642
  } catch {
4869
3643
  return;
4870
3644
  }
@@ -4873,15 +3647,15 @@ var scanPhase = {
4873
3647
  if (entry.name.startsWith(".")) continue;
4874
3648
  if (IGNORED_DIRS.has(entry.name)) continue;
4875
3649
  if (extraIgnore.has(entry.name)) continue;
4876
- walk(path27__default.join(dir, entry.name));
3650
+ walk(path26.join(dir, entry.name));
4877
3651
  } else if (entry.isFile()) {
4878
3652
  const name = entry.name;
4879
3653
  if (IGNORED_FILE_SUFFIXES.some((s) => name.endsWith(s))) continue;
4880
- const ext = path27__default.extname(name);
3654
+ const ext = path26.extname(name);
4881
3655
  if (!extensions.has(ext)) continue;
4882
- const fullPath = path27__default.join(dir, name);
3656
+ const fullPath = path26.join(dir, name);
4883
3657
  try {
4884
- const stat = fs19__default.statSync(fullPath);
3658
+ const stat = fs18.statSync(fullPath);
4885
3659
  if (stat.size > MAX_FILE_SIZE_BYTES) continue;
4886
3660
  } catch {
4887
3661
  continue;
@@ -4908,20 +3682,20 @@ var structurePhase = {
4908
3682
  const dirs = /* @__PURE__ */ new Set();
4909
3683
  let structDone = 0;
4910
3684
  for (const filePath of context2.filePaths) {
4911
- const relativePath = path27__default.relative(context2.workspaceRoot, filePath);
3685
+ const relativePath = path26.relative(context2.workspaceRoot, filePath);
4912
3686
  const lang = detectLanguage(filePath);
4913
3687
  context2.graph.addNode({
4914
3688
  id: generateNodeId("file", relativePath, relativePath),
4915
3689
  kind: "file",
4916
- name: path27__default.basename(filePath),
3690
+ name: path26.basename(filePath),
4917
3691
  filePath: relativePath,
4918
3692
  metadata: lang ? { language: lang } : void 0
4919
3693
  });
4920
- let dir = path27__default.dirname(relativePath);
3694
+ let dir = path26.dirname(relativePath);
4921
3695
  while (dir && dir !== "." && dir !== "") {
4922
3696
  if (dirs.has(dir)) break;
4923
3697
  dirs.add(dir);
4924
- dir = path27__default.dirname(dir);
3698
+ dir = path26.dirname(dir);
4925
3699
  }
4926
3700
  structDone++;
4927
3701
  context2.onPhaseProgress?.("structure", structDone, context2.filePaths.length);
@@ -4930,7 +3704,7 @@ var structurePhase = {
4930
3704
  context2.graph.addNode({
4931
3705
  id: generateNodeId("directory", dir, dir),
4932
3706
  kind: "directory",
4933
- name: path27__default.basename(dir),
3707
+ name: path26.basename(dir),
4934
3708
  filePath: dir
4935
3709
  });
4936
3710
  }
@@ -5041,22 +3815,22 @@ var flowPhase = {
5041
3815
  const queue = [{ nodeId: ep.id, path: [ep.id] }];
5042
3816
  const visited = /* @__PURE__ */ new Set();
5043
3817
  while (queue.length > 0 && flowCount < maxFlows) {
5044
- const { nodeId, path: path29 } = queue.shift();
5045
- if (path29.length > maxDepth) continue;
3818
+ const { nodeId, path: path28 } = queue.shift();
3819
+ if (path28.length > maxDepth) continue;
5046
3820
  const callEdges = [...graph.findEdgesFrom(nodeId)].filter((e) => e.kind === "calls").slice(0, maxBranching);
5047
- if (callEdges.length === 0 && path29.length >= 3) {
3821
+ if (callEdges.length === 0 && path28.length >= 3) {
5048
3822
  const flowId = generateNodeId("flow", ep.filePath, `flow-${flowCount}`);
5049
3823
  graph.addNode({
5050
3824
  id: flowId,
5051
3825
  kind: "flow",
5052
3826
  name: `${ep.name} flow ${flowCount}`,
5053
3827
  filePath: ep.filePath,
5054
- metadata: { steps: path29, entryPoint: ep.name }
3828
+ metadata: { steps: path28, entryPoint: ep.name }
5055
3829
  });
5056
- for (let i = 0; i < path29.length; i++) {
3830
+ for (let i = 0; i < path28.length; i++) {
5057
3831
  graph.addEdge({
5058
- id: generateEdgeId(path29[i], flowId, `step_of_${i}`),
5059
- source: path29[i],
3832
+ id: generateEdgeId(path28[i], flowId, `step_of_${i}`),
3833
+ source: path28[i],
5060
3834
  target: flowId,
5061
3835
  kind: "step_of",
5062
3836
  weight: 1,
@@ -5069,7 +3843,7 @@ var flowPhase = {
5069
3843
  for (const edge of callEdges) {
5070
3844
  if (visited.has(edge.target)) continue;
5071
3845
  visited.add(edge.target);
5072
- queue.push({ nodeId: edge.target, path: [...path29, edge.target] });
3846
+ queue.push({ nodeId: edge.target, path: [...path28, edge.target] });
5073
3847
  }
5074
3848
  }
5075
3849
  }
@@ -5215,17 +3989,17 @@ function traceFlow(entryId, graph, maxDepth = 10, maxBranching = 4) {
5215
3989
  const queue = [{ nodeId: entryId, path: [entryId] }];
5216
3990
  const visited = /* @__PURE__ */ new Set();
5217
3991
  while (queue.length > 0 && flows.length < maxFlows) {
5218
- const { nodeId, path: path29 } = queue.shift();
5219
- if (path29.length > maxDepth) continue;
3992
+ const { nodeId, path: path28 } = queue.shift();
3993
+ if (path28.length > maxDepth) continue;
5220
3994
  const callEdges = [...graph.findEdgesFrom(nodeId)].filter((e) => e.kind === "calls").slice(0, maxBranching);
5221
- if (callEdges.length === 0 && path29.length >= 3) {
5222
- flows.push({ entryPointId: entryId, steps: [...path29] });
3995
+ if (callEdges.length === 0 && path28.length >= 3) {
3996
+ flows.push({ entryPointId: entryId, steps: [...path28] });
5223
3997
  continue;
5224
3998
  }
5225
3999
  for (const edge of callEdges) {
5226
4000
  if (visited.has(edge.target)) continue;
5227
4001
  visited.add(edge.target);
5228
- queue.push({ nodeId: edge.target, path: [...path29, edge.target] });
4002
+ queue.push({ nodeId: edge.target, path: [...path28, edge.target] });
5229
4003
  }
5230
4004
  }
5231
4005
  }
@@ -5386,19 +4160,19 @@ var VectorIndex = class {
5386
4160
  function esc(s) {
5387
4161
  return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "");
5388
4162
  }
5389
- var GLOBAL_DIR = path27__default.join(os12.homedir(), ".code-intel");
5390
- var REPOS_FILE = path27__default.join(GLOBAL_DIR, "repos.json");
4163
+ var GLOBAL_DIR = path26.join(os12.homedir(), ".code-intel");
4164
+ var REPOS_FILE = path26.join(GLOBAL_DIR, "repos.json");
5391
4165
  function loadRegistry() {
5392
4166
  try {
5393
- const data = fs19__default.readFileSync(REPOS_FILE, "utf-8");
4167
+ const data = fs18.readFileSync(REPOS_FILE, "utf-8");
5394
4168
  return JSON.parse(data);
5395
4169
  } catch {
5396
4170
  return [];
5397
4171
  }
5398
4172
  }
5399
4173
  function saveRegistry(entries) {
5400
- fs19__default.mkdirSync(GLOBAL_DIR, { recursive: true });
5401
- fs19__default.writeFileSync(REPOS_FILE, JSON.stringify(entries, null, 2));
4174
+ fs18.mkdirSync(GLOBAL_DIR, { recursive: true });
4175
+ fs18.writeFileSync(REPOS_FILE, JSON.stringify(entries, null, 2));
5402
4176
  }
5403
4177
  function upsertRepo(entry) {
5404
4178
  const entries = loadRegistry();
@@ -5415,23 +4189,23 @@ function removeRepo(repoPath) {
5415
4189
  saveRegistry(entries);
5416
4190
  }
5417
4191
  function saveMetadata(repoDir, metadata) {
5418
- const metaDir = path27__default.join(repoDir, ".code-intel");
5419
- fs19__default.mkdirSync(metaDir, { recursive: true });
5420
- fs19__default.writeFileSync(path27__default.join(metaDir, "meta.json"), JSON.stringify(metadata, null, 2));
4192
+ const metaDir = path26.join(repoDir, ".code-intel");
4193
+ fs18.mkdirSync(metaDir, { recursive: true });
4194
+ fs18.writeFileSync(path26.join(metaDir, "meta.json"), JSON.stringify(metadata, null, 2));
5421
4195
  }
5422
4196
  function loadMetadata(repoDir) {
5423
4197
  try {
5424
- const data = fs19__default.readFileSync(path27__default.join(repoDir, ".code-intel", "meta.json"), "utf-8");
4198
+ const data = fs18.readFileSync(path26.join(repoDir, ".code-intel", "meta.json"), "utf-8");
5425
4199
  return JSON.parse(data);
5426
4200
  } catch {
5427
4201
  return null;
5428
4202
  }
5429
4203
  }
5430
4204
  function getDbPath(repoDir) {
5431
- return path27__default.join(repoDir, ".code-intel", "graph.db");
4205
+ return path26.join(repoDir, ".code-intel", "graph.db");
5432
4206
  }
5433
4207
  function getVectorDbPath(repoDir) {
5434
- return path27__default.join(repoDir, ".code-intel", "vector.db");
4208
+ return path26.join(repoDir, ".code-intel", "vector.db");
5435
4209
  }
5436
4210
 
5437
4211
  // src/mcp-server/server.ts
@@ -5444,7 +4218,7 @@ var DbManager = class {
5444
4218
  this.dbPath = dbPath;
5445
4219
  }
5446
4220
  async init() {
5447
- fs19__default.mkdirSync(path27__default.dirname(this.dbPath), { recursive: true });
4221
+ fs18.mkdirSync(path26.dirname(this.dbPath), { recursive: true });
5448
4222
  this.db = new Database(this.dbPath);
5449
4223
  await this.db.init();
5450
4224
  this.conn = new Connection(this.db);
@@ -5726,8 +4500,8 @@ async function syncGroup(group) {
5726
4500
  logger_default.warn(` \u26A0 Registry entry "${member.registryName}" not found \u2014 skipping ${member.groupPath}`);
5727
4501
  continue;
5728
4502
  }
5729
- const dbPath = path27__default.join(regEntry.path, ".code-intel", "graph.db");
5730
- if (!fs19__default.existsSync(dbPath)) {
4503
+ const dbPath = path26.join(regEntry.path, ".code-intel", "graph.db");
4504
+ if (!fs18.existsSync(dbPath)) {
5731
4505
  logger_default.warn(` \u26A0 No index at ${dbPath} \u2014 run \`code-intel analyze ${regEntry.path}\` first`);
5732
4506
  continue;
5733
4507
  }
@@ -5762,8 +4536,8 @@ async function queryGroup(group, query, limit = 20) {
5762
4536
  for (const member of group.members) {
5763
4537
  const regEntry = registry.find((r) => r.name === member.registryName);
5764
4538
  if (!regEntry) continue;
5765
- const dbPath = path27__default.join(regEntry.path, ".code-intel", "graph.db");
5766
- if (!fs19__default.existsSync(dbPath)) continue;
4539
+ const dbPath = path26.join(regEntry.path, ".code-intel", "graph.db");
4540
+ if (!fs18.existsSync(dbPath)) continue;
5767
4541
  const graph = createKnowledgeGraph();
5768
4542
  const db = new DbManager(dbPath);
5769
4543
  try {
@@ -6353,7 +5127,7 @@ async function dispatchTool(name, a, graph, repoName, workspaceRoot) {
6353
5127
  for (const { filePath: changedFile, changedLines } of changedFiles) {
6354
5128
  for (const node of graph.allNodes()) {
6355
5129
  if (!node.filePath) continue;
6356
- const normNode = node.filePath.replace(repoRoot + "/", "").replace(repoRoot + path27__default.sep, "");
5130
+ const normNode = node.filePath.replace(repoRoot + "/", "").replace(repoRoot + path26.sep, "");
6357
5131
  const normChanged = changedFile.replace(/^a\/|^b\//, "");
6358
5132
  if (!normNode.endsWith(normChanged) && !normChanged.endsWith(normNode)) continue;
6359
5133
  if (node.startLine !== void 0 && node.endLine !== void 0) {
@@ -6623,7 +5397,7 @@ function parseDiff(diffText) {
6623
5397
  return result;
6624
5398
  }
6625
5399
  function writeNodeCSVs(graph, outputDir) {
6626
- fs19__default.mkdirSync(outputDir, { recursive: true });
5400
+ fs18.mkdirSync(outputDir, { recursive: true });
6627
5401
  const header = "id,name,file_path,start_line,end_line,exported,content,metadata\n";
6628
5402
  const tableBuffers = /* @__PURE__ */ new Map();
6629
5403
  const tableFilePaths = /* @__PURE__ */ new Map();
@@ -6631,7 +5405,7 @@ function writeNodeCSVs(graph, outputDir) {
6631
5405
  const table = NODE_TABLE_MAP[node.kind];
6632
5406
  if (!tableBuffers.has(table)) {
6633
5407
  tableBuffers.set(table, [header]);
6634
- tableFilePaths.set(table, path27__default.join(outputDir, `${table}.csv`));
5408
+ tableFilePaths.set(table, path26.join(outputDir, `${table}.csv`));
6635
5409
  }
6636
5410
  tableBuffers.get(table).push(
6637
5411
  csvRow([
@@ -6651,12 +5425,12 @@ function writeNodeCSVs(graph, outputDir) {
6651
5425
  );
6652
5426
  }
6653
5427
  for (const [table, lines] of tableBuffers) {
6654
- fs19__default.writeFileSync(tableFilePaths.get(table), lines.join(""), "utf-8");
5428
+ fs18.writeFileSync(tableFilePaths.get(table), lines.join(""), "utf-8");
6655
5429
  }
6656
5430
  return tableFilePaths;
6657
5431
  }
6658
5432
  function writeEdgeCSV(graph, outputDir) {
6659
- fs19__default.mkdirSync(outputDir, { recursive: true });
5433
+ fs18.mkdirSync(outputDir, { recursive: true });
6660
5434
  const header = "from_id,to_id,kind,weight,label\n";
6661
5435
  const groups = /* @__PURE__ */ new Map();
6662
5436
  for (const edge of graph.allEdges()) {
@@ -6667,7 +5441,7 @@ function writeEdgeCSV(graph, outputDir) {
6667
5441
  const toTable = NODE_TABLE_MAP[targetNode.kind];
6668
5442
  const key = `${fromTable}->${toTable}`;
6669
5443
  if (!groups.has(key)) {
6670
- const filePath = path27__default.join(outputDir, `edges_${fromTable}_${toTable}.csv`);
5444
+ const filePath = path26.join(outputDir, `edges_${fromTable}_${toTable}.csv`);
6671
5445
  groups.set(key, { lines: [header], from: fromTable, to: toTable, filePath });
6672
5446
  }
6673
5447
  groups.get(key).lines.push(
@@ -6682,7 +5456,7 @@ function writeEdgeCSV(graph, outputDir) {
6682
5456
  }
6683
5457
  const result = [];
6684
5458
  for (const group of groups.values()) {
6685
- fs19__default.writeFileSync(group.filePath, group.lines.join(""), "utf-8");
5459
+ fs18.writeFileSync(group.filePath, group.lines.join(""), "utf-8");
6686
5460
  result.push({ fromTable: group.from, toTable: group.to, filePath: group.filePath });
6687
5461
  }
6688
5462
  return result;
@@ -6710,7 +5484,7 @@ async function loadGraphToDB(graph, dbManager) {
6710
5484
  } catch {
6711
5485
  }
6712
5486
  }
6713
- const tmpDir = fs19__default.mkdtempSync(path27__default.join(os12.tmpdir(), "code-intel-csv-"));
5487
+ const tmpDir = fs18.mkdtempSync(path26.join(os12.tmpdir(), "code-intel-csv-"));
6714
5488
  try {
6715
5489
  const nodeTableFiles = writeNodeCSVs(graph, tmpDir);
6716
5490
  const edgeGroups = writeEdgeCSV(graph, tmpDir);
@@ -6729,8 +5503,8 @@ async function loadGraphToDB(graph, dbManager) {
6729
5503
  }
6730
5504
  let nodeCount = 0;
6731
5505
  for (const [table, csvPath] of nodeTableFiles) {
6732
- if (!fs19__default.existsSync(csvPath)) continue;
6733
- const stat = fs19__default.statSync(csvPath);
5506
+ if (!fs18.existsSync(csvPath)) continue;
5507
+ const stat = fs18.statSync(csvPath);
6734
5508
  if (stat.size < 50) continue;
6735
5509
  try {
6736
5510
  await dbManager.execute(
@@ -6743,8 +5517,8 @@ async function loadGraphToDB(graph, dbManager) {
6743
5517
  }
6744
5518
  let edgeCount = 0;
6745
5519
  for (const group of edgeGroups) {
6746
- if (!fs19__default.existsSync(group.filePath)) continue;
6747
- const stat = fs19__default.statSync(group.filePath);
5520
+ if (!fs18.existsSync(group.filePath)) continue;
5521
+ const stat = fs18.statSync(group.filePath);
6748
5522
  if (stat.size < 50) continue;
6749
5523
  try {
6750
5524
  await dbManager.execute(
@@ -6758,7 +5532,7 @@ async function loadGraphToDB(graph, dbManager) {
6758
5532
  return { nodeCount, edgeCount };
6759
5533
  } finally {
6760
5534
  try {
6761
- fs19__default.rmSync(tmpDir, { recursive: true, force: true });
5535
+ fs18.rmSync(tmpDir, { recursive: true, force: true });
6762
5536
  } catch {
6763
5537
  }
6764
5538
  }
@@ -6842,10 +5616,10 @@ var AppError = class extends Error {
6842
5616
  var SECURE_DIR_MODE = 448;
6843
5617
  var SECURE_FILE_MODE = 384;
6844
5618
  function secureMkdir(dir) {
6845
- fs19__default.mkdirSync(dir, { recursive: true, mode: SECURE_DIR_MODE });
5619
+ fs18.mkdirSync(dir, { recursive: true, mode: SECURE_DIR_MODE });
6846
5620
  if (process.platform !== "win32") {
6847
5621
  try {
6848
- fs19__default.chmodSync(dir, SECURE_DIR_MODE);
5622
+ fs18.chmodSync(dir, SECURE_DIR_MODE);
6849
5623
  } catch {
6850
5624
  }
6851
5625
  }
@@ -6853,17 +5627,17 @@ function secureMkdir(dir) {
6853
5627
  function secureChmodFile(file) {
6854
5628
  if (process.platform === "win32") return;
6855
5629
  try {
6856
- fs19__default.chmodSync(file, SECURE_FILE_MODE);
5630
+ fs18.chmodSync(file, SECURE_FILE_MODE);
6857
5631
  } catch {
6858
5632
  }
6859
5633
  }
6860
5634
  function tightenDbFiles(dir) {
6861
5635
  if (process.platform === "win32") return;
6862
- if (!fs19__default.existsSync(dir)) return;
6863
- for (const name of fs19__default.readdirSync(dir)) {
5636
+ if (!fs18.existsSync(dir)) return;
5637
+ for (const name of fs18.readdirSync(dir)) {
6864
5638
  if (name.endsWith(".db") || name.endsWith(".db-wal") || name.endsWith(".db-shm")) {
6865
5639
  try {
6866
- fs19__default.chmodSync(path27__default.join(dir, name), SECURE_FILE_MODE);
5640
+ fs18.chmodSync(path26.join(dir, name), SECURE_FILE_MODE);
6867
5641
  } catch {
6868
5642
  }
6869
5643
  }
@@ -6875,7 +5649,7 @@ var BCRYPT_ROUNDS = 12;
6875
5649
  var UsersDB = class {
6876
5650
  db;
6877
5651
  constructor(dbPath) {
6878
- const dir = path27__default.dirname(dbPath);
5652
+ const dir = path26.dirname(dbPath);
6879
5653
  secureMkdir(dir);
6880
5654
  this.db = new Database2(dbPath);
6881
5655
  this.db.pragma("journal_mode = WAL");
@@ -7145,7 +5919,7 @@ var UsersDB = class {
7145
5919
  }
7146
5920
  };
7147
5921
  function getUsersDBPath() {
7148
- return process.env["CODE_INTEL_USERS_DB_PATH"] ?? path27__default.join(os12.homedir(), ".code-intel", "users.db");
5922
+ return process.env["CODE_INTEL_USERS_DB_PATH"] ?? path26.join(os12.homedir(), ".code-intel", "users.db");
7149
5923
  }
7150
5924
  var _usersDB = null;
7151
5925
  function getOrCreateUsersDB() {
@@ -7164,7 +5938,7 @@ function getScryptN() {
7164
5938
  return Number.isInteger(v) && v >= 1024 ? v : 1 << 14;
7165
5939
  }
7166
5940
  function getSecretsPath() {
7167
- return process.env["CODE_INTEL_SECRETS_PATH"] ?? path27__default.join(os12.homedir(), ".code-intel", ".secrets");
5941
+ return process.env["CODE_INTEL_SECRETS_PATH"] ?? path26.join(os12.homedir(), ".code-intel", ".secrets");
7168
5942
  }
7169
5943
  function getMasterPassword() {
7170
5944
  const fromEnv = process.env["CODE_INTEL_SECRET_KEY"];
@@ -7195,8 +5969,8 @@ function decryptSecrets(encrypted) {
7195
5969
  return JSON.parse(plaintext.toString("utf8"));
7196
5970
  }
7197
5971
  function loadSecrets(secretsPath = getSecretsPath()) {
7198
- if (!fs19__default.existsSync(secretsPath)) return {};
7199
- const blob = fs19__default.readFileSync(secretsPath);
5972
+ if (!fs18.existsSync(secretsPath)) return {};
5973
+ const blob = fs18.readFileSync(secretsPath);
7200
5974
  return decryptSecrets(blob);
7201
5975
  }
7202
5976
  function getSecret(key, secretsPath = getSecretsPath()) {
@@ -7432,12 +6206,12 @@ async function verifyPassword(plain, hash) {
7432
6206
  return bcrypt.compare(plain, hash);
7433
6207
  }
7434
6208
  var RETRY_DELAYS_SECONDS = [5, 30, 120];
7435
- var MAX_ATTEMPTS2 = 3;
6209
+ var MAX_ATTEMPTS = 3;
7436
6210
  var STUCK_THRESHOLD_MINUTES = 30;
7437
6211
  var JobsDB = class {
7438
6212
  db;
7439
6213
  constructor(dbPath) {
7440
- fs19__default.mkdirSync(path27__default.dirname(dbPath), { recursive: true });
6214
+ fs18.mkdirSync(path26.dirname(dbPath), { recursive: true });
7441
6215
  this.db = new Database2(dbPath);
7442
6216
  this.db.pragma("journal_mode = WAL");
7443
6217
  this.db.pragma("foreign_keys = ON");
@@ -7453,7 +6227,7 @@ var JobsDB = class {
7453
6227
  repoPath TEXT NOT NULL,
7454
6228
  params TEXT NOT NULL DEFAULT '{}',
7455
6229
  attempts INTEGER NOT NULL DEFAULT 0,
7456
- maxAttempts INTEGER NOT NULL DEFAULT ${MAX_ATTEMPTS2},
6230
+ maxAttempts INTEGER NOT NULL DEFAULT ${MAX_ATTEMPTS},
7457
6231
  createdAt TEXT NOT NULL,
7458
6232
  startedAt TEXT NULL,
7459
6233
  finishedAt TEXT NULL,
@@ -7479,7 +6253,7 @@ var JobsDB = class {
7479
6253
  this.db.prepare(
7480
6254
  `INSERT INTO jobs (id, kind, status, repoPath, params, attempts, maxAttempts, createdAt, idempotencyKey)
7481
6255
  VALUES (?, ?, 'pending', ?, ?, 0, ?, ?, ?)`
7482
- ).run(id, kind, repoPath, JSON.stringify(params), MAX_ATTEMPTS2, createdAt, idempotencyKey ?? null);
6256
+ ).run(id, kind, repoPath, JSON.stringify(params), MAX_ATTEMPTS, createdAt, idempotencyKey ?? null);
7483
6257
  return this.getJob(id);
7484
6258
  }
7485
6259
  getJob(id) {
@@ -7579,7 +6353,7 @@ var JobsDB = class {
7579
6353
  }
7580
6354
  };
7581
6355
  function getJobsDBPath() {
7582
- return path27__default.join(os12.homedir(), ".code-intel", "jobs.db");
6356
+ return path26.join(os12.homedir(), ".code-intel", "jobs.db");
7583
6357
  }
7584
6358
  var _jobsDB = null;
7585
6359
  function getOrCreateJobsDB() {
@@ -7593,7 +6367,7 @@ var LLMGovernanceLogger = class {
7593
6367
  }
7594
6368
  /** Path to the JSONL log file. */
7595
6369
  getLogPath() {
7596
- return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ?? path27__default.join(os12.homedir(), ".code-intel", "llm-governance.jsonl");
6370
+ return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ?? path26.join(os12.homedir(), ".code-intel", "llm-governance.jsonl");
7597
6371
  }
7598
6372
  /**
7599
6373
  * Append an entry to the governance log.
@@ -7609,8 +6383,8 @@ var LLMGovernanceLogger = class {
7609
6383
  ...entry
7610
6384
  };
7611
6385
  const logPath = this.getLogPath();
7612
- fs19__default.mkdirSync(path27__default.dirname(logPath), { recursive: true });
7613
- fs19__default.appendFileSync(logPath, JSON.stringify(full) + "\n", "utf-8");
6386
+ fs18.mkdirSync(path26.dirname(logPath), { recursive: true });
6387
+ fs18.appendFileSync(logPath, JSON.stringify(full) + "\n", "utf-8");
7614
6388
  } catch {
7615
6389
  }
7616
6390
  }
@@ -7620,7 +6394,7 @@ var LLMGovernanceLogger = class {
7620
6394
  */
7621
6395
  readLog(limit = 100) {
7622
6396
  try {
7623
- const raw = fs19__default.readFileSync(this.getLogPath(), "utf-8");
6397
+ const raw = fs18.readFileSync(this.getLogPath(), "utf-8");
7624
6398
  const lines = raw.split("\n").filter((l) => l.trim().length > 0).slice(-limit);
7625
6399
  return lines.map((l) => JSON.parse(l));
7626
6400
  } catch {
@@ -7655,7 +6429,7 @@ function sigV4SigningKey(secret, date, region, service) {
7655
6429
  return hmac(kService, "aws4_request");
7656
6430
  }
7657
6431
  function s3Request(opts) {
7658
- return new Promise((resolve2, reject) => {
6432
+ return new Promise((resolve, reject) => {
7659
6433
  const { method, cfg, key, body, query } = opts;
7660
6434
  const host = `${cfg.bucket}.s3.${cfg.region}.amazonaws.com`;
7661
6435
  const now = /* @__PURE__ */ new Date();
@@ -7703,7 +6477,7 @@ x-amz-date:${amzDate}
7703
6477
  const req = https.request(reqOptions, (res) => {
7704
6478
  const chunks = [];
7705
6479
  res.on("data", (c) => chunks.push(c));
7706
- res.on("end", () => resolve2({ statusCode: res.statusCode ?? 0, body: Buffer.concat(chunks).toString("utf-8") }));
6480
+ res.on("end", () => resolve({ statusCode: res.statusCode ?? 0, body: Buffer.concat(chunks).toString("utf-8") }));
7707
6481
  });
7708
6482
  req.on("error", reject);
7709
6483
  if (body) req.write(body);
@@ -7714,7 +6488,7 @@ var BACKUP_VERSION = "1.0";
7714
6488
  var ALGORITHM = "aes-256-gcm";
7715
6489
  var IV_LENGTH = 16;
7716
6490
  function getBackupDir() {
7717
- return path27__default.join(os12.homedir(), ".code-intel", "backups");
6491
+ return path26.join(os12.homedir(), ".code-intel", "backups");
7718
6492
  }
7719
6493
  function getBackupKey() {
7720
6494
  const keyHex = process.env["CODE_INTEL_BACKUP_KEY"];
@@ -7745,30 +6519,30 @@ var BackupService = class {
7745
6519
  constructor(backupDir) {
7746
6520
  this.backupDir = backupDir ?? getBackupDir();
7747
6521
  this.key = getBackupKey();
7748
- fs19__default.mkdirSync(this.backupDir, { recursive: true });
6522
+ fs18.mkdirSync(this.backupDir, { recursive: true });
7749
6523
  }
7750
6524
  /**
7751
6525
  * Create a backup for a repository.
7752
6526
  * Returns the backup entry.
7753
6527
  */
7754
6528
  createBackup(repoPath) {
7755
- const codeIntelDir = path27__default.join(repoPath, ".code-intel");
6529
+ const codeIntelDir = path26.join(repoPath, ".code-intel");
7756
6530
  const id = v4();
7757
6531
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
7758
6532
  const filesToBackup = [];
7759
6533
  const candidates = ["graph.db", "vector.db", "meta.json"];
7760
6534
  for (const f of candidates) {
7761
- const fp = path27__default.join(codeIntelDir, f);
7762
- if (fs19__default.existsSync(fp)) {
6535
+ const fp = path26.join(codeIntelDir, f);
6536
+ if (fs18.existsSync(fp)) {
7763
6537
  filesToBackup.push({ name: f, localPath: fp });
7764
6538
  }
7765
6539
  }
7766
- const registryPath = path27__default.join(os12.homedir(), ".code-intel", "registry.json");
7767
- if (fs19__default.existsSync(registryPath)) {
6540
+ const registryPath = path26.join(os12.homedir(), ".code-intel", "registry.json");
6541
+ if (fs18.existsSync(registryPath)) {
7768
6542
  filesToBackup.push({ name: "registry.json", localPath: registryPath });
7769
6543
  }
7770
- const usersDbPath = path27__default.join(os12.homedir(), ".code-intel", "users.db");
7771
- if (fs19__default.existsSync(usersDbPath)) {
6544
+ const usersDbPath = path26.join(os12.homedir(), ".code-intel", "users.db");
6545
+ if (fs18.existsSync(usersDbPath)) {
7772
6546
  filesToBackup.push({ name: "users.db", localPath: usersDbPath });
7773
6547
  }
7774
6548
  if (filesToBackup.length === 0) {
@@ -7779,7 +6553,7 @@ var BackupService = class {
7779
6553
  createdAt,
7780
6554
  version: BACKUP_VERSION,
7781
6555
  files: filesToBackup.map((f) => {
7782
- const data = fs19__default.readFileSync(f.localPath);
6556
+ const data = fs18.readFileSync(f.localPath);
7783
6557
  return {
7784
6558
  name: f.name,
7785
6559
  sha256: crypto4.createHash("sha256").update(data).digest("hex"),
@@ -7793,7 +6567,7 @@ var BackupService = class {
7793
6567
  manifestLenBuf.writeUInt32BE(manifestBuf.length, 0);
7794
6568
  parts.push(manifestLenBuf, manifestBuf);
7795
6569
  for (const f of filesToBackup) {
7796
- const data = fs19__default.readFileSync(f.localPath);
6570
+ const data = fs18.readFileSync(f.localPath);
7797
6571
  const nameBuf = Buffer.from(f.name, "utf-8");
7798
6572
  const nameLenBuf = Buffer.alloc(2);
7799
6573
  nameLenBuf.writeUInt16BE(nameBuf.length, 0);
@@ -7804,8 +6578,8 @@ var BackupService = class {
7804
6578
  const plaintext = Buffer.concat(parts);
7805
6579
  const encrypted = encryptBuffer(plaintext, this.key);
7806
6580
  const backupFileName = `backup-${id}.cib`;
7807
- const backupPath = path27__default.join(this.backupDir, backupFileName);
7808
- fs19__default.writeFileSync(backupPath, encrypted);
6581
+ const backupPath = path26.join(this.backupDir, backupFileName);
6582
+ fs18.writeFileSync(backupPath, encrypted);
7809
6583
  const entry = {
7810
6584
  id,
7811
6585
  createdAt,
@@ -7832,9 +6606,9 @@ var BackupService = class {
7832
6606
  async uploadToS3(entry) {
7833
6607
  const cfg = getS3Config();
7834
6608
  if (!cfg) throw new Error("S3 not configured. Set CODE_INTEL_BACKUP_S3_BUCKET, CODE_INTEL_BACKUP_S3_ACCESS_KEY_ID, CODE_INTEL_BACKUP_S3_SECRET_ACCESS_KEY.");
7835
- const fileName = path27__default.basename(entry.path);
6609
+ const fileName = path26.basename(entry.path);
7836
6610
  const s3Key = `${cfg.prefix}${fileName}`;
7837
- const body = fs19__default.readFileSync(entry.path);
6611
+ const body = fs18.readFileSync(entry.path);
7838
6612
  const result = await s3Request({ method: "PUT", cfg, key: s3Key, body });
7839
6613
  if (result.statusCode < 200 || result.statusCode >= 300) {
7840
6614
  throw new Error(`S3 upload failed (HTTP ${result.statusCode}): ${result.body.slice(0, 200)}`);
@@ -7851,8 +6625,8 @@ var BackupService = class {
7851
6625
  if (result.statusCode < 200 || result.statusCode >= 300) {
7852
6626
  throw new Error(`S3 download failed (HTTP ${result.statusCode}): ${result.body.slice(0, 200)}`);
7853
6627
  }
7854
- fs19__default.mkdirSync(path27__default.dirname(destPath), { recursive: true });
7855
- fs19__default.writeFileSync(destPath, Buffer.from(result.body, "binary"));
6628
+ fs18.mkdirSync(path26.dirname(destPath), { recursive: true });
6629
+ fs18.writeFileSync(destPath, Buffer.from(result.body, "binary"));
7856
6630
  }
7857
6631
  /**
7858
6632
  * List backup objects in S3 with the configured prefix.
@@ -7898,10 +6672,10 @@ var BackupService = class {
7898
6672
  if (!entry) {
7899
6673
  throw new Error(`Backup "${backupId}" not found.`);
7900
6674
  }
7901
- if (!fs19__default.existsSync(entry.path)) {
6675
+ if (!fs18.existsSync(entry.path)) {
7902
6676
  throw new Error(`Backup file not found at: ${entry.path}`);
7903
6677
  }
7904
- const encrypted = fs19__default.readFileSync(entry.path);
6678
+ const encrypted = fs18.readFileSync(entry.path);
7905
6679
  let plaintext;
7906
6680
  try {
7907
6681
  plaintext = decryptBuffer(encrypted, this.key);
@@ -7915,8 +6689,8 @@ var BackupService = class {
7915
6689
  offset += manifestLen;
7916
6690
  const manifest = JSON.parse(manifestStr);
7917
6691
  const restoreBase = targetRepoPath ?? entry.repoPath;
7918
- const codeIntelDir = path27__default.join(restoreBase, ".code-intel");
7919
- fs19__default.mkdirSync(codeIntelDir, { recursive: true });
6692
+ const codeIntelDir = path26.join(restoreBase, ".code-intel");
6693
+ fs18.mkdirSync(codeIntelDir, { recursive: true });
7920
6694
  for (const fileEntry of manifest.files) {
7921
6695
  const nameLen = plaintext.readUInt16BE(offset);
7922
6696
  offset += 2;
@@ -7933,18 +6707,18 @@ var BackupService = class {
7933
6707
  }
7934
6708
  let destPath;
7935
6709
  if (name === "registry.json" || name === "users.db") {
7936
- destPath = path27__default.join(os12.homedir(), ".code-intel", name);
6710
+ destPath = path26.join(os12.homedir(), ".code-intel", name);
7937
6711
  } else {
7938
- destPath = path27__default.join(codeIntelDir, name);
6712
+ destPath = path26.join(codeIntelDir, name);
7939
6713
  }
7940
- fs19__default.writeFileSync(destPath, data);
6714
+ fs18.writeFileSync(destPath, data);
7941
6715
  }
7942
6716
  }
7943
6717
  /**
7944
6718
  * Apply retention policy: keep N daily, M weekly, L monthly backups.
7945
6719
  */
7946
6720
  applyRetention(options = { daily: 7, weekly: 4, monthly: 12 }) {
7947
- const entries = this._loadIndex().filter((e) => fs19__default.existsSync(e.path)).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
6721
+ const entries = this._loadIndex().filter((e) => fs18.existsSync(e.path)).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
7948
6722
  const keep = /* @__PURE__ */ new Set();
7949
6723
  const now = /* @__PURE__ */ new Date();
7950
6724
  const dailyCutoff = new Date(now);
@@ -7974,7 +6748,7 @@ var BackupService = class {
7974
6748
  for (const e of entries) {
7975
6749
  if (!keep.has(e.id)) {
7976
6750
  try {
7977
- fs19__default.unlinkSync(e.path);
6751
+ fs18.unlinkSync(e.path);
7978
6752
  deleted++;
7979
6753
  } catch {
7980
6754
  }
@@ -7986,17 +6760,17 @@ var BackupService = class {
7986
6760
  }
7987
6761
  // ── Index helpers ──────────────────────────────────────────────────────────
7988
6762
  _indexPath() {
7989
- return path27__default.join(this.backupDir, "index.json");
6763
+ return path26.join(this.backupDir, "index.json");
7990
6764
  }
7991
6765
  _loadIndex() {
7992
6766
  try {
7993
- return JSON.parse(fs19__default.readFileSync(this._indexPath(), "utf-8"));
6767
+ return JSON.parse(fs18.readFileSync(this._indexPath(), "utf-8"));
7994
6768
  } catch {
7995
6769
  return [];
7996
6770
  }
7997
6771
  }
7998
6772
  _saveIndex(entries) {
7999
- fs19__default.writeFileSync(this._indexPath(), JSON.stringify(entries, null, 2));
6773
+ fs18.writeFileSync(this._indexPath(), JSON.stringify(entries, null, 2));
8000
6774
  }
8001
6775
  _appendIndex(entry) {
8002
6776
  const entries = this._loadIndex();
@@ -8605,11 +7379,11 @@ var openApiSpec = {
8605
7379
  };
8606
7380
 
8607
7381
  // src/http/app.ts
8608
- var __dirname$1 = path27__default.dirname(fileURLToPath(import.meta.url));
7382
+ var __dirname$1 = path26.dirname(fileURLToPath(import.meta.url));
8609
7383
  var WEB_DIST = (() => {
8610
- const bundled = path27__default.resolve(__dirname$1, "..", "web");
8611
- if (fs19__default.existsSync(bundled)) return bundled;
8612
- return path27__default.resolve(__dirname$1, "..", "..", "..", "web", "dist");
7384
+ const bundled = path26.resolve(__dirname$1, "..", "web");
7385
+ if (fs18.existsSync(bundled)) return bundled;
7386
+ return path26.resolve(__dirname$1, "..", "..", "..", "web", "dist");
8613
7387
  })();
8614
7388
  function getAllowedOrigins() {
8615
7389
  const env = process.env["CODE_INTEL_CORS_ORIGINS"];
@@ -8778,7 +7552,7 @@ function createApp(graph, repoName, workspaceRoot) {
8778
7552
  vectorIndexBuilding = false;
8779
7553
  }
8780
7554
  }
8781
- if (workspaceRoot) {
7555
+ if (workspaceRoot && process.env["NODE_ENV"] !== "test") {
8782
7556
  setImmediate(() => ensureVectorIndex().catch(() => {
8783
7557
  }));
8784
7558
  }
@@ -9139,8 +7913,8 @@ function createApp(graph, repoName, workspaceRoot) {
9139
7913
  const registry = loadRegistry();
9140
7914
  const entry = registry.find((r) => r.name === requestedRepo || r.path === requestedRepo);
9141
7915
  if (!entry) return null;
9142
- const dbPath = path27__default.join(entry.path, ".code-intel", "graph.db");
9143
- if (!fs19__default.existsSync(dbPath)) return null;
7916
+ const dbPath = path26.join(entry.path, ".code-intel", "graph.db");
7917
+ if (!fs18.existsSync(dbPath)) return null;
9144
7918
  const repoGraph = createKnowledgeGraph();
9145
7919
  const db = new DbManager(dbPath);
9146
7920
  try {
@@ -9226,7 +8000,7 @@ function createApp(graph, repoName, workspaceRoot) {
9226
8000
  return;
9227
8001
  }
9228
8002
  try {
9229
- const content = fs19__default.readFileSync(file_path, "utf-8");
8003
+ const content = fs18.readFileSync(file_path, "utf-8");
9230
8004
  res.json({ content });
9231
8005
  } catch {
9232
8006
  res.status(404).json({ error: { code: ErrorCodes.NOT_FOUND, message: "File not found" } });
@@ -9484,8 +8258,8 @@ function createApp(graph, repoName, workspaceRoot) {
9484
8258
  for (const member of group.members) {
9485
8259
  const regEntry = registry.find((r) => r.name === member.registryName);
9486
8260
  if (!regEntry) continue;
9487
- const dbPath = path27__default.join(regEntry.path, ".code-intel", "graph.db");
9488
- if (!fs19__default.existsSync(dbPath)) continue;
8261
+ const dbPath = path26.join(regEntry.path, ".code-intel", "graph.db");
8262
+ if (!fs18.existsSync(dbPath)) continue;
9489
8263
  const db = new DbManager(dbPath);
9490
8264
  try {
9491
8265
  await db.init();
@@ -9497,10 +8271,10 @@ function createApp(graph, repoName, workspaceRoot) {
9497
8271
  }
9498
8272
  res.json({ nodes: [...mergedGraph.allNodes()], edges: [...mergedGraph.allEdges()] });
9499
8273
  });
9500
- if (fs19__default.existsSync(WEB_DIST)) {
8274
+ if (fs18.existsSync(WEB_DIST)) {
9501
8275
  app.use(express.static(WEB_DIST));
9502
8276
  app.get("/{*path}", (_req, res) => {
9503
- res.sendFile(path27__default.join(WEB_DIST, "index.html"));
8277
+ res.sendFile(path26.join(WEB_DIST, "index.html"));
9504
8278
  });
9505
8279
  }
9506
8280
  app.use("/admin", requireRole("admin"));