Files
fusion/plugins/fusion-plugin-hermes-runtime/dist/__tests__/index.test.js
Fusion 626e768f39 feat(FN-2709): migrate Hermes runtime plugin to pi-ai streaming client
- Replace Hermes pi module integration with pi-ai session streaming and updated runtime adapter contracts
- Remove legacy engine guard scaffolding and add hermes-stream-client coverage for streaming behavior
- Rewrite plugin and engine e2e tests to align with the new runtime flow and regenerate dist artifacts
- Update Hermes runtime README and package metadata to document pi-ai execution expectations
2026-04-27 11:34:49 -07:00

86 lines
3.4 KiB
JavaScript

import { beforeEach, describe, expect, it, vi } from "vitest";
const { mockResolveModelConfig } = vi.hoisted(() => ({
mockResolveModelConfig: vi.fn().mockReturnValue({
provider: "anthropic",
modelId: "claude-sonnet-4-5",
apiKey: undefined,
thinkingLevel: undefined,
}),
}));
vi.mock("../pi-module.js", () => ({
resolveModelConfig: mockResolveModelConfig,
}));
import plugin, { hermesRuntimeMetadata, hermesRuntimeFactory, HERMES_RUNTIME_ID } from "../index.js";
import { HermesRuntimeAdapter } from "../runtime-adapter.js";
function createMockContext(settings = {}) {
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(),
},
};
}
describe("hermes-runtime plugin", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("has expected manifest identity", () => {
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.state).toBe("installed");
});
it("registers runtime metadata and exports matching constants", () => {
expect(HERMES_RUNTIME_ID).toBe("hermes");
expect(plugin.runtime?.metadata.runtimeId).toBe("hermes");
expect(plugin.runtime?.metadata.name).toBe("Hermes Runtime");
expect(plugin.runtime?.metadata.description).toContain("pi-ai direct streaming");
expect(plugin.manifest.runtime).toEqual(hermesRuntimeMetadata);
});
it("onLoad resolves model config and logs selected provider/model without api key", async () => {
const ctx = createMockContext({ provider: "openai", modelId: "gpt-5", apiKey: "secret" });
mockResolveModelConfig.mockReturnValue({
provider: "openai",
modelId: "gpt-5",
apiKey: "secret",
thinkingLevel: "medium",
});
await plugin.hooks.onLoad?.(ctx);
expect(mockResolveModelConfig).toHaveBeenCalledWith(ctx.settings);
expect(ctx.logger.info).toHaveBeenCalledWith("Hermes Runtime Plugin loaded — using openai/gpt-5");
expect(ctx.logger.info.mock.calls[0][0]).not.toContain("secret");
expect(ctx.emitEvent).toHaveBeenCalledWith("hermes-runtime:loaded", {
runtimeId: "hermes",
version: "0.1.0",
});
});
it("runtime factory resolves settings and returns HermesRuntimeAdapter", async () => {
const ctx = createMockContext({ provider: "openai", modelId: "gpt-5" });
mockResolveModelConfig.mockReturnValue({
provider: "openai",
modelId: "gpt-5",
apiKey: "api-key",
thinkingLevel: "high",
});
const runtime = (await hermesRuntimeFactory(ctx));
expect(mockResolveModelConfig).toHaveBeenCalledWith(ctx.settings);
expect(runtime).toBeInstanceOf(HermesRuntimeAdapter);
expect(runtime.id).toBe("hermes");
expect(runtime.name).toBe("Hermes Runtime");
expect(runtime.config).toEqual({
provider: "openai",
modelId: "gpt-5",
apiKey: "api-key",
thinkingLevel: "high",
});
});
});
//# sourceMappingURL=index.test.js.map