@glasstrace/sdk 0.8.0 → 0.9.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
@@ -2,7 +2,7 @@ import {
2
2
  buildImportGraph,
3
3
  discoverTestFiles,
4
4
  extractImports
5
- } from "./chunk-SALPGSWK.js";
5
+ } from "./chunk-Y6V7BTF3.js";
6
6
  import {
7
7
  DEFAULT_CAPTURE_CONFIG,
8
8
  GLASSTRACE_ATTRIBUTE_NAMES,
@@ -14,7 +14,7 @@ import {
14
14
  SourceMapUploadResponseSchema,
15
15
  getOrCreateAnonKey,
16
16
  readAnonKey
17
- } from "./chunk-QW6W4CSA.js";
17
+ } from "./chunk-PQWAKVQ5.js";
18
18
  import {
19
19
  INVALID_SPAN_CONTEXT,
20
20
  SamplingDecision,
@@ -3488,6 +3488,43 @@ async function configureOtel(config, sessionManager) {
3488
3488
  registerShutdownHooks(provider);
3489
3489
  }
3490
3490
 
3491
+ // src/nudge/error-nudge.ts
3492
+ import { existsSync } from "fs";
3493
+ import { join as join2 } from "path";
3494
+ var hasFired = false;
3495
+ function sanitize(input) {
3496
+ return input.replace(/[\x00-\x1f\x7f]/g, "");
3497
+ }
3498
+ function maybeShowMcpNudge(errorSummary) {
3499
+ if (hasFired) {
3500
+ return;
3501
+ }
3502
+ const config = resolveConfig();
3503
+ if (isProductionDisabled(config)) {
3504
+ hasFired = true;
3505
+ return;
3506
+ }
3507
+ let markerExists = false;
3508
+ try {
3509
+ const markerPath = join2(process.cwd(), ".glasstrace", "mcp-connected");
3510
+ markerExists = existsSync(markerPath);
3511
+ } catch {
3512
+ markerExists = false;
3513
+ }
3514
+ if (markerExists) {
3515
+ hasFired = true;
3516
+ return;
3517
+ }
3518
+ hasFired = true;
3519
+ const safe = sanitize(errorSummary);
3520
+ process.stderr.write(
3521
+ `[glasstrace] Error captured: ${safe}
3522
+ Debug with AI: ask your agent "What's the latest Glasstrace error?"
3523
+ Not connected? Run: npx glasstrace mcp add
3524
+ `
3525
+ );
3526
+ }
3527
+
3491
3528
  // src/console-capture.ts
3492
3529
  var isGlasstraceLog = false;
3493
3530
  var originalError = null;
@@ -3524,9 +3561,14 @@ async function installConsoleCapture() {
3524
3561
  if (otelApi) {
3525
3562
  const span = otelApi.trace.getSpan(otelApi.context.active());
3526
3563
  if (span) {
3564
+ const formattedMessage = formatArgs(args);
3527
3565
  span.addEvent("console.error", {
3528
- "console.message": formatArgs(args)
3566
+ "console.message": formattedMessage
3529
3567
  });
3568
+ try {
3569
+ maybeShowMcpNudge(formattedMessage);
3570
+ } catch {
3571
+ }
3530
3572
  }
3531
3573
  }
3532
3574
  };
@@ -3692,7 +3734,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
3692
3734
  if (config.verbose) {
3693
3735
  console.info("[glasstrace] Background init firing.");
3694
3736
  }
3695
- const initResult = await performInit(config, anonKeyForInit, "0.8.0");
3737
+ const initResult = await performInit(config, anonKeyForInit, "0.9.1");
3696
3738
  if (generation !== registrationGeneration) return;
3697
3739
  if (initResult?.claimResult) {
3698
3740
  setResolvedApiKey(initResult.claimResult.newApiKey);
@@ -4014,41 +4056,6 @@ async function handleSourceMapUpload(distDir) {
4014
4056
  }
4015
4057
  }
4016
4058
 
4017
- // src/nudge/error-nudge.ts
4018
- import { existsSync } from "fs";
4019
- import { join as join3 } from "path";
4020
- var hasFired = false;
4021
- function sanitize(input) {
4022
- return input.replace(/[\x00-\x1f\x7f]/g, "");
4023
- }
4024
- function maybeShowMcpNudge(errorSummary) {
4025
- if (hasFired) {
4026
- return;
4027
- }
4028
- const config = resolveConfig();
4029
- if (isProductionDisabled(config)) {
4030
- return;
4031
- }
4032
- let markerExists = false;
4033
- try {
4034
- const markerPath = join3(process.cwd(), ".glasstrace", "mcp-connected");
4035
- markerExists = existsSync(markerPath);
4036
- } catch {
4037
- markerExists = false;
4038
- }
4039
- if (markerExists) {
4040
- return;
4041
- }
4042
- hasFired = true;
4043
- const safe = sanitize(errorSummary);
4044
- process.stderr.write(
4045
- `[glasstrace] Error captured: ${safe}
4046
- Debug with AI: ask your agent "What's the latest Glasstrace error?"
4047
- Not connected? Run: npx glasstrace mcp add
4048
- `
4049
- );
4050
- }
4051
-
4052
4059
  // src/capture-error.ts
4053
4060
  function captureError(error) {
4054
4061
  try {