feat(FN-3332): add droid runtime plugin with event bridge and process manag
The merge delivers a new `fusion-plugin-droid-runtime` plugin providing a full MCP server and runtime adapter for droid-based agents, with event bridging, process management, tool mapping, and a prompt builder. It also adds agent delegation and org hierarchy tools to the pi extension, while fixing a Fusion-Task-Id: FN-3332
This commit is contained in:
@@ -1,43 +1,21 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("@fusion-plugin-examples/droid-runtime/probe", () => ({
|
||||
probeDroidBinary: vi.fn(async () => ({
|
||||
available: true,
|
||||
authenticated: true,
|
||||
version: "1.0.0",
|
||||
binaryPath: "/usr/bin/droid",
|
||||
probeDurationMs: 5,
|
||||
})),
|
||||
}));
|
||||
|
||||
import { probeDroidCli } from "../droid-cli-probe.js";
|
||||
|
||||
/**
|
||||
* These tests exercise the real probe — we deliberately do NOT mock
|
||||
* `spawn`. The probe's job is to tell the truth about the local system,
|
||||
* and mocking defeats that. Instead we:
|
||||
*
|
||||
* 1. Assert the shape is sound regardless of binary availability
|
||||
* 2. Assert timeouts fire when the binary hangs (we don't have a
|
||||
* hanging binary fixture, so we cover the structural case only)
|
||||
* 3. Let the suite pass whether or not `droid` is installed on the
|
||||
* test runner — both outcomes are legitimate.
|
||||
*
|
||||
* If you need mocked probe behavior for a higher-level route test, spy
|
||||
* on `probeDroidCli` at the import boundary rather than shimming spawn.
|
||||
*/
|
||||
describe("probeDroidCli", () => {
|
||||
it("returns a well-formed result whether or not droid is installed", async () => {
|
||||
it("delegates to plugin probe and returns shaped status", async () => {
|
||||
const result = await probeDroidCli();
|
||||
expect(typeof result.available).toBe("boolean");
|
||||
expect(typeof result.probeDurationMs).toBe("number");
|
||||
if (result.available) {
|
||||
// When available: version string should come back populated.
|
||||
expect(typeof result.version).toBe("string");
|
||||
} else {
|
||||
// When unavailable: reason must be populated so the UI can render.
|
||||
expect(typeof result.reason).toBe("string");
|
||||
}
|
||||
});
|
||||
|
||||
it("respects a short timeout", async () => {
|
||||
// Not a true hang test (we don't have a hanging binary), but
|
||||
// confirms the timeoutMs option wires through and probe completes
|
||||
// in a bounded window when using a very small timeout.
|
||||
const result = await probeDroidCli({ timeoutMs: 50 });
|
||||
expect(result.probeDurationMs).toBeLessThan(5000);
|
||||
// Either it completed fast enough or hit the timeout — both fine.
|
||||
if (!result.available && result.reason?.includes("timed out")) {
|
||||
expect(result.reason).toContain("50ms");
|
||||
}
|
||||
expect(result.available).toBe(true);
|
||||
expect(result.probeDurationMs).toBeTypeOf("number");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user