@iamtrask/om-bridge 1.0.0 → 1.2.0
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/bridge.js +8 -2
- package/package.json +1 -1
- package/setup.sh +42 -0
package/bridge.js
CHANGED
|
@@ -32,7 +32,11 @@ const jidMap = {}; // sender digits → full remoteJid
|
|
|
32
32
|
|
|
33
33
|
async function start() {
|
|
34
34
|
const { state, saveCreds } = await useMultiFileAuthState("./auth");
|
|
35
|
-
sock = makeWASocket({
|
|
35
|
+
sock = makeWASocket({
|
|
36
|
+
auth: state,
|
|
37
|
+
syncFullHistory: false,
|
|
38
|
+
logger: { info() {}, debug() {}, warn() {}, error: console.error, trace() {}, child() { return this; }, level: "error" }
|
|
39
|
+
});
|
|
36
40
|
sock.ev.on("creds.update", saveCreds);
|
|
37
41
|
|
|
38
42
|
sock.ev.on("connection.update", async ({ connection, lastDisconnect, qr }) => {
|
|
@@ -57,12 +61,14 @@ async function start() {
|
|
|
57
61
|
|
|
58
62
|
sock.ev.on("messages.upsert", async ({ messages }) => {
|
|
59
63
|
for (const msg of messages) {
|
|
60
|
-
|
|
64
|
+
// Allow self-messages for testing (skip other fromMe like delivery receipts)
|
|
65
|
+
if (msg.key.fromMe && !msg.message?.conversation && !msg.message?.extendedTextMessage?.text) continue;
|
|
61
66
|
const text = msg.message?.conversation
|
|
62
67
|
|| msg.message?.extendedTextMessage?.text
|
|
63
68
|
|| "";
|
|
64
69
|
if (!text) continue;
|
|
65
70
|
|
|
71
|
+
console.log("raw JID:", msg.key.remoteJid);
|
|
66
72
|
const sender = digits(msg.key.remoteJid);
|
|
67
73
|
jidMap[sender] = msg.key.remoteJid;
|
|
68
74
|
console.log(`← ${sender}: ${text}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamtrask/om-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The Open Mind — an AI auto-responder for WhatsApp. When someone texts you a message starting with \"om\", a local model replies on your behalf using only the files in that person's folder.",
|
|
5
5
|
"main": "bridge.js",
|
|
6
6
|
"bin": {
|
package/setup.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# OMBox Setup — installs dependencies, pulls the model, and starts the bridge
|
|
4
|
+
|
|
5
|
+
# Install Node.js if missing
|
|
6
|
+
if ! command -v node &> /dev/null; then
|
|
7
|
+
echo "Node.js not found. Installing..."
|
|
8
|
+
if command -v brew &> /dev/null; then
|
|
9
|
+
brew install node
|
|
10
|
+
elif command -v apt-get &> /dev/null; then
|
|
11
|
+
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
|
12
|
+
sudo apt-get install -y nodejs
|
|
13
|
+
else
|
|
14
|
+
echo "Please install Node.js from https://nodejs.org"
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Install Ollama if missing
|
|
20
|
+
if ! command -v ollama &> /dev/null; then
|
|
21
|
+
echo "Ollama not found. Installing..."
|
|
22
|
+
if command -v brew &> /dev/null; then
|
|
23
|
+
brew install ollama
|
|
24
|
+
else
|
|
25
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
26
|
+
fi
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Pull the model
|
|
30
|
+
echo "Pulling gemma4 (swap with e.g. qwen2.5:0.5b if low on memory)..."
|
|
31
|
+
ollama pull gemma4
|
|
32
|
+
|
|
33
|
+
# Start Ollama in the background if not already running
|
|
34
|
+
if ! curl -s http://localhost:11434/api/tags &> /dev/null; then
|
|
35
|
+
echo "Starting Ollama..."
|
|
36
|
+
ollama serve &> /dev/null &
|
|
37
|
+
sleep 2
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Start the WhatsApp bridge
|
|
41
|
+
echo "Starting WhatsApp bridge — scan the QR code with your phone..."
|
|
42
|
+
npx @iamtrask/om-bridge
|