feat: add pluggable agent harness registry

This commit is contained in:
Peter Steinberger
2026-04-10 13:49:45 +01:00
parent fa97004ee1
commit 44ec4d05de
46 changed files with 1030 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
import { listAgentHarnessIds } from "../agents/harness/registry.js";
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
import {
clearInternalHooks,
@@ -1452,6 +1453,49 @@ module.exports = { id: "throws-after-import", register() {} };`,
clearPluginCommands();
});
it("clears plugin agent harnesses during activating reloads", () => {
useNoBundledPlugins();
const plugin = writePlugin({
id: "codex-harness",
filename: "codex-harness.cjs",
body: `module.exports = {
id: "codex-harness",
register(api) {
api.registerAgentHarness({
id: "codex",
label: "Codex",
supports: () => ({ supported: true }),
runAttempt: async () => ({ ok: false, error: "unused" }),
});
},
};`,
});
loadOpenClawPlugins({
cache: false,
workspaceDir: plugin.dir,
config: {
plugins: {
load: { paths: [plugin.file] },
allow: ["codex-harness"],
},
},
onlyPluginIds: ["codex-harness"],
});
expect(listAgentHarnessIds()).toEqual(["codex"]);
loadOpenClawPlugins({
cache: false,
workspaceDir: makeTempDir(),
config: {
plugins: {
allow: [],
},
},
});
expect(listAgentHarnessIds()).toEqual([]);
});
it("does not register internal hooks globally during non-activating loads", () => {
useNoBundledPlugins();
const plugin = writePlugin({