* fix(plugins): keep React out of the server plugin host * fix(plugins): align SDK guidance and tests with runtime boundaries * fix(plugin): loosen the react peer to ~19.1.0 The plugin SDK pins its react peer to exactly 19.1.0, and that pin is what a downstream `npm i -g @getpaseo/cli` resolves against. So every user ends up with react 19.1.0 in their global node_modules, where corporate dependency scanners flag it: the CVE-2025-55182 advisory range covers 19.1.0 even though the vulnerability itself lives in react-server-dom-webpack/-parcel/-turbopack, none of which the CLI installs. The user is then left hand-patching node_modules or uninstalling Paseo. Widening the peer to ~19.1.0 lets a downstream install pick the latest 19.1.x patch (19.1.9 today) while this repo stays on 19.1.0, which the root override still pins. Keeping the repo itself on 19.1.0 is deliberate. react-native 0.81.5 embeds a 19.1.0 Paper renderer that hard-throws "Incompatible React versions" on any exact mismatch, and it is reachable from Fabric builds too: RendererImplementation.js requires the Paper shim unconditionally in findNodeHandle, unstable_batchedUpdates, sendAccessibilityEvent and three other entry points, and react-native-gesture-handler re-exports findNodeHandle. Bumping the app's react is therefore not safe until react-native moves. The published CLI tree contains no react-native, so downstream installs are not subject to that constraint. Supersedes the earlier 19.1.5/19.1.9 version-bump approach on this branch, which would have broken the mobile app. * Enforce example import ownership including client types * Update Nix dependency hash for plugin peer metadata * Group plugin APIs under client and server entry trees * Resolve plugin type dependencies through declarations * Validate declarations for implicit plugin type imports * Preserve optional imports and validate declaration references * Refresh Nix hash for plugin declaration resolver * Canonicalize plugin paths consistently on Windows * Normalize plugin ownership paths across resolver boundaries --------- Co-authored-by: liujin0506 <liujin0506@qq.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
102 lines
3.5 KiB
TypeScript
102 lines
3.5 KiB
TypeScript
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
|
import type { PaseoApi } from "@getpaseo/client";
|
|
import { PaseoApiProvider } from "@getpaseo/plugin/client/host";
|
|
import { usePaseo } from "@getpaseo/plugin/client";
|
|
import React from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { createPluginSurfaceRuntime } from "./surface-runtime";
|
|
|
|
function clientWithWorkspace(id: string) {
|
|
const createWorkspace = vi.fn(async () => ({
|
|
error: null,
|
|
workspace: {
|
|
id,
|
|
projectId: `project-${id}`,
|
|
workspaceDirectory: `/tmp/${id}`,
|
|
name: id,
|
|
status: "active",
|
|
},
|
|
}));
|
|
const createAgent = vi.fn(async () => ({
|
|
id: `agent-${id}`,
|
|
provider: "codex",
|
|
cwd: `/tmp/${id}`,
|
|
workspaceId: id,
|
|
status: "idle",
|
|
}));
|
|
const invokePluginRpc = vi.fn(async () => id);
|
|
return {
|
|
client: { createWorkspace, createAgent, invokePluginRpc } as unknown as DaemonClient,
|
|
createWorkspace,
|
|
createAgent,
|
|
invokePluginRpc,
|
|
};
|
|
}
|
|
|
|
function borrowFromAppProvider(paseo: PaseoApi): PaseoApi {
|
|
let borrowed: PaseoApi | null = null;
|
|
function PluginSurface() {
|
|
borrowed = usePaseo();
|
|
return null;
|
|
}
|
|
renderToStaticMarkup(
|
|
<PaseoApiProvider paseo={paseo}>
|
|
<PluginSurface />
|
|
</PaseoApiProvider>,
|
|
);
|
|
if (!borrowed) throw new Error("Plugin surface did not receive Paseo API");
|
|
return borrowed;
|
|
}
|
|
|
|
describe("plugin surface host runtime", () => {
|
|
it("creates a PR worktree and agent through usePaseo on the selected app host", async () => {
|
|
const selected = clientWithWorkspace("workspace-a");
|
|
const runtime = createPluginSurfaceRuntime(selected.client, "workspace-plugin");
|
|
if (!runtime) throw new Error("Expected selected host runtime");
|
|
|
|
const paseo = borrowFromAppProvider(runtime.paseo);
|
|
const workspace = await paseo.workspaces.create({
|
|
source: {
|
|
kind: "worktree",
|
|
cwd: "/tmp/repository",
|
|
action: "checkout",
|
|
checkoutSource: { kind: "change_request", forge: "github", number: 42 },
|
|
},
|
|
});
|
|
const agent = await workspace.agents.create({
|
|
config: { provider: "codex/gpt-5" },
|
|
prompt: "Review PR #42",
|
|
});
|
|
|
|
expect(workspace.id).toBe("workspace-a");
|
|
expect(agent.id).toBe("agent-workspace-a");
|
|
expect(selected.createWorkspace).toHaveBeenCalledOnce();
|
|
expect(selected.createAgent).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("switches all plugin calls when the selected host changes", async () => {
|
|
const hostA = clientWithWorkspace("workspace-a");
|
|
const hostB = clientWithWorkspace("workspace-b");
|
|
const first = createPluginSurfaceRuntime(hostA.client, "same-plugin");
|
|
const second = createPluginSurfaceRuntime(hostB.client, "same-plugin");
|
|
if (!first || !second) throw new Error("Expected online host runtimes");
|
|
|
|
await first.invoke("host", {});
|
|
await borrowFromAppProvider(second.paseo).workspaces.create({
|
|
source: { kind: "directory", path: "/tmp/workspace-b" },
|
|
});
|
|
|
|
expect(hostA.invokePluginRpc).toHaveBeenCalledWith("same-plugin", "host", {});
|
|
expect(hostA.createWorkspace).not.toHaveBeenCalled();
|
|
expect(hostB.createWorkspace).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("keeps an offline selected host unavailable instead of borrowing another host", () => {
|
|
const otherHost = clientWithWorkspace("workspace-online");
|
|
|
|
expect(createPluginSurfaceRuntime(null, "same-plugin")).toBeNull();
|
|
expect(otherHost.createWorkspace).not.toHaveBeenCalled();
|
|
});
|
|
});
|