@glasstrace/sdk 1.9.0 → 1.10.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.
Files changed (68) hide show
  1. package/dist/async-context/index.cjs +53 -4
  2. package/dist/async-context/index.cjs.map +1 -1
  3. package/dist/async-context/index.js +2 -2
  4. package/dist/{chunk-JHUNLPSS.js → chunk-6RKS3DNA.js} +45 -1
  5. package/dist/{chunk-JHUNLPSS.js.map → chunk-6RKS3DNA.js.map} +1 -1
  6. package/dist/{chunk-HD6JIFKN.js → chunk-BSVWJSVX.js} +2 -2
  7. package/dist/{chunk-QHV7NFON.js → chunk-D54FMQHF.js} +49 -40
  8. package/dist/chunk-D54FMQHF.js.map +1 -0
  9. package/dist/chunk-I2DVVSKW.js +419 -0
  10. package/dist/chunk-I2DVVSKW.js.map +1 -0
  11. package/dist/{chunk-H6WJ63X2.js → chunk-M5GO2SSO.js} +2 -2
  12. package/dist/{chunk-XEPC4NFL.js → chunk-OXA4IHQX.js} +39 -405
  13. package/dist/chunk-OXA4IHQX.js.map +1 -0
  14. package/dist/{chunk-RQ5BIWDT.js → chunk-OXM2BZMF.js} +11 -6
  15. package/dist/{chunk-RQ5BIWDT.js.map → chunk-OXM2BZMF.js.map} +1 -1
  16. package/dist/{chunk-M6EWJCAT.js → chunk-QVTONMVZ.js} +2 -2
  17. package/dist/{chunk-DKV53A2C.js → chunk-RL43PU2X.js} +2 -2
  18. package/dist/{chunk-GWIEUBFR.js → chunk-UMGZJYC4.js} +3 -3
  19. package/dist/{chunk-QXITSNYM.js → chunk-XG6WR2KS.js} +3 -3
  20. package/dist/cli/init.cjs +4 -4
  21. package/dist/cli/init.cjs.map +1 -1
  22. package/dist/cli/init.js +7 -7
  23. package/dist/cli/init.js.map +1 -1
  24. package/dist/cli/mcp-add.cjs +1 -1
  25. package/dist/cli/mcp-add.cjs.map +1 -1
  26. package/dist/cli/mcp-add.js +3 -3
  27. package/dist/cli/mcp-add.js.map +1 -1
  28. package/dist/cli/uninit.js +3 -3
  29. package/dist/cli/upgrade-instructions.cjs +1 -1
  30. package/dist/cli/upgrade-instructions.cjs.map +1 -1
  31. package/dist/cli/upgrade-instructions.js +3 -3
  32. package/dist/cli/upgrade-instructions.js.map +1 -1
  33. package/dist/cli/validate.cjs.map +1 -1
  34. package/dist/cli/validate.js +2 -2
  35. package/dist/edge-entry.cjs +100 -42
  36. package/dist/edge-entry.cjs.map +1 -1
  37. package/dist/edge-entry.js +4 -4
  38. package/dist/index.cjs +58 -5
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.js +10 -8
  41. package/dist/index.js.map +1 -1
  42. package/dist/middleware/index.cjs +91 -38
  43. package/dist/middleware/index.cjs.map +1 -1
  44. package/dist/middleware/index.d.cts +8 -0
  45. package/dist/middleware/index.d.ts +8 -0
  46. package/dist/middleware/index.js +2 -2
  47. package/dist/node-entry.cjs +58 -5
  48. package/dist/node-entry.cjs.map +1 -1
  49. package/dist/node-entry.js +12 -10
  50. package/dist/node-subpath.cjs.map +1 -1
  51. package/dist/node-subpath.js +3 -3
  52. package/dist/{source-map-uploader-MMJ2WCL4.js → source-map-uploader-CLYCE2TZ.js} +3 -3
  53. package/dist/trpc/index.cjs +15164 -503
  54. package/dist/trpc/index.cjs.map +1 -1
  55. package/dist/trpc/index.d.cts +62 -1
  56. package/dist/trpc/index.d.ts +62 -1
  57. package/dist/trpc/index.js +200 -1
  58. package/dist/trpc/index.js.map +1 -1
  59. package/package.json +1 -1
  60. package/dist/chunk-QHV7NFON.js.map +0 -1
  61. package/dist/chunk-XEPC4NFL.js.map +0 -1
  62. /package/dist/{chunk-HD6JIFKN.js.map → chunk-BSVWJSVX.js.map} +0 -0
  63. /package/dist/{chunk-H6WJ63X2.js.map → chunk-M5GO2SSO.js.map} +0 -0
  64. /package/dist/{chunk-M6EWJCAT.js.map → chunk-QVTONMVZ.js.map} +0 -0
  65. /package/dist/{chunk-DKV53A2C.js.map → chunk-RL43PU2X.js.map} +0 -0
  66. /package/dist/{chunk-GWIEUBFR.js.map → chunk-UMGZJYC4.js.map} +0 -0
  67. /package/dist/{chunk-QXITSNYM.js.map → chunk-XG6WR2KS.js.map} +0 -0
  68. /package/dist/{source-map-uploader-MMJ2WCL4.js.map → source-map-uploader-CLYCE2TZ.js.map} +0 -0
@@ -2,8 +2,8 @@ import {
2
2
  identityFingerprint,
3
3
  readMcpMarker,
4
4
  resolveEffectiveMcpCredential
5
- } from "../chunk-DKV53A2C.js";
6
- import "../chunk-JHUNLPSS.js";
5
+ } from "../chunk-RL43PU2X.js";
6
+ import "../chunk-6RKS3DNA.js";
7
7
  import "../chunk-NSBPE2FW.js";
8
8
 
9
9
  // src/cli/validate.ts
@@ -14618,6 +14618,21 @@ var GLASSTRACE_ATTRIBUTE_NAMES = {
14618
14618
  HTTP_METHOD: "glasstrace.http.method",
14619
14619
  HTTP_STATUS_CODE: "glasstrace.http.status_code",
14620
14620
  HTTP_DURATION_MS: "glasstrace.http.duration_ms",
14621
+ /**
14622
+ * Boolean audit attribute set to `true` only when the SDK's
14623
+ * boundary-masked-error heuristic at `enriching-exporter.ts`
14624
+ * fires (SDK-051 / DISC-1125 — same-span scope; descendant-traversal
14625
+ * scope is tracked in a follow-up DISC).
14626
+ *
14627
+ * Strict additivity: backend ingestion ignores unknown attributes
14628
+ * today; this attribute is for audit/observability. Downstream
14629
+ * tooling MAY surface heuristic activation rates by querying for
14630
+ * spans with this attribute set; the backend's status-handling
14631
+ * pipeline does NOT depend on it.
14632
+ *
14633
+ * Absent on spans where the heuristic did not fire.
14634
+ */
14635
+ HTTP_BOUNDARY_MASKED: "glasstrace.http.boundary_masked",
14621
14636
  ERROR_MESSAGE: "glasstrace.error.message",
14622
14637
  ERROR_CODE: "glasstrace.error.code",
14623
14638
  ERROR_CATEGORY: "glasstrace.error.category",
@@ -14657,6 +14672,35 @@ var GLASSTRACE_ATTRIBUTE_NAMES = {
14657
14672
  SOURCE_LINE: "glasstrace.source.line",
14658
14673
  SOURCE_MAPPED: "glasstrace.source.mapped",
14659
14674
  TRPC_PROCEDURE: "glasstrace.trpc.procedure",
14675
+ /**
14676
+ * Zero-based positional index of the current member within a tRPC
14677
+ * HTTP-batch dispatch (SDK-052 / DISC-1534 SDK-side slice). Set on
14678
+ * member spans by `tracedMiddleware` when the SDK's
14679
+ * `wrapBatchedHttpHandler` envelope is in scope. Numeric.
14680
+ *
14681
+ * Load-bearing for batches that include the same procedure name
14682
+ * more than once — name-only matching cannot disambiguate, so the
14683
+ * positional index is the canonical disambiguator. Absent on
14684
+ * non-batched spans and on apps not using `wrapBatchedHttpHandler`.
14685
+ */
14686
+ TRPC_BATCH_MEMBER_INDEX: "glasstrace.trpc.batch.member_index",
14687
+ /**
14688
+ * Ordered list of all procedure names in the current tRPC HTTP
14689
+ * batch (SDK-052 / DISC-1534 SDK-side slice). Stored as an OTel
14690
+ * typed string array (`string[]`), NOT a JSON-encoded string —
14691
+ * the typed-array form preserves first-class queryability in the
14692
+ * OTel ingest pipeline.
14693
+ *
14694
+ * Set on each member span that `tracedMiddleware` produces when a
14695
+ * `wrapBatchedHttpHandler` envelope is in scope. Absent on
14696
+ * non-batched spans, on the root HTTP server span (today's
14697
+ * release ships strict-additive scope only — per-root-span
14698
+ * attribution is deferred to a follow-up wave because changing
14699
+ * the root span's existing `glasstrace.trpc.procedure` shape from
14700
+ * comma-joined to first-member representative is non-additive),
14701
+ * and on apps not using `wrapBatchedHttpHandler`.
14702
+ */
14703
+ TRPC_BATCH_MEMBER_PROCEDURES: "glasstrace.trpc.batch.member_procedures",
14660
14704
  ERROR_RESPONSE_BODY: "glasstrace.error.response_body",
14661
14705
  NEXT_ACTION_DETECTED: "glasstrace.next.action.detected",
14662
14706
  // Client-side attributes
@@ -15037,49 +15081,58 @@ function tracedRequestMiddleware(options, handler) {
15037
15081
  }
15038
15082
  const wrapped = ((req, ...rest) => {
15039
15083
  const tracer = trace.getTracer(TRACER_NAME);
15040
- return tracer.startActiveSpan(options.name, (span) => {
15041
- if (isNoopSpan(span)) {
15042
- if (!_skippedUninstalledEmitted) {
15043
- _skippedUninstalledEmitted = true;
15044
- tryEmitLifecycleEvent("middleware:skipped_uninstalled", {});
15084
+ let callbackInvoked = false;
15085
+ try {
15086
+ return tracer.startActiveSpan(options.name, (span) => {
15087
+ callbackInvoked = true;
15088
+ if (isNoopSpan(span)) {
15089
+ if (!_skippedUninstalledEmitted) {
15090
+ _skippedUninstalledEmitted = true;
15091
+ tryEmitLifecycleEvent("middleware:skipped_uninstalled", {});
15092
+ }
15093
+ endSpanSafely(span);
15094
+ return handler(req, ...rest);
15045
15095
  }
15046
- endSpanSafely(span);
15047
- return handler(req, ...rest);
15048
- }
15049
- try {
15050
- if (options.attributes) {
15051
- span.setAttributes(options.attributes);
15096
+ try {
15097
+ if (options.attributes) {
15098
+ span.setAttributes(options.attributes);
15099
+ }
15100
+ const path = extractRequestPath(req);
15101
+ if (path !== void 0) {
15102
+ span.setAttribute(ATTR2.CAUSAL_MIDDLEWARE_FOR_REQUEST, path);
15103
+ }
15104
+ } catch {
15052
15105
  }
15053
- const path = extractRequestPath(req);
15054
- if (path !== void 0) {
15055
- span.setAttribute(ATTR2.CAUSAL_MIDDLEWARE_FOR_REQUEST, path);
15106
+ let result;
15107
+ try {
15108
+ result = handler(req, ...rest);
15109
+ } catch (error48) {
15110
+ recordSpanError(span, error48);
15111
+ endSpanSafely(span);
15112
+ throw error48;
15113
+ }
15114
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
15115
+ return result.then(
15116
+ (value) => {
15117
+ endSpanSafely(span);
15118
+ return value;
15119
+ },
15120
+ (error48) => {
15121
+ recordSpanError(span, error48);
15122
+ endSpanSafely(span);
15123
+ throw error48;
15124
+ }
15125
+ );
15056
15126
  }
15057
- } catch {
15058
- }
15059
- let result;
15060
- try {
15061
- result = handler(req, ...rest);
15062
- } catch (error48) {
15063
- recordSpanError(span, error48);
15064
15127
  endSpanSafely(span);
15065
- throw error48;
15066
- }
15067
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
15068
- return result.then(
15069
- (value) => {
15070
- endSpanSafely(span);
15071
- return value;
15072
- },
15073
- (error48) => {
15074
- recordSpanError(span, error48);
15075
- endSpanSafely(span);
15076
- throw error48;
15077
- }
15078
- );
15128
+ return result;
15129
+ });
15130
+ } catch (err) {
15131
+ if (callbackInvoked) {
15132
+ throw err;
15079
15133
  }
15080
- endSpanSafely(span);
15081
- return result;
15082
- });
15134
+ return handler(req, ...rest);
15135
+ }
15083
15136
  });
15084
15137
  return wrapped;
15085
15138
  }
@@ -15130,10 +15183,15 @@ function withAsyncCausality(options, fn) {
15130
15183
  })();
15131
15184
  return async () => {
15132
15185
  const tracer = trace.getTracer(TRACER_NAME2);
15133
- const span = tracer.startSpan(options.name, {
15134
- root: true,
15135
- links: capturedContext !== void 0 ? [{ context: capturedContext }] : void 0
15136
- });
15186
+ let span;
15187
+ try {
15188
+ span = tracer.startSpan(options.name, {
15189
+ root: true,
15190
+ links: capturedContext !== void 0 ? [{ context: capturedContext }] : void 0
15191
+ });
15192
+ } catch {
15193
+ return Promise.resolve(fn());
15194
+ }
15137
15195
  if (isNoopSpan2(span)) {
15138
15196
  if (!_skippedUninstalledEmitted2) {
15139
15197
  _skippedUninstalledEmitted2 = true;