jefrichat-mcp 0.5.0 → 0.6.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/dist/http.js +8 -2
- package/dist/index.js +49 -3
- package/package.json +1 -1
package/dist/http.js
CHANGED
|
@@ -50394,10 +50394,16 @@ ${cmd}`
|
|
|
50394
50394
|
})
|
|
50395
50395
|
);
|
|
50396
50396
|
}
|
|
50397
|
-
function attachInbox(c, inbox, self) {
|
|
50397
|
+
function attachInbox(c, inbox, self, onIncoming) {
|
|
50398
50398
|
const capture = (e) => {
|
|
50399
50399
|
const m = e.message;
|
|
50400
|
-
if (m.senderUsername !== self)
|
|
50400
|
+
if (m.senderUsername !== self) {
|
|
50401
|
+
inbox.push(m);
|
|
50402
|
+
try {
|
|
50403
|
+
onIncoming?.(m);
|
|
50404
|
+
} catch {
|
|
50405
|
+
}
|
|
50406
|
+
}
|
|
50401
50407
|
};
|
|
50402
50408
|
c.on("message_received", capture);
|
|
50403
50409
|
c.on("file_received", capture);
|
package/dist/index.js
CHANGED
|
@@ -26302,15 +26302,49 @@ ${cmd}`
|
|
|
26302
26302
|
})
|
|
26303
26303
|
);
|
|
26304
26304
|
}
|
|
26305
|
-
function attachInbox(c, inbox2, self) {
|
|
26305
|
+
function attachInbox(c, inbox2, self, onIncoming) {
|
|
26306
26306
|
const capture = (e) => {
|
|
26307
26307
|
const m = e.message;
|
|
26308
|
-
if (m.senderUsername !== self)
|
|
26308
|
+
if (m.senderUsername !== self) {
|
|
26309
|
+
inbox2.push(m);
|
|
26310
|
+
try {
|
|
26311
|
+
onIncoming?.(m);
|
|
26312
|
+
} catch {
|
|
26313
|
+
}
|
|
26314
|
+
}
|
|
26309
26315
|
};
|
|
26310
26316
|
c.on("message_received", capture);
|
|
26311
26317
|
c.on("file_received", capture);
|
|
26312
26318
|
}
|
|
26313
26319
|
|
|
26320
|
+
// src/notify.ts
|
|
26321
|
+
import cp2 from "node:child_process";
|
|
26322
|
+
var OFF = process.env.JEFRI_NOTIFY === "0" || process.env.JEFRI_NOTIFY === "false";
|
|
26323
|
+
var clean = (s) => (s || "").replace(/[\r\n\t]+/g, " ").replace(/[\x00-\x1F]/g, "").slice(0, 140).trim();
|
|
26324
|
+
function notifyIncoming(title, body) {
|
|
26325
|
+
if (OFF) return;
|
|
26326
|
+
const t = clean(title) || "Jefri Chat";
|
|
26327
|
+
const b = clean(body);
|
|
26328
|
+
try {
|
|
26329
|
+
process.stderr.write("\x07");
|
|
26330
|
+
} catch {
|
|
26331
|
+
}
|
|
26332
|
+
try {
|
|
26333
|
+
if (process.platform === "darwin") {
|
|
26334
|
+
const esc2 = (x) => x.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
26335
|
+
const script = `display notification "${esc2(b)}" with title "${esc2(t)}" sound name "Ping"`;
|
|
26336
|
+
cp2.spawn("osascript", ["-e", script], { stdio: "ignore", detached: true }).unref();
|
|
26337
|
+
} else if (process.platform === "win32") {
|
|
26338
|
+
const esc2 = (x) => x.replace(/'/g, "''");
|
|
26339
|
+
const ps = `Add-Type -AssemblyName System.Windows.Forms;$n=New-Object System.Windows.Forms.NotifyIcon;$n.Icon=[System.Drawing.SystemIcons]::Information;$n.BalloonTipTitle='${esc2(t)}';$n.BalloonTipText='${esc2(b)}';$n.Visible=$true;$n.ShowBalloonTip(6000);Start-Sleep -Milliseconds 6500;$n.Dispose()`;
|
|
26340
|
+
cp2.spawn("powershell", ["-NoProfile", "-WindowStyle", "Hidden", "-Command", ps], { stdio: "ignore", detached: true }).unref();
|
|
26341
|
+
} else {
|
|
26342
|
+
cp2.spawn("notify-send", ["-a", "Jefri Chat", t, b], { stdio: "ignore", detached: true }).unref();
|
|
26343
|
+
}
|
|
26344
|
+
} catch {
|
|
26345
|
+
}
|
|
26346
|
+
}
|
|
26347
|
+
|
|
26314
26348
|
// src/index.ts
|
|
26315
26349
|
var SERVER = process.env.ACP_SERVER ?? "http://localhost:4000";
|
|
26316
26350
|
var TOKEN = process.env.ACP_TOKEN;
|
|
@@ -26364,7 +26398,19 @@ function ensureClient() {
|
|
|
26364
26398
|
if (c.identity) cacheToken(c.token);
|
|
26365
26399
|
}
|
|
26366
26400
|
const self = c.identity?.username ?? USERNAME;
|
|
26367
|
-
|
|
26401
|
+
const groupNames = /* @__PURE__ */ new Map();
|
|
26402
|
+
const refreshGroups = () => c.groups().then((gs) => {
|
|
26403
|
+
groupNames.clear();
|
|
26404
|
+
for (const g of gs) groupNames.set(g.id, g.name);
|
|
26405
|
+
}).catch(() => {
|
|
26406
|
+
});
|
|
26407
|
+
void refreshGroups();
|
|
26408
|
+
setInterval(refreshGroups, 6e4).unref?.();
|
|
26409
|
+
attachInbox(c, inbox, self, (m) => {
|
|
26410
|
+
const preview = m.kind === "file" ? `\u{1F4CE} ${m.fileName ?? "file"}` : m.content ?? "";
|
|
26411
|
+
const where = m.groupId ? ` \xB7 ${groupNames.get(m.groupId) ?? "group"}` : "";
|
|
26412
|
+
notifyIncoming("Jefri Chat", `${m.senderUsername}${where}: ${preview}`);
|
|
26413
|
+
});
|
|
26368
26414
|
log(`connected to ${SERVER} as ${self}`);
|
|
26369
26415
|
return c;
|
|
26370
26416
|
})().catch((e) => {
|
package/package.json
CHANGED