@h-rig/runtime 0.0.6-alpha.3 → 0.0.6-alpha.31

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 (59) hide show
  1. package/dist/bin/rig-agent-dispatch.js +1165 -785
  2. package/dist/bin/rig-agent.js +458 -389
  3. package/dist/src/control-plane/agent-wrapper.js +1191 -504
  4. package/dist/src/control-plane/authority-files.js +12 -6
  5. package/dist/src/control-plane/harness-main.js +2186 -1786
  6. package/dist/src/control-plane/hooks/completion-verification.js +2084 -1019
  7. package/dist/src/control-plane/hooks/inject-context.js +193 -139
  8. package/dist/src/control-plane/hooks/submodule-branch.js +603 -545
  9. package/dist/src/control-plane/hooks/task-runtime-start.js +603 -545
  10. package/dist/src/control-plane/materialize-task-config.js +64 -8
  11. package/dist/src/control-plane/native/git-ops.js +90 -64
  12. package/dist/src/control-plane/native/harness-cli.js +1989 -682
  13. package/dist/src/control-plane/native/pr-automation.js +1657 -54
  14. package/dist/src/control-plane/native/pr-review-gate.js +1455 -0
  15. package/dist/src/control-plane/native/repo-ops.js +3 -0
  16. package/dist/src/control-plane/native/run-ops.js +39 -13
  17. package/dist/src/control-plane/native/task-ops.js +1819 -527
  18. package/dist/src/control-plane/native/validator.js +163 -109
  19. package/dist/src/control-plane/native/verifier.js +1616 -323
  20. package/dist/src/control-plane/native/workspace-ops.js +12 -6
  21. package/dist/src/control-plane/pi-sessiond/bin.js +793 -0
  22. package/dist/src/control-plane/pi-sessiond/client.js +41 -0
  23. package/dist/src/control-plane/pi-sessiond/event-hub.js +59 -0
  24. package/dist/src/control-plane/pi-sessiond/extension-ui-context.js +198 -0
  25. package/dist/src/control-plane/pi-sessiond/launcher.js +173 -0
  26. package/dist/src/control-plane/pi-sessiond/server.js +802 -0
  27. package/dist/src/control-plane/pi-sessiond/session-service.js +540 -0
  28. package/dist/src/control-plane/pi-sessiond/types.js +1 -0
  29. package/dist/src/control-plane/plugin-host-context.js +54 -0
  30. package/dist/src/control-plane/runtime/image/fingerprint-sidecar.js +3 -0
  31. package/dist/src/control-plane/runtime/image/index.js +3 -0
  32. package/dist/src/control-plane/runtime/image-fingerprint-sidecar.js +3 -0
  33. package/dist/src/control-plane/runtime/image.js +3 -0
  34. package/dist/src/control-plane/runtime/index.js +517 -722
  35. package/dist/src/control-plane/runtime/isolation/home.js +28 -6
  36. package/dist/src/control-plane/runtime/isolation/index.js +541 -461
  37. package/dist/src/control-plane/runtime/isolation/runner.js +28 -6
  38. package/dist/src/control-plane/runtime/isolation/shared.js +9 -6
  39. package/dist/src/control-plane/runtime/isolation.js +541 -461
  40. package/dist/src/control-plane/runtime/plugin-mode.js +3 -27
  41. package/dist/src/control-plane/runtime/queue.js +458 -385
  42. package/dist/src/control-plane/runtime/snapshot/task-run.js +3 -0
  43. package/dist/src/control-plane/runtime/task-run-snapshot.js +3 -0
  44. package/dist/src/control-plane/skill-materializer.js +46 -0
  45. package/dist/src/control-plane/tasks/source-aware-task-config-source.js +14 -2
  46. package/dist/src/control-plane/tasks/source-lifecycle.js +86 -32
  47. package/dist/src/index.js +27 -298
  48. package/dist/src/layout.js +12 -7
  49. package/dist/src/local-server.js +20 -14
  50. package/native/darwin-arm64/rig-git +0 -0
  51. package/native/darwin-arm64/rig-git.build-manifest.json +1 -1
  52. package/native/darwin-arm64/rig-shell +0 -0
  53. package/native/darwin-arm64/rig-shell.build-manifest.json +1 -1
  54. package/native/darwin-arm64/rig-tools +0 -0
  55. package/native/darwin-arm64/rig-tools.build-manifest.json +1 -1
  56. package/native/darwin-arm64/runtime-native.dylib +0 -0
  57. package/package.json +8 -6
  58. package/dist/src/control-plane/runtime/plugins.js +0 -1131
  59. package/dist/src/plugins.js +0 -329
@@ -785,6 +785,9 @@ var sharedNativeToolsOutputPath = resolve8(sharedNativeToolsOutputDir, `rig-tool
785
785
  import { createPluginHost } from "@rig/core";
786
786
  import { loadConfig } from "@rig/core/load-config";
787
787
 
788
+ // packages/runtime/src/control-plane/skill-materializer.ts
789
+ import { loadSkill } from "@rig/skill-loader";
790
+
788
791
  // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
789
792
  var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
790
793
 
@@ -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);
@@ -1648,6 +1654,9 @@ import { loadConfig } from "@rig/core/load-config";
1648
1654
  // packages/runtime/src/control-plane/repos/registry.ts
1649
1655
  var MANAGED_REPOS = new Map;
1650
1656
 
1657
+ // packages/runtime/src/control-plane/skill-materializer.ts
1658
+ import { loadSkill } from "@rig/skill-loader";
1659
+
1651
1660
  // packages/runtime/src/control-plane/tasks/source-aware-task-config-source.ts
1652
1661
  var STATUS_LABELS = new Set(["ready", "blocked", "in-progress", "under-review", "failed", "cancelled"]);
1653
1662
 
@@ -2713,11 +2722,13 @@ function runStatus(projectRoot, runtimeContext) {
2713
2722
  recentRuns: runs.slice(0, 10)
2714
2723
  };
2715
2724
  }
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];
2725
+ function latestLocalRunForResume(projectRoot) {
2726
+ 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;
2727
+ }
2728
+ async function submitRunResumeRequest(projectRoot, input) {
2729
+ const run = latestLocalRunForResume(projectRoot);
2719
2730
  if (!run) {
2720
- throw new RemoteCliError("RIG_RUN_NOTHING_TO_RESUME", "No stopped local run is available to resume.", 2);
2731
+ throw new RemoteCliError(input.failureCode, input.nothingMessage, 2);
2721
2732
  }
2722
2733
  const server = await ensureServerForRuns(projectRoot);
2723
2734
  const response = await fetch(`${server.baseUrl}/api/runs/resume`, {
@@ -2726,14 +2737,28 @@ async function runResume(projectRoot, runtimeContext) {
2726
2737
  "content-type": "application/json",
2727
2738
  ...server.authToken ? { authorization: `Bearer ${server.authToken}` } : {}
2728
2739
  },
2729
- body: JSON.stringify({ runId: run.runId, createdAt: new Date().toISOString() })
2740
+ body: JSON.stringify({ runId: run.runId, createdAt: new Date().toISOString(), restart: input.restart })
2730
2741
  });
2731
2742
  if (!response.ok) {
2732
2743
  const text = await response.text();
2733
- throw new RemoteCliError("RIG_RUN_RESUME_FAILED", text || response.statusText, 1, { runId: run.runId });
2744
+ throw new RemoteCliError(input.restart ? "RIG_RUN_RESTART_FAILED" : "RIG_RUN_RESUME_FAILED", text || response.statusText, 1, { runId: run.runId });
2734
2745
  }
2735
2746
  return { runId: run.runId };
2736
2747
  }
2748
+ async function runResume(projectRoot, runtimeContext) {
2749
+ return submitRunResumeRequest(projectRoot, {
2750
+ restart: false,
2751
+ failureCode: "RIG_RUN_NOTHING_TO_RESUME",
2752
+ nothingMessage: "No resumable local run is available."
2753
+ });
2754
+ }
2755
+ async function runRestart(projectRoot, runtimeContext) {
2756
+ return submitRunResumeRequest(projectRoot, {
2757
+ restart: true,
2758
+ failureCode: "RIG_RUN_NOTHING_TO_RESTART",
2759
+ nothingMessage: "No local run is available to restart."
2760
+ });
2761
+ }
2737
2762
  async function runStop(projectRoot) {
2738
2763
  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
2764
  if (activeRuns.length === 0) {
@@ -3068,7 +3093,7 @@ async function ensureLocalControlBinaries(projectRoot, sourceRoot = resolveLocal
3068
3093
  sourcePath: target.sourcePath,
3069
3094
  outputPath: target.outputPath,
3070
3095
  cwd: sourceRoot,
3071
- define: target.entrypoint === "packages/runtime/bin/rig-agent-dispatch.ts" ? secretDefines : undefined
3096
+ define: target.entrypoint === "packages/runtime/bin/rig-agent-dispatch.ts" ? { ...secretDefines, RIG_SOURCE_ROOT: sourceRoot } : undefined
3072
3097
  });
3073
3098
  } catch (error) {
3074
3099
  throw new RemoteCliError("RIG_RUN_BINARY_BUILD_FAILED", `Failed to compile ${target.entrypoint}: ${error instanceof Error ? error.message : "unknown error"}`, 2);
@@ -3267,6 +3292,7 @@ export {
3267
3292
  runStop,
3268
3293
  runStatus,
3269
3294
  runResume,
3295
+ runRestart,
3270
3296
  resolvePreferredShellBinary,
3271
3297
  resolveLocalControlBinarySourceRoot,
3272
3298
  resolveDefaultEpic,