feat(bridges): register CLI-channel config for agents/dispatch-message#130
Merged
Conversation
Introduce lib/cli-channel.sh, a shared helper that writes a mu-plugin file
at wp-content/mu-plugins/wp-coding-agents-channels.php registering chat
bridges with the Data Machine Code generic CLI transport runtime via the
datamachine_code_cli_channels filter. Bridge install/upgrade calls
cli_channel_register; bridge uninstall calls cli_channel_unregister.
Marker-delimited blocks make multi-bridge rewrites idempotent — per-bridge
upserts and removals do not disturb other bridges' entries.
The mu-plugin file is the discovery surface DMC#412 reads to resolve
agents/dispatch-message channel names to command + argv templates with
{recipient} / {message} substitution tokens.
Wired into setup.sh + upgrade.sh lib loader so bridges/*.sh can call the
helper directly during their install / sync_config hooks.
Refs #129
Depends-on Extra-Chill/data-machine-code#412
Each chat bridge now writes its DMC CLI-channel config entry during install
and upgrade-time sync_config, so the Data Machine Code generic CLI transport
runtime (#412) can route agents/dispatch-message calls without bespoke
webhooks or HTTP hops.
Per bridge:
- kimaki: registers the local datamachine-kimaki adapter shim (falls back
to the global kimaki binary). recipient = Discord channel ID. argv =
send --channel {recipient} --prompt {message}.
- cc-connect: registers cc-connect send. recipient = cc-connect project
name (the platform binding lives in config.toml). argv = send --project
{recipient} {message}. Assumption to validate upstream: if --project
isn't supported, the argv collapses to [send,{message}] and recipient
is informational only.
- telegram: opencode-telegram-bot is inbound-only — no outbound send CLI.
Registers curl against Telegram's sendMessage Bot API with
TELEGRAM_BOT_TOKEN baked in at install/upgrade time. recipient =
Telegram chat ID. Re-running upgrade refreshes the token from the bot
.env file if rotated.
Refs #129
Depends-on Extra-Chill/data-machine-code#412
Add an 'Outbound Dispatch (agents/dispatch-message)' section to README covering: how each bridge registers a CLI channel via the mu-plugin discovery file, the channel/recipient semantics per bridge, and a manual migration runbook for retiring the legacy /opt/agent-ping-webhook/ stack. The retirement guidance is intentionally prose + numbered list rather than an automated helper script. The stack exists on exactly one host and shipping permanent automation for a one-shot deletion would be technical debt. Refs #129
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each chat bridge installer now writes a CLI-channel config entry consumed by Data Machine Code's generic CLI transport runtime (Extra-Chill/data-machine-code#412), which backs the
agents/dispatch-messageability. With this in place, outbound dispatch from a data-machine flow becomes:…and DMC's CLI runtime shells the configured command. No HTTP, no Python, no nginx hop. This retires the legacy
/opt/agent-ping-webhook/stack from the architecturally-correct side.Closes #129.
Mechanism: marker-delimited mu-plugin file
Picked Option A from the issue. Each bridge install/upgrade rewrites its block in:
The file registers entries via the
datamachine_code_cli_channelsfilter. Each bridge contributes a marker-delimited block (// BEGIN bridge:<name>…// END bridge:<name>) so per-bridge upserts and removals leave other bridges' blocks untouched. Idempotency is verified manually: repeated registers leave the file byte-identical; updating args replaces only the affected block; unregister removes only that block.Rendered block format:
Substitution tokens (
{recipient},{message}) are resolved by DMC#412 at dispatch time.Per-bridge changes
commandrecipientsemanticsbridges/kimaki.shkimakiRESOLVED_DATAMACHINE_KIMAKIadapter shim (fallback:KIMAKI_BIN/ globalkimaki)[send, --channel, {recipient}, --prompt, {message}]bridges/cc-connect.shcc-connectCC_BIN(fallback: PATHcc-connect)[send, --project, {recipient}, {message}]config.toml)bridges/telegram.shtelegramcurl[-sS, -X, POST, https://api.telegram.org/bot<TOKEN>/sendMessage, --data-urlencode, chat_id={recipient}, --data-urlencode, text={message}]Each bridge registers on both
bridge_install(setup-time) andbridge_sync_config(upgrade-time) so the resolved command path / token stays fresh across npm-global moves and credential rotations.Documented assumptions
Two bridges required reading the CLI without being able to run it on this PR's host:
cc-connect sendis documented in the upstream README (v1.3.x) but the project-routing flag is not explicit. I picked--project {recipient} {message}as a defensible default — a project name is the closest analogue to a routable address in cc-connect's model, since the actual chat platform (Feishu/Slack/Telegram/Discord/…) is bound per-project inconfig.toml. If--projectis unsupported upstream, the argv collapses to[send, {message}]andrecipientbecomes informational only. This is a fast follow-up — the marker-delimited file makes the swap trivial.opencode-telegram-botis inbound-only. It polls Telegram and forwards messages to a local opencode server; it has nosendsubcommand. To preserve the channel/recipient model anyway, the bridge registerscurlagainst Telegram'ssendMessageBot API withTELEGRAM_BOT_TOKENcaptured from either the current env or the bot.envfile. The token is baked into the URL fragment ofcommand— rotating the token requires re-running setup/upgrade.Both assumptions are called out inline in the bridge files and in the README so an operator picking them up later isn't guessing.
Legacy retirement (manual)
Per orchestrator scope-cut: no helper script. The legacy
/opt/agent-ping-webhook/stack exists on exactly one VPS; permanent automation for a one-shot deletion would be technical debt. Retirement is documented as prose + numbered list in README under "Migrating from the legacyagent-pingwebhook". Steps cover: reconfigure dispatch flow →systemctl disable --now+ remove unit →rm -rf /opt/agent-ping-webhook/→ drop thelocation /agent-ping/nginx block →nginx -t && systemctl reload nginx→ free port 8422 → remove the token file.Verification
bash -nparses cleanly onlib/cli-channel.sh, all three modified bridges, andsetup.sh/upgrade.sh.tests/bridge-render.shsnapshot regressions: passes for everything except a pre-existing kimaki-launchd PATH drift (caused bynodebeing on the test host's PATH — unrelated to this PR; confirmed by re-running the test againstmainwith the changes stashed).lib/cli-channel.sh:php -lclean.md5sumunchanged (idempotent no-op).php -lclean.php -lclean.:and/→ escaped correctly in the PHP single-quoted literal,php -lclean.DRY_RUN=truepath → logs intent, writes zero bytes.CHANGELOG.mdorVERSION. Conventional commits; homeboy owns the bumps.Files
lib/cli-channel.sh(new): mu-plugin registrar + idempotent block rewriter.setup.sh/upgrade.sh: load the new lib module.bridges/kimaki.sh:_kimaki_register_cli_channelcalled from install + sync_config.bridges/cc-connect.sh:_cc_connect_register_cli_channelcalled from install + sync_config.bridges/telegram.sh:_telegram_register_cli_channelcalled from install + sync_config (with bot.envfallback for token resolution on upgrade).README.md: new "Outbound Dispatch" section + manual migration runbook.cc <@532385681268408341>