{"id":88,"date":"2026-03-21T22:47:16","date_gmt":"2026-03-21T14:47:16","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/concepts-architecture\/"},"modified":"2026-03-21T23:08:53","modified_gmt":"2026-03-21T15:08:53","slug":"concepts-architecture","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/concepts-architecture\/","title":{"rendered":"Gateway \u7f51\u5173\u67b6\u6784"},"content":{"rendered":"<h1>Gateway \u7f51\u5173\u67b6\u6784<\/h1>\n<p>\u6700\u540e\u66f4\u65b0\uff1a2026-01-22<\/p>\n<h2>\u6982\u8ff0<\/h2>\n<ul>\n<li>\u5355\u4e2a\u957f\u671f\u8fd0\u884c\u7684 <strong>Gateway \u7f51\u5173<\/strong>\u62e5\u6709\u6240\u6709\u6d88\u606f\u5e73\u53f0\uff08\u901a\u8fc7 Baileys \u7684 WhatsApp\u3001\u901a\u8fc7 grammY \u7684 Telegram\u3001Slack\u3001Discord\u3001Signal\u3001iMessage\u3001WebChat\uff09\u3002<\/li>\n<li>\u63a7\u5236\u5e73\u9762\u5ba2\u6237\u7aef\uff08macOS \u5e94\u7528\u3001CLI\u3001Web \u754c\u9762\u3001\u81ea\u52a8\u5316\uff09\u901a\u8fc7\u914d\u7f6e\u7684\u7ed1\u5b9a\u4e3b\u673a\uff08\u9ed8\u8ba4 <code>127.0.0.1:18789<\/code>\uff09\u4e0a\u7684 <strong>WebSocket<\/strong> \u8fde\u63a5\u5230 Gateway \u7f51\u5173\u3002<\/li>\n<li><strong>\u8282\u70b9<\/strong>\uff08macOS\/iOS\/Android\/\u65e0\u5934\u8bbe\u5907\uff09\u4e5f\u901a\u8fc7 <strong>WebSocket<\/strong> \u8fde\u63a5\uff0c\u4f46\u58f0\u660e <code>role: node<\/code> \u5e76\u5e26\u6709\u660e\u786e\u7684\u80fd\u529b\/\u547d\u4ee4\u3002<\/li>\n<li>\u6bcf\u53f0\u4e3b\u673a\u4e00\u4e2a Gateway \u7f51\u5173\uff1b\u5b83\u662f\u552f\u4e00\u6253\u5f00 WhatsApp \u4f1a\u8bdd\u7684\u4f4d\u7f6e\u3002<\/li>\n<li><strong>canvas \u4e3b\u673a<\/strong>\uff08\u9ed8\u8ba4 <code>18793<\/code>\uff09\u63d0\u4f9b\u667a\u80fd\u4f53\u53ef\u7f16\u8f91\u7684 HTML \u548c A2UI\u3002<\/li>\n<\/ul>\n<h2>\u7ec4\u4ef6\u548c\u6d41\u7a0b<\/h2>\n<h3>Gateway \u7f51\u5173\uff08\u5b88\u62a4\u8fdb\u7a0b\uff09<\/h3>\n<ul>\n<li>\u7ef4\u62a4\u63d0\u4f9b\u5546\u8fde\u63a5\u3002<\/li>\n<li>\u66b4\u9732\u7c7b\u578b\u5316\u7684 WS API\uff08\u8bf7\u6c42\u3001\u54cd\u5e94\u3001\u670d\u52a1\u5668\u63a8\u9001\u4e8b\u4ef6\uff09\u3002<\/li>\n<li>\u6839\u636e JSON Schema \u9a8c\u8bc1\u5165\u7ad9\u5e27\u3002<\/li>\n<li>\u53d1\u51fa\u4e8b\u4ef6\u5982 <code>agent<\/code>\u3001<code>chat<\/code>\u3001<code>presence<\/code>\u3001<code>health<\/code>\u3001<code>heartbeat<\/code>\u3001<code>cron<\/code>\u3002<\/li>\n<\/ul>\n<h3>\u5ba2\u6237\u7aef\uff08mac \u5e94\u7528 \/ CLI \/ web \u7ba1\u7406\uff09<\/h3>\n<ul>\n<li>\u6bcf\u4e2a\u5ba2\u6237\u7aef\u4e00\u4e2a WS \u8fde\u63a5\u3002<\/li>\n<li>\u53d1\u9001\u8bf7\u6c42\uff08<code>health<\/code>\u3001<code>status<\/code>\u3001<code>send<\/code>\u3001<code>agent<\/code>\u3001<code>system-presence<\/code>\uff09\u3002<\/li>\n<li>\u8ba2\u9605\u4e8b\u4ef6\uff08<code>tick<\/code>\u3001<code>agent<\/code>\u3001<code>presence<\/code>\u3001<code>shutdown<\/code>\uff09\u3002<\/li>\n<\/ul>\n<h3>\u8282\u70b9\uff08macOS \/ iOS \/ Android \/ \u65e0\u5934\u8bbe\u5907\uff09<\/h3>\n<ul>\n<li>\u4ee5 <code>role: node<\/code> \u8fde\u63a5\u5230<strong>\u540c\u4e00\u4e2a WS \u670d\u52a1\u5668<\/strong>\u3002<\/li>\n<li>\u5728 <code>connect<\/code> \u4e2d\u63d0\u4f9b\u8bbe\u5907\u8eab\u4efd\uff1b\u914d\u5bf9\u662f<strong>\u57fa\u4e8e\u8bbe\u5907<\/strong>\u7684\uff08\u89d2\u8272\u4e3a <code>node<\/code>\uff09\uff0c\u6279\u51c6\u5b58\u50a8\u5728\u8bbe\u5907\u914d\u5bf9\u5b58\u50a8\u4e2d\u3002<\/li>\n<li>\u66b4\u9732\u547d\u4ee4\u5982 <code>canvas.*<\/code>\u3001<code>camera.*<\/code>\u3001<code>screen.record<\/code>\u3001<code>location.get<\/code>\u3002<\/li>\n<\/ul>\n<p>\u534f\u8bae\u8be6\u60c5\uff1a<\/p>\n<ul>\n<li><a href=\"\/gateway\/protocol\">Gateway \u7f51\u5173\u534f\u8bae<\/a><\/li>\n<\/ul>\n<h3>WebChat<\/h3>\n<ul>\n<li>\u9759\u6001\u754c\u9762\uff0c\u4f7f\u7528 Gateway \u7f51\u5173 WS API \u83b7\u53d6\u804a\u5929\u5386\u53f2\u548c\u53d1\u9001\u6d88\u606f\u3002<\/li>\n<li>\u5728\u8fdc\u7a0b\u8bbe\u7f6e\u4e2d\uff0c\u901a\u8fc7\u4e0e\u5176\u4ed6\u5ba2\u6237\u7aef\u76f8\u540c\u7684 SSH\/Tailscale \u96a7\u9053\u8fde\u63a5\u3002<\/li>\n<\/ul>\n<h2>\u8fde\u63a5\u751f\u547d\u5468\u671f\uff08\u5355\u4e2a\u5ba2\u6237\u7aef\uff09<\/h2>\n<pre><code>Client                    Gateway\n  |                          |\n  |---- req:connect --------&gt;|\n  |&lt;------ res (ok) ---------|   (or res error + close)\n  |   (payload=hello-ok carries snapshot: presence + health)\n  |                          |\n  |&lt;------ event:presence ---|\n  |&lt;------ event:tick -------|\n  |                          |\n  |------- req:agent -------&gt;|\n  |&lt;------ res:agent --------|   (ack: {runId,status:&quot;accepted&quot;})\n  |&lt;------ event:agent ------|   (streaming)\n  |&lt;------ res:agent --------|   (final: {runId,status,summary})\n  |                          |\n<\/code><\/pre>\n<h2>\u7ebf\u8def\u534f\u8bae\uff08\u6458\u8981\uff09<\/h2>\n<ul>\n<li>\u4f20\u8f93\uff1aWebSocket\uff0c\u5e26 JSON \u8f7d\u8377\u7684\u6587\u672c\u5e27\u3002<\/li>\n<li>\u7b2c\u4e00\u5e27<strong>\u5fc5\u987b<\/strong>\u662f <code>connect<\/code>\u3002<\/li>\n<li>\u63e1\u624b\u540e\uff1a<\/li>\n<li>\u8bf7\u6c42\uff1a<code>{type:\"req\", id, method, params}<\/code> \u2192 <code>{type:\"res\", id, ok, payload|error}<\/code><\/li>\n<li>\u4e8b\u4ef6\uff1a<code>{type:\"event\", event, payload, seq?, stateVersion?}<\/code><\/li>\n<li>\u5982\u679c\u8bbe\u7f6e\u4e86 <code>OPENCLAW_GATEWAY_TOKEN<\/code>\uff08\u6216 <code>--token<\/code>\uff09\uff0c<code>connect.params.auth.token<\/code> \u5fc5\u987b\u5339\u914d\uff0c\u5426\u5219\u5957\u63a5\u5b57\u5173\u95ed\u3002<\/li>\n<li>\u6709\u526f\u4f5c\u7528\u7684\u65b9\u6cd5\uff08<code>send<\/code>\u3001<code>agent<\/code>\uff09\u9700\u8981\u5e42\u7b49\u952e\u4ee5\u5b89\u5168\u91cd\u8bd5\uff1b\u670d\u52a1\u5668\u4fdd\u6301\u77ed\u671f\u53bb\u91cd\u7f13\u5b58\u3002<\/li>\n<li>\u8282\u70b9\u5fc5\u987b\u5728 <code>connect<\/code> \u4e2d\u5305\u542b <code>role: \"node\"<\/code> \u4ee5\u53ca\u80fd\u529b\/\u547d\u4ee4\/\u6743\u9650\u3002<\/li>\n<\/ul>\n<h2>\u914d\u5bf9 + \u672c\u5730\u4fe1\u4efb<\/h2>\n<ul>\n<li>\u6240\u6709 WS \u5ba2\u6237\u7aef\uff08\u64cd\u4f5c\u5458 + \u8282\u70b9\uff09\u5728 <code>connect<\/code> \u65f6\u5305\u542b<strong>\u8bbe\u5907\u8eab\u4efd<\/strong>\u3002<\/li>\n<li>\u65b0\u8bbe\u5907 ID \u9700\u8981\u914d\u5bf9\u6279\u51c6\uff1bGateway \u7f51\u5173\u4e3a\u540e\u7eed\u8fde\u63a5\u9881\u53d1<strong>\u8bbe\u5907\u4ee4\u724c<\/strong>\u3002<\/li>\n<li><strong>\u672c\u5730<\/strong>\u8fde\u63a5\uff08loopback \u6216 Gateway \u7f51\u5173\u4e3b\u673a\u81ea\u8eab\u7684 tailnet \u5730\u5740\uff09\u53ef\u4ee5\u81ea\u52a8\u6279\u51c6\u4ee5\u4fdd\u6301\u540c\u4e3b\u673a\u7528\u6237\u4f53\u9a8c\u6d41\u7545\u3002<\/li>\n<li><strong>\u975e\u672c\u5730<\/strong>\u8fde\u63a5\u5fc5\u987b\u7b7e\u540d <code>connect.challenge<\/code> nonce \u5e76\u9700\u8981\u660e\u786e\u6279\u51c6\u3002<\/li>\n<li>Gateway \u7f51\u5173\u8ba4\u8bc1\uff08<code>gateway.auth.*<\/code>\uff09\u4ecd\u9002\u7528\u4e8e<strong>\u6240\u6709<\/strong>\u8fde\u63a5\uff0c\u65e0\u8bba\u672c\u5730\u8fd8\u662f\u8fdc\u7a0b\u3002<\/li>\n<\/ul>\n<p>\u8be6\u60c5\uff1a<a href=\"\/gateway\/protocol\">Gateway \u7f51\u5173\u534f\u8bae<\/a>\u3001<a href=\"\/channels\/pairing\">\u914d\u5bf9<\/a>\u3001<a href=\"\/gateway\/security\">\u5b89\u5168<\/a>\u3002<\/p>\n<h2>\u534f\u8bae\u7c7b\u578b\u548c\u4ee3\u7801\u751f\u6210<\/h2>\n<ul>\n<li>TypeBox \u6a21\u5f0f\u5b9a\u4e49\u534f\u8bae\u3002<\/li>\n<li>\u4ece\u8fd9\u4e9b\u6a21\u5f0f\u751f\u6210 JSON Schema\u3002<\/li>\n<li>\u4ece JSON Schema \u751f\u6210 Swift \u6a21\u578b\u3002<\/li>\n<\/ul>\n<h2>\u8fdc\u7a0b\u8bbf\u95ee<\/h2>\n<ul>\n<li>\u63a8\u8350\uff1aTailscale \u6216 VPN\u3002<\/li>\n<li>\u66ff\u4ee3\u65b9\u6848\uff1aSSH \u96a7\u9053<br \/>\n  <code>bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\n  ssh -N -L 18789:127.0.0.1:18789 user@host<\/code><\/li>\n<li>\u76f8\u540c\u7684\u63e1\u624b + \u8ba4\u8bc1\u4ee4\u724c\u9002\u7528\u4e8e\u96a7\u9053\u8fde\u63a5\u3002<\/li>\n<li>\u8fdc\u7a0b\u8bbe\u7f6e\u4e2d\u53ef\u4ee5\u4e3a WS \u542f\u7528 TLS + \u53ef\u9009\u7684\u8bc1\u4e66\u56fa\u5b9a\u3002<\/li>\n<\/ul>\n<h2>\u64cd\u4f5c\u5feb\u7167<\/h2>\n<ul>\n<li>\u542f\u52a8\uff1a<code>openclaw gateway<\/code>\uff08\u524d\u53f0\uff0c\u65e5\u5fd7\u8f93\u51fa\u5230 stdout\uff09\u3002<\/li>\n<li>\u5065\u5eb7\u68c0\u67e5\uff1a\u901a\u8fc7 WS \u7684 <code>health<\/code>\uff08\u4e5f\u5305\u542b\u5728 <code>hello-ok<\/code> \u4e2d\uff09\u3002<\/li>\n<li>\u76d1\u63a7\uff1a\u4f7f\u7528 launchd\/systemd \u81ea\u52a8\u91cd\u542f\u3002<\/li>\n<\/ul>\n<h2>\u4e0d\u53d8\u91cf<\/h2>\n<ul>\n<li>\u6bcf\u53f0\u4e3b\u673a\u6070\u597d\u4e00\u4e2a Gateway \u7f51\u5173\u63a7\u5236\u5355\u4e2a Baileys \u4f1a\u8bdd\u3002<\/li>\n<li>\u63e1\u624b\u662f\u5f3a\u5236\u7684\uff1b\u4efb\u4f55\u975e JSON \u6216\u975e connect \u7684\u7b2c\u4e00\u5e27\u90fd\u4f1a\u5bfc\u81f4\u786c\u5173\u95ed\u3002<\/li>\n<li>\u4e8b\u4ef6\u4e0d\u4f1a\u91cd\u653e\uff1b\u5ba2\u6237\u7aef\u5fc5\u987b\u5728\u51fa\u73b0\u95f4\u9699\u65f6\u5237\u65b0\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Gateway \u7f51\u5173\u67b6\u6784 \u6700\u540e\u66f4\u65b0\uff1a2026-01-22 \u6982\u8ff0 \u5355\u4e2a\u957f\u671f\u8fd0\u884c\u7684 Gateway \u7f51\u5173\u62e5\u6709\u6240\u6709\u6d88 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}