@glasstrace/sdk 1.1.3 → 1.2.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.
Files changed (49) hide show
  1. package/README.md +54 -1
  2. package/dist/{chunk-6RNBUUBR.js → chunk-2GCN27SI.js} +2 -2
  3. package/dist/{chunk-4EZ6JTDG.js → chunk-47B2G3FE.js} +2 -2
  4. package/dist/{chunk-FGDS33I2.js → chunk-CTJO7PUZ.js} +71 -17
  5. package/dist/chunk-CTJO7PUZ.js.map +1 -0
  6. package/dist/{chunk-X5MAXP5T.js → chunk-EBYISKQP.js} +5 -3
  7. package/dist/{chunk-X5MAXP5T.js.map → chunk-EBYISKQP.js.map} +1 -1
  8. package/dist/{chunk-JKI4OCFV.js → chunk-HV5ID2WJ.js} +3 -3
  9. package/dist/{chunk-TWTWRJ25.js → chunk-MD5XPCTQ.js} +2 -2
  10. package/dist/{chunk-TWHCJKRS.js → chunk-NFPDYME5.js} +3 -3
  11. package/dist/{chunk-DST4UBXU.js → chunk-YMLMZCPR.js} +2 -2
  12. package/dist/cli/init.cjs +5 -3
  13. package/dist/cli/init.cjs.map +1 -1
  14. package/dist/cli/init.js +6 -6
  15. package/dist/cli/mcp-add.cjs +4 -2
  16. package/dist/cli/mcp-add.cjs.map +1 -1
  17. package/dist/cli/mcp-add.js +2 -2
  18. package/dist/cli/uninit.js +3 -3
  19. package/dist/cli/validate.cjs +4 -2
  20. package/dist/cli/validate.cjs.map +1 -1
  21. package/dist/cli/validate.js +2 -2
  22. package/dist/edge-entry.cjs +4 -2
  23. package/dist/edge-entry.cjs.map +1 -1
  24. package/dist/edge-entry.js +2 -2
  25. package/dist/index.cjs +70 -14
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +5 -5
  28. package/dist/node-entry.cjs +70 -14
  29. package/dist/node-entry.cjs.map +1 -1
  30. package/dist/node-entry.js +7 -7
  31. package/dist/node-subpath.cjs +4 -2
  32. package/dist/node-subpath.cjs.map +1 -1
  33. package/dist/node-subpath.js +3 -3
  34. package/dist/{source-map-uploader-DPUUCLNW.js → source-map-uploader-RA4Z7TWA.js} +3 -3
  35. package/dist/trpc/index.cjs +809 -0
  36. package/dist/trpc/index.cjs.map +1 -0
  37. package/dist/trpc/index.d.cts +165 -0
  38. package/dist/trpc/index.d.ts +165 -0
  39. package/dist/trpc/index.js +65 -0
  40. package/dist/trpc/index.js.map +1 -0
  41. package/package.json +12 -1
  42. package/dist/chunk-FGDS33I2.js.map +0 -1
  43. /package/dist/{chunk-6RNBUUBR.js.map → chunk-2GCN27SI.js.map} +0 -0
  44. /package/dist/{chunk-4EZ6JTDG.js.map → chunk-47B2G3FE.js.map} +0 -0
  45. /package/dist/{chunk-JKI4OCFV.js.map → chunk-HV5ID2WJ.js.map} +0 -0
  46. /package/dist/{chunk-TWTWRJ25.js.map → chunk-MD5XPCTQ.js.map} +0 -0
  47. /package/dist/{chunk-TWHCJKRS.js.map → chunk-NFPDYME5.js.map} +0 -0
  48. /package/dist/{chunk-DST4UBXU.js.map → chunk-YMLMZCPR.js.map} +0 -0
  49. /package/dist/{source-map-uploader-DPUUCLNW.js.map → source-map-uploader-RA4Z7TWA.js.map} +0 -0
package/dist/index.js CHANGED
@@ -12,12 +12,12 @@ import {
12
12
  registerGlasstrace,
13
13
  waitForReady,
14
14
  withGlasstraceConfig
15
- } from "./chunk-FGDS33I2.js";
15
+ } from "./chunk-CTJO7PUZ.js";
16
16
  import {
17
17
  GlasstraceSpanProcessor,
18
18
  SdkError,
19
19
  captureCorrelationId
20
- } from "./chunk-6RNBUUBR.js";
20
+ } from "./chunk-2GCN27SI.js";
21
21
  import "./chunk-DQ25VOKK.js";
22
22
  import "./chunk-3TU62WD6.js";
23
23
  import {
@@ -27,7 +27,7 @@ import {
27
27
  performInit,
28
28
  saveCachedConfig,
29
29
  sendInitRequest
30
- } from "./chunk-JKI4OCFV.js";
30
+ } from "./chunk-HV5ID2WJ.js";
31
31
  import {
32
32
  isAnonymousMode,
33
33
  isProductionDisabled,
@@ -37,10 +37,10 @@ import {
37
37
  import {
38
38
  getOrCreateAnonKey,
39
39
  readAnonKey
40
- } from "./chunk-TWTWRJ25.js";
40
+ } from "./chunk-MD5XPCTQ.js";
41
41
  import {
42
42
  deriveSessionId
43
- } from "./chunk-X5MAXP5T.js";
43
+ } from "./chunk-EBYISKQP.js";
44
44
  import "./chunk-NSBPE2FW.js";
45
45
  export {
46
46
  GlasstraceExporter,
@@ -14670,13 +14670,15 @@ var init_dist = __esm({
14670
14670
  });
14671
14671
  PresignedUploadResponseSchema = external_exports.object({
14672
14672
  uploadId: external_exports.string().uuid(),
14673
- expiresAt: external_exports.number().int().positive(),
14673
+ expiresAt: external_exports.number().int().nonnegative(),
14674
14674
  files: external_exports.array(
14675
14675
  external_exports.object({
14676
14676
  filePath: external_exports.string().min(1),
14677
14677
  clientToken: external_exports.string().min(1),
14678
14678
  pathname: external_exports.string().min(1),
14679
- maxBytes: external_exports.number().int().positive()
14679
+ maxBytes: external_exports.number().int().positive(),
14680
+ /** Vercel Blob access mode — explicit in the contract per DISC-756. */
14681
+ access: external_exports.enum(["public"])
14680
14682
  })
14681
14683
  ).min(1).max(100)
14682
14684
  });
@@ -18300,16 +18302,22 @@ var ERROR_RESPONSE_BODY_TRUNCATION_MARKER = "...[truncated]";
18300
18302
  var REDACTED = "[REDACTED]";
18301
18303
  var ERROR_STATUS_MIN = 400;
18302
18304
  var ERROR_STATUS_MAX = 599;
18303
- function isHttpErrorStatus(status) {
18305
+ function coerceHttpStatus(value) {
18304
18306
  let numeric;
18305
- if (typeof status === "number") {
18306
- numeric = status;
18307
- } else if (typeof status === "string" && status.length > 0) {
18308
- numeric = Number(status);
18307
+ if (typeof value === "number") {
18308
+ numeric = value;
18309
+ } else if (typeof value === "string") {
18310
+ const trimmed = value.trim();
18311
+ if (trimmed.length === 0) return void 0;
18312
+ numeric = Number(trimmed);
18309
18313
  } else {
18310
- return false;
18314
+ return void 0;
18311
18315
  }
18312
- if (!Number.isFinite(numeric)) return false;
18316
+ return Number.isFinite(numeric) ? numeric : void 0;
18317
+ }
18318
+ function isHttpErrorStatus(status) {
18319
+ const numeric = coerceHttpStatus(status);
18320
+ if (numeric === void 0) return false;
18313
18321
  return numeric >= ERROR_STATUS_MIN && numeric <= ERROR_STATUS_MAX;
18314
18322
  }
18315
18323
  var REDACTION_PATTERNS = [
@@ -18569,7 +18577,7 @@ var GlasstraceExporter = class {
18569
18577
  }
18570
18578
  }
18571
18579
  }
18572
- const statusCode = attrs["http.status_code"] ?? attrs["http.response.status_code"];
18580
+ const statusCode = coerceHttpStatus(attrs["http.status_code"]) ?? coerceHttpStatus(attrs["http.response.status_code"]);
18573
18581
  if (statusCode !== void 0) {
18574
18582
  extra[ATTR2.HTTP_STATUS_CODE] = statusCode;
18575
18583
  }
@@ -22260,8 +22268,51 @@ async function runRegistrationPath(config2, sessionManager) {
22260
22268
  // src/context-manager.ts
22261
22269
  var import_node_async_hooks = require("node:async_hooks");
22262
22270
  init_esm();
22271
+ var GLASSTRACE_BRAND = 1;
22272
+ var GUARD = /* @__PURE__ */ Symbol.for("glasstrace.context-manager.installed");
22273
+ var OTEL_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api.1");
22274
+ function isOtelContextManager(value) {
22275
+ if (typeof value !== "object" || value === null) return false;
22276
+ const candidate = value;
22277
+ return typeof candidate.active === "function" && typeof candidate.with === "function" && typeof candidate.bind === "function" && typeof candidate.enable === "function" && typeof candidate.disable === "function";
22278
+ }
22279
+ function isInstallationRecord(value) {
22280
+ if (typeof value !== "object" || value === null) return false;
22281
+ const candidate = value;
22282
+ if (candidate.glasstraceContextManagerBrand !== GLASSTRACE_BRAND) return false;
22283
+ return candidate.manager === null || isOtelContextManager(candidate.manager);
22284
+ }
22285
+ function getOtelRegisteredContextManager() {
22286
+ const otelSlot = globalThis[OTEL_API_KEY];
22287
+ if (typeof otelSlot !== "object" || otelSlot === null) return void 0;
22288
+ const ctx = otelSlot.context;
22289
+ return isOtelContextManager(ctx) ? ctx : void 0;
22290
+ }
22263
22291
  function installContextManager() {
22264
22292
  try {
22293
+ const slot = globalThis;
22294
+ const existing = slot[GUARD];
22295
+ const otelCurrent = getOtelRegisteredContextManager();
22296
+ if (isInstallationRecord(existing) && existing.manager !== null && existing.manager === otelCurrent) {
22297
+ return true;
22298
+ }
22299
+ if (isInstallationRecord(existing) && existing.manager === null && otelCurrent !== void 0) {
22300
+ return false;
22301
+ }
22302
+ if (isInstallationRecord(existing) && existing.manager !== null) {
22303
+ const reSuccess = context.setGlobalContextManager(existing.manager);
22304
+ if (!reSuccess) {
22305
+ console.warn(
22306
+ "[glasstrace] Another context manager is already registered. Trace context propagation may not work as expected."
22307
+ );
22308
+ }
22309
+ const reRecord = {
22310
+ glasstraceContextManagerBrand: GLASSTRACE_BRAND,
22311
+ manager: reSuccess ? existing.manager : null
22312
+ };
22313
+ slot[GUARD] = reRecord;
22314
+ return reSuccess;
22315
+ }
22265
22316
  const als = new import_node_async_hooks.AsyncLocalStorage();
22266
22317
  const contextManager = {
22267
22318
  active: () => als.getStore() ?? ROOT_CONTEXT,
@@ -22282,6 +22333,11 @@ function installContextManager() {
22282
22333
  "[glasstrace] Another context manager is already registered. Trace context propagation may not work as expected."
22283
22334
  );
22284
22335
  }
22336
+ const record2 = {
22337
+ glasstraceContextManagerBrand: GLASSTRACE_BRAND,
22338
+ manager: success2 ? contextManager : null
22339
+ };
22340
+ slot[GUARD] = record2;
22285
22341
  return success2;
22286
22342
  } catch {
22287
22343
  return false;
@@ -22513,7 +22569,7 @@ function registerGlasstrace(options) {
22513
22569
  setCoreState(CoreState.REGISTERING);
22514
22570
  startRuntimeStateWriter({
22515
22571
  projectRoot: process.cwd(),
22516
- sdkVersion: "1.1.3"
22572
+ sdkVersion: "1.2.1"
22517
22573
  });
22518
22574
  const config2 = resolveConfig(options);
22519
22575
  if (config2.verbose) {
@@ -22679,8 +22735,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22679
22735
  if (config2.verbose) {
22680
22736
  console.info("[glasstrace] Background init firing.");
22681
22737
  }
22682
- const healthReport = collectHealthReport("1.1.3");
22683
- const initResult = await performInit(config2, anonKeyForInit, "1.1.3", healthReport);
22738
+ const healthReport = collectHealthReport("1.2.1");
22739
+ const initResult = await performInit(config2, anonKeyForInit, "1.2.1", healthReport);
22684
22740
  if (generation !== registrationGeneration) return;
22685
22741
  const currentState = getCoreState();
22686
22742
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22703,7 +22759,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22703
22759
  }
22704
22760
  maybeInstallConsoleCapture();
22705
22761
  if (didLastInitSucceed()) {
22706
- startHeartbeat(config2, anonKeyForInit, "1.1.3", generation, (newApiKey, accountId) => {
22762
+ startHeartbeat(config2, anonKeyForInit, "1.2.1", generation, (newApiKey, accountId) => {
22707
22763
  setAuthState(AuthState.CLAIMING);
22708
22764
  emitLifecycleEvent("auth:claim_started", { accountId });
22709
22765
  setResolvedApiKey(newApiKey);