@h-rig/runtime 0.0.6-alpha.1 → 0.0.6-alpha.2

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.
@@ -9193,6 +9193,18 @@ async function runAgentWrapper(options = {}) {
9193
9193
  console.error(`[rig-agent] Failed to provision runtime: ${error}`);
9194
9194
  return 1;
9195
9195
  }
9196
+ try {
9197
+ await waitForDirtyBaselineReady(runtime, taskId);
9198
+ } catch (error) {
9199
+ emitWrapperEvent("runtime.baseline.failed", {
9200
+ runtimeId: runtime.id,
9201
+ taskId,
9202
+ workspaceDir: runtime.workspaceDir,
9203
+ error: error instanceof Error ? error.message : String(error)
9204
+ });
9205
+ console.error(`[rig-agent] Failed to apply selected baseline before provider launch: ${error}`);
9206
+ return 1;
9207
+ }
9196
9208
  const providerArgs = buildProviderArgs(provider, runtime, argv);
9197
9209
  const providerCommand = [providerBinary(provider), ...providerArgs];
9198
9210
  emitWrapperEvent("provider.launch", {
@@ -9413,6 +9425,34 @@ function providerBinary(provider) {
9413
9425
  function emitWrapperEvent(type, payload) {
9414
9426
  console.log(`__RIG_WRAPPER_EVENT__${JSON.stringify({ type, payload, at: new Date().toISOString() })}`);
9415
9427
  }
9428
+ function sleep(ms) {
9429
+ return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
9430
+ }
9431
+ async function waitForDirtyBaselineReady(runtime, taskId) {
9432
+ const readyFile = process.env.RIG_DIRTY_BASELINE_READY_FILE?.trim();
9433
+ if (process.env.RIG_BASELINE_MODE !== "dirty-snapshot" || !readyFile)
9434
+ return;
9435
+ const timeoutMs = Number.parseInt(process.env.RIG_DIRTY_BASELINE_TIMEOUT_MS ?? "30000", 10);
9436
+ const deadline = Date.now() + (Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 30000);
9437
+ emitWrapperEvent("runtime.baseline.waiting", {
9438
+ runtimeId: runtime.id,
9439
+ taskId,
9440
+ workspaceDir: runtime.workspaceDir,
9441
+ readyFile
9442
+ });
9443
+ while (!existsSync33(readyFile)) {
9444
+ if (Date.now() >= deadline) {
9445
+ throw new Error(`Timed out waiting for dirty baseline ready file: ${readyFile}`);
9446
+ }
9447
+ await sleep(50);
9448
+ }
9449
+ emitWrapperEvent("runtime.baseline.completed", {
9450
+ runtimeId: runtime.id,
9451
+ taskId,
9452
+ workspaceDir: runtime.workspaceDir,
9453
+ readyFile
9454
+ });
9455
+ }
9416
9456
  async function resolveTaskId(projectRoot, monorepoRoot) {
9417
9457
  if (process.env.RIG_TASK_ID) {
9418
9458
  return process.env.RIG_TASK_ID;
@@ -9193,6 +9193,18 @@ async function runAgentWrapper(options = {}) {
9193
9193
  console.error(`[rig-agent] Failed to provision runtime: ${error}`);
9194
9194
  return 1;
9195
9195
  }
9196
+ try {
9197
+ await waitForDirtyBaselineReady(runtime, taskId);
9198
+ } catch (error) {
9199
+ emitWrapperEvent("runtime.baseline.failed", {
9200
+ runtimeId: runtime.id,
9201
+ taskId,
9202
+ workspaceDir: runtime.workspaceDir,
9203
+ error: error instanceof Error ? error.message : String(error)
9204
+ });
9205
+ console.error(`[rig-agent] Failed to apply selected baseline before provider launch: ${error}`);
9206
+ return 1;
9207
+ }
9196
9208
  const providerArgs = buildProviderArgs(provider, runtime, argv);
9197
9209
  const providerCommand = [providerBinary(provider), ...providerArgs];
9198
9210
  emitWrapperEvent("provider.launch", {
@@ -9413,6 +9425,34 @@ function providerBinary(provider) {
9413
9425
  function emitWrapperEvent(type, payload) {
9414
9426
  console.log(`__RIG_WRAPPER_EVENT__${JSON.stringify({ type, payload, at: new Date().toISOString() })}`);
9415
9427
  }
9428
+ function sleep(ms) {
9429
+ return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
9430
+ }
9431
+ async function waitForDirtyBaselineReady(runtime, taskId) {
9432
+ const readyFile = process.env.RIG_DIRTY_BASELINE_READY_FILE?.trim();
9433
+ if (process.env.RIG_BASELINE_MODE !== "dirty-snapshot" || !readyFile)
9434
+ return;
9435
+ const timeoutMs = Number.parseInt(process.env.RIG_DIRTY_BASELINE_TIMEOUT_MS ?? "30000", 10);
9436
+ const deadline = Date.now() + (Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 30000);
9437
+ emitWrapperEvent("runtime.baseline.waiting", {
9438
+ runtimeId: runtime.id,
9439
+ taskId,
9440
+ workspaceDir: runtime.workspaceDir,
9441
+ readyFile
9442
+ });
9443
+ while (!existsSync33(readyFile)) {
9444
+ if (Date.now() >= deadline) {
9445
+ throw new Error(`Timed out waiting for dirty baseline ready file: ${readyFile}`);
9446
+ }
9447
+ await sleep(50);
9448
+ }
9449
+ emitWrapperEvent("runtime.baseline.completed", {
9450
+ runtimeId: runtime.id,
9451
+ taskId,
9452
+ workspaceDir: runtime.workspaceDir,
9453
+ readyFile
9454
+ });
9455
+ }
9416
9456
  async function resolveTaskId(projectRoot, monorepoRoot) {
9417
9457
  if (process.env.RIG_TASK_ID) {
9418
9458
  return process.env.RIG_TASK_ID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/runtime",
3
- "version": "0.0.6-alpha.1",
3
+ "version": "0.0.6-alpha.2",
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.1",
68
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.1",
69
- "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.1",
70
- "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.1",
71
- "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.1",
67
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.2",
68
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.2",
69
+ "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.2",
70
+ "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.2",
71
+ "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.2",
72
72
  "effect": "4.0.0-beta.78",
73
73
  "smol-toml": "^1.6.0"
74
74
  }