@h-rig/runtime 0.0.6-alpha.8 → 0.0.6-alpha.9

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
@@ -619,6 +619,18 @@ async function waitForServerHealthy(baseUrl, authToken, timeoutMs) {
619
619
  }
620
620
  return false;
621
621
  }
622
+ function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
623
+ const binary = process.env.RIG_SERVER_BIN?.trim() || which("rig-server")?.trim();
624
+ const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
625
+ if (binary) {
626
+ return { command: binary, args, cwd: projectRoot };
627
+ }
628
+ return {
629
+ command: "bun",
630
+ args: ["run", "packages/server/src/server.ts", ...args],
631
+ cwd: resolve5(import.meta.dir, "../../..")
632
+ };
633
+ }
622
634
  async function waitForPublishedServer(projectRoot, authToken, timeoutMs) {
623
635
  const deadline = Date.now() + timeoutMs;
624
636
  while (Date.now() < deadline) {
@@ -644,23 +656,13 @@ async function ensureLocalRigServerConnection(projectRoot, options = {}) {
644
656
  const host = options.host ?? "127.0.0.1";
645
657
  const startupTimeoutMs = options.startupTimeoutMs ?? 15000;
646
658
  const authToken = Buffer.from(crypto.getRandomValues(new Uint8Array(24))).toString("hex");
647
- const workspaceRoot = resolve5(import.meta.dir, "../../..");
648
659
  const bootstrapLogPath = resolveRigServerLogPath(projectRoot);
649
660
  mkdirSync2(resolveRigServerPaths(projectRoot).logsDir, { recursive: true });
650
661
  const bootstrapLogFd = openSync(bootstrapLogPath, "w");
651
662
  clearPublishedRigServerState(projectRoot);
652
- const child = spawn("bun", [
653
- "run",
654
- "packages/server/src/server.ts",
655
- "start",
656
- "--host",
657
- host,
658
- "--port",
659
- "0",
660
- "--auth-token",
661
- authToken
662
- ], {
663
- cwd: workspaceRoot,
663
+ const spawnPlan = resolveRigServerSpawnPlan(projectRoot, host, authToken);
664
+ const child = spawn(spawnPlan.command, [...spawnPlan.args], {
665
+ cwd: spawnPlan.cwd,
664
666
  env: {
665
667
  ...process.env,
666
668
  PROJECT_RIG_ROOT: projectRoot
@@ -134,6 +134,18 @@ async function waitForServerHealthy(baseUrl, authToken, timeoutMs) {
134
134
  }
135
135
  return false;
136
136
  }
137
+ function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
138
+ const binary = process.env.RIG_SERVER_BIN?.trim() || which("rig-server")?.trim();
139
+ const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
140
+ if (binary) {
141
+ return { command: binary, args, cwd: projectRoot };
142
+ }
143
+ return {
144
+ command: "bun",
145
+ args: ["run", "packages/server/src/server.ts", ...args],
146
+ cwd: resolve2(import.meta.dir, "../../..")
147
+ };
148
+ }
137
149
  async function waitForPublishedServer(projectRoot, authToken, timeoutMs) {
138
150
  const deadline = Date.now() + timeoutMs;
139
151
  while (Date.now() < deadline) {
@@ -159,23 +171,13 @@ async function ensureLocalRigServerConnection(projectRoot, options = {}) {
159
171
  const host = options.host ?? "127.0.0.1";
160
172
  const startupTimeoutMs = options.startupTimeoutMs ?? 15000;
161
173
  const authToken = Buffer.from(crypto.getRandomValues(new Uint8Array(24))).toString("hex");
162
- const workspaceRoot = resolve2(import.meta.dir, "../../..");
163
174
  const bootstrapLogPath = resolveRigServerLogPath(projectRoot);
164
175
  mkdirSync(resolveRigServerPaths(projectRoot).logsDir, { recursive: true });
165
176
  const bootstrapLogFd = openSync(bootstrapLogPath, "w");
166
177
  clearPublishedRigServerState(projectRoot);
167
- const child = spawn("bun", [
168
- "run",
169
- "packages/server/src/server.ts",
170
- "start",
171
- "--host",
172
- host,
173
- "--port",
174
- "0",
175
- "--auth-token",
176
- authToken
177
- ], {
178
- cwd: workspaceRoot,
178
+ const spawnPlan = resolveRigServerSpawnPlan(projectRoot, host, authToken);
179
+ const child = spawn(spawnPlan.command, [...spawnPlan.args], {
180
+ cwd: spawnPlan.cwd,
179
181
  env: {
180
182
  ...process.env,
181
183
  PROJECT_RIG_ROOT: projectRoot
@@ -195,8 +197,12 @@ ${bootstrapLog}` : ` No bootstrap log was written.`;
195
197
  }
196
198
  return toLocalServerConnection(ready);
197
199
  }
200
+ var __testOnly = {
201
+ resolveRigServerSpawnPlan
202
+ };
198
203
  export {
199
204
  readPublishedRigServerStateSync,
200
205
  readPublishedRigServerState,
201
- ensureLocalRigServerConnection
206
+ ensureLocalRigServerConnection,
207
+ __testOnly
202
208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/runtime",
3
- "version": "0.0.6-alpha.8",
3
+ "version": "0.0.6-alpha.9",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -64,11 +64,11 @@
64
64
  "module": "./dist/src/index.js",
65
65
  "dependencies": {
66
66
  "@libsql/client": "^0.17.2",
67
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.8",
68
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.8",
69
- "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.8",
70
- "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.8",
71
- "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.8",
67
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.9",
68
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.9",
69
+ "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.9",
70
+ "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.9",
71
+ "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.9",
72
72
  "effect": "4.0.0-beta.78",
73
73
  "smol-toml": "^1.6.0"
74
74
  }