jefrichat-mcp 0.5.0 → 0.7.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 +79 -9
- 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
|
@@ -6883,12 +6883,12 @@ var require_dist = __commonJS({
|
|
|
6883
6883
|
throw new Error(`Unknown format "${name}"`);
|
|
6884
6884
|
return f;
|
|
6885
6885
|
};
|
|
6886
|
-
function addFormats(ajv, list,
|
|
6886
|
+
function addFormats(ajv, list, fs5, exportName) {
|
|
6887
6887
|
var _a;
|
|
6888
6888
|
var _b;
|
|
6889
6889
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6890
6890
|
for (const f of list)
|
|
6891
|
-
ajv.addFormat(f,
|
|
6891
|
+
ajv.addFormat(f, fs5[f]);
|
|
6892
6892
|
}
|
|
6893
6893
|
module.exports = exports = formatsPlugin;
|
|
6894
6894
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24788,7 +24788,7 @@ var StdioServerTransport = class {
|
|
|
24788
24788
|
};
|
|
24789
24789
|
|
|
24790
24790
|
// src/index.ts
|
|
24791
|
-
import
|
|
24791
|
+
import fs4 from "node:fs";
|
|
24792
24792
|
import os3 from "node:os";
|
|
24793
24793
|
import path2 from "node:path";
|
|
24794
24794
|
|
|
@@ -26302,15 +26302,71 @@ ${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
|
+
import fs3 from "node:fs";
|
|
26323
|
+
var OFF = process.env.JEFRI_NOTIFY === "0" || process.env.JEFRI_NOTIFY === "false";
|
|
26324
|
+
function findTerminalNotifier() {
|
|
26325
|
+
if (process.platform !== "darwin") return null;
|
|
26326
|
+
for (const p of ["/opt/homebrew/bin/terminal-notifier", "/usr/local/bin/terminal-notifier"]) {
|
|
26327
|
+
try {
|
|
26328
|
+
if (fs3.existsSync(p)) return p;
|
|
26329
|
+
} catch {
|
|
26330
|
+
}
|
|
26331
|
+
}
|
|
26332
|
+
try {
|
|
26333
|
+
const out = (cp2.spawnSync("which", ["terminal-notifier"], { encoding: "utf8" }).stdout || "").trim();
|
|
26334
|
+
if (out && fs3.existsSync(out)) return out;
|
|
26335
|
+
} catch {
|
|
26336
|
+
}
|
|
26337
|
+
return null;
|
|
26338
|
+
}
|
|
26339
|
+
var TERMINAL_NOTIFIER = findTerminalNotifier();
|
|
26340
|
+
var macNeedsTerminalNotifier = process.platform === "darwin" && !TERMINAL_NOTIFIER && !OFF;
|
|
26341
|
+
var clean = (s) => (s || "").replace(/[\r\n\t]+/g, " ").replace(/[\x00-\x1F]/g, "").slice(0, 140).trim();
|
|
26342
|
+
function notifyIncoming(title, body) {
|
|
26343
|
+
if (OFF) return;
|
|
26344
|
+
const t = clean(title) || "Jefri Chat";
|
|
26345
|
+
const b = clean(body);
|
|
26346
|
+
try {
|
|
26347
|
+
process.stderr.write("\x07");
|
|
26348
|
+
} catch {
|
|
26349
|
+
}
|
|
26350
|
+
try {
|
|
26351
|
+
if (process.platform === "darwin") {
|
|
26352
|
+
if (TERMINAL_NOTIFIER) {
|
|
26353
|
+
cp2.spawn(TERMINAL_NOTIFIER, ["-title", t, "-message", b, "-sound", "Ping"], { stdio: "ignore", detached: true }).unref();
|
|
26354
|
+
} else {
|
|
26355
|
+
const esc2 = (x) => x.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
26356
|
+
const script = `display notification "${esc2(b)}" with title "${esc2(t)}" sound name "Ping"`;
|
|
26357
|
+
cp2.spawn("osascript", ["-e", script], { stdio: "ignore", detached: true }).unref();
|
|
26358
|
+
}
|
|
26359
|
+
} else if (process.platform === "win32") {
|
|
26360
|
+
const esc2 = (x) => x.replace(/'/g, "''");
|
|
26361
|
+
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()`;
|
|
26362
|
+
cp2.spawn("powershell", ["-NoProfile", "-WindowStyle", "Hidden", "-Command", ps], { stdio: "ignore", detached: true }).unref();
|
|
26363
|
+
} else {
|
|
26364
|
+
cp2.spawn("notify-send", ["-a", "Jefri Chat", t, b], { stdio: "ignore", detached: true }).unref();
|
|
26365
|
+
}
|
|
26366
|
+
} catch {
|
|
26367
|
+
}
|
|
26368
|
+
}
|
|
26369
|
+
|
|
26314
26370
|
// src/index.ts
|
|
26315
26371
|
var SERVER = process.env.ACP_SERVER ?? "http://localhost:4000";
|
|
26316
26372
|
var TOKEN = process.env.ACP_TOKEN;
|
|
@@ -26323,7 +26379,7 @@ var TOKEN_CACHE = path2.join(os3.homedir(), ".acp", "tokens.json");
|
|
|
26323
26379
|
var cacheKey = `${SERVER}::${USERNAME}`;
|
|
26324
26380
|
function readTokenCache() {
|
|
26325
26381
|
try {
|
|
26326
|
-
return JSON.parse(
|
|
26382
|
+
return JSON.parse(fs4.readFileSync(TOKEN_CACHE, "utf8"));
|
|
26327
26383
|
} catch {
|
|
26328
26384
|
return {};
|
|
26329
26385
|
}
|
|
@@ -26331,8 +26387,8 @@ function readTokenCache() {
|
|
|
26331
26387
|
function cacheToken(tok) {
|
|
26332
26388
|
const c = readTokenCache();
|
|
26333
26389
|
c[cacheKey] = tok;
|
|
26334
|
-
|
|
26335
|
-
|
|
26390
|
+
fs4.mkdirSync(path2.dirname(TOKEN_CACHE), { recursive: true });
|
|
26391
|
+
fs4.writeFileSync(TOKEN_CACHE, JSON.stringify(c, null, 2));
|
|
26336
26392
|
}
|
|
26337
26393
|
var clientPromise = null;
|
|
26338
26394
|
var inbox = [];
|
|
@@ -26364,7 +26420,21 @@ function ensureClient() {
|
|
|
26364
26420
|
if (c.identity) cacheToken(c.token);
|
|
26365
26421
|
}
|
|
26366
26422
|
const self = c.identity?.username ?? USERNAME;
|
|
26367
|
-
|
|
26423
|
+
const groupNames = /* @__PURE__ */ new Map();
|
|
26424
|
+
const refreshGroups = () => c.groups().then((gs) => {
|
|
26425
|
+
groupNames.clear();
|
|
26426
|
+
for (const g of gs) groupNames.set(g.id, g.name);
|
|
26427
|
+
}).catch(() => {
|
|
26428
|
+
});
|
|
26429
|
+
void refreshGroups();
|
|
26430
|
+
setInterval(refreshGroups, 6e4).unref?.();
|
|
26431
|
+
if (macNeedsTerminalNotifier)
|
|
26432
|
+
log("tip: for reliable desktop notifications on macOS, run: brew install terminal-notifier");
|
|
26433
|
+
attachInbox(c, inbox, self, (m) => {
|
|
26434
|
+
const preview = m.kind === "file" ? `\u{1F4CE} ${m.fileName ?? "file"}` : m.content ?? "";
|
|
26435
|
+
const where = m.groupId ? ` \xB7 ${groupNames.get(m.groupId) ?? "group"}` : "";
|
|
26436
|
+
notifyIncoming("Jefri Chat", `${m.senderUsername}${where}: ${preview}`);
|
|
26437
|
+
});
|
|
26368
26438
|
log(`connected to ${SERVER} as ${self}`);
|
|
26369
26439
|
return c;
|
|
26370
26440
|
})().catch((e) => {
|
package/package.json
CHANGED