@glasstrace/sdk 1.1.2 → 1.1.3
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-Z35HKVSO.js → chunk-FGDS33I2.js} +10 -11
- package/dist/{chunk-Z35HKVSO.js.map → chunk-FGDS33I2.js.map} +1 -1
- package/dist/{chunk-C567H5EQ.js → chunk-JKI4OCFV.js} +4 -14
- package/dist/chunk-JKI4OCFV.js.map +1 -0
- package/dist/{chunk-UJ2JC7PZ.js → chunk-TWHCJKRS.js} +17 -16
- package/dist/chunk-TWHCJKRS.js.map +1 -0
- package/dist/{chunk-3LILTM3T.js → chunk-TWTWRJ25.js} +233 -9
- package/dist/chunk-TWTWRJ25.js.map +1 -0
- package/dist/cli/init.cjs +156 -17
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +4 -4
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +1 -1
- package/dist/cli/uninit.cjs +113 -11
- package/dist/cli/uninit.cjs.map +1 -1
- package/dist/cli/uninit.js +2 -2
- package/dist/cli/validate.cjs.map +1 -1
- package/dist/cli/validate.js +1 -1
- package/dist/index.cjs +209 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +3 -3
- package/dist/node-entry.cjs +209 -27
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-3LILTM3T.js.map +0 -1
- package/dist/chunk-C567H5EQ.js.map +0 -1
- package/dist/chunk-UJ2JC7PZ.js.map +0 -1
package/dist/cli/mcp-add.js
CHANGED
package/dist/cli/uninit.cjs
CHANGED
|
@@ -52,6 +52,118 @@ var path2 = __toESM(require("node:path"), 1);
|
|
|
52
52
|
// src/cli/constants.ts
|
|
53
53
|
var NEXT_CONFIG_NAMES = ["next.config.ts", "next.config.js", "next.config.mjs"];
|
|
54
54
|
|
|
55
|
+
// src/atomic-write.ts
|
|
56
|
+
function parentDir(filePath) {
|
|
57
|
+
const lastSlash = filePath.lastIndexOf("/");
|
|
58
|
+
const lastBackslash = filePath.lastIndexOf("\\");
|
|
59
|
+
const lastSep = Math.max(lastSlash, lastBackslash);
|
|
60
|
+
if (lastSep < 0) return ".";
|
|
61
|
+
if (lastSep === 0) return filePath.slice(0, 1);
|
|
62
|
+
return filePath.slice(0, lastSep);
|
|
63
|
+
}
|
|
64
|
+
var PARENT_FSYNC_SWALLOWED_CODES = /* @__PURE__ */ new Set([
|
|
65
|
+
"EISDIR",
|
|
66
|
+
"EINVAL",
|
|
67
|
+
"EPERM",
|
|
68
|
+
"ENOTSUP"
|
|
69
|
+
]);
|
|
70
|
+
function errnoCodeOf(err) {
|
|
71
|
+
if (err === null || typeof err !== "object") return void 0;
|
|
72
|
+
const code = err.code;
|
|
73
|
+
return typeof code === "string" ? code : void 0;
|
|
74
|
+
}
|
|
75
|
+
function defaultTmpPath(targetPath) {
|
|
76
|
+
return `${targetPath}.tmp`;
|
|
77
|
+
}
|
|
78
|
+
var fsSyncCache;
|
|
79
|
+
function loadFsSync() {
|
|
80
|
+
if (fsSyncCache !== void 0) {
|
|
81
|
+
if (fsSyncCache === null) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"node:fs is unavailable in this environment; atomicWriteFileSync cannot be used here."
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return fsSyncCache;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
fsSyncCache = require("node:fs");
|
|
90
|
+
return fsSyncCache;
|
|
91
|
+
} catch {
|
|
92
|
+
fsSyncCache = null;
|
|
93
|
+
throw new Error(
|
|
94
|
+
"node:fs is unavailable in this environment; atomicWriteFileSync cannot be used here."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function atomicWriteFileSync(targetPath, payload, options = {}) {
|
|
99
|
+
atomicWriteFileSyncWithTmp(targetPath, defaultTmpPath(targetPath), payload, options);
|
|
100
|
+
}
|
|
101
|
+
function atomicWriteFileSyncWithTmp(targetPath, tmpPath, payload, options = {}) {
|
|
102
|
+
const mode = options.mode ?? 384;
|
|
103
|
+
const encoding = options.encoding ?? "utf-8";
|
|
104
|
+
const fs3 = loadFsSync();
|
|
105
|
+
let fd = null;
|
|
106
|
+
try {
|
|
107
|
+
if (typeof payload === "string") {
|
|
108
|
+
fs3.writeFileSync(tmpPath, payload, { encoding, mode });
|
|
109
|
+
} else {
|
|
110
|
+
fs3.writeFileSync(tmpPath, payload, { mode });
|
|
111
|
+
}
|
|
112
|
+
fs3.chmodSync(tmpPath, mode);
|
|
113
|
+
fd = fs3.openSync(tmpPath, "r");
|
|
114
|
+
fs3.fsyncSync(fd);
|
|
115
|
+
fs3.closeSync(fd);
|
|
116
|
+
fd = null;
|
|
117
|
+
fs3.renameSync(tmpPath, targetPath);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (fd !== null) {
|
|
120
|
+
try {
|
|
121
|
+
fs3.closeSync(fd);
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
removeTmpResidueSync(fs3, tmpPath);
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
fsyncParentDirSyncWithFs(targetPath, fs3);
|
|
129
|
+
}
|
|
130
|
+
function removeTmpResidueSync(fs3, tmpPath) {
|
|
131
|
+
try {
|
|
132
|
+
fs3.unlinkSync(tmpPath);
|
|
133
|
+
return;
|
|
134
|
+
} catch (err) {
|
|
135
|
+
const code = errnoCodeOf(err);
|
|
136
|
+
if (code !== "EISDIR" && code !== "EPERM") {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
fs3.rmdirSync(tmpPath);
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function fsyncParentDirSyncWithFs(targetPath, fs3) {
|
|
146
|
+
const parent = parentDir(targetPath);
|
|
147
|
+
let fd = null;
|
|
148
|
+
try {
|
|
149
|
+
fd = fs3.openSync(parent, "r");
|
|
150
|
+
fs3.fsyncSync(fd);
|
|
151
|
+
} catch (err) {
|
|
152
|
+
const code = errnoCodeOf(err);
|
|
153
|
+
if (code !== void 0 && PARENT_FSYNC_SWALLOWED_CODES.has(code)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
throw err;
|
|
157
|
+
} finally {
|
|
158
|
+
if (fd !== null) {
|
|
159
|
+
try {
|
|
160
|
+
fs3.closeSync(fd);
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
55
167
|
// src/mcp-runtime.ts
|
|
56
168
|
function readEnvLocalApiKey(content) {
|
|
57
169
|
let last = null;
|
|
@@ -474,21 +586,11 @@ function writeShutdownMarker(projectRoot) {
|
|
|
474
586
|
return false;
|
|
475
587
|
}
|
|
476
588
|
const markerPath = path2.join(dirPath, "shutdown-requested");
|
|
477
|
-
const tmpPath = `${markerPath}.tmp`;
|
|
478
589
|
const body = JSON.stringify({ requestedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
479
590
|
try {
|
|
480
|
-
|
|
481
|
-
try {
|
|
482
|
-
fs2.chmodSync(tmpPath, 384);
|
|
483
|
-
} catch {
|
|
484
|
-
}
|
|
485
|
-
fs2.renameSync(tmpPath, markerPath);
|
|
591
|
+
atomicWriteFileSync(markerPath, body, { encoding: "utf-8", mode: 384 });
|
|
486
592
|
return true;
|
|
487
593
|
} catch {
|
|
488
|
-
try {
|
|
489
|
-
fs2.unlinkSync(tmpPath);
|
|
490
|
-
} catch {
|
|
491
|
-
}
|
|
492
594
|
return false;
|
|
493
595
|
}
|
|
494
596
|
}
|