relayrunner 0.5.0 → 0.6.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.
Files changed (3) hide show
  1. package/README.md +18 -12
  2. package/dist/cli.js +328 -64
  3. 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 your workspace's
4
- GitHub Actions jobs. It's published to npm as
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,7 +20,12 @@ 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
- pick the workspace and name for this machine and approve. The machine token is
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
@@ -58,10 +63,10 @@ approved the machine also gets an email, since someone else may have its token.
58
63
  straight away.
59
64
 
60
65
  A new machine runs only jobs you started (`only-me`). Right after signing in,
61
- if the workspace has other members, `connect` asks "Who can run jobs on this
62
- machine?": Only me, or Anyone in the workspace (teammates' and bots' jobs too).
63
- It doesn't ask in a workspace of one, on later runs, or without a terminal to
64
- answer. [`relayrunner share`](#relayrunner-share) changes it later.
66
+ if any of your workspaces has other members, `connect` asks "Who can run jobs on
67
+ this machine?": Only me, or Anyone in your workspaces (teammates' and bots' jobs
68
+ too). It doesn't ask when you're alone in all of them, on later runs, or without
69
+ a terminal to answer. [`relayrunner share`](#relayrunner-share) changes it later.
65
70
 
66
71
  Run inside a checkout of a private repo where no job uses RelayRunner yet,
67
72
  `connect` first asks whether to set it up (default no). Yes runs the same picker
@@ -97,10 +102,10 @@ npx relayrunner whoami
97
102
  ```
98
103
 
99
104
  Asks the gateway who the saved machine token belongs to and prints the machine,
100
- its workspace, who enrolled it (name and email) and whether it's online now.
105
+ the workspaces it's in, who enrolled it (name and email) and whether it's online now.
101
106
 
102
107
  - Not signed in: says so and exits 1.
103
- - Removed from the workspace (or the token is no longer valid): says so and
108
+ - Removed (or the token is no longer valid): says so and
104
109
  exits 1. The saved token is left alone; the next `connect` replaces it.
105
110
  - Gateway unreachable: prints what's saved locally, marked unverified, and exits 0.
106
111
  - `--json` prints the same as JSON (never the token). `--server <url>` or
@@ -148,7 +153,7 @@ npx relayrunner resume
148
153
 
149
154
  Pausing stops new jobs routing to this machine while it stays connected and
150
155
  enrolled. A job it's already running finishes. `resume` lets jobs route here
151
- again. Anyone in the workspace can do the same from the machine's ⋯ menu on the
156
+ again. You can do the same from the machine's ⋯ menu on the
152
157
  Runners page, and a running `relayrunner connect` prints when that happens.
153
158
  In the terminal running `relayrunner connect`, `p` does the same.
154
159
  Both exit 1 when not signed in or when the token is no longer valid.
@@ -158,11 +163,12 @@ Both exit 1 when not signed in or when the token is no longer valid.
158
163
  ```sh
159
164
  npx relayrunner share # show the current setting
160
165
  npx relayrunner share only-me # run only jobs you started
161
- npx relayrunner share anyone # run any job in the workspace
166
+ npx relayrunner share anyone # run any job in your workspaces
162
167
  ```
163
168
 
164
169
  Who can run jobs on this machine. `only-me` takes only jobs you started on
165
- GitHub; `anyone` takes any job in the workspace, including teammates' and bots'.
170
+ GitHub; `anyone` takes any job in your workspaces, including teammates' and
171
+ bots'. It's one setting for all of them.
166
172
  It's the same setting as the sharing icon on the machine's card on the Runners
167
173
  page, and only the machine's owner can change it there. `relayrunner whoami`
168
174
  shows it too. Exits 1 when not signed in or when the token is no longer valid.
package/dist/cli.js CHANGED
@@ -536,7 +536,7 @@ const Credentials = z.object({
536
536
  id: z.string().min(1),
537
537
  name: z.string(),
538
538
  slug: z.string().nullish()
539
- }),
539
+ }).optional(),
540
540
  token: z.string().min(1)
541
541
  });
542
542
  function credentialsPath(home = relayrunnerHome()) {
@@ -902,9 +902,244 @@ async function repoVisibility(repo, fetcher = fetch) {
902
902
  return "unknown";
903
903
  }
904
904
  }
905
+ // ../../packages/providers/src/prices.ts
906
+ /** A provider's rates, and what one minute of each is per. */
907
+ const RATES = {
908
+ blacksmith: {
909
+ linux: "vcpu",
910
+ arm: "vcpu",
911
+ windows: "vcpu",
912
+ macos: "vcpu"
913
+ },
914
+ depot: {
915
+ linux: "vcpu",
916
+ arm: "vcpu",
917
+ windows: "vcpu",
918
+ macos: "vcpu"
919
+ },
920
+ warpbuild: {
921
+ linux: "vcpu",
922
+ arm: "vcpu",
923
+ windows: "vcpu",
924
+ macos: "vcpu"
925
+ },
926
+ ubicloud: {
927
+ standard: "vcpu",
928
+ premium: "vcpu"
929
+ },
930
+ github: {
931
+ "linux-1-core": "runner",
932
+ "linux-2-core": "runner",
933
+ "linux-arm-2-core": "runner",
934
+ "windows-2-core": "runner",
935
+ "windows-arm-2-core": "runner",
936
+ macos: "runner"
937
+ }
938
+ };
939
+ const isRate = (provider, rate) => Object.hasOwn(RATES, provider) && Object.hasOwn(RATES[provider], rate);
940
+ const vcpu = (perRunner, vcpus) => perRunner / vcpus;
941
+ const BASE_PRICES = [
942
+ {
943
+ provider: "blacksmith",
944
+ rate: "linux",
945
+ usd: vcpu(.004, 2),
946
+ from: "2026-11-11"
947
+ },
948
+ {
949
+ provider: "blacksmith",
950
+ rate: "arm",
951
+ usd: vcpu(.0025, 2),
952
+ from: "2026-11-11"
953
+ },
954
+ {
955
+ provider: "blacksmith",
956
+ rate: "windows",
957
+ usd: vcpu(.008, 2),
958
+ from: "2026-11-11"
959
+ },
960
+ {
961
+ provider: "blacksmith",
962
+ rate: "macos",
963
+ usd: vcpu(.08, 6),
964
+ from: "2026-11-11"
965
+ },
966
+ {
967
+ provider: "depot",
968
+ rate: "linux",
969
+ usd: vcpu(.006, 2),
970
+ from: "2026-11-11"
971
+ },
972
+ {
973
+ provider: "depot",
974
+ rate: "arm",
975
+ usd: vcpu(.006, 2),
976
+ from: "2026-11-11"
977
+ },
978
+ {
979
+ provider: "depot",
980
+ rate: "windows",
981
+ usd: vcpu(.008, 2),
982
+ from: "2026-11-11"
983
+ },
984
+ {
985
+ provider: "depot",
986
+ rate: "macos",
987
+ usd: vcpu(.08, 8),
988
+ from: "2026-11-11"
989
+ },
990
+ {
991
+ provider: "warpbuild",
992
+ rate: "linux",
993
+ usd: vcpu(.004, 2),
994
+ from: "2026-11-11"
995
+ },
996
+ {
997
+ provider: "warpbuild",
998
+ rate: "arm",
999
+ usd: vcpu(.003, 2),
1000
+ from: "2026-11-11"
1001
+ },
1002
+ {
1003
+ provider: "warpbuild",
1004
+ rate: "windows",
1005
+ usd: vcpu(.016, 4),
1006
+ from: "2026-11-11"
1007
+ },
1008
+ {
1009
+ provider: "warpbuild",
1010
+ rate: "macos",
1011
+ usd: vcpu(.08, 6),
1012
+ from: "2026-11-11"
1013
+ },
1014
+ {
1015
+ provider: "ubicloud",
1016
+ rate: "standard",
1017
+ usd: vcpu(8e-4, 2),
1018
+ from: "2023-01-01"
1019
+ },
1020
+ {
1021
+ provider: "ubicloud",
1022
+ rate: "standard",
1023
+ usd: vcpu(.001, 2),
1024
+ from: "2026-05-01"
1025
+ },
1026
+ {
1027
+ provider: "ubicloud",
1028
+ rate: "standard",
1029
+ usd: vcpu(.00125, 2),
1030
+ from: "2026-09-01"
1031
+ },
1032
+ {
1033
+ provider: "ubicloud",
1034
+ rate: "premium",
1035
+ usd: vcpu(.0016, 2),
1036
+ from: "2025-05-01"
1037
+ },
1038
+ {
1039
+ provider: "ubicloud",
1040
+ rate: "premium",
1041
+ usd: vcpu(.002, 2),
1042
+ from: "2026-09-01"
1043
+ },
1044
+ {
1045
+ provider: "github",
1046
+ rate: "linux-1-core",
1047
+ usd: .002,
1048
+ from: "2026-11-11"
1049
+ },
1050
+ {
1051
+ provider: "github",
1052
+ rate: "linux-2-core",
1053
+ usd: .006,
1054
+ from: "2026-11-11"
1055
+ },
1056
+ {
1057
+ provider: "github",
1058
+ rate: "linux-arm-2-core",
1059
+ usd: .005,
1060
+ from: "2026-11-11"
1061
+ },
1062
+ {
1063
+ provider: "github",
1064
+ rate: "windows-2-core",
1065
+ usd: .01,
1066
+ from: "2026-11-11"
1067
+ },
1068
+ {
1069
+ provider: "github",
1070
+ rate: "windows-arm-2-core",
1071
+ usd: .01,
1072
+ from: "2026-11-11"
1073
+ },
1074
+ {
1075
+ provider: "github",
1076
+ rate: "macos",
1077
+ usd: .062,
1078
+ from: "2026-11-11"
1079
+ }
1080
+ ];
1081
+ /** A UTC day (YYYY-MM-DD) as epoch ms at its midnight. */
1082
+ const dayMs = (day) => Date.parse(`${day}T00:00:00Z`);
1083
+ /**
1084
+ * Looks up price rows, leaving out any for a rate RATES doesn't list. Rows for the same rate and
1085
+ * day replace earlier ones in the list, so rows added on top of BASE_PRICES win.
1086
+ */
1087
+ function priceBook(rows) {
1088
+ const byRate = /* @__PURE__ */ new Map();
1089
+ for (const row of rows) {
1090
+ if (!isRate(row.provider, row.rate)) continue;
1091
+ const key = `${row.provider}:${row.rate}`;
1092
+ const days = byRate.get(key) ?? /* @__PURE__ */ new Map();
1093
+ days.set(row.from, row);
1094
+ byRate.set(key, days);
1095
+ }
1096
+ const histories = new Map([...byRate].map(([key, days]) => [key, [...days.values()].sort((a, b) => a.from.localeCompare(b.from))]));
1097
+ const changes = /* @__PURE__ */ new Set();
1098
+ for (const history of histories.values()) for (const row of history.slice(1)) changes.add(dayMs(row.from));
1099
+ const history = (provider, rate) => histories.get(`${provider}:${rate}`) ?? [];
1100
+ return {
1101
+ usd(provider, rate, at) {
1102
+ let usd = null;
1103
+ for (const [i, row] of history(provider, rate).entries()) if (i === 0 || dayMs(row.from) <= at) usd = row.usd;
1104
+ return usd;
1105
+ },
1106
+ history,
1107
+ changes: [...changes].sort((a, b) => a - b)
1108
+ };
1109
+ }
1110
+ priceBook(BASE_PRICES);
1111
+ // ../../packages/providers/src/index.ts
1112
+ /**
1113
+ * The hosted runner services a relay can send a job to. Each runs a job under the customer's own
1114
+ * account through its own GitHub App, which picks up any job queued with one of its labels, so
1115
+ * routing to one only means answering one of its labels. Each is a step in the runner order and an
1116
+ * input on the relay, both named by its id.
1117
+ */
1118
+ const HOSTED_PROVIDER_IDS = [
1119
+ "blacksmith",
1120
+ "depot",
1121
+ "namespace",
1122
+ "warpbuild",
1123
+ "ubicloud",
1124
+ "runs-on"
1125
+ ];
1126
+ const LABEL_PREFIXES = {
1127
+ blacksmith: ["blacksmith-"],
1128
+ depot: ["depot-"],
1129
+ namespace: ["namespace-profile-", "nscloud-"],
1130
+ warpbuild: ["warp-"],
1131
+ ubicloud: ["ubicloud-"],
1132
+ "runs-on": ["runs-on=", "runs-on/"]
1133
+ };
1134
+ const matches = (provider, lower) => LABEL_PREFIXES[provider].some((prefix) => lower.startsWith(prefix) || prefix.endsWith("-") && lower === prefix.slice(0, -1));
1135
+ /** The hosted provider whose runners a label asks for, or null. */
1136
+ function hostedProviderOf(label) {
1137
+ const lower = label.toLowerCase();
1138
+ return HOSTED_PROVIDER_IDS.find((id) => matches(id, lower)) ?? null;
1139
+ }
905
1140
  // workflows.ts
906
1141
  /** The relay version `init` writes. Bump it with each relayrunner/actions release. */
907
- const RELAY_REF = "v1.0.0-beta.4";
1142
+ const RELAY_REF = "v1.0.0-beta.5";
908
1143
  const RELAY_WORKFLOW = "relayrunner/actions/.github/workflows/relay.yml";
909
1144
  const DEPLOY_SECRET = /\bsecrets\.(?!GITHUB_TOKEN\b)[A-Za-z_][A-Za-z0-9_]*/;
910
1145
  const LINUX_PACKAGE_MANAGER = /(^|[\s;&|(])(sudo\s+)?(apt-get|apt|yum|dnf|apk)\s+(install|update|add)\b/m;
@@ -973,14 +1208,17 @@ function judge(file, id, job, workflow, relays, reusableOnly, options) {
973
1208
  const lower = label.toLowerCase();
974
1209
  let provider;
975
1210
  let machine = "self-hosted";
976
- if (lower.startsWith("blacksmith-")) provider = "blacksmith";
977
- else if (/^(ubuntu|macos)-/.test(lower)) {
1211
+ const hosted = hostedProviderOf(lower);
1212
+ if (/(^|-)windows-/.test(lower)) return skip("Windows jobs can't run on machines yet");
1213
+ if (hosted) {
1214
+ provider = hosted;
1215
+ if (lower.includes("macos")) machine = "macOS";
1216
+ } else if (/^(ubuntu|macos)-/.test(lower)) {
978
1217
  provider = "github";
979
1218
  if (lower.startsWith("macos-")) machine = "macOS";
980
- } else if (lower.startsWith("windows-")) return skip("Windows jobs can't run on machines yet");
981
- else if (lower === "relayrunner") return skip("already runs on RelayRunner");
1219
+ } else if (lower === "relayrunner") return skip("already runs on RelayRunner");
982
1220
  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 Blacksmith label`);
1221
+ else return skip(`${label} isn't a GitHub-hosted or hosted provider label`);
984
1222
  const warnings = jobWarnings(job, options);
985
1223
  return {
986
1224
  ...base,
@@ -1684,6 +1922,39 @@ function startLive(options) {
1684
1922
  }
1685
1923
  };
1686
1924
  }
1925
+ // workspaces.ts
1926
+ const Workspace = z.object({
1927
+ id: z.string().min(1),
1928
+ name: z.string(),
1929
+ slug: z.string().nullish(),
1930
+ memberCount: z.number().int().nonnegative().optional()
1931
+ });
1932
+ const WorkspaceFields = {
1933
+ workspace: Workspace.nullish(),
1934
+ workspaces: z.array(Workspace).optional()
1935
+ };
1936
+ /** The machine's workspaces, from the list or else the single `workspace` an older gateway sends. */
1937
+ function readWorkspaces(body) {
1938
+ return body.workspaces ?? (body.workspace ? [body.workspace] : []);
1939
+ }
1940
+ /** Whether anyone else is in one of them, so teammates' jobs could run on the machine. */
1941
+ function hasTeammates(workspaces) {
1942
+ return workspaces.some((workspace) => (workspace.memberCount ?? 0) > 1);
1943
+ }
1944
+ /** "Acme", "Acme and atticoos", "Acme, Beta and atticoos". */
1945
+ function workspaceNames(workspaces) {
1946
+ const names = workspaces.map((workspace) => workspace.name);
1947
+ if (names.length <= 1) return names.join("");
1948
+ return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
1949
+ }
1950
+ /** What "anyone" reaches: the one workspace by name, or "your workspaces". */
1951
+ function sharingScope(workspaces) {
1952
+ return workspaces.length === 1 ? workspaces[0].name : "your workspaces";
1953
+ }
1954
+ /** Said after signing in when the machine isn't in any workspace yet. */
1955
+ function noWorkspaceYet(machine, server) {
1956
+ 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");
1957
+ }
1687
1958
  // login.ts
1688
1959
  const CLIENT_ID = "relayrunner-cli";
1689
1960
  const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
@@ -1712,12 +1983,7 @@ const ClaimResponse = z.object({
1712
1983
  id: z.string().min(1),
1713
1984
  name: z.string()
1714
1985
  }),
1715
- workspace: z.object({
1716
- id: z.string().min(1),
1717
- name: z.string(),
1718
- slug: z.string().nullish(),
1719
- memberCount: z.number().int().nonnegative().optional()
1720
- }),
1986
+ ...WorkspaceFields,
1721
1987
  token: z.string().min(1)
1722
1988
  });
1723
1989
  async function login(options) {
@@ -1788,7 +2054,6 @@ async function login(options) {
1788
2054
  }, { authorization: `Bearer ${accessToken}` });
1789
2055
  if (!claimResponse.ok) throw new LoginError("CLAIM_FAILED", `The gateway approved the sign-in but wouldn't enroll this machine (HTTP ${claimResponse.status}).`);
1790
2056
  const claimed = ClaimResponse.parse(await claimResponse.json());
1791
- const { memberCount, ...workspace } = claimed.workspace;
1792
2057
  return {
1793
2058
  credentials: {
1794
2059
  server: new URL(options.server).origin,
@@ -1796,10 +2061,9 @@ async function login(options) {
1796
2061
  id: claimed.machine.id,
1797
2062
  name: claimed.machine.name
1798
2063
  },
1799
- workspace,
1800
2064
  token: claimed.token
1801
2065
  },
1802
- memberCount: memberCount ?? null
2066
+ workspaces: readWorkspaces(claimed)
1803
2067
  };
1804
2068
  }
1805
2069
  function openBrowser(url) {
@@ -1875,11 +2139,11 @@ function parseShareChoice(value) {
1875
2139
  }
1876
2140
  const toSharing = (choice) => choice === "only-me" ? "only_me" : "anyone";
1877
2141
  const toChoice = (sharing) => sharing === "only_me" ? "only-me" : "anyone";
1878
- function sharingMeaning(sharing, workspace) {
1879
- return sharing === "only_me" ? "runs only jobs you started" : `runs any job in ${workspace ?? "the workspace"}, including teammates' and bots'`;
2142
+ function sharingMeaning(sharing, scope = "your workspaces") {
2143
+ return sharing === "only_me" ? "runs only jobs you started" : `runs any job in ${scope}, including teammates' and bots'`;
1880
2144
  }
1881
- function describeSharing(sharing, workspace) {
1882
- return `${toChoice(sharing)}: ${sharingMeaning(sharing, workspace)}`;
2145
+ function describeSharing(sharing, scope) {
2146
+ return `${toChoice(sharing)}: ${sharingMeaning(sharing, scope)}`;
1883
2147
  }
1884
2148
  const SharingResponse = z.object({ machine: z.object({ sharing: MachineSharing }) });
1885
2149
  async function setSharing(options) {
@@ -1937,12 +2201,7 @@ const WhoamiResponse = z.object({
1937
2201
  paused: z.object({ by: z.string().nullable() }).nullish(),
1938
2202
  sharing: z.enum(["only_me", "anyone"]).optional()
1939
2203
  }),
1940
- workspace: z.object({
1941
- id: z.string().min(1),
1942
- name: z.string(),
1943
- slug: z.string().nullish(),
1944
- memberCount: z.number().int().nonnegative().optional()
1945
- }),
2204
+ ...WorkspaceFields,
1946
2205
  enrolledBy: z.object({
1947
2206
  name: z.string(),
1948
2207
  email: z.string()
@@ -1983,7 +2242,7 @@ const DEFAULT_SERVER = "https://app.relayrunner.app";
1983
2242
  const connectCommand = defineCommand({
1984
2243
  meta: {
1985
2244
  name: "connect",
1986
- description: "Put this machine online for your workspace and run the jobs the gateway sends it. Signs in on first run; Ctrl-C takes the machine offline."
2245
+ 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
2246
  },
1988
2247
  args: {
1989
2248
  server: {
@@ -1996,7 +2255,7 @@ const connectCommand = defineCommand({
1996
2255
  },
1997
2256
  share: {
1998
2257
  type: "string",
1999
- description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in the workspace. Skips the question."
2258
+ description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces. Skips the question."
2000
2259
  }
2001
2260
  },
2002
2261
  async run({ args }) {
@@ -2021,8 +2280,8 @@ async function connectMachine(args) {
2021
2280
  }
2022
2281
  if (!credentials) credentials = await enroll(server, args.name, platform, share);
2023
2282
  else {
2024
- clack.log.info(`Machine ${credentials.machine.name} in ${credentials.workspace.name} (${credentials.server})`);
2025
- if (share) await applySharing(credentials, share);
2283
+ clack.log.info(`Machine ${credentials.machine.name} (${credentials.server})`);
2284
+ if (share) await applySharing(credentials, share, null);
2026
2285
  }
2027
2286
  if (process.stdin.isTTY && process.stdout.isTTY) await offerSetup();
2028
2287
  const runner = await ensureRunner({ log: (line) => clack.log.info(line) });
@@ -2086,13 +2345,13 @@ async function connectMachine(args) {
2086
2345
  case "revoked":
2087
2346
  deleteCredentials();
2088
2347
  if (!online) {
2089
- clack.log.warn("This machine was removed from the workspace 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.");
2348
+ 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
2349
  return connectMachine({
2091
2350
  ...args,
2092
2351
  server: credentials.server
2093
2352
  });
2094
2353
  }
2095
- clack.log.error("This machine was removed from the workspace 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.");
2354
+ 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
2355
  clack.outro("Run `relayrunner connect` again to sign in.");
2097
2356
  process.exitCode = 1;
2098
2357
  break;
@@ -2107,7 +2366,7 @@ async function connectMachine(args) {
2107
2366
  process.exitCode = 1;
2108
2367
  }
2109
2368
  }
2110
- async function askSharing(workspace) {
2369
+ async function askSharing(workspaces) {
2111
2370
  const picked = await clack.select({
2112
2371
  message: "Who can run jobs on this machine?",
2113
2372
  options: [{
@@ -2116,7 +2375,7 @@ async function askSharing(workspace) {
2116
2375
  hint: "jobs you started"
2117
2376
  }, {
2118
2377
  value: "anyone",
2119
- label: `Anyone in ${workspace}`,
2378
+ label: `Anyone in ${sharingScope(workspaces)}`,
2120
2379
  hint: "teammates' and bots' jobs too, from repos you can open"
2121
2380
  }],
2122
2381
  initialValue: "only-me"
@@ -2127,7 +2386,7 @@ async function askSharing(workspace) {
2127
2386
  }
2128
2387
  return picked;
2129
2388
  }
2130
- async function applySharing(credentials, choice) {
2389
+ async function applySharing(credentials, choice, workspaces) {
2131
2390
  const result = await withCurrentToken(credentials, (token) => setSharing({
2132
2391
  server: credentials.server,
2133
2392
  token,
@@ -2135,7 +2394,7 @@ async function applySharing(credentials, choice) {
2135
2394
  }));
2136
2395
  switch (result.status) {
2137
2396
  case "ok":
2138
- clack.log.info(`Sharing: ${describeSharing(result.sharing, credentials.workspace.name)}`);
2397
+ clack.log.info(`Sharing: ${describeSharing(result.sharing, workspaces ? sharingScope(workspaces) : void 0)}`);
2139
2398
  break;
2140
2399
  case "revoked": break;
2141
2400
  case "failed": clack.log.warn(`Couldn't set sharing: ${result.reason}. Run \`relayrunner share ${choice}\` to try again.`);
@@ -2144,7 +2403,7 @@ async function applySharing(credentials, choice) {
2144
2403
  const loginCommand = defineCommand({
2145
2404
  meta: {
2146
2405
  name: "login",
2147
- description: "Sign this machine in to your workspace without putting it online. Run `relayrunner connect` afterwards to take jobs."
2406
+ description: "Sign this machine in without putting it online. It's in all your workspaces. Run `relayrunner connect` afterwards to take jobs."
2148
2407
  },
2149
2408
  args: {
2150
2409
  server: {
@@ -2157,7 +2416,7 @@ const loginCommand = defineCommand({
2157
2416
  },
2158
2417
  share: {
2159
2418
  type: "string",
2160
- description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in the workspace. Skips the question."
2419
+ description: "Who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces. Skips the question."
2161
2420
  }
2162
2421
  },
2163
2422
  async run({ args }) {
@@ -2167,15 +2426,18 @@ const loginCommand = defineCommand({
2167
2426
  const saved = readCredentials();
2168
2427
  const server = serverFor(args.server, saved);
2169
2428
  if (saved && saved.server === server) {
2170
- if ((await withCurrentToken(saved, (token) => whoami({
2429
+ const result = await withCurrentToken(saved, (token) => whoami({
2171
2430
  server,
2172
2431
  token
2173
- }))).status !== "revoked") {
2174
- if (share) await applySharing(saved, share);
2175
- clack.outro(`Already signed in as ${saved.machine.name} in ${saved.workspace.name}. Run \`relayrunner connect\` to go online.`);
2432
+ }));
2433
+ if (result.status !== "revoked") {
2434
+ const workspaces = result.status === "ok" ? readWorkspaces(result.identity) : null;
2435
+ if (share) await applySharing(saved, share, workspaces);
2436
+ const where = workspaces?.length ? ` in ${workspaceNames(workspaces)}` : "";
2437
+ clack.outro(`Already signed in as ${saved.machine.name}${where}. Run \`relayrunner connect\` to go online.`);
2176
2438
  return;
2177
2439
  }
2178
- clack.log.warn(`${saved.machine.name} is no longer enrolled in ${saved.workspace.name}. Signing in again.`);
2440
+ clack.log.warn(`${saved.machine.name} is no longer signed in. Signing in again.`);
2179
2441
  } else if (saved) clack.log.warn(`This machine is enrolled with ${saved.server}, not ${server}. Signing in again.`);
2180
2442
  await enroll(server, args.name, machinePlatform(), share);
2181
2443
  clack.outro("Run `relayrunner connect` to put this machine online.");
@@ -2204,16 +2466,17 @@ function machinePlatform() {
2204
2466
  }
2205
2467
  /** Signs in through the browser, saves the machine token, and settles who can run jobs here. */
2206
2468
  async function enroll(server, name, platform, share) {
2207
- const signedIn = await signIn(server, name || await defaultMachineName(), platform);
2208
- const credentials = signedIn.credentials;
2469
+ const { credentials, workspaces } = await signIn(server, name || await defaultMachineName(), platform);
2209
2470
  writeCredentials(credentials);
2210
- clack.log.success(`Enrolled as ${credentials.machine.name} in ${credentials.workspace.name}. Token saved to ${credentialsPath()}.`);
2471
+ const where = workspaces.length ? ` in ${workspaceNames(workspaces)}` : "";
2472
+ clack.log.success(`Enrolled as ${credentials.machine.name}${where}. Token saved to ${credentialsPath()}.`);
2473
+ if (!workspaces.length) clack.log.warn(noWorkspaceYet(credentials.machine.name, server));
2211
2474
  let choice = share;
2212
- if (!choice && (signedIn.memberCount ?? 0) > 1) {
2213
- if (process.stdin.isTTY && process.stdout.isTTY) choice = await askSharing(credentials.workspace.name);
2475
+ if (!choice && hasTeammates(workspaces)) {
2476
+ if (process.stdin.isTTY && process.stdout.isTTY) choice = await askSharing(workspaces);
2214
2477
  else clack.log.info("Only jobs you started run here. `relayrunner share anyone` lets teammates' jobs run here too.");
2215
2478
  }
2216
- if (choice) await applySharing(credentials, choice);
2479
+ if (choice) await applySharing(credentials, choice, workspaces);
2217
2480
  return credentials;
2218
2481
  }
2219
2482
  async function signIn(server, name, platform) {
@@ -2277,7 +2540,7 @@ function show(event) {
2277
2540
  const whoamiCommand = defineCommand({
2278
2541
  meta: {
2279
2542
  name: "whoami",
2280
- description: "Show which machine and workspace this computer is signed in as, checked with the gateway."
2543
+ description: "Show which machine this computer is signed in as and the workspaces it's in, checked with the gateway."
2281
2544
  },
2282
2545
  args: {
2283
2546
  server: {
@@ -2304,8 +2567,7 @@ const whoamiCommand = defineCommand({
2304
2567
  }
2305
2568
  const saved = {
2306
2569
  server: credentials.server,
2307
- machine: credentials.machine,
2308
- workspace: credentials.workspace
2570
+ machine: credentials.machine
2309
2571
  };
2310
2572
  const result = await withCurrentToken(credentials, (token) => whoami({
2311
2573
  server: credentials.server,
@@ -2320,7 +2582,7 @@ const whoamiCommand = defineCommand({
2320
2582
  });
2321
2583
  break;
2322
2584
  case "revoked":
2323
- print(`${credentials.machine.name} was removed from ${credentials.workspace.name} or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`, {
2585
+ print(`${credentials.machine.name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`, {
2324
2586
  status: "revoked",
2325
2587
  ...saved
2326
2588
  });
@@ -2335,20 +2597,21 @@ const whoamiCommand = defineCommand({
2335
2597
  }
2336
2598
  });
2337
2599
  function describeIdentity(server, identity) {
2338
- const { machine, workspace, enrolledBy } = identity;
2600
+ const { machine, enrolledBy } = identity;
2601
+ const workspaces = readWorkspaces(identity);
2339
2602
  const status = (machine.status.online ? `online${machine.status.state ? `, ${machine.status.state}` : ""}` : "offline") + (machine.paused ? `, paused${machine.paused.by ? ` by ${machine.paused.by}` : ""}` : "");
2340
2603
  const enrolled = [enrolledBy && `by ${enrolledBy.name} <${enrolledBy.email}>`, `on ${new Date(machine.createdAt).toLocaleDateString()}`].filter(Boolean).join(" ");
2341
2604
  return table(`${machine.name} (${machine.id})`, [
2342
- ["Workspace", workspace.slug ? `${workspace.name} (${workspace.slug})` : workspace.name],
2605
+ ["Workspaces", workspaces.length ? workspaceNames(workspaces) : "none yet: install RelayRunner on GitHub to get one"],
2343
2606
  ["Platform", [machine.os, machine.arch].filter(Boolean).join(" ") || "unknown"],
2344
2607
  ["Enrolled", enrolled],
2345
2608
  ["Status", status],
2346
- ...machine.sharing ? [["Sharing", describeSharing(machine.sharing, workspace.name)]] : [],
2609
+ ...machine.sharing ? [["Sharing", describeSharing(machine.sharing, sharingScope(workspaces))]] : [],
2347
2610
  ["Gateway", server]
2348
2611
  ]);
2349
2612
  }
2350
2613
  function describeSaved(saved) {
2351
- return table(`${saved.machine.name} (${saved.machine.id})`, [["Workspace", saved.workspace.name], ["Gateway", saved.server]]);
2614
+ return table(`${saved.machine.name} (${saved.machine.id})`, [["Gateway", saved.server]]);
2352
2615
  }
2353
2616
  function table(title, rows) {
2354
2617
  const width = Math.max(...rows.map(([label]) => label.length));
@@ -2374,7 +2637,7 @@ function pauseCommand(paused) {
2374
2637
  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
2638
  break;
2376
2639
  case "revoked":
2377
- console.error(`${name} was removed from ${credentials.workspace.name} or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
2640
+ console.error(`${name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
2378
2641
  process.exitCode = 1;
2379
2642
  break;
2380
2643
  case "failed":
@@ -2387,7 +2650,7 @@ function pauseCommand(paused) {
2387
2650
  const shareCommand = defineCommand({
2388
2651
  meta: {
2389
2652
  name: "share",
2390
- description: "Show or change who can run jobs on this machine: only-me (jobs you started) or anyone in the workspace."
2653
+ description: "Show or change who can run jobs on this machine: only-me (jobs you started) or anyone in your workspaces."
2391
2654
  },
2392
2655
  args: { who: {
2393
2656
  type: "positional",
@@ -2402,9 +2665,8 @@ const shareCommand = defineCommand({
2402
2665
  return;
2403
2666
  }
2404
2667
  const { name } = credentials.machine;
2405
- const workspace = credentials.workspace.name;
2406
2668
  const revoked = () => {
2407
- console.error(`${name} was removed from ${workspace} or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
2669
+ console.error(`${name} was removed or its token is no longer valid.\nRun \`relayrunner connect\` to sign in again.`);
2408
2670
  process.exitCode = 1;
2409
2671
  };
2410
2672
  if (args.who) {
@@ -2425,7 +2687,7 @@ const shareCommand = defineCommand({
2425
2687
  process.exitCode = 1;
2426
2688
  return;
2427
2689
  }
2428
- console.log(`${name} now ${sharingMeaning(result.sharing, workspace)}.`);
2690
+ console.log(`${name} now ${sharingMeaning(result.sharing)}.`);
2429
2691
  return;
2430
2692
  }
2431
2693
  const result = await withCurrentToken(credentials, (token) => whoami({
@@ -2445,8 +2707,10 @@ const shareCommand = defineCommand({
2445
2707
  return;
2446
2708
  }
2447
2709
  const other = sharing === "only_me" ? "anyone" : "only-me";
2448
- const lines = [`${name} ${sharingMeaning(sharing, workspace)} (${toChoice(sharing)}).`];
2449
- if (result.identity.workspace.memberCount === 1) lines.push(`Nobody else is in ${workspace} yet, so this matters once a teammate joins.`);
2710
+ const workspaces = readWorkspaces(result.identity);
2711
+ const lines = [`${name} ${sharingMeaning(sharing, sharingScope(workspaces))} (${toChoice(sharing)}).`];
2712
+ if (!workspaces.length) lines.push(`${name} isn't in a workspace yet, so this matters once it is.`);
2713
+ 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
2714
  lines.push(`Change it with \`relayrunner share ${other}\`.`);
2451
2715
  console.log(lines.join("\n"));
2452
2716
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relayrunner",
3
- "version": "0.5.0",
3
+ "version": "0.6.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"