skydive-cli 0.1.0-beta.389 → 0.1.0-beta.390
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/README.md
CHANGED
|
@@ -25,7 +25,10 @@ single `config.json`:
|
|
|
25
25
|
same machine replaces it rather than accumulating rows, and
|
|
26
26
|
`skydive auth logout` revokes it, so signing out doesn't leave a live key
|
|
27
27
|
behind. The workspace is in the name because the key is pinned to it: unlike
|
|
28
|
-
the session, a key never follows `workspace switch
|
|
28
|
+
the session, a key never follows `workspace switch` — and whenever the key
|
|
29
|
+
(not the session) is the credential actually driving a management command,
|
|
30
|
+
the CLI says so on stderr, naming the pinned workspace, so commands never
|
|
31
|
+
silently act in a workspace you switched away from.
|
|
29
32
|
- a **user session** for `skydive chat`. Chat is user-level and multi-agent,
|
|
30
33
|
so it authenticates as you — and unlike the API key (which is pinned to the
|
|
31
34
|
workspace that minted it), the session follows `skydive workspace switch`.
|
package/dist/js/bin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as getStoredApiKeyId, C as DEFAULT_WEB_URL, E as getPromptHistoryPath, F as
|
|
2
|
+
import { A as getStoredApiKeyId, C as DEFAULT_WEB_URL, E as getPromptHistoryPath, F as resolveManagementAuth, I as resolveSession, M as getUpdateCheckDisabled, N as resolveAppUrl, P as resolveConfig, R as saveConfig, T as getConfigPath, _ as setActiveWorkspace, b as API_KEY_PREFIX, d as themes, g as listWorkspaces, h as getSessionIdentity, j as getStoredApiKeyWorkspaceName, k as getShareMachineDefault, m as getActiveWorkspaceId, p as ensureActiveOrganization, v as API_KEYS_URL, w as deleteConfig, x as DEFAULT_API_URL, y as API_KEY_FAMILY_PREFIX, z as saveSession } from "./theme-C_Fqxi-U.mjs";
|
|
3
3
|
import { n as createRestClient } from "./rest-DTlkPko_.mjs";
|
|
4
4
|
import { i as resolveAgent } from "./print-BhfjRrxI.mjs";
|
|
5
5
|
import { a as registerPortalDevice, c as machineIdentity, n as findThisDevice, o as revokePortalAccess, r as grantPortalAccess, t as fetchPortalDevices } from "./api-DRpbKHz6.mjs";
|
|
@@ -19,7 +19,7 @@ import semver from "semver";
|
|
|
19
19
|
|
|
20
20
|
//#region package.json
|
|
21
21
|
var name = "skydive-cli";
|
|
22
|
-
var version = "0.1.0-beta.
|
|
22
|
+
var version = "0.1.0-beta.390";
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/types.ts
|
|
@@ -578,7 +578,8 @@ async function runBrowserLogin(argv) {
|
|
|
578
578
|
if (minted.isOk()) saveConfig({
|
|
579
579
|
apiKey: minted.value.key,
|
|
580
580
|
apiUrl: appUrl,
|
|
581
|
-
apiKeyId: minted.value.id
|
|
581
|
+
apiKeyId: minted.value.id,
|
|
582
|
+
workspaceName: identity?.activeWorkspaceName ?? null
|
|
582
583
|
});
|
|
583
584
|
else process.stderr.write(`Warning: signed in, but could not mint an API key (${minted.error.message}). Management commands will use your session; run \`skydive auth login\` again to retry.
|
|
584
585
|
`);
|
|
@@ -623,7 +624,8 @@ async function runApiKeyLogin(argv, apiKey) {
|
|
|
623
624
|
saveConfig({
|
|
624
625
|
apiKey,
|
|
625
626
|
apiUrl,
|
|
626
|
-
apiKeyId: null
|
|
627
|
+
apiKeyId: null,
|
|
628
|
+
workspaceName: null
|
|
627
629
|
});
|
|
628
630
|
if (argv.json) output(argv, {
|
|
629
631
|
authenticated: true,
|
|
@@ -694,6 +696,7 @@ const statusCommand$1 = {
|
|
|
694
696
|
workspaceName: identity?.activeWorkspaceName ?? null
|
|
695
697
|
},
|
|
696
698
|
managementAuth: management.isOk() ? management.value.kind : null,
|
|
699
|
+
keyWorkspaceName: getStoredApiKeyWorkspaceName(),
|
|
697
700
|
configPath: getConfigPath()
|
|
698
701
|
});
|
|
699
702
|
return;
|
|
@@ -706,6 +709,8 @@ const statusCommand$1 = {
|
|
|
706
709
|
console.log("API key:");
|
|
707
710
|
console.log(` Key: ${apiKey.value.apiKey.slice(0, 12)}...`);
|
|
708
711
|
console.log(` API: ${apiKey.value.apiUrl}`);
|
|
712
|
+
const pinned = getStoredApiKeyWorkspaceName();
|
|
713
|
+
if (pinned) console.log(` Space: ${pinned} (the key always acts here)`);
|
|
709
714
|
} else console.log("API key: not configured.");
|
|
710
715
|
if (session.isOk()) {
|
|
711
716
|
console.log("Chat session:");
|
|
@@ -721,7 +726,7 @@ const statusCommand$1 = {
|
|
|
721
726
|
}
|
|
722
727
|
} else console.log("Chat session: not signed in.");
|
|
723
728
|
if (management.isOk()) {
|
|
724
|
-
const via = management.value.kind === "session" ? "chat session (follows `workspace switch`)" : "API key (
|
|
729
|
+
const via = management.value.kind === "session" ? "chat session (follows `workspace switch`)" : management.value.pinnedWorkspaceName ? `API key (always acts in "${management.value.pinnedWorkspaceName}")` : "API key (always acts in the workspace it was created in)";
|
|
725
730
|
console.log(`Management commands use: ${via}`);
|
|
726
731
|
}
|
|
727
732
|
console.log(`Config: ${getConfigPath()}`);
|
|
@@ -760,6 +765,8 @@ function requireManagementClient(argv) {
|
|
|
760
765
|
printError(auth.error.message);
|
|
761
766
|
process.exit(1);
|
|
762
767
|
}
|
|
768
|
+
if (auth.value.kind === "api-key" && auth.value.pinnedWorkspaceName) process.stderr.write(`Using this machine's API key, which always acts in the "${auth.value.pinnedWorkspaceName}" workspace (even after \`workspace switch\`). Run \`skydive auth login\` to change that.
|
|
769
|
+
`);
|
|
763
770
|
return new SkydiveApiClient(auth.value);
|
|
764
771
|
}
|
|
765
772
|
/** Resolve the session (see {@link requireSession}) and build a REST client. */
|
|
@@ -1416,7 +1423,7 @@ const chatCommand = {
|
|
|
1416
1423
|
printError(`Unknown theme "${themeId}". Valid themes: ${themes.map((t) => t.id).join(", ")}`);
|
|
1417
1424
|
process.exit(1);
|
|
1418
1425
|
}
|
|
1419
|
-
const { runChat } = await import("./boot-
|
|
1426
|
+
const { runChat } = await import("./boot-Ce1QLo2p.mjs");
|
|
1420
1427
|
await runChat({
|
|
1421
1428
|
appUrl,
|
|
1422
1429
|
sessionToken: session.value.sessionToken,
|
|
@@ -1728,7 +1735,7 @@ const switchCommand = {
|
|
|
1728
1735
|
printError("The workspace picker needs the Bun runtime and it could not be set up automatically. Pass a workspace slug instead, or install Bun and retry.");
|
|
1729
1736
|
process.exit(1);
|
|
1730
1737
|
}
|
|
1731
|
-
const { runWorkspacePicker } = await import("./boot-
|
|
1738
|
+
const { runWorkspacePicker } = await import("./boot-Ce1QLo2p.mjs");
|
|
1732
1739
|
await runWorkspacePicker(session);
|
|
1733
1740
|
return;
|
|
1734
1741
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as getReviewStateDir,
|
|
2
|
+
import { B as saveTheme, D as getReviewStateDir, L as resolveWebUrl, O as getSavedTheme, S as DEFAULT_APP_URL, T as getConfigPath, _ as setActiveWorkspace, a as noColorRequested, c as themeMode, f as themesForMode, g as listWorkspaces, i as monoTheme, l as themeModeFromColorFgBg, m as getActiveWorkspaceId, n as applyTheme, o as theme, r as findTheme, s as themeForMode, t as DEFAULT_THEME_ID, u as themeVersion, x as DEFAULT_API_URL } from "./theme-C_Fqxi-U.mjs";
|
|
3
3
|
import { n as createRestClient, r as errorDetail, t as HttpError } from "./rest-DTlkPko_.mjs";
|
|
4
4
|
import { n as isRecord, t as errorMessage } from "./util-z9Pne47f.mjs";
|
|
5
5
|
import { c as cardActionErrorMessage, d as reconcileMaskedInput, f as resolveConnectUrl, i as resolveAgent, l as parseExternalOauthConnectParams, p as parseConnectCard, s as MASK_CHAR, u as parseOauthConnectParams } from "./print-BhfjRrxI.mjs";
|
|
@@ -77,13 +77,17 @@ function resolveManagementAuth(opts) {
|
|
|
77
77
|
if (session.isOk()) return ok({
|
|
78
78
|
token: session.value.sessionToken,
|
|
79
79
|
apiUrl: session.value.appUrl,
|
|
80
|
-
kind: "session"
|
|
80
|
+
kind: "session",
|
|
81
|
+
pinnedWorkspaceName: null
|
|
81
82
|
});
|
|
82
|
-
const
|
|
83
|
+
const envKey = process.env["SKYDIVE_API_KEY"];
|
|
84
|
+
const storedKey = store.get("apiKey");
|
|
85
|
+
const apiKey = envKey ?? storedKey;
|
|
83
86
|
if (apiKey) return ok({
|
|
84
87
|
token: apiKey,
|
|
85
88
|
apiUrl: process.env["SKYDIVE_API_URL"] ?? opts.apiUrl ?? store.get("apiUrl") ?? DEFAULT_API_URL,
|
|
86
|
-
kind: "api-key"
|
|
89
|
+
kind: "api-key",
|
|
90
|
+
pinnedWorkspaceName: !envKey && storedKey ? store.get("apiKeyWorkspaceName") ?? null : null
|
|
87
91
|
});
|
|
88
92
|
return err({ message: "Not authenticated. Run `skydive auth login`." });
|
|
89
93
|
}
|
|
@@ -92,11 +96,17 @@ function saveConfig(config) {
|
|
|
92
96
|
store.set("apiUrl", config.apiUrl);
|
|
93
97
|
if (config.apiKeyId) store.set("apiKeyId", config.apiKeyId);
|
|
94
98
|
else store.delete("apiKeyId");
|
|
99
|
+
if (config.workspaceName) store.set("apiKeyWorkspaceName", config.workspaceName);
|
|
100
|
+
else store.delete("apiKeyWorkspaceName");
|
|
95
101
|
}
|
|
96
102
|
/** Server-side id of the auto-minted key, if login minted one. */
|
|
97
103
|
function getStoredApiKeyId() {
|
|
98
104
|
return store.get("apiKeyId") ?? null;
|
|
99
105
|
}
|
|
106
|
+
/** Workspace the auto-minted key is pinned to, if login recorded one. */
|
|
107
|
+
function getStoredApiKeyWorkspaceName() {
|
|
108
|
+
return store.get("apiKeyWorkspaceName") ?? null;
|
|
109
|
+
}
|
|
100
110
|
function deleteConfig() {
|
|
101
111
|
store.clear();
|
|
102
112
|
}
|
|
@@ -971,4 +981,4 @@ function applyTheme(def) {
|
|
|
971
981
|
}
|
|
972
982
|
|
|
973
983
|
//#endregion
|
|
974
|
-
export { getStoredApiKeyId as A, DEFAULT_WEB_URL as C, getReviewStateDir as D, getPromptHistoryPath as E,
|
|
984
|
+
export { getStoredApiKeyId as A, saveTheme as B, DEFAULT_WEB_URL as C, getReviewStateDir as D, getPromptHistoryPath as E, resolveManagementAuth as F, resolveSession as I, resolveWebUrl as L, getUpdateCheckDisabled as M, resolveAppUrl as N, getSavedTheme as O, resolveConfig as P, saveConfig as R, DEFAULT_APP_URL as S, getConfigPath as T, setActiveWorkspace as _, noColorRequested as a, API_KEY_PREFIX as b, themeMode as c, themes as d, themesForMode as f, listWorkspaces as g, getSessionIdentity as h, monoTheme as i, getStoredApiKeyWorkspaceName as j, getShareMachineDefault as k, themeModeFromColorFgBg as l, getActiveWorkspaceId as m, applyTheme as n, theme as o, ensureActiveOrganization as p, findTheme as r, themeForMode as s, DEFAULT_THEME_ID as t, themeVersion as u, API_KEYS_URL as v, deleteConfig as w, DEFAULT_API_URL as x, API_KEY_FAMILY_PREFIX as y, saveSession as z };
|