@rehpic/vcli 0.1.0-beta.58.1 → 0.1.0-beta.59.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
|
@@ -1468,6 +1468,7 @@ function getGitInfo(cwd) {
|
|
|
1468
1468
|
// src/bridge-service.ts
|
|
1469
1469
|
var CONFIG_DIR = process.env.VECTOR_HOME?.trim() || join2(homedir3(), ".vector");
|
|
1470
1470
|
var BRIDGE_CONFIG_FILE = join2(CONFIG_DIR, "bridge.json");
|
|
1471
|
+
var DEVICE_KEY_FILE = join2(CONFIG_DIR, "device-key");
|
|
1471
1472
|
var PID_FILE = join2(CONFIG_DIR, "bridge.pid");
|
|
1472
1473
|
var LIVE_ACTIVITIES_CACHE = join2(CONFIG_DIR, "live-activities.json");
|
|
1473
1474
|
var LAUNCHAGENT_DIR = join2(homedir3(), "Library", "LaunchAgents");
|
|
@@ -1492,6 +1493,7 @@ function loadBridgeConfig() {
|
|
|
1492
1493
|
function saveBridgeConfig(config) {
|
|
1493
1494
|
if (!existsSync2(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
|
|
1494
1495
|
writeFileSync(BRIDGE_CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
1496
|
+
persistDeviceKey(config.deviceKey);
|
|
1495
1497
|
}
|
|
1496
1498
|
function writeLiveActivitiesCache(activities) {
|
|
1497
1499
|
if (!existsSync2(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
|
|
@@ -1830,7 +1832,7 @@ var BridgeService = class {
|
|
|
1830
1832
|
}
|
|
1831
1833
|
};
|
|
1832
1834
|
async function setupBridgeDevice(client, convexUrl) {
|
|
1833
|
-
const deviceKey =
|
|
1835
|
+
const deviceKey = getStableDeviceKey();
|
|
1834
1836
|
const displayName = `${process.env.USER ?? "user"}'s ${platform() === "darwin" ? "Mac" : "machine"}`;
|
|
1835
1837
|
const result = await client.mutation(
|
|
1836
1838
|
api.agentBridge.mutations.registerBridgeDevice,
|
|
@@ -1856,6 +1858,28 @@ async function setupBridgeDevice(client, convexUrl) {
|
|
|
1856
1858
|
saveBridgeConfig(config);
|
|
1857
1859
|
return config;
|
|
1858
1860
|
}
|
|
1861
|
+
function getStableDeviceKey() {
|
|
1862
|
+
const existingConfig = loadBridgeConfig();
|
|
1863
|
+
const existingKey = existingConfig?.deviceKey?.trim();
|
|
1864
|
+
if (existingKey) {
|
|
1865
|
+
persistDeviceKey(existingKey);
|
|
1866
|
+
return existingKey;
|
|
1867
|
+
}
|
|
1868
|
+
if (existsSync2(DEVICE_KEY_FILE)) {
|
|
1869
|
+
const savedKey = readFileSync2(DEVICE_KEY_FILE, "utf-8").trim();
|
|
1870
|
+
if (savedKey) {
|
|
1871
|
+
return savedKey;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
const generatedKey = `${hostname()}-${randomUUID().slice(0, 8)}`;
|
|
1875
|
+
persistDeviceKey(generatedKey);
|
|
1876
|
+
return generatedKey;
|
|
1877
|
+
}
|
|
1878
|
+
function persistDeviceKey(deviceKey) {
|
|
1879
|
+
if (!existsSync2(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
|
|
1880
|
+
writeFileSync(DEVICE_KEY_FILE, `${deviceKey}
|
|
1881
|
+
`);
|
|
1882
|
+
}
|
|
1859
1883
|
function buildLaunchPrompt(issueKey, issueTitle, workspacePath) {
|
|
1860
1884
|
return [
|
|
1861
1885
|
`You are working on Vector issue ${issueKey}: ${issueTitle}.`,
|
|
@@ -2516,7 +2540,6 @@ async function ensureBridgeConfig(command) {
|
|
|
2516
2540
|
try {
|
|
2517
2541
|
const runtime = await getRuntime(command);
|
|
2518
2542
|
const session = requireSession(runtime);
|
|
2519
|
-
const authUserId = decodeSessionClaims(session).userId;
|
|
2520
2543
|
const client = await createConvexClient(
|
|
2521
2544
|
session,
|
|
2522
2545
|
runtime.appUrl,
|
|
@@ -2529,13 +2552,14 @@ async function ensureBridgeConfig(command) {
|
|
|
2529
2552
|
const backendDevice = config ? await runQuery(client, api.agentBridge.queries.getDevice, {
|
|
2530
2553
|
deviceId: config.deviceId
|
|
2531
2554
|
}) : null;
|
|
2532
|
-
const needsRegistration = !config ||
|
|
2555
|
+
const needsRegistration = !config || config.userId !== user._id || config.convexUrl !== runtime.convexUrl || !backendDevice;
|
|
2533
2556
|
if (needsRegistration) {
|
|
2534
2557
|
config = await setupBridgeDevice(client, runtime.convexUrl);
|
|
2535
2558
|
}
|
|
2536
2559
|
if (!config) {
|
|
2537
2560
|
throw new Error("Bridge device is not configured.");
|
|
2538
2561
|
}
|
|
2562
|
+
saveBridgeConfig(config);
|
|
2539
2563
|
return config;
|
|
2540
2564
|
} catch (error) {
|
|
2541
2565
|
if (config) {
|