@alfe.ai/openclaw-chat 0.0.11 → 0.0.13
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 +24 -17
- package/package.json +2 -2
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}`,
|
|
@@ -453,17 +460,17 @@ async function handleSessionsGet(request, log) {
|
|
|
453
460
|
}
|
|
454
461
|
const plugin = {
|
|
455
462
|
id: "@alfe.ai/openclaw-chat",
|
|
456
|
-
name: "
|
|
457
|
-
description: "
|
|
463
|
+
name: "Chat Plugin",
|
|
464
|
+
description: "Chat conversation channel — web widget and mobile app share unified chat sessions",
|
|
458
465
|
version: "0.0.8",
|
|
459
466
|
activate(api) {
|
|
460
467
|
if (globalThis.__alfeChatPluginActivated) {
|
|
461
|
-
api.logger.debug("
|
|
468
|
+
api.logger.debug("Chat plugin already activated, skipping re-init");
|
|
462
469
|
return;
|
|
463
470
|
}
|
|
464
471
|
globalThis.__alfeChatPluginActivated = true;
|
|
465
472
|
const log = api.logger;
|
|
466
|
-
log.info("
|
|
473
|
+
log.info("Chat plugin registering...");
|
|
467
474
|
resolveOpenClawSdk(log);
|
|
468
475
|
pluginRuntime = api.runtime ?? null;
|
|
469
476
|
const alfeChannel = createAlfeChannelPlugin();
|
|
@@ -544,14 +551,14 @@ const plugin = {
|
|
|
544
551
|
api.on("session_end", (...eventArgs) => {
|
|
545
552
|
const key = eventArgs[0].sessionKey;
|
|
546
553
|
if (!key || !isAlfeSessionKey(key)) return;
|
|
547
|
-
log.info(`
|
|
554
|
+
log.info(`Chat session ending: ${key}`);
|
|
548
555
|
});
|
|
549
|
-
log.info("
|
|
556
|
+
log.info("Chat plugin registered");
|
|
550
557
|
},
|
|
551
558
|
async deactivate(api) {
|
|
552
559
|
globalThis.__alfeChatPluginActivated = false;
|
|
553
560
|
const log = api.logger;
|
|
554
|
-
log.info("
|
|
561
|
+
log.info("Chat plugin deactivating...");
|
|
555
562
|
if (connectingPromise) {
|
|
556
563
|
await connectingPromise.catch((err) => {
|
|
557
564
|
api.logger.debug(`Connection attempt failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -565,7 +572,7 @@ const plugin = {
|
|
|
565
572
|
}
|
|
566
573
|
pluginRuntime = null;
|
|
567
574
|
dispatchInbound = null;
|
|
568
|
-
log.info("
|
|
575
|
+
log.info("Chat plugin deactivated");
|
|
569
576
|
}
|
|
570
577
|
};
|
|
571
578
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "OpenClaw chat plugin for Alfe — web widget and mobile app channels",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"openclaw.plugin.json"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@alfe.ai/chat": "^0.0.
|
|
28
|
+
"@alfe.ai/chat": "^0.0.4"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"openclaw": ">=2026.3.0"
|