@exla/rudder 4.0.0-alpha.7 → 4.0.0
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/README.md +33 -69
- package/dist/agent-efficiency/backend-observer.d.ts +13 -0
- package/dist/agent-efficiency/backend-observer.js +77 -0
- package/dist/agent-efficiency/backend-observer.js.map +1 -0
- package/dist/agent-efficiency/handoff.d.ts +9 -0
- package/dist/agent-efficiency/handoff.js +42 -0
- package/dist/agent-efficiency/handoff.js.map +1 -0
- package/dist/agent-efficiency/index.d.ts +11 -0
- package/dist/agent-efficiency/index.js +7 -0
- package/dist/agent-efficiency/index.js.map +1 -0
- package/dist/agent-efficiency/lessons.d.ts +55 -0
- package/dist/agent-efficiency/lessons.js +107 -0
- package/dist/agent-efficiency/lessons.js.map +1 -0
- package/dist/agent-efficiency/privacy.d.ts +6 -0
- package/dist/agent-efficiency/privacy.js +28 -0
- package/dist/agent-efficiency/privacy.js.map +1 -0
- package/dist/agent-efficiency/production.d.ts +16 -0
- package/dist/agent-efficiency/production.js +120 -0
- package/dist/agent-efficiency/production.js.map +1 -0
- package/dist/agent-efficiency/storage.d.ts +3 -0
- package/dist/agent-efficiency/storage.js +28 -0
- package/dist/agent-efficiency/storage.js.map +1 -0
- package/dist/agent-efficiency/telemetry.d.ts +59 -0
- package/dist/agent-efficiency/telemetry.js +143 -0
- package/dist/agent-efficiency/telemetry.js.map +1 -0
- package/dist/agent-efficiency/trace-lessons.d.ts +21 -0
- package/dist/agent-efficiency/trace-lessons.js +36 -0
- package/dist/agent-efficiency/trace-lessons.js.map +1 -0
- package/dist/agent-efficiency/waits.d.ts +52 -0
- package/dist/agent-efficiency/waits.js +131 -0
- package/dist/agent-efficiency/waits.js.map +1 -0
- package/dist/backends.js +14 -8
- package/dist/backends.js.map +1 -1
- package/dist/board/authority.d.ts +48 -0
- package/dist/board/authority.js +125 -0
- package/dist/board/authority.js.map +1 -0
- package/dist/board/board.js +6 -2
- package/dist/board/daemon.d.ts +3 -6
- package/dist/board/daemon.js +242 -222
- package/dist/board/daemon.js.map +1 -1
- package/dist/board/host-access.d.ts +8 -0
- package/dist/board/host-access.js +222 -0
- package/dist/board/host-access.js.map +1 -0
- package/dist/board/project-files.d.ts +12 -0
- package/dist/board/project-files.js +78 -0
- package/dist/board/project-files.js.map +1 -0
- package/dist/brain.d.ts +2 -1
- package/dist/brain.js +15 -21
- package/dist/brain.js.map +1 -1
- package/dist/claude-sdk-protocol.js +10 -7
- package/dist/claude-sdk-protocol.js.map +1 -1
- package/dist/cloud-build-profile.d.ts +22 -0
- package/dist/cloud-build-profile.js +160 -0
- package/dist/cloud-build-profile.js.map +1 -0
- package/dist/cloud.js +23 -470
- package/dist/cloud.js.map +1 -1
- package/dist/codex-binary.d.ts +1 -0
- package/dist/codex-binary.js +8 -1
- package/dist/codex-binary.js.map +1 -1
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.js +14 -2
- package/dist/daemon.js.map +1 -1
- package/dist/effort.d.ts +8 -0
- package/dist/effort.js +15 -2
- package/dist/effort.js.map +1 -1
- package/dist/engine-authority.js +16 -0
- package/dist/engine-authority.js.map +1 -1
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +11 -2
- package/dist/engine.js.map +1 -1
- package/dist/fabric-fetch.d.ts +25 -0
- package/dist/fabric-fetch.js +402 -0
- package/dist/fabric-fetch.js.map +1 -0
- package/dist/fabric-local.d.ts +5 -2
- package/dist/fabric-local.js +36 -1
- package/dist/fabric-local.js.map +1 -1
- package/dist/fabric-remote.d.ts +76 -1
- package/dist/fabric-remote.js +333 -61
- package/dist/fabric-remote.js.map +1 -1
- package/dist/git.js +23 -0
- package/dist/git.js.map +1 -1
- package/dist/graph.js +9 -1
- package/dist/graph.js.map +1 -1
- package/dist/jj.d.ts +3 -1
- package/dist/jj.js +34 -2
- package/dist/jj.js.map +1 -1
- package/dist/main.js +102 -310
- package/dist/main.js.map +1 -1
- package/dist/migration.d.ts +2 -0
- package/dist/migration.js +3 -0
- package/dist/migration.js.map +1 -1
- package/dist/models.js +11 -6
- package/dist/models.js.map +1 -1
- package/dist/native/darwin-arm64/native-manifest.json +19 -0
- package/dist/native/darwin-arm64/rudder-jj +0 -0
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/darwin-x64/native-manifest.json +19 -0
- package/dist/native/darwin-x64/rudder-jj +0 -0
- package/dist/native/darwin-x64/rudder-native +0 -0
- package/dist/native/linux-x64/native-manifest.json +19 -0
- package/dist/native/linux-x64/rudder-jj +0 -0
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/native-agents.js +3 -7
- package/dist/native-agents.js.map +1 -1
- package/dist/native-binary.js +11 -1
- package/dist/native-binary.js.map +1 -1
- package/dist/operations/cli.d.ts +23 -0
- package/dist/operations/cli.js +110 -0
- package/dist/operations/cli.js.map +1 -0
- package/dist/operations/registry.d.ts +1076 -0
- package/dist/operations/registry.js +69 -0
- package/dist/operations/registry.js.map +1 -0
- package/dist/operations/registry.json +124 -0
- package/dist/operations/requests.d.ts +167 -0
- package/dist/operations/requests.js +223 -0
- package/dist/operations/requests.js.map +1 -0
- package/dist/planning-ownership/index.d.ts +134 -0
- package/dist/planning-ownership/index.js +291 -0
- package/dist/planning-ownership/index.js.map +1 -0
- package/dist/planning-ownership/ingress.d.ts +30 -0
- package/dist/planning-ownership/ingress.js +41 -0
- package/dist/planning-ownership/ingress.js.map +1 -0
- package/dist/planning-ownership/store.d.ts +19 -0
- package/dist/planning-ownership/store.js +30 -0
- package/dist/planning-ownership/store.js.map +1 -0
- package/dist/private-access/cli.d.ts +22 -0
- package/dist/private-access/cli.js +76 -0
- package/dist/private-access/cli.js.map +1 -0
- package/dist/private-access/engine.d.ts +20 -0
- package/dist/private-access/engine.js +47 -0
- package/dist/private-access/engine.js.map +1 -0
- package/dist/private-access/home.d.ts +21 -0
- package/dist/private-access/home.js +80 -0
- package/dist/private-access/home.js.map +1 -0
- package/dist/private-access/previews.d.ts +101 -0
- package/dist/private-access/previews.js +447 -0
- package/dist/private-access/previews.js.map +1 -0
- package/dist/project-files/cli.d.ts +7 -0
- package/dist/project-files/cli.js +22 -0
- package/dist/project-files/cli.js.map +1 -0
- package/dist/project-files/engine.d.ts +14 -0
- package/dist/project-files/engine.js +52 -0
- package/dist/project-files/engine.js.map +1 -0
- package/dist/project-files/home.d.ts +13 -0
- package/dist/project-files/home.js +46 -0
- package/dist/project-files/home.js.map +1 -0
- package/dist/project-files/http.d.ts +9 -0
- package/dist/project-files/http.js +54 -0
- package/dist/project-files/http.js.map +1 -0
- package/dist/project-files/open.d.ts +10 -0
- package/dist/project-files/open.js +37 -0
- package/dist/project-files/open.js.map +1 -0
- package/dist/project-files/references.d.ts +9 -0
- package/dist/project-files/references.js +29 -0
- package/dist/project-files/references.js.map +1 -0
- package/dist/project-files/service.d.ts +32 -0
- package/dist/project-files/service.js +236 -0
- package/dist/project-files/service.js.map +1 -0
- package/dist/project-files/types.d.ts +40 -0
- package/dist/project-files/types.js +2 -0
- package/dist/project-files/types.js.map +1 -0
- package/dist/run-manager.d.ts +2 -0
- package/dist/run-manager.js +183 -13
- package/dist/run-manager.js.map +1 -1
- package/dist/run-timeline.d.ts +29 -0
- package/dist/run-timeline.js +112 -0
- package/dist/run-timeline.js.map +1 -0
- package/dist/scheduler.js +72 -13
- package/dist/scheduler.js.map +1 -1
- package/dist/surfaces.js +3 -8
- package/dist/surfaces.js.map +1 -1
- package/dist/tailscale-preview.d.ts +6 -2
- package/dist/tailscale-preview.js +58 -13
- package/dist/tailscale-preview.js.map +1 -1
- package/dist/task-routing.d.ts +2 -0
- package/dist/task-routing.js +42 -25
- package/dist/task-routing.js.map +1 -1
- package/dist/terminal-screen.d.ts +6 -0
- package/dist/terminal-screen.js +23 -0
- package/dist/terminal-screen.js.map +1 -0
- package/dist/tool-cache.d.ts +23 -0
- package/dist/tool-cache.js +144 -0
- package/dist/tool-cache.js.map +1 -0
- package/dist/types.d.ts +0 -17
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +8 -0
- package/dist/util.js +38 -2
- package/dist/util.js.map +1 -1
- package/dist/v4-migration/capture.d.ts +53 -0
- package/dist/v4-migration/capture.js +197 -0
- package/dist/v4-migration/capture.js.map +1 -0
- package/dist/v4-migration/cli.d.ts +4 -0
- package/dist/v4-migration/cli.js +38 -0
- package/dist/v4-migration/cli.js.map +1 -0
- package/dist/v4-migration/recovery.d.ts +43 -0
- package/dist/v4-migration/recovery.js +180 -0
- package/dist/v4-migration/recovery.js.map +1 -0
- package/dist/version-check.d.ts +2 -0
- package/dist/version-check.js +23 -0
- package/dist/version-check.js.map +1 -1
- package/dist/warm-snapshot.d.ts +55 -0
- package/dist/warm-snapshot.js +381 -0
- package/dist/warm-snapshot.js.map +1 -0
- package/package.json +4 -3
- package/scripts/copy-native.mjs +35 -48
- package/scripts/native-artifacts.mjs +248 -0
- package/dist/improve/advisor.d.ts +0 -10
- package/dist/improve/advisor.js +0 -115
- package/dist/improve/advisor.js.map +0 -1
- package/dist/improve/collect.d.ts +0 -49
- package/dist/improve/collect.js +0 -274
- package/dist/improve/collect.js.map +0 -1
- package/dist/improve/gate.d.ts +0 -17
- package/dist/improve/gate.js +0 -60
- package/dist/improve/gate.js.map +0 -1
- package/dist/improve/index.d.ts +0 -9
- package/dist/improve/index.js +0 -376
- package/dist/improve/index.js.map +0 -1
- package/dist/improve/judge.d.ts +0 -32
- package/dist/improve/judge.js +0 -114
- package/dist/improve/judge.js.map +0 -1
- package/dist/improve/mine.d.ts +0 -31
- package/dist/improve/mine.js +0 -192
- package/dist/improve/mine.js.map +0 -1
- package/dist/improve/propose.d.ts +0 -51
- package/dist/improve/propose.js +0 -150
- package/dist/improve/propose.js.map +0 -1
- package/dist/improve/rank.d.ts +0 -16
- package/dist/improve/rank.js +0 -49
- package/dist/improve/rank.js.map +0 -1
- package/dist/improve/schedule.d.ts +0 -1
- package/dist/improve/schedule.js +0 -95
- package/dist/improve/schedule.js.map +0 -1
- package/dist/improve/ship.d.ts +0 -25
- package/dist/improve/ship.js +0 -82
- package/dist/improve/ship.js.map +0 -1
- package/dist/improve/state.d.ts +0 -157
- package/dist/improve/state.js +0 -264
- package/dist/improve/state.js.map +0 -1
package/dist/cloud.js
CHANGED
|
@@ -14,8 +14,8 @@ import { runLaptopOnboarding } from "./onboarding.js";
|
|
|
14
14
|
import { renderQrForTerminal } from "./qr.js";
|
|
15
15
|
import { describeSync, exportWork, importWork, syncCheckout } from "./checkout-sync.js";
|
|
16
16
|
import { pullFromHome } from "./cloud-pull.js";
|
|
17
|
-
import {
|
|
18
|
-
import { ensureDir, commandExists, expandHome, isTty, newRunId, nowIso, pathExists, promptConfirm,
|
|
17
|
+
import { localTailnetStatus, previewReachable } from "./tailscale-preview.js";
|
|
18
|
+
import { ensureDir, commandExists, expandHome, isTty, newRunId, nowIso, pathExists, promptConfirm, promptSecret, readJson, runCommand, shortenHome, writeJson, } from "./util.js";
|
|
19
19
|
const DEFAULT_LOGIN_INTERVAL_MS = 2000;
|
|
20
20
|
const DEFAULT_LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
21
21
|
const DEFAULT_CLOUD_URL = "https://rudder-cloud-control.fly.dev";
|
|
@@ -134,6 +134,9 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
134
134
|
case "login":
|
|
135
135
|
await login(options, rest);
|
|
136
136
|
return;
|
|
137
|
+
case "logout":
|
|
138
|
+
await logout(options);
|
|
139
|
+
return;
|
|
137
140
|
case "home":
|
|
138
141
|
await homeCommand(rest, options);
|
|
139
142
|
return;
|
|
@@ -156,13 +159,6 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
156
159
|
case "sail":
|
|
157
160
|
await launch(rest, options);
|
|
158
161
|
return;
|
|
159
|
-
case "byoc":
|
|
160
|
-
await setupByoc(rest, options);
|
|
161
|
-
return;
|
|
162
|
-
case "vm":
|
|
163
|
-
case "byo-vm":
|
|
164
|
-
await launch(rest, options, "task", "byo-vm");
|
|
165
|
-
return;
|
|
166
162
|
case "list":
|
|
167
163
|
case "ls":
|
|
168
164
|
await listSails(options);
|
|
@@ -203,9 +199,6 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
203
199
|
case "pull":
|
|
204
200
|
await pullCommand(rest, options);
|
|
205
201
|
return;
|
|
206
|
-
case "bootstrap":
|
|
207
|
-
await bootstrap(rest, options);
|
|
208
|
-
return;
|
|
209
202
|
case "pause":
|
|
210
203
|
await mutateSail("pause", rest, options);
|
|
211
204
|
return;
|
|
@@ -225,28 +218,6 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
225
218
|
case "setup-google":
|
|
226
219
|
await setupOAuthProvider("google", rest, options);
|
|
227
220
|
return;
|
|
228
|
-
case "setup-byoc":
|
|
229
|
-
await setupByoc(rest, options);
|
|
230
|
-
return;
|
|
231
|
-
case "setup-vm":
|
|
232
|
-
await setupByoc(rest, options);
|
|
233
|
-
return;
|
|
234
|
-
case "setup-fly":
|
|
235
|
-
await configureDefaultRuntime("fly", options);
|
|
236
|
-
return;
|
|
237
|
-
case "setup":
|
|
238
|
-
if (rest[0] === "byoc" || rest[0] === "vm" || rest[0] === "byo-vm") {
|
|
239
|
-
await setupByoc(rest.slice(1), options);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
if (rest[0] === "fly") {
|
|
243
|
-
await configureDefaultRuntime("fly", options);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
throw new Error("Usage: rudder cloud setup byoc | rudder cloud setup fly");
|
|
247
|
-
case "runtime":
|
|
248
|
-
await runtime(rest, options);
|
|
249
|
-
return;
|
|
250
221
|
case "region":
|
|
251
222
|
await configureRegion(rest, options);
|
|
252
223
|
return;
|
|
@@ -469,14 +440,10 @@ async function githubOAuthRequest(url, body) {
|
|
|
469
440
|
}
|
|
470
441
|
async function saveCloudLogin(client, login, token, options, source) {
|
|
471
442
|
const previous = await loadCloudAuth();
|
|
472
|
-
const previousRuntime = previous?.cloudUrl === client.baseUrl ? parseCloudRuntime(previous.defaultRuntime) : undefined;
|
|
473
|
-
const previousByocHost = previous?.cloudUrl === client.baseUrl ? previous.byocSshHost : undefined;
|
|
474
443
|
await saveCloudAuth({
|
|
475
444
|
version: 1,
|
|
476
445
|
token,
|
|
477
446
|
cloudUrl: client.baseUrl,
|
|
478
|
-
defaultRuntime: previousRuntime,
|
|
479
|
-
byocSshHost: previousByocHost,
|
|
480
447
|
accountId: login.accountId,
|
|
481
448
|
email: login.email,
|
|
482
449
|
expiresAt: login.expiresAt ?? (login.expiresIn ? new Date(Date.now() + login.expiresIn * 1000).toISOString() : undefined),
|
|
@@ -511,14 +478,13 @@ export async function cloudRepoSummaries() {
|
|
|
511
478
|
return null;
|
|
512
479
|
}
|
|
513
480
|
}
|
|
514
|
-
async function launch(args, options, mode = "name"
|
|
481
|
+
async function launch(args, options, mode = "name") {
|
|
515
482
|
const raw = args.join(" ").trim();
|
|
516
483
|
const repoRoot = findRepoRoot();
|
|
517
484
|
const snapshot = await createSnapshot(repoRoot, options.homePaths ?? []);
|
|
518
485
|
try {
|
|
519
486
|
const client = await cloudClient({ requireToken: true });
|
|
520
|
-
const
|
|
521
|
-
const task = mode === "task" || runtime === "byo-vm" ? raw : "";
|
|
487
|
+
const task = mode === "task" ? raw : "";
|
|
522
488
|
const launchName = process.env.RUDDER_CLOUD_LAUNCH_NAME?.trim();
|
|
523
489
|
const name = launchName || (task ? cloudNameFromTask(task) : raw || randomCloudName());
|
|
524
490
|
const body = {
|
|
@@ -531,9 +497,6 @@ async function launch(args, options, mode = "name", explicitRuntime) {
|
|
|
531
497
|
manifest: snapshot.manifest,
|
|
532
498
|
},
|
|
533
499
|
};
|
|
534
|
-
if (runtime !== "fly") {
|
|
535
|
-
body.runtime = runtime;
|
|
536
|
-
}
|
|
537
500
|
if (task) {
|
|
538
501
|
body.task = task;
|
|
539
502
|
}
|
|
@@ -558,7 +521,6 @@ async function onload(args, options) {
|
|
|
558
521
|
const snapshot = await createSnapshot(repoRoot, options.homePaths ?? [], { includeRudderState: true });
|
|
559
522
|
try {
|
|
560
523
|
const client = await cloudClient({ requireToken: true });
|
|
561
|
-
const runtime = await selectedCloudRuntime();
|
|
562
524
|
const body = {
|
|
563
525
|
repoName: path.basename(repoRoot),
|
|
564
526
|
workspace: true,
|
|
@@ -570,9 +532,6 @@ async function onload(args, options) {
|
|
|
570
532
|
manifest: snapshot.manifest,
|
|
571
533
|
},
|
|
572
534
|
};
|
|
573
|
-
if (runtime !== "fly") {
|
|
574
|
-
body.runtime = runtime;
|
|
575
|
-
}
|
|
576
535
|
const result = await client.request("/api/rudder/sail/onload", {
|
|
577
536
|
method: "POST",
|
|
578
537
|
body,
|
|
@@ -627,7 +586,6 @@ async function handoffRunToCloud(repoRoot, runId, options) {
|
|
|
627
586
|
rudderStateRunIds: [runId],
|
|
628
587
|
});
|
|
629
588
|
try {
|
|
630
|
-
const runtime = await selectedCloudRuntime();
|
|
631
589
|
const body = {
|
|
632
590
|
repoName,
|
|
633
591
|
runId,
|
|
@@ -638,9 +596,6 @@ async function handoffRunToCloud(repoRoot, runId, options) {
|
|
|
638
596
|
manifest: snapshot.manifest,
|
|
639
597
|
},
|
|
640
598
|
};
|
|
641
|
-
if (runtime !== "fly") {
|
|
642
|
-
body.runtime = runtime;
|
|
643
|
-
}
|
|
644
599
|
const result = await client.request("/api/rudder/sail/onload", {
|
|
645
600
|
method: "POST",
|
|
646
601
|
body,
|
|
@@ -707,7 +662,6 @@ async function listSails(options) {
|
|
|
707
662
|
async function status(options) {
|
|
708
663
|
const client = await cloudClient({ requireToken: true });
|
|
709
664
|
const state = await loadCloudAuth();
|
|
710
|
-
const runtime = await selectedCloudRuntime();
|
|
711
665
|
const sails = await client.request("/api/rudder/sail", { method: "GET" });
|
|
712
666
|
const sailRows = Array.isArray(sails)
|
|
713
667
|
? sails
|
|
@@ -718,7 +672,6 @@ async function status(options) {
|
|
|
718
672
|
const result = {
|
|
719
673
|
ok: true,
|
|
720
674
|
cloudUrl: client.baseUrl,
|
|
721
|
-
runtime,
|
|
722
675
|
sails: sailCount,
|
|
723
676
|
};
|
|
724
677
|
if (state?.cloudUrl === client.baseUrl) {
|
|
@@ -728,33 +681,14 @@ async function status(options) {
|
|
|
728
681
|
if (state.accountId) {
|
|
729
682
|
result.accountId = state.accountId;
|
|
730
683
|
}
|
|
731
|
-
if (state.byocSshHost) {
|
|
732
|
-
result.byocSshHost = state.byocSshHost;
|
|
733
|
-
}
|
|
734
684
|
}
|
|
735
685
|
if (options.json) {
|
|
736
686
|
printJson(result);
|
|
737
687
|
return;
|
|
738
688
|
}
|
|
739
689
|
console.log(`Logged in to ${client.baseUrl}${state?.email ? ` as ${state.email}` : ""}.`);
|
|
740
|
-
console.log(`Runtime: ${runtime}`);
|
|
741
|
-
if (state?.byocSshHost) {
|
|
742
|
-
console.log(`BYOC SSH host: ${state.byocSshHost}`);
|
|
743
|
-
}
|
|
744
690
|
console.log(`Cloud workers: ${sailCount}`);
|
|
745
691
|
}
|
|
746
|
-
async function bootstrap(args, options) {
|
|
747
|
-
const sailId = args[0];
|
|
748
|
-
if (!sailId) {
|
|
749
|
-
throw new Error("Missing sail id. Usage: rudder cloud bootstrap <id>");
|
|
750
|
-
}
|
|
751
|
-
const client = await cloudClient({ requireToken: true });
|
|
752
|
-
const result = await client.request(`/api/rudder/sail/${encodeURIComponent(sailId)}/bootstrap`, {
|
|
753
|
-
method: "POST",
|
|
754
|
-
body: {},
|
|
755
|
-
});
|
|
756
|
-
await printResult(result, options);
|
|
757
|
-
}
|
|
758
692
|
async function mutateSail(action, args, options) {
|
|
759
693
|
const sailId = args[0];
|
|
760
694
|
if (!sailId) {
|
|
@@ -937,258 +871,6 @@ async function setupOAuthProvider(provider, args, options) {
|
|
|
937
871
|
});
|
|
938
872
|
await printResult(result, options);
|
|
939
873
|
}
|
|
940
|
-
async function setupByoc(args, options) {
|
|
941
|
-
const sshConfigPath = path.join(os.homedir(), ".ssh", "config");
|
|
942
|
-
const configuredHosts = await listSshConfigHosts(sshConfigPath);
|
|
943
|
-
const host = (options.sshHost ?? args.join(" ").trim()) || await chooseByocHost(configuredHosts);
|
|
944
|
-
if (!host) {
|
|
945
|
-
throw new Error([
|
|
946
|
-
"Missing BYOC SSH host.",
|
|
947
|
-
"Add your workstation/server to ~/.ssh/config, then run:",
|
|
948
|
-
"",
|
|
949
|
-
" rudder cloud byoc <ssh-host>",
|
|
950
|
-
"",
|
|
951
|
-
"Example ~/.ssh/config:",
|
|
952
|
-
" Host rudder-workstation",
|
|
953
|
-
" HostName 203.0.113.10",
|
|
954
|
-
" User ubuntu",
|
|
955
|
-
" IdentityFile ~/.ssh/id_ed25519",
|
|
956
|
-
"",
|
|
957
|
-
configuredHosts.length
|
|
958
|
-
? `Detected SSH hosts: ${configuredHosts.slice(0, 12).join(", ")}`
|
|
959
|
-
: `No usable hosts found in ${shortenHome(sshConfigPath)}.`,
|
|
960
|
-
].join("\n"));
|
|
961
|
-
}
|
|
962
|
-
const configMentionsHost = configuredHosts.includes(host) || await sshConfigMentions(sshConfigPath, host);
|
|
963
|
-
const diagnostics = await checkByocHost(host);
|
|
964
|
-
const client = await cloudClient({ requireToken: true });
|
|
965
|
-
const state = await loadCloudAuth();
|
|
966
|
-
if (!state || state.cloudUrl !== client.baseUrl) {
|
|
967
|
-
throw new Error("Not logged in to this Rudder Cloud control plane. Run `rudder login` first.");
|
|
968
|
-
}
|
|
969
|
-
await saveCloudAuth({
|
|
970
|
-
...state,
|
|
971
|
-
defaultRuntime: state.defaultRuntime === "byo-vm" ? "fly" : state.defaultRuntime,
|
|
972
|
-
byocSshHost: host,
|
|
973
|
-
updatedAt: nowIso(),
|
|
974
|
-
});
|
|
975
|
-
if (options.json) {
|
|
976
|
-
const result = {
|
|
977
|
-
ok: true,
|
|
978
|
-
cloudUrl: client.baseUrl,
|
|
979
|
-
byocSshHost: host,
|
|
980
|
-
};
|
|
981
|
-
const defaultRuntime = state.defaultRuntime === "byo-vm" ? "fly" : state.defaultRuntime;
|
|
982
|
-
if (defaultRuntime) {
|
|
983
|
-
result.defaultRuntime = defaultRuntime;
|
|
984
|
-
}
|
|
985
|
-
printJson(result);
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
console.log(`Rudder BYOC host set to ${host}.`);
|
|
989
|
-
console.log("Plain `rudder cloud` and dashboard `/cloud` continue to use Fly by default.");
|
|
990
|
-
console.log("Use `rudder cloud vm <task>` when you want to run a task on this BYOC host.");
|
|
991
|
-
if (!configMentionsHost) {
|
|
992
|
-
console.log(`\nNote: ${shortenHome(sshConfigPath)} does not appear to define Host ${host}.`);
|
|
993
|
-
console.log("Rudder can still use it if SSH resolves it, but a ~/.ssh/config entry is recommended:");
|
|
994
|
-
console.log(` Host ${host}`);
|
|
995
|
-
console.log(" HostName <server-ip-or-dns>");
|
|
996
|
-
console.log(" User <user>");
|
|
997
|
-
console.log(" IdentityFile ~/.ssh/<private-key>");
|
|
998
|
-
}
|
|
999
|
-
if (diagnostics.ok) {
|
|
1000
|
-
console.log(`SSH check passed for ${host}. Docker is available on the BYOC host.`);
|
|
1001
|
-
}
|
|
1002
|
-
else {
|
|
1003
|
-
console.log(`\nSSH check did not fully pass for ${host}: ${diagnostics.message}`);
|
|
1004
|
-
console.log("Fix SSH/Docker before launching, or run the printed Docker command manually on that host.");
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
async function chooseByocHost(hosts) {
|
|
1008
|
-
if (hosts.length === 0) {
|
|
1009
|
-
return await promptText("SSH host from ~/.ssh/config");
|
|
1010
|
-
}
|
|
1011
|
-
return await promptSelect("Choose a BYOC SSH host from ~/.ssh/config", hosts.slice(0, 24).map((host) => ({ value: host, label: host })), hosts[0]);
|
|
1012
|
-
}
|
|
1013
|
-
async function configureDefaultRuntime(runtime, options, byocSshHost) {
|
|
1014
|
-
const client = await cloudClient({ requireToken: true });
|
|
1015
|
-
const state = await loadCloudAuth();
|
|
1016
|
-
if (!state || state.cloudUrl !== client.baseUrl) {
|
|
1017
|
-
throw new Error("Not logged in to this Rudder Cloud control plane. Run `rudder login` first.");
|
|
1018
|
-
}
|
|
1019
|
-
await saveCloudAuth({
|
|
1020
|
-
...state,
|
|
1021
|
-
defaultRuntime: runtime,
|
|
1022
|
-
byocSshHost: runtime === "byo-vm" ? byocSshHost ?? state.byocSshHost : undefined,
|
|
1023
|
-
updatedAt: nowIso(),
|
|
1024
|
-
});
|
|
1025
|
-
const result = {
|
|
1026
|
-
ok: true,
|
|
1027
|
-
cloudUrl: client.baseUrl,
|
|
1028
|
-
defaultRuntime: runtime,
|
|
1029
|
-
};
|
|
1030
|
-
const savedByocHost = byocSshHost ?? state.byocSshHost;
|
|
1031
|
-
if (runtime === "byo-vm" && savedByocHost) {
|
|
1032
|
-
result.byocSshHost = savedByocHost;
|
|
1033
|
-
}
|
|
1034
|
-
const envRuntime = envCloudRuntime();
|
|
1035
|
-
if (envRuntime) {
|
|
1036
|
-
result.envOverride = envRuntime;
|
|
1037
|
-
}
|
|
1038
|
-
if (options.json) {
|
|
1039
|
-
printJson(result);
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
console.log(`Rudder Cloud runtime set to ${runtime}.`);
|
|
1043
|
-
if (runtime === "byo-vm") {
|
|
1044
|
-
const host = byocSshHost ?? state.byocSshHost;
|
|
1045
|
-
console.log("Future `rudder cloud <task>` and `/sail <task>` launches will prepare a BYOC worker instead of creating a Fly Machine.");
|
|
1046
|
-
console.log(host
|
|
1047
|
-
? `Rudder will try to start the worker over SSH on ${host}.`
|
|
1048
|
-
: "Run `rudder cloud byoc <ssh-host>` to let Rudder start workers over SSH.");
|
|
1049
|
-
}
|
|
1050
|
-
else {
|
|
1051
|
-
console.log("Future `rudder cloud <task>` and `/sail <task>` launches will create Fly Machines.");
|
|
1052
|
-
}
|
|
1053
|
-
if (envRuntime) {
|
|
1054
|
-
console.log(`RUDDER_CLOUD_RUNTIME=${envRuntime} is set and will override this saved default.`);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
async function runtime(args, options) {
|
|
1058
|
-
const next = args[0] ? parseCloudRuntime(args[0]) : undefined;
|
|
1059
|
-
if (args[0] && !next) {
|
|
1060
|
-
throw new Error("Runtime must be `fly`, `byoc`, or `byo-vm`.");
|
|
1061
|
-
}
|
|
1062
|
-
if (next) {
|
|
1063
|
-
await configureDefaultRuntime(next, options);
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
const client = await cloudClient({ requireToken: true });
|
|
1067
|
-
const current = await selectedCloudRuntime();
|
|
1068
|
-
const state = await loadCloudAuth();
|
|
1069
|
-
const savedRuntime = parseCloudRuntime(state?.defaultRuntime);
|
|
1070
|
-
const result = {
|
|
1071
|
-
cloudUrl: client.baseUrl,
|
|
1072
|
-
runtime: current,
|
|
1073
|
-
};
|
|
1074
|
-
const envRuntime = envCloudRuntime();
|
|
1075
|
-
if (state?.cloudUrl === client.baseUrl && savedRuntime) {
|
|
1076
|
-
result.savedDefaultRuntime = savedRuntime;
|
|
1077
|
-
}
|
|
1078
|
-
if (state?.cloudUrl === client.baseUrl && state.byocSshHost) {
|
|
1079
|
-
result.byocSshHost = state.byocSshHost;
|
|
1080
|
-
}
|
|
1081
|
-
if (envRuntime) {
|
|
1082
|
-
result.envOverride = envRuntime;
|
|
1083
|
-
}
|
|
1084
|
-
if (options.json) {
|
|
1085
|
-
printJson(result);
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
console.log(`Rudder Cloud runtime: ${current}`);
|
|
1089
|
-
if (envRuntime) {
|
|
1090
|
-
console.log(`Set by RUDDER_CLOUD_RUNTIME=${envRuntime}.`);
|
|
1091
|
-
}
|
|
1092
|
-
else if (state?.cloudUrl === client.baseUrl && savedRuntime) {
|
|
1093
|
-
console.log("Set in local Rudder Cloud config.");
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
console.log("Using default Fly Machines runtime.");
|
|
1097
|
-
}
|
|
1098
|
-
if (state?.cloudUrl === client.baseUrl && state.byocSshHost) {
|
|
1099
|
-
console.log(`BYOC SSH host: ${state.byocSshHost}`);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
async function sshConfigMentions(configPath, host) {
|
|
1104
|
-
const text = await fsp.readFile(configPath, "utf8").catch(() => "");
|
|
1105
|
-
if (!text.trim()) {
|
|
1106
|
-
return false;
|
|
1107
|
-
}
|
|
1108
|
-
const target = host.toLowerCase();
|
|
1109
|
-
for (const line of text.split(/\r?\n/)) {
|
|
1110
|
-
const trimmed = line.trim();
|
|
1111
|
-
if (!trimmed || trimmed.startsWith("#")) {
|
|
1112
|
-
continue;
|
|
1113
|
-
}
|
|
1114
|
-
const match = /^Host\s+(.+)$/i.exec(trimmed);
|
|
1115
|
-
if (!match) {
|
|
1116
|
-
continue;
|
|
1117
|
-
}
|
|
1118
|
-
const patterns = match[1].split(/\s+/).map((part) => part.toLowerCase());
|
|
1119
|
-
if (patterns.includes(target)) {
|
|
1120
|
-
return true;
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
return false;
|
|
1124
|
-
}
|
|
1125
|
-
async function listSshConfigHosts(configPath) {
|
|
1126
|
-
const text = await fsp.readFile(configPath, "utf8").catch(() => "");
|
|
1127
|
-
const hosts = [];
|
|
1128
|
-
const seen = new Set();
|
|
1129
|
-
for (const line of text.split(/\r?\n/)) {
|
|
1130
|
-
const trimmed = line.trim();
|
|
1131
|
-
if (!trimmed || trimmed.startsWith("#")) {
|
|
1132
|
-
continue;
|
|
1133
|
-
}
|
|
1134
|
-
const match = /^Host\s+(.+)$/i.exec(trimmed);
|
|
1135
|
-
if (!match) {
|
|
1136
|
-
continue;
|
|
1137
|
-
}
|
|
1138
|
-
for (const host of match[1].split(/\s+/)) {
|
|
1139
|
-
if (!host || host.includes("*") || host.includes("?") || host.startsWith("!")) {
|
|
1140
|
-
continue;
|
|
1141
|
-
}
|
|
1142
|
-
if (seen.has(host)) {
|
|
1143
|
-
continue;
|
|
1144
|
-
}
|
|
1145
|
-
seen.add(host);
|
|
1146
|
-
hosts.push(host);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
return hosts;
|
|
1150
|
-
}
|
|
1151
|
-
async function checkByocHost(host) {
|
|
1152
|
-
if (!commandExists("ssh")) {
|
|
1153
|
-
return { ok: false, message: "ssh is not installed or not on PATH" };
|
|
1154
|
-
}
|
|
1155
|
-
const result = await runCommand("ssh", [
|
|
1156
|
-
"-o",
|
|
1157
|
-
"BatchMode=yes",
|
|
1158
|
-
"-o",
|
|
1159
|
-
"ConnectTimeout=8",
|
|
1160
|
-
host,
|
|
1161
|
-
"command -v docker >/dev/null && docker info >/dev/null 2>&1",
|
|
1162
|
-
], { allowFailure: true });
|
|
1163
|
-
if (result.code === 0) {
|
|
1164
|
-
return { ok: true, message: "ok" };
|
|
1165
|
-
}
|
|
1166
|
-
const detail = (result.stderr || result.stdout || `ssh exited ${result.code}`).trim();
|
|
1167
|
-
return { ok: false, message: detail };
|
|
1168
|
-
}
|
|
1169
|
-
async function startByocWorkerOverSsh(host, bootstrapCommand) {
|
|
1170
|
-
if (!commandExists("ssh")) {
|
|
1171
|
-
throw new Error("ssh is not installed or not on PATH");
|
|
1172
|
-
}
|
|
1173
|
-
const remoteCommand = [
|
|
1174
|
-
"mkdir -p ~/.rudder/byoc",
|
|
1175
|
-
`nohup sh -lc ${shellQuote(nonInteractiveDockerCommand(bootstrapCommand))} > ~/.rudder/byoc/worker.log 2>&1 < /dev/null &`,
|
|
1176
|
-
].join(" && ");
|
|
1177
|
-
await runCommand("ssh", [
|
|
1178
|
-
"-o",
|
|
1179
|
-
"BatchMode=yes",
|
|
1180
|
-
"-o",
|
|
1181
|
-
"ConnectTimeout=10",
|
|
1182
|
-
host,
|
|
1183
|
-
remoteCommand,
|
|
1184
|
-
]);
|
|
1185
|
-
}
|
|
1186
|
-
function nonInteractiveDockerCommand(command) {
|
|
1187
|
-
return command
|
|
1188
|
-
.replace(/\bdocker run --rm -it\b/g, "docker run --rm")
|
|
1189
|
-
.replace(/\bdocker run --rm -i -t\b/g, "docker run --rm")
|
|
1190
|
-
.replace(/\bdocker run --rm -t -i\b/g, "docker run --rm");
|
|
1191
|
-
}
|
|
1192
874
|
async function cloudClient(options) {
|
|
1193
875
|
const baseUrl = normalizeCloudUrl(process.env.RUDDER_CLOUD_URL);
|
|
1194
876
|
const state = await loadCloudAuth();
|
|
@@ -1252,8 +934,7 @@ function normalizeCloudUrl(raw) {
|
|
|
1252
934
|
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
1253
935
|
throw new Error("RUDDER_CLOUD_URL must be a valid http(s) URL.");
|
|
1254
936
|
}
|
|
1255
|
-
// The control plane
|
|
1256
|
-
// can auto-run over SSH, so a plain-HTTP control plane is a MITM-to-RCE risk.
|
|
937
|
+
// The token and snapshots travel to the control plane, so plain HTTP is a MITM risk.
|
|
1257
938
|
// Require https except for loopback dev or an explicit opt-in.
|
|
1258
939
|
const isLoopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "::1";
|
|
1259
940
|
if (url.protocol === "http:" && !isLoopback && process.env.RUDDER_CLOUD_ALLOW_HTTP !== "1") {
|
|
@@ -1264,39 +945,6 @@ function normalizeCloudUrl(raw) {
|
|
|
1264
945
|
url.search = "";
|
|
1265
946
|
return url.toString().replace(/\/$/, "");
|
|
1266
947
|
}
|
|
1267
|
-
async function selectedCloudRuntime(explicit) {
|
|
1268
|
-
if (explicit) {
|
|
1269
|
-
return explicit;
|
|
1270
|
-
}
|
|
1271
|
-
const envRuntime = envCloudRuntime();
|
|
1272
|
-
if (envRuntime) {
|
|
1273
|
-
return envRuntime;
|
|
1274
|
-
}
|
|
1275
|
-
const baseUrl = normalizeCloudUrl(process.env.RUDDER_CLOUD_URL);
|
|
1276
|
-
const state = await loadCloudAuth();
|
|
1277
|
-
const savedRuntime = parseCloudRuntime(state?.defaultRuntime);
|
|
1278
|
-
return state?.cloudUrl === baseUrl && savedRuntime ? savedRuntime : "fly";
|
|
1279
|
-
}
|
|
1280
|
-
function parseCloudRuntime(raw) {
|
|
1281
|
-
const value = raw?.trim().toLowerCase();
|
|
1282
|
-
if (!value) {
|
|
1283
|
-
return undefined;
|
|
1284
|
-
}
|
|
1285
|
-
if (value === "fly" || value === "fly-machine" || value === "fly-machines") {
|
|
1286
|
-
return "fly";
|
|
1287
|
-
}
|
|
1288
|
-
if (value === "byo" || value === "byoc" || value === "byo-vm" || value === "manual" || value === "self-hosted" || value === "vm") {
|
|
1289
|
-
return "byo-vm";
|
|
1290
|
-
}
|
|
1291
|
-
return undefined;
|
|
1292
|
-
}
|
|
1293
|
-
function envCloudRuntime() {
|
|
1294
|
-
const runtime = parseCloudRuntime(process.env.RUDDER_CLOUD_RUNTIME);
|
|
1295
|
-
if (process.env.RUDDER_CLOUD_RUNTIME?.trim() && !runtime) {
|
|
1296
|
-
throw new Error("RUDDER_CLOUD_RUNTIME must be `fly`, `byoc`, or `byo-vm`.");
|
|
1297
|
-
}
|
|
1298
|
-
return runtime;
|
|
1299
|
-
}
|
|
1300
948
|
async function pollLogin(client, pollPath, deviceCode) {
|
|
1301
949
|
if (pollPath.startsWith("http://") || pollPath.startsWith("https://") || !deviceCode) {
|
|
1302
950
|
return await client.request(pollPath, { method: "GET" });
|
|
@@ -1310,6 +958,15 @@ async function loadCloudAuth() {
|
|
|
1310
958
|
const state = await readJson(cloudAuthPath());
|
|
1311
959
|
return state?.version === 1 && typeof state.token === "string" ? state : null;
|
|
1312
960
|
}
|
|
961
|
+
async function logout(options) {
|
|
962
|
+
const existed = (await loadCloudAuth()) !== null;
|
|
963
|
+
await fsp.rm(cloudAuthPath(), { force: true });
|
|
964
|
+
if (options.json) {
|
|
965
|
+
printJson({ ok: true, loggedOut: existed });
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
console.log(existed ? "Logged out of Rudder Cloud." : "Not logged in to Rudder Cloud.");
|
|
969
|
+
}
|
|
1313
970
|
async function saveCloudAuth(state) {
|
|
1314
971
|
await writeJson(cloudAuthPath(), state, { mode: 0o600 });
|
|
1315
972
|
}
|
|
@@ -1818,44 +1475,6 @@ async function printResult(result, options) {
|
|
|
1818
1475
|
}
|
|
1819
1476
|
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
1820
1477
|
const record = result;
|
|
1821
|
-
if (typeof record.bootstrapCommand === "string") {
|
|
1822
|
-
const id = typeof record.id === "string" ? record.id : "BYOC sail";
|
|
1823
|
-
const status = typeof record.status === "string" ? record.status : undefined;
|
|
1824
|
-
const state = await loadCloudAuth();
|
|
1825
|
-
const host = options.sshHost ?? state?.byocSshHost;
|
|
1826
|
-
console.log(`${id}${status ? ` (${status})` : ""} is ready for BYOC.`);
|
|
1827
|
-
// bootstrapCommand is a shell command supplied by the control plane. Auto-running
|
|
1828
|
-
// it over SSH is RCE-on-your-host if the control plane is compromised or MITM'd,
|
|
1829
|
-
// so autostart is OPT-IN (RUDDER_BYOC_AUTOSTART=1) and the command is always
|
|
1830
|
-
// printed first so the user can review exactly what would run.
|
|
1831
|
-
console.log("BYOC bootstrap command (review before running):");
|
|
1832
|
-
console.log(record.bootstrapCommand);
|
|
1833
|
-
if (host && process.env.RUDDER_BYOC_AUTOSTART === "1") {
|
|
1834
|
-
try {
|
|
1835
|
-
console.log(`\nRUDDER_BYOC_AUTOSTART=1 set — running the above over SSH on ${host}...`);
|
|
1836
|
-
await startByocWorkerOverSsh(host, record.bootstrapCommand);
|
|
1837
|
-
console.log(`Started BYOC worker over SSH on ${host}.`);
|
|
1838
|
-
console.log(`Remote log: ssh ${host} 'tail -f ~/.rudder/byoc/worker.log'`);
|
|
1839
|
-
}
|
|
1840
|
-
catch (error) {
|
|
1841
|
-
console.log(`Could not start BYOC worker over SSH on ${host}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1842
|
-
console.log("Run the command above manually on your workstation/server.");
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
else {
|
|
1846
|
-
console.log("\nRun the command above on your workstation/server.");
|
|
1847
|
-
if (host) {
|
|
1848
|
-
console.log("To auto-run it over SSH next time, set RUDDER_BYOC_AUTOSTART=1.");
|
|
1849
|
-
}
|
|
1850
|
-
else {
|
|
1851
|
-
console.log("Tip: run `rudder cloud byoc <ssh-host>` to target an SSH host.");
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
if (typeof record.updatedAt === "string") {
|
|
1855
|
-
console.log(`\nIf the command expires, run: rudder cloud bootstrap ${id}`);
|
|
1856
|
-
}
|
|
1857
|
-
return;
|
|
1858
|
-
}
|
|
1859
1478
|
const sails = record.sails ?? record.items;
|
|
1860
1479
|
if (Array.isArray(sails)) {
|
|
1861
1480
|
printSailList(sails);
|
|
@@ -3709,9 +3328,6 @@ async function maybeAutoAttach(result, options) {
|
|
|
3709
3328
|
return;
|
|
3710
3329
|
}
|
|
3711
3330
|
const record = result;
|
|
3712
|
-
if (typeof record.bootstrapCommand === "string") {
|
|
3713
|
-
return;
|
|
3714
|
-
}
|
|
3715
3331
|
const sailId = extractSailId(record);
|
|
3716
3332
|
if (!sailId) {
|
|
3717
3333
|
return;
|
|
@@ -3738,8 +3354,8 @@ Usage:
|
|
|
3738
3354
|
holds every repo) and attach to its dashboard. --snapshot uploads this
|
|
3739
3355
|
folder to its own machine instead.
|
|
3740
3356
|
rudder cloud home [status|start|stop|open <owner/repo>]
|
|
3741
|
-
rudder cloud preview [
|
|
3742
|
-
|
|
3357
|
+
rudder cloud preview [preview-id] [--list] [--json]
|
|
3358
|
+
list registered private previews; open the exact preview-id over Tailscale
|
|
3743
3359
|
rudder cloud move [runId...] [--yes]
|
|
3744
3360
|
move this repo's unfinished agents (or just the named ones) to the
|
|
3745
3361
|
home machine: their jj changes and conversations go along, nothing is
|
|
@@ -3758,8 +3374,6 @@ Usage:
|
|
|
3758
3374
|
rudder cloud help
|
|
3759
3375
|
rudder cloud [name or task]
|
|
3760
3376
|
rudder cloud launch [--home-path <path>] ["task"]
|
|
3761
|
-
rudder cloud byoc [ssh-host]
|
|
3762
|
-
rudder cloud vm ["task"]
|
|
3763
3377
|
rudder cloud list
|
|
3764
3378
|
rudder cloud onload [runId]
|
|
3765
3379
|
with a runId, hands that agent off to its own cloud machine and
|
|
@@ -3785,10 +3399,6 @@ Usage:
|
|
|
3785
3399
|
manage the encrypted cloud secrets vault; \`sync\` imports your local credentials once
|
|
3786
3400
|
rudder cloud region [<fly-region>|clear]
|
|
3787
3401
|
override worker placement (default: next to the relay for lowest typing latency)
|
|
3788
|
-
rudder cloud bootstrap <id>
|
|
3789
|
-
rudder cloud runtime [fly|byoc]
|
|
3790
|
-
rudder cloud setup-byoc <ssh-host> compatibility alias
|
|
3791
|
-
rudder cloud setup-fly
|
|
3792
3402
|
rudder sail [name or task]
|
|
3793
3403
|
rudder sail list
|
|
3794
3404
|
rudder sail pause <id>
|
|
@@ -3798,7 +3408,6 @@ Usage:
|
|
|
3798
3408
|
|
|
3799
3409
|
Environment:
|
|
3800
3410
|
RUDDER_CLOUD_URL Cloud control plane URL (defaults to ${DEFAULT_CLOUD_URL})
|
|
3801
|
-
RUDDER_CLOUD_RUNTIME fly, byoc, or byo-vm (overrides saved local default)
|
|
3802
3411
|
RUDDER_CLOUD_HOME_PATHS Extra comma-separated HOME paths to include in snapshots
|
|
3803
3412
|
RUDDER_GITHUB_CLIENT_ID GitHub App OAuth client ID for setup-github
|
|
3804
3413
|
RUDDER_GITHUB_CLIENT_SECRET GitHub App OAuth client secret for setup-github
|
|
@@ -4707,69 +4316,13 @@ async function homeAgentsCommand(client, sub, args, options) {
|
|
|
4707
4316
|
: "Deleted on the home machine.");
|
|
4708
4317
|
}
|
|
4709
4318
|
async function cloudPreviewCommand(args, options) {
|
|
4710
|
-
const
|
|
4711
|
-
const positional = args.filter((arg) => arg !== "--list");
|
|
4712
|
-
if (positional.length > 1 || (positional[0] && !/^\d{2,5}$/.test(positional[0]))) {
|
|
4713
|
-
throw new Error("Usage: rudder cloud preview [port] [--list] [--json]");
|
|
4714
|
-
}
|
|
4715
|
-
const requestedPort = positional[0] ? Number(positional[0]) : null;
|
|
4716
|
-
if (requestedPort !== null && (requestedPort < 1024 || requestedPort > 65535)) {
|
|
4717
|
-
throw new Error("Preview port must be between 1024 and 65535.");
|
|
4718
|
-
}
|
|
4319
|
+
const { runPrivatePreviewCommand } = await import("./private-access/cli.js");
|
|
4719
4320
|
const root = findRepoRoot();
|
|
4720
4321
|
const repo = await githubSlugFromOrigin(root).catch(() => null);
|
|
4721
|
-
const project = repo ? { repo } : { name: path.basename(root) };
|
|
4722
4322
|
const client = await cloudClient({ requireToken: true });
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
await client.request("/api/rudder/home/start", { method: "POST", body: {} });
|
|
4727
|
-
const deadline = Date.now() + 90_000;
|
|
4728
|
-
while ((!state.home?.connected || state.home.stateLive === false) && Date.now() < deadline) {
|
|
4729
|
-
await sleep(1500);
|
|
4730
|
-
state = await client.request("/api/rudder/home", { method: "GET" });
|
|
4731
|
-
}
|
|
4732
|
-
}
|
|
4733
|
-
const ready = () => cloudPreviews(state, project).filter((entry) => requestedPort === null || entry.port === requestedPort);
|
|
4734
|
-
let previews = ready();
|
|
4735
|
-
if (!listOnly && !previews.length && state.home?.connected) {
|
|
4736
|
-
const deadline = Date.now() + 20_000;
|
|
4737
|
-
process.stderr.write("Waiting for this project's private preview...\n");
|
|
4738
|
-
while (!previews.length && state.home?.connected && Date.now() < deadline) {
|
|
4739
|
-
const tailnet = state.home.tailnet;
|
|
4740
|
-
if (tailnet && typeof tailnet === "object" && !Array.isArray(tailnet) && tailnet.error)
|
|
4741
|
-
break;
|
|
4742
|
-
await sleep(1000);
|
|
4743
|
-
state = await client.request("/api/rudder/home", { method: "GET" });
|
|
4744
|
-
previews = ready();
|
|
4745
|
-
}
|
|
4746
|
-
}
|
|
4747
|
-
if (options.json) {
|
|
4748
|
-
printJson({ previews, connected: state.home?.connected === true, access: "tailnet", requiresTailscale: true });
|
|
4749
|
-
return;
|
|
4750
|
-
}
|
|
4751
|
-
if (!previews.length) {
|
|
4752
|
-
const tailnet = state.home?.tailnet;
|
|
4753
|
-
const detail = tailnet && typeof tailnet === "object" && !Array.isArray(tailnet) && typeof tailnet.error === "string"
|
|
4754
|
-
? ` ${tailnet.error}.` : "";
|
|
4755
|
-
throw new Error(`No ready private preview${requestedPort ? ` on port ${requestedPort}` : ""} for ${repo || project.name}.${detail} Start a dev server in that project's cloud workspace, then retry.`);
|
|
4756
|
-
}
|
|
4757
|
-
if (listOnly || previews.length > 1) {
|
|
4758
|
-
for (const preview of previews)
|
|
4759
|
-
console.log(`:${preview.port} ${preview.label} ${preview.url}`);
|
|
4760
|
-
if (!listOnly)
|
|
4761
|
-
console.log("Open one with: rudder cloud preview <port>");
|
|
4762
|
-
return;
|
|
4763
|
-
}
|
|
4764
|
-
const preview = previews[0];
|
|
4765
|
-
const access = previewAccess(await localTailnetStatus(), new URL(preview.url).hostname);
|
|
4766
|
-
if (!access.ok)
|
|
4767
|
-
throw new Error(`${access.error} Preview: ${preview.url}`);
|
|
4768
|
-
if (!(await previewReachable(preview.url))) {
|
|
4769
|
-
throw new Error(`The preview is not reachable from this computer. Check the dev server and your existing Tailscale access rules. Preview: ${preview.url}`);
|
|
4770
|
-
}
|
|
4771
|
-
console.log(preview.url);
|
|
4772
|
-
openBrowser(preview.url);
|
|
4323
|
+
await runPrivatePreviewCommand(args, options, { client, project: repo ? { repo } : { name: path.basename(root) },
|
|
4324
|
+
localStatus: localTailnetStatus, reachable: previewReachable, open: openBrowser,
|
|
4325
|
+
printJson: value => printJson(value) });
|
|
4773
4326
|
}
|
|
4774
4327
|
async function homeCommand(args, options) {
|
|
4775
4328
|
const client = await cloudClient({ requireToken: true });
|