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:
75
plugins/fusion-plugin-openclaw-runtime/README.md
Normal file
75
plugins/fusion-plugin-openclaw-runtime/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# OpenClaw Runtime Plugin
|
||||
|
||||
> **Status:** Experimental placeholder - runtime execution deferred
|
||||
|
||||
Provides an OpenClaw runtime plugin for Fusion. This package enables runtime registration and discovery so agents can be configured with `runtimeConfig.runtimeHint: "openclaw"`.
|
||||
|
||||
## Overview
|
||||
|
||||
This plugin mirrors the Hermes runtime plugin pattern: runtime registration succeeds and can be discovered by Fusion's runtime resolver, while execution behavior is intentionally deferred.
|
||||
|
||||
## Installation
|
||||
|
||||
### Option 1: Copy to plugins directory
|
||||
|
||||
```bash
|
||||
cp -r fusion-plugin-openclaw-runtime ~/.fusion/plugins/
|
||||
```
|
||||
|
||||
### Option 2: Install via CLI
|
||||
|
||||
```bash
|
||||
fn plugin add ./plugins/fusion-plugin-openclaw-runtime
|
||||
```
|
||||
|
||||
## Current Status
|
||||
|
||||
| Component | Status |
|
||||
|-----------|--------|
|
||||
| Plugin Scaffold | ✅ Complete |
|
||||
| Runtime Registration | ✅ Complete |
|
||||
| Runtime Discovery | ✅ Complete |
|
||||
| Runtime Execution | ⏳ Deferred placeholder |
|
||||
|
||||
## Runtime Metadata
|
||||
|
||||
- **Plugin ID:** `fusion-plugin-openclaw-runtime`
|
||||
- **Package name:** `@fusion-plugin-examples/openclaw-runtime`
|
||||
- **Runtime ID:** `openclaw`
|
||||
- **Runtime name:** `OpenClaw Runtime`
|
||||
- **Version:** `0.1.0`
|
||||
- **Description:** Experimental OpenClaw runtime integration for Fusion tasks (execution deferred)
|
||||
|
||||
## Agent Configuration
|
||||
|
||||
Configure an agent to target OpenClaw via `runtimeConfig.runtimeHint`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "OpenClaw Executor",
|
||||
"role": "executor",
|
||||
"runtimeConfig": {
|
||||
"runtimeHint": "openclaw"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Placeholder Runtime Behavior
|
||||
|
||||
The runtime factory currently returns a deferred placeholder object:
|
||||
|
||||
- Runtime registration and lookup are supported
|
||||
- Runtime factory invocation succeeds
|
||||
- `execute()` intentionally throws a descriptive not-implemented/deferred error
|
||||
|
||||
This prevents silent misbehavior while making runtime configuration and compatibility tests possible.
|
||||
|
||||
## Local Development
|
||||
|
||||
```bash
|
||||
# Run plugin tests
|
||||
pnpm --filter @fusion-plugin-examples/openclaw-runtime test
|
||||
|
||||
# Build plugin output to dist/
|
||||
pnpm --filter @fusion-plugin-examples/openclaw-runtime build
|
||||
```
|
||||
2
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.d.ts
vendored
Normal file
2
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=index.test.d.ts.map
|
||||
1
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.d.ts.map
vendored
Normal file
1
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
|
||||
92
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.js
vendored
Normal file
92
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.js
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import plugin, { openclawRuntimeMetadata, openclawRuntimeFactory, OPENCLAW_RUNTIME_ID } from "../index.js";
|
||||
function createMockContext(overrides = {}) {
|
||||
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);
|
||||
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());
|
||||
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());
|
||||
await expect(runtime.execute()).rejects.toThrow("not implemented");
|
||||
await expect(runtime.execute()).rejects.toThrow("deferred");
|
||||
});
|
||||
it("factory creation should not throw", () => {
|
||||
expect(() => openclawRuntimeFactory(createMockContext())).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=index.test.js.map
|
||||
1
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.js.map
vendored
Normal file
1
plugins/fusion-plugin-openclaw-runtime/dist/__tests__/index.test.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names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C5B,SAAS,EAAE,UAAU;gBACrB,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,UAAU;aACnB,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;YAC9E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;YACjF,MAAM,OAAO,GAAG,sBAAsB,CAAC,iBAAiB,EAAS,CAAsC,CAAC;YACxG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YACnE,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,iBAAiB,EAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||
14
plugins/fusion-plugin-openclaw-runtime/dist/index.d.ts
vendored
Normal file
14
plugins/fusion-plugin-openclaw-runtime/dist/index.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* OpenClaw Runtime Plugin
|
||||
*
|
||||
* Registers an experimental OpenClaw runtime with Fusion's plugin runtime
|
||||
* discovery pipeline. Runtime execution behavior is intentionally deferred.
|
||||
*/
|
||||
import type { FusionPlugin, PluginRuntimeFactory, PluginRuntimeManifestMetadata } from "@fusion/plugin-sdk";
|
||||
declare const OPENCLAW_RUNTIME_ID = "openclaw";
|
||||
declare const openclawRuntimeMetadata: PluginRuntimeManifestMetadata;
|
||||
declare const openclawRuntimeFactory: PluginRuntimeFactory;
|
||||
declare const plugin: FusionPlugin;
|
||||
export default plugin;
|
||||
export { openclawRuntimeMetadata, openclawRuntimeFactory, OPENCLAW_RUNTIME_ID };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
plugins/fusion-plugin-openclaw-runtime/dist/index.d.ts.map
vendored
Normal file
1
plugins/fusion-plugin-openclaw-runtime/dist/index.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EAEZ,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,oBAAoB,CAAC;AAE5B,QAAA,MAAM,mBAAmB,aAAa,CAAC;AAGvC,QAAA,MAAM,uBAAuB,EAAE,6BAK9B,CAAC;AAEF,QAAA,MAAM,sBAAsB,EAAE,oBAa7B,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,YA4BZ,CAAC;AAEH,eAAe,MAAM,CAAC;AAEtB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,CAAC"}
|
||||
58
plugins/fusion-plugin-openclaw-runtime/dist/index.js
vendored
Normal file
58
plugins/fusion-plugin-openclaw-runtime/dist/index.js
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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";
|
||||
const OPENCLAW_RUNTIME_ID = "openclaw";
|
||||
const OPENCLAW_RUNTIME_VERSION = "0.1.0";
|
||||
const openclawRuntimeMetadata = {
|
||||
runtimeId: OPENCLAW_RUNTIME_ID,
|
||||
name: "OpenClaw Runtime",
|
||||
description: "Experimental OpenClaw runtime integration for Fusion tasks (execution deferred)",
|
||||
version: OPENCLAW_RUNTIME_VERSION,
|
||||
};
|
||||
const openclawRuntimeFactory = (_ctx) => {
|
||||
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 = 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 };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
plugins/fusion-plugin-openclaw-runtime/dist/index.js.map
vendored
Normal file
1
plugins/fusion-plugin-openclaw-runtime/dist/index.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,MAAM,mBAAmB,GAAG,UAAU,CAAC;AACvC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,MAAM,uBAAuB,GAAkC;IAC7D,SAAS,EAAE,mBAAmB;IAC9B,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,iFAAiF;IAC9F,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,MAAM,sBAAsB,GAAyB,CAAC,IAAmB,EAAE,EAAE;IAC3E,OAAO;QACL,SAAS,EAAE,mBAAmB;QAC9B,OAAO,EAAE,wBAAwB;QACjC,MAAM,EAAE,UAAU;QAClB,OAAO,EACL,oHAAoH;QACtH,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,IAAI,KAAK,CACb,wHAAwH,CACzH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAiB,YAAY,CAAC;IACxC,QAAQ,EAAE;QACR,EAAE,EAAE,gCAAgC;QACpC,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,yEAAyE;QACtF,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,kCAAkC;QAC5C,OAAO,EAAE,uBAAuB;KACjC;IACD,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;YACd,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;YACrF,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE;gBACvC,SAAS,EAAE,mBAAmB;gBAC9B,OAAO,EAAE,wBAAwB;gBACjC,MAAM,EAAE,UAAU;aACnB,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,qCAAqC;QACvC,CAAC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,uBAAuB;QACjC,OAAO,EAAE,sBAAsB;KAChC;CACF,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC;AAEtB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,CAAC"}
|
||||
14
plugins/fusion-plugin-openclaw-runtime/manifest.json
Normal file
14
plugins/fusion-plugin-openclaw-runtime/manifest.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"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": {
|
||||
"runtimeId": "openclaw",
|
||||
"name": "OpenClaw Runtime",
|
||||
"description": "Experimental OpenClaw runtime integration for Fusion tasks (execution deferred)",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
}
|
||||
31
plugins/fusion-plugin-openclaw-runtime/package.json
Normal file
31
plugins/fusion-plugin-openclaw-runtime/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@fusion-plugin-examples/openclaw-runtime",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"description": "OpenClaw runtime plugin for Fusion - experimental placeholder runtime registration",
|
||||
"keywords": [
|
||||
"fusion-plugin",
|
||||
"openclaw",
|
||||
"runtime",
|
||||
"experimental"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "vitest run --silent=passed-only --reporter=dot"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fusion/plugin-sdk": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.5.2",
|
||||
"typescript": "^5.7.0",
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
73
plugins/fusion-plugin-openclaw-runtime/src/index.ts
Normal file
73
plugins/fusion-plugin-openclaw-runtime/src/index.ts
Normal 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 };
|
||||
9
plugins/fusion-plugin-openclaw-runtime/tsconfig.json
Normal file
9
plugins/fusion-plugin-openclaw-runtime/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"types": ["node", "vitest/globals"]
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
14
plugins/fusion-plugin-openclaw-runtime/vitest.config.ts
Normal file
14
plugins/fusion-plugin-openclaw-runtime/vitest.config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? "2", 10);
|
||||
const maxWorkers = Math.max(1, Math.min(4, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : 2));
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ["src/**/*.test.ts"],
|
||||
pool: "threads",
|
||||
maxWorkers,
|
||||
poolOptions: { threads: { minThreads: 1, maxThreads: maxWorkers }, forks: { minForks: 1, maxForks: maxWorkers } },
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user