@glasstrace/sdk 1.3.4 → 1.3.6

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.
@@ -5,7 +5,7 @@ import {
5
5
  injectInfoSection,
6
6
  updateGitignore,
7
7
  writeMcpConfig
8
- } from "../chunk-P4OYPFQ5.js";
8
+ } from "../chunk-TZMYGEMB.js";
9
9
  import {
10
10
  MCP_ENDPOINT,
11
11
  identityFingerprint,
package/dist/index.cjs CHANGED
@@ -22088,6 +22088,27 @@ function detectSentry() {
22088
22088
  }
22089
22089
  }
22090
22090
 
22091
+ // src/proxy-detection.ts
22092
+ function isProxyTracerProvider(value) {
22093
+ if (value === null || value === void 0 || typeof value !== "object") {
22094
+ return false;
22095
+ }
22096
+ return "getTracer" in value && typeof value.getTracer === "function" && "getDelegate" in value && typeof value.getDelegate === "function" && "setDelegate" in value && typeof value.setDelegate === "function" && "getDelegateTracer" in value && typeof value.getDelegateTracer === "function";
22097
+ }
22098
+ function isProxyTracer(value, ownerProvider) {
22099
+ if (value === null || value === void 0 || typeof value !== "object") {
22100
+ return false;
22101
+ }
22102
+ const structurallyShaped = "_getTracer" in value && typeof value._getTracer === "function" && "startSpan" in value && typeof value.startSpan === "function" && "startActiveSpan" in value && typeof value.startActiveSpan === "function";
22103
+ if (!structurallyShaped) {
22104
+ return false;
22105
+ }
22106
+ if (!Object.hasOwn(value, "_provider")) {
22107
+ return false;
22108
+ }
22109
+ return value._provider === ownerProvider;
22110
+ }
22111
+
22091
22112
  // src/otel-config.ts
22092
22113
  var resolvedApiKey = API_KEY_PENDING;
22093
22114
  var activeExporter = null;
@@ -22126,7 +22147,7 @@ async function configureOtel(config2, sessionManager) {
22126
22147
  });
22127
22148
  const existingProvider = trace.getTracerProvider();
22128
22149
  const probeTracer = existingProvider.getTracer("glasstrace-probe");
22129
- const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
22150
+ const anotherProviderRegistered = !isProxyTracerProvider(existingProvider) || !isProxyTracer(probeTracer, existingProvider);
22130
22151
  if (anotherProviderRegistered) {
22131
22152
  setCoexistenceState("coexisting");
22132
22153
  await runCoexistencePath(existingProvider, config2);
@@ -22405,19 +22426,19 @@ function stopHeartbeat() {
22405
22426
  }
22406
22427
  }
22407
22428
  function checkShutdownMarker(projectRoot) {
22408
- let fsSync = null;
22409
- let pathSync = null;
22429
+ let fsSync2 = null;
22430
+ let pathSync2 = null;
22410
22431
  try {
22411
- fsSync = require("node:fs");
22412
- pathSync = require("node:path");
22432
+ fsSync2 = require("node:fs");
22433
+ pathSync2 = require("node:path");
22413
22434
  } catch {
22414
22435
  return { triggered: false };
22415
22436
  }
22416
22437
  const root = projectRoot ?? (typeof process !== "undefined" ? process.cwd() : ".");
22417
- const markerPath = pathSync.join(root, SHUTDOWN_MARKER_RELPATH);
22418
- if (!fsSync.existsSync(markerPath)) return { triggered: false };
22438
+ const markerPath = pathSync2.join(root, SHUTDOWN_MARKER_RELPATH);
22439
+ if (!fsSync2.existsSync(markerPath)) return { triggered: false };
22419
22440
  try {
22420
- fsSync.unlinkSync(markerPath);
22441
+ fsSync2.unlinkSync(markerPath);
22421
22442
  } catch {
22422
22443
  }
22423
22444
  const shutdown = executeShutdown().catch(() => {
@@ -22497,9 +22518,16 @@ function registerHeartbeatShutdownHook(config2, anonKey, sdkVersion) {
22497
22518
  }
22498
22519
 
22499
22520
  // src/runtime-state.ts
22500
- var import_node_fs = require("node:fs");
22501
- var import_node_path = require("node:path");
22502
22521
  init_console_capture();
22522
+ var fsSync = null;
22523
+ var pathSync = null;
22524
+ try {
22525
+ fsSync = require("node:fs");
22526
+ pathSync = require("node:path");
22527
+ } catch {
22528
+ fsSync = null;
22529
+ pathSync = null;
22530
+ }
22503
22531
  var _projectRoot = null;
22504
22532
  var _sdkVersion = "unknown";
22505
22533
  var _lastScenario;
@@ -22508,7 +22536,7 @@ var _debounceTimer = null;
22508
22536
  var _started = false;
22509
22537
  function startRuntimeStateWriter(options) {
22510
22538
  if (_started) return;
22511
- if (!isSyncFsAvailable()) {
22539
+ if (!isSyncFsAvailable() || fsSync === null || pathSync === null) {
22512
22540
  _started = true;
22513
22541
  return;
22514
22542
  }
@@ -22560,9 +22588,9 @@ function writeStateNow() {
22560
22588
  if (_lastError) {
22561
22589
  runtimeState.lastError = _lastError;
22562
22590
  }
22563
- const dir = (0, import_node_path.join)(_projectRoot, ".glasstrace");
22564
- const filePath = (0, import_node_path.join)(dir, "runtime-state.json");
22565
- (0, import_node_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
22591
+ const dir = pathSync.join(_projectRoot, ".glasstrace");
22592
+ const filePath = pathSync.join(dir, "runtime-state.json");
22593
+ fsSync.mkdirSync(dir, { recursive: true, mode: 448 });
22566
22594
  atomicWriteFileSync(filePath, JSON.stringify(runtimeState, null, 2) + "\n", {
22567
22595
  mode: 384
22568
22596
  });
@@ -22604,7 +22632,7 @@ function registerGlasstrace(options) {
22604
22632
  setCoreState(CoreState.REGISTERING);
22605
22633
  startRuntimeStateWriter({
22606
22634
  projectRoot: process.cwd(),
22607
- sdkVersion: "1.3.4"
22635
+ sdkVersion: "1.3.6"
22608
22636
  });
22609
22637
  const config2 = resolveConfig(options);
22610
22638
  if (config2.verbose) {
@@ -22620,8 +22648,9 @@ function registerGlasstrace(options) {
22620
22648
  if (config2.verbose) {
22621
22649
  console.info("[glasstrace] Not production-disabled.");
22622
22650
  }
22623
- const existingProbe = trace.getTracerProvider().getTracer("glasstrace-probe");
22624
- const anotherProviderRegistered = existingProbe.constructor.name !== "ProxyTracer";
22651
+ const existingTracerProvider = trace.getTracerProvider();
22652
+ const existingProbe = existingTracerProvider.getTracer("glasstrace-probe");
22653
+ const anotherProviderRegistered = !isProxyTracerProvider(existingTracerProvider) || !isProxyTracer(existingProbe, existingTracerProvider);
22625
22654
  if (anotherProviderRegistered) {
22626
22655
  setCoexistenceState("coexisting");
22627
22656
  }
@@ -22770,8 +22799,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22770
22799
  if (config2.verbose) {
22771
22800
  console.info("[glasstrace] Background init firing.");
22772
22801
  }
22773
- const healthReport = collectHealthReport("1.3.4");
22774
- const initResult = await performInit(config2, anonKeyForInit, "1.3.4", healthReport);
22802
+ const healthReport = collectHealthReport("1.3.6");
22803
+ const initResult = await performInit(config2, anonKeyForInit, "1.3.6", healthReport);
22775
22804
  if (generation !== registrationGeneration) return;
22776
22805
  const currentState = getCoreState();
22777
22806
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22794,7 +22823,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22794
22823
  }
22795
22824
  maybeInstallConsoleCapture();
22796
22825
  if (didLastInitSucceed()) {
22797
- startHeartbeat(config2, anonKeyForInit, "1.3.4", generation, (newApiKey, accountId) => {
22826
+ startHeartbeat(config2, anonKeyForInit, "1.3.6", generation, (newApiKey, accountId) => {
22798
22827
  setAuthState(AuthState.CLAIMING);
22799
22828
  emitLifecycleEvent("auth:claim_started", { accountId });
22800
22829
  setResolvedApiKey(newApiKey);