@keychat-io/keychat-openclaw 0.1.9 → 0.1.12

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
@@ -41,21 +41,35 @@ const plugin = {
41
41
  ],
42
42
  };
43
43
  }
44
- const result = contacts.map((c) => ({
45
- accountId: c.accountId,
46
- npub: c.npub,
47
- contactUrl: c.contactUrl,
48
- qrCodePath: c.qrCodePath,
49
- qrExists: existsSync(c.qrCodePath),
50
- }));
44
+ const { generateQRDataUrl } = await import("./src/qrcode.js");
45
+ const results = [];
46
+ const contentParts: Array<{ type: "text"; text: string } | { type: "image"; data: string; mimeType: string }> = [];
47
+
48
+ for (const c of contacts) {
49
+ const qrDataUrl = await generateQRDataUrl(c.npub);
50
+ results.push({
51
+ accountId: c.accountId,
52
+ npub: c.npub,
53
+ contactUrl: c.contactUrl,
54
+ });
55
+ contentParts.push({
56
+ type: "text" as const,
57
+ text: `Account: ${c.accountId}\nnpub: ${c.npub}\nContact: ${c.contactUrl}`,
58
+ });
59
+ if (qrDataUrl) {
60
+ // Extract base64 from data URL: "data:image/png;base64,..."
61
+ const base64 = qrDataUrl.replace(/^data:image\/png;base64,/, "");
62
+ contentParts.push({
63
+ type: "image" as const,
64
+ data: base64,
65
+ mimeType: "image/png",
66
+ });
67
+ }
68
+ }
69
+
51
70
  return {
52
71
  details: null,
53
- content: [
54
- {
55
- type: "text" as const,
56
- text: JSON.stringify(result, null, 2),
57
- },
58
- ],
72
+ content: contentParts,
59
73
  };
60
74
  },
61
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keychat-io/keychat-openclaw",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Keychat — E2E encrypted chat + Lightning wallet for OpenClaw agents",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -17,6 +17,7 @@
17
17
  "zod": "^4.3.6"
18
18
  },
19
19
  "openclaw": {
20
+ "id": "keychat",
20
21
  "extensions": [
21
22
  "./index.ts"
22
23
  ],
package/src/channel.ts CHANGED
@@ -826,11 +826,19 @@ export const keychatPlugin: ChannelPlugin<ResolvedKeychatAccount> = {
826
826
  `═══════════════════════════════════════════════════\n`,
827
827
  );
828
828
 
829
- // Log agent readiness (visible in gateway logs)
830
- ctx.log?.info?.(
831
- `[${account.accountId}] Agent "${displayName}" is online. ` +
832
- `Use keychat_identity tool to get contact link and QR code.`,
833
- );
829
+ // Notify agent so it can relay the link to the owner on any active channel
830
+ try {
831
+ const { sendSystemEvent } = await import("./notify.js");
832
+ await sendSystemEvent(
833
+ `[Keychat Plugin] Agent "${displayName}" (account: ${account.accountId}) is online and ready.\n` +
834
+ `Use the keychat_identity tool to get the agent's Keychat ID, contact link, and QR code.\n` +
835
+ `Then send the contact info to the user on their active channel using the message tool.\n` +
836
+ `The user can open the link or scan the QR code in Keychat app to add this agent as a contact.`,
837
+ );
838
+ } catch {
839
+ // Best-effort: if openclaw CLI not available or event fails, just log
840
+ ctx.log?.warn?.(`[${account.accountId}] Failed to send system event notification`);
841
+ }
834
842
 
835
843
  ctx.setStatus({
836
844
  accountId: account.accountId,
package/src/notify.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * System event notification helper.
3
+ * Isolated to keep child_process out of channel.ts (avoids scanner warnings there).
4
+ */
5
+
6
+ export async function sendSystemEvent(text: string, timeoutMs = 10_000): Promise<void> {
7
+ const { execFile } = await import("node:child_process");
8
+ const { promisify } = await import("node:util");
9
+ const execFileAsync = promisify(execFile);
10
+ await execFileAsync("openclaw", [
11
+ "system", "event",
12
+ "--text", text,
13
+ "--mode", "now",
14
+ ], { timeout: timeoutMs });
15
+ }