@vendian/cli 0.0.25 → 0.0.27
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/cli-wrapper.mjs +72 -38
- package/package.json +1 -1
package/cli-wrapper.mjs
CHANGED
|
@@ -1107,7 +1107,7 @@ import path8 from "node:path";
|
|
|
1107
1107
|
import readlinePromises from "node:readline/promises";
|
|
1108
1108
|
|
|
1109
1109
|
// src/version.js
|
|
1110
|
-
var CLI_VERSION = true ? "0.0.
|
|
1110
|
+
var CLI_VERSION = true ? "0.0.27" : process.env.npm_package_version || "0.0.0-dev";
|
|
1111
1111
|
|
|
1112
1112
|
// src/npm-update.js
|
|
1113
1113
|
var NPM_CHECK_INTERVAL_MS = 30 * 60 * 1e3;
|
|
@@ -2588,17 +2588,10 @@ async function showConnect({ env, platform }) {
|
|
|
2588
2588
|
}
|
|
2589
2589
|
const ep = ENDPOINTS[resp.selectedIndex];
|
|
2590
2590
|
term("\n");
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
await switchOrLoginEndpoint({ backend: ep.key, env, platform });
|
|
2595
|
-
term.green(` ${fig.check} Signed in to ${ep.label} successfully
|
|
2596
|
-
`);
|
|
2597
|
-
} catch (error) {
|
|
2598
|
-
term.red(` ${endpointErrorStatus(error)}
|
|
2599
|
-
`);
|
|
2591
|
+
const outcome = await connectEndpointInteractive({ backend: ep.key, label: ep.label, env, platform });
|
|
2592
|
+
if (outcome.promptedInTui) {
|
|
2593
|
+
await pressEnterToContinue();
|
|
2600
2594
|
}
|
|
2601
|
-
await pressEnterToContinue({ grabActive: false });
|
|
2602
2595
|
}
|
|
2603
2596
|
}
|
|
2604
2597
|
async function connectCustomUrl({ env, platform }) {
|
|
@@ -2611,15 +2604,10 @@ async function connectCustomUrl({ env, platform }) {
|
|
|
2611
2604
|
if (!url) return;
|
|
2612
2605
|
term("\n\n");
|
|
2613
2606
|
term.gray(" Connecting\u2026\n");
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
`);
|
|
2618
|
-
} catch (error) {
|
|
2619
|
-
term.red(` ${endpointErrorStatus(error)}
|
|
2620
|
-
`);
|
|
2607
|
+
const outcome = await connectEndpointInteractive({ apiUrl: url, label: url, env, platform, successLabel: "Connected successfully" });
|
|
2608
|
+
if (outcome.promptedInTui) {
|
|
2609
|
+
await pressEnterToContinue();
|
|
2621
2610
|
}
|
|
2622
|
-
await pressEnterToContinue({ grabActive: false });
|
|
2623
2611
|
}
|
|
2624
2612
|
async function showCreate({ env, platform }) {
|
|
2625
2613
|
term.clear();
|
|
@@ -2823,6 +2811,8 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
2823
2811
|
let overlayActive = false;
|
|
2824
2812
|
let ctrlCArmed = false;
|
|
2825
2813
|
let ctrlCArmTimer = null;
|
|
2814
|
+
let dashboardClosed = false;
|
|
2815
|
+
let exitPromptActive = false;
|
|
2826
2816
|
let selectedIdx = 0;
|
|
2827
2817
|
const agentRowMap = /* @__PURE__ */ new Map();
|
|
2828
2818
|
function agentDisplayList() {
|
|
@@ -2850,7 +2840,7 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
2850
2840
|
return serveDebugEntries(state.logs, maxLines);
|
|
2851
2841
|
}
|
|
2852
2842
|
function redraw() {
|
|
2853
|
-
if (overlayActive) return;
|
|
2843
|
+
if (dashboardClosed || overlayActive) return;
|
|
2854
2844
|
drawHeader({ env, platform, serveState: state });
|
|
2855
2845
|
term.moveTo(1, SERVE_CONTENT_ROW);
|
|
2856
2846
|
term.eraseDisplayBelow();
|
|
@@ -3022,6 +3012,7 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
3022
3012
|
env,
|
|
3023
3013
|
platform,
|
|
3024
3014
|
onProgress: (msg) => {
|
|
3015
|
+
if (dashboardClosed) return;
|
|
3025
3016
|
state = { ...state, activity: msg || "Preparing\u2026" };
|
|
3026
3017
|
redraw();
|
|
3027
3018
|
}
|
|
@@ -3031,10 +3022,12 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
3031
3022
|
attachServeChild(
|
|
3032
3023
|
child,
|
|
3033
3024
|
(updater) => {
|
|
3025
|
+
if (dashboardClosed) return;
|
|
3034
3026
|
state = updater(state);
|
|
3035
3027
|
redraw();
|
|
3036
3028
|
},
|
|
3037
3029
|
({ message } = {}) => {
|
|
3030
|
+
if (dashboardClosed) return;
|
|
3038
3031
|
if (!state.stopped) state = { ...state, stopped: true, activity: message || "Stopped" };
|
|
3039
3032
|
redraw();
|
|
3040
3033
|
},
|
|
@@ -3046,23 +3039,39 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
3046
3039
|
}
|
|
3047
3040
|
return new Promise((resolve) => {
|
|
3048
3041
|
function openAgentLog(idx) {
|
|
3049
|
-
if (idx < 0 || idx >= state.agents.length) return;
|
|
3042
|
+
if (dashboardClosed || exitPromptActive || idx < 0 || idx >= state.agents.length) return;
|
|
3050
3043
|
overlayActive = true;
|
|
3051
3044
|
const ag = agentDisplayList()[idx];
|
|
3052
3045
|
showAgentLog({ agent: ag, state, env, platform }).then(() => {
|
|
3046
|
+
if (dashboardClosed) return;
|
|
3053
3047
|
overlayActive = false;
|
|
3054
3048
|
term.clear();
|
|
3055
3049
|
redraw();
|
|
3056
3050
|
});
|
|
3057
3051
|
}
|
|
3052
|
+
function clearCtrlCArm() {
|
|
3053
|
+
ctrlCArmed = false;
|
|
3054
|
+
if (ctrlCArmTimer) {
|
|
3055
|
+
clearTimeout(ctrlCArmTimer);
|
|
3056
|
+
ctrlCArmTimer = null;
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
function detachDashboardHandlers() {
|
|
3060
|
+
term.off("key", handleKey);
|
|
3061
|
+
term.off("mouse", handleMouse);
|
|
3062
|
+
}
|
|
3063
|
+
function finish(next) {
|
|
3064
|
+
if (dashboardClosed) return;
|
|
3065
|
+
dashboardClosed = true;
|
|
3066
|
+
clearCtrlCArm();
|
|
3067
|
+
detachDashboardHandlers();
|
|
3068
|
+
resolve(next);
|
|
3069
|
+
}
|
|
3058
3070
|
function handleKey(name) {
|
|
3059
3071
|
if (name === "CTRL_C") {
|
|
3060
3072
|
if (ctrlCArmed) {
|
|
3061
|
-
clearTimeout(ctrlCArmTimer);
|
|
3062
3073
|
child?.kill("SIGINT");
|
|
3063
|
-
|
|
3064
|
-
term.off("mouse", handleMouse);
|
|
3065
|
-
resolve("exit");
|
|
3074
|
+
finish("exit");
|
|
3066
3075
|
return;
|
|
3067
3076
|
}
|
|
3068
3077
|
ctrlCArmed = true;
|
|
@@ -3089,9 +3098,7 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
3089
3098
|
openAgentLog(selectedIdx);
|
|
3090
3099
|
} else if (name === "s" || name === "S") {
|
|
3091
3100
|
child?.kill("SIGINT");
|
|
3092
|
-
|
|
3093
|
-
term.off("mouse", handleMouse);
|
|
3094
|
-
resolve("home");
|
|
3101
|
+
finish("home");
|
|
3095
3102
|
}
|
|
3096
3103
|
}
|
|
3097
3104
|
function handleMouse(name, data) {
|
|
@@ -3112,16 +3119,13 @@ async function runServeDashboard({ env, platform, agentsDir, collectionId }) {
|
|
|
3112
3119
|
if (child) {
|
|
3113
3120
|
child.once("exit", () => {
|
|
3114
3121
|
setTimeout(() => {
|
|
3115
|
-
if (
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
resolve("home");
|
|
3123
|
-
});
|
|
3124
|
-
}
|
|
3122
|
+
if (dashboardClosed || overlayActive) return;
|
|
3123
|
+
exitPromptActive = true;
|
|
3124
|
+
detachDashboardHandlers();
|
|
3125
|
+
redraw();
|
|
3126
|
+
term("\n");
|
|
3127
|
+
term.gray(" Your agents have stopped. Press any key to go back\u2026");
|
|
3128
|
+
term.once("key", () => finish("home"));
|
|
3125
3129
|
}, 600);
|
|
3126
3130
|
});
|
|
3127
3131
|
}
|
|
@@ -3461,6 +3465,36 @@ async function switchOrLoginEndpoint({
|
|
|
3461
3465
|
await setupFn({ backend, apiUrl, forceAuth: true, env, platform });
|
|
3462
3466
|
return { apiUrl: status.apiUrl, reused: false, activated: true };
|
|
3463
3467
|
}
|
|
3468
|
+
async function connectEndpointInteractive({
|
|
3469
|
+
backend,
|
|
3470
|
+
apiUrl,
|
|
3471
|
+
label,
|
|
3472
|
+
env = process.env,
|
|
3473
|
+
platform = process.platform,
|
|
3474
|
+
setupFn = setup,
|
|
3475
|
+
activateFn = activateCloudProfile,
|
|
3476
|
+
successLabel
|
|
3477
|
+
} = {}) {
|
|
3478
|
+
const status = cloudAuthStatus({ backend, apiUrl, env, platform });
|
|
3479
|
+
const destination = label || envLabel(status.apiUrl);
|
|
3480
|
+
if (status.authenticated) {
|
|
3481
|
+
term.gray(` Connecting to ${destination}\u2026
|
|
3482
|
+
`);
|
|
3483
|
+
try {
|
|
3484
|
+
await switchOrLoginEndpoint({ backend, apiUrl, env, platform, setupFn, activateFn });
|
|
3485
|
+
term.green(` ${fig.check} ${successLabel || `Signed in to ${destination} successfully`}
|
|
3486
|
+
`);
|
|
3487
|
+
} catch (error) {
|
|
3488
|
+
term.red(` ${endpointErrorStatus(error)}
|
|
3489
|
+
`);
|
|
3490
|
+
}
|
|
3491
|
+
return { promptedInTui: true };
|
|
3492
|
+
}
|
|
3493
|
+
await withOutputMode(`Connecting to ${destination}`, async () => {
|
|
3494
|
+
await switchOrLoginEndpoint({ backend, apiUrl, env, platform, setupFn, activateFn });
|
|
3495
|
+
});
|
|
3496
|
+
return { promptedInTui: false };
|
|
3497
|
+
}
|
|
3464
3498
|
function endpointErrorStatus(error) {
|
|
3465
3499
|
const message = error && typeof error.message === "string" ? error.message : String(error || "Connection failed");
|
|
3466
3500
|
return `${fig.cross} ${message}`;
|