feat(extensions): add mqtt-hooks plugin scaffold#1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47de37e508
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,346 @@ | |||
| import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core"; | |||
| import { pickFirstExistingAgentId } from "../../src/routing/resolve-route.js"; | |||
There was a problem hiding this comment.
Stop importing core src from npm plugin entry
This entrypoint hard-imports ../../src/routing/resolve-route.js, but plugin discovery loads extensions from their package directory (including npm-installed plugins under the extensions install root), so this relative path resolves outside the plugin package and becomes a module-not-found at startup in standalone installs. In practice, that prevents @openclaw/mqtt-hooks from loading when installed via the plugin installer.
Useful? React with 👍 / 👎.
| api.runtime.system.enqueueSystemEvent(messageText, { | ||
| sessionKey: sub.sessionKey, | ||
| }); |
There was a problem hiding this comment.
Require sessionKey before enqueueing wake events
The wake path forwards sub.sessionKey directly into enqueueSystemEvent, but enqueueSystemEvent requires a non-empty session key and throws otherwise (requireSessionKey in src/infra/system-events.ts). Because sessionKey is optional in this plugin config, any wake subscription that omits it will fail on every message (and the subsequent heartbeat request is skipped due to the throw), so the wake action is effectively broken by default.
Useful? React with 👍 / 👎.
Motivation
Description
extensions/mqtt-hooks/implementing connection, subscription, payload parsing, templating, and action dispatch toagent/wake/webhook(files:extensions/mqtt-hooks/index.ts,extensions/mqtt-hooks/openclaw.plugin.json,extensions/mqtt-hooks/README.md,extensions/mqtt-hooks/package.json).renderTemplate), and a context-enriched fallback envelope builder (buildDefaultMessage) (seeextensions/mqtt-hooks/index.ts).api.runtime.subagent.run), enqueue a system event / request heartbeat (api.runtime.system.enqueueSystemEvent/requestHeartbeatNow), or POST to an external webhook; concurrency bounding and per-message timeout protections are included.mqttruntime package via dynamicimportand emit a clear runtime warning ifmqttis not installed to avoid failingpnpm installin locked-down environments, and add a labeler entry in.github/labeler.ymlfor the new extension.Testing
bunx vitest run extensions/mqtt-hooks/test/index.test.ts, and the test file passed (2 testspassed).pnpm buildin this environment but it failed in an unrelated step (canvas:a2ui:bundle) that is not introduced by this change; the plugin code and its tests are unaffected.npmfetch formqttfailed in this environment (403), so the plugin intentionally does a runtime dynamic import and logs if the package is absent.Codex Task