Python
Install an integration
Section titled “Install an integration”A manifest is a file’s path, a dict, or None for the repository’s
config.
import agent_harness_adapter as aha
mytool = { "version": 1, "name": "mytool", "instructions": "Run `mytool check` before you finish.\n", "skills": [{"name": "mytool", "description": "Check the project with mytool.", "body": "Run `mytool check`; fix what it reports.\n"}], "hooks": [{"event": "pre-tool", "tools": "shell", "command": "mytool hook {harness} {event}"}], "allow_commands": ["mytool"],}
result = aha.install(mytool, ["claude", "codex", "gemini"])for h in result["harnesses"]: print(h["harness"], [f'{p["state"]} {p["path"]}' for p in h["parts"]])Keyword arguments take the options: scope ("project", "user" or
"local"), root (the project directory), home, and for install force
and without. uninstall and status take the same arguments. Results are
the JSON of agent-harness-adapter install --json, as dicts.
Answer a hook
Section titled “Answer a hook”With command = "mytool hook {harness} {event}", run_hook reads the
harness’s input as Claude Code’s and writes your answer in the harness’s form.
# mytool hook <harness> <event>: Claude Code's input in, its answer out,# translated for whichever agent ran the hook.import sys
import agent_harness_adapter as aha
def decide(hook): if "rm -rf" in str((hook.get("tool_input") or {}).get("command", "")): return {"decision": "block", "reason": "mytool: no rm -rf here"} return None # allow
sys.exit(aha.run_hook(sys.argv[1], sys.argv[2], decide))parse_hook and answer_hook do the two halves separately. Errors raise
ValueError with the library’s message.