@glasstrace/sdk 0.9.0 → 0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/source-map-uploader.ts","../src/nudge/error-nudge.ts","../src/env-detection.ts","../src/console-capture.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport * as crypto from \"node:crypto\";\nimport { execFileSync } from \"node:child_process\";\nimport { sdkLog } from \"./console-capture.js\";\nimport {\n SourceMapUploadResponseSchema,\n type SourceMapUploadResponse,\n PresignedUploadResponseSchema,\n type PresignedUploadResponse,\n SourceMapManifestResponseSchema,\n type SourceMapManifestResponse,\n} from \"@glasstrace/protocol\";\n\nexport interface SourceMapEntry {\n filePath: string;\n content: string;\n}\n\n/**\n * Recursively finds all .map files in the given build directory.\n * Returns relative paths and file contents.\n */\nexport async function collectSourceMaps(\n buildDir: string,\n): Promise<SourceMapEntry[]> {\n const results: SourceMapEntry[] = [];\n\n try {\n await walkDir(buildDir, buildDir, results);\n } catch {\n // Directory doesn't exist or is unreadable — return empty\n return [];\n }\n\n return results;\n}\n\nasync function walkDir(\n baseDir: string,\n currentDir: string,\n results: SourceMapEntry[],\n): Promise<void> {\n let entries: import(\"node:fs\").Dirent[];\n try {\n entries = await fs.readdir(currentDir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n if (entry.isDirectory()) {\n await walkDir(baseDir, fullPath, results);\n } else if (entry.isFile() && entry.name.endsWith(\".map\")) {\n try {\n const content = await fs.readFile(fullPath, \"utf-8\");\n const relativePath = path.relative(baseDir, fullPath).replace(/\\\\/g, \"/\");\n // Strip the trailing .map extension so the key matches the compiled\n // JS path that the runtime uses for stack-frame lookups (e.g.\n // \"static/chunks/main.js\" instead of \"static/chunks/main.js.map\").\n const compiledPath = relativePath.replace(/\\.map$/, \"\");\n results.push({ filePath: compiledPath, content });\n } catch {\n // Skip unreadable files\n }\n }\n }\n}\n\n/**\n * Computes a build hash for source map uploads.\n *\n * First tries `git rev-parse HEAD` to get the git commit SHA.\n * On failure, falls back to a deterministic content hash:\n * sort source map file paths alphabetically, concatenate each as\n * `{relativePath}\\n{fileLength}\\n{fileContent}`, then SHA-256 the result.\n */\nexport async function computeBuildHash(\n maps?: SourceMapEntry[],\n): Promise<string> {\n // Try git first\n try {\n const sha = execFileSync(\"git\", [\"rev-parse\", \"HEAD\"], { encoding: \"utf-8\" }).trim();\n if (sha) {\n return sha;\n }\n } catch {\n // Git not available, fall through to content hash\n }\n\n // Fallback: content-based hash\n const sortedMaps = [...(maps ?? [])].sort((a, b) =>\n a.filePath.localeCompare(b.filePath),\n );\n\n const hashInput = sortedMaps\n .map((m) => `${m.filePath}\\n${m.content.length}\\n${m.content}`)\n .join(\"\");\n\n const hash = crypto.createHash(\"sha256\").update(hashInput).digest(\"hex\");\n return hash;\n}\n\n/**\n * Uploads source maps to the ingestion API.\n *\n * POSTs to `{endpoint}/v1/source-maps` with the API key, build hash,\n * and file entries. Validates the response against SourceMapUploadResponseSchema.\n */\nexport async function uploadSourceMaps(\n apiKey: string,\n endpoint: string,\n buildHash: string,\n maps: SourceMapEntry[],\n): Promise<SourceMapUploadResponse> {\n const body = {\n apiKey,\n buildHash,\n files: maps.map((m) => ({\n filePath: m.filePath,\n sourceMap: m.content,\n })),\n };\n\n const baseUrl = stripTrailingSlashes(endpoint);\n const response = await fetch(`${baseUrl}/v1/source-maps`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n // Consume the response body to release the connection back to the pool.\n // Without this, the underlying TCP socket stays allocated until GC, which\n // causes connection pool exhaustion under sustained error conditions.\n // Wrapped in try-catch so a stream error doesn't mask the HTTP status error.\n try { await response.text(); } catch { /* body drain is best-effort */ }\n throw new Error(\n `Source map upload failed: ${String(response.status)} ${response.statusText}`,\n );\n }\n\n const json: unknown = await response.json();\n return SourceMapUploadResponseSchema.parse(json);\n}\n\n// ---------------------------------------------------------------------------\n// Presigned source map upload (3-phase flow for large builds)\n// ---------------------------------------------------------------------------\n\n/** Builds at or above this byte size route to the presigned upload flow. */\nexport const PRESIGNED_THRESHOLD_BYTES = 4_500_000;\n\n/** Signature for the blob upload function, injectable for testing. */\nexport type BlobUploader = (\n clientToken: string,\n pathname: string,\n content: string,\n) => Promise<{ url: string; size: number }>;\n\n/**\n * Strips trailing slashes from a URL string.\n * Uses an iterative approach to avoid regex (CodeQL js/polynomial-redos).\n */\nfunction stripTrailingSlashes(url: string): string {\n let result = url;\n while (result.endsWith(\"/\")) {\n result = result.slice(0, -1);\n }\n return result;\n}\n\n/**\n * Phase 1: Request presigned upload tokens from the ingestion API.\n *\n * POSTs to `{endpoint}/v1/source-maps/presign` with the build hash and\n * file metadata. Returns presigned tokens for each file that the client\n * uses to upload directly to blob storage.\n */\nexport async function requestPresignedTokens(\n apiKey: string,\n endpoint: string,\n buildHash: string,\n files: Array<{ filePath: string; sizeBytes: number }>,\n): Promise<PresignedUploadResponse> {\n const baseUrl = stripTrailingSlashes(endpoint);\n const response = await fetch(`${baseUrl}/v1/source-maps/presign`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({ buildHash, files }),\n });\n\n if (!response.ok) {\n try { await response.text(); } catch { /* body drain is best-effort */ }\n throw new Error(\n `Presigned token request failed: ${String(response.status)} ${response.statusText}`,\n );\n }\n\n const json: unknown = await response.json();\n return PresignedUploadResponseSchema.parse(json);\n}\n\n/**\n * Phase 2: Upload a single source map to blob storage using a presigned token.\n *\n * Dynamically imports `@vercel/blob/client` to avoid bundling the dependency.\n * Throws a descriptive error if the package is not installed.\n */\nexport async function uploadToBlob(\n clientToken: string,\n pathname: string,\n content: string,\n): Promise<{ url: string; size: number }> {\n let mod: { put: (pathname: string, body: Blob, options: { access: string; token: string }) => Promise<{ url: string }> };\n try {\n mod = await import(\"@vercel/blob/client\") as typeof mod;\n } catch (err) {\n // Distinguish \"not installed\" from other import errors\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"ERR_MODULE_NOT_FOUND\" || code === \"MODULE_NOT_FOUND\") {\n throw new Error(\n \"Presigned upload requires @vercel/blob. Install it: npm install @vercel/blob\",\n );\n }\n throw err;\n }\n\n const result = await mod.put(pathname, new Blob([content]), {\n access: \"public\",\n token: clientToken,\n });\n\n return { url: result.url, size: Buffer.byteLength(content, \"utf-8\") };\n}\n\n/**\n * Phase 3: Submit the upload manifest to finalize a presigned upload.\n *\n * POSTs to `{endpoint}/v1/source-maps/manifest` with the upload ID,\n * build hash, and blob URLs for each uploaded file. The backend activates\n * the source maps for stack trace resolution.\n */\nexport async function submitManifest(\n apiKey: string,\n endpoint: string,\n uploadId: string,\n buildHash: string,\n files: Array<{ filePath: string; sizeBytes: number; blobUrl: string }>,\n): Promise<SourceMapManifestResponse> {\n const baseUrl = stripTrailingSlashes(endpoint);\n const response = await fetch(`${baseUrl}/v1/source-maps/manifest`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({ uploadId, buildHash, files }),\n });\n\n if (!response.ok) {\n try { await response.text(); } catch { /* body drain is best-effort */ }\n throw new Error(\n `Source map manifest submission failed: ${String(response.status)} ${response.statusText}`,\n );\n }\n\n const json: unknown = await response.json();\n return SourceMapManifestResponseSchema.parse(json);\n}\n\n/**\n * Orchestrates the 3-phase presigned upload flow.\n *\n * 1. Requests presigned tokens for all source map files\n * 2. Uploads each file to blob storage with a concurrency limit of 5\n * 3. Submits the manifest to finalize the upload\n *\n * Accepts an optional `blobUploader` for test injection; defaults to\n * {@link uploadToBlob}.\n */\nexport async function uploadSourceMapsPresigned(\n apiKey: string,\n endpoint: string,\n buildHash: string,\n maps: SourceMapEntry[],\n blobUploader: BlobUploader = uploadToBlob,\n): Promise<SourceMapManifestResponse> {\n if (maps.length === 0) {\n throw new Error(\"No source maps to upload\");\n }\n\n // Phase 1: request presigned tokens\n const presigned = await requestPresignedTokens(apiKey, endpoint, buildHash,\n maps.map((m) => ({\n filePath: m.filePath,\n sizeBytes: Buffer.byteLength(m.content, \"utf-8\"),\n })),\n );\n\n // Build a lookup map for O(1) access by filePath\n const mapsByPath = new Map(maps.map((m) => [m.filePath, m]));\n\n if (mapsByPath.size !== maps.length) {\n throw new Error(\"Duplicate filePath entries in source maps\");\n }\n\n // Phase 2: upload to blob storage with concurrency limit of 5.\n // Validate all tokens have matching entries before starting any uploads.\n for (const token of presigned.files) {\n if (!mapsByPath.has(token.filePath)) {\n throw new Error(\n `Presigned token for \"${token.filePath}\" has no matching source map entry`,\n );\n }\n }\n\n // Phase 2: upload to blob storage in chunks of CONCURRENCY\n const CONCURRENCY = 5;\n const uploadResults: Array<{ filePath: string; sizeBytes: number; blobUrl: string }> = [];\n\n for (let i = 0; i < presigned.files.length; i += CONCURRENCY) {\n const chunk = presigned.files.slice(i, i + CONCURRENCY);\n const chunkResults = await Promise.all(\n chunk.map(async (token) => {\n const entry = mapsByPath.get(token.filePath)!;\n const result = await blobUploader(token.clientToken, token.pathname, entry.content);\n return {\n filePath: token.filePath,\n sizeBytes: result.size,\n blobUrl: result.url,\n };\n }),\n );\n uploadResults.push(...chunkResults);\n }\n\n // Phase 3: submit manifest\n return submitManifest(apiKey, endpoint, presigned.uploadId, buildHash, uploadResults);\n}\n\n/**\n * Options for {@link uploadSourceMapsAuto}, primarily used for test injection.\n */\nexport interface AutoUploadOptions {\n /** Override blob availability check (for testing). */\n checkBlobAvailable?: () => Promise<boolean>;\n /** Override blob uploader (for testing). */\n blobUploader?: BlobUploader;\n}\n\n/**\n * Automatically routes source map uploads based on total build size.\n *\n * - Below {@link PRESIGNED_THRESHOLD_BYTES}: uses the legacy single-request\n * {@link uploadSourceMaps} endpoint.\n * - At or above the threshold: checks if `@vercel/blob` is available and\n * uses the presigned 3-phase flow. Falls back to legacy with a warning\n * if the package is not installed.\n */\nexport async function uploadSourceMapsAuto(\n apiKey: string,\n endpoint: string,\n buildHash: string,\n maps: SourceMapEntry[],\n options?: AutoUploadOptions,\n): Promise<SourceMapUploadResponse | SourceMapManifestResponse> {\n if (maps.length === 0) {\n throw new Error(\"No source maps to upload\");\n }\n\n const totalBytes = maps.reduce(\n (sum, m) => sum + Buffer.byteLength(m.content, \"utf-8\"),\n 0,\n );\n\n if (totalBytes < PRESIGNED_THRESHOLD_BYTES) {\n return uploadSourceMaps(apiKey, endpoint, buildHash, maps);\n }\n\n // Check if @vercel/blob is available\n const checkAvailable = options?.checkBlobAvailable ?? (async () => {\n try {\n await import(\"@vercel/blob/client\");\n return true;\n } catch {\n return false;\n }\n });\n\n const blobAvailable = await checkAvailable();\n\n if (blobAvailable) {\n return uploadSourceMapsPresigned(\n apiKey, endpoint, buildHash, maps, options?.blobUploader,\n );\n }\n\n // Fall back to legacy upload with a warning\n sdkLog(\"warn\",\n `[glasstrace] Build exceeds 4.5MB (${totalBytes} bytes). Install @vercel/blob for ` +\n `presigned uploads to avoid serverless body size limits. Falling back to legacy upload.`\n );\n\n return uploadSourceMaps(apiKey, endpoint, buildHash, maps);\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveConfig, isProductionDisabled } from \"../env-detection.js\";\n\n/**\n * Module-level flag ensuring the nudge fires at most once per process.\n */\nlet hasFired = false;\n\n/**\n * Strips control characters (except space) from a string to prevent\n * terminal escape sequence injection via error summaries written to stderr.\n */\nfunction sanitize(input: string): string {\n // eslint-disable-next-line no-control-regex\n return input.replace(/[\\x00-\\x1f\\x7f]/g, \"\");\n}\n\n/**\n * Shows a one-time stderr nudge when the SDK captures its first error\n * and the MCP connection marker file is absent.\n *\n * The nudge is suppressed when:\n * - It has already fired in this process\n * - The `.glasstrace/mcp-connected` marker file exists at the project root\n * - The environment is detected as production (and force-enable is off)\n *\n * Uses `process.stderr.write()` instead of `console.error()` to avoid\n * being captured by OpenTelemetry console instrumentation.\n */\nexport function maybeShowMcpNudge(errorSummary: string): void {\n if (hasFired) {\n return;\n }\n\n // Production check — suppress silently, but remember the decision\n // so subsequent calls fast-exit via hasFired without re-running I/O.\n const config = resolveConfig();\n if (isProductionDisabled(config)) {\n hasFired = true;\n return;\n }\n\n // Check for MCP connection marker file.\n // Guard process.cwd() — it throws ENOENT if the working directory has been removed.\n let markerExists = false;\n try {\n const markerPath = join(process.cwd(), \".glasstrace\", \"mcp-connected\");\n markerExists = existsSync(markerPath);\n } catch {\n // Permission denied, ENOENT from cwd(), or other filesystem error — treat as not connected\n markerExists = false;\n }\n\n if (markerExists) {\n hasFired = true;\n return;\n }\n\n // Fire the nudge exactly once\n hasFired = true;\n\n const safe = sanitize(errorSummary);\n process.stderr.write(\n `[glasstrace] Error captured: ${safe}\\n` +\n ` Debug with AI: ask your agent \"What's the latest Glasstrace error?\"\\n` +\n ` Not connected? Run: npx glasstrace mcp add\\n`,\n );\n}\n","import type { GlasstraceEnvVars, GlasstraceOptions } from \"@glasstrace/protocol\";\n\n/**\n * Resolved configuration after merging explicit options with environment variables.\n */\nexport interface ResolvedConfig {\n apiKey: string | undefined;\n endpoint: string;\n forceEnable: boolean;\n verbose: boolean;\n environment: string | undefined;\n coverageMapEnabled: boolean;\n nodeEnv: string | undefined;\n vercelEnv: string | undefined;\n}\n\nconst DEFAULT_ENDPOINT = \"https://api.glasstrace.dev\";\n\n/**\n * Reads all recognized Glasstrace environment variables from process.env.\n * Returns undefined for any variable not set. Never throws.\n */\nexport function readEnvVars(): GlasstraceEnvVars {\n return {\n GLASSTRACE_API_KEY: process.env.GLASSTRACE_API_KEY?.trim() || undefined,\n GLASSTRACE_FORCE_ENABLE: process.env.GLASSTRACE_FORCE_ENABLE,\n GLASSTRACE_ENV: process.env.GLASSTRACE_ENV,\n GLASSTRACE_COVERAGE_MAP: process.env.GLASSTRACE_COVERAGE_MAP,\n NODE_ENV: process.env.NODE_ENV,\n VERCEL_ENV: process.env.VERCEL_ENV,\n };\n}\n\n/**\n * Merges explicit GlasstraceOptions with environment variables.\n * Explicit options take precedence over environment variables.\n */\nexport function resolveConfig(options?: GlasstraceOptions): ResolvedConfig {\n const env = readEnvVars();\n\n return {\n apiKey: options?.apiKey ?? env.GLASSTRACE_API_KEY,\n endpoint: options?.endpoint ?? DEFAULT_ENDPOINT,\n forceEnable: options?.forceEnable ?? env.GLASSTRACE_FORCE_ENABLE === \"true\",\n verbose: options?.verbose ?? false,\n environment: env.GLASSTRACE_ENV,\n coverageMapEnabled: env.GLASSTRACE_COVERAGE_MAP === \"true\",\n nodeEnv: env.NODE_ENV,\n vercelEnv: env.VERCEL_ENV,\n };\n}\n\n/**\n * Returns true when the SDK should be inactive (production detected without force-enable).\n * Logic order:\n * 1. forceEnable === true → return false (override)\n * 2. NODE_ENV === 'production' → return true\n * 3. VERCEL_ENV === 'production' → return true\n * 4. Otherwise → return false\n */\nexport function isProductionDisabled(config: ResolvedConfig): boolean {\n if (config.forceEnable) {\n return false;\n }\n if (config.nodeEnv === \"production\") {\n return true;\n }\n if (config.vercelEnv === \"production\") {\n return true;\n }\n return false;\n}\n\n/**\n * Returns true when no API key is configured (anonymous mode).\n * Treats undefined, empty string, whitespace-only, and gt_anon_* keys as anonymous.\n */\nexport function isAnonymousMode(config: ResolvedConfig): boolean {\n if (config.apiKey === undefined) {\n return true;\n }\n if (config.apiKey.trim() === \"\") {\n return true;\n }\n if (config.apiKey.startsWith(\"gt_anon_\")) {\n return true;\n }\n return false;\n}\n","/**\n * Console error/warn capture module.\n *\n * When enabled, monkey-patches `console.error` and `console.warn` to record\n * their output as OTel span events on the currently active span. SDK-internal\n * log messages (prefixed with \"[glasstrace]\") are never captured.\n */\n\nimport { maybeShowMcpNudge } from \"./nudge/error-nudge.js\";\n\n/**\n * Module-level flag to suppress capture of SDK-internal log messages.\n * Set to `true` before calling `console.warn`/`console.error` from SDK code,\n * then reset to `false` immediately after.\n */\nexport let isGlasstraceLog = false;\n\n/** Saved reference to the original `console.error`. */\nlet originalError: typeof console.error | null = null;\n\n/** Saved reference to the original `console.warn`. */\nlet originalWarn: typeof console.warn | null = null;\n\n/** Whether the console capture is currently installed. */\nlet installed = false;\n\n/** Cached OTel API module reference, resolved at install time. */\nlet otelApi: typeof import(\"@opentelemetry/api\") | null = null;\n\n/**\n * Formats console arguments into a single string for span event attributes.\n * Uses best-effort serialization: strings pass through, Errors preserve their\n * stack trace, and other values are JSON-stringified with a String() fallback.\n */\nfunction formatArgs(args: unknown[]): string {\n return args\n .map((arg) => {\n if (typeof arg === \"string\") return arg;\n if (arg instanceof Error) return arg.stack ?? arg.message;\n try {\n return JSON.stringify(arg);\n } catch {\n return String(arg);\n }\n })\n .join(\" \");\n}\n\n/**\n * Returns `true` if the first argument is a string starting with \"[glasstrace]\".\n * Used to skip capture of SDK-internal log messages without requiring every\n * call site to set the `isGlasstraceLog` flag.\n */\nfunction isSdkMessage(args: unknown[]): boolean {\n return typeof args[0] === \"string\" && args[0].startsWith(\"[glasstrace]\");\n}\n\n/**\n * Installs console capture by replacing `console.error` and `console.warn`\n * with wrappers that record span events on the active OTel span.\n *\n * Must be called after OTel is configured so the API module is available.\n * Safe to call multiple times; subsequent calls are no-ops.\n */\nexport async function installConsoleCapture(): Promise<void> {\n if (installed) return;\n\n // Resolve OTel API at install time via dynamic import so that:\n // 1. tsup inlines @opentelemetry/api into the bundle (it's in noExternal)\n // 2. vitest's vi.doMock can intercept this import for testing\n try {\n otelApi = await import(\"@opentelemetry/api\");\n } catch {\n otelApi = null;\n }\n\n originalError = console.error;\n originalWarn = console.warn;\n installed = true;\n\n console.error = (...args: unknown[]) => {\n // Always call the original first to preserve developer experience\n originalError!.apply(console, args);\n\n // Skip SDK-internal messages and flagged messages\n if (isGlasstraceLog || isSdkMessage(args)) return;\n\n if (otelApi) {\n const span = otelApi.trace.getSpan(otelApi.context.active());\n if (span) {\n const formattedMessage = formatArgs(args);\n span.addEvent(\"console.error\", {\n \"console.message\": formattedMessage,\n });\n // Show one-time MCP connection nudge on first captured error\n try {\n maybeShowMcpNudge(formattedMessage);\n } catch {\n // Never allow the monkey-patched console.error wrapper to throw\n }\n }\n }\n };\n\n console.warn = (...args: unknown[]) => {\n originalWarn!.apply(console, args);\n\n if (isGlasstraceLog || isSdkMessage(args)) return;\n\n if (otelApi) {\n const span = otelApi.trace.getSpan(otelApi.context.active());\n if (span) {\n span.addEvent(\"console.warn\", {\n \"console.message\": formatArgs(args),\n });\n }\n }\n };\n}\n\n/**\n * Restores the original `console.error` and `console.warn` methods.\n * Primarily intended for use in tests.\n */\nexport function uninstallConsoleCapture(): void {\n if (!installed) return;\n\n if (originalError) console.error = originalError;\n if (originalWarn) console.warn = originalWarn;\n\n originalError = null;\n originalWarn = null;\n otelApi = null;\n installed = false;\n}\n\n/**\n * Logs a message from SDK-internal code without triggering console capture.\n *\n * Use this helper in new SDK code instead of bare `console.warn(...)` calls\n * to prevent SDK log messages from being recorded as user-facing span events.\n *\n * @param level - The console log level to use.\n * @param message - The message to log.\n */\nexport function sdkLog(level: \"warn\" | \"info\" | \"error\", message: string): void {\n isGlasstraceLog = true;\n try {\n console[level](message);\n } finally {\n isGlasstraceLog = false;\n }\n}\n"],"mappings":";;;;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,YAAY;AACxB,SAAS,oBAAoB;;;ACH7B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;;;ACerB,IAAM,mBAAmB;AAMlB,SAAS,cAAiC;AAC/C,SAAO;AAAA,IACL,oBAAoB,QAAQ,IAAI,oBAAoB,KAAK,KAAK;AAAA,IAC9D,yBAAyB,QAAQ,IAAI;AAAA,IACrC,gBAAgB,QAAQ,IAAI;AAAA,IAC5B,yBAAyB,QAAQ,IAAI;AAAA,IACrC,UAAU,QAAQ,IAAI;AAAA,IACtB,YAAY,QAAQ,IAAI;AAAA,EAC1B;AACF;AAMO,SAAS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,UAAU,WAAW,IAAI;AAC3D;","names":[]}
@@ -2,10 +2,6 @@ import {
2
2
  __export
3
3
  } from "./chunk-PZ5AY32C.js";
4
4
 
5
- // src/anon-key.ts
6
- import { readFile, writeFile, mkdir, chmod } from "fs/promises";
7
- import { join } from "path";
8
-
9
5
  // ../../node_modules/zod/v4/classic/external.js
10
6
  var external_exports = {};
11
7
  __export(external_exports, {
@@ -509,7 +505,7 @@ __export(core_exports2, {
509
505
  parse: () => parse,
510
506
  parseAsync: () => parseAsync,
511
507
  prettifyError: () => prettifyError,
512
- process: () => process2,
508
+ process: () => process,
513
509
  regexes: () => regexes_exports,
514
510
  registry: () => registry,
515
511
  safeDecode: () => safeDecode,
@@ -10910,7 +10906,7 @@ function initializeContext(params) {
10910
10906
  external: params?.external ?? void 0
10911
10907
  };
10912
10908
  }
10913
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10909
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
10914
10910
  var _a2;
10915
10911
  const def = schema._zod.def;
10916
10912
  const seen = ctx.seen.get(schema);
@@ -10947,7 +10943,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10947
10943
  if (parent) {
10948
10944
  if (!result.ref)
10949
10945
  result.ref = parent;
10950
- process2(parent, ctx, params);
10946
+ process(parent, ctx, params);
10951
10947
  ctx.seen.get(parent).isParent = true;
10952
10948
  }
10953
10949
  }
@@ -11228,14 +11224,14 @@ function isTransforming(_schema, _ctx) {
11228
11224
  }
11229
11225
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11230
11226
  const ctx = initializeContext({ ...params, processors });
11231
- process2(schema, ctx);
11227
+ process(schema, ctx);
11232
11228
  extractDefs(ctx, schema);
11233
11229
  return finalize(ctx, schema);
11234
11230
  };
11235
11231
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11236
11232
  const { libraryOptions, target } = params ?? {};
11237
11233
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11238
- process2(schema, ctx);
11234
+ process(schema, ctx);
11239
11235
  extractDefs(ctx, schema);
11240
11236
  return finalize(ctx, schema);
11241
11237
  };
@@ -11492,7 +11488,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
11492
11488
  if (typeof maximum === "number")
11493
11489
  json2.maxItems = maximum;
11494
11490
  json2.type = "array";
11495
- json2.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
11491
+ json2.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
11496
11492
  };
11497
11493
  var objectProcessor = (schema, ctx, _json, params) => {
11498
11494
  const json2 = _json;
@@ -11501,7 +11497,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11501
11497
  json2.properties = {};
11502
11498
  const shape = def.shape;
11503
11499
  for (const key in shape) {
11504
- json2.properties[key] = process2(shape[key], ctx, {
11500
+ json2.properties[key] = process(shape[key], ctx, {
11505
11501
  ...params,
11506
11502
  path: [...params.path, "properties", key]
11507
11503
  });
@@ -11524,7 +11520,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11524
11520
  if (ctx.io === "output")
11525
11521
  json2.additionalProperties = false;
11526
11522
  } else if (def.catchall) {
11527
- json2.additionalProperties = process2(def.catchall, ctx, {
11523
+ json2.additionalProperties = process(def.catchall, ctx, {
11528
11524
  ...params,
11529
11525
  path: [...params.path, "additionalProperties"]
11530
11526
  });
@@ -11533,7 +11529,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11533
11529
  var unionProcessor = (schema, ctx, json2, params) => {
11534
11530
  const def = schema._zod.def;
11535
11531
  const isExclusive = def.inclusive === false;
11536
- const options = def.options.map((x, i) => process2(x, ctx, {
11532
+ const options = def.options.map((x, i) => process(x, ctx, {
11537
11533
  ...params,
11538
11534
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
11539
11535
  }));
@@ -11545,11 +11541,11 @@ var unionProcessor = (schema, ctx, json2, params) => {
11545
11541
  };
11546
11542
  var intersectionProcessor = (schema, ctx, json2, params) => {
11547
11543
  const def = schema._zod.def;
11548
- const a = process2(def.left, ctx, {
11544
+ const a = process(def.left, ctx, {
11549
11545
  ...params,
11550
11546
  path: [...params.path, "allOf", 0]
11551
11547
  });
11552
- const b = process2(def.right, ctx, {
11548
+ const b = process(def.right, ctx, {
11553
11549
  ...params,
11554
11550
  path: [...params.path, "allOf", 1]
11555
11551
  });
@@ -11566,11 +11562,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
11566
11562
  json2.type = "array";
11567
11563
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
11568
11564
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
11569
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
11565
+ const prefixItems = def.items.map((x, i) => process(x, ctx, {
11570
11566
  ...params,
11571
11567
  path: [...params.path, prefixPath, i]
11572
11568
  }));
11573
- const rest = def.rest ? process2(def.rest, ctx, {
11569
+ const rest = def.rest ? process(def.rest, ctx, {
11574
11570
  ...params,
11575
11571
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
11576
11572
  }) : null;
@@ -11610,7 +11606,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11610
11606
  const keyBag = keyType._zod.bag;
11611
11607
  const patterns = keyBag?.patterns;
11612
11608
  if (def.mode === "loose" && patterns && patterns.size > 0) {
11613
- const valueSchema = process2(def.valueType, ctx, {
11609
+ const valueSchema = process(def.valueType, ctx, {
11614
11610
  ...params,
11615
11611
  path: [...params.path, "patternProperties", "*"]
11616
11612
  });
@@ -11620,12 +11616,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
11620
11616
  }
11621
11617
  } else {
11622
11618
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
11623
- json2.propertyNames = process2(def.keyType, ctx, {
11619
+ json2.propertyNames = process(def.keyType, ctx, {
11624
11620
  ...params,
11625
11621
  path: [...params.path, "propertyNames"]
11626
11622
  });
11627
11623
  }
11628
- json2.additionalProperties = process2(def.valueType, ctx, {
11624
+ json2.additionalProperties = process(def.valueType, ctx, {
11629
11625
  ...params,
11630
11626
  path: [...params.path, "additionalProperties"]
11631
11627
  });
@@ -11640,7 +11636,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11640
11636
  };
11641
11637
  var nullableProcessor = (schema, ctx, json2, params) => {
11642
11638
  const def = schema._zod.def;
11643
- const inner = process2(def.innerType, ctx, params);
11639
+ const inner = process(def.innerType, ctx, params);
11644
11640
  const seen = ctx.seen.get(schema);
11645
11641
  if (ctx.target === "openapi-3.0") {
11646
11642
  seen.ref = def.innerType;
@@ -11651,20 +11647,20 @@ var nullableProcessor = (schema, ctx, json2, params) => {
11651
11647
  };
11652
11648
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
11653
11649
  const def = schema._zod.def;
11654
- process2(def.innerType, ctx, params);
11650
+ process(def.innerType, ctx, params);
11655
11651
  const seen = ctx.seen.get(schema);
11656
11652
  seen.ref = def.innerType;
11657
11653
  };
11658
11654
  var defaultProcessor = (schema, ctx, json2, params) => {
11659
11655
  const def = schema._zod.def;
11660
- process2(def.innerType, ctx, params);
11656
+ process(def.innerType, ctx, params);
11661
11657
  const seen = ctx.seen.get(schema);
11662
11658
  seen.ref = def.innerType;
11663
11659
  json2.default = JSON.parse(JSON.stringify(def.defaultValue));
11664
11660
  };
11665
11661
  var prefaultProcessor = (schema, ctx, json2, params) => {
11666
11662
  const def = schema._zod.def;
11667
- process2(def.innerType, ctx, params);
11663
+ process(def.innerType, ctx, params);
11668
11664
  const seen = ctx.seen.get(schema);
11669
11665
  seen.ref = def.innerType;
11670
11666
  if (ctx.io === "input")
@@ -11672,7 +11668,7 @@ var prefaultProcessor = (schema, ctx, json2, params) => {
11672
11668
  };
11673
11669
  var catchProcessor = (schema, ctx, json2, params) => {
11674
11670
  const def = schema._zod.def;
11675
- process2(def.innerType, ctx, params);
11671
+ process(def.innerType, ctx, params);
11676
11672
  const seen = ctx.seen.get(schema);
11677
11673
  seen.ref = def.innerType;
11678
11674
  let catchValue;
@@ -11686,32 +11682,32 @@ var catchProcessor = (schema, ctx, json2, params) => {
11686
11682
  var pipeProcessor = (schema, ctx, _json, params) => {
11687
11683
  const def = schema._zod.def;
11688
11684
  const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
11689
- process2(innerType, ctx, params);
11685
+ process(innerType, ctx, params);
11690
11686
  const seen = ctx.seen.get(schema);
11691
11687
  seen.ref = innerType;
11692
11688
  };
11693
11689
  var readonlyProcessor = (schema, ctx, json2, params) => {
11694
11690
  const def = schema._zod.def;
11695
- process2(def.innerType, ctx, params);
11691
+ process(def.innerType, ctx, params);
11696
11692
  const seen = ctx.seen.get(schema);
11697
11693
  seen.ref = def.innerType;
11698
11694
  json2.readOnly = true;
11699
11695
  };
11700
11696
  var promiseProcessor = (schema, ctx, _json, params) => {
11701
11697
  const def = schema._zod.def;
11702
- process2(def.innerType, ctx, params);
11698
+ process(def.innerType, ctx, params);
11703
11699
  const seen = ctx.seen.get(schema);
11704
11700
  seen.ref = def.innerType;
11705
11701
  };
11706
11702
  var optionalProcessor = (schema, ctx, _json, params) => {
11707
11703
  const def = schema._zod.def;
11708
- process2(def.innerType, ctx, params);
11704
+ process(def.innerType, ctx, params);
11709
11705
  const seen = ctx.seen.get(schema);
11710
11706
  seen.ref = def.innerType;
11711
11707
  };
11712
11708
  var lazyProcessor = (schema, ctx, _json, params) => {
11713
11709
  const innerType = schema._zod.innerType;
11714
- process2(innerType, ctx, params);
11710
+ process(innerType, ctx, params);
11715
11711
  const seen = ctx.seen.get(schema);
11716
11712
  seen.ref = innerType;
11717
11713
  };
@@ -11763,7 +11759,7 @@ function toJSONSchema(input, params) {
11763
11759
  const defs = {};
11764
11760
  for (const entry of registry2._idmap.entries()) {
11765
11761
  const [_, schema] = entry;
11766
- process2(schema, ctx2);
11762
+ process(schema, ctx2);
11767
11763
  }
11768
11764
  const schemas = {};
11769
11765
  const external = {
@@ -11786,7 +11782,7 @@ function toJSONSchema(input, params) {
11786
11782
  return { schemas };
11787
11783
  }
11788
11784
  const ctx = initializeContext({ ...params, processors: allProcessors });
11789
- process2(input, ctx);
11785
+ process(input, ctx);
11790
11786
  extractDefs(ctx, input);
11791
11787
  return finalize(ctx, input);
11792
11788
  }
@@ -11844,7 +11840,7 @@ var JSONSchemaGenerator = class {
11844
11840
  * This must be called before emit().
11845
11841
  */
11846
11842
  process(schema, _params = { path: [], schemaPath: [] }) {
11847
- return process2(schema, this.ctx, _params);
11843
+ return process(schema, this.ctx, _params);
11848
11844
  }
11849
11845
  /**
11850
11846
  * Emit the final JSON Schema after processing.
@@ -13951,68 +13947,10 @@ var DEFAULT_CAPTURE_CONFIG = {
13951
13947
  consoleErrors: false
13952
13948
  };
13953
13949
 
13954
- // src/anon-key.ts
13955
- var GLASSTRACE_DIR = ".glasstrace";
13956
- var ANON_KEY_FILE = "anon_key";
13957
- var ephemeralKeyCache = /* @__PURE__ */ new Map();
13958
- async function readAnonKey(projectRoot) {
13959
- const root = projectRoot ?? process.cwd();
13960
- const keyPath = join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
13961
- try {
13962
- const content = await readFile(keyPath, "utf-8");
13963
- const result = AnonApiKeySchema.safeParse(content);
13964
- if (result.success) {
13965
- return result.data;
13966
- }
13967
- } catch {
13968
- }
13969
- const cached2 = ephemeralKeyCache.get(root);
13970
- if (cached2 !== void 0) {
13971
- return cached2;
13972
- }
13973
- return null;
13974
- }
13975
- async function getOrCreateAnonKey(projectRoot) {
13976
- const root = projectRoot ?? process.cwd();
13977
- const dirPath = join(root, GLASSTRACE_DIR);
13978
- const keyPath = join(dirPath, ANON_KEY_FILE);
13979
- const existingKey = await readAnonKey(root);
13980
- if (existingKey !== null) {
13981
- return existingKey;
13982
- }
13983
- const cached2 = ephemeralKeyCache.get(root);
13984
- if (cached2 !== void 0) {
13985
- return cached2;
13986
- }
13987
- const newKey = createAnonApiKey();
13988
- try {
13989
- await mkdir(dirPath, { recursive: true, mode: 448 });
13990
- await writeFile(keyPath, newKey, { flag: "wx", mode: 384 });
13991
- return newKey;
13992
- } catch (err) {
13993
- const code = err.code;
13994
- if (code === "EEXIST") {
13995
- const winnerKey = await readAnonKey(root);
13996
- if (winnerKey !== null) {
13997
- return winnerKey;
13998
- }
13999
- try {
14000
- await writeFile(keyPath, newKey, { mode: 384 });
14001
- await chmod(keyPath, 384);
14002
- return newKey;
14003
- } catch {
14004
- }
14005
- }
14006
- ephemeralKeyCache.set(root, newKey);
14007
- console.warn(
14008
- `[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`
14009
- );
14010
- return newKey;
14011
- }
14012
- }
14013
-
14014
13950
  export {
13951
+ AnonApiKeySchema,
14015
13952
  SessionIdSchema,
13953
+ createAnonApiKey,
14016
13954
  createBuildHash,
14017
13955
  SdkCachedConfigSchema,
14018
13956
  SdkInitResponseSchema,
@@ -14020,8 +13958,6 @@ export {
14020
13958
  PresignedUploadResponseSchema,
14021
13959
  SourceMapManifestResponseSchema,
14022
13960
  GLASSTRACE_ATTRIBUTE_NAMES,
14023
- DEFAULT_CAPTURE_CONFIG,
14024
- readAnonKey,
14025
- getOrCreateAnonKey
13961
+ DEFAULT_CAPTURE_CONFIG
14026
13962
  };
14027
- //# sourceMappingURL=chunk-QW6W4CSA.js.map
13963
+ //# sourceMappingURL=chunk-O3Y45VGV.js.map