@techsologic/unolock-agent 0.1.32 → 0.1.33
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/bin/unolock-agent.js +65 -7
- package/package.json +1 -1
package/bin/unolock-agent.js
CHANGED
|
@@ -7,9 +7,48 @@ 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.
|
|
11
|
-
const FALLBACK_BINARY_VERSION = "0.1.
|
|
10
|
+
const PACKAGE_VERSION = "0.1.33";
|
|
11
|
+
const FALLBACK_BINARY_VERSION = "0.1.33";
|
|
12
12
|
const REPO = "TechSologic/unolock-agent";
|
|
13
|
+
const TOP_LEVEL_USAGE = `usage: unolock-agent [-h] [--version] {link-agent-key,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
|
+
|
|
15
|
+
UnoLock Agent commands.
|
|
16
|
+
|
|
17
|
+
positional arguments:
|
|
18
|
+
link-agent-key Link a one-time UnoLock Agent Key URL and PIN to this device.
|
|
19
|
+
set-agent-pin Set the in-memory UnoLock agent PIN.
|
|
20
|
+
list-spaces List accessible UnoLock spaces.
|
|
21
|
+
get-current-space Show the current UnoLock space.
|
|
22
|
+
set-current-space Set the current UnoLock space.
|
|
23
|
+
list-records List notes and checklists in the current space.
|
|
24
|
+
list-notes List notes in the current space.
|
|
25
|
+
list-checklists List checklists in the current space.
|
|
26
|
+
get-record Get one note or checklist by record_ref.
|
|
27
|
+
create-note Create a note in the current space.
|
|
28
|
+
update-note Update an existing note.
|
|
29
|
+
append-note Append text to an existing note.
|
|
30
|
+
rename-record Rename a note or checklist.
|
|
31
|
+
create-checklist Create a checklist in the current space.
|
|
32
|
+
set-checklist-item-done
|
|
33
|
+
Set one checklist item's done state.
|
|
34
|
+
add-checklist-item Add an item to a checklist.
|
|
35
|
+
remove-checklist-item Remove an item from a checklist.
|
|
36
|
+
list-files List Cloud files in the current space.
|
|
37
|
+
get-file Get metadata for one Cloud file.
|
|
38
|
+
download-file Download a Cloud file to the local filesystem.
|
|
39
|
+
upload-file Upload a local file into the current space.
|
|
40
|
+
rename-file Rename a Cloud file.
|
|
41
|
+
replace-file Replace a Cloud file with local content.
|
|
42
|
+
delete-file Delete a Cloud file.
|
|
43
|
+
tpm-diagnose Diagnose TPM/vTPM readiness for the UnoLock agent MCP.
|
|
44
|
+
tpm-check Fail-fast check for production-ready TPM/vTPM/platform-backed key access.
|
|
45
|
+
self-test Run a one-shot UnoLock Agent readiness check.
|
|
46
|
+
mcp Run the UnoLock stdio MCP server.
|
|
47
|
+
|
|
48
|
+
options:
|
|
49
|
+
-h, --help show this help message and exit
|
|
50
|
+
--version show program's version number and exit
|
|
51
|
+
`;
|
|
13
52
|
|
|
14
53
|
function platformAssetInfo() {
|
|
15
54
|
const platform = process.platform;
|
|
@@ -173,12 +212,26 @@ function writeReleaseMetadata(releaseVersion) {
|
|
|
173
212
|
);
|
|
174
213
|
}
|
|
175
214
|
|
|
176
|
-
|
|
215
|
+
function cachedReleaseVersion() {
|
|
177
216
|
const override = normalizeVersion(process.env.UNOLOCK_AGENT_BINARY_VERSION);
|
|
178
217
|
if (override) {
|
|
179
218
|
return override;
|
|
180
219
|
}
|
|
181
220
|
const metadata = readReleaseMetadata();
|
|
221
|
+
if (metadata && typeof metadata.releaseVersion === "string" && fs.existsSync(binaryPath(metadata.releaseVersion))) {
|
|
222
|
+
return metadata.releaseVersion;
|
|
223
|
+
}
|
|
224
|
+
if (fs.existsSync(binaryPath(FALLBACK_BINARY_VERSION))) {
|
|
225
|
+
return FALLBACK_BINARY_VERSION;
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async function resolveReleaseVersion() {
|
|
231
|
+
const cached = cachedReleaseVersion();
|
|
232
|
+
if (cached) {
|
|
233
|
+
return cached;
|
|
234
|
+
}
|
|
182
235
|
try {
|
|
183
236
|
const payload = await fetchJson(`https://api.github.com/repos/${REPO}/releases/latest`);
|
|
184
237
|
const latest = normalizeVersion(payload && payload.tag_name);
|
|
@@ -187,9 +240,6 @@ async function resolveReleaseVersion() {
|
|
|
187
240
|
return latest;
|
|
188
241
|
}
|
|
189
242
|
} catch (error) {
|
|
190
|
-
if (metadata && typeof metadata.releaseVersion === "string" && fs.existsSync(binaryPath(metadata.releaseVersion))) {
|
|
191
|
-
return metadata.releaseVersion;
|
|
192
|
-
}
|
|
193
243
|
process.stderr.write(`Warning: ${error.message}. Falling back to bundled release ${FALLBACK_BINARY_VERSION}.\n`);
|
|
194
244
|
}
|
|
195
245
|
writeReleaseMetadata(FALLBACK_BINARY_VERSION);
|
|
@@ -209,8 +259,16 @@ async function ensureBinary() {
|
|
|
209
259
|
}
|
|
210
260
|
|
|
211
261
|
async function main() {
|
|
212
|
-
const { dest, releaseVersion } = await ensureBinary();
|
|
213
262
|
const forwardedArgs = process.argv.length > 2 ? process.argv.slice(2) : [];
|
|
263
|
+
if (forwardedArgs.length === 0 || forwardedArgs[0] === "-h" || forwardedArgs[0] === "--help") {
|
|
264
|
+
process.stdout.write(TOP_LEVEL_USAGE);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (forwardedArgs[0] === "--version") {
|
|
268
|
+
process.stdout.write(`${PACKAGE_VERSION}\n`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const { dest, releaseVersion } = await ensureBinary();
|
|
214
272
|
const child = spawn(dest, forwardedArgs, {
|
|
215
273
|
stdio: "inherit",
|
|
216
274
|
env: {
|