Skip to content

Commit f4387b7

Browse files
authored
feat(plugins): support the Agent Plugins bundle format (#120115)
* feat(plugins): support the Agent Plugins bundle format * docs(plugins): document the Agent Plugins bundle format * test(agents): preserve agent bundle runtime discovery * fix(plugins): isolate Agent Plugins data-dir failures and align MCP support reporting * docs(plugins): list Agent Plugins in the canonical plugin-format guides * fix(plugins): gate Agent Plugins detection on schema, pure inspection, root-relative cwd * fix(plugins): record Agent Plugins data-dir ownership explicitly * docs(plugins): cover Agent Plugins in the CLI install detection guide * fix(plugins): carry Agent Plugins data-dir and transport contracts through external MCP projections
1 parent 06d5e44 commit f4387b7

43 files changed

Lines changed: 1887 additions & 206 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/cli/plugins.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Bundled plugins ship with OpenClaw. Some are enabled by default (for example bun
6464

6565
Native OpenClaw plugins ship `openclaw.plugin.json` with an inline JSON Schema (`configSchema`, even if empty). Compatible bundles use their own bundle manifests instead.
6666

67-
`plugins list` shows `Format: openclaw` or `Format: bundle`. Verbose list/info output also shows the bundle subtype (`codex`, `claude`, or `cursor`) plus detected bundle capabilities.
67+
`plugins list` shows `Format: openclaw` or `Format: bundle`. Verbose list/info output also shows the bundle subtype (`agent (Agent Plugins)`, `codex`, `claude`, or `cursor`) plus detected bundle capabilities.
6868
</Note>
6969

7070
## Author
@@ -308,6 +308,7 @@ openclaw plugins install <plugin-name> --marketplace ./my-marketplace
308308
For local paths and archives, OpenClaw auto-detects:
309309

310310
- native OpenClaw plugins (`openclaw.plugin.json`)
311+
- Agent Plugins bundles (root `plugin.json` declaring the [Agent Plugins](https://agent-plugins.org) `$schema`)
311312
- Codex-compatible bundles (`.codex-plugin/plugin.json`)
312313
- Claude-compatible bundles (`.claude-plugin/plugin.json`, or the default Claude component layout when that manifest file is absent)
313314
- Cursor-compatible bundles (`.cursor-plugin/plugin.json`)
@@ -321,7 +322,7 @@ top-level script files as local helpers. List standalone files explicitly in
321322
`plugins.load.paths` instead.
322323

323324
<Note>
324-
Compatible bundles install into the normal plugin root and participate in the same list/info/enable/disable flow. Today, bundle skills, Claude command-skills, Claude `settings.json` defaults, Claude `.lsp.json` / manifest-declared `lspServers` defaults, Cursor command-skills, and compatible Codex hook directories are supported; other detected bundle capabilities are shown in diagnostics/info but are not yet wired into runtime execution.
325+
Compatible bundles install into the normal plugin root and participate in the same list/info/enable/disable flow. Today, bundle skills, bundle MCP servers, Agent Plugins skills/MCP (with the `PLUGIN_ROOT`/`PLUGIN_DATA` subprocess contract), Claude command-skills, Claude `settings.json` defaults, Claude `.lsp.json` / manifest-declared `lspServers` defaults, Cursor command-skills, and compatible Codex hook directories are supported; other detected bundle capabilities are shown in diagnostics/info but are not yet wired into runtime execution. See [Plugin bundles](/plugins/bundles) for the per-format mapping.
325326
</Note>
326327

327328
Use `-l`/`--link` to point at a local plugin directory without copying it (adds

‎docs/plugins/bundles.md‎

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
2-
summary: "Install and use Codex, Claude, and Cursor bundles as OpenClaw plugins"
2+
summary: "Install and use Agent Plugins, Codex, Claude, and Cursor bundles as OpenClaw plugins"
33
read_when:
4-
- You want to install a Codex, Claude, or Cursor-compatible bundle
4+
- You want to install an Agent Plugins, Codex, Claude, or Cursor-compatible bundle
55
- You need to understand how OpenClaw maps bundle content into native features
66
- You are debugging bundle detection or missing capabilities
77
title: "Plugin bundles"
88
---
99

10-
OpenClaw can install plugins from three external ecosystems: **Codex**, **Claude**,
11-
and **Cursor**. These are called **bundles** - content and metadata packs that
12-
OpenClaw maps into native features like skills, hooks, and MCP tools.
10+
OpenClaw can install plugins from four external ecosystems: the vendor-neutral
11+
[**Agent Plugins**](https://agent-plugins.org) standard, plus **Codex**,
12+
**Claude**, and **Cursor**. These are called **bundles** - content and metadata
13+
packs that OpenClaw maps into native features like skills, hooks, and MCP tools.
1314

1415
<Info>
1516
Bundles are **not** the same as native OpenClaw plugins. Native plugins run
@@ -19,11 +20,11 @@ OpenClaw maps into native features like skills, hooks, and MCP tools.
1920

2021
## Why bundles exist
2122

22-
Many useful plugins are published in Codex, Claude, or Cursor format. Instead
23-
of requiring authors to rewrite them as native OpenClaw plugins, OpenClaw
24-
detects these formats and maps their supported content into the native feature
25-
set. You can install a Claude command pack or a Codex skill bundle and use it
26-
immediately.
23+
Many useful plugins are published in the Agent Plugins, Codex, Claude, or
24+
Cursor format. Instead of requiring authors to rewrite them as native OpenClaw
25+
plugins, OpenClaw detects these formats and maps their supported content into
26+
the native feature set. You can install an Agent Plugins package, a Claude
27+
command pack, or a Codex skill bundle and use it immediately.
2728

2829
## Install a bundle
2930

@@ -51,8 +52,8 @@ immediately.
5152
openclaw plugins inspect <id>
5253
```
5354

54-
Bundles show `Format: bundle` plus a `Bundle format:` value of `codex`,
55-
`claude`, or `cursor`.
55+
Bundles show `Format: bundle` plus a `Bundle format:` value of
56+
`agent (Agent Plugins)`, `codex`, `claude`, or `cursor`.
5657

5758
</Step>
5859

@@ -79,6 +80,7 @@ is detected but not yet wired.
7980
| Commands | `commands/` and `.cursor/commands/` treated as skill roots | Claude, Cursor |
8081
| Hook packs | OpenClaw-style `HOOK.md` + `handler.ts` layouts | Codex |
8182
| MCP tools | Bundle MCP config merged into embedded OpenClaw settings; supported stdio and HTTP servers loaded | All formats |
83+
| Env contract | `PLUGIN_ROOT` and `PLUGIN_DATA` env vars plus placeholder expansion for stdio MCP servers | Agent Plugins |
8284
| LSP servers | Claude `.lsp.json` and manifest-declared `lspServers` merged into embedded OpenClaw LSP defaults | Claude |
8385
| Settings | Claude `settings.json` imported as embedded OpenClaw defaults | Claude |
8486

@@ -210,6 +212,38 @@ These are recognized and shown in diagnostics, but OpenClaw does not run them:
210212
## Bundle formats
211213

212214
<AccordionGroup>
215+
<Accordion title="Agent Plugins bundles">
216+
Marker: `plugin.json` at the package root, per the open
217+
[Agent Plugins 1.0.0 standard](https://agent-plugins.org)
218+
219+
Optional content: `skills/`, `mcp.json`
220+
221+
Format behavior:
222+
223+
- The manifest is strict JSON (not JSON5). OpenClaw requires a non-empty
224+
`name`; other manifest fields are optional and unknown fields are ignored
225+
- Immediate child directories of `skills/` that contain a `SKILL.md` load as
226+
skills; children without one are skipped with a warning, and deeper
227+
directories are not scanned
228+
- `mcp.json` must declare the 1.0.0 `$schema` and an `mcpServers` object
229+
only; `stdio`, `streamable-http`, and legacy `sse` transports are
230+
supported
231+
- stdio servers launch with `PLUGIN_ROOT` (the plugin root) and
232+
`PLUGIN_DATA` (a persistent per-plugin data directory OpenClaw creates
233+
under its state dir) in their environment; `${PLUGIN_ROOT}` and
234+
`${PLUGIN_DATA}` placeholders expand in `args`, `env` values, and `cwd`
235+
in a single pass
236+
- A stdio `command` must be a bare executable name or a `./`-relative path
237+
inside the plugin; `cwd` must stay inside `PLUGIN_ROOT` or `PLUGIN_DATA`
238+
- Invalid `mcp.json` disables MCP for the plugin with a diagnostic while
239+
skills keep loading; invalid individual server entries are skipped
240+
- `.mcp.json` (dot-prefixed) and inline manifest `mcpServers` are **not**
241+
read for this format; the standard's closed schema wins
242+
- Reverse-domain client directories and manifest `extensions` namespaces
243+
are ignored, as the standard allows for incremental adoption
244+
245+
</Accordion>
246+
213247
<Accordion title="Codex bundles">
214248
Markers: `.codex-plugin/plugin.json`
215249

@@ -253,10 +287,15 @@ These are recognized and shown in diagnostics, but OpenClaw does not run them:
253287
OpenClaw checks for native plugin format first:
254288

255289
1. `openclaw.plugin.json` or a valid `package.json` with `openclaw.extensions` - treated as a **native plugin**
256-
2. Bundle markers (`.codex-plugin/`, `.claude-plugin/`, or default Claude/Cursor layout) - treated as a **bundle**
257-
258-
If a directory contains both, OpenClaw uses the native path. This prevents
259-
dual-format packages from being partially installed as bundles.
290+
2. Client-specific bundle markers (`.codex-plugin/`, `.cursor-plugin/`, `.claude-plugin/`) - treated as a **bundle** in that format
291+
3. A root `plugin.json` - treated as an **Agent Plugins bundle**
292+
4. Default manifestless Claude layout (`skills/`, `commands/`, `.mcp.json`, ...) - treated as a **Claude bundle**
293+
294+
If a package carries both a client-specific marker and a root `plugin.json`,
295+
the client-specific format wins so its richer mappings (commands, hooks,
296+
settings) are preserved. If a directory contains both a native manifest and
297+
bundle markers, OpenClaw uses the native path. This prevents dual-format
298+
packages from being partially installed as bundles.
260299

261300
## Runtime dependencies and cleanup
262301

‎docs/plugins/manifest.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ read_when:
66
title: "Plugin manifest"
77
---
88

9-
This page covers the **native OpenClaw plugin manifest**, `openclaw.plugin.json`. For compatible bundle layouts (Codex, Claude, Cursor), see [Plugin bundles](/plugins/bundles).
9+
This page covers the **native OpenClaw plugin manifest**, `openclaw.plugin.json`. For compatible bundle layouts (Agent Plugins, Codex, Claude, Cursor), see [Plugin bundles](/plugins/bundles).
1010

1111
Compatible bundle formats use their own manifest files instead:
1212

13+
- Agent Plugins bundle: `plugin.json` at the package root, per the open [Agent Plugins standard](https://agent-plugins.org)
1314
- Codex bundle: `.codex-plugin/plugin.json`
1415
- Claude bundle: `.claude-plugin/plugin.json`, or the default Claude component layout with no manifest
1516
- Cursor bundle: `.cursor-plugin/plugin.json`

‎docs/tools/plugin.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ paths.
228228

229229
OpenClaw recognizes two plugin formats:
230230

231-
| Format | How it loads | Use when |
232-
| ---------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
233-
| Native OpenClaw plugin | `openclaw.plugin.json` plus a runtime module loaded in process | You are installing or building OpenClaw-specific runtime capabilities |
234-
| Compatible bundle | Codex, Claude, or Cursor plugin layout mapped into OpenClaw plugin inventory | You are reusing compatible skills, commands, hooks, or bundle metadata |
231+
| Format | How it loads | Use when |
232+
| ---------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
233+
| Native OpenClaw plugin | `openclaw.plugin.json` plus a runtime module loaded in process | You are installing or building OpenClaw-specific runtime capabilities |
234+
| Compatible bundle | Agent Plugins, Codex, Claude, or Cursor plugin layout mapped into OpenClaw plugin inventory | You are reusing compatible skills, commands, hooks, or bundle metadata |
235235

236236
Both formats appear in `openclaw plugins list`, `openclaw plugins inspect`,
237237
`openclaw plugins enable`, and `openclaw plugins disable`. See

‎src/agents/agent-bundle-mcp-runtime-config.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { loadSessionMcpConfig } from "./agent-bundle-mcp-runtime-config.js";
66
const mocks = vi.hoisted(() => ({
77
loadCount: 0,
88
diagnostics: [] as Array<{ pluginId: string; message: string }>,
9+
prepareDataDirsByServer: {} as Record<string, { pluginId: string; dataDir: string }>,
910
}));
1011

1112
vi.mock("./embedded-agent-mcp.js", () => ({
@@ -22,17 +23,49 @@ vi.mock("./embedded-agent-mcp.js", () => ({
2223
return {
2324
diagnostics: structuredClone(mocks.diagnostics),
2425
mcpServers: servers,
26+
prepareDataDirsByServer: structuredClone(mocks.prepareDataDirsByServer),
2527
};
2628
},
2729
}));
2830

2931
afterEach(() => {
3032
mocks.loadCount = 0;
3133
mocks.diagnostics = [];
34+
mocks.prepareDataDirsByServer = {};
3235
clearPluginMetadataLifecycleCaches();
3336
});
3437

3538
describe("session MCP config discovery cache", () => {
39+
it("keeps Agent Plugins launch ownership out of fingerprints and filtered partitions", () => {
40+
const cfg = {
41+
mcp: { servers: { alpha: { command: "alpha" }, beta: { command: "beta" } } },
42+
};
43+
mocks.prepareDataDirsByServer = {
44+
alpha: { pluginId: "agent-plugin", dataDir: "/state/one" },
45+
beta: { pluginId: "agent-plugin", dataDir: "/state/two" },
46+
};
47+
const first = loadSessionMcpConfig({ workspaceDir: "/ownership-workspace", cfg });
48+
const filtered = loadSessionMcpConfig({
49+
workspaceDir: "/ownership-workspace",
50+
cfg,
51+
includeServerNames: new Set(["alpha"]),
52+
});
53+
54+
expect(first.loaded.prepareDataDirsByServer).toEqual({
55+
alpha: { pluginId: "agent-plugin", dataDir: "/state/one" },
56+
beta: { pluginId: "agent-plugin", dataDir: "/state/two" },
57+
});
58+
expect(filtered.loaded.prepareDataDirsByServer).toEqual({
59+
alpha: { pluginId: "agent-plugin", dataDir: "/state/one" },
60+
});
61+
clearPluginMetadataLifecycleCaches();
62+
mocks.prepareDataDirsByServer = {
63+
alpha: { pluginId: "agent-plugin", dataDir: "/different/state" },
64+
};
65+
const changedOwnership = loadSessionMcpConfig({ workspaceDir: "/ownership-workspace", cfg });
66+
expect(changedOwnership.fingerprint).toBe(first.fingerprint);
67+
});
68+
3669
it("reuses immutable discovery across full and filtered catalog preparation", () => {
3770
const cfg = {
3871
mcp: {

‎src/agents/agent-bundle-mcp-runtime-config.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,21 @@ export function loadSessionMcpConfig(params: {
265265
includeServerNames: params.includeServerNames,
266266
excludeServerNames: params.excludeServerNames,
267267
});
268+
const prepareDataDirsByServer = Object.fromEntries(
269+
Object.entries(discovery.loaded.prepareDataDirsByServer ?? {}).filter(([serverName]) =>
270+
Object.hasOwn(mcpServers, serverName),
271+
),
272+
);
268273
const fingerprintServers = params.redactConnectionServerNames?.size
269274
? redactMcpServersForFingerprint(mcpServers, params.redactConnectionServerNames)
270275
: mcpServers;
271276
const result = {
272277
loaded: {
273278
...discovery.loaded,
274279
mcpServers,
280+
// Launch ownership is not serialized or fingerprinted; the injected env path already
281+
// participates in the server fingerprint and this sidecar only authorizes mkdir.
282+
prepareDataDirsByServer,
275283
},
276284
fingerprint: createCatalogFingerprint({
277285
servers: fingerprintServers,

0 commit comments

Comments
 (0)