@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
@@ -2091,20 +2091,23 @@ function taskRuntimeId(taskId) {
2091
2091
  }
2092
2092
  function resolveGithubCliBinaryPath() {
2093
2093
  const explicit = process.env.RIG_GH_BIN?.trim();
2094
- if (explicit && existsSync8(explicit)) {
2094
+ if (explicit && existsSync8(explicit) && !isRuntimeGatewayGhPath(explicit)) {
2095
2095
  return explicit;
2096
2096
  }
2097
- const bunResolved = Bun.which("gh");
2098
- if (bunResolved && existsSync8(bunResolved)) {
2099
- return bunResolved;
2100
- }
2101
- for (const candidate of ["/opt/homebrew/bin/gh", "/usr/local/bin/gh", "/usr/bin/gh"]) {
2097
+ for (const candidate of ["/usr/bin/gh", "/opt/homebrew/bin/gh", "/usr/local/bin/gh"]) {
2102
2098
  if (existsSync8(candidate)) {
2103
2099
  return candidate;
2104
2100
  }
2105
2101
  }
2102
+ const bunResolved = Bun.which("gh");
2103
+ if (bunResolved && existsSync8(bunResolved) && !isRuntimeGatewayGhPath(bunResolved)) {
2104
+ return bunResolved;
2105
+ }
2106
2106
  return "";
2107
2107
  }
2108
+ function isRuntimeGatewayGhPath(candidate) {
2109
+ return /\/\.rig\/bin\/gh$/.test(candidate.replace(/\\/g, "/"));
2110
+ }
2108
2111
  async function resolveGithubCliAuthToken(ghBinary = "") {
2109
2112
  const gh = ghBinary || resolveGithubCliBinaryPath();
2110
2113
  if (!gh) {
@@ -2145,6 +2148,21 @@ var GITHUB_KNOWN_HOSTS = [
2145
2148
  "github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk="
2146
2149
  ].join(`
2147
2150
  `);
2151
+ function resolveControlPlaneSourceRoot(projectRoot) {
2152
+ const candidates = [
2153
+ process.env.RIG_CONTROL_PLANE_SOURCE_ROOT?.trim(),
2154
+ process.env.RIG_HOST_PROJECT_ROOT?.trim(),
2155
+ resolve11(import.meta.dir, "../../../../.."),
2156
+ projectRoot
2157
+ ].filter((value) => Boolean(value));
2158
+ for (const candidate of candidates) {
2159
+ const root = resolve11(candidate);
2160
+ if (existsSync9(resolve11(root, "packages/runtime/src/control-plane/pi-sessiond/bin.ts"))) {
2161
+ return root;
2162
+ }
2163
+ }
2164
+ return "";
2165
+ }
2148
2166
  async function runtimeEnv(projectRoot, runtime) {
2149
2167
  const bunBinaryPath = resolveBunBinaryPath();
2150
2168
  const bunDir = resolveBunInstallDir(bunBinaryPath);
@@ -2190,14 +2208,18 @@ async function runtimeEnv(projectRoot, runtime) {
2190
2208
  const runtimeRigGit = resolve11(runtime.binDir, runtimeRigGitFileName());
2191
2209
  const preferredShell = existsSync9(runtimeBash) ? runtimeBash : "/bin/bash";
2192
2210
  const nativeRuntimeLibraryPath = await materializeNativeRuntimeLibrary(runtime.binDir);
2211
+ const controlPlaneSourceRoot = resolveControlPlaneSourceRoot(projectRoot);
2193
2212
  const env = {
2194
2213
  PROJECT_RIG_ROOT: projectRoot,
2195
2214
  RIG_HOST_PROJECT_ROOT: projectRoot,
2215
+ ...controlPlaneSourceRoot ? { RIG_CONTROL_PLANE_SOURCE_ROOT: controlPlaneSourceRoot } : {},
2196
2216
  HOME: runtime.homeDir,
2197
2217
  TMPDIR: runtime.tmpDir,
2198
2218
  XDG_CACHE_HOME: runtime.cacheDir,
2199
2219
  XDG_STATE_HOME: runtime.stateDir,
2200
2220
  RIG_AGENT_ID: runtime.id,
2221
+ ...process.env.RIG_RUN_ID?.trim() ? { RIG_RUN_ID: process.env.RIG_RUN_ID.trim() } : {},
2222
+ ...process.env.RIG_SERVER_RUN_ID?.trim() ? { RIG_SERVER_RUN_ID: process.env.RIG_SERVER_RUN_ID.trim() } : {},
2201
2223
  RIG_TASK_ID: runtime.taskId,
2202
2224
  RIG_TASK_RUNTIME_ID: runtime.id,
2203
2225
  RIG_TASK_WORKSPACE: runtime.workspaceDir,
@@ -417,20 +417,23 @@ function hashProjectPath(workspaceDir) {
417
417
  }
418
418
  function resolveGithubCliBinaryPath() {
419
419
  const explicit = process.env.RIG_GH_BIN?.trim();
420
- if (explicit && existsSync3(explicit)) {
420
+ if (explicit && existsSync3(explicit) && !isRuntimeGatewayGhPath(explicit)) {
421
421
  return explicit;
422
422
  }
423
- const bunResolved = Bun.which("gh");
424
- if (bunResolved && existsSync3(bunResolved)) {
425
- return bunResolved;
426
- }
427
- for (const candidate of ["/opt/homebrew/bin/gh", "/usr/local/bin/gh", "/usr/bin/gh"]) {
423
+ for (const candidate of ["/usr/bin/gh", "/opt/homebrew/bin/gh", "/usr/local/bin/gh"]) {
428
424
  if (existsSync3(candidate)) {
429
425
  return candidate;
430
426
  }
431
427
  }
428
+ const bunResolved = Bun.which("gh");
429
+ if (bunResolved && existsSync3(bunResolved) && !isRuntimeGatewayGhPath(bunResolved)) {
430
+ return bunResolved;
431
+ }
432
432
  return "";
433
433
  }
434
+ function isRuntimeGatewayGhPath(candidate) {
435
+ return /\/\.rig\/bin\/gh$/.test(candidate.replace(/\\/g, "/"));
436
+ }
434
437
  async function resolveGithubCliAuthToken(ghBinary = "") {
435
438
  const gh = ghBinary || resolveGithubCliBinaryPath();
436
439
  if (!gh) {