@agentlayer.tech/wallet 0.1.21 → 0.1.22
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.
|
@@ -226,6 +226,62 @@ function activeVersion(env = process.env) {
|
|
|
226
226
|
return path.basename(path.resolve(path.dirname(current), link));
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
function detectRuntimeVersion(runtimeRoot) {
|
|
230
|
+
try {
|
|
231
|
+
const packageJsonText = fs.readFileSync(path.join(runtimeRoot, "package.json"), "utf8");
|
|
232
|
+
const pkg = JSON.parse(packageJsonText);
|
|
233
|
+
return String(pkg.version || "").trim() || null;
|
|
234
|
+
} catch {
|
|
235
|
+
// ignored
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
const pyprojectText = fs.readFileSync(path.join(runtimeRoot, "agent-wallet", "pyproject.toml"), "utf8");
|
|
239
|
+
const match = pyprojectText.match(/^version = "([^"]+)"/m);
|
|
240
|
+
return match?.[1] || null;
|
|
241
|
+
} catch {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function uniquePathWithSuffix(targetPath) {
|
|
247
|
+
if (!fs.existsSync(targetPath)) return targetPath;
|
|
248
|
+
let counter = 2;
|
|
249
|
+
while (true) {
|
|
250
|
+
const candidate = `${targetPath}-${counter}`;
|
|
251
|
+
if (!fs.existsSync(candidate)) return candidate;
|
|
252
|
+
counter += 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function migrateDirectoryRuntimePointer(linkPath) {
|
|
257
|
+
const stat = fs.lstatSync(linkPath);
|
|
258
|
+
if (!stat.isDirectory()) return null;
|
|
259
|
+
const runtimeBase = path.dirname(linkPath);
|
|
260
|
+
const releasesDir = path.join(runtimeBase, "releases");
|
|
261
|
+
fs.mkdirSync(releasesDir, { recursive: true });
|
|
262
|
+
const detectedVersion = detectRuntimeVersion(linkPath);
|
|
263
|
+
const baseName = detectedVersion ? `${detectedVersion}-migrated` : `legacy-current-${Date.now()}`;
|
|
264
|
+
const destination = uniquePathWithSuffix(path.join(releasesDir, baseName));
|
|
265
|
+
fs.renameSync(linkPath, destination);
|
|
266
|
+
return destination;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function existingRuntimePointerTarget(linkPath) {
|
|
270
|
+
const link = readLinkOrNull(linkPath);
|
|
271
|
+
if (link) {
|
|
272
|
+
return path.resolve(path.dirname(linkPath), link);
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const stat = fs.lstatSync(linkPath);
|
|
276
|
+
if (stat.isDirectory()) {
|
|
277
|
+
return migrateDirectoryRuntimePointer(linkPath);
|
|
278
|
+
}
|
|
279
|
+
} catch (error) {
|
|
280
|
+
if (error?.code !== "ENOENT") throw error;
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
229
285
|
function listDirectories(rootPath) {
|
|
230
286
|
try {
|
|
231
287
|
return fs
|
|
@@ -665,6 +721,7 @@ function runInstall(args, { commandName = "install" } = {}) {
|
|
|
665
721
|
const currentPath = currentRuntimePath();
|
|
666
722
|
const previousPath = previousRuntimePath();
|
|
667
723
|
const installerArgs = withoutCliOnlyArgs(args);
|
|
724
|
+
const dryRun = hasFlag(args, "--dry-run");
|
|
668
725
|
|
|
669
726
|
if (!hasFlag(installerArgs, "--runtime-root")) {
|
|
670
727
|
installerArgs.push("--runtime-root", releaseRoot);
|
|
@@ -695,9 +752,13 @@ function runInstall(args, { commandName = "install" } = {}) {
|
|
|
695
752
|
return result.status ?? 1;
|
|
696
753
|
}
|
|
697
754
|
|
|
698
|
-
|
|
755
|
+
if (dryRun) {
|
|
756
|
+
return 0;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const currentTarget = existingRuntimePointerTarget(currentPath);
|
|
699
760
|
if (currentTarget) {
|
|
700
|
-
switchSymlink(previousPath,
|
|
761
|
+
switchSymlink(previousPath, currentTarget);
|
|
701
762
|
}
|
|
702
763
|
switchSymlink(currentPath, releaseRoot);
|
|
703
764
|
|