feat(FN-2347): add experimental OpenClaw runtime plugin scaffold

- Add fusion-plugin-openclaw-runtime workspace package with manifest, runtime metadata, and deferred placeholder factory
- Add unit tests for OpenClaw plugin behavior and PluginRunner runtime discovery compatibility
- Document OpenClaw runtime installation and runtimeHint usage in README, getting-started, and settings reference docs
- Include built dist artifacts for the new plugin and update workspace/lockfile entries
This commit is contained in:
Fusion
2026-04-23 14:03:35 -07:00
committed by gsxdsm
parent 79d00604ae
commit ce8cf6337a
21 changed files with 693 additions and 9 deletions

View File

@@ -0,0 +1,124 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import plugin, { openclawRuntimeMetadata, openclawRuntimeFactory, OPENCLAW_RUNTIME_ID } from "../index.js";
interface MockLogger {
info: ReturnType<typeof vi.fn>;
warn: ReturnType<typeof vi.fn>;
error: ReturnType<typeof vi.fn>;
debug: ReturnType<typeof vi.fn>;
}
interface MockContext {
pluginId: string;
settings: Record<string, unknown>;
logger: MockLogger;
emitEvent: ReturnType<typeof vi.fn>;
taskStore: {
getTask: ReturnType<typeof vi.fn>;
};
}
function createMockContext(overrides: Partial<MockContext> = {}): MockContext {
return {
pluginId: "fusion-plugin-openclaw-runtime",
settings: {},
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
},
emitEvent: vi.fn(),
taskStore: {
getTask: vi.fn(),
},
...overrides,
};
}
describe("openclaw-runtime plugin", () => {
beforeEach(() => {
vi.clearAllMocks();
});
afterEach(() => {
vi.restoreAllMocks();
});
describe("plugin manifest identity", () => {
it("should have correct manifest fields", () => {
expect(plugin.manifest.id).toBe("fusion-plugin-openclaw-runtime");
expect(plugin.manifest.name).toBe("OpenClaw Runtime Plugin");
expect(plugin.manifest.version).toBe("0.1.0");
expect(plugin.manifest.description).toContain("OpenClaw");
expect(plugin.manifest.author).toBe("Fusion Team");
expect(plugin.state).toBe("installed");
});
});
describe("runtime registration", () => {
it("should register openclaw runtime metadata", () => {
expect(plugin.runtime).toBeDefined();
expect(plugin.runtime?.metadata.runtimeId).toBe(OPENCLAW_RUNTIME_ID);
expect(plugin.runtime?.metadata.name).toBe("OpenClaw Runtime");
expect(plugin.runtime?.metadata.description).toContain("execution deferred");
expect(plugin.runtime?.metadata.version).toBe("0.1.0");
});
it("should have consistent runtime metadata between export and manifest", () => {
expect(plugin.manifest.runtime).toEqual(openclawRuntimeMetadata);
expect(plugin.runtime?.metadata).toEqual(openclawRuntimeMetadata);
});
});
describe("hooks", () => {
it("onLoad should log startup message and emit loaded event", async () => {
const ctx = createMockContext();
await plugin.hooks.onLoad?.(ctx as any);
expect(ctx.logger.info).toHaveBeenCalledWith(
expect.stringContaining("OpenClaw Runtime Plugin loaded"),
);
expect(ctx.emitEvent).toHaveBeenCalledWith("openclaw-runtime:loaded", {
runtimeId: OPENCLAW_RUNTIME_ID,
version: "0.1.0",
status: "deferred",
});
});
it("onUnload should not throw", () => {
expect(() => plugin.hooks.onUnload?.()).not.toThrow();
});
});
describe("deferred runtime behavior", () => {
it("should export runtime constants", () => {
expect(OPENCLAW_RUNTIME_ID).toBe("openclaw");
expect(openclawRuntimeMetadata.runtimeId).toBe("openclaw");
expect(typeof openclawRuntimeFactory).toBe("function");
});
it("runtime factory should return placeholder runtime shape", () => {
const runtime = openclawRuntimeFactory(createMockContext() as any) as Record<string, unknown>;
expect(runtime).toMatchObject({
runtimeId: "openclaw",
version: "0.1.0",
status: "deferred",
});
expect(runtime).toHaveProperty("message");
expect(String(runtime.message)).toContain("discovery and configuration only");
expect(String(runtime.message)).not.toContain("FN-");
});
it("runtime execute should reject with deferred/not-implemented error", async () => {
const runtime = openclawRuntimeFactory(createMockContext() as any) as { execute: () => Promise<never> };
await expect(runtime.execute()).rejects.toThrow("not implemented");
await expect(runtime.execute()).rejects.toThrow("deferred");
});
it("factory creation should not throw", () => {
expect(() => openclawRuntimeFactory(createMockContext() as any)).not.toThrow();
});
});
});

View File

@@ -0,0 +1,73 @@
/**
* OpenClaw Runtime Plugin
*
* Registers an experimental OpenClaw runtime with Fusion's plugin runtime
* discovery pipeline. Runtime execution behavior is intentionally deferred.
*/
import { definePlugin } from "@fusion/plugin-sdk";
import type {
FusionPlugin,
PluginContext,
PluginRuntimeFactory,
PluginRuntimeManifestMetadata,
} from "@fusion/plugin-sdk";
const OPENCLAW_RUNTIME_ID = "openclaw";
const OPENCLAW_RUNTIME_VERSION = "0.1.0";
const openclawRuntimeMetadata: PluginRuntimeManifestMetadata = {
runtimeId: OPENCLAW_RUNTIME_ID,
name: "OpenClaw Runtime",
description: "Experimental OpenClaw runtime integration for Fusion tasks (execution deferred)",
version: OPENCLAW_RUNTIME_VERSION,
};
const openclawRuntimeFactory: PluginRuntimeFactory = (_ctx: PluginContext) => {
return {
runtimeId: OPENCLAW_RUNTIME_ID,
version: OPENCLAW_RUNTIME_VERSION,
status: "deferred",
message:
"OpenClaw runtime execution is currently deferred. This runtime is registered for discovery and configuration only.",
execute: async () => {
throw new Error(
"OpenClaw runtime is not implemented yet. Runtime discovery and configuration are supported, but execution is deferred.",
);
},
};
};
const plugin: FusionPlugin = definePlugin({
manifest: {
id: "fusion-plugin-openclaw-runtime",
name: "OpenClaw Runtime Plugin",
version: "0.1.0",
description: "OpenClaw runtime plugin for Fusion with experimental deferred execution",
author: "Fusion Team",
homepage: "https://github.com/gsxdsm/fusion",
runtime: openclawRuntimeMetadata,
},
state: "installed",
hooks: {
onLoad: (ctx) => {
ctx.logger.info("OpenClaw Runtime Plugin loaded (experimental placeholder runtime)");
ctx.emitEvent("openclaw-runtime:loaded", {
runtimeId: OPENCLAW_RUNTIME_ID,
version: OPENCLAW_RUNTIME_VERSION,
status: "deferred",
});
},
onUnload: () => {
// No context available during unload
},
},
runtime: {
metadata: openclawRuntimeMetadata,
factory: openclawRuntimeFactory,
},
});
export default plugin;
export { openclawRuntimeMetadata, openclawRuntimeFactory, OPENCLAW_RUNTIME_ID };