@glasstrace/sdk 1.3.7 → 1.3.8

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
@@ -12,7 +12,7 @@ import {
12
12
  registerGlasstrace,
13
13
  waitForReady,
14
14
  withGlasstraceConfig
15
- } from "./chunk-LW7474ZA.js";
15
+ } from "./chunk-E23HN24Z.js";
16
16
  import {
17
17
  GlasstraceSpanProcessor,
18
18
  SdkError,
@@ -27,7 +27,7 @@ import {
27
27
  performInit,
28
28
  saveCachedConfig,
29
29
  sendInitRequest
30
- } from "./chunk-YSBGMBI5.js";
30
+ } from "./chunk-ADUD4PEK.js";
31
31
  import {
32
32
  isAnonymousMode,
33
33
  isProductionDisabled,
@@ -37,7 +37,7 @@ import {
37
37
  import {
38
38
  getOrCreateAnonKey,
39
39
  readAnonKey
40
- } from "./chunk-V2S7BSV4.js";
40
+ } from "./chunk-GYTCZSAV.js";
41
41
  import {
42
42
  deriveSessionId
43
43
  } from "./chunk-XS5W3SPL.js";
@@ -17775,6 +17775,50 @@ function mcpConfigMatches(existingContent, expectedContent) {
17775
17775
  }
17776
17776
  return existingContent.trim() === trimmedExpected;
17777
17777
  }
17778
+ function genericMcpConfigOrLegacyShapeMatches(existingContent, expectedGenericContent) {
17779
+ if (mcpConfigMatches(existingContent, expectedGenericContent)) {
17780
+ return true;
17781
+ }
17782
+ try {
17783
+ const expectedParsed = JSON.parse(expectedGenericContent.trim());
17784
+ const expectedLegacy = stripTypeFromGlasstraceServer(expectedParsed);
17785
+ if (expectedLegacy === null) {
17786
+ return false;
17787
+ }
17788
+ const existingParsed = JSON.parse(existingContent);
17789
+ return JSON.stringify(canonicalize(existingParsed)) === JSON.stringify(canonicalize(expectedLegacy));
17790
+ } catch {
17791
+ return false;
17792
+ }
17793
+ }
17794
+ function stripTypeFromGlasstraceServer(value) {
17795
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
17796
+ return null;
17797
+ }
17798
+ const root = value;
17799
+ const servers = root["mcpServers"];
17800
+ if (servers === null || typeof servers !== "object" || Array.isArray(servers)) {
17801
+ return null;
17802
+ }
17803
+ const serversObj = servers;
17804
+ const server = serversObj["glasstrace"];
17805
+ if (server === null || typeof server !== "object" || Array.isArray(server)) {
17806
+ return null;
17807
+ }
17808
+ const serverObj = server;
17809
+ if (serverObj["type"] !== "http") {
17810
+ return null;
17811
+ }
17812
+ const { type: _omittedType, ...serverWithoutType } = serverObj;
17813
+ void _omittedType;
17814
+ return {
17815
+ ...root,
17816
+ mcpServers: {
17817
+ ...serversObj,
17818
+ glasstrace: serverWithoutType
17819
+ }
17820
+ };
17821
+ }
17778
17822
  function canonicalize(value) {
17779
17823
  if (Array.isArray(value)) {
17780
17824
  return value.map(canonicalize);
@@ -17937,6 +17981,7 @@ function genericMcpConfigContent(endpoint, bearer) {
17937
17981
  {
17938
17982
  mcpServers: {
17939
17983
  glasstrace: {
17984
+ type: "http",
17940
17985
  url: endpoint,
17941
17986
  headers: {
17942
17987
  Authorization: `Bearer ${bearer}`
@@ -17970,7 +18015,7 @@ async function refreshGenericMcpConfigAtRuntime(projectRoot, effective, anonKeyO
17970
18015
  return { action: "preserved" };
17971
18016
  }
17972
18017
  const expectedAnon = genericMcpConfigContent(MCP_ENDPOINT, anonKeyOnDisk);
17973
- if (!mcpConfigMatches(existing, expectedAnon)) {
18018
+ if (!genericMcpConfigOrLegacyShapeMatches(existing, expectedAnon)) {
17974
18019
  return { action: "preserved" };
17975
18020
  }
17976
18021
  const replacement = genericMcpConfigContent(MCP_ENDPOINT, effective.key);
@@ -22708,7 +22753,7 @@ function registerGlasstrace(options) {
22708
22753
  setCoreState(CoreState.REGISTERING);
22709
22754
  startRuntimeStateWriter({
22710
22755
  projectRoot: process.cwd(),
22711
- sdkVersion: "1.3.7"
22756
+ sdkVersion: "1.3.8"
22712
22757
  });
22713
22758
  const config2 = resolveConfig(options);
22714
22759
  if (config2.verbose) {
@@ -22875,8 +22920,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22875
22920
  if (config2.verbose) {
22876
22921
  console.info("[glasstrace] Background init firing.");
22877
22922
  }
22878
- const healthReport = collectHealthReport("1.3.7");
22879
- const initResult = await performInit(config2, anonKeyForInit, "1.3.7", healthReport);
22923
+ const healthReport = collectHealthReport("1.3.8");
22924
+ const initResult = await performInit(config2, anonKeyForInit, "1.3.8", healthReport);
22880
22925
  if (generation !== registrationGeneration) return;
22881
22926
  const currentState = getCoreState();
22882
22927
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22899,7 +22944,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22899
22944
  }
22900
22945
  maybeInstallConsoleCapture();
22901
22946
  if (didLastInitSucceed()) {
22902
- startHeartbeat(config2, anonKeyForInit, "1.3.7", generation, (newApiKey, accountId) => {
22947
+ startHeartbeat(config2, anonKeyForInit, "1.3.8", generation, (newApiKey, accountId) => {
22903
22948
  setAuthState(AuthState.CLAIMING);
22904
22949
  emitLifecycleEvent("auth:claim_started", { accountId });
22905
22950
  setResolvedApiKey(newApiKey);