@glasstrace/sdk 0.20.0 → 1.0.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 (61) hide show
  1. package/README.md +37 -5
  2. package/dist/chunk-3TU62WD6.js +142 -0
  3. package/dist/chunk-3TU62WD6.js.map +1 -0
  4. package/dist/chunk-67RIOAXV.js +105 -0
  5. package/dist/chunk-67RIOAXV.js.map +1 -0
  6. package/dist/{chunk-VN3GZDV6.js → chunk-7PDDBLST.js} +4 -141
  7. package/dist/chunk-7PDDBLST.js.map +1 -0
  8. package/dist/chunk-BT2OCXCG.js +178 -0
  9. package/dist/chunk-BT2OCXCG.js.map +1 -0
  10. package/dist/chunk-D3WYZBQA.js +4547 -0
  11. package/dist/chunk-D3WYZBQA.js.map +1 -0
  12. package/dist/{chunk-F2TZRBEH.js → chunk-DO2YPMQ5.js} +9 -181
  13. package/dist/chunk-DO2YPMQ5.js.map +1 -0
  14. package/dist/{chunk-YPXW2TN3.js → chunk-IP4NMDJK.js} +2 -2
  15. package/dist/{chunk-6JRI4OGB.js → chunk-LU3PPAOQ.js} +5 -3
  16. package/dist/{chunk-6JRI4OGB.js.map → chunk-LU3PPAOQ.js.map} +1 -1
  17. package/dist/{chunk-5N2IR4EO.js → chunk-TQ54WLCZ.js} +1 -1
  18. package/dist/{chunk-5N2IR4EO.js.map → chunk-TQ54WLCZ.js.map} +1 -1
  19. package/dist/cli/init.cjs +5 -3
  20. package/dist/cli/init.cjs.map +1 -1
  21. package/dist/cli/init.js +8 -6
  22. package/dist/cli/init.js.map +1 -1
  23. package/dist/cli/mcp-add.cjs.map +1 -1
  24. package/dist/cli/mcp-add.js +2 -2
  25. package/dist/cli/uninit.cjs +3 -1
  26. package/dist/cli/uninit.cjs.map +1 -1
  27. package/dist/cli/uninit.js +2 -2
  28. package/dist/edge-entry-CFq085RZ.d.ts +130 -0
  29. package/dist/edge-entry-DYl05SJ-.d.cts +130 -0
  30. package/dist/edge-entry.cjs +14839 -0
  31. package/dist/edge-entry.cjs.map +1 -0
  32. package/dist/edge-entry.d.cts +6 -0
  33. package/dist/edge-entry.d.ts +6 -0
  34. package/dist/edge-entry.js +14 -0
  35. package/dist/index.cjs +38 -244
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d-CYYe3PxB.d.cts +191 -0
  38. package/dist/index.d-CYYe3PxB.d.ts +191 -0
  39. package/dist/index.d.cts +8 -461
  40. package/dist/index.d.ts +8 -461
  41. package/dist/index.js +25 -4636
  42. package/dist/index.js.map +1 -1
  43. package/dist/node-entry.cjs +22481 -0
  44. package/dist/node-entry.cjs.map +1 -0
  45. package/dist/node-entry.d.cts +10 -0
  46. package/dist/node-entry.d.ts +10 -0
  47. package/dist/node-entry.js +100 -0
  48. package/dist/node-entry.js.map +1 -0
  49. package/dist/node-subpath.cjs +14506 -0
  50. package/dist/node-subpath.cjs.map +1 -0
  51. package/dist/node-subpath.d.cts +132 -0
  52. package/dist/node-subpath.d.ts +132 -0
  53. package/dist/node-subpath.js +31 -0
  54. package/dist/node-subpath.js.map +1 -0
  55. package/dist/{source-map-uploader-VPDZWWM2.js → source-map-uploader-ZHA3B4GE.js} +4 -3
  56. package/dist/source-map-uploader-ZHA3B4GE.js.map +1 -0
  57. package/package.json +13 -1
  58. package/dist/chunk-F2TZRBEH.js.map +0 -1
  59. package/dist/chunk-VN3GZDV6.js.map +0 -1
  60. /package/dist/{chunk-YPXW2TN3.js.map → chunk-IP4NMDJK.js.map} +0 -0
  61. /package/dist/{source-map-uploader-VPDZWWM2.js.map → edge-entry.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,197 +1,13 @@
1
- import * as z from './v4/classic/external.cjs';
1
+ import { a as SessionManager } from './edge-entry-CFq085RZ.js';
2
+ export { C as CorrelationIdRequest, G as GlasstraceSpanProcessor, S as SdkError, c as captureCorrelationId, g as getDateString, b as getOrigin } from './edge-entry-CFq085RZ.js';
3
+ import { G as GlasstraceEnvVars, a as GlasstraceOptions, A as AnonApiKey, S as SdkInitResponse, C as CaptureConfig, b as SdkHealthReport, I as ImportGraphPayload, c as SdkDiagnosticCode } from './index.d-CYYe3PxB.js';
4
+ export { d as deriveSessionId } from './index.d-CYYe3PxB.js';
2
5
  import { ReadableSpan } from './export/ReadableSpan';
3
- import { Span } from './Span';
4
- import { SpanProcessor } from './SpanProcessor';
5
6
  import { SpanExporter } from './export/SpanExporter';
6
7
  import { ExportResult } from './ExportResult';
7
-
8
- /** Anonymous API key: `gt_anon_` + 48 hex chars. */
9
- declare const AnonApiKeySchema: z.core.$ZodBranded<z.ZodString, "AnonApiKey", "out">;
10
- type AnonApiKey = z.infer<typeof AnonApiKeySchema>;
11
- /** Session ID: 16 hex chars (deterministic, derived from API key + time window). */
12
- declare const SessionIdSchema: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
13
- type SessionId = z.infer<typeof SessionIdSchema>;
14
-
15
- /**
16
- * SDK-specific enums.
17
- */
18
-
19
- /** Diagnostic codes the SDK can report during health checks. */
20
- declare const SdkDiagnosticCodeSchema: z.ZodEnum<{
21
- ingestion_unreachable: "ingestion_unreachable";
22
- ingestion_auth_failed: "ingestion_auth_failed";
23
- ingestion_rate_limited: "ingestion_rate_limited";
24
- config_sync_failed: "config_sync_failed";
25
- source_map_upload_failed: "source_map_upload_failed";
26
- }>;
27
- type SdkDiagnosticCode = z.infer<typeof SdkDiagnosticCodeSchema>;
28
-
29
- /**
30
- * SDK configuration types.
31
- */
32
-
33
- /** SDK capture configuration: which events to capture. */
34
- declare const CaptureConfigSchema: z.ZodObject<{
35
- requestBodies: z.ZodBoolean;
36
- queryParamValues: z.ZodBoolean;
37
- envVarValues: z.ZodBoolean;
38
- fullConsoleOutput: z.ZodBoolean;
39
- importGraph: z.ZodBoolean;
40
- consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
- errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
42
- }, z.core.$strip>;
43
- type CaptureConfig = z.infer<typeof CaptureConfigSchema>;
44
- /** Developer-facing config for registerGlasstrace(). */
45
- declare const GlasstraceOptionsSchema: z.ZodObject<{
46
- apiKey: z.ZodOptional<z.ZodString>;
47
- endpoint: z.ZodOptional<z.ZodString>;
48
- forceEnable: z.ZodOptional<z.ZodBoolean>;
49
- verbose: z.ZodOptional<z.ZodBoolean>;
50
- }, z.core.$strip>;
51
- type GlasstraceOptions = z.infer<typeof GlasstraceOptionsSchema>;
52
- /** All recognized SDK environment variables. */
53
- declare const GlasstraceEnvVarsSchema: z.ZodObject<{
54
- GLASSTRACE_API_KEY: z.ZodOptional<z.ZodString>;
55
- GLASSTRACE_FORCE_ENABLE: z.ZodOptional<z.ZodString>;
56
- GLASSTRACE_ENV: z.ZodOptional<z.ZodString>;
57
- GLASSTRACE_COVERAGE_MAP: z.ZodOptional<z.ZodString>;
58
- NODE_ENV: z.ZodOptional<z.ZodString>;
59
- VERCEL_ENV: z.ZodOptional<z.ZodString>;
60
- }, z.core.$strip>;
61
- type GlasstraceEnvVars = z.infer<typeof GlasstraceEnvVarsSchema>;
62
-
63
- /**
64
- * Wire format types for SDK ↔ backend communication.
65
- *
66
- * These schemas define the request/response shapes for:
67
- * - SDK initialization (POST /v1/sdk/init)
68
- * - SDK health diagnostics (embedded in init requests)
69
- * - Discovery endpoint (GET /__glasstrace/config)
70
- * - Source map upload (POST /v1/source-maps)
71
- * - Presigned source map upload (POST /v1/source-maps/presign, POST /v1/source-maps/manifest)
72
- */
73
-
74
- /** Test file import relationships, embedded in SDK init request. */
75
- declare const ImportGraphPayloadSchema: z.ZodObject<{
76
- buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
77
- graph: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
78
- }, z.core.$strip>;
79
- type ImportGraphPayload = z.infer<typeof ImportGraphPayloadSchema>;
80
- /** SDK health diagnostics included in init requests. */
81
- declare const SdkHealthReportSchema: z.ZodObject<{
82
- tracesExportedSinceLastInit: z.ZodNumber;
83
- tracesDropped: z.ZodNumber;
84
- initFailures: z.ZodNumber;
85
- configAge: z.ZodNumber;
86
- sdkVersion: z.ZodString;
87
- }, z.core.$strip>;
88
- type SdkHealthReport = z.infer<typeof SdkHealthReportSchema>;
89
- /**
90
- * Response from POST /v1/sdk/init.
91
- *
92
- * Note: SdkInitRequest is intentionally NOT in the protocol package.
93
- * The request schema includes backend-specific types (TierLimits,
94
- * SubscriptionStatus) that are not part of the public contract.
95
- * The backend owns the request validation; the SDK only needs to
96
- * understand the response.
97
- */
98
- declare const SdkInitResponseSchema: z.ZodObject<{
99
- config: z.ZodObject<{
100
- requestBodies: z.ZodBoolean;
101
- queryParamValues: z.ZodBoolean;
102
- envVarValues: z.ZodBoolean;
103
- fullConsoleOutput: z.ZodBoolean;
104
- importGraph: z.ZodBoolean;
105
- consoleErrors: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
106
- errorResponseBodies: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
107
- }, z.core.$strip>;
108
- subscriptionStatus: z.ZodString;
109
- linkedAccountId: z.ZodOptional<z.ZodString>;
110
- minimumSdkVersion: z.ZodString;
111
- apiVersion: z.ZodString;
112
- tierLimits: z.ZodObject<{
113
- tracesPerMinute: z.ZodNumber;
114
- storageTtlHours: z.ZodNumber;
115
- maxTraceSizeBytes: z.ZodNumber;
116
- maxConcurrentSessions: z.ZodNumber;
117
- }, z.core.$strip>;
118
- claimResult: z.ZodOptional<z.ZodObject<{
119
- newApiKey: z.core.$ZodBranded<z.ZodString, "DevApiKey", "out">;
120
- accountId: z.ZodString;
121
- graceExpiresAt: z.ZodNumber;
122
- }, z.core.$strip>>;
123
- }, z.core.$strip>;
124
- type SdkInitResponse = z.infer<typeof SdkInitResponseSchema>;
125
- /** Response from POST /v1/source-maps. */
126
- declare const SourceMapUploadResponseSchema: z.ZodObject<{
127
- success: z.ZodLiteral<true>;
128
- buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
129
- fileCount: z.ZodNumber;
130
- totalSizeBytes: z.ZodNumber;
131
- }, z.core.$strip>;
132
- type SourceMapUploadResponse = z.infer<typeof SourceMapUploadResponseSchema>;
133
- /** Response confirming source map manifest activation. */
134
- declare const SourceMapManifestResponseSchema: z.ZodObject<{
135
- success: z.ZodLiteral<true>;
136
- buildHash: z.core.$ZodBranded<z.ZodString, "BuildHash", "out">;
137
- fileCount: z.ZodNumber;
138
- totalSizeBytes: z.ZodNumber;
139
- activatedAt: z.ZodNumber;
140
- }, z.core.$strip>;
141
- type SourceMapManifestResponse = z.infer<typeof SourceMapManifestResponseSchema>;
142
-
143
- /**
144
- * Session ID derivation — part of the public Glasstrace wire contract.
145
- *
146
- * Deriving the session ID is deterministic: given the same inputs,
147
- * every runtime that implements this module produces the same
148
- * 16-character hex identifier. That determinism is the contract — it
149
- * lets independent clients (SDK, browser extension, server tooling)
150
- * agree on the same session without coordination.
151
- *
152
- * This module is pure: it has no module-level state and no
153
- * runtime-dependent branches. It is safe to import from Node 20+,
154
- * modern browsers, Vercel Edge, and Cloudflare Workers. The SHA-256
155
- * implementation is pure JavaScript; no `node:crypto`, no Web Crypto,
156
- * no bundler-specific shims.
157
- */
158
-
159
- /**
160
- * Derives a deterministic session ID from the inputs that define a
161
- * Glasstrace session. The output is a 16-character lowercase hex
162
- * string validated through {@link SessionIdSchema}.
163
- *
164
- * This function is part of the Glasstrace wire contract: any consumer
165
- * (SDK, browser extension, server tooling) that calls it with the same
166
- * arguments receives the same `SessionId`. That property is what lets
167
- * independent clients agree on a session without coordination.
168
- *
169
- * Uses a pure-JavaScript SHA-256 so the output is identical across
170
- * every runtime this package supports (Node 20+, modern browsers,
171
- * Vercel Edge, Cloudflare Workers).
172
- *
173
- * Security note: the session ID is an **identifier**, not a secret or
174
- * an authentication token. It is never used for authorization.
175
- *
176
- * @param apiKey - The project's API key (or anonymous placeholder).
177
- * @param origin - The origin string identifying the deployment
178
- * environment (for example `localhost:3000` or `production`).
179
- * @param date - UTC date as `YYYY-MM-DD`.
180
- * @param windowIndex - Zero-based index of the 4-hour activity window
181
- * within the day.
182
- * @returns A 16-character hex {@link SessionId}.
183
- */
184
- declare function deriveSessionId(apiKey: string, origin: string, date: string, windowIndex: number): SessionId;
185
-
186
- /**
187
- * Internal SDK error class with a typed diagnostic code.
188
- * Caught at the boundary and converted to a log message + diagnostic entry.
189
- * Never thrown to the developer.
190
- */
191
- declare class SdkError extends Error {
192
- readonly code: SdkDiagnosticCode;
193
- constructor(code: SdkDiagnosticCode, message: string, cause?: Error);
194
- }
8
+ import { SpanProcessor } from './SpanProcessor';
9
+ import './Span';
10
+ import './v4/classic/external.cjs';
195
11
 
196
12
  /**
197
13
  * Resolved configuration after merging explicit options with environment variables.
@@ -231,43 +47,6 @@ declare function isProductionDisabled(config: ResolvedConfig): boolean;
231
47
  */
232
48
  declare function isAnonymousMode(config: ResolvedConfig): boolean;
233
49
 
234
- /**
235
- * Returns the origin string for the current process.
236
- * If GLASSTRACE_ENV is set, returns that value.
237
- * Otherwise returns `localhost:{PORT}` (PORT defaults to 3000).
238
- *
239
- * @returns The origin string used as a session derivation input.
240
- */
241
- declare function getOrigin(): string;
242
- /**
243
- * Returns the current UTC date as a YYYY-MM-DD string.
244
- *
245
- * @returns The UTC date formatted as "YYYY-MM-DD".
246
- */
247
- declare function getDateString(): string;
248
- /**
249
- * Tracks the current session state with 4-hour window tracking.
250
- * Instantiated once by the orchestrator.
251
- */
252
- declare class SessionManager {
253
- private windowIndex;
254
- private lastActivityTimestamp;
255
- private lastDate;
256
- private lastApiKey;
257
- private currentSessionId;
258
- /**
259
- * Returns the current session ID, deriving a new one if:
260
- * - More than 4 hours have elapsed since last activity
261
- * - The UTC date has changed (resets window index to 0)
262
- * - The API key has changed (e.g., deferred anonymous key swap)
263
- * - This is the first call
264
- *
265
- * @param apiKey - The project's API key used in session derivation.
266
- * @returns The current or newly derived SessionId.
267
- */
268
- getSessionId(apiKey: string): SessionId;
269
- }
270
-
271
50
  /**
272
51
  * The set of recognized fetch target categories.
273
52
  */
@@ -374,29 +153,6 @@ declare function getActiveConfig(): CaptureConfig;
374
153
  */
375
154
  declare function getLinkedAccountId(): string | undefined;
376
155
 
377
- /**
378
- * Lightweight SpanProcessor that delegates to a wrapped processor.
379
- *
380
- * All glasstrace.* attribute enrichment has been moved to {@link GlasstraceExporter}
381
- * (see enriching-exporter.ts), which enriches spans at export time. This resolves:
382
- * - Cold-start spans are buffered in the exporter, not dropped
383
- * - Vercel's CompositeSpanProcessor skips onEnding(); the exporter doesn't need it
384
- * - Session ID is computed at export time with the resolved API key
385
- *
386
- * This class is retained for backward compatibility. New code should use
387
- * GlasstraceExporter directly.
388
- *
389
- * @deprecated Use GlasstraceExporter for span enrichment. This processor is now a pass-through.
390
- */
391
- declare class GlasstraceSpanProcessor implements SpanProcessor {
392
- private readonly wrappedProcessor;
393
- constructor(wrappedProcessor: SpanProcessor, _sessionManager?: SessionManager, _apiKey?: string | (() => string), _getConfig?: () => CaptureConfig, _environment?: string);
394
- onStart(span: Span, parentContext: Parameters<SpanProcessor["onStart"]>[1]): void;
395
- onEnd(readableSpan: ReadableSpan): void;
396
- shutdown(): Promise<void>;
397
- forceFlush(): Promise<void>;
398
- }
399
-
400
156
  /**
401
157
  * Options for constructing a {@link GlasstraceExporter}.
402
158
  */
@@ -483,33 +239,6 @@ declare class GlasstraceExporter implements SpanExporter {
483
239
  private flushPending;
484
240
  }
485
241
 
486
- /**
487
- * Claim state returned by the `getClaimState` callback.
488
- *
489
- * - `claimed` — `true` when the anonymous key has been linked to an account.
490
- * - `accountHint` — optional masked identifier (e.g. `"er***@example.com"`)
491
- * for the browser extension to display to the user.
492
- */
493
- interface ClaimState {
494
- claimed: boolean;
495
- accountHint?: string;
496
- }
497
- /**
498
- * Creates a request handler for the `/__glasstrace/config` discovery endpoint.
499
- *
500
- * The returned handler checks if the request URL path is `/__glasstrace/config`.
501
- * If not, returns `null` (pass-through). If it matches, returns a `DiscoveryResponse`
502
- * with the anonymous key and current session ID.
503
- *
504
- * When `getClaimState` returns a non-null value with `claimed: true`, the
505
- * response includes `claimed` and (optionally) `accountHint` so the browser
506
- * extension can prompt the user to sign in.
507
- *
508
- * The triple guard (anonymous + dev + active) is enforced by the caller,
509
- * not by this module. If the handler is registered, it serves.
510
- */
511
- declare function createDiscoveryHandler(getAnonKey: () => Promise<AnonApiKey | null>, getSessionId: () => SessionId, getClaimState?: () => ClaimState | null): (request: Request) => Promise<Response | null>;
512
-
513
242
  /**
514
243
  * The primary SDK entry point called by developers in their `instrumentation.ts`.
515
244
  * Orchestrates OTel setup, span processor, init client, anon key, and discovery endpoint.
@@ -673,105 +402,6 @@ declare function getStatus(): {
673
402
  */
674
403
  declare function createGlasstraceSpanProcessor(options?: GlasstraceOptions): SpanProcessor;
675
404
 
676
- interface SourceMapEntry {
677
- filePath: string;
678
- content: string;
679
- }
680
- /**
681
- * Metadata for a discovered source map file, without its content loaded.
682
- * Used by the streaming upload flow to defer file reads until upload time.
683
- */
684
- interface SourceMapFileInfo {
685
- /** Relative path to the compiled JS file (`.map` extension stripped). */
686
- filePath: string;
687
- /** Absolute path on disk for reading the file content on demand. */
688
- absolutePath: string;
689
- /** File size in bytes. */
690
- sizeBytes: number;
691
- }
692
- /**
693
- * Recursively discovers all `.map` files in the given build directory.
694
- * Returns metadata only — file content is NOT read into memory.
695
- */
696
- declare function discoverSourceMapFiles(buildDir: string): Promise<SourceMapFileInfo[]>;
697
- /**
698
- * Recursively finds all .map files in the given build directory.
699
- * Returns relative paths and file contents.
700
- *
701
- * @deprecated Prefer {@link discoverSourceMapFiles} to avoid loading all
702
- * source maps into memory simultaneously.
703
- */
704
- declare function collectSourceMaps(buildDir: string): Promise<SourceMapEntry[]>;
705
- /**
706
- * Computes a build hash for source map uploads.
707
- *
708
- * First tries `git rev-parse HEAD` to get the git commit SHA.
709
- * On failure, falls back to a deterministic content hash:
710
- * sort source map file paths alphabetically, concatenate each as
711
- * `{relativePath}\n{fileLength}\n{fileContent}`, then SHA-256 the result.
712
- *
713
- * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
714
- * `SourceMapFileInfo[]` (streaming, reads on demand).
715
- */
716
- declare function computeBuildHash(maps?: SourceMapEntry[] | SourceMapFileInfo[]): Promise<string>;
717
- /**
718
- * Uploads source maps to the ingestion API.
719
- *
720
- * POSTs to `{endpoint}/v1/source-maps` with the API key, build hash,
721
- * and file entries. Validates the response against SourceMapUploadResponseSchema.
722
- *
723
- * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
724
- * `SourceMapFileInfo[]` (deferred reads). With `SourceMapFileInfo[]`,
725
- * file content is read at upload time rather than at discovery time.
726
- * Note: the legacy endpoint sends all files in a single JSON body, so
727
- * peak memory is similar — the benefit is deferring reads past discovery.
728
- */
729
- declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[]): Promise<SourceMapUploadResponse>;
730
- /** Builds at or above this byte size route to the presigned upload flow. */
731
- declare const PRESIGNED_THRESHOLD_BYTES = 4500000;
732
- /** Signature for the blob upload function, injectable for testing. */
733
- type BlobUploader = (clientToken: string, pathname: string, content: string) => Promise<{
734
- url: string;
735
- size: number;
736
- }>;
737
- /**
738
- * Orchestrates the 3-phase presigned upload flow.
739
- *
740
- * 1. Requests presigned tokens for all source map files
741
- * 2. Uploads each file to blob storage with a concurrency limit of 5,
742
- * reading file content from disk just before each upload
743
- * 3. Submits the manifest to finalize the upload
744
- *
745
- * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
746
- * `SourceMapFileInfo[]` (streaming, reads on demand).
747
- *
748
- * Accepts an optional `blobUploader` for test injection; defaults to
749
- * {@link uploadToBlob}.
750
- */
751
- declare function uploadSourceMapsPresigned(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], blobUploader?: BlobUploader): Promise<SourceMapManifestResponse>;
752
- /**
753
- * Options for {@link uploadSourceMapsAuto}, primarily used for test injection.
754
- */
755
- interface AutoUploadOptions {
756
- /** Override blob availability check (for testing). */
757
- checkBlobAvailable?: () => Promise<boolean>;
758
- /** Override blob uploader (for testing). */
759
- blobUploader?: BlobUploader;
760
- }
761
- /**
762
- * Automatically routes source map uploads based on total build size.
763
- *
764
- * - Below {@link PRESIGNED_THRESHOLD_BYTES}: uses the legacy single-request
765
- * {@link uploadSourceMaps} endpoint.
766
- * - At or above the threshold: checks if `@vercel/blob` is available and
767
- * uses the presigned 3-phase flow. Falls back to legacy with a warning
768
- * if the package is not installed.
769
- *
770
- * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
771
- * `SourceMapFileInfo[]` (streaming, reads on demand).
772
- */
773
- declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], options?: AutoUploadOptions): Promise<SourceMapUploadResponse | SourceMapManifestResponse>;
774
-
775
405
  /**
776
406
  * Manual error capture API.
777
407
  *
@@ -804,87 +434,4 @@ declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHas
804
434
  */
805
435
  declare function captureError(error: unknown): void;
806
436
 
807
- /**
808
- * Minimal Fetch-API `Headers`-like interface supporting case-insensitive
809
- * single-value lookup. Matches `Headers` from `undici` / the Web Fetch API.
810
- */
811
- interface FetchHeadersLike {
812
- get(name: string): string | null;
813
- }
814
- /**
815
- * Minimal Node `IncomingMessage.headers`-like shape: a dictionary mapping
816
- * (typically lower-cased) header names to a value, a list of values, or
817
- * `undefined`.
818
- */
819
- type NodeHeadersLike = Record<string, string | string[] | undefined>;
820
- /**
821
- * Accepted request shape for {@link captureCorrelationId}. Intentionally
822
- * loose so callers can pass either a Fetch `Request` (or `NextRequest`)
823
- * or a Node `IncomingMessage` without adapting the type.
824
- */
825
- interface CorrelationIdRequest {
826
- headers: FetchHeadersLike | NodeHeadersLike | undefined;
827
- }
828
- /**
829
- * Captures the Glasstrace correlation ID header (`x-gt-cid`) from an
830
- * incoming request and materializes it as the
831
- * `glasstrace.correlation.id` attribute on the currently active OTel span
832
- * (DISC-1253).
833
- *
834
- * The SDK does not own any HTTP instrumentation, so it cannot read this
835
- * header itself. Users opt in by calling this helper from a hook that
836
- * runs inside the request's OTel context — typically a Next.js
837
- * `middleware.ts` or a custom server request handler.
838
- *
839
- * The function is intentionally forgiving:
840
- * - No active span → no-op.
841
- * - Missing / empty header → no-op.
842
- * - Array header values (Node IncomingMessage) → the first non-empty
843
- * value is used; subsequent values are ignored because a correlation
844
- * ID is a single logical value.
845
- * - Malformed or unexpected `headers` shapes → caught and ignored; the
846
- * helper never throws.
847
- *
848
- * @example
849
- * ```ts
850
- * // Next.js middleware.ts
851
- * import { captureCorrelationId } from "@glasstrace/sdk";
852
- *
853
- * export function middleware(req: Request) {
854
- * captureCorrelationId(req);
855
- * return NextResponse.next();
856
- * }
857
- * ```
858
- */
859
- declare function captureCorrelationId(req: CorrelationIdRequest | null | undefined): void;
860
-
861
- /**
862
- * Discovers test files by scanning the project directory for conventional
863
- * test file patterns. Also reads vitest/jest config files for custom include
864
- * patterns and merges them with the defaults. Excludes node_modules/ and .next/.
865
- *
866
- * @param projectRoot - Absolute path to the project root directory.
867
- * @returns Relative POSIX paths from projectRoot, capped at {@link MAX_TEST_FILES}.
868
- */
869
- declare function discoverTestFiles(projectRoot: string): Promise<string[]>;
870
- /**
871
- * Extracts import paths from file content using regex.
872
- * Handles ES module imports, CommonJS requires, and dynamic imports.
873
- *
874
- * @param fileContent - The full text content of a TypeScript/JavaScript file.
875
- * @returns An array of import path strings as written in the source (e.g. "./foo", "react").
876
- */
877
- declare function extractImports(fileContent: string): string[];
878
- /**
879
- * Builds an import graph mapping test file paths to their imported module paths.
880
- *
881
- * Discovers test files, reads each, extracts imports, and builds a graph.
882
- * Computes a deterministic buildHash from the serialized graph content.
883
- * Individual file read failures are silently skipped.
884
- *
885
- * @param projectRoot - Absolute path to the project root directory.
886
- * @returns An {@link ImportGraphPayload} containing the graph and a deterministic buildHash.
887
- */
888
- declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
889
-
890
- export { type AutoUploadOptions, type BlobUploader, type ClaimState, type CorrelationIdRequest, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureCorrelationId, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, createGlasstraceSpanProcessor, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, getStatus, isAnonymousMode, isProductionDisabled, isReady, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, waitForReady, withGlasstraceConfig };
437
+ export { type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, type InitClaimResult, type ResolvedConfig, SessionManager, captureError, classifyFetchTarget, createGlasstraceSpanProcessor, getActiveConfig, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getStatus, isAnonymousMode, isProductionDisabled, isReady, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, waitForReady, withGlasstraceConfig };