relayrunner 0.9.2 → 0.10.1

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 +2 -1
  2. package/dist/cli.js +409 -15
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -11,7 +11,8 @@ npm install --global relayrunner # or use npx relayrunner
11
11
 
12
12
  Machines only take jobs from private repositories. To opt jobs in, see the
13
13
  [root README](../../README.md#how-it-works) or
14
- [docs/agent-install.md](../../docs/agent-install.md).
14
+ [docs/agent-install.md](../../docs/agent-install.md). To teach your coding
15
+ agent the CLI, see the [agent skills](../../skills).
15
16
 
16
17
  ## `relayrunner connect`
17
18
 
package/dist/cli.js CHANGED
@@ -66,6 +66,15 @@ const StatusMessage = z.object({
66
66
  state: z.enum(["idle", "busy"]),
67
67
  running: z.number().int().nonnegative().max(1e3).optional()
68
68
  });
69
+ const JobUsage = z.object({
70
+ cpuP95: z.number().min(0).max(1),
71
+ cpuPeak: z.number().min(0).max(1),
72
+ memoryP95Mb: z.number().int().nonnegative(),
73
+ memoryPeakMb: z.number().int().nonnegative(),
74
+ cpus: z.number().int().positive().max(1e5),
75
+ memoryMb: z.number().int().positive().max(1e9),
76
+ samples: z.number().int().positive()
77
+ });
69
78
  const JobMessage = z.object({
70
79
  v: version$1,
71
80
  type: z.literal("job"),
@@ -75,7 +84,8 @@ const JobMessage = z.object({
75
84
  "finished",
76
85
  "failed"
77
86
  ]),
78
- message: z.string().optional()
87
+ message: z.string().optional(),
88
+ usage: JobUsage.optional().catch(void 0)
79
89
  });
80
90
  const TokenSavedMessage = z.object({
81
91
  v: version$1,
@@ -174,7 +184,7 @@ function parse(version) {
174
184
  ] : null;
175
185
  }
176
186
  // version.ts
177
- const cliVersion = "0.9.2";
187
+ const cliVersion = "0.10.1";
178
188
  // paths.ts
179
189
  function relayrunnerHome() {
180
190
  return resolve(process.env.RELAYRUNNER_HOME || join(homedir(), ".relayrunner"));
@@ -1017,6 +1027,121 @@ function duplicateKey(value) {
1017
1027
  function decodeJson(base64) {
1018
1028
  return JSON.parse(Buffer.from(base64, "base64").toString("utf8").replace(/^/, ""));
1019
1029
  }
1030
+ // usage.ts
1031
+ const SAMPLE_MS = 5e3;
1032
+ const MB = 1048576;
1033
+ /**
1034
+ * Reads `source` every few seconds until stop(), which resolves with the job's usage, or
1035
+ * undefined when nothing was read (a job too short to sample, or a source that never answered).
1036
+ * Calling stop() again resolves with the same answer.
1037
+ */
1038
+ function sampleUsage(source, intervalMs = SAMPLE_MS) {
1039
+ const readings = [];
1040
+ let pending = Promise.resolve();
1041
+ let stopped;
1042
+ const timer = setInterval(() => {
1043
+ pending = pending.then(() => source.read().then((reading) => void (reading && readings.push(reading)), () => void 0));
1044
+ }, intervalMs);
1045
+ return { stop() {
1046
+ clearInterval(timer);
1047
+ return stopped ??= pending.then(() => summarize(readings, source));
1048
+ } };
1049
+ }
1050
+ function summarize(readings, capacity) {
1051
+ if (readings.length === 0) return void 0;
1052
+ const cpu = readings.map((reading) => Math.min(Math.max(reading.cpu, 0), 1));
1053
+ const memory = readings.map((reading) => Math.round(reading.memoryBytes / MB));
1054
+ return {
1055
+ cpuP95: round(p95(cpu)),
1056
+ cpuPeak: round(Math.max(...cpu)),
1057
+ memoryP95Mb: p95(memory),
1058
+ memoryPeakMb: Math.max(...memory),
1059
+ cpus: capacity.cpus,
1060
+ memoryMb: capacity.memoryMb,
1061
+ samples: readings.length
1062
+ };
1063
+ }
1064
+ function p95(values) {
1065
+ const sorted = [...values].sort((a, b) => a - b);
1066
+ return sorted[Math.ceil(sorted.length * .95) - 1];
1067
+ }
1068
+ const round = (share) => Math.round(share * 1e3) / 1e3;
1069
+ /**
1070
+ * A job in the VM `name`, read with `container stats`, which reports the cores the VM is busy
1071
+ * on right now (it samples for about two seconds per call).
1072
+ */
1073
+ function vmUsage(name, size, command = "container") {
1074
+ return {
1075
+ cpus: size.cpus,
1076
+ memoryMb: size.memoryGb * 1024,
1077
+ async read() {
1078
+ const output = await run(command, [
1079
+ "stats",
1080
+ "--format",
1081
+ "json",
1082
+ "--no-stream",
1083
+ name
1084
+ ]);
1085
+ if (!output) return null;
1086
+ const [stats] = JSON.parse(output);
1087
+ if (typeof stats?.cpuUtilization !== "number" || typeof stats.memoryUsageBytes !== "number") return null;
1088
+ return {
1089
+ cpu: stats.cpuUtilization / size.cpus,
1090
+ memoryBytes: stats.memoryUsageBytes
1091
+ };
1092
+ }
1093
+ };
1094
+ }
1095
+ /**
1096
+ * A job running on this machine, read from `ps` as the runner process `pid` and everything under
1097
+ * it. Rougher than a VM's reading: a process the job hands work to outside its tree (Docker
1098
+ * Desktop, a simulator) isn't counted, and `ps` reports each process's recent CPU, not exact use.
1099
+ */
1100
+ function processTreeUsage(pid) {
1101
+ const cores = cpus().length;
1102
+ return {
1103
+ cpus: cores,
1104
+ memoryMb: Math.round(totalmem() / MB),
1105
+ async read() {
1106
+ const output = await run("ps", [
1107
+ "-A",
1108
+ "-o",
1109
+ "pid=,ppid=,%cpu=,rss="
1110
+ ]);
1111
+ return output ? treeReading(output, pid, cores) : null;
1112
+ }
1113
+ };
1114
+ }
1115
+ /** Sums `ps -o pid=,ppid=,%cpu=,rss=` output over `root` and its descendants. */
1116
+ function treeReading(output, root, cores) {
1117
+ const children = /* @__PURE__ */ new Map();
1118
+ const usage = /* @__PURE__ */ new Map();
1119
+ for (const line of output.split("\n")) {
1120
+ const [pid, ppid, cpu, rss] = line.trim().split(/\s+/).map(Number);
1121
+ if (!Number.isFinite(pid) || !Number.isFinite(ppid)) continue;
1122
+ usage.set(pid, {
1123
+ cpu: cpu || 0,
1124
+ rssKb: rss || 0
1125
+ });
1126
+ const siblings = children.get(ppid);
1127
+ if (siblings) siblings.push(pid);
1128
+ else children.set(ppid, [pid]);
1129
+ }
1130
+ if (!usage.has(root)) return null;
1131
+ let percent = 0;
1132
+ let rssKb = 0;
1133
+ const stack = [root];
1134
+ for (let pid = stack.pop(); pid !== void 0; pid = stack.pop()) {
1135
+ const own = usage.get(pid);
1136
+ percent += own.cpu;
1137
+ rssKb += own.rssKb;
1138
+ stack.push(...children.get(pid) ?? []);
1139
+ }
1140
+ return {
1141
+ cpu: percent / 100 / cores,
1142
+ memoryBytes: rssKb * 1024
1143
+ };
1144
+ }
1020
1145
  // job.ts
1021
1146
  const runnerEnv = () => Object.fromEntries([
1022
1147
  "HOME",
@@ -1036,15 +1161,17 @@ async function runJob(run, options) {
1036
1161
  report(update);
1037
1162
  return update;
1038
1163
  };
1039
- const failed = (message) => finish({
1164
+ const failed = (message, usage) => finish({
1040
1165
  routeId,
1041
1166
  state: "failed",
1042
- message
1167
+ message,
1168
+ usage
1043
1169
  });
1044
1170
  const checked = checkJitConfig(run.jitConfig, routeId);
1045
1171
  if (!checked.ok) return failed(`Refused the job's runner config: ${checked.reason}.`);
1046
1172
  options.onChecked?.(checked.target);
1047
1173
  let clean = false;
1174
+ let sampler;
1048
1175
  try {
1049
1176
  const child = launcher.start(run);
1050
1177
  child.stdout.on("data", (chunk) => output(chunk, "stdout"));
@@ -1058,16 +1185,20 @@ async function runJob(run, options) {
1058
1185
  routeId,
1059
1186
  state: "started"
1060
1187
  });
1188
+ if (launcher.usage) sampler = sampleUsage(launcher.usage(run, child));
1061
1189
  const [code, signal] = await new Promise((resolve) => child.once("close", (code, signal) => resolve([code, signal])));
1190
+ const usage = await sampler?.stop();
1062
1191
  clean = code === 0;
1063
1192
  if (clean) return finish({
1064
1193
  routeId,
1065
- state: "finished"
1194
+ state: "finished",
1195
+ usage
1066
1196
  });
1067
- return failed(signal ? `The runner was stopped by ${signal}` : `The runner exited with ${code}`);
1197
+ return failed(signal ? `The runner was stopped by ${signal}` : `The runner exited with ${code}`, usage);
1068
1198
  } catch (error) {
1069
1199
  return failed(error instanceof Error ? error.message : String(error));
1070
1200
  } finally {
1201
+ sampler?.stop();
1071
1202
  await launcher.cleanup(run, clean);
1072
1203
  }
1073
1204
  }
@@ -1095,6 +1226,7 @@ function hostLauncher(dir) {
1095
1226
  ]
1096
1227
  });
1097
1228
  },
1229
+ usage: (_run, child) => processTreeUsage(child.pid),
1098
1230
  cleanup() {
1099
1231
  if (!locked) return;
1100
1232
  clean(dir);
@@ -1472,6 +1604,7 @@ function isolatedLauncher(isolation) {
1472
1604
  child.once("close", (code, signal) => debug.write(`${name}: exit ${signal ?? code}`));
1473
1605
  return child;
1474
1606
  },
1607
+ usage: (run) => vmUsage(containerName(run.routeId), isolation, command),
1475
1608
  async cleanup(run, clean) {
1476
1609
  if (clean) return;
1477
1610
  const args = [
@@ -2471,6 +2604,261 @@ function sharingScope(workspaces) {
2471
2604
  function noWorkspaceYet(machine, server) {
2472
2605
  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");
2473
2606
  }
2607
+ // ../../packages/errors/src/codes.ts
2608
+ /**
2609
+ * Every error code the API can return. A code never changes once it ships; its message can.
2610
+ * Feature-specific codes read `DOMAIN_FAILURE`, so the code alone names the feature and what
2611
+ * went wrong. Add a code here before returning it: apps/site builds the errors page and the
2612
+ * OpenAPI enum from this list.
2613
+ */
2614
+ const ERRORS = {
2615
+ INVALID_REQUEST: {
2616
+ status: 400,
2617
+ message: "The request isn't valid."
2618
+ },
2619
+ PAYLOAD_TOO_LARGE: {
2620
+ status: 413,
2621
+ message: "The request body is too large."
2622
+ },
2623
+ NOT_FOUND: {
2624
+ status: 404,
2625
+ message: "Not found."
2626
+ },
2627
+ METHOD_NOT_ALLOWED: {
2628
+ status: 405,
2629
+ message: "That method isn't allowed here."
2630
+ },
2631
+ RATE_LIMITED: {
2632
+ status: 429,
2633
+ message: "Too many requests. Try again shortly."
2634
+ },
2635
+ INTERNAL_ERROR: {
2636
+ status: 500,
2637
+ message: "Something went wrong on our side."
2638
+ },
2639
+ UNAUTHENTICATED: {
2640
+ status: 401,
2641
+ message: "Sign in first."
2642
+ },
2643
+ INVALID_TOKEN: {
2644
+ status: 401,
2645
+ message: "The token is invalid, expired or revoked."
2646
+ },
2647
+ FORBIDDEN: {
2648
+ status: 403,
2649
+ message: "You don't have access to that."
2650
+ },
2651
+ AGENT_NOT_ALLOWED: {
2652
+ status: 403,
2653
+ message: "Agent tokens can't call this route."
2654
+ },
2655
+ NOT_A_MEMBER: {
2656
+ status: 403,
2657
+ message: "You aren't a member of that workspace."
2658
+ },
2659
+ LEGAL_TERMS_OUTDATED: {
2660
+ status: 409,
2661
+ message: "The terms changed since you opened this page. Reload it to read the new version."
2662
+ },
2663
+ NO_ACTIVE_WORKSPACE: {
2664
+ status: 409,
2665
+ message: "Pick a workspace first."
2666
+ },
2667
+ WORKSPACE_REQUIRED: {
2668
+ status: 409,
2669
+ message: "This token reads more than one workspace. Name one with the x-relayrunner-workspace header."
2670
+ },
2671
+ CANNOT_DEMOTE_SELF: {
2672
+ status: 400,
2673
+ message: "You can't remove your own operator role."
2674
+ },
2675
+ CANNOT_DELETE_SELF: {
2676
+ status: 400,
2677
+ message: "You can't delete your own account here."
2678
+ },
2679
+ USER_HAS_SHARED_WORKSPACES: {
2680
+ status: 409,
2681
+ message: "The user is in workspaces with other members. Remove them from those first."
2682
+ },
2683
+ MACHINE_NOT_OWNED: {
2684
+ status: 403,
2685
+ message: "Only a machine with an owner can do this."
2686
+ },
2687
+ DEVICE_CODE_INVALID: {
2688
+ status: 400,
2689
+ message: "That code doesn't match a sign-in request. Check it against your terminal."
2690
+ },
2691
+ DEVICE_CODE_EXPIRED: {
2692
+ status: 400,
2693
+ message: "That code has expired. Run `relayrunner connect` again for a new one."
2694
+ },
2695
+ DEVICE_CODE_USED: {
2696
+ status: 409,
2697
+ message: "That code has already been used."
2698
+ },
2699
+ DEVICE_CODE_CLAIMED: {
2700
+ status: 403,
2701
+ message: "Another account already approved or denied this request. Run `relayrunner connect` again for a new code."
2702
+ },
2703
+ WEBSOCKET_REQUIRED: {
2704
+ status: 426,
2705
+ message: "Connect with a WebSocket upgrade."
2706
+ },
2707
+ RUNNER_ORDER_INVALID: {
2708
+ status: 400,
2709
+ message: "The runner order isn't valid."
2710
+ },
2711
+ PROVIDER_UNKNOWN: {
2712
+ status: 400,
2713
+ message: "There's no provider with that id."
2714
+ },
2715
+ PROVIDER_INVALID: {
2716
+ status: 400,
2717
+ message: "Fill in a name, summary and labels, and use https:// links."
2718
+ },
2719
+ PROVIDER_ID_INVALID: {
2720
+ status: 400,
2721
+ message: "Use lowercase letters, numbers and dashes for the id."
2722
+ },
2723
+ PROVIDER_PREFIXES_INVALID: {
2724
+ status: 400,
2725
+ message: "Add at least one label prefix, three or more characters each."
2726
+ },
2727
+ PROVIDER_EXISTS: {
2728
+ status: 409,
2729
+ message: "There's already a provider with that id."
2730
+ },
2731
+ PROVIDER_PREFIX_TAKEN: {
2732
+ status: 409,
2733
+ message: "Another provider, or GitHub's own runners, already use labels like that."
2734
+ },
2735
+ PROVIDER_NOT_CONNECTED: {
2736
+ status: 404,
2737
+ message: "That provider isn't connected."
2738
+ },
2739
+ PROVIDER_TOKEN_REJECTED: {
2740
+ status: 400,
2741
+ message: "The provider didn't accept that token. Check it and its scope."
2742
+ },
2743
+ PROVIDER_UNREACHABLE: {
2744
+ status: 502,
2745
+ message: "The provider's API didn't answer. Try again shortly."
2746
+ },
2747
+ PRICE_INVALID: {
2748
+ status: 400,
2749
+ message: "Check the price and date."
2750
+ },
2751
+ PRICE_EXISTS: {
2752
+ status: 409,
2753
+ message: "That rate already has a price from that day. Remove it first to correct it."
2754
+ },
2755
+ TOKEN_STORAGE_UNAVAILABLE: {
2756
+ status: 503,
2757
+ message: "Saving provider tokens isn't set up on this server yet."
2758
+ },
2759
+ TELEMETRY_ENDPOINT_INVALID: {
2760
+ status: 400,
2761
+ message: "Use an https URL on the internet, like https://api.honeycomb.io."
2762
+ },
2763
+ TELEMETRY_HEADER_MISSING: {
2764
+ status: 400,
2765
+ message: "Enter a value for each header."
2766
+ },
2767
+ TELEMETRY_NOT_CONFIGURED: {
2768
+ status: 404,
2769
+ message: "Telemetry isn't set up for this workspace."
2770
+ },
2771
+ WEBHOOK_SIGNATURE_INVALID: {
2772
+ status: 401,
2773
+ message: "The webhook signature is missing or doesn't match the App's secret."
2774
+ },
2775
+ WEBHOOK_SECRET_NOT_CONFIGURED: {
2776
+ status: 500,
2777
+ message: "The webhook secret for this App isn't set up on this server."
2778
+ },
2779
+ WEBHOOK_ENQUEUE_FAILED: {
2780
+ status: 503,
2781
+ message: "The delivery couldn't be queued. Redeliver it from the App's settings."
2782
+ },
2783
+ GITHUB_UNAVAILABLE: {
2784
+ status: 502,
2785
+ message: "GitHub didn't answer. Try again shortly."
2786
+ },
2787
+ GITHUB_RATE_LIMITED: {
2788
+ status: 503,
2789
+ message: "GitHub's API limit was reached. Try again shortly."
2790
+ },
2791
+ GITHUB_APP_NOT_CONFIGURED: {
2792
+ status: 500,
2793
+ message: "The GitHub App isn't set up."
2794
+ }
2795
+ };
2796
+ function isErrorCode(code) {
2797
+ return typeof code === "string" && Object.hasOwn(ERRORS, code);
2798
+ }
2799
+ // ../../packages/errors/src/app-error.ts
2800
+ /**
2801
+ * A failure with a stable code. Throw it from an API route and the API's error handler answers
2802
+ * with the code's status and an {@link ErrorBody}; clients get one back from {@link parseError}.
2803
+ */
2804
+ var AppError = class extends Error {
2805
+ /** A string rather than ErrorCode: a client can receive codes added after it was built. */
2806
+ code;
2807
+ status;
2808
+ details;
2809
+ retryAfter;
2810
+ constructor(code, options = {}) {
2811
+ super(options.message ?? ERRORS[code].message, { cause: options.cause });
2812
+ this.name = "AppError";
2813
+ this.code = code;
2814
+ this.status = ERRORS[code].status;
2815
+ this.details = options.details;
2816
+ this.retryAfter = options.retryAfter;
2817
+ }
2818
+ toJSON() {
2819
+ return { error: {
2820
+ code: this.code,
2821
+ message: this.message,
2822
+ ...this.details === void 0 ? {} : { details: this.details }
2823
+ } };
2824
+ }
2825
+ };
2826
+ /** Whether a response body is an {@link ErrorBody}. */
2827
+ function isErrorBody(body) {
2828
+ const error = body?.error;
2829
+ return typeof error === "object" && error !== null && typeof error.code === "string" && typeof error.message === "string";
2830
+ }
2831
+ /**
2832
+ * Reads a non-2xx response body as an AppError. Never throws: a body that isn't an
2833
+ * {@link ErrorBody} (a proxy's HTML page, an empty body) keeps the status with a generic message.
2834
+ */
2835
+ function parseError(body, status) {
2836
+ const { code, message, details } = isErrorBody(body) ? body.error : {
2837
+ code: "INTERNAL_ERROR",
2838
+ message: `The request failed with status ${status}.`,
2839
+ details: void 0
2840
+ };
2841
+ const parsed = new AppError(isErrorCode(code) ? code : "INTERNAL_ERROR", {
2842
+ message,
2843
+ details
2844
+ });
2845
+ return Object.assign(parsed, {
2846
+ status,
2847
+ code
2848
+ });
2849
+ }
2850
+ /** An error in one line for an agent or a terminal: "Not found (NOT_FOUND)". */
2851
+ function describeError(error) {
2852
+ return `${error.message.replace(/\.$/, "")} (${error.code})`;
2853
+ }
2854
+ // api-error.ts
2855
+ /**
2856
+ * Why a request to the gateway failed, for "Couldn't …: <reason>.": the API's message and error
2857
+ * code when it sent one (@relayrunner/errors), else the HTTP status.
2858
+ */
2859
+ function failureReason(server, status, body) {
2860
+ return isErrorBody(body) ? describeError(parseError(body, status)) : `${server} answered HTTP ${status}`;
2861
+ }
2474
2862
  // login.ts
2475
2863
  const CLIENT_ID = "relayrunner-cli";
2476
2864
  const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
@@ -2568,7 +2956,10 @@ async function login(options) {
2568
2956
  deviceCode: code.device_code,
2569
2957
  ...options.platform
2570
2958
  }, { authorization: `Bearer ${accessToken}` });
2571
- if (!claimResponse.ok) throw new LoginError("CLAIM_FAILED", `The gateway approved the sign-in but wouldn't enroll this machine (HTTP ${claimResponse.status}).`);
2959
+ if (!claimResponse.ok) {
2960
+ const body = await claimResponse.json().catch(() => null);
2961
+ throw new LoginError("CLAIM_FAILED", `The gateway approved the sign-in but wouldn't enroll this machine: ${failureReason(options.server, claimResponse.status, body)}.`);
2962
+ }
2572
2963
  const claimed = ClaimResponse.parse(await claimResponse.json());
2573
2964
  return {
2574
2965
  credentials: {
@@ -2624,11 +3015,12 @@ async function setPaused(options) {
2624
3015
  };
2625
3016
  }
2626
3017
  if (response.status === 401) return { status: "revoked" };
3018
+ const body = await response.json().catch(() => null);
2627
3019
  if (!response.ok) return {
2628
3020
  status: "failed",
2629
- reason: `${options.server} answered HTTP ${response.status}`
3021
+ reason: failureReason(options.server, response.status, body)
2630
3022
  };
2631
- const parsed = PauseResponse.safeParse(await response.json().catch(() => null));
3023
+ const parsed = PauseResponse.safeParse(body);
2632
3024
  if (!parsed.success) return {
2633
3025
  status: "failed",
2634
3026
  reason: `${options.server} sent an unexpected response`
@@ -2743,11 +3135,12 @@ async function setSharing(options) {
2743
3135
  status: "failed",
2744
3136
  reason: `${options.server} doesn't support sharing yet`
2745
3137
  };
3138
+ const body = await response.json().catch(() => null);
2746
3139
  if (!response.ok) return {
2747
3140
  status: "failed",
2748
- reason: `${options.server} answered HTTP ${response.status}`
3141
+ reason: failureReason(options.server, response.status, body)
2749
3142
  };
2750
- const parsed = SharingResponse.safeParse(await response.json().catch(() => null));
3143
+ const parsed = SharingResponse.safeParse(body);
2751
3144
  if (!parsed.success) return {
2752
3145
  status: "failed",
2753
3146
  reason: `${options.server} sent an unexpected response`
@@ -2913,11 +3306,12 @@ async function whoami(options) {
2913
3306
  };
2914
3307
  }
2915
3308
  if (response.status === 401) return { status: "revoked" };
3309
+ const body = await response.json().catch(() => null);
2916
3310
  if (!response.ok) return {
2917
3311
  status: "unverified",
2918
- reason: `${options.server} answered HTTP ${response.status}`
3312
+ reason: failureReason(options.server, response.status, body)
2919
3313
  };
2920
- const parsed = WhoamiResponse.safeParse(await response.json().catch(() => null));
3314
+ const parsed = WhoamiResponse.safeParse(body);
2921
3315
  if (!parsed.success) return {
2922
3316
  status: "unverified",
2923
3317
  reason: `${options.server} sent an unexpected response`
@@ -2965,7 +3359,7 @@ async function machineWorkspaces(options) {
2965
3359
  }
2966
3360
  if (response.status === 401) return { status: "revoked" };
2967
3361
  const body = await response.json().catch(() => null);
2968
- if (change && response.status === 404 && body?.error === "not_found") return { status: "not_found" };
3362
+ if (change && response.status === 404 && isErrorBody(body) && body.error.code === "NOT_FOUND") return { status: "not_found" };
2969
3363
  if (response.status === 404 || response.status === 405) return {
2970
3364
  status: "failed",
2971
3365
  reason: `${options.server} doesn't support choosing workspaces yet`
@@ -2976,7 +3370,7 @@ async function machineWorkspaces(options) {
2976
3370
  };
2977
3371
  if (!response.ok) return {
2978
3372
  status: "failed",
2979
- reason: `${options.server} answered HTTP ${response.status}`
3373
+ reason: failureReason(options.server, response.status, body)
2980
3374
  };
2981
3375
  const parsed = MachineWorkspaces.safeParse(body);
2982
3376
  if (!parsed.success) return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relayrunner",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "description": "Run GitHub Actions jobs on your machine through the RelayRunner gateway.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -25,6 +25,7 @@
25
25
  "zod": "^4.6.7"
26
26
  },
27
27
  "devDependencies": {
28
+ "@relayrunner/errors": "0.0.0",
28
29
  "@relayrunner/machine-protocol": "0.0.0",
29
30
  "@relayrunner/providers": "0.0.0",
30
31
  "@types/ws": "^8.18.2",