@2en/clawly-plugins 1.32.0-beta.1 → 1.32.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,21 +43,31 @@ type ChannelPluginLike = {
43
43
  /**
44
44
  * Resolve the openclaw-weixin channel plugin from the host OpenClaw process.
45
45
  *
46
- * ⚠️ KNOWN INTERNAL DEPENDENCY: This uses OpenClaw's private module path
47
- * (`openclaw/src/channels/plugins/index.js`) because there is no public API
48
- * for accessing the channel plugin registry. If OpenClaw restructures this
49
- * path, the require will fail and `resolveWeixinPlugin` returns null (login
50
- * unavailable, not a crash). Verify this path when upgrading OpenClaw.
46
+ * Accesses the plugin registry singleton via the well-known global symbol
47
+ * `Symbol.for("openclaw.pluginRegistryState")` (see openclaw/src/plugins/runtime.ts).
48
+ * This avoids importing internal OpenClaw paths that don't exist in the published
49
+ * npm package (bundled dist only).
50
+ *
51
+ * Assumed registry shape: `{ channels: Array<{ plugin: ChannelPlugin }> }`.
52
+ * Verified against OpenClaw 2026.3.x. If the shape changes, this returns null
53
+ * with a logged warning — re-verify after major OpenClaw upgrades.
51
54
  */
52
55
  function resolveWeixinPlugin(logger?: {warn: (msg: string) => void}): ChannelPluginLike | null {
53
56
  try {
54
- // eslint-disable-next-line @typescript-eslint/no-require-imports
55
- const {getChannelPlugin} = require('openclaw/src/channels/plugins/index.js')
56
- const plugin = getChannelPlugin(WEIXIN_CHANNEL_ID) as ChannelPluginLike | undefined
57
- return plugin ?? null
57
+ const REGISTRY_STATE = Symbol.for('openclaw.pluginRegistryState')
58
+ const registryState = (globalThis as Record<symbol, unknown>)[REGISTRY_STATE] as
59
+ | {registry: {channels: Array<{plugin: ChannelPluginLike}>} | null}
60
+ | undefined
61
+ const channels = registryState?.registry?.channels
62
+ if (!channels) {
63
+ logger?.warn('weixin-login: plugin registry not available on globalThis')
64
+ return null
65
+ }
66
+ const entry = channels.find((e) => e.plugin?.id === WEIXIN_CHANNEL_ID)
67
+ return entry?.plugin ?? null
58
68
  } catch (err) {
59
69
  logger?.warn(
60
- `weixin-login: failed to resolve channel plugin registry: ${err instanceof Error ? err.message : err}`,
70
+ `weixin-login: failed to resolve channel plugin: ${err instanceof Error ? err.message : err}`,
61
71
  )
62
72
  return null
63
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2en/clawly-plugins",
3
- "version": "1.32.0-beta.1",
3
+ "version": "1.32.0-beta.2",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "repository": {