@mulmobridge/line 1.0.4 → 1.1.1

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.
Files changed (3) hide show
  1. package/README.md +19 -12
  2. package/dist/index.js +7 -6
  3. 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 | Required | Description |
56
- |---|---|---|
57
- | `LINE_CHANNEL_SECRET` | Yes | Channel secret for signature verification |
58
- | `LINE_CHANNEL_ACCESS_TOKEN` | Yes | Long-lived channel access token |
59
- | `LINE_BRIDGE_PORT` | No | Webhook port (default: 3002) |
60
- | `MULMOCLAUDE_API_URL` | No | Default `http://localhost:3001` |
61
- | `MULMOCLAUDE_AUTH_TOKEN` | No | Bearer token |
62
- | `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. |
63
- | `BRIDGE_DEFAULT_ROLE` | No | Same as above but shared across every bridge. Transport-specific `LINE_BRIDGE_DEFAULT_ROLE` wins when both are set. |
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 `~/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.
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
- **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.
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 ← **this package**
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 http://localhost:3001
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
- const PORT = Number(process.env.LINE_BRIDGE_PORT) || 3002;
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;
@@ -143,8 +144,8 @@ app.post("/webhook", webhookRateLimit, async (req, res) => {
143
144
  }
144
145
  }
145
146
  });
146
- app.listen(PORT, () => {
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:${PORT}/webhook`);
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.4",
3
+ "version": "1.1.1",
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.2",
25
+ "@mulmobridge/client": "^1.3.0",
26
26
  "@mulmobridge/protocol": "^1.0.1",
27
- "@mulmobridge/webhook-runtime": "^1.0.3",
27
+ "@mulmobridge/webhook-runtime": "^1.2.0",
28
28
  "dotenv": "^17.0.0",
29
29
  "express": "^5.1.0",
30
- "express-rate-limit": "^8.6.1"
30
+ "express-rate-limit": "^8.7.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/express": "^5.0.0",
34
- "@types/node": "^26.1.2",
35
- "tsx": "^4.23.4",
34
+ "@types/node": "^26.5.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",