primcli 3.0.0-preview.4 → 3.0.0-preview.6

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.
@@ -1 +1 @@
1
- export { s as runBackgroundListenSupervisor } from "../listen-background-C0F9gNDD.js";
1
+ export { l as runBackgroundListenSupervisor } from "../listen-background-DyBYca28.js";
@@ -1,7 +1,7 @@
1
1
  import { N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, j as AGENT_PROFILE_ENV } from "../cli-config-Ms_0vNjq.js";
2
- import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-C0F9gNDD.js";
3
- import { d as SESSION_UUID, t as notificationScope } from "../notify-session-aMGIFmeu.js";
4
- import { It as detectAgentRuntime } from "../api-command-BFfgKPTp.js";
2
+ import { a as backgroundListenStatus, i as backgroundListenRestartable, s as claimBackgroundListenRestart, t as BACKGROUND_LISTEN_RELAUNCH_ENV } from "../listen-background-DyBYca28.js";
3
+ import { d as SESSION_UUID, t as notificationScope } from "../notify-session-DTyg-sfS.js";
4
+ import { It as detectAgentRuntime } from "../api-command-CRjIK1QL.js";
5
5
  import { d as readMailJson } from "../shared-mail-files-BAQSGxxz.js";
6
6
  import { join } from "node:path";
7
7
  import { spawn } from "node:child_process";
@@ -66,6 +66,7 @@ function healSelectedReceiver(options = {}) {
66
66
  PRIMITIVE_CONFIG_DIR: configDir,
67
67
  [RECEIVER_HEAL_ENV]: "0"
68
68
  };
69
+ delete childEnv[BACKGROUND_LISTEN_RELAUNCH_ENV];
69
70
  (options.spawnListener ?? spawnDetached)(listenArgv, childEnv);
70
71
  return {
71
72
  action: "restarting",
@@ -31,23 +31,23 @@ function readRootCredentials(configDir) {
31
31
  return null;
32
32
  }
33
33
  }
34
- function accountEndpoint(apiBaseUrl) {
35
- return `${apiBaseUrl.replace(/\/+$/, "")}/account`;
34
+ function whoamiEndpoint(apiBaseUrl) {
35
+ return `${apiBaseUrl.replace(/\/+$/, "")}/whoami`;
36
36
  }
37
- function parseRootAccount(payload) {
37
+ function parseRootIdentity(payload) {
38
38
  if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return null;
39
39
  const data = payload.data;
40
40
  if (data === null || typeof data !== "object" || Array.isArray(data)) return null;
41
- const account = data;
42
- if (typeof account.email !== "string" || !account.email.trim()) return null;
43
- if (typeof account.id !== "string" || !account.id.trim()) return null;
41
+ const identity = data;
42
+ if (typeof identity.org_id !== "string" || !identity.org_id.trim()) return null;
43
+ const member = identity.member_address;
44
44
  return {
45
- email: account.email,
46
- id: account.id
45
+ memberAddress: member && typeof member.address === "string" && member.address.trim() ? member.address : null,
46
+ orgId: identity.org_id
47
47
  };
48
48
  }
49
- function rootAuthLine(account) {
50
- return `Signed in as ${account.email} (org ${account.id})\n\n`;
49
+ function rootAuthLine(identity) {
50
+ return identity.memberAddress ? `Signed in as ${identity.memberAddress} (org ${identity.orgId})\n\n` : `Signed in (org ${identity.orgId})\n\n`;
51
51
  }
52
52
  function rootRequestConfig(configDir, env) {
53
53
  const config = loadCliConfig(configDir);
@@ -60,11 +60,11 @@ function rootRequestConfig(configDir, env) {
60
60
  headers: currentEnvironment?.config.headers
61
61
  };
62
62
  }
63
- async function fetchRootAccount(params) {
63
+ async function fetchRootIdentity(params) {
64
64
  const controller = new AbortController();
65
65
  const timer = setTimeout(() => controller.abort(), params.timeoutMs);
66
66
  try {
67
- const response = await params.fetch(accountEndpoint(params.apiBaseUrl), {
67
+ const response = await params.fetch(whoamiEndpoint(params.apiBaseUrl), {
68
68
  headers: {
69
69
  ...params.headers ?? {},
70
70
  accept: "application/json",
@@ -73,7 +73,7 @@ async function fetchRootAccount(params) {
73
73
  signal: controller.signal
74
74
  });
75
75
  if (!response.ok) return null;
76
- return parseRootAccount(await response.json().catch(() => null));
76
+ return parseRootIdentity(await response.json().catch(() => null));
77
77
  } catch {
78
78
  return null;
79
79
  } finally {
@@ -95,14 +95,14 @@ async function rootSignedInSummary(options = {}) {
95
95
  const stored = explicitApiKey ? null : readRootCredentials(configDir);
96
96
  const apiKey = explicitApiKey || stored?.accessToken;
97
97
  if (!apiKey) return null;
98
- const account = await fetchRootAccount({
98
+ const identity = await fetchRootIdentity({
99
99
  apiBaseUrl: stored?.apiBaseUrl ?? requestConfig.apiBaseUrl,
100
100
  apiKey,
101
101
  fetch: options.fetch ?? fetch,
102
102
  headers: requestConfig.headers,
103
103
  timeoutMs: options.timeoutMs ?? ROOT_AUTH_TIMEOUT_MS
104
104
  });
105
- return account ? rootAuthLine(account) : null;
105
+ return identity ? rootAuthLine(identity) : null;
106
106
  }
107
107
  function shouldShowLoggedOutSignupHint(options = {}) {
108
108
  if ((options.argv ?? process.argv.slice(2)).length > 0) return false;