@ssm123ssm/vault 0.1.13 → 0.1.15
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/package.json +1 -1
- package/preview-agent.js +9 -2
package/package.json
CHANGED
package/preview-agent.js
CHANGED
|
@@ -403,6 +403,9 @@ async function linkAgent({ silent = false } = {}) {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
const appUrl = response.appUrl.replace(/\/$/, "");
|
|
406
|
+
if (silent) {
|
|
407
|
+
console.log(`Linking agent via ${appUrl}`);
|
|
408
|
+
}
|
|
406
409
|
const claim = await fetch(`${appUrl}/api/agents/claim`, {
|
|
407
410
|
method: "POST",
|
|
408
411
|
headers: { "Content-Type": "application/json" },
|
|
@@ -422,6 +425,7 @@ async function linkAgent({ silent = false } = {}) {
|
|
|
422
425
|
const data = await claim.json();
|
|
423
426
|
const wsUrlFromEnv = process.env.PREVIEW_AGENT_WS_URL || null;
|
|
424
427
|
const wsUrlFromServer = data.wsUrl || null;
|
|
428
|
+
const resolvedWsUrl = normalizeWsUrl(wsUrlFromEnv || wsUrlFromServer, appUrl);
|
|
425
429
|
const updated = {
|
|
426
430
|
...config,
|
|
427
431
|
appUrl,
|
|
@@ -429,11 +433,13 @@ async function linkAgent({ silent = false } = {}) {
|
|
|
429
433
|
sessionToken: data.sessionToken,
|
|
430
434
|
agentName: response.name || config.agentName || os.hostname(),
|
|
431
435
|
agentKeyPair: keyPair,
|
|
432
|
-
wsUrl:
|
|
436
|
+
wsUrl: resolvedWsUrl,
|
|
433
437
|
};
|
|
434
438
|
await saveConfig(updated);
|
|
435
439
|
if (!silent) {
|
|
436
440
|
console.log(`Linked agent ${data.agentId}.`);
|
|
441
|
+
} else {
|
|
442
|
+
console.log(`Resolved WS URL: ${resolvedWsUrl}`);
|
|
437
443
|
}
|
|
438
444
|
}
|
|
439
445
|
|
|
@@ -666,6 +672,7 @@ function runDaemon() {
|
|
|
666
672
|
let reconnectMs = 2000;
|
|
667
673
|
console.log("Preview agent starting...");
|
|
668
674
|
const daemonMode = hasFlag("--daemon") || hasFlag("--daemon-child");
|
|
675
|
+
const uiMode = hasFlag("--ui");
|
|
669
676
|
|
|
670
677
|
if (hasFlag("--daemon") && !hasFlag("--daemon-child")) {
|
|
671
678
|
const args = process.argv.slice(2).filter((arg) => arg !== "--daemon");
|
|
@@ -769,7 +776,7 @@ function runDaemon() {
|
|
|
769
776
|
keyPair
|
|
770
777
|
);
|
|
771
778
|
const projectName = command.payload?.projectName || null;
|
|
772
|
-
const sourceDir = daemonMode
|
|
779
|
+
const sourceDir = daemonMode || uiMode
|
|
773
780
|
? await selectDirectoryViaServer()
|
|
774
781
|
: await selectDirectory(process.cwd());
|
|
775
782
|
config.projects = config.projects || {};
|