@glasstrace/sdk 0.9.1 → 0.11.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.
- package/dist/chunk-2JUH3VGJ.js +77 -0
- package/dist/chunk-2JUH3VGJ.js.map +1 -0
- package/dist/{chunk-PQWAKVQ5.js → chunk-D3JC3LAK.js} +36 -103
- package/dist/chunk-D3JC3LAK.js.map +1 -0
- package/dist/{chunk-Y6V7BTF3.js → chunk-M7RDFOFR.js} +2 -2
- package/dist/chunk-SLSWEQCC.js +417 -0
- package/dist/chunk-SLSWEQCC.js.map +1 -0
- package/dist/cli/init.cjs +58 -19
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +3 -1
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +2 -1
- package/dist/cli/mcp-add.js.map +1 -1
- package/dist/cli/uninit.cjs +57 -18
- package/dist/cli/uninit.cjs.map +1 -1
- package/dist/cli/uninit.d.cts +34 -2
- package/dist/cli/uninit.d.ts +34 -2
- package/dist/cli/uninit.js +55 -18
- package/dist/cli/uninit.js.map +1 -1
- package/dist/index.cjs +15731 -15009
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +64 -408
- package/dist/index.js.map +1 -1
- package/dist/source-map-uploader-OFEM54UE.js +25 -0
- package/dist/source-map-uploader-OFEM54UE.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-PQWAKVQ5.js.map +0 -1
- /package/dist/{chunk-Y6V7BTF3.js.map → chunk-M7RDFOFR.js.map} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnonApiKeySchema,
|
|
3
|
+
createAnonApiKey
|
|
4
|
+
} from "./chunk-D3JC3LAK.js";
|
|
5
|
+
|
|
6
|
+
// src/anon-key.ts
|
|
7
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var GLASSTRACE_DIR = ".glasstrace";
|
|
10
|
+
var ANON_KEY_FILE = "anon_key";
|
|
11
|
+
var ephemeralKeyCache = /* @__PURE__ */ new Map();
|
|
12
|
+
async function readAnonKey(projectRoot) {
|
|
13
|
+
const root = projectRoot ?? process.cwd();
|
|
14
|
+
const keyPath = join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
|
|
15
|
+
try {
|
|
16
|
+
const content = await readFile(keyPath, "utf-8");
|
|
17
|
+
const result = AnonApiKeySchema.safeParse(content);
|
|
18
|
+
if (result.success) {
|
|
19
|
+
return result.data;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
const cached = ephemeralKeyCache.get(root);
|
|
24
|
+
if (cached !== void 0) {
|
|
25
|
+
return cached;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
async function getOrCreateAnonKey(projectRoot) {
|
|
30
|
+
const root = projectRoot ?? process.cwd();
|
|
31
|
+
const dirPath = join(root, GLASSTRACE_DIR);
|
|
32
|
+
const keyPath = join(dirPath, ANON_KEY_FILE);
|
|
33
|
+
const existingKey = await readAnonKey(root);
|
|
34
|
+
if (existingKey !== null) {
|
|
35
|
+
return existingKey;
|
|
36
|
+
}
|
|
37
|
+
const cached = ephemeralKeyCache.get(root);
|
|
38
|
+
if (cached !== void 0) {
|
|
39
|
+
return cached;
|
|
40
|
+
}
|
|
41
|
+
const newKey = createAnonApiKey();
|
|
42
|
+
try {
|
|
43
|
+
await mkdir(dirPath, { recursive: true, mode: 448 });
|
|
44
|
+
await writeFile(keyPath, newKey, { flag: "wx", mode: 384 });
|
|
45
|
+
return newKey;
|
|
46
|
+
} catch (err) {
|
|
47
|
+
const code = err.code;
|
|
48
|
+
if (code === "EEXIST") {
|
|
49
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
50
|
+
const winnerKey = await readAnonKey(root);
|
|
51
|
+
if (winnerKey !== null) {
|
|
52
|
+
return winnerKey;
|
|
53
|
+
}
|
|
54
|
+
if (attempt < 2) {
|
|
55
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
await writeFile(keyPath, newKey, { mode: 384 });
|
|
60
|
+
await chmod(keyPath, 384);
|
|
61
|
+
return newKey;
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ephemeralKeyCache.set(root, newKey);
|
|
66
|
+
console.warn(
|
|
67
|
+
`[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`
|
|
68
|
+
);
|
|
69
|
+
return newKey;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
readAnonKey,
|
|
75
|
+
getOrCreateAnonKey
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chunk-2JUH3VGJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/anon-key.ts"],"sourcesContent":["import { readFile, writeFile, mkdir, chmod } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { AnonApiKeySchema, createAnonApiKey } from \"@glasstrace/protocol\";\nimport type { AnonApiKey } from \"@glasstrace/protocol\";\n\nconst GLASSTRACE_DIR = \".glasstrace\";\nconst ANON_KEY_FILE = \"anon_key\";\n\n/**\n * In-memory cache for ephemeral keys when filesystem persistence fails.\n * Keyed by resolved project root to support multiple roots in tests.\n */\nconst ephemeralKeyCache = new Map<string, AnonApiKey>();\n\n/**\n * Reads an existing anonymous key from the filesystem.\n * Returns the key if valid, or null if:\n * - The file does not exist\n * - The file content is invalid\n * - An I/O error occurs\n */\nexport async function readAnonKey(projectRoot?: string): Promise<AnonApiKey | null> {\n const root = projectRoot ?? process.cwd();\n const keyPath = join(root, GLASSTRACE_DIR, ANON_KEY_FILE);\n\n try {\n const content = await readFile(keyPath, \"utf-8\");\n const result = AnonApiKeySchema.safeParse(content);\n if (result.success) {\n return result.data;\n }\n } catch {\n // Fall through to check ephemeral cache\n }\n\n // Check in-memory cache (used when filesystem persistence failed)\n const cached = ephemeralKeyCache.get(root);\n if (cached !== undefined) {\n return cached;\n }\n\n return null;\n}\n\n/**\n * Gets an existing anonymous key from the filesystem, or creates a new one.\n *\n * - If file exists and contains a valid key, returns it\n * - If file does not exist or content is invalid, generates a new key via createAnonApiKey()\n * - Writes the new key to `.glasstrace/anon_key`, creating the directory if needed\n * - On file write failure: logs a warning, caches an ephemeral in-memory key so\n * repeated calls in the same process return the same key\n */\nexport async function getOrCreateAnonKey(projectRoot?: string): Promise<AnonApiKey> {\n const root = projectRoot ?? process.cwd();\n const dirPath = join(root, GLASSTRACE_DIR);\n const keyPath = join(dirPath, ANON_KEY_FILE);\n\n // Try reading existing key from filesystem\n const existingKey = await readAnonKey(root);\n if (existingKey !== null) {\n return existingKey;\n }\n\n // Check in-memory cache (used when filesystem is unavailable)\n const cached = ephemeralKeyCache.get(root);\n if (cached !== undefined) {\n return cached;\n }\n\n // Generate a new key\n const newKey = createAnonApiKey();\n\n // Persist to filesystem using atomic create-or-fail (O_CREAT | O_EXCL)\n // to prevent TOCTOU races where concurrent cold starts both generate keys.\n try {\n await mkdir(dirPath, { recursive: true, mode: 0o700 });\n await writeFile(keyPath, newKey, { flag: \"wx\", mode: 0o600 });\n return newKey;\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"EEXIST\") {\n // Another process won the race. Retry reading their key with\n // short delays — the winner's writeFile is atomic for small\n // payloads but the filesystem may not have flushed yet.\n for (let attempt = 0; attempt < 3; attempt++) {\n const winnerKey = await readAnonKey(root);\n if (winnerKey !== null) {\n return winnerKey;\n }\n // Short delay before next retry (50ms), skip after final attempt\n if (attempt < 2) {\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n }\n // All retries exhausted — overwrite as last resort.\n // Use explicit chmod after overwrite since writeFile mode only\n // applies on creation on some platforms.\n try {\n await writeFile(keyPath, newKey, { mode: 0o600 });\n await chmod(keyPath, 0o600);\n return newKey;\n } catch {\n // Overwrite failed — fall through to ephemeral cache\n }\n }\n\n // Non-EEXIST error (EACCES, ENOTDIR, etc.) — cache in memory so\n // repeated calls get the same ephemeral key within this process.\n ephemeralKeyCache.set(root, newKey);\n console.warn(\n `[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`,\n );\n return newKey;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAS,UAAU,WAAW,OAAO,aAAa;AAClD,SAAS,YAAY;AAIrB,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AAMtB,IAAM,oBAAoB,oBAAI,IAAwB;AAStD,eAAsB,YAAY,aAAkD;AAClF,QAAM,OAAO,eAAe,QAAQ,IAAI;AACxC,QAAM,UAAU,KAAK,MAAM,gBAAgB,aAAa;AAExD,MAAI;AACF,UAAM,UAAU,MAAM,SAAS,SAAS,OAAO;AAC/C,UAAM,SAAS,iBAAiB,UAAU,OAAO;AACjD,QAAI,OAAO,SAAS;AAClB,aAAO,OAAO;AAAA,IAChB;AAAA,EACF,QAAQ;AAAA,EAER;AAGA,QAAM,SAAS,kBAAkB,IAAI,IAAI;AACzC,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAWA,eAAsB,mBAAmB,aAA2C;AAClF,QAAM,OAAO,eAAe,QAAQ,IAAI;AACxC,QAAM,UAAU,KAAK,MAAM,cAAc;AACzC,QAAM,UAAU,KAAK,SAAS,aAAa;AAG3C,QAAM,cAAc,MAAM,YAAY,IAAI;AAC1C,MAAI,gBAAgB,MAAM;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,kBAAkB,IAAI,IAAI;AACzC,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,iBAAiB;AAIhC,MAAI;AACF,UAAM,MAAM,SAAS,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACrD,UAAM,UAAU,SAAS,QAAQ,EAAE,MAAM,MAAM,MAAM,IAAM,CAAC;AAC5D,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,UAAM,OAAQ,IAA8B;AAC5C,QAAI,SAAS,UAAU;AAIrB,eAAS,UAAU,GAAG,UAAU,GAAG,WAAW;AAC5C,cAAM,YAAY,MAAM,YAAY,IAAI;AACxC,YAAI,cAAc,MAAM;AACtB,iBAAO;AAAA,QACT;AAEA,YAAI,UAAU,GAAG;AACf,gBAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,QACxD;AAAA,MACF;AAIA,UAAI;AACF,cAAM,UAAU,SAAS,QAAQ,EAAE,MAAM,IAAM,CAAC;AAChD,cAAM,MAAM,SAAS,GAAK;AAC1B,eAAO;AAAA,MACT,QAAQ;AAAA,MAER;AAAA,IACF;AAIA,sBAAkB,IAAI,MAAM,MAAM;AAClC,YAAQ;AAAA,MACN,mDAAmD,OAAO,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IACjH;AACA,WAAO;AAAA,EACT;AACF;","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: () =>
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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] =
|
|
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 =
|
|
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) =>
|
|
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 =
|
|
11544
|
+
const a = process(def.left, ctx, {
|
|
11549
11545
|
...params,
|
|
11550
11546
|
path: [...params.path, "allOf", 0]
|
|
11551
11547
|
});
|
|
11552
|
-
const b =
|
|
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) =>
|
|
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 ?
|
|
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 =
|
|
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 =
|
|
11619
|
+
json2.propertyNames = process(def.keyType, ctx, {
|
|
11624
11620
|
...params,
|
|
11625
11621
|
path: [...params.path, "propertyNames"]
|
|
11626
11622
|
});
|
|
11627
11623
|
}
|
|
11628
|
-
json2.additionalProperties =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
11843
|
+
return process(schema, this.ctx, _params);
|
|
11848
11844
|
}
|
|
11849
11845
|
/**
|
|
11850
11846
|
* Emit the final JSON Schema after processing.
|
|
@@ -13860,7 +13856,9 @@ var SdkInitResponseSchema = external_exports.object({
|
|
|
13860
13856
|
});
|
|
13861
13857
|
var DiscoveryResponseSchema = external_exports.object({
|
|
13862
13858
|
key: AnonApiKeySchema,
|
|
13863
|
-
sessionId: SessionIdSchema
|
|
13859
|
+
sessionId: SessionIdSchema,
|
|
13860
|
+
claimed: external_exports.boolean().optional(),
|
|
13861
|
+
accountHint: external_exports.string().optional()
|
|
13864
13862
|
});
|
|
13865
13863
|
var SourceMapUploadResponseSchema = external_exports.object({
|
|
13866
13864
|
success: external_exports.literal(true),
|
|
@@ -13951,73 +13949,10 @@ var DEFAULT_CAPTURE_CONFIG = {
|
|
|
13951
13949
|
consoleErrors: false
|
|
13952
13950
|
};
|
|
13953
13951
|
|
|
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
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
13996
|
-
const winnerKey = await readAnonKey(root);
|
|
13997
|
-
if (winnerKey !== null) {
|
|
13998
|
-
return winnerKey;
|
|
13999
|
-
}
|
|
14000
|
-
if (attempt < 2) {
|
|
14001
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
14002
|
-
}
|
|
14003
|
-
}
|
|
14004
|
-
try {
|
|
14005
|
-
await writeFile(keyPath, newKey, { mode: 384 });
|
|
14006
|
-
await chmod(keyPath, 384);
|
|
14007
|
-
return newKey;
|
|
14008
|
-
} catch {
|
|
14009
|
-
}
|
|
14010
|
-
}
|
|
14011
|
-
ephemeralKeyCache.set(root, newKey);
|
|
14012
|
-
console.warn(
|
|
14013
|
-
`[glasstrace] Failed to persist anonymous key to ${keyPath}: ${err instanceof Error ? err.message : String(err)}. Using ephemeral key.`
|
|
14014
|
-
);
|
|
14015
|
-
return newKey;
|
|
14016
|
-
}
|
|
14017
|
-
}
|
|
14018
|
-
|
|
14019
13952
|
export {
|
|
13953
|
+
AnonApiKeySchema,
|
|
14020
13954
|
SessionIdSchema,
|
|
13955
|
+
createAnonApiKey,
|
|
14021
13956
|
createBuildHash,
|
|
14022
13957
|
SdkCachedConfigSchema,
|
|
14023
13958
|
SdkInitResponseSchema,
|
|
@@ -14025,8 +13960,6 @@ export {
|
|
|
14025
13960
|
PresignedUploadResponseSchema,
|
|
14026
13961
|
SourceMapManifestResponseSchema,
|
|
14027
13962
|
GLASSTRACE_ATTRIBUTE_NAMES,
|
|
14028
|
-
DEFAULT_CAPTURE_CONFIG
|
|
14029
|
-
readAnonKey,
|
|
14030
|
-
getOrCreateAnonKey
|
|
13963
|
+
DEFAULT_CAPTURE_CONFIG
|
|
14031
13964
|
};
|
|
14032
|
-
//# sourceMappingURL=chunk-
|
|
13965
|
+
//# sourceMappingURL=chunk-D3JC3LAK.js.map
|