moltbook-mcp 0.1.7 → 0.1.8

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 CHANGED
@@ -205,6 +205,12 @@ Requires Node.js >= 22.
205
205
 
206
206
  ## Changelog
207
207
 
208
+ ### 0.1.8
209
+
210
+ - Harden challenge solver for split token fragments: pre-merge pass in `extractNumbers` joins orphan fragments like `["t", "wo"]` → `["two"]` before the main extraction loop
211
+ - Add operator-split solver path: splits challenges on literal `+`, `-`, `*`, `/` and extracts numbers per-side, isolating operands from cross-side noise
212
+ - Fix answer priority in `handleVerify`: manual (LLM) answer now takes precedence over auto-solver, preventing the solver from overriding a correct answer with a wrong one
213
+
208
214
  ### 0.1.7
209
215
 
210
216
  - Fix `moltbook_write_guard_status` and `moltbook_health` missing "Do NOT retry" guidance: both now call `checkWriteBlocked()` and include `write_blocked` object and `guidance` message in responses during active cooldowns
package/dist/index.js CHANGED
@@ -332,7 +332,19 @@ function fuzzyMatch(candidate, db) {
332
332
  return null;
333
333
  }
334
334
  function extractNumbers(text) {
335
- const tokens = text.split(" ").filter((t) => t.length > 0 && !FILLER.has(t));
335
+ let tokens = text.split(" ").filter((t) => t.length > 0 && !FILLER.has(t));
336
+ let j = 0;
337
+ while (j < tokens.length - 1) {
338
+ const t = tokens[j];
339
+ if (!fuzzyMatch(t, TENS) && !fuzzyMatch(t, ONES)) {
340
+ const merged = t + tokens[j + 1];
341
+ if (fuzzyMatch(merged, TENS) || fuzzyMatch(merged, ONES)) {
342
+ tokens.splice(j, 2, merged);
343
+ continue;
344
+ }
345
+ }
346
+ j++;
347
+ }
336
348
  const numbers = [];
337
349
  let i = 0;
338
350
  while (i < tokens.length) {
@@ -409,9 +421,28 @@ function solveDigitExpression(challenge) {
409
421
  return null;
410
422
  }
411
423
  }
424
+ function solveWithOperatorSplit(challenge) {
425
+ const opMap = { "+": "add", "-": "sub", "*": "mul", "/": "div" };
426
+ for (const [opChar, op] of Object.entries(opMap)) {
427
+ const sides = challenge.split(opChar);
428
+ if (sides.length !== 2) continue;
429
+ const left = sides[0].trim();
430
+ const right = sides[1].trim();
431
+ if (!left || !right) continue;
432
+ const leftNums = extractNumbers(normalizeChallenge(left));
433
+ const rightNums = extractNumbers(normalizeChallenge(right));
434
+ if (leftNums.length !== 1 || rightNums.length !== 1) continue;
435
+ const result = compute([leftNums[0], rightNums[0]], op);
436
+ if (result === null || !Number.isFinite(result)) continue;
437
+ return result.toFixed(2);
438
+ }
439
+ return null;
440
+ }
412
441
  function solveChallenge(challenge) {
413
442
  const digitResult = solveDigitExpression(challenge);
414
443
  if (digitResult !== null) return digitResult;
444
+ const opSplitResult = solveWithOperatorSplit(challenge);
445
+ if (opSplitResult !== null) return opSplitResult;
415
446
  const normalized = normalizeChallenge(challenge);
416
447
  const numbers = extractNumbers(normalized);
417
448
  if (numbers.length < 2) return null;
@@ -451,16 +482,14 @@ async function handleVerify(args) {
451
482
  const rawAnswer = args.answer ?? args.solution;
452
483
  const rawChallenge = typeof args.challenge === "string" ? args.challenge : void 0;
453
484
  let answer;
454
- if (rawChallenge && typeof rawChallenge === "string") {
455
- const solved = solveChallenge(rawChallenge);
456
- if (solved) answer = solved;
457
- }
458
- if (!answer && rawAnswer !== void 0 && rawAnswer !== null && String(rawAnswer).trim() !== "") {
485
+ if (rawAnswer !== void 0 && rawAnswer !== null && String(rawAnswer).trim() !== "") {
459
486
  answer = String(rawAnswer).trim();
460
487
  const asNum = Number(answer);
461
- if (Number.isFinite(asNum)) {
462
- answer = asNum.toFixed(2);
463
- }
488
+ if (Number.isFinite(asNum)) answer = asNum.toFixed(2);
489
+ }
490
+ if (!answer && rawChallenge && typeof rawChallenge === "string") {
491
+ const solved = solveChallenge(rawChallenge);
492
+ if (solved) answer = solved;
464
493
  }
465
494
  if (!answer) {
466
495
  return makeResult({ ok: false, tool: "moltbook_verify", error: { code: "missing_answer", message: "Provide answer or challenge text to auto-solve." } }, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moltbook-mcp",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Challenge-aware MCP server for Moltbook with write safety guards",
5
5
  "type": "module",
6
6
  "bin": {