@rehpic/vcli 0.1.0-beta.44.1 → 0.1.0-beta.46.1

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/index.js CHANGED
@@ -49,6 +49,19 @@ function isBridgeRunning() {
49
49
  return { running: false };
50
50
  }
51
51
  }
52
+ function getSessionInfo() {
53
+ try {
54
+ const session = JSON.parse(
55
+ readFileSync(join(CONFIG_DIR, "cli-default.json"), "utf-8")
56
+ );
57
+ return {
58
+ orgSlug: session.activeOrgSlug ?? "oss-lab",
59
+ appUrl: session.appUrl
60
+ };
61
+ } catch {
62
+ return { orgSlug: "oss-lab" };
63
+ }
64
+ }
52
65
  function getOrgSlug() {
53
66
  try {
54
67
  const session = JSON.parse(
@@ -145,16 +158,37 @@ function buildMenu() {
145
158
  }
146
159
  items.push({ title: "---", enabled: false });
147
160
  idx++;
161
+ if (config) {
162
+ const { orgSlug, appUrl } = getSessionInfo();
163
+ items.push({
164
+ title: `Account: ${config.userId.slice(0, 12)}...`,
165
+ enabled: false
166
+ });
167
+ idx++;
168
+ if (orgSlug) {
169
+ items.push({ title: `Org: ${orgSlug}`, enabled: false });
170
+ idx++;
171
+ }
172
+ items.push({ title: "---", enabled: false });
173
+ idx++;
174
+ }
148
175
  items.push({ title: "Open Vector" });
149
176
  actions.set(idx, () => {
177
+ const { appUrl } = getSessionInfo();
178
+ const url = appUrl ?? "http://localhost:3000";
150
179
  try {
151
- execSync("open http://localhost:3000", { stdio: "ignore" });
180
+ execSync(`open "${url}"`, { stdio: "ignore" });
152
181
  } catch {
153
182
  }
154
183
  });
155
184
  idx++;
156
- items.push({ title: "Quit" });
185
+ items.push({ title: "Quit Vector" });
157
186
  actions.set(idx, () => {
187
+ try {
188
+ const { pid: bridgePid } = isBridgeRunning();
189
+ if (bridgePid) process.kill(bridgePid, "SIGTERM");
190
+ } catch {
191
+ }
158
192
  process.exit(0);
159
193
  });
160
194
  idx++;
@@ -1673,8 +1707,9 @@ async function launchMenuBar() {
1673
1707
  }
1674
1708
  function getBridgeStatus() {
1675
1709
  const config = loadBridgeConfig();
1676
- if (!config) return { configured: false, running: false };
1710
+ if (!config) return { configured: false, running: false, starting: false };
1677
1711
  let running = false;
1712
+ let starting = false;
1678
1713
  let pid;
1679
1714
  if (existsSync2(PID_FILE2)) {
1680
1715
  const pidStr = readFileSync2(PID_FILE2, "utf-8").trim();
@@ -1686,7 +1721,19 @@ function getBridgeStatus() {
1686
1721
  running = false;
1687
1722
  }
1688
1723
  }
1689
- return { configured: true, running, pid, config };
1724
+ if (!running && platform() === "darwin") {
1725
+ try {
1726
+ const result = execSync2(
1727
+ `launchctl list ${LAUNCHAGENT_LABEL} 2>/dev/null`,
1728
+ { encoding: "utf-8", timeout: 3e3 }
1729
+ );
1730
+ if (result.includes(LAUNCHAGENT_LABEL)) {
1731
+ starting = true;
1732
+ }
1733
+ } catch {
1734
+ }
1735
+ }
1736
+ return { configured: true, running, starting, pid, config };
1690
1737
  }
1691
1738
  function stopBridge() {
1692
1739
  if (!existsSync2(PID_FILE2)) return false;
@@ -3722,9 +3769,6 @@ serviceCommand.command("start").description("Start the bridge service via Launch
3722
3769
  loadLaunchAgent();
3723
3770
  await launchMenuBar();
3724
3771
  console.log("Bridge service started.");
3725
- console.log("");
3726
- console.log("Run `vcli service status` to check.");
3727
- console.log("Run `vcli service stop` to stop.");
3728
3772
  } else {
3729
3773
  console.log(
3730
3774
  "Starting bridge in foreground (use systemd for background)..."
@@ -3771,9 +3815,8 @@ serviceCommand.command("status").description("Show bridge service status").actio
3771
3815
  ` Device: ${status.config.displayName} (${status.config.deviceId})`
3772
3816
  );
3773
3817
  console.log(` User: ${status.config.userId}`);
3774
- console.log(
3775
- ` Status: ${status.running ? `Running (PID ${status.pid})` : "Not running"}`
3776
- );
3818
+ const statusLabel = status.running ? `Running (PID ${status.pid})` : status.starting ? "Starting..." : "Not running";
3819
+ console.log(` Status: ${statusLabel}`);
3777
3820
  console.log(` Config: ~/.vector/bridge.json`);
3778
3821
  });
3779
3822
  serviceCommand.command("install").description("Install the bridge as a system service (macOS LaunchAgent)").action(async (_options, command) => {
@@ -3801,14 +3844,9 @@ serviceCommand.command("install").description("Install the bridge as a system se
3801
3844
  const vcliPath = process.argv[1] ?? "vcli";
3802
3845
  installLaunchAgent(vcliPath);
3803
3846
  loadLaunchAgent();
3804
- console.log("");
3805
- console.log("Bridge is now running and will start automatically on login.");
3806
- console.log("");
3807
- console.log("To start the service manually:");
3808
- console.log(" vcli service start");
3809
- console.log("");
3810
- console.log("To check status:");
3811
- console.log(" vcli service status");
3847
+ console.log(
3848
+ "Bridge installed and running. Will start automatically on login."
3849
+ );
3812
3850
  });
3813
3851
  serviceCommand.command("uninstall").description("Uninstall the bridge system service").action(() => {
3814
3852
  uninstallLaunchAgent();