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

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
@@ -686,20 +686,23 @@ function hashProjectPath(workspaceDir) {
686
686
  }
687
687
  function resolveGithubCliBinaryPath() {
688
688
  const explicit = process.env.RIG_GH_BIN?.trim();
689
- if (explicit && existsSync5(explicit)) {
689
+ if (explicit && existsSync5(explicit) && !isRuntimeGatewayGhPath(explicit)) {
690
690
  return explicit;
691
691
  }
692
- const bunResolved = Bun.which("gh");
693
- if (bunResolved && existsSync5(bunResolved)) {
694
- return bunResolved;
695
- }
696
- for (const candidate of ["/opt/homebrew/bin/gh", "/usr/local/bin/gh", "/usr/bin/gh"]) {
692
+ for (const candidate of ["/usr/bin/gh", "/opt/homebrew/bin/gh", "/usr/local/bin/gh"]) {
697
693
  if (existsSync5(candidate)) {
698
694
  return candidate;
699
695
  }
700
696
  }
697
+ const bunResolved = Bun.which("gh");
698
+ if (bunResolved && existsSync5(bunResolved) && !isRuntimeGatewayGhPath(bunResolved)) {
699
+ return bunResolved;
700
+ }
701
701
  return "";
702
702
  }
703
+ function isRuntimeGatewayGhPath(candidate) {
704
+ return /\/\.rig\/bin\/gh$/.test(candidate.replace(/\\/g, "/"));
705
+ }
703
706
  async function resolveGithubCliAuthToken(ghBinary = "") {
704
707
  const gh = ghBinary || resolveGithubCliBinaryPath();
705
708
  if (!gh) {
@@ -747,6 +750,21 @@ var GITHUB_KNOWN_HOSTS = [
747
750
  "github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk="
748
751
  ].join(`
749
752
  `);
753
+ function resolveControlPlaneSourceRoot(projectRoot) {
754
+ const candidates = [
755
+ process.env.RIG_CONTROL_PLANE_SOURCE_ROOT?.trim(),
756
+ process.env.RIG_HOST_PROJECT_ROOT?.trim(),
757
+ resolve7(import.meta.dir, "../../../../.."),
758
+ projectRoot
759
+ ].filter((value) => Boolean(value));
760
+ for (const candidate of candidates) {
761
+ const root = resolve7(candidate);
762
+ if (existsSync6(resolve7(root, "packages/runtime/src/control-plane/pi-sessiond/bin.ts"))) {
763
+ return root;
764
+ }
765
+ }
766
+ return "";
767
+ }
750
768
  async function runtimeEnv(projectRoot, runtime) {
751
769
  const bunBinaryPath = resolveBunBinaryPath();
752
770
  const bunDir = resolveBunInstallDir(bunBinaryPath);
@@ -792,14 +810,18 @@ async function runtimeEnv(projectRoot, runtime) {
792
810
  const runtimeRigGit = resolve7(runtime.binDir, runtimeRigGitFileName());
793
811
  const preferredShell = existsSync6(runtimeBash) ? runtimeBash : "/bin/bash";
794
812
  const nativeRuntimeLibraryPath = await materializeNativeRuntimeLibrary(runtime.binDir);
813
+ const controlPlaneSourceRoot = resolveControlPlaneSourceRoot(projectRoot);
795
814
  const env = {
796
815
  PROJECT_RIG_ROOT: projectRoot,
797
816
  RIG_HOST_PROJECT_ROOT: projectRoot,
817
+ ...controlPlaneSourceRoot ? { RIG_CONTROL_PLANE_SOURCE_ROOT: controlPlaneSourceRoot } : {},
798
818
  HOME: runtime.homeDir,
799
819
  TMPDIR: runtime.tmpDir,
800
820
  XDG_CACHE_HOME: runtime.cacheDir,
801
821
  XDG_STATE_HOME: runtime.stateDir,
802
822
  RIG_AGENT_ID: runtime.id,
823
+ ...process.env.RIG_RUN_ID?.trim() ? { RIG_RUN_ID: process.env.RIG_RUN_ID.trim() } : {},
824
+ ...process.env.RIG_SERVER_RUN_ID?.trim() ? { RIG_SERVER_RUN_ID: process.env.RIG_SERVER_RUN_ID.trim() } : {},
803
825
  RIG_TASK_ID: runtime.taskId,
804
826
  RIG_TASK_RUNTIME_ID: runtime.id,
805
827
  RIG_TASK_WORKSPACE: runtime.workspaceDir,