@glasstrace/sdk 0.10.0 → 0.12.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 (48) hide show
  1. package/dist/adapters/drizzle.js +1 -1
  2. package/dist/{chunk-ZRNG36LU.js → chunk-6GRNJ722.js} +38 -17
  3. package/dist/chunk-6GRNJ722.js.map +1 -0
  4. package/dist/chunk-IPGOKORJ.js +580 -0
  5. package/dist/chunk-IPGOKORJ.js.map +1 -0
  6. package/dist/{chunk-5MAHIPFH.js → chunk-LW7DPKBA.js} +2 -2
  7. package/dist/{chunk-KOYJ2UQE.js → chunk-MSMOH6IH.js} +108 -38
  8. package/dist/chunk-MSMOH6IH.js.map +1 -0
  9. package/dist/chunk-NSBPE2FW.js +17 -0
  10. package/dist/{chunk-O3Y45VGV.js → chunk-OKIP4SRG.js} +5 -3
  11. package/dist/{chunk-O3Y45VGV.js.map → chunk-OKIP4SRG.js.map} +1 -1
  12. package/dist/cli/init.cjs +457 -330
  13. package/dist/cli/init.cjs.map +1 -1
  14. package/dist/cli/init.d.cts +25 -1
  15. package/dist/cli/init.d.ts +25 -1
  16. package/dist/cli/init.js +114 -4
  17. package/dist/cli/init.js.map +1 -1
  18. package/dist/cli/mcp-add.cjs +63 -47
  19. package/dist/cli/mcp-add.cjs.map +1 -1
  20. package/dist/cli/mcp-add.js +3 -3
  21. package/dist/cli/uninit.js +15 -564
  22. package/dist/cli/uninit.js.map +1 -1
  23. package/dist/{esm-POMEQPKL.js → esm-KBPHCVB4.js} +2 -2
  24. package/dist/{getMachineId-bsd-TC3JSTY5.js → getMachineId-bsd-345PYXFX.js} +2 -2
  25. package/dist/{getMachineId-darwin-2SUKQCE6.js → getMachineId-darwin-5L2D25AD.js} +2 -2
  26. package/dist/{getMachineId-linux-PNAFHLXH.js → getMachineId-linux-KJR4P5HN.js} +2 -2
  27. package/dist/{getMachineId-unsupported-L2MNYW3W.js → getMachineId-unsupported-NDNXDYDY.js} +2 -2
  28. package/dist/{getMachineId-win-D6D42WOQ.js → getMachineId-win-T7PJNJXG.js} +2 -2
  29. package/dist/index.cjs +327 -159
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +75 -11
  32. package/dist/index.d.ts +75 -11
  33. package/dist/index.js +159 -82
  34. package/dist/index.js.map +1 -1
  35. package/dist/{source-map-uploader-OA5NCDOK.js → source-map-uploader-ZFCYOURS.js} +6 -4
  36. package/package.json +1 -1
  37. package/dist/chunk-KOYJ2UQE.js.map +0 -1
  38. package/dist/chunk-PZ5AY32C.js +0 -10
  39. package/dist/chunk-ZRNG36LU.js.map +0 -1
  40. /package/dist/{chunk-5MAHIPFH.js.map → chunk-LW7DPKBA.js.map} +0 -0
  41. /package/dist/{chunk-PZ5AY32C.js.map → chunk-NSBPE2FW.js.map} +0 -0
  42. /package/dist/{esm-POMEQPKL.js.map → esm-KBPHCVB4.js.map} +0 -0
  43. /package/dist/{getMachineId-bsd-TC3JSTY5.js.map → getMachineId-bsd-345PYXFX.js.map} +0 -0
  44. /package/dist/{getMachineId-darwin-2SUKQCE6.js.map → getMachineId-darwin-5L2D25AD.js.map} +0 -0
  45. /package/dist/{getMachineId-linux-PNAFHLXH.js.map → getMachineId-linux-KJR4P5HN.js.map} +0 -0
  46. /package/dist/{getMachineId-unsupported-L2MNYW3W.js.map → getMachineId-unsupported-NDNXDYDY.js.map} +0 -0
  47. /package/dist/{getMachineId-win-D6D42WOQ.js.map → getMachineId-win-T7PJNJXG.js.map} +0 -0
  48. /package/dist/{source-map-uploader-OA5NCDOK.js.map → source-map-uploader-ZFCYOURS.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -187,8 +187,9 @@ declare function isProductionDisabled(config: ResolvedConfig): boolean;
187
187
  declare function isAnonymousMode(config: ResolvedConfig): boolean;
188
188
 
189
189
  /**
190
- * Derives a deterministic session ID from the given inputs using SHA-256.
191
- * The hash is truncated to 16 hex characters and parsed through SessionIdSchema.
190
+ * Derives a deterministic session ID from the given inputs.
191
+ * Uses SHA-256 (truncated to 16 hex chars) when `node:crypto` is available,
192
+ * or a deterministic FNV-1a hash as a fallback in non-Node environments.
192
193
  *
193
194
  * @param apiKey - The project's API key (or anonymous placeholder).
194
195
  * @param origin - The origin string identifying the deployment environment.
@@ -253,6 +254,7 @@ declare function classifyFetchTarget(url: string): FetchTarget;
253
254
  * - The file does not exist
254
255
  * - The file content is invalid
255
256
  * - An I/O error occurs
257
+ * - `node:fs` is unavailable (non-Node environment)
256
258
  */
257
259
  declare function readAnonKey(projectRoot?: string): Promise<AnonApiKey | null>;
258
260
  /**
@@ -263,17 +265,20 @@ declare function readAnonKey(projectRoot?: string): Promise<AnonApiKey | null>;
263
265
  * - Writes the new key to `.glasstrace/anon_key`, creating the directory if needed
264
266
  * - On file write failure: logs a warning, caches an ephemeral in-memory key so
265
267
  * repeated calls in the same process return the same key
268
+ * - In non-Node environments: returns an ephemeral in-memory key
266
269
  */
267
270
  declare function getOrCreateAnonKey(projectRoot?: string): Promise<AnonApiKey>;
268
271
 
269
272
  /**
270
273
  * Reads and validates a cached config file from `.glasstrace/config`.
271
- * Returns the parsed `SdkInitResponse` or `null` on any failure.
274
+ * Returns the parsed `SdkInitResponse` or `null` on any failure,
275
+ * including when `node:fs` is unavailable (non-Node environments).
272
276
  */
273
277
  declare function loadCachedConfig(projectRoot?: string): SdkInitResponse | null;
274
278
  /**
275
279
  * Persists the init response to `.glasstrace/config`.
276
- * On failure, logs a warning and continues.
280
+ * Silently skipped when `node:fs` is unavailable (non-Node environments).
281
+ * On I/O failure, logs a warning and continues.
277
282
  */
278
283
  declare function saveCachedConfig(response: SdkInitResponse, projectRoot?: string): Promise<void>;
279
284
  /**
@@ -314,6 +319,14 @@ declare function performInit(config: ResolvedConfig, anonKey: AnonApiKey | null,
314
319
  * every span export batch).
315
320
  */
316
321
  declare function getActiveConfig(): CaptureConfig;
322
+ /**
323
+ * Returns the `linkedAccountId` from the current in-memory init response,
324
+ * or `undefined` if no init response is available or no account is linked.
325
+ *
326
+ * Used by the discovery endpoint to determine whether `claimed: true`
327
+ * should be included in the response.
328
+ */
329
+ declare function getLinkedAccountId(): string | undefined;
317
330
 
318
331
  /**
319
332
  * Lightweight SpanProcessor that delegates to a wrapped processor.
@@ -417,6 +430,17 @@ declare class GlasstraceExporter implements SpanExporter {
417
430
  private flushPending;
418
431
  }
419
432
 
433
+ /**
434
+ * Claim state returned by the `getClaimState` callback.
435
+ *
436
+ * - `claimed` — `true` when the anonymous key has been linked to an account.
437
+ * - `accountHint` — optional masked identifier (e.g. `"er***@example.com"`)
438
+ * for the browser extension to display to the user.
439
+ */
440
+ interface ClaimState {
441
+ claimed: boolean;
442
+ accountHint?: string;
443
+ }
420
444
  /**
421
445
  * Creates a request handler for the `/__glasstrace/config` discovery endpoint.
422
446
  *
@@ -424,10 +448,14 @@ declare class GlasstraceExporter implements SpanExporter {
424
448
  * If not, returns `null` (pass-through). If it matches, returns a `DiscoveryResponse`
425
449
  * with the anonymous key and current session ID.
426
450
  *
451
+ * When `getClaimState` returns a non-null value with `claimed: true`, the
452
+ * response includes `claimed` and (optionally) `accountHint` so the browser
453
+ * extension can prompt the user to sign in.
454
+ *
427
455
  * The triple guard (anonymous + dev + active) is enforced by the caller,
428
456
  * not by this module. If the handler is registered, it serves.
429
457
  */
430
- declare function createDiscoveryHandler(getAnonKey: () => Promise<AnonApiKey | null>, getSessionId: () => SessionId): (request: Request) => Promise<Response | null>;
458
+ declare function createDiscoveryHandler(getAnonKey: () => Promise<AnonApiKey | null>, getSessionId: () => SessionId, getClaimState?: () => ClaimState | null): (request: Request) => Promise<Response | null>;
431
459
 
432
460
  /**
433
461
  * The primary SDK entry point called by developers in their `instrumentation.ts`.
@@ -468,9 +496,29 @@ interface SourceMapEntry {
468
496
  filePath: string;
469
497
  content: string;
470
498
  }
499
+ /**
500
+ * Metadata for a discovered source map file, without its content loaded.
501
+ * Used by the streaming upload flow to defer file reads until upload time.
502
+ */
503
+ interface SourceMapFileInfo {
504
+ /** Relative path to the compiled JS file (`.map` extension stripped). */
505
+ filePath: string;
506
+ /** Absolute path on disk for reading the file content on demand. */
507
+ absolutePath: string;
508
+ /** File size in bytes. */
509
+ sizeBytes: number;
510
+ }
511
+ /**
512
+ * Recursively discovers all `.map` files in the given build directory.
513
+ * Returns metadata only — file content is NOT read into memory.
514
+ */
515
+ declare function discoverSourceMapFiles(buildDir: string): Promise<SourceMapFileInfo[]>;
471
516
  /**
472
517
  * Recursively finds all .map files in the given build directory.
473
518
  * Returns relative paths and file contents.
519
+ *
520
+ * @deprecated Prefer {@link discoverSourceMapFiles} to avoid loading all
521
+ * source maps into memory simultaneously.
474
522
  */
475
523
  declare function collectSourceMaps(buildDir: string): Promise<SourceMapEntry[]>;
476
524
  /**
@@ -480,15 +528,24 @@ declare function collectSourceMaps(buildDir: string): Promise<SourceMapEntry[]>;
480
528
  * On failure, falls back to a deterministic content hash:
481
529
  * sort source map file paths alphabetically, concatenate each as
482
530
  * `{relativePath}\n{fileLength}\n{fileContent}`, then SHA-256 the result.
531
+ *
532
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
533
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
483
534
  */
484
- declare function computeBuildHash(maps?: SourceMapEntry[]): Promise<string>;
535
+ declare function computeBuildHash(maps?: SourceMapEntry[] | SourceMapFileInfo[]): Promise<string>;
485
536
  /**
486
537
  * Uploads source maps to the ingestion API.
487
538
  *
488
539
  * POSTs to `{endpoint}/v1/source-maps` with the API key, build hash,
489
540
  * and file entries. Validates the response against SourceMapUploadResponseSchema.
541
+ *
542
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
543
+ * `SourceMapFileInfo[]` (deferred reads). With `SourceMapFileInfo[]`,
544
+ * file content is read at upload time rather than at discovery time.
545
+ * Note: the legacy endpoint sends all files in a single JSON body, so
546
+ * peak memory is similar — the benefit is deferring reads past discovery.
490
547
  */
491
- declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[]): Promise<SourceMapUploadResponse>;
548
+ declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[]): Promise<SourceMapUploadResponse>;
492
549
  /** Builds at or above this byte size route to the presigned upload flow. */
493
550
  declare const PRESIGNED_THRESHOLD_BYTES = 4500000;
494
551
  /** Signature for the blob upload function, injectable for testing. */
@@ -500,13 +557,17 @@ type BlobUploader = (clientToken: string, pathname: string, content: string) =>
500
557
  * Orchestrates the 3-phase presigned upload flow.
501
558
  *
502
559
  * 1. Requests presigned tokens for all source map files
503
- * 2. Uploads each file to blob storage with a concurrency limit of 5
560
+ * 2. Uploads each file to blob storage with a concurrency limit of 5,
561
+ * reading file content from disk just before each upload
504
562
  * 3. Submits the manifest to finalize the upload
505
563
  *
564
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
565
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
566
+ *
506
567
  * Accepts an optional `blobUploader` for test injection; defaults to
507
568
  * {@link uploadToBlob}.
508
569
  */
509
- declare function uploadSourceMapsPresigned(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[], blobUploader?: BlobUploader): Promise<SourceMapManifestResponse>;
570
+ declare function uploadSourceMapsPresigned(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], blobUploader?: BlobUploader): Promise<SourceMapManifestResponse>;
510
571
  /**
511
572
  * Options for {@link uploadSourceMapsAuto}, primarily used for test injection.
512
573
  */
@@ -524,8 +585,11 @@ interface AutoUploadOptions {
524
585
  * - At or above the threshold: checks if `@vercel/blob` is available and
525
586
  * uses the presigned 3-phase flow. Falls back to legacy with a warning
526
587
  * if the package is not installed.
588
+ *
589
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
590
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
527
591
  */
528
- declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[], options?: AutoUploadOptions): Promise<SourceMapUploadResponse | SourceMapManifestResponse>;
592
+ declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], options?: AutoUploadOptions): Promise<SourceMapUploadResponse | SourceMapManifestResponse>;
529
593
 
530
594
  /**
531
595
  * Manual error capture API.
@@ -588,4 +652,4 @@ declare function extractImports(fileContent: string): string[];
588
652
  */
589
653
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
590
654
 
591
- export { type AutoUploadOptions, type BlobUploader, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };
655
+ export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };
package/dist/index.d.ts CHANGED
@@ -187,8 +187,9 @@ declare function isProductionDisabled(config: ResolvedConfig): boolean;
187
187
  declare function isAnonymousMode(config: ResolvedConfig): boolean;
188
188
 
189
189
  /**
190
- * Derives a deterministic session ID from the given inputs using SHA-256.
191
- * The hash is truncated to 16 hex characters and parsed through SessionIdSchema.
190
+ * Derives a deterministic session ID from the given inputs.
191
+ * Uses SHA-256 (truncated to 16 hex chars) when `node:crypto` is available,
192
+ * or a deterministic FNV-1a hash as a fallback in non-Node environments.
192
193
  *
193
194
  * @param apiKey - The project's API key (or anonymous placeholder).
194
195
  * @param origin - The origin string identifying the deployment environment.
@@ -253,6 +254,7 @@ declare function classifyFetchTarget(url: string): FetchTarget;
253
254
  * - The file does not exist
254
255
  * - The file content is invalid
255
256
  * - An I/O error occurs
257
+ * - `node:fs` is unavailable (non-Node environment)
256
258
  */
257
259
  declare function readAnonKey(projectRoot?: string): Promise<AnonApiKey | null>;
258
260
  /**
@@ -263,17 +265,20 @@ declare function readAnonKey(projectRoot?: string): Promise<AnonApiKey | null>;
263
265
  * - Writes the new key to `.glasstrace/anon_key`, creating the directory if needed
264
266
  * - On file write failure: logs a warning, caches an ephemeral in-memory key so
265
267
  * repeated calls in the same process return the same key
268
+ * - In non-Node environments: returns an ephemeral in-memory key
266
269
  */
267
270
  declare function getOrCreateAnonKey(projectRoot?: string): Promise<AnonApiKey>;
268
271
 
269
272
  /**
270
273
  * Reads and validates a cached config file from `.glasstrace/config`.
271
- * Returns the parsed `SdkInitResponse` or `null` on any failure.
274
+ * Returns the parsed `SdkInitResponse` or `null` on any failure,
275
+ * including when `node:fs` is unavailable (non-Node environments).
272
276
  */
273
277
  declare function loadCachedConfig(projectRoot?: string): SdkInitResponse | null;
274
278
  /**
275
279
  * Persists the init response to `.glasstrace/config`.
276
- * On failure, logs a warning and continues.
280
+ * Silently skipped when `node:fs` is unavailable (non-Node environments).
281
+ * On I/O failure, logs a warning and continues.
277
282
  */
278
283
  declare function saveCachedConfig(response: SdkInitResponse, projectRoot?: string): Promise<void>;
279
284
  /**
@@ -314,6 +319,14 @@ declare function performInit(config: ResolvedConfig, anonKey: AnonApiKey | null,
314
319
  * every span export batch).
315
320
  */
316
321
  declare function getActiveConfig(): CaptureConfig;
322
+ /**
323
+ * Returns the `linkedAccountId` from the current in-memory init response,
324
+ * or `undefined` if no init response is available or no account is linked.
325
+ *
326
+ * Used by the discovery endpoint to determine whether `claimed: true`
327
+ * should be included in the response.
328
+ */
329
+ declare function getLinkedAccountId(): string | undefined;
317
330
 
318
331
  /**
319
332
  * Lightweight SpanProcessor that delegates to a wrapped processor.
@@ -417,6 +430,17 @@ declare class GlasstraceExporter implements SpanExporter {
417
430
  private flushPending;
418
431
  }
419
432
 
433
+ /**
434
+ * Claim state returned by the `getClaimState` callback.
435
+ *
436
+ * - `claimed` — `true` when the anonymous key has been linked to an account.
437
+ * - `accountHint` — optional masked identifier (e.g. `"er***@example.com"`)
438
+ * for the browser extension to display to the user.
439
+ */
440
+ interface ClaimState {
441
+ claimed: boolean;
442
+ accountHint?: string;
443
+ }
420
444
  /**
421
445
  * Creates a request handler for the `/__glasstrace/config` discovery endpoint.
422
446
  *
@@ -424,10 +448,14 @@ declare class GlasstraceExporter implements SpanExporter {
424
448
  * If not, returns `null` (pass-through). If it matches, returns a `DiscoveryResponse`
425
449
  * with the anonymous key and current session ID.
426
450
  *
451
+ * When `getClaimState` returns a non-null value with `claimed: true`, the
452
+ * response includes `claimed` and (optionally) `accountHint` so the browser
453
+ * extension can prompt the user to sign in.
454
+ *
427
455
  * The triple guard (anonymous + dev + active) is enforced by the caller,
428
456
  * not by this module. If the handler is registered, it serves.
429
457
  */
430
- declare function createDiscoveryHandler(getAnonKey: () => Promise<AnonApiKey | null>, getSessionId: () => SessionId): (request: Request) => Promise<Response | null>;
458
+ declare function createDiscoveryHandler(getAnonKey: () => Promise<AnonApiKey | null>, getSessionId: () => SessionId, getClaimState?: () => ClaimState | null): (request: Request) => Promise<Response | null>;
431
459
 
432
460
  /**
433
461
  * The primary SDK entry point called by developers in their `instrumentation.ts`.
@@ -468,9 +496,29 @@ interface SourceMapEntry {
468
496
  filePath: string;
469
497
  content: string;
470
498
  }
499
+ /**
500
+ * Metadata for a discovered source map file, without its content loaded.
501
+ * Used by the streaming upload flow to defer file reads until upload time.
502
+ */
503
+ interface SourceMapFileInfo {
504
+ /** Relative path to the compiled JS file (`.map` extension stripped). */
505
+ filePath: string;
506
+ /** Absolute path on disk for reading the file content on demand. */
507
+ absolutePath: string;
508
+ /** File size in bytes. */
509
+ sizeBytes: number;
510
+ }
511
+ /**
512
+ * Recursively discovers all `.map` files in the given build directory.
513
+ * Returns metadata only — file content is NOT read into memory.
514
+ */
515
+ declare function discoverSourceMapFiles(buildDir: string): Promise<SourceMapFileInfo[]>;
471
516
  /**
472
517
  * Recursively finds all .map files in the given build directory.
473
518
  * Returns relative paths and file contents.
519
+ *
520
+ * @deprecated Prefer {@link discoverSourceMapFiles} to avoid loading all
521
+ * source maps into memory simultaneously.
474
522
  */
475
523
  declare function collectSourceMaps(buildDir: string): Promise<SourceMapEntry[]>;
476
524
  /**
@@ -480,15 +528,24 @@ declare function collectSourceMaps(buildDir: string): Promise<SourceMapEntry[]>;
480
528
  * On failure, falls back to a deterministic content hash:
481
529
  * sort source map file paths alphabetically, concatenate each as
482
530
  * `{relativePath}\n{fileLength}\n{fileContent}`, then SHA-256 the result.
531
+ *
532
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
533
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
483
534
  */
484
- declare function computeBuildHash(maps?: SourceMapEntry[]): Promise<string>;
535
+ declare function computeBuildHash(maps?: SourceMapEntry[] | SourceMapFileInfo[]): Promise<string>;
485
536
  /**
486
537
  * Uploads source maps to the ingestion API.
487
538
  *
488
539
  * POSTs to `{endpoint}/v1/source-maps` with the API key, build hash,
489
540
  * and file entries. Validates the response against SourceMapUploadResponseSchema.
541
+ *
542
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
543
+ * `SourceMapFileInfo[]` (deferred reads). With `SourceMapFileInfo[]`,
544
+ * file content is read at upload time rather than at discovery time.
545
+ * Note: the legacy endpoint sends all files in a single JSON body, so
546
+ * peak memory is similar — the benefit is deferring reads past discovery.
490
547
  */
491
- declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[]): Promise<SourceMapUploadResponse>;
548
+ declare function uploadSourceMaps(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[]): Promise<SourceMapUploadResponse>;
492
549
  /** Builds at or above this byte size route to the presigned upload flow. */
493
550
  declare const PRESIGNED_THRESHOLD_BYTES = 4500000;
494
551
  /** Signature for the blob upload function, injectable for testing. */
@@ -500,13 +557,17 @@ type BlobUploader = (clientToken: string, pathname: string, content: string) =>
500
557
  * Orchestrates the 3-phase presigned upload flow.
501
558
  *
502
559
  * 1. Requests presigned tokens for all source map files
503
- * 2. Uploads each file to blob storage with a concurrency limit of 5
560
+ * 2. Uploads each file to blob storage with a concurrency limit of 5,
561
+ * reading file content from disk just before each upload
504
562
  * 3. Submits the manifest to finalize the upload
505
563
  *
564
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
565
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
566
+ *
506
567
  * Accepts an optional `blobUploader` for test injection; defaults to
507
568
  * {@link uploadToBlob}.
508
569
  */
509
- declare function uploadSourceMapsPresigned(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[], blobUploader?: BlobUploader): Promise<SourceMapManifestResponse>;
570
+ declare function uploadSourceMapsPresigned(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], blobUploader?: BlobUploader): Promise<SourceMapManifestResponse>;
510
571
  /**
511
572
  * Options for {@link uploadSourceMapsAuto}, primarily used for test injection.
512
573
  */
@@ -524,8 +585,11 @@ interface AutoUploadOptions {
524
585
  * - At or above the threshold: checks if `@vercel/blob` is available and
525
586
  * uses the presigned 3-phase flow. Falls back to legacy with a warning
526
587
  * if the package is not installed.
588
+ *
589
+ * Accepts either `SourceMapEntry[]` (legacy, in-memory) or
590
+ * `SourceMapFileInfo[]` (streaming, reads on demand).
527
591
  */
528
- declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[], options?: AutoUploadOptions): Promise<SourceMapUploadResponse | SourceMapManifestResponse>;
592
+ declare function uploadSourceMapsAuto(apiKey: string, endpoint: string, buildHash: string, maps: SourceMapEntry[] | SourceMapFileInfo[], options?: AutoUploadOptions): Promise<SourceMapUploadResponse | SourceMapManifestResponse>;
529
593
 
530
594
  /**
531
595
  * Manual error capture API.
@@ -588,4 +652,4 @@ declare function extractImports(fileContent: string): string[];
588
652
  */
589
653
  declare function buildImportGraph(projectRoot: string): Promise<ImportGraphPayload>;
590
654
 
591
- export { type AutoUploadOptions, type BlobUploader, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };
655
+ export { type AutoUploadOptions, type BlobUploader, type ClaimState, type FetchTarget, GlasstraceExporter, type GlasstraceExporterOptions, GlasstraceSpanProcessor, type InitClaimResult, PRESIGNED_THRESHOLD_BYTES, type ResolvedConfig, SdkError, SessionManager, type SourceMapEntry, type SourceMapFileInfo, buildImportGraph, captureError, classifyFetchTarget, collectSourceMaps, computeBuildHash, createDiscoveryHandler, deriveSessionId, discoverSourceMapFiles, discoverTestFiles, extractImports, getActiveConfig, getDateString, getDiscoveryHandler, getLinkedAccountId, getOrCreateAnonKey, getOrigin, isAnonymousMode, isProductionDisabled, loadCachedConfig, performInit, readAnonKey, readEnvVars, registerGlasstrace, resolveConfig, saveCachedConfig, sendInitRequest, uploadSourceMaps, uploadSourceMapsAuto, uploadSourceMapsPresigned, withGlasstraceConfig };