jefrichat-mcp 0.16.0 → 0.17.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 +2 -1
- package/dist/index.js +33 -10
- package/package.json +1 -1
package/dist/http.js
CHANGED
|
@@ -49466,6 +49466,7 @@ function setPrefs(patch) {
|
|
|
49466
49466
|
}
|
|
49467
49467
|
return { ...prefs };
|
|
49468
49468
|
}
|
|
49469
|
+
var LOG_FILE = np.join(os2.homedir(), ".jefri", "notify.log");
|
|
49469
49470
|
|
|
49470
49471
|
// src/autonomous.ts
|
|
49471
49472
|
import fs3 from "node:fs";
|
|
@@ -49485,7 +49486,7 @@ var DEFAULTS2 = {
|
|
|
49485
49486
|
};
|
|
49486
49487
|
var DIR = np2.join(os3.homedir(), ".jefri");
|
|
49487
49488
|
var FILE = np2.join(DIR, "autonomous.json");
|
|
49488
|
-
var
|
|
49489
|
+
var LOG_FILE2 = np2.join(DIR, "autonomous.log");
|
|
49489
49490
|
function loadCfg() {
|
|
49490
49491
|
try {
|
|
49491
49492
|
return { ...DEFAULTS2, ...JSON.parse(fs3.readFileSync(FILE, "utf8")) };
|
package/dist/index.js
CHANGED
|
@@ -25387,16 +25387,27 @@ function inQuietHours() {
|
|
|
25387
25387
|
return from < to ? cur >= from && cur < to : cur >= from || cur < to;
|
|
25388
25388
|
}
|
|
25389
25389
|
var clean = (s) => (s || "").replace(/[\r\n\t]+/g, " ").replace(/[\x00-\x1F]/g, "").slice(0, 140).trim();
|
|
25390
|
+
var LOG_FILE = np.join(os2.homedir(), ".jefri", "notify.log");
|
|
25391
|
+
function logNotify(line) {
|
|
25392
|
+
try {
|
|
25393
|
+
fs2.mkdirSync(np.dirname(LOG_FILE), { recursive: true });
|
|
25394
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
25395
|
+
fs2.appendFileSync(LOG_FILE, `[${ts}] ${line}
|
|
25396
|
+
`);
|
|
25397
|
+
} catch {
|
|
25398
|
+
}
|
|
25399
|
+
}
|
|
25390
25400
|
function notifyIncoming(m) {
|
|
25391
|
-
if (OFF || !prefs.enabled) return;
|
|
25392
|
-
if (m.isGroup ? !prefs.groups : !prefs.dms) return;
|
|
25393
|
-
if (m.isGroup && prefs.onlyMentions && !m.isMention) return;
|
|
25394
|
-
if (m.isGroup && m.groupId && prefs.mutedGroups.includes(m.groupId)) return;
|
|
25395
|
-
if (prefs.mutedUsers.includes(m.sender)) return;
|
|
25396
|
-
if (inQuietHours()) return;
|
|
25401
|
+
if (OFF || !prefs.enabled) return logNotify(`skip (disabled) from @${m.sender}`);
|
|
25402
|
+
if (m.isGroup ? !prefs.groups : !prefs.dms) return logNotify(`skip (dms/groups pref) from @${m.sender}`);
|
|
25403
|
+
if (m.isGroup && prefs.onlyMentions && !m.isMention) return logNotify(`skip (onlyMentions) from @${m.sender}`);
|
|
25404
|
+
if (m.isGroup && m.groupId && prefs.mutedGroups.includes(m.groupId)) return logNotify(`skip (muted group) from @${m.sender}`);
|
|
25405
|
+
if (prefs.mutedUsers.includes(m.sender)) return logNotify(`skip (muted user) @${m.sender}`);
|
|
25406
|
+
if (inQuietHours()) return logNotify(`skip (quiet hours) from @${m.sender}`);
|
|
25397
25407
|
const sound = prefs.sound;
|
|
25398
25408
|
const title = "Jefri Chat";
|
|
25399
25409
|
const body = clean(m.body);
|
|
25410
|
+
logNotify(`fire on ${process.platform} for @${m.sender}: ${body.slice(0, 60)}`);
|
|
25400
25411
|
if (sound) {
|
|
25401
25412
|
try {
|
|
25402
25413
|
process.stderr.write("\x07");
|
|
@@ -25420,9 +25431,21 @@ function notifyIncoming(m) {
|
|
|
25420
25431
|
const xesc = (x) => x.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
25421
25432
|
const audio = sound ? `<audio src="ms-winsoundevent:Notification.Default"/>` : `<audio silent="true"/>`;
|
|
25422
25433
|
const xml = `<toast><visual><binding template="ToastGeneric"><text>${xesc(title)}</text><text>${xesc(body)}</text></binding></visual>${audio}</toast>`;
|
|
25423
|
-
const ps = `$ErrorActionPreference='Stop';$t='${esc2(title)}';$b='${esc2(body)}';try{[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null;[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom, ContentType = WindowsRuntime] | Out-Null;$d=New-Object Windows.Data.Xml.Dom.XmlDocument;$d.LoadXml('${xml}');$toast=New-Object Windows.UI.Notifications.ToastNotification -ArgumentList $d;[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe').Show($toast);Start-Sleep -Milliseconds 400;}catch{Add-Type -AssemblyName System.Windows.Forms;Add-Type -AssemblyName System.Drawing;$n=New-Object System.Windows.Forms.NotifyIcon;$n.Icon=[System.Drawing.SystemIcons]::Information;$n.BalloonTipTitle=$t;$n.BalloonTipText=$b;$n.Visible=$true;$n.ShowBalloonTip(6000);Start-Sleep -Milliseconds 6500;$n.Dispose();}`;
|
|
25434
|
+
const ps = `$ErrorActionPreference='Stop';$t='${esc2(title)}';$b='${esc2(body)}';try{[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null;[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom, ContentType = WindowsRuntime] | Out-Null;$d=New-Object Windows.Data.Xml.Dom.XmlDocument;$d.LoadXml('${xml}');$toast=New-Object Windows.UI.Notifications.ToastNotification -ArgumentList $d;[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe').Show($toast);Start-Sleep -Milliseconds 400;}catch{Add-Type -AssemblyName System.Windows.Forms;Add-Type -AssemblyName System.Drawing;$n=New-Object System.Windows.Forms.NotifyIcon;$n.Icon=[System.Drawing.SystemIcons]::Information;$n.BalloonTipTitle=$t;$n.BalloonTipText=$b;$n.Visible=$true;$n.ShowBalloonTip(6000);Start-Sleep -Milliseconds 6500;$n.Dispose();[Console]::Error.WriteLine('TOASTERR-fell-back-to-balloon: '+$_.Exception.Message);}`;
|
|
25424
25435
|
const encoded = Buffer.from(ps, "utf16le").toString("base64");
|
|
25425
|
-
|
|
25436
|
+
const child = cp.spawn(
|
|
25437
|
+
"powershell",
|
|
25438
|
+
["-NoProfile", "-WindowStyle", "Hidden", "-EncodedCommand", encoded],
|
|
25439
|
+
{ stdio: ["ignore", "ignore", "pipe"] }
|
|
25440
|
+
);
|
|
25441
|
+
let errBuf = "";
|
|
25442
|
+
child.stderr?.on("data", (d) => errBuf += d.toString());
|
|
25443
|
+
child.on("error", (e) => logNotify(`win: powershell spawn FAILED: ${e.message}`));
|
|
25444
|
+
child.on(
|
|
25445
|
+
"close",
|
|
25446
|
+
(code) => logNotify(`win: powershell exit=${code}${errBuf.trim() ? ` stderr=${errBuf.trim().slice(0, 300)}` : " (no error output)"}`)
|
|
25447
|
+
);
|
|
25448
|
+
child.unref();
|
|
25426
25449
|
} else {
|
|
25427
25450
|
cp.spawn("notify-send", ["-a", "Jefri Chat", title, body], { stdio: "ignore", detached: true }).unref();
|
|
25428
25451
|
}
|
|
@@ -25449,12 +25472,12 @@ var DEFAULTS2 = {
|
|
|
25449
25472
|
};
|
|
25450
25473
|
var DIR = np2.join(os3.homedir(), ".jefri");
|
|
25451
25474
|
var FILE = np2.join(DIR, "autonomous.json");
|
|
25452
|
-
var
|
|
25475
|
+
var LOG_FILE2 = np2.join(DIR, "autonomous.log");
|
|
25453
25476
|
function logLine(line) {
|
|
25454
25477
|
try {
|
|
25455
25478
|
fs3.mkdirSync(DIR, { recursive: true });
|
|
25456
25479
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
25457
|
-
fs3.appendFileSync(
|
|
25480
|
+
fs3.appendFileSync(LOG_FILE2, `[${ts}] ${line}
|
|
25458
25481
|
`);
|
|
25459
25482
|
} catch {
|
|
25460
25483
|
}
|
package/package.json
CHANGED