@eclaw/openclaw-channel 1.2.3 → 1.2.4
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/client.d.ts +4 -0
- package/dist/client.js +8 -0
- package/dist/webhook-handler.js +13 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -27,4 +27,8 @@ export declare class EClawClient {
|
|
|
27
27
|
get currentDeviceId(): string | null;
|
|
28
28
|
get currentBotSecret(): string | null;
|
|
29
29
|
get currentEntityId(): number | undefined;
|
|
30
|
+
/** Rebind to a different entity slot (e.g. when the user moves the channel binding).
|
|
31
|
+
* Updates internal botSecret and entityId.
|
|
32
|
+
*/
|
|
33
|
+
rebindToEntity(entityId: number, name?: string): Promise<BindResponse>;
|
|
30
34
|
}
|
package/dist/client.js
CHANGED
|
@@ -132,4 +132,12 @@ export class EClawClient {
|
|
|
132
132
|
get currentDeviceId() { return this.deviceId; }
|
|
133
133
|
get currentBotSecret() { return this.botSecret; }
|
|
134
134
|
get currentEntityId() { return this.entityId; }
|
|
135
|
+
/** Rebind to a different entity slot (e.g. when the user moves the channel binding).
|
|
136
|
+
* Updates internal botSecret and entityId.
|
|
137
|
+
*/
|
|
138
|
+
async rebindToEntity(entityId, name) {
|
|
139
|
+
const data = await this.bindEntity(entityId, name);
|
|
140
|
+
// bindEntity already updates this.botSecret, this.entityId, this.deviceId
|
|
141
|
+
return data;
|
|
142
|
+
}
|
|
135
143
|
}
|
package/dist/webhook-handler.js
CHANGED
|
@@ -36,6 +36,19 @@ cfg // full openclaw config (ctx.cfg from startAccount)
|
|
|
36
36
|
const rt = getPluginRuntime();
|
|
37
37
|
const client = getClient(accountId);
|
|
38
38
|
const conversationId = msg.conversationId || `${msg.deviceId}:${msg.entityId}`;
|
|
39
|
+
// Auto-rebind if the incoming entityId differs from the stored one.
|
|
40
|
+
// This happens when the user moves the channel binding to a different slot
|
|
41
|
+
// via the EClaw app — the plugin needs to update its botSecret/entityId.
|
|
42
|
+
if (client && msg.entityId !== undefined && client.currentEntityId !== msg.entityId) {
|
|
43
|
+
try {
|
|
44
|
+
console.log(`[E-Claw] Entity mismatch: bound=${client.currentEntityId}, incoming=${msg.entityId}. Rebinding...`);
|
|
45
|
+
const bindData = await client.rebindToEntity(msg.entityId);
|
|
46
|
+
console.log(`[E-Claw] Rebound to entity ${bindData.entityId}, publicCode: ${bindData.publicCode}`);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
console.error(`[E-Claw] Rebind to entity ${msg.entityId} failed:`, err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
// Capture event context for deliver routing
|
|
40
53
|
const event = msg.event || 'message';
|
|
41
54
|
const fromEntityId = msg.fromEntityId;
|