@alfe.ai/openclaw-chat 0.0.11 → 0.0.12
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/index.d.ts +2 -0
- package/dist/plugin2.js +16 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/plugin2.js
CHANGED
|
@@ -28,7 +28,7 @@ function createAlfeChannelPlugin() {
|
|
|
28
28
|
id: CHANNEL_ID,
|
|
29
29
|
label: "Alfe",
|
|
30
30
|
selectionLabel: "Alfe (Web & Mobile)",
|
|
31
|
-
detailLabel: "Alfe
|
|
31
|
+
detailLabel: "Alfe",
|
|
32
32
|
docsPath: "/channels/alfe",
|
|
33
33
|
docsLabel: "alfe",
|
|
34
34
|
blurb: "Alfe native chat — web widget and mobile app conversations.",
|
|
@@ -246,13 +246,15 @@ async function createSession(sessionId, agentId, channel, tenantId, userId) {
|
|
|
246
246
|
cleanupOldSessions();
|
|
247
247
|
return session;
|
|
248
248
|
}
|
|
249
|
-
async function addMessage(sessionId, role, content) {
|
|
249
|
+
async function addMessage(sessionId, role, content, senderId, senderName) {
|
|
250
250
|
const session = await getSession(sessionId);
|
|
251
251
|
if (!session) return;
|
|
252
252
|
session.messages.push({
|
|
253
253
|
role,
|
|
254
254
|
content,
|
|
255
|
-
timestamp: Date.now()
|
|
255
|
+
timestamp: Date.now(),
|
|
256
|
+
...senderId ? { senderId } : {},
|
|
257
|
+
...senderName ? { senderName } : {}
|
|
256
258
|
});
|
|
257
259
|
await saveSession(session);
|
|
258
260
|
}
|
|
@@ -335,16 +337,16 @@ async function handleAgentRequest(request, log) {
|
|
|
335
337
|
chatClient?.sendResponse(request.id, false, { message: "OpenClaw SDK not available — cannot dispatch" });
|
|
336
338
|
return;
|
|
337
339
|
}
|
|
338
|
-
const { message, sessionKey: legacySessionKey, userId, conversationId, tenantId, clientType, displayName } = request.params;
|
|
340
|
+
const { message, sessionKey: legacySessionKey, userId, conversationId, conversationType, tenantId, clientType, displayName } = request.params;
|
|
339
341
|
if (!message) {
|
|
340
342
|
chatClient?.sendResponse(request.id, false, { message: "Missing message" });
|
|
341
343
|
return;
|
|
342
344
|
}
|
|
343
|
-
const senderId = displayName ?? userId ??
|
|
345
|
+
const senderId = displayName ?? userId ?? "anon";
|
|
344
346
|
const cfg = runtime.config.loadConfig();
|
|
345
347
|
const sessionId = conversationId ?? legacySessionKey;
|
|
346
348
|
if (!await getSession(sessionId)) await createSession(sessionId, "", "alfe", tenantId, userId);
|
|
347
|
-
await addMessage(sessionId, "user", message);
|
|
349
|
+
await addMessage(sessionId, "user", message, userId ?? senderId, displayName ?? senderId);
|
|
348
350
|
let resolvedOpenClawKey = null;
|
|
349
351
|
const unsubscribe = runtime.events.onAgentEvent((evt) => {
|
|
350
352
|
if (!evt.sessionKey) return;
|
|
@@ -360,16 +362,21 @@ async function handleAgentRequest(request, log) {
|
|
|
360
362
|
});
|
|
361
363
|
});
|
|
362
364
|
try {
|
|
363
|
-
const
|
|
365
|
+
const shortConvId = conversationId?.slice(-8) ?? "";
|
|
366
|
+
const userLabel = displayName ?? userId ?? senderId;
|
|
367
|
+
const conversationLabel = conversationType === "group" ? shortConvId ? `[Alfe] Group (${shortConvId})` : "[Alfe] Group" : shortConvId ? `[Alfe] ${userLabel} (${shortConvId})` : `[Alfe] ${userLabel}`;
|
|
364
368
|
resolvedOpenClawKey = (await dispatchInbound({
|
|
365
369
|
cfg,
|
|
366
370
|
runtime: { channel: runtime.channel },
|
|
367
371
|
channel: "alfe",
|
|
368
372
|
channelLabel: "Alfe",
|
|
369
373
|
accountId: "default",
|
|
370
|
-
peer: {
|
|
374
|
+
peer: conversationType === "group" ? {
|
|
375
|
+
kind: "group",
|
|
376
|
+
id: conversationId ?? senderId
|
|
377
|
+
} : {
|
|
371
378
|
kind: "direct",
|
|
372
|
-
id: senderId
|
|
379
|
+
id: conversationId ? `${senderId}:conv:${conversationId}` : senderId
|
|
373
380
|
},
|
|
374
381
|
senderId,
|
|
375
382
|
senderAddress: `user:${senderId}`,
|