@exla/rudder 4.1.2 → 4.2.2
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/cloud/README.md +348 -0
- package/cloud/host/90-rudder.conf +10 -0
- package/cloud/host/rudder-home-apply-update +66 -0
- package/cloud/host/rudder-home-start +37 -0
- package/cloud/host/rudder-home-update.path +9 -0
- package/cloud/host/rudder-home-update.service +9 -0
- package/cloud/host/rudder-home.service +17 -0
- package/cloud/host/rudder-host-setup +65 -0
- package/cloud/package.json +37 -0
- package/dist/attach-session.d.ts +6 -0
- package/dist/attach-session.js +20 -0
- package/dist/attach-session.js.map +1 -1
- package/dist/backends.js +4 -1
- package/dist/backends.js.map +1 -1
- package/dist/cloud-host.d.ts +26 -0
- package/dist/cloud-host.js +229 -0
- package/dist/cloud-host.js.map +1 -0
- package/dist/cloud.js +72 -20
- package/dist/cloud.js.map +1 -1
- package/dist/codex-binary.d.ts +8 -0
- package/dist/codex-binary.js +12 -0
- package/dist/codex-binary.js.map +1 -1
- package/dist/home-scratch.d.ts +1 -0
- package/dist/home-scratch.js +23 -0
- package/dist/home-scratch.js.map +1 -0
- package/dist/input-receipts.d.ts +28 -0
- package/dist/input-receipts.js +72 -0
- package/dist/input-receipts.js.map +1 -0
- package/dist/jj.js +5 -3
- package/dist/jj.js.map +1 -1
- package/dist/native/darwin-arm64/native-manifest.json +5 -5
- package/dist/native/darwin-arm64/rudder-jj +0 -0
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/linux-x64/native-manifest.json +5 -5
- package/dist/native/linux-x64/rudder-jj +0 -0
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/native-agents.js +3 -1
- package/dist/native-agents.js.map +1 -1
- package/dist/predict.d.ts +26 -4
- package/dist/predict.js +119 -23
- package/dist/predict.js.map +1 -1
- package/dist/run-manager.js +2 -1
- package/dist/run-manager.js.map +1 -1
- package/dist/warm-snapshot.d.ts +16 -5
- package/dist/warm-snapshot.js +74 -13
- package/dist/warm-snapshot.js.map +1 -1
- package/package.json +2 -1
package/dist/cloud.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { AttachSession, containsCtrlC } from "./attach-session.js";
|
|
4
|
+
import { InputReceipts } from "./input-receipts.js";
|
|
4
5
|
import { PasteBridge, readLocalClipboard } from "./paste-bridge.js";
|
|
5
6
|
import fsp from "node:fs/promises";
|
|
6
7
|
import os from "node:os";
|
|
@@ -14,6 +15,7 @@ import { runLaptopOnboarding } from "./onboarding.js";
|
|
|
14
15
|
import { renderQrForTerminal } from "./qr.js";
|
|
15
16
|
import { describeSync, exportWork, importWork, syncCheckout } from "./checkout-sync.js";
|
|
16
17
|
import { pullFromHome } from "./cloud-pull.js";
|
|
18
|
+
import { hostCommand } from "./cloud-host.js";
|
|
17
19
|
import { localTailnetStatus, previewReachable } from "./tailscale-preview.js";
|
|
18
20
|
import { ensureDir, commandExists, expandHome, isTty, newRunId, nowIso, pathExists, promptConfirm, promptSecret, readJson, runCommand, shortenHome, writeJson, } from "./util.js";
|
|
19
21
|
const DEFAULT_LOGIN_INTERVAL_MS = 2000;
|
|
@@ -140,6 +142,12 @@ export async function runCloudCommand(command, args, options = {}) {
|
|
|
140
142
|
case "home":
|
|
141
143
|
await homeCommand(rest, options);
|
|
142
144
|
return;
|
|
145
|
+
case "host":
|
|
146
|
+
if (process.env.RUDDER_CLOUD_RUNTIME === "home") {
|
|
147
|
+
throw new Error("run this from your laptop: moving the home to another host restarts it.");
|
|
148
|
+
}
|
|
149
|
+
await hostCommand(rest, await cloudClient({ requireToken: true }), options);
|
|
150
|
+
return;
|
|
143
151
|
case "preview":
|
|
144
152
|
await cloudPreviewCommand(rest, options);
|
|
145
153
|
return;
|
|
@@ -2517,6 +2525,9 @@ async function attachHomeProject(name, options) {
|
|
|
2517
2525
|
const ATTACH_PING_MS = 5_000;
|
|
2518
2526
|
const ATTACH_PONG_TIMEOUT_MS = 20_000;
|
|
2519
2527
|
const ATTACH_SLEEP_GAP_MS = 15_000;
|
|
2528
|
+
// Typed keys normally confirm within one round trip; this long without a
|
|
2529
|
+
// receipt means the link is gone even though the socket still says open.
|
|
2530
|
+
const ATTACH_RECEIPT_TIMEOUT_MS = 4_000;
|
|
2520
2531
|
// Retry at once (a blip, a deploy), then back off; never more than 5s apart,
|
|
2521
2532
|
// so coming back to a reachable cloud never waits long.
|
|
2522
2533
|
const ATTACH_RETRY_DELAYS_MS = [250, 1_000, 2_000, 3_000, 5_000];
|
|
@@ -2695,6 +2706,33 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2695
2706
|
let workerState = "unknown";
|
|
2696
2707
|
let hasControl = true;
|
|
2697
2708
|
let result = "failed";
|
|
2709
|
+
// Keys sent but not yet known to have reached the relay (src/input-receipts.ts):
|
|
2710
|
+
// a link that dies first hands them to the next connection.
|
|
2711
|
+
const receipts = new InputReceipts();
|
|
2712
|
+
const sendPing = () => {
|
|
2713
|
+
socket.ping(receipts.nextPing());
|
|
2714
|
+
};
|
|
2715
|
+
const sendInput = (data) => {
|
|
2716
|
+
if (socket.readyState !== WebSocket.OPEN) {
|
|
2717
|
+
session.keepUnsent([data], false);
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
// Typing into a link whose receipts stopped coming: it is dead, so stop
|
|
2721
|
+
// feeding it and let the reconnect carry these keys.
|
|
2722
|
+
if (receipts.oldestPingAge() > ATTACH_RECEIPT_TIMEOUT_MS) {
|
|
2723
|
+
session.keepUnsent([data], false);
|
|
2724
|
+
socket.terminate();
|
|
2725
|
+
return;
|
|
2726
|
+
}
|
|
2727
|
+
socket.send(data, { binary: true });
|
|
2728
|
+
predictor?.onInput(data);
|
|
2729
|
+
if (receipts.sent(data)) {
|
|
2730
|
+
try {
|
|
2731
|
+
sendPing();
|
|
2732
|
+
}
|
|
2733
|
+
catch { /* the liveness check handles a dead socket */ }
|
|
2734
|
+
}
|
|
2735
|
+
};
|
|
2698
2736
|
const splashAllowed = isInteractive && !options.json && !options.quietBanner && !resuming;
|
|
2699
2737
|
const splash = splashAllowed ? new AttachSplash(stdout, target.label) : null;
|
|
2700
2738
|
// Predictive local echo (src/predict.ts): typed characters appear at the
|
|
@@ -2727,12 +2765,7 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2727
2765
|
// Files and clipboard images from this computer reach the cloud machine
|
|
2728
2766
|
// as uploads (src/paste-bridge.ts); only the home's repo rows take them.
|
|
2729
2767
|
const paste = new PasteBridge({
|
|
2730
|
-
send:
|
|
2731
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
2732
|
-
socket.send(data, { binary: true });
|
|
2733
|
-
predictor?.onInput(data);
|
|
2734
|
-
}
|
|
2735
|
-
},
|
|
2768
|
+
send: sendInput,
|
|
2736
2769
|
upload: (file, name) => uploadPastedFile(baseUrl, token, target.id, file, name),
|
|
2737
2770
|
readClipboard: target.kind === "workspace" && isInteractive ? readLocalClipboard : undefined,
|
|
2738
2771
|
status: (text) => (text ? session.showStatus(text) : session.clearStatus()),
|
|
@@ -2777,8 +2810,19 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2777
2810
|
return;
|
|
2778
2811
|
}
|
|
2779
2812
|
if (!hasControl) {
|
|
2780
|
-
|
|
2781
|
-
|
|
2813
|
+
if (socket.readyState !== WebSocket.OPEN) {
|
|
2814
|
+
session.showStatus("Read-only · another terminal has control");
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
// Typing here picks this terminal: take control from the other one
|
|
2818
|
+
// (often a laptop that slept) instead of dropping the keys. The relay
|
|
2819
|
+
// handles the request, the size and then the keys in order. An older
|
|
2820
|
+
// relay answers read-only again and the badge comes back.
|
|
2821
|
+
socket.send(JSON.stringify({ type: "take-control" }));
|
|
2822
|
+
hasControl = true;
|
|
2823
|
+
sendResize();
|
|
2824
|
+
requestRepaint();
|
|
2825
|
+
session.clearStatus();
|
|
2782
2826
|
}
|
|
2783
2827
|
// The machine end is away (its dashboard restarting, the machine
|
|
2784
2828
|
// waking). Forwarding Ctrl+C would kill the next dashboard as soon as it
|
|
@@ -2824,12 +2868,17 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2824
2868
|
// as a dropped connection, which attachWithReconnect reopens.
|
|
2825
2869
|
let lastHeard = Date.now();
|
|
2826
2870
|
let lastTick = Date.now();
|
|
2827
|
-
|
|
2828
|
-
socket.on("pong", () => {
|
|
2871
|
+
socket.on("pong", (data) => {
|
|
2829
2872
|
lastHeard = Date.now();
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2873
|
+
const { rtt, again } = receipts.pong(data);
|
|
2874
|
+
if (rtt !== null) {
|
|
2875
|
+
predictor?.noteRtt(rtt);
|
|
2876
|
+
}
|
|
2877
|
+
if (again) {
|
|
2878
|
+
try {
|
|
2879
|
+
sendPing();
|
|
2880
|
+
}
|
|
2881
|
+
catch { /* the liveness check handles a dead socket */ }
|
|
2833
2882
|
}
|
|
2834
2883
|
});
|
|
2835
2884
|
socket.on("message", () => { lastHeard = Date.now(); });
|
|
@@ -2840,13 +2889,12 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2840
2889
|
if (socket.readyState !== WebSocket.OPEN) {
|
|
2841
2890
|
return;
|
|
2842
2891
|
}
|
|
2843
|
-
if (slept || now - lastHeard > ATTACH_PONG_TIMEOUT_MS) {
|
|
2892
|
+
if (slept || now - lastHeard > ATTACH_PONG_TIMEOUT_MS || (receipts.unconfirmed > 0 && receipts.oldestPingAge() > ATTACH_RECEIPT_TIMEOUT_MS)) {
|
|
2844
2893
|
socket.terminate();
|
|
2845
2894
|
return;
|
|
2846
2895
|
}
|
|
2847
2896
|
try {
|
|
2848
|
-
|
|
2849
|
-
pingSentAt = Date.now();
|
|
2897
|
+
sendPing();
|
|
2850
2898
|
}
|
|
2851
2899
|
catch {
|
|
2852
2900
|
socket.terminate();
|
|
@@ -2879,6 +2927,7 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2879
2927
|
process.off("SIGINT", onSigint);
|
|
2880
2928
|
splash?.stop();
|
|
2881
2929
|
if (keepTerminal) {
|
|
2930
|
+
session.keepUnsent(receipts.takeUnconfirmed(), true);
|
|
2882
2931
|
session.enterGap();
|
|
2883
2932
|
}
|
|
2884
2933
|
else {
|
|
@@ -2994,8 +3043,7 @@ async function runAttach(target, options, sharedSession) {
|
|
|
2994
3043
|
session.exitGap();
|
|
2995
3044
|
// Measure the round trip at once: predictive echo waits on it.
|
|
2996
3045
|
try {
|
|
2997
|
-
|
|
2998
|
-
pingSentAt = Date.now();
|
|
3046
|
+
sendPing();
|
|
2999
3047
|
}
|
|
3000
3048
|
catch {
|
|
3001
3049
|
// the liveness timer retries
|
|
@@ -3044,7 +3092,7 @@ async function runAttach(target, options, sharedSession) {
|
|
|
3044
3092
|
// Typed while the link was down: sent first, in order.
|
|
3045
3093
|
const queued = session.takeQueued();
|
|
3046
3094
|
if (queued) {
|
|
3047
|
-
|
|
3095
|
+
sendInput(queued);
|
|
3048
3096
|
}
|
|
3049
3097
|
requestRepaint();
|
|
3050
3098
|
if (session.theme?.known) {
|
|
@@ -3217,7 +3265,7 @@ async function runAttach(target, options, sharedSession) {
|
|
|
3217
3265
|
// Past the splash nothing is written into the dashboard's picture: the
|
|
3218
3266
|
// state goes in the corner badge and comes off when it is over.
|
|
3219
3267
|
if (!hasControl) {
|
|
3220
|
-
session.showStatus("
|
|
3268
|
+
session.showStatus("Another terminal has control · type to take it");
|
|
3221
3269
|
}
|
|
3222
3270
|
else if (workerState === "down") {
|
|
3223
3271
|
session.showStatus(message.state === "worker-waiting"
|
|
@@ -3354,6 +3402,10 @@ Usage:
|
|
|
3354
3402
|
holds every repo) and attach to its dashboard. --snapshot uploads this
|
|
3355
3403
|
folder to its own machine instead.
|
|
3356
3404
|
rudder cloud home [status|start|stop|open <owner/repo>]
|
|
3405
|
+
rudder cloud host <ssh-target> [--data-disk /dev/X] [--hostname <name>] [--skip-setup] [--copy-from-fly] [--yes]
|
|
3406
|
+
run your home on any Linux host with Docker instead of Fly: sets the
|
|
3407
|
+
host up, then switches the home there (its Fly machine and volume stay
|
|
3408
|
+
as they are). --copy-from-fly prints how to copy the Fly disk first
|
|
3357
3409
|
rudder cloud preview [preview-id] [--list] [--json]
|
|
3358
3410
|
list registered private previews; open the exact preview-id over Tailscale
|
|
3359
3411
|
rudder cloud move [runId...] [--yes]
|