[codex] Show bundled plugins in plugin manager (#6734)

## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies.
> - The plugin system is how Paperclip exposes optional capabilities and
integrations without bloating the control plane.
> - Operators need the Instance Settings plugin manager to show both
installed external plugins and bundled built-in plugins.
> - Bundled plugins were available in the server/UI surface but were not
represented consistently in the plugin manager list.
> - Workspace runtime reuse also needed to stay pinned to the current
branch/base so the plugin manager can be validated from the intended
checkout.
> - This pull request shows bundled plugins in the manager, marks
experimental bundled plugins clearly, and tightens runtime/worktree
reuse guards.
> - The benefit is that operators can discover bundled plugins from the
same management screen as installed plugins without stale workspace
sessions hiding the latest branch state.

## What Changed

- Lists bundled monorepo plugin packages through the plugin routes API,
including plugin status and install metadata needed by the UI.
- Updates the plugin manager UI/API client to render bundled plugins and
display experimental badges based on installed plugin records.
- Adds server authorization coverage around plugin routes so board and
agent access stay company-scoped.
- Guards execution workspace/runtime reuse against stale base refs and
defaults new worktrees to the fetched target base.
- Expands workspace runtime tests for service reuse, stale workspace
prevention, and controlled runtime stops.
- Addressed Greptile feedback by respecting `origin/HEAD`, using async
cached bundled-plugin discovery, and avoiding duplicated UI experimental
plugin lists.

## Verification

- `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts
server/src/__tests__/workspace-runtime.test.ts
server/src/__tests__/heartbeat-workspace-session.test.ts`
- `pnpm --filter @paperclipai/ui typecheck`
- `pnpm --filter @paperclipai/plugin-sdk build && pnpm --filter
@paperclipai/server typecheck`
- `pnpm --filter @paperclipai/server typecheck`
- `gh pr checks 6734 --repo paperclipai/paperclip` reports all checks
passing on `10e1ba9e0f505637cd913713fb28c2c99ae92011`.
- Greptile Review reports 5/5 on
`10e1ba9e0f505637cd913713fb28c2c99ae92011`.
- Confirmed the branch is rebased onto `public-gh/master` and the PR
diff does not include `pnpm-lock.yaml` or `.github/workflows` changes.
- UI screenshots were not captured in this PR-creation pass because the
available local board runtime is authenticated; the visible UI path is
covered by the plugin manager code changes and server/API tests above.

## Risks

- Medium risk: this touches shared plugin listing behavior and workspace
runtime reuse, so regressions could affect plugin manager visibility or
service reuse across execution workspaces.
- No database migrations.
- No lockfile or GitHub workflow changes.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI GPT-5 Codex, coding-agent workflow with shell/tool use in a
local Paperclip worktree. Context window not surfaced by the runtime;
reasoning mode not externally reported.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Dotta 2026-05-26 08:32:45 -05:00 committed by GitHub
parent 9aea3e3d35
commit f0ddd24d61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 609 additions and 93 deletions

View file

@ -132,13 +132,14 @@ export interface PluginDashboardData {
checkedAt: string;
}
export interface AvailablePluginExample {
export interface AvailableBundledPlugin {
packageName: string;
pluginKey: string;
displayName: string;
description: string;
localPath: string;
tag: "example" | "first-party";
experimental: boolean;
}
export interface PluginLocalFolderProblem {
@ -215,10 +216,10 @@ export const pluginsApi = {
api.get<PluginRecord[]>(`/plugins${status ? `?status=${status}` : ""}`),
/**
* List bundled example plugins available from the current repo checkout.
* List bundled plugin packages available from the current repo checkout.
*/
listExamples: () =>
api.get<AvailablePluginExample[]>("/plugins/examples"),
listBundled: () =>
api.get<AvailableBundledPlugin[]>("/plugins/examples"),
/**
* Fetch a single plugin record by its UUID or plugin key.

View file

@ -43,6 +43,31 @@ function getPluginErrorSummary(plugin: PluginRecord): string {
return firstNonEmptyLine(plugin.lastError) ?? "Plugin entered an error state without a stored error message.";
}
function isExperimentalPluginIdentity(input: {
packageName?: string | null;
packagePath?: string | null;
manifestJson?: PluginRecord["manifestJson"] | null;
bundledExperimental?: boolean;
}) {
if (input.bundledExperimental) return true;
const packageName = input.packageName ?? "";
const packagePath = input.packagePath ?? "";
if (packageName.includes("sandbox") || packagePath.includes("sandbox")) return true;
return input.manifestJson?.environmentDrivers?.some((driver) => driver.kind === "sandbox_provider") === true;
}
function ExperimentalBadge() {
return (
<Badge
variant="outline"
className="border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200"
>
Experimental
</Badge>
);
}
/**
* PluginManager page component.
*
@ -85,9 +110,9 @@ export function PluginManager() {
queryFn: () => pluginsApi.list(),
});
const examplesQuery = useQuery({
const bundledQuery = useQuery({
queryKey: queryKeys.plugins.examples,
queryFn: () => pluginsApi.listExamples(),
queryFn: () => pluginsApi.listBundled(),
});
const invalidatePluginQueries = () => {
@ -144,9 +169,9 @@ export function PluginManager() {
});
const installedPlugins = plugins ?? [];
const examples = examplesQuery.data ?? [];
const bundledPlugins = bundledQuery.data ?? [];
const installedByPackageName = new Map(installedPlugins.map((plugin) => [plugin.packageName, plugin]));
const examplePackageNames = new Set(examples.map((example) => example.packageName));
const bundledByPackageName = new Map(bundledPlugins.map((plugin) => [plugin.packageName, plugin]));
const errorSummaryByPluginId = useMemo(
() =>
new Map(
@ -223,30 +248,37 @@ export function PluginManager() {
<Badge variant="outline">Bundled</Badge>
</div>
{examplesQuery.isLoading ? (
{bundledQuery.isLoading ? (
<div className="text-sm text-muted-foreground">Loading bundled plugins...</div>
) : examplesQuery.error ? (
) : bundledQuery.error ? (
<div className="text-sm text-destructive">Failed to load bundled plugins.</div>
) : examples.length === 0 ? (
) : bundledPlugins.length === 0 ? (
<div className="rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground">
No bundled plugins were found in this checkout.
</div>
) : (
<ul className="divide-y rounded-md border bg-card">
{examples.map((example) => {
const installedPlugin = installedByPackageName.get(example.packageName);
{bundledPlugins.map((bundledPlugin) => {
const installedPlugin = installedByPackageName.get(bundledPlugin.packageName);
const installPending =
installMutation.isPending &&
installMutation.variables?.isLocalPath &&
installMutation.variables.packageName === example.localPath;
installMutation.variables.packageName === bundledPlugin.localPath;
return (
<li key={example.packageName}>
<li key={bundledPlugin.packageName}>
<div className="flex items-center gap-4 px-4 py-3">
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
<span className="font-medium">{example.displayName}</span>
<Badge variant="outline">{example.tag === "first-party" ? "First-party" : "Example"}</Badge>
<span className="font-medium">{bundledPlugin.displayName}</span>
<Badge variant="outline">
{bundledPlugin.tag === "first-party" ? "First-party" : "Example"}
</Badge>
{isExperimentalPluginIdentity({
packageName: bundledPlugin.packageName,
packagePath: bundledPlugin.localPath,
bundledExperimental: bundledPlugin.experimental,
}) && <ExperimentalBadge />}
{installedPlugin ? (
<Badge
variant={installedPlugin.status === "ready" ? "default" : "secondary"}
@ -258,8 +290,8 @@ export function PluginManager() {
<Badge variant="secondary">Not installed</Badge>
)}
</div>
<p className="mt-1 text-sm text-muted-foreground">{example.description}</p>
<p className="mt-1 text-xs text-muted-foreground">{example.packageName}</p>
<p className="mt-1 text-sm text-muted-foreground">{bundledPlugin.description}</p>
<p className="mt-1 text-xs text-muted-foreground">{bundledPlugin.packageName}</p>
</div>
<div className="flex items-center gap-2 shrink-0">
{installedPlugin ? (
@ -286,12 +318,12 @@ export function PluginManager() {
disabled={installPending || installMutation.isPending}
onClick={() =>
installMutation.mutate({
packageName: example.localPath,
packageName: bundledPlugin.localPath,
isLocalPath: true,
})
}
>
{installPending ? "Installing..." : "Install Example"}
{installPending ? "Installing..." : "Install"}
</Button>
)}
</div>
@ -333,9 +365,19 @@ export function PluginManager() {
>
{plugin.manifestJson.displayName ?? plugin.packageName}
</Link>
{examplePackageNames.has(plugin.packageName) && (
<Badge variant="outline">Example</Badge>
{bundledByPackageName.has(plugin.packageName) && (
<Badge variant="outline">
{bundledByPackageName.get(plugin.packageName)?.tag === "first-party"
? "First-party"
: "Example"}
</Badge>
)}
{isExperimentalPluginIdentity({
packageName: plugin.packageName,
packagePath: plugin.packagePath,
manifestJson: plugin.manifestJson,
bundledExperimental: bundledByPackageName.get(plugin.packageName)?.experimental,
}) && <ExperimentalBadge />}
</div>
<div>
<p className="text-xs text-muted-foreground mt-0.5 truncate" title={plugin.packageName}>