@alfe.ai/openclaw-chat 0.1.2 → 0.1.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/plugin.d.cts CHANGED
@@ -288,7 +288,7 @@ interface PluginApi {
288
288
  execute: (toolCallId: string, params: Record<string, unknown>) => Promise<unknown>;
289
289
  }): void;
290
290
  registerGatewayMethod?(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
291
- registerService?(service: {
291
+ registerService(service: {
292
292
  id: string;
293
293
  start: (ctx: PluginServiceContext) => void | Promise<void>;
294
294
  stop?: (ctx: PluginServiceContext) => void | Promise<void>;
package/dist/plugin.d.ts CHANGED
@@ -288,7 +288,7 @@ interface PluginApi {
288
288
  execute: (toolCallId: string, params: Record<string, unknown>) => Promise<unknown>;
289
289
  }): void;
290
290
  registerGatewayMethod?(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
291
- registerService?(service: {
291
+ registerService(service: {
292
292
  id: string;
293
293
  start: (ctx: PluginServiceContext) => void | Promise<void>;
294
294
  stop?: (ctx: PluginServiceContext) => void | Promise<void>;
package/dist/plugin2.cjs CHANGED
@@ -44,6 +44,7 @@ async function sendViaChat(deps, ctx, mediaUrl) {
44
44
  conversationId,
45
45
  text: ctx.text,
46
46
  sessionKey: conversationId,
47
+ messageId,
47
48
  ...mediaUrl ? { mediaUrls: [mediaUrl] } : {}
48
49
  });
49
50
  return {
@@ -716,7 +717,7 @@ async function handleAgentRequest(request, log) {
716
717
  chatClient?.sendResponse(request.id, false, { message: "OpenClaw SDK not available — cannot dispatch" });
717
718
  return;
718
719
  }
719
- const { message, sessionKey: legacySessionKey, userId, conversationId, conversationType, tenantId, clientType, displayName, identityId, senderPermissions, attachments: rawAttachments, a2a } = request.params;
720
+ const { message, sessionKey: legacySessionKey, userId, conversationId, conversationType, tenantId, clientType, displayName, identityId, senderPermissions, attachments: rawAttachments, a2a, chatMessageId } = request.params;
720
721
  const isA2A = !!a2a;
721
722
  if (!message && !rawAttachments?.length) {
722
723
  chatClient?.sendResponse(request.id, false, { message: "Missing message" });
@@ -812,6 +813,7 @@ async function handleAgentRequest(request, log) {
812
813
  conversationId: conversationId ?? legacySessionKey,
813
814
  text: responseText,
814
815
  sessionKey: resolvedOpenClawKey ?? legacySessionKey,
816
+ messageId: chatMessageId ?? request.id,
815
817
  ...mediaUrls.length ? { mediaUrls } : {}
816
818
  });
817
819
  },
@@ -896,7 +898,6 @@ const plugin = {
896
898
  version: pkg.version,
897
899
  activate(api) {
898
900
  const log = api.logger;
899
- const alreadyActivated = globalThis.__alfeChatPluginActivated === true;
900
901
  const alfeChannel = createAlfeChannelPlugin({
901
902
  getChatClient: () => chatClient,
902
903
  listSessions,
@@ -959,26 +960,6 @@ const plugin = {
959
960
  log.info(`Registered ${String(a2aTools.length)} agent-to-agent tools`);
960
961
  }
961
962
  }).catch(() => {});
962
- api.on("session_start", async (...eventArgs) => {
963
- if (!pluginRuntime) return;
964
- const key = eventArgs[0].sessionKey;
965
- if (!key || isAlfeSessionKey(key)) return;
966
- log.info(`Chat session starting: ${key}`);
967
- await createSession(key, "", "alfe");
968
- }, { priority: 50 });
969
- api.on("message_received", async (...eventArgs) => {
970
- if (!pluginRuntime) return;
971
- const event = eventArgs[0];
972
- const ctx = eventArgs[1];
973
- if (!ctx.conversationId || ctx.channelId === "alfe") return;
974
- await addMessage(ctx.conversationId, "user", event.content, event.from);
975
- });
976
- api.on("session_end", (...eventArgs) => {
977
- if (!pluginRuntime) return;
978
- const key = eventArgs[0].sessionKey;
979
- if (!key || !isAlfeSessionKey(key)) return;
980
- log.info(`Chat session ending: ${key}`);
981
- });
982
963
  };
983
964
  const stopChatService = async () => {
984
965
  globalThis.__alfeChatPluginActivated = false;
@@ -1032,7 +1013,27 @@ const plugin = {
1032
1013
  });
1033
1014
  log.info("Registered gateway RPC methods: sessions.list, sessions.get");
1034
1015
  }
1035
- if (api.registerService) api.registerService({
1016
+ api.on("session_start", async (...eventArgs) => {
1017
+ if (!pluginRuntime) return;
1018
+ const key = eventArgs[0].sessionKey;
1019
+ if (!key || isAlfeSessionKey(key)) return;
1020
+ log.info(`Chat session starting: ${key}`);
1021
+ await createSession(key, "", "alfe");
1022
+ }, { priority: 50 });
1023
+ api.on("message_received", async (...eventArgs) => {
1024
+ if (!pluginRuntime) return;
1025
+ const event = eventArgs[0];
1026
+ const ctx = eventArgs[1];
1027
+ if (!ctx.conversationId || ctx.channelId === "alfe") return;
1028
+ await addMessage(ctx.conversationId, "user", event.content, event.from);
1029
+ });
1030
+ api.on("session_end", (...eventArgs) => {
1031
+ if (!pluginRuntime) return;
1032
+ const key = eventArgs[0].sessionKey;
1033
+ if (!key || !isAlfeSessionKey(key)) return;
1034
+ log.info(`Chat session ending: ${key}`);
1035
+ });
1036
+ api.registerService({
1036
1037
  id: "alfe-chat-relay",
1037
1038
  start: () => {
1038
1039
  startChatService();
@@ -1041,7 +1042,6 @@ const plugin = {
1041
1042
  await stopChatService();
1042
1043
  }
1043
1044
  });
1044
- else if (!alreadyActivated) startChatService();
1045
1045
  log.info("Chat plugin registered");
1046
1046
  },
1047
1047
  async deactivate(api) {
package/dist/plugin2.js CHANGED
@@ -44,6 +44,7 @@ async function sendViaChat(deps, ctx, mediaUrl) {
44
44
  conversationId,
45
45
  text: ctx.text,
46
46
  sessionKey: conversationId,
47
+ messageId,
47
48
  ...mediaUrl ? { mediaUrls: [mediaUrl] } : {}
48
49
  });
49
50
  return {
@@ -716,7 +717,7 @@ async function handleAgentRequest(request, log) {
716
717
  chatClient?.sendResponse(request.id, false, { message: "OpenClaw SDK not available — cannot dispatch" });
717
718
  return;
718
719
  }
719
- const { message, sessionKey: legacySessionKey, userId, conversationId, conversationType, tenantId, clientType, displayName, identityId, senderPermissions, attachments: rawAttachments, a2a } = request.params;
720
+ const { message, sessionKey: legacySessionKey, userId, conversationId, conversationType, tenantId, clientType, displayName, identityId, senderPermissions, attachments: rawAttachments, a2a, chatMessageId } = request.params;
720
721
  const isA2A = !!a2a;
721
722
  if (!message && !rawAttachments?.length) {
722
723
  chatClient?.sendResponse(request.id, false, { message: "Missing message" });
@@ -812,6 +813,7 @@ async function handleAgentRequest(request, log) {
812
813
  conversationId: conversationId ?? legacySessionKey,
813
814
  text: responseText,
814
815
  sessionKey: resolvedOpenClawKey ?? legacySessionKey,
816
+ messageId: chatMessageId ?? request.id,
815
817
  ...mediaUrls.length ? { mediaUrls } : {}
816
818
  });
817
819
  },
@@ -896,7 +898,6 @@ const plugin = {
896
898
  version: pkg.version,
897
899
  activate(api) {
898
900
  const log = api.logger;
899
- const alreadyActivated = globalThis.__alfeChatPluginActivated === true;
900
901
  const alfeChannel = createAlfeChannelPlugin({
901
902
  getChatClient: () => chatClient,
902
903
  listSessions,
@@ -959,26 +960,6 @@ const plugin = {
959
960
  log.info(`Registered ${String(a2aTools.length)} agent-to-agent tools`);
960
961
  }
961
962
  }).catch(() => {});
962
- api.on("session_start", async (...eventArgs) => {
963
- if (!pluginRuntime) return;
964
- const key = eventArgs[0].sessionKey;
965
- if (!key || isAlfeSessionKey(key)) return;
966
- log.info(`Chat session starting: ${key}`);
967
- await createSession(key, "", "alfe");
968
- }, { priority: 50 });
969
- api.on("message_received", async (...eventArgs) => {
970
- if (!pluginRuntime) return;
971
- const event = eventArgs[0];
972
- const ctx = eventArgs[1];
973
- if (!ctx.conversationId || ctx.channelId === "alfe") return;
974
- await addMessage(ctx.conversationId, "user", event.content, event.from);
975
- });
976
- api.on("session_end", (...eventArgs) => {
977
- if (!pluginRuntime) return;
978
- const key = eventArgs[0].sessionKey;
979
- if (!key || !isAlfeSessionKey(key)) return;
980
- log.info(`Chat session ending: ${key}`);
981
- });
982
963
  };
983
964
  const stopChatService = async () => {
984
965
  globalThis.__alfeChatPluginActivated = false;
@@ -1032,7 +1013,27 @@ const plugin = {
1032
1013
  });
1033
1014
  log.info("Registered gateway RPC methods: sessions.list, sessions.get");
1034
1015
  }
1035
- if (api.registerService) api.registerService({
1016
+ api.on("session_start", async (...eventArgs) => {
1017
+ if (!pluginRuntime) return;
1018
+ const key = eventArgs[0].sessionKey;
1019
+ if (!key || isAlfeSessionKey(key)) return;
1020
+ log.info(`Chat session starting: ${key}`);
1021
+ await createSession(key, "", "alfe");
1022
+ }, { priority: 50 });
1023
+ api.on("message_received", async (...eventArgs) => {
1024
+ if (!pluginRuntime) return;
1025
+ const event = eventArgs[0];
1026
+ const ctx = eventArgs[1];
1027
+ if (!ctx.conversationId || ctx.channelId === "alfe") return;
1028
+ await addMessage(ctx.conversationId, "user", event.content, event.from);
1029
+ });
1030
+ api.on("session_end", (...eventArgs) => {
1031
+ if (!pluginRuntime) return;
1032
+ const key = eventArgs[0].sessionKey;
1033
+ if (!key || !isAlfeSessionKey(key)) return;
1034
+ log.info(`Chat session ending: ${key}`);
1035
+ });
1036
+ api.registerService({
1036
1037
  id: "alfe-chat-relay",
1037
1038
  start: () => {
1038
1039
  startChatService();
@@ -1041,7 +1042,6 @@ const plugin = {
1041
1042
  await stopChatService();
1042
1043
  }
1043
1044
  });
1044
- else if (!alreadyActivated) startChatService();
1045
1045
  log.info("Chat plugin registered");
1046
1046
  },
1047
1047
  async deactivate(api) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw-chat",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "OpenClaw chat plugin for Alfe — web widget and mobile app channels",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin.js",
@@ -27,7 +27,7 @@
27
27
  "openclaw.plugin.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@alfe.ai/agent-api-client": "^0.1.1",
30
+ "@alfe.ai/agent-api-client": "^0.1.3",
31
31
  "@alfe.ai/chat": "^0.0.8",
32
32
  "@alfe.ai/config": "^0.0.8"
33
33
  },