MsgMesh

v0.1.11
com.alderflux/msgmesh Checked 4 days ago Published 2 months ago

Event bus for AI agents: watch_topic long-polls live events; manage topics, schemas, webhooks.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

create_topic

建立一個事件 topic

ParameterTypeDescription
name *string
partitionsnumber

list_topics

列出目前所有 topic。每列的 origin 標明是誰建的:user = 使用者自建;starter = 一鍵開箱建立的預設 topic;example = 一鍵開箱時一併建立、供官方範例使用的 topic;unknown = 平台開始記錄之前就存在。starter / example 是普通 topic:一樣佔 topic 額度,可以刪除(刪除即釋出額度,但會清掉其中的訊息,刪前先問使用者)。

delete_topic

刪除指定 topic。**不可逆**:該 topic 的所有訊息、死信佇列、schema、函數與 webhook 綁定會立即被清除,同名重建只會得到一個全新的空 topic。刪除前請先向使用者確認。與該 topic 的死信重放、清除死信互斥:其中一個正在進行時回 409(錯誤碼 operation_in_progress,什麼都沒刪),等 Retry-After 秒後重試同一個呼叫,不得改用其他操作繞過;回 503 代表平台暫時無法確認沒有重放在進行,同樣什麼都沒刪,稍後再試。

ParameterTypeDescription
name *string

publish_message

發送一則訊息到指定 topic(可選 room 做房間路由:同房訊息保證順序,訂閱端用同一個 room 收)

ParameterTypeDescription
topic *string
message
roomstring

consume_messages

從指定 topic 拉取訊息(可指定 consumer group 與最大筆數)。⚠️ 會提交 consumer group 位移(at-most-once):取回的訊息不會再送第二次,不是唯讀查詢。

ParameterTypeDescription
topic *string
groupstring
maxnumber

watch_topic

訂閱並『等待』某 topic 的下一批事件:長輪詢到有事件才回(或等待視窗逾時回空+提示再呼叫)。適合 AI agent 監看事件流——收到後處理、再次以同一 group 呼叫即可繼續等下一批。與 consume_messages(有就回、沒有即回空)不同。maxWaitSec 預設 25、上限 55。⚠️ 同樣會提交 consumer group 位移(at-most-once),不是唯讀查詢。

ParameterTypeDescription
topic *string
groupstring
maxWaitSecnumber

register_schema

為 topic 註冊 JSON Schema(compatibility:none/backward)。每次呼叫都會新增一個版本(非冪等)

ParameterTypeDescription
topic *string
compatibilitystring
schema

get_schema

取得 topic 最新版本的 schema

ParameterTypeDescription
topic *string

list_schemas

列出 topic 所有 schema 版本

ParameterTypeDescription
topic *string

delete_schema

刪除 topic 的指定 schema 版本(不可刪最新版,否則回 409)

ParameterTypeDescription
topic *string
version *number

create_webhook

建立 webhook:topic 有新訊息時 POST 到指定 URL(可選 secret 做 HMAC 簽章)。from 預設 end:只投遞建立之後發布的訊息(建立後立刻發布的也收得到),topic 既有的歷史不投遞、不計費;from=start 會把 topic 保留期內的歷史全部再投遞一次、每次投遞照常計費——只在使用者明確要補送歷史時才用。要換既有 webhook 的網址請用 update_webhook,不要刪除重建。

ParameterTypeDescription
topic *string
url *string
fromstring
secretstring

list_webhooks

列出目前所有 webhook

update_webhook

更新 webhook 的投遞網址(與選填的 secret)。**改網址用這個,不要刪除重建**:沿用同一個 webhook,投遞進度不變、已投遞的不重送、歷史不重送,約 10 秒內改投新網址(含重試中的那一筆)。secret 省略或給空字串 = 不動(要換密鑰才給新值;本 tool 不提供關掉簽章)。停權中的 webhook 改完網址仍是停權,請使用者確認新網址可用後到面板按「重新啟用」。

ParameterTypeDescription
id *string
url *string
secretstring

delete_webhook

刪除指定 webhook(以 id)。若刪掉之後該 topic 沒有其他啟用中(未停權)的 webhook 且死信佇列(DLQ)還有死信,不帶 dlq 會失敗(錯誤碼 dlq_not_empty,錯誤訊息含筆數),什麼都不刪。碰到 dlq_not_empty 時**必須先告訴使用者有幾筆死信、刪掉後沒有任何啟用中的 webhook 會收到它們,問他要保留(dlq=keep)還是一併清除(dlq=purge,不可復原)**,再依他的選擇重新呼叫;不得自行選 purge。topic 上還有停權中的 webhook 時(它們重新啟用後可重放收到)只能保留:帶 dlq=purge 會失敗(錯誤碼 dlq_pu…

ParameterTypeDescription
id *string
dlqstring

register_function

為 topic 註冊訊息轉換函數(訊息進入時執行)。language 預設 javascript(JS 程式碼);傳 wasm 則 code 須為 base64 編碼的 WASI 模組(讀 stdin JSON、寫 stdout JSON)。⚠️ 同一 topic 只有一個函數:重複註冊會**覆寫**既有的,舊程式碼不保留。

ParameterTypeDescription
code *string
topic *string
languagestring

get_function

取得 topic 綁定的訊息轉換函數

ParameterTypeDescription
topic *string

delete_function

刪除 topic 綁定的訊息轉換函數

ParameterTypeDescription
topic *string

list_keys

列出目前所有 API key(僅 prefix,不含完整 key)

create_key

建立新的 API key(本身需 admin scope,權限不足時不要用它自助開通)。scope:admin|producer|consumer。可選 capabilities 做細粒度授權(scope 須 producer/consumer):[{ops:["publish"|"subscribe"],topics:["orders","support*","*"]}]

ParameterTypeDescription
scope *string
capabilitiesarray
namestring

delete_key

刪除指定 API key(以 id)

ParameterTypeDescription
id *string

get_plan

查詢目前方案與配額限制(也是最輕量的憑證檢查:成功=key 有效且具 admin scope)

set_plan

切換方案。目前只有 free 可用;payg 在 Beta 期間不開放自助切換(後端回 403)——收款管道尚未開通,而且切過去的租戶會被餘額閘擋住且無法自助解除。paid 是訂閱方案,也不能由這裡切入(後端回 403),只能經付款訂閱開通。而且租戶有進行中的訂閱時,方案由訂閱管理,切任何方案(含降回 free)後端一律回 409 —— 重試不會成功,要降級請先到面板 https://msgmesh-panel.alderflux.com 的帳單頁「管理訂閱」取消(本期結束時生效),取消後同一個請求才會成功。

ParameterTypeDescription
plan *string

get_billing

查詢預付餘額/計費狀態/續航天數,以及本期含量用量(included_msgs / period_operations,單位為 operations = 每 16 KiB ×(1 次發布 + 每一次投遞))

get_audit

查詢操作審計紀錄(可指定筆數上限)

ParameterTypeDescription
limitnumber

dlq_peek

查看 topic 的死信佇列(DLQ)訊息。⚠️ 底層走 committing poll:會提交 DLQ consumer group 位移,看過的訊息不會再回一次,不是唯讀查詢(要把死信放回主 topic 請用 dlq_replay)

ParameterTypeDescription
topic *string
groupstring
maxnumber

dlq_replay

將 topic 死信佇列(DLQ)訊息重放回原 topic(可限制筆數)。先修好或重建 webhook 再重放:死信不記得是哪個 webhook 的,重放是把它們發回 topic、由當下 topic 上的 webhook 再投遞;topic 上沒有 webhook(例如刪掉了最後一個)或端點仍壞著時,重放出去的訊息送不到任何端點,但照常計費。重放成功的死信會從 DLQ 移除,正常情況下重複呼叫不會重送(只處理之後新進的死信);但移除失敗、或服務恰在重放後移除前重啟時,下一次重放會把那一批(最多 max 則)再發布、再計費一次(…

ParameterTypeDescription
topic *string
maxnumber

get_presence

查詢 topic 目前線上連線數(realtime 服務)

ParameterTypeDescription
topic *string

get_docs

取得由租戶 topics+schema 生成的 Markdown 使用文件

get_connection_snippet

取得可貼給 AI 的接入提示

get_usage

查詢租戶用量(可指定日期 period=YYYY-MM-DD)。計費維度是 operations;messages / deliveries_* 是可見性維度,相加不等於 operations

ParameterTypeDescription
periodstring