openclaw-channel-dmwork 0.2.10 → 0.2.11
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/package.json +1 -1
- package/src/api-fetch.ts +19 -0
- package/src/inbound.ts +13 -1
package/package.json
CHANGED
package/src/api-fetch.ts
CHANGED
|
@@ -127,3 +127,22 @@ export async function registerBot(params: {
|
|
|
127
127
|
: "/v1/bot/register";
|
|
128
128
|
return postJson(params.apiUrl, params.botToken, path, {}, params.signal);
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
// Fetch the groups the bot belongs to
|
|
132
|
+
export async function fetchBotGroups(params: {
|
|
133
|
+
apiUrl: string;
|
|
134
|
+
botToken: string;
|
|
135
|
+
}): Promise<Array<{ group_no: string; name: string }>> {
|
|
136
|
+
const url = `${params.apiUrl}/v1/bot/groups`;
|
|
137
|
+
const resp = await fetch(url, {
|
|
138
|
+
method: "GET",
|
|
139
|
+
headers: {
|
|
140
|
+
"Authorization": `Bearer ${params.botToken}`,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
if (!resp.ok) {
|
|
144
|
+
// Fallback: return empty if API not available
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
return resp.json();
|
|
148
|
+
}
|
package/src/inbound.ts
CHANGED
|
@@ -172,9 +172,16 @@ export async function handleInboundMessage(params: {
|
|
|
172
172
|
log?.error?.(`dmwork: routing methods: ${core?.channel?.routing ? Object.keys(core.channel.routing).join(",") : "N/A"}`);
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
// Log available SDK functions for debugging version compatibility
|
|
177
|
+
log?.info?.(`dmwork: SDK check - resolveEnvelopeFormatOptions=${typeof core.channel.reply.resolveEnvelopeFormatOptions}, formatAgentEnvelope=${typeof core.channel.reply.formatAgentEnvelope}, finalizeInboundContext=${typeof core.channel.reply.finalizeInboundContext}`);
|
|
178
|
+
log?.info?.(`dmwork: SDK check - resolveStorePath=${typeof core.channel.session.resolveStorePath}, readSessionUpdatedAt=${typeof core.channel.session.readSessionUpdatedAt}, recordInboundSession=${typeof core.channel.session.recordInboundSession}`);
|
|
179
|
+
|
|
175
180
|
const config = core.config.loadConfig() as OpenClawConfig;
|
|
176
181
|
|
|
177
|
-
|
|
182
|
+
let route;
|
|
183
|
+
try {
|
|
184
|
+
route = core.channel.routing.resolveAgentRoute({
|
|
178
185
|
cfg: config,
|
|
179
186
|
channel: "dmwork",
|
|
180
187
|
accountId: account.accountId,
|
|
@@ -184,6 +191,11 @@ export async function handleInboundMessage(params: {
|
|
|
184
191
|
},
|
|
185
192
|
});
|
|
186
193
|
|
|
194
|
+
} catch (routeErr) {
|
|
195
|
+
log?.error?.(`dmwork: resolveAgentRoute failed: ${String(routeErr)}`);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
187
199
|
const fromLabel = isGroup
|
|
188
200
|
? `group:${message.channel_id}`
|
|
189
201
|
: `user:${message.from_uid}`;
|