clawsocial-plugin 1.0.22 → 1.0.23

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/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { initStore } from "./src/store.js";
2
2
  import { initApi } from "./src/api.js";
3
3
  import { startWsClient, stopWsClient } from "./src/ws-client.js";
4
- import { setEnqueueFn, setSessionKey } from "./src/notify.js";
4
+ import { setRuntimeFns, setSessionKey } from "./src/notify.js";
5
5
  import { createRegisterTool } from "./src/tools/register.js";
6
6
  import { createSearchTool } from "./src/tools/search.js";
7
7
  import { createConnectTool } from "./src/tools/connect.js";
@@ -19,9 +19,12 @@ export default {
19
19
  register(api: any) {
20
20
  const serverUrl = (api.pluginConfig?.serverUrl as string) || "https://clawsocial-server-production.up.railway.app";
21
21
 
22
- // Wire up notification system: enqueueSystemEvent pushes text into user's chat
22
+ // Wire up notification system: enqueueSystemEvent + requestHeartbeatNow
23
23
  if (api.runtime?.system?.enqueueSystemEvent) {
24
- setEnqueueFn(api.runtime.system.enqueueSystemEvent);
24
+ setRuntimeFns(
25
+ api.runtime.system.enqueueSystemEvent,
26
+ api.runtime.system.requestHeartbeatNow,
27
+ );
25
28
  }
26
29
 
27
30
  // Capture sessionKey from before_agent_start hook so background WS can push notifications
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawsocial-plugin",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "ClawSocial OpenClaw Plugin — social discovery for AI agents",
5
5
  "type": "module",
6
6
  "dependencies": {
package/src/notify.ts CHANGED
@@ -1,14 +1,17 @@
1
- // Push notifications into the user's OpenClaw chat via enqueueSystemEvent.
2
- // sessionKey is captured from the before_agent_start hook; enqueueSystemEvent
3
- // is set once during plugin registration.
1
+ // Push notifications into the user's OpenClaw chat via enqueueSystemEvent +
2
+ // requestHeartbeatNow. sessionKey is captured from the before_agent_start hook;
3
+ // runtime functions are set once during plugin registration.
4
4
 
5
5
  type EnqueueFn = (text: string, opts: { sessionKey: string }) => void;
6
+ type HeartbeatFn = () => void;
6
7
 
7
8
  let _enqueue: EnqueueFn | null = null;
9
+ let _heartbeat: HeartbeatFn | null = null;
8
10
  let _sessionKey: string | null = null;
9
11
 
10
- export function setEnqueueFn(fn: EnqueueFn): void {
11
- _enqueue = fn;
12
+ export function setRuntimeFns(enqueue: EnqueueFn, heartbeat?: HeartbeatFn): void {
13
+ _enqueue = enqueue;
14
+ _heartbeat = heartbeat ?? null;
12
15
  }
13
16
 
14
17
  export function setSessionKey(key: string): void {
@@ -18,4 +21,6 @@ export function setSessionKey(key: string): void {
18
21
  export function pushNotification(text: string): void {
19
22
  if (!_enqueue || !_sessionKey) return;
20
23
  _enqueue(text, { sessionKey: _sessionKey });
24
+ // Trigger immediate AI response so the user sees the notification right away
25
+ if (_heartbeat) _heartbeat();
21
26
  }