agendex-cli 0.10.0 → 0.11.0
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/cli.js +64 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2721,6 +2721,12 @@ function isRunning(pid) {
|
|
|
2721
2721
|
}
|
|
2722
2722
|
|
|
2723
2723
|
// src/api.ts
|
|
2724
|
+
class AuthExpiredError extends Error {
|
|
2725
|
+
constructor() {
|
|
2726
|
+
super("Cloud token expired. Run `agendex login` to re-authenticate.");
|
|
2727
|
+
this.name = "AuthExpiredError";
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2724
2730
|
var cachedDeviceId;
|
|
2725
2731
|
function getCloudConfig() {
|
|
2726
2732
|
const config = loadConfig();
|
|
@@ -2897,6 +2903,9 @@ async function fetchDevices() {
|
|
|
2897
2903
|
});
|
|
2898
2904
|
}
|
|
2899
2905
|
}
|
|
2906
|
+
if (res.status === 401) {
|
|
2907
|
+
throw new AuthExpiredError;
|
|
2908
|
+
}
|
|
2900
2909
|
if (res.status < 200 || res.status >= 300) {
|
|
2901
2910
|
return [];
|
|
2902
2911
|
}
|
|
@@ -2948,18 +2957,21 @@ function getDefaultSiteUrl() {
|
|
|
2948
2957
|
return process.env.AGENDEX_SITE_URL;
|
|
2949
2958
|
return isDevMode() ? DEV_SITE_URL : PROD_SITE_URL;
|
|
2950
2959
|
}
|
|
2960
|
+
function launchBrowser(url, label) {
|
|
2961
|
+
console.log(`[agendex] Opening ${label}...`);
|
|
2962
|
+
console.log(`[agendex] If it doesn't open, visit: ${url}`);
|
|
2963
|
+
if (process.env.AGENDEX_DISABLE_BROWSER === "1") {
|
|
2964
|
+
console.log("[agendex] Browser launch disabled by AGENDEX_DISABLE_BROWSER=1.");
|
|
2965
|
+
} else {
|
|
2966
|
+
openBrowser(url);
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2951
2969
|
async function login(siteUrlOverride) {
|
|
2952
2970
|
const { port, result } = await startCallbackServer();
|
|
2953
2971
|
const callbackUrl = `http://127.0.0.1:${port}/callback`;
|
|
2954
2972
|
const siteUrl = siteUrlOverride ?? getDefaultSiteUrl();
|
|
2955
2973
|
const authUrl = `${siteUrl}/auth/cli?callback=${encodeURIComponent(callbackUrl)}`;
|
|
2956
|
-
|
|
2957
|
-
console.log(`[agendex] If it doesn't open, visit: ${authUrl}`);
|
|
2958
|
-
if (process.env.AGENDEX_DISABLE_BROWSER === "1") {
|
|
2959
|
-
console.log("[agendex] Browser launch disabled by AGENDEX_DISABLE_BROWSER=1.");
|
|
2960
|
-
} else {
|
|
2961
|
-
openBrowser(authUrl);
|
|
2962
|
-
}
|
|
2974
|
+
launchBrowser(authUrl, "browser for authentication");
|
|
2963
2975
|
const callback = await result;
|
|
2964
2976
|
const existing = loadConfig();
|
|
2965
2977
|
const config = {
|
|
@@ -3409,7 +3421,7 @@ import { join as join12 } from "node:path";
|
|
|
3409
3421
|
// package.json
|
|
3410
3422
|
var package_default = {
|
|
3411
3423
|
name: "agendex-cli",
|
|
3412
|
-
version: "0.
|
|
3424
|
+
version: "0.11.0",
|
|
3413
3425
|
description: "Agendex CLI for login, sync, and daemon workflows",
|
|
3414
3426
|
homepage: "https://github.com/Tyru5/Agendex#readme",
|
|
3415
3427
|
repository: {
|
|
@@ -3523,13 +3535,23 @@ function isNewer(latest, current) {
|
|
|
3523
3535
|
async function openAgendexWeb(siteUrlOverride) {
|
|
3524
3536
|
const base = siteUrlOverride ?? getDefaultSiteUrl();
|
|
3525
3537
|
const url = base.replace(/\/$/, "");
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3538
|
+
launchBrowser(url, "Agendex in your browser");
|
|
3539
|
+
}
|
|
3540
|
+
async function openSharedPlan(url) {
|
|
3541
|
+
let parsed;
|
|
3542
|
+
try {
|
|
3543
|
+
parsed = new URL(url);
|
|
3544
|
+
} catch {
|
|
3545
|
+
console.error(`[agendex] invalid URL: ${url}`);
|
|
3546
|
+
return false;
|
|
3547
|
+
}
|
|
3548
|
+
if (!parsed.pathname.includes("/shared/")) {
|
|
3549
|
+
console.error(`[agendex] not a shared plan URL: ${url}`);
|
|
3550
|
+
console.error("[agendex] expected format: https://app.agendex.dev/shared/<token>");
|
|
3551
|
+
return false;
|
|
3532
3552
|
}
|
|
3553
|
+
launchBrowser(url, "shared plan in your browser");
|
|
3554
|
+
return true;
|
|
3533
3555
|
}
|
|
3534
3556
|
|
|
3535
3557
|
// src/cli.ts
|
|
@@ -3559,6 +3581,7 @@ async function main() {
|
|
|
3559
3581
|
"login",
|
|
3560
3582
|
"logout",
|
|
3561
3583
|
"open",
|
|
3584
|
+
"view",
|
|
3562
3585
|
"cleanup",
|
|
3563
3586
|
"help",
|
|
3564
3587
|
"--help",
|
|
@@ -3579,6 +3602,16 @@ async function main() {
|
|
|
3579
3602
|
await openAgendexWeb(siteUrl);
|
|
3580
3603
|
return 0;
|
|
3581
3604
|
}
|
|
3605
|
+
case "view": {
|
|
3606
|
+
const url = args.find((a) => a !== "view" && a !== "--dev" && !a.startsWith("--"));
|
|
3607
|
+
if (!url) {
|
|
3608
|
+
writeStderr("[agendex] usage: agendex view <shared-plan-url>");
|
|
3609
|
+
return 1;
|
|
3610
|
+
}
|
|
3611
|
+
if (!await openSharedPlan(url))
|
|
3612
|
+
return 1;
|
|
3613
|
+
return 0;
|
|
3614
|
+
}
|
|
3582
3615
|
case "start": {
|
|
3583
3616
|
if (args.includes("--daemon")) {
|
|
3584
3617
|
await startSupervisor();
|
|
@@ -3656,7 +3689,16 @@ async function main() {
|
|
|
3656
3689
|
writeStderr("[agendex] not logged in. Run `agendex login` first.");
|
|
3657
3690
|
return 1;
|
|
3658
3691
|
}
|
|
3659
|
-
|
|
3692
|
+
let allDevices;
|
|
3693
|
+
try {
|
|
3694
|
+
allDevices = await fetchDevices();
|
|
3695
|
+
} catch (err) {
|
|
3696
|
+
if (err instanceof AuthExpiredError) {
|
|
3697
|
+
writeStderr("[agendex] cloud token expired. Run `agendex login` to re-authenticate.");
|
|
3698
|
+
return 1;
|
|
3699
|
+
}
|
|
3700
|
+
throw err;
|
|
3701
|
+
}
|
|
3660
3702
|
if (allDevices.length === 0) {
|
|
3661
3703
|
writeStdout("[agendex] no daemons found");
|
|
3662
3704
|
return 0;
|
|
@@ -3765,7 +3807,12 @@ async function main() {
|
|
|
3765
3807
|
writeStdout(`[agendex] All daemons: none`);
|
|
3766
3808
|
}
|
|
3767
3809
|
}
|
|
3768
|
-
} catch {
|
|
3810
|
+
} catch (err) {
|
|
3811
|
+
if (err instanceof AuthExpiredError) {
|
|
3812
|
+
writeStderr(`[agendex] Cloud token expired — cloud sync and daemon tracking are inactive.`);
|
|
3813
|
+
writeStderr(`[agendex] Run \`agendex login\` to re-authenticate.`);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3769
3816
|
return 0;
|
|
3770
3817
|
}
|
|
3771
3818
|
case "help":
|
|
@@ -3782,6 +3829,7 @@ Usage:
|
|
|
3782
3829
|
agendex login --url <url> Login to a self-hosted instance
|
|
3783
3830
|
agendex open Open the Agendex web app in your browser
|
|
3784
3831
|
agendex open --url <url> Open a self-hosted instance
|
|
3832
|
+
agendex view <url> Open a shared plan URL in your browser
|
|
3785
3833
|
agendex logout Clear stored cloud token
|
|
3786
3834
|
agendex configure Select which agents/adapters to index
|
|
3787
3835
|
agendex sync One-shot scan + sync to cloud (skips unchanged plans)
|