@h-rig/run-worker 0.0.6-alpha.157 → 0.0.6-alpha.159
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.
- package/dist/src/autohost.d.ts +8 -10
- package/dist/src/autohost.js +683 -95
- package/dist/src/constants.d.ts +0 -1
- package/dist/src/constants.js +0 -2
- package/dist/src/extension.js +683 -95
- package/dist/src/host-kernel.d.ts +22 -0
- package/dist/src/host-kernel.js +78 -0
- package/dist/src/host.d.ts +2 -0
- package/dist/src/host.js +419 -0
- package/dist/src/index.d.ts +0 -6
- package/dist/src/index.js +1913 -133
- package/dist/src/local-run-changes.d.ts +3 -0
- package/dist/src/local-run-changes.js +65 -0
- package/dist/src/notifications.js +13 -5
- package/dist/src/notify-cap.d.ts +11 -0
- package/dist/src/notify-cap.js +13 -0
- package/dist/src/panel-plugin.js +3 -7
- package/dist/src/plugin.d.ts +0 -11
- package/dist/src/plugin.js +1910 -101
- package/dist/src/{runs → read-model-backend}/control.d.ts +0 -1
- package/dist/src/{runs → read-model-backend}/control.js +361 -38
- package/dist/src/{runs → read-model-backend}/diagnostics.d.ts +0 -1
- package/dist/src/{runs → read-model-backend}/diagnostics.js +1 -3
- package/dist/src/{runs → read-model-backend}/guard.js +2 -3
- package/dist/src/{runs → read-model-backend}/inbox.js +366 -36
- package/dist/src/{runs → read-model-backend}/index.js +552 -223
- package/dist/src/{runs → read-model-backend}/inspect.d.ts +0 -1
- package/dist/src/{runs → read-model-backend}/inspect.js +350 -34
- package/dist/src/{runs → read-model-backend}/projection.d.ts +21 -7
- package/dist/src/{runs → read-model-backend}/projection.js +349 -31
- package/dist/src/{runs → read-model-backend}/run-status.d.ts +6 -3
- package/dist/src/{runs → read-model-backend}/run-status.js +53 -33
- package/dist/src/{runs → read-model-backend}/stats.d.ts +0 -1
- package/dist/src/{runs → read-model-backend}/stats.js +373 -58
- package/dist/src/read-model-service.d.ts +2 -0
- package/dist/src/read-model-service.js +1433 -0
- package/dist/src/session-journal.d.ts +60 -0
- package/dist/src/session-journal.js +471 -0
- package/dist/src/stall.d.ts +8 -3
- package/dist/src/stall.js +0 -1
- package/dist/src/utils.js +282 -3
- package/package.json +9 -12
- package/dist/src/journal.d.ts +0 -33
- package/dist/src/journal.js +0 -31
- /package/dist/src/{runs → read-model-backend}/guard.d.ts +0 -0
- /package/dist/src/{runs → read-model-backend}/inbox.d.ts +0 -0
- /package/dist/src/{runs → read-model-backend}/index.d.ts +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/run-worker/src/local-run-changes.ts
|
|
3
|
+
import { existsSync, mkdirSync, watch } from "fs";
|
|
4
|
+
import { dirname, resolve } from "path";
|
|
5
|
+
import { Effect, Queue, Stream } from "effect";
|
|
6
|
+
function findNearestGitCheckoutRoot(startDir) {
|
|
7
|
+
let current = resolve(startDir);
|
|
8
|
+
for (;; ) {
|
|
9
|
+
if (existsSync(resolve(current, ".git")))
|
|
10
|
+
return current;
|
|
11
|
+
const parent = dirname(current);
|
|
12
|
+
if (parent === current)
|
|
13
|
+
return null;
|
|
14
|
+
current = parent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function resolveCheckoutRoot(projectRoot) {
|
|
18
|
+
const normalizedProjectRoot = resolve(projectRoot);
|
|
19
|
+
const explicit = process.env.MONOREPO_ROOT?.trim();
|
|
20
|
+
if (explicit) {
|
|
21
|
+
const explicitRoot = resolve(explicit);
|
|
22
|
+
const gitRoot = findNearestGitCheckoutRoot(explicitRoot);
|
|
23
|
+
if (gitRoot)
|
|
24
|
+
return gitRoot;
|
|
25
|
+
throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there or above it.`);
|
|
26
|
+
}
|
|
27
|
+
return findNearestGitCheckoutRoot(normalizedProjectRoot) ?? normalizedProjectRoot;
|
|
28
|
+
}
|
|
29
|
+
function isRelevantLocalRunChange(filename) {
|
|
30
|
+
if (filename === null || filename === undefined)
|
|
31
|
+
return true;
|
|
32
|
+
const raw = filename.toString();
|
|
33
|
+
if (!raw.trim())
|
|
34
|
+
return true;
|
|
35
|
+
const segments = raw.split(/[\\/]+/).filter(Boolean);
|
|
36
|
+
if (segments.some((segment) => segment === ".git" || segment === "node_modules" || segment === "build" || segment === "dist" || segment === "out" || segment === ".next" || segment === "coverage")) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const rigIndex = segments.lastIndexOf(".rig");
|
|
40
|
+
if (rigIndex < 0)
|
|
41
|
+
return false;
|
|
42
|
+
const rigChild = segments[rigIndex + 1];
|
|
43
|
+
if (rigChild === "session")
|
|
44
|
+
return true;
|
|
45
|
+
return rigChild === "runtime-context.json" && segments[rigIndex + 2] === undefined;
|
|
46
|
+
}
|
|
47
|
+
var localRunChanges = (projectRoot) => Stream.callback((queue) => Effect.gen(function* () {
|
|
48
|
+
const worktreesRoot = resolve(resolveCheckoutRoot(projectRoot), ".worktrees");
|
|
49
|
+
if (!existsSync(worktreesRoot)) {
|
|
50
|
+
try {
|
|
51
|
+
mkdirSync(worktreesRoot, { recursive: true });
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
const watcher = watch(worktreesRoot, { recursive: true }, (_event, filename) => {
|
|
55
|
+
if (!isRelevantLocalRunChange(filename))
|
|
56
|
+
return;
|
|
57
|
+
Queue.offerUnsafe(queue, undefined);
|
|
58
|
+
});
|
|
59
|
+
watcher.on("error", () => {});
|
|
60
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => watcher.close()));
|
|
61
|
+
}), { bufferSize: 1, strategy: "sliding" });
|
|
62
|
+
export {
|
|
63
|
+
localRunChanges,
|
|
64
|
+
isRelevantLocalRunChange
|
|
65
|
+
};
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/run-worker/src/notify-cap.ts
|
|
3
|
+
import { NOTIFY_SERVICE_CAPABILITY } from "@rig/contracts";
|
|
4
|
+
import { defineCapability } from "@rig/core/capability";
|
|
5
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
6
|
+
var NotifyCap = defineCapability(NOTIFY_SERVICE_CAPABILITY);
|
|
7
|
+
async function resolveNotifyService(projectRoot) {
|
|
8
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
9
|
+
return NotifyCap.resolve(host);
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
// packages/run-worker/src/notifications.ts
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import { dispatchEventToTargets, loadNotificationConfig } from "@rig/notifications-plugin/notifications";
|
|
5
13
|
async function dispatchRunNotifications(projectRoot, runId, taskId, outcome, detail) {
|
|
6
14
|
try {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
15
|
+
const notifier = await resolveNotifyService(projectRoot);
|
|
16
|
+
if (!notifier)
|
|
9
17
|
return;
|
|
10
18
|
const event = { runId, type: `run.${outcome}`, timestamp: new Date().toISOString(), payload: { taskId, detail } };
|
|
11
19
|
await Promise.race([
|
|
12
|
-
|
|
20
|
+
notifier.notify(event),
|
|
13
21
|
new Promise((resolveCap) => setTimeout(resolveCap, 5000))
|
|
14
22
|
]);
|
|
15
23
|
} catch {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-plugin seam: run-exec dispatches run notifications off the host's
|
|
3
|
+
* NOTIFY capability instead of importing `@rig/notifications-plugin`'s impl
|
|
4
|
+
* (`dispatchEventToTargets`/`loadNotificationConfig`). `@rig/notifications-plugin`
|
|
5
|
+
* OWNS the policy (target selection + `.rig/notifications.json` load) and
|
|
6
|
+
* registers it under {@link NOTIFY_SERVICE_CAPABILITY}; this module is the
|
|
7
|
+
* run-exec-side resolver so no run-exec file imports the provider impl.
|
|
8
|
+
*/
|
|
9
|
+
import { type NotifyService } from "@rig/contracts";
|
|
10
|
+
/** Resolve the notify service from the project's plugin host, or `null` if unregistered. */
|
|
11
|
+
export declare function resolveNotifyService(projectRoot: string): Promise<NotifyService | null>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/run-worker/src/notify-cap.ts
|
|
3
|
+
import { NOTIFY_SERVICE_CAPABILITY } from "@rig/contracts";
|
|
4
|
+
import { defineCapability } from "@rig/core/capability";
|
|
5
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
6
|
+
var NotifyCap = defineCapability(NOTIFY_SERVICE_CAPABILITY);
|
|
7
|
+
async function resolveNotifyService(projectRoot) {
|
|
8
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
9
|
+
return NotifyCap.resolve(host);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
resolveNotifyService
|
|
13
|
+
};
|
package/dist/src/panel-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/run-worker/src/panel-plugin.ts
|
|
3
|
-
import { createProjectPluginHost
|
|
3
|
+
import { createProjectPluginHost } from "@rig/core/project-plugins";
|
|
4
4
|
import { RIG_CAPABILITY_PANEL_SLOT, RIG_RUN_STOP_PANEL_ACTION, RIG_SUPERVISOR_PANEL_ID } from "@rig/contracts";
|
|
5
5
|
var RIG_PANELS_CUSTOM_MESSAGE_TYPE = "rig-panels";
|
|
6
6
|
var PANEL_PRODUCER_TIMEOUT_MS = 2000;
|
|
@@ -20,13 +20,9 @@ async function produceWorkerPanelPayload(producer, context) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
async function loadWorkerPanelRegistry(projectRoot) {
|
|
23
|
-
const { host
|
|
24
|
-
mode: "strict-config-only"
|
|
25
|
-
surfaceName: "run-worker-panel-registry"
|
|
23
|
+
const { host } = await createProjectPluginHost(projectRoot, {
|
|
24
|
+
mode: "strict-config-only"
|
|
26
25
|
});
|
|
27
|
-
for (const message of projectPluginResolutionWarningMessages(resolved)) {
|
|
28
|
-
console.warn(`[rig-run] ${message}`);
|
|
29
|
-
}
|
|
30
26
|
return {
|
|
31
27
|
registrations: host.listPanels().filter((registration) => registration.slot === RIG_CAPABILITY_PANEL_SLOT),
|
|
32
28
|
producers: host.listExecutablePanels().filter((registration) => registration.slot === RIG_CAPABILITY_PANEL_SLOT)
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import { type RigPlugin } from "@rig/core/config";
|
|
2
|
-
/**
|
|
3
|
-
* The run lifecycle is a real plugin contribution: it installs the run-worker
|
|
4
|
-
* session extension (plan→implement→validate→commit→PR→merge→closeout) into
|
|
5
|
-
* an agent session.
|
|
6
|
-
*
|
|
7
|
-
* CRITICAL: `install` lazily `await import("./extension")` rather than a
|
|
8
|
-
* top-level import so that config-time evaluation of this plugin does NOT drag
|
|
9
|
-
* the heavy autohost execution stack into every plugin-host load (architecture
|
|
10
|
-
* §8). The heavy module is only pulled in when an agent session actually
|
|
11
|
-
* installs the extension.
|
|
12
|
-
*/
|
|
13
2
|
export declare const runWorkerPlugin: RigPlugin;
|
|
14
3
|
export declare function createRunWorkerPlugin(): RigPlugin;
|