hyperclaw 5.2.5 → 5.2.6
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/audit-NPINyRh4.js +445 -0
- package/dist/chat-8E4H6nqx.js +325 -0
- package/dist/connector-1_9a4Mhv.js +276 -0
- package/dist/connector-BeHsEhpz.js +164 -0
- package/dist/connector-DJ63fLj9.js +555 -0
- package/dist/connector-Ic8H84de.js +204 -0
- package/dist/daemon-DRhU750_.js +7 -0
- package/dist/daemon-bJ8IYnkd.js +421 -0
- package/dist/delivery-1vTBQ0a0.js +95 -0
- package/dist/delivery-BbOfKejh.js +4 -0
- package/dist/engine-BjzV25HS.js +7 -0
- package/dist/engine-DJSr69DF.js +327 -0
- package/dist/heartbeat-engine-0swQl6wg.js +89 -0
- package/dist/hub-BuUwiTxh.js +6 -0
- package/dist/hub-DIoASRn6.js +512 -0
- package/dist/hyperclawbot-CIvGq2IG.js +516 -0
- package/dist/inference-BSWFHqzs.js +2854 -0
- package/dist/inference-DQiqWbqu.js +8 -0
- package/dist/loader-Bpju2Xqs.js +6 -0
- package/dist/loader-DRfmh8hU.js +410 -0
- package/dist/logger-CnxILOPV.js +86 -0
- package/dist/mcp-loader-D-uIqYwB.js +93 -0
- package/dist/memory-auto-CK5M1YV8.js +5 -0
- package/dist/memory-auto-Cs6XiIxb.js +306 -0
- package/dist/node-4_wJsNEN.js +226 -0
- package/dist/oauth-flow-CJ7dFXKT.js +148 -0
- package/dist/onboard-C1RArB82.js +3865 -0
- package/dist/onboard-CQkUrkNk.js +13 -0
- package/dist/orchestrator-D9R2u9yL.js +6 -0
- package/dist/orchestrator-DMDgfB8j.js +189 -0
- package/dist/pairing-CNNtZ8JR.js +6 -0
- package/dist/pairing-fGaxBlgG.js +207 -0
- package/dist/pc-access-CaE4x3Vt.js +8 -0
- package/dist/pc-access-OIwXRyAD.js +858 -0
- package/dist/run-main.js +50 -44
- package/dist/runner-CFvEFt23.js +1274 -0
- package/dist/server-BSCeWSlZ.js +1304 -0
- package/dist/server-DIwR4tT3.js +4 -0
- package/dist/skill-runtime-CCwGR7iX.js +5 -0
- package/dist/skill-runtime-vmBIhuVk.js +104 -0
- package/dist/src-3dXyf5GQ.js +458 -0
- package/dist/src-BVeLalMV.js +63 -0
- package/dist/sub-agent-tools-C1dWyUAR.js +39 -0
- package/dist/tts-elevenlabs-F_xjKQ-I.js +64 -0
- package/dist/vision-BR5Gdb2s.js +169 -0
- package/dist/vision-tools-DuB1QtlE.js +51 -0
- package/dist/vision-tools-LvL8RMWR.js +5 -0
- package/dist/voice-transcription-D6dK7b9A.js +171 -0
- package/dist/website-watch-tools-Cqp7RPvn.js +176 -0
- package/dist/website-watch-tools-UPSrnBk2.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const chalk = require_chunk.__toESM(require("chalk"));
|
|
3
|
+
const fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
4
|
+
const path = require_chunk.__toESM(require("path"));
|
|
5
|
+
const os = require_chunk.__toESM(require("os"));
|
|
6
|
+
const events = require_chunk.__toESM(require("events"));
|
|
7
|
+
|
|
8
|
+
//#region extensions/whatsapp-baileys/src/connector.ts
|
|
9
|
+
const AUTH_DIR = path.default.join(os.default.homedir(), ".hyperclaw", "baileys-auth");
|
|
10
|
+
const STATE_FILE = path.default.join(os.default.homedir(), ".hyperclaw", "whatsapp-baileys-state.json");
|
|
11
|
+
var WhatsAppBaileysConnector = class extends events.EventEmitter {
|
|
12
|
+
config;
|
|
13
|
+
sock = null;
|
|
14
|
+
running = false;
|
|
15
|
+
qrCallback;
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
super();
|
|
18
|
+
this.config = {
|
|
19
|
+
dmPolicy: "allowlist",
|
|
20
|
+
allowFrom: [],
|
|
21
|
+
approvedPairings: [],
|
|
22
|
+
pendingPairings: {},
|
|
23
|
+
...config
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
onQR(cb) {
|
|
27
|
+
this.qrCallback = cb;
|
|
28
|
+
}
|
|
29
|
+
async connect() {
|
|
30
|
+
try {
|
|
31
|
+
const makeWASocket$1 = require("@whiskeysockets/baileys");
|
|
32
|
+
const { useMultiFileAuthState: useMultiFileAuthState$1 } = require("@whiskeysockets/baileys");
|
|
33
|
+
} catch {
|
|
34
|
+
throw new Error("Baileys not installed. Run: npm install @whiskeysockets/baileys");
|
|
35
|
+
}
|
|
36
|
+
const makeWASocket = require("@whiskeysockets/baileys").default;
|
|
37
|
+
const { useMultiFileAuthState } = require("@whiskeysockets/baileys");
|
|
38
|
+
await fs_extra.default.ensureDir(AUTH_DIR);
|
|
39
|
+
const { state, saveCreds } = await useMultiFileAuthState(AUTH_DIR);
|
|
40
|
+
await this.loadState();
|
|
41
|
+
this.sock = makeWASocket({
|
|
42
|
+
auth: state,
|
|
43
|
+
printQRInTerminal: true,
|
|
44
|
+
generateHighQualityLinkPreview: false
|
|
45
|
+
});
|
|
46
|
+
this.sock.ev.on("creds.update", saveCreds);
|
|
47
|
+
this.sock.ev.on("connection.update", (upd) => {
|
|
48
|
+
if (upd.qr) this.qrCallback?.(upd.qr);
|
|
49
|
+
if (upd.connection === "open") {
|
|
50
|
+
console.log(chalk.default.green(" 🦅 WhatsApp Baileys: connected"));
|
|
51
|
+
this.emit("connected", {});
|
|
52
|
+
}
|
|
53
|
+
if (upd.connection === "close") this.emit("disconnected", upd);
|
|
54
|
+
});
|
|
55
|
+
this.sock.ev.on("messages.upsert", async ({ messages }) => {
|
|
56
|
+
for (const m of messages) {
|
|
57
|
+
if (m.key.fromMe) continue;
|
|
58
|
+
const msg = m.message;
|
|
59
|
+
if (!msg) continue;
|
|
60
|
+
let text = msg.conversation || msg.extendedTextMessage?.text || "";
|
|
61
|
+
const from = (m.key.remoteJid || "").replace(/@.*/, "");
|
|
62
|
+
if (msg.audioMessage || msg.pttMessage) {
|
|
63
|
+
let audioBuffer;
|
|
64
|
+
try {
|
|
65
|
+
const { downloadMediaMessage } = require("@whiskeysockets/baileys");
|
|
66
|
+
audioBuffer = await downloadMediaMessage(m, "buffer", {}, { reuploadRequest: this.sock?.updateMessageSent });
|
|
67
|
+
} catch {}
|
|
68
|
+
this.emit("message", {
|
|
69
|
+
id: m.key.id,
|
|
70
|
+
channelId: "whatsapp-baileys",
|
|
71
|
+
from,
|
|
72
|
+
chatId: m.key.remoteJid,
|
|
73
|
+
text: "[voice note]",
|
|
74
|
+
audioBuffer,
|
|
75
|
+
timestamp: new Date(parseInt(m.messageTimestamp || "0") * 1e3).toISOString(),
|
|
76
|
+
isDM: true
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (!text) continue;
|
|
81
|
+
const allowed = await this.checkDMPolicy(from, text);
|
|
82
|
+
if (!allowed) continue;
|
|
83
|
+
this.emit("message", {
|
|
84
|
+
id: m.key.id,
|
|
85
|
+
channelId: "whatsapp-baileys",
|
|
86
|
+
from,
|
|
87
|
+
chatId: m.key.remoteJid,
|
|
88
|
+
text,
|
|
89
|
+
timestamp: new Date(parseInt(m.messageTimestamp) * 1e3).toISOString(),
|
|
90
|
+
isDM: true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
this.running = true;
|
|
95
|
+
}
|
|
96
|
+
async checkDMPolicy(from, text) {
|
|
97
|
+
if (this.config.dmPolicy === "none") return false;
|
|
98
|
+
if (this.config.dmPolicy === "open") return true;
|
|
99
|
+
if (this.config.dmPolicy === "allowlist") {
|
|
100
|
+
if (this.config.allowFrom.includes(from)) return true;
|
|
101
|
+
await this.sendMessage(from, "🦅 HyperClaw: Not on allowlist.").catch(() => {});
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (this.config.dmPolicy === "pairing") {
|
|
105
|
+
if (this.config.approvedPairings.includes(from)) return true;
|
|
106
|
+
const upper = text.trim().toUpperCase();
|
|
107
|
+
if (this.config.pendingPairings[upper]) {
|
|
108
|
+
this.config.approvedPairings.push(from);
|
|
109
|
+
delete this.config.pendingPairings[upper];
|
|
110
|
+
await this.saveState();
|
|
111
|
+
await this.sendMessage(from, "🦅 Paired!").catch(() => {});
|
|
112
|
+
this.emit("pairing:approved", {
|
|
113
|
+
userId: from,
|
|
114
|
+
channelId: "whatsapp-baileys"
|
|
115
|
+
});
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
const code = Array.from({ length: 6 }, () => "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"[Math.floor(Math.random() * 32)]).join("");
|
|
119
|
+
this.config.pendingPairings[code] = from;
|
|
120
|
+
await this.saveState();
|
|
121
|
+
await this.sendMessage(from, `🦅 Code: ${code}\nApprove: hyperclaw pairing approve whatsapp-baileys ${code}`).catch(() => {});
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
async sendMessage(to, text) {
|
|
127
|
+
if (!this.sock) return;
|
|
128
|
+
const jid = to.includes("@") ? to : `${to}@s.whatsapp.net`;
|
|
129
|
+
await this.sock.sendMessage(jid, { text: text.slice(0, 4096) });
|
|
130
|
+
}
|
|
131
|
+
disconnect() {
|
|
132
|
+
this.running = false;
|
|
133
|
+
this.sock?.end?.();
|
|
134
|
+
this.sock = null;
|
|
135
|
+
}
|
|
136
|
+
approvePairing(code) {
|
|
137
|
+
const upper = code.toUpperCase();
|
|
138
|
+
if (!this.config.pendingPairings[upper]) return false;
|
|
139
|
+
this.config.approvedPairings.push(this.config.pendingPairings[upper]);
|
|
140
|
+
delete this.config.pendingPairings[upper];
|
|
141
|
+
this.saveState();
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
async loadState() {
|
|
145
|
+
try {
|
|
146
|
+
const s = await fs_extra.default.readJson(STATE_FILE);
|
|
147
|
+
if (s.p) this.config.pendingPairings = s.p;
|
|
148
|
+
if (s.a) this.config.approvedPairings = s.a;
|
|
149
|
+
} catch {}
|
|
150
|
+
}
|
|
151
|
+
async saveState() {
|
|
152
|
+
await fs_extra.default.ensureDir(path.default.dirname(STATE_FILE));
|
|
153
|
+
await fs_extra.default.writeJson(STATE_FILE, {
|
|
154
|
+
p: this.config.pendingPairings,
|
|
155
|
+
a: this.config.approvedPairings
|
|
156
|
+
}, { spaces: 2 });
|
|
157
|
+
}
|
|
158
|
+
isRunning() {
|
|
159
|
+
return this.running;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
exports.WhatsAppBaileysConnector = WhatsAppBaileysConnector;
|