adp-openclaw 0.0.47 → 0.0.49

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
@@ -91,11 +91,17 @@ const plugin = {
91
91
  description: "ADP channel plugin backed by a Go WebSocket server",
92
92
  configSchema: emptyPluginConfigSchema(),
93
93
  register(api: OpenClawPluginApi) {
94
- // console.log("[adp-openclaw] register() called");
94
+ // Log registration for debugging
95
+ console.log("[adp-openclaw] register() called - starting plugin registration");
96
+ api.logger.info?.("[adp-openclaw] Plugin register() called");
97
+
95
98
  setAdpOpenclawRuntime(api.runtime);
96
99
 
97
100
  // Register the ADP file upload tool
98
101
  // This allows AI to send files to users via ADP storage
102
+ console.log(`[adp-openclaw] Registering tool: ${ADP_UPLOAD_TOOL_NAME}`);
103
+ api.logger.info?.(`[adp-openclaw] Registering tool: ${ADP_UPLOAD_TOOL_NAME}`);
104
+
99
105
  api.registerTool({
100
106
  name: ADP_UPLOAD_TOOL_NAME,
101
107
  description:
@@ -233,9 +239,16 @@ const plugin = {
233
239
  };
234
240
  },
235
241
  });
242
+
243
+ // Log tool registration success
244
+ console.log(`[adp-openclaw] Tool ${ADP_UPLOAD_TOOL_NAME} registered successfully`);
245
+ api.logger.info?.(`[adp-openclaw] Tool ${ADP_UPLOAD_TOOL_NAME} registered successfully`);
236
246
 
237
247
  // Register the channel plugin
238
248
  api.registerChannel({ plugin: adpOpenclawPlugin });
249
+
250
+ console.log("[adp-openclaw] Plugin registration complete");
251
+ api.logger.info?.("[adp-openclaw] Plugin registration complete");
239
252
  },
240
253
  };
241
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adp-openclaw",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "ADP-OpenClaw demo channel plugin (Go WebSocket backend)",
5
5
  "type": "module",
6
6
  "dependencies": {
package/src/channel.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  DEFAULT_ACCOUNT_ID,
8
8
  } from "openclaw/plugin-sdk";
9
9
  import { adpOpenclawOnboardingAdapter } from "./onboarding.js";
10
+ import { getActiveWebSocket } from "./runtime.js";
10
11
 
11
12
  // Default WebSocket URL for ADP OpenClaw
12
13
  const DEFAULT_WS_URL = "wss://wss.lke.cloud.tencent.com/bot/gateway/conn";
@@ -218,6 +219,42 @@ export const adpOpenclawPlugin: ChannelPlugin<ResolvedAdpOpenclawAccount> = {
218
219
  });
219
220
  },
220
221
  },
221
- // Note: outbound.send is not available in WebSocket-only architecture
222
- // All message sending is done through the WebSocket connection in monitor.ts
222
+ // Outbound message support for the "message" tool
223
+ outbound: {
224
+ send: async ({ text, to, log }) => {
225
+ const ws = getActiveWebSocket();
226
+ if (!ws) {
227
+ log?.error?.("[adp-openclaw] No active WebSocket connection for outbound message");
228
+ return { ok: false, error: "No active WebSocket connection" };
229
+ }
230
+
231
+ // Parse target: expected format is "adp-openclaw:{userId}" or "adp-openclaw:bot"
232
+ // The "to" parameter comes from the message tool with format like "adp-openclaw:user123"
233
+ const targetParts = to.split(":");
234
+ const targetUserId = targetParts.length > 1 ? targetParts.slice(1).join(":") : to;
235
+
236
+ log?.info?.(`[adp-openclaw] Sending outbound message to ${targetUserId}: ${text.slice(0, 50)}...`);
237
+
238
+ try {
239
+ // Generate unique request ID
240
+ const requestId = `outbound-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
241
+
242
+ const outMsg = {
243
+ type: "outbound",
244
+ requestId,
245
+ payload: {
246
+ to: targetUserId,
247
+ text: text,
248
+ },
249
+ timestamp: Date.now(),
250
+ };
251
+
252
+ ws.send(JSON.stringify(outMsg));
253
+ return { ok: true };
254
+ } catch (err) {
255
+ log?.error?.(`[adp-openclaw] Failed to send outbound message: ${err}`);
256
+ return { ok: false, error: String(err) };
257
+ }
258
+ },
259
+ },
223
260
  };
package/src/monitor.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Supports: API Token auth, conversation tracking for multi-turn dialogues
3
3
 
4
4
  import type { PluginLogger, ClawdbotConfig } from "openclaw/plugin-sdk";
5
- import { getAdpOpenclawRuntime } from "./runtime.js";
5
+ import { getAdpOpenclawRuntime, setActiveWebSocket } from "./runtime.js";
6
6
  import {
7
7
  getChatHistory,
8
8
  listSessions,
@@ -176,6 +176,9 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
176
176
 
177
177
  ws.on("open", () => {
178
178
  log?.info(`[adp-openclaw] WebSocket connected, authenticating...`);
179
+
180
+ // Save active WebSocket for outbound messaging
181
+ setActiveWebSocket(ws);
179
182
 
180
183
  // Send authentication message with signature (includes timestamp for anti-replay)
181
184
  const nonce = generateNonce();
@@ -691,6 +694,8 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
691
694
  ws.on("close", (code, reason) => {
692
695
  if (pingInterval) clearInterval(pingInterval);
693
696
  abortSignal?.removeEventListener("abort", abortHandler);
697
+ // Clear active WebSocket when connection closes
698
+ setActiveWebSocket(null);
694
699
  log?.info(`[adp-openclaw] WebSocket closed: ${code} ${reason.toString()}`);
695
700
  resolve();
696
701
  });
package/src/runtime.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // Runtime singleton for adp-openclaw plugin
2
2
  import type { PluginRuntime } from "openclaw/plugin-sdk";
3
+ import type { WebSocket } from "ws";
3
4
 
4
5
  let adpOpenclawRuntime: PluginRuntime | null = null;
5
6
 
@@ -16,6 +17,17 @@ export type PluginConfig = {
16
17
 
17
18
  let pluginConfig: PluginConfig = {};
18
19
 
20
+ // Active WebSocket connection for outbound messaging
21
+ let activeWebSocket: WebSocket | null = null;
22
+
23
+ export function setActiveWebSocket(ws: WebSocket | null): void {
24
+ activeWebSocket = ws;
25
+ }
26
+
27
+ export function getActiveWebSocket(): WebSocket | null {
28
+ return activeWebSocket;
29
+ }
30
+
19
31
  export function setAdpOpenclawRuntime(runtime: PluginRuntime): void {
20
32
  adpOpenclawRuntime = runtime;
21
33
  }