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

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 (46) hide show
  1. package/dist/bin/rig-agent-dispatch.js +84 -313
  2. package/dist/bin/rig-agent.js +85 -27
  3. package/dist/src/control-plane/agent-wrapper.js +101 -27
  4. package/dist/src/control-plane/authority-files.js +12 -6
  5. package/dist/src/control-plane/harness-main.js +1357 -180
  6. package/dist/src/control-plane/hooks/completion-verification.js +1669 -329
  7. package/dist/src/control-plane/hooks/inject-context.js +2 -2
  8. package/dist/src/control-plane/hooks/submodule-branch.js +26 -3
  9. package/dist/src/control-plane/hooks/task-runtime-start.js +26 -3
  10. package/dist/src/control-plane/native/git-ops.js +134 -68
  11. package/dist/src/control-plane/native/harness-cli.js +1357 -180
  12. package/dist/src/control-plane/native/pr-automation.js +1532 -54
  13. package/dist/src/control-plane/native/pr-review-gate.js +1330 -0
  14. package/dist/src/control-plane/native/run-ops.js +35 -12
  15. package/dist/src/control-plane/native/task-ops.js +1274 -155
  16. package/dist/src/control-plane/native/validator.js +2 -2
  17. package/dist/src/control-plane/native/verifier.js +1274 -154
  18. package/dist/src/control-plane/native/workspace-ops.js +12 -6
  19. package/dist/src/control-plane/runtime/index.js +38 -9
  20. package/dist/src/control-plane/runtime/isolation/home.js +31 -6
  21. package/dist/src/control-plane/runtime/isolation/index.js +38 -9
  22. package/dist/src/control-plane/runtime/isolation/runner.js +31 -6
  23. package/dist/src/control-plane/runtime/isolation/shared.js +9 -6
  24. package/dist/src/control-plane/runtime/isolation.js +38 -9
  25. package/dist/src/control-plane/runtime/queue.js +38 -9
  26. package/dist/src/control-plane/tasks/source-aware-task-config-source.js +14 -2
  27. package/dist/src/control-plane/tasks/source-lifecycle.js +2 -2
  28. package/dist/src/index.js +27 -20
  29. package/dist/src/layout.js +12 -7
  30. package/dist/src/local-server.js +20 -14
  31. package/native/darwin-arm64/{bin/rig-git → rig-git} +0 -0
  32. package/native/darwin-arm64/rig-git.build-manifest.json +4 -0
  33. package/native/darwin-arm64/{bin/rig-shell → rig-shell} +0 -0
  34. package/native/darwin-arm64/rig-shell.build-manifest.json +4 -0
  35. package/native/darwin-arm64/{bin/rig-tools → rig-tools} +0 -0
  36. package/native/darwin-arm64/rig-tools.build-manifest.json +4 -0
  37. package/native/darwin-arm64/{lib/runtime-native.dylib → runtime-native.dylib} +0 -0
  38. package/package.json +6 -6
  39. package/native/darwin-arm64/lib/runtime-native-darwin-arm64.dylib +0 -0
  40. package/native/darwin-arm64/manifest.json +0 -1
  41. package/native/linux-x64/bin/rig-git +0 -0
  42. package/native/linux-x64/bin/rig-shell +0 -0
  43. package/native/linux-x64/bin/rig-tools +0 -0
  44. package/native/linux-x64/lib/runtime-native-linux-x64.so +0 -0
  45. package/native/linux-x64/lib/runtime-native.so +0 -0
  46. package/native/linux-x64/manifest.json +0 -1
@@ -621,10 +621,6 @@ function runBelongsToProject(projectRoot, run, runsDir) {
621
621
  if (recordedProjectRoot) {
622
622
  return resolve3(recordedProjectRoot) === normalizedRoot;
623
623
  }
624
- const projectLocalRunsDir = resolve3(normalizedRoot, ".rig", "runs");
625
- if (isPathWithin(projectLocalRunsDir, resolve3(runsDir))) {
626
- return true;
627
- }
628
624
  const pathFields = [
629
625
  run.worktreePath,
630
626
  run.artifactRoot,
@@ -632,10 +628,20 @@ function runBelongsToProject(projectRoot, run, runsDir) {
632
628
  run.sessionPath,
633
629
  run.sessionLogPath
634
630
  ].filter((value) => typeof value === "string" && value.trim().length > 0);
635
- if (pathFields.length === 0) {
631
+ if (pathFields.length > 0) {
632
+ if (pathFields.some((value) => isPathWithin(normalizedRoot, resolve3(value)))) {
633
+ return true;
634
+ }
635
+ const pointsAtManagedWorkspace = pathFields.some((value) => /(?:^|[/\\])\.worktrees(?:[/\\]|$)/.test(value));
636
+ if (pointsAtManagedWorkspace) {
637
+ return false;
638
+ }
639
+ }
640
+ const projectLocalRunsDir = resolve3(normalizedRoot, ".rig", "runs");
641
+ if (isPathWithin(projectLocalRunsDir, resolve3(runsDir))) {
636
642
  return true;
637
643
  }
638
- return pathFields.some((value) => isPathWithin(normalizedRoot, resolve3(value)));
644
+ return pathFields.length === 0;
639
645
  }
640
646
  function isPathWithin(root, candidate) {
641
647
  const relativePath = relative(root, candidate);
@@ -2713,11 +2719,13 @@ function runStatus(projectRoot, runtimeContext) {
2713
2719
  recentRuns: runs.slice(0, 10)
2714
2720
  };
2715
2721
  }
2716
- async function runResume(projectRoot, runtimeContext) {
2717
- const resumable = listAuthorityRuns(projectRoot).map((entry) => readAuthorityRun(projectRoot, entry.runId)).filter((run2) => Boolean(run2)).filter((run2) => run2.mode === "local" && (run2.status === "stopped" || run2.status === "failed" || run2.status === "created")).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")));
2718
- const run = resumable[0];
2722
+ function latestLocalRunForResume(projectRoot) {
2723
+ return listAuthorityRuns(projectRoot).map((entry) => readAuthorityRun(projectRoot, entry.runId)).filter((run) => Boolean(run)).filter((run) => run.mode === "local" && ["created", "preparing", "running", "validating", "reviewing", "stopped", "failed", "needs_attention"].includes(String(run.status ?? ""))).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")))[0] ?? null;
2724
+ }
2725
+ async function submitRunResumeRequest(projectRoot, input) {
2726
+ const run = latestLocalRunForResume(projectRoot);
2719
2727
  if (!run) {
2720
- throw new RemoteCliError("RIG_RUN_NOTHING_TO_RESUME", "No stopped local run is available to resume.", 2);
2728
+ throw new RemoteCliError(input.failureCode, input.nothingMessage, 2);
2721
2729
  }
2722
2730
  const server = await ensureServerForRuns(projectRoot);
2723
2731
  const response = await fetch(`${server.baseUrl}/api/runs/resume`, {
@@ -2726,14 +2734,28 @@ async function runResume(projectRoot, runtimeContext) {
2726
2734
  "content-type": "application/json",
2727
2735
  ...server.authToken ? { authorization: `Bearer ${server.authToken}` } : {}
2728
2736
  },
2729
- body: JSON.stringify({ runId: run.runId, createdAt: new Date().toISOString() })
2737
+ body: JSON.stringify({ runId: run.runId, createdAt: new Date().toISOString(), restart: input.restart })
2730
2738
  });
2731
2739
  if (!response.ok) {
2732
2740
  const text = await response.text();
2733
- throw new RemoteCliError("RIG_RUN_RESUME_FAILED", text || response.statusText, 1, { runId: run.runId });
2741
+ throw new RemoteCliError(input.restart ? "RIG_RUN_RESTART_FAILED" : "RIG_RUN_RESUME_FAILED", text || response.statusText, 1, { runId: run.runId });
2734
2742
  }
2735
2743
  return { runId: run.runId };
2736
2744
  }
2745
+ async function runResume(projectRoot, runtimeContext) {
2746
+ return submitRunResumeRequest(projectRoot, {
2747
+ restart: false,
2748
+ failureCode: "RIG_RUN_NOTHING_TO_RESUME",
2749
+ nothingMessage: "No resumable local run is available."
2750
+ });
2751
+ }
2752
+ async function runRestart(projectRoot, runtimeContext) {
2753
+ return submitRunResumeRequest(projectRoot, {
2754
+ restart: true,
2755
+ failureCode: "RIG_RUN_NOTHING_TO_RESTART",
2756
+ nothingMessage: "No local run is available to restart."
2757
+ });
2758
+ }
2737
2759
  async function runStop(projectRoot) {
2738
2760
  const activeRuns = listAuthorityRuns(projectRoot).map((entry) => readAuthorityRun(projectRoot, entry.runId)).filter((run) => Boolean(run)).filter((run) => run.mode === "local" && ACTIVE_RUN_STATUSES.has(String(run.status ?? "")));
2739
2761
  if (activeRuns.length === 0) {
@@ -3267,6 +3289,7 @@ export {
3267
3289
  runStop,
3268
3290
  runStatus,
3269
3291
  runResume,
3292
+ runRestart,
3270
3293
  resolvePreferredShellBinary,
3271
3294
  resolveLocalControlBinarySourceRoot,
3272
3295
  resolveDefaultEpic,