feat(FN-2481): align Hermes runtime artifacts and compatibility coverage

- Regenerate fusion-plugin-hermes-runtime build artifacts and manifest metadata for runtime packaging
- Refactor Hermes runtime source into dedicated pi-module, runtime-adapter, and shared type modules
- Expand Hermes and engine plugin-runner tests to validate cross-runtime compatibility behavior
- Update getting-started, settings reference, and Hermes README docs to reflect the current runtime integration guidance
This commit is contained in:
Fusion
2026-04-24 14:44:04 -07:00
committed by gsxdsm
parent 9a84bb1e1a
commit 16959811bc
35 changed files with 753 additions and 287 deletions

View File

@@ -1,34 +1,16 @@
# Hermes Runtime Plugin
> **Status:** Experimental placeholder runtime (current behavior)
Provides an executable Hermes runtime plugin for Fusion. This package enables runtime registration, discovery, and session execution so agents configured with `runtimeConfig.runtimeHint: "hermes"` can run through the standard runtime adapter contract.
Provides a Hermes runtime plugin for Fusion. The plugin is active today for runtime registration/discovery and runtime selection via `runtimeConfig.runtimeHint: "hermes"`.
## Overview
## What it does today
This plugin follows the runtime adapter pattern used by other executable plugin runtimes:
- Registers Hermes runtime metadata with the plugin system
- Exposes a runtime factory that returns a placeholder runtime object
- Emits `hermes-runtime:loaded` on plugin load
- Supports runtime routing with `runtimeHint: "hermes"`
## Current behavior and limitations
This plugin currently provides **registration + placeholder execution semantics**.
- Runtime factory returns an object with:
- `runtimeId: "hermes"`
- `version: "0.1.0"`
- `status: "deferred"`
- `message` describing placeholder/deferred status
- `execute()` function
- Calling `execute()` always throws a not-implemented error.
- Runtime creation itself does **not** throw.
Expected execution failure message includes:
```
Hermes runtime is not yet implemented. Full implementation deferred to FN-2264. See https://github.com/gsxdsm/fusion/issues/FN-2264
```
- Registers Hermes runtime metadata for resolver discovery
- Creates executable runtime sessions via `createFnAgent`
- Delegates prompt execution through `promptWithFallback`
- Exposes model descriptions through `describeModel`
- Supports best-effort session disposal via `dispose()`
## Installation
@@ -44,9 +26,18 @@ cp -r fusion-plugin-hermes-runtime ~/.fusion/plugins/
fn plugin add ./plugins/fusion-plugin-hermes-runtime
```
## Runtime routing (`runtimeHint`)
## Runtime Metadata
To route an agent to Hermes, set `runtimeConfig.runtimeHint` to `"hermes"`:
- **Plugin ID:** `fusion-plugin-hermes-runtime`
- **Package name:** `@fusion-plugin-examples/hermes-runtime`
- **Runtime ID:** `hermes`
- **Runtime name:** `Hermes Runtime`
- **Version:** `0.1.0`
- **Description:** Hermes-backed AI session using the user's configured pi provider and model
## Agent Configuration
Configure an agent to target Hermes via `runtimeConfig.runtimeHint`:
```json
{
@@ -58,66 +49,12 @@ To route an agent to Hermes, set `runtimeConfig.runtimeHint` to `"hermes"`:
}
```
> ⚠️ With the current placeholder runtime, agent/session selection can target Hermes successfully, but runtime `execute()` will throw.
## Source-of-truth metadata
### `manifest.json`
```json
{
"id": "fusion-plugin-hermes-runtime",
"name": "Hermes Runtime Plugin",
"version": "0.1.0",
"description": "Hermes AI runtime plugin for Fusion - provides AI agent execution runtime capabilities",
"author": "Fusion Team",
"homepage": "https://github.com/gsxdsm/fusion",
"runtime": {
"runtimeId": "hermes",
"name": "Hermes Runtime",
"description": "Experimental Hermes runtime integration for Fusion tasks (implementation deferred to FN-2264)",
"version": "0.1.0"
}
}
```
### Runtime metadata (from `src/index.ts`)
- **Runtime ID:** `hermes`
- **Name:** `Hermes Runtime`
- **Version:** `0.1.0`
- **Description:** `Experimental Hermes runtime integration for Fusion tasks (implementation deferred to FN-2264)`
## Development
## Local Development
```bash
# Install dependencies
pnpm install
# Run plugin tests
pnpm --filter @fusion-plugin-examples/hermes-runtime test
# Build
pnpm build
# Build plugin output to dist/
pnpm --filter @fusion-plugin-examples/hermes-runtime build
```
## Test coverage
The plugin tests validate:
- Manifest identity
- Runtime registration + metadata consistency
- Placeholder runtime return shape (`status: "deferred"`)
- `execute()` failure semantics
- Hook behavior (`onLoad`, `onUnload`, event emission)
## Exports
- `default` — plugin instance
- `hermesRuntimeMetadata` — runtime metadata object
- `hermesRuntimeFactory` — runtime factory
- `HERMES_RUNTIME_ID` — runtime ID constant (`"hermes"`)
## License
MIT

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.test.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,94 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
const { mockCreateFnAgent, mockPromptWithFallback, mockDescribeModel } = vi.hoisted(() => ({
mockCreateFnAgent: vi.fn(),
mockPromptWithFallback: vi.fn(),
mockDescribeModel: vi.fn().mockReturnValue("unknown model"),
}));
vi.mock("../pi-module.js", () => ({
createFnAgent: mockCreateFnAgent,
promptWithFallback: mockPromptWithFallback,
describeModel: mockDescribeModel,
}));
import plugin, { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID } from "../index.js";
import { HermesRuntimeAdapter } from "../runtime-adapter.js";
function createMockContext(overrides = {}) {
return {
pluginId: "fusion-plugin-hermes-runtime",
settings: {},
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
},
emitEvent: vi.fn(),
taskStore: {
getTask: vi.fn(),
},
...overrides,
};
}
describe("hermes-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-hermes-runtime");
expect(plugin.manifest.name).toBe("Hermes Runtime Plugin");
expect(plugin.manifest.version).toBe("0.1.0");
expect(plugin.manifest.description).toContain("Hermes");
expect(plugin.manifest.author).toBe("Fusion Team");
expect(plugin.state).toBe("installed");
});
});
describe("runtime registration", () => {
it("should register hermes runtime metadata", () => {
expect(plugin.runtime).toBeDefined();
expect(plugin.runtime?.metadata.runtimeId).toBe(HERMES_RUNTIME_ID);
expect(plugin.runtime?.metadata.name).toBe("Hermes Runtime");
expect(plugin.runtime?.metadata.description).toContain("Hermes-backed AI session");
expect(plugin.runtime?.metadata.version).toBe("0.1.0");
});
it("should have consistent runtime metadata between export and manifest", () => {
expect(plugin.manifest.runtime).toEqual(hermesRuntimeMetadata);
expect(plugin.runtime?.metadata).toEqual(hermesRuntimeMetadata);
});
});
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("Hermes Runtime Plugin loaded");
expect(ctx.emitEvent).toHaveBeenCalledWith("hermes-runtime:loaded", {
runtimeId: HERMES_RUNTIME_ID,
version: "0.1.0",
});
});
it("onUnload should not throw", () => {
expect(() => plugin.hooks.onUnload?.()).not.toThrow();
});
});
describe("runtime factory behavior", () => {
it("should export runtime constants", () => {
expect(HERMES_RUNTIME_ID).toBe("hermes");
expect(hermesRuntimeMetadata.runtimeId).toBe("hermes");
expect(typeof hermesRuntimeFactory).toBe("function");
});
it("runtime factory should return executable runtime adapter", async () => {
const runtime = (await hermesRuntimeFactory(createMockContext()));
expect(runtime).toBeInstanceOf(HermesRuntimeAdapter);
expect(runtime.id).toBe("hermes");
expect(runtime.name).toBe("Hermes Runtime");
expect(runtime).not.toHaveProperty("status");
expect(runtime).not.toHaveProperty("execute");
});
it("factory creation should not throw", async () => {
await expect(hermesRuntimeFactory(createMockContext())).resolves.toBeInstanceOf(HermesRuntimeAdapter);
});
});
});
//# sourceMappingURL=index.test.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzE,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzF,iBAAiB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC1B,sBA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ACvD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;YACxE,MAAM,OAAO,GAAG,CAAC,MAAM,oBAAoB,CAAC,iBAAiB,EAAS,CAAC,CAAyB,CAAC;YAEjG,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YACrD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;YACjD,MAAM,MAAM,CAAC,oBAAoB,CAAC,iBAAiB,EAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CACpF,oBAAoB,CACrB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=runtime-adapter.test.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime-adapter.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/runtime-adapter.test.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,80 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { HermesRuntimeAdapter } from "../runtime-adapter.js";
const { mockCreateFnAgent, mockPromptWithFallback, mockDescribeModel } = vi.hoisted(() => ({
mockCreateFnAgent: vi.fn(),
mockPromptWithFallback: vi.fn(),
mockDescribeModel: vi.fn(),
}));
vi.mock("../pi-module.js", () => ({
createFnAgent: mockCreateFnAgent,
promptWithFallback: mockPromptWithFallback,
describeModel: mockDescribeModel,
}));
describe("HermesRuntimeAdapter", () => {
let adapter;
beforeEach(() => {
vi.clearAllMocks();
mockDescribeModel.mockReturnValue("mock/anthropic-claude");
adapter = new HermesRuntimeAdapter();
});
afterEach(() => {
vi.restoreAllMocks();
});
it("has stable runtime identity", () => {
expect(adapter.id).toBe("hermes");
expect(adapter.name).toBe("Hermes Runtime");
});
it("delegates createSession to createFnAgent with mapped options", async () => {
const mockSession = { dispose: vi.fn() };
mockCreateFnAgent.mockResolvedValue({ session: mockSession, sessionFile: "/tmp/session.json" });
const result = await adapter.createSession({
cwd: "/project",
systemPrompt: "You are helpful",
defaultProvider: "anthropic",
defaultModelId: "claude-sonnet-4-5",
fallbackProvider: "openai",
fallbackModelId: "gpt-4o",
skills: ["bash"],
});
expect(mockCreateFnAgent).toHaveBeenCalledWith({
cwd: "/project",
systemPrompt: "You are helpful",
tools: undefined,
customTools: undefined,
onText: undefined,
onThinking: undefined,
onToolStart: undefined,
onToolEnd: undefined,
defaultProvider: "anthropic",
defaultModelId: "claude-sonnet-4-5",
fallbackProvider: "openai",
fallbackModelId: "gpt-4o",
defaultThinkingLevel: undefined,
sessionManager: undefined,
skillSelection: undefined,
skills: ["bash"],
});
expect(result.session).toBe(mockSession);
expect(result.sessionFile).toBe("/tmp/session.json");
});
it("delegates promptWithFallback to pi seam", async () => {
const session = { id: "s-1" };
mockPromptWithFallback.mockResolvedValue(undefined);
await adapter.promptWithFallback(session, "Hello", { images: [] });
expect(mockPromptWithFallback).toHaveBeenCalledWith(session, "Hello", { images: [] });
});
it("delegates describeModel to pi seam", () => {
const session = { id: "s-2" };
mockDescribeModel.mockReturnValue("anthropic/claude-sonnet-4-5");
const result = adapter.describeModel(session);
expect(mockDescribeModel).toHaveBeenCalledWith(session);
expect(result).toBe("anthropic/claude-sonnet-4-5");
});
it("dispose calls session.dispose when present and no-ops otherwise", async () => {
const disposeMock = vi.fn().mockResolvedValue(undefined);
await adapter.dispose({ dispose: disposeMock });
await expect(adapter.dispose({ id: "no-dispose" })).resolves.toBeUndefined();
expect(disposeMock).toHaveBeenCalledTimes(1);
});
});
//# sourceMappingURL=runtime-adapter.test.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime-adapter.test.js","sourceRoot":"","sources":["../../src/__tests__/runtime-adapter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzF,iBAAiB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC1B,sBAAsB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC/B,iBAAiB,EAAE,EAAE,CAAC,EAAE,EAAE;CAC3B,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,aAAa,EAAE,iBAAiB;IAChC,kBAAkB,EAAE,sBAAsB;IAC1C,aAAa,EAAE,iBAAiB;CACjC,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,OAA6B,CAAC;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,aAAa,EAAE,CAAC;QACnB,iBAAiB,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;QAC3D,OAAO,GAAG,IAAI,oBAAoB,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAA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EAAE,YAAY,EAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;QAEpF,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* Hermes Runtime Plugin
*
* Provides an executable Hermes runtime adapter for Fusion's plugin runtime
* discovery and session execution pipeline.
*/
import type { FusionPlugin, PluginRuntimeFactory, PluginRuntimeManifestMetadata } from "@fusion/plugin-sdk";
declare const HERMES_RUNTIME_ID = "hermes";
declare const hermesRuntimeMetadata: PluginRuntimeManifestMetadata;
declare const hermesRuntimeFactory: PluginRuntimeFactory;
declare const plugin: FusionPlugin;
export default plugin;
export { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,oBAAoB,CAAC;AAI5B,QAAA,MAAM,iBAAiB,WAAW,CAAC;AAGnC,QAAA,MAAM,qBAAqB,EAAE,6BAK5B,CAAC;AAIF,QAAA,MAAM,oBAAoB,EAAE,oBAE3B,CAAC;AAIF,QAAA,MAAM,MAAM,EAAE,YA2BZ,CAAC;AAEH,eAAe,MAAM,CAAC;AAItB,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}

View File

@@ -0,0 +1,54 @@
/**
* Hermes Runtime Plugin
*
* Provides an executable Hermes runtime adapter for Fusion's plugin runtime
* discovery and session execution pipeline.
*/
import { definePlugin } from "@fusion/plugin-sdk";
import { HermesRuntimeAdapter } from "./runtime-adapter.js";
// ── Hermes Runtime Metadata ───────────────────────────────────────────────────
const HERMES_RUNTIME_ID = "hermes";
const HERMES_RUNTIME_VERSION = "0.1.0";
const hermesRuntimeMetadata = {
runtimeId: HERMES_RUNTIME_ID,
name: "Hermes Runtime",
description: "Hermes-backed AI session using the user's configured pi provider and model",
version: HERMES_RUNTIME_VERSION,
};
// ── Hermes Runtime Factory ────────────────────────────────────────────────────
const hermesRuntimeFactory = async () => {
return new HermesRuntimeAdapter();
};
// ── Plugin Definition ─────────────────────────────────────────────────────────
const plugin = definePlugin({
manifest: {
id: "fusion-plugin-hermes-runtime",
name: "Hermes Runtime Plugin",
version: "0.1.0",
description: "Hermes AI runtime plugin for Fusion - provides AI agent execution runtime capabilities",
author: "Fusion Team",
homepage: "https://github.com/gsxdsm/fusion",
runtime: hermesRuntimeMetadata,
},
state: "installed",
hooks: {
onLoad: (ctx) => {
ctx.logger.info("Hermes Runtime Plugin loaded");
ctx.emitEvent("hermes-runtime:loaded", {
runtimeId: HERMES_RUNTIME_ID,
version: HERMES_RUNTIME_VERSION,
});
},
onUnload: () => {
// No context available during unload
},
},
runtime: {
metadata: hermesRuntimeMetadata,
factory: hermesRuntimeFactory,
},
});
export default plugin;
// ── Exports for Testing ───────────────────────────────────────────────────────
export { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID };
//# sourceMappingURL=index.js.map

View 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;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAO5D,iFAAiF;AAEjF,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAEvC,MAAM,qBAAqB,GAAkC;IAC3D,SAAS,EAAE,iBAAiB;IAC5B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,4EAA4E;IACzF,OAAO,EAAE,sBAAsB;CAChC,CAAC;AAEF,iFAAiF;AAEjF,MAAM,oBAAoB,GAAyB,KAAK,IAAI,EAAE;IAC5D,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF,iFAAiF;AAEjF,MAAM,MAAM,GAAiB,YAAY,CAAC;IACxC,QAAQ,EAAE;QACR,EAAE,EAAE,8BAA8B;QAClC,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,wFAAwF;QACrG,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,kCAAkC;QAC5C,OAAO,EAAE,qBAAqB;KAC/B;IACD,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;YACd,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAChD,GAAG,CAAC,SAAS,CAAC,uBAAuB,EAAE;gBACrC,SAAS,EAAE,iBAAiB;gBAC5B,OAAO,EAAE,sBAAsB;aAChC,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,qCAAqC;QACvC,CAAC;KACF;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,qBAAqB;QAC/B,OAAO,EAAE,oBAAoB;KAC9B;CACF,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC;AAEtB,iFAAiF;AAEjF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}

View File

@@ -0,0 +1,34 @@
/**
* Pi Module Seam
*
* Provides a mockable import path for pi functions used by the HermesRuntimeAdapter.
*/
export interface PiAgentSession {
dispose?: () => Promise<void> | void;
}
export interface PiAgentResult {
session: PiAgentSession;
sessionFile?: string;
}
export interface PiAgentOptions {
cwd: string;
systemPrompt: string;
tools?: unknown;
customTools?: unknown;
onText?: (text: string) => void;
onThinking?: (text: string) => void;
onToolStart?: (toolName: string, args?: unknown) => void;
onToolEnd?: (toolName: string, result?: unknown) => void;
defaultProvider?: string;
defaultModelId?: string;
fallbackProvider?: string;
fallbackModelId?: string;
defaultThinkingLevel?: string;
sessionManager?: unknown;
skillSelection?: unknown;
skills?: string[];
}
export declare const createFnAgent: (options: PiAgentOptions) => Promise<PiAgentResult>;
export declare const promptWithFallback: (session: PiAgentSession, prompt: string, options?: unknown) => Promise<void>;
export declare const describeModel: (session: PiAgentSession) => string;
//# sourceMappingURL=pi-module.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pi-module.d.ts","sourceRoot":"","sources":["../src/pi-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AASD,eAAO,MAAM,aAAa,YALC,cAAc,KAAK,OAAO,CAAC,aAAa,CAKf,CAAC;AACrD,eAAO,MAAM,kBAAkB,YALC,cAAc,UAAU,MAAM,YAAY,OAAO,KAAK,OAAO,CAAC,IAAI,CAKpC,CAAC;AAC/D,eAAO,MAAM,aAAa,YALC,cAAc,KAAK,MAKM,CAAC"}

View File

@@ -0,0 +1,11 @@
/**
* Pi Module Seam
*
* Provides a mockable import path for pi functions used by the HermesRuntimeAdapter.
*/
// eslint-disable-next-line @typescript-eslint/no-require-imports
const _piModule = require("../../../packages/engine/src/pi.js");
export const createFnAgent = _piModule.createFnAgent;
export const promptWithFallback = _piModule.promptWithFallback;
export const describeModel = _piModule.describeModel;
//# sourceMappingURL=pi-module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pi-module.js","sourceRoot":"","sources":["../src/pi-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH,iEAAiE;AACjE,MAAM,SAAS,GAAG,OAAO,CAAC,oCAAoC,CAI7D,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC"}

View File

@@ -0,0 +1,10 @@
import type { AgentRuntime, AgentRuntimeOptions, AgentSession, AgentSessionResult } from "./types.js";
export declare class HermesRuntimeAdapter implements AgentRuntime {
readonly id = "hermes";
readonly name = "Hermes Runtime";
createSession(options: AgentRuntimeOptions): Promise<AgentSessionResult>;
promptWithFallback(session: AgentSession, prompt: string, options?: unknown): Promise<void>;
describeModel(session: AgentSession): string;
dispose(session: AgentSession): Promise<void>;
}
//# sourceMappingURL=runtime-adapter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime-adapter.d.ts","sourceRoot":"","sources":["../src/runtime-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAKpB,qBAAa,oBAAqB,YAAW,YAAY;IACvD,QAAQ,CAAC,EAAE,YAAY;IACvB,QAAQ,CAAC,IAAI,oBAAoB;IAE3B,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqBxE,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;IAItC,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAKpD"}

View File

@@ -0,0 +1,38 @@
import { createFnAgent, describeModel, promptWithFallback } from "./pi-module.js";
const getModelDescription = describeModel;
export class HermesRuntimeAdapter {
id = "hermes";
name = "Hermes Runtime";
async createSession(options) {
return createFnAgent({
cwd: options.cwd,
systemPrompt: options.systemPrompt,
tools: options.tools,
customTools: options.customTools,
onText: options.onText,
onThinking: options.onThinking,
onToolStart: options.onToolStart,
onToolEnd: options.onToolEnd,
defaultProvider: options.defaultProvider,
defaultModelId: options.defaultModelId,
fallbackProvider: options.fallbackProvider,
fallbackModelId: options.fallbackModelId,
defaultThinkingLevel: options.defaultThinkingLevel,
sessionManager: options.sessionManager,
skillSelection: options.skillSelection,
skills: options.skills,
});
}
async promptWithFallback(session, prompt, options) {
return promptWithFallback(session, prompt, options);
}
describeModel(session) {
return getModelDescription(session);
}
async dispose(session) {
if (typeof session.dispose === "function") {
await session.dispose();
}
}
}
//# sourceMappingURL=runtime-adapter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime-adapter.js","sourceRoot":"","sources":["../src/runtime-adapter.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElF,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C,MAAM,OAAO,oBAAoB;IACtB,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,gBAAgB,CAAC;IAEjC,KAAK,CAAC,aAAa,CAAC,OAA4B;QAC9C,OAAO,aAAa,CAAC;YACnB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAClD,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAAqB,EAAE,MAAc,EAAE,OAAiB;QAC/E,OAAO,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,aAAa,CAAC,OAAqB;QACjC,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,IAAI,OAAQ,OAA6C,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACjF,MAAO,OAA4C,CAAC,OAAO,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;CACF"}

View File

@@ -0,0 +1,44 @@
/**
* Hermes Runtime Plugin - Type Definitions
*
* The runtime contract is defined locally to avoid compile-time coupling to
* internal engine exports.
*/
/** Minimal session shape used by the runtime adapter. */
export interface AgentSession {
dispose?: () => Promise<void> | void;
}
/** Options for creating an agent session. Mirrors createFnAgent inputs used by the adapter. */
export interface AgentRuntimeOptions {
cwd: string;
systemPrompt: string;
tools?: unknown;
customTools?: unknown;
onText?: (text: string) => void;
onThinking?: (text: string) => void;
onToolStart?: (toolName: string, args?: unknown) => void;
onToolEnd?: (toolName: string, result?: unknown) => void;
defaultProvider?: string;
defaultModelId?: string;
fallbackProvider?: string;
fallbackModelId?: string;
defaultThinkingLevel?: string;
sessionManager?: unknown;
skillSelection?: unknown;
skills?: string[];
}
/** Result of creating a session. */
export interface AgentSessionResult {
session: AgentSession;
sessionFile?: string;
}
/** Agent runtime adapter interface. */
export interface AgentRuntime {
id: string;
name: string;
createSession(options: AgentRuntimeOptions): Promise<AgentSessionResult>;
promptWithFallback(session: AgentSession, prompt: string, options?: unknown): Promise<void>;
describeModel(session: AgentSession): string;
dispose?(session: AgentSession): Promise<void>;
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,E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AAC;CAChD"}

View File

@@ -0,0 +1,8 @@
/**
* Hermes Runtime Plugin - Type Definitions
*
* The runtime contract is defined locally to avoid compile-time coupling to
* internal engine exports.
*/
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}

View File

@@ -8,7 +8,7 @@
"runtime": {
"runtimeId": "hermes",
"name": "Hermes Runtime",
"description": "Experimental Hermes runtime integration for Fusion tasks (implementation deferred to FN-2264)",
"description": "Hermes-backed AI session using the user's configured pi provider and model",
"version": "0.1.0"
}
}

View File

@@ -1,15 +1,19 @@
/**
* Hermes Runtime Plugin Tests
*
* Tests verify:
* - Plugin manifest identity
* - Runtime registration presence
* - Deferred-implementation behavior
*/
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import plugin, { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID } from "../index.js";
// ── Mock Context ───────────────────────────────────────────────────────────────
const { mockCreateFnAgent, mockPromptWithFallback, mockDescribeModel } = vi.hoisted(() => ({
mockCreateFnAgent: vi.fn(),
mockPromptWithFallback: vi.fn(),
mockDescribeModel: vi.fn().mockReturnValue("unknown model"),
}));
vi.mock("../pi-module.js", () => ({
createFnAgent: mockCreateFnAgent,
promptWithFallback: mockPromptWithFallback,
describeModel: mockDescribeModel,
}));
import plugin, { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID } from "../index.js";
import { HermesRuntimeAdapter } from "../runtime-adapter.js";
interface MockLogger {
info: ReturnType<typeof vi.fn>;
@@ -46,8 +50,6 @@ function createMockContext(overrides: Partial<MockContext> = {}): MockContext {
};
}
// ── Test Suite ─────────────────────────────────────────────────────────────────
describe("hermes-runtime plugin", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -58,153 +60,69 @@ describe("hermes-runtime plugin", () => {
});
describe("plugin manifest identity", () => {
it("should have correct manifest id", () => {
it("should have correct manifest fields", () => {
expect(plugin.manifest.id).toBe("fusion-plugin-hermes-runtime");
});
it("should have correct manifest name", () => {
expect(plugin.manifest.name).toBe("Hermes Runtime Plugin");
});
it("should have correct version", () => {
expect(plugin.manifest.version).toBe("0.1.0");
});
it("should have description", () => {
expect(plugin.manifest.description).toBeDefined();
expect(plugin.manifest.description).toContain("Hermes");
});
it("should have author", () => {
expect(plugin.manifest.author).toBe("Fusion Team");
});
it("should have homepage", () => {
expect(plugin.manifest.homepage).toBe("https://github.com/gsxdsm/fusion");
});
it("should have state 'installed'", () => {
expect(plugin.state).toBe("installed");
});
});
describe("runtime registration", () => {
it("should have runtime registration", () => {
it("should register hermes runtime metadata", () => {
expect(plugin.runtime).toBeDefined();
});
it("should have correct runtime metadata", () => {
expect(plugin.runtime?.metadata).toBeDefined();
expect(plugin.runtime?.metadata.runtimeId).toBe(HERMES_RUNTIME_ID);
expect(plugin.runtime?.metadata.name).toBe("Hermes Runtime");
expect(plugin.runtime?.metadata.description).toContain("deferred to FN-2264");
expect(plugin.runtime?.metadata.description).toContain("Hermes-backed AI session");
expect(plugin.runtime?.metadata.version).toBe("0.1.0");
});
it("should have runtime factory function", () => {
expect(plugin.runtime?.factory).toBeDefined();
expect(typeof plugin.runtime?.factory).toBe("function");
});
it("should have consistent runtime metadata between export and manifest", () => {
expect(plugin.manifest.runtime).toBeDefined();
expect(plugin.manifest.runtime?.runtimeId).toBe(hermesRuntimeMetadata.runtimeId);
expect(plugin.manifest.runtime?.name).toBe(hermesRuntimeMetadata.name);
expect(plugin.manifest.runtime?.version).toBe(hermesRuntimeMetadata.version);
expect(plugin.manifest.runtime).toEqual(hermesRuntimeMetadata);
expect(plugin.runtime?.metadata).toEqual(hermesRuntimeMetadata);
});
});
describe("hooks", () => {
it("should have onLoad hook", () => {
expect(plugin.hooks.onLoad).toBeDefined();
expect(typeof plugin.hooks.onLoad).toBe("function");
});
it("should have onUnload hook", () => {
expect(plugin.hooks.onUnload).toBeDefined();
expect(typeof plugin.hooks.onUnload).toBe("function");
});
it("onLoad should log startup message", async () => {
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("Hermes Runtime Plugin loaded"),
);
});
it("onLoad should emit loaded event", async () => {
const ctx = createMockContext();
await plugin.hooks.onLoad?.(ctx as any);
expect(ctx.logger.info).toHaveBeenCalledWith("Hermes Runtime Plugin loaded");
expect(ctx.emitEvent).toHaveBeenCalledWith("hermes-runtime:loaded", {
runtimeId: HERMES_RUNTIME_ID,
version: "0.1.0",
status: "deferred",
});
});
it("onUnload should not throw", () => {
expect(plugin.hooks.onUnload).toBeDefined();
expect(() => plugin.hooks.onUnload?.()).not.toThrow();
});
});
describe("deferred implementation behavior", () => {
it("should export hermesRuntimeMetadata", () => {
expect(hermesRuntimeMetadata).toBeDefined();
describe("runtime factory behavior", () => {
it("should export runtime constants", () => {
expect(HERMES_RUNTIME_ID).toBe("hermes");
expect(hermesRuntimeMetadata.runtimeId).toBe("hermes");
expect(hermesRuntimeMetadata.name).toBe("Hermes Runtime");
});
it("should export hermesRuntimeFactory", () => {
expect(hermesRuntimeFactory).toBeDefined();
expect(typeof hermesRuntimeFactory).toBe("function");
});
it("should export HERMES_RUNTIME_ID constant", () => {
expect(HERMES_RUNTIME_ID).toBe("hermes");
it("runtime factory should return executable runtime adapter", async () => {
const runtime = (await hermesRuntimeFactory(createMockContext() as any)) as HermesRuntimeAdapter;
expect(runtime).toBeInstanceOf(HermesRuntimeAdapter);
expect(runtime.id).toBe("hermes");
expect(runtime.name).toBe("Hermes Runtime");
expect(runtime).not.toHaveProperty("status");
expect(runtime).not.toHaveProperty("execute");
});
it("runtime factory should return placeholder object", () => {
const ctx = createMockContext();
const runtime = hermesRuntimeFactory(ctx as any) as Record<string, unknown>;
expect(runtime).toBeDefined();
expect(runtime).toHaveProperty("runtimeId", HERMES_RUNTIME_ID);
expect(runtime).toHaveProperty("version", "0.1.0");
expect(runtime).toHaveProperty("status", "deferred");
expect(runtime).toHaveProperty("message");
expect(runtime.message).toContain("FN-2264");
});
it("runtime factory execute should throw error referencing FN-2264", async () => {
const ctx = createMockContext();
const runtime = hermesRuntimeFactory(ctx as any) as { execute: () => Promise<never> };
await expect(runtime.execute()).rejects.toThrow("FN-2264");
await expect(runtime.execute()).rejects.toThrow("not yet implemented");
});
it("runtime factory should not throw during creation (only on execute)", () => {
const ctx = createMockContext();
expect(() => hermesRuntimeFactory(ctx as any)).not.toThrow();
});
});
describe("manifest consistency", () => {
it("plugin.manifest.runtime matches hermesRuntimeMetadata", () => {
expect(plugin.manifest.runtime).toEqual(hermesRuntimeMetadata);
});
it("plugin.runtime.metadata matches hermesRuntimeMetadata", () => {
expect(plugin.runtime?.metadata).toEqual(hermesRuntimeMetadata);
});
it("manifest.json fields match plugin manifest", () => {
// These should match the manifest.json file
expect(plugin.manifest.id).toBe("fusion-plugin-hermes-runtime");
expect(plugin.manifest.name).toBe("Hermes Runtime Plugin");
expect(plugin.manifest.version).toBe("0.1.0");
it("factory creation should not throw", async () => {
await expect(hermesRuntimeFactory(createMockContext() as any)).resolves.toBeInstanceOf(
HermesRuntimeAdapter,
);
});
});
});

View File

@@ -0,0 +1,97 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { HermesRuntimeAdapter } from "../runtime-adapter.js";
const { mockCreateFnAgent, mockPromptWithFallback, mockDescribeModel } = vi.hoisted(() => ({
mockCreateFnAgent: vi.fn(),
mockPromptWithFallback: vi.fn(),
mockDescribeModel: vi.fn(),
}));
vi.mock("../pi-module.js", () => ({
createFnAgent: mockCreateFnAgent,
promptWithFallback: mockPromptWithFallback,
describeModel: mockDescribeModel,
}));
describe("HermesRuntimeAdapter", () => {
let adapter: HermesRuntimeAdapter;
beforeEach(() => {
vi.clearAllMocks();
mockDescribeModel.mockReturnValue("mock/anthropic-claude");
adapter = new HermesRuntimeAdapter();
});
afterEach(() => {
vi.restoreAllMocks();
});
it("has stable runtime identity", () => {
expect(adapter.id).toBe("hermes");
expect(adapter.name).toBe("Hermes Runtime");
});
it("delegates createSession to createFnAgent with mapped options", async () => {
const mockSession = { dispose: vi.fn() };
mockCreateFnAgent.mockResolvedValue({ session: mockSession, sessionFile: "/tmp/session.json" });
const result = await adapter.createSession({
cwd: "/project",
systemPrompt: "You are helpful",
defaultProvider: "anthropic",
defaultModelId: "claude-sonnet-4-5",
fallbackProvider: "openai",
fallbackModelId: "gpt-4o",
skills: ["bash"],
});
expect(mockCreateFnAgent).toHaveBeenCalledWith({
cwd: "/project",
systemPrompt: "You are helpful",
tools: undefined,
customTools: undefined,
onText: undefined,
onThinking: undefined,
onToolStart: undefined,
onToolEnd: undefined,
defaultProvider: "anthropic",
defaultModelId: "claude-sonnet-4-5",
fallbackProvider: "openai",
fallbackModelId: "gpt-4o",
defaultThinkingLevel: undefined,
sessionManager: undefined,
skillSelection: undefined,
skills: ["bash"],
});
expect(result.session).toBe(mockSession);
expect(result.sessionFile).toBe("/tmp/session.json");
});
it("delegates promptWithFallback to pi seam", async () => {
const session = { id: "s-1" };
mockPromptWithFallback.mockResolvedValue(undefined);
await adapter.promptWithFallback(session as any, "Hello", { images: [] });
expect(mockPromptWithFallback).toHaveBeenCalledWith(session, "Hello", { images: [] });
});
it("delegates describeModel to pi seam", () => {
const session = { id: "s-2" };
mockDescribeModel.mockReturnValue("anthropic/claude-sonnet-4-5");
const result = adapter.describeModel(session as any);
expect(mockDescribeModel).toHaveBeenCalledWith(session);
expect(result).toBe("anthropic/claude-sonnet-4-5");
});
it("dispose calls session.dispose when present and no-ops otherwise", async () => {
const disposeMock = vi.fn().mockResolvedValue(undefined);
await adapter.dispose({ dispose: disposeMock });
await expect(adapter.dispose({ id: "no-dispose" } as any)).resolves.toBeUndefined();
expect(disposeMock).toHaveBeenCalledTimes(1);
});
});

View File

@@ -1,17 +1,14 @@
/**
* Hermes Runtime Plugin
*
* Provides Hermes AI runtime capabilities for Fusion tasks.
* This plugin registers the Hermes runtime with the Fusion plugin system.
*
* Note: Full runtime behavior is deferred to FN-2264.
* Any runtime invocation will return a "not implemented" signal.
* Provides an executable Hermes runtime adapter for Fusion's plugin runtime
* discovery and session execution pipeline.
*/
import { definePlugin } from "@fusion/plugin-sdk";
import { HermesRuntimeAdapter } from "./runtime-adapter.js";
import type {
FusionPlugin,
PluginContext,
PluginRuntimeFactory,
PluginRuntimeManifestMetadata,
} from "@fusion/plugin-sdk";
@@ -24,37 +21,14 @@ const HERMES_RUNTIME_VERSION = "0.1.0";
const hermesRuntimeMetadata: PluginRuntimeManifestMetadata = {
runtimeId: HERMES_RUNTIME_ID,
name: "Hermes Runtime",
description: "Experimental Hermes runtime integration for Fusion tasks (implementation deferred to FN-2264)",
description: "Hermes-backed AI session using the user's configured pi provider and model",
version: HERMES_RUNTIME_VERSION,
};
// ── Hermes Runtime Factory ────────────────────────────────────────────────────
/**
* Factory function for creating the Hermes runtime instance.
*
* This is a placeholder implementation. Full runtime behavior is deferred to FN-2264.
* Any runtime invocation will throw a descriptive error referencing FN-2264.
*
* @param _ctx - Plugin context (unused in placeholder)
* @throws Error with message referencing FN-2264 for full implementation
*/
const hermesRuntimeFactory: PluginRuntimeFactory = (_ctx: PluginContext) => {
// Return a placeholder object that signals deferred implementation
return {
runtimeId: HERMES_RUNTIME_ID,
version: HERMES_RUNTIME_VERSION,
status: "deferred",
message: `Hermes runtime implementation is deferred to FN-2264. ` +
`Current invocation is a placeholder.`,
execute: async () => {
throw new Error(
`Hermes runtime is not yet implemented. ` +
`Full implementation deferred to FN-2264. ` +
`See https://github.com/gsxdsm/fusion/issues/FN-2264`,
);
},
};
const hermesRuntimeFactory: PluginRuntimeFactory = async () => {
return new HermesRuntimeAdapter();
};
// ── Plugin Definition ─────────────────────────────────────────────────────────
@@ -72,11 +46,10 @@ const plugin: FusionPlugin = definePlugin({
state: "installed",
hooks: {
onLoad: (ctx) => {
ctx.logger.info("Hermes Runtime Plugin loaded (placeholder - FN-2264 pending)");
ctx.logger.info("Hermes Runtime Plugin loaded");
ctx.emitEvent("hermes-runtime:loaded", {
runtimeId: HERMES_RUNTIME_ID,
version: HERMES_RUNTIME_VERSION,
status: "deferred",
});
},
onUnload: () => {

View File

@@ -0,0 +1,44 @@
/**
* Pi Module Seam
*
* Provides a mockable import path for pi functions used by the HermesRuntimeAdapter.
*/
export interface PiAgentSession {
dispose?: () => Promise<void> | void;
}
export interface PiAgentResult {
session: PiAgentSession;
sessionFile?: string;
}
export interface PiAgentOptions {
cwd: string;
systemPrompt: string;
tools?: unknown;
customTools?: unknown;
onText?: (text: string) => void;
onThinking?: (text: string) => void;
onToolStart?: (toolName: string, args?: unknown) => void;
onToolEnd?: (toolName: string, result?: unknown) => void;
defaultProvider?: string;
defaultModelId?: string;
fallbackProvider?: string;
fallbackModelId?: string;
defaultThinkingLevel?: string;
sessionManager?: unknown;
skillSelection?: unknown;
skills?: string[];
}
// eslint-disable-next-line @typescript-eslint/no-require-imports
const _piModule = require("../../../packages/engine/src/pi.js") as {
createFnAgent: (options: PiAgentOptions) => Promise<PiAgentResult>;
promptWithFallback: (session: PiAgentSession, prompt: string, options?: unknown) => Promise<void>;
describeModel: (session: PiAgentSession) => string;
};
export const createFnAgent = _piModule.createFnAgent;
export const promptWithFallback = _piModule.promptWithFallback;
export const describeModel = _piModule.describeModel;

View File

@@ -0,0 +1,49 @@
import type {
AgentRuntime,
AgentRuntimeOptions,
AgentSession,
AgentSessionResult,
} from "./types.js";
import { createFnAgent, describeModel, promptWithFallback } from "./pi-module.js";
const getModelDescription = describeModel;
export class HermesRuntimeAdapter implements AgentRuntime {
readonly id = "hermes";
readonly name = "Hermes Runtime";
async createSession(options: AgentRuntimeOptions): Promise<AgentSessionResult> {
return createFnAgent({
cwd: options.cwd,
systemPrompt: options.systemPrompt,
tools: options.tools,
customTools: options.customTools,
onText: options.onText,
onThinking: options.onThinking,
onToolStart: options.onToolStart,
onToolEnd: options.onToolEnd,
defaultProvider: options.defaultProvider,
defaultModelId: options.defaultModelId,
fallbackProvider: options.fallbackProvider,
fallbackModelId: options.fallbackModelId,
defaultThinkingLevel: options.defaultThinkingLevel,
sessionManager: options.sessionManager,
skillSelection: options.skillSelection,
skills: options.skills,
});
}
async promptWithFallback(session: AgentSession, prompt: string, options?: unknown): Promise<void> {
return promptWithFallback(session, prompt, options);
}
describeModel(session: AgentSession): string {
return getModelDescription(session);
}
async dispose(session: AgentSession): Promise<void> {
if (typeof (session as { dispose?: () => Promise<void> }).dispose === "function") {
await (session as { dispose: () => Promise<void> }).dispose();
}
}
}

View File

@@ -0,0 +1,47 @@
/**
* Hermes Runtime Plugin - Type Definitions
*
* The runtime contract is defined locally to avoid compile-time coupling to
* internal engine exports.
*/
/** Minimal session shape used by the runtime adapter. */
export interface AgentSession {
dispose?: () => Promise<void> | void;
}
/** Options for creating an agent session. Mirrors createFnAgent inputs used by the adapter. */
export interface AgentRuntimeOptions {
cwd: string;
systemPrompt: string;
tools?: unknown;
customTools?: unknown;
onText?: (text: string) => void;
onThinking?: (text: string) => void;
onToolStart?: (toolName: string, args?: unknown) => void;
onToolEnd?: (toolName: string, result?: unknown) => void;
defaultProvider?: string;
defaultModelId?: string;
fallbackProvider?: string;
fallbackModelId?: string;
defaultThinkingLevel?: string;
sessionManager?: unknown;
skillSelection?: unknown;
skills?: string[];
}
/** Result of creating a session. */
export interface AgentSessionResult {
session: AgentSession;
sessionFile?: string;
}
/** Agent runtime adapter interface. */
export interface AgentRuntime {
id: string;
name: string;
createSession(options: AgentRuntimeOptions): Promise<AgentSessionResult>;
promptWithFallback(session: AgentSession, prompt: string, options?: unknown): Promise<void>;
describeModel(session: AgentSession): string;
dispose?(session: AgentSession): Promise<void>;
}