aios-mqtt-channel
v0.0.1
Published
MQTT channel plugin for OpenClaw - bidirectional messaging via MQTT brokers, part of the AIOS suite.
Downloads
139
Maintainers
Readme
aios-mqtt-channel
aios-mqtt-channel 鏄潰鍚?OpenClaw 鐨?MQTT 鍙屽悜閫氶亾鎻掍欢锛屽彲閫氳繃 MQTT Broker 涓?IoT銆佸搴嚜鍔ㄥ寲銆佽繍缁村憡璀︾郴缁熶簰閫氭秷鎭€?
璇存槑锛?
- 鎻掍欢鍖呭悕銆佹彃浠跺悕涓?
channel id宸茬粺涓€涓?aios-mqtt-channel銆?- OpenClaw 鐨勬彃浠跺畨瑁呫€佹彃浠剁鐞嗐€乣channels閰嶇疆閿兘浣跨敤aios-mqtt-channel銆? 褰撳墠鐗堟湰闈㈠悜 OpenClaw2026.5.x` 閫氶亾 SDK锛屽寘鍚柊鐗?channel/setup 鍏ュ彛鍙?configured-state 鍏冩暟鎹€?
鍔熻兘鐗规€?
- 鍙屽悜娑堟伅鏀跺彂锛氳闃?MQTT Topic锛屽苟灏?OpenClaw 鍥炲鍥炲啓鍒版寚瀹?Topic銆?- 澶氳处鍙锋敮鎸侊細涓€涓?OpenClaw 瀹炰緥鍙悓鏃惰繛鎺ュ涓?MQTT 璐﹀彿閰嶇疆銆?- 鑷姩閲嶈繛锛欱roker 閲嶅惎鎴栫綉缁滄姈鍔ㄥ悗鍙嚜鍔ㄦ仮澶嶃€?- TLS 鏀寔锛氭敮鎸?
mqtts://瀹夊叏杩炴帴銆?- QoS 鍙厤缃細鏀寔0 / 1 / 2涓夌鎶曢€掍繚闅滅瓑绾с€?
瀹夎
openclaw plugins install aios-mqtt-channel濡傛灉 OpenClaw 褰撳墠浼樺厛鍔犺浇鐨勬槸鏈湴鏈墭绠$洰褰?~/.openclaw/extensions/aios-mqtt-channel锛屽畠浼氳鐩栧叏灞€ npm 瀹夎銆傚彲閫氳繃浠ヤ笅鍛戒护纭瀹為檯鍔犺浇鏉ユ簮锛?
openclaw plugins info aios-mqtt-channel濡傛灉杈撳嚭鏄剧ず褰撳墠鏉ユ簮鏄?~/.openclaw/extensions/aios-mqtt-channel/dist/index.js锛屽彲浠ユ墽琛岋細
openclaw plugins update aios-mqtt-channel濡傛灉 plugins info 鏄剧ず鐨勬槸鏃х殑鏈湴澶囦唤鐩綍鑰屼笉鏄凡瀹夎鎻掍欢璁板綍锛?
- 灏?
~/.openclaw/extensions/涓嬫棫鐨?aios-mqtt-channel澶囦唤鐩綍绉昏蛋銆?2. 閲嶆柊鎵цopenclaw plugins install aios-mqtt-channel銆?3. 閲嶅惎 OpenClaw 缃戝叧銆? 涓嶈鎶?aios-mqtt-channel.bak-*涔嬬被鐨勫浠界洰褰曠暀鍦?~/.openclaw/extensions/涓嬶紝鍚﹀垯 OpenClaw 鍙兘璇嗗埆鍒伴噸澶嶆彃浠躲€?
閰嶇疆
灏嗕互涓嬪唴瀹瑰姞鍏?~/.openclaw/openclaw.json锛?
{
"channels": {
"aios-mqtt-channel": {
"accounts": {
"admin": {
"brokerUrl": "mqtts://your-server:8883",
"username": "your-name",
"password": "your-password",
"topics": {
"inbound": "openclaw/inbound-admin",
"outbound": "openclaw/outbound-admin"
},
"qos": 1,
"disableBlockStreaming": false
},
"lowcode": {
"brokerUrl": "mqtts://your-server:8883",
"username": "your-name",
"password": "your-password",
"topics": {
"inbound": "openclaw/inbound-lowcode",
"outbound": "openclaw/outbound-lowcode"
},
"qos": 1,
"disableBlockStreaming": false
}
}
}
},
"plugins": {
"allow": [
"aios-mqtt-channel"
],
"entries": {
"aios-mqtt-channel": {
"enabled": true
}
}
}
}璇存槑锛?
channels["aios-mqtt-channel"]鏄€氶亾閰嶇疆閿€?-plugins.allow涓?plugins.entries涓簲濉啓鎻掍欢鍚?aios-mqtt-channel銆?-accounts涓嬫瘡涓敭閮芥槸涓€涓?OpenClaw 璐﹀彿 ID锛屾彃浠朵細涓烘瘡涓处鍙峰惎鍔ㄧ嫭绔?MQTT 瀹㈡埛绔€?- 鏃х増鍗曡处鍙峰啓娉曚粛鐒跺吋瀹癸紝骞朵細琚涓?default璐﹀彿锛涙柊閮ㄧ讲寤鸿缁熶竴浣跨敤accounts銆? 閰嶇疆瀹屾垚鍚庨噸鍚綉鍏宠繘绋嬶細
systemctl restart openclaw鐢ㄦ硶
Session ID 璇存槑
- 璺敱渚濇嵁鏄?MQTT 璐﹀彿 ID 鍔犱笂鍏ョ珯娑堟伅涓殑
senderId銆傛彃浠朵細鍏堣В鏋?OpenClaw route锛屽叾涓?peer.id = senderId锛岄殢鍚庣敱 OpenClaw 鏍规嵁bindings涓?session 閰嶇疆璁$畻鏈€缁堢殑agentId鍜?sessionKey銆?-sessionId鍙槸璇锋眰绾у瓧娈点€傚鏋滃叆绔?JSON 涓惡甯?sessionId锛屾彃浠朵細鍦ㄥ嚭绔?JSON 涓師鏍峰洖鏄撅紝渚夸簬瀹㈡埛绔叧鑱旇姹備笌鍥炲銆?-sessionId涓嶄細鍒涘缓鏂颁細璇濓紝涔熶笉浼氱洿鎺ユ敼鍙樿蹇嗕笂涓嬫枃銆? 濡傛灉甯屾湜涓嶅悓瀵硅瘽褰兼闅旂锛屽簲浣跨敤涓嶅悓鐨?senderId銆?
鎺ユ敹鍏ョ珯娑堟伅
鍙戝竷鍒版煇涓处鍙?inbound Topic 鐨勬秷鎭細琚?OpenClaw 澶勭悊銆傛敮鎸佺函鏂囨湰鍜?JSON锛屾帹鑽?JSON锛?
# 绾枃鏈紙admin 璐﹀彿锛?mosquitto_pub -t "openclaw/inbound-admin" -m "Alert: Service down on playground"
# JSON锛堟帹鑽愶紝lowcode 璐﹀彿锛?mosquitto_pub -t "openclaw/inbound-lowcode" -m "{\"senderId\":\"pg-cli\",\"text\":\"hello\",\"sessionId\":\"abc-123\"}"鍏ョ珯 JSON 绀轰緥锛?
{"senderId":"conn-test2","text":"What is your agent name?","sessionId":"conn-test2"}鎸夋秷鎭鐩?disableBlockStreaming 鐨勭ず渚嬶細
{"senderId":"conn-test2","text":"Give me the final answer only","sessionId":"conn-test2","disableBlockStreaming":true}璇存槑锛?
disableBlockStreaming浠呭奖鍝嶅綋鍓嶈繖鏉?MQTT 璇锋眰銆?- 濡傛灉娑堟伅閲屼笉浼犺瀛楁锛屽垯缁ф壙璐﹀彿绾ч厤缃腑鐨?disableBlockStreaming銆?-true浼氬己鍒跺綋鍓嶈姹傝蛋闈?block-streaming 璺緞锛屼互渚?OpenClaw 杈撳嚭final鍥炲銆?-false浼氭樉寮忓厑璁稿綋鍓嶈姹備娇鐢?block streaming锛屽嵆浣胯处鍙烽粯璁ゅ叧闂簡瀹冦€?
鎺ユ敹鍑虹珯鍥炲
Agent 鍥炲浼氫互 JSON 褰㈠紡鍙戝竷鍒拌璐﹀彿瀵瑰簲鐨?outbound Topic锛?
{"senderId":"openclaw","text":"...","kind":"final","sessionId":"conn-test2","ts":1700000000000}濡傛灉鍏ョ珯 JSON 鎼哄甫浜?sessionId锛屽嚭绔欏洖澶嶄腑浼氬師鏍峰洖鏄捐瀛楁锛屽寘鎷粡鐢?OpenClaw 閫氱敤鍑虹珯璺緞鍙戦€佺殑缂撳啿鎴栧欢杩熷洖澶嶃€?
璁㈤槄绀轰緥锛?
mosquitto_sub -t "openclaw/outbound-lowcode" -v棰勬湡鍥炲缁撴瀯锛?
{"senderId":"openclaw","text":"...","kind":"final","ts":1700000000000,"sessionId":"abc-123"}璇存槑锛?
- 鎻掍欢浼氬師鏍烽€忎紶 OpenClaw 鐨勫嚭绔?
kind锛屼笉浼氭妸block鏀瑰啓鎴?final锛屼篃涓嶄細鍙嶅悜鏀瑰啓銆?- 寮€鍚?block streaming 鏃讹紝kind鍙兘鏄?block锛涙渶缁堝洖澶嶉€氬父鏄?final銆?- 濡傛灉鍏ョ珯娑堟伅璁剧疆浜?disableBlockStreaming: true锛岃璇锋眰浼氳姹?OpenClaw 灏介噺閬垮厤 block streaming锛屼粠鑰屼紭鍏堣緭鍑?final銆?- 濡傛灉鍏ョ珯娑堟伅娌℃湁璁剧疆disableBlockStreaming锛屽垯鍑虹珯kind鍙楄处鍙风骇閰嶇疆褰卞搷銆?- 鍙湁鍦ㄥ叆绔?JSON 鍚湁sessionId鏃讹紝鍑虹珯 JSON 鎵嶄細鍥炴樉璇ュ瓧娈点€?- 鏁板瓧绫诲瀷鐨勫叆绔?sessionId浼氬湪鍑虹珯 JSON 涓鑼冨寲涓哄瓧绗︿覆銆?-outbound.sendText()浣跨敤鐩稿悓 JSON 鍖呰鏍煎紡锛涘鏋?OpenClaw 鎻愪緵浜?threadId锛屾彃浠朵細灏嗗叾浣滀负sessionId鍐欏洖锛屽惁鍒欓粯璁ゅ啓鍏?-1銆?
鏁呴殰鎺掓煡
妫€鏌?OpenClaw 褰撳墠瀹為檯鍔犺浇鐨勬槸鍝竴浠芥彃浠讹細
openclaw plugins info aios-mqtt-channel甯哥敤瀹炴椂鏃ュ織锛?
journalctl -u openclaw -f | grep -E "MQTT channel ready|MQTT route resolved|Inbound MQTT message|sent reply"澶氳处鍙峰満鏅笅锛屾甯稿惎鍔ㄦ椂搴旂湅鍒版瘡涓处鍙峰悇鑷畬鎴愯闃咃紝渚嬪锛?
[admin] MQTT channel ready, subscribed to openclaw/inbound-admin
[lowcode] MQTT channel ready, subscribed to openclaw/inbound-lowcode姣忔潯鍏ョ珯娑堟伅杩樹細杈撳嚭瑙f瀽鍚庣殑璺敱鏃ュ織锛?
MQTT route resolved topic=openclaw/inbound-lowcode inboundAccount=lowcode routeAccount=lowcode agent=lowcode session=...濡傛灉杩欓噷鏄剧ず agent=main锛岃鏄?MQTT Topic 宸插懡涓彃浠讹紝浣?OpenClaw 浠嶆牴鎹綋鍓?bindings 鎶婅姹傝矾鐢卞埌浜嗕富 agent銆?
瀹夊叏璇存槑
閲嶈锛氫换浣曡兘澶熷悜鍏ョ珯 Topic 鍙戝竷娑堟伅鐨勫鎴风锛岄兘绛夊悓浜庢嫢鏈?OpenClaw Agent 鐨勫畬鏁磋闂兘鍔涖€傝浠呭湪鍙俊鐜涓毚闇?MQTT 閫氶亾锛屼緥濡傦細
- 鍙楁帶 Broker
- 寮€鍚璇?- 绉佹湁缃戠粶
- 涓婃父澧炲姞棰濆閴存潈鎴栨牎楠屽眰
濡傛灉闇€瑕佹帴鍏ヤ笉鍙俊瀹㈡埛绔紝寤鸿鍏堝湪鍙戝竷鍒?openclaw/inbound 涔嬪墠澧炲姞鐙珛楠岃瘉灞傘€?
寮€鍙?
# 鍏嬮殕浠撳簱锛堝皢 <host> 鏇挎崲涓哄疄闄呭湴鍧€锛?git clone ssh://<host>/opt/git/openclaw-mqtt.git
cd openclaw-mqtt
# 瀹夎渚濊禆
npm install
# 杩愯娴嬭瘯
npm test
# 绫诲瀷妫€鏌?npm run typecheck
# 鏋勫缓
npm run build鏋舵瀯
MQTT Broker (Mosquitto/EMQX)
|
+--> inbound topic ---> OpenClaw Gateway ---> Agent
|
+<-- outbound topic <-- OpenClaw Gateway <--- Agent璁稿彲璇?
MIT
