opencode
opencode copied to clipboard
feat(tui): enable plugin tools to use Task component rendering
Summary
This PR enables external plugin tools to use the built-in Task component's TUI rendering, providing a consistent visual experience for custom task implementations.
Changes
-
TUI Routing: Route plugin tools with
sessionIdmetadata to Task/BlockTool component - Task Component: Support flexible input shapes from external tools (agentName fallback chain, conditional toolcalls display)
-
Registry: Preserve plugin tool metadata by wrapping context and capturing
metadata()calls
How it works
Plugin tools can now call ctx.metadata({ metadata: { sessionId: "..." } }) to opt into BlockTool rendering. The TUI checks for metadata.sessionId presence and routes accordingly.
Technical Details
- Removed
as anytype assertion in registry, replaced with explicit types - Added
wrappedCtxto intercept and capture metadata from plugin tool execution - Task component now derives
agentNamefrom multiple sources:subagent_type → agent → category → tool