Repository navigation
Conversation
added 2 commits
November 24, 2026 17:08
Implement OpenBot runtime CLI agent adapters for Hermes Agent (hermes chat --format stream-json) and OpenCode (opencode run --format json), mirroring the existing Claude Code adapter contract in base.py: - hermes.py / opencode.py: provider/label/binary/path_setting / install_dirs / argv / parser / not_found, StreamParser feed/finish/usage_so_far, system prompt threaded via child stdin, every output line JSON (non-JSON dropped at debug), CLIs forced into JSON output mode. - session_id_re overridden per adapter (default rejects OpenCode's ses_... ids); status_argv=() and min_version=(0,0,0) for both. - Conservative permission mapping with WHY comments: hermes EDIT -> -t file, opencode EDIT -> allow edit; READ_ONLY never auto-approves writes. - Register both adapters in ADAPTERS; add unit tests for argv construction and stream parsing (recorded event lines). - base.py extended with Turn.cwd, adapter.combine(), adapter.turn_env(), env merged into child env. - schemas.py: add hermes/opencode to Provider literal + MODEL_OPTIONAL. - config.py: add hermes_path / opencode_path settings. - conftest.py: pin LOG_FILE=nul before openbot.main import so the import-time configure_logging does not crash in file-creation-blocked sandboxes. Ruff clean; 59/59 cli_agents tests pass; full suite 840 passed with 7 pre-existing environmental failures (file/SQLite creation blocked), none in the adapter code.
Upstream's test asserted cli_agents held exactly one entry (claude-code), which held while it was the only adapter. With Hermes and OpenCode registered, the providers endpoint lists all three, so the assertion has to cover them. Pin every adapter's path setting, not just claude_code_path: without that, ound depends on what happens to be installed on the developer's PATH, and a machine with hermes or opencode installed would fail a test that passes in CI.
Author
|
This PR is ready for review. The CI workflow run for this branch is in \�ction_required\ state — it needs fork workflow approval from a maintainer to proceed. Local verification: 4 failed / 886 passed on the branch vs 5 failed / 872 passed on bare upstream main — zero new failures introduced. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two CLI-agent adapters alongside upstream's Claude Code, so a bot can run its turn
through the Hermes Agent or OpenCode CLI instead of OpenBot's own model loop:
hermes chat --format stream-jsonopencode run --format jsonBoth mirror the existing
CliAdaptercontract inbase.py, so they register inADAPTERSand appear in the bot editor and the providers endpoint exactly like the existing agent.
Details
hermes.py/opencode.py— provider/label/binary/path_setting/install dirs, argvconstruction, stream parsing (
StreamParserfeed/finish/usage), and a conservativepermission mapping with WHY comments: EDIT maps to a scoped flag per CLI, and READ_ONLY
never auto-approves a write.
session_id_reoverridden per adapter so OpenCode'sses_...ids are not rejected;
status_argv=()andmin_version=(0,0,0)for both.base.py—Turn.cwd,adapter.combine(),adapter.turn_env(), with the env mergedinto the child environment.
schemas.py— hermes/opencode added to theProviderliteral andMODEL_OPTIONAL.config.py—hermes_path/opencode_path, so the executable can be named explicitlythe way
claude_code_pathalready is.conftest.py— pinsLOG_FILE=nulbeforeopenbot.mainis imported.main.pycallscreate_app()at import time, which callsconfigure_logging(Settings()); where the testsandbox cannot create files that crashes the import. It is a
setdefault, so it is a no-opfor anyone who already sets
LOG_FILE. Happy to drop this if you consider it out of scope.Test change this forces
test_providers_lists_the_cli_by_whether_it_is_found_without_running_itassertedcli_agents == [claude-code], which held while it was the only adapter. With three registeredthe providers endpoint lists all three, so the assertion has to cover them. Every adapter's
path is pinned (not just
claude_code_path) sofoundis deterministic rather than dependingon what happens to be installed on the developer's
PATH.Verification
ruff check .— clean.tests/test_cli_agents.py— 62 passed.-n 4 --dist loadfile, this branch: 4 failed, 886 passed, 7 skipped.mainas merged today: 5 failed, 872 passed, 7 skipped.So this branch's failure set is a subset of
main's (one flaky parallel test passed herethat failed there), adding 14 passing tests and no new failures. Three of the remaining
failures are environmental on this machine and reproduce on unmodified
main:test_search_code_...,test_workspace_tools_keep_out_of_the_openbot_state_dir, andtest_versioned_matrix_is_complete_and_honest. CI runs serially and should be unaffected.