Skip to content

feat: add OpenCode + Codex desktop + Hermes Agent support - #1

Open
Leocarneiroo wants to merge 8 commits into
realfishsam:mainfrom
Leocarneiroo:main
Open

feat: add OpenCode + Codex desktop + Hermes Agent support#1
Leocarneiroo wants to merge 8 commits into
realfishsam:mainfrom
Leocarneiroo:main

Conversation

@Leocarneiroo

@Leocarneiroo Leocarneiroo commented Jul 21, 2026

Copy link
Copy Markdown

What

Adds 3 new agents to Agent Notch:

1. OpenCode

  • Process detection via ps + lsof
  • Session scanning from SQLite (~/.local/share/opencode/opencode.db)
  • Liveness: cwd-based fallback
  • Indicator: 🟣 purple ring

2. Codex desktop app (ChatGPT.app)

  • Removes TTY requirement for Codex/OpenCode
  • Desktop sentinel: codex-desktop bypasses lsof
  • All recent Codex sessions marked live when desktop app runs

3. Hermes Agent

  • Detects hermes_cli, slash_worker, Hermes.app
  • Sentinel pattern (all Hermes processes are headless)
  • Reads active sessions from ~/.hermes/state.db (ended_at IS NULL)
  • Indicator: 🟠 amber/gold ring

Current agent roster

Agent Icon Color Data source
Claude Code 🦀 crab Orange ~/.claude/projects/
Codex 🐾 pet Teal ~/.codex/sessions/
OpenCode 🟣 ring Purple ~/.local/share/opencode/opencode.db
Hermes 🟠 ring Amber ~/.hermes/state.db

Testing

  • Compiles clean on macOS 15.5 arm64
  • All 4 agents detected via --scan with live processes
  • Desktop app support tested with ChatGPT.app + Hermes.app
  • LaunchAgent plist for auto-start on login

Diff: ~250 insertions, ~15 deletions across 3 commits

Detects opencode processes via ps/lsof, reads sessions from SQLite
(~/.local/share/opencode/opencode.db). Uses cwd-based liveness
detection (same fallback pattern as Claude Code).

- AgentKind.opencode added
- ProcessDiscovery.isOpenCode() detects opencode binary
- SessionScanner.scanOpenCode() queries SQLite for sessions
- IndicatorView: purple ring animation for OpenCode
- AppDelegate: state tracking + terminal-acknowledge support

Known limitation: text extraction uses simple regex on JSON;
nested quotes in messages may truncate snippets.
@realfishsam

Copy link
Copy Markdown
Owner

Thanks for the PR! Verified it compiles and runs, but a few things need fixing before this can be merged:

  1. Rebase properly — this reverts main's latest commit. The diff restores the per-pid lsof calls and the 0.5s/0.2s timeouts, undoing 443c0f5 ("Batch lsof and raise command timeouts so load can't kill discovery"). Please rebase so the batched lsofChunks + 2.0s timeouts stay intact and only the OpenCode additions land.

  2. The three snippet/prompt/activity SQL strings never match. They use '\\(sessionID)' inside a regular """ string — that's an escaped backslash plus the literal text (sessionID), not interpolation, so the queries always return nothing. Fix to \(sessionID), or use raw strings with \#(...) like the first query does.

  3. Tighten isOpenCode. lowered.contains("/opencode") matches any terminal-attached process whose command line mentions an opencode path (e.g. tail -f ~/.local/share/opencode/foo.log). Match on the executable token only, like isCodex does.

Codex desktop app (ChatGPT.app) runs without a terminal TTY.
Previously, process detection required TTY != '??', so the
desktop app was invisible to Agent Notch.

Changes:
- Remove unconditional TTY requirement; scope to Claude only
- Codex/OpenCode without TTY: insert 'codex-desktop' sentinel
- Sentinel bypasses lsof (unreliable at 0.2s for desktop apps
  with many open files)
- scanCodex: sentinel marks all recent sessions live
- --scan debug mode: handle sentinel correctly

Desktop sessions detected via ps alone — no lsof dependency.
@Leocarneiroo Leocarneiroo changed the title feat: add OpenCode support feat: add OpenCode + Codex desktop app support Jul 21, 2026
Detects hermes_cli, slash_worker, and Hermes.app processes.
Uses sentinel pattern (hermes key) since all processes are
background/headless with no TTY. Reads active sessions from
~/.hermes/state.db (ended_at IS NULL).

- AgentKind.hermes with amber/gold ring indicator
- isHermes() detects hermes_cli, slash_worker, Hermes.app
- scanHermes() queries SQLite for active sessions
- Full IndicatorView + AppDelegate state tracking
@Leocarneiroo Leocarneiroo changed the title feat: add OpenCode + Codex desktop app support feat: add OpenCode + Codex desktop + Hermes Agent support Jul 21, 2026
1. Rebase: restore batch lsof (lsofChunks) + 2.0s timeouts from upstream
   (was accidentally reverted in our patches)
2. SQL fix: opencodeTailInfo strings used escaped backslash
   '\\\(sessionID)' → '\(sessionID)' — queries now interpolate
3. isOpenCode: restrict to executable token only (first == 'opencode'
   or hasSuffix('/opencode')), remove broad contains('/opencode')
- opencodeTailInfo: fix '\\\(sessionID)' → '\(sessionID)' so SQL
  queries actually interpolate the session ID (were literal text before)
- isOpenCode: remove broad contains('/opencode') — only match on
  executable token (first == 'opencode' or hasSuffix('/opencode'))
  to avoid false positives on commands mentioning opencode paths
@Leocarneiroo

Copy link
Copy Markdown
Author

Thanks for the review! All three points addressed:

  1. Rebase/lsof: Restored lsofChunks batch pattern + 2.0s timeouts. Codex/Hermes sentinels skip lsof entirely; remaining candidates use single batched call. (commit 6599b58)

  2. SQL interpolation: Fixed '\\\\(sessionID)''\(sessionID)' in all three opencodeTailInfo queries. Confirmed with Swift test — bare \( interpolates correctly in """ strings. (commit 6517195)

  3. isOpenCode tightened: Now matches executable token only (first == "opencode" || hasSuffix("/opencode")), same pattern as isCodex. (commit 6517195)

PR now at 5 commits, compiles clean on macOS 15.5 arm64, --scan shows all 4 agents live.

@nima54851

Copy link
Copy Markdown

Great work on the agent orchestration approach! The OpenCode + Codex integration looks solid.

I noticed this fits well with AI Agent workflow automation patterns — if you ever want automated testing, CI/CD integration, or multi-agent orchestration templates, check out agent-studio which covers exactly these use cases with n8n workflows and SKILL.md conventions.

Keep building! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants