A plugin declares `commands` in plugin.json — each one names a declared action, with a summary, its args and how to print the answer — and gets `ai-agent plugin <id> <command> …` and, opt-in (`"mcp": true`), the MCP tool `plugin_<id>_<command>`. Core no longer names any plugin (Gabriel's form ai-agent-cli-and-mcp-for-live-plugins_fevcts: manifest commands, namespaced under `plugin`, MCP opt-in, guests by their grants). - backend/plugins/commands.py: validation (names, typed args, positional order, output text|rows, ≤ 64-char tool names, no commands for a plugin named like a core verb) and the caller's catalogue; GET /api/plugins/commands (plugins.use — a guest's CLI and AI-app connection see the plugins granted to them, never an ownerOnly action). Not in the approval fingerprint: a command only reaches an action the plugin already declares, through the same route. The consent card lists them. - cli/plugin_commands.py: the per-plugin argparse parser, table/text printing, `ai-agent plugin commands`, `ai-agent plugin call ID ACTION` (any action, raw), and the MCP tool specs. readOnly actions go by GET ?payload=, so read-only MCP connections work. - cli/mcp_tools.py: tools/list appends the plugin tools (read group when readOnly, run otherwise; none on a worker-bound connection); tools/call runs them. - Removed the hard-coded plugin surfaces: `ai-agent plans|memories|goals`, MCP browse plans|goals|memories, read_document, work_on_goal (goals is not used — Gabriel). Plans and memories come back as their plugins' commands. This also fixes read-only MCP connections, which got "this connection is read-only" on plans and memories since they moved to plugins (the CLI POSTed). `ai-agent plans` now says where its commands are. - openapi.json + orval regenerated, authz golden matrix (+1 route), docs (plugins.md "Commands", mcp.md, CLAUDE.md, create-plugin skill). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 KiB
11 KiB
name, description, portable, trigger_words
| name | description | portable | trigger_words | ||||||
|---|---|---|---|---|---|---|---|---|---|
| create-plugin | Build, validate, test, and live-install an ai-agent plugin (v1 + v2 + v3) — manifest (`plugin.json`), write-only secrets, allowlisted HTTP proxy, declarative or sandboxed Settings/Nav UI, scheduled non-LLM jobs, inbound webhooks, sandboxed backend actions, and a live-injected skill (`SKILL.md` + scripts). Use when creating a new ai-agent plugin, migrating an existing ai-agent feature into a live plugin, or editing/reloading a plugin in `~/projects/ai-agent-plugins` or a user's plugin repo. | true |
|
create-plugin — build & live-install an ai-agent plugin
An ai-agent live plugin is a self-contained folder with a plugin.json manifest (schema 1) plus optional skill/, ui/, jobs/, and handlers/. It installs live with zero Docker or Vite rebuild.
Where plugin sources & data live
- Hub / operator plugins:
~/projects/ai-agent-plugins/plugins/<id>/(private Gitea repogabrielvidal/ai-agent-plugins). - User-created plugins: their own folder/Gitea repo under
~/projects/plugin-<uid>-<slug>/. - Runtime data (NEVER committed to git):
/data/plugins/on the hub (installed.json,0600per-user/hub secrets, per-user storagedata/<uid>/<id>/, materializedlive-skills/<uid>/<id>/).
Folder layout
<plugin-dir>/
├── plugin.json # required manifest (schema: 1)
├── skill/ # optional — injected live into runs + labsync
│ ├── SKILL.md
│ └── scripts/
│ ├── hubclient.py # stdlib client for AIA_TOOLS_URL / hub.json
│ └── <tool> # chmod +x CLI calling plugins/<id>/...
├── ui/ # optional (v2) — sandboxed HTML pages/cards/slots
├── jobs/ # optional (v1) — scheduled non-LLM scripts
└── handlers/ # optional (v3) — sandboxed action scripts
Manifest reference (plugin.json)
Every unknown top-level key is rejected. Paths must stay inside the plugin directory (no ..).
{
"schema": 1,
"id": "my-plugin",
"name": "My Plugin",
"version": "1.0.0",
"description": "One-sentence summary of what it does",
"icon": "puzzle",
"author": "gabrielvidal",
"skill": { "dir": "skill", "name": "my-plugin" },
"secrets": [
{
"key": "token",
"label": "API Token",
"placeholder": "sk_...",
"help": "Stored write-only on the hub; never returned to browser or runs.",
"scope": "user",
"required": true
}
],
"settings": {
"subtitle": "Short subtitle (<= 8 words)",
"instructions": "1. Open the provider dashboard...\n2. Create a read-only token...\n3. Paste it above.",
"fields": [
{ "key": "timezone", "label": "Timezone", "type": "text", "default": "Europe/Paris" }
],
"testAction": "inspect",
"statusAction": "status"
},
"proxy": {
"baseUrl": "https://api.example.com/v1",
"internal": false,
"stream": false,
"auth": { "in": "header", "name": "Authorization", "prefix": "Bearer ", "secret": "token" },
"headers": { "X-User": "guest-{{user.id}}" },
"allow": [
{ "method": "GET", "path": "^me$" },
{ "method": "GET", "path": "^items/[A-Za-z0-9_-]+$" }
],
"denyParams": ["access_token", "method"],
"stripResponseKeys": ["access_token"],
"scrubSecrets": true,
"maxBytes": 20971520,
"inspect": {
"method": "GET",
"path": "me/permissions",
"requireOnlyScopes": ["read_only_scope"]
}
},
"managed": {
"defaultForGuests": false,
"allowUserSecretOverride": false,
"metered": false,
"grantFields": [
{ "key": "allowPro", "label": "Allow Pro models", "type": "checkbox", "default": false }
],
"limits": { "inFlight": 4, "jobsPerDay": 40, "defaultMonthlyBudgetUsd": 5.0 },
"keyHealth": { "alertLimit": 20.0, "currency": "EUR", "pushAtPct": 80, "pushOnBreak": true }
},
"storage": { "maxMb": 50 },
"schedules": [
{ "id": "daily", "cron": "0 7 * * *", "script": "jobs/sync.py", "timeoutSec": 180, "description": "Daily sync" }
],
"ui": {
"settingsHtml": "ui/settings.html",
"pages": [{ "id": "board", "label": "Board", "nav": "dashboards", "html": "ui/board.html" }],
"toolCards": [{ "id": "card", "match": { "tool": "shell", "commandRegex": "\\bmytool\\b" }, "label": "My Tool", "html": "ui/card.html", "height": 180 }],
"slots": [{ "id": "badge", "where": "project.detail", "html": "ui/slot.html", "height": 120 }]
},
"events": [
{ "id": "on-done", "on": ["conversation.finished"], "url": "https://example.com/hook", "secret": "token" }
],
"webhooks": [
{ "id": "inbound", "mode": "notify", "titleTemplate": "Update: {{title}}" }
],
"actions": {
"status": { "script": "handlers/status.py", "timeoutSec": 20, "description": "Read status summary" }
},
"resources": [
{ "id": "ticket", "label": "Ticket", "urlRegex": "https://example\\.com/t/(\\d+)", "color": "#2563eb" }
],
"capabilities": []
}
Key rules
- Secrets stay on the hub. Never pass raw API tokens into agent runs, skills, or browser responses.
"scope": "user"(default): each user pastes their own key on/settings/plugin/<id>."scope": "hub": operator sets one shared key for everyone (requires operator approval).proxy.inspect.requireOnlyScopes: automatically refuses tokens that carry write/admin scopes on connect.
- Public-only by default.
proxy.baseUrlmust behttps://and resolve to public IPs (plugins/egress.py). Set"internal": trueONLY for homelab Docker/LAN services (operator-only approval; can be promoted to the hub catalog for guests). - Skills call the hub proxy with stdlib Python only (
AIA_TOOLS_URL+AIA_TOOLS_TOKEN, falling back tohub.jsonbesideSKILL.mdfor paired computers):- Outbound proxy:
ALL <AIA_TOOLS_URL>/plugins/<id>/proxy/<path>(owner can pass headerX-Plugin-As: <guest>to inspect a guest's plugin). - Per-user data dir:
GET <AIA_TOOLS_URL>/plugins/<id>/data(list),GET|PUT|DELETE .../data/<relpath>. - Non-secret config:
GET <AIA_TOOLS_URL>/plugins/<id>/config. - Sandboxed action (v3):
POST <AIA_TOOLS_URL>/plugins/<id>/actions/<action>.
- Outbound proxy:
- Jobs & actions (
jobs/*.py,handlers/*.py) run in a stripped environment with:AIA_TOOLS_URL,AIA_TOOLS_TOKEN,AIA_PLUGIN_ID,AIA_PLUGIN_DIR,AIA_PLUGIN_DATA_DIR,AIA_PLUGIN_CONFIG(JSON),AIA_USER_CONTEXT({"uid", "isOwner", "domains", "grant"?: {"...grantFields", "monthlyBudgetUsd", "usingOwnSecret"}}).- Receive JSON payload on
stdin; print a JSON object onstdout(exit 0 on success, non-zero with error message onstderr). - Return an optional
"_meter": {"usd": 0.04, "units": {"images": 1}, "creates": false, "model": "...", "keyHealth": {"status": "ok|no-credit|invalid|denied|capped", "message": "..."}}key; the hub strips it, records LEDGER usage, enforces per-plugin guest budgets & daily job caps, and pushes owner key-health/spend alerts (break + recovery, the alert line's % and 100 %). A plugin withmanaged.keyHealthgets the owner's Hub key section on its Settings page (docs/plugins.md → "The hub key");settings.links([{label, url}],{{config.<field>}}allowed) add provider console links there. services.read(capability, operator only): the owner's handler runs getAIA_SERVICES_DIR, the host's services dir (theservicesplugin reads it).provides: {"service.cards": "<action>"}makes the host run that action and merge per-dir card fields into/api/services(docs/plugins.md → "Host data and slots").- Hub capability bridges (when declared in
capabilities):GET <AIA_TOOLS_URL>/plugins/<id>/hub/conversations,GET .../hub/conversations/<sid>,GET .../hub/goals,POST .../hub/goals/work,GET .../hub/graph(graph.read, owner only),GET .../hub/footprint?account=&range=(footprint.read, owner only),GET .../hub/telemetry/usage?range=&who=(telemetry.read, owner only),GET .../hub/analytics?account=&range=&tzOffset=&cron=(analytics.read, owner only),POST .../hub/notify. - NEVER assume host env vars (
ANTHROPIC_API_KEY, etc.) exist — they are stripped.
- Sandboxed UI (
ui/*.html) runs in/sandbox-frame.html(opaque"null"origin) withwindow.aiAgentPlugin:window.aiAgentPlugin.init(initial config/status)await window.aiAgentPlugin.action(name, payload)await window.aiAgentPlugin.setConfig(config)await window.aiAgentPlugin.setSecret(key, value)window.aiAgentPlugin.resize(px)window.aiAgentPlugin.navigate(path)(an app path),window.aiAgentPlugin.onTheme(cb);init.theme={scheme, tokens}, already applied to<html>(darkclass + the tokens)- A page with
"fill": truefills the page under the header (a canvas) instead of growing with its content. - No network and no app CSS inside the frame: inline everything, load data through an action.
- Use theme CSS variables (
hsl(var(--foreground)),--card,--border,--muted-foreground,--primary) so dark/light mode matches the app.
- CLI commands + MCP tools (
commands) — to make an action usable from a shell or an AI app, declare it incommands, never in the corecli/ai_agent.py/cli/mcp_tools.py: it becomesai-agent plugin <id> <command> …and, with"mcp": true, the MCP toolplugin_<id>_<command>. Each command:action(a declared one),summary(required — the--helpline and the tool description),args(name,typestring|integer|number|boolean|array,positional,required,enum,default,help),output({"text": "<field>"}or{"rows": "<list field>", "columns": [...]}; absent = the JSON answer). AreadOnlyaction is called by GET (read-only MCP connections can use it); guests get the commands of the plugins granted to them, never anownerOnlyaction's. Opt into MCP only what an AI app should call (not a webhook orinspecthandler). Check withai-agent plugin commandsafter a reload (ai-agentdocs/plugins.md→ "Commands").
Step-by-step workflow
- Create the plugin folder (
~/projects/ai-agent-plugins/plugins/<id>/for hub plugins, or the user's plugin repo). - Write
plugin.json, narrowingproxy.allowto the exact HTTP methods and path regexes needed. - Write
skill/SKILL.md+skill/scripts/(keep scripts stdlib-only Python,chmod +x, put CSV/data shaping in the script rather than the hub). - Write any
handlers/,jobs/, orui/needed, plus a self-contained unit test script (tests/test_plugin.py) mocking upstream HTTP. - Validate with the hub:
ai-agent plugin validate <plugin-dir> - Install live (and promote to catalog if hub-wide):
ai-agent plugin install <plugin-dir> ai-agent plugin promote <plugin-dir> # operator only, if guests should 1-click install it - Reload after edits:
ai-agent plugin reload <id> # keeps approval automatically unless capabilities widened ai-agent plugin reload <id> --approve # if capabilities changed ai-agent plugin test <id> - Commit & push the plugin repo (
commit-project ~/projects/ai-agent-plugins -m "feat(plugins): add <id>").