@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.
- package/dist/adapters/drizzle.js +1 -1
- package/dist/{chunk-ZRNG36LU.js → chunk-6GRNJ722.js} +38 -17
- package/dist/chunk-6GRNJ722.js.map +1 -0
- package/dist/chunk-IPGOKORJ.js +580 -0
- package/dist/chunk-IPGOKORJ.js.map +1 -0
- package/dist/{chunk-5MAHIPFH.js → chunk-LW7DPKBA.js} +2 -2
- package/dist/{chunk-KOYJ2UQE.js → chunk-MSMOH6IH.js} +108 -38
- package/dist/chunk-MSMOH6IH.js.map +1 -0
- package/dist/chunk-NSBPE2FW.js +17 -0
- package/dist/{chunk-O3Y45VGV.js → chunk-OKIP4SRG.js} +5 -3
- package/dist/{chunk-O3Y45VGV.js.map → chunk-OKIP4SRG.js.map} +1 -1
- package/dist/cli/init.cjs +457 -330
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +25 -1
- package/dist/cli/init.d.ts +25 -1
- package/dist/cli/init.js +114 -4
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +63 -47
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +3 -3
- package/dist/cli/uninit.js +15 -564
- package/dist/cli/uninit.js.map +1 -1
- package/dist/{esm-POMEQPKL.js → esm-KBPHCVB4.js} +2 -2
- package/dist/{getMachineId-bsd-TC3JSTY5.js → getMachineId-bsd-345PYXFX.js} +2 -2
- package/dist/{getMachineId-darwin-2SUKQCE6.js → getMachineId-darwin-5L2D25AD.js} +2 -2
- package/dist/{getMachineId-linux-PNAFHLXH.js → getMachineId-linux-KJR4P5HN.js} +2 -2
- package/dist/{getMachineId-unsupported-L2MNYW3W.js → getMachineId-unsupported-NDNXDYDY.js} +2 -2
- package/dist/{getMachineId-win-D6D42WOQ.js → getMachineId-win-T7PJNJXG.js} +2 -2
- package/dist/index.cjs +327 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -11
- package/dist/index.d.ts +75 -11
- package/dist/index.js +159 -82
- package/dist/index.js.map +1 -1
- package/dist/{source-map-uploader-OA5NCDOK.js → source-map-uploader-ZFCYOURS.js} +6 -4
- package/package.json +1 -1
- package/dist/chunk-KOYJ2UQE.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-ZRNG36LU.js.map +0 -1
- /package/dist/{chunk-5MAHIPFH.js.map → chunk-LW7DPKBA.js.map} +0 -0
- /package/dist/{chunk-PZ5AY32C.js.map → chunk-NSBPE2FW.js.map} +0 -0
- /package/dist/{esm-POMEQPKL.js.map → esm-KBPHCVB4.js.map} +0 -0
- /package/dist/{getMachineId-bsd-TC3JSTY5.js.map → getMachineId-bsd-345PYXFX.js.map} +0 -0
- /package/dist/{getMachineId-darwin-2SUKQCE6.js.map → getMachineId-darwin-5L2D25AD.js.map} +0 -0
- /package/dist/{getMachineId-linux-PNAFHLXH.js.map → getMachineId-linux-KJR4P5HN.js.map} +0 -0
- /package/dist/{getMachineId-unsupported-L2MNYW3W.js.map → getMachineId-unsupported-NDNXDYDY.js.map} +0 -0
- /package/dist/{getMachineId-win-D6D42WOQ.js.map → getMachineId-win-T7PJNJXG.js.map} +0 -0
- /package/dist/{source-map-uploader-OA5NCDOK.js.map → source-map-uploader-ZFCYOURS.js.map} +0 -0
package/dist/cli/mcp-add.cjs
CHANGED
|
@@ -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, {
|
|
@@ -13885,7 +13881,9 @@ var SdkInitResponseSchema = external_exports.object({
|
|
|
13885
13881
|
});
|
|
13886
13882
|
var DiscoveryResponseSchema = external_exports.object({
|
|
13887
13883
|
key: AnonApiKeySchema,
|
|
13888
|
-
sessionId: SessionIdSchema
|
|
13884
|
+
sessionId: SessionIdSchema,
|
|
13885
|
+
claimed: external_exports.boolean().optional(),
|
|
13886
|
+
accountHint: external_exports.string().optional()
|
|
13889
13887
|
});
|
|
13890
13888
|
var SourceMapUploadResponseSchema = external_exports.object({
|
|
13891
13889
|
success: external_exports.literal(true),
|
|
@@ -13936,17 +13934,35 @@ var SourceMapManifestResponseSchema = external_exports.object({
|
|
|
13936
13934
|
// src/anon-key.ts
|
|
13937
13935
|
var GLASSTRACE_DIR = ".glasstrace";
|
|
13938
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
|
+
}
|
|
13939
13952
|
var ephemeralKeyCache = /* @__PURE__ */ new Map();
|
|
13940
13953
|
async function readAnonKey(projectRoot) {
|
|
13941
13954
|
const root = projectRoot ?? process.cwd();
|
|
13942
|
-
const
|
|
13943
|
-
|
|
13944
|
-
const
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
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 {
|
|
13948
13965
|
}
|
|
13949
|
-
} catch {
|
|
13950
13966
|
}
|
|
13951
13967
|
const cached2 = ephemeralKeyCache.get(root);
|
|
13952
13968
|
if (cached2 !== void 0) {
|
|
@@ -13957,31 +13973,31 @@ async function readAnonKey(projectRoot) {
|
|
|
13957
13973
|
|
|
13958
13974
|
// src/agent-detection/detect.ts
|
|
13959
13975
|
var import_node_child_process = require("child_process");
|
|
13960
|
-
var
|
|
13961
|
-
var
|
|
13976
|
+
var import_promises = require("fs/promises");
|
|
13977
|
+
var import_node_path = require("path");
|
|
13962
13978
|
var import_node_os = require("os");
|
|
13963
13979
|
var import_node_fs = require("fs");
|
|
13964
13980
|
var AGENT_RULES = [
|
|
13965
13981
|
{
|
|
13966
13982
|
name: "claude",
|
|
13967
13983
|
markers: [".claude", "CLAUDE.md"],
|
|
13968
|
-
mcpConfigPath: (dir) => (0,
|
|
13969
|
-
infoFilePath: (dir) => (0,
|
|
13984
|
+
mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".mcp.json"),
|
|
13985
|
+
infoFilePath: (dir) => (0, import_node_path.join)(dir, "CLAUDE.md"),
|
|
13970
13986
|
cliBinary: "claude",
|
|
13971
13987
|
registrationCommand: "npx glasstrace mcp add --agent claude"
|
|
13972
13988
|
},
|
|
13973
13989
|
{
|
|
13974
13990
|
name: "codex",
|
|
13975
13991
|
markers: ["codex.md", ".codex"],
|
|
13976
|
-
mcpConfigPath: (dir) => (0,
|
|
13977
|
-
infoFilePath: (dir) => (0,
|
|
13992
|
+
mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".codex", "config.toml"),
|
|
13993
|
+
infoFilePath: (dir) => (0, import_node_path.join)(dir, "codex.md"),
|
|
13978
13994
|
cliBinary: "codex",
|
|
13979
13995
|
registrationCommand: "npx glasstrace mcp add --agent codex"
|
|
13980
13996
|
},
|
|
13981
13997
|
{
|
|
13982
13998
|
name: "gemini",
|
|
13983
13999
|
markers: [".gemini"],
|
|
13984
|
-
mcpConfigPath: (dir) => (0,
|
|
14000
|
+
mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".gemini", "settings.json"),
|
|
13985
14001
|
infoFilePath: () => null,
|
|
13986
14002
|
cliBinary: "gemini",
|
|
13987
14003
|
registrationCommand: "npx glasstrace mcp add --agent gemini"
|
|
@@ -13989,41 +14005,41 @@ var AGENT_RULES = [
|
|
|
13989
14005
|
{
|
|
13990
14006
|
name: "cursor",
|
|
13991
14007
|
markers: [".cursor", ".cursorrules"],
|
|
13992
|
-
mcpConfigPath: (dir) => (0,
|
|
13993
|
-
infoFilePath: (dir) => (0,
|
|
14008
|
+
mcpConfigPath: (dir) => (0, import_node_path.join)(dir, ".cursor", "mcp.json"),
|
|
14009
|
+
infoFilePath: (dir) => (0, import_node_path.join)(dir, ".cursorrules"),
|
|
13994
14010
|
cliBinary: null,
|
|
13995
14011
|
registrationCommand: "npx glasstrace mcp add --agent cursor"
|
|
13996
14012
|
},
|
|
13997
14013
|
{
|
|
13998
14014
|
name: "windsurf",
|
|
13999
14015
|
markers: [".windsurfrules", ".windsurf"],
|
|
14000
|
-
mcpConfigPath: () => (0,
|
|
14001
|
-
infoFilePath: (dir) => (0,
|
|
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"),
|
|
14002
14018
|
cliBinary: null,
|
|
14003
14019
|
registrationCommand: "npx glasstrace mcp add --agent windsurf"
|
|
14004
14020
|
}
|
|
14005
14021
|
];
|
|
14006
14022
|
async function pathExists(path3, mode = import_node_fs.constants.R_OK) {
|
|
14007
14023
|
try {
|
|
14008
|
-
await (0,
|
|
14024
|
+
await (0, import_promises.access)(path3, mode);
|
|
14009
14025
|
return true;
|
|
14010
14026
|
} catch {
|
|
14011
14027
|
return false;
|
|
14012
14028
|
}
|
|
14013
14029
|
}
|
|
14014
14030
|
async function findGitRoot(startDir) {
|
|
14015
|
-
let current = (0,
|
|
14031
|
+
let current = (0, import_node_path.resolve)(startDir);
|
|
14016
14032
|
while (true) {
|
|
14017
|
-
if (await pathExists((0,
|
|
14033
|
+
if (await pathExists((0, import_node_path.join)(current, ".git"), import_node_fs.constants.F_OK)) {
|
|
14018
14034
|
return current;
|
|
14019
14035
|
}
|
|
14020
|
-
const parent = (0,
|
|
14036
|
+
const parent = (0, import_node_path.dirname)(current);
|
|
14021
14037
|
if (parent === current) {
|
|
14022
14038
|
break;
|
|
14023
14039
|
}
|
|
14024
14040
|
current = parent;
|
|
14025
14041
|
}
|
|
14026
|
-
return (0,
|
|
14042
|
+
return (0, import_node_path.resolve)(startDir);
|
|
14027
14043
|
}
|
|
14028
14044
|
function isCliAvailable(binary) {
|
|
14029
14045
|
return new Promise((resolve2) => {
|
|
@@ -14034,10 +14050,10 @@ function isCliAvailable(binary) {
|
|
|
14034
14050
|
});
|
|
14035
14051
|
}
|
|
14036
14052
|
async function detectAgents(projectRoot) {
|
|
14037
|
-
const resolvedRoot = (0,
|
|
14053
|
+
const resolvedRoot = (0, import_node_path.resolve)(projectRoot);
|
|
14038
14054
|
let rootStat;
|
|
14039
14055
|
try {
|
|
14040
|
-
rootStat = await (0,
|
|
14056
|
+
rootStat = await (0, import_promises.stat)(resolvedRoot);
|
|
14041
14057
|
} catch (err) {
|
|
14042
14058
|
const code = err.code;
|
|
14043
14059
|
throw new Error(
|
|
@@ -14055,7 +14071,7 @@ async function detectAgents(projectRoot) {
|
|
|
14055
14071
|
if (current === gitRoot) {
|
|
14056
14072
|
break;
|
|
14057
14073
|
}
|
|
14058
|
-
const parent = (0,
|
|
14074
|
+
const parent = (0, import_node_path.dirname)(current);
|
|
14059
14075
|
if (parent === current) {
|
|
14060
14076
|
break;
|
|
14061
14077
|
}
|
|
@@ -14068,7 +14084,7 @@ async function detectAgents(projectRoot) {
|
|
|
14068
14084
|
for (const dir of searchDirs) {
|
|
14069
14085
|
let markerFound = false;
|
|
14070
14086
|
for (const marker of rule.markers) {
|
|
14071
|
-
if (await pathExists((0,
|
|
14087
|
+
if (await pathExists((0, import_node_path.join)(dir, marker))) {
|
|
14072
14088
|
markerFound = true;
|
|
14073
14089
|
break;
|
|
14074
14090
|
}
|
|
@@ -14100,7 +14116,7 @@ async function detectAgents(projectRoot) {
|
|
|
14100
14116
|
}
|
|
14101
14117
|
detected.push({
|
|
14102
14118
|
name: "generic",
|
|
14103
|
-
mcpConfigPath: (0,
|
|
14119
|
+
mcpConfigPath: (0, import_node_path.join)(resolvedRoot, ".glasstrace", "mcp.json"),
|
|
14104
14120
|
infoFilePath: null,
|
|
14105
14121
|
cliAvailable: false,
|
|
14106
14122
|
registrationCommand: null
|
|
@@ -14271,8 +14287,8 @@ ${content}${m.end}
|
|
|
14271
14287
|
}
|
|
14272
14288
|
|
|
14273
14289
|
// src/agent-detection/inject.ts
|
|
14274
|
-
var
|
|
14275
|
-
var
|
|
14290
|
+
var import_promises2 = require("fs/promises");
|
|
14291
|
+
var import_node_path2 = require("path");
|
|
14276
14292
|
var HTML_START = "<!-- glasstrace:mcp:start -->";
|
|
14277
14293
|
var HTML_END = "<!-- glasstrace:mcp:end -->";
|
|
14278
14294
|
var HASH_START = "# glasstrace:mcp:start";
|
|
@@ -14286,9 +14302,9 @@ async function writeMcpConfig(agent, content, projectRoot) {
|
|
|
14286
14302
|
return;
|
|
14287
14303
|
}
|
|
14288
14304
|
const configPath = agent.mcpConfigPath;
|
|
14289
|
-
const parentDir = (0,
|
|
14305
|
+
const parentDir = (0, import_node_path2.dirname)(configPath);
|
|
14290
14306
|
try {
|
|
14291
|
-
await (0,
|
|
14307
|
+
await (0, import_promises2.mkdir)(parentDir, { recursive: true });
|
|
14292
14308
|
} catch (err) {
|
|
14293
14309
|
if (isPermissionError(err)) {
|
|
14294
14310
|
process.stderr.write(
|
|
@@ -14300,7 +14316,7 @@ async function writeMcpConfig(agent, content, projectRoot) {
|
|
|
14300
14316
|
throw err;
|
|
14301
14317
|
}
|
|
14302
14318
|
try {
|
|
14303
|
-
await (0,
|
|
14319
|
+
await (0, import_promises2.writeFile)(configPath, content, { mode: 384 });
|
|
14304
14320
|
} catch (err) {
|
|
14305
14321
|
if (isPermissionError(err)) {
|
|
14306
14322
|
process.stderr.write(
|
|
@@ -14312,7 +14328,7 @@ async function writeMcpConfig(agent, content, projectRoot) {
|
|
|
14312
14328
|
throw err;
|
|
14313
14329
|
}
|
|
14314
14330
|
try {
|
|
14315
|
-
await (0,
|
|
14331
|
+
await (0, import_promises2.chmod)(configPath, 384);
|
|
14316
14332
|
} catch {
|
|
14317
14333
|
}
|
|
14318
14334
|
}
|
|
@@ -14345,7 +14361,7 @@ async function injectInfoSection(agent, content, projectRoot) {
|
|
|
14345
14361
|
const filePath = agent.infoFilePath;
|
|
14346
14362
|
let existingContent = null;
|
|
14347
14363
|
try {
|
|
14348
|
-
existingContent = await (0,
|
|
14364
|
+
existingContent = await (0, import_promises2.readFile)(filePath, "utf-8");
|
|
14349
14365
|
} catch (err) {
|
|
14350
14366
|
const code = err.code;
|
|
14351
14367
|
if (code !== "ENOENT") {
|
|
@@ -14361,8 +14377,8 @@ async function injectInfoSection(agent, content, projectRoot) {
|
|
|
14361
14377
|
}
|
|
14362
14378
|
if (existingContent === null) {
|
|
14363
14379
|
try {
|
|
14364
|
-
await (0,
|
|
14365
|
-
await (0,
|
|
14380
|
+
await (0, import_promises2.mkdir)((0, import_node_path2.dirname)(filePath), { recursive: true });
|
|
14381
|
+
await (0, import_promises2.writeFile)(filePath, content, "utf-8");
|
|
14366
14382
|
} catch (err) {
|
|
14367
14383
|
if (isPermissionError(err)) {
|
|
14368
14384
|
process.stderr.write(
|
|
@@ -14388,7 +14404,7 @@ async function injectInfoSection(agent, content, projectRoot) {
|
|
|
14388
14404
|
newContent = existingContent + separator + content;
|
|
14389
14405
|
}
|
|
14390
14406
|
try {
|
|
14391
|
-
await (0,
|
|
14407
|
+
await (0, import_promises2.writeFile)(filePath, newContent, "utf-8");
|
|
14392
14408
|
} catch (err) {
|
|
14393
14409
|
if (isPermissionError(err)) {
|
|
14394
14410
|
process.stderr.write(
|
|
@@ -14401,14 +14417,14 @@ async function injectInfoSection(agent, content, projectRoot) {
|
|
|
14401
14417
|
}
|
|
14402
14418
|
}
|
|
14403
14419
|
async function updateGitignore(paths, projectRoot) {
|
|
14404
|
-
const gitignorePath = (0,
|
|
14405
|
-
const relativePaths = paths.filter((p) => !(0,
|
|
14420
|
+
const gitignorePath = (0, import_node_path2.join)(projectRoot, ".gitignore");
|
|
14421
|
+
const relativePaths = paths.filter((p) => !(0, import_node_path2.isAbsolute)(p));
|
|
14406
14422
|
if (relativePaths.length === 0) {
|
|
14407
14423
|
return;
|
|
14408
14424
|
}
|
|
14409
14425
|
let existingContent = "";
|
|
14410
14426
|
try {
|
|
14411
|
-
existingContent = await (0,
|
|
14427
|
+
existingContent = await (0, import_promises2.readFile)(gitignorePath, "utf-8");
|
|
14412
14428
|
} catch (err) {
|
|
14413
14429
|
const code = err.code;
|
|
14414
14430
|
if (code !== "ENOENT") {
|
|
@@ -14434,7 +14450,7 @@ async function updateGitignore(paths, projectRoot) {
|
|
|
14434
14450
|
}
|
|
14435
14451
|
updatedContent += toAdd.join("\n") + "\n";
|
|
14436
14452
|
try {
|
|
14437
|
-
await (0,
|
|
14453
|
+
await (0, import_promises2.writeFile)(gitignorePath, updatedContent, "utf-8");
|
|
14438
14454
|
} catch (err) {
|
|
14439
14455
|
if (isPermissionError(err)) {
|
|
14440
14456
|
process.stderr.write(
|