@glasstrace/sdk 1.3.7 → 1.3.9

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.
@@ -2,7 +2,7 @@ import {
2
2
  identityFingerprint,
3
3
  readMcpMarker,
4
4
  resolveEffectiveMcpCredential
5
- } from "../chunk-V2S7BSV4.js";
5
+ } from "../chunk-GYTCZSAV.js";
6
6
  import "../chunk-XS5W3SPL.js";
7
7
  import "../chunk-NSBPE2FW.js";
8
8
 
package/dist/index.cjs CHANGED
@@ -17678,6 +17678,50 @@ function mcpConfigMatches(existingContent, expectedContent) {
17678
17678
  }
17679
17679
  return existingContent.trim() === trimmedExpected;
17680
17680
  }
17681
+ function genericMcpConfigOrLegacyShapeMatches(existingContent, expectedGenericContent) {
17682
+ if (mcpConfigMatches(existingContent, expectedGenericContent)) {
17683
+ return true;
17684
+ }
17685
+ try {
17686
+ const expectedParsed = JSON.parse(expectedGenericContent.trim());
17687
+ const expectedLegacy = stripTypeFromGlasstraceServer(expectedParsed);
17688
+ if (expectedLegacy === null) {
17689
+ return false;
17690
+ }
17691
+ const existingParsed = JSON.parse(existingContent);
17692
+ return JSON.stringify(canonicalize(existingParsed)) === JSON.stringify(canonicalize(expectedLegacy));
17693
+ } catch {
17694
+ return false;
17695
+ }
17696
+ }
17697
+ function stripTypeFromGlasstraceServer(value) {
17698
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
17699
+ return null;
17700
+ }
17701
+ const root = value;
17702
+ const servers = root["mcpServers"];
17703
+ if (servers === null || typeof servers !== "object" || Array.isArray(servers)) {
17704
+ return null;
17705
+ }
17706
+ const serversObj = servers;
17707
+ const server = serversObj["glasstrace"];
17708
+ if (server === null || typeof server !== "object" || Array.isArray(server)) {
17709
+ return null;
17710
+ }
17711
+ const serverObj = server;
17712
+ if (serverObj["type"] !== "http") {
17713
+ return null;
17714
+ }
17715
+ const { type: _omittedType, ...serverWithoutType } = serverObj;
17716
+ void _omittedType;
17717
+ return {
17718
+ ...root,
17719
+ mcpServers: {
17720
+ ...serversObj,
17721
+ glasstrace: serverWithoutType
17722
+ }
17723
+ };
17724
+ }
17681
17725
  function canonicalize(value) {
17682
17726
  if (Array.isArray(value)) {
17683
17727
  return value.map(canonicalize);
@@ -17840,6 +17884,7 @@ function genericMcpConfigContent(endpoint, bearer) {
17840
17884
  {
17841
17885
  mcpServers: {
17842
17886
  glasstrace: {
17887
+ type: "http",
17843
17888
  url: endpoint,
17844
17889
  headers: {
17845
17890
  Authorization: `Bearer ${bearer}`
@@ -17873,7 +17918,7 @@ async function refreshGenericMcpConfigAtRuntime(projectRoot, effective, anonKeyO
17873
17918
  return { action: "preserved" };
17874
17919
  }
17875
17920
  const expectedAnon = genericMcpConfigContent(MCP_ENDPOINT, anonKeyOnDisk);
17876
- if (!mcpConfigMatches(existing, expectedAnon)) {
17921
+ if (!genericMcpConfigOrLegacyShapeMatches(existing, expectedAnon)) {
17877
17922
  return { action: "preserved" };
17878
17923
  }
17879
17924
  const replacement = genericMcpConfigContent(MCP_ENDPOINT, effective.key);
@@ -22632,7 +22677,7 @@ function registerGlasstrace(options) {
22632
22677
  setCoreState(CoreState.REGISTERING);
22633
22678
  startRuntimeStateWriter({
22634
22679
  projectRoot: process.cwd(),
22635
- sdkVersion: "1.3.7"
22680
+ sdkVersion: "1.3.9"
22636
22681
  });
22637
22682
  const config2 = resolveConfig(options);
22638
22683
  if (config2.verbose) {
@@ -22799,8 +22844,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22799
22844
  if (config2.verbose) {
22800
22845
  console.info("[glasstrace] Background init firing.");
22801
22846
  }
22802
- const healthReport = collectHealthReport("1.3.7");
22803
- const initResult = await performInit(config2, anonKeyForInit, "1.3.7", healthReport);
22847
+ const healthReport = collectHealthReport("1.3.9");
22848
+ const initResult = await performInit(config2, anonKeyForInit, "1.3.9", healthReport);
22804
22849
  if (generation !== registrationGeneration) return;
22805
22850
  const currentState = getCoreState();
22806
22851
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22823,7 +22868,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22823
22868
  }
22824
22869
  maybeInstallConsoleCapture();
22825
22870
  if (didLastInitSucceed()) {
22826
- startHeartbeat(config2, anonKeyForInit, "1.3.7", generation, (newApiKey, accountId) => {
22871
+ startHeartbeat(config2, anonKeyForInit, "1.3.9", generation, (newApiKey, accountId) => {
22827
22872
  setAuthState(AuthState.CLAIMING);
22828
22873
  emitLifecycleEvent("auth:claim_started", { accountId });
22829
22874
  setResolvedApiKey(newApiKey);