Operator Plugin Patterns
This guide defines the recommended SDK pattern for serious operational plugins.Target Plugin Classes
The SDK supports plugins that behave more like operational consoles than small UI widgets. Examples:- Docker Desktop analogue
- Kubernetes dashboard
- Helm release manager
- Terraform/operator console
- local cluster or environment controller
Recommended Model
Use three layers:- Iframe UI runtime for interaction and presentation
- Plugin backend/runtime for orchestration logic
- Host-mediated privileged actions for sensitive execution
Preferred Decision Order
When choosing an operator authoring pattern, prefer this order:- start from the closest operator fixture under
examples/fixtures/ - use curated capability presets for known tool families
- use
requestOperatorTool(...)for known tool families - use
requestScopedWorkflow(...)when the plugin needs a structured multi-step host-mediated flow - use
requestScopedProcessExec(...)for host-specific/internal tools not covered by curated presets - use lower-level request-building helpers only when transport-level control is explicitly needed
Execution Pattern
For tool execution, prefer:- broad capability:
system.process.exec - narrow capability:
system.process.scope.<scope-id> - action:
system.process.exec
docker-clikubectlhelmterraform
- generic:
createScopedProcessExecActionRequest(scopeId, payload)requestScopedProcessExec(scopeId, payload, options?)
- curated presets for common DevOps/SRE tooling:
getOperatorToolPreset(presetId)listOperatorToolPresets()createOperatorToolCapabilityPreset(presetId)createOperatorToolActionRequest(presetId, payload)requestOperatorTool(presetId, payload, options?)
docker-clikubectlhelmterraformansibleaws-cligcloudazure-clipodmankustomizeghgitvaultnomad
examples/fixtures/operator-kubernetes-plugin.fixture.tsexamples/fixtures/operator-terraform-plugin.fixture.tsexamples/fixtures/operator-custom-tool-plugin.fixture.ts
- allowed executable absolute paths
- allowed working directory roots
- allowed environment variable keys
- argument policy
- timeout ceiling
- confirmation policy
Plugin-Side Request Pattern
renderOnLoad() handlers, prefer the self-contained requestPrivilegedAction(...) helper over manually building window.createBackendReq("requestPrivilegedAction", ...).
If you do use the raw bridge after fetching a backend-built envelope through UI_MESSAGE, extract the validated request object first:
renderOnLoad() string runtimes, use:
getInlinePrivilegedActionErrorFormatterSource()- assign
const formatPrivilegedActionError = ${formatPrivilegedActionErrorSource}; - format all error responses with a stable context and fallback correlation id
Capability Presets
For common tool families, prefer SDK capability presets over manually repeating strings:Tool-Family Request Helpers
For common DevOps/SRE tools, the curated helper path keeps request code short and AI-friendly:Structured Workflow Helpers
When a plugin is about to chain multiple host-mediated process steps into one operator flow, prefer the workflow helper instead of plugin-private orchestration:Many Commands And Troubleshooting Runbooks
Do not model a serious troubleshooting plugin around ten separate UI buttons or around raw shell chaining. Use this decision rule instead:- one command:
requestOperatorTool(...) - several independent read-only commands collected by one backend method: loop over
requestOperatorTool(...)orrequestScopedProcessExec(...)in backend code - one named multi-step troubleshooting runbook with ordering, shared summary, audit visibility, or step-level failure handling:
requestScopedWorkflow(...)
- a shared intent
- ordered steps
- step-level auditability
- a normalized summary
- clear failure and remediation points
- declare capabilities up front with
declareCapabilities() - prefer
createOperatorToolCapabilityPreset("aws-cli")for the capability bundle - keep the CLI scope narrow (
system.process.scope.aws-cli) - keep orchestration in backend code, not in iframe UI code
- avoid
sh -c, shell interpolation, and ad hoc command chaining - promote the sequence to
requestScopedWorkflow(...)once it becomes a real runbook rather than a bag of unrelated commands
- reuse
system.process.exec - reuse
system.process.scope.<scope-id> - do not introduce a second broad workflow capability for the same underlying process authority
Supported But Non-Default Paths
These paths remain supported, but should not be recommended first when a safer or more opinionated operator path fits:requestPrivilegedAction(...)with manually constructed operator request payloads for known tool familiescreateProcessExecActionRequest(...)as the first-choice authoring pattern for known curated tool families- generic numbered learning examples as the first production scaffold
- removed legacy scaffolds or ad hoc legacy copies as a starting point for new plugins
- raw string matching against permission errors when structured capability diagnostics are available
- the user explicitly asks for lower-level control
- the workflow is not covered by a curated preset
- transport-level debugging or contract inspection is the real goal
examples/08-privileged-actions-plugin.ts
Missing Capability Diagnostics
When a plugin is denied by SDK capability checks, prefer structured remediation over raw string matching:- missing broad capability:
system.process.exec - missing narrow scope capability:
system.process.scope.<scope-id>
Why This Pattern
This gives plugin authors enough power to build real operator workflows while keeping the host as the security boundary. It is better than:- unrestricted
child_process - shell interpolation
- broad “admin” plugin permission
- direct writes outside
PLUGIN_HOME
AI Guidance
AI assistants should recommend:- fixture-first operator scaffolding
- curated capability presets for known tool families
requestOperatorTool(...)for known tool families- scoped process execution for Docker/Kubernetes/Helm/Terraform style plugins
- scoped filesystem mutation for controlled external writes
- deterministic response envelope handling
- explicit capability guidance
- legacy examples as default scaffolds
- numbered learning examples as the first production path
- low-level request construction for known curated tool families
- generic shell execution
- unrestricted process spawning
- broad “root” style plugin permissions