Skip to content

OpenCode

tenfyzhong edited this page Oct 18, 2026 · 14 revisions

OpenCode

Agentix connects to the original OpenCode TUI using its plugin API. OpenCode 2.0.32 or newer is required; 2.0.32 is the validated baseline. Earlier 2.0 patches and 1.x are unsupported. Later native API changes require compatibility testing. Keep that terminal running while using IM; attaching does not start a resumed copy of the agent.

Availability

OpenCode support is available on main. Build/install matching Agentix and Taskix versions containing OpenCode support. Use the installer checkout that includes native GitHub installation; older installer revisions copy even SOURCE=main packages into a local directory.

Install the plugins

Install the matching Agentix and Taskix builds, OpenCode, Node.js 24+ and npm. For the current Homebrew 2.x channel, use brew install anomalyco/tap/opencode-v2 (or brew upgrade anomalyco/tap/opencode-v2 when already installed), then verify opencode --version. The legacy opencode formula/npm opencode-ai channel can remain on 1.x; the 2.x npm package is @opencode/cli. If the legacy Homebrew formula owns the opencode link, run brew unlink opencode before installing opencode-v2. Keep existing configuration/authentication files.

To test plugins from your current checkout, run:

make plugin SOURCE=local HOSTS=opencode

To install remote plugins, run from an Agentix checkout with Git available:

make plugin SOURCE=main HOSTS=opencode

The Make target configures both native entrypoints. The plugins use native 2.x setup/cleanup objects and plain JSON Schema without Zod or an npm dependency repair. Bare make plugin targets all five hosts: Codex, Pi, OMP, Claude Code, and OpenCode. Use HOSTS=opencode to select only OpenCode.

SOURCE=main installs these native GitHub package references through opencode plugin add, using temporary configuration before publishing both entries:

  • Taskix server: github:tenfyzhong/agentix#main::path:plugins/taskix-manager
  • Bridge TUI: github:tenfyzhong/agentix#main::path:plugins/agentix-bridge

The configuration keeps the GitHub references; OpenCode downloads and manages the local package cache. Run opencode plugin update for remote updates. A failed package installation leaves the previous configuration and local installation intact. Downloaded cache entries remain managed by OpenCode after failure or removal.

SOURCE=local copies package directories under .agentix-plugin inside the OpenCode configuration directory and registers file:// references. It loads both staged plugin entrypoints and their imports before publishing them, without activating the plugins. Incomplete sources fail before replacing the installation. Switching modes removes previous installer-owned references; successful remote installation also removes the old .agentix-plugin copy.

The configuration directory is OPENCODE_CONFIG_DIR, or $XDG_CONFIG_HOME/opencode, defaulting to ~/.config/opencode. The installer adds the Bridge package to cli.json and Taskix Manager to opencode.json/opencode.jsonc, using plugins. OpenCode does not read cli.jsonc; the installer leaves it untouched. The Bridge package exports ./tui; Taskix uses its default server export. Existing unrelated configuration, comments and plugin references are preserved. When both server JSON and JSONC exist, the installer cleans stale Agentix references in both and adds the current entry once to JSONC. Legacy Agentix tui.json and singular plugin references are removed. Reported publication failures during install, update or removal roll back package and configuration changes, preserving original symlinks and existing file modes. This does not guarantee recovery from a process/host crash or concurrent installers. OpenCode's default TUI connects to a background server that survives closing the terminal. After repairing a server-plugin load failure, finish active turns and restart that server, then reopen the TUI:

opencode service restart

For opencode --standalone, restart that terminal process instead. Reopening only the default TUI can retain the old server's failed plugin state. The installer does not restart running sessions. Use opencode plugin list to inspect loaded plugin IDs; the server API's /api/plugin response reports each plugin's state.

To remove these integrations:

make remove-plugin HOSTS=opencode

Removal preserves unrelated plugins and settings. See Taskix Manager for Taskix configuration and optional routing.

Configure Agentix

Add this table to ~/.config/agentix/config.toml alongside your chat channel:

[agent.opencode]
command = "opencode"
state_dir = "~/.local/share/agentix/opencode"

The fields shown are their defaults. state_dir contains Agentix delivery receipts and queues; it is separate from OpenCode's database. If you customize it, export the same absolute path in terminals that start OpenCode:

export AGENTIX_OPENCODE_STATE_DIR=/absolute/path/to/opencode-bridge-state

For a custom [server].endpoint, also export AGENTIX_CONTROL_ENDPOINT with the matching value. For example:

export AGENTIX_CONTROL_ENDPOINT=unix:///absolute/path/to/control.sock

For loopback TCP, including Windows, use an endpoint such as tcp://127.0.0.1:32198 on both sides. Agentix supplies the configured endpoint and state directory to OpenCode sessions launched from its terminal menu, using --standalone so the new native server inherits that environment.

Start and attach

Start agentix serve. In another terminal, change to your project directory and run opencode. Run agentix doctor, then select the session with /sessions opencode in IM. Public IDs have the form opencode:<native-session-id>.

With rmux or tmux available to Agentix, /rmux opencode or /tmux opencode opens the corresponding terminal menu. Choose a pane and start OpenCode there to attach the new session. Ordinary attachment to an existing TUI does not require a multiplexer.

Supported controls

Send ordinary chat messages for prompts and streamed replies. /last, /history, /stop, /queue, /queue resume, /queue clear, /new, /status, /rename, /model, /compact, /diff and /skills use native APIs or the bridge's delivery queue. The session's help shows available controls. Steering, fork and reasoning controls are not exposed.

An IM model choice updates the native session model. The original TUI still sends its own locally selected model with its next prompt, so select the same model there if you want later terminal prompts to use it.

/new stops active work and creates a new native session in the same TUI. Agentix follows the replacement. Resuming an existing session does not inherit another session's queue. /detach leaves the terminal running.

Permissions and questions

Native permission requests appear as IM actions preserving OpenCode's choices: Allow once, Always allow, and Reject. Always allow retains OpenCode's native rule scope; it is not limited to the current IM attachment. Reject denies the requested tool and sends explicit rejection feedback, allowing the assistant to respond. Use /stop to interrupt the whole execution.

Questions appear one at a time. Multiple-choice questions allow selecting several options before Submit. An Other… path is hidden when the native event explicitly sets custom: false. Agentix maps native string and multiselect form fields, preserving option values and custom-input rules. Conditional forms, other typed fields and unsupported validation constraints require the native terminal; IM still offers rejection. Agentix submits all supported answers together; rejection cancels the native form with explicit feedback so the assistant may respond. Use /stop to interrupt the whole execution. Answering in the original TUI retires the corresponding IM controls. Old buttons cannot answer a later request.

Queue recovery

The bridge records accepted delivery IDs before submission and does not automatically resend them after a lost response or restart. An in-flight delivery recovered from disk is marked uncertain and pauses the queue. Inspect /history and /queue, then use /queue clear to abandon the uncertain receipt before submitting a new request if needed. Clearing does not cancel a prompt OpenCode already accepted.

The sidecar directory uses owner-only permissions and contains delivery state. Preserve it when restarting. These local writes support process-restart recovery; they are not a power-loss durability guarantee. See the technical protocol for implementation boundaries.

Native turn identity and limits

Native tagged history and delivered inbox/user IDs provide turn identity without server stamps or prompt fingerprints. Compaction entries do not become user prompts. Identical real prompts and attachments retain distinct IDs. Admitting a queued prompt does not replace the running Taskix context; native delivery activates it. Individual model/tool steps and assistant step errors do not complete a turn. A busy native execution can include several promoted users and settles them at its terminal boundary. Taskix stores minimal active context/ownership in native plugin storage for compaction and process-restart recovery. Failed activation can retry with the same source ID. Plugin cleanup preserves unfinished native continuation context rather than recording a completed reply.

The remote queue accepts up to 128 prompts / 8 MiB, with 256 KiB per prompt. History reads are limited to twenty pages of 200 native messages within five seconds. If a turn cannot fit that reconstruction limit, history fails explicitly instead of presenting a complete-looking partial turn. Bridge metadata/alias caches target 4,096 entries with active identity pinning. The separate part-text cache retains at most 8,192 entries / 8 MiB and evicts old entries without pinning active text. Native turn associations retain IDs rather than full prompt or attachment payloads. These caches do not truncate model input or native history. Sidecar checkpoints limit the delta journal to 4,096 records / 1 MiB between checkpoints. Hot delivery receipts retain 2,048 entries / 1 MiB except active work; older receipts remain in a disk archive for exact retry deduplication. The archive intentionally grows with distinct deliveries; these limits do not cap a session's lifetime.

Taskix keeps up to 64 inactive native-session wrappers. Idle wrappers stop lease timers and check ownership from current context; active owned leases continue renewing and are not evicted just to meet the idle limit. Wrappers with active or queued dispatcher work are also retained. Taskix dispatch permits sixteen event jobs globally and four per session, preserving per-session ordering and applying backpressure to the native event stream when full.

Bridge filters foreign-session events and omits unused tool payloads before queueing. Selected-session event count remains uncapped during bounded SDK waits (normally five seconds). Cache limits therefore do not cap total memory, and the receipt archive has no lifetime disk quota.

Validation boundary

The installed OpenCode 2.0.32 headless integration passed locally through the native HTTP server API, covering Taskix schema/skills, attachment history and compaction identity. It does not exercise Bridge TCP registration. The current production Telegram/Engine/BridgeHub/native-TUI/Taskix chain passed with both tmux and rmux, covering native permissions, multiselect answers and service-component replacement during a pending permission. The final installed, uninstrumented native TUI suite also passed with tmux and rmux, including original terminal isolation, permissions/forms and rejection feedback, queue/crash recovery, compaction and session replacement. The denied shell tool was not executed and subsequent prompts still ran. Detailed acceptance results are recorded in the integration coverage map. Telegram HTTP and provider services are local fixtures; this does not verify live IM accounts or production providers. Earlier Linux ARM64/OpenCode 1.19.3 results are historical 1.x evidence. Native 2.0.32 headless Linux/Windows CI exercises the HTTP server/plugin boundary; it does not prove a full Linux/Windows IM/TUI chain. Separate native tmux/Telegram jobs run on Linux/macOS; Windows native TUI/IM acceptance remains unverified. Native Feishu/Slack closed loops and live external IM/provider acceptance remain unverified. Current 2.x and historical 1.x performance measurements state their scopes separately and do not establish a zero-regression claim.

Clone this wiki locally