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,25 +1,8 @@
|
||||
# @fusion/droid-cli
|
||||
|
||||
First-party Fusion pi extension package that routes pi provider requests through the `droid` CLI subprocess using stream-json NDJSON.
|
||||
Compatibility shim package for Fusion's Droid integration.
|
||||
|
||||
## Provider
|
||||
Runtime/provider implementation now lives in:
|
||||
- `@fusion-plugin-examples/droid-runtime` (`plugins/fusion-plugin-droid-runtime`)
|
||||
|
||||
- Provider ID: `droid-cli`
|
||||
- Binary: `droid` (must be installed and authenticated on PATH)
|
||||
- Registration: package extension entrypoint in `index.ts`
|
||||
|
||||
## Capabilities
|
||||
|
||||
- Subprocess streaming bridge for text/thinking/tool events
|
||||
- Model auto-discovery from Droid CLI at provider startup with in-process caching
|
||||
- Session resume support (`--resume` / `--session-id`) to avoid replaying prior turns
|
||||
- MCP schema bridge for exposing pi custom tools as schema-only definitions
|
||||
- Tool mapping and break-early control so pi remains the tool executor
|
||||
- Thinking effort mapping from pi reasoning options to Droid CLI flags
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
pnpm --filter @fusion/droid-cli test
|
||||
pnpm --filter @fusion/droid-cli exec tsc --noEmit
|
||||
```
|
||||
This package preserves the historical pi extension entrypoint and delegates to the plugin-owned implementation so existing imports continue to work.
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
import { streamViaCli } from "./src/provider.js";
|
||||
import { streamViaCli } from "../../plugins/fusion-plugin-droid-runtime/src/provider.js";
|
||||
import {
|
||||
discoverDroidModels,
|
||||
validateCliPresenceAsync,
|
||||
validateCliAuthAsync,
|
||||
killAllProcesses,
|
||||
discoverDroidModels,
|
||||
} from "./src/process-manager.js";
|
||||
} from "../../plugins/fusion-plugin-droid-runtime/src/process-manager.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
getCustomToolDefs,
|
||||
toolsFromContext,
|
||||
writeMcpConfig,
|
||||
type McpToolDef,
|
||||
} from "./src/mcp-config.js";
|
||||
} from "../../plugins/fusion-plugin-droid-runtime/src/mcp-config.js";
|
||||
|
||||
process.on("exit", killAllProcesses);
|
||||
|
||||
@@ -117,7 +117,11 @@ export default function (pi: ExtensionAPI) {
|
||||
pi,
|
||||
(context as { tools?: ReadonlyArray<{ name: string; description: string; parameters: Record<string, unknown> }> }).tools,
|
||||
);
|
||||
return streamViaCli(model, context, { ...options, mcpConfigPath: configPath });
|
||||
return streamViaCli(
|
||||
model,
|
||||
context as never,
|
||||
{ ...(options ?? {}), mcpConfigPath: configPath } as never,
|
||||
);
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
"@mariozechner/pi-ai": "*",
|
||||
"@mariozechner/pi-coding-agent": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fusion-plugin-examples/droid-runtime": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"typescript": "^5.7.0",
|
||||
|
||||
@@ -71,16 +71,16 @@ import { streamViaCli } from "../provider";
|
||||
describe("provider registration (default export)", () => {
|
||||
it("registers provider id droid-cli with deduped discovered models", async () => {
|
||||
vi.resetModules();
|
||||
vi.doMock("../../src/provider.js", () => ({
|
||||
vi.doMock("../../../../plugins/fusion-plugin-droid-runtime/src/provider.js", () => ({
|
||||
streamViaCli: vi.fn(() => ({ mocked: true })),
|
||||
}));
|
||||
vi.doMock("../../src/process-manager.js", () => ({
|
||||
vi.doMock("../../../../plugins/fusion-plugin-droid-runtime/src/process-manager.js", () => ({
|
||||
validateCliPresenceAsync: vi.fn(async () => ({ ok: true })),
|
||||
validateCliAuthAsync: vi.fn(async () => true),
|
||||
killAllProcesses: vi.fn(),
|
||||
discoverDroidModels: vi.fn(async () => ["droid-pro", "droid-max", "droid-pro"]),
|
||||
}));
|
||||
vi.doMock("../../src/mcp-config.js", () => ({
|
||||
vi.doMock("../../../../plugins/fusion-plugin-droid-runtime/src/mcp-config.js", () => ({
|
||||
getCustomToolDefs: vi.fn(() => []),
|
||||
toolsFromContext: vi.fn(() => []),
|
||||
writeMcpConfig: vi.fn(() => "/tmp/droid-mcp.json"),
|
||||
@@ -105,9 +105,9 @@ describe("provider registration (default export)", () => {
|
||||
"droid-pro",
|
||||
"droid-max",
|
||||
]);
|
||||
vi.doUnmock("../../src/provider.js");
|
||||
vi.doUnmock("../../src/process-manager.js");
|
||||
vi.doUnmock("../../src/mcp-config.js");
|
||||
vi.doUnmock("../../../../plugins/fusion-plugin-droid-runtime/src/provider.js");
|
||||
vi.doUnmock("../../../../plugins/fusion-plugin-droid-runtime/src/process-manager.js");
|
||||
vi.doUnmock("../../../../plugins/fusion-plugin-droid-runtime/src/mcp-config.js");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user