optio-opencode
Run opencode web as an optio task — local subprocess or remote over SSH — with opencode's UI reachable through optio's UI components.
What it does
Given an OpencodeTaskConfig (workdir contents, prompt, deliverable callback), optio-opencode:
- Provisions a fresh workdir on the chosen host (local or remote).
- Writes
AGENTS.md(base prompt + your instructions) andopencode.json(your config) into it. - Installs the opencode binary if missing (remote mode only).
- Launches
opencode webwith a random auth password. - Registers the opencode UI as a widget that optio's UI components can embed via the widget proxy — SSH tunnel hidden from optio-api.
- Tails a log file the LLM writes to and translates structured lines into optio events:
STATUS: …→ctx.report_progress(percent, message)DELIVERABLE: <path>→ fetches the file, invokes youron_deliverablecallbackDONE [summary]→ clean completionERROR [message]→ failure
- Cleans up workdir and SSH connection on teardown.
The same OpencodeTaskConfig works for local and remote modes; only SSHConfig differs.
When to use it
You want an opencode-driven assistant session as a managed optio task — surfaced through optio's UI, with progress reporting and file deliverables — without writing the host management, log parsing, or widget plumbing yourself.
Installation
pip install optio-opencode
Python 3.11+. Depends on optio-core, optio-host, and asyncssh.
Minimal example
from optio_opencode import create_opencode_task, OpencodeTaskConfig
from optio_host import SSHConfig
config = OpencodeTaskConfig(
workdir_files={"AGENTS.md": "Do the thing.", "opencode.json": "{...}"},
on_deliverable=lambda ctx, path, text: print(f"got {path}: {len(text)} bytes"),
ssh=SSHConfig(host="worker-1", user="optio", key_path="~/.ssh/id_optio"),
)
task = create_opencode_task(config)
# Schedule / run via optio-core as usual.
Set ssh=None for local subprocess mode.
Messages
use_client_messages(bool, defaultFalse) — enable theCLIENT_MESSAGE:log keyword: the agent can push{keyword, data}messages to the browser session that launched the task (surfaced via optio-ui'sonClientMessage).on_caller_message(async callback, defaultNone) — enable theCALLER_MESSAGE:log keyword: the agent can push{keyword, data}messages to your application. Signature(hook_ctx, keyword, data) -> str | None; a non-None return is sent back to the agent as feedback. Keywords that are not enabled are absent from both the parser and the agent-facing protocol documentation.
License
Apache-2.0.
Metadata
Release files for optio-opencode 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| optio_opencode-0.6.1.tar.gz | 124.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optio_opencode-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 189.4 kB
Release files / optio_opencode-0.6.1.tar.gz
| Download URL | optio_opencode-0.6.1.tar.gz |
|---|---|
| Size | 124.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80f0ecefed94a14b91d98e2a25575b2ab91619261e5fbf7f87a79d74271e412c
|
|
BLAKE2b-256 checksum How to use checksums |
cd48396980e5b00acf682e7aa3ac6987073b12a9a0b484f08913202e443b28a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / optio_opencode-0.6.1-py3-none-any.whl
| Download URL | optio_opencode-0.6.1-py3-none-any.whl |
|---|---|
| Size | 64.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93f678cdb797c21fe04393f70cbeea44782ab5acb4f3ce358362924931e657b8
|
|
BLAKE2b-256 checksum How to use checksums |
93e3b8d160b1806979d84601c48e2aad7aa1e1aef76fabb8ca903fec2dc9dca8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|