@gloablehive/celphone-wechat-plugin 1.1.0 → 1.1.1
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/dist/src/channel.js +20 -2
- package/package.json +2 -2
- package/src/channel.ts +23 -2
- package/test-integration.ts +1 -1
package/dist/src/channel.js
CHANGED
|
@@ -21,6 +21,7 @@ import { createCacheManager, createAccountRegistry, } from "@gloablehive/wechat-
|
|
|
21
21
|
import { getWorkPhoneClient, createClientConfig } from "./client-pool.js";
|
|
22
22
|
// Cache manager instance (lazy initialized)
|
|
23
23
|
let cacheManager = null;
|
|
24
|
+
let cacheManagerReady = null;
|
|
24
25
|
// Account registry for routing
|
|
25
26
|
let accountRegistry = null;
|
|
26
27
|
/**
|
|
@@ -74,9 +75,19 @@ function getCacheManager(cfg) {
|
|
|
74
75
|
initializeRegistry(cfg);
|
|
75
76
|
const basePath = globalThis?.process?.env?.OPENCLAW_CACHE_PATH
|
|
76
77
|
|| "~/.openclaw/channels/celphone-wechat";
|
|
78
|
+
// Build knowledge config if provided in section
|
|
79
|
+
let knowledgeConfig;
|
|
80
|
+
if (section?.knowledge) {
|
|
81
|
+
knowledgeConfig = {
|
|
82
|
+
...section.knowledge,
|
|
83
|
+
nodeId: section.knowledge.nodeId || 'celphone-wechat-node',
|
|
84
|
+
agentId: section.knowledge.agentId || section.agentId || 'default-agent',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
77
87
|
cacheManager = createCacheManager({
|
|
78
88
|
basePath,
|
|
79
89
|
accounts,
|
|
90
|
+
knowledgeConfig,
|
|
80
91
|
saasConfig: section?.saas ? {
|
|
81
92
|
apiBaseUrl: section.saas.apiBaseUrl,
|
|
82
93
|
apiKey: section.saas.apiKey,
|
|
@@ -88,12 +99,19 @@ function getCacheManager(cfg) {
|
|
|
88
99
|
syncIntervalMs: section.sync.syncIntervalMs || 5 * 60 * 1000,
|
|
89
100
|
} : undefined,
|
|
90
101
|
});
|
|
91
|
-
// Initialize cache manager -
|
|
92
|
-
cacheManager.init().catch(err => {
|
|
102
|
+
// Initialize cache manager - await for ready state
|
|
103
|
+
cacheManagerReady = cacheManager.init().catch(err => {
|
|
93
104
|
console.error("[CelPhoneWeChat] Cache manager init failed:", err);
|
|
105
|
+
throw err; // Re-throw so caller knows init failed
|
|
94
106
|
});
|
|
95
107
|
return cacheManager;
|
|
96
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Get cache manager ready promise - await before processing messages
|
|
111
|
+
*/
|
|
112
|
+
export function getCacheManagerReady() {
|
|
113
|
+
return cacheManagerReady;
|
|
114
|
+
}
|
|
97
115
|
/**
|
|
98
116
|
* List all account IDs from config
|
|
99
117
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gloablehive/celphone-wechat-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw channel plugin for workphone-wechat API - enables sending/receiving WeChat messages through workphone. Supports multi-account with per-account agent binding.",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@gloablehive/wechat-cache": "
|
|
27
|
+
"@gloablehive/wechat-cache": "file:../wechat-cache",
|
|
28
28
|
"openclaw": ">=1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/channel.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
AccountRegistry,
|
|
32
32
|
createAccountRegistry,
|
|
33
33
|
type RegisteredAccount,
|
|
34
|
+
type KnowledgeConfig,
|
|
34
35
|
} from "@gloablehive/wechat-cache";
|
|
35
36
|
|
|
36
37
|
// Import client pool
|
|
@@ -38,6 +39,7 @@ import { getWorkPhoneClient, createClientConfig, getClientPool } from "./client-
|
|
|
38
39
|
|
|
39
40
|
// Cache manager instance (lazy initialized)
|
|
40
41
|
let cacheManager: CacheManager | null = null;
|
|
42
|
+
let cacheManagerReady: Promise<void> | null = null;
|
|
41
43
|
|
|
42
44
|
// Account registry for routing
|
|
43
45
|
let accountRegistry: AccountRegistry | null = null;
|
|
@@ -101,9 +103,20 @@ function getCacheManager(cfg: OpenClawConfig): CacheManager {
|
|
|
101
103
|
const basePath = (globalThis as any)?.process?.env?.OPENCLAW_CACHE_PATH
|
|
102
104
|
|| "~/.openclaw/channels/celphone-wechat";
|
|
103
105
|
|
|
106
|
+
// Build knowledge config if provided in section
|
|
107
|
+
let knowledgeConfig: (Partial<KnowledgeConfig> & { nodeId: string; agentId: string }) | undefined;
|
|
108
|
+
if (section?.knowledge) {
|
|
109
|
+
knowledgeConfig = {
|
|
110
|
+
...section.knowledge,
|
|
111
|
+
nodeId: section.knowledge.nodeId || 'celphone-wechat-node',
|
|
112
|
+
agentId: section.knowledge.agentId || section.agentId || 'default-agent',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
cacheManager = createCacheManager({
|
|
105
117
|
basePath,
|
|
106
118
|
accounts,
|
|
119
|
+
knowledgeConfig,
|
|
107
120
|
saasConfig: section?.saas ? {
|
|
108
121
|
apiBaseUrl: section.saas.apiBaseUrl,
|
|
109
122
|
apiKey: section.saas.apiKey,
|
|
@@ -116,14 +129,22 @@ function getCacheManager(cfg: OpenClawConfig): CacheManager {
|
|
|
116
129
|
} : undefined,
|
|
117
130
|
});
|
|
118
131
|
|
|
119
|
-
// Initialize cache manager -
|
|
120
|
-
cacheManager.init().catch(err => {
|
|
132
|
+
// Initialize cache manager - await for ready state
|
|
133
|
+
cacheManagerReady = cacheManager.init().catch(err => {
|
|
121
134
|
console.error("[CelPhoneWeChat] Cache manager init failed:", err);
|
|
135
|
+
throw err; // Re-throw so caller knows init failed
|
|
122
136
|
});
|
|
123
137
|
|
|
124
138
|
return cacheManager;
|
|
125
139
|
}
|
|
126
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Get cache manager ready promise - await before processing messages
|
|
143
|
+
*/
|
|
144
|
+
export function getCacheManagerReady(): Promise<void> | null {
|
|
145
|
+
return cacheManagerReady;
|
|
146
|
+
}
|
|
147
|
+
|
|
127
148
|
export interface CelPhoneWeChatResolvedAccount {
|
|
128
149
|
accountId: string | null;
|
|
129
150
|
agentId: string | null;
|
package/test-integration.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
createCacheManager,
|
|
12
12
|
WeChatAccount,
|
|
13
13
|
WeChatMessage,
|
|
14
|
-
} from '
|
|
14
|
+
} from '@gloablehive/wechat-cache';
|
|
15
15
|
import { handleInboundMessage } from './src/channel.js';
|
|
16
16
|
|
|
17
17
|
const TEST_CACHE_PATH = '/tmp/wechat-integration-test';
|