@h-rig/server 0.0.6-alpha.5 → 0.0.6-alpha.6

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/dist/src/index.js CHANGED
@@ -2819,7 +2819,6 @@ function createGitHubTaskReconciler(input) {
2819
2819
  }
2820
2820
 
2821
2821
  // packages/server/src/server-helpers/issue-analysis.ts
2822
- import { execFile } from "child_process";
2823
2822
  import { createHash } from "crypto";
2824
2823
  function stableIssueHash(issue) {
2825
2824
  const labels = Array.isArray(issue.labels) ? [...issue.labels].map(String).sort() : [];
@@ -2953,16 +2952,33 @@ function parseIssueAnalysisResult(raw) {
2953
2952
  return result;
2954
2953
  }
2955
2954
  function createDefaultPiIssueAnalysisCommandRunner() {
2956
- return (command, args, options) => new Promise((resolve11) => {
2957
- execFile(command, [...args], {
2958
- timeout: options.timeoutMs,
2959
- maxBuffer: 10 * 1024 * 1024,
2960
- env: options.env ? { ...process.env, ...options.env } : process.env
2961
- }, (error, stdout, stderr) => {
2962
- const exitCode = typeof error?.code === "number" ? error.code : error ? 1 : 0;
2963
- resolve11({ exitCode, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
2955
+ return async (command, args, options) => {
2956
+ const env = options.env ? { ...process.env, ...options.env } : process.env;
2957
+ const proc = Bun.spawn([command, ...args], {
2958
+ stdout: "pipe",
2959
+ stderr: "pipe",
2960
+ env
2964
2961
  });
2965
- });
2962
+ let timedOut = false;
2963
+ const timer = setTimeout(() => {
2964
+ timedOut = true;
2965
+ proc.kill();
2966
+ }, options.timeoutMs);
2967
+ try {
2968
+ const [stdout, stderr, exitCode] = await Promise.all([
2969
+ new Response(proc.stdout).text(),
2970
+ new Response(proc.stderr).text(),
2971
+ proc.exited
2972
+ ]);
2973
+ return {
2974
+ exitCode: timedOut && exitCode === 0 ? 1 : exitCode,
2975
+ stdout,
2976
+ stderr: timedOut && stderr.trim().length === 0 ? `Pi issue analysis timed out after ${options.timeoutMs}ms` : stderr
2977
+ };
2978
+ } finally {
2979
+ clearTimeout(timer);
2980
+ }
2981
+ };
2966
2982
  }
2967
2983
  function createPiIssueAnalyzer(input = {}) {
2968
2984
  const piBinary = input.piBinary ?? process.env.RIG_ISSUE_ANALYSIS_PI_BINARY ?? "pi";
@@ -5844,7 +5860,46 @@ function isLoopbackRequest(req) {
5844
5860
  }
5845
5861
  }
5846
5862
  function isPublicRigAuthBootstrapRoute(pathname) {
5847
- return pathname === "/" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
5863
+ return pathname === "/" || pathname === "/install" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
5864
+ }
5865
+ function buildRigInstallScript() {
5866
+ return `#!/usr/bin/env bash
5867
+ set -euo pipefail
5868
+
5869
+ say() {
5870
+ printf 'rig-install: %s
5871
+ ' "$*"
5872
+ }
5873
+
5874
+ if ! command -v bun >/dev/null 2>&1; then
5875
+ say "Bun not found; installing Bun first"
5876
+ curl -fsSL https://bun.sh/install | bash
5877
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
5878
+ export PATH="$BUN_INSTALL/bin:$PATH"
5879
+ fi
5880
+
5881
+ if ! command -v bun >/dev/null 2>&1; then
5882
+ printf 'rig-install: bun install completed, but bun is still not on PATH. Add ~/.bun/bin to PATH and retry.
5883
+ ' >&2
5884
+ exit 1
5885
+ fi
5886
+
5887
+ say "Installing @h-rig/cli@latest"
5888
+ bun add -g @h-rig/cli@latest
5889
+
5890
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
5891
+ export PATH="$BUN_INSTALL/bin:$PATH"
5892
+
5893
+ if ! command -v rig >/dev/null 2>&1; then
5894
+ printf 'rig-install: rig installed, but rig is not on PATH. Add %s/bin to PATH and retry.
5895
+ ' "$BUN_INSTALL" >&2
5896
+ exit 1
5897
+ fi
5898
+
5899
+ say "Verifying rig"
5900
+ rig --help >/dev/null
5901
+ say "Done. Run: rig --help"
5902
+ `;
5848
5903
  }
5849
5904
  function normalizePrMode(value) {
5850
5905
  const mode = normalizeString(value);
@@ -6248,6 +6303,13 @@ function createRigServerFetch(state, deps) {
6248
6303
  notifications: state.targets.length
6249
6304
  });
6250
6305
  }
6306
+ if (url.pathname === "/install" && req.method === "GET") {
6307
+ return new Response(buildRigInstallScript(), {
6308
+ headers: {
6309
+ "Content-Type": "text/x-shellscript; charset=utf-8"
6310
+ }
6311
+ });
6312
+ }
6251
6313
  const isLinearWebhook = url.pathname === "/api/linear/webhook" && req.method === "POST";
6252
6314
  const isInspectorStream = url.pathname === "/api/inspector/stream" && req.method === "GET";
6253
6315
  const legacyAuthorizedHttpRequest = Boolean(state.authToken) && (isInspectorStream && isAuthorizedInspectorStreamRequest(req, state.authToken) ? true : deps.isAuthorizedHttpRequest(req, state.authToken));
@@ -470,7 +470,6 @@ async function refreshTaskProjection(projectRoot, input) {
470
470
  }
471
471
 
472
472
  // packages/server/src/server-helpers/issue-analysis.ts
473
- import { execFile } from "child_process";
474
473
  import { createHash } from "crypto";
475
474
  function stableIssueHash(issue) {
476
475
  const labels = Array.isArray(issue.labels) ? [...issue.labels].map(String).sort() : [];
@@ -604,16 +603,33 @@ function parseIssueAnalysisResult(raw) {
604
603
  return result;
605
604
  }
606
605
  function createDefaultPiIssueAnalysisCommandRunner() {
607
- return (command, args, options) => new Promise((resolve6) => {
608
- execFile(command, [...args], {
609
- timeout: options.timeoutMs,
610
- maxBuffer: 10 * 1024 * 1024,
611
- env: options.env ? { ...process.env, ...options.env } : process.env
612
- }, (error, stdout, stderr) => {
613
- const exitCode = typeof error?.code === "number" ? error.code : error ? 1 : 0;
614
- resolve6({ exitCode, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
606
+ return async (command, args, options) => {
607
+ const env = options.env ? { ...process.env, ...options.env } : process.env;
608
+ const proc = Bun.spawn([command, ...args], {
609
+ stdout: "pipe",
610
+ stderr: "pipe",
611
+ env
615
612
  });
616
- });
613
+ let timedOut = false;
614
+ const timer = setTimeout(() => {
615
+ timedOut = true;
616
+ proc.kill();
617
+ }, options.timeoutMs);
618
+ try {
619
+ const [stdout, stderr, exitCode] = await Promise.all([
620
+ new Response(proc.stdout).text(),
621
+ new Response(proc.stderr).text(),
622
+ proc.exited
623
+ ]);
624
+ return {
625
+ exitCode: timedOut && exitCode === 0 ? 1 : exitCode,
626
+ stdout,
627
+ stderr: timedOut && stderr.trim().length === 0 ? `Pi issue analysis timed out after ${options.timeoutMs}ms` : stderr
628
+ };
629
+ } finally {
630
+ clearTimeout(timer);
631
+ }
632
+ };
617
633
  }
618
634
  function createPiIssueAnalyzer(input = {}) {
619
635
  const piBinary = input.piBinary ?? process.env.RIG_ISSUE_ANALYSIS_PI_BINARY ?? "pi";
@@ -2127,7 +2143,46 @@ function isLoopbackRequest(req) {
2127
2143
  }
2128
2144
  }
2129
2145
  function isPublicRigAuthBootstrapRoute(pathname) {
2130
- return pathname === "/" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
2146
+ return pathname === "/" || pathname === "/install" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
2147
+ }
2148
+ function buildRigInstallScript() {
2149
+ return `#!/usr/bin/env bash
2150
+ set -euo pipefail
2151
+
2152
+ say() {
2153
+ printf 'rig-install: %s
2154
+ ' "$*"
2155
+ }
2156
+
2157
+ if ! command -v bun >/dev/null 2>&1; then
2158
+ say "Bun not found; installing Bun first"
2159
+ curl -fsSL https://bun.sh/install | bash
2160
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
2161
+ export PATH="$BUN_INSTALL/bin:$PATH"
2162
+ fi
2163
+
2164
+ if ! command -v bun >/dev/null 2>&1; then
2165
+ printf 'rig-install: bun install completed, but bun is still not on PATH. Add ~/.bun/bin to PATH and retry.
2166
+ ' >&2
2167
+ exit 1
2168
+ fi
2169
+
2170
+ say "Installing @h-rig/cli@latest"
2171
+ bun add -g @h-rig/cli@latest
2172
+
2173
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
2174
+ export PATH="$BUN_INSTALL/bin:$PATH"
2175
+
2176
+ if ! command -v rig >/dev/null 2>&1; then
2177
+ printf 'rig-install: rig installed, but rig is not on PATH. Add %s/bin to PATH and retry.
2178
+ ' "$BUN_INSTALL" >&2
2179
+ exit 1
2180
+ fi
2181
+
2182
+ say "Verifying rig"
2183
+ rig --help >/dev/null
2184
+ say "Done. Run: rig --help"
2185
+ `;
2131
2186
  }
2132
2187
  function normalizePrMode(value) {
2133
2188
  const mode = normalizeString(value);
@@ -2531,6 +2586,13 @@ function createRigServerFetch(state, deps) {
2531
2586
  notifications: state.targets.length
2532
2587
  });
2533
2588
  }
2589
+ if (url.pathname === "/install" && req.method === "GET") {
2590
+ return new Response(buildRigInstallScript(), {
2591
+ headers: {
2592
+ "Content-Type": "text/x-shellscript; charset=utf-8"
2593
+ }
2594
+ });
2595
+ }
2534
2596
  const isLinearWebhook = url.pathname === "/api/linear/webhook" && req.method === "POST";
2535
2597
  const isInspectorStream = url.pathname === "/api/inspector/stream" && req.method === "GET";
2536
2598
  const legacyAuthorizedHttpRequest = Boolean(state.authToken) && (isInspectorStream && isAuthorizedInspectorStreamRequest(req, state.authToken) ? true : deps.isAuthorizedHttpRequest(req, state.authToken));
@@ -1,6 +1,5 @@
1
1
  // @bun
2
2
  // packages/server/src/server-helpers/issue-analysis.ts
3
- import { execFile } from "child_process";
4
3
  import { createHash } from "crypto";
5
4
  function stableIssueHash(issue) {
6
5
  const labels = Array.isArray(issue.labels) ? [...issue.labels].map(String).sort() : [];
@@ -134,16 +133,33 @@ function parseIssueAnalysisResult(raw) {
134
133
  return result;
135
134
  }
136
135
  function createDefaultPiIssueAnalysisCommandRunner() {
137
- return (command, args, options) => new Promise((resolve) => {
138
- execFile(command, [...args], {
139
- timeout: options.timeoutMs,
140
- maxBuffer: 10 * 1024 * 1024,
141
- env: options.env ? { ...process.env, ...options.env } : process.env
142
- }, (error, stdout, stderr) => {
143
- const exitCode = typeof error?.code === "number" ? error.code : error ? 1 : 0;
144
- resolve({ exitCode, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
136
+ return async (command, args, options) => {
137
+ const env = options.env ? { ...process.env, ...options.env } : process.env;
138
+ const proc = Bun.spawn([command, ...args], {
139
+ stdout: "pipe",
140
+ stderr: "pipe",
141
+ env
145
142
  });
146
- });
143
+ let timedOut = false;
144
+ const timer = setTimeout(() => {
145
+ timedOut = true;
146
+ proc.kill();
147
+ }, options.timeoutMs);
148
+ try {
149
+ const [stdout, stderr, exitCode] = await Promise.all([
150
+ new Response(proc.stdout).text(),
151
+ new Response(proc.stderr).text(),
152
+ proc.exited
153
+ ]);
154
+ return {
155
+ exitCode: timedOut && exitCode === 0 ? 1 : exitCode,
156
+ stdout,
157
+ stderr: timedOut && stderr.trim().length === 0 ? `Pi issue analysis timed out after ${options.timeoutMs}ms` : stderr
158
+ };
159
+ } finally {
160
+ clearTimeout(timer);
161
+ }
162
+ };
147
163
  }
148
164
  function createPiIssueAnalyzer(input = {}) {
149
165
  const piBinary = input.piBinary ?? process.env.RIG_ISSUE_ANALYSIS_PI_BINARY ?? "pi";
@@ -2312,7 +2312,6 @@ function createGitHubTaskReconciler(input) {
2312
2312
  }
2313
2313
 
2314
2314
  // packages/server/src/server-helpers/issue-analysis.ts
2315
- import { execFile } from "child_process";
2316
2315
  import { createHash } from "crypto";
2317
2316
  function stableIssueHash(issue) {
2318
2317
  const labels = Array.isArray(issue.labels) ? [...issue.labels].map(String).sort() : [];
@@ -2446,16 +2445,33 @@ function parseIssueAnalysisResult(raw) {
2446
2445
  return result;
2447
2446
  }
2448
2447
  function createDefaultPiIssueAnalysisCommandRunner() {
2449
- return (command, args, options) => new Promise((resolve11) => {
2450
- execFile(command, [...args], {
2451
- timeout: options.timeoutMs,
2452
- maxBuffer: 10 * 1024 * 1024,
2453
- env: options.env ? { ...process.env, ...options.env } : process.env
2454
- }, (error, stdout, stderr) => {
2455
- const exitCode = typeof error?.code === "number" ? error.code : error ? 1 : 0;
2456
- resolve11({ exitCode, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
2448
+ return async (command, args, options) => {
2449
+ const env = options.env ? { ...process.env, ...options.env } : process.env;
2450
+ const proc = Bun.spawn([command, ...args], {
2451
+ stdout: "pipe",
2452
+ stderr: "pipe",
2453
+ env
2457
2454
  });
2458
- });
2455
+ let timedOut = false;
2456
+ const timer = setTimeout(() => {
2457
+ timedOut = true;
2458
+ proc.kill();
2459
+ }, options.timeoutMs);
2460
+ try {
2461
+ const [stdout, stderr, exitCode] = await Promise.all([
2462
+ new Response(proc.stdout).text(),
2463
+ new Response(proc.stderr).text(),
2464
+ proc.exited
2465
+ ]);
2466
+ return {
2467
+ exitCode: timedOut && exitCode === 0 ? 1 : exitCode,
2468
+ stdout,
2469
+ stderr: timedOut && stderr.trim().length === 0 ? `Pi issue analysis timed out after ${options.timeoutMs}ms` : stderr
2470
+ };
2471
+ } finally {
2472
+ clearTimeout(timer);
2473
+ }
2474
+ };
2459
2475
  }
2460
2476
  function createPiIssueAnalyzer(input = {}) {
2461
2477
  const piBinary = input.piBinary ?? process.env.RIG_ISSUE_ANALYSIS_PI_BINARY ?? "pi";
@@ -5337,7 +5353,46 @@ function isLoopbackRequest(req) {
5337
5353
  }
5338
5354
  }
5339
5355
  function isPublicRigAuthBootstrapRoute(pathname) {
5340
- return pathname === "/" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
5356
+ return pathname === "/" || pathname === "/install" || pathname === "/health" || pathname === "/api/health" || pathname === "/api/github/auth/status" || pathname === "/api/github/auth/token" || pathname === "/api/github/auth/device/start" || pathname === "/api/github/auth/device/poll";
5357
+ }
5358
+ function buildRigInstallScript() {
5359
+ return `#!/usr/bin/env bash
5360
+ set -euo pipefail
5361
+
5362
+ say() {
5363
+ printf 'rig-install: %s
5364
+ ' "$*"
5365
+ }
5366
+
5367
+ if ! command -v bun >/dev/null 2>&1; then
5368
+ say "Bun not found; installing Bun first"
5369
+ curl -fsSL https://bun.sh/install | bash
5370
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
5371
+ export PATH="$BUN_INSTALL/bin:$PATH"
5372
+ fi
5373
+
5374
+ if ! command -v bun >/dev/null 2>&1; then
5375
+ printf 'rig-install: bun install completed, but bun is still not on PATH. Add ~/.bun/bin to PATH and retry.
5376
+ ' >&2
5377
+ exit 1
5378
+ fi
5379
+
5380
+ say "Installing @h-rig/cli@latest"
5381
+ bun add -g @h-rig/cli@latest
5382
+
5383
+ export BUN_INSTALL="\${BUN_INSTALL:-$HOME/.bun}"
5384
+ export PATH="$BUN_INSTALL/bin:$PATH"
5385
+
5386
+ if ! command -v rig >/dev/null 2>&1; then
5387
+ printf 'rig-install: rig installed, but rig is not on PATH. Add %s/bin to PATH and retry.
5388
+ ' "$BUN_INSTALL" >&2
5389
+ exit 1
5390
+ fi
5391
+
5392
+ say "Verifying rig"
5393
+ rig --help >/dev/null
5394
+ say "Done. Run: rig --help"
5395
+ `;
5341
5396
  }
5342
5397
  function normalizePrMode(value) {
5343
5398
  const mode = normalizeString(value);
@@ -5741,6 +5796,13 @@ function createRigServerFetch(state, deps) {
5741
5796
  notifications: state.targets.length
5742
5797
  });
5743
5798
  }
5799
+ if (url.pathname === "/install" && req.method === "GET") {
5800
+ return new Response(buildRigInstallScript(), {
5801
+ headers: {
5802
+ "Content-Type": "text/x-shellscript; charset=utf-8"
5803
+ }
5804
+ });
5805
+ }
5744
5806
  const isLinearWebhook = url.pathname === "/api/linear/webhook" && req.method === "POST";
5745
5807
  const isInspectorStream = url.pathname === "/api/inspector/stream" && req.method === "GET";
5746
5808
  const legacyAuthorizedHttpRequest = Boolean(state.authToken) && (isInspectorStream && isAuthorizedInspectorStreamRequest(req, state.authToken) ? true : deps.isAuthorizedHttpRequest(req, state.authToken));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/server",
3
- "version": "0.0.6-alpha.5",
3
+ "version": "0.0.6-alpha.6",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -25,9 +25,9 @@
25
25
  "rig-server": "./dist/src/server.js"
26
26
  },
27
27
  "dependencies": {
28
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.5",
29
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.5",
30
- "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.5",
28
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.6",
29
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.6",
30
+ "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.6",
31
31
  "effect": "4.0.0-beta.78"
32
32
  }
33
33
  }