Documentation
¶
Overview ¶
Command echo-channel is the reference rysh channel plugin (docs/plugin-authoring.md).
It speaks the stdio transport: newline-delimited JSON-RPC 2.0 on stdin/stdout, exactly what rysh's PluginSupervisor drives (internal/channels/plugin/stdio.go is the core-side counterpart). The nats transport exists too (subjects rysh.channel.plugin.{name}.*), but stdio is the right starting point for authors: no bus credentials, no extra dependency — this file imports only the standard library, so it can be copied out of the rysh repo and built standalone.
"Echo" semantics: an echo channel has no real platform behind it, so the only external stimulus is rysh sending a message. Every outbound `send` is reflected straight back as an `inbound` notification on the same thread — which exercises both directions of the wire contract and makes a humanoid literally talk to itself.
Wire contract (core → plugin requests, plugin replies by id):
start(ChannelConfig) begin "connecting"; reply {ok}; then push status + inbounds
send(OutboundMessage) deliver to the platform; reply {ok} or an error object
status() reply the current ChannelStatus
stop() graceful shutdown; reply {ok}, then exit 0
Core → plugin notification (no id, no reply):
setReplyMode({op,mode})
Plugin → core notifications:
ready() REQUIRED once at startup — core's spawn blocks on it inbound(InboundMessage) a message arriving from the platform status(ChannelStatus) connection-state updates (core caches the last one)
Rules a plugin must obey:
- stdout is the protocol. One JSON object per line, nothing else — log to stderr (core forwards it).
- Emit `ready` promptly: core kills the process after its ready timeout (10s default).
- Exit 0 on `stop` and on stdin EOF. Any other exit is treated as a crash: core restarts with backoff and eventually circuit-breaks.