Documentation · Extensibility

Policy Advisor hooks and plugin contract

ohd discovers executable PolicyAdvisor scripts (chmod 0700) in ~/.config/oh-router/plugins/ or loads pinned entries from ~/.config/oh-router/config.json, running each hook with a bounded 2000ms timeout.

Stdio JSONL protocol

For every launch or on_limit trigger, ohd writes a single UTF-8 JSON line (PluginContext) to the plugin's stdin and reads one UTF-8 JSON line (PluginAdvice) from stdout.

FieldValuesDescription
event (input)"launch", "on_limit"Lifecycle hook being evaluated by ohd.
request / session (input)JSON objectProject name, requested kind, model_tier, effort, is_review, and capability tags.
profiles[] (input)JSON arraySigned-in workspace profiles with window_5h, window_7d, and folder lock flags.
action (output)"proceed", "relaunch", "wait", "redeem_reset"Routing primitive returned by the advisor.
profile_id / model_tier (output)Optional stringsTarget profile and canonical tier (opus, sol, fable, astra) for proceed or relaunch.

Every PluginAdvice response is checked against oh-router-core invariants before execution: pinned browser-auth requirements, active folder locks, and window holds are never overridden.

Inspect the spec or start a plugin session in OH

Click **New Policy Plugin in OH** inside Cmd+3 Router to launch a frontier session (Fable or Astra) preloaded with the full PolicyAdvisor specification in ~/.config/oh-router/plugins/, or print the spec from the terminal:

Print the PolicyAdvisor specification
$ oh-router policy plugin-spec
$ oh-router policy plugin-spec --json

To pin a plugin's integrity digest, add its 64-character hex sha256 under plugins[] in ~/.config/oh-router/config.json. ohd verifies the digest before every invocation and displays sha256_prefix in Cmd+3 Router.