Files
ai-agent/backend/schemas/plugin_commands.py

56 lines
1.6 KiB
Python

"""Plugin commands — what live plugins add to the ``ai-agent`` CLI and the
hub's MCP server (``GET /api/plugins/commands``, ``plugins/commands.py``)."""
from __future__ import annotations
from typing import Literal, Optional, Union
from .base import Schema
__all__ = [
"PluginCommandArg",
"PluginCommandOutput",
"PluginCommand",
"PluginCommandsResponse",
]
class PluginCommandArg(Schema):
name: str
type: Literal["string", "integer", "number", "boolean", "array"]
help: str = ""
required: bool = False
positional: bool = False
enum: Optional[list[str]] = None
default: Optional[Union[bool, int, float, str, list[str]]] = None
class PluginCommandOutput(Schema):
"""How to print the action's answer: one text field, or a list field as
rows of ``columns``; absent = the JSON answer."""
text: Optional[str] = None
rows: Optional[str] = None
columns: Optional[list[str]] = None
class PluginCommand(Schema):
"""``ai-agent plugin <plugin> <name> …``; with ``mcp`` also the MCP tool
``tool``. ``readOnly`` (the action's) = called by GET; ``timeoutSec`` (the
action's) = how long a caller should wait for the answer."""
plugin: str
pluginName: str
name: str
summary: str
description: str = ""
action: str
readOnly: bool = False
args: list[PluginCommandArg] = []
output: Optional[PluginCommandOutput] = None
mcp: bool = False
destructive: bool = False
tool: Optional[str] = None
timeoutSec: int = 30 # how long its action may run
class PluginCommandsResponse(Schema):
commands: list[PluginCommand] = []