@alfe.ai/openclaw-chat 0.0.12 → 0.0.14

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.
Files changed (2) hide show
  1. package/dist/plugin2.js +34 -33
  2. package/package.json +2 -2
package/dist/plugin2.js CHANGED
@@ -460,26 +460,25 @@ async function handleSessionsGet(request, log) {
460
460
  }
461
461
  const plugin = {
462
462
  id: "@alfe.ai/openclaw-chat",
463
- name: "Alfe Chat Plugin",
464
- description: "Alfe conversation channel — web widget and mobile app share unified chat sessions",
463
+ name: "Chat Plugin",
464
+ description: "Chat conversation channel — web widget and mobile app share unified chat sessions",
465
465
  version: "0.0.8",
466
466
  activate(api) {
467
- if (globalThis.__alfeChatPluginActivated) {
468
- api.logger.debug("Alfe Chat plugin already activated, skipping re-init");
469
- return;
470
- }
471
- globalThis.__alfeChatPluginActivated = true;
472
467
  const log = api.logger;
473
- log.info("Alfe Chat plugin registering...");
474
- resolveOpenClawSdk(log);
475
- pluginRuntime = api.runtime ?? null;
468
+ const alreadyActivated = globalThis.__alfeChatPluginActivated === true;
469
+ globalThis.__alfeChatPluginActivated = true;
476
470
  const alfeChannel = createAlfeChannelPlugin();
477
471
  api.registerChannel(alfeChannel);
478
472
  log.info(`Registered channel: ${alfeChannel.id}`);
473
+ if (!alreadyActivated) {
474
+ log.info("Chat plugin registering...");
475
+ resolveOpenClawSdk(log);
476
+ pluginRuntime = api.runtime ?? null;
477
+ }
479
478
  const pluginConfig = (((api.config ?? {}).plugins?.entries)?.["@alfe.ai/openclaw-chat"] ?? {}).config ?? {};
480
- connectingPromise = (async () => {
479
+ if (!alreadyActivated) connectingPromise = Promise.resolve().then(() => {
481
480
  try {
482
- const { apiKey, chatWsUrl } = await resolveAlfeChat({
481
+ const { apiKey, chatWsUrl } = resolveAlfeChat({
483
482
  apiKey: pluginConfig.apiKey,
484
483
  chatWsUrl: pluginConfig.chatWsUrl
485
484
  });
@@ -505,7 +504,7 @@ const plugin = {
505
504
  } catch (err) {
506
505
  log.error(`Failed to initialize chat service: ${err instanceof Error ? err.message : String(err)}`);
507
506
  }
508
- })();
507
+ });
509
508
  if (typeof api.registerGatewayMethod === "function") {
510
509
  api.registerGatewayMethod("sessions.list", async (...args) => {
511
510
  const params = args[0];
@@ -536,29 +535,31 @@ const plugin = {
536
535
  });
537
536
  log.info("Registered gateway RPC methods: sessions.list, sessions.get");
538
537
  }
539
- api.on("session_start", async (...eventArgs) => {
540
- const key = eventArgs[0].sessionKey;
541
- if (!key || isAlfeSessionKey(key)) return;
542
- log.info(`Chat session starting: ${key}`);
543
- await createSession(key, "", "alfe");
544
- }, { priority: 50 });
545
- api.on("message", async (...eventArgs) => {
546
- const event = eventArgs[0];
547
- const key = event.sessionKey;
548
- if (!key || isAlfeSessionKey(key)) return;
549
- await addMessage(key, event.role, event.content);
550
- });
551
- api.on("session_end", (...eventArgs) => {
552
- const key = eventArgs[0].sessionKey;
553
- if (!key || !isAlfeSessionKey(key)) return;
554
- log.info(`Alfe chat session ending: ${key}`);
555
- });
556
- log.info("Alfe Chat plugin registered");
538
+ if (!alreadyActivated) {
539
+ api.on("session_start", async (...eventArgs) => {
540
+ const key = eventArgs[0].sessionKey;
541
+ if (!key || isAlfeSessionKey(key)) return;
542
+ log.info(`Chat session starting: ${key}`);
543
+ await createSession(key, "", "alfe");
544
+ }, { priority: 50 });
545
+ api.on("message", async (...eventArgs) => {
546
+ const event = eventArgs[0];
547
+ const key = event.sessionKey;
548
+ if (!key || isAlfeSessionKey(key)) return;
549
+ await addMessage(key, event.role, event.content);
550
+ });
551
+ api.on("session_end", (...eventArgs) => {
552
+ const key = eventArgs[0].sessionKey;
553
+ if (!key || !isAlfeSessionKey(key)) return;
554
+ log.info(`Chat session ending: ${key}`);
555
+ });
556
+ }
557
+ log.info("Chat plugin registered");
557
558
  },
558
559
  async deactivate(api) {
559
560
  globalThis.__alfeChatPluginActivated = false;
560
561
  const log = api.logger;
561
- log.info("Alfe Chat plugin deactivating...");
562
+ log.info("Chat plugin deactivating...");
562
563
  if (connectingPromise) {
563
564
  await connectingPromise.catch((err) => {
564
565
  api.logger.debug(`Connection attempt failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -572,7 +573,7 @@ const plugin = {
572
573
  }
573
574
  pluginRuntime = null;
574
575
  dispatchInbound = null;
575
- log.info("Alfe Chat plugin deactivated");
576
+ log.info("Chat plugin deactivated");
576
577
  }
577
578
  };
578
579
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw-chat",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
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.3"
28
+ "@alfe.ai/chat": "^0.0.4"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "openclaw": ">=2026.3.0"