Problem
OpenCode CLI runtime (src/middleware/runtimes/opencode.ts) has a --file flag for file input, but it hardcodes text/plain MIME type for all files (source). Binary media (images, audio, video) is sent as text, making multimodal input non-functional.
Current state
- Uses
run --format json for invocation
--file <path> flag exists but hardcodes text/plain MIME type
- All binary media would be corrupted/ignored
Implementation
While upstream bug persists
- Declare:
acceptsInbound: [] (no media support)
- All media must be handled by middleware fallback (STT for audio, vision API for images)
emitsOutbound: false
readonly mediaCapabilities = {
acceptsInbound: [],
emitsOutbound: false,
};
When upstream fixes MIME detection
- Pass
--file <path> for media attachments with correct MIME types
- Temp file management similar to Gemini
- Update capability based on which MIME types OpenCode supports
Tests
Unit tests (src/middleware/runtimes/opencode.test.ts)
Future tests (when upstream is fixed)
Upstream tracking
Depends on
Related
Problem
OpenCode CLI runtime (
src/middleware/runtimes/opencode.ts) has a--fileflag for file input, but it hardcodestext/plainMIME type for all files (source). Binary media (images, audio, video) is sent as text, making multimodal input non-functional.Current state
run --format jsonfor invocation--file <path>flag exists but hardcodestext/plainMIME typeImplementation
While upstream bug persists
acceptsInbound: [](no media support)emitsOutbound: falseWhen upstream fixes MIME detection
--file <path>for media attachments with correct MIME typesTests
Unit tests (
src/middleware/runtimes/opencode.test.ts)execute()with media present does NOT pass--fileflag (upstream bug workaround)mediaCapabilitiesreports emptyacceptsInboundFuture tests (when upstream is fixed)
execute()with image attachment passes--fileflagUpstream tracking
run --filehardcodestext/plainMIME type for all files anomalyco/opencode#16723mediaCapabilities, implement--filepassthrough, enable testsDepends on
Related