Dev Guidedoc/{zh,en}/guide/plugin-development.md

Plugin Development

Status: 2026-11-16. How to build, test and ship an Orquelo plugin. The wire protocol is in plugin protocol; hooks in detail are in the hook reference. Back to the guide index.

Status: 2026-11-16. How to build, test and ship an Orquelo plugin. The wire protocol is in plugin protocol; hooks in detail are in the hook reference. Back to the guide index.

1. What a Plugin Is

A plugin is a directory with a plugin.yaml. An instance is one configured use of it under plugins: in the Host configuration, with its own id, configuration, options, data directory and scope. A plugin acts only in the roles its manifest declares, and only for runtimes that list its instance in uses. Identity and authority always come from the Host (CallContext), never from a plugin or a model.

2. Quick Start A: No Code

A manifest plugin that offers an MCP server's tools, a skill, a hook that blocks dangerous shell commands, and a hook that adds context to every request.

text
release-helper/
  plugin.yaml
  skills/release-notes/SKILL.md
  hooks/no-force-push.py
  hooks/add-branch.py

plugin.yaml:

yaml
api: v1
name: release-helper
version: 0.1.0
description: Release tools from an MCP server, a release-notes skill, and two hooks.
host: ">=0.1.0 <1.0.0"
execution: manifest
roles: [tool, skill, guard]          # tool: mcp_servers; skill: skills; guard: pre_tool and user_input hooks
mcp_servers:
  - name: gh
    command: [npx, -y, "@modelcontextprotocol/server-github"]
    env: {GITHUB_TOKEN: "${option.token}"}
    approval: ["create_*", "merge_*"]   # these tools need a person's approval
options:
  token: {type: string, title: GitHub token, required: true, sensitive: true}
skills:
  - skills/release-notes
hooks:
  - {event: pre_tool, match: "bash|powershell", command: [python3, "${PLUGIN_ROOT}/hooks/no-force-push.py"], timeout: 5s}
  - {event: user_input, command: [python3, "${PLUGIN_ROOT}/hooks/add-branch.py"], on_error: ignore}

skills/release-notes/SKILL.md:

markdown
---
name: release-notes
description: Write release notes from the merged pull requests since the last tag.
---

List the pull requests merged since the last tag with the gh tools, group them
by label, and write one line per change in the imperative mood.

hooks/no-force-push.py blocks with exit code 2; stderr is the reason the model sees:

python
#!/usr/bin/env python3
import json, sys
event = json.load(sys.stdin)
if "push --force" in json.dumps(event.get("tool_input", {})):
    print("force pushes are not allowed; push a new commit instead", file=sys.stderr)
    sys.exit(2)

hooks/add-branch.py adds context the model sees as reference material of that run:

python
#!/usr/bin/env python3
import json, sys
json.load(sys.stdin)
print(json.dumps({"hookSpecificOutput": {"hookEventName": "UserPromptSubmit",
                  "additionalContext": "Releases are cut from the main branch."}}))

If the Host configuration sets policy.mcp_commands, hook executables (here python3) must be listed there too. user_input context reaches the model only when the plugin also declares the context role (roles: [tool, skill, guard, context]); without it the text is held and never read. See the hook reference for every event.

Load it. In the Host configuration:

yaml
plugin_dirs: [/path/to/plugins]          # the parent directory of release-helper/
plugins:
  - {id: release, plugin: release-helper}
  - {id: agent, plugin: agent, uses: [kimi, files, release], config: {model: kimi}}

Then:

StepCommand
Store the sensitive option (value read from stdin)orquelo secret set -c CONFIG release token
See each instance, and each MCP server and skill, with its statusorquelo plugins -c CONFIG
Apply the configuration to a running Hostorquelo reload -c CONFIG
Before the first start, and after changing the plugin's filesorquelo plugin approve -c CONFIG release-helper (until then the plugin is unavailable with not_approved, or changed_since_approved once its files changed)

orquelo plugin add -c CONFIG [-uses a,b] [-option KEY=VALUE]... ID PLUGIN adds an instance without editing the file.

3. Quick Start B: Any Language

A process plugin is an executable that speaks JSON-RPC 2.0 over its stdin and stdout. plugins/notes-python is a complete example in Python with only the standard library: two tools, a guard, context and a skill. It passes the same conformance suites as Go plugins (TestPythonPlugin in internal/process).

plugin.yaml:

yaml
api: v1
name: notes-python
version: 0.1.0
description: Example process plugin in Python (standard library only) with tools, a guard, context and a skill.
execution: process
roles: [tool, guard, context, skill]
platforms: [darwin, linux]
process:
  command:                 # os/arch → executable, relative to the plugin directory
    darwin/arm64: main.py
    darwin/amd64: main.py
    linux/amd64: main.py
    linux/arm64: main.py
config_schema:
  type: object
  properties:
    blocked_words: {type: array, items: {type: string}}

main.py, in order:

PartWhat it does
read() / write()One message = Content-Length: N\r\n\r\n + N bytes of JSON. Writes hold a lock because replies and callbacks share stdout
initializeSaves data_dir and config; returns {"manifest": {"name", "version", "roles"}}. The Host refuses the process if these three differ from plugin.yaml
HANDLERSMethod name → function: tool/list, tool/invoke, guard/check, context/get, skill/list, skill/load, shutdown. Unknown methods answer -32601
call_host()A callback: a request from the plugin to the Host, here host/remind with the call_id that tool/invoke gave. It is only allowed during that call
main()Reads messages. A reply wakes the waiting call_host; a notification ($/cancel) is ignored; each request runs on its own thread, so a tool call can wait for a callback's reply while the loop keeps reading
ErrorsA raised exception becomes {"code": -32000, "message", "data": {"code": "notes.failed", "message"}}

The process runs with the plugin directory as its working directory and a minimal environment (PATH, HOME, USER, LANG, LC_ALL, TMPDIR, TZ; on Windows also the system variables). Write only protocol frames to stdout; write logs to stderr, which the Host keeps in its log (redacted, at most 8 MiB per process).

Windows. process.command names an executable that is started without a shell. A script needs a launcher (for example a .exe or a .cmd the system can run directly); notes-python declares platforms: [darwin, linux] for that reason.

4. Go SDK

pkg/plugin/serve runs a Go plugin as a process: serve.Main(manifestYAML, New) where New is a plugin.Factory (func(plugin.Env) (plugin.Plugin, error)). The plugin implements the role interfaces of pkg/plugin (Tool, Guard, ContextProvider, …); the SDK speaks the protocol and turns callbacks into the Caller/ToolHost/RuntimeHost methods. The same code can be compiled into the Host as a builtin (first-party only) or shipped as a process plugin; internal/process tests run localenv both ways with the same results.

5. plugin.yaml Reference

Unknown fields are refused, so a typo never drops a declaration silently.

FieldTypeRequiredMeaning and rules
apistringyesContract version; v1
namestringyes^[a-z0-9][a-z0-9-]{0,62}$; stable id
versionstringyesThe plugin's version; must match what a process reports at initialize
descriptionstringrecommendedEnglish; shown to operators and models
hoststringnoHost versions the plugin works with, e.g. ">=0.1.0 <1.0.0"
executionstringnomanifest, process or builtin; manifest when omitted
roleslistyesAt least one of the roles in section 6; a process must report the same list
publisherstringnoA claim shown to operators; the Host records the real source
defaultstringnoavailable (default) or enabled (part of the starter configuration of orquelo init)
platformslistnoos or os/arch, e.g. darwin, linux/amd64; elsewhere the instance is unavailable (platform_unsupported)
works_withobjectnotransports: [feishu]: only with these channels
resumableboolnoRuntimes only: continue from the checkpoint after a Host restart
requireslistnoRoles that must be offered by the instances it uses (requirement_missing)
dependslistnoOther plugins that must be installed: name or name@range
prerequisiteslistnoSoftware outside Orquelo with a check and install steps (dependencies)
shellmapnopath: directories under ${PLUGIN_ROOT} or ${PLUGIN_DEPS} first on the shell's PATH; env: variables for the shell (same page, ADR 0001 decision 9)
permissionsobjectnoRequested, shown at install; never a grant
optionsmapnoTyped settings (section 7); key ^[A-Za-z_][A-Za-z0-9_]{0,63}$; type one of string, number, boolean, file, directory, and a title
config_schemaJSON SchemanoValidates the instance config at load (config_invalid)
display, localesobjectnoMessage keys and locale files for operator interfaces
inputslistnoModels only: text, image
processobjectprocesscommand (os/arch → executable), args
mcp_serverslistmanifestname, exactly one of command (stdio) or url (Streamable HTTP), env, tools.include/exclude, approval, parallel; for URL servers only, headers (sent with every request, such as X-API-Key: "${option.api_key}"; an instance's config.headers overrides a header of the same name), auth: oauth and scopes. Every ${option.<key>} in url, command, env and headers must name a declared option, or the manifest is refused
skillslistmanifestDirectories with a SKILL.md
hookslistmanifestevent, match, command, timeout (default 10s), on_error (deny default or ignore); each event needs the role it fills (hook reference)

A manifest plugin needs at least one of mcp_servers, skills or hooks. Values in MCP commands, URLs, env, headers and hook commands may use ${PLUGIN_ROOT} (the plugin directory), ${PLUGIN_DATA} (the instance's data directory), ${PLUGIN_DEPS} and ${option.KEY}. A sensitive option may not appear in an MCP or hook command line, which any process on the machine can read: the server or hook then fails to start with a message to pass it in env (or a header) instead (Feishu #255).

6. Roles

A role is an interface in pkg/plugin and a set of protocol methods. Powers are fixed: an extension can only do what its role allows.

RoleMethods (protocol)MayOn failureHost timeout
tooltool/list, tool/invokeOffer tools; each call goes through the ledger and approvalsError result for the modelThe tool's own (call_timeout for MCP, default 2m)
skillskill/list, skill/loadOffer cards and text; grants nothingThat instance's skills are left out—
guardguard/check; optional check_input, check_result, check_completionDeny or ask before a call; refuse an input; withhold a result or add a note; ask for more workDeny / refuse / withhold; completion check skipped5 s check; 10 s others (longer with hooks)
guard (optional, hook model)guard/rewrite, guard/filter_tools, guard/before_model, guard/after_model, guard/check_stepRewrite a call's arguments or a model call (needs grants: [rewrite], ADR 0005); remove tools from a run; refuse a model call; add context or stop the run after a batch of tool callsRewrites and model checks refuse the call; tool filters and step checks are skipped5 s rewrite; 10 s others
reviewerreviewer/reviewApprove, deny or escalate an approval; needs grants: [review]Escalates to a person30 s
contextcontext/getAdd reference items at run start; cannot instruct, except an instance in the operator's policy.hooks, whose items reach the model as instructionsOmitted5 s
observerobserver/observe; optional observer/before_compactRead committed facts (run.finished, session.*, tool.finished, question.*, compaction.done, delivery.*); name facts a summary must keepRetried from a durable cursor2 min per event; 30 s before compact
compactorcompactor/compactWrite a session summary recordNext compactor, then the builtin one120 s
context_processorprocessor/processReturn typed edits of the history (shorten, redact, hide, annotate)That processor's edits are dropped5 s
serviceservice/serveIts own long work, through BackgroundHostRestarted with backoff, 1 s doubling to 5 min—
modelmodel/chat (+ model/delta stream)Produce responsesThe run failsRun timeout
runtimeruntime/executeRun a task, with the RuntimeHost callbacksThe run fails or is retriedRun timeout
transport, trigger, presentation, deliverytransport/start, transport/fetch, trigger/match, presentation/present, delivery/deliverThe channel stages of a connectionPer stage (architecture)—

Rules shared by all roles are in extension points §6: tighten only, fixed per run, deterministic order (uses order), scope decides presence, bounded inputs and outputs, effects are tool calls, recovery reuses records.

7. Configuration and Secrets

configoptions
Declared byconfig_schema (JSON Schema)options: with typed entries
Set inconfig: of the instanceoptions: of the instance, the secret store, or the default
Sensitive valuesNot allowed: use an option (orquelo plugin test fails on a property named like a credential, such as api_key, token or password)sensitive: true, stored with orquelo secret set -c CONFIG INSTANCE NAME (stdin), or ${ENV}
The plugin receivesEnv.Config / initialize.configEnv.Options / initialize.options; ${option.KEY} in manifest values

Every top-level config_schema property needs a description (orquelo plugin test fails without one): the admin plugin's config_describe shows it to the model that configures the Host from a chat, so write what the setting does, its default and units, and any cost or security effect, in English.

A missing required option makes the instance unavailable with option_missing. Secrets are encrypted at rest; plugins must not log or return option values. For per-user secrets at call time (a user's own token), use host/secret_get, host/secret_put, host/secret_delete: they are keyed by the calling principal, and no other instance or principal sees them. Durable plugin state belongs in the instance data directory (Env.DataDir, initialize.data_dir, ${PLUGIN_DATA}), which survives restarts and upgrades.

Logins (ADR 0012) give the agent CLIs and websites. A login lands where the CLI or the site keeps it, so a tool gets nothing extra in its call. A tool that takes a secret: reference from the model, for something the person typed into a sign-in, resolves it with host/resolve_secret (plugin.SecretResolver for builtin plugins); the Host removes the value from the run's later tool results. Websites are reached through the agent-browser CLI, so a site's code goes in through localenv's secret_env like any CLI's (P87 S6). The login skill is the one skill marked with metadata.orquelo.login: true.

8. Testing

PluginHow
GoThe suites of pkg/plugin/plugintest: ManifestSuite, ToolSuite, GuardSuite, ContextSuite, SkillSuite, ModelSuite, TriggerSuite, PresentationSuite, DeliverySuite, RuntimeSuite, TransportSuite. They take a plugintest.T, which *testing.T satisfies
Any languageorquelo plugin test [-config JSON] [-options JSON] DIR (-options: the plugin's option values, as an instance's options): reads DIR/plugin.yaml, checks the manifest, starts the plugin the way the Host does, and runs the suite of each declared role over the real protocol. It prints PASS <suite> or FAIL <suite> with one indented line per problem, and exits non-zero on any failure. Roles that need a live backend (model, delivery, transport, service, observer) are reported as SKIP
MessagesValidate requests and replies against schemas/protocol/v1 (JSON Schema 2020-12, generated from the Go code)

Examples of what the suites catch: a skill/load that returns a file outside the skill directory, a guard that errors on an ordinary intent, a tool list with invalid parameter schemas, locale files with different keys.

9. Publishing and Installing

orquelo plugin install -c CONFIG [-upgrade] [-yes] SOURCE accepts:

SourceForm
Local directory./release-helper
Git, pinnedgit+https://github.com/org/repo#<40-hex commit>[:subdir]; branches and tags are refused
Archivehttps://…/plugin.tgz#sha256=<64 hex> (.tar.gz, .tgz, .zip, at most 200 MiB)
CatalogA plugin name from the configured catalogs (orquelo plugin search)

Install stages the plugin, plans dependencies and prerequisites (-yes, or the policy allow_system_installs, allows system packages; a plugin's own dependencies also install when a configured instance loads), commits by swapping directories, and rolls back on failure; -upgrade replaces an installed version and keeps a backup. orquelo plugin doctor -c CONFIG NAME rechecks prerequisites. A plugin never activates on install: only instances in the configuration run.

Claude Code and Codex packages. Installing a directory with .claude-plugin/plugin.json, .codex-plugin/plugin.json or a root plugin.json converts it into a manifest plugin without running its code:

ConvertedLeft out, with a note
Skills; commands (as skills); MCP servers (stdio and HTTP) with path and option variables mapped; command hooks of PreToolUse, PostToolUse, UserPromptSubmit, Stop, SubagentStop, SessionStart, PreCompact, PermissionRequest (with on_error: ignore, matching those tools)Agents, output styles, LSP, workflows, themes, monitors, channels, apps, bin/, dependencies, legacy SSE servers, non-command hooks, hooks that need a shell, other hook events

10. Rules Every Plugin Follows

  • ◆Identity from the Host only. Key per-user data by CallContext.principal.user; never trust ids in arguments or model output.
  • ◆Tighten only. Guards restrict, context adds, reviewers decide approvals only with the grant, observers read. Nothing relaxes another's decision or the operator's policy.
  • ◆Effects are tool calls. A side effect during a run is a tool, so it goes through the ledger and approvals.
  • ◆Idempotent by key. A tool call carries key, stable across retries; a call whose outcome is unknown after a crash is reported, never replayed blindly.
  • ◆No shell. Commands and executables start without a shell; commands that need one are refused at import.
  • ◆stdout is the protocol. A process writes only frames to stdout; stderr is logged and redacted.
  • ◆Bounded. Every call has a Host timeout; return short text; keep files in the data directory.