@rehpic/vcli 0.1.0-beta.42.1 → 0.1.0-beta.44.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 +245 -102
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -9,6 +9,203 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/menubar.ts
|
|
13
|
+
var menubar_exports = {};
|
|
14
|
+
__export(menubar_exports, {
|
|
15
|
+
startMenuBar: () => startMenuBar
|
|
16
|
+
});
|
|
17
|
+
import SysTray from "systray2";
|
|
18
|
+
import { existsSync, readFileSync } from "fs";
|
|
19
|
+
import { homedir as homedir2 } from "os";
|
|
20
|
+
import { join } from "path";
|
|
21
|
+
import { execSync } from "child_process";
|
|
22
|
+
function loadIconBase64() {
|
|
23
|
+
const iconPath = join(CONFIG_DIR, "assets", "vector-menubar.png");
|
|
24
|
+
if (existsSync(iconPath)) {
|
|
25
|
+
return readFileSync(iconPath).toString("base64");
|
|
26
|
+
}
|
|
27
|
+
return "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
28
|
+
}
|
|
29
|
+
function loadConfig() {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(readFileSync(BRIDGE_CONFIG_FILE, "utf-8"));
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function loadActivities() {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(readFileSync(LIVE_ACTIVITIES_FILE, "utf-8"));
|
|
39
|
+
} catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function isBridgeRunning() {
|
|
44
|
+
try {
|
|
45
|
+
const pid = Number(readFileSync(PID_FILE, "utf-8").trim());
|
|
46
|
+
process.kill(pid, 0);
|
|
47
|
+
return { running: true, pid };
|
|
48
|
+
} catch {
|
|
49
|
+
return { running: false };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function getOrgSlug() {
|
|
53
|
+
try {
|
|
54
|
+
const session = JSON.parse(
|
|
55
|
+
readFileSync(join(CONFIG_DIR, "cli-default.json"), "utf-8")
|
|
56
|
+
);
|
|
57
|
+
return session.activeOrgSlug ?? "oss-lab";
|
|
58
|
+
} catch {
|
|
59
|
+
return "oss-lab";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function providerLabel(provider) {
|
|
63
|
+
if (provider === "claude_code") return "Claude";
|
|
64
|
+
if (provider === "codex") return "Codex";
|
|
65
|
+
return provider;
|
|
66
|
+
}
|
|
67
|
+
function buildMenu() {
|
|
68
|
+
const config = loadConfig();
|
|
69
|
+
const { running, pid } = isBridgeRunning();
|
|
70
|
+
const activities = loadActivities();
|
|
71
|
+
const items = [];
|
|
72
|
+
const actions = /* @__PURE__ */ new Map();
|
|
73
|
+
let idx = 0;
|
|
74
|
+
if (running && config) {
|
|
75
|
+
items.push({
|
|
76
|
+
title: `Vector Bridge \u2014 Running (PID ${pid})`,
|
|
77
|
+
enabled: false
|
|
78
|
+
});
|
|
79
|
+
idx++;
|
|
80
|
+
items.push({ title: ` ${config.displayName}`, enabled: false });
|
|
81
|
+
idx++;
|
|
82
|
+
} else if (config) {
|
|
83
|
+
items.push({ title: "Vector Bridge \u2014 Offline", enabled: false });
|
|
84
|
+
idx++;
|
|
85
|
+
} else {
|
|
86
|
+
items.push({ title: "Vector Bridge \u2014 Not Configured", enabled: false });
|
|
87
|
+
idx++;
|
|
88
|
+
items.push({
|
|
89
|
+
title: " Run: vcli service start",
|
|
90
|
+
enabled: false
|
|
91
|
+
});
|
|
92
|
+
idx++;
|
|
93
|
+
}
|
|
94
|
+
items.push({ title: "---", enabled: false });
|
|
95
|
+
idx++;
|
|
96
|
+
if (activities.length > 0) {
|
|
97
|
+
items.push({ title: "Active Sessions", enabled: false });
|
|
98
|
+
idx++;
|
|
99
|
+
const orgSlug = getOrgSlug();
|
|
100
|
+
for (const a of activities) {
|
|
101
|
+
const label = `${a.issueKey} \u2014 ${a.title ?? a.issueTitle} (${providerLabel(a.provider)})`;
|
|
102
|
+
items.push({ title: label, tooltip: a.latestSummary });
|
|
103
|
+
const issueKey = a.issueKey;
|
|
104
|
+
actions.set(idx, () => {
|
|
105
|
+
const url = `http://localhost:3000/${orgSlug}/issues/${issueKey}`;
|
|
106
|
+
try {
|
|
107
|
+
execSync(`open "${url}"`, { stdio: "ignore" });
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
idx++;
|
|
112
|
+
}
|
|
113
|
+
items.push({ title: "---", enabled: false });
|
|
114
|
+
idx++;
|
|
115
|
+
}
|
|
116
|
+
if (running) {
|
|
117
|
+
items.push({ title: "Stop Bridge" });
|
|
118
|
+
actions.set(idx, () => {
|
|
119
|
+
try {
|
|
120
|
+
if (pid) process.kill(pid, "SIGTERM");
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
idx++;
|
|
125
|
+
items.push({ title: "Restart Bridge" });
|
|
126
|
+
actions.set(idx, () => {
|
|
127
|
+
try {
|
|
128
|
+
if (pid) process.kill(pid, "SIGTERM");
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
execSync("vcli service start", { stdio: "ignore" });
|
|
131
|
+
}, 2e3);
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
idx++;
|
|
136
|
+
} else if (config) {
|
|
137
|
+
items.push({ title: "Start Bridge" });
|
|
138
|
+
actions.set(idx, () => {
|
|
139
|
+
try {
|
|
140
|
+
execSync("vcli service start", { stdio: "ignore" });
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
idx++;
|
|
145
|
+
}
|
|
146
|
+
items.push({ title: "---", enabled: false });
|
|
147
|
+
idx++;
|
|
148
|
+
items.push({ title: "Open Vector" });
|
|
149
|
+
actions.set(idx, () => {
|
|
150
|
+
try {
|
|
151
|
+
execSync("open http://localhost:3000", { stdio: "ignore" });
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
idx++;
|
|
156
|
+
items.push({ title: "Quit" });
|
|
157
|
+
actions.set(idx, () => {
|
|
158
|
+
process.exit(0);
|
|
159
|
+
});
|
|
160
|
+
idx++;
|
|
161
|
+
return { items, actions };
|
|
162
|
+
}
|
|
163
|
+
async function startMenuBar() {
|
|
164
|
+
const icon = loadIconBase64();
|
|
165
|
+
const { items, actions } = buildMenu();
|
|
166
|
+
const systray = new SysTray({
|
|
167
|
+
menu: {
|
|
168
|
+
icon,
|
|
169
|
+
title: "",
|
|
170
|
+
tooltip: "Vector Bridge",
|
|
171
|
+
items: items.map((item) => ({
|
|
172
|
+
title: item.title,
|
|
173
|
+
tooltip: item.tooltip ?? "",
|
|
174
|
+
checked: item.checked ?? false,
|
|
175
|
+
enabled: item.enabled ?? true,
|
|
176
|
+
hidden: false
|
|
177
|
+
}))
|
|
178
|
+
},
|
|
179
|
+
debug: false,
|
|
180
|
+
copyDir: false
|
|
181
|
+
});
|
|
182
|
+
void systray.onClick((action) => {
|
|
183
|
+
const handler = actions.get(action.seq_id);
|
|
184
|
+
if (handler) handler();
|
|
185
|
+
});
|
|
186
|
+
setInterval(() => {
|
|
187
|
+
const { items: newItems, actions: newActions } = buildMenu();
|
|
188
|
+
void newItems;
|
|
189
|
+
void newActions;
|
|
190
|
+
}, 15e3);
|
|
191
|
+
}
|
|
192
|
+
var CONFIG_DIR, BRIDGE_CONFIG_FILE, PID_FILE, LIVE_ACTIVITIES_FILE;
|
|
193
|
+
var init_menubar = __esm({
|
|
194
|
+
"src/menubar.ts"() {
|
|
195
|
+
"use strict";
|
|
196
|
+
CONFIG_DIR = join(homedir2(), ".vector");
|
|
197
|
+
BRIDGE_CONFIG_FILE = join(CONFIG_DIR, "bridge.json");
|
|
198
|
+
PID_FILE = join(CONFIG_DIR, "bridge.pid");
|
|
199
|
+
LIVE_ACTIVITIES_FILE = join(CONFIG_DIR, "live-activities.json");
|
|
200
|
+
if (process.argv[1]?.endsWith("menubar.ts") || process.argv[1]?.endsWith("menubar.js")) {
|
|
201
|
+
startMenuBar().catch((e) => {
|
|
202
|
+
console.error("Menu bar error:", e);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
12
209
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
13
210
|
import fs from "fs";
|
|
14
211
|
function hasDockerEnv() {
|
|
@@ -735,10 +932,10 @@ var init_open = __esm({
|
|
|
735
932
|
}
|
|
736
933
|
});
|
|
737
934
|
|
|
738
|
-
//
|
|
739
|
-
import { readFileSync as
|
|
935
|
+
// src/index.ts
|
|
936
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
740
937
|
import { readFile as readFile2 } from "fs/promises";
|
|
741
|
-
import { dirname, extname, join as
|
|
938
|
+
import { dirname, extname, join as join3 } from "path";
|
|
742
939
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
743
940
|
import { config as loadEnv } from "dotenv";
|
|
744
941
|
import { Command } from "commander";
|
|
@@ -749,7 +946,7 @@ import { anyApi, componentsGeneric } from "convex/server";
|
|
|
749
946
|
var api = anyApi;
|
|
750
947
|
var components = componentsGeneric();
|
|
751
948
|
|
|
752
|
-
//
|
|
949
|
+
// src/auth.ts
|
|
753
950
|
import { isCancel, password as passwordPrompt, text } from "@clack/prompts";
|
|
754
951
|
function buildUrl(appUrl, pathname) {
|
|
755
952
|
return new URL(pathname, appUrl).toString();
|
|
@@ -989,7 +1186,7 @@ async function promptSecret(question) {
|
|
|
989
1186
|
return String(value);
|
|
990
1187
|
}
|
|
991
1188
|
|
|
992
|
-
//
|
|
1189
|
+
// src/convex.ts
|
|
993
1190
|
import { ConvexHttpClient } from "convex/browser";
|
|
994
1191
|
async function createConvexClient(session, appUrl, convexUrl) {
|
|
995
1192
|
const { token } = await fetchConvexToken(session, appUrl);
|
|
@@ -1007,7 +1204,7 @@ async function runAction(client, ref, ...args) {
|
|
|
1007
1204
|
return await client.action(ref, ...args);
|
|
1008
1205
|
}
|
|
1009
1206
|
|
|
1010
|
-
//
|
|
1207
|
+
// src/output.ts
|
|
1011
1208
|
function simplify(value) {
|
|
1012
1209
|
if (value === null || value === void 0) {
|
|
1013
1210
|
return value;
|
|
@@ -1054,7 +1251,7 @@ function printOutput(data, json = false) {
|
|
|
1054
1251
|
console.log(String(data));
|
|
1055
1252
|
}
|
|
1056
1253
|
|
|
1057
|
-
//
|
|
1254
|
+
// src/session.ts
|
|
1058
1255
|
import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
1059
1256
|
import { homedir } from "os";
|
|
1060
1257
|
import path from "path";
|
|
@@ -1094,40 +1291,40 @@ function createEmptySession() {
|
|
|
1094
1291
|
};
|
|
1095
1292
|
}
|
|
1096
1293
|
|
|
1097
|
-
//
|
|
1294
|
+
// src/bridge-service.ts
|
|
1098
1295
|
import { ConvexHttpClient as ConvexHttpClient2 } from "convex/browser";
|
|
1099
|
-
import { execSync } from "child_process";
|
|
1296
|
+
import { execSync as execSync2 } from "child_process";
|
|
1100
1297
|
import {
|
|
1101
|
-
existsSync,
|
|
1298
|
+
existsSync as existsSync2,
|
|
1102
1299
|
mkdirSync,
|
|
1103
|
-
readFileSync,
|
|
1300
|
+
readFileSync as readFileSync2,
|
|
1104
1301
|
writeFileSync,
|
|
1105
1302
|
unlinkSync
|
|
1106
1303
|
} from "fs";
|
|
1107
|
-
import { homedir as
|
|
1108
|
-
import { join } from "path";
|
|
1304
|
+
import { homedir as homedir3, hostname, platform } from "os";
|
|
1305
|
+
import { join as join2 } from "path";
|
|
1109
1306
|
import { randomUUID } from "crypto";
|
|
1110
|
-
var
|
|
1111
|
-
var
|
|
1112
|
-
var
|
|
1113
|
-
var LIVE_ACTIVITIES_CACHE =
|
|
1114
|
-
var LAUNCHAGENT_DIR =
|
|
1115
|
-
var LAUNCHAGENT_PLIST =
|
|
1307
|
+
var CONFIG_DIR2 = join2(homedir3(), ".vector");
|
|
1308
|
+
var BRIDGE_CONFIG_FILE2 = join2(CONFIG_DIR2, "bridge.json");
|
|
1309
|
+
var PID_FILE2 = join2(CONFIG_DIR2, "bridge.pid");
|
|
1310
|
+
var LIVE_ACTIVITIES_CACHE = join2(CONFIG_DIR2, "live-activities.json");
|
|
1311
|
+
var LAUNCHAGENT_DIR = join2(homedir3(), "Library", "LaunchAgents");
|
|
1312
|
+
var LAUNCHAGENT_PLIST = join2(LAUNCHAGENT_DIR, "com.vector.bridge.plist");
|
|
1116
1313
|
var LAUNCHAGENT_LABEL = "com.vector.bridge";
|
|
1117
1314
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
1118
1315
|
var COMMAND_POLL_INTERVAL_MS = 5e3;
|
|
1119
1316
|
var PROCESS_DISCOVERY_INTERVAL_MS = 6e4;
|
|
1120
1317
|
function loadBridgeConfig() {
|
|
1121
|
-
if (!
|
|
1318
|
+
if (!existsSync2(BRIDGE_CONFIG_FILE2)) return null;
|
|
1122
1319
|
try {
|
|
1123
|
-
return JSON.parse(
|
|
1320
|
+
return JSON.parse(readFileSync2(BRIDGE_CONFIG_FILE2, "utf-8"));
|
|
1124
1321
|
} catch {
|
|
1125
1322
|
return null;
|
|
1126
1323
|
}
|
|
1127
1324
|
}
|
|
1128
1325
|
function saveBridgeConfig(config) {
|
|
1129
|
-
if (!
|
|
1130
|
-
writeFileSync(
|
|
1326
|
+
if (!existsSync2(CONFIG_DIR2)) mkdirSync(CONFIG_DIR2, { recursive: true });
|
|
1327
|
+
writeFileSync(BRIDGE_CONFIG_FILE2, JSON.stringify(config, null, 2));
|
|
1131
1328
|
}
|
|
1132
1329
|
function discoverLocalProcesses() {
|
|
1133
1330
|
const processes = [];
|
|
@@ -1142,7 +1339,7 @@ function discoverLocalProcesses() {
|
|
|
1142
1339
|
];
|
|
1143
1340
|
for (const { grep, provider, label, prefix } of patterns) {
|
|
1144
1341
|
try {
|
|
1145
|
-
const ps =
|
|
1342
|
+
const ps = execSync2(
|
|
1146
1343
|
`ps aux | grep -E '${grep}' | grep -v vector-bridge | grep -v grep`,
|
|
1147
1344
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
1148
1345
|
);
|
|
@@ -1151,7 +1348,7 @@ function discoverLocalProcesses() {
|
|
|
1151
1348
|
if (!pid) continue;
|
|
1152
1349
|
let cwd;
|
|
1153
1350
|
try {
|
|
1154
|
-
cwd =
|
|
1351
|
+
cwd = execSync2(
|
|
1155
1352
|
`lsof -p ${pid} 2>/dev/null | grep cwd | awk '{print $NF}'`,
|
|
1156
1353
|
{ encoding: "utf-8", timeout: 3e3 }
|
|
1157
1354
|
).trim() || void 0;
|
|
@@ -1177,12 +1374,12 @@ function discoverLocalProcesses() {
|
|
|
1177
1374
|
}
|
|
1178
1375
|
function getGitInfo(cwd) {
|
|
1179
1376
|
try {
|
|
1180
|
-
const branch =
|
|
1377
|
+
const branch = execSync2("git rev-parse --abbrev-ref HEAD", {
|
|
1181
1378
|
encoding: "utf-8",
|
|
1182
1379
|
cwd,
|
|
1183
1380
|
timeout: 3e3
|
|
1184
1381
|
}).trim();
|
|
1185
|
-
const repoRoot =
|
|
1382
|
+
const repoRoot = execSync2("git rev-parse --show-toplevel", {
|
|
1186
1383
|
encoding: "utf-8",
|
|
1187
1384
|
cwd,
|
|
1188
1385
|
timeout: 3e3
|
|
@@ -1295,8 +1492,8 @@ var BridgeService = class {
|
|
|
1295
1492
|
console.log(` Convex: ${this.config.convexUrl}`);
|
|
1296
1493
|
console.log(` PID: ${process.pid}`);
|
|
1297
1494
|
console.log("");
|
|
1298
|
-
if (!
|
|
1299
|
-
writeFileSync(
|
|
1495
|
+
if (!existsSync2(CONFIG_DIR2)) mkdirSync(CONFIG_DIR2, { recursive: true });
|
|
1496
|
+
writeFileSync(PID_FILE2, String(process.pid));
|
|
1300
1497
|
await this.heartbeat();
|
|
1301
1498
|
await this.reportProcesses();
|
|
1302
1499
|
await this.refreshLiveActivities();
|
|
@@ -1330,7 +1527,7 @@ var BridgeService = class {
|
|
|
1330
1527
|
[${ts()}] Shutting down...`);
|
|
1331
1528
|
for (const t of this.timers) clearInterval(t);
|
|
1332
1529
|
try {
|
|
1333
|
-
unlinkSync(
|
|
1530
|
+
unlinkSync(PID_FILE2);
|
|
1334
1531
|
} catch {
|
|
1335
1532
|
}
|
|
1336
1533
|
process.exit(0);
|
|
@@ -1393,9 +1590,9 @@ function installLaunchAgent(vcliPath) {
|
|
|
1393
1590
|
<key>KeepAlive</key>
|
|
1394
1591
|
<true/>
|
|
1395
1592
|
<key>StandardOutPath</key>
|
|
1396
|
-
<string>${
|
|
1593
|
+
<string>${CONFIG_DIR2}/bridge.log</string>
|
|
1397
1594
|
<key>StandardErrorPath</key>
|
|
1398
|
-
<string>${
|
|
1595
|
+
<string>${CONFIG_DIR2}/bridge.err.log</string>
|
|
1399
1596
|
<key>EnvironmentVariables</key>
|
|
1400
1597
|
<dict>
|
|
1401
1598
|
<key>PATH</key>
|
|
@@ -1404,11 +1601,11 @@ function installLaunchAgent(vcliPath) {
|
|
|
1404
1601
|
</dict>
|
|
1405
1602
|
</plist>`;
|
|
1406
1603
|
const menuBarCandidates = [
|
|
1407
|
-
|
|
1604
|
+
join2(CONFIG_DIR2, "VectorMenuBar"),
|
|
1408
1605
|
"/usr/local/bin/VectorMenuBar",
|
|
1409
|
-
|
|
1606
|
+
join2(homedir3(), ".local", "bin", "VectorMenuBar")
|
|
1410
1607
|
];
|
|
1411
|
-
const menuBarBinary = menuBarCandidates.find((p) =>
|
|
1608
|
+
const menuBarBinary = menuBarCandidates.find((p) => existsSync2(p));
|
|
1412
1609
|
if (menuBarBinary) {
|
|
1413
1610
|
const menuBarPlist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
1414
1611
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -1426,15 +1623,15 @@ function installLaunchAgent(vcliPath) {
|
|
|
1426
1623
|
<false/>
|
|
1427
1624
|
</dict>
|
|
1428
1625
|
</plist>`;
|
|
1429
|
-
const menuBarPlistPath =
|
|
1626
|
+
const menuBarPlistPath = join2(LAUNCHAGENT_DIR, "com.vector.menubar.plist");
|
|
1430
1627
|
writeFileSync(menuBarPlistPath, menuBarPlist);
|
|
1431
1628
|
try {
|
|
1432
|
-
|
|
1629
|
+
execSync2(`launchctl load ${menuBarPlistPath}`, { stdio: "pipe" });
|
|
1433
1630
|
console.log("Menu bar helper installed.");
|
|
1434
1631
|
} catch {
|
|
1435
1632
|
}
|
|
1436
1633
|
}
|
|
1437
|
-
if (!
|
|
1634
|
+
if (!existsSync2(LAUNCHAGENT_DIR)) {
|
|
1438
1635
|
mkdirSync(LAUNCHAGENT_DIR, { recursive: true });
|
|
1439
1636
|
}
|
|
1440
1637
|
writeFileSync(LAUNCHAGENT_PLIST, plist);
|
|
@@ -1442,7 +1639,7 @@ function installLaunchAgent(vcliPath) {
|
|
|
1442
1639
|
}
|
|
1443
1640
|
function loadLaunchAgent() {
|
|
1444
1641
|
try {
|
|
1445
|
-
|
|
1642
|
+
execSync2(`launchctl load ${LAUNCHAGENT_PLIST}`, { stdio: "inherit" });
|
|
1446
1643
|
console.log(
|
|
1447
1644
|
"LaunchAgent loaded. Bridge will start automatically on login."
|
|
1448
1645
|
);
|
|
@@ -1452,7 +1649,7 @@ function loadLaunchAgent() {
|
|
|
1452
1649
|
}
|
|
1453
1650
|
function unloadLaunchAgent() {
|
|
1454
1651
|
try {
|
|
1455
|
-
|
|
1652
|
+
execSync2(`launchctl unload ${LAUNCHAGENT_PLIST}`, { stdio: "inherit" });
|
|
1456
1653
|
console.log("LaunchAgent unloaded.");
|
|
1457
1654
|
} catch {
|
|
1458
1655
|
console.error("Failed to unload LaunchAgent (may not be loaded)");
|
|
@@ -1466,64 +1663,10 @@ function uninstallLaunchAgent() {
|
|
|
1466
1663
|
} catch {
|
|
1467
1664
|
}
|
|
1468
1665
|
}
|
|
1469
|
-
async function compileMenuBar() {
|
|
1470
|
-
if (platform() !== "darwin") return null;
|
|
1471
|
-
const binaryPath = join(CONFIG_DIR, "VectorMenuBar");
|
|
1472
|
-
if (existsSync(binaryPath)) return binaryPath;
|
|
1473
|
-
const sourceCandidates = [
|
|
1474
|
-
join(CONFIG_DIR, "VectorMenuBar.swift"),
|
|
1475
|
-
// In the repo checkout (dev mode)
|
|
1476
|
-
join(process.cwd(), "cli", "macos", "VectorMenuBar.swift")
|
|
1477
|
-
];
|
|
1478
|
-
const source = sourceCandidates.find((p) => existsSync(p));
|
|
1479
|
-
if (!source) return null;
|
|
1480
|
-
try {
|
|
1481
|
-
execSync("which swiftc", { stdio: "pipe" });
|
|
1482
|
-
} catch {
|
|
1483
|
-
return null;
|
|
1484
|
-
}
|
|
1485
|
-
try {
|
|
1486
|
-
console.log("Compiling menu bar app...");
|
|
1487
|
-
execSync(`swiftc -o "${binaryPath}" "${source}" -framework AppKit`, {
|
|
1488
|
-
stdio: "pipe",
|
|
1489
|
-
timeout: 3e4
|
|
1490
|
-
});
|
|
1491
|
-
const sourceDir = join(source, "..", "assets");
|
|
1492
|
-
const destDir = join(CONFIG_DIR, "assets");
|
|
1493
|
-
if (existsSync(sourceDir)) {
|
|
1494
|
-
mkdirSync(destDir, { recursive: true });
|
|
1495
|
-
for (const f of ["vector-menubar.png", "vector-menubar@2x.png"]) {
|
|
1496
|
-
const src = join(sourceDir, f);
|
|
1497
|
-
if (existsSync(src)) {
|
|
1498
|
-
writeFileSync(join(destDir, f), readFileSync(src));
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
console.log("Menu bar app compiled.");
|
|
1503
|
-
return binaryPath;
|
|
1504
|
-
} catch {
|
|
1505
|
-
console.error(
|
|
1506
|
-
"Failed to compile menu bar app (Xcode CLI tools may be needed)."
|
|
1507
|
-
);
|
|
1508
|
-
return null;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
1666
|
async function launchMenuBar() {
|
|
1512
|
-
if (platform() !== "darwin") return;
|
|
1513
|
-
const candidates = [
|
|
1514
|
-
join(CONFIG_DIR, "VectorMenuBar"),
|
|
1515
|
-
"/usr/local/bin/VectorMenuBar",
|
|
1516
|
-
join(homedir2(), ".local", "bin", "VectorMenuBar")
|
|
1517
|
-
];
|
|
1518
|
-
let binary = candidates.find((p) => existsSync(p));
|
|
1519
|
-
if (!binary) {
|
|
1520
|
-
binary = await compileMenuBar() ?? void 0;
|
|
1521
|
-
}
|
|
1522
|
-
if (!binary) return;
|
|
1523
1667
|
try {
|
|
1524
|
-
const {
|
|
1525
|
-
|
|
1526
|
-
child.unref();
|
|
1668
|
+
const { startMenuBar: startMenuBar2 } = await Promise.resolve().then(() => (init_menubar(), menubar_exports));
|
|
1669
|
+
void startMenuBar2();
|
|
1527
1670
|
console.log("Menu bar started.");
|
|
1528
1671
|
} catch {
|
|
1529
1672
|
}
|
|
@@ -1533,8 +1676,8 @@ function getBridgeStatus() {
|
|
|
1533
1676
|
if (!config) return { configured: false, running: false };
|
|
1534
1677
|
let running = false;
|
|
1535
1678
|
let pid;
|
|
1536
|
-
if (
|
|
1537
|
-
const pidStr =
|
|
1679
|
+
if (existsSync2(PID_FILE2)) {
|
|
1680
|
+
const pidStr = readFileSync2(PID_FILE2, "utf-8").trim();
|
|
1538
1681
|
pid = Number(pidStr);
|
|
1539
1682
|
try {
|
|
1540
1683
|
process.kill(pid, 0);
|
|
@@ -1546,8 +1689,8 @@ function getBridgeStatus() {
|
|
|
1546
1689
|
return { configured: true, running, pid, config };
|
|
1547
1690
|
}
|
|
1548
1691
|
function stopBridge() {
|
|
1549
|
-
if (!
|
|
1550
|
-
const pid = Number(
|
|
1692
|
+
if (!existsSync2(PID_FILE2)) return false;
|
|
1693
|
+
const pid = Number(readFileSync2(PID_FILE2, "utf-8").trim());
|
|
1551
1694
|
try {
|
|
1552
1695
|
process.kill(pid, "SIGTERM");
|
|
1553
1696
|
return true;
|
|
@@ -1559,7 +1702,7 @@ function ts() {
|
|
|
1559
1702
|
return (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
1560
1703
|
}
|
|
1561
1704
|
|
|
1562
|
-
//
|
|
1705
|
+
// src/index.ts
|
|
1563
1706
|
import { platform as osPlatform } from "os";
|
|
1564
1707
|
loadEnv({ path: ".env.local", override: false });
|
|
1565
1708
|
loadEnv({ path: ".env", override: false });
|
|
@@ -2003,7 +2146,7 @@ var program = new Command();
|
|
|
2003
2146
|
function readPackageVersionSync() {
|
|
2004
2147
|
try {
|
|
2005
2148
|
const dir = import.meta.dirname ?? dirname(fileURLToPath2(import.meta.url));
|
|
2006
|
-
const raw =
|
|
2149
|
+
const raw = readFileSync3(join3(dir, "..", "package.json"), "utf8");
|
|
2007
2150
|
return JSON.parse(raw).version ?? "unknown";
|
|
2008
2151
|
} catch {
|
|
2009
2152
|
return "unknown";
|