Skip to content

feat: safe, revertable plugin system with agent control - #1

Open
Josephivgi wants to merge 2 commits into
mainfrom
devin/plugin-system
Open

Josephivgi wants to merge 2 commits into
mainfrom
devin/plugin-system

Conversation

@Josephivgi

@Josephivgi Josephivgi commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Problem

T3 Code has no extension mechanism. There is no way to add UI contributions (header icons, panels, themes) without forking the app, and agents driving the server have no way to manage extensions.

Change

Adds a declarative plugin system with safety and reversibility built in:

  • Contracts (packages/contracts): PluginManifest/PluginRecord schemas, a capability allowlist (ui:header-icon, ui:panel, ui:theme-css), and a plugins group on the environment HTTP API (list, install, enable, disable, remove, revert).
  • Server (apps/server/src/plugins): PluginManager service validates manifests, enforces the declared capability allowlist, copies assets into the server plugins dir, resolves assets only inside a plugin's own directory, and journals a snapshot before every mutation so install/enable/disable/remove can be reverted. /api/plugin-assets/<pluginId>/<asset> serves assets with nosniff and a sandboxed CSP for HTML.
  • Agent control (apps/server/src/mcp/toolkits/plugins): five MCP tools (t3_plugins_list/install/enable/disable/remove/revert) give agents the full lifecycle.
  • Web (apps/web): a Plugins settings panel (install by path, enable/disable switch, remove, revert-last-change), a useEnvironmentPlugins hook with cross-view propagation (event bus + visible-tab polling), and PluginContributions in the chat header rendering ui:header-icon buttons and sandboxed-iframe ui:panel contributions plus ui:theme-css stylesheets.
  • Examples (examples/plugins): a devin-icon header-icon plugin and a README describing the manifest format and safety model.

Scope

Feature work on this fork (user-requested plugin system). Bug-fix-only scope of upstream does not apply here.

Verification

  • vp run typecheck: clean across all workspaces. vp check: 0 errors.
  • vp test run src/cli/: pre-existing Windows quoting/launcher failures in up/pair/invocation tests, none related to plugins.
  • End-to-end verification with computer use recorded (see the E2E comment below): install/enable/disable/remove/revert exercised through the UI, the Devin icon verified in the chat header with live propagation, unsafe manifests refused, and refusal reasons surfaced to the UI.

Done by Devin (Cognition AI).

Link to Devin session: https://app.devin.ai/sessions/013a096f76254db791df0bf496875fb8
Open in Devin Desktop: https://app.devin.ai/desktop/session/013a096f76254db791df0bf496875fb8?variant=devin
Requested by: @Josephivgi

- contracts: PluginManifest/PluginRecord/journal schemas + plugins API
  group on the environment HTTP API (list/install/enable/disable/
  remove/revert) and shared plugin contract exports
- server: PluginManager service — manifest validation, capability
  allowlist, sandboxed asset resolution, journal snapshots so every
  mutation can be reverted; /api/plugin-assets route serving plugin
  assets with nosniff + sandboxed CSP for HTML
- mcp: plugins toolkit (list/install/enable/disable/remove/revert)
  so agents have full lifecycle control
- web: Plugins settings panel, useEnvironmentPlugins hook,
  PluginContributions (header icons, sandboxed panels, theme css)
  mounted in the chat header, settings route/search/sidebar entries
- examples: devin-icon plugin + plugins README

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Josephivgi Josephivgi self-assigned this Nov 19, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T08:28:43.764758Z 92c893c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL labels Nov 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92c893c87a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export function useEnvironmentPluginsApi(environmentId: EnvironmentId | null): PluginsApi | null {
const prepared = usePreparedConnection(environmentId);
if (prepared._tag !== "Some") return null;
return makePluginsApi(prepared.value.httpBaseUrl);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Memoize the plugins API per environment

When a connected chat or settings view uses this hook, makePluginsApi returns a new object on every render. useEnvironmentPlugins keys its fetch effect on api and updates plugin state after each response, so each list request triggers a render and another /api/plugins request indefinitely. Memoize the API by httpBaseUrl so state updates do not restart the fetch.

Useful? React with 👍 / 👎.

Comment on lines +86 to +87
for (const href of contributes.themeCss ?? []) {
themeCss.push({ pluginId: plugin.manifest.id, href });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat the theme stylesheet as a single asset path

PluginContributes.themeCss is a single PluginAssetPath string, not an array. Iterating it here creates one contribution per character, so the generated links point to individual characters rather than the stylesheet and the plugin theme is not applied. Add the single path directly to themeCss instead.

Useful? React with 👍 / 👎.

seq,
plugins: {
...state.plugins,
[candidate.pluginId]: { enabled: true, installedAt: now, updatedAt: now },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the removed plugin's previous state on revert

If a disabled plugin is removed and then reverted, this branch recreates it as enabled, so the revert activates a plugin that was disabled before removal. It also drops the prior source and resets its timestamps. Preserve and restore the pre-remove PluginStateEntry so revert undoes the removal rather than creating a new default entry.

Useful? React with 👍 / 👎.

Comment on lines +165 to +167
...(isHtml
? { "content-security-policy": "sandbox allow-scripts allow-forms allow-popups" }
: {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Sandbox SVG assets served by the plugin route

If an installed plugin contributes an SVG containing script and a user opens its asset URL (for example, through the plugin's href), the route serves it as an SVG document but only adds a sandbox CSP for HTML. The SVG script can then run as a same-origin document and access the app's DOM and APIs, bypassing the panel iframe sandbox. Apply the SVG sandbox policy to these responses too.

Useful? React with 👍 / 👎.

return;
}
for (const entry of entries) {
if (limit.files > MAX_PLUGIN_FILES) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject plugin packages that exceed the file-count limit

When a source contains more than 256 files, this walk returns without recording a problem, so checkPluginDir accepts the package. Installation then copies the entire source tree rather than the scanned file list, bypassing the file-count and remaining size checks and potentially copying an unbounded amount of data into the state directory. Record a refusal at the limit and copy only validated files.

Useful? React with 👍 / 👎.

seq,
plugins: {
...state.plugins,
[candidate.pluginId]: { enabled: true, installedAt: now, updatedAt: now },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the removed plugin's previous state on revert

If a disabled plugin is removed and then reverted, this branch recreates it as enabled, so the revert activates a plugin that was disabled before removal. It also drops the prior source and resets its timestamps. Preserve and restore the pre-remove PluginStateEntry so revert undoes the removal rather than creating a new default entry.

AGENTS.md reference: AGENTS.md:L74-L74

Useful? React with 👍 / 👎.

headers: { "content-type": "application/json" },
body: JSON.stringify(input.body),
};
const response = await fetch(`${input.baseUrl}${input.path}`, init);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize the base URL before appending plugin paths

When a prepared connection's httpBaseUrl ends in /—as configured targets serialized with URL.toString() do—this concatenation requests //api/plugins instead of the registered /api/plugins route, so plugin management fails for that environment. pluginAssetUrl uses the same construction and breaks asset URLs in that case; normalize the base URL before appending either path.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.


const readJournal = (): Array<StoredJournalEntry> => {
const raw = readPluginFileGuarded(journalPath, MAX_JOURNAL_READ_BYTES);
if (raw === null) return [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep journal history readable as it grows

Once journal.jsonl grows past 1 MiB, readPluginFileGuarded returns null and this function treats the entire journal as empty, while mutations continue appending to it. From then on the UI loses the history and revert cannot undo any operation. Retain a bounded tail or rotate the journal instead of discarding all history.

AGENTS.md reference: AGENTS.md:L74-L74

Useful? React with 👍 / 👎.

headers: { "content-type": "application/json" },
body: JSON.stringify(input.body),
};
const response = await fetch(`${input.baseUrl}${input.path}`, init);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the prepared connection's authorization for plugin API calls

When the UI manages a prepared connection using Bearer or DPoP authentication, these fetches send only cookies and content type, omitting the connection's authorization headers and proof. EnvironmentAuthenticatedAuth then rejects list and mutation requests, making plugin management unusable for those remote sessions. Route these calls through the shared environment HTTP auth client.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Comment on lines +84 to +87
return `${api.baseUrl}/api/plugin-assets/${encodeURIComponent(pluginId)}/${assetPath
.split("/")
.map(encodeURIComponent)
.join("/")}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mint media tickets for plugin asset URLs

For a connection authenticated with Bearer or DPoP, this builds a bare asset URL without a wsTicket. The <img>, <link>, and iframe requests cannot attach authorization headers, while the asset route authenticates them as media requests; icons, panels, and theme stylesheets therefore fail to load in those remote sessions. Mint a media ticket for the asset URLs.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

- t3_plugins_list: omit parameters (Schema.Struct({}) serializes to
  {"not":{"type":"null"}} and crashes McpSchema.Tool registration,
  preventing server boot)
- pluginsApi: strip trailing slashes from httpBaseUrl so /api paths
  hit the Vite proxy instead of returning index.html
- propagate plugin mutations across mounted views via a change bus
  plus visible-tab polling, so header icons update live
- surface PluginRefusedError.problem as detail on the 400 response
  so refusal reasons reach the UI

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Josephivgi

Copy link
Copy Markdown
Owner Author

E2E verification — plugin system

Tested on devin/plugin-system via node scripts/dev-runner.ts dev + paired browser (computer-use driven UI + in-process PluginManager checks, 21/21).

Two blocking bugs were found by testing and fixed in d45de9bb (server boot crash from Schema.Struct({}) tool params; //api URLs from trailing-slash base URL). Re-tested on the shipped commit — all checks pass.

Verified

  • Settings → Plugins page (sidebar, route, search); list loads clean
  • Install by path → Devin v1.0.0 row, devin-icon · ui:header-icon, enabled
  • Header icon renders from /api/plugin-assets/devin-icon/icon.svg (200, image/svg+xml, nosniff); click opens devin.ai
  • Disable/enable → journal entries, icon updates live — in the mounted header DOM via the event bus, and across browser tabs via polling (~7s)
  • Remove → files moved to trash; "Revert last change" restores it enabled
  • Safety: under-declared capability and ../ traversal manifests refused, store untouched; refusal toast now shows the server's reason (contributes.headerIcons requires capability "ui:header-icon", which the manifest does not declare)
  • t3_plugins_* MCP tools register and advertise valid type:"object" schemas (actual agent invocation untested: /mcp needs OAuth credentials and no provider CLI is installed on the test box)

Devin icon in chat header
Plugin installed and enabled
Refusal toast with specific reason
Revert restored plugin

@github-actions

Copy link
Copy Markdown

Thread transfer impact

⚠️ The latest CI run did not produce a thread transfer result for d45de9b.

This comment will update automatically after the next completed run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant