@datalyr/wizard 1.0.3 → 1.0.4
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/bin/wizard.js +2 -53
- package/dist/bin/wizard.js.map +1 -1
- package/dist/index.js +2 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -11
package/dist/index.mjs
CHANGED
|
@@ -2832,38 +2832,8 @@ async function runAgentWizard(_config, options = {}) {
|
|
|
2832
2832
|
const validateSpinner = p.spinner();
|
|
2833
2833
|
validateSpinner.start("Validating API key...");
|
|
2834
2834
|
try {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
if (allWorkspaces.length > 1) {
|
|
2838
|
-
validateSpinner.stop("API key validated");
|
|
2839
|
-
const workspaceChoice = await p.select({
|
|
2840
|
-
message: "Select a workspace to configure:",
|
|
2841
|
-
options: allWorkspaces.map((w) => ({
|
|
2842
|
-
value: w.id,
|
|
2843
|
-
label: w.name,
|
|
2844
|
-
hint: w.domain || void 0
|
|
2845
|
-
}))
|
|
2846
|
-
});
|
|
2847
|
-
if (p.isCancel(workspaceChoice)) {
|
|
2848
|
-
p.cancel("Wizard cancelled");
|
|
2849
|
-
return { success: false, error: "User cancelled" };
|
|
2850
|
-
}
|
|
2851
|
-
const selectedWorkspace = allWorkspaces.find((w) => w.id === workspaceChoice);
|
|
2852
|
-
if (selectedWorkspace) {
|
|
2853
|
-
workspace = {
|
|
2854
|
-
id: selectedWorkspace.id,
|
|
2855
|
-
name: selectedWorkspace.name,
|
|
2856
|
-
timezone: null,
|
|
2857
|
-
domain: selectedWorkspace.domain
|
|
2858
|
-
};
|
|
2859
|
-
} else {
|
|
2860
|
-
workspace = defaultWorkspace;
|
|
2861
|
-
}
|
|
2862
|
-
p.log.info(`Selected workspace: ${chalk4.cyan(workspace.name)}`);
|
|
2863
|
-
} else {
|
|
2864
|
-
workspace = defaultWorkspace;
|
|
2865
|
-
validateSpinner.stop(`Workspace: ${chalk4.cyan(workspace.name)}`);
|
|
2866
|
-
}
|
|
2835
|
+
workspace = await validateApiKey(apiKey);
|
|
2836
|
+
validateSpinner.stop(`Workspace: ${chalk4.cyan(workspace.name)}`);
|
|
2867
2837
|
} catch (error) {
|
|
2868
2838
|
validateSpinner.stop(chalk4.red("Invalid API key"));
|
|
2869
2839
|
const errorMessage = error instanceof Error ? error.message : "Failed to validate API key";
|
|
@@ -3438,27 +3408,6 @@ async function validateApiKey(apiKey) {
|
|
|
3438
3408
|
}
|
|
3439
3409
|
return result.workspace;
|
|
3440
3410
|
}
|
|
3441
|
-
async function fetchWorkspaces(apiKey) {
|
|
3442
|
-
const controller = new AbortController();
|
|
3443
|
-
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
3444
|
-
const response = await fetch(`${LLM_GATEWAY_URL}/workspaces`, {
|
|
3445
|
-
method: "POST",
|
|
3446
|
-
headers: {
|
|
3447
|
-
"Content-Type": "application/json"
|
|
3448
|
-
},
|
|
3449
|
-
body: JSON.stringify({ apiKey }),
|
|
3450
|
-
signal: controller.signal
|
|
3451
|
-
});
|
|
3452
|
-
clearTimeout(timeoutId);
|
|
3453
|
-
if (!response.ok) {
|
|
3454
|
-
return [];
|
|
3455
|
-
}
|
|
3456
|
-
const result = await response.json();
|
|
3457
|
-
if (!result.success || !result.workspaces) {
|
|
3458
|
-
return [];
|
|
3459
|
-
}
|
|
3460
|
-
return result.workspaces;
|
|
3461
|
-
}
|
|
3462
3411
|
async function verifyInstallation(apiKey, workspaceId) {
|
|
3463
3412
|
try {
|
|
3464
3413
|
const controller = new AbortController();
|