skydive-cli 0.1.0-beta.87 → 0.1.0-beta.89

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.
Files changed (2) hide show
  1. package/dist/js/bin.mjs +57 -2
  2. package/package.json +1 -1
package/dist/js/bin.mjs CHANGED
@@ -13,7 +13,7 @@ import fs from "node:fs";
13
13
  import zlib from "node:zlib";
14
14
 
15
15
  //#region package.json
16
- var version$1 = "0.1.0-beta.87";
16
+ var version$1 = "0.1.0-beta.89";
17
17
 
18
18
  //#endregion
19
19
  //#region src/types.ts
@@ -433,6 +433,44 @@ async function listWorkspaces({ appUrl, sessionToken }) {
433
433
  return err({ message: e instanceof Error ? e.message : String(e) });
434
434
  }
435
435
  }
436
+ /**
437
+ * Resolve who the current chat session belongs to: the signed-in user's
438
+ * email/name and the active workspace. Used by `auth status` so a user running
439
+ * multiple accounts can answer "am I logged into the right one?" without
440
+ * another command. Best-effort: any failure yields nulls rather than throwing,
441
+ * since `auth status` should still report the rest of the state.
442
+ */
443
+ async function getSessionIdentity({ appUrl, sessionToken }) {
444
+ try {
445
+ const res = await fetch(`${appUrl}/api/auth/get-session?disableCookieCache=true`, { headers: authHeaders(sessionToken) });
446
+ if (!res.ok) return err({ message: `failed to read session (${res.status})` });
447
+ const parsed = z.object({
448
+ user: z.object({
449
+ email: z.string().nullable().optional(),
450
+ name: z.string().nullable().optional()
451
+ }).nullable().optional(),
452
+ session: z.object({ activeOrganizationId: z.string().nullable().optional() }).nullable().optional()
453
+ }).nullable().safeParse(await res.json());
454
+ if (!parsed.success) return err({ message: "unexpected session response" });
455
+ const activeWorkspaceId = parsed.data?.session?.activeOrganizationId ?? null;
456
+ let activeWorkspaceName = null;
457
+ if (activeWorkspaceId) {
458
+ const workspaces = await listWorkspaces({
459
+ appUrl,
460
+ sessionToken
461
+ });
462
+ if (workspaces.isOk()) activeWorkspaceName = workspaces.value.find((w) => w.id === activeWorkspaceId)?.name ?? null;
463
+ }
464
+ return ok({
465
+ email: parsed.data?.user?.email ?? null,
466
+ name: parsed.data?.user?.name ?? null,
467
+ activeWorkspaceId,
468
+ activeWorkspaceName
469
+ });
470
+ } catch (e) {
471
+ return err({ message: e instanceof Error ? e.message : String(e) });
472
+ }
473
+ }
436
474
  /** The workspace bound to the current session, or `null` if none is set. */
437
475
  async function getActiveWorkspaceId({ appUrl, sessionToken }) {
438
476
  try {
@@ -693,6 +731,10 @@ const statusCommand = {
693
731
  handler: async (argv) => {
694
732
  const apiKey = resolveConfig({ apiUrl: argv["api-url"] });
695
733
  const session = resolveSession({});
734
+ const identity = session.isOk() ? (await getSessionIdentity({
735
+ appUrl: session.value.appUrl,
736
+ sessionToken: session.value.sessionToken
737
+ })).unwrapOr(null) : null;
696
738
  if (argv.json) {
697
739
  output(argv, {
698
740
  authenticated: apiKey.isOk(),
@@ -700,7 +742,11 @@ const statusCommand = {
700
742
  apiUrl: apiKey.isOk() ? apiKey.value.apiUrl : null,
701
743
  chat: {
702
744
  authenticated: session.isOk(),
703
- appUrl: session.isOk() ? session.value.appUrl : null
745
+ appUrl: session.isOk() ? session.value.appUrl : null,
746
+ email: identity?.email ?? null,
747
+ name: identity?.name ?? null,
748
+ workspaceId: identity?.activeWorkspaceId ?? null,
749
+ workspaceName: identity?.activeWorkspaceName ?? null
704
750
  },
705
751
  configPath: getConfigPath()
706
752
  });
@@ -718,6 +764,15 @@ const statusCommand = {
718
764
  if (session.isOk()) {
719
765
  console.log("Chat session:");
720
766
  console.log(` App: ${session.value.appUrl}`);
767
+ if (identity?.email || identity?.name) {
768
+ const who = identity.email ?? identity.name;
769
+ const suffix = identity.email && identity.name ? ` (${identity.name})` : "";
770
+ console.log(` User: ${who}${suffix}`);
771
+ }
772
+ if (identity?.activeWorkspaceName || identity?.activeWorkspaceId) {
773
+ const ws = identity.activeWorkspaceName ?? identity.activeWorkspaceId;
774
+ console.log(` Space: ${ws}`);
775
+ }
721
776
  } else console.log("Chat session: not signed in.");
722
777
  console.log(`Config: ${getConfigPath()}`);
723
778
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skydive-cli",
3
- "version": "0.1.0-beta.87",
3
+ "version": "0.1.0-beta.89",
4
4
  "description": "Skydive CLI — manage AI agents from the command line",
5
5
  "homepage": "https://skydive.com",
6
6
  "license": "MIT",