relayrunner 0.5.0 → 0.7.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 +25 -13
- package/dist/cli.js +593 -116
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# RelayRunner CLI
|
|
2
2
|
|
|
3
|
-
Connects a machine to the RelayRunner gateway so it can run
|
|
4
|
-
|
|
3
|
+
Connects a machine to the RelayRunner gateway so it can run GitHub Actions jobs
|
|
4
|
+
in your workspaces. It's published to npm as
|
|
5
5
|
[`relayrunner`](https://www.npmjs.com/package/relayrunner) and needs Node.js 22
|
|
6
6
|
or newer on macOS or Linux (x64 or ARM64).
|
|
7
7
|
|
|
@@ -20,14 +20,19 @@ npx relayrunner connect
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
The first run signs you in: it shows a code and opens the dashboard, where you
|
|
23
|
-
|
|
23
|
+
name this machine and approve. The machine is yours, and it's in every workspace
|
|
24
|
+
you're a member of (one per GitHub account or org RelayRunner is installed on),
|
|
25
|
+
so there's no workspace to pick. `connect` prints which ones it's in. If you
|
|
26
|
+
aren't in one yet, say because you skipped the install or an org owner hasn't
|
|
27
|
+
accepted your install request, it says so and links to the install. The
|
|
28
|
+
machine can still go online, and it takes jobs once you're in a workspace. The machine token is
|
|
24
29
|
saved to `~/.relayrunner/machine.json` (mode 0600); later runs reuse it. The
|
|
25
30
|
gateway sends a new token every time `connect` comes online and the old one
|
|
26
31
|
stops working, so a copy of `machine.json` from a backup or a synced dotfiles
|
|
27
32
|
folder can't sign in as the machine.
|
|
28
33
|
|
|
29
34
|
While it runs, the machine is online: it keeps a WebSocket open to the gateway,
|
|
30
|
-
runs the jobs it's sent
|
|
35
|
+
runs the jobs it's sent and prints what happens, including the
|
|
31
36
|
repo each job is from. It reconnects on its own if the connection drops. Ctrl-C
|
|
32
37
|
takes it offline; a job that's running stops with it. Press `p` to pause or
|
|
33
38
|
resume it without going offline (see `relayrunner pause`). The terminal tab's
|
|
@@ -53,15 +58,21 @@ approved the machine also gets an email, since someone else may have its token.
|
|
|
53
58
|
one is set, otherwise the Mac's Computer Name from System Settings).
|
|
54
59
|
- `--share only-me|anyone` sets who can run jobs on this machine without asking.
|
|
55
60
|
It works on a machine that's already signed in too.
|
|
61
|
+
- `--concurrency <n>` sets how many jobs it runs at once. The default is 2 on a
|
|
62
|
+
computer with 8 or more CPU cores, otherwise 1, and `connect` prints it. Each
|
|
63
|
+
slot runs its jobs in its own copy of the runner,
|
|
64
|
+
`~/.relayrunner/runner/<version>/slot-<n>/`, made when `connect` starts (a
|
|
65
|
+
copy-on-write clone where the disk supports it). With more than one slot,
|
|
66
|
+
each line of a job's output starts with its slot, such as `[slot 2]`.
|
|
56
67
|
- If the machine is removed in the dashboard, `connect` deletes the saved token.
|
|
57
68
|
A running `connect` exits and asks you to run it again; a new one signs in
|
|
58
69
|
straight away.
|
|
59
70
|
|
|
60
71
|
A new machine runs only jobs you started (`only-me`). Right after signing in,
|
|
61
|
-
if
|
|
62
|
-
machine?": Only me, or Anyone in
|
|
63
|
-
It doesn't ask in
|
|
64
|
-
answer. [`relayrunner share`](#relayrunner-share) changes it later.
|
|
72
|
+
if any of your workspaces has other members, `connect` asks "Who can run jobs on
|
|
73
|
+
this machine?": Only me, or Anyone in your workspaces (teammates' and bots' jobs
|
|
74
|
+
too). It doesn't ask when you're alone in all of them, on later runs, or without
|
|
75
|
+
a terminal to answer. [`relayrunner share`](#relayrunner-share) changes it later.
|
|
65
76
|
|
|
66
77
|
Run inside a checkout of a private repo where no job uses RelayRunner yet,
|
|
67
78
|
`connect` first asks whether to set it up (default no). Yes runs the same picker
|
|
@@ -97,10 +108,10 @@ npx relayrunner whoami
|
|
|
97
108
|
```
|
|
98
109
|
|
|
99
110
|
Asks the gateway who the saved machine token belongs to and prints the machine,
|
|
100
|
-
|
|
111
|
+
the workspaces it's in, who enrolled it (name and email) and whether it's online now.
|
|
101
112
|
|
|
102
113
|
- Not signed in: says so and exits 1.
|
|
103
|
-
- Removed
|
|
114
|
+
- Removed (or the token is no longer valid): says so and
|
|
104
115
|
exits 1. The saved token is left alone; the next `connect` replaces it.
|
|
105
116
|
- Gateway unreachable: prints what's saved locally, marked unverified, and exits 0.
|
|
106
117
|
- `--json` prints the same as JSON (never the token). `--server <url>` or
|
|
@@ -148,7 +159,7 @@ npx relayrunner resume
|
|
|
148
159
|
|
|
149
160
|
Pausing stops new jobs routing to this machine while it stays connected and
|
|
150
161
|
enrolled. A job it's already running finishes. `resume` lets jobs route here
|
|
151
|
-
again.
|
|
162
|
+
again. You can do the same from the machine's ⋯ menu on the
|
|
152
163
|
Runners page, and a running `relayrunner connect` prints when that happens.
|
|
153
164
|
In the terminal running `relayrunner connect`, `p` does the same.
|
|
154
165
|
Both exit 1 when not signed in or when the token is no longer valid.
|
|
@@ -158,11 +169,12 @@ Both exit 1 when not signed in or when the token is no longer valid.
|
|
|
158
169
|
```sh
|
|
159
170
|
npx relayrunner share # show the current setting
|
|
160
171
|
npx relayrunner share only-me # run only jobs you started
|
|
161
|
-
npx relayrunner share anyone # run any job in
|
|
172
|
+
npx relayrunner share anyone # run any job in your workspaces
|
|
162
173
|
```
|
|
163
174
|
|
|
164
175
|
Who can run jobs on this machine. `only-me` takes only jobs you started on
|
|
165
|
-
GitHub; `anyone` takes any job in
|
|
176
|
+
GitHub; `anyone` takes any job in your workspaces, including teammates' and
|
|
177
|
+
bots'. It's one setting for all of them.
|
|
166
178
|
It's the same setting as the sharing icon on the machine's card on the Runners
|
|
167
179
|
page, and only the machine's owner can change it there. `relayrunner whoami`
|
|
168
180
|
shows it too. Exits 1 when not signed in or when the token is no longer valid.
|
package/dist/cli.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import * as clack from "@clack/prompts";
|
|
3
3
|
import { defineCommand, runMain } from "citty";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { arch, cpus, homedir, hostname, platform, totalmem } from "node:os";
|
|
5
|
+
import { arch, availableParallelism, cpus, homedir, hostname, platform, totalmem } from "node:os";
|
|
6
6
|
import { basename, dirname, join, resolve } from "node:path";
|
|
7
|
-
import { chmodSync, createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { chmodSync, constants, cpSync, createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { execFile, spawn } from "node:child_process";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { Readable, Transform } from "node:stream";
|
|
11
11
|
import { pipeline } from "node:stream/promises";
|
|
12
12
|
import { styleText } from "node:util";
|
|
13
13
|
import { Scalar, YAMLSeq, isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
14
|
-
const version = z.literal(1);
|
|
14
|
+
const version$1 = z.literal(1);
|
|
15
15
|
const routeId = z.string().min(1);
|
|
16
16
|
const DeviceKind = z.enum([
|
|
17
17
|
"laptop",
|
|
@@ -31,7 +31,7 @@ const Device = z.object({
|
|
|
31
31
|
osVersion: text.optional()
|
|
32
32
|
});
|
|
33
33
|
const HelloMessage = z.object({
|
|
34
|
-
v: version,
|
|
34
|
+
v: version$1,
|
|
35
35
|
type: z.literal("hello"),
|
|
36
36
|
machineId: z.string().min(1),
|
|
37
37
|
os: z.enum([
|
|
@@ -45,16 +45,19 @@ const HelloMessage = z.object({
|
|
|
45
45
|
"arm"
|
|
46
46
|
]),
|
|
47
47
|
runnerVersion: z.string().min(1),
|
|
48
|
+
cliVersion: z.string().trim().min(1).max(40).optional(),
|
|
48
49
|
device: Device.optional().catch(void 0),
|
|
49
|
-
rotatesToken: z.boolean().optional()
|
|
50
|
+
rotatesToken: z.boolean().optional(),
|
|
51
|
+
slots: z.number().int().positive().max(1e3).optional()
|
|
50
52
|
});
|
|
51
53
|
const StatusMessage = z.object({
|
|
52
|
-
v: version,
|
|
54
|
+
v: version$1,
|
|
53
55
|
type: z.literal("status"),
|
|
54
|
-
state: z.enum(["idle", "busy"])
|
|
56
|
+
state: z.enum(["idle", "busy"]),
|
|
57
|
+
running: z.number().int().nonnegative().max(1e3).optional()
|
|
55
58
|
});
|
|
56
59
|
const JobMessage = z.object({
|
|
57
|
-
v: version,
|
|
60
|
+
v: version$1,
|
|
58
61
|
type: z.literal("job"),
|
|
59
62
|
routeId,
|
|
60
63
|
state: z.enum([
|
|
@@ -65,7 +68,7 @@ const JobMessage = z.object({
|
|
|
65
68
|
message: z.string().optional()
|
|
66
69
|
});
|
|
67
70
|
const TokenSavedMessage = z.object({
|
|
68
|
-
v: version,
|
|
71
|
+
v: version$1,
|
|
69
72
|
type: z.literal("token_saved")
|
|
70
73
|
});
|
|
71
74
|
z.discriminatedUnion("type", [
|
|
@@ -75,25 +78,25 @@ z.discriminatedUnion("type", [
|
|
|
75
78
|
TokenSavedMessage
|
|
76
79
|
]);
|
|
77
80
|
const RunMessage = z.object({
|
|
78
|
-
v: version,
|
|
81
|
+
v: version$1,
|
|
79
82
|
type: z.literal("run"),
|
|
80
83
|
routeId,
|
|
81
84
|
jitConfig: z.string().min(1)
|
|
82
85
|
});
|
|
83
86
|
const ErrorMessage = z.object({
|
|
84
|
-
v: version,
|
|
87
|
+
v: version$1,
|
|
85
88
|
type: z.literal("error"),
|
|
86
89
|
code: z.enum(["version_mismatch", "invalid_message"]),
|
|
87
90
|
message: z.string()
|
|
88
91
|
});
|
|
89
92
|
const PausedMessage = z.object({
|
|
90
|
-
v: version,
|
|
93
|
+
v: version$1,
|
|
91
94
|
type: z.literal("paused"),
|
|
92
95
|
paused: z.boolean(),
|
|
93
96
|
by: z.string().nullable()
|
|
94
97
|
});
|
|
95
98
|
const TokenMessage = z.object({
|
|
96
|
-
v: version,
|
|
99
|
+
v: version$1,
|
|
97
100
|
type: z.literal("token"),
|
|
98
101
|
token: z.string().min(1)
|
|
99
102
|
});
|
|
@@ -104,12 +107,12 @@ const GatewayMessage = z.discriminatedUnion("type", [
|
|
|
104
107
|
TokenMessage
|
|
105
108
|
]);
|
|
106
109
|
function parseGatewayMessage(frame) {
|
|
107
|
-
return parse(GatewayMessage, frame);
|
|
110
|
+
return parse$1(GatewayMessage, frame);
|
|
108
111
|
}
|
|
109
112
|
function encodeMessage(message) {
|
|
110
113
|
return JSON.stringify(message);
|
|
111
114
|
}
|
|
112
|
-
function parse(schema, frame) {
|
|
115
|
+
function parse$1(schema, frame) {
|
|
113
116
|
let data;
|
|
114
117
|
try {
|
|
115
118
|
data = JSON.parse(frame);
|
|
@@ -142,6 +145,8 @@ function parse(schema, frame) {
|
|
|
142
145
|
function isRunnerForRoute(runnerName, routeId) {
|
|
143
146
|
return runnerName.endsWith(`-${routeId}`);
|
|
144
147
|
}
|
|
148
|
+
// version.ts
|
|
149
|
+
const cliVersion = "0.7.0";
|
|
145
150
|
// paths.ts
|
|
146
151
|
function relayrunnerHome() {
|
|
147
152
|
return resolve(process.env.RELAYRUNNER_HOME || join(homedir(), ".relayrunner"));
|
|
@@ -149,7 +154,7 @@ function relayrunnerHome() {
|
|
|
149
154
|
function runnersDir() {
|
|
150
155
|
return join(relayrunnerHome(), "runner");
|
|
151
156
|
}
|
|
152
|
-
const userAgent =
|
|
157
|
+
const userAgent = `relayrunner-cli/${cliVersion}`;
|
|
153
158
|
const CLOSE_POLICY = 1008;
|
|
154
159
|
const NodeWebSocket = WebSocket;
|
|
155
160
|
function connectUrl(server) {
|
|
@@ -167,7 +172,8 @@ async function connect(options) {
|
|
|
167
172
|
const maxBackoffMs = options.maxBackoffMs ?? 3e4;
|
|
168
173
|
const emit = options.onEvent ?? (() => {});
|
|
169
174
|
const signal = options.signal;
|
|
170
|
-
|
|
175
|
+
const slots = options.slots ?? 1;
|
|
176
|
+
const busy = /* @__PURE__ */ new Set();
|
|
171
177
|
let socket = null;
|
|
172
178
|
let token = options.token;
|
|
173
179
|
const pending = [];
|
|
@@ -179,7 +185,8 @@ async function connect(options) {
|
|
|
179
185
|
const sendStatus = () => send({
|
|
180
186
|
v: 1,
|
|
181
187
|
type: "status",
|
|
182
|
-
state
|
|
188
|
+
state: busy.size > 0 ? "busy" : "idle",
|
|
189
|
+
running: busy.size
|
|
183
190
|
});
|
|
184
191
|
const saveToken = (next) => {
|
|
185
192
|
if (!options.saveToken) return;
|
|
@@ -199,15 +206,18 @@ async function connect(options) {
|
|
|
199
206
|
});
|
|
200
207
|
};
|
|
201
208
|
const startJob = (run) => {
|
|
202
|
-
|
|
209
|
+
let slot = 1;
|
|
210
|
+
while (busy.has(slot)) slot++;
|
|
211
|
+
if (slot > slots) {
|
|
203
212
|
emit({
|
|
204
213
|
type: "run-refused",
|
|
205
|
-
routeId: run.routeId
|
|
214
|
+
routeId: run.routeId,
|
|
215
|
+
running: busy.size
|
|
206
216
|
});
|
|
207
217
|
const update = {
|
|
208
218
|
routeId: run.routeId,
|
|
209
219
|
state: "failed",
|
|
210
|
-
message: "The machine is already running a job."
|
|
220
|
+
message: busy.size === 1 ? "The machine is already running a job." : `The machine is already running ${busy.size} jobs.`
|
|
211
221
|
};
|
|
212
222
|
send({
|
|
213
223
|
v: 1,
|
|
@@ -218,14 +228,16 @@ async function connect(options) {
|
|
|
218
228
|
}
|
|
219
229
|
emit({
|
|
220
230
|
type: "run",
|
|
221
|
-
routeId: run.routeId
|
|
231
|
+
routeId: run.routeId,
|
|
232
|
+
slot
|
|
222
233
|
});
|
|
223
|
-
|
|
234
|
+
busy.add(slot);
|
|
224
235
|
sendStatus();
|
|
225
|
-
options.runJob(run, (update) => {
|
|
236
|
+
options.runJob(run, slot, (update) => {
|
|
226
237
|
emit({
|
|
227
238
|
type: "job",
|
|
228
|
-
update
|
|
239
|
+
update,
|
|
240
|
+
slot
|
|
229
241
|
});
|
|
230
242
|
send({
|
|
231
243
|
v: 1,
|
|
@@ -233,7 +245,7 @@ async function connect(options) {
|
|
|
233
245
|
...update
|
|
234
246
|
});
|
|
235
247
|
}).finally(() => {
|
|
236
|
-
|
|
248
|
+
busy.delete(slot);
|
|
237
249
|
sendStatus();
|
|
238
250
|
});
|
|
239
251
|
};
|
|
@@ -271,6 +283,7 @@ async function connect(options) {
|
|
|
271
283
|
v: 1,
|
|
272
284
|
type: "hello",
|
|
273
285
|
...options.hello,
|
|
286
|
+
slots,
|
|
274
287
|
rotatesToken
|
|
275
288
|
}));
|
|
276
289
|
sendStatus();
|
|
@@ -536,7 +549,7 @@ const Credentials = z.object({
|
|
|
536
549
|
id: z.string().min(1),
|
|
537
550
|
name: z.string(),
|
|
538
551
|
slug: z.string().nullish()
|
|
539
|
-
}),
|
|
552
|
+
}).optional(),
|
|
540
553
|
token: z.string().min(1)
|
|
541
554
|
});
|
|
542
555
|
function credentialsPath(home = relayrunnerHome()) {
|
|
@@ -902,9 +915,244 @@ async function repoVisibility(repo, fetcher = fetch) {
|
|
|
902
915
|
return "unknown";
|
|
903
916
|
}
|
|
904
917
|
}
|
|
918
|
+
// ../../packages/providers/src/prices.ts
|
|
919
|
+
/** A provider's rates, and what one minute of each is per. */
|
|
920
|
+
const RATES = {
|
|
921
|
+
blacksmith: {
|
|
922
|
+
linux: "vcpu",
|
|
923
|
+
arm: "vcpu",
|
|
924
|
+
windows: "vcpu",
|
|
925
|
+
macos: "vcpu"
|
|
926
|
+
},
|
|
927
|
+
depot: {
|
|
928
|
+
linux: "vcpu",
|
|
929
|
+
arm: "vcpu",
|
|
930
|
+
windows: "vcpu",
|
|
931
|
+
macos: "vcpu"
|
|
932
|
+
},
|
|
933
|
+
warpbuild: {
|
|
934
|
+
linux: "vcpu",
|
|
935
|
+
arm: "vcpu",
|
|
936
|
+
windows: "vcpu",
|
|
937
|
+
macos: "vcpu"
|
|
938
|
+
},
|
|
939
|
+
ubicloud: {
|
|
940
|
+
standard: "vcpu",
|
|
941
|
+
premium: "vcpu"
|
|
942
|
+
},
|
|
943
|
+
github: {
|
|
944
|
+
"linux-1-core": "runner",
|
|
945
|
+
"linux-2-core": "runner",
|
|
946
|
+
"linux-arm-2-core": "runner",
|
|
947
|
+
"windows-2-core": "runner",
|
|
948
|
+
"windows-arm-2-core": "runner",
|
|
949
|
+
macos: "runner"
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
const isRate = (provider, rate) => Object.hasOwn(RATES, provider) && Object.hasOwn(RATES[provider], rate);
|
|
953
|
+
const vcpu = (perRunner, vcpus) => perRunner / vcpus;
|
|
954
|
+
const BASE_PRICES = [
|
|
955
|
+
{
|
|
956
|
+
provider: "blacksmith",
|
|
957
|
+
rate: "linux",
|
|
958
|
+
usd: vcpu(.004, 2),
|
|
959
|
+
from: "2026-11-11"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
provider: "blacksmith",
|
|
963
|
+
rate: "arm",
|
|
964
|
+
usd: vcpu(.0025, 2),
|
|
965
|
+
from: "2026-11-11"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
provider: "blacksmith",
|
|
969
|
+
rate: "windows",
|
|
970
|
+
usd: vcpu(.008, 2),
|
|
971
|
+
from: "2026-11-11"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
provider: "blacksmith",
|
|
975
|
+
rate: "macos",
|
|
976
|
+
usd: vcpu(.08, 6),
|
|
977
|
+
from: "2026-11-11"
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
provider: "depot",
|
|
981
|
+
rate: "linux",
|
|
982
|
+
usd: vcpu(.006, 2),
|
|
983
|
+
from: "2026-11-11"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
provider: "depot",
|
|
987
|
+
rate: "arm",
|
|
988
|
+
usd: vcpu(.006, 2),
|
|
989
|
+
from: "2026-11-11"
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
provider: "depot",
|
|
993
|
+
rate: "windows",
|
|
994
|
+
usd: vcpu(.008, 2),
|
|
995
|
+
from: "2026-11-11"
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
provider: "depot",
|
|
999
|
+
rate: "macos",
|
|
1000
|
+
usd: vcpu(.08, 8),
|
|
1001
|
+
from: "2026-11-11"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
provider: "warpbuild",
|
|
1005
|
+
rate: "linux",
|
|
1006
|
+
usd: vcpu(.004, 2),
|
|
1007
|
+
from: "2026-11-11"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
provider: "warpbuild",
|
|
1011
|
+
rate: "arm",
|
|
1012
|
+
usd: vcpu(.003, 2),
|
|
1013
|
+
from: "2026-11-11"
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
provider: "warpbuild",
|
|
1017
|
+
rate: "windows",
|
|
1018
|
+
usd: vcpu(.016, 4),
|
|
1019
|
+
from: "2026-11-11"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
provider: "warpbuild",
|
|
1023
|
+
rate: "macos",
|
|
1024
|
+
usd: vcpu(.08, 6),
|
|
1025
|
+
from: "2026-11-11"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
provider: "ubicloud",
|
|
1029
|
+
rate: "standard",
|
|
1030
|
+
usd: vcpu(8e-4, 2),
|
|
1031
|
+
from: "2023-01-01"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
provider: "ubicloud",
|
|
1035
|
+
rate: "standard",
|
|
1036
|
+
usd: vcpu(.001, 2),
|
|
1037
|
+
from: "2026-05-01"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
provider: "ubicloud",
|
|
1041
|
+
rate: "standard",
|
|
1042
|
+
usd: vcpu(.00125, 2),
|
|
1043
|
+
from: "2026-09-01"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
provider: "ubicloud",
|
|
1047
|
+
rate: "premium",
|
|
1048
|
+
usd: vcpu(.0016, 2),
|
|
1049
|
+
from: "2025-05-01"
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
provider: "ubicloud",
|
|
1053
|
+
rate: "premium",
|
|
1054
|
+
usd: vcpu(.002, 2),
|
|
1055
|
+
from: "2026-09-01"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
provider: "github",
|
|
1059
|
+
rate: "linux-1-core",
|
|
1060
|
+
usd: .002,
|
|
1061
|
+
from: "2026-11-11"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
provider: "github",
|
|
1065
|
+
rate: "linux-2-core",
|
|
1066
|
+
usd: .006,
|
|
1067
|
+
from: "2026-11-11"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
provider: "github",
|
|
1071
|
+
rate: "linux-arm-2-core",
|
|
1072
|
+
usd: .005,
|
|
1073
|
+
from: "2026-11-11"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
provider: "github",
|
|
1077
|
+
rate: "windows-2-core",
|
|
1078
|
+
usd: .01,
|
|
1079
|
+
from: "2026-11-11"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
provider: "github",
|
|
1083
|
+
rate: "windows-arm-2-core",
|
|
1084
|
+
usd: .01,
|
|
1085
|
+
from: "2026-11-11"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
provider: "github",
|
|
1089
|
+
rate: "macos",
|
|
1090
|
+
usd: .062,
|
|
1091
|
+
from: "2026-11-11"
|
|
1092
|
+
}
|
|
1093
|
+
];
|
|
1094
|
+
/** A UTC day (YYYY-MM-DD) as epoch ms at its midnight. */
|
|
1095
|
+
const dayMs = (day) => Date.parse(`${day}T00:00:00Z`);
|
|
1096
|
+
/**
|
|
1097
|
+
* Looks up price rows, leaving out any for a rate RATES doesn't list. Rows for the same rate and
|
|
1098
|
+
* day replace earlier ones in the list, so rows added on top of BASE_PRICES win.
|
|
1099
|
+
*/
|
|
1100
|
+
function priceBook(rows) {
|
|
1101
|
+
const byRate = /* @__PURE__ */ new Map();
|
|
1102
|
+
for (const row of rows) {
|
|
1103
|
+
if (!isRate(row.provider, row.rate)) continue;
|
|
1104
|
+
const key = `${row.provider}:${row.rate}`;
|
|
1105
|
+
const days = byRate.get(key) ?? /* @__PURE__ */ new Map();
|
|
1106
|
+
days.set(row.from, row);
|
|
1107
|
+
byRate.set(key, days);
|
|
1108
|
+
}
|
|
1109
|
+
const histories = new Map([...byRate].map(([key, days]) => [key, [...days.values()].sort((a, b) => a.from.localeCompare(b.from))]));
|
|
1110
|
+
const changes = /* @__PURE__ */ new Set();
|
|
1111
|
+
for (const history of histories.values()) for (const row of history.slice(1)) changes.add(dayMs(row.from));
|
|
1112
|
+
const history = (provider, rate) => histories.get(`${provider}:${rate}`) ?? [];
|
|
1113
|
+
return {
|
|
1114
|
+
usd(provider, rate, at) {
|
|
1115
|
+
let usd = null;
|
|
1116
|
+
for (const [i, row] of history(provider, rate).entries()) if (i === 0 || dayMs(row.from) <= at) usd = row.usd;
|
|
1117
|
+
return usd;
|
|
1118
|
+
},
|
|
1119
|
+
history,
|
|
1120
|
+
changes: [...changes].sort((a, b) => a - b)
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
priceBook(BASE_PRICES);
|
|
1124
|
+
// ../../packages/providers/src/index.ts
|
|
1125
|
+
/**
|
|
1126
|
+
* The hosted runner services a relay can send a job to. Each runs a job under the customer's own
|
|
1127
|
+
* account through its own GitHub App, which picks up any job queued with one of its labels, so
|
|
1128
|
+
* routing to one only means answering one of its labels. Each is a step in the runner order and an
|
|
1129
|
+
* input on the relay, both named by its id.
|
|
1130
|
+
*/
|
|
1131
|
+
const HOSTED_PROVIDER_IDS = [
|
|
1132
|
+
"blacksmith",
|
|
1133
|
+
"depot",
|
|
1134
|
+
"namespace",
|
|
1135
|
+
"warpbuild",
|
|
1136
|
+
"ubicloud",
|
|
1137
|
+
"runs-on"
|
|
1138
|
+
];
|
|
1139
|
+
const LABEL_PREFIXES = {
|
|
1140
|
+
blacksmith: ["blacksmith-"],
|
|
1141
|
+
depot: ["depot-"],
|
|
1142
|
+
namespace: ["namespace-profile-", "nscloud-"],
|
|
1143
|
+
warpbuild: ["warp-"],
|
|
1144
|
+
ubicloud: ["ubicloud-"],
|
|
1145
|
+
"runs-on": ["runs-on=", "runs-on/"]
|
|
1146
|
+
};
|
|
1147
|
+
const matches = (provider, lower) => LABEL_PREFIXES[provider].some((prefix) => lower.startsWith(prefix) || prefix.endsWith("-") && lower === prefix.slice(0, -1));
|
|
1148
|
+
/** The hosted provider whose runners a label asks for, or null. */
|
|
1149
|
+
function hostedProviderOf(label) {
|
|
1150
|
+
const lower = label.toLowerCase();
|
|
1151
|
+
return HOSTED_PROVIDER_IDS.find((id) => matches(id, lower)) ?? null;
|
|
1152
|
+
}
|
|
905
1153
|
// workflows.ts
|
|
906
1154
|
/** The relay version `init` writes. Bump it with each relayrunner/actions release. */
|
|
907
|
-
const RELAY_REF = "v1.0.0-beta.
|
|
1155
|
+
const RELAY_REF = "v1.0.0-beta.5";
|
|
908
1156
|
const RELAY_WORKFLOW = "relayrunner/actions/.github/workflows/relay.yml";
|
|
909
1157
|
const DEPLOY_SECRET = /\bsecrets\.(?!GITHUB_TOKEN\b)[A-Za-z_][A-Za-z0-9_]*/;
|
|
910
1158
|
const LINUX_PACKAGE_MANAGER = /(^|[\s;&|(])(sudo\s+)?(apt-get|apt|yum|dnf|apk)\s+(install|update|add)\b/m;
|
|
@@ -973,14 +1221,17 @@ function judge(file, id, job, workflow, relays, reusableOnly, options) {
|
|
|
973
1221
|
const lower = label.toLowerCase();
|
|
974
1222
|
let provider;
|
|
975
1223
|
let machine = "self-hosted";
|
|
976
|
-
|
|
977
|
-
|
|
1224
|
+
const hosted = hostedProviderOf(lower);
|
|
1225
|
+
if (/(^|-)windows-/.test(lower)) return skip("Windows jobs can't run on machines yet");
|
|
1226
|
+
if (hosted) {
|
|
1227
|
+
provider = hosted;
|
|
1228
|
+
if (lower.includes("macos")) machine = "macOS";
|
|
1229
|
+
} else if (/^(ubuntu|macos)-/.test(lower)) {
|
|
978
1230
|
provider = "github";
|
|
979
1231
|
if (lower.startsWith("macos-")) machine = "macOS";
|
|
980
|
-
} else if (lower
|
|
981
|
-
else if (lower === "relayrunner") return skip("already runs on RelayRunner");
|
|
1232
|
+
} else if (lower === "relayrunner") return skip("already runs on RelayRunner");
|
|
982
1233
|
else if (lower === "self-hosted") return skip("already runs on a self-hosted runner");
|
|
983
|
-
else return skip(`${label} isn't a GitHub-hosted or
|
|
1234
|
+
else return skip(`${label} isn't a GitHub-hosted or hosted provider label`);
|
|
984
1235
|
const warnings = jobWarnings(job, options);
|
|
985
1236
|
return {
|
|
986
1237
|
...base,
|
|
@@ -1480,7 +1731,7 @@ const JOB_STATE = [
|
|
|
1480
1731
|
".credentials_rsaparams"
|
|
1481
1732
|
];
|
|
1482
1733
|
async function runJob(run, options) {
|
|
1483
|
-
const {
|
|
1734
|
+
const { dir, report } = options;
|
|
1484
1735
|
const output = options.output ?? ((chunk, stream) => (stream === "stdout" ? process.stdout : process.stderr).write(chunk));
|
|
1485
1736
|
const finish = (update) => {
|
|
1486
1737
|
report(update);
|
|
@@ -1493,16 +1744,16 @@ async function runJob(run, options) {
|
|
|
1493
1744
|
message: `Refused the job's runner config: ${checked.reason}.`
|
|
1494
1745
|
});
|
|
1495
1746
|
options.onChecked?.(checked.target);
|
|
1496
|
-
const lock = join(
|
|
1747
|
+
const lock = join(dir, "job.lock");
|
|
1497
1748
|
if (!takeLock(lock)) return finish({
|
|
1498
1749
|
routeId: run.routeId,
|
|
1499
1750
|
state: "failed",
|
|
1500
|
-
message: `Another job is using the runner in ${
|
|
1751
|
+
message: `Another job is using the runner in ${dir}.`
|
|
1501
1752
|
});
|
|
1502
1753
|
try {
|
|
1503
|
-
clean(
|
|
1504
|
-
const child = spawn(join(
|
|
1505
|
-
cwd:
|
|
1754
|
+
clean(dir);
|
|
1755
|
+
const child = spawn(join(dir, "run.sh"), ["--jitconfig", run.jitConfig], {
|
|
1756
|
+
cwd: dir,
|
|
1506
1757
|
env: runnerEnv(),
|
|
1507
1758
|
stdio: [
|
|
1508
1759
|
"ignore",
|
|
@@ -1542,7 +1793,7 @@ async function runJob(run, options) {
|
|
|
1542
1793
|
message: error instanceof Error ? error.message : String(error)
|
|
1543
1794
|
});
|
|
1544
1795
|
} finally {
|
|
1545
|
-
clean(
|
|
1796
|
+
clean(dir);
|
|
1546
1797
|
rmSync(lock, { force: true });
|
|
1547
1798
|
}
|
|
1548
1799
|
}
|
|
@@ -1572,11 +1823,35 @@ function isAlive(pid) {
|
|
|
1572
1823
|
return error.code === "EPERM";
|
|
1573
1824
|
}
|
|
1574
1825
|
}
|
|
1826
|
+
function prefixLines(prefix, write) {
|
|
1827
|
+
const partial = {
|
|
1828
|
+
stdout: "",
|
|
1829
|
+
stderr: ""
|
|
1830
|
+
};
|
|
1831
|
+
const output = (chunk, stream) => {
|
|
1832
|
+
const text = partial[stream] + chunk.toString();
|
|
1833
|
+
const end = text.lastIndexOf("\n") + 1;
|
|
1834
|
+
partial[stream] = text.slice(end);
|
|
1835
|
+
if (end === 0) return;
|
|
1836
|
+
const lines = text.slice(0, end).replace(/^(?=.)/gm, prefix);
|
|
1837
|
+
write(Buffer.from(lines), stream);
|
|
1838
|
+
};
|
|
1839
|
+
const flush = () => {
|
|
1840
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
1841
|
+
if (partial[stream]) write(Buffer.from(`${prefix}${partial[stream]}\n`), stream);
|
|
1842
|
+
partial[stream] = "";
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
return {
|
|
1846
|
+
output,
|
|
1847
|
+
flush
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1575
1850
|
// live.ts
|
|
1576
1851
|
const INITIAL_STATE = {
|
|
1577
1852
|
link: "connecting",
|
|
1578
1853
|
paused: false,
|
|
1579
|
-
|
|
1854
|
+
jobs: []
|
|
1580
1855
|
};
|
|
1581
1856
|
/** The state after a connection event. */
|
|
1582
1857
|
function nextState(state, event) {
|
|
@@ -1595,11 +1870,11 @@ function nextState(state, event) {
|
|
|
1595
1870
|
};
|
|
1596
1871
|
case "run": return {
|
|
1597
1872
|
...state,
|
|
1598
|
-
|
|
1873
|
+
jobs: [...state.jobs, event.routeId]
|
|
1599
1874
|
};
|
|
1600
|
-
case "job": return event.update.state === "started" || event.update.routeId
|
|
1875
|
+
case "job": return event.update.state === "started" || !state.jobs.includes(event.update.routeId) ? state : {
|
|
1601
1876
|
...state,
|
|
1602
|
-
|
|
1877
|
+
jobs: state.jobs.filter((id) => id !== event.update.routeId)
|
|
1603
1878
|
};
|
|
1604
1879
|
case "paused": return {
|
|
1605
1880
|
...state,
|
|
@@ -1615,10 +1890,11 @@ function nextState(state, event) {
|
|
|
1615
1890
|
function titleFor(state, machine) {
|
|
1616
1891
|
return `RelayRunner · ${machine} · ${statusText(state)}`;
|
|
1617
1892
|
}
|
|
1618
|
-
function statusText({ link, paused,
|
|
1893
|
+
function statusText({ link, paused, jobs }) {
|
|
1894
|
+
const running = jobs.length === 1 ? "Running a job" : `Running ${jobs.length} jobs`;
|
|
1619
1895
|
if (link === "connecting") return "Connecting…";
|
|
1620
|
-
if (link === "reconnecting") return
|
|
1621
|
-
if (
|
|
1896
|
+
if (link === "reconnecting") return jobs.length ? `${running}, reconnecting…` : "Reconnecting…";
|
|
1897
|
+
if (jobs.length) return paused ? `${running}, then paused` : running;
|
|
1622
1898
|
return paused ? "Paused" : "Waiting for jobs";
|
|
1623
1899
|
}
|
|
1624
1900
|
const ESC = "\x1B";
|
|
@@ -1684,6 +1960,119 @@ function startLive(options) {
|
|
|
1684
1960
|
}
|
|
1685
1961
|
};
|
|
1686
1962
|
}
|
|
1963
|
+
// update-check.ts
|
|
1964
|
+
const CHECK_INTERVAL_MS = 864e5;
|
|
1965
|
+
const REGISTRY_URL = "https://registry.npmjs.org/relayrunner/latest";
|
|
1966
|
+
const TIMEOUT_MS = 3e3;
|
|
1967
|
+
const Cache = z.object({
|
|
1968
|
+
checkedAt: z.number(),
|
|
1969
|
+
latest: z.string()
|
|
1970
|
+
});
|
|
1971
|
+
/** The newer version npm has, or null when this CLI is current or the check couldn't tell. */
|
|
1972
|
+
async function checkForUpdate(options = {}) {
|
|
1973
|
+
const now = options.now ?? Date.now();
|
|
1974
|
+
const current = options.current ?? cliVersion;
|
|
1975
|
+
let cache = readCache();
|
|
1976
|
+
if (!cache || now - cache.checkedAt >= 864e5) {
|
|
1977
|
+
const latest = await fetchLatest(options.fetch ?? fetch);
|
|
1978
|
+
if (latest) {
|
|
1979
|
+
cache = {
|
|
1980
|
+
checkedAt: now,
|
|
1981
|
+
latest
|
|
1982
|
+
};
|
|
1983
|
+
writeCache(cache);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return cache && isNewer(cache.latest, current) ? cache.latest : null;
|
|
1987
|
+
}
|
|
1988
|
+
/** The line to print for a newer version, with the command that updates the way this one runs. */
|
|
1989
|
+
function updateNotice(latest, current = cliVersion, argv1 = process.argv[1] ?? "") {
|
|
1990
|
+
return `relayrunner ${latest} is available (you have ${current}). Update with \`${/[\\/]_npx[\\/]/.test(argv1) ? "npx relayrunner@latest connect" : "npm install --global relayrunner@latest"}\`.`;
|
|
1991
|
+
}
|
|
1992
|
+
function isNewer(candidate, current) {
|
|
1993
|
+
const a = parse(candidate);
|
|
1994
|
+
const b = parse(current);
|
|
1995
|
+
if (!a || !b) return false;
|
|
1996
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
function parse(version) {
|
|
2000
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version.trim());
|
|
2001
|
+
return match ? [
|
|
2002
|
+
Number(match[1]),
|
|
2003
|
+
Number(match[2]),
|
|
2004
|
+
Number(match[3])
|
|
2005
|
+
] : null;
|
|
2006
|
+
}
|
|
2007
|
+
async function fetchLatest(fetcher) {
|
|
2008
|
+
try {
|
|
2009
|
+
const response = await fetcher(REGISTRY_URL, {
|
|
2010
|
+
headers: {
|
|
2011
|
+
accept: "application/json",
|
|
2012
|
+
"user-agent": userAgent
|
|
2013
|
+
},
|
|
2014
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
2015
|
+
});
|
|
2016
|
+
if (!response.ok) {
|
|
2017
|
+
await response.body?.cancel();
|
|
2018
|
+
return null;
|
|
2019
|
+
}
|
|
2020
|
+
const body = z.object({ version: z.string() }).safeParse(await response.json());
|
|
2021
|
+
return body.success ? body.data.version : null;
|
|
2022
|
+
} catch {
|
|
2023
|
+
return null;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
function cachePath() {
|
|
2027
|
+
return join(relayrunnerHome(), "update-check.json");
|
|
2028
|
+
}
|
|
2029
|
+
function readCache() {
|
|
2030
|
+
try {
|
|
2031
|
+
const parsed = Cache.safeParse(JSON.parse(readFileSync(cachePath(), "utf8")));
|
|
2032
|
+
return parsed.success ? parsed.data : null;
|
|
2033
|
+
} catch {
|
|
2034
|
+
return null;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
function writeCache(cache) {
|
|
2038
|
+
try {
|
|
2039
|
+
mkdirSync(relayrunnerHome(), { recursive: true });
|
|
2040
|
+
writeFileSync(cachePath(), `${JSON.stringify(cache)}\n`);
|
|
2041
|
+
} catch {}
|
|
2042
|
+
}
|
|
2043
|
+
// workspaces.ts
|
|
2044
|
+
const Workspace = z.object({
|
|
2045
|
+
id: z.string().min(1),
|
|
2046
|
+
name: z.string(),
|
|
2047
|
+
slug: z.string().nullish(),
|
|
2048
|
+
memberCount: z.number().int().nonnegative().optional()
|
|
2049
|
+
});
|
|
2050
|
+
const WorkspaceFields = {
|
|
2051
|
+
workspace: Workspace.nullish(),
|
|
2052
|
+
workspaces: z.array(Workspace).optional()
|
|
2053
|
+
};
|
|
2054
|
+
/** The machine's workspaces, from the list or else the single `workspace` an older gateway sends. */
|
|
2055
|
+
function readWorkspaces(body) {
|
|
2056
|
+
return body.workspaces ?? (body.workspace ? [body.workspace] : []);
|
|
2057
|
+
}
|
|
2058
|
+
/** Whether anyone else is in one of them, so teammates' jobs could run on the machine. */
|
|
2059
|
+
function hasTeammates(workspaces) {
|
|
2060
|
+
return workspaces.some((workspace) => (workspace.memberCount ?? 0) > 1);
|
|
2061
|
+
}
|
|
2062
|
+
/** "Acme", "Acme and atticoos", "Acme, Beta and atticoos". */
|
|
2063
|
+
function workspaceNames(workspaces) {
|
|
2064
|
+
const names = workspaces.map((workspace) => workspace.name);
|
|
2065
|
+
if (names.length <= 1) return names.join("");
|
|
2066
|
+
return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
2067
|
+
}
|
|
2068
|
+
/** What "anyone" reaches: the one workspace by name, or "your workspaces". */
|
|
2069
|
+
function sharingScope(workspaces) {
|
|
2070
|
+
return workspaces.length === 1 ? workspaces[0].name : "your workspaces";
|
|
2071
|
+
}
|
|
2072
|
+
/** Said after signing in when the machine isn't in any workspace yet. */
|
|
2073
|
+
function noWorkspaceYet(machine, server) {
|
|
2074
|
+
return [`${machine} isn't in a workspace yet. It takes jobs once RelayRunner is installed on a GitHub account or org you belong to, or once an org owner accepts your install request.`, `Install: ${new URL("/api/github/install", server)}`].join("\n");
|
|
2075
|
+
}
|
|
1687
2076
|
// login.ts
|
|
1688
2077
|
const CLIENT_ID = "relayrunner-cli";
|
|
1689
2078
|
const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -1712,12 +2101,7 @@ const ClaimResponse = z.object({
|
|
|
1712
2101
|
id: z.string().min(1),
|
|
1713
2102
|
name: z.string()
|
|
1714
2103
|
}),
|
|
1715
|
-
|
|
1716
|
-
id: z.string().min(1),
|
|
1717
|
-
name: z.string(),
|
|
1718
|
-
slug: z.string().nullish(),
|
|
1719
|
-
memberCount: z.number().int().nonnegative().optional()
|
|
1720
|
-
}),
|
|
2104
|
+
...WorkspaceFields,
|
|
1721
2105
|
token: z.string().min(1)
|
|
1722
2106
|
});
|
|
1723
2107
|
async function login(options) {
|
|
@@ -1788,7 +2172,6 @@ async function login(options) {
|
|
|
1788
2172
|
}, { authorization: `Bearer ${accessToken}` });
|
|
1789
2173
|
if (!claimResponse.ok) throw new LoginError("CLAIM_FAILED", `The gateway approved the sign-in but wouldn't enroll this machine (HTTP ${claimResponse.status}).`);
|
|
1790
2174
|
const claimed = ClaimResponse.parse(await claimResponse.json());
|
|
1791
|
-
const { memberCount, ...workspace } = claimed.workspace;
|
|
1792
2175
|
return {
|
|
1793
2176
|
credentials: {
|
|
1794
2177
|
server: new URL(options.server).origin,
|
|
@@ -1796,10 +2179,9 @@ async function login(options) {
|
|
|
1796
2179
|
id: claimed.machine.id,
|
|
1797
2180
|
name: claimed.machine.name
|
|
1798
2181
|
},
|
|
1799
|
-
workspace,
|
|
1800
2182
|
token: claimed.token
|
|
1801
2183
|
},
|
|
1802
|
-
|
|
2184
|
+
workspaces: readWorkspaces(claimed)
|
|
1803
2185
|
};
|
|
1804
2186
|
}
|
|
1805
2187
|
function openBrowser(url) {
|
|
@@ -1867,6 +2249,62 @@ function pauseMachine(credentials, paused) {
|
|
|
1867
2249
|
paused
|
|
1868
2250
|
}));
|
|
1869
2251
|
}
|
|
2252
|
+
// slots.ts
|
|
2253
|
+
const MAX_SLOTS = 1e3;
|
|
2254
|
+
function defaultConcurrency(cores = availableParallelism()) {
|
|
2255
|
+
return cores >= 8 ? 2 : 1;
|
|
2256
|
+
}
|
|
2257
|
+
function parseConcurrency(value, cores) {
|
|
2258
|
+
if (value === void 0 || value === "") return defaultConcurrency(cores);
|
|
2259
|
+
const n = Number(value);
|
|
2260
|
+
if (!/^\d+$/.test(value.trim()) || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new Error(`--concurrency takes a whole number from 1 to ${MAX_SLOTS}, not "${value}".`);
|
|
2261
|
+
return n;
|
|
2262
|
+
}
|
|
2263
|
+
function slotDir(runner, slot) {
|
|
2264
|
+
return join(runner.dir, `slot-${slot}`);
|
|
2265
|
+
}
|
|
2266
|
+
function ensureSlots(runner, count, log = () => {}) {
|
|
2267
|
+
const dirs = [];
|
|
2268
|
+
const missing = [];
|
|
2269
|
+
for (let slot = 1; slot <= count; slot++) {
|
|
2270
|
+
const dir = slotDir(runner, slot);
|
|
2271
|
+
dirs.push(dir);
|
|
2272
|
+
if (!existsSync(join(dir, "run.sh"))) missing.push(slot);
|
|
2273
|
+
}
|
|
2274
|
+
if (missing.length > 0) log(missing.length === 1 ? `Setting up runner slot ${missing[0]}…` : `Setting up ${missing.length} runner slots…`);
|
|
2275
|
+
for (const slot of missing) copySlot(runner.dir, slotDir(runner, slot));
|
|
2276
|
+
return dirs;
|
|
2277
|
+
}
|
|
2278
|
+
const SKIP = /^(slot-\d+|\.slot-.*|_work|_diag|\.runner|\.credentials.*|job\.lock)$/;
|
|
2279
|
+
function copySlot(source, dir) {
|
|
2280
|
+
rmSync(dir, {
|
|
2281
|
+
recursive: true,
|
|
2282
|
+
force: true
|
|
2283
|
+
});
|
|
2284
|
+
const temp = mkdtempSync(join(source, `.${basename(dir)}-`));
|
|
2285
|
+
try {
|
|
2286
|
+
for (const name of readdirSync(source)) {
|
|
2287
|
+
if (SKIP.test(name)) continue;
|
|
2288
|
+
cpSync(join(source, name), join(temp, name), {
|
|
2289
|
+
recursive: true,
|
|
2290
|
+
mode: constants.COPYFILE_FICLONE,
|
|
2291
|
+
verbatimSymlinks: true,
|
|
2292
|
+
preserveTimestamps: true
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
try {
|
|
2296
|
+
renameSync(temp, dir);
|
|
2297
|
+
} catch (error) {
|
|
2298
|
+
const code = error.code;
|
|
2299
|
+
if (code !== "EEXIST" && code !== "ENOTEMPTY") throw error;
|
|
2300
|
+
}
|
|
2301
|
+
} finally {
|
|
2302
|
+
rmSync(temp, {
|
|
2303
|
+
recursive: true,
|
|
2304
|
+
force: true
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
1870
2308
|
// share.ts
|
|
1871
2309
|
const SHARE_CHOICES = ["only-me", "anyone"];
|
|
1872
2310
|
const MachineSharing = z.enum(["only_me", "anyone"]);
|
|
@@ -1875,11 +2313,11 @@ function parseShareChoice(value) {
|
|
|
1875
2313
|
}
|
|
1876
2314
|
const toSharing = (choice) => choice === "only-me" ? "only_me" : "anyone";
|
|
1877
2315
|
const toChoice = (sharing) => sharing === "only_me" ? "only-me" : "anyone";
|
|
1878
|
-
function sharingMeaning(sharing,
|
|
1879
|
-
return sharing === "only_me" ? "runs only jobs you started" : `runs any job in ${
|
|
2316
|
+
function sharingMeaning(sharing, scope = "your workspaces") {
|
|
2317
|
+
return sharing === "only_me" ? "runs only jobs you started" : `runs any job in ${scope}, including teammates' and bots'`;
|
|
1880
2318
|
}
|
|
1881
|
-
function describeSharing(sharing,
|
|
1882
|
-
return `${toChoice(sharing)}: ${sharingMeaning(sharing,
|
|
2319
|
+
function describeSharing(sharing, scope) {
|
|
2320
|
+
return `${toChoice(sharing)}: ${sharingMeaning(sharing, scope)}`;
|
|
1883
2321
|
}
|
|
1884
2322
|
const SharingResponse = z.object({ machine: z.object({ sharing: MachineSharing }) });
|
|
1885
2323
|
async function setSharing(options) {
|
|
@@ -1937,12 +2375,7 @@ const WhoamiResponse = z.object({
|
|
|
1937
2375
|
paused: z.object({ by: z.string().nullable() }).nullish(),
|
|
1938
2376
|
sharing: z.enum(["only_me", "anyone"]).optional()
|
|
1939
2377
|
}),
|
|
1940
|
-
|
|
1941
|
-
id: z.string().min(1),
|
|
1942
|
-
name: z.string(),
|
|
1943
|
-
slug: z.string().nullish(),
|
|
1944
|
-
memberCount: z.number().int().nonnegative().optional()
|
|
1945
|
-
}),
|
|
2378
|
+
...WorkspaceFields,
|
|
1946
2379
|
enrolledBy: z.object({
|
|
1947
2380
|
name: z.string(),
|
|
1948
2381
|
email: z.string()
|
|
@@ -1983,7 +2416,7 @@ const DEFAULT_SERVER = "https://app.relayrunner.app";
|
|
|
1983
2416
|
const connectCommand = defineCommand({
|
|
1984
2417
|
meta: {
|
|
1985
2418
|
name: "connect",
|
|
1986
|
-
description: "Put this machine online for your
|
|
2419
|
+
description: "Put this machine online for your workspaces and run the jobs the gateway sends it. Signs in on first run; Ctrl-C takes the machine offline."
|
|
1987
2420
|
},
|
|
1988
2421
|
args: {
|
|
1989
2422
|
server: {
|
|
@@ -1996,13 +2429,28 @@ const connectCommand = defineCommand({
|
|
|
1996
2429
|
},
|
|
1997
2430
|
share: {
|
|
1998
2431
|
type: "string",
|
|
1999
|
-
description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in
|
|
2432
|
+
description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces. Skips the question."
|
|
2433
|
+
},
|
|
2434
|
+
concurrency: {
|
|
2435
|
+
type: "string",
|
|
2436
|
+
description: "How many jobs to run at once (default: 2 with 8 or more CPU cores, otherwise 1)"
|
|
2000
2437
|
}
|
|
2001
2438
|
},
|
|
2002
2439
|
async run({ args }) {
|
|
2003
2440
|
clack.intro("RelayRunner");
|
|
2441
|
+
let concurrency;
|
|
2442
|
+
try {
|
|
2443
|
+
concurrency = parseConcurrency(args.concurrency);
|
|
2444
|
+
} catch (error) {
|
|
2445
|
+
clack.log.error(error.message);
|
|
2446
|
+
process.exitCode = 1;
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2004
2449
|
try {
|
|
2005
|
-
await connectMachine(
|
|
2450
|
+
await connectMachine({
|
|
2451
|
+
...args,
|
|
2452
|
+
concurrency
|
|
2453
|
+
});
|
|
2006
2454
|
} catch (error) {
|
|
2007
2455
|
if (!(error instanceof LoginError || error instanceof RunnerError)) throw error;
|
|
2008
2456
|
clack.log.error(error.message);
|
|
@@ -2021,11 +2469,23 @@ async function connectMachine(args) {
|
|
|
2021
2469
|
}
|
|
2022
2470
|
if (!credentials) credentials = await enroll(server, args.name, platform, share);
|
|
2023
2471
|
else {
|
|
2024
|
-
clack.log.info(`Machine ${credentials.machine.name}
|
|
2025
|
-
if (share) await applySharing(credentials, share);
|
|
2472
|
+
clack.log.info(`Machine ${credentials.machine.name} (${credentials.server})`);
|
|
2473
|
+
if (share) await applySharing(credentials, share, null);
|
|
2026
2474
|
}
|
|
2027
2475
|
if (process.stdin.isTTY && process.stdout.isTTY) await offerSetup();
|
|
2476
|
+
let updateTimer;
|
|
2477
|
+
if (process.stdout.isTTY && !process.env.CI) {
|
|
2478
|
+
const notifyUpdate = () => void checkForUpdate().then((latest) => {
|
|
2479
|
+
if (latest) clack.log.warn(updateNotice(latest));
|
|
2480
|
+
});
|
|
2481
|
+
notifyUpdate();
|
|
2482
|
+
updateTimer = setInterval(notifyUpdate, CHECK_INTERVAL_MS);
|
|
2483
|
+
updateTimer.unref();
|
|
2484
|
+
}
|
|
2028
2485
|
const runner = await ensureRunner({ log: (line) => clack.log.info(line) });
|
|
2486
|
+
const slots = args.concurrency;
|
|
2487
|
+
const slotDirs = ensureSlots(runner, slots, (line) => clack.log.info(line));
|
|
2488
|
+
clack.log.info(slots === 1 ? "Running 1 job at a time. Change with --concurrency." : `Running up to ${slots} jobs at once. Change with --concurrency.`);
|
|
2029
2489
|
const device = await detectDevice();
|
|
2030
2490
|
const stop = new AbortController();
|
|
2031
2491
|
const enrolled = credentials;
|
|
@@ -2058,24 +2518,35 @@ async function connectMachine(args) {
|
|
|
2058
2518
|
machineId: credentials.machine.id,
|
|
2059
2519
|
...platform,
|
|
2060
2520
|
runnerVersion: runner.version,
|
|
2521
|
+
cliVersion,
|
|
2061
2522
|
device
|
|
2062
2523
|
},
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2524
|
+
slots,
|
|
2525
|
+
runJob: async (run, slot, report) => {
|
|
2526
|
+
const prefixed = slots > 1 ? prefixLines(`[slot ${slot}] `, (chunk, stream) => (stream === "stdout" ? process.stdout : process.stderr).write(chunk)) : void 0;
|
|
2527
|
+
try {
|
|
2528
|
+
return await runJob(run, {
|
|
2529
|
+
dir: slotDirs[slot - 1],
|
|
2530
|
+
report,
|
|
2531
|
+
output: prefixed?.output,
|
|
2532
|
+
onChecked: (target) => {
|
|
2533
|
+
if (target) clack.log.info(`${(/* @__PURE__ */ new Date()).toLocaleTimeString()} Job ${run.routeId}${slots > 1 ? ` (slot ${slot})` : ""} is from ${target}`);
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
} finally {
|
|
2537
|
+
prefixed?.flush();
|
|
2068
2538
|
}
|
|
2069
|
-
}
|
|
2539
|
+
},
|
|
2070
2540
|
saveToken: (token) => saveRotatedToken(credentials, token),
|
|
2071
2541
|
onEvent: (event) => {
|
|
2072
2542
|
if (event.type === "connected") online = true;
|
|
2073
|
-
show(event);
|
|
2543
|
+
show(event, slots > 1);
|
|
2074
2544
|
live.onEvent(event);
|
|
2075
2545
|
},
|
|
2076
2546
|
signal: stop.signal
|
|
2077
2547
|
});
|
|
2078
2548
|
} finally {
|
|
2549
|
+
clearInterval(updateTimer);
|
|
2079
2550
|
live.end();
|
|
2080
2551
|
process.off("SIGINT", onInterrupt);
|
|
2081
2552
|
}
|
|
@@ -2086,13 +2557,13 @@ async function connectMachine(args) {
|
|
|
2086
2557
|
case "revoked":
|
|
2087
2558
|
deleteCredentials();
|
|
2088
2559
|
if (!online) {
|
|
2089
|
-
clack.log.warn("This machine was removed
|
|
2560
|
+
clack.log.warn("This machine was removed or its token is no longer valid. If you didn't remove it, another copy of its token may have signed in elsewhere: check the Runners page. Signing in again.");
|
|
2090
2561
|
return connectMachine({
|
|
2091
2562
|
...args,
|
|
2092
2563
|
server: credentials.server
|
|
2093
2564
|
});
|
|
2094
2565
|
}
|
|
2095
|
-
clack.log.error("This machine was removed
|
|
2566
|
+
clack.log.error("This machine was removed or its token is no longer valid. If you didn't remove it, another copy of its token may have signed in elsewhere: check the Runners page and revoke it if so.");
|
|
2096
2567
|
clack.outro("Run `relayrunner connect` again to sign in.");
|
|
2097
2568
|
process.exitCode = 1;
|
|
2098
2569
|
break;
|
|
@@ -2107,7 +2578,7 @@ async function connectMachine(args) {
|
|
|
2107
2578
|
process.exitCode = 1;
|
|
2108
2579
|
}
|
|
2109
2580
|
}
|
|
2110
|
-
async function askSharing(
|
|
2581
|
+
async function askSharing(workspaces) {
|
|
2111
2582
|
const picked = await clack.select({
|
|
2112
2583
|
message: "Who can run jobs on this machine?",
|
|
2113
2584
|
options: [{
|
|
@@ -2116,7 +2587,7 @@ async function askSharing(workspace) {
|
|
|
2116
2587
|
hint: "jobs you started"
|
|
2117
2588
|
}, {
|
|
2118
2589
|
value: "anyone",
|
|
2119
|
-
label: `Anyone in ${
|
|
2590
|
+
label: `Anyone in ${sharingScope(workspaces)}`,
|
|
2120
2591
|
hint: "teammates' and bots' jobs too, from repos you can open"
|
|
2121
2592
|
}],
|
|
2122
2593
|
initialValue: "only-me"
|
|
@@ -2127,7 +2598,7 @@ async function askSharing(workspace) {
|
|
|
2127
2598
|
}
|
|
2128
2599
|
return picked;
|
|
2129
2600
|
}
|
|
2130
|
-
async function applySharing(credentials, choice) {
|
|
2601
|
+
async function applySharing(credentials, choice, workspaces) {
|
|
2131
2602
|
const result = await withCurrentToken(credentials, (token) => setSharing({
|
|
2132
2603
|
server: credentials.server,
|
|
2133
2604
|
token,
|
|
@@ -2135,7 +2606,7 @@ async function applySharing(credentials, choice) {
|
|
|
2135
2606
|
}));
|
|
2136
2607
|
switch (result.status) {
|
|
2137
2608
|
case "ok":
|
|
2138
|
-
clack.log.info(`Sharing: ${describeSharing(result.sharing,
|
|
2609
|
+
clack.log.info(`Sharing: ${describeSharing(result.sharing, workspaces ? sharingScope(workspaces) : void 0)}`);
|
|
2139
2610
|
break;
|
|
2140
2611
|
case "revoked": break;
|
|
2141
2612
|
case "failed": clack.log.warn(`Couldn't set sharing: ${result.reason}. Run \`relayrunner share ${choice}\` to try again.`);
|
|
@@ -2144,7 +2615,7 @@ async function applySharing(credentials, choice) {
|
|
|
2144
2615
|
const loginCommand = defineCommand({
|
|
2145
2616
|
meta: {
|
|
2146
2617
|
name: "login",
|
|
2147
|
-
description: "Sign this machine in
|
|
2618
|
+
description: "Sign this machine in without putting it online. It's in all your workspaces. Run `relayrunner connect` afterwards to take jobs."
|
|
2148
2619
|
},
|
|
2149
2620
|
args: {
|
|
2150
2621
|
server: {
|
|
@@ -2157,7 +2628,7 @@ const loginCommand = defineCommand({
|
|
|
2157
2628
|
},
|
|
2158
2629
|
share: {
|
|
2159
2630
|
type: "string",
|
|
2160
|
-
description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in
|
|
2631
|
+
description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces. Skips the question."
|
|
2161
2632
|
}
|
|
2162
2633
|
},
|
|
2163
2634
|
async run({ args }) {
|
|
@@ -2167,15 +2638,18 @@ const loginCommand = defineCommand({
|
|
|
2167
2638
|
const saved = readCredentials();
|
|
2168
2639
|
const server = serverFor(args.server, saved);
|
|
2169
2640
|
if (saved && saved.server === server) {
|
|
2170
|
-
|
|
2641
|
+
const result = await withCurrentToken(saved, (token) => whoami({
|
|
2171
2642
|
server,
|
|
2172
2643
|
token
|
|
2173
|
-
}))
|
|
2174
|
-
|
|
2175
|
-
|
|
2644
|
+
}));
|
|
2645
|
+
if (result.status !== "revoked") {
|
|
2646
|
+
const workspaces = result.status === "ok" ? readWorkspaces(result.identity) : null;
|
|
2647
|
+
if (share) await applySharing(saved, share, workspaces);
|
|
2648
|
+
const where = workspaces?.length ? ` in ${workspaceNames(workspaces)}` : "";
|
|
2649
|
+
clack.outro(`Already signed in as ${saved.machine.name}${where}. Run \`relayrunner connect\` to go online.`);
|
|
2176
2650
|
return;
|
|
2177
2651
|
}
|
|
2178
|
-
clack.log.warn(`${saved.machine.name} is no longer
|
|
2652
|
+
clack.log.warn(`${saved.machine.name} is no longer signed in. Signing in again.`);
|
|
2179
2653
|
} else if (saved) clack.log.warn(`This machine is enrolled with ${saved.server}, not ${server}. Signing in again.`);
|
|
2180
2654
|
await enroll(server, args.name, machinePlatform(), share);
|
|
2181
2655
|
clack.outro("Run `relayrunner connect` to put this machine online.");
|
|
@@ -2204,16 +2678,17 @@ function machinePlatform() {
|
|
|
2204
2678
|
}
|
|
2205
2679
|
/** Signs in through the browser, saves the machine token, and settles who can run jobs here. */
|
|
2206
2680
|
async function enroll(server, name, platform, share) {
|
|
2207
|
-
const
|
|
2208
|
-
const credentials = signedIn.credentials;
|
|
2681
|
+
const { credentials, workspaces } = await signIn(server, name || await defaultMachineName(), platform);
|
|
2209
2682
|
writeCredentials(credentials);
|
|
2210
|
-
|
|
2683
|
+
const where = workspaces.length ? ` in ${workspaceNames(workspaces)}` : "";
|
|
2684
|
+
clack.log.success(`Enrolled as ${credentials.machine.name}${where}. Token saved to ${credentialsPath()}.`);
|
|
2685
|
+
if (!workspaces.length) clack.log.warn(noWorkspaceYet(credentials.machine.name, server));
|
|
2211
2686
|
let choice = share;
|
|
2212
|
-
if (!choice && (
|
|
2213
|
-
if (process.stdin.isTTY && process.stdout.isTTY) choice = await askSharing(
|
|
2687
|
+
if (!choice && hasTeammates(workspaces)) {
|
|
2688
|
+
if (process.stdin.isTTY && process.stdout.isTTY) choice = await askSharing(workspaces);
|
|
2214
2689
|
else clack.log.info("Only jobs you started run here. `relayrunner share anyone` lets teammates' jobs run here too.");
|
|
2215
2690
|
}
|
|
2216
|
-
if (choice) await applySharing(credentials, choice);
|
|
2691
|
+
if (choice) await applySharing(credentials, choice, workspaces);
|
|
2217
2692
|
return credentials;
|
|
2218
2693
|
}
|
|
2219
2694
|
async function signIn(server, name, platform) {
|
|
@@ -2236,7 +2711,7 @@ async function signIn(server, name, platform) {
|
|
|
2236
2711
|
throw error;
|
|
2237
2712
|
}
|
|
2238
2713
|
}
|
|
2239
|
-
function show(event) {
|
|
2714
|
+
function show(event, slotted) {
|
|
2240
2715
|
const at = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
2241
2716
|
switch (event.type) {
|
|
2242
2717
|
case "connecting":
|
|
@@ -2252,7 +2727,7 @@ function show(event) {
|
|
|
2252
2727
|
clack.log.error(`${at} Gateway: ${event.message}`);
|
|
2253
2728
|
break;
|
|
2254
2729
|
case "run":
|
|
2255
|
-
clack.log.step(`${at} Starting job ${event.routeId}`);
|
|
2730
|
+
clack.log.step(`${at} Starting job ${event.routeId}${slotted ? ` in slot ${event.slot}` : ""}`);
|
|
2256
2731
|
break;
|
|
2257
2732
|
case "paused":
|
|
2258
2733
|
if (event.paused) clack.log.warn(`${at} Paused${event.by ? ` by ${event.by}` : ""}. Staying online, but new jobs skip this machine until it's resumed.${process.stdin.isTTY ? " Press p to resume." : ""}`);
|
|
@@ -2262,11 +2737,11 @@ function show(event) {
|
|
|
2262
2737
|
clack.log.warn(`${at} Couldn't save the machine's new token (${event.message}). Keeping the old one.`);
|
|
2263
2738
|
break;
|
|
2264
2739
|
case "run-refused":
|
|
2265
|
-
clack.log.warn(`${at} Turned down job ${event.routeId}: already running one.`);
|
|
2740
|
+
clack.log.warn(`${at} Turned down job ${event.routeId}: already running ${event.running === 1 ? "one" : `${event.running}`}.`);
|
|
2266
2741
|
break;
|
|
2267
2742
|
case "job": {
|
|
2268
2743
|
const { routeId, state, message } = event.update;
|
|
2269
|
-
const line = `${at} Job ${routeId} ${state}${message ? `: ${message}` : ""}`;
|
|
2744
|
+
const line = `${at} Job ${routeId}${slotted ? ` (slot ${event.slot})` : ""} ${state}${message ? `: ${message}` : ""}`;
|
|
2270
2745
|
if (state === "failed") clack.log.error(line);
|
|
2271
2746
|
else if (state === "finished") clack.log.success(line);
|
|
2272
2747
|
else clack.log.info(line);
|
|
@@ -2277,7 +2752,7 @@ function show(event) {
|
|
|
2277
2752
|
const whoamiCommand = defineCommand({
|
|
2278
2753
|
meta: {
|
|
2279
2754
|
name: "whoami",
|
|
2280
|
-
description: "Show which machine
|
|
2755
|
+
description: "Show which machine this computer is signed in as and the workspaces it's in, checked with the gateway."
|
|
2281
2756
|
},
|
|
2282
2757
|
args: {
|
|
2283
2758
|
server: {
|
|
@@ -2304,8 +2779,7 @@ const whoamiCommand = defineCommand({
|
|
|
2304
2779
|
}
|
|
2305
2780
|
const saved = {
|
|
2306
2781
|
server: credentials.server,
|
|
2307
|
-
machine: credentials.machine
|
|
2308
|
-
workspace: credentials.workspace
|
|
2782
|
+
machine: credentials.machine
|
|
2309
2783
|
};
|
|
2310
2784
|
const result = await withCurrentToken(credentials, (token) => whoami({
|
|
2311
2785
|
server: credentials.server,
|
|
@@ -2320,7 +2794,7 @@ const whoamiCommand = defineCommand({
|
|
|
2320
2794
|
});
|
|
2321
2795
|
break;
|
|
2322
2796
|
case "revoked":
|
|
2323
|
-
print(`${credentials.machine.name} was removed
|
|
2797
|
+
print(`${credentials.machine.name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`, {
|
|
2324
2798
|
status: "revoked",
|
|
2325
2799
|
...saved
|
|
2326
2800
|
});
|
|
@@ -2335,20 +2809,21 @@ const whoamiCommand = defineCommand({
|
|
|
2335
2809
|
}
|
|
2336
2810
|
});
|
|
2337
2811
|
function describeIdentity(server, identity) {
|
|
2338
|
-
const { machine,
|
|
2812
|
+
const { machine, enrolledBy } = identity;
|
|
2813
|
+
const workspaces = readWorkspaces(identity);
|
|
2339
2814
|
const status = (machine.status.online ? `online${machine.status.state ? `, ${machine.status.state}` : ""}` : "offline") + (machine.paused ? `, paused${machine.paused.by ? ` by ${machine.paused.by}` : ""}` : "");
|
|
2340
2815
|
const enrolled = [enrolledBy && `by ${enrolledBy.name} <${enrolledBy.email}>`, `on ${new Date(machine.createdAt).toLocaleDateString()}`].filter(Boolean).join(" ");
|
|
2341
2816
|
return table(`${machine.name} (${machine.id})`, [
|
|
2342
|
-
["
|
|
2817
|
+
["Workspaces", workspaces.length ? workspaceNames(workspaces) : "none yet: install RelayRunner on GitHub to get one"],
|
|
2343
2818
|
["Platform", [machine.os, machine.arch].filter(Boolean).join(" ") || "unknown"],
|
|
2344
2819
|
["Enrolled", enrolled],
|
|
2345
2820
|
["Status", status],
|
|
2346
|
-
...machine.sharing ? [["Sharing", describeSharing(machine.sharing,
|
|
2821
|
+
...machine.sharing ? [["Sharing", describeSharing(machine.sharing, sharingScope(workspaces))]] : [],
|
|
2347
2822
|
["Gateway", server]
|
|
2348
2823
|
]);
|
|
2349
2824
|
}
|
|
2350
2825
|
function describeSaved(saved) {
|
|
2351
|
-
return table(`${saved.machine.name} (${saved.machine.id})`, [["
|
|
2826
|
+
return table(`${saved.machine.name} (${saved.machine.id})`, [["Gateway", saved.server]]);
|
|
2352
2827
|
}
|
|
2353
2828
|
function table(title, rows) {
|
|
2354
2829
|
const width = Math.max(...rows.map(([label]) => label.length));
|
|
@@ -2374,7 +2849,7 @@ function pauseCommand(paused) {
|
|
|
2374
2849
|
console.log(paused ? `Paused ${name}. It stays connected, and new jobs will skip it.${result.busy ? "\nIt finishes the job it's running first." : ""}\nRun \`relayrunner resume\` to take jobs again.` : `Resumed ${name}. Jobs can route here again.`);
|
|
2375
2850
|
break;
|
|
2376
2851
|
case "revoked":
|
|
2377
|
-
console.error(`${name} was removed
|
|
2852
|
+
console.error(`${name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
|
|
2378
2853
|
process.exitCode = 1;
|
|
2379
2854
|
break;
|
|
2380
2855
|
case "failed":
|
|
@@ -2387,7 +2862,7 @@ function pauseCommand(paused) {
|
|
|
2387
2862
|
const shareCommand = defineCommand({
|
|
2388
2863
|
meta: {
|
|
2389
2864
|
name: "share",
|
|
2390
|
-
description: "Show or change who can run jobs on this machine: only-me (jobs you started) or anyone in
|
|
2865
|
+
description: "Show or change who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces."
|
|
2391
2866
|
},
|
|
2392
2867
|
args: { who: {
|
|
2393
2868
|
type: "positional",
|
|
@@ -2402,9 +2877,8 @@ const shareCommand = defineCommand({
|
|
|
2402
2877
|
return;
|
|
2403
2878
|
}
|
|
2404
2879
|
const { name } = credentials.machine;
|
|
2405
|
-
const workspace = credentials.workspace.name;
|
|
2406
2880
|
const revoked = () => {
|
|
2407
|
-
console.error(`${name} was removed
|
|
2881
|
+
console.error(`${name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
|
|
2408
2882
|
process.exitCode = 1;
|
|
2409
2883
|
};
|
|
2410
2884
|
if (args.who) {
|
|
@@ -2425,7 +2899,7 @@ const shareCommand = defineCommand({
|
|
|
2425
2899
|
process.exitCode = 1;
|
|
2426
2900
|
return;
|
|
2427
2901
|
}
|
|
2428
|
-
console.log(`${name} now ${sharingMeaning(result.sharing
|
|
2902
|
+
console.log(`${name} now ${sharingMeaning(result.sharing)}.`);
|
|
2429
2903
|
return;
|
|
2430
2904
|
}
|
|
2431
2905
|
const result = await withCurrentToken(credentials, (token) => whoami({
|
|
@@ -2445,8 +2919,10 @@ const shareCommand = defineCommand({
|
|
|
2445
2919
|
return;
|
|
2446
2920
|
}
|
|
2447
2921
|
const other = sharing === "only_me" ? "anyone" : "only-me";
|
|
2448
|
-
const
|
|
2449
|
-
|
|
2922
|
+
const workspaces = readWorkspaces(result.identity);
|
|
2923
|
+
const lines = [`${name} ${sharingMeaning(sharing, sharingScope(workspaces))} (${toChoice(sharing)}).`];
|
|
2924
|
+
if (!workspaces.length) lines.push(`${name} isn't in a workspace yet, so this matters once it is.`);
|
|
2925
|
+
else if (workspaces.every((workspace) => workspace.memberCount === 1)) lines.push(`Nobody else is in ${sharingScope(workspaces)} yet, so this matters once a teammate joins.`);
|
|
2450
2926
|
lines.push(`Change it with \`relayrunner share ${other}\`.`);
|
|
2451
2927
|
console.log(lines.join("\n"));
|
|
2452
2928
|
}
|
|
@@ -2454,6 +2930,7 @@ const shareCommand = defineCommand({
|
|
|
2454
2930
|
const main = defineCommand({
|
|
2455
2931
|
meta: {
|
|
2456
2932
|
name: "relayrunner",
|
|
2933
|
+
version: cliVersion,
|
|
2457
2934
|
description: "Run GitHub Actions jobs on your machine through the RelayRunner gateway."
|
|
2458
2935
|
},
|
|
2459
2936
|
subCommands: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relayrunner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Run GitHub Actions jobs on your machine through the RelayRunner gateway.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@relayrunner/machine-protocol": "0.0.0",
|
|
28
|
+
"@relayrunner/providers": "0.0.0",
|
|
28
29
|
"@types/ws": "^8.18.2",
|
|
29
30
|
"tsdown": "^0.23.5",
|
|
30
31
|
"ws": "^8.22.1"
|