@agentlayer.tech/wallet 0.1.20 → 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.
|
@@ -53,6 +53,21 @@ by updates. The update command fetches the latest published npm package and
|
|
|
53
53
|
reuses shared dependency snapshots when possible.`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function primaryBinCommand(pkg = packageJson) {
|
|
57
|
+
const bin = pkg?.bin;
|
|
58
|
+
if (!bin) return "wallet";
|
|
59
|
+
if (typeof bin === "string") {
|
|
60
|
+
const packageName = String(pkg?.name || "").trim();
|
|
61
|
+
if (packageName) {
|
|
62
|
+
const parts = packageName.split("/");
|
|
63
|
+
return parts[parts.length - 1] || "wallet";
|
|
64
|
+
}
|
|
65
|
+
return "wallet";
|
|
66
|
+
}
|
|
67
|
+
const names = Object.keys(bin);
|
|
68
|
+
return names[0] || "wallet";
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
function expandHome(value) {
|
|
57
72
|
if (!value) return value;
|
|
58
73
|
if (value === "~") return os.homedir();
|
|
@@ -211,6 +226,62 @@ function activeVersion(env = process.env) {
|
|
|
211
226
|
return path.basename(path.resolve(path.dirname(current), link));
|
|
212
227
|
}
|
|
213
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
|
+
|
|
214
285
|
function listDirectories(rootPath) {
|
|
215
286
|
try {
|
|
216
287
|
return fs
|
|
@@ -650,6 +721,7 @@ function runInstall(args, { commandName = "install" } = {}) {
|
|
|
650
721
|
const currentPath = currentRuntimePath();
|
|
651
722
|
const previousPath = previousRuntimePath();
|
|
652
723
|
const installerArgs = withoutCliOnlyArgs(args);
|
|
724
|
+
const dryRun = hasFlag(args, "--dry-run");
|
|
653
725
|
|
|
654
726
|
if (!hasFlag(installerArgs, "--runtime-root")) {
|
|
655
727
|
installerArgs.push("--runtime-root", releaseRoot);
|
|
@@ -680,9 +752,13 @@ function runInstall(args, { commandName = "install" } = {}) {
|
|
|
680
752
|
return result.status ?? 1;
|
|
681
753
|
}
|
|
682
754
|
|
|
683
|
-
|
|
755
|
+
if (dryRun) {
|
|
756
|
+
return 0;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const currentTarget = existingRuntimePointerTarget(currentPath);
|
|
684
760
|
if (currentTarget) {
|
|
685
|
-
switchSymlink(previousPath,
|
|
761
|
+
switchSymlink(previousPath, currentTarget);
|
|
686
762
|
}
|
|
687
763
|
switchSymlink(currentPath, releaseRoot);
|
|
688
764
|
|
|
@@ -748,9 +824,10 @@ function runDelegatedInstallForUpdate(args, { captureOutput = false } = {}) {
|
|
|
748
824
|
}
|
|
749
825
|
|
|
750
826
|
const packageSpec = resolveUpdatePackageSpec();
|
|
827
|
+
const binCommand = primaryBinCommand();
|
|
751
828
|
const result = spawnSync(
|
|
752
829
|
npmBin,
|
|
753
|
-
["exec", "--yes", `--package=${packageSpec}`, "
|
|
830
|
+
["exec", "--yes", `--package=${packageSpec}`, binCommand, "--", "install", ...args],
|
|
754
831
|
{
|
|
755
832
|
cwd: packageRoot,
|
|
756
833
|
stdio: captureOutput ? "pipe" : "inherit",
|