@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.
- package/gateway/weixin-login.ts +20 -10
- package/package.json +1 -1
package/gateway/weixin-login.ts
CHANGED
|
@@ -43,21 +43,31 @@ type ChannelPluginLike = {
|
|
|
43
43
|
/**
|
|
44
44
|
* Resolve the openclaw-weixin channel plugin from the host OpenClaw process.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
* (`openclaw/src/
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
70
|
+
`weixin-login: failed to resolve channel plugin: ${err instanceof Error ? err.message : err}`,
|
|
61
71
|
)
|
|
62
72
|
return null
|
|
63
73
|
}
|