@mulmobridge/line 1.0.3 → 1.1.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/README.md +19 -12
- package/dist/index.js +8 -7
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ ngrok http 3002
|
|
|
26
26
|
### 3. Configure the webhook
|
|
27
27
|
|
|
28
28
|
In the LINE Developers Console → Messaging API tab:
|
|
29
|
+
|
|
29
30
|
- **Webhook URL**: `https://xxxx.ngrok-free.app/webhook` — the trailing `/webhook` is **required** (without it you get 404)
|
|
30
31
|
- **Use webhook**: enabled
|
|
31
32
|
- **Auto-reply messages**: disabled (LINE Official Account settings → Auto-reply messages → OFF, otherwise you get double replies)
|
|
@@ -52,21 +53,27 @@ Scan the QR code in the LINE Developers Console → Messaging API tab. Send a me
|
|
|
52
53
|
|
|
53
54
|
## Environment Variables
|
|
54
55
|
|
|
55
|
-
| Variable
|
|
56
|
-
|
|
57
|
-
| `LINE_CHANNEL_SECRET`
|
|
58
|
-
| `LINE_CHANNEL_ACCESS_TOKEN` | Yes
|
|
59
|
-
| `LINE_BRIDGE_PORT`
|
|
60
|
-
| `MULMOCLAUDE_API_URL`
|
|
61
|
-
| `MULMOCLAUDE_AUTH_TOKEN`
|
|
62
|
-
| `LINE_BRIDGE_DEFAULT_ROLE`
|
|
63
|
-
| `BRIDGE_DEFAULT_ROLE`
|
|
56
|
+
| Variable | Required | Description |
|
|
57
|
+
| --------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `LINE_CHANNEL_SECRET` | Yes | Channel secret for signature verification |
|
|
59
|
+
| `LINE_CHANNEL_ACCESS_TOKEN` | Yes | Long-lived channel access token |
|
|
60
|
+
| `LINE_BRIDGE_PORT` | No | Webhook port (default: 3002; `0` asks the OS for a free port) |
|
|
61
|
+
| `MULMOCLAUDE_API_URL` | No | Default: auto (`.server-port`; waits if nothing is published) |
|
|
62
|
+
| `MULMOCLAUDE_AUTH_TOKEN` | No | Bearer token |
|
|
63
|
+
| `LINE_BRIDGE_DEFAULT_ROLE` | No | Role id to seed new bridge sessions with (e.g. `coder`, `general`). Applied ONLY when a line 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. |
|
|
64
|
+
| `BRIDGE_DEFAULT_ROLE` | No | Same as above but shared across every bridge. Transport-specific `LINE_BRIDGE_DEFAULT_ROLE` wins when both are set. |
|
|
65
|
+
|
|
66
|
+
An unusable value (a typo, a number outside 0-65535) stops the bridge with a message naming
|
|
67
|
+
the variable, rather than silently starting on the default. A port already in use is reported
|
|
68
|
+
the same way (#3084).
|
|
64
69
|
|
|
65
70
|
### Auth token persistence across server restarts
|
|
66
71
|
|
|
67
|
-
The MulmoClaude server regenerates a fresh bearer token on every startup and writes it to
|
|
72
|
+
The MulmoClaude server regenerates a fresh bearer token on every startup and writes it to `<workspace>/.session-token` (`$MULMOCLAUDE_WORKSPACE_PATH`, or `~/mulmoclaude` when unset), alongside the port it bound in `.server-port`.
|
|
73
|
+
|
|
74
|
+
**The bridge follows a restart on its own.** When the connection fails it re-reads both files, and if the server came back as a different generation — new token, new port, or both — it rebuilds its socket against it (#3078). You do not have to restart the bridge.
|
|
68
75
|
|
|
69
|
-
**
|
|
76
|
+
Pinning the token is still useful when the bridge runs **on a different machine** from the server, where it cannot read the workspace at all: set `MULMOCLAUDE_AUTH_TOKEN` to the same long random value on both sides. The server then uses it verbatim instead of regenerating.
|
|
70
77
|
|
|
71
78
|
```bash
|
|
72
79
|
# Server (one-time setup — same value across restarts)
|
|
@@ -114,7 +121,7 @@ Part of the [`@mulmobridge/*`](https://www.npmjs.com/~mulmobridge) package famil
|
|
|
114
121
|
- [`@mulmobridge/email`](https://www.npmjs.com/package/@mulmobridge/email) — IMAP poll + SMTP reply, threading preserved
|
|
115
122
|
- [`@mulmobridge/google-chat`](https://www.npmjs.com/package/@mulmobridge/google-chat) — Google Chat via MulmoBridge relay
|
|
116
123
|
- [`@mulmobridge/irc`](https://www.npmjs.com/package/@mulmobridge/irc) — IRC (Libera, Freenode, custom)
|
|
117
|
-
- [`@mulmobridge/line`](https://www.npmjs.com/package/@mulmobridge/line) — LINE Messaging API via MulmoBridge relay
|
|
124
|
+
- [`@mulmobridge/line`](https://www.npmjs.com/package/@mulmobridge/line) — LINE Messaging API via MulmoBridge relay ← **this package**
|
|
118
125
|
- [`@mulmobridge/line-works`](https://www.npmjs.com/package/@mulmobridge/line-works) — LINE Works (enterprise LINE)
|
|
119
126
|
- [`@mulmobridge/mastodon`](https://www.npmjs.com/package/@mulmobridge/mastodon) — Mastodon DMs + mentions
|
|
120
127
|
- [`@mulmobridge/matrix`](https://www.npmjs.com/package/@mulmobridge/matrix) — Matrix / Element
|
package/dist/index.js
CHANGED
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Optional:
|
|
12
12
|
// LINE_BRIDGE_PORT — Webhook listener port (default: 3002)
|
|
13
|
-
// MULMOCLAUDE_API_URL — default
|
|
13
|
+
// MULMOCLAUDE_API_URL — default: the port in <workspace>/.server-port.
|
|
14
|
+
// With none published the client waits (#3078)
|
|
14
15
|
// MULMOCLAUDE_AUTH_TOKEN — bearer token
|
|
15
16
|
import "dotenv/config";
|
|
16
|
-
import { createBridgeClient, chunkText, formatAckReply } from "@mulmobridge/client";
|
|
17
|
-
import { createWebhookApp, createWebhookRateLimit, verifyHmacSignature } from "@mulmobridge/webhook-runtime";
|
|
17
|
+
import { createBridgeClient, chunkText, formatAckReply, installProcessGuards } from "@mulmobridge/client";
|
|
18
|
+
import { createWebhookApp, createWebhookRateLimit, verifyHmacSignature, listenWebhook } from "@mulmobridge/webhook-runtime";
|
|
18
19
|
import { extractIncomingLineMessage, parseLineWebhookBody } from "./parse.js";
|
|
19
20
|
const TRANSPORT_ID = "line";
|
|
20
|
-
|
|
21
|
+
installProcessGuards({ name: TRANSPORT_ID });
|
|
21
22
|
function readRequiredEnv() {
|
|
22
23
|
const channelSecret = process.env.LINE_CHANNEL_SECRET;
|
|
23
24
|
const channelAccessToken = process.env.LINE_CHANNEL_ACCESS_TOKEN;
|
|
@@ -51,7 +52,7 @@ async function downloadLineImage(messageId) {
|
|
|
51
52
|
// serves the original sender format (PNG, GIF, …). Trust the
|
|
52
53
|
// Content-Type header so the photo-EXIF hook (#1222 PR-A) can
|
|
53
54
|
// tell HEIC apart from JPEG and surface the right sidecar.
|
|
54
|
-
const mimeType = res.headers.get("content-type")?.split(";")[0]
|
|
55
|
+
const mimeType = res.headers.get("content-type")?.split(";")[0]?.trim() || "image/jpeg";
|
|
55
56
|
const arrayBuffer = await res.arrayBuffer();
|
|
56
57
|
return { bytes: Buffer.from(arrayBuffer), mimeType };
|
|
57
58
|
}
|
|
@@ -143,8 +144,8 @@ app.post("/webhook", webhookRateLimit, async (req, res) => {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
});
|
|
146
|
-
app
|
|
147
|
+
listenWebhook(app, { envVar: "LINE_BRIDGE_PORT", fallback: 3002 }, (port) => {
|
|
147
148
|
console.log("MulmoClaude LINE bridge");
|
|
148
|
-
console.log(`Webhook listening on http://localhost:${
|
|
149
|
+
console.log(`Webhook listening on http://localhost:${port}/webhook`);
|
|
149
150
|
console.log("Set your LINE webhook URL to: <public-url>/webhook");
|
|
150
151
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulmobridge/line",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "LINE bridge for MulmoBridge — connect a LINE bot to MulmoClaude",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"author": "Receptron Team",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mulmobridge/client": "^1.0
|
|
25
|
+
"@mulmobridge/client": "^1.2.0",
|
|
26
26
|
"@mulmobridge/protocol": "^1.0.1",
|
|
27
|
-
"@mulmobridge/webhook-runtime": "^1.0
|
|
27
|
+
"@mulmobridge/webhook-runtime": "^1.2.0",
|
|
28
28
|
"dotenv": "^17.0.0",
|
|
29
29
|
"express": "^5.1.0",
|
|
30
|
-
"express-rate-limit": "^8.
|
|
30
|
+
"express-rate-limit": "^8.7.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/express": "^5.0.0",
|
|
34
|
-
"@types/node": "^26.1
|
|
35
|
-
"tsx": "^4.23.
|
|
34
|
+
"@types/node": "^26.4.1",
|
|
35
|
+
"tsx": "^4.23.13",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/receptron/mulmoclaude/tree/main/packages/bridges/line#readme",
|