@mulmoclaude/core 4.8.0 → 4.9.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.
@@ -64,7 +64,7 @@ would run ahead of it and see no `__MC_VIEW`; there is no reason to write one.)
64
64
  window.__MC_VIEW = {
65
65
  slug: "annual-plan", // this collection
66
66
  token: "<scoped capability token>", // Authorization bearer
67
- dataUrl: "http://localhost:3001/api/collections/annual-plan/view-data",
67
+ dataUrl: "http://127.0.0.1:<port>/api/collections/annual-plan/view-data", // absolute, filled in by the host
68
68
  onChange: (cb) => unsubscribe, // live refresh — see "Staying live" below
69
69
  searchQuery: "", // live text in the app's own search box — see "One search box"
70
70
  onSearchQueryChange: (cb) => unsubscribe, // fires when the user types there
@@ -1297,6 +1297,100 @@ nor remove documents that other members also read, and removing its records
1297
1297
  first does not unlock it. Retiring the whole app is a Firestore project
1298
1298
  administrator's recursive delete, not something this app does.
1299
1299
 
1300
+ ## A messaging bridge's bot does not reply, and nothing errors
1301
+
1302
+ ### Symptoms
1303
+
1304
+ The user talks to the bot on Telegram / Slack / LINE / Discord / …, and nothing
1305
+ comes back. No error in the server log, none from the bridge. Sending again does
1306
+ nothing either.
1307
+
1308
+ ### First, do NOT say "restart the bridge"
1309
+
1310
+ That advice is out of date. Since #3078 the shared client re-reads the token and
1311
+ the port after **every failed connection** and rebuilds its socket when the
1312
+ server has come back as a different generation. A server restart — new token,
1313
+ new port, or both — is handled without touching the bridge.
1314
+
1315
+ ### The bridge tells you where it went — start there
1316
+
1317
+ Every bridge prints its target as it starts — the shared client emits it, so
1318
+ this holds for all of them, not only the ones with a banner:
1319
+
1320
+ ```text
1321
+ Connecting to http://127.0.0.1:3099
1322
+ ```
1323
+
1324
+ It prints again each time the bridge follows the server to a new address, so a
1325
+ bridge that has outlived a restart has several. **Compare the last one** — the
1326
+ earlier lines are where it used to be. Against what the server published:
1327
+
1328
+ ```bash
1329
+ cat "${MULMOCLAUDE_WORKSPACE_PATH:-$HOME/mulmoclaude}/.server-port"
1330
+ ```
1331
+
1332
+ - **They agree** → the address is right; the problem is further in (see below).
1333
+ - **They disagree**, and the bridge says `http://localhost:3001` → that bridge
1334
+ is an npm build from before the port-following fix. Reinstall it
1335
+ (`npm i -g @mulmobridge/<platform>@latest`, or `npx @mulmobridge/<platform>@latest`).
1336
+ Check the banner rather than a version number: the banner is the behaviour,
1337
+ and a version is one more thing to keep current.
1338
+
1339
+ ### `The server has not published a port yet` is waiting, not failing
1340
+
1341
+ ```text
1342
+ The server has not published a port yet — waiting for it rather than guessing.
1343
+ ```
1344
+
1345
+ The server writes `.session-token` before it binds its port, and sandbox setup
1346
+ sits in between — a cold start that builds the Docker image can hold there for
1347
+ minutes. The bridge deliberately refuses to guess `localhost:3001` while holding
1348
+ a freshly minted token, and joins on its own once the port appears. Wait, or
1349
+ check that the server is actually starting.
1350
+
1351
+ ### A bridge that cannot see the workspace needs both variables
1352
+
1353
+ Running on another machine, or in a container without the workspace mounted,
1354
+ means no `.server-port` and no `.session-token`. Such a bridge needs BOTH:
1355
+
1356
+ ```bash
1357
+ MULMOCLAUDE_API_URL=http://127.0.0.1:<port> \
1358
+ MULMOCLAUDE_AUTH_TOKEN=<the same value the server was given> \
1359
+ npx @mulmobridge/<platform>
1360
+ ```
1361
+
1362
+ Two things make this narrower than it looks:
1363
+
1364
+ - **The server binds the IPv4 loopback only** (`app.listen(port, "127.0.0.1")`),
1365
+ so a bridge on another machine cannot reach it by naming the host. It needs a
1366
+ tunnel — an SSH port-forward is the usual one — and then
1367
+ `MULMOCLAUDE_API_URL` points at the LOCAL end of that tunnel, which is why the
1368
+ recipe above still says `127.0.0.1`. Do not "fix" this by making the server
1369
+ listen on `0.0.0.0`: there is no TLS on that port, and the bearer token would
1370
+ cross the network in the clear.
1371
+ - **`MULMOCLAUDE_AUTH_TOKEN` must be set on the SERVER too**, or it regenerates a
1372
+ new token on every start and the pinned one stops matching.
1373
+
1374
+ In a container on the same host, `MULMOCLAUDE_HOST=host.docker.internal` is how
1375
+ the sandbox's own hooks reach the parent server; a bridge there needs the same
1376
+ treatment, and the workspace mounted if you want it to follow the port.
1377
+
1378
+ ### Only then, the platform side
1379
+
1380
+ - The chat ID is not on the bridge's allowlist — the bot answers
1381
+ `"Access denied"` to a stranger, but an allowlist typo simply drops the
1382
+ message.
1383
+ - The platform token (bot token, app token) was revoked or regenerated.
1384
+ - The bridge process is not running at all. Check before assuming anything above.
1385
+
1386
+ ### What to collect if none of it explains the silence
1387
+
1388
+ The bridge's first three lines (they name the transport and the resolved URL),
1389
+ the server's `[server] listening port=…` line, and whether
1390
+ `<workspace>/.server-port` exists. Those three answer "which server, on which
1391
+ port, and did the bridge agree" — which is what every one of these turns out to
1392
+ be.
1393
+
1300
1394
  ## `renderShapeScript` says Chromium is not installed
1301
1395
 
1302
1396
  `renderShapeScript` rasterises a ShapeScript model by driving Puppeteer's
@@ -67,7 +67,7 @@ See [Wiki](config/helps/wiki.md) for details on how it works.
67
67
  - [Spreadsheet](config/helps/spreadsheet.md) — cell format, formulas, date handling, and format codes for the presentSpreadsheet plugin
68
68
  - [presentHtml](config/helps/presenthtml.md) — self-contained HTML rules and the three-`../` relative-path convention used by the presentHtml plugin to keep generated files portable under `file://`
69
69
  - [Sandbox](config/helps/sandbox.md) — how the Docker sandbox isolates the agent, what it can access, and how to disable it
70
- - [Error recovery](config/helps/error-recovery.md) — the lookup the agent reads on tool failures (gh/git/SSH in the sandbox, Marp PDF, registry import, build/workspace, plugin runtime), plus the four-step triage for when a user reports something broken
70
+ - [Error recovery](config/helps/error-recovery.md) — the lookup the agent reads on tool failures (sandbox gh/git/SSH, Marp PDF, registry import, build/workspace, plugin runtime, a bridge gone quiet), plus the triage for a “broken” report
71
71
  - [Bug-report FAQ](config/helps/bug-report-faq.md) — symptoms that turn out to be configuration or by design (voice input, push, chat titles, journal, connector tools, preset skills, custom views); says where to read the live value, never what it is
72
72
  - [Telegram Bridge](config/helps/telegram.md) — how to talk to MulmoClaude from the Telegram app: creating a bot, starting the bridge, allowlisting chat IDs, commands, and troubleshooting
73
73
  - [Remote host](config/helps/remote-host.md) — drive MulmoClaude from a phone at mulmoserver.web.app: Google sign-in connect, host online vs. offline (queued chats, 7-day expiry), photo attachments, and the security model
@@ -7,7 +7,7 @@ This is useful when you want to reach your MulmoClaude away from your computer
7
7
  ## How It Works
8
8
 
9
9
  - You create a **bot** with Telegram's BotFather; it gives you a token.
10
- - You run a **bridge process** (`yarn telegram`) on the same machine as the MulmoClaude server. The bridge uses your bot token to receive messages from Telegram, forwards them to MulmoClaude over `localhost:3001`, and sends the replies back to the Telegram user.
10
+ - You run a **bridge process** (`yarn telegram`) on the same machine as the MulmoClaude server. The bridge uses your bot token to receive messages from Telegram, forwards them to MulmoClaude over the loopback port the server actually bound, and sends the replies back to the Telegram user. It finds that port itself, and follows it when the server restarts.
11
11
  - A short **allowlist** of Telegram chat IDs controls who can talk to the bot. Everyone else gets `"Access denied"`.
12
12
 
13
13
  Your computer has to be on and connected to the internet for the bot to respond. Close the laptop → the bot goes silent.
@@ -41,7 +41,7 @@ In terminal A, start MulmoClaude:
41
41
  yarn dev
42
42
  ```
43
43
 
44
- Wait until you see `[server] listening port=3001`.
44
+ Wait until you see `[server] listening port=…`. The number is whatever the server bound: it honours `PORT`, and an implicit default that is already busy walks forward. You do not need to note it — the bridge reads it from the workspace.
45
45
 
46
46
  In terminal B, start the bridge. Leave the allowlist **empty on purpose** for the first run — you will need to discover your own chat ID before you can add it.
47
47
 
@@ -56,9 +56,15 @@ Expected output:
56
56
  ```
57
57
  MulmoClaude Telegram bridge
58
58
  Allowlist: (empty — all chats will be denied)
59
+ Connecting to http://127.0.0.1:<port>
59
60
  Connected (<socket id>).
60
61
  ```
61
62
 
63
+ That third line is the bridge telling you which server it found. If it ever says
64
+ `http://localhost:3001` while `.server-port` says something else, that bridge is
65
+ an old build — see "a messaging bridge's bot does not reply" in the error
66
+ recovery help.
67
+
62
68
  ## Step 3 — Find Your Chat ID and Allowlist It
63
69
 
64
70
  1. In Telegram, open your new bot (search the username you picked) and send it any message — `hi` works.
@@ -114,7 +120,7 @@ Any other text is treated as a message to the assistant.
114
120
 
115
121
  ## Troubleshooting
116
122
 
117
- **`Connect error: bearer token rejected`** — MulmoClaude was restarted, so its bearer token changed. Restart `yarn telegram` to pick up the new one. To avoid this, pin `MULMOCLAUDE_AUTH_TOKEN` to the same value on both sides (see `docs/developer.md` §Auth).
123
+ **`Connect error: bearer token rejected`** — MulmoClaude restarted and its bearer token changed. **Do not restart the bridge**: it re-reads the token and the port after a failed connection and reconnects on its own, usually within a second or two. If it is still saying this after that, the server has not finished starting (it writes the token before it binds its port, and a cold start builds the sandbox image in between) — wait for `[server] listening port=…`. Pinning `MULMOCLAUDE_AUTH_TOKEN` on both sides is for a bridge that cannot read the workspace at all, not for this.
118
124
 
119
125
  **`TELEGRAM_ALLOWED_CHAT_IDS: "foo" is not an integer chat id`** — typo in the allowlist. Chat IDs are plain integers only — no spaces, quotes, or `#` prefix. Negative integers (for group chats) are allowed.
120
126
 
@@ -129,7 +135,7 @@ Any other text is treated as a message to the assistant.
129
135
  - The bot token is a password. If it leaks, regenerate it via BotFather's `/revoke`.
130
136
  - The allowlist is the only thing standing between "my friends" and "every Telegram user on Earth". Keep it current — remove chat IDs when you no longer want that person to have access, and restart the bridge.
131
137
  - The bridge logs chat IDs, usernames, and message lengths, but **not** message contents or the bot token. If you need a full audit trail, record it separately.
132
- - The MulmoClaude bearer token never leaves your machine. The bridge only talks to `localhost:3001`; your friends talk to Telegram's servers, which then talk to your bridge.
138
+ - The MulmoClaude bearer token never leaves your machine. The bridge only ever talks to the IPv4 loopback (`127.0.0.1`), whatever port the server bound; your friends talk to Telegram's servers, which then talk to your bridge.
133
139
 
134
140
  ## Full Operator Guide
135
141
 
@@ -138,7 +138,7 @@ IconGlyph.props = {
138
138
  };
139
139
  //#endregion
140
140
  //#region ../../node_modules/dompurify/dist/purify.es.mjs
141
- /*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */
141
+ /*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */
142
142
  function _arrayLikeToArray(r, a) {
143
143
  (null == a || a > r.length) && (a = r.length);
144
144
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -1133,7 +1133,7 @@ var _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback)
1133
1133
  function createDOMPurify() {
1134
1134
  let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
1135
1135
  const DOMPurify = (root) => createDOMPurify(root);
1136
- DOMPurify.version = "3.4.14";
1136
+ DOMPurify.version = "3.4.15";
1137
1137
  DOMPurify.removed = [];
1138
1138
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1139
1139
  DOMPurify.isSupported = false;
@@ -1150,6 +1150,7 @@ function createDOMPurify() {
1150
1150
  const ElementPrototype = Element.prototype;
1151
1151
  const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
1152
1152
  const remove = lookupGetter(ElementPrototype, "remove");
1153
+ const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
1153
1154
  const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
1154
1155
  const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
1155
1156
  const getParentNode = lookupGetter(ElementPrototype, "parentNode");
@@ -1604,7 +1605,7 @@ function createDOMPurify() {
1604
1605
  */
1605
1606
  const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
1606
1607
  try {
1607
- element.removeAttributeNode(attribute);
1608
+ removeAttributeNode(element, attribute);
1608
1609
  } catch (_) {
1609
1610
  try {
1610
1611
  element.removeAttribute(name);
@@ -1677,7 +1678,7 @@ function createDOMPurify() {
1677
1678
  from: element
1678
1679
  });
1679
1680
  try {
1680
- if (attr) element.removeAttributeNode(attr);
1681
+ if (attr) removeAttributeNode(element, attr);
1681
1682
  else element.removeAttribute(name);
1682
1683
  } catch (_) {
1683
1684
  try {
@@ -1923,7 +1924,7 @@ function createDOMPurify() {
1923
1924
  const realTagName = getNodeName ? getNodeName(element) : null;
1924
1925
  if (typeof realTagName !== "string") return false;
1925
1926
  if (transformCaseFunc(realTagName) !== "form") return false;
1926
- return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
1927
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
1927
1928
  };
1928
1929
  /**
1929
1930
  * Checks whether the given value is a DocumentFragment from any realm.
@@ -2208,24 +2209,38 @@ function createDOMPurify() {
2208
2209
  /**
2209
2210
  * Write a modified attribute value back onto the element. On
2210
2211
  * success, re-probe for clobbering introduced by the new value and
2211
- * remove the element when found; otherwise pop the removal entry
2212
- * recorded by the earlier _removeAttribute (long-standing pairing
2213
- * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
2212
+ * remove the element when found; otherwise, when this writeback is the
2213
+ * recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the
2214
+ * removal entry that path recorded so it does not show as removed. On
2214
2215
  * failure, remove the attribute instead.
2215
2216
  *
2217
+ * Returns true only on a clean write (the value was set and the new value
2218
+ * introduced no clobbering). The caller uses that, together with its own
2219
+ * knowledge of whether this attribute pushed a DOMPurify.removed record, to
2220
+ * decide whether to pop that record. The pop must happen ONLY for the
2221
+ * named-prop remove-and-recreate; popping on any other value change (trim,
2222
+ * template scrubbing, Trusted Types) would consume an unrelated _forceRemove
2223
+ * subtree-cleanup record and let that detached subtree keep a live event
2224
+ * handler through the IN_PLACE neutralization pass (SO-001).
2225
+ *
2216
2226
  * @param currentNode the element carrying the attribute
2217
2227
  * @param name the attribute name as present on the element
2218
2228
  * @param namespaceURI the attribute's namespace, if any
2219
2229
  * @param value the new attribute value
2230
+ * @return true if the value was written without introducing clobbering
2220
2231
  */
2221
2232
  const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2222
2233
  try {
2223
2234
  if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
2224
2235
  else currentNode.setAttribute(name, value);
2225
- if (_isClobbered(currentNode)) _forceRemove(currentNode);
2226
- else arrayPop(DOMPurify.removed);
2236
+ if (_isClobbered(currentNode)) {
2237
+ _forceRemove(currentNode);
2238
+ return false;
2239
+ }
2240
+ return true;
2227
2241
  } catch (_) {
2228
2242
  _removeAttribute(name, currentNode);
2243
+ return false;
2229
2244
  }
2230
2245
  };
2231
2246
  /**
@@ -2258,6 +2273,7 @@ function createDOMPurify() {
2258
2273
  const lcName = transformCaseFunc(name);
2259
2274
  const initValue = attrValue;
2260
2275
  let value = name === "value" ? initValue : stringTrim(initValue);
2276
+ let recreatedNamedProp = false;
2261
2277
  hookEvent.attrName = lcName;
2262
2278
  hookEvent.attrValue = value;
2263
2279
  hookEvent.keepAttr = true;
@@ -2267,6 +2283,7 @@ function createDOMPurify() {
2267
2283
  if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2268
2284
  _removeAttribute(name, currentNode, attr);
2269
2285
  value = SANITIZE_NAMED_PROPS_PREFIX + value;
2286
+ recreatedNamedProp = true;
2270
2287
  }
2271
2288
  if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2272
2289
  _removeAttribute(name, currentNode, attr);
@@ -2291,7 +2308,9 @@ function createDOMPurify() {
2291
2308
  continue;
2292
2309
  }
2293
2310
  value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2294
- if (value !== initValue) _setAttributeValue(currentNode, name, namespaceURI, value);
2311
+ if (value !== initValue) {
2312
+ if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
2313
+ }
2295
2314
  }
2296
2315
  _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2297
2316
  };
@@ -2425,7 +2444,7 @@ function createDOMPurify() {
2425
2444
  if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
2426
2445
  else if (importedNode.nodeName === "HTML") body = importedNode;
2427
2446
  else body.appendChild(importedNode);
2428
- _sanitizeAttachedShadowRoots(importedNode);
2447
+ _sanitizeAttachedShadowRoots(body);
2429
2448
  } else {
2430
2449
  if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2431
2450
  body = _initDocument(dirty);