@glasstrace/sdk 0.11.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-2JUH3VGJ.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-M7RDFOFR.js → chunk-LW7DPKBA.js} +2 -2
  7. package/dist/{chunk-SLSWEQCC.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-D3JC3LAK.js → chunk-OKIP4SRG.js} +2 -2
  11. package/dist/cli/init.cjs +454 -329
  12. package/dist/cli/init.cjs.map +1 -1
  13. package/dist/cli/init.d.cts +25 -1
  14. package/dist/cli/init.d.ts +25 -1
  15. package/dist/cli/init.js +114 -4
  16. package/dist/cli/init.js.map +1 -1
  17. package/dist/cli/mcp-add.cjs +60 -46
  18. package/dist/cli/mcp-add.cjs.map +1 -1
  19. package/dist/cli/mcp-add.js +3 -3
  20. package/dist/cli/uninit.js +15 -564
  21. package/dist/cli/uninit.js.map +1 -1
  22. package/dist/{esm-POMEQPKL.js → esm-KBPHCVB4.js} +2 -2
  23. package/dist/{getMachineId-bsd-TC3JSTY5.js → getMachineId-bsd-345PYXFX.js} +2 -2
  24. package/dist/{getMachineId-darwin-2SUKQCE6.js → getMachineId-darwin-5L2D25AD.js} +2 -2
  25. package/dist/{getMachineId-linux-PNAFHLXH.js → getMachineId-linux-KJR4P5HN.js} +2 -2
  26. package/dist/{getMachineId-unsupported-L2MNYW3W.js → getMachineId-unsupported-NDNXDYDY.js} +2 -2
  27. package/dist/{getMachineId-win-D6D42WOQ.js → getMachineId-win-T7PJNJXG.js} +2 -2
  28. package/dist/index.cjs +297 -154
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +51 -10
  31. package/dist/index.d.ts +51 -10
  32. package/dist/index.js +133 -78
  33. package/dist/index.js.map +1 -1
  34. package/dist/{source-map-uploader-OFEM54UE.js → source-map-uploader-ZFCYOURS.js} +6 -4
  35. package/package.json +1 -1
  36. package/dist/chunk-2JUH3VGJ.js.map +0 -1
  37. package/dist/chunk-PZ5AY32C.js +0 -10
  38. package/dist/chunk-SLSWEQCC.js.map +0 -1
  39. /package/dist/{chunk-M7RDFOFR.js.map → chunk-LW7DPKBA.js.map} +0 -0
  40. /package/dist/{chunk-PZ5AY32C.js.map → chunk-NSBPE2FW.js.map} +0 -0
  41. /package/dist/{chunk-D3JC3LAK.js.map → chunk-OKIP4SRG.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-OFEM54UE.js.map → source-map-uploader-ZFCYOURS.js.map} +0 -0
@@ -38,10 +38,6 @@ var fs2 = __toESM(require("fs"), 1);
38
38
  var path2 = __toESM(require("path"), 1);
39
39
  var import_node_util = require("util");
40
40
 
41
- // src/anon-key.ts
42
- var import_promises = require("fs/promises");
43
- var import_node_path = require("path");
44
-
45
41
  // ../../node_modules/zod/v4/classic/external.js
46
42
  var external_exports = {};
47
43
  __export(external_exports, {
@@ -13938,17 +13934,35 @@ var SourceMapManifestResponseSchema = external_exports.object({
13938
13934
  // src/anon-key.ts
13939
13935
  var GLASSTRACE_DIR = ".glasstrace";
13940
13936
  var ANON_KEY_FILE = "anon_key";
13937
+ var fsPathCache;
13938
+ async function loadFsPath() {
13939
+ if (fsPathCache !== void 0) return fsPathCache;
13940
+ try {
13941
+ const [fs3, path3] = await Promise.all([
13942
+ import("fs/promises"),
13943
+ import("path")
13944
+ ]);
13945
+ fsPathCache = { fs: fs3, path: path3 };
13946
+ return fsPathCache;
13947
+ } catch {
13948
+ fsPathCache = null;
13949
+ return null;
13950
+ }
13951
+ }
13941
13952
  var ephemeralKeyCache = /* @__PURE__ */ new Map();
13942
13953
  async function readAnonKey(projectRoot) {
13943
13954
  const root = projectRoot ?? process.cwd();
13944
- const keyPath = (0, import_node_path.join)(root, GLASSTRACE_DIR, ANON_KEY_FILE);
13945
- try {
13946
- const content = await (0, import_promises.readFile)(keyPath, "utf-8");
13947
- const result = AnonApiKeySchema.safeParse(content);
13948
- if (result.success) {
13949
- return result.data;
13955
+ const modules = await loadFsPath();
13956
+ if (modules) {
13957
+ const keyPath = modules.path.join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
13958
+ try {
13959
+ const content = await modules.fs.readFile(keyPath, "utf-8");
13960
+ const result = AnonApiKeySchema.safeParse(content);
13961
+ if (result.success) {
13962
+ return result.data;
13963
+ }
13964
+ } catch {
13950
13965
  }
13951
- } catch {
13952
13966
  }
13953
13967
  const cached2 = ephemeralKeyCache.get(root);
13954
13968
  if (cached2 !== void 0) {
@@ -13959,31 +13973,31 @@ async function readAnonKey(projectRoot) {
13959
13973
 
13960
13974
  // src/agent-detection/detect.ts
13961
13975
  var import_node_child_process = require("child_process");
13962
- var import_promises2 = require("fs/promises");
13963
- var import_node_path2 = require("path");
13976
+ var import_promises = require("fs/promises");
13977
+ var import_node_path = require("path");
13964
13978
  var import_node_os = require("os");
13965
13979
  var import_node_fs = require("fs");
13966
13980
  var AGENT_RULES = [
13967
13981
  {
13968
13982
  name: "claude",
13969
13983
  markers: [".claude", "CLAUDE.md"],
13970
- mcpConfigPath: (dir) => (0, import_node_path2.join)(dir, ".mcp.json"),
13971
- infoFilePath: (dir) => (0, import_node_path2.join)(dir, "CLAUDE.md"),
13984
+ mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".mcp.json"),
13985
+ infoFilePath: (dir) => (0, import_node_path.join)(dir, "CLAUDE.md"),
13972
13986
  cliBinary: "claude",
13973
13987
  registrationCommand: "npx glasstrace mcp add --agent claude"
13974
13988
  },
13975
13989
  {
13976
13990
  name: "codex",
13977
13991
  markers: ["codex.md", ".codex"],
13978
- mcpConfigPath: (dir) => (0, import_node_path2.join)(dir, ".codex", "config.toml"),
13979
- infoFilePath: (dir) => (0, import_node_path2.join)(dir, "codex.md"),
13992
+ mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".codex", "config.toml"),
13993
+ infoFilePath: (dir) => (0, import_node_path.join)(dir, "codex.md"),
13980
13994
  cliBinary: "codex",
13981
13995
  registrationCommand: "npx glasstrace mcp add --agent codex"
13982
13996
  },
13983
13997
  {
13984
13998
  name: "gemini",
13985
13999
  markers: [".gemini"],
13986
- mcpConfigPath: (dir) => (0, import_node_path2.join)(dir, ".gemini", "settings.json"),
14000
+ mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".gemini", "settings.json"),
13987
14001
  infoFilePath: () => null,
13988
14002
  cliBinary: "gemini",
13989
14003
  registrationCommand: "npx glasstrace mcp add --agent gemini"
@@ -13991,41 +14005,41 @@ var AGENT_RULES = [
13991
14005
  {
13992
14006
  name: "cursor",
13993
14007
  markers: [".cursor", ".cursorrules"],
13994
- mcpConfigPath: (dir) => (0, import_node_path2.join)(dir, ".cursor", "mcp.json"),
13995
- infoFilePath: (dir) => (0, import_node_path2.join)(dir, ".cursorrules"),
14008
+ mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".cursor", "mcp.json"),
14009
+ infoFilePath: (dir) => (0, import_node_path.join)(dir, ".cursorrules"),
13996
14010
  cliBinary: null,
13997
14011
  registrationCommand: "npx glasstrace mcp add --agent cursor"
13998
14012
  },
13999
14013
  {
14000
14014
  name: "windsurf",
14001
14015
  markers: [".windsurfrules", ".windsurf"],
14002
- mcpConfigPath: () => (0, import_node_path2.join)((0, import_node_os.homedir)(), ".codeium", "windsurf", "mcp_config.json"),
14003
- infoFilePath: (dir) => (0, import_node_path2.join)(dir, ".windsurfrules"),
14016
+ mcpConfigPath: () => (0, import_node_path.join)((0, import_node_os.homedir)(), ".codeium", "windsurf", "mcp_config.json"),
14017
+ infoFilePath: (dir) => (0, import_node_path.join)(dir, ".windsurfrules"),
14004
14018
  cliBinary: null,
14005
14019
  registrationCommand: "npx glasstrace mcp add --agent windsurf"
14006
14020
  }
14007
14021
  ];
14008
14022
  async function pathExists(path3, mode = import_node_fs.constants.R_OK) {
14009
14023
  try {
14010
- await (0, import_promises2.access)(path3, mode);
14024
+ await (0, import_promises.access)(path3, mode);
14011
14025
  return true;
14012
14026
  } catch {
14013
14027
  return false;
14014
14028
  }
14015
14029
  }
14016
14030
  async function findGitRoot(startDir) {
14017
- let current = (0, import_node_path2.resolve)(startDir);
14031
+ let current = (0, import_node_path.resolve)(startDir);
14018
14032
  while (true) {
14019
- if (await pathExists((0, import_node_path2.join)(current, ".git"), import_node_fs.constants.F_OK)) {
14033
+ if (await pathExists((0, import_node_path.join)(current, ".git"), import_node_fs.constants.F_OK)) {
14020
14034
  return current;
14021
14035
  }
14022
- const parent = (0, import_node_path2.dirname)(current);
14036
+ const parent = (0, import_node_path.dirname)(current);
14023
14037
  if (parent === current) {
14024
14038
  break;
14025
14039
  }
14026
14040
  current = parent;
14027
14041
  }
14028
- return (0, import_node_path2.resolve)(startDir);
14042
+ return (0, import_node_path.resolve)(startDir);
14029
14043
  }
14030
14044
  function isCliAvailable(binary) {
14031
14045
  return new Promise((resolve2) => {
@@ -14036,10 +14050,10 @@ function isCliAvailable(binary) {
14036
14050
  });
14037
14051
  }
14038
14052
  async function detectAgents(projectRoot) {
14039
- const resolvedRoot = (0, import_node_path2.resolve)(projectRoot);
14053
+ const resolvedRoot = (0, import_node_path.resolve)(projectRoot);
14040
14054
  let rootStat;
14041
14055
  try {
14042
- rootStat = await (0, import_promises2.stat)(resolvedRoot);
14056
+ rootStat = await (0, import_promises.stat)(resolvedRoot);
14043
14057
  } catch (err) {
14044
14058
  const code = err.code;
14045
14059
  throw new Error(
@@ -14057,7 +14071,7 @@ async function detectAgents(projectRoot) {
14057
14071
  if (current === gitRoot) {
14058
14072
  break;
14059
14073
  }
14060
- const parent = (0, import_node_path2.dirname)(current);
14074
+ const parent = (0, import_node_path.dirname)(current);
14061
14075
  if (parent === current) {
14062
14076
  break;
14063
14077
  }
@@ -14070,7 +14084,7 @@ async function detectAgents(projectRoot) {
14070
14084
  for (const dir of searchDirs) {
14071
14085
  let markerFound = false;
14072
14086
  for (const marker of rule.markers) {
14073
- if (await pathExists((0, import_node_path2.join)(dir, marker))) {
14087
+ if (await pathExists((0, import_node_path.join)(dir, marker))) {
14074
14088
  markerFound = true;
14075
14089
  break;
14076
14090
  }
@@ -14102,7 +14116,7 @@ async function detectAgents(projectRoot) {
14102
14116
  }
14103
14117
  detected.push({
14104
14118
  name: "generic",
14105
- mcpConfigPath: (0, import_node_path2.join)(resolvedRoot, ".glasstrace", "mcp.json"),
14119
+ mcpConfigPath: (0, import_node_path.join)(resolvedRoot, ".glasstrace", "mcp.json"),
14106
14120
  infoFilePath: null,
14107
14121
  cliAvailable: false,
14108
14122
  registrationCommand: null
@@ -14273,8 +14287,8 @@ ${content}${m.end}
14273
14287
  }
14274
14288
 
14275
14289
  // src/agent-detection/inject.ts
14276
- var import_promises3 = require("fs/promises");
14277
- var import_node_path3 = require("path");
14290
+ var import_promises2 = require("fs/promises");
14291
+ var import_node_path2 = require("path");
14278
14292
  var HTML_START = "<!-- glasstrace:mcp:start -->";
14279
14293
  var HTML_END = "<!-- glasstrace:mcp:end -->";
14280
14294
  var HASH_START = "# glasstrace:mcp:start";
@@ -14288,9 +14302,9 @@ async function writeMcpConfig(agent, content, projectRoot) {
14288
14302
  return;
14289
14303
  }
14290
14304
  const configPath = agent.mcpConfigPath;
14291
- const parentDir = (0, import_node_path3.dirname)(configPath);
14305
+ const parentDir = (0, import_node_path2.dirname)(configPath);
14292
14306
  try {
14293
- await (0, import_promises3.mkdir)(parentDir, { recursive: true });
14307
+ await (0, import_promises2.mkdir)(parentDir, { recursive: true });
14294
14308
  } catch (err) {
14295
14309
  if (isPermissionError(err)) {
14296
14310
  process.stderr.write(
@@ -14302,7 +14316,7 @@ async function writeMcpConfig(agent, content, projectRoot) {
14302
14316
  throw err;
14303
14317
  }
14304
14318
  try {
14305
- await (0, import_promises3.writeFile)(configPath, content, { mode: 384 });
14319
+ await (0, import_promises2.writeFile)(configPath, content, { mode: 384 });
14306
14320
  } catch (err) {
14307
14321
  if (isPermissionError(err)) {
14308
14322
  process.stderr.write(
@@ -14314,7 +14328,7 @@ async function writeMcpConfig(agent, content, projectRoot) {
14314
14328
  throw err;
14315
14329
  }
14316
14330
  try {
14317
- await (0, import_promises3.chmod)(configPath, 384);
14331
+ await (0, import_promises2.chmod)(configPath, 384);
14318
14332
  } catch {
14319
14333
  }
14320
14334
  }
@@ -14347,7 +14361,7 @@ async function injectInfoSection(agent, content, projectRoot) {
14347
14361
  const filePath = agent.infoFilePath;
14348
14362
  let existingContent = null;
14349
14363
  try {
14350
- existingContent = await (0, import_promises3.readFile)(filePath, "utf-8");
14364
+ existingContent = await (0, import_promises2.readFile)(filePath, "utf-8");
14351
14365
  } catch (err) {
14352
14366
  const code = err.code;
14353
14367
  if (code !== "ENOENT") {
@@ -14363,8 +14377,8 @@ async function injectInfoSection(agent, content, projectRoot) {
14363
14377
  }
14364
14378
  if (existingContent === null) {
14365
14379
  try {
14366
- await (0, import_promises3.mkdir)((0, import_node_path3.dirname)(filePath), { recursive: true });
14367
- await (0, import_promises3.writeFile)(filePath, content, "utf-8");
14380
+ await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(filePath), { recursive: true });
14381
+ await (0, import_promises2.writeFile)(filePath, content, "utf-8");
14368
14382
  } catch (err) {
14369
14383
  if (isPermissionError(err)) {
14370
14384
  process.stderr.write(
@@ -14390,7 +14404,7 @@ async function injectInfoSection(agent, content, projectRoot) {
14390
14404
  newContent = existingContent + separator + content;
14391
14405
  }
14392
14406
  try {
14393
- await (0, import_promises3.writeFile)(filePath, newContent, "utf-8");
14407
+ await (0, import_promises2.writeFile)(filePath, newContent, "utf-8");
14394
14408
  } catch (err) {
14395
14409
  if (isPermissionError(err)) {
14396
14410
  process.stderr.write(
@@ -14403,14 +14417,14 @@ async function injectInfoSection(agent, content, projectRoot) {
14403
14417
  }
14404
14418
  }
14405
14419
  async function updateGitignore(paths, projectRoot) {
14406
- const gitignorePath = (0, import_node_path3.join)(projectRoot, ".gitignore");
14407
- const relativePaths = paths.filter((p) => !(0, import_node_path3.isAbsolute)(p));
14420
+ const gitignorePath = (0, import_node_path2.join)(projectRoot, ".gitignore");
14421
+ const relativePaths = paths.filter((p) => !(0, import_node_path2.isAbsolute)(p));
14408
14422
  if (relativePaths.length === 0) {
14409
14423
  return;
14410
14424
  }
14411
14425
  let existingContent = "";
14412
14426
  try {
14413
- existingContent = await (0, import_promises3.readFile)(gitignorePath, "utf-8");
14427
+ existingContent = await (0, import_promises2.readFile)(gitignorePath, "utf-8");
14414
14428
  } catch (err) {
14415
14429
  const code = err.code;
14416
14430
  if (code !== "ENOENT") {
@@ -14436,7 +14450,7 @@ async function updateGitignore(paths, projectRoot) {
14436
14450
  }
14437
14451
  updatedContent += toAdd.join("\n") + "\n";
14438
14452
  try {
14439
- await (0, import_promises3.writeFile)(gitignorePath, updatedContent, "utf-8");
14453
+ await (0, import_promises2.writeFile)(gitignorePath, updatedContent, "utf-8");
14440
14454
  } catch (err) {
14441
14455
  if (isPermissionError(err)) {
14442
14456
  process.stderr.write(