@glasstrace/sdk 1.4.0 → 1.5.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/README.md +56 -0
- package/dist/{chunk-JZ475QRH.js → chunk-D3QXU2VM.js} +22 -191
- package/dist/chunk-D3QXU2VM.js.map +1 -0
- package/dist/{chunk-VQDYXXVS.js → chunk-N3XIVM2U.js} +154 -8
- package/dist/chunk-N3XIVM2U.js.map +1 -0
- package/dist/{chunk-VJQIFY33.js → chunk-YLY7AGLC.js} +7 -4
- package/dist/chunk-YLY7AGLC.js.map +1 -0
- package/dist/chunk-ZBQQXVHD.js +208 -0
- package/dist/chunk-ZBQQXVHD.js.map +1 -0
- package/dist/cli/init.cjs +206 -34
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +65 -8
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +45 -25
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +10 -7
- package/dist/cli/mcp-add.js.map +1 -1
- package/dist/cli/status.cjs +33 -3
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.js +12 -3
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/uninit.cjs +27 -3
- package/dist/cli/uninit.cjs.map +1 -1
- package/dist/cli/uninit.d.cts +10 -2
- package/dist/cli/uninit.d.ts +10 -2
- package/dist/cli/uninit.js +2 -1
- package/dist/cli/upgrade-instructions.cjs +440 -0
- package/dist/cli/upgrade-instructions.cjs.map +1 -0
- package/dist/cli/upgrade-instructions.d.cts +48 -0
- package/dist/cli/upgrade-instructions.d.ts +48 -0
- package/dist/cli/upgrade-instructions.js +80 -0
- package/dist/cli/upgrade-instructions.js.map +1 -0
- package/dist/index.cjs +229 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/node-entry.cjs +237 -68
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-JZ475QRH.js.map +0 -1
- package/dist/chunk-VJQIFY33.js.map +0 -1
- package/dist/chunk-VQDYXXVS.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -339,10 +339,10 @@ function mergeDefs(...defs) {
|
|
|
339
339
|
function cloneDef(schema) {
|
|
340
340
|
return mergeDefs(schema._zod.def);
|
|
341
341
|
}
|
|
342
|
-
function getElementAtPath(obj,
|
|
343
|
-
if (!
|
|
342
|
+
function getElementAtPath(obj, path4) {
|
|
343
|
+
if (!path4)
|
|
344
344
|
return obj;
|
|
345
|
-
return
|
|
345
|
+
return path4.reduce((acc, key) => acc?.[key], obj);
|
|
346
346
|
}
|
|
347
347
|
function promiseAllObject(promisesObj) {
|
|
348
348
|
const keys = Object.keys(promisesObj);
|
|
@@ -654,11 +654,11 @@ function aborted(x, startIndex = 0) {
|
|
|
654
654
|
}
|
|
655
655
|
return false;
|
|
656
656
|
}
|
|
657
|
-
function prefixIssues(
|
|
657
|
+
function prefixIssues(path4, issues) {
|
|
658
658
|
return issues.map((iss) => {
|
|
659
659
|
var _a2;
|
|
660
660
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
661
|
-
iss.path.unshift(
|
|
661
|
+
iss.path.unshift(path4);
|
|
662
662
|
return iss;
|
|
663
663
|
});
|
|
664
664
|
}
|
|
@@ -901,7 +901,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
901
901
|
}
|
|
902
902
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
903
903
|
const result = { errors: [] };
|
|
904
|
-
const processError = (error49,
|
|
904
|
+
const processError = (error49, path4 = []) => {
|
|
905
905
|
var _a2, _b;
|
|
906
906
|
for (const issue2 of error49.issues) {
|
|
907
907
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -911,7 +911,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
911
911
|
} else if (issue2.code === "invalid_element") {
|
|
912
912
|
processError({ issues: issue2.issues }, issue2.path);
|
|
913
913
|
} else {
|
|
914
|
-
const fullpath = [...
|
|
914
|
+
const fullpath = [...path4, ...issue2.path];
|
|
915
915
|
if (fullpath.length === 0) {
|
|
916
916
|
result.errors.push(mapper(issue2));
|
|
917
917
|
continue;
|
|
@@ -943,8 +943,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
943
943
|
}
|
|
944
944
|
function toDotPath(_path) {
|
|
945
945
|
const segs = [];
|
|
946
|
-
const
|
|
947
|
-
for (const seg of
|
|
946
|
+
const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
947
|
+
for (const seg of path4) {
|
|
948
948
|
if (typeof seg === "number")
|
|
949
949
|
segs.push(`[${seg}]`);
|
|
950
950
|
else if (typeof seg === "symbol")
|
|
@@ -13708,13 +13708,13 @@ function resolveRef(ref, ctx) {
|
|
|
13708
13708
|
if (!ref.startsWith("#")) {
|
|
13709
13709
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
13710
13710
|
}
|
|
13711
|
-
const
|
|
13712
|
-
if (
|
|
13711
|
+
const path4 = ref.slice(1).split("/").filter(Boolean);
|
|
13712
|
+
if (path4.length === 0) {
|
|
13713
13713
|
return ctx.rootSchema;
|
|
13714
13714
|
}
|
|
13715
13715
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
13716
|
-
if (
|
|
13717
|
-
const key =
|
|
13716
|
+
if (path4[0] === defsKey) {
|
|
13717
|
+
const key = path4[1];
|
|
13718
13718
|
if (!key || !ctx.defs[key]) {
|
|
13719
13719
|
throw new Error(`Reference not found: ${ref}`);
|
|
13720
13720
|
}
|
|
@@ -16521,10 +16521,10 @@ function sanitize(input) {
|
|
|
16521
16521
|
}
|
|
16522
16522
|
function markerFileExists() {
|
|
16523
16523
|
try {
|
|
16524
|
-
const
|
|
16525
|
-
const
|
|
16526
|
-
const markerPath =
|
|
16527
|
-
return
|
|
16524
|
+
const fs4 = require("node:fs");
|
|
16525
|
+
const path4 = require("node:path");
|
|
16526
|
+
const markerPath = path4.join(process.cwd(), ".glasstrace", "mcp-connected");
|
|
16527
|
+
return fs4.existsSync(markerPath);
|
|
16528
16528
|
} catch {
|
|
16529
16529
|
return false;
|
|
16530
16530
|
}
|
|
@@ -16673,7 +16673,7 @@ __export(source_map_uploader_exports, {
|
|
|
16673
16673
|
uploadToBlob: () => uploadToBlob
|
|
16674
16674
|
});
|
|
16675
16675
|
async function discoverSourceMapFiles(buildDir) {
|
|
16676
|
-
const resolvedDir =
|
|
16676
|
+
const resolvedDir = path3.resolve(buildDir);
|
|
16677
16677
|
const results = [];
|
|
16678
16678
|
try {
|
|
16679
16679
|
await walkDirMetadata(resolvedDir, resolvedDir, results);
|
|
@@ -16694,18 +16694,18 @@ async function discoverSourceMapFiles(buildDir) {
|
|
|
16694
16694
|
async function walkDirMetadata(baseDir, currentDir, results) {
|
|
16695
16695
|
let entries;
|
|
16696
16696
|
try {
|
|
16697
|
-
entries = await
|
|
16697
|
+
entries = await fs3.readdir(currentDir, { withFileTypes: true });
|
|
16698
16698
|
} catch {
|
|
16699
16699
|
return;
|
|
16700
16700
|
}
|
|
16701
16701
|
for (const entry of entries) {
|
|
16702
|
-
const fullPath =
|
|
16702
|
+
const fullPath = path3.join(currentDir, entry.name);
|
|
16703
16703
|
if (entry.isDirectory()) {
|
|
16704
16704
|
await walkDirMetadata(baseDir, fullPath, results);
|
|
16705
16705
|
} else if (entry.isFile() && entry.name.endsWith(".map")) {
|
|
16706
16706
|
try {
|
|
16707
|
-
const stat2 = await
|
|
16708
|
-
const relativePath =
|
|
16707
|
+
const stat2 = await fs3.stat(fullPath);
|
|
16708
|
+
const relativePath = path3.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
16709
16709
|
const compiledPath = relativePath.replace(/\.map$/, "");
|
|
16710
16710
|
results.push({
|
|
16711
16711
|
filePath: compiledPath,
|
|
@@ -16718,7 +16718,7 @@ async function walkDirMetadata(baseDir, currentDir, results) {
|
|
|
16718
16718
|
}
|
|
16719
16719
|
}
|
|
16720
16720
|
async function readSourceMapContent(absolutePath) {
|
|
16721
|
-
return
|
|
16721
|
+
return fs3.readFile(absolutePath, "utf-8");
|
|
16722
16722
|
}
|
|
16723
16723
|
async function collectSourceMaps(buildDir) {
|
|
16724
16724
|
const fileInfos = await discoverSourceMapFiles(buildDir);
|
|
@@ -16973,12 +16973,12 @@ async function uploadSourceMapsAuto(apiKey, endpoint, buildHash, maps, options)
|
|
|
16973
16973
|
);
|
|
16974
16974
|
return uploadSourceMaps(apiKey, endpoint, buildHash, maps);
|
|
16975
16975
|
}
|
|
16976
|
-
var
|
|
16976
|
+
var fs3, path3, crypto2, import_node_child_process, LARGE_FILE_WARNING_BYTES, PRESIGNED_THRESHOLD_BYTES, _blobClientLoader;
|
|
16977
16977
|
var init_source_map_uploader = __esm({
|
|
16978
16978
|
"src/source-map-uploader.ts"() {
|
|
16979
16979
|
"use strict";
|
|
16980
|
-
|
|
16981
|
-
|
|
16980
|
+
fs3 = __toESM(require("node:fs/promises"), 1);
|
|
16981
|
+
path3 = __toESM(require("node:path"), 1);
|
|
16982
16982
|
crypto2 = __toESM(require("node:crypto"), 1);
|
|
16983
16983
|
import_node_child_process = require("node:child_process");
|
|
16984
16984
|
init_console_capture();
|
|
@@ -17134,11 +17134,11 @@ var fsPathCache;
|
|
|
17134
17134
|
async function loadFsPath() {
|
|
17135
17135
|
if (fsPathCache !== void 0) return fsPathCache;
|
|
17136
17136
|
try {
|
|
17137
|
-
const [
|
|
17137
|
+
const [fs4, path4] = await Promise.all([
|
|
17138
17138
|
import("node:fs/promises"),
|
|
17139
17139
|
import("node:path")
|
|
17140
17140
|
]);
|
|
17141
|
-
fsPathCache = { fs:
|
|
17141
|
+
fsPathCache = { fs: fs4, path: path4 };
|
|
17142
17142
|
return fsPathCache;
|
|
17143
17143
|
} catch {
|
|
17144
17144
|
fsPathCache = null;
|
|
@@ -17659,35 +17659,35 @@ function atomicWriteFileSync(targetPath, payload, options = {}) {
|
|
|
17659
17659
|
function atomicWriteFileSyncWithTmp(targetPath, tmpPath, payload, options = {}) {
|
|
17660
17660
|
const mode = options.mode ?? 384;
|
|
17661
17661
|
const encoding = options.encoding ?? "utf-8";
|
|
17662
|
-
const
|
|
17662
|
+
const fs4 = loadFsSync();
|
|
17663
17663
|
let fd = null;
|
|
17664
17664
|
try {
|
|
17665
17665
|
if (typeof payload === "string") {
|
|
17666
|
-
|
|
17666
|
+
fs4.writeFileSync(tmpPath, payload, { encoding, mode });
|
|
17667
17667
|
} else {
|
|
17668
|
-
|
|
17668
|
+
fs4.writeFileSync(tmpPath, payload, { mode });
|
|
17669
17669
|
}
|
|
17670
|
-
|
|
17671
|
-
fd =
|
|
17672
|
-
|
|
17673
|
-
|
|
17670
|
+
fs4.chmodSync(tmpPath, mode);
|
|
17671
|
+
fd = fs4.openSync(tmpPath, "r");
|
|
17672
|
+
fs4.fsyncSync(fd);
|
|
17673
|
+
fs4.closeSync(fd);
|
|
17674
17674
|
fd = null;
|
|
17675
|
-
|
|
17675
|
+
fs4.renameSync(tmpPath, targetPath);
|
|
17676
17676
|
} catch (err) {
|
|
17677
17677
|
if (fd !== null) {
|
|
17678
17678
|
try {
|
|
17679
|
-
|
|
17679
|
+
fs4.closeSync(fd);
|
|
17680
17680
|
} catch {
|
|
17681
17681
|
}
|
|
17682
17682
|
}
|
|
17683
|
-
removeTmpResidueSync(
|
|
17683
|
+
removeTmpResidueSync(fs4, tmpPath);
|
|
17684
17684
|
throw err;
|
|
17685
17685
|
}
|
|
17686
|
-
fsyncParentDirSyncWithFs(targetPath,
|
|
17686
|
+
fsyncParentDirSyncWithFs(targetPath, fs4);
|
|
17687
17687
|
}
|
|
17688
|
-
function removeTmpResidueSync(
|
|
17688
|
+
function removeTmpResidueSync(fs4, tmpPath) {
|
|
17689
17689
|
try {
|
|
17690
|
-
|
|
17690
|
+
fs4.unlinkSync(tmpPath);
|
|
17691
17691
|
return;
|
|
17692
17692
|
} catch (err) {
|
|
17693
17693
|
const code = errnoCodeOf(err);
|
|
@@ -17696,16 +17696,16 @@ function removeTmpResidueSync(fs3, tmpPath) {
|
|
|
17696
17696
|
}
|
|
17697
17697
|
}
|
|
17698
17698
|
try {
|
|
17699
|
-
|
|
17699
|
+
fs4.rmdirSync(tmpPath);
|
|
17700
17700
|
} catch {
|
|
17701
17701
|
}
|
|
17702
17702
|
}
|
|
17703
|
-
function fsyncParentDirSyncWithFs(targetPath,
|
|
17703
|
+
function fsyncParentDirSyncWithFs(targetPath, fs4) {
|
|
17704
17704
|
const parent = parentDir(targetPath);
|
|
17705
17705
|
let fd = null;
|
|
17706
17706
|
try {
|
|
17707
|
-
fd =
|
|
17708
|
-
|
|
17707
|
+
fd = fs4.openSync(parent, "r");
|
|
17708
|
+
fs4.fsyncSync(fd);
|
|
17709
17709
|
} catch (err) {
|
|
17710
17710
|
const code = errnoCodeOf(err);
|
|
17711
17711
|
if (code !== void 0 && PARENT_FSYNC_SWALLOWED_CODES.has(code)) {
|
|
@@ -17715,7 +17715,7 @@ function fsyncParentDirSyncWithFs(targetPath, fs3) {
|
|
|
17715
17715
|
} finally {
|
|
17716
17716
|
if (fd !== null) {
|
|
17717
17717
|
try {
|
|
17718
|
-
|
|
17718
|
+
fs4.closeSync(fd);
|
|
17719
17719
|
} catch {
|
|
17720
17720
|
}
|
|
17721
17721
|
}
|
|
@@ -17736,11 +17736,11 @@ var fsPathCache2;
|
|
|
17736
17736
|
async function loadFsPath2() {
|
|
17737
17737
|
if (fsPathCache2 !== void 0) return fsPathCache2;
|
|
17738
17738
|
try {
|
|
17739
|
-
const [
|
|
17739
|
+
const [fs4, path4] = await Promise.all([
|
|
17740
17740
|
import("node:fs/promises"),
|
|
17741
17741
|
import("node:path")
|
|
17742
17742
|
]);
|
|
17743
|
-
fsPathCache2 = { fs:
|
|
17743
|
+
fsPathCache2 = { fs: fs4, path: path4 };
|
|
17744
17744
|
return fsPathCache2;
|
|
17745
17745
|
} catch {
|
|
17746
17746
|
fsPathCache2 = null;
|
|
@@ -18026,11 +18026,11 @@ var fsPathAsyncCache;
|
|
|
18026
18026
|
async function loadFsPathAsync() {
|
|
18027
18027
|
if (fsPathAsyncCache !== void 0) return fsPathAsyncCache;
|
|
18028
18028
|
try {
|
|
18029
|
-
const [
|
|
18029
|
+
const [fs4, path4] = await Promise.all([
|
|
18030
18030
|
import("node:fs/promises"),
|
|
18031
18031
|
import("node:path")
|
|
18032
18032
|
]);
|
|
18033
|
-
fsPathAsyncCache = { fs:
|
|
18033
|
+
fsPathAsyncCache = { fs: fs4, path: path4 };
|
|
18034
18034
|
return fsPathAsyncCache;
|
|
18035
18035
|
} catch {
|
|
18036
18036
|
fsPathAsyncCache = null;
|
|
@@ -18039,9 +18039,9 @@ async function loadFsPathAsync() {
|
|
|
18039
18039
|
}
|
|
18040
18040
|
function loadFsSyncOrNull() {
|
|
18041
18041
|
try {
|
|
18042
|
-
const
|
|
18043
|
-
const
|
|
18044
|
-
return { readFileSync:
|
|
18042
|
+
const fs4 = require("node:fs");
|
|
18043
|
+
const path4 = require("node:path");
|
|
18044
|
+
return { readFileSync: fs4.readFileSync, join: path4.join };
|
|
18045
18045
|
} catch {
|
|
18046
18046
|
return null;
|
|
18047
18047
|
}
|
|
@@ -20509,7 +20509,7 @@ function appendRootPathToUrlIfNeeded(url2) {
|
|
|
20509
20509
|
return void 0;
|
|
20510
20510
|
}
|
|
20511
20511
|
}
|
|
20512
|
-
function appendResourcePathToUrl(url2,
|
|
20512
|
+
function appendResourcePathToUrl(url2, path4) {
|
|
20513
20513
|
try {
|
|
20514
20514
|
new URL(url2);
|
|
20515
20515
|
} catch {
|
|
@@ -20519,11 +20519,11 @@ function appendResourcePathToUrl(url2, path3) {
|
|
|
20519
20519
|
if (!url2.endsWith("/")) {
|
|
20520
20520
|
url2 = url2 + "/";
|
|
20521
20521
|
}
|
|
20522
|
-
url2 +=
|
|
20522
|
+
url2 += path4;
|
|
20523
20523
|
try {
|
|
20524
20524
|
new URL(url2);
|
|
20525
20525
|
} catch {
|
|
20526
|
-
diag2.warn(`Configuration: Provided URL appended with '${
|
|
20526
|
+
diag2.warn(`Configuration: Provided URL appended with '${path4}' is not a valid URL, using 'undefined' instead of '${url2}'`);
|
|
20527
20527
|
return void 0;
|
|
20528
20528
|
}
|
|
20529
20529
|
return url2;
|
|
@@ -22729,6 +22729,171 @@ function writeStateNow() {
|
|
|
22729
22729
|
}
|
|
22730
22730
|
}
|
|
22731
22731
|
|
|
22732
|
+
// src/agent-detection/upgrade-notice.ts
|
|
22733
|
+
var fs2 = __toESM(require("node:fs"), 1);
|
|
22734
|
+
var path2 = __toESM(require("node:path"), 1);
|
|
22735
|
+
|
|
22736
|
+
// src/agent-detection/inject.ts
|
|
22737
|
+
var HTML_START_RE = /^<!--\s*glasstrace:mcp:start(?:\s+v=([^\s>]+))?\s*-->$/;
|
|
22738
|
+
var HTML_END = "<!-- glasstrace:mcp:end -->";
|
|
22739
|
+
var HASH_START_RE = /^#\s*glasstrace:mcp:start(?:\s+v=(\S+))?$/;
|
|
22740
|
+
var HASH_END = "# glasstrace:mcp:end";
|
|
22741
|
+
function parseStartMarkerLine(line) {
|
|
22742
|
+
const trimmed = line.trim();
|
|
22743
|
+
const html = HTML_START_RE.exec(trimmed);
|
|
22744
|
+
if (html !== null) {
|
|
22745
|
+
return { kind: "html", stamp: html[1] ?? null };
|
|
22746
|
+
}
|
|
22747
|
+
const hash2 = HASH_START_RE.exec(trimmed);
|
|
22748
|
+
if (hash2 !== null) {
|
|
22749
|
+
return { kind: "hash", stamp: hash2[1] ?? null };
|
|
22750
|
+
}
|
|
22751
|
+
return null;
|
|
22752
|
+
}
|
|
22753
|
+
function isEndMarker(line) {
|
|
22754
|
+
const trimmed = line.trim();
|
|
22755
|
+
return trimmed === HTML_END || trimmed === HASH_END;
|
|
22756
|
+
}
|
|
22757
|
+
function isEndMarkerLine(line) {
|
|
22758
|
+
return isEndMarker(line);
|
|
22759
|
+
}
|
|
22760
|
+
|
|
22761
|
+
// src/agent-detection/upgrade-notice.ts
|
|
22762
|
+
var warningEmitted = false;
|
|
22763
|
+
var AGENT_INSTRUCTION_FILES = [
|
|
22764
|
+
"CLAUDE.md",
|
|
22765
|
+
"codex.md",
|
|
22766
|
+
".cursorrules"
|
|
22767
|
+
];
|
|
22768
|
+
function parseSemver(input) {
|
|
22769
|
+
const plusIdx = input.indexOf("+");
|
|
22770
|
+
const core = plusIdx === -1 ? input : input.slice(0, plusIdx);
|
|
22771
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(core);
|
|
22772
|
+
if (m === null) return null;
|
|
22773
|
+
return {
|
|
22774
|
+
major: Number(m[1]),
|
|
22775
|
+
minor: Number(m[2]),
|
|
22776
|
+
patch: Number(m[3]),
|
|
22777
|
+
prerelease: m[4] ?? null
|
|
22778
|
+
};
|
|
22779
|
+
}
|
|
22780
|
+
function comparePrerelease(a, b) {
|
|
22781
|
+
const ap = a.split(".");
|
|
22782
|
+
const bp = b.split(".");
|
|
22783
|
+
const len = Math.min(ap.length, bp.length);
|
|
22784
|
+
for (let i = 0; i < len; i++) {
|
|
22785
|
+
const x = ap[i];
|
|
22786
|
+
const y = bp[i];
|
|
22787
|
+
const xNumeric = /^\d+$/.test(x);
|
|
22788
|
+
const yNumeric = /^\d+$/.test(y);
|
|
22789
|
+
if (xNumeric && yNumeric) {
|
|
22790
|
+
const xv = Number(x);
|
|
22791
|
+
const yv = Number(y);
|
|
22792
|
+
if (xv !== yv) return xv < yv ? -1 : 1;
|
|
22793
|
+
} else if (xNumeric) {
|
|
22794
|
+
return -1;
|
|
22795
|
+
} else if (yNumeric) {
|
|
22796
|
+
return 1;
|
|
22797
|
+
} else if (x !== y) {
|
|
22798
|
+
return x < y ? -1 : 1;
|
|
22799
|
+
}
|
|
22800
|
+
}
|
|
22801
|
+
return ap.length - bp.length;
|
|
22802
|
+
}
|
|
22803
|
+
function compareSemver(a, b) {
|
|
22804
|
+
const pa = parseSemver(a);
|
|
22805
|
+
const pb = parseSemver(b);
|
|
22806
|
+
if (pa === null || pb === null) return null;
|
|
22807
|
+
if (pa.major !== pb.major) return pa.major - pb.major;
|
|
22808
|
+
if (pa.minor !== pb.minor) return pa.minor - pb.minor;
|
|
22809
|
+
if (pa.patch !== pb.patch) return pa.patch - pb.patch;
|
|
22810
|
+
if (pa.prerelease === null && pb.prerelease === null) return 0;
|
|
22811
|
+
if (pa.prerelease === null) return 1;
|
|
22812
|
+
if (pb.prerelease === null) return -1;
|
|
22813
|
+
return comparePrerelease(pa.prerelease, pb.prerelease);
|
|
22814
|
+
}
|
|
22815
|
+
function isOptedOut() {
|
|
22816
|
+
const raw = process.env.GLASSTRACE_DISABLE_UPGRADE_NOTICE;
|
|
22817
|
+
if (typeof raw !== "string") return false;
|
|
22818
|
+
const trimmed = raw.trim().toLowerCase();
|
|
22819
|
+
return trimmed === "1" || trimmed === "true" || trimmed === "yes";
|
|
22820
|
+
}
|
|
22821
|
+
function isQuietCiContext() {
|
|
22822
|
+
const stderrIsTty = process.stderr.isTTY === true;
|
|
22823
|
+
if (stderrIsTty) return false;
|
|
22824
|
+
return process.env.CI === "true";
|
|
22825
|
+
}
|
|
22826
|
+
var MAX_AGENT_FILE_BYTES = 5 * 1024 * 1024;
|
|
22827
|
+
function inspectFile(filePath, runningSdkVersion) {
|
|
22828
|
+
let content;
|
|
22829
|
+
try {
|
|
22830
|
+
const stat2 = fs2.statSync(filePath);
|
|
22831
|
+
if (!stat2.isFile()) return "absent";
|
|
22832
|
+
if (stat2.size > MAX_AGENT_FILE_BYTES) return "absent";
|
|
22833
|
+
content = fs2.readFileSync(filePath, "utf-8");
|
|
22834
|
+
} catch {
|
|
22835
|
+
return "absent";
|
|
22836
|
+
}
|
|
22837
|
+
const lines = content.split("\n");
|
|
22838
|
+
let lastStart = null;
|
|
22839
|
+
let foundEnd = false;
|
|
22840
|
+
for (const line of lines) {
|
|
22841
|
+
const parsed = parseStartMarkerLine(line);
|
|
22842
|
+
if (parsed !== null) {
|
|
22843
|
+
lastStart = parsed;
|
|
22844
|
+
continue;
|
|
22845
|
+
}
|
|
22846
|
+
if (lastStart !== null && isEndMarkerLine(line)) {
|
|
22847
|
+
foundEnd = true;
|
|
22848
|
+
break;
|
|
22849
|
+
}
|
|
22850
|
+
}
|
|
22851
|
+
if (lastStart === null || !foundEnd) {
|
|
22852
|
+
return "no-section";
|
|
22853
|
+
}
|
|
22854
|
+
if (lastStart.stamp === null) {
|
|
22855
|
+
return "no-stamp";
|
|
22856
|
+
}
|
|
22857
|
+
const cmp = compareSemver(lastStart.stamp, runningSdkVersion);
|
|
22858
|
+
if (cmp === null) {
|
|
22859
|
+
return "unknown-stamp";
|
|
22860
|
+
}
|
|
22861
|
+
return cmp < 0 ? "stale" : "current";
|
|
22862
|
+
}
|
|
22863
|
+
function maybeWarnStaleAgentInstructions(options) {
|
|
22864
|
+
try {
|
|
22865
|
+
if (warningEmitted) return;
|
|
22866
|
+
if (typeof process === "undefined" || typeof process.versions?.node !== "string" || typeof process.env !== "object" || process.env === null) {
|
|
22867
|
+
return;
|
|
22868
|
+
}
|
|
22869
|
+
if (isOptedOut()) return;
|
|
22870
|
+
if (isQuietCiContext()) return;
|
|
22871
|
+
if (parseSemver(options.sdkVersion) === null) return;
|
|
22872
|
+
const staleFiles = [];
|
|
22873
|
+
for (const fileName of AGENT_INSTRUCTION_FILES) {
|
|
22874
|
+
const fullPath = path2.join(options.projectRoot, fileName);
|
|
22875
|
+
const state = inspectFile(fullPath, options.sdkVersion);
|
|
22876
|
+
if (state === "stale") {
|
|
22877
|
+
staleFiles.push(fileName);
|
|
22878
|
+
}
|
|
22879
|
+
}
|
|
22880
|
+
if (staleFiles.length === 0) return;
|
|
22881
|
+
const fileList = staleFiles.join(", ");
|
|
22882
|
+
const message = `[glasstrace] Glasstrace managed MCP section in ${fileList} was rendered by an older @glasstrace/sdk; run \`npx glasstrace upgrade-instructions\` to refresh (silence with GLASSTRACE_DISABLE_UPGRADE_NOTICE=1).
|
|
22883
|
+
`;
|
|
22884
|
+
warningEmitted = true;
|
|
22885
|
+
if (options.stderrWrite !== void 0) {
|
|
22886
|
+
options.stderrWrite(message);
|
|
22887
|
+
return;
|
|
22888
|
+
}
|
|
22889
|
+
try {
|
|
22890
|
+
process.stderr.write(message);
|
|
22891
|
+
} catch {
|
|
22892
|
+
}
|
|
22893
|
+
} catch {
|
|
22894
|
+
}
|
|
22895
|
+
}
|
|
22896
|
+
|
|
22732
22897
|
// src/register.ts
|
|
22733
22898
|
function maskKey(key) {
|
|
22734
22899
|
if (key.length <= 12) return key.slice(0, 4) + "...";
|
|
@@ -22757,9 +22922,13 @@ function registerGlasstrace(options) {
|
|
|
22757
22922
|
return;
|
|
22758
22923
|
}
|
|
22759
22924
|
setCoreState(CoreState.REGISTERING);
|
|
22925
|
+
maybeWarnStaleAgentInstructions({
|
|
22926
|
+
projectRoot: process.cwd(),
|
|
22927
|
+
sdkVersion: "1.5.0"
|
|
22928
|
+
});
|
|
22760
22929
|
startRuntimeStateWriter({
|
|
22761
22930
|
projectRoot: process.cwd(),
|
|
22762
|
-
sdkVersion: "1.
|
|
22931
|
+
sdkVersion: "1.5.0"
|
|
22763
22932
|
});
|
|
22764
22933
|
const config2 = resolveConfig(options);
|
|
22765
22934
|
if (config2.verbose) {
|
|
@@ -22926,8 +23095,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22926
23095
|
if (config2.verbose) {
|
|
22927
23096
|
console.info("[glasstrace] Background init firing.");
|
|
22928
23097
|
}
|
|
22929
|
-
const healthReport = collectHealthReport("1.
|
|
22930
|
-
const initResult = await performInit(config2, anonKeyForInit, "1.
|
|
23098
|
+
const healthReport = collectHealthReport("1.5.0");
|
|
23099
|
+
const initResult = await performInit(config2, anonKeyForInit, "1.5.0", healthReport);
|
|
22931
23100
|
if (generation !== registrationGeneration) return;
|
|
22932
23101
|
const currentState = getCoreState();
|
|
22933
23102
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -22950,7 +23119,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22950
23119
|
}
|
|
22951
23120
|
maybeInstallConsoleCapture();
|
|
22952
23121
|
if (didLastInitSucceed()) {
|
|
22953
|
-
startHeartbeat(config2, anonKeyForInit, "1.
|
|
23122
|
+
startHeartbeat(config2, anonKeyForInit, "1.5.0", generation, (newApiKey, accountId) => {
|
|
22954
23123
|
setAuthState(AuthState.CLAIMING);
|
|
22955
23124
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
22956
23125
|
setResolvedApiKey(newApiKey);
|