@techsologic/unolock-agent 0.1.37 → 0.1.38

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.
@@ -7,8 +7,8 @@ const path = require("path");
7
7
  const https = require("https");
8
8
  const { spawn } = require("child_process");
9
9
 
10
- const PACKAGE_VERSION = "0.1.37";
11
- const FALLBACK_BINARY_VERSION = "0.1.37";
10
+ const PACKAGE_VERSION = "0.1.38";
11
+ const FALLBACK_BINARY_VERSION = "0.1.38";
12
12
  const REPO = "TechSologic/unolock-agent";
13
13
  const TOP_LEVEL_USAGE = `usage: unolock-agent [-h] [--version] {register,set-agent-pin,list-spaces,get-current-space,set-current-space,list-records,list-notes,list-checklists,get-record,create-note,update-note,append-note,rename-record,create-checklist,set-checklist-item-done,add-checklist-item,remove-checklist-item,list-files,get-file,download-file,upload-file,rename-file,replace-file,delete-file,tpm-diagnose,tpm-check,self-test,mcp} ...
14
14
 
@@ -188,6 +188,23 @@ function normalizeVersion(value) {
188
188
  return trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;
189
189
  }
190
190
 
191
+ function compareVersions(left, right) {
192
+ const leftParts = String(left || "").split(".").map((part) => Number.parseInt(part, 10) || 0);
193
+ const rightParts = String(right || "").split(".").map((part) => Number.parseInt(part, 10) || 0);
194
+ const length = Math.max(leftParts.length, rightParts.length);
195
+ for (let index = 0; index < length; index += 1) {
196
+ const leftValue = leftParts[index] || 0;
197
+ const rightValue = rightParts[index] || 0;
198
+ if (leftValue > rightValue) {
199
+ return 1;
200
+ }
201
+ if (leftValue < rightValue) {
202
+ return -1;
203
+ }
204
+ }
205
+ return 0;
206
+ }
207
+
191
208
  function readReleaseMetadata() {
192
209
  try {
193
210
  return JSON.parse(fs.readFileSync(metadataPath(), "utf8"));
@@ -218,8 +235,11 @@ function cachedReleaseVersion() {
218
235
  return override;
219
236
  }
220
237
  const metadata = readReleaseMetadata();
221
- if (metadata && typeof metadata.releaseVersion === "string" && fs.existsSync(binaryPath(metadata.releaseVersion))) {
222
- return metadata.releaseVersion;
238
+ const cached = metadata && typeof metadata.releaseVersion === "string" ? normalizeVersion(metadata.releaseVersion) : null;
239
+ if (cached && fs.existsSync(binaryPath(cached))) {
240
+ if (compareVersions(cached, FALLBACK_BINARY_VERSION) >= 0) {
241
+ return cached;
242
+ }
223
243
  }
224
244
  if (fs.existsSync(binaryPath(FALLBACK_BINARY_VERSION))) {
225
245
  return FALLBACK_BINARY_VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techsologic/unolock-agent",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "npx wrapper for the official UnoLock Agent release binaries",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://unolock.ai",