Skip to main content

OpenCode agent type plugin for mngr

Project description

imbue-mngr-opencode

Plugin that registers the opencode agent type for mngr.

OpenCode is an open-source terminal-based AI coding agent. This plugin runs it as a first-class mngr agent: an interactive TUI with RUNNING/WAITING lifecycle reporting, conversation resume across stop/start, mngr transcript support, and per-agent config/credential isolation.

Usage

mngr create my-agent opencode

Pass arguments straight through to the opencode command with --:

mngr create my-agent opencode -- --model anthropic/claude-sonnet-4-5

mngr stop then mngr start resumes the agent's conversation; mngr transcript <agent> prints the conversation; mngr list reports the agent as RUNNING while it works and WAITING when it is idle.

How it works

OpenCode is a client-server app (a server owns the sessions and event bus; TUI / CLI / HTTP clients talk to it) with SQLite-backed sessions and no POSIX-sh hook mechanism. mngr leans into that shape:

  • The agent runs as a server + an attached TUI. Each agent's tmux pane runs a launch script that starts a headless opencode serve plus an opencode attach TUI client. mngr connect shows the attached client; the server owns the session.
  • Messages are sent via the server's HTTP API, not by typing into the TUI: mngr message POSTs the prompt to the agent's server (prompt_async), and the attached client renders it — so the conversation is fully visible while sending stays robust (no keystroke races, no screen-scraping).
  • Isolation is via OPENCODE_CONFIG_DIR (a per-agent config dir holding opencode.json + an auto-loaded plugin) and XDG_DATA_HOME (a per-agent data dir holding the session db, auth.json, storage, and logs), injected only on the OpenCode processes. No $HOME relocation.
  • Lifecycle (RUNNING/WAITING) is maintained by a small in-process TypeScript plugin that watches the server's event bus and touches/removes the mngr active marker (it runs only in the server process). It is subagent-aware: the marker clears only when the root session goes idle, so spawning task-tool subagents keeps the agent RUNNING until the whole turn finishes.
  • waiting_reason (shown by mngr list) reports why a WAITING agent is blocked, as the claude and codex agent types do. When a tool blocks on an approval prompt (an ask permission policy), opencode emits permission.asked; the plugin tracks pending prompts and keeps a permissions_waiting marker, which promotes the agent to WAITING and surfaces a PERMISSIONS reason. An idle agent whose turn is complete reports END_OF_TURN. Unlike codex (whose hook model fires nothing when a dialog is cancelled, briefly mislabeling the reason), answering or cancelling an opencode prompt clears the marker promptly: a denial emits permission.replied and session.idle, and an abort emits session.idle — each clears it (verified live against opencode 1.17.7).
  • Transcripts: the same plugin writes the raw transcript and, on session idle, rebuilds the common-format transcript mngr transcript reads — both in-process, no background converter or supervisor.
  • Auth: the per-agent auth.json symlinks to the user's shared ~/.local/share/opencode/auth.json, so one opencode auth login (in any agent) authenticates them all.

Configuration

Define a custom variant in your mngr config (mngr config edit):

[agent_types.my_opencode]
parent_type = "opencode"
auto_allow_permissions = true

[agent_types.my_opencode.config_overrides]
model = "anthropic/claude-sonnet-4-5"

Then create agents with your custom type:

mngr create my-agent my_opencode

Options

Option Default Meaning
cli_args () Extra arguments forwarded to the opencode attach (TUI) client.
config_overrides {} Key/value blob merged last into the per-agent opencode.json (e.g. model, the permission policy block).
sync_global_config true Base the per-agent opencode.json on a copy of the user's ~/.config/opencode/opencode.json.
symlink_auth true Symlink the per-agent auth.json to the shared one (one login authenticates all agents). Set false for full isolation.
auto_allow_permissions false Inject a wildcard allow into the per-agent permission policy (auto-approve everything not explicitly denied).
emit_common_transcript true Emit the common transcript that mngr transcript reads.

Choosing the model

The model is read by the agent's OpenCode server from its per-agent opencode.json, so it is set through config (format: provider/model; list options with opencode models). Three ways, highest precedence first:

  1. Per agent-type -- config_overrides.model on an opencode variant (the TOML example above). Applies to every agent of that type.

  2. On the mngr create command line -- mngr's generic per-invocation override reaches right into config_overrides:

    mngr create my-agent opencode -S agent_types.opencode.config_overrides.model=anthropic/claude-sonnet-4-5
    
  3. Globally -- the "model" in your ~/.config/opencode/opencode.json, inherited when sync_global_config is true (the default).

Notes:

  • If the model's provider isn't authenticated, OpenCode silently falls back to a free model -- so if you set, say, anthropic/claude-sonnet-4-5 but the agent shows a free "OpenCode Zen" model, run opencode auth login and create/restart the agent. (The free OpenCode-Zen models need no auth.)
  • Passing the model after -- (mngr create ... opencode -- --model X) does not work: -- args go to the opencode attach client, which has no --model flag; the model is used by the serve process, from opencode.json.

Not yet implemented

Carried gaps (shared with mngr_antigravity): session preservation on destroy, scheduled-deploy contributions, the live streaming snapshot, and clone carrying the source conversation forward.

See the mngr agent types documentation for more details.

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

imbue_mngr_opencode-0.2.16.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

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

imbue_mngr_opencode-0.2.16-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file imbue_mngr_opencode-0.2.16.tar.gz.

File metadata

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

File hashes

Hashes for imbue_mngr_opencode-0.2.16.tar.gz
Algorithm Hash digest
SHA256 b891a9419885eb73e89a98bd5b6c87f29b36be97d545bce1d4cbdf15af7b8ade
MD5 5d410cfa166ab72deef5de75422c5138
BLAKE2b-256 8a48f5db986aebc3c5cdcfe86c725266c5258a6be4c51cd254cd2e97107ac0b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for imbue_mngr_opencode-0.2.16.tar.gz:

Publisher: publish.yml on imbue-ai/mngr

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

File details

Details for the file imbue_mngr_opencode-0.2.16-py3-none-any.whl.

File metadata

File hashes

Hashes for imbue_mngr_opencode-0.2.16-py3-none-any.whl
Algorithm Hash digest
SHA256 386f55f6bf19fac37741dbb4de8e24bc2d908fdbbebc3b73be3a795ede821b4e
MD5 5cbef12fbef374622d1abc305193720a
BLAKE2b-256 6eb423e6b88b1d163edeae500668efae92a3a77840f0fc6a26e9819a9e8ef009

See more details on using hashes here.

Provenance

The following attestation bundles were made for imbue_mngr_opencode-0.2.16-py3-none-any.whl:

Publisher: publish.yml on imbue-ai/mngr

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