Files
fusion/plugins/fusion-plugin-hermes-runtime/dist/__tests__/index.test.js
semih 3578a96561 Merge upstream/main (1547 commits) into local main
Resolved 7 conflicts and reconciled local patches with upstream's evolved API:

- packages/core/src/plugin-loader.ts: dropped local createContextFor()/buildContext()
  in favor of upstream's createRouteContext() which provides the same TaskStore-
  override capability our patch added.

- packages/dashboard/src/routes.ts: removed local manual plugin-route mounter
  (upstream's createPluginRouter handles this with richer response support);
  kept registerPluginExemptPath loop so external webhook plugins (telemetry-
  watcher, Grafana/Sentry) still bypass daemon-token auth. Removed obsolete
  resolveHeartbeatMonitorFor (replaced by upstream's resolveHeartbeatMonitor).

- packages/dashboard/src/routes/register-agent-runtime-routes.ts: ported
  4 call sites to upstream's isHeartbeatMonitorForProject + resolveHeartbeatMonitor
  dual-fallback pattern (multi-project monitor resolution).

- packages/cli/package.json: combined upstream's pi-ai 0.73.0 + dockerode
  bumps with our cross-spawn dep for vendored pi-claude-cli.

- pnpm-workspace.yaml: kept telemetry-watcher entry alongside upstream's new
  plugin entries (droid-runtime, cursor-runtime, agent-browser, whatsapp-chat,
  roadmap, even-realities-glasses, even-cards, reports).

- packages/dashboard/app/components/SetupWizardModal.css: kept z-index:110
  fix (wizard stacks above ModelOnboardingModal) and added upstream's
  overflow-y/overscroll-behavior on .setup-wizard-overlay.

- pnpm-lock.yaml: took upstream verbatim; pnpm install regenerated to
  include cross-spawn.

Typechecks: @fusion/core and @fusion/dashboard pass cleanly.
2026-05-11 08:24:34 +00:00

114 lines
4.4 KiB
JavaScript

import { beforeEach, describe, expect, it, vi } from "vitest";
const { mockResolveCli, mockInstallFusionSkill } = vi.hoisted(() => ({
mockResolveCli: vi.fn().mockReturnValue({
binaryPath: "hermes",
model: undefined,
provider: undefined,
maxTurns: 12,
yolo: false,
cliTimeoutMs: 300_000,
}),
mockInstallFusionSkill: vi.fn().mockReturnValue({
outcome: "installed",
sourceDir: "/tmp/source",
targetDir: "/tmp/target",
}),
}));
vi.mock("../cli-spawn.js", async () => {
const actual = await vi.importActual("../cli-spawn.js");
return {
...actual,
resolveCliSettings: mockResolveCli,
};
});
vi.mock("../fusion-skill-install.js", async () => {
const actual = await vi.importActual("../fusion-skill-install.js");
return {
...actual,
installFusionSkillIntoHermesHome: mockInstallFusionSkill,
};
});
import plugin, { HERMES_RUNTIME_ID, hermesRuntimeFactory, hermesRuntimeMetadata } 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();
mockResolveCli.mockReturnValue({
binaryPath: "hermes",
model: undefined,
provider: undefined,
maxTurns: 12,
yolo: false,
cliTimeoutMs: 300_000,
profile: undefined,
});
mockInstallFusionSkill.mockReturnValue({
outcome: "installed",
sourceDir: "/tmp/source",
targetDir: "/tmp/target",
});
});
it("has expected manifest identity", () => {
expect(plugin.manifest.id).toBe("fusion-plugin-hermes-runtime");
expect(plugin.manifest.name).toBe("Hermes Runtime Plugin");
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("hermes");
expect(plugin.manifest.runtime).toEqual(hermesRuntimeMetadata);
});
it("onLoad logs selected binary path & model and emits loaded event", async () => {
mockResolveCli.mockReturnValue({
binaryPath: "/opt/homebrew/bin/hermes",
model: "claude-sonnet-4-5",
provider: "anthropic",
maxTurns: 12,
yolo: false,
cliTimeoutMs: 300_000,
profile: undefined,
});
const ctx = createMockContext({ binaryPath: "/opt/homebrew/bin/hermes" });
await plugin.hooks.onLoad(ctx);
expect(mockResolveCli).toHaveBeenCalledWith(ctx.settings);
expect(mockInstallFusionSkill).toHaveBeenCalledWith({ profile: undefined });
expect(ctx.logger.info).toHaveBeenCalledWith(expect.stringContaining("fusionSkill=installed"));
expect(ctx.emitEvent).toHaveBeenCalledWith("hermes-runtime:loaded", {
runtimeId: "hermes",
version: plugin.manifest.version,
});
});
it("onLoad warns but continues when skill install warns", async () => {
mockInstallFusionSkill.mockReturnValue({
outcome: "warning",
sourceDir: null,
targetDir: "/tmp/target",
reason: "missing skill source",
});
const ctx = createMockContext();
await plugin.hooks.onLoad(ctx);
expect(ctx.logger.warn).toHaveBeenCalledWith(expect.stringContaining("auto-install warning"));
expect(ctx.emitEvent).toHaveBeenCalledWith("hermes-runtime:loaded", {
runtimeId: "hermes",
version: plugin.manifest.version,
});
});
it("factory returns a HermesRuntimeAdapter", async () => {
const ctx = createMockContext({ binaryPath: "hermes" });
const runtime = (await hermesRuntimeFactory(ctx));
expect(runtime).toBeInstanceOf(HermesRuntimeAdapter);
expect(runtime.id).toBe("hermes");
});
});
//# sourceMappingURL=index.test.js.map