@glasstrace/sdk 0.10.0 → 0.11.0

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.
@@ -9,8 +9,8 @@ import {
9
9
  } from "../chunk-4NDQPWDJ.js";
10
10
  import {
11
11
  readAnonKey
12
- } from "../chunk-ZRNG36LU.js";
13
- import "../chunk-O3Y45VGV.js";
12
+ } from "../chunk-2JUH3VGJ.js";
13
+ import "../chunk-D3JC3LAK.js";
14
14
  import {
15
15
  MCP_ENDPOINT,
16
16
  formatAgentName
package/dist/index.cjs CHANGED
@@ -14571,7 +14571,9 @@ var init_dist = __esm({
14571
14571
  });
14572
14572
  DiscoveryResponseSchema = external_exports.object({
14573
14573
  key: AnonApiKeySchema,
14574
- sessionId: SessionIdSchema
14574
+ sessionId: SessionIdSchema,
14575
+ claimed: external_exports.boolean().optional(),
14576
+ accountHint: external_exports.string().optional()
14575
14577
  });
14576
14578
  SourceMapUploadResponseSchema = external_exports.object({
14577
14579
  success: external_exports.literal(true),
@@ -16639,6 +16641,7 @@ __export(src_exports, {
16639
16641
  getActiveConfig: () => getActiveConfig,
16640
16642
  getDateString: () => getDateString,
16641
16643
  getDiscoveryHandler: () => getDiscoveryHandler,
16644
+ getLinkedAccountId: () => getLinkedAccountId,
16642
16645
  getOrCreateAnonKey: () => getOrCreateAnonKey,
16643
16646
  getOrigin: () => getOrigin,
16644
16647
  isAnonymousMode: () => isAnonymousMode,
@@ -17094,6 +17097,12 @@ function getActiveConfig() {
17094
17097
  }
17095
17098
  return { ...DEFAULT_CAPTURE_CONFIG };
17096
17099
  }
17100
+ function getLinkedAccountId() {
17101
+ return currentConfig?.linkedAccountId;
17102
+ }
17103
+ function getClaimResult() {
17104
+ return currentConfig?.claimResult;
17105
+ }
17097
17106
  function _setCurrentConfig(config2) {
17098
17107
  currentConfig = config2;
17099
17108
  }
@@ -17407,7 +17416,7 @@ function buildCorsHeaders(origin) {
17407
17416
  }
17408
17417
  return headers;
17409
17418
  }
17410
- function createDiscoveryHandler(getAnonKey, getSessionId) {
17419
+ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
17411
17420
  return async (request) => {
17412
17421
  let url2;
17413
17422
  try {
@@ -17451,8 +17460,16 @@ function createDiscoveryHandler(getAnonKey, getSessionId) {
17451
17460
  );
17452
17461
  }
17453
17462
  const sessionId = getSessionId();
17463
+ const responseBody = { key: anonKey, sessionId };
17464
+ const claimState = getClaimState?.();
17465
+ if (claimState?.claimed) {
17466
+ responseBody.claimed = true;
17467
+ if (claimState.accountHint) {
17468
+ responseBody.accountHint = claimState.accountHint;
17469
+ }
17470
+ }
17454
17471
  return new Response(
17455
- JSON.stringify({ key: anonKey, sessionId }),
17472
+ JSON.stringify(responseBody),
17456
17473
  {
17457
17474
  status: 200,
17458
17475
  headers: corsHeaders
@@ -20244,9 +20261,15 @@ function registerGlasstrace(options) {
20244
20261
  if (isDiscoveryEnabled(config2)) {
20245
20262
  let resolvedAnonKey = null;
20246
20263
  const anonKeyPromise = getOrCreateAnonKey();
20264
+ const getClaimState = () => {
20265
+ if (getLinkedAccountId()) return { claimed: true };
20266
+ if (getClaimResult()) return { claimed: true };
20267
+ return null;
20268
+ };
20247
20269
  discoveryHandler = createDiscoveryHandler(
20248
20270
  async () => resolvedAnonKey,
20249
- () => sessionManager.getSessionId(getResolvedApiKey())
20271
+ () => sessionManager.getSessionId(getResolvedApiKey()),
20272
+ getClaimState
20250
20273
  );
20251
20274
  if (config2.verbose) {
20252
20275
  console.info("[glasstrace] Discovery endpoint registered (key pending).");
@@ -20262,7 +20285,8 @@ function registerGlasstrace(options) {
20262
20285
  if (currentGeneration !== registrationGeneration) return;
20263
20286
  discoveryHandler = createDiscoveryHandler(
20264
20287
  () => Promise.resolve(anonKey),
20265
- () => sessionManager.getSessionId(getResolvedApiKey())
20288
+ () => sessionManager.getSessionId(getResolvedApiKey()),
20289
+ getClaimState
20266
20290
  );
20267
20291
  await backgroundInit(config2, anonKey, currentGeneration);
20268
20292
  } catch (err) {
@@ -20319,7 +20343,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
20319
20343
  if (config2.verbose) {
20320
20344
  console.info("[glasstrace] Background init firing.");
20321
20345
  }
20322
- const initResult = await performInit(config2, anonKeyForInit, "0.10.0");
20346
+ const initResult = await performInit(config2, anonKeyForInit, "0.11.0");
20323
20347
  if (generation !== registrationGeneration) return;
20324
20348
  if (initResult?.claimResult) {
20325
20349
  setResolvedApiKey(initResult.claimResult.newApiKey);
@@ -20624,6 +20648,7 @@ async function buildImportGraph(projectRoot) {
20624
20648
  getActiveConfig,
20625
20649
  getDateString,
20626
20650
  getDiscoveryHandler,
20651
+ getLinkedAccountId,
20627
20652
  getOrCreateAnonKey,
20628
20653
  getOrigin,
20629
20654
  isAnonymousMode,