Skip to main content

Bridge daemon for codex CLI ↔ Molecule platform — long-polls the platform inbox, runs `codex exec --resume <session>` per inbound message, replies via send_message_to_user MCP tool. Counterpart to hermes-channel-molecule.

Project description

codex-channel-molecule

Bridge daemon — gives codex CLI push parity with the Molecule AI platform's other external runtimes.

The Molecule platform's hermes-channel-molecule plugin gives hermes-agent true push delivery — peer agents and canvas-user messages land mid-session as conversation turns. Codex CLI has no plugin API today and its MCP runtime drops inbound notifications, so this daemon is the equivalent push surface — built outside the codex process.

How it works

canvas user / peer agent ──► molecule platform inbox
                                       │
                              wait_for_message (long-poll)
                                       │
                                       ▼
                       codex-channel-molecule daemon
                                       │
                              codex exec --resume <sid> "<msg>"
                                       │
                              capture stdout
                                       │
                              send_message_to_user / delegate_task
                                       │
                              inbox_pop(activity_id)
                                       │
                                       ▼
                         canvas chat / peer workspace

Per chat thread (one canvas-user thread or one peer-workspace thread) gets its own codex session_id, persisted to ~/.codex-channel-molecule/sessions.json so daemon restarts don't lose conversation context.

When to use this vs. the codex tab in the External Connect modal

The codex tab wires the molecule MCP server into ~/.codex/config.toml so codex can call platform tools (list_peers, delegate_task, send_message_to_user, commit_memory, etc.). That's outbound — codex calls out to the platform.

This daemon is the inbound counterpart — the platform pushes to codex. Run both for full bidirectional integration.

Install

npm install -g @openai/codex@^0.57
pip install codex-channel-molecule

Configure + run

The same env-var contract as hermes-channel-molecule's outbound MCP path (WORKSPACE_ID, PLATFORM_URL, MOLECULE_WORKSPACE_TOKEN):

export WORKSPACE_ID=<uuid from External Connect modal>
export PLATFORM_URL=https://<your-tenant>.moleculesai.app
export MOLECULE_WORKSPACE_TOKEN=<bearer token from External Connect modal>

codex-channel-molecule

The daemon runs in the foreground; logs go to stderr. For systemd hosts, register a unit; for one-off use, nohup ... & plus a log file works.

Deprecation path

When openai/codex#17543 lands upstream — a generic path for handling MCP custom notifications in codex and forwarding them into the active session as user submissions — this daemon becomes redundant. Codex itself will accept inbound molecule messages as Op::UserInput directly through the MCP server already wired in ~/.codex/config.toml. Until then, this is the operator-facing answer.

Development

git clone https://github.com/Molecule-AI/codex-channel-molecule
cd codex-channel-molecule
pip install -e ".[test]"
pytest -q

Tests are entirely real-subprocess (no mocking the spawn boundary) so the boot path is covered the same way the daemon runs in production.

Releasing

Tag-on-push triggers publish.yml which builds + publishes to PyPI via OIDC trusted publishing (no API token needed).

# Bump pyproject.toml `version`, commit, then:
git tag v0.1.1 && git push origin v0.1.1

The workflow refuses to publish if the tag doesn't match pyproject.toml's version — keeps PyPI versions and git tags in lockstep.

One-time PyPI setup (before the first release):

  1. Create the project on PyPI by uploading the first wheel manually, OR
  2. Pre-register the project on PyPI under a "Pending publisher" config so the first tagged push creates it.

Either way, on the project's PyPI page → "Manage" → "Publishing" → "Add a new publisher", configure:

  • Owner: Molecule-AI
  • Repository: codex-channel-molecule
  • Workflow filename: publish.yml
  • Environment name: pypi

After this, every git push origin v*.*.* ships the wheel to PyPI without any further intervention.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_channel_molecule-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_channel_molecule-0.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file codex_channel_molecule-0.1.0.tar.gz.

File metadata

  • Download URL: codex_channel_molecule-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codex_channel_molecule-0.1.0.tar.gz
Algorithm Hash digest
SHA256 355b494ce0b2cf38c5e62f7b52df39bc2f28d9a645d3a5c43803c3ae2094b532
MD5 33ecd3b46e3ab3ecb12d9b09bd01947a
BLAKE2b-256 abd92616986ef5999d92afef6cb2d1a63949700b9f3cc9ba152322b6beb3f1d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_channel_molecule-0.1.0.tar.gz:

Publisher: publish.yml on Molecule-AI/codex-channel-molecule

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_channel_molecule-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codex_channel_molecule-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f7d3e7d8405252ccbc1d51ec1a3c12f2ae39f684c02797f852d346ee37e2e3d
MD5 7eb1506304df1ed5b21aa08c603873c1
BLAKE2b-256 9cdefe704d4ddbff05fb6e7ccb5c8a3769c55d2e26449f16d8051c6392f4d56b

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_channel_molecule-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Molecule-AI/codex-channel-molecule

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page