@mulmobridge/discord 0.1.1 → 0.1.2
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/README.md +18 -0
- package/dist/index.js +10 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,6 +50,24 @@ npx @mulmobridge/discord
|
|
|
50
50
|
| `DISCORD_BRIDGE_DEFAULT_ROLE` | No | Role id to seed new bridge sessions with (e.g. `coder`, `general`). Applied ONLY when a discord session first appears — once the user switches role via `/role <id>` the session's own role wins. Unknown role ids silently fall back to the server's default with a warn log. |
|
|
51
51
|
| `BRIDGE_DEFAULT_ROLE` | No | Same as above but shared across every bridge. Transport-specific `DISCORD_BRIDGE_DEFAULT_ROLE` wins when both are set. |
|
|
52
52
|
|
|
53
|
+
### Auth token persistence across server restarts
|
|
54
|
+
|
|
55
|
+
The MulmoClaude server regenerates a fresh bearer token on every startup and writes it to `~/mulmoclaude/.session-token`. The bridge reads that file once at launch and keeps the token in memory — so if the server restarts while the bridge is running, the bridge keeps using the **old** token and every API call returns **401**, silently.
|
|
56
|
+
|
|
57
|
+
**Fix**: set `MULMOCLAUDE_AUTH_TOKEN` to the same long random value on **both** the server and the bridge. The server uses it verbatim instead of regenerating, so the token survives restarts and the bridge stays authenticated.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Server (one-time setup — same value across restarts)
|
|
61
|
+
MULMOCLAUDE_AUTH_TOKEN=long-random-string yarn dev
|
|
62
|
+
|
|
63
|
+
# Bridge (separate process / machine — same value)
|
|
64
|
+
MULMOCLAUDE_AUTH_TOKEN=long-random-string \
|
|
65
|
+
<bridge-specific-envs> \
|
|
66
|
+
npx <this-package>@latest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Recommended: at least 32 characters of random data (the server logs a warning at startup for shorter values).
|
|
70
|
+
|
|
53
71
|
## Ecosystem
|
|
54
72
|
|
|
55
73
|
Part of the [`@mulmobridge/*`](https://www.npmjs.com/~mulmobridge) package family.
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,10 @@ const discord = new Client({
|
|
|
30
30
|
partials: [Partials.Channel],
|
|
31
31
|
});
|
|
32
32
|
const mulmo = createBridgeClient({ transportId: TRANSPORT_ID });
|
|
33
|
-
mulmo.onPush(
|
|
33
|
+
mulmo.onPush((pushEvent) => {
|
|
34
|
+
onPushEvent(pushEvent).catch((err) => console.error(`[discord] push handler error: ${err}`));
|
|
35
|
+
});
|
|
36
|
+
async function onPushEvent(pushEvent) {
|
|
34
37
|
try {
|
|
35
38
|
const channel = discord.channels.cache.get(pushEvent.chatId) ?? (await discord.channels.fetch(pushEvent.chatId).catch(() => null));
|
|
36
39
|
if (channel?.isTextBased() && "send" in channel) {
|
|
@@ -44,11 +47,14 @@ mulmo.onPush(async (pushEvent) => {
|
|
|
44
47
|
catch (err) {
|
|
45
48
|
console.error(`[discord] push send failed: ${err}`);
|
|
46
49
|
}
|
|
50
|
+
}
|
|
51
|
+
discord.on("messageCreate", (msg) => {
|
|
52
|
+
onMessageCreate(msg).catch((err) => console.error(`[discord] messageCreate handler error: ${err}`));
|
|
47
53
|
});
|
|
48
|
-
|
|
54
|
+
async function onMessageCreate(msg) {
|
|
49
55
|
if (msg.author.bot)
|
|
50
56
|
return;
|
|
51
|
-
const channelId = msg
|
|
57
|
+
const { channelId } = msg;
|
|
52
58
|
const text = msg.content.trim();
|
|
53
59
|
if (!text)
|
|
54
60
|
return;
|
|
@@ -68,7 +74,7 @@ discord.on("messageCreate", async (msg) => {
|
|
|
68
74
|
catch (err) {
|
|
69
75
|
console.error(`[discord] message handling failed: ${err}`);
|
|
70
76
|
}
|
|
71
|
-
}
|
|
77
|
+
}
|
|
72
78
|
async function sendChunked(msg, text) {
|
|
73
79
|
if (text.length === 0) {
|
|
74
80
|
await msg.reply("(empty reply)");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulmobridge/discord",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Discord bridge for MulmoBridge — connect a Discord bot to MulmoClaude",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@mulmobridge/client": "^0.1.4",
|
|
25
25
|
"@mulmobridge/protocol": "^0.1.4",
|
|
26
|
-
"discord.js": "^14.
|
|
26
|
+
"discord.js": "^14.27.0",
|
|
27
27
|
"dotenv": "^17.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^
|
|
30
|
+
"@types/node": "^26.1.1",
|
|
31
31
|
"typescript": "^6.0.3"
|
|
32
32
|
}
|
|
33
33
|
}
|